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_info
.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
;
259 int ty
, by
, my
, x
, y
, mx
, s
;
264 /* This seems necessary for some odd reason (too lazy to write x1-1 and
265 * x2-1 everywhere below in the code). But why only for x? */
268 if (HAS_BORDER(wwin
)) {
269 x1
+= FRAME_BORDER_WIDTH
;
270 x2
+= FRAME_BORDER_WIDTH
;
271 y1
+= FRAME_BORDER_WIDTH
;
272 y2
+= FRAME_BORDER_WIDTH
;
275 ty
= y1
+ wwin
->frame
->top_width
;
276 by
= y2
- wwin
->frame
->bottom_width
;
278 if (wPreferences
.size_display
== WDIS_NEW
) {
279 fw
= XTextWidth(scr
->tech_draw_font
, "8888", 4);
280 fh
= scr
->tech_draw_font
->ascent
+scr
->tech_draw_font
->descent
;
282 XSetForeground(dpy
, gc
, scr
->line_pixel
);
284 /* vertical geometry */
285 if (((direction
& LEFT
) && (x2
< scr
->scr_width
- fw
)) || (x1
< fw
)) {
294 /* top arrow & end bar */
295 segment
[0].x1
= x
- (s
+ 6); segment
[0].y1
= ty
;
296 segment
[0].x2
= x
- (s
- 10); segment
[0].y2
= ty
;
299 segment
[1].x1
= x
- (s
- 2); segment
[1].y1
= ty
+ 1;
300 segment
[1].x2
= x
- (s
- 5); segment
[1].y2
= ty
+ 7;
302 segment
[2].x1
= x
- (s
- 2); segment
[2].y1
= ty
+ 1;
303 segment
[2].x2
= x
- (s
+ 1); segment
[2].y2
= ty
+ 7;
306 segment
[3].x1
= x
- (s
- 2); segment
[3].y1
= ty
+ 1;
307 segment
[3].x2
= x
- (s
- 2); segment
[3].y2
= my
- fh
/2 - 1;
309 XDrawSegments(dpy
, root
, gc
, segment
, 4);
311 /* bottom arrow & end bar */
316 segment
[1].y1
= by
- 1;
317 segment
[1].y2
= by
- 7;
319 segment
[2].y1
= by
- 1;
320 segment
[2].y2
= by
- 7;
323 segment
[3].y1
= my
+ fh
/2 + 2;
324 segment
[3].y2
= by
- 1;
326 XDrawSegments(dpy
, root
, gc
, segment
, 4);
328 snprintf(num
, sizeof(num
), "%i", (by
- ty
- wwin
->normal_hints
->base_height
) /
329 wwin
->normal_hints
->height_inc
);
330 fw
= XTextWidth(scr
->tech_draw_font
, num
, strlen(num
));
332 /* Display the height. */
333 XSetFont(dpy
, gc
, scr
->tech_draw_font
->fid
);
334 XDrawString(dpy
, root
, gc
, x
- s
+ 3 - fw
/2, my
+ scr
->tech_draw_font
->ascent
- fh
/2 + 1, num
, strlen(num
));
336 /* horizontal geometry */
344 mx
= x1
+ (x2
- x1
)/2;
345 snprintf(num
, sizeof(num
), "%i", (x2
- x1
- wwin
->normal_hints
->base_width
) /
346 wwin
->normal_hints
->width_inc
);
347 fw
= XTextWidth(scr
->tech_draw_font
, num
, strlen(num
));
349 /* left arrow & end bar */
350 segment
[0].x1
= x1
; segment
[0].y1
= y
- (s
+ 6);
351 segment
[0].x2
= x1
; segment
[0].y2
= y
- (s
- 10);
354 segment
[1].x1
= x1
+ 7; segment
[1].y1
= y
- (s
+ 1);
355 segment
[1].x2
= x1
+ 1; segment
[1].y2
= y
- (s
- 2);
357 segment
[2].x1
= x1
+ 1; segment
[2].y1
= y
- (s
- 2);
358 segment
[2].x2
= x1
+ 7; segment
[2].y2
= y
- (s
- 5);
361 segment
[3].x1
= x1
+ 1; segment
[3].y1
= y
- (s
- 2);
362 segment
[3].x2
= mx
- fw
/2 - 2; segment
[3].y2
= y
- (s
- 2);
364 XDrawSegments(dpy
, root
, gc
, segment
, 4);
366 /* right arrow & end bar */
367 segment
[0].x1
= x2
+ 1;
368 segment
[0].x2
= x2
+ 1;
371 segment
[1].x1
= x2
- 6;
375 segment
[2].x2
= x2
- 6;
378 segment
[3].x1
= mx
+ fw
/2 + 2;
381 XDrawSegments(dpy
, root
, gc
, segment
, 4);
383 /* Display the width. */
384 XDrawString(dpy
, root
, gc
, mx
- fw
/2 + 1, y
- s
+ scr
->tech_draw_font
->ascent
- fh
/2 + 1, num
, strlen(num
));
386 WSetGeometryViewShownSize(scr
->gview
,
387 (x2
- x1
- wwin
->normal_hints
->base_width
)
388 / wwin
->normal_hints
->width_inc
,
389 (by
- ty
- wwin
->normal_hints
->base_height
)
390 / wwin
->normal_hints
->height_inc
);
396 cycleGeometryDisplay(WWindow
*wwin
, int x
, int y
, int w
, int h
, int dir
)
398 WScreen
*scr
= wwin
->screen_ptr
;
401 wPreferences
.size_display
++;
402 wPreferences
.size_display
%= NUM_DISPLAYS
;
404 if (wPreferences
.size_display
== WDIS_NEW
405 || wPreferences
.size_display
== WDIS_NONE
) {
406 WMUnmapWidget(scr
->gview
);
408 if (wPreferences
.size_display
== WDIS_CENTER
) {
409 rect
= wGetRectForHead(scr
, wGetHeadForWindow(wwin
));
410 moveGeometryDisplayCentered(scr
,
411 rect
.pos
.x
+ rect
.size
.width
/2,
412 rect
.pos
.y
+ rect
.size
.height
/2);
413 } else if (wPreferences
.size_display
== WDIS_TOPLEFT
) {
414 rect
= wGetRectForHead(scr
, wGetHeadForWindow(wwin
));
415 moveGeometryDisplayCentered(scr
, rect
.pos
.x
+ 1, rect
.pos
.y
+ 1);
416 } else if (wPreferences
.size_display
== WDIS_FRAME_CENTER
) {
417 moveGeometryDisplayCentered(scr
, x
+ w
/2, y
+ h
/2);
419 WMMapWidget(scr
->gview
);
420 showGeometry(wwin
, x
, y
, x
+ w
, y
+ h
, dir
);
426 mapGeometryDisplay(WWindow
*wwin
, int x
, int y
, int w
, int h
)
428 WScreen
*scr
= wwin
->screen_ptr
;
431 if (wPreferences
.size_display
== WDIS_NEW
432 || wPreferences
.size_display
== WDIS_NONE
)
435 if (wPreferences
.size_display
== WDIS_CENTER
) {
436 rect
= wGetRectForHead(scr
, wGetHeadForWindow(wwin
));
437 moveGeometryDisplayCentered(scr
,
438 rect
.pos
.x
+ rect
.size
.width
/2,
439 rect
.pos
.y
+ rect
.size
.height
/2);
440 } else if (wPreferences
.size_display
== WDIS_TOPLEFT
) {
441 rect
= wGetRectForHead(scr
, wGetHeadForWindow(wwin
));
442 moveGeometryDisplayCentered(scr
, rect
.pos
.x
+ 1, rect
.pos
.y
+ 1);
443 } else if (wPreferences
.size_display
== WDIS_FRAME_CENTER
) {
444 moveGeometryDisplayCentered(scr
, x
+ w
/2, y
+ h
/2);
446 WMMapWidget(scr
->gview
);
447 showGeometry(wwin
, x
, y
, x
+ w
, y
+ h
, 0);
453 doWindowMove(WWindow
*wwin
, WMArray
*array
, int dx
, int dy
)
456 WScreen
*scr
= wwin
->screen_ptr
;
459 if (!array
|| !WMGetArrayItemCount(array
)) {
460 wWindowMove(wwin
, wwin
->frame_x
+ dx
, wwin
->frame_y
+ dy
);
462 WMArrayIterator iter
;
464 WM_ITERATE_ARRAY(array
, tmpw
, iter
) {
465 x
= tmpw
->frame_x
+ dx
;
466 y
= tmpw
->frame_y
+ dy
;
468 #if 1 /* XXX: with xinerama patch was #if 0, check this */
469 /* don't let windows become unreachable */
471 if (x
+ (int)tmpw
->frame
->core
->width
< 20)
472 x
= 20 - (int)tmpw
->frame
->core
->width
;
473 else if (x
+ 20 > scr
->scr_width
)
474 x
= scr
->scr_width
- 20;
476 if (y
+ (int)tmpw
->frame
->core
->height
< 20)
477 y
= 20 - (int)tmpw
->frame
->core
->height
;
478 else if (y
+ 20 > scr
->scr_height
)
479 y
= scr
->scr_height
- 20;
481 wScreenBringInside(scr
, &x
, &y
,
482 (int)tmpw
->frame
->core
->width
,
483 (int)tmpw
->frame
->core
->height
);
486 wWindowMove(tmpw
, x
, y
);
493 drawTransparentFrame(WWindow
*wwin
, int x
, int y
, int width
, int height
)
495 Window root
= wwin
->screen_ptr
->root_win
;
496 GC gc
= wwin
->screen_ptr
->frame_gc
;
500 if (HAS_BORDER(wwin
)) {
501 x
+= FRAME_BORDER_WIDTH
;
502 y
+= FRAME_BORDER_WIDTH
;
505 if (!WFLAGP(wwin
, no_titlebar
) && !wwin
->flags
.shaded
) {
506 h
= WMFontHeight(wwin
->screen_ptr
->title_font
) + (wPreferences
.window_title_clearance
+ TITLEBAR_EXTEND_SPACE
) * 2;
508 if (!WFLAGP(wwin
, no_resizebar
) && !wwin
->flags
.shaded
) {
509 /* Can't use wwin-frame->bottom_width because, in some cases
510 (e.g. interactive placement), frame does not point to anything. */
511 bottom
= RESIZEBAR_HEIGHT
;
513 XDrawRectangle(dpy
, root
, gc
, x
- 1, y
- 1, width
+ 1, height
+ 1);
516 XDrawLine(dpy
, root
, gc
, x
, y
+ h
- 1, x
+ width
, y
+ h
- 1);
519 XDrawLine(dpy
, root
, gc
, x
, y
+ height
- bottom
,
520 x
+ width
, y
+ height
- bottom
);
526 drawFrames(WWindow
*wwin
, WMArray
*array
, int dx
, int dy
)
529 int scr_width
= wwin
->screen_ptr
->scr_width
;
530 int scr_height
= wwin
->screen_ptr
->scr_height
;
535 x
= wwin
->frame_x
+ dx
;
536 y
= wwin
->frame_y
+ dy
;
538 drawTransparentFrame(wwin
, x
, y
,
539 wwin
->frame
->core
->width
,
540 wwin
->frame
->core
->height
);
543 WMArrayIterator iter
;
545 WM_ITERATE_ARRAY(array
, tmpw
, iter
) {
546 x
= tmpw
->frame_x
+ dx
;
547 y
= tmpw
->frame_y
+ dy
;
549 /* don't let windows become unreachable */
550 #if 1 /* XXX: was 0 in XINERAMA patch, check */
551 if (x
+ (int)tmpw
->frame
->core
->width
< 20)
552 x
= 20 - (int)tmpw
->frame
->core
->width
;
553 else if (x
+ 20 > scr_width
)
556 if (y
+ (int)tmpw
->frame
->core
->height
< 20)
557 y
= 20 - (int)tmpw
->frame
->core
->height
;
558 else if (y
+ 20 > scr_height
)
562 wScreenBringInside(wwin
->screen_ptr
, &x
, &y
,
563 (int)tmpw
->frame
->core
->width
,
564 (int)tmpw
->frame
->core
->height
);
567 drawTransparentFrame(tmpw
, x
, y
, tmpw
->frame
->core
->width
,
568 tmpw
->frame
->core
->height
);
581 while (XCheckMaskEvent(dpy
, ButtonMotionMask
, &ev
)) ;
586 crossWorkspace(WScreen
*scr
, WWindow
*wwin
, int opaque_move
,
587 int new_workspace
, int rewind
)
589 /* do not let window be unmapped */
591 wwin
->flags
.changing_workspace
= 1;
592 wWindowChangeWorkspace(wwin
, new_workspace
);
594 /* go to new workspace */
595 wWorkspaceChange(scr
, new_workspace
);
597 wwin
->flags
.changing_workspace
= 0;
600 XWarpPointer(dpy
, None
, None
, 0, 0, 0, 0, scr
->scr_width
- 20, 0);
602 XWarpPointer(dpy
, None
, None
, 0, 0, 0, 0, -(scr
->scr_width
- 20), 0);
607 XGrabPointer(dpy
, scr
->root_win
, True
, PointerMotionMask
608 |ButtonReleaseMask
|ButtonPressMask
, GrabModeAsync
,
609 GrabModeAsync
, None
, wCursor
[WCUR_MOVE
], CurrentTime
);
617 /* arrays of WWindows sorted by the respective border position */
618 WWindow
**topList
; /* top border */
619 WWindow
**leftList
; /* left border */
620 WWindow
**rightList
; /* right border */
621 WWindow
**bottomList
; /* bottom border */
624 /* index of window in the above lists indicating the relative position
625 * of the window with the others */
631 int rubCount
; /* for workspace switching */
633 int winWidth
, winHeight
; /* width/height of the window */
634 int realX
, realY
; /* actual position of the window */
635 int calcX
, calcY
; /* calculated position of window */
636 int omouseX
, omouseY
; /* old mouse position */
637 int mouseX
, mouseY
; /* last known position of the pointer */
640 #define WTOP(w) (w)->frame_y
641 #define WLEFT(w) (w)->frame_x
642 #define WRIGHT(w) ((w)->frame_x + (int)(w)->frame->core->width - 1 + \
643 (HAS_BORDER(w) ? 2*FRAME_BORDER_WIDTH : 0))
644 #define WBOTTOM(w) ((w)->frame_y + (int)(w)->frame->core->height - 1 + \
645 (HAS_BORDER(w) ? 2*FRAME_BORDER_WIDTH : 0))
648 compareWTop(const void *a
, const void *b
)
650 WWindow
*wwin1
= *(WWindow
**)a
;
651 WWindow
*wwin2
= *(WWindow
**)b
;
653 if (WTOP(wwin1
) > WTOP(wwin2
))
655 else if (WTOP(wwin1
) < WTOP(wwin2
))
663 compareWLeft(const void *a
, const void *b
)
665 WWindow
*wwin1
= *(WWindow
**)a
;
666 WWindow
*wwin2
= *(WWindow
**)b
;
668 if (WLEFT(wwin1
) > WLEFT(wwin2
))
670 else if (WLEFT(wwin1
) < WLEFT(wwin2
))
678 compareWRight(const void *a
, const void *b
)
680 WWindow
*wwin1
= *(WWindow
**)a
;
681 WWindow
*wwin2
= *(WWindow
**)b
;
683 if (WRIGHT(wwin1
) < WRIGHT(wwin2
))
685 else if (WRIGHT(wwin1
) > WRIGHT(wwin2
))
694 compareWBottom(const void *a
, const void *b
)
696 WWindow
*wwin1
= *(WWindow
**)a
;
697 WWindow
*wwin2
= *(WWindow
**)b
;
699 if (WBOTTOM(wwin1
) < WBOTTOM(wwin2
))
701 else if (WBOTTOM(wwin1
) > WBOTTOM(wwin2
))
709 updateResistance(WWindow
*wwin
, MoveData
*data
, int newX
, int newY
)
712 int newX2
= newX
+ data
->winWidth
;
713 int newY2
= newY
+ data
->winHeight
;
716 if (newX
< data
->realX
) {
717 if (data
->rightIndex
> 0
718 && newX
< WRIGHT(data
->rightList
[data
->rightIndex
-1])) {
720 } else if (data
->leftIndex
<= data
->count
-1
721 && newX2
<= WLEFT(data
->leftList
[data
->leftIndex
])) {
724 } else if (newX
> data
->realX
) {
725 if (data
->leftIndex
> 0
726 && newX2
> WLEFT(data
->leftList
[data
->leftIndex
-1])) {
728 } else if (data
->rightIndex
<= data
->count
-1
729 && newX
>= WRIGHT(data
->rightList
[data
->rightIndex
])) {
735 if (newY
< data
->realY
) {
736 if (data
->bottomIndex
> 0
737 && newY
< WBOTTOM(data
->bottomList
[data
->bottomIndex
-1])) {
739 } else if (data
->topIndex
<= data
->count
-1
740 && newY2
<= WTOP(data
->topList
[data
->topIndex
])) {
743 } else if (newY
> data
->realY
) {
744 if (data
->topIndex
> 0
745 && newY2
> WTOP(data
->topList
[data
->topIndex
-1])) {
747 } else if (data
->bottomIndex
<= data
->count
-1
748 && newY
>= WBOTTOM(data
->bottomList
[data
->bottomIndex
])) {
757 /* TODO: optimize this */
758 if (data
->realY
< WBOTTOM(data
->bottomList
[0])) {
759 data
->bottomIndex
= 0;
761 if (data
->realX
< WRIGHT(data
->rightList
[0])) {
762 data
->rightIndex
= 0;
764 if ((data
->realX
+ data
->winWidth
) > WLEFT(data
->leftList
[0])) {
767 if ((data
->realY
+ data
->winHeight
) > WTOP(data
->topList
[0])) {
770 for (i
= 0; i
< data
->count
; i
++) {
771 if (data
->realY
> WBOTTOM(data
->bottomList
[i
])) {
772 data
->bottomIndex
= i
+ 1;
774 if (data
->realX
> WRIGHT(data
->rightList
[i
])) {
775 data
->rightIndex
= i
+ 1;
777 if ((data
->realX
+ data
->winWidth
) < WLEFT(data
->leftList
[i
])) {
778 data
->leftIndex
= i
+ 1;
780 if ((data
->realY
+ data
->winHeight
) < WTOP(data
->topList
[i
])) {
781 data
->topIndex
= i
+ 1;
788 freeMoveData(MoveData
*data
)
791 wfree(data
->topList
);
793 wfree(data
->leftList
);
795 wfree(data
->rightList
);
796 if (data
->bottomList
)
797 wfree(data
->bottomList
);
802 updateMoveData(WWindow
*wwin
, MoveData
*data
)
804 WScreen
*scr
= wwin
->screen_ptr
;
809 tmp
= scr
->focused_window
;
811 if (tmp
!= wwin
&& scr
->current_workspace
== tmp
->frame
->workspace
812 && !tmp
->flags
.miniaturized
813 && !tmp
->flags
.hidden
814 && !tmp
->flags
.obscured
815 && !WFLAGP(tmp
, sunken
)) {
816 data
->topList
[data
->count
] = tmp
;
817 data
->leftList
[data
->count
] = tmp
;
818 data
->rightList
[data
->count
] = tmp
;
819 data
->bottomList
[data
->count
] = tmp
;
825 if (data
->count
== 0) {
828 data
->rightIndex
= 0;
829 data
->bottomIndex
= 0;
833 /* order from closest to the border of the screen to farthest */
835 qsort(data
->topList
, data
->count
, sizeof(WWindow
**), compareWTop
);
836 qsort(data
->leftList
, data
->count
, sizeof(WWindow
**), compareWLeft
);
837 qsort(data
->rightList
, data
->count
, sizeof(WWindow
**), compareWRight
);
838 qsort(data
->bottomList
, data
->count
, sizeof(WWindow
**), compareWBottom
);
840 /* figure the position of the window relative to the others */
843 data
->leftIndex
= -1;
844 data
->rightIndex
= -1;
845 data
->bottomIndex
= -1;
847 if (WTOP(wwin
) < WBOTTOM(data
->bottomList
[0])) {
848 data
->bottomIndex
= 0;
850 if (WLEFT(wwin
) < WRIGHT(data
->rightList
[0])) {
851 data
->rightIndex
= 0;
853 if (WRIGHT(wwin
) > WLEFT(data
->leftList
[0])) {
856 if (WBOTTOM(wwin
) > WTOP(data
->topList
[0])) {
859 for (i
= 0; i
< data
->count
; i
++) {
860 if (WTOP(wwin
) >= WBOTTOM(data
->bottomList
[i
])) {
861 data
->bottomIndex
= i
+ 1;
863 if (WLEFT(wwin
) >= WRIGHT(data
->rightList
[i
])) {
864 data
->rightIndex
= i
+ 1;
866 if (WRIGHT(wwin
) <= WLEFT(data
->leftList
[i
])) {
867 data
->leftIndex
= i
+ 1;
869 if (WBOTTOM(wwin
) <= WTOP(data
->topList
[i
])) {
870 data
->topIndex
= i
+ 1;
877 initMoveData(WWindow
*wwin
, MoveData
*data
)
882 memset(data
, 0, sizeof(MoveData
));
884 for (i
= 0, tmp
= wwin
->screen_ptr
->focused_window
;
886 tmp
= tmp
->prev
, i
++);
889 data
->topList
= wmalloc(sizeof(WWindow
*) * i
);
890 data
->leftList
= wmalloc(sizeof(WWindow
*) * i
);
891 data
->rightList
= wmalloc(sizeof(WWindow
*) * i
);
892 data
->bottomList
= wmalloc(sizeof(WWindow
*) * i
);
894 updateMoveData(wwin
, data
);
897 data
->realX
= wwin
->frame_x
;
898 data
->realY
= wwin
->frame_y
;
899 data
->calcX
= wwin
->frame_x
;
900 data
->calcY
= wwin
->frame_y
;
902 data
->winWidth
= wwin
->frame
->core
->width
+
903 (HAS_BORDER(wwin
) ? 2*FRAME_BORDER_WIDTH
: 0);
904 data
->winHeight
= wwin
->frame
->core
->height
+
905 (HAS_BORDER(wwin
) ? 2*FRAME_BORDER_WIDTH
: 0);
910 checkWorkspaceChange(WWindow
*wwin
, MoveData
*data
, Bool opaqueMove
)
912 WScreen
*scr
= wwin
->screen_ptr
;
913 Bool changed
= False
;
915 if (data
->mouseX
<= 1) {
916 if (scr
->current_workspace
> 0) {
918 crossWorkspace(scr
, wwin
, opaqueMove
, scr
->current_workspace
- 1,
923 } else if (scr
->current_workspace
== 0 && wPreferences
.ws_cycle
) {
925 crossWorkspace(scr
, wwin
, opaqueMove
, scr
->workspace_count
- 1,
930 } else if (data
->mouseX
>= scr
->scr_width
- 2) {
932 if (scr
->current_workspace
== scr
->workspace_count
- 1) {
934 if (wPreferences
.ws_cycle
935 || scr
->workspace_count
== MAX_WORKSPACES
) {
937 crossWorkspace(scr
, wwin
, opaqueMove
, 0, False
);
941 /* if user insists on trying to go to next workspace even when
942 * it's already the last, create a new one */
943 else if (data
->omouseX
== data
->mouseX
944 && wPreferences
.ws_advance
) {
946 /* detect user "rubbing" the window against the edge */
947 if (data
->rubCount
> 0
948 && data
->omouseY
- data
->mouseY
> MOVE_THRESHOLD
) {
950 data
->rubCount
= -(data
->rubCount
+ 1);
952 } else if (data
->rubCount
<= 0
953 && data
->mouseY
- data
->omouseY
> MOVE_THRESHOLD
) {
955 data
->rubCount
= -data
->rubCount
+ 1;
958 /* create a new workspace */
959 if (abs(data
->rubCount
) > 2) {
960 /* go to next workspace */
963 crossWorkspace(scr
, wwin
, opaqueMove
,
964 scr
->current_workspace
+1, False
);
968 } else if (scr
->current_workspace
< scr
->workspace_count
) {
970 /* go to next workspace */
971 crossWorkspace(scr
, wwin
, opaqueMove
,
972 scr
->current_workspace
+1, False
);
985 updateWindowPosition(WWindow
*wwin
, MoveData
*data
, Bool doResistance
,
986 Bool opaqueMove
, int newMouseX
, int newMouseY
)
988 WScreen
*scr
= wwin
->screen_ptr
;
989 int dx
, dy
; /* how much mouse moved */
990 int winL
, winR
, winT
, winB
; /* requested new window position */
991 int newX
, newY
; /* actual new window position */
992 Bool hresist
, vresist
;
1001 /* check the direction of the movement */
1002 dx
= newMouseX
- data
->mouseX
;
1003 dy
= newMouseY
- data
->mouseY
;
1005 data
->omouseX
= data
->mouseX
;
1006 data
->omouseY
= data
->mouseY
;
1007 data
->mouseX
= newMouseX
;
1008 data
->mouseY
= newMouseY
;
1010 winL
= data
->calcX
+ dx
;
1011 winR
= data
->calcX
+ data
->winWidth
+ dx
;
1012 winT
= data
->calcY
+ dy
;
1013 winB
= data
->calcY
+ data
->winHeight
+ dy
;
1025 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1026 attract
= wPreferences
.attract
;
1027 /* horizontal movement: check horizontal edge resistances */
1031 /* window is the leftmost window: check against screen edge */
1033 /* Add inter head resistance 1/2 (if needed) */
1034 head
= wGetHeadForPointerLocation(scr
);
1035 rect
= wGetRectForHead(scr
, head
);
1037 l_edge
= WMAX(scr
->totalUsableArea
[head
].x1
, rect
.pos
.x
);
1038 edge_l
= l_edge
- resist
;
1039 edge_r
= WMIN(scr
->totalUsableArea
[head
].x2
, rect
.pos
.x
+ rect
.size
.width
);
1040 r_edge
= edge_r
+ resist
;
1043 if ((data
->rightIndex
>= 0) && (data
->rightIndex
<= data
->count
)) {
1046 for (i
= data
->rightIndex
- 1; i
>= 0; i
--) {
1047 looprw
= data
->rightList
[i
];
1048 if (!(data
->realY
> WBOTTOM(looprw
)
1049 || (data
->realY
+ data
->winHeight
) < WTOP(looprw
))) {
1051 || ((data
->realX
< (WRIGHT(looprw
) + 2)) && dx
< 0)) {
1052 l_edge
= WRIGHT(looprw
) + 1;
1053 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1060 for (i
= data
->rightIndex
; i
< data
->count
; i
++) {
1061 looprw
= data
->rightList
[i
];
1062 if(!(data
->realY
> WBOTTOM(looprw
)
1063 || (data
->realY
+ data
->winHeight
) < WTOP(looprw
))) {
1064 r_edge
= WRIGHT(looprw
) + 1;
1065 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1072 if ((data
->leftIndex
>= 0) && (data
->leftIndex
<= data
->count
)) {
1075 for (i
= data
->leftIndex
- 1; i
>= 0; i
--) {
1076 looprw
= data
->leftList
[i
];
1077 if (!(data
->realY
> WBOTTOM(looprw
)
1078 || (data
->realY
+ data
->winHeight
) < WTOP(looprw
))) {
1080 || (((data
->realX
+ data
->winWidth
) > (WLEFT(looprw
) - 1)) && dx
> 0)) {
1081 edge_r
= WLEFT(looprw
);
1082 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1089 for (i
= data
->leftIndex
; i
< data
->count
; i
++) {
1090 looprw
= data
->leftList
[i
];
1091 if(!(data
->realY
> WBOTTOM(looprw
)
1092 || (data
->realY
+ data
->winHeight
) < WTOP(looprw
))) {
1093 edge_l
= WLEFT(looprw
);
1094 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1101 printf("%d %d\n",winL,winR);
1102 printf("l_ %d r_ %d _l %d _r %d\n",l_edge,r_edge,edge_l,edge_r);
1105 if ((winL
- l_edge
) < (r_edge
- winL
)) {
1107 if ((attract
&& winL
<= l_edge
+ resist
&& winL
>= l_edge
- resist
)
1108 || (dx
< 0 && winL
<= l_edge
&& winL
>= l_edge
- resist
)) {
1114 if (resist
> 0 && attract
&& winL
>= r_edge
- resist
&& winL
<= r_edge
+ resist
) {
1120 if ((winR
- edge_l
) < (edge_r
- winR
)) {
1121 if (resist
> 0 && attract
&& winR
<= edge_l
+ resist
&& winR
>= edge_l
- resist
) {
1122 newX
= edge_l
- data
->winWidth
;
1127 if ((attract
&& winR
>= edge_r
- resist
&& winR
<= edge_r
+ resist
)
1128 || (dx
> 0 && winR
>= edge_r
&& winR
<= edge_r
+ resist
)) {
1129 newX
= edge_r
- data
->winWidth
;
1136 /* Add inter head resistance 2/2 (if needed) */
1137 t_edge
= WMAX(scr
->totalUsableArea
[head
].y1
, rect
.pos
.y
);
1138 edge_t
= t_edge
- resist
;
1139 edge_b
= WMIN(scr
->totalUsableArea
[head
].y2
, rect
.pos
.y
+ rect
.size
.height
);
1140 b_edge
= edge_b
+ resist
;
1142 if ((data
->bottomIndex
>= 0) && (data
->bottomIndex
<= data
->count
)) {
1145 for (i
= data
->bottomIndex
- 1; i
>= 0; i
--) {
1146 looprw
= data
->bottomList
[i
];
1147 if (!(data
->realX
> WRIGHT(looprw
)
1148 || (data
->realX
+ data
->winWidth
) < WLEFT(looprw
))) {
1150 || ((data
->realY
< (WBOTTOM(looprw
) + 2)) && dy
< 0)) {
1151 t_edge
= WBOTTOM(looprw
) + 1;
1152 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1159 for (i
= data
->bottomIndex
; i
< data
->count
; i
++) {
1160 looprw
= data
->bottomList
[i
];
1161 if(!(data
->realX
> WRIGHT(looprw
)
1162 || (data
->realX
+ data
->winWidth
) < WLEFT(looprw
))) {
1163 b_edge
= WBOTTOM(looprw
) + 1;
1164 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1171 if ((data
->topIndex
>= 0) && (data
->topIndex
<= data
->count
)) {
1174 for (i
= data
->topIndex
- 1; i
>= 0; i
--) {
1175 looprw
= data
->topList
[i
];
1176 if (!(data
->realX
> WRIGHT(looprw
)
1177 || (data
->realX
+ data
->winWidth
) < WLEFT(looprw
))) {
1179 || (((data
->realY
+ data
->winHeight
) > (WTOP(looprw
) - 1)) && dy
> 0)) {
1180 edge_b
= WTOP(looprw
);
1181 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1188 for (i
= data
->topIndex
; i
< data
->count
; i
++) {
1189 looprw
= data
->topList
[i
];
1190 if(!(data
->realX
> WRIGHT(looprw
)
1191 || (data
->realX
+ data
->winWidth
) < WLEFT(looprw
))) {
1192 edge_t
= WTOP(looprw
);
1193 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1199 if ((winT
- t_edge
) < (b_edge
- winT
)) {
1201 if ((attract
&& winT
<= t_edge
+ resist
&& winT
>= t_edge
- resist
)
1202 || (dy
< 0 && winT
<= t_edge
&& winT
>= t_edge
- resist
)) {
1209 if (resist
> 0 && attract
&& winT
>= b_edge
- resist
&& winT
<= b_edge
+ resist
) {
1215 if ((winB
- edge_t
) < (edge_b
- winB
)) {
1216 if (resist
> 0 && attract
&& winB
<= edge_t
+ resist
&& winB
>= edge_t
- resist
) {
1217 newY
= edge_t
- data
->winHeight
;
1223 if ((attract
&& winB
>= edge_b
- resist
&& winB
<= edge_b
+ resist
)
1224 || (dy
> 0 && winB
>= edge_b
&& winB
<= edge_b
+ resist
)) {
1225 newY
= edge_b
- data
->winHeight
;
1235 /* update window position */
1239 if (((dx
> 0 && data
->calcX
- data
->realX
> 0)
1240 || (dx
< 0 && data
->calcX
- data
->realX
< 0)) && !hresist
)
1243 if (((dy
> 0 && data
->calcY
- data
->realY
> 0)
1244 || (dy
< 0 && data
->calcY
- data
->realY
< 0)) && !vresist
)
1247 if (data
->realX
!= newX
|| data
->realY
!= newY
) {
1249 if (wPreferences
.move_display
== WDIS_NEW
1250 && !scr
->selected_windows
) {
1251 showPosition(wwin
, data
->realX
, data
->realY
);
1254 doWindowMove(wwin
, scr
->selected_windows
,
1255 newX
- wwin
->frame_x
,
1256 newY
- wwin
->frame_y
);
1259 drawFrames(wwin
, scr
->selected_windows
,
1260 data
->realX
- wwin
->frame_x
,
1261 data
->realY
- wwin
->frame_y
);
1264 if (!scr
->selected_windows
1265 && wPreferences
.move_display
== WDIS_FRAME_CENTER
) {
1267 moveGeometryDisplayCentered(scr
, newX
+ data
->winWidth
/2,
1268 newY
+ data
->winHeight
/2);
1273 drawFrames(wwin
, scr
->selected_windows
,
1274 newX
- wwin
->frame_x
,
1275 newY
- wwin
->frame_y
);
1278 if (!scr
->selected_windows
) {
1279 showPosition(wwin
, newX
, newY
);
1284 /* recalc relative window position */
1285 if (doResistance
&& (data
->realX
!= newX
|| data
->realY
!= newY
)) {
1286 updateResistance(wwin
, data
, newX
, newY
);
1294 #define _KS KEY_CONTROL_WINDOW_WEIGHT
1297 wKeyboardMoveResizeWindow(WWindow
*wwin
)
1299 WScreen
*scr
= wwin
->screen_ptr
;
1300 Window root
= scr
->root_win
;
1302 int w
= wwin
->frame
->core
->width
;
1303 int h
= wwin
->frame
->core
->height
;
1304 int scr_width
= wwin
->screen_ptr
->scr_width
;
1305 int scr_height
= wwin
->screen_ptr
->scr_height
;
1306 int vert_border
= wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
;
1307 int src_x
= wwin
->frame_x
;
1308 int src_y
= wwin
->frame_y
;
1309 int done
,off_x
,off_y
,ww
,wh
;
1312 KeySym keysym
=NoSymbol
;
1314 KeyCode shiftl
,shiftr
,ctrll
,ctrlmode
;
1316 shiftl
= XKeysymToKeycode(dpy
, XK_Shift_L
);
1317 shiftr
= XKeysymToKeycode(dpy
, XK_Shift_R
);
1318 ctrll
= XKeysymToKeycode(dpy
, XK_Control_L
);
1319 ctrlmode
=done
=off_x
=off_y
=0;
1323 XGrabKeyboard(dpy
, root
, False
, GrabModeAsync
, GrabModeAsync
, CurrentTime
);
1325 if (!wwin
->flags
.selected
) {
1326 wUnselectWindows(scr
);
1329 XGrabPointer(dpy
, scr
->root_win
, True
, PointerMotionMask
1330 |ButtonReleaseMask
|ButtonPressMask
, GrabModeAsync
,
1331 GrabModeAsync
, None
, wCursor
[WCUR_DEFAULT
], CurrentTime
);
1333 if (wwin
->flags
.shaded
|| scr
->selected_windows
) {
1334 if(scr
->selected_windows
)
1335 drawFrames(wwin
,scr
->selected_windows
,off_x
,off_y
);
1336 else drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, w
, h
);
1337 if(!scr
->selected_windows
)
1338 mapPositionDisplay(wwin
, src_x
, src_y
, w
, h
);
1340 drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, w
, h
);
1350 WMMaskEvent(dpy
, KeyPressMask
| ButtonReleaseMask
1351 | ButtonPressMask
| ExposureMask
, &event
);
1352 if (event
.type
== Expose
) {
1353 WMHandleEvent(&event
);
1355 } while (event
.type
== Expose
);
1358 if (wwin
->flags
.shaded
|| scr
->selected_windows
) {
1359 if(scr
->selected_windows
)
1360 drawFrames(wwin
,scr
->selected_windows
,off_x
,off_y
);
1361 else drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, w
, h
);
1362 /*** I HATE EDGE RESISTANCE - ]d ***/
1365 drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, ww
, wh
);
1369 showGeometry(wwin
, src_x
+off_x
, src_y
+off_y
, src_x
+off_x
+ww
, src_y
+off_y
+wh
,0);
1374 switch (event
.type
) {
1377 if (event
.xkey
.time
- lastTime
> 50) {
1378 kspeed
/=(1 + (event
.xkey
.time
- lastTime
)/100);
1384 if (kspeed
< _KS
) kspeed
= _KS
;
1385 lastTime
= event
.xkey
.time
;
1387 if (event
.xkey
.state
& ControlMask
&& !wwin
->flags
.shaded
) {
1389 wUnselectWindows(scr
);
1394 if (event
.xkey
.keycode
== shiftl
|| event
.xkey
.keycode
== shiftr
) {
1396 cycleGeometryDisplay(wwin
, src_x
+off_x
, src_y
+off_y
, ww
, wh
, 0);
1398 cyclePositionDisplay(wwin
, src_x
+off_x
, src_y
+off_y
, ww
, wh
);
1402 keysym
= XLookupKeysym(&event
.xkey
, 0);
1457 if (moment
!= RIGHT
)
1468 wWindowConstrainSize(wwin
, &ww
, &wh
);
1471 if (wPreferences
.ws_cycle
){
1472 if (src_x
+ off_x
+ ww
< 20){
1473 if(!scr
->current_workspace
) {
1474 wWorkspaceChange(scr
, scr
->workspace_count
-1);
1476 else wWorkspaceChange(scr
, scr
->current_workspace
-1);
1479 else if (src_x
+ off_x
+ 20 > scr_width
){
1480 if(scr
->current_workspace
== scr
->workspace_count
-1) {
1481 wWorkspaceChange(scr
, 0);
1483 else wWorkspaceChange(scr
, scr
->current_workspace
+1);
1488 if (src_x
+ off_x
+ ww
< 20)
1489 off_x
= 20 - ww
- src_x
;
1490 else if (src_x
+ off_x
+ 20 > scr_width
)
1491 off_x
= scr_width
- 20 - src_x
;
1494 if (src_y
+ off_y
+ wh
< 20) {
1495 off_y
= 20 - wh
- src_y
;
1497 else if (src_y
+ off_y
+ 20 > scr_height
) {
1498 off_y
= scr_height
- 20 - src_y
;
1507 WMHandleEvent(&event
);
1508 while (XCheckTypedEvent(dpy
, Expose
, &event
)) {
1509 WMHandleEvent(&event
);
1514 WMHandleEvent(&event
);
1521 if (wwin
->flags
.shaded
&& !scr
->selected_windows
){
1522 moveGeometryDisplayCentered(scr
, src_x
+off_x
+ w
/2, src_y
+off_y
+ h
/2);
1525 WMUnmapWidget(scr
->gview
);
1526 mapGeometryDisplay(wwin
, src_x
+off_x
, src_y
+off_y
, ww
, wh
);
1527 } else if(!scr
->selected_windows
) {
1528 WMUnmapWidget(scr
->gview
);
1529 mapPositionDisplay(wwin
, src_x
+off_x
, src_y
+off_y
, ww
, wh
);
1533 if (wwin
->flags
.shaded
|| scr
->selected_windows
) {
1534 if (scr
->selected_windows
)
1535 drawFrames(wwin
,scr
->selected_windows
,off_x
,off_y
);
1537 drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, w
, h
);
1539 drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, ww
, wh
);
1544 showGeometry(wwin
, src_x
+off_x
, src_y
+off_y
, src_x
+off_x
+ww
, src_y
+off_y
+wh
,0);
1545 } else if(!scr
->selected_windows
)
1546 showPosition(wwin
, src_x
+off_x
, src_y
+off_y
);
1550 scr
->keymove_tick
=0;
1552 WMDeleteTimerWithClientData(&looper);
1554 if (wwin
->flags
.shaded
|| scr
->selected_windows
) {
1555 if(scr
->selected_windows
)
1556 drawFrames(wwin
,scr
->selected_windows
,off_x
,off_y
);
1557 else drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, w
, h
);
1560 drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, ww
, wh
);
1564 showGeometry(wwin
, src_x
+off_x
, src_y
+off_y
, src_x
+off_x
+ww
, src_y
+off_y
+wh
,0);
1565 WMUnmapWidget(scr
->gview
);
1567 WMUnmapWidget(scr
->gview
);
1569 XUngrabKeyboard(dpy
, CurrentTime
);
1570 XUngrabPointer(dpy
, CurrentTime
);
1574 if (wwin
->flags
.shaded
|| scr
->selected_windows
) {
1575 if (!scr
->selected_windows
) {
1576 wWindowMove(wwin
, src_x
+off_x
, src_y
+off_y
);
1577 wWindowSynthConfigureNotify(wwin
);
1579 WMArrayIterator iter
;
1582 doWindowMove(wwin
, scr
->selected_windows
, off_x
, off_y
);
1584 WM_ITERATE_ARRAY(scr
->selected_windows
, foo
, iter
) {
1585 wWindowSynthConfigureNotify(foo
);
1589 if (wwin
->client
.width
!= ww
)
1590 wwin
->flags
.user_changed_width
= 1;
1592 if (wwin
->client
.height
!= wh
- vert_border
)
1593 wwin
->flags
.user_changed_height
= 1;
1595 wWindowConfigure(wwin
, src_x
+off_x
, src_y
+off_y
,
1596 ww
, wh
- vert_border
);
1597 wWindowSynthConfigureNotify(wwin
);
1599 wWindowChangeWorkspace(wwin
, scr
->current_workspace
);
1600 wSetFocusTo(scr
, wwin
);
1609 *----------------------------------------------------------------------
1610 * wMouseMoveWindow--
1611 * Move the named window and the other selected ones (if any),
1612 * interactively. Also shows the position of the window, if only one
1613 * window is being moved.
1614 * If the window is not on the selected window list, the selected
1615 * windows are deselected.
1616 * If shift is pressed during the operation, the position display
1617 * is changed to another type.
1620 * True if the window was moved, False otherwise.
1623 * The window(s) position is changed, and the client(s) are
1624 * notified about that.
1625 * The position display configuration may be changed.
1626 *----------------------------------------------------------------------
1629 wMouseMoveWindow(WWindow
*wwin
, XEvent
*ev
)
1631 WScreen
*scr
= wwin
->screen_ptr
;
1633 Window root
= scr
->root_win
;
1634 KeyCode shiftl
, shiftr
;
1638 /* This needs not to change while moving, else bad things can happen */
1639 int opaqueMove
= wPreferences
.opaque_move
;
1641 #ifdef GHOST_WINDOW_MOVE
1644 rimg
= InitGhostWindowMove(scr
);
1648 if (wPreferences
.opaque_move
&& !wPreferences
.use_saveunders
) {
1649 XSetWindowAttributes attr
;
1651 attr
.save_under
= True
;
1652 XChangeWindowAttributes(dpy
, wwin
->frame
->core
->window
,
1653 CWSaveUnder
, &attr
);
1657 initMoveData(wwin
, &moveData
);
1659 moveData
.mouseX
= ev
->xmotion
.x_root
;
1660 moveData
.mouseY
= ev
->xmotion
.y_root
;
1662 if (!wwin
->flags
.selected
) {
1663 /* this window is not selected, unselect others and move only wwin */
1664 wUnselectWindows(scr
);
1667 puts("Moving window");
1669 shiftl
= XKeysymToKeycode(dpy
, XK_Shift_L
);
1670 shiftr
= XKeysymToKeycode(dpy
, XK_Shift_R
);
1676 /* XWarpPointer() doesn't seem to generate Motion events, so
1677 * we've got to simulate them */
1678 XQueryPointer(dpy
, root
, &junkw
, &junkw
, &event
.xmotion
.x_root
,
1679 &event
.xmotion
.y_root
, &junk
, &junk
,
1680 (unsigned *) &junk
);
1682 WMMaskEvent(dpy
, KeyPressMask
| ButtonMotionMask
1683 | PointerMotionHintMask
1684 | ButtonReleaseMask
| ButtonPressMask
| ExposureMask
,
1687 if (event
.type
== MotionNotify
) {
1688 /* compress MotionNotify events */
1689 while (XCheckMaskEvent(dpy
, ButtonMotionMask
, &event
)) ;
1690 if (!checkMouseSamplingRate(&event
))
1694 switch (event
.type
) {
1696 if ((event
.xkey
.keycode
== shiftl
|| event
.xkey
.keycode
== shiftr
)
1697 && started
&& !scr
->selected_windows
) {
1700 drawFrames(wwin
, scr
->selected_windows
,
1701 moveData
.realX
- wwin
->frame_x
,
1702 moveData
.realY
- wwin
->frame_y
);
1705 if (wPreferences
.move_display
== WDIS_NEW
1706 && !scr
->selected_windows
) {
1707 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1710 cyclePositionDisplay(wwin
, moveData
.realX
, moveData
.realY
,
1711 moveData
.winWidth
, moveData
.winHeight
);
1713 if (wPreferences
.move_display
== WDIS_NEW
1714 && !scr
->selected_windows
) {
1716 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1720 drawFrames(wwin
, scr
->selected_windows
,
1721 moveData
.realX
- wwin
->frame_x
,
1722 moveData
.realY
- wwin
->frame_y
);
1725 WMHandleEvent(&event); this causes problems needs fixing */
1731 updateWindowPosition(wwin
, &moveData
,
1732 scr
->selected_windows
== NULL
1733 && wPreferences
.edge_resistance
> 0,
1735 event
.xmotion
.x_root
,
1736 event
.xmotion
.y_root
);
1738 if (!warped
&& !wPreferences
.no_autowrap
) {
1739 int oldWorkspace
= scr
->current_workspace
;
1741 if (wPreferences
.move_display
== WDIS_NEW
1742 && !scr
->selected_windows
) {
1743 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1747 drawFrames(wwin
, scr
->selected_windows
,
1748 moveData
.realX
- wwin
->frame_x
,
1749 moveData
.realY
- wwin
->frame_y
);
1751 if (checkWorkspaceChange(wwin
, &moveData
, opaqueMove
)) {
1752 if (scr
->current_workspace
!= oldWorkspace
1753 && wPreferences
.edge_resistance
> 0
1754 && scr
->selected_windows
== NULL
)
1755 updateMoveData(wwin
, &moveData
);
1759 drawFrames(wwin
, scr
->selected_windows
,
1760 moveData
.realX
- wwin
->frame_x
,
1761 moveData
.realY
- wwin
->frame_y
);
1763 if (wPreferences
.move_display
== WDIS_NEW
1764 && !scr
->selected_windows
) {
1766 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1772 } else if (abs(ev
->xmotion
.x_root
- event
.xmotion
.x_root
) >= MOVE_THRESHOLD
1773 || abs(ev
->xmotion
.y_root
- event
.xmotion
.y_root
) >= MOVE_THRESHOLD
) {
1775 XChangeActivePointerGrab(dpy
, ButtonMotionMask
1776 | ButtonReleaseMask
| ButtonPressMask
,
1777 wCursor
[WCUR_MOVE
], CurrentTime
);
1779 XGrabKeyboard(dpy
, root
, False
, GrabModeAsync
, GrabModeAsync
,
1782 if (!scr
->selected_windows
)
1783 mapPositionDisplay(wwin
, moveData
.realX
, moveData
.realY
,
1784 moveData
.winWidth
, moveData
.winHeight
);
1786 if (started
&& !opaqueMove
)
1787 drawFrames(wwin
, scr
->selected_windows
, 0, 0);
1789 if (!opaqueMove
|| (wPreferences
.move_display
==WDIS_NEW
1790 && !scr
->selected_windows
)) {
1792 if (wPreferences
.move_display
==WDIS_NEW
)
1793 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1802 if (event
.xbutton
.button
!= ev
->xbutton
.button
)
1808 drawFrames(wwin
, scr
->selected_windows
,
1809 moveData
.realX
- wwin
->frame_x
,
1810 moveData
.realY
- wwin
->frame_y
);
1812 doWindowMove(wwin
, scr
->selected_windows
,
1813 moveData
.realX
- wwin
->frame_x
,
1814 moveData
.realY
- wwin
->frame_y
);
1816 #ifndef CONFIGURE_WINDOW_WHILE_MOVING
1817 wWindowSynthConfigureNotify(wwin
);
1819 XUngrabKeyboard(dpy
, CurrentTime
);
1822 wWindowChangeWorkspace(wwin
, scr
->current_workspace
);
1823 wSetFocusTo(scr
, wwin
);
1825 if (wPreferences
.move_display
== WDIS_NEW
)
1826 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1828 /* discard all enter/leave events that happened until
1829 * the time the button was released */
1830 while (XCheckTypedEvent(dpy
, EnterNotify
, &e
)) {
1831 if (e
.xcrossing
.time
> event
.xbutton
.time
) {
1832 XPutBackEvent(dpy
, &e
);
1836 while (XCheckTypedEvent(dpy
, LeaveNotify
, &e
)) {
1837 if (e
.xcrossing
.time
> event
.xbutton
.time
) {
1838 XPutBackEvent(dpy
, &e
);
1843 if (!scr
->selected_windows
) {
1844 /* get rid of the geometry window */
1845 WMUnmapWidget(scr
->gview
);
1849 puts("End move window");
1855 if (started
&& !opaqueMove
) {
1856 drawFrames(wwin
, scr
->selected_windows
,
1857 moveData
.realX
- wwin
->frame_x
,
1858 moveData
.realY
- wwin
->frame_y
);
1860 WMHandleEvent(&event
);
1863 drawFrames(wwin
, scr
->selected_windows
,
1864 moveData
.realX
- wwin
->frame_x
,
1865 moveData
.realY
- wwin
->frame_y
);
1867 WMHandleEvent(&event
);
1873 if (wPreferences
.opaque_move
&& !wPreferences
.use_saveunders
) {
1874 XSetWindowAttributes attr
;
1877 attr
.save_under
= False
;
1878 XChangeWindowAttributes(dpy
, wwin
->frame
->core
->window
,
1879 CWSaveUnder
, &attr
);
1883 freeMoveData(&moveData
);
1890 #define HCONSTRAIN 2
1893 getResizeDirection(WWindow
*wwin
, int x
, int y
, int dx
, int dy
,
1896 int w
= wwin
->frame
->core
->width
- 1;
1897 int cw
= wwin
->frame
->resizebar_corner_width
;
1900 /* if not resizing through the resizebar */
1901 if (!(flags
& RESIZEBAR
)) {
1902 int xdir
= (abs(x
) < (wwin
->client
.width
/2)) ? LEFT
: RIGHT
;
1903 int ydir
= (abs(y
) < (wwin
->client
.height
/2)) ? UP
: DOWN
;
1904 if (abs(dx
) < 2 || abs(dy
) < 2) {
1905 if (abs(dy
) > abs(dx
))
1910 return (xdir
| ydir
);
1913 /* window is too narrow. allow diagonal resize */
1917 if (flags
& HCONSTRAIN
)
1922 return (LEFT
| ydir
);
1924 return (RIGHT
| ydir
);
1926 /* vertical resize */
1927 if ((x
> cw
) && (x
< w
- cw
))
1935 if ((abs(dy
) > 0) && !(flags
& HCONSTRAIN
))
1943 wMouseResizeWindow(WWindow
*wwin
, XEvent
*ev
)
1946 WScreen
*scr
= wwin
->screen_ptr
;
1947 Window root
= scr
->root_win
;
1948 int vert_border
= wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
;
1949 int fw
= wwin
->frame
->core
->width
;
1950 int fh
= wwin
->frame
->core
->height
;
1951 int fx
= wwin
->frame_x
;
1952 int fy
= wwin
->frame_y
;
1953 int is_resizebar
= (wwin
->frame
->resizebar
1954 && ev
->xany
.window
==wwin
->frame
->resizebar
->window
);
1958 int rw
= fw
, rh
= fh
;
1959 int rx1
, ry1
, rx2
, ry2
;
1961 KeyCode shiftl
, shiftr
;
1968 if (wwin
->flags
.shaded
) {
1969 wwarning("internal error: tryein");
1972 orig_x
= ev
->xbutton
.x_root
;
1973 orig_y
= ev
->xbutton
.y_root
;
1977 puts("Resizing window");
1980 wUnselectWindows(scr
);
1985 shiftl
= XKeysymToKeycode(dpy
, XK_Shift_L
);
1986 shiftr
= XKeysymToKeycode(dpy
, XK_Shift_R
);
1987 if (!WFLAGP(wwin
, no_titlebar
))
1988 h
= WMFontHeight(wwin
->screen_ptr
->title_font
) + (wPreferences
.window_title_clearance
+ TITLEBAR_EXTEND_SPACE
) * 2;
1992 WMMaskEvent(dpy
, KeyPressMask
| ButtonMotionMask
1993 | ButtonReleaseMask
| PointerMotionHintMask
1994 | ButtonPressMask
| ExposureMask
, &event
);
1995 if (!checkMouseSamplingRate(&event
))
1998 switch (event
.type
) {
2000 showGeometry(wwin
, fx
, fy
, fx
+ fw
, fy
+ fh
, res
);
2001 if ((event
.xkey
.keycode
== shiftl
|| event
.xkey
.keycode
== shiftr
)
2003 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2004 cycleGeometryDisplay(wwin
, fx
, fy
, fw
, fh
, res
);
2005 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2007 showGeometry(wwin
, fx
, fy
, fx
+ fw
, fy
+ fh
, res
);
2012 while (XCheckMaskEvent(dpy
, ButtonMotionMask
, &event
)) ;
2023 dw
= orig_x
- event
.xmotion
.x_root
;
2024 else if (res
& RIGHT
)
2025 dw
= event
.xmotion
.x_root
- orig_x
;
2027 dh
= orig_y
- event
.xmotion
.y_root
;
2028 else if (res
& DOWN
)
2029 dh
= event
.xmotion
.y_root
- orig_y
;
2031 orig_x
= event
.xmotion
.x_root
;
2032 orig_y
= event
.xmotion
.y_root
;
2037 fh
= rh
- vert_border
;
2038 wWindowConstrainSize(wwin
, &fw
, &fh
);
2042 else if (res
& RIGHT
)
2046 else if (res
& DOWN
)
2048 } else if (abs(orig_x
- event
.xmotion
.x_root
) >= MOVE_THRESHOLD
2049 || abs(orig_y
- event
.xmotion
.y_root
) >= MOVE_THRESHOLD
) {
2054 XTranslateCoordinates(dpy
, root
, wwin
->frame
->core
->window
,
2055 orig_x
, orig_y
, &tx
, &ty
, &junkw
);
2057 /* check if resizing through resizebar */
2063 if (is_resizebar
&& ((ev
->xbutton
.state
& ShiftMask
)
2064 || abs(orig_y
- event
.xmotion
.y_root
) < HRESIZE_THRESHOLD
))
2065 flags
|= HCONSTRAIN
;
2067 res
= getResizeDirection(wwin
, tx
, ty
,
2068 orig_x
- event
.xmotion
.x_root
,
2069 orig_y
- event
.xmotion
.y_root
, flags
);
2071 if (res
== (UP
|LEFT
))
2072 XChangeActivePointerGrab(dpy
, ButtonMotionMask
2073 | ButtonReleaseMask
| ButtonPressMask
,
2074 wCursor
[WCUR_TOPLEFTRESIZE
], CurrentTime
);
2075 else if (res
== (UP
|RIGHT
))
2076 XChangeActivePointerGrab(dpy
, ButtonMotionMask
2077 | ButtonReleaseMask
| ButtonPressMask
,
2078 wCursor
[WCUR_TOPRIGHTRESIZE
], CurrentTime
);
2079 else if (res
== (DOWN
|LEFT
))
2080 XChangeActivePointerGrab(dpy
, ButtonMotionMask
2081 | ButtonReleaseMask
| ButtonPressMask
,
2082 wCursor
[WCUR_BOTTOMLEFTRESIZE
], CurrentTime
);
2083 else if (res
== (DOWN
|RIGHT
))
2084 XChangeActivePointerGrab(dpy
, ButtonMotionMask
2085 | ButtonReleaseMask
| ButtonPressMask
,
2086 wCursor
[WCUR_BOTTOMRIGHTRESIZE
], CurrentTime
);
2087 else if (res
== DOWN
|| res
== UP
)
2088 XChangeActivePointerGrab(dpy
, ButtonMotionMask
2089 | ButtonReleaseMask
| ButtonPressMask
,
2090 wCursor
[WCUR_VERTICALRESIZE
], CurrentTime
);
2091 else if (res
& (DOWN
|UP
))
2092 XChangeActivePointerGrab(dpy
, ButtonMotionMask
2093 | ButtonReleaseMask
| ButtonPressMask
,
2094 wCursor
[WCUR_VERTICALRESIZE
], CurrentTime
);
2095 else if (res
& (LEFT
|RIGHT
))
2096 XChangeActivePointerGrab(dpy
, ButtonMotionMask
2097 | ButtonReleaseMask
| ButtonPressMask
,
2098 wCursor
[WCUR_HORIZONRESIZE
], CurrentTime
);
2100 XGrabKeyboard(dpy
, root
, False
, GrabModeAsync
, GrabModeAsync
,
2105 /* Draw the resize frame for the first time. */
2106 mapGeometryDisplay(wwin
, fx
, fy
, fw
, fh
);
2108 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2110 showGeometry(wwin
, fx
, fy
, fx
+ fw
, fy
+ fh
, res
);
2115 if (wPreferences
.size_display
== WDIS_FRAME_CENTER
) {
2116 drawTransparentFrame(wwin
, orig_fx
, orig_fy
,
2118 moveGeometryDisplayCentered(scr
, fx
+ fw
/ 2, fy
+ fh
/ 2);
2119 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2121 drawTransparentFrame(wwin
, orig_fx
, orig_fy
,
2123 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2125 if (fh
!= orig_fh
|| fw
!= orig_fw
) {
2126 if (wPreferences
.size_display
== WDIS_NEW
) {
2127 showGeometry(wwin
, orig_fx
, orig_fy
, orig_fx
+ orig_fw
,
2128 orig_fy
+ orig_fh
, res
);
2130 showGeometry(wwin
, fx
, fy
, fx
+ fw
, fy
+ fh
, res
);
2139 if (event
.xbutton
.button
!= ev
->xbutton
.button
)
2143 showGeometry(wwin
, fx
, fy
, fx
+ fw
, fy
+ fh
, res
);
2145 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2147 XUngrabKeyboard(dpy
, CurrentTime
);
2148 WMUnmapWidget(scr
->gview
);
2151 if (wwin
->client
.width
!= fw
)
2152 wwin
->flags
.user_changed_width
= 1;
2154 if (wwin
->client
.height
!= fh
- vert_border
)
2155 wwin
->flags
.user_changed_height
= 1;
2157 wWindowConfigure(wwin
, fx
, fy
, fw
, fh
- vert_border
);
2160 puts("End resize window");
2165 WMHandleEvent(&event
);
2180 wUnselectWindows(WScreen
*scr
)
2184 if (!scr
->selected_windows
)
2187 while (WMGetArrayItemCount(scr
->selected_windows
)) {
2188 wwin
= WMGetFromArray(scr
->selected_windows
, 0);
2189 if (wwin
->flags
.miniaturized
&& wwin
->icon
&& wwin
->icon
->selected
)
2190 wIconSelect(wwin
->icon
);
2192 wSelectWindow(wwin
, False
);
2194 WMFreeArray(scr
->selected_windows
);
2195 scr
->selected_windows
= NULL
;
2200 selectWindowsInside(WScreen
*scr
, int x1
, int y1
, int x2
, int y2
)
2204 /* select the windows and put them in the selected window list */
2205 tmpw
= scr
->focused_window
;
2206 while (tmpw
!= NULL
) {
2207 if (!(tmpw
->flags
.miniaturized
|| tmpw
->flags
.hidden
)) {
2208 if ((tmpw
->frame
->workspace
== scr
->current_workspace
2209 || IS_OMNIPRESENT(tmpw
))
2210 && (tmpw
->frame_x
>= x1
) && (tmpw
->frame_y
>= y1
)
2211 && (tmpw
->frame
->core
->width
+ tmpw
->frame_x
<= x2
)
2212 && (tmpw
->frame
->core
->height
+ tmpw
->frame_y
<= y2
)) {
2213 wSelectWindow(tmpw
, True
);
2222 wSelectWindows(WScreen
*scr
, XEvent
*ev
)
2225 Window root
= scr
->root_win
;
2226 GC gc
= scr
->frame_gc
;
2227 int xp
= ev
->xbutton
.x_root
;
2228 int yp
= ev
->xbutton
.y_root
;
2233 puts("Selecting windows");
2235 if (XGrabPointer(dpy
, scr
->root_win
, False
, ButtonMotionMask
2236 | ButtonReleaseMask
| ButtonPressMask
, GrabModeAsync
,
2237 GrabModeAsync
, None
, wCursor
[WCUR_DEFAULT
],
2238 CurrentTime
) != Success
) {
2243 wUnselectWindows(scr
);
2245 XDrawRectangle(dpy
, root
, gc
, xp
, yp
, w
, h
);
2247 WMMaskEvent(dpy
, ButtonReleaseMask
| PointerMotionMask
2248 | ButtonPressMask
, &event
);
2250 switch (event
.type
) {
2252 XDrawRectangle(dpy
, root
, gc
, x
, y
, w
, h
);
2253 x
= event
.xmotion
.x_root
;
2260 y
= event
.xmotion
.y_root
;
2267 XDrawRectangle(dpy
, root
, gc
, x
, y
, w
, h
);
2274 if (event
.xbutton
.button
!= ev
->xbutton
.button
)
2277 XDrawRectangle(dpy
, root
, gc
, x
, y
, w
, h
);
2279 XUngrabPointer(dpy
, CurrentTime
);
2280 selectWindowsInside(scr
, x
, y
, x
+ w
, y
+ h
);
2283 wKWMSelectRootRegion(scr
, xp
, yp
, w
, h
,
2284 event
.xbutton
.state
& ControlMask
);
2285 #endif /* KWM_HINTS */
2288 puts("End window selection");
2293 WMHandleEvent(&event
);
2301 InteractivePlaceWindow(WWindow
*wwin
, int *x_ret
, int *y_ret
,
2302 unsigned width
, unsigned height
)
2304 WScreen
*scr
= wwin
->screen_ptr
;
2305 Window root
= scr
->root_win
;
2308 KeyCode shiftl
, shiftr
;
2312 if (XGrabPointer(dpy
, root
, True
, PointerMotionMask
| ButtonPressMask
,
2313 GrabModeAsync
, GrabModeAsync
, None
,
2314 wCursor
[WCUR_DEFAULT
], CurrentTime
) != Success
) {
2319 if (!WFLAGP(wwin
, no_titlebar
)) {
2320 h
= WMFontHeight(scr
->title_font
) + (wPreferences
.window_title_clearance
+ TITLEBAR_EXTEND_SPACE
) * 2;
2323 if (!WFLAGP(wwin
, no_resizebar
)) {
2324 height
+= RESIZEBAR_HEIGHT
;
2326 XGrabKeyboard(dpy
, root
, False
, GrabModeAsync
, GrabModeAsync
, CurrentTime
);
2327 XQueryPointer(dpy
, root
, &junkw
, &junkw
, &x
, &y
, &junk
, &junk
,
2328 (unsigned *) &junk
);
2329 mapPositionDisplay(wwin
, x
- width
/2, y
- h
/2, width
, height
);
2331 drawTransparentFrame(wwin
, x
- width
/2, y
- h
/2, width
, height
);
2333 shiftl
= XKeysymToKeycode(dpy
, XK_Shift_L
);
2334 shiftr
= XKeysymToKeycode(dpy
, XK_Shift_R
);
2336 WMMaskEvent(dpy
, PointerMotionMask
|ButtonPressMask
|ExposureMask
|KeyPressMask
,
2339 if (!checkMouseSamplingRate(&event
))
2342 switch (event
.type
) {
2344 if ((event
.xkey
.keycode
== shiftl
)
2345 || (event
.xkey
.keycode
== shiftr
)) {
2346 drawTransparentFrame(wwin
,
2347 x
- width
/2, y
- h
/2, width
, height
);
2348 cyclePositionDisplay(wwin
,
2349 x
- width
/2, y
- h
/2, width
, height
);
2350 drawTransparentFrame(wwin
,
2351 x
- width
/2, y
- h
/2, width
, height
);
2356 drawTransparentFrame(wwin
, x
- width
/2, y
- h
/2, width
, height
);
2358 x
= event
.xmotion
.x_root
;
2359 y
= event
.xmotion
.y_root
;
2361 if (wPreferences
.move_display
== WDIS_FRAME_CENTER
)
2362 moveGeometryDisplayCentered(scr
, x
, y
+ (height
- h
) / 2);
2364 showPosition(wwin
, x
- width
/2, y
- h
/2);
2366 drawTransparentFrame(wwin
, x
- width
/2, y
- h
/2, width
, height
);
2371 drawTransparentFrame(wwin
, x
- width
/2, y
- h
/2, width
, height
);
2373 *x_ret
= x
- width
/2;
2375 XUngrabPointer(dpy
, CurrentTime
);
2376 XUngrabKeyboard(dpy
, CurrentTime
);
2377 /* get rid of the geometry window */
2378 WMUnmapWidget(scr
->gview
);
2382 WMHandleEvent(&event
);