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"
40 #include "workspace.h"
46 #include <WINGs/WINGsP.h>
48 /* How many different types of geometry/position
49 display thingies are there? */
50 #define NUM_DISPLAYS 5
54 #define HORIZONTAL (LEFT|RIGHT)
57 #define VERTICAL (UP|DOWN)
59 /* True if window currently has a border. This also includes borderless
60 * windows which are currently selected
62 #define HAS_BORDER_WITH_SELECT(w) ((w)->flags.selected || HAS_BORDER(w))
64 /****** Global Variables ******/
65 extern Cursor wCursor
[WCUR_LAST
];
66 extern WPreferences wPreferences
;
69 *----------------------------------------------------------------------
70 * checkMouseSamplingRate-
71 * For lowering the mouse motion sampling rate for machines where
72 * it's too high (SGIs). If it returns False then the event should be
74 *----------------------------------------------------------------------
76 static Bool
checkMouseSamplingRate(XEvent
* ev
)
78 static Time previousMotion
= 0;
80 if (ev
->type
== MotionNotify
) {
81 if (ev
->xmotion
.time
- previousMotion
< DELAY_BETWEEN_MOUSE_SAMPLING
) {
84 previousMotion
= ev
->xmotion
.time
;
91 *----------------------------------------------------------------------
92 * moveGeometryDisplayCentered
94 * routine that moves the geometry/position window on scr so it is
95 * centered over the given coordinates (x,y). Also the window position
96 * is clamped so it stays on the screen at all times.
97 *----------------------------------------------------------------------
99 static void moveGeometryDisplayCentered(WScreen
* scr
, int x
, int y
)
101 unsigned int w
= WMWidgetWidth(scr
->gview
);
102 unsigned int h
= WMWidgetHeight(scr
->gview
);
103 int x1
= 0, y1
= 0, x2
= scr
->scr_width
, y2
= scr
->scr_height
;
108 /* dead area check */
109 if (scr
->xine_info
.count
) {
116 rect
.size
.height
= h
;
118 head
= wGetRectPlacementInfo(scr
, rect
, &flags
);
120 if (flags
& (XFLAG_DEAD
| XFLAG_PARTIAL
)) {
121 rect
= wGetRectForHead(scr
, head
);
124 x2
= x1
+ rect
.size
.width
;
125 y2
= y1
+ rect
.size
.height
;
131 else if (x
> (x2
- w
))
136 else if (y
> (y2
- h
))
139 WMMoveWidget(scr
->gview
, x
, y
);
142 static void showPosition(WWindow
* wwin
, int x
, int y
)
144 WScreen
*scr
= wwin
->screen_ptr
;
146 if (wPreferences
.move_display
== WDIS_NEW
) {
148 int width
= wwin
->frame
->core
->width
;
149 int height
= wwin
->frame
->core
->height
;
151 GC lgc
= scr
->line_gc
;
152 XSetForeground(dpy
, lgc
, scr
->line_pixel
);
153 sprintf(num
, "%i", x
);
155 XDrawLine(dpy
, scr
->root_win
, lgc
, 0, y
- 1, scr
->scr_width
, y
- 1);
156 XDrawLine(dpy
, scr
->root_win
, lgc
, 0, y
+ height
+ 2, scr
->scr_width
, y
+ height
+ 2);
157 XDrawLine(dpy
, scr
->root_win
, lgc
, x
- 1, 0, x
- 1, scr
->scr_height
);
158 XDrawLine(dpy
, scr
->root_win
, lgc
, x
+ width
+ 2, 0, x
+ width
+ 2, scr
->scr_height
);
161 WSetGeometryViewShownPosition(scr
->gview
, x
, y
);
165 static void cyclePositionDisplay(WWindow
* wwin
, int x
, int y
, int w
, int h
)
167 WScreen
*scr
= wwin
->screen_ptr
;
170 wPreferences
.move_display
++;
171 wPreferences
.move_display
%= NUM_DISPLAYS
;
173 if (wPreferences
.move_display
== WDIS_NEW
) {
174 wPreferences
.move_display
++;
175 wPreferences
.move_display
%= NUM_DISPLAYS
;
178 if (wPreferences
.move_display
== WDIS_NONE
) {
179 WMUnmapWidget(scr
->gview
);
181 if (wPreferences
.move_display
== WDIS_CENTER
) {
182 rect
= wGetRectForHead(scr
, wGetHeadForWindow(wwin
));
183 moveGeometryDisplayCentered(scr
, rect
.pos
.x
+ rect
.size
.width
/ 2,
184 rect
.pos
.y
+ rect
.size
.height
/ 2);
185 } else if (wPreferences
.move_display
== WDIS_TOPLEFT
) {
186 rect
= wGetRectForHead(scr
, wGetHeadForWindow(wwin
));
187 moveGeometryDisplayCentered(scr
, rect
.pos
.x
+ 1, rect
.pos
.y
+ 1);
188 } else if (wPreferences
.move_display
== WDIS_FRAME_CENTER
) {
189 moveGeometryDisplayCentered(scr
, x
+ w
/ 2, y
+ h
/ 2);
191 WMMapWidget(scr
->gview
);
195 static void mapPositionDisplay(WWindow
* wwin
, int x
, int y
, int w
, int h
)
197 WScreen
*scr
= wwin
->screen_ptr
;
200 if (wPreferences
.move_display
== WDIS_NEW
|| wPreferences
.move_display
== WDIS_NONE
) {
202 } else if (wPreferences
.move_display
== WDIS_CENTER
) {
203 rect
= wGetRectForHead(scr
, wGetHeadForWindow(wwin
));
204 moveGeometryDisplayCentered(scr
, rect
.pos
.x
+ rect
.size
.width
/ 2,
205 rect
.pos
.y
+ rect
.size
.height
/ 2);
206 } else if (wPreferences
.move_display
== WDIS_TOPLEFT
) {
207 rect
= wGetRectForHead(scr
, wGetHeadForWindow(wwin
));
208 moveGeometryDisplayCentered(scr
, rect
.pos
.x
+ 1, rect
.pos
.y
+ 1);
209 } else if (wPreferences
.move_display
== WDIS_FRAME_CENTER
) {
210 moveGeometryDisplayCentered(scr
, x
+ w
/ 2, y
+ h
/ 2);
212 WMMapWidget(scr
->gview
);
213 WSetGeometryViewShownPosition(scr
->gview
, x
, y
);
216 static void showGeometry(WWindow
* wwin
, int x1
, int y1
, int x2
, int y2
, int direction
)
218 WScreen
*scr
= wwin
->screen_ptr
;
219 Window root
= scr
->root_win
;
220 GC gc
= scr
->line_gc
;
221 int ty
, by
, my
, x
, y
, mx
, s
;
226 /* This seems necessary for some odd reason (too lazy to write x1-1 and
227 * x2-1 everywhere below in the code). But why only for x? */
231 if (HAS_BORDER_WITH_SELECT(wwin
)) {
232 x1
+= FRAME_BORDER_WIDTH
;
233 x2
+= FRAME_BORDER_WIDTH
;
234 y1
+= FRAME_BORDER_WIDTH
;
235 y2
+= FRAME_BORDER_WIDTH
;
238 ty
= y1
+ wwin
->frame
->top_width
;
239 by
= y2
- wwin
->frame
->bottom_width
;
241 if (wPreferences
.size_display
== WDIS_NEW
) {
242 fw
= XTextWidth(scr
->tech_draw_font
, "8888", 4);
243 fh
= scr
->tech_draw_font
->ascent
+ scr
->tech_draw_font
->descent
;
245 XSetForeground(dpy
, gc
, scr
->line_pixel
);
247 /* vertical geometry */
248 if (((direction
& LEFT
) && (x2
< scr
->scr_width
- fw
)) || (x1
< fw
)) {
257 /* top arrow & end bar */
258 segment
[0].x1
= x
- (s
+ 6);
260 segment
[0].x2
= x
- (s
- 10);
264 segment
[1].x1
= x
- (s
- 2);
265 segment
[1].y1
= ty
+ 1;
266 segment
[1].x2
= x
- (s
- 5);
267 segment
[1].y2
= ty
+ 7;
269 segment
[2].x1
= x
- (s
- 2);
270 segment
[2].y1
= ty
+ 1;
271 segment
[2].x2
= x
- (s
+ 1);
272 segment
[2].y2
= ty
+ 7;
275 segment
[3].x1
= x
- (s
- 2);
276 segment
[3].y1
= ty
+ 1;
277 segment
[3].x2
= x
- (s
- 2);
278 segment
[3].y2
= my
- fh
/ 2 - 1;
280 XDrawSegments(dpy
, root
, gc
, segment
, 4);
282 /* bottom arrow & end bar */
287 segment
[1].y1
= by
- 1;
288 segment
[1].y2
= by
- 7;
290 segment
[2].y1
= by
- 1;
291 segment
[2].y2
= by
- 7;
294 segment
[3].y1
= my
+ fh
/ 2 + 2;
295 segment
[3].y2
= by
- 1;
297 XDrawSegments(dpy
, root
, gc
, segment
, 4);
299 snprintf(num
, sizeof(num
), "%i", (by
- ty
- wwin
->normal_hints
->base_height
) /
300 wwin
->normal_hints
->height_inc
);
301 fw
= XTextWidth(scr
->tech_draw_font
, num
, strlen(num
));
303 /* Display the height. */
304 XSetFont(dpy
, gc
, scr
->tech_draw_font
->fid
);
305 XDrawString(dpy
, root
, gc
, x
- s
+ 3 - fw
/ 2, my
+ scr
->tech_draw_font
->ascent
- fh
/ 2 + 1, num
,
308 /* horizontal geometry */
316 mx
= x1
+ (x2
- x1
) / 2;
317 snprintf(num
, sizeof(num
), "%i", (x2
- x1
- wwin
->normal_hints
->base_width
) /
318 wwin
->normal_hints
->width_inc
);
319 fw
= XTextWidth(scr
->tech_draw_font
, num
, strlen(num
));
321 /* left arrow & end bar */
323 segment
[0].y1
= y
- (s
+ 6);
325 segment
[0].y2
= y
- (s
- 10);
328 segment
[1].x1
= x1
+ 7;
329 segment
[1].y1
= y
- (s
+ 1);
330 segment
[1].x2
= x1
+ 1;
331 segment
[1].y2
= y
- (s
- 2);
333 segment
[2].x1
= x1
+ 1;
334 segment
[2].y1
= y
- (s
- 2);
335 segment
[2].x2
= x1
+ 7;
336 segment
[2].y2
= y
- (s
- 5);
339 segment
[3].x1
= x1
+ 1;
340 segment
[3].y1
= y
- (s
- 2);
341 segment
[3].x2
= mx
- fw
/ 2 - 2;
342 segment
[3].y2
= y
- (s
- 2);
344 XDrawSegments(dpy
, root
, gc
, segment
, 4);
346 /* right arrow & end bar */
347 segment
[0].x1
= x2
+ 1;
348 segment
[0].x2
= x2
+ 1;
351 segment
[1].x1
= x2
- 6;
355 segment
[2].x2
= x2
- 6;
358 segment
[3].x1
= mx
+ fw
/ 2 + 2;
361 XDrawSegments(dpy
, root
, gc
, segment
, 4);
363 /* Display the width. */
364 XDrawString(dpy
, root
, gc
, mx
- fw
/ 2 + 1, y
- s
+ scr
->tech_draw_font
->ascent
- fh
/ 2 + 1, num
,
367 WSetGeometryViewShownSize(scr
->gview
, (x2
- x1
- wwin
->normal_hints
->base_width
)
368 / wwin
->normal_hints
->width_inc
,
369 (by
- ty
- wwin
->normal_hints
->base_height
)
370 / wwin
->normal_hints
->height_inc
);
374 static void cycleGeometryDisplay(WWindow
* wwin
, int x
, int y
, int w
, int h
, int dir
)
376 WScreen
*scr
= wwin
->screen_ptr
;
379 wPreferences
.size_display
++;
380 wPreferences
.size_display
%= NUM_DISPLAYS
;
382 if (wPreferences
.size_display
== WDIS_NEW
|| wPreferences
.size_display
== WDIS_NONE
) {
383 WMUnmapWidget(scr
->gview
);
385 if (wPreferences
.size_display
== WDIS_CENTER
) {
386 rect
= wGetRectForHead(scr
, wGetHeadForWindow(wwin
));
387 moveGeometryDisplayCentered(scr
, rect
.pos
.x
+ rect
.size
.width
/ 2,
388 rect
.pos
.y
+ rect
.size
.height
/ 2);
389 } else if (wPreferences
.size_display
== WDIS_TOPLEFT
) {
390 rect
= wGetRectForHead(scr
, wGetHeadForWindow(wwin
));
391 moveGeometryDisplayCentered(scr
, rect
.pos
.x
+ 1, rect
.pos
.y
+ 1);
392 } else if (wPreferences
.size_display
== WDIS_FRAME_CENTER
) {
393 moveGeometryDisplayCentered(scr
, x
+ w
/ 2, y
+ h
/ 2);
395 WMMapWidget(scr
->gview
);
396 showGeometry(wwin
, x
, y
, x
+ w
, y
+ h
, dir
);
400 static void mapGeometryDisplay(WWindow
* wwin
, int x
, int y
, int w
, int h
)
402 WScreen
*scr
= wwin
->screen_ptr
;
405 if (wPreferences
.size_display
== WDIS_NEW
|| wPreferences
.size_display
== WDIS_NONE
)
408 if (wPreferences
.size_display
== WDIS_CENTER
) {
409 rect
= wGetRectForHead(scr
, wGetHeadForWindow(wwin
));
410 moveGeometryDisplayCentered(scr
, rect
.pos
.x
+ rect
.size
.width
/ 2,
411 rect
.pos
.y
+ rect
.size
.height
/ 2);
412 } else if (wPreferences
.size_display
== WDIS_TOPLEFT
) {
413 rect
= wGetRectForHead(scr
, wGetHeadForWindow(wwin
));
414 moveGeometryDisplayCentered(scr
, rect
.pos
.x
+ 1, rect
.pos
.y
+ 1);
415 } else if (wPreferences
.size_display
== WDIS_FRAME_CENTER
) {
416 moveGeometryDisplayCentered(scr
, x
+ w
/ 2, y
+ h
/ 2);
418 WMMapWidget(scr
->gview
);
419 showGeometry(wwin
, x
, y
, x
+ w
, y
+ h
, 0);
422 static void doWindowMove(WWindow
* wwin
, WMArray
* array
, int dx
, int dy
)
425 WScreen
*scr
= wwin
->screen_ptr
;
428 if (!array
|| !WMGetArrayItemCount(array
)) {
429 wWindowMove(wwin
, wwin
->frame_x
+ dx
, wwin
->frame_y
+ dy
);
431 WMArrayIterator iter
;
433 WM_ITERATE_ARRAY(array
, tmpw
, iter
) {
434 x
= tmpw
->frame_x
+ dx
;
435 y
= tmpw
->frame_y
+ dy
;
437 #if 1 /* XXX: with xinerama patch was #if 0, check this */
438 /* don't let windows become unreachable */
440 if (x
+ (int)tmpw
->frame
->core
->width
< 20)
441 x
= 20 - (int)tmpw
->frame
->core
->width
;
442 else if (x
+ 20 > scr
->scr_width
)
443 x
= scr
->scr_width
- 20;
445 if (y
+ (int)tmpw
->frame
->core
->height
< 20)
446 y
= 20 - (int)tmpw
->frame
->core
->height
;
447 else if (y
+ 20 > scr
->scr_height
)
448 y
= scr
->scr_height
- 20;
450 wScreenBringInside(scr
, &x
, &y
,
451 (int)tmpw
->frame
->core
->width
, (int)tmpw
->frame
->core
->height
);
454 wWindowMove(tmpw
, x
, y
);
459 static void drawTransparentFrame(WWindow
* wwin
, int x
, int y
, int width
, int height
)
461 Window root
= wwin
->screen_ptr
->root_win
;
462 GC gc
= wwin
->screen_ptr
->frame_gc
;
466 if (HAS_BORDER_WITH_SELECT(wwin
)) {
467 x
+= FRAME_BORDER_WIDTH
;
468 y
+= FRAME_BORDER_WIDTH
;
471 if (HAS_TITLEBAR(wwin
) && !wwin
->flags
.shaded
) {
472 h
= WMFontHeight(wwin
->screen_ptr
->title_font
) + (wPreferences
.window_title_clearance
+
473 TITLEBAR_EXTEND_SPACE
) * 2;
475 if (HAS_RESIZEBAR(wwin
) && !wwin
->flags
.shaded
) {
476 /* Can't use wwin-frame->bottom_width because, in some cases
477 (e.g. interactive placement), frame does not point to anything. */
478 bottom
= RESIZEBAR_HEIGHT
;
480 XDrawRectangle(dpy
, root
, gc
, x
- 1, y
- 1, width
+ 1, height
+ 1);
483 XDrawLine(dpy
, root
, gc
, x
, y
+ h
- 1, x
+ width
, y
+ h
- 1);
486 XDrawLine(dpy
, root
, gc
, x
, y
+ height
- bottom
, x
+ width
, y
+ height
- bottom
);
490 static void drawFrames(WWindow
* wwin
, WMArray
* array
, int dx
, int dy
)
493 int scr_width
= wwin
->screen_ptr
->scr_width
;
494 int scr_height
= wwin
->screen_ptr
->scr_height
;
499 x
= wwin
->frame_x
+ dx
;
500 y
= wwin
->frame_y
+ dy
;
502 drawTransparentFrame(wwin
, x
, y
, wwin
->frame
->core
->width
, wwin
->frame
->core
->height
);
505 WMArrayIterator iter
;
507 WM_ITERATE_ARRAY(array
, tmpw
, iter
) {
508 x
= tmpw
->frame_x
+ dx
;
509 y
= tmpw
->frame_y
+ dy
;
511 /* don't let windows become unreachable */
512 #if 1 /* XXX: was 0 in XINERAMA patch, check */
513 if (x
+ (int)tmpw
->frame
->core
->width
< 20)
514 x
= 20 - (int)tmpw
->frame
->core
->width
;
515 else if (x
+ 20 > scr_width
)
518 if (y
+ (int)tmpw
->frame
->core
->height
< 20)
519 y
= 20 - (int)tmpw
->frame
->core
->height
;
520 else if (y
+ 20 > scr_height
)
524 wScreenBringInside(wwin
->screen_ptr
, &x
, &y
,
525 (int)tmpw
->frame
->core
->width
, (int)tmpw
->frame
->core
->height
);
528 drawTransparentFrame(tmpw
, x
, y
, tmpw
->frame
->core
->width
, tmpw
->frame
->core
->height
);
533 static void flushMotion()
538 while (XCheckMaskEvent(dpy
, ButtonMotionMask
, &ev
)) ;
541 static void crossWorkspace(WScreen
* scr
, WWindow
* wwin
, int opaque_move
, int new_workspace
, int rewind
)
543 /* do not let window be unmapped */
545 wwin
->flags
.changing_workspace
= 1;
546 wWindowChangeWorkspace(wwin
, new_workspace
);
548 /* go to new workspace */
549 wWorkspaceChange(scr
, new_workspace
);
551 wwin
->flags
.changing_workspace
= 0;
554 XWarpPointer(dpy
, None
, None
, 0, 0, 0, 0, scr
->scr_width
- 20, 0);
556 XWarpPointer(dpy
, None
, None
, 0, 0, 0, 0, -(scr
->scr_width
- 20), 0);
561 XGrabPointer(dpy
, scr
->root_win
, True
, PointerMotionMask
562 | ButtonReleaseMask
| ButtonPressMask
, GrabModeAsync
,
563 GrabModeAsync
, None
, wCursor
[WCUR_MOVE
], CurrentTime
);
568 /* arrays of WWindows sorted by the respective border position */
569 WWindow
**topList
; /* top border */
570 WWindow
**leftList
; /* left border */
571 WWindow
**rightList
; /* right border */
572 WWindow
**bottomList
; /* bottom border */
575 /* index of window in the above lists indicating the relative position
576 * of the window with the others */
582 int rubCount
; /* for workspace switching */
584 int winWidth
, winHeight
; /* width/height of the window */
585 int realX
, realY
; /* actual position of the window */
586 int calcX
, calcY
; /* calculated position of window */
587 int omouseX
, omouseY
; /* old mouse position */
588 int mouseX
, mouseY
; /* last known position of the pointer */
591 #define WTOP(w) (w)->frame_y
592 #define WLEFT(w) (w)->frame_x
593 #define WRIGHT(w) ((w)->frame_x + (int)(w)->frame->core->width - 1 + \
594 (HAS_BORDER_WITH_SELECT(w) ? 2*FRAME_BORDER_WIDTH : 0))
595 #define WBOTTOM(w) ((w)->frame_y + (int)(w)->frame->core->height - 1 + \
596 (HAS_BORDER_WITH_SELECT(w) ? 2*FRAME_BORDER_WIDTH : 0))
598 static int compareWTop(const void *a
, const void *b
)
600 WWindow
*wwin1
= *(WWindow
**) a
;
601 WWindow
*wwin2
= *(WWindow
**) b
;
603 if (WTOP(wwin1
) > WTOP(wwin2
))
605 else if (WTOP(wwin1
) < WTOP(wwin2
))
611 static int compareWLeft(const void *a
, const void *b
)
613 WWindow
*wwin1
= *(WWindow
**) a
;
614 WWindow
*wwin2
= *(WWindow
**) b
;
616 if (WLEFT(wwin1
) > WLEFT(wwin2
))
618 else if (WLEFT(wwin1
) < WLEFT(wwin2
))
624 static int compareWRight(const void *a
, const void *b
)
626 WWindow
*wwin1
= *(WWindow
**) a
;
627 WWindow
*wwin2
= *(WWindow
**) b
;
629 if (WRIGHT(wwin1
) < WRIGHT(wwin2
))
631 else if (WRIGHT(wwin1
) > WRIGHT(wwin2
))
637 static int compareWBottom(const void *a
, const void *b
)
639 WWindow
*wwin1
= *(WWindow
**) a
;
640 WWindow
*wwin2
= *(WWindow
**) b
;
642 if (WBOTTOM(wwin1
) < WBOTTOM(wwin2
))
644 else if (WBOTTOM(wwin1
) > WBOTTOM(wwin2
))
650 static void updateResistance(WWindow
* wwin
, MoveData
* data
, int newX
, int newY
)
653 int newX2
= newX
+ data
->winWidth
;
654 int newY2
= newY
+ data
->winHeight
;
657 if (newX
< data
->realX
) {
658 if (data
->rightIndex
> 0 && newX
< WRIGHT(data
->rightList
[data
->rightIndex
- 1])) {
660 } else if (data
->leftIndex
<= data
->count
- 1 && newX2
<= WLEFT(data
->leftList
[data
->leftIndex
])) {
663 } else if (newX
> data
->realX
) {
664 if (data
->leftIndex
> 0 && newX2
> WLEFT(data
->leftList
[data
->leftIndex
- 1])) {
666 } else if (data
->rightIndex
<= data
->count
- 1
667 && newX
>= WRIGHT(data
->rightList
[data
->rightIndex
])) {
673 if (newY
< data
->realY
) {
674 if (data
->bottomIndex
> 0 && newY
< WBOTTOM(data
->bottomList
[data
->bottomIndex
- 1])) {
676 } else if (data
->topIndex
<= data
->count
- 1
677 && newY2
<= WTOP(data
->topList
[data
->topIndex
])) {
680 } else if (newY
> data
->realY
) {
681 if (data
->topIndex
> 0 && newY2
> WTOP(data
->topList
[data
->topIndex
- 1])) {
683 } else if (data
->bottomIndex
<= data
->count
- 1
684 && newY
>= WBOTTOM(data
->bottomList
[data
->bottomIndex
])) {
693 /* TODO: optimize this */
694 if (data
->realY
< WBOTTOM(data
->bottomList
[0])) {
695 data
->bottomIndex
= 0;
697 if (data
->realX
< WRIGHT(data
->rightList
[0])) {
698 data
->rightIndex
= 0;
700 if ((data
->realX
+ data
->winWidth
) > WLEFT(data
->leftList
[0])) {
703 if ((data
->realY
+ data
->winHeight
) > WTOP(data
->topList
[0])) {
706 for (i
= 0; i
< data
->count
; i
++) {
707 if (data
->realY
> WBOTTOM(data
->bottomList
[i
])) {
708 data
->bottomIndex
= i
+ 1;
710 if (data
->realX
> WRIGHT(data
->rightList
[i
])) {
711 data
->rightIndex
= i
+ 1;
713 if ((data
->realX
+ data
->winWidth
) < WLEFT(data
->leftList
[i
])) {
714 data
->leftIndex
= i
+ 1;
716 if ((data
->realY
+ data
->winHeight
) < WTOP(data
->topList
[i
])) {
717 data
->topIndex
= i
+ 1;
722 static void freeMoveData(MoveData
* data
)
725 wfree(data
->topList
);
727 wfree(data
->leftList
);
729 wfree(data
->rightList
);
730 if (data
->bottomList
)
731 wfree(data
->bottomList
);
734 static void updateMoveData(WWindow
* wwin
, MoveData
* data
)
736 WScreen
*scr
= wwin
->screen_ptr
;
741 tmp
= scr
->focused_window
;
743 if (tmp
!= wwin
&& scr
->current_workspace
== tmp
->frame
->workspace
744 && !tmp
->flags
.miniaturized
745 && !tmp
->flags
.hidden
&& !tmp
->flags
.obscured
&& !WFLAGP(tmp
, sunken
)) {
746 data
->topList
[data
->count
] = tmp
;
747 data
->leftList
[data
->count
] = tmp
;
748 data
->rightList
[data
->count
] = tmp
;
749 data
->bottomList
[data
->count
] = tmp
;
755 if (data
->count
== 0) {
758 data
->rightIndex
= 0;
759 data
->bottomIndex
= 0;
763 /* order from closest to the border of the screen to farthest */
765 qsort(data
->topList
, data
->count
, sizeof(WWindow
**), compareWTop
);
766 qsort(data
->leftList
, data
->count
, sizeof(WWindow
**), compareWLeft
);
767 qsort(data
->rightList
, data
->count
, sizeof(WWindow
**), compareWRight
);
768 qsort(data
->bottomList
, data
->count
, sizeof(WWindow
**), compareWBottom
);
770 /* figure the position of the window relative to the others */
773 data
->leftIndex
= -1;
774 data
->rightIndex
= -1;
775 data
->bottomIndex
= -1;
777 if (WTOP(wwin
) < WBOTTOM(data
->bottomList
[0])) {
778 data
->bottomIndex
= 0;
780 if (WLEFT(wwin
) < WRIGHT(data
->rightList
[0])) {
781 data
->rightIndex
= 0;
783 if (WRIGHT(wwin
) > WLEFT(data
->leftList
[0])) {
786 if (WBOTTOM(wwin
) > WTOP(data
->topList
[0])) {
789 for (i
= 0; i
< data
->count
; i
++) {
790 if (WTOP(wwin
) >= WBOTTOM(data
->bottomList
[i
])) {
791 data
->bottomIndex
= i
+ 1;
793 if (WLEFT(wwin
) >= WRIGHT(data
->rightList
[i
])) {
794 data
->rightIndex
= i
+ 1;
796 if (WRIGHT(wwin
) <= WLEFT(data
->leftList
[i
])) {
797 data
->leftIndex
= i
+ 1;
799 if (WBOTTOM(wwin
) <= WTOP(data
->topList
[i
])) {
800 data
->topIndex
= i
+ 1;
805 static void initMoveData(WWindow
* wwin
, MoveData
* data
)
810 memset(data
, 0, sizeof(MoveData
));
812 for (i
= 0, tmp
= wwin
->screen_ptr
->focused_window
; tmp
!= NULL
; tmp
= tmp
->prev
, i
++) ;
815 data
->topList
= wmalloc(sizeof(WWindow
*) * i
);
816 data
->leftList
= wmalloc(sizeof(WWindow
*) * i
);
817 data
->rightList
= wmalloc(sizeof(WWindow
*) * i
);
818 data
->bottomList
= wmalloc(sizeof(WWindow
*) * i
);
820 updateMoveData(wwin
, data
);
823 data
->realX
= wwin
->frame_x
;
824 data
->realY
= wwin
->frame_y
;
825 data
->calcX
= wwin
->frame_x
;
826 data
->calcY
= wwin
->frame_y
;
828 data
->winWidth
= wwin
->frame
->core
->width
+ (HAS_BORDER_WITH_SELECT(wwin
) ? 2 * FRAME_BORDER_WIDTH
: 0);
829 data
->winHeight
= wwin
->frame
->core
->height
+ (HAS_BORDER_WITH_SELECT(wwin
) ? 2 * FRAME_BORDER_WIDTH
: 0);
832 static Bool
checkWorkspaceChange(WWindow
* wwin
, MoveData
* data
, Bool opaqueMove
)
834 WScreen
*scr
= wwin
->screen_ptr
;
835 Bool changed
= False
;
837 if (data
->mouseX
<= 1) {
838 if (scr
->current_workspace
> 0) {
840 crossWorkspace(scr
, wwin
, opaqueMove
, scr
->current_workspace
- 1, True
);
844 } else if (scr
->current_workspace
== 0 && wPreferences
.ws_cycle
) {
846 crossWorkspace(scr
, wwin
, opaqueMove
, scr
->workspace_count
- 1, True
);
850 } else if (data
->mouseX
>= scr
->scr_width
- 2) {
852 if (scr
->current_workspace
== scr
->workspace_count
- 1) {
854 if (wPreferences
.ws_cycle
|| scr
->workspace_count
== MAX_WORKSPACES
) {
856 crossWorkspace(scr
, wwin
, opaqueMove
, 0, False
);
860 /* if user insists on trying to go to next workspace even when
861 * it's already the last, create a new one */
862 else if (data
->omouseX
== data
->mouseX
&& wPreferences
.ws_advance
) {
864 /* detect user "rubbing" the window against the edge */
865 if (data
->rubCount
> 0 && data
->omouseY
- data
->mouseY
> MOVE_THRESHOLD
) {
867 data
->rubCount
= -(data
->rubCount
+ 1);
869 } else if (data
->rubCount
<= 0 && data
->mouseY
- data
->omouseY
> MOVE_THRESHOLD
) {
871 data
->rubCount
= -data
->rubCount
+ 1;
874 /* create a new workspace */
875 if (abs(data
->rubCount
) > 2) {
876 /* go to next workspace */
879 crossWorkspace(scr
, wwin
, opaqueMove
, scr
->current_workspace
+ 1, False
);
883 } else if (scr
->current_workspace
< scr
->workspace_count
) {
885 /* go to next workspace */
886 crossWorkspace(scr
, wwin
, opaqueMove
, scr
->current_workspace
+ 1, False
);
898 updateWindowPosition(WWindow
* wwin
, MoveData
* data
, Bool doResistance
,
899 Bool opaqueMove
, int newMouseX
, int newMouseY
)
901 WScreen
*scr
= wwin
->screen_ptr
;
902 int dx
, dy
; /* how much mouse moved */
903 int winL
, winR
, winT
, winB
; /* requested new window position */
904 int newX
, newY
; /* actual new window position */
905 Bool hresist
, vresist
;
914 /* check the direction of the movement */
915 dx
= newMouseX
- data
->mouseX
;
916 dy
= newMouseY
- data
->mouseY
;
918 data
->omouseX
= data
->mouseX
;
919 data
->omouseY
= data
->mouseY
;
920 data
->mouseX
= newMouseX
;
921 data
->mouseY
= newMouseY
;
923 winL
= data
->calcX
+ dx
;
924 winR
= data
->calcX
+ data
->winWidth
+ dx
;
925 winT
= data
->calcY
+ dy
;
926 winB
= data
->calcY
+ data
->winHeight
+ dy
;
938 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
939 attract
= wPreferences
.attract
;
940 /* horizontal movement: check horizontal edge resistances */
944 /* window is the leftmost window: check against screen edge */
946 /* Add inter head resistance 1/2 (if needed) */
947 head
= wGetHeadForPointerLocation(scr
);
948 rect
= wGetRectForHead(scr
, head
);
950 l_edge
= WMAX(scr
->totalUsableArea
[head
].x1
, rect
.pos
.x
);
951 edge_l
= l_edge
- resist
;
952 edge_r
= WMIN(scr
->totalUsableArea
[head
].x2
, rect
.pos
.x
+ rect
.size
.width
);
953 r_edge
= edge_r
+ resist
;
956 if ((data
->rightIndex
>= 0) && (data
->rightIndex
<= data
->count
)) {
959 for (i
= data
->rightIndex
- 1; i
>= 0; i
--) {
960 looprw
= data
->rightList
[i
];
961 if (!(data
->realY
> WBOTTOM(looprw
)
962 || (data
->realY
+ data
->winHeight
) < WTOP(looprw
))) {
963 if (attract
|| ((data
->realX
< (WRIGHT(looprw
) + 2)) && dx
< 0)) {
964 l_edge
= WRIGHT(looprw
) + 1;
965 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
972 for (i
= data
->rightIndex
; i
< data
->count
; i
++) {
973 looprw
= data
->rightList
[i
];
974 if (!(data
->realY
> WBOTTOM(looprw
)
975 || (data
->realY
+ data
->winHeight
) < WTOP(looprw
))) {
976 r_edge
= WRIGHT(looprw
) + 1;
977 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
984 if ((data
->leftIndex
>= 0) && (data
->leftIndex
<= data
->count
)) {
987 for (i
= data
->leftIndex
- 1; i
>= 0; i
--) {
988 looprw
= data
->leftList
[i
];
989 if (!(data
->realY
> WBOTTOM(looprw
)
990 || (data
->realY
+ data
->winHeight
) < WTOP(looprw
))) {
992 || (((data
->realX
+ data
->winWidth
) > (WLEFT(looprw
) - 1))
994 edge_r
= WLEFT(looprw
);
995 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1002 for (i
= data
->leftIndex
; i
< data
->count
; i
++) {
1003 looprw
= data
->leftList
[i
];
1004 if (!(data
->realY
> WBOTTOM(looprw
)
1005 || (data
->realY
+ data
->winHeight
) < WTOP(looprw
))) {
1006 edge_l
= WLEFT(looprw
);
1007 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1014 printf("%d %d\n",winL,winR);
1015 printf("l_ %d r_ %d _l %d _r %d\n",l_edge,r_edge,edge_l,edge_r);
1018 if ((winL
- l_edge
) < (r_edge
- winL
)) {
1020 if ((attract
&& winL
<= l_edge
+ resist
&& winL
>= l_edge
- resist
)
1021 || (dx
< 0 && winL
<= l_edge
&& winL
>= l_edge
- resist
)) {
1027 if (resist
> 0 && attract
&& winL
>= r_edge
- resist
&& winL
<= r_edge
+ resist
) {
1033 if ((winR
- edge_l
) < (edge_r
- winR
)) {
1034 if (resist
> 0 && attract
&& winR
<= edge_l
+ resist
&& winR
>= edge_l
- resist
) {
1035 newX
= edge_l
- data
->winWidth
;
1040 if ((attract
&& winR
>= edge_r
- resist
&& winR
<= edge_r
+ resist
)
1041 || (dx
> 0 && winR
>= edge_r
&& winR
<= edge_r
+ resist
)) {
1042 newX
= edge_r
- data
->winWidth
;
1049 /* Add inter head resistance 2/2 (if needed) */
1050 t_edge
= WMAX(scr
->totalUsableArea
[head
].y1
, rect
.pos
.y
);
1051 edge_t
= t_edge
- resist
;
1052 edge_b
= WMIN(scr
->totalUsableArea
[head
].y2
, rect
.pos
.y
+ rect
.size
.height
);
1053 b_edge
= edge_b
+ resist
;
1055 if ((data
->bottomIndex
>= 0) && (data
->bottomIndex
<= data
->count
)) {
1058 for (i
= data
->bottomIndex
- 1; i
>= 0; i
--) {
1059 looprw
= data
->bottomList
[i
];
1060 if (!(data
->realX
> WRIGHT(looprw
)
1061 || (data
->realX
+ data
->winWidth
) < WLEFT(looprw
))) {
1062 if (attract
|| ((data
->realY
< (WBOTTOM(looprw
) + 2)) && dy
< 0)) {
1063 t_edge
= WBOTTOM(looprw
) + 1;
1064 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1071 for (i
= data
->bottomIndex
; i
< data
->count
; i
++) {
1072 looprw
= data
->bottomList
[i
];
1073 if (!(data
->realX
> WRIGHT(looprw
)
1074 || (data
->realX
+ data
->winWidth
) < WLEFT(looprw
))) {
1075 b_edge
= WBOTTOM(looprw
) + 1;
1076 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1083 if ((data
->topIndex
>= 0) && (data
->topIndex
<= data
->count
)) {
1086 for (i
= data
->topIndex
- 1; i
>= 0; i
--) {
1087 looprw
= data
->topList
[i
];
1088 if (!(data
->realX
> WRIGHT(looprw
)
1089 || (data
->realX
+ data
->winWidth
) < WLEFT(looprw
))) {
1091 || (((data
->realY
+ data
->winHeight
) > (WTOP(looprw
) - 1))
1093 edge_b
= WTOP(looprw
);
1094 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1101 for (i
= data
->topIndex
; i
< data
->count
; i
++) {
1102 looprw
= data
->topList
[i
];
1103 if (!(data
->realX
> WRIGHT(looprw
)
1104 || (data
->realX
+ data
->winWidth
) < WLEFT(looprw
))) {
1105 edge_t
= WTOP(looprw
);
1106 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1112 if ((winT
- t_edge
) < (b_edge
- winT
)) {
1114 if ((attract
&& winT
<= t_edge
+ resist
&& winT
>= t_edge
- resist
)
1115 || (dy
< 0 && winT
<= t_edge
&& winT
>= t_edge
- resist
)) {
1121 if (resist
> 0 && attract
&& winT
>= b_edge
- resist
&& winT
<= b_edge
+ resist
) {
1127 if ((winB
- edge_t
) < (edge_b
- winB
)) {
1128 if (resist
> 0 && attract
&& winB
<= edge_t
+ resist
&& winB
>= edge_t
- resist
) {
1129 newY
= edge_t
- data
->winHeight
;
1134 if ((attract
&& winB
>= edge_b
- resist
&& winB
<= edge_b
+ resist
)
1135 || (dy
> 0 && winB
>= edge_b
&& winB
<= edge_b
+ resist
)) {
1136 newY
= edge_b
- data
->winHeight
;
1146 /* update window position */
1150 if (((dx
> 0 && data
->calcX
- data
->realX
> 0)
1151 || (dx
< 0 && data
->calcX
- data
->realX
< 0)) && !hresist
)
1154 if (((dy
> 0 && data
->calcY
- data
->realY
> 0)
1155 || (dy
< 0 && data
->calcY
- data
->realY
< 0)) && !vresist
)
1158 if (data
->realX
!= newX
|| data
->realY
!= newY
) {
1160 if (wPreferences
.move_display
== WDIS_NEW
&& !scr
->selected_windows
) {
1161 showPosition(wwin
, data
->realX
, data
->realY
);
1164 doWindowMove(wwin
, scr
->selected_windows
, newX
- wwin
->frame_x
, newY
- wwin
->frame_y
);
1167 drawFrames(wwin
, scr
->selected_windows
,
1168 data
->realX
- wwin
->frame_x
, data
->realY
- wwin
->frame_y
);
1171 if (!scr
->selected_windows
&& wPreferences
.move_display
== WDIS_FRAME_CENTER
) {
1173 moveGeometryDisplayCentered(scr
, newX
+ data
->winWidth
/ 2, newY
+ data
->winHeight
/ 2);
1178 drawFrames(wwin
, scr
->selected_windows
, newX
- wwin
->frame_x
, newY
- wwin
->frame_y
);
1181 if (!scr
->selected_windows
) {
1182 showPosition(wwin
, newX
, newY
);
1186 /* recalc relative window position */
1187 if (doResistance
&& (data
->realX
!= newX
|| data
->realY
!= newY
)) {
1188 updateResistance(wwin
, data
, newX
, newY
);
1195 #define _KS KEY_CONTROL_WINDOW_WEIGHT
1197 #define MOVABLE_BIT 0x01
1198 #define RESIZABLE_BIT 0x02
1200 int wKeyboardMoveResizeWindow(WWindow
* wwin
)
1202 WScreen
*scr
= wwin
->screen_ptr
;
1203 Window root
= scr
->root_win
;
1205 int w
= wwin
->frame
->core
->width
;
1206 int h
= wwin
->frame
->core
->height
;
1207 int scr_width
= wwin
->screen_ptr
->scr_width
;
1208 int scr_height
= wwin
->screen_ptr
->scr_height
;
1209 int vert_border
= wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
;
1210 int src_x
= wwin
->frame_x
;
1211 int src_y
= wwin
->frame_y
;
1212 int done
, off_x
, off_y
, ww
, wh
;
1215 KeyCode shiftl
, shiftr
, ctrll
, ctrlmode
;
1216 KeySym keysym
= NoSymbol
;
1218 int modes
= ((IS_MOVABLE(wwin
) ? MOVABLE_BIT
: 0) | (IS_RESIZABLE(wwin
) ? RESIZABLE_BIT
: 0));
1219 int head
= ((wPreferences
.auto_arrange_icons
&& wXineramaHeads(scr
) > 1)
1220 ? wGetHeadForWindow(wwin
)
1221 : scr
->xine_info
.primary_head
);
1223 shiftl
= XKeysymToKeycode(dpy
, XK_Shift_L
);
1224 shiftr
= XKeysymToKeycode(dpy
, XK_Shift_R
);
1225 ctrll
= XKeysymToKeycode(dpy
, XK_Control_L
);
1226 ctrlmode
= done
= off_x
= off_y
= 0;
1228 if (modes
== RESIZABLE_BIT
) {
1234 XGrabKeyboard(dpy
, root
, False
, GrabModeAsync
, GrabModeAsync
, CurrentTime
);
1236 if (!wwin
->flags
.selected
) {
1237 wUnselectWindows(scr
);
1240 XGrabPointer(dpy
, scr
->root_win
, True
, PointerMotionMask
1241 | ButtonReleaseMask
| ButtonPressMask
, GrabModeAsync
,
1242 GrabModeAsync
, None
, wCursor
[WCUR_DEFAULT
], CurrentTime
);
1244 if (wwin
->flags
.shaded
|| scr
->selected_windows
) {
1245 if (scr
->selected_windows
)
1246 drawFrames(wwin
, scr
->selected_windows
, off_x
, off_y
);
1248 drawTransparentFrame(wwin
, src_x
+ off_x
, src_y
+ off_y
, w
, h
);
1249 if (!scr
->selected_windows
)
1250 mapPositionDisplay(wwin
, src_x
, src_y
, w
, h
);
1252 drawTransparentFrame(wwin
, src_x
+ off_x
, src_y
+ off_y
, w
, h
);
1262 WMMaskEvent(dpy
, KeyPressMask
| ButtonReleaseMask
1263 | ButtonPressMask
| ExposureMask
, &event
);
1264 if (event
.type
== Expose
) {
1265 WMHandleEvent(&event
);
1267 } while (event
.type
== Expose
);
1269 if (wwin
->flags
.shaded
|| scr
->selected_windows
) {
1270 if (scr
->selected_windows
)
1271 drawFrames(wwin
, scr
->selected_windows
, off_x
, off_y
);
1273 drawTransparentFrame(wwin
, src_x
+ off_x
, src_y
+ off_y
, w
, h
);
1274 /*** I HATE EDGE RESISTANCE - ]d ***/
1276 drawTransparentFrame(wwin
, src_x
+ off_x
, src_y
+ off_y
, ww
, wh
);
1280 showGeometry(wwin
, src_x
+ off_x
, src_y
+ off_y
, src_x
+ off_x
+ ww
, src_y
+ off_y
+ wh
,
1286 switch (event
.type
) {
1289 if (event
.xkey
.time
- lastTime
> 50) {
1290 kspeed
/= (1 + (event
.xkey
.time
- lastTime
) / 100);
1298 lastTime
= event
.xkey
.time
;
1299 if (modes
== (MOVABLE_BIT
| RESIZABLE_BIT
)) {
1300 if ((event
.xkey
.state
& ControlMask
) && !wwin
->flags
.shaded
) {
1302 wUnselectWindows(scr
);
1307 if (event
.xkey
.keycode
== shiftl
|| event
.xkey
.keycode
== shiftr
) {
1309 cycleGeometryDisplay(wwin
, src_x
+ off_x
, src_y
+ off_y
, ww
, wh
, 0);
1311 cyclePositionDisplay(wwin
, src_x
+ off_x
, src_y
+ off_y
, ww
, wh
);
1314 keysym
= XLookupKeysym(&event
.xkey
, 0);
1371 if (moment
!= RIGHT
)
1383 wWindowConstrainSize(wwin
, (unsigned int *)&ww
, (unsigned int *)&wh
);
1386 if (wPreferences
.ws_cycle
) {
1387 if (src_x
+ off_x
+ ww
< 20) {
1388 if (!scr
->current_workspace
) {
1389 wWorkspaceChange(scr
, scr
->workspace_count
- 1);
1391 wWorkspaceChange(scr
, scr
->current_workspace
- 1);
1393 } else if (src_x
+ off_x
+ 20 > scr_width
) {
1394 if (scr
->current_workspace
== scr
->workspace_count
- 1) {
1395 wWorkspaceChange(scr
, 0);
1397 wWorkspaceChange(scr
, scr
->current_workspace
+ 1);
1401 if (src_x
+ off_x
+ ww
< 20)
1402 off_x
= 20 - ww
- src_x
;
1403 else if (src_x
+ off_x
+ 20 > scr_width
)
1404 off_x
= scr_width
- 20 - src_x
;
1407 if (src_y
+ off_y
+ wh
< 20) {
1408 off_y
= 20 - wh
- src_y
;
1409 } else if (src_y
+ off_y
+ 20 > scr_height
) {
1410 off_y
= scr_height
- 20 - src_y
;
1419 WMHandleEvent(&event
);
1420 while (XCheckTypedEvent(dpy
, Expose
, &event
)) {
1421 WMHandleEvent(&event
);
1426 WMHandleEvent(&event
);
1433 if (wwin
->flags
.shaded
&& !scr
->selected_windows
) {
1434 moveGeometryDisplayCentered(scr
, src_x
+ off_x
+ w
/ 2, src_y
+ off_y
+ h
/ 2);
1437 WMUnmapWidget(scr
->gview
);
1438 mapGeometryDisplay(wwin
, src_x
+ off_x
, src_y
+ off_y
, ww
, wh
);
1439 } else if (!scr
->selected_windows
) {
1440 WMUnmapWidget(scr
->gview
);
1441 mapPositionDisplay(wwin
, src_x
+ off_x
, src_y
+ off_y
, ww
, wh
);
1445 if (wwin
->flags
.shaded
|| scr
->selected_windows
) {
1446 if (scr
->selected_windows
)
1447 drawFrames(wwin
, scr
->selected_windows
, off_x
, off_y
);
1449 drawTransparentFrame(wwin
, src_x
+ off_x
, src_y
+ off_y
, w
, h
);
1451 drawTransparentFrame(wwin
, src_x
+ off_x
, src_y
+ off_y
, ww
, wh
);
1455 showGeometry(wwin
, src_x
+ off_x
, src_y
+ off_y
, src_x
+ off_x
+ ww
, src_y
+ off_y
+ wh
,
1457 } else if (!scr
->selected_windows
)
1458 showPosition(wwin
, src_x
+ off_x
, src_y
+ off_y
);
1461 scr
->keymove_tick
= 0;
1463 WMDeleteTimerWithClientData(&looper);
1465 if (wwin
->flags
.shaded
|| scr
->selected_windows
) {
1466 if (scr
->selected_windows
)
1467 drawFrames(wwin
, scr
->selected_windows
, off_x
, off_y
);
1469 drawTransparentFrame(wwin
, src_x
+ off_x
, src_y
+ off_y
, w
, h
);
1471 drawTransparentFrame(wwin
, src_x
+ off_x
, src_y
+ off_y
, ww
, wh
);
1475 showGeometry(wwin
, src_x
+ off_x
, src_y
+ off_y
, src_x
+ off_x
+ ww
,
1476 src_y
+ off_y
+ wh
, 0);
1477 WMUnmapWidget(scr
->gview
);
1479 WMUnmapWidget(scr
->gview
);
1481 XUngrabKeyboard(dpy
, CurrentTime
);
1482 XUngrabPointer(dpy
, CurrentTime
);
1486 if (wwin
->flags
.shaded
|| scr
->selected_windows
) {
1487 if (!scr
->selected_windows
) {
1488 wWindowMove(wwin
, src_x
+ off_x
, src_y
+ off_y
);
1489 wWindowSynthConfigureNotify(wwin
);
1491 WMArrayIterator iter
;
1494 doWindowMove(wwin
, scr
->selected_windows
, off_x
, off_y
);
1496 WM_ITERATE_ARRAY(scr
->selected_windows
, foo
, iter
) {
1497 wWindowSynthConfigureNotify(foo
);
1501 if (wwin
->client
.width
!= ww
) {
1502 wwin
->flags
.user_changed_width
= 1;
1503 wwin
->flags
.maximized
&= ~(MAX_HORIZONTAL
| MAX_MAXIMUS
);
1506 if (wwin
->client
.height
!= wh
- vert_border
) {
1507 wwin
->flags
.user_changed_height
= 1;
1508 wwin
->flags
.maximized
&= ~(MAX_VERTICAL
| MAX_LEFTHALF
| MAX_RIGHTHALF
| MAX_MAXIMUS
);
1511 wWindowConfigure(wwin
, src_x
+ off_x
, src_y
+ off_y
, ww
, wh
- vert_border
);
1512 wWindowSynthConfigureNotify(wwin
);
1514 wWindowChangeWorkspace(wwin
, scr
->current_workspace
);
1515 wSetFocusTo(scr
, wwin
);
1518 if (wPreferences
.auto_arrange_icons
&& wXineramaHeads(scr
) > 1 &&
1519 head
!= wGetHeadForWindow(wwin
)) {
1520 wArrangeIcons(scr
, True
);
1529 *----------------------------------------------------------------------
1530 * wMouseMoveWindow--
1531 * Move the named window and the other selected ones (if any),
1532 * interactively. Also shows the position of the window, if only one
1533 * window is being moved.
1534 * If the window is not on the selected window list, the selected
1535 * windows are deselected.
1536 * If shift is pressed during the operation, the position display
1537 * is changed to another type.
1540 * True if the window was moved, False otherwise.
1543 * The window(s) position is changed, and the client(s) are
1544 * notified about that.
1545 * The position display configuration may be changed.
1546 *----------------------------------------------------------------------
1548 int wMouseMoveWindow(WWindow
* wwin
, XEvent
* ev
)
1550 WScreen
*scr
= wwin
->screen_ptr
;
1552 Window root
= scr
->root_win
;
1553 KeyCode shiftl
, shiftr
;
1557 /* This needs not to change while moving, else bad things can happen */
1558 int opaqueMove
= wPreferences
.opaque_move
;
1560 int head
= ((wPreferences
.auto_arrange_icons
&& wXineramaHeads(scr
) > 1)
1561 ? wGetHeadForWindow(wwin
)
1562 : scr
->xine_info
.primary_head
);
1564 if (!IS_MOVABLE(wwin
))
1567 if (wPreferences
.opaque_move
&& !wPreferences
.use_saveunders
) {
1568 XSetWindowAttributes attr
;
1570 attr
.save_under
= True
;
1571 XChangeWindowAttributes(dpy
, wwin
->frame
->core
->window
, CWSaveUnder
, &attr
);
1574 initMoveData(wwin
, &moveData
);
1576 moveData
.mouseX
= ev
->xmotion
.x_root
;
1577 moveData
.mouseY
= ev
->xmotion
.y_root
;
1579 if (!wwin
->flags
.selected
) {
1580 /* this window is not selected, unselect others and move only wwin */
1581 wUnselectWindows(scr
);
1583 shiftl
= XKeysymToKeycode(dpy
, XK_Shift_L
);
1584 shiftr
= XKeysymToKeycode(dpy
, XK_Shift_R
);
1590 /* XWarpPointer() doesn't seem to generate Motion events, so
1591 * we've got to simulate them */
1592 XQueryPointer(dpy
, root
, &junkw
, &junkw
, &event
.xmotion
.x_root
,
1593 &event
.xmotion
.y_root
, &junk
, &junk
, (unsigned *)&junk
);
1595 WMMaskEvent(dpy
, KeyPressMask
| ButtonMotionMask
1596 | PointerMotionHintMask
1597 | ButtonReleaseMask
| ButtonPressMask
| ExposureMask
, &event
);
1599 if (event
.type
== MotionNotify
) {
1600 /* compress MotionNotify events */
1601 while (XCheckMaskEvent(dpy
, ButtonMotionMask
, &event
)) ;
1602 if (!checkMouseSamplingRate(&event
))
1606 switch (event
.type
) {
1608 if ((event
.xkey
.keycode
== shiftl
|| event
.xkey
.keycode
== shiftr
)
1609 && started
&& !scr
->selected_windows
) {
1612 drawFrames(wwin
, scr
->selected_windows
,
1613 moveData
.realX
- wwin
->frame_x
, moveData
.realY
- wwin
->frame_y
);
1616 if (wPreferences
.move_display
== WDIS_NEW
&& !scr
->selected_windows
) {
1617 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1620 cyclePositionDisplay(wwin
, moveData
.realX
, moveData
.realY
,
1621 moveData
.winWidth
, moveData
.winHeight
);
1623 if (wPreferences
.move_display
== WDIS_NEW
&& !scr
->selected_windows
) {
1625 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1629 drawFrames(wwin
, scr
->selected_windows
,
1630 moveData
.realX
- wwin
->frame_x
, moveData
.realY
- wwin
->frame_y
);
1633 WMHandleEvent(&event); this causes problems needs fixing */
1639 updateWindowPosition(wwin
, &moveData
,
1640 scr
->selected_windows
== NULL
1641 && wPreferences
.edge_resistance
> 0,
1642 opaqueMove
, event
.xmotion
.x_root
, event
.xmotion
.y_root
);
1644 if (!warped
&& !wPreferences
.no_autowrap
) {
1645 int oldWorkspace
= scr
->current_workspace
;
1647 if (wPreferences
.move_display
== WDIS_NEW
&& !scr
->selected_windows
) {
1648 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1652 drawFrames(wwin
, scr
->selected_windows
,
1653 moveData
.realX
- wwin
->frame_x
,
1654 moveData
.realY
- wwin
->frame_y
);
1656 if (checkWorkspaceChange(wwin
, &moveData
, opaqueMove
)) {
1657 if (scr
->current_workspace
!= oldWorkspace
1658 && wPreferences
.edge_resistance
> 0
1659 && scr
->selected_windows
== NULL
)
1660 updateMoveData(wwin
, &moveData
);
1664 drawFrames(wwin
, scr
->selected_windows
,
1665 moveData
.realX
- wwin
->frame_x
,
1666 moveData
.realY
- wwin
->frame_y
);
1668 if (wPreferences
.move_display
== WDIS_NEW
&& !scr
->selected_windows
) {
1670 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1676 } else if (abs(ev
->xmotion
.x_root
- event
.xmotion
.x_root
) >= MOVE_THRESHOLD
1677 || abs(ev
->xmotion
.y_root
- event
.xmotion
.y_root
) >= MOVE_THRESHOLD
) {
1679 XChangeActivePointerGrab(dpy
, ButtonMotionMask
1680 | ButtonReleaseMask
| ButtonPressMask
,
1681 wCursor
[WCUR_MOVE
], CurrentTime
);
1683 XGrabKeyboard(dpy
, root
, False
, GrabModeAsync
, GrabModeAsync
, CurrentTime
);
1685 if (!scr
->selected_windows
)
1686 mapPositionDisplay(wwin
, moveData
.realX
, moveData
.realY
,
1687 moveData
.winWidth
, moveData
.winHeight
);
1689 if (started
&& !opaqueMove
)
1690 drawFrames(wwin
, scr
->selected_windows
, 0, 0);
1692 if (!opaqueMove
|| (wPreferences
.move_display
== WDIS_NEW
1693 && !scr
->selected_windows
)) {
1695 if (wPreferences
.move_display
== WDIS_NEW
)
1696 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1705 if (event
.xbutton
.button
!= ev
->xbutton
.button
)
1711 drawFrames(wwin
, scr
->selected_windows
,
1712 moveData
.realX
- wwin
->frame_x
, moveData
.realY
- wwin
->frame_y
);
1714 doWindowMove(wwin
, scr
->selected_windows
,
1715 moveData
.realX
- wwin
->frame_x
,
1716 moveData
.realY
- wwin
->frame_y
);
1718 #ifndef CONFIGURE_WINDOW_WHILE_MOVING
1719 wWindowSynthConfigureNotify(wwin
);
1721 XUngrabKeyboard(dpy
, CurrentTime
);
1724 wWindowChangeWorkspace(wwin
, scr
->current_workspace
);
1725 wSetFocusTo(scr
, wwin
);
1727 if (wPreferences
.move_display
== WDIS_NEW
)
1728 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1730 /* discard all enter/leave events that happened until
1731 * the time the button was released */
1732 while (XCheckTypedEvent(dpy
, EnterNotify
, &e
)) {
1733 if (e
.xcrossing
.time
> event
.xbutton
.time
) {
1734 XPutBackEvent(dpy
, &e
);
1738 while (XCheckTypedEvent(dpy
, LeaveNotify
, &e
)) {
1739 if (e
.xcrossing
.time
> event
.xbutton
.time
) {
1740 XPutBackEvent(dpy
, &e
);
1745 if (!scr
->selected_windows
) {
1746 /* get rid of the geometry window */
1747 WMUnmapWidget(scr
->gview
);
1754 if (started
&& !opaqueMove
) {
1755 drawFrames(wwin
, scr
->selected_windows
,
1756 moveData
.realX
- wwin
->frame_x
, moveData
.realY
- wwin
->frame_y
);
1758 WMHandleEvent(&event
);
1761 drawFrames(wwin
, scr
->selected_windows
,
1762 moveData
.realX
- wwin
->frame_x
, moveData
.realY
- wwin
->frame_y
);
1764 WMHandleEvent(&event
);
1770 if (wPreferences
.opaque_move
&& !wPreferences
.use_saveunders
) {
1771 XSetWindowAttributes attr
;
1773 attr
.save_under
= False
;
1774 XChangeWindowAttributes(dpy
, wwin
->frame
->core
->window
, CWSaveUnder
, &attr
);
1778 freeMoveData(&moveData
);
1780 if (started
&& wPreferences
.auto_arrange_icons
&& wXineramaHeads(scr
) > 1 &&
1781 head
!= wGetHeadForWindow(wwin
)) {
1782 wArrangeIcons(scr
, True
);
1788 #define HCONSTRAIN 2
1790 static int getResizeDirection(WWindow
* wwin
, int x
, int y
, int dx
, int dy
, int flags
)
1792 int w
= wwin
->frame
->core
->width
- 1;
1793 int cw
= wwin
->frame
->resizebar_corner_width
;
1796 /* if not resizing through the resizebar */
1797 if (!(flags
& RESIZEBAR
)) {
1798 int xdir
= (abs(x
) < (wwin
->client
.width
/ 2)) ? LEFT
: RIGHT
;
1799 int ydir
= (abs(y
) < (wwin
->client
.height
/ 2)) ? UP
: DOWN
;
1800 if (abs(dx
) < 2 || abs(dy
) < 2) {
1801 if (abs(dy
) > abs(dx
))
1806 return (xdir
| ydir
);
1809 /* window is too narrow. allow diagonal resize */
1813 if (flags
& HCONSTRAIN
)
1818 return (LEFT
| ydir
);
1820 return (RIGHT
| ydir
);
1822 /* vertical resize */
1823 if ((x
> cw
) && (x
< w
- cw
))
1831 if ((abs(dy
) > 0) && !(flags
& HCONSTRAIN
))
1837 void wMouseResizeWindow(WWindow
* wwin
, XEvent
* ev
)
1840 WScreen
*scr
= wwin
->screen_ptr
;
1841 Window root
= scr
->root_win
;
1842 int vert_border
= wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
;
1843 int fw
= wwin
->frame
->core
->width
;
1844 int fh
= wwin
->frame
->core
->height
;
1845 int fx
= wwin
->frame_x
;
1846 int fy
= wwin
->frame_y
;
1847 int is_resizebar
= (wwin
->frame
->resizebar
&& ev
->xany
.window
== wwin
->frame
->resizebar
->window
);
1851 int rw
= fw
, rh
= fh
;
1852 int rx1
, ry1
, rx2
, ry2
;
1854 KeyCode shiftl
, shiftr
;
1860 int head
= ((wPreferences
.auto_arrange_icons
&& wXineramaHeads(scr
) > 1)
1861 ? wGetHeadForWindow(wwin
)
1862 : scr
->xine_info
.primary_head
);
1864 if (!IS_RESIZABLE(wwin
))
1867 if (wwin
->flags
.shaded
) {
1868 wwarning("internal error: tryein");
1871 orig_x
= ev
->xbutton
.x_root
;
1872 orig_y
= ev
->xbutton
.y_root
;
1875 wUnselectWindows(scr
);
1880 shiftl
= XKeysymToKeycode(dpy
, XK_Shift_L
);
1881 shiftr
= XKeysymToKeycode(dpy
, XK_Shift_R
);
1882 if (HAS_TITLEBAR(wwin
))
1883 h
= WMFontHeight(wwin
->screen_ptr
->title_font
) + (wPreferences
.window_title_clearance
+
1884 TITLEBAR_EXTEND_SPACE
) * 2;
1888 WMMaskEvent(dpy
, KeyPressMask
| ButtonMotionMask
1889 | ButtonReleaseMask
| PointerMotionHintMask
| ButtonPressMask
| ExposureMask
, &event
);
1890 if (!checkMouseSamplingRate(&event
))
1893 switch (event
.type
) {
1895 showGeometry(wwin
, fx
, fy
, fx
+ fw
, fy
+ fh
, res
);
1896 if ((event
.xkey
.keycode
== shiftl
|| event
.xkey
.keycode
== shiftr
)
1898 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
1899 cycleGeometryDisplay(wwin
, fx
, fy
, fw
, fh
, res
);
1900 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
1902 showGeometry(wwin
, fx
, fy
, fx
+ fw
, fy
+ fh
, res
);
1907 while (XCheckMaskEvent(dpy
, ButtonMotionMask
, &event
)) ;
1918 dw
= orig_x
- event
.xmotion
.x_root
;
1919 else if (res
& RIGHT
)
1920 dw
= event
.xmotion
.x_root
- orig_x
;
1922 dh
= orig_y
- event
.xmotion
.y_root
;
1923 else if (res
& DOWN
)
1924 dh
= event
.xmotion
.y_root
- orig_y
;
1926 orig_x
= event
.xmotion
.x_root
;
1927 orig_y
= event
.xmotion
.y_root
;
1932 fh
= rh
- vert_border
;
1933 wWindowConstrainSize(wwin
, (unsigned int *)&fw
, (unsigned int *)&fh
);
1937 else if (res
& RIGHT
)
1941 else if (res
& DOWN
)
1943 } else if (abs(orig_x
- event
.xmotion
.x_root
) >= MOVE_THRESHOLD
1944 || abs(orig_y
- event
.xmotion
.y_root
) >= MOVE_THRESHOLD
) {
1949 XTranslateCoordinates(dpy
, root
, wwin
->frame
->core
->window
,
1950 orig_x
, orig_y
, &tx
, &ty
, &junkw
);
1952 /* check if resizing through resizebar */
1958 if (is_resizebar
&& ((ev
->xbutton
.state
& ShiftMask
)
1959 || abs(orig_y
- event
.xmotion
.y_root
) < HRESIZE_THRESHOLD
))
1960 flags
|= HCONSTRAIN
;
1962 res
= getResizeDirection(wwin
, tx
, ty
,
1963 orig_x
- event
.xmotion
.x_root
,
1964 orig_y
- event
.xmotion
.y_root
, flags
);
1966 if (res
== (UP
| LEFT
))
1967 XChangeActivePointerGrab(dpy
, ButtonMotionMask
1968 | ButtonReleaseMask
| ButtonPressMask
,
1969 wCursor
[WCUR_TOPLEFTRESIZE
], CurrentTime
);
1970 else if (res
== (UP
| RIGHT
))
1971 XChangeActivePointerGrab(dpy
, ButtonMotionMask
1972 | ButtonReleaseMask
| ButtonPressMask
,
1973 wCursor
[WCUR_TOPRIGHTRESIZE
], CurrentTime
);
1974 else if (res
== (DOWN
| LEFT
))
1975 XChangeActivePointerGrab(dpy
, ButtonMotionMask
1976 | ButtonReleaseMask
| ButtonPressMask
,
1977 wCursor
[WCUR_BOTTOMLEFTRESIZE
], CurrentTime
);
1978 else if (res
== (DOWN
| RIGHT
))
1979 XChangeActivePointerGrab(dpy
, ButtonMotionMask
1980 | ButtonReleaseMask
| ButtonPressMask
,
1981 wCursor
[WCUR_BOTTOMRIGHTRESIZE
], CurrentTime
);
1982 else if (res
== DOWN
|| res
== UP
)
1983 XChangeActivePointerGrab(dpy
, ButtonMotionMask
1984 | ButtonReleaseMask
| ButtonPressMask
,
1985 wCursor
[WCUR_VERTICALRESIZE
], CurrentTime
);
1986 else if (res
& (DOWN
| UP
))
1987 XChangeActivePointerGrab(dpy
, ButtonMotionMask
1988 | ButtonReleaseMask
| ButtonPressMask
,
1989 wCursor
[WCUR_VERTICALRESIZE
], CurrentTime
);
1990 else if (res
& (LEFT
| RIGHT
))
1991 XChangeActivePointerGrab(dpy
, ButtonMotionMask
1992 | ButtonReleaseMask
| ButtonPressMask
,
1993 wCursor
[WCUR_HORIZONRESIZE
], CurrentTime
);
1995 XGrabKeyboard(dpy
, root
, False
, GrabModeAsync
, GrabModeAsync
, CurrentTime
);
1999 /* Draw the resize frame for the first time. */
2000 mapGeometryDisplay(wwin
, fx
, fy
, fw
, fh
);
2002 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2004 showGeometry(wwin
, fx
, fy
, fx
+ fw
, fy
+ fh
, res
);
2009 if (wPreferences
.size_display
== WDIS_FRAME_CENTER
) {
2010 drawTransparentFrame(wwin
, orig_fx
, orig_fy
, orig_fw
, orig_fh
);
2011 moveGeometryDisplayCentered(scr
, fx
+ fw
/ 2, fy
+ fh
/ 2);
2012 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2014 drawTransparentFrame(wwin
, orig_fx
, orig_fy
, orig_fw
, orig_fh
);
2015 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2017 if (fh
!= orig_fh
|| fw
!= orig_fw
) {
2018 if (wPreferences
.size_display
== WDIS_NEW
) {
2019 showGeometry(wwin
, orig_fx
, orig_fy
, orig_fx
+ orig_fw
,
2020 orig_fy
+ orig_fh
, res
);
2022 showGeometry(wwin
, fx
, fy
, fx
+ fw
, fy
+ fh
, res
);
2031 if (event
.xbutton
.button
!= ev
->xbutton
.button
)
2035 showGeometry(wwin
, fx
, fy
, fx
+ fw
, fy
+ fh
, res
);
2037 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2039 XUngrabKeyboard(dpy
, CurrentTime
);
2040 WMUnmapWidget(scr
->gview
);
2043 if (wwin
->client
.width
!= fw
) {
2044 wwin
->flags
.user_changed_width
= 1;
2045 wwin
->flags
.maximized
&= ~(MAX_HORIZONTAL
| MAX_MAXIMUS
);
2048 if (wwin
->client
.height
!= fh
- vert_border
) {
2049 wwin
->flags
.user_changed_height
= 1;
2050 wwin
->flags
.maximized
&= ~(MAX_VERTICAL
| MAX_LEFTHALF
| MAX_RIGHTHALF
| MAX_MAXIMUS
);
2053 wWindowConfigure(wwin
, fx
, fy
, fw
, fh
- vert_border
);
2058 WMHandleEvent(&event
);
2062 if (wPreferences
.auto_arrange_icons
&& wXineramaHeads(scr
) > 1 && head
!= wGetHeadForWindow(wwin
)) {
2063 wArrangeIcons(scr
, True
);
2076 void wUnselectWindows(WScreen
* scr
)
2080 if (!scr
->selected_windows
)
2083 while (WMGetArrayItemCount(scr
->selected_windows
)) {
2084 wwin
= WMGetFromArray(scr
->selected_windows
, 0);
2085 if (wwin
->flags
.miniaturized
&& wwin
->icon
&& wwin
->icon
->selected
)
2086 wIconSelect(wwin
->icon
);
2088 wSelectWindow(wwin
, False
);
2090 WMFreeArray(scr
->selected_windows
);
2091 scr
->selected_windows
= NULL
;
2094 static void selectWindowsInside(WScreen
* scr
, int x1
, int y1
, int x2
, int y2
)
2098 /* select the windows and put them in the selected window list */
2099 tmpw
= scr
->focused_window
;
2100 while (tmpw
!= NULL
) {
2101 if (!(tmpw
->flags
.miniaturized
|| tmpw
->flags
.hidden
)) {
2102 if ((tmpw
->frame
->workspace
== scr
->current_workspace
|| IS_OMNIPRESENT(tmpw
))
2103 && (tmpw
->frame_x
>= x1
) && (tmpw
->frame_y
>= y1
)
2104 && (tmpw
->frame
->core
->width
+ tmpw
->frame_x
<= x2
)
2105 && (tmpw
->frame
->core
->height
+ tmpw
->frame_y
<= y2
)) {
2106 wSelectWindow(tmpw
, True
);
2113 void wSelectWindows(WScreen
* scr
, XEvent
* ev
)
2116 Window root
= scr
->root_win
;
2117 GC gc
= scr
->frame_gc
;
2118 int xp
= ev
->xbutton
.x_root
;
2119 int yp
= ev
->xbutton
.y_root
;
2123 if (XGrabPointer(dpy
, scr
->root_win
, False
, ButtonMotionMask
2124 | ButtonReleaseMask
| ButtonPressMask
, GrabModeAsync
,
2125 GrabModeAsync
, None
, wCursor
[WCUR_DEFAULT
], CurrentTime
) != Success
) {
2130 wUnselectWindows(scr
);
2132 XDrawRectangle(dpy
, root
, gc
, xp
, yp
, w
, h
);
2134 WMMaskEvent(dpy
, ButtonReleaseMask
| PointerMotionMask
| ButtonPressMask
, &event
);
2136 switch (event
.type
) {
2138 XDrawRectangle(dpy
, root
, gc
, x
, y
, w
, h
);
2139 x
= event
.xmotion
.x_root
;
2146 y
= event
.xmotion
.y_root
;
2153 XDrawRectangle(dpy
, root
, gc
, x
, y
, w
, h
);
2160 if (event
.xbutton
.button
!= ev
->xbutton
.button
)
2163 XDrawRectangle(dpy
, root
, gc
, x
, y
, w
, h
);
2165 XUngrabPointer(dpy
, CurrentTime
);
2166 selectWindowsInside(scr
, x
, y
, x
+ w
, y
+ h
);
2170 WMHandleEvent(&event
);
2176 void InteractivePlaceWindow(WWindow
* wwin
, int *x_ret
, int *y_ret
, unsigned width
, unsigned height
)
2178 WScreen
*scr
= wwin
->screen_ptr
;
2179 Window root
= scr
->root_win
;
2182 KeyCode shiftl
, shiftr
;
2186 if (XGrabPointer(dpy
, root
, True
, PointerMotionMask
| ButtonPressMask
,
2187 GrabModeAsync
, GrabModeAsync
, None
, wCursor
[WCUR_DEFAULT
], CurrentTime
) != Success
) {
2192 if (HAS_TITLEBAR(wwin
)) {
2193 h
= WMFontHeight(scr
->title_font
) + (wPreferences
.window_title_clearance
+
2194 TITLEBAR_EXTEND_SPACE
) * 2;
2197 if (HAS_RESIZEBAR(wwin
)) {
2198 height
+= RESIZEBAR_HEIGHT
;
2200 XGrabKeyboard(dpy
, root
, False
, GrabModeAsync
, GrabModeAsync
, CurrentTime
);
2201 XQueryPointer(dpy
, root
, &junkw
, &junkw
, &x
, &y
, &junk
, &junk
, (unsigned *)&junk
);
2202 mapPositionDisplay(wwin
, x
- width
/ 2, y
- h
/ 2, width
, height
);
2204 drawTransparentFrame(wwin
, x
- width
/ 2, y
- h
/ 2, width
, height
);
2206 shiftl
= XKeysymToKeycode(dpy
, XK_Shift_L
);
2207 shiftr
= XKeysymToKeycode(dpy
, XK_Shift_R
);
2209 WMMaskEvent(dpy
, PointerMotionMask
| ButtonPressMask
| ExposureMask
| KeyPressMask
, &event
);
2211 if (!checkMouseSamplingRate(&event
))
2214 switch (event
.type
) {
2216 if ((event
.xkey
.keycode
== shiftl
)
2217 || (event
.xkey
.keycode
== shiftr
)) {
2218 drawTransparentFrame(wwin
, x
- width
/ 2, y
- h
/ 2, width
, height
);
2219 cyclePositionDisplay(wwin
, x
- width
/ 2, y
- h
/ 2, width
, height
);
2220 drawTransparentFrame(wwin
, x
- width
/ 2, y
- h
/ 2, width
, height
);
2225 drawTransparentFrame(wwin
, x
- width
/ 2, y
- h
/ 2, width
, height
);
2227 x
= event
.xmotion
.x_root
;
2228 y
= event
.xmotion
.y_root
;
2230 if (wPreferences
.move_display
== WDIS_FRAME_CENTER
)
2231 moveGeometryDisplayCentered(scr
, x
, y
+ (height
- h
) / 2);
2233 showPosition(wwin
, x
- width
/ 2, y
- h
/ 2);
2235 drawTransparentFrame(wwin
, x
- width
/ 2, y
- h
/ 2, width
, height
);
2240 drawTransparentFrame(wwin
, x
- width
/ 2, y
- h
/ 2, width
, height
);
2242 *x_ret
= x
- width
/ 2;
2244 XUngrabPointer(dpy
, CurrentTime
);
2245 XUngrabKeyboard(dpy
, CurrentTime
);
2246 /* get rid of the geometry window */
2247 WMUnmapWidget(scr
->gview
);
2251 WMHandleEvent(&event
);