From: Hugo Villeneuve Date: Sat, 25 May 2013 15:52:26 +0000 (-0400) Subject: Tests pour rediriger les clics de souris vers WindowMaker (non concluant) X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=refs%2Fheads%2Fmouse-tests;p=dockapps%2Fwmnotify.git Tests pour rediriger les clics de souris vers WindowMaker (non concluant) --- diff --git a/src/dockapp.c b/src/dockapp.c index 6156c33..3978390 100644 --- a/src/dockapp.c +++ b/src/dockapp.c @@ -300,8 +300,8 @@ InitDockAppWindow(int argc, char *argv[], char *pixmap_data[]) /* ... */ (void) XSelectInput(dockapp.display, dockapp.win, - ButtonPressMask | ExposureMask | - ButtonReleaseMask | PointerMotionMask | + /*ButtonPressMask | */ ExposureMask | + /*ButtonReleaseMask | */ PointerMotionMask | StructureNotifyMask); (void) XSelectInput(dockapp.display, dockapp.iconwin, diff --git a/src/xevents.c b/src/xevents.c index 3eec774..5bb213f 100644 --- a/src/xevents.c +++ b/src/xevents.c @@ -102,6 +102,33 @@ static void detect_double_click(bool *double_click) } } +/* Create a button event */ +XButtonEvent create_button_event(Display *display, Window win, + Window win_root, int pressed, int x, int y, int modifiers) +{ + XButtonEvent event; + + event.display = display; + event.window = win; + event.root = win_root; + event.subwindow = None; + event.time = CurrentTime; + event.x = 1; + event.y = 1; + event.x_root = x; + event.y_root = y; + event.same_screen = True; + event.state = modifiers; + event.button = Button3; + + if (pressed) + event.type = ButtonPress; + else + event.type = ButtonRelease; + + return event; +} + /* Processing of X events */ void ProcessXlibEvents(void) { @@ -117,6 +144,9 @@ void ProcessXlibEvents(void) * If no other button 1 events are received after the * delay, then it is a single-click mouse event. */ + + printf("SingleClickCallback TEST()\n"); + if (SingleClickCallback != NULL) (*SingleClickCallback)(); @@ -128,6 +158,47 @@ void ProcessXlibEvents(void) * other tasks when no events are available. */ (void) XNextEvent(dockapp.display, &Event); + + if (((Event.type == ButtonPress) || (Event.type == ButtonRelease)) && + (Event.xbutton.button == Button3)) { + Status status; + XButtonEvent event; + XButtonEvent *ev; + Window parent; + Window root; + Window *children; + unsigned int nchildren; + + ev = (XButtonEvent *)&Event; + + XQueryTree(dockapp.display, dockapp.win, &root, &parent, + &children, &nchildren); + + printf("Resend event to parent window\n"); + printf(" Children = %d\n", nchildren); + printf(" X root = %d\n", ev->x_root); + printf(" X = %d\n", ev->x); + + event = create_button_event(dockapp.display, + dockapp.win, + dockapp.root_win, + true, + ev->x_root, ev->y_root, + ButtonPressMask); + + status = XSendEvent(event.display, + event.window, + true, ButtonPressMask, + (XEvent *)&event); + if (status == 0) { + char buf[256]; + + XGetErrorText(dockapp.display, status, buf, + sizeof(buf)); + printf("Error: %s\n", buf); + } + } + switch (Event.type) { case Expose: /* Window was uncovered... */ @@ -148,6 +219,9 @@ void ProcessXlibEvents(void) /* Mouse LEFT button pressed. */ button1_pressed = true; } + else if (Event.xbutton.button == Button2) { + printf("BOZO BOZO BUTTON2 BOZO BOZO\n"); + } break; case ButtonRelease: if (Event.xbutton.button == Button1) {