diff --git a/configure.in b/configure.in index 52c91013..d3f9a12a 100644 --- a/configure.in +++ b/configure.in @@ -186,9 +186,9 @@ echo "zoom has been turned off by request at compiletime" fi AC_SUBST(XVM_LIBS) -AC_ARG_ENABLE(randr, - [ --enable-randr compile with RandR support [default=no]], ,enable_randr=no) -if test "x$enable_randr" = "xyes"; then +AC_ARG_ENABLE(xrandr, + [ --enable-xrandr compile with RandR support [default=no]], ,enable_xrandr=no) +if test "x$enable_xrandr" = "xyes"; then AC_CHECK_LIB(Xrandr, XRRQueryExtension, AC_DEFINE(HAS_XRANDR, 1, [RandR support]) XRANDR_LIBS=-lXrandr, ,$X_LIBS) AC_CHECK_HEADERS(X11/extensions/Xrandr.h) diff --git a/src/E.h b/src/E.h index ece92f50..ba4094e9 100644 --- a/src/E.h +++ b/src/E.h @@ -26,6 +26,10 @@ #define _GNU_SOURCE #include "config.h" +#define USE_STRDUP 1 /* Use libc strdup if present */ +#define USE_STRNDUP 1 /* Use libc strndup if present */ +#define DEBUG_EWMH 0 + #include #include #include @@ -33,10 +37,11 @@ #include #include #include - -#define USE_STRDUP 1 /* Use libc strdup if present */ -#define USE_STRNDUP 1 /* Use libc strndup if present */ -#define DEBUG_EWMH 0 +#ifdef HAS_XRANDR +#ifdef HAVE_X11_EXTENSIONS_XRANDR_H +#define USE_XRANDR 1 +#endif +#endif #define ESetColor(pxc, r, g, b) \ ({ (pxc)->red = ((r)<<8)|r; (pxc)->green = ((g)<<8)|g; (pxc)->blue = ((b)<<8)|b; }) @@ -1963,25 +1968,27 @@ void EventDebugInit(const char *s); void EventShow(const XEvent * ev); /* evhandlers.c */ -void HandleClientMessage(XEvent * ev); -void HandleFocusIn(XEvent * ev); -void HandleFocusOut(XEvent * ev); -void HandleChildShapeChange(XEvent * ev); -void HandleMotion(XEvent * ev); -void HandleDestroy(XEvent * ev); -void HandleProperty(XEvent * ev); -void HandleCirculate(XEvent * ev); -void HandleReparent(XEvent * ev); -void HandleConfigureRequest(XEvent * ev); -void HandleResizeRequest(XEvent * ev); -void HandleMap(XEvent * ev); -void HandleUnmap(XEvent * ev); -void HandleMapRequest(XEvent * ev); -void HandleExpose(XEvent * ev); void HandleMouseDown(XEvent * ev); void HandleMouseUp(XEvent * ev); +void HandleMotion(XEvent * ev); void HandleMouseIn(XEvent * ev); void HandleMouseOut(XEvent * ev); +void HandleFocusIn(XEvent * ev); +void HandleFocusOut(XEvent * ev); +void HandleExpose(XEvent * ev); +void HandleDestroy(XEvent * ev); +void HandleUnmap(XEvent * ev); +void HandleMap(XEvent * ev); +void HandleMapRequest(XEvent * ev); +void HandleReparent(XEvent * ev); +void HandleConfigureNotify(XEvent * ev); +void HandleConfigureRequest(XEvent * ev); +void HandleResizeRequest(XEvent * ev); +void HandleCirculateRequest(XEvent * ev); +void HandleProperty(XEvent * ev); +void HandleClientMessage(XEvent * ev); +void HandleChildShapeChange(XEvent * ev); +void HandleScreenChange(XEvent * ev); #if ENABLE_EWMH /* ewmh.c */ diff --git a/src/events.c b/src/events.c index 5cf6ee58..753484dc 100644 --- a/src/events.c +++ b/src/events.c @@ -23,12 +23,8 @@ #include "E.h" #include #include - -#ifdef HAS_XRANDR -#ifdef HAVE_X11_EXTENSIONS_XRANDR_H +#ifdef USE_XRANDR #include -#define USE_XRANDR 1 -#endif #endif static int event_base_shape = 0; @@ -83,22 +79,6 @@ EventsInit(void) EExit((void *)1); } - /* check for the XTEST extension */ -/* - * if (XTestQueryExtension(disp, &test_event_base, &test_error_base, &test_v1, &test_v2)) - * { - * XTestGrabControl(disp, True); - * } - * else - * Alert("WARNING:\n" - * "This Xserver does not support the XTest extension.\n" - * "This is required for Enlightenment to run properly.\n" - * "Enlightenment will continue to run, but parts may not.\n" - * "Work correctly.\n" - * "Please contact your system administrator, or see the manuals\n" - * "For your XServer to find out how to enable the XTest\n" - * "Extension\n"); - */ #ifdef USE_XRANDR if (XRRQueryExtension(disp, &event_base_randr, &error_base_randr)) { @@ -107,6 +87,9 @@ EventsInit(void) printf("Found extension RandR version %d.%d\n" " Event/error base = %d/%d\n", major, minor, event_base_randr, error_base_randr); + + /* Listen for RandR events */ + XRRSelectInput(disp, root.win, RRScreenChangeNotifyMask); } #endif } @@ -212,384 +195,6 @@ EventsCompress(XEvent * ev) } -static void -HKeyPress(XEvent * ev) -{ - EDBUG(7, "HKeyPress"); - DialogEventKeyPress(ev); - EDBUG_RETURN_; -} - -static void -HKeyRelease(XEvent * ev) -{ - EDBUG(7, "HKeyRelease"); - ev = NULL; - EDBUG_RETURN_; -} - -#if 0 -struct _pbuf -{ - int w, h, depth; - Pixmap id; - void *stack[32]; - struct _pbuf *next; -}; -extern struct _pbuf *pbuf = NULL; - -#endif - -static void -HButtonPress(XEvent * ev) -{ - EDBUG(7, "HButtonPress"); - SoundPlay("SOUND_BUTTON_CLICK"); - HandleMouseDown(ev); -#if 0 - { - int x, y, maxh = 0, count = 0, mcount = 0, ww, hh; - struct _pbuf *pb; - GC gc; - XGCValues gcv; - - gc = XCreateGC(disp, root.win, 0, &gcv); - XSetForeground(disp, gc, WhitePixel(disp, root.scr)); - fprintf(stderr, "Pixmaps allocated:\n"); - x = 0; - y = 0; - XClearWindow(disp, root.win); - for (pb = pbuf; pb; pb = pb->next) - { - ww = pb->w; - hh = pb->h; - if (ww > 64) - ww = 64; - if (hh > 64) - hh = 64; - if (x + ww > root.w) - { - x = 0; - y += maxh; - maxh = 0; - } - XCopyArea(disp, pb->id, root.win, gc, 0, 0, ww, hh, x, y); - XDrawRectangle(disp, root.win, gc, x, y, ww, hh); - x += ww; - if (hh > maxh) - maxh = hh; - count++; - if (pb->depth == 1) - mcount++; - fprintf(stderr, - "%08x (%5ix%5i %i) : " "%x %x %x %x %x %x %x %x " - "%x %x %x %x %x %x %x %x " "%x %x %x %x %x %x %x %x " - "%x %x %x %x %x %x %x %x\n", pb->id, pb->w, pb->h, - pb->depth, pb->stack[0], pb->stack[1], pb->stack[2], - pb->stack[3], pb->stack[4], pb->stack[5], pb->stack[6], - pb->stack[7], pb->stack[8], pb->stack[9], pb->stack[10], - pb->stack[11], pb->stack[12], pb->stack[13], pb->stack[14], - pb->stack[15], pb->stack[16], pb->stack[17], pb->stack[18], - pb->stack[19], pb->stack[20], pb->stack[21], pb->stack[22], - pb->stack[23], pb->stack[24], pb->stack[25], pb->stack[26], - pb->stack[27], pb->stack[28], pb->stack[29], pb->stack[30], - pb->stack[31]); - } - fprintf(stderr, "Total %i, %i of them bitmaps\n", count, mcount); - XFreeGC(disp, gc); - } -#endif - EDBUG_RETURN_; -} - -static void -HButtonRelease(XEvent * ev) -{ - EDBUG(7, "HButtonRelease"); - SoundPlay("SOUND_BUTTON_RAISE"); - HandleMouseUp(ev); - EDBUG_RETURN_; -} - -static void -HMotionNotify(XEvent * ev) -{ - EDBUG(7, "HMotionNotify"); - HandleMotion(ev); - EDBUG_RETURN_; -} - -static void -HEnterNotify(XEvent * ev) -{ - EDBUG(7, "HEnterNotify"); - HandleMouseIn(ev); - EDBUG_RETURN_; -} - -static void -HLeaveNotify(XEvent * ev) -{ - EDBUG(7, "HLeaveNotify"); - HandleMouseOut(ev); - EDBUG_RETURN_; -} - -static void -HFocusIn(XEvent * ev) -{ - EDBUG(7, "HFocusIn"); - HandleFocusIn(ev); - EDBUG_RETURN_; -} - -static void -HFocusOut(XEvent * ev) -{ - EDBUG(7, "HFocusOut"); - HandleFocusOut(ev); - EDBUG_RETURN_; -} - -static void -HKeymapNotify(XEvent * ev) -{ - EDBUG(7, "HKeymapNotify"); - ev = NULL; - EDBUG_RETURN_; -} - -static void -HExpose(XEvent * ev) -{ - EDBUG(7, "HExpose"); - HandleExpose(ev); - EDBUG_RETURN_; -} - -static void -HGraphicsExpose(XEvent * ev) -{ - EDBUG(7, "HGraphicsExpose"); - ev = NULL; - EDBUG_RETURN_; -} - -static void -HNoExpose(XEvent * ev) -{ - EDBUG(7, "HNoExpose"); - ev = NULL; - EDBUG_RETURN_; -} - -static void -HVisibilityNotify(XEvent * ev) -{ - EDBUG(7, "HVisibilityNotify"); - ev = NULL; - EDBUG_RETURN_; -} - -static void -HCreateNotify(XEvent * ev) -{ - EDBUG(7, "HCreateNotify"); - ev = NULL; - EDBUG_RETURN_; -} - -static void -HDestroyNotify(XEvent * ev) -{ - EDBUG(7, "HDestroyNotify"); - HandleDestroy(ev); - EDBUG_RETURN_; -} - -static void -HUnmapNotify(XEvent * ev) -{ - EDBUG(7, "HUnmapNotify"); - HandleUnmap(ev); - EDBUG_RETURN_; -} - -static void -HMapNotify(XEvent * ev) -{ - EDBUG(7, "HMapNotify"); - HandleMap(ev); - EDBUG_RETURN_; -} - -static void -HMapRequest(XEvent * ev) -{ - EDBUG(7, "HMapRequest"); - HandleMapRequest(ev); - EDBUG_RETURN_; -} - -static void -HReparentNotify(XEvent * ev) -{ - EDBUG(7, "HReparentNotify"); - HandleReparent(ev); - EDBUG_RETURN_; -} - -static void -HConfigureNotify(XEvent * ev) -{ - EDBUG(7, "HConfigureNotify"); - ev = NULL; - EDBUG_RETURN_; -} - -static void -HConfigureRequest(XEvent * ev) -{ - EDBUG(7, "HConfigureRequest"); - HandleConfigureRequest(ev); - EDBUG_RETURN_; -} - -static void -HGravityNotify(XEvent * ev) -{ - EDBUG(7, "HGravityNotify"); - ev = NULL; - EDBUG_RETURN_; -} - -static void -HResizeRequest(XEvent * ev) -{ - EDBUG(7, "HResizeRequest"); - HandleResizeRequest(ev); - EDBUG_RETURN_; -} - -static void -HCirculateNotify(XEvent * ev) -{ - EDBUG(7, "HCirculateNotify"); - ev = NULL; - EDBUG_RETURN_; -} - -static void -HCirculateRequest(XEvent * ev) -{ - EDBUG(7, "HCirculateRequest"); - HandleCirculate(ev); - EDBUG_RETURN_; -} - -static void -HPropertyNotify(XEvent * ev) -{ - EDBUG(7, "HPropertyNotify"); - HandleProperty(ev); - EDBUG_RETURN_; -} - -static void -HSelectionClear(XEvent * ev) -{ - EDBUG(7, "HSelectionClear"); - ev = NULL; - EDBUG_RETURN_; -} - -static void -HSelectionRequest(XEvent * ev) -{ - EDBUG(7, "HSelectionRequest"); - ev = NULL; - EDBUG_RETURN_; -} - -static void -HSelectionNotify(XEvent * ev) -{ - EDBUG(7, "HSelectionNotify"); - ev = NULL; - EDBUG_RETURN_; -} - -static void -HColormapNotify(XEvent * ev) -{ - EDBUG(7, "HColormapNotify"); - ev = NULL; - EDBUG_RETURN_; -} - -static void -HClientMessage(XEvent * ev) -{ - EDBUG(7, "HClientMessage"); - HandleClientMessage(ev); - EDBUG_RETURN_; -} - -static void -HMappingNotify(XEvent * ev) -{ - EDBUG(7, "HMappingNotify"); - ev = NULL; - EDBUG_RETURN_; -} - -static void -DefaultFunc(XEvent * ev) -{ - EDBUG(7, "DefaultFunc"); - ev = NULL; - EDBUG_RETURN_; -} - -static HandleStruct HArray[] = { - {DefaultFunc}, - {DefaultFunc}, - {HKeyPress}, - {HKeyRelease}, - {HButtonPress}, - {HButtonRelease}, - {HMotionNotify}, - {HEnterNotify}, - {HLeaveNotify}, - {HFocusIn}, - {HFocusOut}, - {HKeymapNotify}, - {HExpose}, - {HGraphicsExpose}, - {HNoExpose}, - {HVisibilityNotify}, - {HCreateNotify}, - {HDestroyNotify}, - {HUnmapNotify}, - {HMapNotify}, - {HMapRequest}, - {HReparentNotify}, - {HConfigureNotify}, - {HConfigureRequest}, - {HGravityNotify}, - {HResizeRequest}, - {HCirculateNotify}, - {HCirculateRequest}, - {HPropertyNotify}, - {HSelectionClear}, - {HSelectionRequest}, - {HSelectionNotify}, - {HColormapNotify}, - {HClientMessage}, - {HMappingNotify}, - {DefaultFunc} -}; - static void HandleEvent(XEvent * ev) { @@ -604,13 +209,14 @@ HandleEvent(XEvent * ev) #endif mode.current_event = ev; - if (ev->type == event_base_shape + ShapeNotify) - HandleChildShapeChange(ev); - - if ((ev->type == KeyPress) || (ev->type == KeyRelease) - || (ev->type == ButtonPress) || (ev->type == ButtonRelease) - || (ev->type == EnterNotify) || (ev->type == LeaveNotify)) + switch (ev->type) { + case KeyPress: + case KeyRelease: + case ButtonPress: + case ButtonRelease: + case EnterNotify: + case LeaveNotify: if (((ev->type == KeyPress) || (ev->type == KeyRelease)) && (ev->xkey.root != root.win)) { @@ -633,11 +239,110 @@ HandleEvent(XEvent * ev) Efree(lst); } } + break; } - if (ev->type <= 35) - HArray[ev->type].func(ev); + switch (ev->type) + { + case KeyPress: /* 2 */ + DialogEventKeyPress(ev); + break; + case KeyRelease: /* 3 */ + break; + case ButtonPress: /* 4 */ + SoundPlay("SOUND_BUTTON_CLICK"); + HandleMouseDown(ev); + break; + case ButtonRelease: /* 5 */ + SoundPlay("SOUND_BUTTON_RAISE"); + HandleMouseUp(ev); + break; + case MotionNotify: /* 6 */ + HandleMotion(ev); + break; + case EnterNotify: /* 7 */ + HandleMouseIn(ev); + break; + case LeaveNotify: /* 8 */ + HandleMouseOut(ev); + break; + case FocusIn: /* 9 */ + HandleFocusIn(ev); + break; + case FocusOut: /* 10 */ + HandleFocusOut(ev); + break; + case KeymapNotify: /* 11 */ + break; + case Expose: /* 12 */ + HandleExpose(ev); + break; + case GraphicsExpose: /* 13 */ + break; + case NoExpose: /* 14 */ + break; + case VisibilityNotify: /* 15 */ + break; + case CreateNotify: /* 16 */ + break; + case DestroyNotify: /* 17 */ + HandleDestroy(ev); + break; + case UnmapNotify: /* 18 */ + HandleUnmap(ev); + break; + case MapNotify: /* 19 */ + HandleMap(ev); + break; + case MapRequest: /* 20 */ + HandleMapRequest(ev); + break; + case ReparentNotify: /* 21 */ + HandleReparent(ev); + break; + case ConfigureNotify: /* 22 */ + HandleConfigureNotify(ev); + break; + case ConfigureRequest: /* 23 */ + HandleConfigureRequest(ev); + break; + case GravityNotify: /* 24 */ + break; + case ResizeRequest: /* 25 */ + HandleResizeRequest(ev); + break; + case CirculateNotify: /* 26 */ + break; + case CirculateRequest: /* 27 */ + HandleCirculateRequest(ev); + break; + case PropertyNotify: /* 28 */ + HandleProperty(ev); + break; + case SelectionClear: /* 29 */ + break; + case SelectionRequest: /* 30 */ + break; + case SelectionNotify: /* 31 */ + break; + case ColormapNotify: /* 32 */ + break; + case ClientMessage: /* 33 */ + HandleClientMessage(ev); + break; + case MappingNotify: /* 34 */ + break; + default: + if (ev->type == event_base_shape + ShapeNotify) + HandleChildShapeChange(ev); +#ifdef USE_XRANDR + else if (ev->type == event_base_randr + RRScreenChangeNotify) + HandleScreenChange(ev); +#endif + break; + } + /* Should not be "global" */ IconboxesHandleEvent(ev); if (diddeskaccount) @@ -968,8 +673,14 @@ EventShow(const XEvent * ev) case MapNotify: case MapRequest: case ReparentNotify: - case ConfigureNotify: goto case_common; + case ConfigureNotify: + printf("EV-%s: win=%#lx event=%#lx %d+%d %dx%d bw=%d above=%#lx\n", + name, ev->xconfigure.window, win, + ev->xconfigure.x, ev->xconfigure.y, + ev->xconfigure.width, ev->xconfigure.height, + ev->xconfigure.border_width, ev->xconfigure.above); + break; case ConfigureRequest: printf ("EV-%s: win=%#lx parent=%#lx m=%#lx %d+%d %dx%d bw=%d above=%#lx stk=%d\n", @@ -1015,6 +726,10 @@ EventShow(const XEvent * ev) default: if (ev->type == event_base_shape + ShapeNotify) printf("EV-ShapeNotify win=%#lx\n", win); +#ifdef USE_XRANDR + else if (ev->type == event_base_randr + RRScreenChangeNotify) + printf("EV-RRScreenChangeNotify win=%#lx\n", win); +#endif else printf("EV-??? Type=%d win=%#lx\n", ev->type, win); break; diff --git a/src/evhandlers.c b/src/evhandlers.c index c4541347..74bbf235 100644 --- a/src/evhandlers.c +++ b/src/evhandlers.c @@ -100,593 +100,6 @@ ButtonProxySendEvent(XEvent * ev) ev); } -void -HandleClientMessage(XEvent * ev) -{ - EDBUG(5, "HandleClientMessage"); - - HintsProcessClientMessage(&(ev->xclient)); - - EDBUG_RETURN_; -} - -void -HandleFocusIn(XEvent * ev) -{ - Window win = ev->xfocus.window; - EWin *ewin; - - EDBUG(5, "HandleFocusIn"); - - ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); - if (ewin && !ewin->active) - { - ewin->active = 1; - DrawEwin(ewin); - - FocusEwinSetGrabs(ewin); - } - - EDBUG_RETURN_; -} - -void -HandleFocusOut(XEvent * ev) -{ - Window win = ev->xfocus.window; - EWin *ewin; - - EDBUG(5, "HandleFocusOut"); - - /* Do nothing if the focus is passed down to child */ - if (ev->xfocus.detail == NotifyInferior) - goto exit; - - ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); - if (ewin && ewin->active) - { - ewin->active = 0; - DrawEwin(ewin); - - FocusEwinSetGrabs(ewin); - } - - exit: - EDBUG_RETURN_; -} - -void -HandleChildShapeChange(XEvent * ev) -{ - Window win; - EWin *ewin; - Border *b; - - EDBUG(5, "HandleChildShapeChange"); - win = ((XShapeEvent *) ev)->window; - ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); - if (ewin) - { - b = ewin->border; - SyncBorderToEwin(ewin); - if (ewin->border == b) - PropagateShapes(ewin->win); - } - EDBUG_RETURN_; -} - -void -HandleMotion(XEvent * ev) -{ - EDBUG(5, "HandleMotion"); - - TooltipsHandleEvent(); - EdgeHandleMotion(ev); - mode.px = mode.x; - mode.py = mode.y; - mode.x = ev->xmotion.x_root; - mode.y = ev->xmotion.y_root; - desks.current = DesktopAt(mode.x, mode.y); - - if ((!(ev->xmotion.state - & (Button1Mask | Button2Mask | Button3Mask | Button4Mask | - Button5Mask)) && (!mode.place))) - { - if (ActionsEnd(NULL)) - EDBUG_RETURN_; - } - - ActionsHandleMotion(); - -#define SCROLL_RATIO 2/3 - if (((mode.cur_menu_mode) || (clickmenu)) && (mode.cur_menu_depth > 0)) - { - int i, offx = 0, offy = 0, xdist = 0, ydist = 0; - EWin *ewin; - EWin *menus[256]; - int fx[256]; - int fy[256]; - int tx[256]; - int ty[256]; - static int menu_scroll_dist = 4; - int my_width, my_height, x_org, y_org, head_num = 0; - - head_num = ScreenGetGeometry(mode.x, mode.y, &x_org, &y_org, - &my_width, &my_height); - - if (mode.x > ((x_org + my_width) - (menu_scroll_dist + 1))) - { - xdist = -(menu_scroll_dist + (mode.x - (x_org + my_width))); - } - else if (mode.x < (menu_scroll_dist + x_org)) - { - xdist = x_org + menu_scroll_dist - (mode.x); - } - - if (mode.y > (root.h - (menu_scroll_dist + 1))) - { - ydist = -(menu_scroll_dist + (mode.y - (y_org + my_height))); - } - else if (mode.y < (menu_scroll_dist + y_org)) - { - ydist = y_org + menu_scroll_dist - (mode.y); - } - - /* That's a hack to avoid unwanted events: - * If the user entered the border area, he has to - * leave it first, before he can scroll menus again ... - */ - if ((xdist != 0) || (ydist != 0) || mode.doingslide) - { - /* -10 has no meaning, only makes sure that the if's */ - /* above can't be fulfilled ... */ - menu_scroll_dist = -10; - } - else - { - menu_scroll_dist = 13; - } - - if (mode.cur_menu_depth > 0) - { - int x1, y1, x2, y2; - - x1 = x_org + my_width; - x2 = x_org - 1; - y1 = y_org + my_height; - y2 = y_org - 1; - /* work out the minimum and maximum extents of our */ - /* currently active menus */ - for (i = 0; i < mode.cur_menu_depth; i++) - { - if (mode.cur_menu[i]) - { - ewin = FindEwinByMenu(mode.cur_menu[i]); - if (ewin) - { - if (ewin->x < x1) - x1 = ewin->x; - if (ewin->y < y1) - y1 = ewin->y; - if ((ewin->x + ewin->w - 1) > x2) - x2 = ewin->x + ewin->w - 1; - if ((ewin->y + ewin->h - 1) > y2) - y2 = ewin->y + ewin->h - 1; - } - } - } - - if (xdist < 0) - { - offx = (x_org + my_width) - x2; - } - else if (xdist > 0) - { - offx = x_org - x1; - } - if (ydist < 0) - { - offy = (y_org + my_height) - y2; - } - else if (ydist > 0) - { - offy = y_org - y1; - } - - if ((xdist < 0) && (offx <= 0)) - xdist = offx; - if ((xdist > 0) && (offx >= 0)) - xdist = offx; - if ((ydist < 0) && (offy <= 0)) - ydist = offy; - if ((ydist > 0) && (offy >= 0)) - ydist = offy; - - /* only if any active menus are partially off screen then scroll */ - if ((((xdist > 0) && (x1 < x_org)) - || ((xdist < 0) && (x2 >= (x_org + my_width)))) - || (((ydist > 0) && (y1 < y_org)) - || ((ydist < 0) && (y2 >= (y_org + my_height))))) - { - /* If we would scroll too far, limit scrolling to 2/3s of screen */ - if (ydist < -my_width) - ydist = -my_width * SCROLL_RATIO; - if (ydist > my_width) - ydist = my_width * SCROLL_RATIO; - - if (xdist < -my_height) - xdist = -my_height * SCROLL_RATIO; - if (xdist > my_height) - xdist = my_height * SCROLL_RATIO; - - if (mode.cur_menu_depth) - { -#ifdef HAS_XINERAMA - ewin = FindEwinByMenu(mode.cur_menu[0]); - if (ewin->head == head_num) - { -#endif - for (i = 0; i < mode.cur_menu_depth; i++) - { - menus[i] = NULL; - if (mode.cur_menu[i]) - { - ewin = FindEwinByMenu(mode.cur_menu[i]); - if (ewin) - { - menus[i] = ewin; - fx[i] = ewin->x; - fy[i] = ewin->y; - tx[i] = ewin->x + xdist; - ty[i] = ewin->y + ydist; - } - } - } - SlideEwinsTo(menus, fx, fy, tx, ty, - mode.cur_menu_depth, conf.shadespeed); - if (((xdist != 0) || (ydist != 0)) - && (conf.warpmenus)) - XWarpPointer(disp, None, None, 0, 0, 0, 0, xdist, - ydist); -#ifdef HAS_XINERAMA - } -#endif - } - } - } - } - - PagersEventMotion(ev); - - DialogEventMotion(ev); - - EDBUG_RETURN_; -} - -void -HandleDestroy(XEvent * ev) -{ - Window win = ev->xdestroywindow.window; - EWin *ewin; - Client *c; - - EDBUG(5, "HandleDestroy"); - - EForgetWindow(disp, win); - - if (win == mode.context_win) - mode.context_win = 0; - - ewin = RemoveItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); - if (ewin) - { - FreeEwin(ewin); - EDBUG_RETURN_; - } - - c = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_CLIENT); - if (c) - DeleteClient(c); - - EDBUG_RETURN_; -} - -void -HandleProperty(XEvent * ev) -{ - Window win = ev->xproperty.window; - EWin *ewin; - - EDBUG(5, "HandleProperty"); - - ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); - if (!ewin) - goto exit; - - GrabX(); - EwinChangesStart(ewin); - - HintsProcessPropertyChange(ewin, ev->xproperty.atom); - ICCCM_GetTitle(ewin, ev->xproperty.atom); - ICCCM_GetHints(ewin, ev->xproperty.atom); - ICCCM_GetInfo(ewin, ev->xproperty.atom); - ICCCM_Cmap(ewin); - ICCCM_GetGeoms(ewin, ev->xproperty.atom); - SessionGetInfo(ewin, ev->xproperty.atom); - SyncBorderToEwin(ewin); - - EwinChangesProcess(ewin); - UngrabX(); - - exit: - EDBUG_RETURN_; -} - -void -HandleCirculate(XEvent * ev) -{ - Window win; - EWin *ewin; - - EDBUG(5, "HandleCirculate"); - win = ev->xcirculaterequest.window; - ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); - if (ewin) - { - if (ev->xcirculaterequest.place == PlaceOnTop) - RaiseEwin(ewin); - else - LowerEwin(ewin); - } - else - { - if (ev->xcirculaterequest.place == PlaceOnTop) - XRaiseWindow(disp, win); - else - XLowerWindow(disp, win); - } - EDBUG_RETURN_; -} - -void -HandleReparent(XEvent * ev) -{ - EDBUG(5, "HandleReparent"); - EDBUG_RETURN_; -} - -void -HandleConfigureRequest(XEvent * ev) -{ - Window win, winrel; - EWin *ewin, *ewin2; - int x = 0, y = 0, w = 0, h = 0; - XWindowChanges xwc; - - EDBUG(5, "HandleConfigureRequest"); - win = ev->xconfigurerequest.window; - ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); - if (ewin) - { - x = ewin->x + ewin->border->border.left; - y = ewin->y + ewin->border->border.top; - w = ewin->client.w; - h = ewin->client.h; - winrel = 0; - if (ev->xconfigurerequest.value_mask & CWX) - x = ev->xconfigurerequest.x; - if (ev->xconfigurerequest.value_mask & CWY) - y = ev->xconfigurerequest.y; - if (ev->xconfigurerequest.value_mask & CWWidth) - w = ev->xconfigurerequest.width; - if (ev->xconfigurerequest.value_mask & CWHeight) - h = ev->xconfigurerequest.height; - if (ev->xconfigurerequest.value_mask & CWSibling) - winrel = ev->xconfigurerequest.above; - if (ev->xconfigurerequest.value_mask & CWStackMode) - { - ewin2 = FindItem(NULL, winrel, LIST_FINDBY_ID, LIST_TYPE_EWIN); - if (ewin2) - winrel = ewin2->win; - xwc.sibling = winrel; - xwc.stack_mode = ev->xconfigurerequest.detail; - if (mode.mode == MODE_NONE) - { - if (xwc.stack_mode == Above) - RaiseEwin(ewin); - else if (xwc.stack_mode == Below) - LowerEwin(ewin); - } - /* else - * XConfigureWindow(disp, ewin->win, - * ev->xconfigurerequest.value_mask & - * (CWSibling | CWStackMode), &xwc); */ - } - /* this ugly workaround here is because x11amp is very brain-dead */ - /* and sets its minunum and maximm sizes the same - fair enough */ - /* to ensure it doesnt get resized - BUT hwne it shades itself */ - /* it resizes down to a smaller size - of course keeping the */ - /* minimum and maximim size same - E unconditionally disallows any */ - /* client window to be resized outside of its constraints */ - /* (any client could do this resize - not just x11amp thus E is */ - /* imposing the hints x11amp set up - this works around by */ - /* modifying the constraints to fit what the app requested */ - if (w < ewin->client.width.min) - ewin->client.width.min = w; - if (w > ewin->client.width.max) - ewin->client.width.max = w; - if (h < ewin->client.height.min) - ewin->client.height.min = h; - if (h > ewin->client.height.max) - ewin->client.height.max = h; - MoveResizeEwin(ewin, x - ewin->border->border.left, - y - ewin->border->border.top, w, h); - if (mode.mode == MODE_MOVE_PENDING || mode.mode == MODE_MOVE) - ICCCM_Configure(ewin); - { - char pshaped; - - pshaped = ewin->client.shaped; - ICCCM_GetShapeInfo(ewin); - if (pshaped != ewin->client.shaped) - { - SyncBorderToEwin(ewin); - PropagateShapes(ewin->win); - } - } - ReZoom(ewin); - } - else - { - xwc.x = ev->xconfigurerequest.x; - xwc.y = ev->xconfigurerequest.y; - xwc.width = ev->xconfigurerequest.width; - xwc.height = ev->xconfigurerequest.height; - xwc.border_width = ev->xconfigurerequest.border_width; - xwc.sibling = ev->xconfigurerequest.above; - xwc.stack_mode = ev->xconfigurerequest.detail; - XConfigureWindow(disp, win, ev->xconfigurerequest.value_mask, &xwc); - } - EDBUG_RETURN_; -} - -void -HandleResizeRequest(XEvent * ev) -{ - Window win; - EWin *ewin; - int w, h; - - EDBUG(5, "HandleResizeRequest"); - win = ev->xresizerequest.window; - ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); - if (ewin) - { - w = ev->xresizerequest.width; - h = ev->xresizerequest.height; - ResizeEwin(ewin, w, h); - { - char pshaped; - - pshaped = ewin->client.shaped; - ICCCM_GetShapeInfo(ewin); - if (pshaped != ewin->client.shaped) - { - SyncBorderToEwin(ewin); - PropagateShapes(ewin->win); - } - } - ReZoom(ewin); - } - else - EResizeWindow(disp, win, ev->xresizerequest.width, - ev->xresizerequest.height); - EDBUG_RETURN_; -} - -void -HandleMap(XEvent * ev) -{ - Window win = ev->xunmap.window; - EWin *ewin; - - EDBUG(5, "HandleMap"); - ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); - if (ewin) - { - ewin->mapped = 1; - } - EDBUG_RETURN_; -} - -void -HandleUnmap(XEvent * ev) -{ - Window win = ev->xunmap.window; - EWin *ewin; - - EDBUG(5, "HandleUnmap"); - ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); - if (ewin) - { - ewin->mapped = 0; - - if (ewin->pager) - PagerEventUnmap(ewin->pager); - - if (conf.dockapp_support && ewin->docked) - DockDestroy(ewin); - - ActionsEnd(ewin); - if (ewin == GetContextEwin()) - SlideoutsHide(); - - if (ewin == mode.focuswin) - FocusToEWin(NULL, FOCUS_EWIN_GONE); - if (ewin == mode.mouse_over_win) - mode.mouse_over_win = NULL; - - if (!ewin->iconified) - { - XTranslateCoordinates(disp, ewin->client.win, root.win, - -ewin->border->border.left, - -ewin->border->border.top, &ewin->client.x, - &ewin->client.y, &win); - EReparentWindow(disp, ewin->client.win, root.win, ewin->client.x, - ewin->client.y); - ICCCM_Withdraw(ewin); - RemoveItem(NULL, ewin->client.win, LIST_FINDBY_ID, LIST_TYPE_EWIN); - FreeEwin(ewin); - } - else - { - HideEwin(ewin); - } - } - EDBUG_RETURN_; -} - -void -HandleMapRequest(XEvent * ev) -{ - Window win; - EWin *ewin; - - EDBUG(5, "HandleMapRequest"); - - win = ev->xconfigurerequest.window; - ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); - if (ewin && ewin->iconified) - { - DeIconifyEwin(ewin); - } - else - { - AddToFamily(ev->xmap.window); - HintsSetClientList(); - } - - EDBUG_RETURN_; -} - -void -HandleExpose(XEvent * ev) -{ - EDBUG(5, "HandleExpose"); - - if (BordersEventExpose(ev)) - goto exit; - - if (ButtonsEventExpose(ev)) - goto exit; - - if (DialogEventExpose(ev)) - goto exit; - - exit: - EDBUG_RETURN_; -} - void HandleMouseDown(XEvent * ev) { @@ -909,6 +322,194 @@ HandleMouseUp(XEvent * ev) EDBUG_RETURN_; } +void +HandleMotion(XEvent * ev) +{ + EDBUG(5, "HandleMotion"); + + TooltipsHandleEvent(); + EdgeHandleMotion(ev); + mode.px = mode.x; + mode.py = mode.y; + mode.x = ev->xmotion.x_root; + mode.y = ev->xmotion.y_root; + desks.current = DesktopAt(mode.x, mode.y); + + if ((!(ev->xmotion.state + & (Button1Mask | Button2Mask | Button3Mask | Button4Mask | + Button5Mask)) && (!mode.place))) + { + if (ActionsEnd(NULL)) + EDBUG_RETURN_; + } + + ActionsHandleMotion(); + +#define SCROLL_RATIO 2/3 + if (((mode.cur_menu_mode) || (clickmenu)) && (mode.cur_menu_depth > 0)) + { + int i, offx = 0, offy = 0, xdist = 0, ydist = 0; + EWin *ewin; + EWin *menus[256]; + int fx[256]; + int fy[256]; + int tx[256]; + int ty[256]; + static int menu_scroll_dist = 4; + int my_width, my_height, x_org, y_org, head_num = 0; + + head_num = ScreenGetGeometry(mode.x, mode.y, &x_org, &y_org, + &my_width, &my_height); + + if (mode.x > ((x_org + my_width) - (menu_scroll_dist + 1))) + { + xdist = -(menu_scroll_dist + (mode.x - (x_org + my_width))); + } + else if (mode.x < (menu_scroll_dist + x_org)) + { + xdist = x_org + menu_scroll_dist - (mode.x); + } + + if (mode.y > (root.h - (menu_scroll_dist + 1))) + { + ydist = -(menu_scroll_dist + (mode.y - (y_org + my_height))); + } + else if (mode.y < (menu_scroll_dist + y_org)) + { + ydist = y_org + menu_scroll_dist - (mode.y); + } + + /* That's a hack to avoid unwanted events: + * If the user entered the border area, he has to + * leave it first, before he can scroll menus again ... + */ + if ((xdist != 0) || (ydist != 0) || mode.doingslide) + { + /* -10 has no meaning, only makes sure that the if's */ + /* above can't be fulfilled ... */ + menu_scroll_dist = -10; + } + else + { + menu_scroll_dist = 13; + } + + if (mode.cur_menu_depth > 0) + { + int x1, y1, x2, y2; + + x1 = x_org + my_width; + x2 = x_org - 1; + y1 = y_org + my_height; + y2 = y_org - 1; + /* work out the minimum and maximum extents of our */ + /* currently active menus */ + for (i = 0; i < mode.cur_menu_depth; i++) + { + if (mode.cur_menu[i]) + { + ewin = FindEwinByMenu(mode.cur_menu[i]); + if (ewin) + { + if (ewin->x < x1) + x1 = ewin->x; + if (ewin->y < y1) + y1 = ewin->y; + if ((ewin->x + ewin->w - 1) > x2) + x2 = ewin->x + ewin->w - 1; + if ((ewin->y + ewin->h - 1) > y2) + y2 = ewin->y + ewin->h - 1; + } + } + } + + if (xdist < 0) + { + offx = (x_org + my_width) - x2; + } + else if (xdist > 0) + { + offx = x_org - x1; + } + if (ydist < 0) + { + offy = (y_org + my_height) - y2; + } + else if (ydist > 0) + { + offy = y_org - y1; + } + + if ((xdist < 0) && (offx <= 0)) + xdist = offx; + if ((xdist > 0) && (offx >= 0)) + xdist = offx; + if ((ydist < 0) && (offy <= 0)) + ydist = offy; + if ((ydist > 0) && (offy >= 0)) + ydist = offy; + + /* only if any active menus are partially off screen then scroll */ + if ((((xdist > 0) && (x1 < x_org)) + || ((xdist < 0) && (x2 >= (x_org + my_width)))) + || (((ydist > 0) && (y1 < y_org)) + || ((ydist < 0) && (y2 >= (y_org + my_height))))) + { + /* If we would scroll too far, limit scrolling to 2/3s of screen */ + if (ydist < -my_width) + ydist = -my_width * SCROLL_RATIO; + if (ydist > my_width) + ydist = my_width * SCROLL_RATIO; + + if (xdist < -my_height) + xdist = -my_height * SCROLL_RATIO; + if (xdist > my_height) + xdist = my_height * SCROLL_RATIO; + + if (mode.cur_menu_depth) + { +#ifdef HAS_XINERAMA + ewin = FindEwinByMenu(mode.cur_menu[0]); + if (ewin->head == head_num) + { +#endif + for (i = 0; i < mode.cur_menu_depth; i++) + { + menus[i] = NULL; + if (mode.cur_menu[i]) + { + ewin = FindEwinByMenu(mode.cur_menu[i]); + if (ewin) + { + menus[i] = ewin; + fx[i] = ewin->x; + fy[i] = ewin->y; + tx[i] = ewin->x + xdist; + ty[i] = ewin->y + ydist; + } + } + } + SlideEwinsTo(menus, fx, fy, tx, ty, + mode.cur_menu_depth, conf.shadespeed); + if (((xdist != 0) || (ydist != 0)) + && (conf.warpmenus)) + XWarpPointer(disp, None, None, 0, 0, 0, 0, xdist, + ydist); +#ifdef HAS_XINERAMA + } +#endif + } + } + } + } + + PagersEventMotion(ev); + + DialogEventMotion(ev); + + EDBUG_RETURN_; +} + void HandleMouseIn(XEvent * ev) { @@ -983,3 +584,436 @@ HandleMouseOut(XEvent * ev) EDBUG_RETURN_; } + +void +HandleFocusIn(XEvent * ev) +{ + Window win = ev->xfocus.window; + EWin *ewin; + + EDBUG(5, "HandleFocusIn"); + + ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); + if (ewin && !ewin->active) + { + ewin->active = 1; + DrawEwin(ewin); + + FocusEwinSetGrabs(ewin); + } + + EDBUG_RETURN_; +} + +void +HandleFocusOut(XEvent * ev) +{ + Window win = ev->xfocus.window; + EWin *ewin; + + EDBUG(5, "HandleFocusOut"); + + /* Do nothing if the focus is passed down to child */ + if (ev->xfocus.detail == NotifyInferior) + goto exit; + + ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); + if (ewin && ewin->active) + { + ewin->active = 0; + DrawEwin(ewin); + + FocusEwinSetGrabs(ewin); + } + + exit: + EDBUG_RETURN_; +} + +void +HandleExpose(XEvent * ev) +{ + EDBUG(5, "HandleExpose"); + + if (BordersEventExpose(ev)) + goto exit; + + if (ButtonsEventExpose(ev)) + goto exit; + + if (DialogEventExpose(ev)) + goto exit; + + exit: + EDBUG_RETURN_; +} + +void +HandleDestroy(XEvent * ev) +{ + Window win = ev->xdestroywindow.window; + EWin *ewin; + Client *c; + + EDBUG(5, "HandleDestroy"); + + EForgetWindow(disp, win); + + if (win == mode.context_win) + mode.context_win = 0; + + ewin = RemoveItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); + if (ewin) + { + FreeEwin(ewin); + EDBUG_RETURN_; + } + + c = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_CLIENT); + if (c) + DeleteClient(c); + + EDBUG_RETURN_; +} + +void +HandleUnmap(XEvent * ev) +{ + Window win = ev->xunmap.window; + EWin *ewin; + + EDBUG(5, "HandleUnmap"); + ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); + if (ewin) + { + ewin->mapped = 0; + + if (ewin->pager) + PagerEventUnmap(ewin->pager); + + if (conf.dockapp_support && ewin->docked) + DockDestroy(ewin); + + ActionsEnd(ewin); + if (ewin == GetContextEwin()) + SlideoutsHide(); + + if (ewin == mode.focuswin) + FocusToEWin(NULL, FOCUS_EWIN_GONE); + if (ewin == mode.mouse_over_win) + mode.mouse_over_win = NULL; + + if (!ewin->iconified) + { + XTranslateCoordinates(disp, ewin->client.win, root.win, + -ewin->border->border.left, + -ewin->border->border.top, &ewin->client.x, + &ewin->client.y, &win); + EReparentWindow(disp, ewin->client.win, root.win, ewin->client.x, + ewin->client.y); + ICCCM_Withdraw(ewin); + RemoveItem(NULL, ewin->client.win, LIST_FINDBY_ID, LIST_TYPE_EWIN); + FreeEwin(ewin); + } + else + { + HideEwin(ewin); + } + } + EDBUG_RETURN_; +} + +void +HandleMap(XEvent * ev) +{ + Window win = ev->xunmap.window; + EWin *ewin; + + EDBUG(5, "HandleMap"); + ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); + if (ewin) + { + ewin->mapped = 1; + } + EDBUG_RETURN_; +} + +void +HandleMapRequest(XEvent * ev) +{ + Window win; + EWin *ewin; + + EDBUG(5, "HandleMapRequest"); + + win = ev->xconfigurerequest.window; + ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); + if (ewin && ewin->iconified) + { + DeIconifyEwin(ewin); + } + else + { + AddToFamily(ev->xmap.window); + HintsSetClientList(); + } + + EDBUG_RETURN_; +} + +void +HandleReparent(XEvent * ev) +{ + EDBUG(5, "HandleReparent"); + EDBUG_RETURN_; +} + +void +HandleConfigureNotify(XEvent * ev) +{ + EDBUG(5, "HandleConfigureNotify"); + +#ifdef USE_XRANDR + if (ev->xconfigure.window == root.win) + DialogOK("Wheee! (ConfigureNotify)", + "Screen size changed to\n%dx%d pixels", + ev->xconfigure.width, ev->xconfigure.height); +#endif + + EDBUG_RETURN_; +} + +void +HandleConfigureRequest(XEvent * ev) +{ + Window win, winrel; + EWin *ewin, *ewin2; + int x = 0, y = 0, w = 0, h = 0; + XWindowChanges xwc; + + EDBUG(5, "HandleConfigureRequest"); + win = ev->xconfigurerequest.window; + ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); + if (ewin) + { + x = ewin->x + ewin->border->border.left; + y = ewin->y + ewin->border->border.top; + w = ewin->client.w; + h = ewin->client.h; + winrel = 0; + if (ev->xconfigurerequest.value_mask & CWX) + x = ev->xconfigurerequest.x; + if (ev->xconfigurerequest.value_mask & CWY) + y = ev->xconfigurerequest.y; + if (ev->xconfigurerequest.value_mask & CWWidth) + w = ev->xconfigurerequest.width; + if (ev->xconfigurerequest.value_mask & CWHeight) + h = ev->xconfigurerequest.height; + if (ev->xconfigurerequest.value_mask & CWSibling) + winrel = ev->xconfigurerequest.above; + if (ev->xconfigurerequest.value_mask & CWStackMode) + { + ewin2 = FindItem(NULL, winrel, LIST_FINDBY_ID, LIST_TYPE_EWIN); + if (ewin2) + winrel = ewin2->win; + xwc.sibling = winrel; + xwc.stack_mode = ev->xconfigurerequest.detail; + if (mode.mode == MODE_NONE) + { + if (xwc.stack_mode == Above) + RaiseEwin(ewin); + else if (xwc.stack_mode == Below) + LowerEwin(ewin); + } + /* else + * XConfigureWindow(disp, ewin->win, + * ev->xconfigurerequest.value_mask & + * (CWSibling | CWStackMode), &xwc); */ + } + /* this ugly workaround here is because x11amp is very brain-dead */ + /* and sets its minunum and maximm sizes the same - fair enough */ + /* to ensure it doesnt get resized - BUT hwne it shades itself */ + /* it resizes down to a smaller size - of course keeping the */ + /* minimum and maximim size same - E unconditionally disallows any */ + /* client window to be resized outside of its constraints */ + /* (any client could do this resize - not just x11amp thus E is */ + /* imposing the hints x11amp set up - this works around by */ + /* modifying the constraints to fit what the app requested */ + if (w < ewin->client.width.min) + ewin->client.width.min = w; + if (w > ewin->client.width.max) + ewin->client.width.max = w; + if (h < ewin->client.height.min) + ewin->client.height.min = h; + if (h > ewin->client.height.max) + ewin->client.height.max = h; + MoveResizeEwin(ewin, x - ewin->border->border.left, + y - ewin->border->border.top, w, h); + if (mode.mode == MODE_MOVE_PENDING || mode.mode == MODE_MOVE) + ICCCM_Configure(ewin); + { + char pshaped; + + pshaped = ewin->client.shaped; + ICCCM_GetShapeInfo(ewin); + if (pshaped != ewin->client.shaped) + { + SyncBorderToEwin(ewin); + PropagateShapes(ewin->win); + } + } + ReZoom(ewin); + } + else + { + xwc.x = ev->xconfigurerequest.x; + xwc.y = ev->xconfigurerequest.y; + xwc.width = ev->xconfigurerequest.width; + xwc.height = ev->xconfigurerequest.height; + xwc.border_width = ev->xconfigurerequest.border_width; + xwc.sibling = ev->xconfigurerequest.above; + xwc.stack_mode = ev->xconfigurerequest.detail; + XConfigureWindow(disp, win, ev->xconfigurerequest.value_mask, &xwc); + } + EDBUG_RETURN_; +} + +void +HandleResizeRequest(XEvent * ev) +{ + Window win; + EWin *ewin; + int w, h; + + EDBUG(5, "HandleResizeRequest"); + win = ev->xresizerequest.window; + ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); + if (ewin) + { + w = ev->xresizerequest.width; + h = ev->xresizerequest.height; + ResizeEwin(ewin, w, h); + { + char pshaped; + + pshaped = ewin->client.shaped; + ICCCM_GetShapeInfo(ewin); + if (pshaped != ewin->client.shaped) + { + SyncBorderToEwin(ewin); + PropagateShapes(ewin->win); + } + } + ReZoom(ewin); + } + else + EResizeWindow(disp, win, ev->xresizerequest.width, + ev->xresizerequest.height); + EDBUG_RETURN_; +} + +void +HandleCirculateRequest(XEvent * ev) +{ + Window win; + EWin *ewin; + + EDBUG(5, "HandleCirculate"); + win = ev->xcirculaterequest.window; + ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); + if (ewin) + { + if (ev->xcirculaterequest.place == PlaceOnTop) + RaiseEwin(ewin); + else + LowerEwin(ewin); + } + else + { + if (ev->xcirculaterequest.place == PlaceOnTop) + XRaiseWindow(disp, win); + else + XLowerWindow(disp, win); + } + EDBUG_RETURN_; +} + +void +HandleProperty(XEvent * ev) +{ + Window win = ev->xproperty.window; + EWin *ewin; + + EDBUG(5, "HandleProperty"); + + ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); + if (!ewin) + goto exit; + + GrabX(); + EwinChangesStart(ewin); + + HintsProcessPropertyChange(ewin, ev->xproperty.atom); + ICCCM_GetTitle(ewin, ev->xproperty.atom); + ICCCM_GetHints(ewin, ev->xproperty.atom); + ICCCM_GetInfo(ewin, ev->xproperty.atom); + ICCCM_Cmap(ewin); + ICCCM_GetGeoms(ewin, ev->xproperty.atom); + SessionGetInfo(ewin, ev->xproperty.atom); + SyncBorderToEwin(ewin); + + EwinChangesProcess(ewin); + UngrabX(); + + exit: + EDBUG_RETURN_; +} + +void +HandleClientMessage(XEvent * ev) +{ + EDBUG(5, "HandleClientMessage"); + + HintsProcessClientMessage(&(ev->xclient)); + + EDBUG_RETURN_; +} + +void +HandleChildShapeChange(XEvent * ev) +{ + Window win = ((XShapeEvent *) ev)->window; + EWin *ewin; + Border *b; + + EDBUG(5, "HandleChildShapeChange"); + + ewin = FindItem(NULL, win, LIST_FINDBY_ID, LIST_TYPE_EWIN); + if (ewin) + { + b = ewin->border; + SyncBorderToEwin(ewin); + if (ewin->border == b) + PropagateShapes(ewin->win); + } + + EDBUG_RETURN_; +} + +#ifdef USE_XRANDR +#include + +void +HandleScreenChange(XEvent * evx) +{ + XRRScreenChangeNotifyEvent *ev = (XRRScreenChangeNotifyEvent *) evx; + + EDBUG(5, "HandleScreenChange"); + + DialogOK("Wheee! (RRScreenChangeNotify)", + "Screen size changed to\n%dx%d pixels (%dx%d millimeters)", + ev->width, ev->height, ev->mwidth, ev->mheight); + + EDBUG_RETURN_; +} +#endif diff --git a/src/setup.c b/src/setup.c index 8efd8c4a..b8afe903 100644 --- a/src/setup.c +++ b/src/setup.c @@ -194,9 +194,6 @@ SetupX() /* set up a handler for when the X Connection goes down */ XSetIOErrorHandler((XIOErrorHandler) HandleXIOError); - /* initialise event handling */ - EventsInit(); - /* initialise imlib */ #if USE_IMLIB2 root.win = DefaultRootWindow(disp); @@ -259,6 +256,9 @@ SetupX() root.w = DisplayWidth(disp, root.scr); root.h = DisplayHeight(disp, root.scr); + /* Initialise event handling */ + EventsInit(); + /* just in case - set them up again */ /* set up an error handler for then E would normally have fatal X errors */ XSetErrorHandler((XErrorHandler) EHandleXError);