2 * Window Maker window manager
4 * Copyright (c) 1997-2003 Alfredo K. Kojima
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
25 #include <X11/Xutil.h>
26 #include <X11/keysym.h>
32 #include "WindowMaker.h"
41 #include "workspace.h"
47 #include <WINGs/WINGsP.h>
54 /* How many different types of geometry/position
55 display thingies are there? */
56 #define NUM_DISPLAYS 5
60 #define HORIZONTAL (LEFT|RIGHT)
63 #define VERTICAL (UP|DOWN)
66 /* True if window currently has a border. This also includes borderless
67 * windows which are currently selected
69 #define HAS_BORDER(w) ((w)->flags.selected || !WFLAGP((w), no_border))
72 /****** Global Variables ******/
73 extern Time LastTimestamp
;
75 extern Cursor wCursor
[WCUR_LAST
];
77 extern WPreferences wPreferences
;
79 extern Atom _XA_WM_PROTOCOLS
;
84 *----------------------------------------------------------------------
85 * checkMouseSamplingRate-
86 * For lowering the mouse motion sampling rate for machines where
87 * it's too high (SGIs). If it returns False then the event should be
89 *----------------------------------------------------------------------
92 checkMouseSamplingRate(XEvent
*ev
)
94 static Time previousMotion
= 0;
96 if (ev
->type
== MotionNotify
) {
97 if (ev
->xmotion
.time
- previousMotion
< DELAY_BETWEEN_MOUSE_SAMPLING
) {
100 previousMotion
= ev
->xmotion
.time
;
109 *----------------------------------------------------------------------
110 * moveGeometryDisplayCentered
112 * routine that moves the geometry/position window on scr so it is
113 * centered over the given coordinates (x,y). Also the window position
114 * is clamped so it stays on the screen at all times.
115 *----------------------------------------------------------------------
118 moveGeometryDisplayCentered(WScreen
*scr
, int x
, int y
)
120 unsigned int w
= WMWidgetWidth(scr
->gview
);
121 unsigned int h
= WMWidgetHeight(scr
->gview
);
122 int x1
= 0, y1
= 0, x2
= scr
->scr_width
, y2
= scr
->scr_height
;
127 /* dead area check */
128 if (scr
->xine_count
) {
135 rect
.size
.height
= h
;
137 head
= wGetRectPlacementInfo(scr
, rect
, &flags
);
139 if (flags
& (XFLAG_DEAD
| XFLAG_PARTIAL
)) {
140 rect
= wGetRectForHead(scr
, head
);
143 x2
= x1
+ rect
.size
.width
;
144 y2
= y1
+ rect
.size
.height
;
150 else if (x
> (x2
- w
))
155 else if (y
> (y2
- h
))
159 WMMoveWidget(scr
->gview
, x
, y
);
164 showPosition(WWindow
*wwin
, int x
, int y
)
166 WScreen
*scr
= wwin
->screen_ptr
;
168 if (wPreferences
.move_display
== WDIS_NEW
) {
170 int width
= wwin
->frame
->core
->width
;
171 int height
= wwin
->frame
->core
->height
;
173 GC lgc
= scr
->line_gc
;
174 XSetForeground(dpy
, lgc
, scr
->line_pixel
);
175 sprintf(num
, "%i", x
);
177 XDrawLine(dpy
, scr
->root_win
, lgc
, 0, y
-1, scr
->scr_width
, y
-1);
178 XDrawLine(dpy
, scr
->root_win
, lgc
, 0, y
+height
+2, scr
->scr_width
,
180 XDrawLine(dpy
, scr
->root_win
, lgc
, x
-1, 0, x
-1, scr
->scr_height
);
181 XDrawLine(dpy
, scr
->root_win
, lgc
, x
+width
+2, 0, x
+width
+2,
185 #ifdef VIRTUAL_DESKTOP
186 WSetGeometryViewShownPosition(scr
->gview
,
187 x
+ scr
->workspaces
[scr
->current_workspace
]->view_x
,
188 y
+ scr
->workspaces
[scr
->current_workspace
]->view_y
);
190 WSetGeometryViewShownPosition(scr
->gview
, x
, y
);
197 cyclePositionDisplay(WWindow
*wwin
, int x
, int y
, int w
, int h
)
199 WScreen
*scr
= wwin
->screen_ptr
;
202 wPreferences
.move_display
++;
203 wPreferences
.move_display
%= NUM_DISPLAYS
;
205 if (wPreferences
.move_display
== WDIS_NEW
) {
206 wPreferences
.move_display
++;
207 wPreferences
.move_display
%= NUM_DISPLAYS
;
210 if (wPreferences
.move_display
== WDIS_NONE
) {
211 WMUnmapWidget(scr
->gview
);
213 if (wPreferences
.move_display
== WDIS_CENTER
) {
214 rect
= wGetRectForHead(scr
, wGetHeadForWindow(wwin
));
215 moveGeometryDisplayCentered(scr
, rect
.pos
.x
+ rect
.size
.width
/2,
216 rect
.pos
.y
+ rect
.size
.height
/2);
217 } else if (wPreferences
.move_display
== WDIS_TOPLEFT
) {
218 rect
= wGetRectForHead(scr
, wGetHeadForWindow(wwin
));
219 moveGeometryDisplayCentered(scr
, rect
.pos
.x
+ 1, rect
.pos
.y
+ 1);
220 } else if (wPreferences
.move_display
== WDIS_FRAME_CENTER
) {
221 moveGeometryDisplayCentered(scr
, x
+ w
/2, y
+ h
/2);
223 WMMapWidget(scr
->gview
);
229 mapPositionDisplay(WWindow
*wwin
, int x
, int y
, int w
, int h
)
231 WScreen
*scr
= wwin
->screen_ptr
;
234 if (wPreferences
.move_display
== WDIS_NEW
235 || wPreferences
.move_display
== WDIS_NONE
) {
237 } else if (wPreferences
.move_display
== WDIS_CENTER
) {
238 rect
= wGetRectForHead(scr
, wGetHeadForWindow(wwin
));
239 moveGeometryDisplayCentered(scr
,
240 rect
.pos
.x
+ rect
.size
.width
/2,
241 rect
.pos
.y
+ rect
.size
.height
/2);
242 } else if (wPreferences
.move_display
== WDIS_TOPLEFT
) {
243 rect
= wGetRectForHead(scr
, wGetHeadForWindow(wwin
));
244 moveGeometryDisplayCentered(scr
, rect
.pos
.x
+ 1, rect
.pos
.y
+ 1);
245 } else if (wPreferences
.move_display
== WDIS_FRAME_CENTER
) {
246 moveGeometryDisplayCentered(scr
, x
+ w
/2, y
+ h
/2);
248 WMMapWidget(scr
->gview
);
249 WSetGeometryViewShownPosition(scr
->gview
, x
, y
);
254 showGeometry(WWindow
*wwin
, int x1
, int y1
, int x2
, int y2
, int direction
)
256 WScreen
*scr
= wwin
->screen_ptr
;
257 Window root
= scr
->root_win
;
258 GC gc
= scr
->line_gc
, saveGC
;
259 int ty
, by
, my
, x
, y
, mx
, s
;
266 /* This seems necessary for some odd reason (too lazy to write x1-1 and
267 * x2-1 everywhere below in the code). But why only for x? */
270 if (HAS_BORDER(wwin
)) {
271 x1
+= FRAME_BORDER_WIDTH
;
272 x2
+= FRAME_BORDER_WIDTH
;
273 y1
+= FRAME_BORDER_WIDTH
;
274 y2
+= FRAME_BORDER_WIDTH
;
277 ty
= y1
+ wwin
->frame
->top_width
;
278 by
= y2
- wwin
->frame
->bottom_width
;
280 if (wPreferences
.size_display
== WDIS_NEW
) {
281 fw
= WMWidthOfString(scr
->tech_draw_font
, "8888", 4);
282 fh
= WMFontHeight(scr
->tech_draw_font
);
284 XSetForeground(dpy
, gc
, scr
->line_pixel
);
286 /* vertical geometry */
287 if (((direction
& LEFT
) && (x2
< scr
->scr_width
- fw
)) || (x1
< fw
)) {
296 /* top arrow & end bar */
297 segment
[0].x1
= x
- (s
+ 6); segment
[0].y1
= ty
;
298 segment
[0].x2
= x
- (s
- 10); segment
[0].y2
= ty
;
301 segment
[1].x1
= x
- (s
- 2); segment
[1].y1
= ty
+ 1;
302 segment
[1].x2
= x
- (s
- 5); segment
[1].y2
= ty
+ 7;
304 segment
[2].x1
= x
- (s
- 2); segment
[2].y1
= ty
+ 1;
305 segment
[2].x2
= x
- (s
+ 1); segment
[2].y2
= ty
+ 7;
308 segment
[3].x1
= x
- (s
- 2); segment
[3].y1
= ty
+ 1;
309 segment
[3].x2
= x
- (s
- 2); segment
[3].y2
= my
- fh
/2 - 1;
311 XDrawSegments(dpy
, root
, gc
, segment
, 4);
313 /* bottom arrow & end bar */
318 segment
[1].y1
= by
- 1;
319 segment
[1].y2
= by
- 7;
321 segment
[2].y1
= by
- 1;
322 segment
[2].y2
= by
- 7;
325 segment
[3].y1
= my
+ fh
/2 + 2;
326 segment
[3].y2
= by
- 1;
328 XDrawSegments(dpy
, root
, gc
, segment
, 4);
330 snprintf(num
, sizeof(num
), "%i", (by
- ty
- wwin
->normal_hints
->base_height
) /
331 wwin
->normal_hints
->height_inc
);
332 fw
= WMWidthOfString(scr
->tech_draw_font
, num
, strlen(num
));
334 /* XSetForeground(dpy, gc, WMColorPixel(scr->window_title_color[WS_UNFOCUSED])); */
336 color
= WMBlackColor(scr
->wmscreen
);
337 saveGC
= scr
->wmscreen
->drawStringGC
;
338 pixel
= color
->color
.pixel
;
340 /* Display the height. */
343 color
->color
.pixel
= scr
->line_pixel
;
344 scr
->wmscreen
->drawStringGC
= gc
;
345 WMDrawString(scr
->wmscreen
, root
, color
, scr
->tech_draw_font
,
346 x
- s
+ 3 - fw
/2, my
- fh
/2 + 1, num
, strlen(num
));
347 scr
->wmscreen
->drawStringGC
= saveGC
;
348 color
->color
.pixel
= pixel
;
350 XSetForeground(dpy
, gc
, scr
->line_pixel
);
351 /* horizontal geometry */
359 mx
= x1
+ (x2
- x1
)/2;
360 snprintf(num
, sizeof(num
), "%i", (x2
- x1
- wwin
->normal_hints
->base_width
) /
361 wwin
->normal_hints
->width_inc
);
362 fw
= WMWidthOfString(scr
->tech_draw_font
, num
, strlen(num
));
364 /* left arrow & end bar */
365 segment
[0].x1
= x1
; segment
[0].y1
= y
- (s
+ 6);
366 segment
[0].x2
= x1
; segment
[0].y2
= y
- (s
- 10);
369 segment
[1].x1
= x1
+ 7; segment
[1].y1
= y
- (s
+ 1);
370 segment
[1].x2
= x1
+ 1; segment
[1].y2
= y
- (s
- 2);
372 segment
[2].x1
= x1
+ 1; segment
[2].y1
= y
- (s
- 2);
373 segment
[2].x2
= x1
+ 7; segment
[2].y2
= y
- (s
- 5);
376 segment
[3].x1
= x1
+ 1; segment
[3].y1
= y
- (s
- 2);
377 segment
[3].x2
= mx
- fw
/2 - 2; segment
[3].y2
= y
- (s
- 2);
379 XDrawSegments(dpy
, root
, gc
, segment
, 4);
381 /* right arrow & end bar */
382 segment
[0].x1
= x2
+ 1;
383 segment
[0].x2
= x2
+ 1;
386 segment
[1].x1
= x2
- 6;
390 segment
[2].x2
= x2
- 6;
393 segment
[3].x1
= mx
+ fw
/2 + 2;
396 XDrawSegments(dpy
, root
, gc
, segment
, 4);
398 /* XSetForeground(dpy, gc, WMColorPixel(scr->window_title_color[WS_UNFOCUSED])); */
400 /* Display the width. */
402 color
->color
.pixel
= scr
->line_pixel
;
403 scr
->wmscreen
->drawStringGC
= gc
;
404 WMDrawString(scr
->wmscreen
, root
, color
, scr
->tech_draw_font
,
405 mx
- fw
/2 + 1, y
- s
- fh
/2 + 1, num
, strlen(num
));
406 scr
->wmscreen
->drawStringGC
= saveGC
;
407 color
->color
.pixel
= pixel
;
408 WMReleaseColor(color
);
410 WSetGeometryViewShownSize(scr
->gview
,
411 (x2
- x1
- wwin
->normal_hints
->base_width
)
412 / wwin
->normal_hints
->width_inc
,
413 (by
- ty
- wwin
->normal_hints
->base_height
)
414 / wwin
->normal_hints
->height_inc
);
420 cycleGeometryDisplay(WWindow
*wwin
, int x
, int y
, int w
, int h
, int dir
)
422 WScreen
*scr
= wwin
->screen_ptr
;
425 wPreferences
.size_display
++;
426 wPreferences
.size_display
%= NUM_DISPLAYS
;
428 if (wPreferences
.size_display
== WDIS_NEW
429 || wPreferences
.size_display
== WDIS_NONE
) {
430 WMUnmapWidget(scr
->gview
);
432 if (wPreferences
.size_display
== WDIS_CENTER
) {
433 rect
= wGetRectForHead(scr
, wGetHeadForWindow(wwin
));
434 moveGeometryDisplayCentered(scr
,
435 rect
.pos
.x
+ rect
.size
.width
/2,
436 rect
.pos
.y
+ rect
.size
.height
/2);
437 } else if (wPreferences
.size_display
== WDIS_TOPLEFT
) {
438 rect
= wGetRectForHead(scr
, wGetHeadForWindow(wwin
));
439 moveGeometryDisplayCentered(scr
, rect
.pos
.x
+ 1, rect
.pos
.y
+ 1);
440 } else if (wPreferences
.size_display
== WDIS_FRAME_CENTER
) {
441 moveGeometryDisplayCentered(scr
, x
+ w
/2, y
+ h
/2);
443 WMMapWidget(scr
->gview
);
444 showGeometry(wwin
, x
, y
, x
+ w
, y
+ h
, dir
);
450 mapGeometryDisplay(WWindow
*wwin
, int x
, int y
, int w
, int h
)
452 WScreen
*scr
= wwin
->screen_ptr
;
455 if (wPreferences
.size_display
== WDIS_NEW
456 || wPreferences
.size_display
== WDIS_NONE
)
459 if (wPreferences
.size_display
== WDIS_CENTER
) {
460 rect
= wGetRectForHead(scr
, wGetHeadForWindow(wwin
));
461 moveGeometryDisplayCentered(scr
,
462 rect
.pos
.x
+ rect
.size
.width
/2,
463 rect
.pos
.y
+ rect
.size
.height
/2);
464 } else if (wPreferences
.size_display
== WDIS_TOPLEFT
) {
465 rect
= wGetRectForHead(scr
, wGetHeadForWindow(wwin
));
466 moveGeometryDisplayCentered(scr
, rect
.pos
.x
+ 1, rect
.pos
.y
+ 1);
467 } else if (wPreferences
.size_display
== WDIS_FRAME_CENTER
) {
468 moveGeometryDisplayCentered(scr
, x
+ w
/2, y
+ h
/2);
470 WMMapWidget(scr
->gview
);
471 showGeometry(wwin
, x
, y
, x
+ w
, y
+ h
, 0);
477 doWindowMove(WWindow
*wwin
, WMArray
*array
, int dx
, int dy
)
480 WScreen
*scr
= wwin
->screen_ptr
;
483 if (!array
|| !WMGetArrayItemCount(array
)) {
484 wWindowMove(wwin
, wwin
->frame_x
+ dx
, wwin
->frame_y
+ dy
);
486 WMArrayIterator iter
;
488 WM_ITERATE_ARRAY(array
, tmpw
, iter
) {
489 x
= tmpw
->frame_x
+ dx
;
490 y
= tmpw
->frame_y
+ dy
;
492 #if 1 /* XXX: with xinerama patch was #if 0, check this */
493 /* don't let windows become unreachable */
495 if (x
+ (int)tmpw
->frame
->core
->width
< 20)
496 x
= 20 - (int)tmpw
->frame
->core
->width
;
497 else if (x
+ 20 > scr
->scr_width
)
498 x
= scr
->scr_width
- 20;
500 if (y
+ (int)tmpw
->frame
->core
->height
< 20)
501 y
= 20 - (int)tmpw
->frame
->core
->height
;
502 else if (y
+ 20 > scr
->scr_height
)
503 y
= scr
->scr_height
- 20;
505 wScreenBringInside(scr
, &x
, &y
,
506 (int)tmpw
->frame
->core
->width
,
507 (int)tmpw
->frame
->core
->height
);
510 wWindowMove(tmpw
, x
, y
);
517 drawTransparentFrame(WWindow
*wwin
, int x
, int y
, int width
, int height
)
519 Window root
= wwin
->screen_ptr
->root_win
;
520 GC gc
= wwin
->screen_ptr
->frame_gc
;
524 if (HAS_BORDER(wwin
)) {
525 x
+= FRAME_BORDER_WIDTH
;
526 y
+= FRAME_BORDER_WIDTH
;
529 if (!WFLAGP(wwin
, no_titlebar
) && !wwin
->flags
.shaded
) {
530 h
= WMFontHeight(wwin
->screen_ptr
->title_font
) + (wPreferences
.window_title_clearance
+ TITLEBAR_EXTEND_SPACE
) * 2;
532 if (!WFLAGP(wwin
, no_resizebar
) && !wwin
->flags
.shaded
) {
533 /* Can't use wwin-frame->bottom_width because, in some cases
534 (e.g. interactive placement), frame does not point to anything. */
535 bottom
= RESIZEBAR_HEIGHT
;
537 XDrawRectangle(dpy
, root
, gc
, x
- 1, y
- 1, width
+ 1, height
+ 1);
540 XDrawLine(dpy
, root
, gc
, x
, y
+ h
- 1, x
+ width
, y
+ h
- 1);
543 XDrawLine(dpy
, root
, gc
, x
, y
+ height
- bottom
,
544 x
+ width
, y
+ height
- bottom
);
550 drawFrames(WWindow
*wwin
, WMArray
*array
, int dx
, int dy
)
553 int scr_width
= wwin
->screen_ptr
->scr_width
;
554 int scr_height
= wwin
->screen_ptr
->scr_height
;
559 x
= wwin
->frame_x
+ dx
;
560 y
= wwin
->frame_y
+ dy
;
562 drawTransparentFrame(wwin
, x
, y
,
563 wwin
->frame
->core
->width
,
564 wwin
->frame
->core
->height
);
567 WMArrayIterator iter
;
569 WM_ITERATE_ARRAY(array
, tmpw
, iter
) {
570 x
= tmpw
->frame_x
+ dx
;
571 y
= tmpw
->frame_y
+ dy
;
573 /* don't let windows become unreachable */
574 #if 1 /* XXX: was 0 in XINERAMA patch, check */
575 if (x
+ (int)tmpw
->frame
->core
->width
< 20)
576 x
= 20 - (int)tmpw
->frame
->core
->width
;
577 else if (x
+ 20 > scr_width
)
580 if (y
+ (int)tmpw
->frame
->core
->height
< 20)
581 y
= 20 - (int)tmpw
->frame
->core
->height
;
582 else if (y
+ 20 > scr_height
)
586 wScreenBringInside(wwin
->screen_ptr
, &x
, &y
,
587 (int)tmpw
->frame
->core
->width
,
588 (int)tmpw
->frame
->core
->height
);
591 drawTransparentFrame(tmpw
, x
, y
, tmpw
->frame
->core
->width
,
592 tmpw
->frame
->core
->height
);
605 while (XCheckMaskEvent(dpy
, ButtonMotionMask
, &ev
)) ;
610 crossWorkspace(WScreen
*scr
, WWindow
*wwin
, int opaque_move
,
611 int new_workspace
, int rewind
)
613 /* do not let window be unmapped */
615 wwin
->flags
.changing_workspace
= 1;
616 wWindowChangeWorkspace(wwin
, new_workspace
);
618 /* go to new workspace */
619 wWorkspaceChange(scr
, new_workspace
);
621 wwin
->flags
.changing_workspace
= 0;
624 XWarpPointer(dpy
, None
, None
, 0, 0, 0, 0, scr
->scr_width
- 20, 0);
626 XWarpPointer(dpy
, None
, None
, 0, 0, 0, 0, -(scr
->scr_width
- 20), 0);
631 XGrabPointer(dpy
, scr
->root_win
, True
, PointerMotionMask
632 |ButtonReleaseMask
|ButtonPressMask
, GrabModeAsync
,
633 GrabModeAsync
, None
, wCursor
[WCUR_MOVE
], CurrentTime
);
641 /* arrays of WWindows sorted by the respective border position */
642 WWindow
**topList
; /* top border */
643 WWindow
**leftList
; /* left border */
644 WWindow
**rightList
; /* right border */
645 WWindow
**bottomList
; /* bottom border */
648 /* index of window in the above lists indicating the relative position
649 * of the window with the others */
655 int rubCount
; /* for workspace switching */
657 int winWidth
, winHeight
; /* width/height of the window */
658 int realX
, realY
; /* actual position of the window */
659 int calcX
, calcY
; /* calculated position of window */
660 int omouseX
, omouseY
; /* old mouse position */
661 int mouseX
, mouseY
; /* last known position of the pointer */
664 #define WTOP(w) (w)->frame_y
665 #define WLEFT(w) (w)->frame_x
666 #define WRIGHT(w) ((w)->frame_x + (int)(w)->frame->core->width - 1 + \
667 (HAS_BORDER(w) ? 2*FRAME_BORDER_WIDTH : 0))
668 #define WBOTTOM(w) ((w)->frame_y + (int)(w)->frame->core->height - 1 + \
669 (HAS_BORDER(w) ? 2*FRAME_BORDER_WIDTH : 0))
672 compareWTop(const void *a
, const void *b
)
674 WWindow
*wwin1
= *(WWindow
**)a
;
675 WWindow
*wwin2
= *(WWindow
**)b
;
677 if (WTOP(wwin1
) > WTOP(wwin2
))
679 else if (WTOP(wwin1
) < WTOP(wwin2
))
687 compareWLeft(const void *a
, const void *b
)
689 WWindow
*wwin1
= *(WWindow
**)a
;
690 WWindow
*wwin2
= *(WWindow
**)b
;
692 if (WLEFT(wwin1
) > WLEFT(wwin2
))
694 else if (WLEFT(wwin1
) < WLEFT(wwin2
))
702 compareWRight(const void *a
, const void *b
)
704 WWindow
*wwin1
= *(WWindow
**)a
;
705 WWindow
*wwin2
= *(WWindow
**)b
;
707 if (WRIGHT(wwin1
) < WRIGHT(wwin2
))
709 else if (WRIGHT(wwin1
) > WRIGHT(wwin2
))
718 compareWBottom(const void *a
, const void *b
)
720 WWindow
*wwin1
= *(WWindow
**)a
;
721 WWindow
*wwin2
= *(WWindow
**)b
;
723 if (WBOTTOM(wwin1
) < WBOTTOM(wwin2
))
725 else if (WBOTTOM(wwin1
) > WBOTTOM(wwin2
))
733 updateResistance(WWindow
*wwin
, MoveData
*data
, int newX
, int newY
)
736 int newX2
= newX
+ data
->winWidth
;
737 int newY2
= newY
+ data
->winHeight
;
740 if (newX
< data
->realX
) {
741 if (data
->rightIndex
> 0
742 && newX
< WRIGHT(data
->rightList
[data
->rightIndex
-1])) {
744 } else if (data
->leftIndex
<= data
->count
-1
745 && newX2
<= WLEFT(data
->leftList
[data
->leftIndex
])) {
748 } else if (newX
> data
->realX
) {
749 if (data
->leftIndex
> 0
750 && newX2
> WLEFT(data
->leftList
[data
->leftIndex
-1])) {
752 } else if (data
->rightIndex
<= data
->count
-1
753 && newX
>= WRIGHT(data
->rightList
[data
->rightIndex
])) {
759 if (newY
< data
->realY
) {
760 if (data
->bottomIndex
> 0
761 && newY
< WBOTTOM(data
->bottomList
[data
->bottomIndex
-1])) {
763 } else if (data
->topIndex
<= data
->count
-1
764 && newY2
<= WTOP(data
->topList
[data
->topIndex
])) {
767 } else if (newY
> data
->realY
) {
768 if (data
->topIndex
> 0
769 && newY2
> WTOP(data
->topList
[data
->topIndex
-1])) {
771 } else if (data
->bottomIndex
<= data
->count
-1
772 && newY
>= WBOTTOM(data
->bottomList
[data
->bottomIndex
])) {
781 /* TODO: optimize this */
782 if (data
->realY
< WBOTTOM(data
->bottomList
[0])) {
783 data
->bottomIndex
= 0;
785 if (data
->realX
< WRIGHT(data
->rightList
[0])) {
786 data
->rightIndex
= 0;
788 if ((data
->realX
+ data
->winWidth
) > WLEFT(data
->leftList
[0])) {
791 if ((data
->realY
+ data
->winHeight
) > WTOP(data
->topList
[0])) {
794 for (i
= 0; i
< data
->count
; i
++) {
795 if (data
->realY
> WBOTTOM(data
->bottomList
[i
])) {
796 data
->bottomIndex
= i
+ 1;
798 if (data
->realX
> WRIGHT(data
->rightList
[i
])) {
799 data
->rightIndex
= i
+ 1;
801 if ((data
->realX
+ data
->winWidth
) < WLEFT(data
->leftList
[i
])) {
802 data
->leftIndex
= i
+ 1;
804 if ((data
->realY
+ data
->winHeight
) < WTOP(data
->topList
[i
])) {
805 data
->topIndex
= i
+ 1;
812 freeMoveData(MoveData
*data
)
815 wfree(data
->topList
);
817 wfree(data
->leftList
);
819 wfree(data
->rightList
);
820 if (data
->bottomList
)
821 wfree(data
->bottomList
);
826 updateMoveData(WWindow
*wwin
, MoveData
*data
)
828 WScreen
*scr
= wwin
->screen_ptr
;
833 tmp
= scr
->focused_window
;
835 if (tmp
!= wwin
&& scr
->current_workspace
== tmp
->frame
->workspace
836 && !tmp
->flags
.miniaturized
837 && !tmp
->flags
.hidden
838 && !tmp
->flags
.obscured
839 && !WFLAGP(tmp
, sunken
)) {
840 data
->topList
[data
->count
] = tmp
;
841 data
->leftList
[data
->count
] = tmp
;
842 data
->rightList
[data
->count
] = tmp
;
843 data
->bottomList
[data
->count
] = tmp
;
849 if (data
->count
== 0) {
852 data
->rightIndex
= 0;
853 data
->bottomIndex
= 0;
857 /* order from closest to the border of the screen to farthest */
859 qsort(data
->topList
, data
->count
, sizeof(WWindow
**), compareWTop
);
860 qsort(data
->leftList
, data
->count
, sizeof(WWindow
**), compareWLeft
);
861 qsort(data
->rightList
, data
->count
, sizeof(WWindow
**), compareWRight
);
862 qsort(data
->bottomList
, data
->count
, sizeof(WWindow
**), compareWBottom
);
864 /* figure the position of the window relative to the others */
867 data
->leftIndex
= -1;
868 data
->rightIndex
= -1;
869 data
->bottomIndex
= -1;
871 if (WTOP(wwin
) < WBOTTOM(data
->bottomList
[0])) {
872 data
->bottomIndex
= 0;
874 if (WLEFT(wwin
) < WRIGHT(data
->rightList
[0])) {
875 data
->rightIndex
= 0;
877 if (WRIGHT(wwin
) > WLEFT(data
->leftList
[0])) {
880 if (WBOTTOM(wwin
) > WTOP(data
->topList
[0])) {
883 for (i
= 0; i
< data
->count
; i
++) {
884 if (WTOP(wwin
) >= WBOTTOM(data
->bottomList
[i
])) {
885 data
->bottomIndex
= i
+ 1;
887 if (WLEFT(wwin
) >= WRIGHT(data
->rightList
[i
])) {
888 data
->rightIndex
= i
+ 1;
890 if (WRIGHT(wwin
) <= WLEFT(data
->leftList
[i
])) {
891 data
->leftIndex
= i
+ 1;
893 if (WBOTTOM(wwin
) <= WTOP(data
->topList
[i
])) {
894 data
->topIndex
= i
+ 1;
901 initMoveData(WWindow
*wwin
, MoveData
*data
)
906 memset(data
, 0, sizeof(MoveData
));
908 for (i
= 0, tmp
= wwin
->screen_ptr
->focused_window
;
910 tmp
= tmp
->prev
, i
++);
913 data
->topList
= wmalloc(sizeof(WWindow
*) * i
);
914 data
->leftList
= wmalloc(sizeof(WWindow
*) * i
);
915 data
->rightList
= wmalloc(sizeof(WWindow
*) * i
);
916 data
->bottomList
= wmalloc(sizeof(WWindow
*) * i
);
918 updateMoveData(wwin
, data
);
921 data
->realX
= wwin
->frame_x
;
922 data
->realY
= wwin
->frame_y
;
923 data
->calcX
= wwin
->frame_x
;
924 data
->calcY
= wwin
->frame_y
;
926 data
->winWidth
= wwin
->frame
->core
->width
+
927 (HAS_BORDER(wwin
) ? 2*FRAME_BORDER_WIDTH
: 0);
928 data
->winHeight
= wwin
->frame
->core
->height
+
929 (HAS_BORDER(wwin
) ? 2*FRAME_BORDER_WIDTH
: 0);
934 checkWorkspaceChange(WWindow
*wwin
, MoveData
*data
, Bool opaqueMove
)
936 WScreen
*scr
= wwin
->screen_ptr
;
937 Bool changed
= False
;
939 if (data
->mouseX
<= 1) {
940 if (scr
->current_workspace
> 0) {
942 crossWorkspace(scr
, wwin
, opaqueMove
, scr
->current_workspace
- 1,
947 } else if (scr
->current_workspace
== 0 && wPreferences
.ws_cycle
) {
949 crossWorkspace(scr
, wwin
, opaqueMove
, scr
->workspace_count
- 1,
954 } else if (data
->mouseX
>= scr
->scr_width
- 2) {
956 if (scr
->current_workspace
== scr
->workspace_count
- 1) {
958 if (wPreferences
.ws_cycle
959 || scr
->workspace_count
== MAX_WORKSPACES
) {
961 crossWorkspace(scr
, wwin
, opaqueMove
, 0, False
);
965 /* if user insists on trying to go to next workspace even when
966 * it's already the last, create a new one */
967 else if (data
->omouseX
== data
->mouseX
968 && wPreferences
.ws_advance
) {
970 /* detect user "rubbing" the window against the edge */
971 if (data
->rubCount
> 0
972 && data
->omouseY
- data
->mouseY
> MOVE_THRESHOLD
) {
974 data
->rubCount
= -(data
->rubCount
+ 1);
976 } else if (data
->rubCount
<= 0
977 && data
->mouseY
- data
->omouseY
> MOVE_THRESHOLD
) {
979 data
->rubCount
= -data
->rubCount
+ 1;
982 /* create a new workspace */
983 if (abs(data
->rubCount
) > 2) {
984 /* go to next workspace */
987 crossWorkspace(scr
, wwin
, opaqueMove
,
988 scr
->current_workspace
+1, False
);
992 } else if (scr
->current_workspace
< scr
->workspace_count
) {
994 /* go to next workspace */
995 crossWorkspace(scr
, wwin
, opaqueMove
,
996 scr
->current_workspace
+1, False
);
1009 updateWindowPosition(WWindow
*wwin
, MoveData
*data
, Bool doResistance
,
1010 Bool opaqueMove
, int newMouseX
, int newMouseY
)
1012 WScreen
*scr
= wwin
->screen_ptr
;
1013 int dx
, dy
; /* how much mouse moved */
1014 int winL
, winR
, winT
, winB
; /* requested new window position */
1015 int newX
, newY
; /* actual new window position */
1016 Bool hresist
, vresist
;
1023 updateIndex
= False
;
1025 /* check the direction of the movement */
1026 dx
= newMouseX
- data
->mouseX
;
1027 dy
= newMouseY
- data
->mouseY
;
1029 data
->omouseX
= data
->mouseX
;
1030 data
->omouseY
= data
->mouseY
;
1031 data
->mouseX
= newMouseX
;
1032 data
->mouseY
= newMouseY
;
1034 winL
= data
->calcX
+ dx
;
1035 winR
= data
->calcX
+ data
->winWidth
+ dx
;
1036 winT
= data
->calcY
+ dy
;
1037 winB
= data
->calcY
+ data
->winHeight
+ dy
;
1049 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1050 attract
= wPreferences
.attract
;
1051 /* horizontal movement: check horizontal edge resistances */
1055 /* window is the leftmost window: check against screen edge */
1057 /* Add inter head resistance 1/2 (if needed) */
1058 rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
1060 l_edge
= WMAX(scr
->totalUsableArea
.x1
, rect
.pos
.x
);
1061 edge_l
= l_edge
- resist
;
1062 edge_r
= WMIN(scr
->totalUsableArea
.x2
, rect
.pos
.x
+ rect
.size
.width
);
1063 r_edge
= edge_r
+ resist
;
1066 if ((data
->rightIndex
>= 0) && (data
->rightIndex
<= data
->count
)) {
1069 for (i
= data
->rightIndex
- 1; i
>= 0; i
--) {
1070 looprw
= data
->rightList
[i
];
1071 if (!(data
->realY
> WBOTTOM(looprw
)
1072 || (data
->realY
+ data
->winHeight
) < WTOP(looprw
))) {
1074 || ((data
->realX
< (WRIGHT(looprw
) + 2)) && dx
< 0)) {
1075 l_edge
= WRIGHT(looprw
) + 1;
1076 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1083 for (i
= data
->rightIndex
; i
< data
->count
; i
++) {
1084 looprw
= data
->rightList
[i
];
1085 if(!(data
->realY
> WBOTTOM(looprw
)
1086 || (data
->realY
+ data
->winHeight
) < WTOP(looprw
))) {
1087 r_edge
= WRIGHT(looprw
) + 1;
1088 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1095 if ((data
->leftIndex
>= 0) && (data
->leftIndex
<= data
->count
)) {
1098 for (i
= data
->leftIndex
- 1; i
>= 0; i
--) {
1099 looprw
= data
->leftList
[i
];
1100 if (!(data
->realY
> WBOTTOM(looprw
)
1101 || (data
->realY
+ data
->winHeight
) < WTOP(looprw
))) {
1103 || (((data
->realX
+ data
->winWidth
) > (WLEFT(looprw
) - 1)) && dx
> 0)) {
1104 edge_r
= WLEFT(looprw
);
1105 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1112 for (i
= data
->leftIndex
; i
< data
->count
; i
++) {
1113 looprw
= data
->leftList
[i
];
1114 if(!(data
->realY
> WBOTTOM(looprw
)
1115 || (data
->realY
+ data
->winHeight
) < WTOP(looprw
))) {
1116 edge_l
= WLEFT(looprw
);
1117 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1124 printf("%d %d\n",winL,winR);
1125 printf("l_ %d r_ %d _l %d _r %d\n",l_edge,r_edge,edge_l,edge_r);
1128 if ((winL
- l_edge
) < (r_edge
- winL
)) {
1130 if ((attract
&& winL
<= l_edge
+ resist
&& winL
>= l_edge
- resist
)
1131 || (dx
< 0 && winL
<= l_edge
&& winL
>= l_edge
- resist
)) {
1137 if (resist
> 0 && attract
&& winL
>= r_edge
- resist
&& winL
<= r_edge
+ resist
) {
1143 if ((winR
- edge_l
) < (edge_r
- winR
)) {
1144 if (resist
> 0 && attract
&& winR
<= edge_l
+ resist
&& winR
>= edge_l
- resist
) {
1145 newX
= edge_l
- data
->winWidth
;
1150 if ((attract
&& winR
>= edge_r
- resist
&& winR
<= edge_r
+ resist
)
1151 || (dx
> 0 && winR
>= edge_r
&& winR
<= edge_r
+ resist
)) {
1152 newX
= edge_r
- data
->winWidth
;
1159 /* Add inter head resistance 2/2 (if needed) */
1160 t_edge
= WMAX(scr
->totalUsableArea
.y1
, rect
.pos
.y
);
1161 edge_t
= t_edge
- resist
;
1162 edge_b
= WMIN(scr
->totalUsableArea
.y2
, rect
.pos
.y
+ rect
.size
.height
);
1163 b_edge
= edge_b
+ resist
;
1165 if ((data
->bottomIndex
>= 0) && (data
->bottomIndex
<= data
->count
)) {
1168 for (i
= data
->bottomIndex
- 1; i
>= 0; i
--) {
1169 looprw
= data
->bottomList
[i
];
1170 if (!(data
->realX
> WRIGHT(looprw
)
1171 || (data
->realX
+ data
->winWidth
) < WLEFT(looprw
))) {
1173 || ((data
->realY
< (WBOTTOM(looprw
) + 2)) && dy
< 0)) {
1174 t_edge
= WBOTTOM(looprw
) + 1;
1175 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1182 for (i
= data
->bottomIndex
; i
< data
->count
; i
++) {
1183 looprw
= data
->bottomList
[i
];
1184 if(!(data
->realX
> WRIGHT(looprw
)
1185 || (data
->realX
+ data
->winWidth
) < WLEFT(looprw
))) {
1186 b_edge
= WBOTTOM(looprw
) + 1;
1187 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1194 if ((data
->topIndex
>= 0) && (data
->topIndex
<= data
->count
)) {
1197 for (i
= data
->topIndex
- 1; i
>= 0; i
--) {
1198 looprw
= data
->topList
[i
];
1199 if (!(data
->realX
> WRIGHT(looprw
)
1200 || (data
->realX
+ data
->winWidth
) < WLEFT(looprw
))) {
1202 || (((data
->realY
+ data
->winHeight
) > (WTOP(looprw
) - 1)) && dy
> 0)) {
1203 edge_b
= WTOP(looprw
);
1204 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1211 for (i
= data
->topIndex
; i
< data
->count
; i
++) {
1212 looprw
= data
->topList
[i
];
1213 if(!(data
->realX
> WRIGHT(looprw
)
1214 || (data
->realX
+ data
->winWidth
) < WLEFT(looprw
))) {
1215 edge_t
= WTOP(looprw
);
1216 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1222 if ((winT
- t_edge
) < (b_edge
- winT
)) {
1224 if ((attract
&& winT
<= t_edge
+ resist
&& winT
>= t_edge
- resist
)
1225 || (dy
< 0 && winT
<= t_edge
&& winT
>= t_edge
- resist
)) {
1232 if (resist
> 0 && attract
&& winT
>= b_edge
- resist
&& winT
<= b_edge
+ resist
) {
1238 if ((winB
- edge_t
) < (edge_b
- winB
)) {
1239 if (resist
> 0 && attract
&& winB
<= edge_t
+ resist
&& winB
>= edge_t
- resist
) {
1240 newY
= edge_t
- data
->winHeight
;
1246 if ((attract
&& winB
>= edge_b
- resist
&& winB
<= edge_b
+ resist
)
1247 || (dy
> 0 && winB
>= edge_b
&& winB
<= edge_b
+ resist
)) {
1248 newY
= edge_b
- data
->winHeight
;
1258 /* update window position */
1262 if (((dx
> 0 && data
->calcX
- data
->realX
> 0)
1263 || (dx
< 0 && data
->calcX
- data
->realX
< 0)) && !hresist
)
1266 if (((dy
> 0 && data
->calcY
- data
->realY
> 0)
1267 || (dy
< 0 && data
->calcY
- data
->realY
< 0)) && !vresist
)
1270 if (data
->realX
!= newX
|| data
->realY
!= newY
) {
1272 if (wPreferences
.move_display
== WDIS_NEW
1273 && !scr
->selected_windows
) {
1274 showPosition(wwin
, data
->realX
, data
->realY
);
1277 doWindowMove(wwin
, scr
->selected_windows
,
1278 newX
- wwin
->frame_x
,
1279 newY
- wwin
->frame_y
);
1282 drawFrames(wwin
, scr
->selected_windows
,
1283 data
->realX
- wwin
->frame_x
,
1284 data
->realY
- wwin
->frame_y
);
1287 if (!scr
->selected_windows
1288 && wPreferences
.move_display
== WDIS_FRAME_CENTER
) {
1290 moveGeometryDisplayCentered(scr
, newX
+ data
->winWidth
/2,
1291 newY
+ data
->winHeight
/2);
1296 drawFrames(wwin
, scr
->selected_windows
,
1297 newX
- wwin
->frame_x
,
1298 newY
- wwin
->frame_y
);
1301 if (!scr
->selected_windows
) {
1302 showPosition(wwin
, newX
, newY
);
1307 /* recalc relative window position */
1308 if (doResistance
&& (data
->realX
!= newX
|| data
->realY
!= newY
)) {
1309 updateResistance(wwin
, data
, newX
, newY
);
1317 #define _KS KEY_CONTROL_WINDOW_WEIGHT
1320 wKeyboardMoveResizeWindow(WWindow
*wwin
)
1322 WScreen
*scr
= wwin
->screen_ptr
;
1323 Window root
= scr
->root_win
;
1325 int w
= wwin
->frame
->core
->width
;
1326 int h
= wwin
->frame
->core
->height
;
1327 int scr_width
= wwin
->screen_ptr
->scr_width
;
1328 int scr_height
= wwin
->screen_ptr
->scr_height
;
1329 int vert_border
= wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
;
1330 int src_x
= wwin
->frame_x
;
1331 int src_y
= wwin
->frame_y
;
1332 int done
,off_x
,off_y
,ww
,wh
;
1335 KeySym keysym
=NoSymbol
;
1337 KeyCode shiftl
,shiftr
,ctrll
,ctrlmode
;
1339 shiftl
= XKeysymToKeycode(dpy
, XK_Shift_L
);
1340 shiftr
= XKeysymToKeycode(dpy
, XK_Shift_R
);
1341 ctrll
= XKeysymToKeycode(dpy
, XK_Control_L
);
1342 ctrlmode
=done
=off_x
=off_y
=0;
1346 XGrabKeyboard(dpy
, root
, False
, GrabModeAsync
, GrabModeAsync
, CurrentTime
);
1348 if (!wwin
->flags
.selected
) {
1349 wUnselectWindows(scr
);
1352 XGrabPointer(dpy
, scr
->root_win
, True
, PointerMotionMask
1353 |ButtonReleaseMask
|ButtonPressMask
, GrabModeAsync
,
1354 GrabModeAsync
, None
, wCursor
[WCUR_DEFAULT
], CurrentTime
);
1356 if (wwin
->flags
.shaded
|| scr
->selected_windows
) {
1357 if(scr
->selected_windows
)
1358 drawFrames(wwin
,scr
->selected_windows
,off_x
,off_y
);
1359 else drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, w
, h
);
1360 if(!scr
->selected_windows
)
1361 mapPositionDisplay(wwin
, src_x
, src_y
, w
, h
);
1363 drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, w
, h
);
1373 WMMaskEvent(dpy
, KeyPressMask
| ButtonReleaseMask
1374 | ButtonPressMask
| ExposureMask
, &event
);
1375 if (event
.type
== Expose
) {
1376 WMHandleEvent(&event
);
1378 } while (event
.type
== Expose
);
1381 if (wwin
->flags
.shaded
|| scr
->selected_windows
) {
1382 if(scr
->selected_windows
)
1383 drawFrames(wwin
,scr
->selected_windows
,off_x
,off_y
);
1384 else drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, w
, h
);
1385 /*** I HATE EDGE RESISTANCE - ]d ***/
1388 drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, ww
, wh
);
1392 showGeometry(wwin
, src_x
+off_x
, src_y
+off_y
, src_x
+off_x
+ww
, src_y
+off_y
+wh
,0);
1397 switch (event
.type
) {
1400 if (event
.xkey
.time
- lastTime
> 50) {
1401 kspeed
/=(1 + (event
.xkey
.time
- lastTime
)/100);
1407 if (kspeed
< _KS
) kspeed
= _KS
;
1408 lastTime
= event
.xkey
.time
;
1410 if (event
.xkey
.state
& ControlMask
&& !wwin
->flags
.shaded
) {
1412 wUnselectWindows(scr
);
1417 if (event
.xkey
.keycode
== shiftl
|| event
.xkey
.keycode
== shiftr
) {
1419 cycleGeometryDisplay(wwin
, src_x
+off_x
, src_y
+off_y
, ww
, wh
, 0);
1421 cyclePositionDisplay(wwin
, src_x
+off_x
, src_y
+off_y
, ww
, wh
);
1425 keysym
= XLookupKeysym(&event
.xkey
, 0);
1480 if (moment
!= RIGHT
)
1491 wWindowConstrainSize(wwin
, &ww
, &wh
);
1494 if (wPreferences
.ws_cycle
){
1495 if (src_x
+ off_x
+ ww
< 20){
1496 if(!scr
->current_workspace
) {
1497 wWorkspaceChange(scr
, scr
->workspace_count
-1);
1499 else wWorkspaceChange(scr
, scr
->current_workspace
-1);
1502 else if (src_x
+ off_x
+ 20 > scr_width
){
1503 if(scr
->current_workspace
== scr
->workspace_count
-1) {
1504 wWorkspaceChange(scr
, 0);
1506 else wWorkspaceChange(scr
, scr
->current_workspace
+1);
1511 if (src_x
+ off_x
+ ww
< 20)
1512 off_x
= 20 - ww
- src_x
;
1513 else if (src_x
+ off_x
+ 20 > scr_width
)
1514 off_x
= scr_width
- 20 - src_x
;
1517 if (src_y
+ off_y
+ wh
< 20) {
1518 off_y
= 20 - wh
- src_y
;
1520 else if (src_y
+ off_y
+ 20 > scr_height
) {
1521 off_y
= scr_height
- 20 - src_y
;
1530 WMHandleEvent(&event
);
1531 while (XCheckTypedEvent(dpy
, Expose
, &event
)) {
1532 WMHandleEvent(&event
);
1537 WMHandleEvent(&event
);
1544 if (wwin
->flags
.shaded
&& !scr
->selected_windows
){
1545 moveGeometryDisplayCentered(scr
, src_x
+off_x
+ w
/2, src_y
+off_y
+ h
/2);
1548 WMUnmapWidget(scr
->gview
);
1549 mapGeometryDisplay(wwin
, src_x
+off_x
, src_y
+off_y
, ww
, wh
);
1550 } else if(!scr
->selected_windows
) {
1551 WMUnmapWidget(scr
->gview
);
1552 mapPositionDisplay(wwin
, src_x
+off_x
, src_y
+off_y
, ww
, wh
);
1556 if (wwin
->flags
.shaded
|| scr
->selected_windows
) {
1557 if (scr
->selected_windows
)
1558 drawFrames(wwin
,scr
->selected_windows
,off_x
,off_y
);
1560 drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, w
, h
);
1562 drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, ww
, wh
);
1567 showGeometry(wwin
, src_x
+off_x
, src_y
+off_y
, src_x
+off_x
+ww
, src_y
+off_y
+wh
,0);
1568 } else if(!scr
->selected_windows
)
1569 showPosition(wwin
, src_x
+off_x
, src_y
+off_y
);
1573 scr
->keymove_tick
=0;
1575 WMDeleteTimerWithClientData(&looper);
1577 if (wwin
->flags
.shaded
|| scr
->selected_windows
) {
1578 if(scr
->selected_windows
)
1579 drawFrames(wwin
,scr
->selected_windows
,off_x
,off_y
);
1580 else drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, w
, h
);
1583 drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, ww
, wh
);
1587 showGeometry(wwin
, src_x
+off_x
, src_y
+off_y
, src_x
+off_x
+ww
, src_y
+off_y
+wh
,0);
1588 WMUnmapWidget(scr
->gview
);
1590 WMUnmapWidget(scr
->gview
);
1592 XUngrabKeyboard(dpy
, CurrentTime
);
1593 XUngrabPointer(dpy
, CurrentTime
);
1597 if (wwin
->flags
.shaded
|| scr
->selected_windows
) {
1598 if (!scr
->selected_windows
) {
1599 wWindowMove(wwin
, src_x
+off_x
, src_y
+off_y
);
1600 wWindowSynthConfigureNotify(wwin
);
1602 WMArrayIterator iter
;
1605 doWindowMove(wwin
, scr
->selected_windows
, off_x
, off_y
);
1607 WM_ITERATE_ARRAY(scr
->selected_windows
, foo
, iter
) {
1608 wWindowSynthConfigureNotify(foo
);
1612 if (wwin
->client
.width
!= ww
)
1613 wwin
->flags
.user_changed_width
= 1;
1615 if (wwin
->client
.height
!= wh
- vert_border
)
1616 wwin
->flags
.user_changed_height
= 1;
1618 wWindowConfigure(wwin
, src_x
+off_x
, src_y
+off_y
,
1619 ww
, wh
- vert_border
);
1620 wWindowSynthConfigureNotify(wwin
);
1622 wWindowChangeWorkspace(wwin
, scr
->current_workspace
);
1623 wSetFocusTo(scr
, wwin
);
1632 *----------------------------------------------------------------------
1633 * wMouseMoveWindow--
1634 * Move the named window and the other selected ones (if any),
1635 * interactively. Also shows the position of the window, if only one
1636 * window is being moved.
1637 * If the window is not on the selected window list, the selected
1638 * windows are deselected.
1639 * If shift is pressed during the operation, the position display
1640 * is changed to another type.
1643 * True if the window was moved, False otherwise.
1646 * The window(s) position is changed, and the client(s) are
1647 * notified about that.
1648 * The position display configuration may be changed.
1649 *----------------------------------------------------------------------
1652 wMouseMoveWindow(WWindow
*wwin
, XEvent
*ev
)
1654 WScreen
*scr
= wwin
->screen_ptr
;
1656 Window root
= scr
->root_win
;
1657 KeyCode shiftl
, shiftr
;
1661 /* This needs not to change while moving, else bad things can happen */
1662 int opaqueMove
= wPreferences
.opaque_move
;
1664 #ifdef GHOST_WINDOW_MOVE
1667 rimg
= InitGhostWindowMove(scr
);
1671 if (wPreferences
.opaque_move
&& !wPreferences
.use_saveunders
) {
1672 XSetWindowAttributes attr
;
1674 attr
.save_under
= True
;
1675 XChangeWindowAttributes(dpy
, wwin
->frame
->core
->window
,
1676 CWSaveUnder
, &attr
);
1680 initMoveData(wwin
, &moveData
);
1682 moveData
.mouseX
= ev
->xmotion
.x_root
;
1683 moveData
.mouseY
= ev
->xmotion
.y_root
;
1685 if (!wwin
->flags
.selected
) {
1686 /* this window is not selected, unselect others and move only wwin */
1687 wUnselectWindows(scr
);
1690 puts("Moving window");
1692 shiftl
= XKeysymToKeycode(dpy
, XK_Shift_L
);
1693 shiftr
= XKeysymToKeycode(dpy
, XK_Shift_R
);
1699 /* XWarpPointer() doesn't seem to generate Motion events, so
1700 * we've got to simulate them */
1701 XQueryPointer(dpy
, root
, &junkw
, &junkw
, &event
.xmotion
.x_root
,
1702 &event
.xmotion
.y_root
, &junk
, &junk
,
1703 (unsigned *) &junk
);
1705 WMMaskEvent(dpy
, KeyPressMask
| ButtonMotionMask
1706 | PointerMotionHintMask
1707 | ButtonReleaseMask
| ButtonPressMask
| ExposureMask
,
1710 if (event
.type
== MotionNotify
) {
1711 /* compress MotionNotify events */
1712 while (XCheckMaskEvent(dpy
, ButtonMotionMask
, &event
)) ;
1713 if (!checkMouseSamplingRate(&event
))
1717 switch (event
.type
) {
1719 if ((event
.xkey
.keycode
== shiftl
|| event
.xkey
.keycode
== shiftr
)
1720 && started
&& !scr
->selected_windows
) {
1723 drawFrames(wwin
, scr
->selected_windows
,
1724 moveData
.realX
- wwin
->frame_x
,
1725 moveData
.realY
- wwin
->frame_y
);
1728 if (wPreferences
.move_display
== WDIS_NEW
1729 && !scr
->selected_windows
) {
1730 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1733 cyclePositionDisplay(wwin
, moveData
.realX
, moveData
.realY
,
1734 moveData
.winWidth
, moveData
.winHeight
);
1736 if (wPreferences
.move_display
== WDIS_NEW
1737 && !scr
->selected_windows
) {
1739 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1743 drawFrames(wwin
, scr
->selected_windows
,
1744 moveData
.realX
- wwin
->frame_x
,
1745 moveData
.realY
- wwin
->frame_y
);
1748 WMHandleEvent(&event); this causes problems needs fixing */
1754 updateWindowPosition(wwin
, &moveData
,
1755 scr
->selected_windows
== NULL
1756 && wPreferences
.edge_resistance
> 0,
1758 event
.xmotion
.x_root
,
1759 event
.xmotion
.y_root
);
1761 if (!warped
&& !wPreferences
.no_autowrap
) {
1762 int oldWorkspace
= scr
->current_workspace
;
1764 if (wPreferences
.move_display
== WDIS_NEW
1765 && !scr
->selected_windows
) {
1766 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1770 drawFrames(wwin
, scr
->selected_windows
,
1771 moveData
.realX
- wwin
->frame_x
,
1772 moveData
.realY
- wwin
->frame_y
);
1774 if (checkWorkspaceChange(wwin
, &moveData
, opaqueMove
)) {
1775 if (scr
->current_workspace
!= oldWorkspace
1776 && wPreferences
.edge_resistance
> 0
1777 && scr
->selected_windows
== NULL
)
1778 updateMoveData(wwin
, &moveData
);
1782 drawFrames(wwin
, scr
->selected_windows
,
1783 moveData
.realX
- wwin
->frame_x
,
1784 moveData
.realY
- wwin
->frame_y
);
1786 if (wPreferences
.move_display
== WDIS_NEW
1787 && !scr
->selected_windows
) {
1789 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1795 } else if (abs(ev
->xmotion
.x_root
- event
.xmotion
.x_root
) >= MOVE_THRESHOLD
1796 || abs(ev
->xmotion
.y_root
- event
.xmotion
.y_root
) >= MOVE_THRESHOLD
) {
1798 XChangeActivePointerGrab(dpy
, ButtonMotionMask
1799 | ButtonReleaseMask
| ButtonPressMask
,
1800 wCursor
[WCUR_MOVE
], CurrentTime
);
1802 XGrabKeyboard(dpy
, root
, False
, GrabModeAsync
, GrabModeAsync
,
1805 if (!scr
->selected_windows
)
1806 mapPositionDisplay(wwin
, moveData
.realX
, moveData
.realY
,
1807 moveData
.winWidth
, moveData
.winHeight
);
1809 if (started
&& !opaqueMove
)
1810 drawFrames(wwin
, scr
->selected_windows
, 0, 0);
1812 if (!opaqueMove
|| (wPreferences
.move_display
==WDIS_NEW
1813 && !scr
->selected_windows
)) {
1815 if (wPreferences
.move_display
==WDIS_NEW
)
1816 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1825 if (event
.xbutton
.button
!= ev
->xbutton
.button
)
1831 drawFrames(wwin
, scr
->selected_windows
,
1832 moveData
.realX
- wwin
->frame_x
,
1833 moveData
.realY
- wwin
->frame_y
);
1835 doWindowMove(wwin
, scr
->selected_windows
,
1836 moveData
.realX
- wwin
->frame_x
,
1837 moveData
.realY
- wwin
->frame_y
);
1839 #ifndef CONFIGURE_WINDOW_WHILE_MOVING
1840 wWindowSynthConfigureNotify(wwin
);
1842 XUngrabKeyboard(dpy
, CurrentTime
);
1845 wWindowChangeWorkspace(wwin
, scr
->current_workspace
);
1846 wSetFocusTo(scr
, wwin
);
1848 if (wPreferences
.move_display
== WDIS_NEW
)
1849 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1851 /* discard all enter/leave events that happened until
1852 * the time the button was released */
1853 while (XCheckTypedEvent(dpy
, EnterNotify
, &e
)) {
1854 if (e
.xcrossing
.time
> event
.xbutton
.time
) {
1855 XPutBackEvent(dpy
, &e
);
1859 while (XCheckTypedEvent(dpy
, LeaveNotify
, &e
)) {
1860 if (e
.xcrossing
.time
> event
.xbutton
.time
) {
1861 XPutBackEvent(dpy
, &e
);
1866 if (!scr
->selected_windows
) {
1867 /* get rid of the geometry window */
1868 WMUnmapWidget(scr
->gview
);
1872 puts("End move window");
1878 if (started
&& !opaqueMove
) {
1879 drawFrames(wwin
, scr
->selected_windows
,
1880 moveData
.realX
- wwin
->frame_x
,
1881 moveData
.realY
- wwin
->frame_y
);
1883 WMHandleEvent(&event
);
1886 drawFrames(wwin
, scr
->selected_windows
,
1887 moveData
.realX
- wwin
->frame_x
,
1888 moveData
.realY
- wwin
->frame_y
);
1890 WMHandleEvent(&event
);
1896 if (wPreferences
.opaque_move
&& !wPreferences
.use_saveunders
) {
1897 XSetWindowAttributes attr
;
1900 attr
.save_under
= False
;
1901 XChangeWindowAttributes(dpy
, wwin
->frame
->core
->window
,
1902 CWSaveUnder
, &attr
);
1906 freeMoveData(&moveData
);
1913 #define HCONSTRAIN 2
1916 getResizeDirection(WWindow
*wwin
, int x
, int y
, int dx
, int dy
,
1919 int w
= wwin
->frame
->core
->width
- 1;
1920 int cw
= wwin
->frame
->resizebar_corner_width
;
1923 /* if not resizing through the resizebar */
1924 if (!(flags
& RESIZEBAR
)) {
1925 int xdir
= (abs(x
) < (wwin
->client
.width
/2)) ? LEFT
: RIGHT
;
1926 int ydir
= (abs(y
) < (wwin
->client
.height
/2)) ? UP
: DOWN
;
1927 if (abs(dx
) < 2 || abs(dy
) < 2) {
1928 if (abs(dy
) > abs(dx
))
1933 return (xdir
| ydir
);
1936 /* window is too narrow. allow diagonal resize */
1940 if (flags
& HCONSTRAIN
)
1945 return (LEFT
| ydir
);
1947 return (RIGHT
| ydir
);
1949 /* vertical resize */
1950 if ((x
> cw
) && (x
< w
- cw
))
1958 if ((abs(dy
) > 0) && !(flags
& HCONSTRAIN
))
1966 wMouseResizeWindow(WWindow
*wwin
, XEvent
*ev
)
1969 WScreen
*scr
= wwin
->screen_ptr
;
1970 Window root
= scr
->root_win
;
1971 int vert_border
= wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
;
1972 int fw
= wwin
->frame
->core
->width
;
1973 int fh
= wwin
->frame
->core
->height
;
1974 int fx
= wwin
->frame_x
;
1975 int fy
= wwin
->frame_y
;
1976 int is_resizebar
= (wwin
->frame
->resizebar
1977 && ev
->xany
.window
==wwin
->frame
->resizebar
->window
);
1981 int rw
= fw
, rh
= fh
;
1982 int rx1
, ry1
, rx2
, ry2
;
1984 KeyCode shiftl
, shiftr
;
1991 if (wwin
->flags
.shaded
) {
1992 wwarning("internal error: tryein");
1995 orig_x
= ev
->xbutton
.x_root
;
1996 orig_y
= ev
->xbutton
.y_root
;
2000 puts("Resizing window");
2003 wUnselectWindows(scr
);
2008 shiftl
= XKeysymToKeycode(dpy
, XK_Shift_L
);
2009 shiftr
= XKeysymToKeycode(dpy
, XK_Shift_R
);
2010 if (!WFLAGP(wwin
, no_titlebar
))
2011 h
= WMFontHeight(wwin
->screen_ptr
->title_font
) + (wPreferences
.window_title_clearance
+ TITLEBAR_EXTEND_SPACE
) * 2;
2015 WMMaskEvent(dpy
, KeyPressMask
| ButtonMotionMask
2016 | ButtonReleaseMask
| PointerMotionHintMask
2017 | ButtonPressMask
| ExposureMask
, &event
);
2018 if (!checkMouseSamplingRate(&event
))
2021 switch (event
.type
) {
2023 showGeometry(wwin
, fx
, fy
, fx
+ fw
, fy
+ fh
, res
);
2024 if ((event
.xkey
.keycode
== shiftl
|| event
.xkey
.keycode
== shiftr
)
2026 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2027 cycleGeometryDisplay(wwin
, fx
, fy
, fw
, fh
, res
);
2028 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2030 showGeometry(wwin
, fx
, fy
, fx
+ fw
, fy
+ fh
, res
);
2035 while (XCheckMaskEvent(dpy
, ButtonMotionMask
, &event
)) ;
2046 dw
= orig_x
- event
.xmotion
.x_root
;
2047 else if (res
& RIGHT
)
2048 dw
= event
.xmotion
.x_root
- orig_x
;
2050 dh
= orig_y
- event
.xmotion
.y_root
;
2051 else if (res
& DOWN
)
2052 dh
= event
.xmotion
.y_root
- orig_y
;
2054 orig_x
= event
.xmotion
.x_root
;
2055 orig_y
= event
.xmotion
.y_root
;
2060 fh
= rh
- vert_border
;
2061 wWindowConstrainSize(wwin
, &fw
, &fh
);
2065 else if (res
& RIGHT
)
2069 else if (res
& DOWN
)
2071 } else if (abs(orig_x
- event
.xmotion
.x_root
) >= MOVE_THRESHOLD
2072 || abs(orig_y
- event
.xmotion
.y_root
) >= MOVE_THRESHOLD
) {
2077 XTranslateCoordinates(dpy
, root
, wwin
->frame
->core
->window
,
2078 orig_x
, orig_y
, &tx
, &ty
, &junkw
);
2080 /* check if resizing through resizebar */
2086 if (is_resizebar
&& ((ev
->xbutton
.state
& ShiftMask
)
2087 || abs(orig_y
- event
.xmotion
.y_root
) < HRESIZE_THRESHOLD
))
2088 flags
|= HCONSTRAIN
;
2090 res
= getResizeDirection(wwin
, tx
, ty
,
2091 orig_x
- event
.xmotion
.x_root
,
2092 orig_y
- event
.xmotion
.y_root
, flags
);
2094 if (res
== (UP
|LEFT
))
2095 XChangeActivePointerGrab(dpy
, ButtonMotionMask
2096 | ButtonReleaseMask
| ButtonPressMask
,
2097 wCursor
[WCUR_TOPLEFTRESIZE
], CurrentTime
);
2098 else if (res
== (UP
|RIGHT
))
2099 XChangeActivePointerGrab(dpy
, ButtonMotionMask
2100 | ButtonReleaseMask
| ButtonPressMask
,
2101 wCursor
[WCUR_TOPRIGHTRESIZE
], CurrentTime
);
2102 else if (res
== (DOWN
|LEFT
))
2103 XChangeActivePointerGrab(dpy
, ButtonMotionMask
2104 | ButtonReleaseMask
| ButtonPressMask
,
2105 wCursor
[WCUR_BOTTOMLEFTRESIZE
], CurrentTime
);
2106 else if (res
== (DOWN
|RIGHT
))
2107 XChangeActivePointerGrab(dpy
, ButtonMotionMask
2108 | ButtonReleaseMask
| ButtonPressMask
,
2109 wCursor
[WCUR_BOTTOMRIGHTRESIZE
], CurrentTime
);
2110 else if (res
== DOWN
|| res
== UP
)
2111 XChangeActivePointerGrab(dpy
, ButtonMotionMask
2112 | ButtonReleaseMask
| ButtonPressMask
,
2113 wCursor
[WCUR_VERTICALRESIZE
], CurrentTime
);
2114 else if (res
& (DOWN
|UP
))
2115 XChangeActivePointerGrab(dpy
, ButtonMotionMask
2116 | ButtonReleaseMask
| ButtonPressMask
,
2117 wCursor
[WCUR_VERTICALRESIZE
], CurrentTime
);
2118 else if (res
& (LEFT
|RIGHT
))
2119 XChangeActivePointerGrab(dpy
, ButtonMotionMask
2120 | ButtonReleaseMask
| ButtonPressMask
,
2121 wCursor
[WCUR_HORIZONRESIZE
], CurrentTime
);
2123 XGrabKeyboard(dpy
, root
, False
, GrabModeAsync
, GrabModeAsync
,
2128 /* Draw the resize frame for the first time. */
2129 mapGeometryDisplay(wwin
, fx
, fy
, fw
, fh
);
2131 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2133 showGeometry(wwin
, fx
, fy
, fx
+ fw
, fy
+ fh
, res
);
2138 if (wPreferences
.size_display
== WDIS_FRAME_CENTER
) {
2139 drawTransparentFrame(wwin
, orig_fx
, orig_fy
,
2141 moveGeometryDisplayCentered(scr
, fx
+ fw
/ 2, fy
+ fh
/ 2);
2142 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2144 drawTransparentFrame(wwin
, orig_fx
, orig_fy
,
2146 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2148 if (fh
!= orig_fh
|| fw
!= orig_fw
) {
2149 if (wPreferences
.size_display
== WDIS_NEW
) {
2150 showGeometry(wwin
, orig_fx
, orig_fy
, orig_fx
+ orig_fw
,
2151 orig_fy
+ orig_fh
, res
);
2153 showGeometry(wwin
, fx
, fy
, fx
+ fw
, fy
+ fh
, res
);
2162 if (event
.xbutton
.button
!= ev
->xbutton
.button
)
2166 showGeometry(wwin
, fx
, fy
, fx
+ fw
, fy
+ fh
, res
);
2168 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2170 XUngrabKeyboard(dpy
, CurrentTime
);
2171 WMUnmapWidget(scr
->gview
);
2174 if (wwin
->client
.width
!= fw
)
2175 wwin
->flags
.user_changed_width
= 1;
2177 if (wwin
->client
.height
!= fh
- vert_border
)
2178 wwin
->flags
.user_changed_height
= 1;
2180 wWindowConfigure(wwin
, fx
, fy
, fw
, fh
- vert_border
);
2183 puts("End resize window");
2188 WMHandleEvent(&event
);
2203 wUnselectWindows(WScreen
*scr
)
2207 if (!scr
->selected_windows
)
2210 while (WMGetArrayItemCount(scr
->selected_windows
)) {
2211 wwin
= WMGetFromArray(scr
->selected_windows
, 0);
2212 if (wwin
->flags
.miniaturized
&& wwin
->icon
&& wwin
->icon
->selected
)
2213 wIconSelect(wwin
->icon
);
2215 wSelectWindow(wwin
, False
);
2217 WMFreeArray(scr
->selected_windows
);
2218 scr
->selected_windows
= NULL
;
2223 selectWindowsInside(WScreen
*scr
, int x1
, int y1
, int x2
, int y2
)
2227 /* select the windows and put them in the selected window list */
2228 tmpw
= scr
->focused_window
;
2229 while (tmpw
!= NULL
) {
2230 if (!(tmpw
->flags
.miniaturized
|| tmpw
->flags
.hidden
)) {
2231 if ((tmpw
->frame
->workspace
== scr
->current_workspace
2232 || IS_OMNIPRESENT(tmpw
))
2233 && (tmpw
->frame_x
>= x1
) && (tmpw
->frame_y
>= y1
)
2234 && (tmpw
->frame
->core
->width
+ tmpw
->frame_x
<= x2
)
2235 && (tmpw
->frame
->core
->height
+ tmpw
->frame_y
<= y2
)) {
2236 wSelectWindow(tmpw
, True
);
2245 wSelectWindows(WScreen
*scr
, XEvent
*ev
)
2248 Window root
= scr
->root_win
;
2249 GC gc
= scr
->frame_gc
;
2250 int xp
= ev
->xbutton
.x_root
;
2251 int yp
= ev
->xbutton
.y_root
;
2256 puts("Selecting windows");
2258 if (XGrabPointer(dpy
, scr
->root_win
, False
, ButtonMotionMask
2259 | ButtonReleaseMask
| ButtonPressMask
, GrabModeAsync
,
2260 GrabModeAsync
, None
, wCursor
[WCUR_DEFAULT
],
2261 CurrentTime
) != Success
) {
2266 wUnselectWindows(scr
);
2268 XDrawRectangle(dpy
, root
, gc
, xp
, yp
, w
, h
);
2270 WMMaskEvent(dpy
, ButtonReleaseMask
| PointerMotionMask
2271 | ButtonPressMask
, &event
);
2273 switch (event
.type
) {
2275 XDrawRectangle(dpy
, root
, gc
, x
, y
, w
, h
);
2276 x
= event
.xmotion
.x_root
;
2283 y
= event
.xmotion
.y_root
;
2290 XDrawRectangle(dpy
, root
, gc
, x
, y
, w
, h
);
2297 if (event
.xbutton
.button
!= ev
->xbutton
.button
)
2300 XDrawRectangle(dpy
, root
, gc
, x
, y
, w
, h
);
2302 XUngrabPointer(dpy
, CurrentTime
);
2303 selectWindowsInside(scr
, x
, y
, x
+ w
, y
+ h
);
2306 wKWMSelectRootRegion(scr
, xp
, yp
, w
, h
,
2307 event
.xbutton
.state
& ControlMask
);
2308 #endif /* KWM_HINTS */
2311 puts("End window selection");
2316 WMHandleEvent(&event
);
2324 InteractivePlaceWindow(WWindow
*wwin
, int *x_ret
, int *y_ret
,
2325 unsigned width
, unsigned height
)
2327 WScreen
*scr
= wwin
->screen_ptr
;
2328 Window root
= scr
->root_win
;
2331 KeyCode shiftl
, shiftr
;
2335 if (XGrabPointer(dpy
, root
, True
, PointerMotionMask
| ButtonPressMask
,
2336 GrabModeAsync
, GrabModeAsync
, None
,
2337 wCursor
[WCUR_DEFAULT
], CurrentTime
) != Success
) {
2342 if (!WFLAGP(wwin
, no_titlebar
)) {
2343 h
= WMFontHeight(scr
->title_font
) + (wPreferences
.window_title_clearance
+ TITLEBAR_EXTEND_SPACE
) * 2;
2346 if (!WFLAGP(wwin
, no_resizebar
)) {
2347 height
+= RESIZEBAR_HEIGHT
;
2349 XGrabKeyboard(dpy
, root
, False
, GrabModeAsync
, GrabModeAsync
, CurrentTime
);
2350 XQueryPointer(dpy
, root
, &junkw
, &junkw
, &x
, &y
, &junk
, &junk
,
2351 (unsigned *) &junk
);
2352 mapPositionDisplay(wwin
, x
- width
/2, y
- h
/2, width
, height
);
2354 drawTransparentFrame(wwin
, x
- width
/2, y
- h
/2, width
, height
);
2356 shiftl
= XKeysymToKeycode(dpy
, XK_Shift_L
);
2357 shiftr
= XKeysymToKeycode(dpy
, XK_Shift_R
);
2359 WMMaskEvent(dpy
, PointerMotionMask
|ButtonPressMask
|ExposureMask
|KeyPressMask
,
2362 if (!checkMouseSamplingRate(&event
))
2365 switch (event
.type
) {
2367 if ((event
.xkey
.keycode
== shiftl
)
2368 || (event
.xkey
.keycode
== shiftr
)) {
2369 drawTransparentFrame(wwin
,
2370 x
- width
/2, y
- h
/2, width
, height
);
2371 cyclePositionDisplay(wwin
,
2372 x
- width
/2, y
- h
/2, width
, height
);
2373 drawTransparentFrame(wwin
,
2374 x
- width
/2, y
- h
/2, width
, height
);
2379 drawTransparentFrame(wwin
, x
- width
/2, y
- h
/2, width
, height
);
2381 x
= event
.xmotion
.x_root
;
2382 y
= event
.xmotion
.y_root
;
2384 if (wPreferences
.move_display
== WDIS_FRAME_CENTER
)
2385 moveGeometryDisplayCentered(scr
, x
, y
+ (height
- h
) / 2);
2387 showPosition(wwin
, x
- width
/2, y
- h
/2);
2389 drawTransparentFrame(wwin
, x
- width
/2, y
- h
/2, width
, height
);
2394 drawTransparentFrame(wwin
, x
- width
/2, y
- h
/2, width
, height
);
2396 *x_ret
= x
- width
/2;
2398 XUngrabPointer(dpy
, CurrentTime
);
2399 XUngrabKeyboard(dpy
, CurrentTime
);
2400 /* get rid of the geometry window */
2401 WMUnmapWidget(scr
->gview
);
2405 WMHandleEvent(&event
);