1 /****************************************************************************
2 * This module is all new
3 * by Rob Nation
4 ****************************************************************************/
5 /***********************************************************************
6 *
7 * afterstep pager handling code
8 *
9 ***********************************************************************/
10
11 #include "../configure.h"
12
13 #include <stdio.h>
14 #include <signal.h>
15 #include <string.h>
16 #include "afterstep.h"
17 #include "menus.h"
18 #include "misc.h"
19 #include "parse.h"
20 #include "screen.h"
21 #include "module.h"
22
23 extern XEvent Event;
24
25 XGCValues Globalgcv;
26 unsigned long Globalgcm;
27
28 void DrawPartitionLines(void);
29 ASWindow *FindCounterpart(Window target);
30 Bool pagerOn = True;
31 Bool EnablePagerRedraw = True;
32 Bool DoHandlePageing = True;
33
34 /****************************************************************************
35 * Cause the pager window to be re-drawn
36 *
37 * Trying to get clever - re-draw the pager by causing an expose event,
38 * the really redraw only when an expose arrives. Advantage is that the
39 * number of re-draws will be minimized
40 ***************************************************************************/
RedrawPager()41 void RedrawPager()
42 {
43 #ifndef NO_PAGER
44 if((Scr.ASPager)&&(EnablePagerRedraw))
45 XClearArea(dpy,Scr.Pager_w, 0, 0, Scr.ASPager->frame_width,
46 Scr.ASPager->frame_height,True);
47 #endif
48 }
49
ReallyRedrawPager()50 void ReallyRedrawPager()
51 {
52 #ifndef NO_PAGER
53 ASWindow *t;
54 Pixel TextColor,BackColor;
55
56 if(!Scr.ASPager)
57 return;
58
59 flush_expose (Scr.Pager_w);
60 flush_expose (Scr.CPagerWin);
61
62 if(Scr.PagerFont.height > 0)
63 {
64 if(Scr.Hilite != NULL)
65 {
66 if(!(Scr.Hilite->flags & STICKY)&& (!(Scr.Hilite->flags&ICONIFIED)||(!(Scr.Hilite->flags & SUPPRESSICON)))&&
67 (!(Scr.Hilite->flags&ICONIFIED)||(!(Scr.flags & StickyIcons)))&&
68 (Scr.Hilite->icon_name != NULL))
69 {
70 TextColor = Scr.HiColors.fore;
71 BackColor = Scr.HiColors.back;
72 NewFontAndColor(Scr.PagerFont.font->fid,TextColor,BackColor);
73 flush_expose(Scr.Hilite->pager_view);
74 XDrawImageString (dpy, Scr.Hilite->pager_view, Scr.FontGC,
75 2,Scr.PagerFont.y+2,
76 Scr.Hilite->icon_name, strlen(Scr.Hilite->icon_name));
77 }
78 }
79
80 TextColor = Scr.StdColors.fore;
81 BackColor = Scr.StdColors.back;
82 NewFontAndColor(Scr.PagerFont.font->fid,TextColor,BackColor);
83
84
85 for (t = Scr.ASRoot.next; t != NULL; t = t->next)
86 {
87 if(t != Scr.Hilite)
88 {
89 if(!(t->flags & STICKY)&&
90 (!(t->flags & ICONIFIED)||(!(t->flags & SUPPRESSICON)))&&
91 (!(t->flags & ICONIFIED)||(!(Scr.flags & StickyIcons)))&&
92 (t->icon_name != NULL))
93 {
94 flush_expose(t->pager_view);
95 XDrawImageString (dpy, t->pager_view, Scr.FontGC,
96 2,Scr.PagerFont.y+2,
97 t->icon_name, strlen(t->icon_name));
98 }
99 }
100 }
101 }
102 DrawPartitionLines();
103 #endif
104 }
105
106 #ifndef NO_PAGER
DrawPartitionLines(void)107 void DrawPartitionLines(void)
108 {
109 int y, y1, y2, x, x1, x2;
110 int MaxW,MaxH,width,height;
111
112 MaxW = Scr.VxMax + Scr.MyDisplayWidth;
113 MaxH = Scr.VyMax + Scr.MyDisplayHeight;
114
115 width = Scr.ASPager->frame_width - 2*Scr.ASPager->boundary_width;
116 height = Scr.ASPager->frame_height - Scr.ASPager->title_height
117 - 2*Scr.ASPager->boundary_width;
118
119 x = Scr.MyDisplayWidth;
120 y1 = 0;
121 y2 = height;
122 while(x < MaxW)
123 {
124 x1 = x*width/MaxW;
125 XDrawLine(dpy,Scr.Pager_w,Scr.NormalGC,x1,y1,x1,y2);
126 x += Scr.MyDisplayWidth;
127 }
128
129 y = Scr.MyDisplayHeight;
130 x1 = 0;
131 x2 = width;
132 while(y < MaxH)
133 {
134 y1 = y*height/MaxH;
135 XDrawLine(dpy,Scr.Pager_w,Scr.NormalGC,x1,y1,x2,y1);
136 y += Scr.MyDisplayHeight;
137 }
138 }
139 #endif
140
SwitchPages(Bool align,Bool ChangeFocus)141 void SwitchPages(Bool align, Bool ChangeFocus)
142 {
143 #ifndef NO_PAGER
144 int x,y;
145 unsigned int width,height;
146 ASWindow *tmp_win;
147 Window dumwin;
148
149 if(!Scr.ASPager)
150 return;
151
152 XTranslateCoordinates (dpy, Event.xbutton.window, Scr.Pager_w,
153 Event.xbutton.x, Event.xbutton.y, &x, &y, &dumwin);
154
155 width = Scr.ASPager->frame_width - 2*Scr.ASPager->boundary_width;
156 height = Scr.ASPager->frame_height - Scr.ASPager->title_height
157 - 2*Scr.ASPager->boundary_width;
158
159 if(x<0)x=0;
160 if(y<0)y=0;
161 x = x * (Scr.VxMax+Scr.MyDisplayWidth)/width;
162 y = y * (Scr.VyMax+Scr.MyDisplayHeight)/height;
163 if(align)
164 {
165 x = (x/Scr.MyDisplayWidth)*Scr.MyDisplayWidth;
166 y = (y/Scr.MyDisplayHeight)*Scr.MyDisplayHeight;
167 }
168 if(x<0)x=0;
169 if(y<0)y=0;
170 #ifndef NON_VIRTUAL
171 MoveViewport(x,y,True);
172 #endif
173 if((ChangeFocus)&&(Scr.flags & ClickToFocus))
174 {
175 tmp_win = FindCounterpart(Event.xbutton.subwindow);
176 if(tmp_win)
177 {
178 RaiseWindow(tmp_win);
179 SetFocus(tmp_win->w,tmp_win, False);
180 }
181 }
182 UpdateVisibility();
183 #endif
184 }
185
186
RaiseWindow(ASWindow * t)187 void RaiseWindow(ASWindow *t)
188 {
189 ASWindow *t2, *tn, *top, *ttop;
190 int count, i;
191 Window *wins;
192 SetTimer(0);
193
194 /* raise the target, at least */
195 count = 1;
196 Broadcast(M_RAISE_WINDOW,3,t->w,t->frame,(unsigned long)t,0,0,0,0);
197
198 if (t->next) t->next->prev = t->prev;
199 t->prev->next = t->next;
200
201 top = &Scr.ASRoot; ttop = NULL;
202 for (t2 = Scr.ASRoot.next; t2 != NULL; t2 = tn)
203 {
204 tn = t2->next;
205 if(t2->flags & ONTOP)
206 {
207 count++;
208 if (top->next != t2)
209 {
210 t2->prev->next = t2->next;
211 if (t2->next) t2->next->prev = t2->prev;
212 t2->next = top->next;
213 t2->prev = top;
214 top->next->prev = t2;
215 top->next = t2;
216 }
217 top = t2;
218 }
219 #ifndef DONT_RAISE_TRANSIENTS
220 else if((t2->flags & TRANSIENT) &&(t2->transientfor == t->w))
221 {
222 #ifndef NO_PAGER
223 if((Scr.Pager_w)&& !(t2->flags & STICKY))
224 XRaiseWindow(dpy,t2->pager_view);
225 #endif
226 count++;
227 Broadcast(M_RAISE_WINDOW,3,t2->w,t2->frame,(unsigned long) t2,
228 0,0,0,0);
229 if ((t2->flags & ICONIFIED)&&(!(t2->flags & SUPPRESSICON)))
230 {
231 count++;
232 }
233 if (ttop == NULL) ttop = top;
234 if (ttop->next != t2)
235 {
236 t2->prev->next = t2->next;
237 if (t2->next) t2->next->prev = t2->prev;
238 t2->next = ttop->next;
239 t2->prev = ttop;
240 ttop->next->prev = t2;
241 ttop->next = t2;
242 }
243 ttop = t2;
244 }
245 #endif
246 }
247
248 if ((t->flags & ICONIFIED)&& ! (t->flags & SUPPRESSICON))
249 count++;
250
251 if (ttop == NULL) ttop = top; /* where to insert a non-ontop window */
252
253 #ifndef NO_PAGER
254 if((Scr.Pager_w)&& !(t->flags & STICKY))
255 {
256 XRaiseWindow(dpy,t->pager_view);
257 }
258 #endif
259
260 wins = (Window *)safemalloc(count*sizeof(Window));
261 i=0;
262
263 if (t->flags & ONTOP)
264 wins[i++] = t->frame;
265
266 /* ONTOP windows on top */
267 for (t2 = Scr.ASRoot.next; t2 != top->next; t2 = t2->next)
268 {
269 Broadcast(M_RAISE_WINDOW,3,t2->w,t2->frame,(unsigned long) t2,
270 0,0,0,0);
271 wins[i++] = t2->frame;
272 }
273
274 /* now raise transients */
275 #ifndef DONT_RAISE_TRANSIENTS
276 for (; t2 != ttop->next; t2 = t2->next)
277 {
278 wins[i++] = t2->frame;
279 if ((t2->flags & ICONIFIED)&& ! (t2->flags & SUPPRESSICON))
280 {
281 wins[i++] = t2->icon_pixmap_w;
282 }
283 }
284 #endif
285
286 if ((t->flags & ICONIFIED) && ! (t->flags & SUPPRESSICON))
287 {
288 wins[i++] = t->icon_pixmap_w;
289 }
290
291 if (t->flags & ONTOP)
292 {
293 t->next = Scr.ASRoot.next;
294 t->prev = &Scr.ASRoot;
295 if (Scr.ASRoot.next) Scr.ASRoot.next->prev = t;
296 Scr.ASRoot.next = t;
297 }
298 else
299 {
300 wins[i++] = t->frame;
301
302 t->prev = ttop;
303 t->next = ttop->next;
304 if (ttop->next) ttop->next->prev = t;
305 ttop->next = t;
306 }
307
308 XRaiseWindow(dpy,wins[0]);
309 XRestackWindows(dpy,wins,i);
310 free(wins);
311
312 RedrawPager();
313 #ifndef NON_VIRTUAL
314 raisePanFrames();
315 #endif
316 UpdateVisibility();
317 }
318
319
LowerWindow(ASWindow * t)320 void LowerWindow(ASWindow *t)
321 {
322 XLowerWindow(dpy,t->frame);
323
324 SetTimer(0);
325
326 if (t->next)
327 {
328 ASWindow* tn = t->next;
329 while (tn->next) tn = tn->next;
330 t->next->prev = t->prev;
331 t->prev->next = t->next;
332 tn->next = t;
333 t->prev = tn;
334 t->next = NULL;
335 }
336
337
338 Broadcast(M_LOWER_WINDOW,3,t->w,t->frame,(unsigned long)t,0,0,0,0);
339 #ifndef NO_PAGER
340 if((Scr.Pager_w)&& !(t->flags & STICKY))
341 XLowerWindow(dpy,t->pager_view);
342 #endif
343
344 if((t->flags & ICONIFIED)&&(!(t->flags & SUPPRESSICON)))
345 {
346 XLowerWindow(dpy, t->icon_pixmap_w);
347 }
348 #ifndef NO_PAGER
349 if(Scr.CPagerWin)
350 XLowerWindow(dpy,Scr.CPagerWin);
351 #endif
352 RedrawPager();
353 UpdateVisibility();
354 }
355
356
PagerMoveWindow()357 void PagerMoveWindow()
358 {
359 #ifndef NO_PAGER
360 ASWindow *tmp_win;
361 unsigned int width, height;
362 int Xoff,Yoff,x,y,MaxW,MaxH,xl,yt,xl1,yt1;
363 Window target;
364 Bool done,finished = False;
365 /* I tried to implement a feature so that when windows which could be
366 * opaque moved in a normal move would get the full size windows moved in
367 * conjunction with the pager version of the window, but it seems to
368 * be buggy on some machines */
369 #ifdef BROKEN_STUFF
370 Bool OpaqueMove = False;
371 int dwidth,dheight;
372 #endif
373 if(!Scr.ASPager)
374 return;
375
376
377 EnablePagerRedraw = False;
378 target = Event.xbutton.subwindow;
379 tmp_win = FindCounterpart(target);
380
381 if(tmp_win == NULL)
382 return;
383
384
385 MaxW = Scr.VxMax + Scr.MyDisplayWidth;
386 MaxH = Scr.VyMax + Scr.MyDisplayHeight;
387
388 width = Scr.ASPager->frame_width - 2*Scr.ASPager->boundary_width;
389 height = Scr.ASPager->frame_height - Scr.ASPager->title_height
390 - 2*Scr.ASPager->boundary_width;
391
392 XQueryPointer(dpy, target, &JunkRoot, &JunkChild,
393 &JunkX, &JunkY, &Xoff, &Yoff, &JunkMask);
394
395 XQueryPointer(dpy, Scr.Pager_w, &JunkRoot, &JunkChild,
396 &JunkX, &JunkY, &xl, &yt, &JunkMask);
397 if(xl<0)xl=0;
398 if(yt<0)yt=0;
399 if(xl>width)xl=width;
400 if(yt>height)yt=height;
401 xl -= Xoff;
402 yt -= Yoff;
403 xl1=xl;
404 yt1=yt;
405
406 while (!finished)
407 {
408 /* block until there is an interesting event */
409 XMaskEvent(dpy, ButtonPressMask | ButtonReleaseMask | KeyPressMask |
410 PointerMotionMask | ButtonMotionMask | ExposureMask, &Event);
411 StashEventTime(&Event);
412
413 if (Event.type == MotionNotify)
414 /* discard any extra motion events before a logical release */
415 while(XCheckMaskEvent(dpy, PointerMotionMask | ButtonMotionMask |
416 ButtonRelease, &Event))
417 {
418 StashEventTime(&Event);
419 if(Event.type == ButtonRelease) break;
420 }
421
422 done = FALSE;
423
424 /* Handle a limited number of key press events to allow mouseless
425 * operation */
426 if(Event.type == KeyPress)
427 Keyboard_shortcuts(&Event,ButtonRelease);
428 switch(Event.type)
429 {
430 case ButtonPress:
431 case KeyPress:
432 /* throw away enter and leave events until release */
433 done = TRUE;
434 break;
435 case ButtonRelease:
436 XQueryPointer(dpy, Scr.Pager_w, &JunkRoot, &JunkChild,
437 &JunkX, &JunkY, &xl, &yt, &JunkMask);
438 if(xl<0)xl=0;
439 if(yt<0)yt=0;
440 if(xl>width)xl=width;
441 if(yt>height)yt=height;
442 xl -= Xoff;
443 yt -= Yoff;
444 done = TRUE;
445 finished = TRUE;
446 break;
447
448 case MotionNotify:
449 XQueryPointer(dpy, Scr.Pager_w, &JunkRoot, &JunkChild,
450 &JunkX, &JunkY, &xl, &yt, &JunkMask);
451 if(xl<0)xl=0;
452 if(yt<0)yt=0;
453 if(xl>width)xl=width;
454 if(yt>height)yt=height;
455
456 /* redraw the rubberband */
457 xl -= Xoff;
458 yt -= Yoff;
459
460 done = TRUE;
461 break;
462
463 default:
464 break;
465 }
466 if(!done)
467 {
468 DispatchEvent();
469 }
470 XMoveWindow(dpy, target,xl, yt);
471 DrawPartitionLines();
472
473 }
474
475 x = xl*MaxW/(int)width - Scr.Vx;
476 y = yt*MaxH/(int)height - Scr.Vy;
477
478 MoveResizePagerView(tmp_win);
479 if((xl1!=xl)||(yt1 != yt))
480 {
481 if((tmp_win->flags & ICONIFIED)&&(!(tmp_win->flags & SUPPRESSICON)))
482 {
483 tmp_win->icon_x_loc = x;
484 tmp_win->icon_y_loc = y;
485
486 if(tmp_win->icon_pixmap_w != None)
487 XMoveWindow (dpy, tmp_win->icon_pixmap_w, x,y);
488
489 tmp_win->flags |= ICON_MOVED;
490
491 }
492 else
493 {
494 /* show the actual window */
495 SetupFrame(tmp_win,x,y, tmp_win->frame_width,tmp_win->frame_height,FALSE);
496 }
497 }
498 EnablePagerRedraw = True;
499 RedrawPager();
500 UpdateVisibility();
501 #endif
502 }
503
504
505
506 #ifndef NO_PAGER
FindCounterpart(Window target)507 ASWindow *FindCounterpart(Window target)
508 {
509 ASWindow *t,*tmp_win=0;
510
511 tmp_win = NULL;
512 for (t = Scr.ASRoot.next; t != NULL; t = t->next)
513 {
514 if(t->pager_view == target)
515 {
516 tmp_win = t;
517 }
518 }
519 return tmp_win;
520 }
521 #endif
522
523 /***************************************************************************
524 *
525 * Check to see if the pointer is on the edge of the screen, and scroll/page
526 * if needed
527 ***************************************************************************/
HandlePaging(int HorWarpSize,int VertWarpSize,int * xl,int * yt,int * delta_x,int * delta_y,Bool Grab)528 void HandlePaging(int HorWarpSize, int VertWarpSize, int *xl, int *yt,
529 int *delta_x, int *delta_y,Bool Grab)
530 {
531 #ifndef NON_VIRTUAL
532 int x,y,total;
533 #endif
534
535 *delta_x = 0;
536 *delta_y = 0;
537
538 #ifndef NON_VIRTUAL
539 if (DoHandlePageing)
540 {
541 if((Scr.ScrollResistance >= 10000)||
542 ((HorWarpSize ==0)&&(VertWarpSize==0)))
543 return;
544
545 /* need to move the viewport */
546 if(( *xl >= SCROLL_REGION)&&( *xl < Scr.MyDisplayWidth-SCROLL_REGION)&&
547 ( *yt >= SCROLL_REGION)&&( *yt < Scr.MyDisplayHeight-SCROLL_REGION))
548 return;
549
550 total = 0;
551 while(total < Scr.ScrollResistance)
552 {
553 sleep_a_little(10000);
554 total+=10;
555 if(XCheckWindowEvent(dpy,Scr.PanFrameTop.win,
556 LeaveWindowMask,&Event))
557 {
558 StashEventTime(&Event);
559 return;
560 }
561 if(XCheckWindowEvent(dpy,Scr.PanFrameBottom.win,
562 LeaveWindowMask,&Event))
563 {
564 StashEventTime(&Event);
565 return;
566 }
567 if(XCheckWindowEvent(dpy,Scr.PanFrameLeft.win,
568 LeaveWindowMask,&Event))
569 {
570 StashEventTime(&Event);
571 return;
572 }
573 if(XCheckWindowEvent(dpy,Scr.PanFrameRight.win,
574 LeaveWindowMask,&Event))
575 {
576 StashEventTime(&Event);
577 return;
578 }
579 }
580
581 XQueryPointer(dpy, Scr.Root, &JunkRoot, &JunkChild,
582 &x, &y, &JunkX, &JunkY, &JunkMask);
583
584 /* Turn off the rubberband if its on */
585 MoveOutline(Scr.Root,0,0,0,0);
586
587 /* Move the viewport */
588 /* and/or move the cursor back to the approximate correct location */
589 /* that is, the same place on the virtual desktop that it */
590 /* started at */
591 if( x<SCROLL_REGION)
592 *delta_x = -HorWarpSize;
593 else if ( x >= Scr.MyDisplayWidth-SCROLL_REGION)
594 *delta_x = HorWarpSize;
595 else
596 *delta_x = 0;
597 if( y<SCROLL_REGION)
598 *delta_y = -VertWarpSize;
599 else if ( y >= Scr.MyDisplayHeight-SCROLL_REGION)
600 *delta_y = VertWarpSize;
601 else
602 *delta_y = 0;
603
604 /* Ouch! lots of bounds checking */
605 if(Scr.Vx + *delta_x < 0)
606 {
607 if (!(Scr.flags & EdgeWrapX ))
608 {
609 *delta_x = -Scr.Vx;
610 *xl = x - *delta_x;
611 }
612 else
613 {
614 *delta_x += Scr.VxMax + Scr.MyDisplayWidth;
615 *xl = x + *delta_x % Scr.MyDisplayWidth + HorWarpSize;
616 }
617 }
618 else if(Scr.Vx + *delta_x > Scr.VxMax)
619 {
620 if (!(Scr.flags & EdgeWrapX))
621 {
622 *delta_x = Scr.VxMax - Scr.Vx;
623 *xl = x - *delta_x;
624 }
625 else
626 {
627 *delta_x -= Scr.VxMax +Scr.MyDisplayWidth;
628 *xl = x + *delta_x % Scr.MyDisplayWidth - HorWarpSize;
629 }
630 }
631 else
632 *xl = x - *delta_x;
633
634 if(Scr.Vy + *delta_y < 0)
635 {
636 if (!(Scr.flags & EdgeWrapY))
637 {
638 *delta_y = -Scr.Vy;
639 *yt = y - *delta_y;
640 }
641 else
642 {
643 *delta_y += Scr.VyMax + Scr.MyDisplayHeight;
644 *yt = y + *delta_y % Scr.MyDisplayHeight + VertWarpSize;
645 }
646 }
647 else if(Scr.Vy + *delta_y > Scr.VyMax)
648 {
649 if (!(Scr.flags & EdgeWrapY))
650 {
651 *delta_y = Scr.VyMax - Scr.Vy;
652 *yt = y - *delta_y;
653 }
654 else
655 {
656 *delta_y -= Scr.VyMax + Scr.MyDisplayHeight;
657 *yt = y + *delta_y % Scr.MyDisplayHeight - VertWarpSize;
658 }
659 }
660 else
661 *yt = y - *delta_y;
662
663 if(*xl <= SCROLL_REGION) *xl = SCROLL_REGION+1;
664 if(*yt <= SCROLL_REGION) *yt = SCROLL_REGION+1;
665 if(*xl >= Scr.MyDisplayWidth - SCROLL_REGION)
666 *xl = Scr.MyDisplayWidth - SCROLL_REGION -1;
667 if(*yt >= Scr.MyDisplayHeight - SCROLL_REGION)
668 *yt = Scr.MyDisplayHeight - SCROLL_REGION -1;
669
670 if((*delta_x != 0)||(*delta_y!=0))
671 {
672 if(Grab)
673 XGrabServer(dpy);
674 XWarpPointer(dpy,None,Scr.Root,0,0,0,0,*xl,*yt);
675 MoveViewport(Scr.Vx + *delta_x,Scr.Vy + *delta_y,False);
676 XQueryPointer(dpy, Scr.Root, &JunkRoot, &JunkChild,
677 xl, yt, &JunkX, &JunkY, &JunkMask);
678 if(Grab)
679 XUngrabServer(dpy);
680 }
681 }
682 #endif
683 }
684
685
686
MoveResizeViewPortIndicator(void)687 void MoveResizeViewPortIndicator(void)
688 {
689 #ifndef NO_PAGER
690 int width,height,x1,x2,y1,y2;
691
692 if((Scr.CPagerWin)&&(Scr.ASPager))
693 {
694 width = Scr.ASPager->frame_width - 2*Scr.ASPager->boundary_width;
695 height = Scr.ASPager->frame_height - Scr.ASPager->title_height
696 - 2*Scr.ASPager->boundary_width;
697 x1 = Scr.Vx * width/(Scr.VxMax+Scr.MyDisplayWidth)+1;
698 y1 = Scr.Vy * height/(Scr.VyMax+Scr.MyDisplayHeight)+1;
699 x2 = (Scr.MyDisplayWidth) * width/(Scr.VxMax+Scr.MyDisplayWidth)-1;
700 y2 = (Scr.MyDisplayHeight) * height/(Scr.VyMax+Scr.MyDisplayHeight)-1;
701 if(x1==1)
702 {
703 x1--;
704 x2++;
705 }
706 if(y1==1)
707 {
708 y1--;
709 y2++;
710 }
711 XMoveResizeWindow(dpy,Scr.CPagerWin,x1,y1,x2,y2);
712 }
713 #endif
714 }
715
716
MoveResizePagerView(ASWindow * t)717 void MoveResizePagerView(ASWindow *t)
718 {
719 #ifndef NO_PAGER
720 unsigned int width,height;
721 int ww,wh;
722 int wx,wy;
723 int MaxH,MaxW;
724
725 if((!Scr.ASPager)||(!pagerOn))
726 return;
727
728 width = Scr.ASPager->frame_width - 2*Scr.ASPager->boundary_width;
729 height = Scr.ASPager->frame_height - Scr.ASPager->title_height
730 - 2*Scr.ASPager->boundary_width;
731
732 MaxW = Scr.VxMax + Scr.MyDisplayWidth;
733 MaxH = Scr.VyMax + Scr.MyDisplayHeight;
734
735 if((!(t->flags & STICKY)&&
736 (!(t->flags & ICONIFIED)||(!(t->flags & SUPPRESSICON)))&&
737 (!(t->flags & ICONIFIED)||(!(t->flags & SUPPRESSICON))))&&
738 (!((t->flags & ICONIFIED)&&(t->flags &ICON_UNMAPPED)))&&
739 (t->Desk == Scr.CurrentDesk))
740 {
741 if(t->flags & ICONIFIED)
742 {
743 /* show the icon loc */
744 wx = (t->icon_x_loc + Scr.Vx)*(int)width/MaxW;;
745 wy = (t->icon_y_loc + Scr.Vy)*(int)height/MaxH;
746 ww = t->icon_p_width*(int)width/MaxW;
747 wh = t->icon_p_height*(int)height/MaxH;
748 }
749 else
750 {
751 /* show the actual window */
752 wx = (t->frame_x + Scr.Vx)*(int)width/MaxW;
753 wy = (t->frame_y + Scr.Vy)*(int)height/MaxH;
754 ww = t->frame_width*(int)width/MaxW;
755 wh = t->frame_height*(int)height/MaxH;
756 }
757 if(ww<2)ww=2;
758 if(wh<2)wh=2;
759 XMoveResizeWindow(dpy, t->pager_view, wx, wy, ww, wh);
760 }
761 else
762 {
763 /* window is sticky - make sure that the pager_view window is not
764 * visible */
765 XMoveResizeWindow(dpy, t->pager_view, -10, -10, 5, 5);
766 }
767 RedrawPager();
768 #endif
769 }
770
771
772 /***********************************************************************
773 *
774 * Procedure:
775 * Initialize_pager - creates the pager window, if needed
776 *
777 * Inputs:
778 * x,y location of the window
779 *
780 ***********************************************************************/
781 #ifndef NO_PAGER
782 char *pager_name = "AfterStep Pager";
783 XSizeHints sizehints =
784 {
785 (PMinSize | PResizeInc | PBaseSize | PWinGravity),
786 0, 0, 100, 100, /* x, y, width and height */
787 1, 1, /* Min width and height */
788 0, 0, /* Max width and height */
789 1, 1, /* Width and height increments */
790 {0, 0}, {0, 0}, /* Aspect ratio - not used */
791 1, 1, /* base size */
792 (NorthWestGravity) /* gravity */
793 };
794
initialize_pager(int x,int y)795 void initialize_pager(int x, int y)
796 {
797 XTextProperty name;
798 int width,height,window_x,window_y;
799 unsigned long valuemask;
800 XSetWindowAttributes attributes;
801 extern Pixel PagerBackColor;
802 extern Pixel PagerForeColor;
803
804 width = (Scr.VxMax + Scr.MyDisplayWidth)/Scr.VScale;
805 height = (Scr.VyMax + Scr.MyDisplayHeight)/Scr.VScale;
806
807 if(x >=0)
808 window_x = x;
809 else
810 {
811 sizehints.win_gravity = NorthEastGravity;
812 window_x = Scr.MyDisplayWidth - width + x -2;
813 }
814
815 if(y >=0)
816 window_y = y;
817 else
818 {
819 window_y = Scr.MyDisplayHeight - height + y -2;
820 if(x<0)
821 sizehints.win_gravity = SouthEastGravity;
822 else
823 sizehints.win_gravity = SouthWestGravity;
824 }
825 valuemask = (CWBackPixel | CWBorderPixel | CWEventMask|CWCursor);
826 attributes.background_pixel = PagerBackColor;
827 attributes.border_pixel = Scr.StdColors.fore;
828 attributes.cursor = Scr.ASCursors[DEFAULT];
829 attributes.event_mask = (ExposureMask | EnterWindowMask|ButtonReleaseMask|
830 ButtonMotionMask);
831 sizehints.width = width;
832 sizehints.height = height;
833 sizehints.x = window_x;
834 sizehints.y = window_y;
835
836 Scr.Pager_w = XCreateWindow (dpy, Scr.Root, window_x, window_y, width,
837 height, (unsigned int) 1,
838 CopyFromParent, InputOutput,
839 (Visual *) CopyFromParent,
840 valuemask, &attributes);
841 XSetWMNormalHints(dpy,Scr.Pager_w,&sizehints);
842 XStringListToTextProperty(&pager_name,1,&name);
843 XSetWMName(dpy,Scr.Pager_w,&name);
844 XSetWMIconName(dpy,Scr.Pager_w,&name);
845 XFree((char *)name.value);
846
847 attributes.event_mask = KeyPressMask | ExposureMask;
848 attributes.background_pixel = PagerForeColor;
849 attributes.cursor = Scr.ASCursors[DEFAULT];
850 Scr.CPagerWin=XCreateWindow(dpy,Scr.Pager_w,-10, -10, 10, 10,0,
851 CopyFromParent,
852 InputOutput,CopyFromParent,
853 CWEventMask|CWBackPixel|CWCursor,
854 &attributes);
855 XMapRaised(dpy,Scr.CPagerWin);
856 }
857 #endif
858