2 * Window Maker window manager
4 * Copyright (c) 1997-2002 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)
65 /****** Global Variables ******/
66 extern Time LastTimestamp
;
68 extern Cursor wCursor
[WCUR_LAST
];
70 extern WPreferences wPreferences
;
72 extern Atom _XA_WM_PROTOCOLS
;
77 *----------------------------------------------------------------------
78 * checkMouseSamplingRate-
79 * For lowering the mouse motion sampling rate for machines where
80 * it's too high (SGIs). If it returns False then the event should be
82 *----------------------------------------------------------------------
85 checkMouseSamplingRate(XEvent
*ev
)
87 static Time previousMotion
= 0;
89 if (ev
->type
== MotionNotify
) {
90 if (ev
->xmotion
.time
- previousMotion
< DELAY_BETWEEN_MOUSE_SAMPLING
) {
93 previousMotion
= ev
->xmotion
.time
;
102 *----------------------------------------------------------------------
103 * moveGeometryDisplayCentered
105 * routine that moves the geometry/position window on scr so it is
106 * centered over the given coordinates (x,y). Also the window position
107 * is clamped so it stays on the screen at all times.
108 *----------------------------------------------------------------------
111 moveGeometryDisplayCentered(WScreen
*scr
, int x
, int y
)
113 unsigned int w
= WMWidgetWidth(scr
->gview
);
114 unsigned int h
= WMWidgetHeight(scr
->gview
);
115 unsigned int x1
= 0, y1
= 0, x2
= scr
->scr_width
, y2
= scr
->scr_height
;
124 if (scr
->xine_count
) {
131 rect
.size
.height
= h
;
133 head
= wGetRectPlacementInfo(scr
, rect
, &flags
);
135 if (flags
& (XFLAG_DEAD
| XFLAG_PARTIAL
)) {
136 rect
= wGetRectForHead(scr
, head
);
139 x2
= x1
+ rect
.size
.width
;
140 y2
= y1
+ rect
.size
.height
;
146 else if (x
> (x2
- w
))
151 else if (y
> (y2
- h
))
155 WMMoveWidget(scr
->gview
, x
, y
);
160 showPosition(WWindow
*wwin
, int x
, int y
)
162 WScreen
*scr
= wwin
->screen_ptr
;
164 if (wPreferences
.move_display
== WDIS_NEW
) {
166 int width
= wwin
->frame
->core
->width
;
167 int height
= wwin
->frame
->core
->height
;
169 GC lgc
= scr
->line_gc
;
170 XSetForeground(dpy
, lgc
, scr
->line_pixel
);
171 sprintf(num
, "%i", x
);
173 XDrawLine(dpy
, scr
->root_win
, lgc
, 0, y
-1, scr
->scr_width
, y
-1);
174 XDrawLine(dpy
, scr
->root_win
, lgc
, 0, y
+height
+2, scr
->scr_width
,
176 XDrawLine(dpy
, scr
->root_win
, lgc
, x
-1, 0, x
-1, scr
->scr_height
);
177 XDrawLine(dpy
, scr
->root_win
, lgc
, x
+width
+2, 0, x
+width
+2,
181 #ifdef VIRTUAL_DESKTOP
182 WSetGeometryViewShownPosition(scr
->gview
,
183 x
+ scr
->workspaces
[scr
->current_workspace
]->view_x
,
184 y
+ scr
->workspaces
[scr
->current_workspace
]->view_y
);
186 WSetGeometryViewShownPosition(scr
->gview
, x
, y
);
193 cyclePositionDisplay(WWindow
*wwin
, int x
, int y
, int w
, int h
)
195 WScreen
*scr
= wwin
->screen_ptr
;
197 wPreferences
.move_display
++;
198 wPreferences
.move_display
%= NUM_DISPLAYS
;
200 if (wPreferences
.move_display
== WDIS_NEW
) {
201 wPreferences
.move_display
++;
202 wPreferences
.move_display
%= NUM_DISPLAYS
;
205 if (wPreferences
.move_display
== WDIS_NONE
) {
206 WMUnmapWidget(scr
->gview
);
208 if (wPreferences
.move_display
== WDIS_CENTER
) {
209 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
210 moveGeometryDisplayCentered(scr
,
211 rect
.pos
.x
+ rect
.size
.width
/2,
212 rect
.pos
.y
+ rect
.size
.width
/2);
213 } else if (wPreferences
.move_display
== WDIS_TOPLEFT
) {
214 moveGeometryDisplayCentered(scr
, 1, 1);
215 } else if (wPreferences
.move_display
== WDIS_FRAME_CENTER
) {
216 moveGeometryDisplayCentered(scr
, x
+ w
/2, y
+ h
/2);
218 WMMapWidget(scr
->gview
);
224 mapPositionDisplay(WWindow
*wwin
, int x
, int y
, int w
, int h
)
226 WScreen
*scr
= wwin
->screen_ptr
;
228 if (wPreferences
.move_display
== WDIS_NEW
229 || wPreferences
.move_display
== WDIS_NONE
) {
231 } else if (wPreferences
.move_display
== WDIS_CENTER
) {
232 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
233 moveGeometryDisplayCentered(scr
,
234 rect
.pos
.x
+ rect
.size
.width
/2,
235 rect
.pos
.y
+ rect
.size
.width
/2);
236 } else if (wPreferences
.move_display
== WDIS_TOPLEFT
) {
237 moveGeometryDisplayCentered(scr
, 1, 1);
238 } else if (wPreferences
.move_display
== WDIS_FRAME_CENTER
) {
239 moveGeometryDisplayCentered(scr
, x
+ w
/2, y
+ h
/2);
241 WMMapWidget(scr
->gview
);
242 WSetGeometryViewShownPosition(scr
->gview
, x
, y
);
247 showGeometry(WWindow
*wwin
, int x1
, int y1
, int x2
, int y2
, int direction
)
249 WScreen
*scr
= wwin
->screen_ptr
;
250 Window root
= scr
->root_win
;
251 GC gc
= scr
->line_gc
, saveGC
;
252 int ty
, by
, my
, x
, y
, mx
, s
;
259 ty
= y1
+ wwin
->frame
->top_width
;
260 by
= y2
- wwin
->frame
->bottom_width
;
262 if (wPreferences
.size_display
== WDIS_NEW
) {
263 fw
= WMWidthOfString(scr
->tech_draw_font
, "8888", 4);
264 fh
= WMFontHeight(scr
->tech_draw_font
);
266 XSetForeground(dpy
, gc
, scr
->line_pixel
);
268 /* vertical geometry */
269 if (((direction
& LEFT
) && (x2
< scr
->scr_width
- fw
)) || (x1
< fw
)) {
280 segment
[0].x1
= x
- (s
+ 6); segment
[0].y1
= ty
;
281 segment
[0].x2
= x
- (s
- 10); segment
[0].y2
= ty
;
284 segment
[1].x1
= x
- (s
- 2); segment
[1].y1
= ty
+ 1;
285 segment
[1].x2
= x
- (s
- 5); segment
[1].y2
= ty
+ 7;
287 segment
[2].x1
= x
- (s
- 2); segment
[2].y1
= ty
+ 1;
288 segment
[2].x2
= x
- (s
+ 1); segment
[2].y2
= ty
+ 7;
291 segment
[3].x1
= x
- (s
- 2); segment
[3].y1
= ty
+ 1;
292 segment
[3].x2
= x
- (s
- 2); segment
[3].y2
= my
- fh
/2 - 1;
294 XDrawSegments(dpy
, root
, gc
, segment
, 4);
302 segment
[1].y1
= by
- 1;
303 segment
[1].y2
= by
- 7;
305 segment
[2].y1
= by
- 1;
306 segment
[2].y2
= by
- 7;
309 segment
[3].y1
= my
+ fh
/2 + 2;
310 segment
[3].y2
= by
- 1;
312 XDrawSegments(dpy
, root
, gc
, segment
, 4);
314 snprintf(num
, sizeof(num
), "%i", (by
- ty
- wwin
->normal_hints
->base_height
) /
315 wwin
->normal_hints
->height_inc
);
316 fw
= WMWidthOfString(scr
->tech_draw_font
, num
, strlen(num
));
318 /* XSetForeground(dpy, gc, WMColorPixel(scr->window_title_color[WS_UNFOCUSED])); */
320 color
= WMBlackColor(scr
->wmscreen
);
321 saveGC
= scr
->wmscreen
->drawStringGC
;
322 pixel
= color
->color
.pixel
;
324 /* Display the height. */
327 color
->color
.pixel
= scr
->line_pixel
;
328 scr
->wmscreen
->drawStringGC
= gc
;
329 WMDrawString(scr
->wmscreen
, root
, color
, scr
->tech_draw_font
,
330 x
- s
+ 3 - fw
/2, my
- fh
/2 + 1, num
, strlen(num
));
331 scr
->wmscreen
->drawStringGC
= saveGC
;
332 color
->color
.pixel
= pixel
;
334 XSetForeground(dpy
, gc
, scr
->line_pixel
);
335 /* horizontal geometry */
343 mx
= x1
+ (x2
- x1
)/2;
344 snprintf(num
, sizeof(num
), "%i", (x2
- x1
- wwin
->normal_hints
->base_width
) /
345 wwin
->normal_hints
->width_inc
);
346 fw
= WMWidthOfString(scr
->tech_draw_font
, num
, strlen(num
));
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);
368 segment
[0].x1
= x2
+ 1;
369 segment
[0].x2
= x2
+ 1;
372 segment
[1].x1
= x2
- 6;
376 segment
[2].x2
= x2
- 6;
379 segment
[3].x1
= mx
+ fw
/2 + 2;
382 XDrawSegments(dpy
, root
, gc
, segment
, 4);
384 /* XSetForeground(dpy, gc, WMColorPixel(scr->window_title_color[WS_UNFOCUSED])); */
386 /* Display the width. */
388 color
->color
.pixel
= scr
->line_pixel
;
389 scr
->wmscreen
->drawStringGC
= gc
;
390 WMDrawString(scr
->wmscreen
, root
, color
, scr
->tech_draw_font
,
391 mx
- fw
/2 + 1, y
- s
- fh
/2 + 1, num
, strlen(num
));
392 scr
->wmscreen
->drawStringGC
= saveGC
;
393 color
->color
.pixel
= pixel
;
394 WMReleaseColor(color
);
396 WSetGeometryViewShownSize(scr
->gview
,
397 (x2
- x1
- wwin
->normal_hints
->base_width
)
398 / wwin
->normal_hints
->width_inc
,
399 (by
- ty
- wwin
->normal_hints
->base_height
)
400 / wwin
->normal_hints
->height_inc
);
406 cycleGeometryDisplay(WWindow
*wwin
, int x
, int y
, int w
, int h
, int dir
)
408 WScreen
*scr
= wwin
->screen_ptr
;
410 wPreferences
.size_display
++;
411 wPreferences
.size_display
%= NUM_DISPLAYS
;
413 if (wPreferences
.size_display
== WDIS_NEW
414 || wPreferences
.size_display
== WDIS_NONE
) {
415 WMUnmapWidget(scr
->gview
);
417 if (wPreferences
.size_display
== WDIS_CENTER
) {
418 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
419 moveGeometryDisplayCentered(scr
,
420 rect
.pos
.x
+ rect
.size
.width
/2,
421 rect
.pos
.y
+ rect
.size
.width
/2);
422 } else if (wPreferences
.size_display
== WDIS_TOPLEFT
) {
423 moveGeometryDisplayCentered(scr
, 1, 1);
424 } else if (wPreferences
.size_display
== WDIS_FRAME_CENTER
) {
425 moveGeometryDisplayCentered(scr
, x
+ w
/2, y
+ h
/2);
427 WMMapWidget(scr
->gview
);
428 showGeometry(wwin
, x
, y
, x
+ w
, y
+ h
, dir
);
434 mapGeometryDisplay(WWindow
*wwin
, int x
, int y
, int w
, int h
)
436 WScreen
*scr
= wwin
->screen_ptr
;
438 if (wPreferences
.size_display
== WDIS_NEW
439 || wPreferences
.size_display
== WDIS_NONE
)
442 if (wPreferences
.size_display
== WDIS_CENTER
) {
443 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
444 moveGeometryDisplayCentered(scr
,
445 rect
.pos
.x
+ rect
.size
.width
/2,
446 rect
.pos
.y
+ rect
.size
.width
/2);
447 } else if (wPreferences
.size_display
== WDIS_TOPLEFT
) {
448 moveGeometryDisplayCentered(scr
, 1, 1);
449 } else if (wPreferences
.size_display
== WDIS_FRAME_CENTER
) {
450 moveGeometryDisplayCentered(scr
, x
+ w
/2, y
+ h
/2);
452 WMMapWidget(scr
->gview
);
453 showGeometry(wwin
, x
, y
, x
+ w
, y
+ h
, 0);
459 doWindowMove(WWindow
*wwin
, WMArray
*array
, int dx
, int dy
)
462 WScreen
*scr
= wwin
->screen_ptr
;
465 if (!array
|| !WMGetArrayItemCount(array
)) {
466 wWindowMove(wwin
, wwin
->frame_x
+ dx
, wwin
->frame_y
+ dy
);
468 WMArrayIterator iter
;
470 WM_ITERATE_ARRAY(array
, tmpw
, iter
) {
471 x
= tmpw
->frame_x
+ dx
;
472 y
= tmpw
->frame_y
+ dy
;
474 #if 1 /* XXX: with xinerama patch was #if 0, check this */
475 /* don't let windows become unreachable */
477 if (x
+ (int)tmpw
->frame
->core
->width
< 20)
478 x
= 20 - (int)tmpw
->frame
->core
->width
;
479 else if (x
+ 20 > scr
->scr_width
)
480 x
= scr
->scr_width
- 20;
482 if (y
+ (int)tmpw
->frame
->core
->height
< 20)
483 y
= 20 - (int)tmpw
->frame
->core
->height
;
484 else if (y
+ 20 > scr
->scr_height
)
485 y
= scr
->scr_height
- 20;
487 wScreenBringInside(scr
, &x
, &y
,
488 (int)tmpw
->frame
->core
->width
,
489 (int)tmpw
->frame
->core
->height
);
492 wWindowMove(tmpw
, x
, y
);
499 drawTransparentFrame(WWindow
*wwin
, int x
, int y
, int width
, int height
)
501 Window root
= wwin
->screen_ptr
->root_win
;
502 GC gc
= wwin
->screen_ptr
->frame_gc
;
506 if (!WFLAGP(wwin
, no_titlebar
) && !wwin
->flags
.shaded
) {
507 h
= WMFontHeight(wwin
->screen_ptr
->title_font
) + (wPreferences
.window_title_clearance
+ TITLEBAR_EXTEND_SPACE
) * 2;
509 if (!WFLAGP(wwin
, no_resizebar
) && !wwin
->flags
.shaded
) {
510 /* Can't use wwin-frame->bottom_width because, in some cases
511 (e.g. interactive placement), frame does not point to anything. */
512 bottom
= RESIZEBAR_HEIGHT
- 1;
514 XDrawRectangle(dpy
, root
, gc
, x
, y
, width
+ 1, height
+ 1);
517 XDrawLine(dpy
, root
, gc
, x
+ 1, y
+ h
, x
+ width
+ 1, y
+ h
);
520 XDrawLine(dpy
, root
, gc
, x
+ 1,
523 y
+ height
- bottom
);
529 drawFrames(WWindow
*wwin
, WMArray
*array
, int dx
, int dy
)
532 int scr_width
= wwin
->screen_ptr
->scr_width
;
533 int scr_height
= wwin
->screen_ptr
->scr_height
;
538 x
= wwin
->frame_x
+ dx
;
539 y
= wwin
->frame_y
+ dy
;
541 drawTransparentFrame(wwin
, x
, y
,
542 wwin
->frame
->core
->width
,
543 wwin
->frame
->core
->height
);
546 WMArrayIterator iter
;
548 WM_ITERATE_ARRAY(array
, tmpw
, iter
) {
549 x
= tmpw
->frame_x
+ dx
;
550 y
= tmpw
->frame_y
+ dy
;
552 /* don't let windows become unreachable */
553 #if 1 /* XXX: was 0 in XINERAMA patch, check */
554 if (x
+ (int)tmpw
->frame
->core
->width
< 20)
555 x
= 20 - (int)tmpw
->frame
->core
->width
;
556 else if (x
+ 20 > scr_width
)
559 if (y
+ (int)tmpw
->frame
->core
->height
< 20)
560 y
= 20 - (int)tmpw
->frame
->core
->height
;
561 else if (y
+ 20 > scr_height
)
565 wScreenBringInside(wwin
->screen_ptr
, &x
, &y
,
566 (int)tmpw
->frame
->core
->width
,
567 (int)tmpw
->frame
->core
->height
);
570 drawTransparentFrame(tmpw
, x
, y
, tmpw
->frame
->core
->width
,
571 tmpw
->frame
->core
->height
);
584 while (XCheckMaskEvent(dpy
, ButtonMotionMask
, &ev
)) ;
589 crossWorkspace(WScreen
*scr
, WWindow
*wwin
, int opaque_move
,
590 int new_workspace
, int rewind
)
592 /* do not let window be unmapped */
594 wwin
->flags
.changing_workspace
= 1;
595 wWindowChangeWorkspace(wwin
, new_workspace
);
597 /* go to new workspace */
598 wWorkspaceChange(scr
, new_workspace
);
600 wwin
->flags
.changing_workspace
= 0;
603 XWarpPointer(dpy
, None
, None
, 0, 0, 0, 0, scr
->scr_width
- 20, 0);
605 XWarpPointer(dpy
, None
, None
, 0, 0, 0, 0, -(scr
->scr_width
- 20), 0);
610 XGrabPointer(dpy
, scr
->root_win
, True
, PointerMotionMask
611 |ButtonReleaseMask
|ButtonPressMask
, GrabModeAsync
,
612 GrabModeAsync
, None
, wCursor
[WCUR_MOVE
], CurrentTime
);
620 /* arrays of WWindows sorted by the respective border position */
621 WWindow
**topList
; /* top border */
622 WWindow
**leftList
; /* left border */
623 WWindow
**rightList
; /* right border */
624 WWindow
**bottomList
; /* bottom border */
627 /* index of window in the above lists indicating the relative position
628 * of the window with the others */
634 int rubCount
; /* for workspace switching */
636 int winWidth
, winHeight
; /* width/height of the window */
637 int realX
, realY
; /* actual position of the window */
638 int calcX
, calcY
; /* calculated position of window */
639 int omouseX
, omouseY
; /* old mouse position */
640 int mouseX
, mouseY
; /* last known position of the pointer */
643 #define WTOP(w) (w)->frame_y
644 #define WLEFT(w) (w)->frame_x
645 #define WRIGHT(w) ((w)->frame_x + (int)(w)->frame->core->width + FRAME_BORDER_WIDTH)
646 #define WBOTTOM(w) ((w)->frame_y + (int)(w)->frame->core->height + FRAME_BORDER_WIDTH)
649 compareWTop(const void *a
, const void *b
)
651 WWindow
*wwin1
= *(WWindow
**)a
;
652 WWindow
*wwin2
= *(WWindow
**)b
;
654 if (WTOP(wwin1
) > WTOP(wwin2
))
656 else if (WTOP(wwin1
) < WTOP(wwin2
))
664 compareWLeft(const void *a
, const void *b
)
666 WWindow
*wwin1
= *(WWindow
**)a
;
667 WWindow
*wwin2
= *(WWindow
**)b
;
669 if (WLEFT(wwin1
) > WLEFT(wwin2
))
671 else if (WLEFT(wwin1
) < WLEFT(wwin2
))
679 compareWRight(const void *a
, const void *b
)
681 WWindow
*wwin1
= *(WWindow
**)a
;
682 WWindow
*wwin2
= *(WWindow
**)b
;
684 if (WRIGHT(wwin1
) < WRIGHT(wwin2
))
686 else if (WRIGHT(wwin1
) > WRIGHT(wwin2
))
695 compareWBottom(const void *a
, const void *b
)
697 WWindow
*wwin1
= *(WWindow
**)a
;
698 WWindow
*wwin2
= *(WWindow
**)b
;
700 if (WBOTTOM(wwin1
) < WBOTTOM(wwin2
))
702 else if (WBOTTOM(wwin1
) > WBOTTOM(wwin2
))
710 updateResistance(WWindow
*wwin
, MoveData
*data
, int newX
, int newY
)
713 int newX2
= newX
+ data
->winWidth
;
714 int newY2
= newY
+ data
->winHeight
;
717 if (newX
< data
->realX
) {
718 if (data
->rightIndex
> 0
719 && newX
< WRIGHT(data
->rightList
[data
->rightIndex
-1])) {
721 } else if (data
->leftIndex
<= data
->count
-1
722 && newX2
<= WLEFT(data
->leftList
[data
->leftIndex
])) {
725 } else if (newX
> data
->realX
) {
726 if (data
->leftIndex
> 0
727 && newX2
> WLEFT(data
->leftList
[data
->leftIndex
-1])) {
729 } else if (data
->rightIndex
<= data
->count
-1
730 && newX
>= WRIGHT(data
->rightList
[data
->rightIndex
])) {
736 if (newY
< data
->realY
) {
737 if (data
->bottomIndex
> 0
738 && newY
< WBOTTOM(data
->bottomList
[data
->bottomIndex
-1])) {
740 } else if (data
->topIndex
<= data
->count
-1
741 && newY2
<= WTOP(data
->topList
[data
->topIndex
])) {
744 } else if (newY
> data
->realY
) {
745 if (data
->topIndex
> 0
746 && newY2
> WTOP(data
->topList
[data
->topIndex
-1])) {
748 } else if (data
->bottomIndex
<= data
->count
-1
749 && newY
>= WBOTTOM(data
->bottomList
[data
->bottomIndex
])) {
758 /* TODO: optimize this */
759 if (data
->realY
< WBOTTOM(data
->bottomList
[0])) {
760 data
->bottomIndex
= 0;
762 if (data
->realX
< WRIGHT(data
->rightList
[0])) {
763 data
->rightIndex
= 0;
765 if ((data
->realX
+ data
->winWidth
) > WLEFT(data
->leftList
[0])) {
768 if ((data
->realY
+ data
->winHeight
) > WTOP(data
->topList
[0])) {
771 for (i
= 0; i
< data
->count
; i
++) {
772 if (data
->realY
> WBOTTOM(data
->bottomList
[i
])) {
773 data
->bottomIndex
= i
+ 1;
775 if (data
->realX
> WRIGHT(data
->rightList
[i
])) {
776 data
->rightIndex
= i
+ 1;
778 if ((data
->realX
+ data
->winWidth
) < WLEFT(data
->leftList
[i
])) {
779 data
->leftIndex
= i
+ 1;
781 if ((data
->realY
+ data
->winHeight
) < WTOP(data
->topList
[i
])) {
782 data
->topIndex
= i
+ 1;
789 freeMoveData(MoveData
*data
)
792 wfree(data
->topList
);
794 wfree(data
->leftList
);
796 wfree(data
->rightList
);
797 if (data
->bottomList
)
798 wfree(data
->bottomList
);
803 updateMoveData(WWindow
*wwin
, MoveData
*data
)
805 WScreen
*scr
= wwin
->screen_ptr
;
810 tmp
= scr
->focused_window
;
812 if (tmp
!= wwin
&& scr
->current_workspace
== tmp
->frame
->workspace
813 && !tmp
->flags
.miniaturized
814 && !tmp
->flags
.hidden
815 && !tmp
->flags
.obscured
816 && !WFLAGP(tmp
, sunken
)) {
817 data
->topList
[data
->count
] = tmp
;
818 data
->leftList
[data
->count
] = tmp
;
819 data
->rightList
[data
->count
] = tmp
;
820 data
->bottomList
[data
->count
] = tmp
;
826 if (data
->count
== 0) {
829 data
->rightIndex
= 0;
830 data
->bottomIndex
= 0;
835 * order from closest to the border of the screen to farthest
837 qsort(data
->topList
, data
->count
, sizeof(WWindow
**), compareWTop
);
838 qsort(data
->leftList
, data
->count
, sizeof(WWindow
**), compareWLeft
);
839 qsort(data
->rightList
, data
->count
, sizeof(WWindow
**), compareWRight
);
840 qsort(data
->bottomList
, data
->count
, sizeof(WWindow
**), compareWBottom
);
842 /* figure the position of the window relative to the others */
845 data
->leftIndex
= -1;
846 data
->rightIndex
= -1;
847 data
->bottomIndex
= -1;
849 if (WTOP(wwin
) < WBOTTOM(data
->bottomList
[0])) {
850 data
->bottomIndex
= 0;
852 if (WLEFT(wwin
) < WRIGHT(data
->rightList
[0])) {
853 data
->rightIndex
= 0;
855 if (WRIGHT(wwin
) > WLEFT(data
->leftList
[0])) {
858 if (WBOTTOM(wwin
) > WTOP(data
->topList
[0])) {
861 for (i
= 0; i
< data
->count
; i
++) {
862 if (WTOP(wwin
) >= WBOTTOM(data
->bottomList
[i
])) {
863 data
->bottomIndex
= i
+ 1;
865 if (WLEFT(wwin
) >= WRIGHT(data
->rightList
[i
])) {
866 data
->rightIndex
= i
+ 1;
868 if (WRIGHT(wwin
) <= WLEFT(data
->leftList
[i
])) {
869 data
->leftIndex
= i
+ 1;
871 if (WBOTTOM(wwin
) <= WTOP(data
->topList
[i
])) {
872 data
->topIndex
= i
+ 1;
879 initMoveData(WWindow
*wwin
, MoveData
*data
)
884 memset(data
, 0, sizeof(MoveData
));
886 for (i
= 0, tmp
= wwin
->screen_ptr
->focused_window
;
888 tmp
= tmp
->prev
, i
++);
891 data
->topList
= wmalloc(sizeof(WWindow
*) * i
);
892 data
->leftList
= wmalloc(sizeof(WWindow
*) * i
);
893 data
->rightList
= wmalloc(sizeof(WWindow
*) * i
);
894 data
->bottomList
= wmalloc(sizeof(WWindow
*) * i
);
896 updateMoveData(wwin
, data
);
899 data
->realX
= wwin
->frame_x
;
900 data
->realY
= wwin
->frame_y
;
901 data
->calcX
= wwin
->frame_x
;
902 data
->calcY
= wwin
->frame_y
;
904 data
->winWidth
= wwin
->frame
->core
->width
+ 2;
905 data
->winHeight
= wwin
->frame
->core
->height
+ 2;
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 */
1030 /* window is the leftmost window: check against screen edge */
1033 * Add inter head resistance 1/2 (if needed)
1035 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
1037 l_edge
= WMAX(scr
->totalUsableArea
.x1
, rect
.pos
.x
);
1038 edge_l
= l_edge
- resist
;
1039 edge_r
= WMIN(scr
->totalUsableArea
.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
;
1137 * Add inter head resistance 2/2 (if needed)
1139 t_edge
= WMAX(scr
->totalUsableArea
.y1
, rect
.pos
.y
);
1140 edge_t
= t_edge
- resist
;
1141 edge_b
= WMIN(scr
->totalUsableArea
.y2
, rect
.pos
.y
+ rect
.size
.height
);
1142 b_edge
= edge_b
+ resist
;
1144 if ((data
->bottomIndex
>= 0) && (data
->bottomIndex
<= data
->count
)) {
1147 for (i
= data
->bottomIndex
- 1; i
>= 0; i
--) {
1148 looprw
= data
->bottomList
[i
];
1149 if (!(data
->realX
> WRIGHT(looprw
)
1150 || (data
->realX
+ data
->winWidth
) < WLEFT(looprw
))) {
1152 || ((data
->realY
< (WBOTTOM(looprw
) + 2)) && dy
< 0)) {
1153 t_edge
= WBOTTOM(looprw
) + 1;
1154 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1161 for (i
= data
->bottomIndex
; i
< data
->count
; i
++) {
1162 looprw
= data
->bottomList
[i
];
1163 if(!(data
->realX
> WRIGHT(looprw
)
1164 || (data
->realX
+ data
->winWidth
) < WLEFT(looprw
))) {
1165 b_edge
= WBOTTOM(looprw
) + 1;
1166 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1173 if ((data
->topIndex
>= 0) && (data
->topIndex
<= data
->count
)) {
1176 for (i
= data
->topIndex
- 1; i
>= 0; i
--) {
1177 looprw
= data
->topList
[i
];
1178 if (!(data
->realX
> WRIGHT(looprw
)
1179 || (data
->realX
+ data
->winWidth
) < WLEFT(looprw
))) {
1181 || (((data
->realY
+ data
->winHeight
) > (WTOP(looprw
) - 1)) && dy
> 0)) {
1182 edge_b
= WTOP(looprw
);
1183 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1190 for (i
= data
->topIndex
; i
< data
->count
; i
++) {
1191 looprw
= data
->topList
[i
];
1192 if(!(data
->realX
> WRIGHT(looprw
)
1193 || (data
->realX
+ data
->winWidth
) < WLEFT(looprw
))) {
1194 edge_t
= WTOP(looprw
);
1195 resist
= WIN_RESISTANCE(wPreferences
.edge_resistance
);
1201 if ((winT
- t_edge
) < (b_edge
- winT
)) {
1203 if ((attract
&& winT
<= t_edge
+ resist
&& winT
>= t_edge
- resist
)
1204 || (dy
< 0 && winT
<= t_edge
&& winT
>= t_edge
- resist
)) {
1211 if (resist
> 0 && attract
&& winT
>= b_edge
- resist
&& winT
<= b_edge
+ resist
) {
1217 if ((winB
- edge_t
) < (edge_b
- winB
)) {
1218 if (resist
> 0 && attract
&& winB
<= edge_t
+ resist
&& winB
>= edge_t
- resist
) {
1219 newY
= edge_t
- data
->winHeight
;
1225 if ((attract
&& winB
>= edge_b
- resist
&& winB
<= edge_b
+ resist
)
1226 || (dy
> 0 && winB
>= edge_b
&& winB
<= edge_b
+ resist
)) {
1227 newY
= edge_b
- data
->winHeight
;
1237 /* update window position */
1241 if (((dx
> 0 && data
->calcX
- data
->realX
> 0)
1242 || (dx
< 0 && data
->calcX
- data
->realX
< 0)) && !hresist
)
1245 if (((dy
> 0 && data
->calcY
- data
->realY
> 0)
1246 || (dy
< 0 && data
->calcY
- data
->realY
< 0)) && !vresist
)
1249 if (data
->realX
!= newX
|| data
->realY
!= newY
) {
1251 if (wPreferences
.move_display
== WDIS_NEW
1252 && !scr
->selected_windows
) {
1253 showPosition(wwin
, data
->realX
, data
->realY
);
1256 doWindowMove(wwin
, scr
->selected_windows
,
1257 newX
- wwin
->frame_x
,
1258 newY
- wwin
->frame_y
);
1261 drawFrames(wwin
, scr
->selected_windows
,
1262 data
->realX
- wwin
->frame_x
,
1263 data
->realY
- wwin
->frame_y
);
1266 if (!scr
->selected_windows
1267 && wPreferences
.move_display
== WDIS_FRAME_CENTER
) {
1269 moveGeometryDisplayCentered(scr
, newX
+ data
->winWidth
/2,
1270 newY
+ data
->winHeight
/2);
1275 drawFrames(wwin
, scr
->selected_windows
,
1276 newX
- wwin
->frame_x
,
1277 newY
- wwin
->frame_y
);
1280 if (!scr
->selected_windows
) {
1281 showPosition(wwin
, newX
, newY
);
1286 /* recalc relative window position */
1287 if (doResistance
&& (data
->realX
!= newX
|| data
->realY
!= newY
)) {
1288 updateResistance(wwin
, data
, newX
, newY
);
1296 #define _KS KEY_CONTROL_WINDOW_WEIGHT
1299 wKeyboardMoveResizeWindow(WWindow
*wwin
)
1301 WScreen
*scr
= wwin
->screen_ptr
;
1302 Window root
= scr
->root_win
;
1304 int w
= wwin
->frame
->core
->width
;
1305 int h
= wwin
->frame
->core
->height
;
1306 int scr_width
= wwin
->screen_ptr
->scr_width
;
1307 int scr_height
= wwin
->screen_ptr
->scr_height
;
1308 int vert_border
= wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
;
1309 int src_x
= wwin
->frame_x
;
1310 int src_y
= wwin
->frame_y
;
1311 int done
,off_x
,off_y
,ww
,wh
;
1314 KeySym keysym
=NoSymbol
;
1316 KeyCode shiftl
,shiftr
,ctrll
,ctrlmode
;
1318 shiftl
= XKeysymToKeycode(dpy
, XK_Shift_L
);
1319 shiftr
= XKeysymToKeycode(dpy
, XK_Shift_R
);
1320 ctrll
= XKeysymToKeycode(dpy
, XK_Control_L
);
1321 ctrlmode
=done
=off_x
=off_y
=0;
1325 XGrabKeyboard(dpy
, root
, False
, GrabModeAsync
, GrabModeAsync
, CurrentTime
);
1327 if (!wwin
->flags
.selected
) {
1328 wUnselectWindows(scr
);
1331 XGrabPointer(dpy
, scr
->root_win
, True
, PointerMotionMask
1332 |ButtonReleaseMask
|ButtonPressMask
, GrabModeAsync
,
1333 GrabModeAsync
, None
, wCursor
[WCUR_DEFAULT
], CurrentTime
);
1335 if (wwin
->flags
.shaded
|| scr
->selected_windows
) {
1336 if(scr
->selected_windows
)
1337 drawFrames(wwin
,scr
->selected_windows
,off_x
,off_y
);
1338 else drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, w
, h
);
1339 if(!scr
->selected_windows
)
1340 mapPositionDisplay(wwin
, src_x
, src_y
, w
, h
);
1342 drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, w
, h
);
1352 WMMaskEvent(dpy
, KeyPressMask
| ButtonReleaseMask
1353 | ButtonPressMask
| ExposureMask
, &event
);
1354 if (event
.type
== Expose
) {
1355 WMHandleEvent(&event
);
1357 } while (event
.type
== Expose
);
1360 if (wwin
->flags
.shaded
|| scr
->selected_windows
) {
1361 if(scr
->selected_windows
)
1362 drawFrames(wwin
,scr
->selected_windows
,off_x
,off_y
);
1363 else drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, w
, h
);
1364 /*** I HATE EDGE RESISTANCE - ]d ***/
1367 drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, ww
, wh
);
1371 showGeometry(wwin
, src_x
+off_x
, src_y
+off_y
, src_x
+off_x
+ww
, src_y
+off_y
+wh
,0);
1376 switch (event
.type
) {
1379 if (event
.xkey
.time
- lastTime
> 50) {
1380 kspeed
/=(1 + (event
.xkey
.time
- lastTime
)/100);
1386 if (kspeed
< _KS
) kspeed
= _KS
;
1387 lastTime
= event
.xkey
.time
;
1389 if (event
.xkey
.state
& ControlMask
&& !wwin
->flags
.shaded
) {
1391 wUnselectWindows(scr
);
1396 if (event
.xkey
.keycode
== shiftl
|| event
.xkey
.keycode
== shiftr
) {
1398 cycleGeometryDisplay(wwin
, src_x
+off_x
, src_y
+off_y
, ww
, wh
, 0);
1400 cyclePositionDisplay(wwin
, src_x
+off_x
, src_y
+off_y
, ww
, wh
);
1404 keysym
= XLookupKeysym(&event
.xkey
, 0);
1459 if (moment
!= RIGHT
)
1470 wWindowConstrainSize(wwin
, &ww
, &wh
);
1473 if (wPreferences
.ws_cycle
){
1474 if (src_x
+ off_x
+ ww
< 20){
1475 if(!scr
->current_workspace
) {
1476 wWorkspaceChange(scr
, scr
->workspace_count
-1);
1478 else wWorkspaceChange(scr
, scr
->current_workspace
-1);
1481 else if (src_x
+ off_x
+ 20 > scr_width
){
1482 if(scr
->current_workspace
== scr
->workspace_count
-1) {
1483 wWorkspaceChange(scr
, 0);
1485 else wWorkspaceChange(scr
, scr
->current_workspace
+1);
1490 if (src_x
+ off_x
+ ww
< 20)
1491 off_x
= 20 - ww
- src_x
;
1492 else if (src_x
+ off_x
+ 20 > scr_width
)
1493 off_x
= scr_width
- 20 - src_x
;
1496 if (src_y
+ off_y
+ wh
< 20) {
1497 off_y
= 20 - wh
- src_y
;
1499 else if (src_y
+ off_y
+ 20 > scr_height
) {
1500 off_y
= scr_height
- 20 - src_y
;
1509 WMHandleEvent(&event
);
1510 while (XCheckTypedEvent(dpy
, Expose
, &event
)) {
1511 WMHandleEvent(&event
);
1516 WMHandleEvent(&event
);
1523 if (wwin
->flags
.shaded
&& !scr
->selected_windows
){
1524 moveGeometryDisplayCentered(scr
, src_x
+off_x
+ w
/2, src_y
+off_y
+ h
/2);
1527 WMUnmapWidget(scr
->gview
);
1528 mapGeometryDisplay(wwin
, src_x
+off_x
, src_y
+off_y
, ww
, wh
);
1529 } else if(!scr
->selected_windows
) {
1530 WMUnmapWidget(scr
->gview
);
1531 mapPositionDisplay(wwin
, src_x
+off_x
, src_y
+off_y
, ww
, wh
);
1535 if (wwin
->flags
.shaded
|| scr
->selected_windows
) {
1536 if (scr
->selected_windows
)
1537 drawFrames(wwin
,scr
->selected_windows
,off_x
,off_y
);
1539 drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, w
, h
);
1541 drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, ww
, wh
);
1546 showGeometry(wwin
, src_x
+off_x
, src_y
+off_y
, src_x
+off_x
+ww
, src_y
+off_y
+wh
,0);
1547 } else if(!scr
->selected_windows
)
1548 showPosition(wwin
, src_x
+off_x
, src_y
+off_y
);
1552 scr
->keymove_tick
=0;
1554 WMDeleteTimerWithClientData(&looper);
1556 if (wwin
->flags
.shaded
|| scr
->selected_windows
) {
1557 if(scr
->selected_windows
)
1558 drawFrames(wwin
,scr
->selected_windows
,off_x
,off_y
);
1559 else drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, w
, h
);
1562 drawTransparentFrame(wwin
, src_x
+off_x
, src_y
+off_y
, ww
, wh
);
1566 showGeometry(wwin
, src_x
+off_x
, src_y
+off_y
, src_x
+off_x
+ww
, src_y
+off_y
+wh
,0);
1567 WMUnmapWidget(scr
->gview
);
1569 WMUnmapWidget(scr
->gview
);
1571 XUngrabKeyboard(dpy
, CurrentTime
);
1572 XUngrabPointer(dpy
, CurrentTime
);
1576 if (wwin
->flags
.shaded
|| scr
->selected_windows
) {
1577 if (!scr
->selected_windows
) {
1578 wWindowMove(wwin
, src_x
+off_x
, src_y
+off_y
);
1579 wWindowSynthConfigureNotify(wwin
);
1581 WMArrayIterator iter
;
1584 doWindowMove(wwin
, scr
->selected_windows
, off_x
, off_y
);
1586 WM_ITERATE_ARRAY(scr
->selected_windows
, foo
, iter
) {
1587 wWindowSynthConfigureNotify(foo
);
1591 if (wwin
->client
.width
!= ww
)
1592 wwin
->flags
.user_changed_width
= 1;
1594 if (wwin
->client
.height
!= wh
- vert_border
)
1595 wwin
->flags
.user_changed_height
= 1;
1597 wWindowConfigure(wwin
, src_x
+off_x
, src_y
+off_y
,
1598 ww
, wh
- vert_border
);
1599 wWindowSynthConfigureNotify(wwin
);
1601 wWindowChangeWorkspace(wwin
, scr
->current_workspace
);
1602 wSetFocusTo(scr
, wwin
);
1611 *----------------------------------------------------------------------
1612 * wMouseMoveWindow--
1613 * Move the named window and the other selected ones (if any),
1614 * interactively. Also shows the position of the window, if only one
1615 * window is being moved.
1616 * If the window is not on the selected window list, the selected
1617 * windows are deselected.
1618 * If shift is pressed during the operation, the position display
1619 * is changed to another type.
1622 * True if the window was moved, False otherwise.
1625 * The window(s) position is changed, and the client(s) are
1626 * notified about that.
1627 * The position display configuration may be changed.
1628 *----------------------------------------------------------------------
1631 wMouseMoveWindow(WWindow
*wwin
, XEvent
*ev
)
1633 WScreen
*scr
= wwin
->screen_ptr
;
1635 Window root
= scr
->root_win
;
1636 KeyCode shiftl
, shiftr
;
1640 /* This needs not to change while moving, else bad things can happen */
1641 int opaqueMove
= wPreferences
.opaque_move
;
1643 #ifdef GHOST_WINDOW_MOVE
1646 rimg
= InitGhostWindowMove(scr
);
1650 if (wPreferences
.opaque_move
&& !wPreferences
.use_saveunders
) {
1651 XSetWindowAttributes attr
;
1653 attr
.save_under
= True
;
1654 XChangeWindowAttributes(dpy
, wwin
->frame
->core
->window
,
1655 CWSaveUnder
, &attr
);
1659 initMoveData(wwin
, &moveData
);
1661 moveData
.mouseX
= ev
->xmotion
.x_root
;
1662 moveData
.mouseY
= ev
->xmotion
.y_root
;
1664 if (!wwin
->flags
.selected
) {
1665 /* this window is not selected, unselect others and move only wwin */
1666 wUnselectWindows(scr
);
1669 puts("Moving window");
1671 shiftl
= XKeysymToKeycode(dpy
, XK_Shift_L
);
1672 shiftr
= XKeysymToKeycode(dpy
, XK_Shift_R
);
1678 /* XWarpPointer() doesn't seem to generate Motion events, so
1679 we've got to simulate them */
1680 XQueryPointer(dpy
, root
, &junkw
, &junkw
, &event
.xmotion
.x_root
,
1681 &event
.xmotion
.y_root
, &junk
, &junk
,
1682 (unsigned *) &junk
);
1684 WMMaskEvent(dpy
, KeyPressMask
| ButtonMotionMask
1685 | PointerMotionHintMask
1686 | ButtonReleaseMask
| ButtonPressMask
| ExposureMask
,
1689 if (event
.type
== MotionNotify
) {
1690 /* compress MotionNotify events */
1691 while (XCheckMaskEvent(dpy
, ButtonMotionMask
, &event
)) ;
1692 if (!checkMouseSamplingRate(&event
))
1696 switch (event
.type
) {
1698 if ((event
.xkey
.keycode
== shiftl
|| event
.xkey
.keycode
== shiftr
)
1699 && started
&& !scr
->selected_windows
) {
1702 drawFrames(wwin
, scr
->selected_windows
,
1703 moveData
.realX
- wwin
->frame_x
,
1704 moveData
.realY
- wwin
->frame_y
);
1707 if (wPreferences
.move_display
== WDIS_NEW
1708 && !scr
->selected_windows
) {
1709 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1712 cyclePositionDisplay(wwin
, moveData
.realX
, moveData
.realY
,
1713 moveData
.winWidth
, moveData
.winHeight
);
1715 if (wPreferences
.move_display
== WDIS_NEW
1716 && !scr
->selected_windows
) {
1718 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1722 drawFrames(wwin
, scr
->selected_windows
,
1723 moveData
.realX
- wwin
->frame_x
,
1724 moveData
.realY
- wwin
->frame_y
);
1727 WMHandleEvent(&event); this causes problems needs fixing */
1733 updateWindowPosition(wwin
, &moveData
,
1734 scr
->selected_windows
== NULL
1735 && wPreferences
.edge_resistance
> 0,
1737 event
.xmotion
.x_root
,
1738 event
.xmotion
.y_root
);
1740 if (!warped
&& !wPreferences
.no_autowrap
) {
1741 int oldWorkspace
= scr
->current_workspace
;
1743 if (wPreferences
.move_display
== WDIS_NEW
1744 && !scr
->selected_windows
) {
1745 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1749 drawFrames(wwin
, scr
->selected_windows
,
1750 moveData
.realX
- wwin
->frame_x
,
1751 moveData
.realY
- wwin
->frame_y
);
1753 if (checkWorkspaceChange(wwin
, &moveData
, opaqueMove
)) {
1754 if (scr
->current_workspace
!= oldWorkspace
1755 && wPreferences
.edge_resistance
> 0
1756 && scr
->selected_windows
== NULL
)
1757 updateMoveData(wwin
, &moveData
);
1761 drawFrames(wwin
, scr
->selected_windows
,
1762 moveData
.realX
- wwin
->frame_x
,
1763 moveData
.realY
- wwin
->frame_y
);
1765 if (wPreferences
.move_display
== WDIS_NEW
1766 && !scr
->selected_windows
) {
1768 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1774 } else if (abs(ev
->xmotion
.x_root
- event
.xmotion
.x_root
) >= MOVE_THRESHOLD
1775 || abs(ev
->xmotion
.y_root
- event
.xmotion
.y_root
) >= MOVE_THRESHOLD
) {
1777 XChangeActivePointerGrab(dpy
, ButtonMotionMask
1778 | ButtonReleaseMask
| ButtonPressMask
,
1779 wCursor
[WCUR_MOVE
], CurrentTime
);
1781 XGrabKeyboard(dpy
, root
, False
, GrabModeAsync
, GrabModeAsync
,
1784 if (!scr
->selected_windows
)
1785 mapPositionDisplay(wwin
, moveData
.realX
, moveData
.realY
,
1786 moveData
.winWidth
, moveData
.winHeight
);
1788 if (started
&& !opaqueMove
)
1789 drawFrames(wwin
, scr
->selected_windows
, 0, 0);
1791 if (!opaqueMove
|| (wPreferences
.move_display
==WDIS_NEW
1792 && !scr
->selected_windows
)) {
1794 if (wPreferences
.move_display
==WDIS_NEW
)
1795 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1804 if (event
.xbutton
.button
!= ev
->xbutton
.button
)
1810 drawFrames(wwin
, scr
->selected_windows
,
1811 moveData
.realX
- wwin
->frame_x
,
1812 moveData
.realY
- wwin
->frame_y
);
1814 doWindowMove(wwin
, scr
->selected_windows
,
1815 moveData
.realX
- wwin
->frame_x
,
1816 moveData
.realY
- wwin
->frame_y
);
1818 #ifndef CONFIGURE_WINDOW_WHILE_MOVING
1819 wWindowSynthConfigureNotify(wwin
);
1821 XUngrabKeyboard(dpy
, CurrentTime
);
1824 wWindowChangeWorkspace(wwin
, scr
->current_workspace
);
1825 wSetFocusTo(scr
, wwin
);
1827 if (wPreferences
.move_display
== WDIS_NEW
)
1828 showPosition(wwin
, moveData
.realX
, moveData
.realY
);
1830 /* discard all enter/leave events that happened until
1831 * the time the button was released */
1832 while (XCheckTypedEvent(dpy
, EnterNotify
, &e
)) {
1833 if (e
.xcrossing
.time
> event
.xbutton
.time
) {
1834 XPutBackEvent(dpy
, &e
);
1838 while (XCheckTypedEvent(dpy
, LeaveNotify
, &e
)) {
1839 if (e
.xcrossing
.time
> event
.xbutton
.time
) {
1840 XPutBackEvent(dpy
, &e
);
1845 if (!scr
->selected_windows
) {
1846 /* get rid of the geometry window */
1847 WMUnmapWidget(scr
->gview
);
1851 puts("End move window");
1857 if (started
&& !opaqueMove
) {
1858 drawFrames(wwin
, scr
->selected_windows
,
1859 moveData
.realX
- wwin
->frame_x
,
1860 moveData
.realY
- wwin
->frame_y
);
1862 WMHandleEvent(&event
);
1865 drawFrames(wwin
, scr
->selected_windows
,
1866 moveData
.realX
- wwin
->frame_x
,
1867 moveData
.realY
- wwin
->frame_y
);
1869 WMHandleEvent(&event
);
1875 if (wPreferences
.opaque_move
&& !wPreferences
.use_saveunders
) {
1876 XSetWindowAttributes attr
;
1879 attr
.save_under
= False
;
1880 XChangeWindowAttributes(dpy
, wwin
->frame
->core
->window
,
1881 CWSaveUnder
, &attr
);
1885 freeMoveData(&moveData
);
1892 #define HCONSTRAIN 2
1895 getResizeDirection(WWindow
*wwin
, int x
, int y
, int dx
, int dy
,
1898 int w
= wwin
->frame
->core
->width
- 1;
1899 int cw
= wwin
->frame
->resizebar_corner_width
;
1902 /* if not resizing through the resizebar */
1903 if (!(flags
& RESIZEBAR
)) {
1904 int xdir
= (abs(x
) < (wwin
->client
.width
/2)) ? LEFT
: RIGHT
;
1905 int ydir
= (abs(y
) < (wwin
->client
.height
/2)) ? UP
: DOWN
;
1906 if (abs(dx
) < 2 || abs(dy
) < 2) {
1907 if (abs(dy
) > abs(dx
))
1912 return (xdir
| ydir
);
1915 /* window is too narrow. allow diagonal resize */
1919 if (flags
& HCONSTRAIN
)
1924 return (LEFT
| ydir
);
1926 return (RIGHT
| ydir
);
1928 /* vertical resize */
1929 if ((x
> cw
) && (x
< w
- cw
))
1937 if ((abs(dy
) > 0) && !(flags
& HCONSTRAIN
))
1945 wMouseResizeWindow(WWindow
*wwin
, XEvent
*ev
)
1948 WScreen
*scr
= wwin
->screen_ptr
;
1949 Window root
= scr
->root_win
;
1950 int vert_border
= wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
;
1951 int fw
= wwin
->frame
->core
->width
;
1952 int fh
= wwin
->frame
->core
->height
;
1953 int fx
= wwin
->frame_x
;
1954 int fy
= wwin
->frame_y
;
1955 int is_resizebar
= (wwin
->frame
->resizebar
1956 && ev
->xany
.window
==wwin
->frame
->resizebar
->window
);
1960 int rw
= fw
, rh
= fh
;
1961 int rx1
, ry1
, rx2
, ry2
;
1963 KeyCode shiftl
, shiftr
;
1970 if (wwin
->flags
.shaded
) {
1971 wwarning("internal error: tryein");
1974 orig_x
= ev
->xbutton
.x_root
;
1975 orig_y
= ev
->xbutton
.y_root
;
1979 puts("Resizing window");
1982 wUnselectWindows(scr
);
1987 shiftl
= XKeysymToKeycode(dpy
, XK_Shift_L
);
1988 shiftr
= XKeysymToKeycode(dpy
, XK_Shift_R
);
1989 if (!WFLAGP(wwin
, no_titlebar
))
1990 h
= WMFontHeight(wwin
->screen_ptr
->title_font
) + (wPreferences
.window_title_clearance
+ TITLEBAR_EXTEND_SPACE
) * 2;
1994 WMMaskEvent(dpy
, KeyPressMask
| ButtonMotionMask
1995 | ButtonReleaseMask
| PointerMotionHintMask
1996 | ButtonPressMask
| ExposureMask
, &event
);
1997 if (!checkMouseSamplingRate(&event
))
2000 switch (event
.type
) {
2002 showGeometry(wwin
, fx
, fy
, fx
+ fw
, fy
+ fh
, res
);
2003 if ((event
.xkey
.keycode
== shiftl
|| event
.xkey
.keycode
== shiftr
)
2005 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2006 cycleGeometryDisplay(wwin
, fx
, fy
, fw
, fh
, res
);
2007 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2009 showGeometry(wwin
, fx
, fy
, fx
+ fw
, fy
+ fh
, res
);
2014 while (XCheckMaskEvent(dpy
, ButtonMotionMask
, &event
)) ;
2025 dw
= orig_x
- event
.xmotion
.x_root
;
2026 else if (res
& RIGHT
)
2027 dw
= event
.xmotion
.x_root
- orig_x
;
2029 dh
= orig_y
- event
.xmotion
.y_root
;
2030 else if (res
& DOWN
)
2031 dh
= event
.xmotion
.y_root
- orig_y
;
2033 orig_x
= event
.xmotion
.x_root
;
2034 orig_y
= event
.xmotion
.y_root
;
2039 fh
= rh
- vert_border
;
2040 wWindowConstrainSize(wwin
, &fw
, &fh
);
2044 else if (res
& RIGHT
)
2048 else if (res
& DOWN
)
2050 } else if (abs(orig_x
- event
.xmotion
.x_root
) >= MOVE_THRESHOLD
2051 || abs(orig_y
- event
.xmotion
.y_root
) >= MOVE_THRESHOLD
) {
2056 XTranslateCoordinates(dpy
, root
, wwin
->frame
->core
->window
,
2057 orig_x
, orig_y
, &tx
, &ty
, &junkw
);
2059 /* check if resizing through resizebar */
2065 if (is_resizebar
&& ((ev
->xbutton
.state
& ShiftMask
)
2066 || abs(orig_y
- event
.xmotion
.y_root
) < HRESIZE_THRESHOLD
))
2067 flags
|= HCONSTRAIN
;
2069 res
= getResizeDirection(wwin
, tx
, ty
,
2070 orig_x
- event
.xmotion
.x_root
,
2071 orig_y
- event
.xmotion
.y_root
, flags
);
2073 if (res
== (UP
|LEFT
))
2074 XChangeActivePointerGrab(dpy
, ButtonMotionMask
2075 | ButtonReleaseMask
| ButtonPressMask
,
2076 wCursor
[WCUR_TOPLEFTRESIZE
], CurrentTime
);
2077 else if (res
== (UP
|RIGHT
))
2078 XChangeActivePointerGrab(dpy
, ButtonMotionMask
2079 | ButtonReleaseMask
| ButtonPressMask
,
2080 wCursor
[WCUR_TOPRIGHTRESIZE
], CurrentTime
);
2081 else if (res
== (DOWN
|LEFT
))
2082 XChangeActivePointerGrab(dpy
, ButtonMotionMask
2083 | ButtonReleaseMask
| ButtonPressMask
,
2084 wCursor
[WCUR_BOTTOMLEFTRESIZE
], CurrentTime
);
2085 else if (res
== (DOWN
|RIGHT
))
2086 XChangeActivePointerGrab(dpy
, ButtonMotionMask
2087 | ButtonReleaseMask
| ButtonPressMask
,
2088 wCursor
[WCUR_BOTTOMRIGHTRESIZE
], CurrentTime
);
2089 else if (res
== DOWN
|| res
== UP
)
2090 XChangeActivePointerGrab(dpy
, ButtonMotionMask
2091 | ButtonReleaseMask
| ButtonPressMask
,
2092 wCursor
[WCUR_VERTICALRESIZE
], CurrentTime
);
2093 else if (res
& (DOWN
|UP
))
2094 XChangeActivePointerGrab(dpy
, ButtonMotionMask
2095 | ButtonReleaseMask
| ButtonPressMask
,
2096 wCursor
[WCUR_VERTICALRESIZE
], CurrentTime
);
2097 else if (res
& (LEFT
|RIGHT
))
2098 XChangeActivePointerGrab(dpy
, ButtonMotionMask
2099 | ButtonReleaseMask
| ButtonPressMask
,
2100 wCursor
[WCUR_HORIZONRESIZE
], CurrentTime
);
2102 XGrabKeyboard(dpy
, root
, False
, GrabModeAsync
, GrabModeAsync
,
2107 /* Draw the resize frame for the first time. */
2108 mapGeometryDisplay(wwin
, fx
, fy
, fw
, fh
);
2110 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2112 showGeometry(wwin
, fx
, fy
, fx
+ fw
, fy
+ fh
, res
);
2117 if (wPreferences
.size_display
== WDIS_FRAME_CENTER
) {
2118 drawTransparentFrame(wwin
, orig_fx
, orig_fy
,
2120 moveGeometryDisplayCentered(scr
, fx
+ fw
/ 2, fy
+ fh
/ 2);
2121 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2123 drawTransparentFrame(wwin
, orig_fx
, orig_fy
,
2125 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2127 if (fh
!= orig_fh
|| fw
!= orig_fw
) {
2128 if (wPreferences
.size_display
== WDIS_NEW
) {
2129 showGeometry(wwin
, orig_fx
, orig_fy
, orig_fx
+ orig_fw
,
2130 orig_fy
+ orig_fh
, res
);
2132 showGeometry(wwin
, fx
, fy
, fx
+ fw
, fy
+ fh
, res
);
2141 if (event
.xbutton
.button
!= ev
->xbutton
.button
)
2145 showGeometry(wwin
, fx
, fy
, fx
+ fw
, fy
+ fh
, res
);
2147 drawTransparentFrame(wwin
, fx
, fy
, fw
, fh
);
2149 XUngrabKeyboard(dpy
, CurrentTime
);
2150 WMUnmapWidget(scr
->gview
);
2153 if (wwin
->client
.width
!= fw
)
2154 wwin
->flags
.user_changed_width
= 1;
2156 if (wwin
->client
.height
!= fh
- vert_border
)
2157 wwin
->flags
.user_changed_height
= 1;
2159 wWindowConfigure(wwin
, fx
, fy
, fw
, fh
- vert_border
);
2162 puts("End resize window");
2167 WMHandleEvent(&event
);
2182 wUnselectWindows(WScreen
*scr
)
2186 if (!scr
->selected_windows
)
2189 while (WMGetArrayItemCount(scr
->selected_windows
)) {
2190 wwin
= WMGetFromArray(scr
->selected_windows
, 0);
2191 if (wwin
->flags
.miniaturized
&& wwin
->icon
&& wwin
->icon
->selected
)
2192 wIconSelect(wwin
->icon
);
2194 wSelectWindow(wwin
, False
);
2196 WMFreeArray(scr
->selected_windows
);
2197 scr
->selected_windows
= NULL
;
2202 selectWindowsInside(WScreen
*scr
, int x1
, int y1
, int x2
, int y2
)
2206 /* select the windows and put them in the selected window list */
2207 tmpw
= scr
->focused_window
;
2208 while (tmpw
!= NULL
) {
2209 if (!(tmpw
->flags
.miniaturized
|| tmpw
->flags
.hidden
)) {
2210 if ((tmpw
->frame
->workspace
== scr
->current_workspace
2211 || IS_OMNIPRESENT(tmpw
))
2212 && (tmpw
->frame_x
>= x1
) && (tmpw
->frame_y
>= y1
)
2213 && (tmpw
->frame
->core
->width
+ tmpw
->frame_x
<= x2
)
2214 && (tmpw
->frame
->core
->height
+ tmpw
->frame_y
<= y2
)) {
2215 wSelectWindow(tmpw
, True
);
2224 wSelectWindows(WScreen
*scr
, XEvent
*ev
)
2227 Window root
= scr
->root_win
;
2228 GC gc
= scr
->frame_gc
;
2229 int xp
= ev
->xbutton
.x_root
;
2230 int yp
= ev
->xbutton
.y_root
;
2235 puts("Selecting windows");
2237 if (XGrabPointer(dpy
, scr
->root_win
, False
, ButtonMotionMask
2238 | ButtonReleaseMask
| ButtonPressMask
, GrabModeAsync
,
2239 GrabModeAsync
, None
, wCursor
[WCUR_DEFAULT
],
2240 CurrentTime
) != Success
) {
2245 wUnselectWindows(scr
);
2247 XDrawRectangle(dpy
, root
, gc
, xp
, yp
, w
, h
);
2249 WMMaskEvent(dpy
, ButtonReleaseMask
| PointerMotionMask
2250 | ButtonPressMask
, &event
);
2252 switch (event
.type
) {
2254 XDrawRectangle(dpy
, root
, gc
, x
, y
, w
, h
);
2255 x
= event
.xmotion
.x_root
;
2262 y
= event
.xmotion
.y_root
;
2269 XDrawRectangle(dpy
, root
, gc
, x
, y
, w
, h
);
2276 if (event
.xbutton
.button
!= ev
->xbutton
.button
)
2279 XDrawRectangle(dpy
, root
, gc
, x
, y
, w
, h
);
2281 XUngrabPointer(dpy
, CurrentTime
);
2282 selectWindowsInside(scr
, x
, y
, x
+ w
, y
+ h
);
2285 wKWMSelectRootRegion(scr
, xp
, yp
, w
, h
,
2286 event
.xbutton
.state
& ControlMask
);
2287 #endif /* KWM_HINTS */
2290 puts("End window selection");
2295 WMHandleEvent(&event
);
2303 InteractivePlaceWindow(WWindow
*wwin
, int *x_ret
, int *y_ret
,
2304 unsigned width
, unsigned height
)
2306 WScreen
*scr
= wwin
->screen_ptr
;
2307 Window root
= scr
->root_win
;
2310 KeyCode shiftl
, shiftr
;
2314 if (XGrabPointer(dpy
, root
, True
, PointerMotionMask
| ButtonPressMask
,
2315 GrabModeAsync
, GrabModeAsync
, None
,
2316 wCursor
[WCUR_DEFAULT
], CurrentTime
) != Success
) {
2321 if (!WFLAGP(wwin
, no_titlebar
)) {
2322 h
= WMFontHeight(scr
->title_font
) + (wPreferences
.window_title_clearance
+ TITLEBAR_EXTEND_SPACE
) * 2;
2325 if (!WFLAGP(wwin
, no_resizebar
)) {
2326 height
+= RESIZEBAR_HEIGHT
;
2328 XGrabKeyboard(dpy
, root
, False
, GrabModeAsync
, GrabModeAsync
, CurrentTime
);
2329 XQueryPointer(dpy
, root
, &junkw
, &junkw
, &x
, &y
, &junk
, &junk
,
2330 (unsigned *) &junk
);
2331 mapPositionDisplay(wwin
, x
- width
/2, y
- h
/2, width
, height
);
2333 drawTransparentFrame(wwin
, x
- width
/2, y
- h
/2, width
, height
);
2335 shiftl
= XKeysymToKeycode(dpy
, XK_Shift_L
);
2336 shiftr
= XKeysymToKeycode(dpy
, XK_Shift_R
);
2338 WMMaskEvent(dpy
, PointerMotionMask
|ButtonPressMask
|ExposureMask
|KeyPressMask
,
2341 if (!checkMouseSamplingRate(&event
))
2344 switch (event
.type
) {
2346 if ((event
.xkey
.keycode
== shiftl
)
2347 || (event
.xkey
.keycode
== shiftr
)) {
2348 drawTransparentFrame(wwin
,
2349 x
- width
/2, y
- h
/2, width
, height
);
2350 cyclePositionDisplay(wwin
,
2351 x
- width
/2, y
- h
/2, width
, height
);
2352 drawTransparentFrame(wwin
,
2353 x
- width
/2, y
- h
/2, width
, height
);
2358 drawTransparentFrame(wwin
, x
- width
/2, y
- h
/2, width
, height
);
2360 x
= event
.xmotion
.x_root
;
2361 y
= event
.xmotion
.y_root
;
2363 if (wPreferences
.move_display
== WDIS_FRAME_CENTER
)
2364 moveGeometryDisplayCentered(scr
, x
, y
+ (height
- h
) / 2);
2366 showPosition(wwin
, x
- width
/2, y
- h
/2);
2368 drawTransparentFrame(wwin
, x
- width
/2, y
- h
/2, width
, height
);
2373 drawTransparentFrame(wwin
, x
- width
/2, y
- h
/2, width
, height
);
2375 *x_ret
= x
- width
/2;
2377 XUngrabPointer(dpy
, CurrentTime
);
2378 XUngrabKeyboard(dpy
, CurrentTime
);
2379 /* get rid of the geometry window */
2380 WMUnmapWidget(scr
->gview
);
2384 WMHandleEvent(&event
);