summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root@JOEL-GENTOO2.(none)>2008-02-29 11:39:13 +0900
committerroot <root@JOEL-GENTOO2.(none)>2008-02-29 11:39:13 +0900
commit1abdbc97379a63744544a6a2634ded043be75431 (patch)
tree9fe5cdeb9f992ee384b5e363314f87e1067b9050
parentbe2336143c860e912765e94a112fca1d30c0c422 (diff)
downloadmp-1abdbc97379a63744544a6a2634ded043be75431.tar.gz
mp-1abdbc97379a63744544a6a2634ded043be75431.tar.bz2
Add a patch for window decorator - this NEEDS to be used if you want to use resize2
-rw-r--r--0001-Hacks-on-gtk-window-decorator-to-give-deviceid-this.patch303
1 files changed, 303 insertions, 0 deletions
diff --git a/0001-Hacks-on-gtk-window-decorator-to-give-deviceid-this.patch b/0001-Hacks-on-gtk-window-decorator-to-give-deviceid-this.patch
new file mode 100644
index 0000000..213eb85
--- /dev/null
+++ b/0001-Hacks-on-gtk-window-decorator-to-give-deviceid-this.patch
@@ -0,0 +1,303 @@
+From bda80922c29d283d04a5969b0c0785855143f7f4 Mon Sep 17 00:00:00 2001
+From: root <root@JOEL-GENTOO2.(none)>
+Date: Fri, 29 Feb 2008 11:36:34 +0900
+Subject: [PATCH] Hacks on gtk-window-decorator to give deviceid (this breaks the spec)
+
+---
+ gtk/window-decorator/gtk-window-decorator.c | 197 ++++++++++++++++++++++-----
+ 1 files changed, 161 insertions(+), 36 deletions(-)
+
+diff --git a/gtk/window-decorator/gtk-window-decorator.c b/gtk/window-decorator/gtk-window-decorator.c
+index 41ce6ae..556b228 100644
+--- a/gtk/window-decorator/gtk-window-decorator.c
++++ b/gtk/window-decorator/gtk-window-decorator.c
+@@ -29,6 +29,8 @@
+ #include <X11/Xatom.h>
+ #include <X11/cursorfont.h>
+ #include <X11/extensions/Xrender.h>
++#include <X11/extensions/XI.h>
++#include <X11/extensions/XInput.h>
+ #include <X11/Xregion.h>
+
+ #ifndef GDK_DISABLE_DEPRECATED
+@@ -230,6 +232,7 @@ int double_click_action = DOUBLE_CLICK_ACTION_DEFAULT;
+ int middle_click_action = MIDDLE_CLICK_ACTION_DEFAULT;
+ int right_click_action = RIGHT_CLICK_ACTION_DEFAULT;
+ int wheel_action = WHEEL_ACTION_DEFAULT;
++static int DeviceButtonPressed;
+
+ static gboolean minimal = FALSE;
+
+@@ -237,6 +240,50 @@ static double decoration_alpha = 0.5;
+
+ #define SWITCHER_SPACE 40
+
++typedef struct _ResizePointer ResizePointer;
++struct _ResizePointer
++{
++ XDevice *device;
++ XID deviceid;
++
++ ResizePointer *next;
++};
++
++static ResizePointer *pointerHead = NULL;
++
++static ResizePointer
++*addDevice (void)
++{
++ int i=0;
++ ResizePointer *p;
++
++ if(pointerHead == NULL)
++ {
++ pointerHead = malloc (sizeof(ResizePointer));
++ if(pointerHead == NULL) return NULL;
++ p = pointerHead;
++ }
++ else
++ {
++ for(p=pointerHead; p->next; p=p->next) i++;
++ p->next = malloc (sizeof(ResizePointer));
++ if(p->next == NULL) return NULL;
++ p = p->next;
++ }
++ return p;
++}
++
++static ResizePointer
++*resizeFindDeviceFromDeviceid(XID deviceid)
++{
++ ResizePointer *dev;
++ for(dev=pointerHead; dev; dev=dev->next)
++ {
++ if(dev->deviceid == deviceid) break;
++ }
++ return dev;
++}
++
+ static decor_extents_t _shadow_extents = { 0, 0, 0, 0 };
+ static decor_extents_t _win_extents = { 6, 6, 4, 6 };
+ static decor_extents_t _max_win_extents = { 6, 6, 4, 6 };
+@@ -3489,11 +3536,66 @@ add_frame_window (WnckWindow *win,
+
+ xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+
+- attr.event_mask = ButtonPressMask | EnterWindowMask | LeaveWindowMask;
++ attr.event_mask = EnterWindowMask | LeaveWindowMask;
+ attr.override_redirect = TRUE;
+
+ gdk_error_trap_push ();
+
++
++ /* *** MPX *** *
++ int num;
++ int num_pointers;
++
++ XDeviceInfo* devs = XListInputDevices(xdisplay, &num);
++ XDevice **pointers = (XDevice**)calloc(sizeof(XDevice*), num);
++ XEventClass *evclasses = (XEventClass*)calloc(sizeof(XEventClass), num);
++ num_pointers = 0;
++
++ while(num-- > 0)
++ {
++ if (devs[num].use == IsXPointer) //only care about master pointers
++ {
++ XDevice* dev = XOpenDevice(xdisplay, devs[num].id);
++ DeviceButtonPress(dev, DeviceButtonPressed, evclasses[num_pointers]);
++ pointers[num_pointers++] = dev;
++ }
++ }
++
++ pointers = realloc(pointers, sizeof(XDevice**) * num_pointers);
++ evclasses = realloc(evclasses, sizeof(XEventClass) * num_pointers);
++
++
++ /*************/
++ pointerHead = NULL;
++
++ XDeviceInfo* devs;
++ int num;
++ int tempNum = 0;
++
++ devs = XListInputDevices(xdisplay, &num);
++ ResizePointer *dev;
++
++ XEventClass *evclasses = (XEventClass*)calloc(sizeof(XEventClass), num);
++
++ while(num-- > 0)
++ {
++ if (devs[num].use == IsXPointer)
++ {
++ dev = addDevice();
++ if(dev == NULL) fprintf (stderr, "FAILED\n");
++ dev->device = XOpenDevice(xdisplay, devs[num].id);
++ dev->deviceid = devs[num].id;
++ dev->next = NULL;
++ DeviceButtonPress(dev->device, DeviceButtonPressed, evclasses[++tempNum]);
++ fprintf(stderr, "Add a device: %d \n", devs[num].id);
++ }
++ }
++ fprintf(stderr, "%d", tempNum);
++ evclasses = realloc(evclasses, sizeof(XEventClass) * tempNum);
++
++ XFreeDeviceList(devs);
++ /* ***** */
++
+ for (i = 0; i < 3; i++)
+ {
+ for (j = 0; j < 3; j++)
+@@ -3504,6 +3606,8 @@ add_frame_window (WnckWindow *win,
+ 0, 0, 1, 1, 0,
+ CopyFromParent, CopyFromParent, CopyFromParent,
+ CWOverrideRedirect | CWEventMask, &attr);
++
++ XSelectExtensionEvent(xdisplay, d->event_windows[i][j], evclasses, tempNum); /* MPX */
+
+ if (cursor[i][j].cursor)
+ XDefineCursor (xdisplay, d->event_windows[i][j],
+@@ -3512,6 +3616,7 @@ add_frame_window (WnckWindow *win,
+ }
+
+ attr.event_mask |= ButtonReleaseMask;
++ attr.event_mask |= ButtonPressMask;
+
+ for (i = 0; i < BUTTON_NUM; i++)
+ {
+@@ -4021,49 +4126,59 @@ move_resize_window (WnckWindow *win,
+ int direction,
+ XEvent *xevent)
+ {
+- Display *xdisplay;
+- GdkDisplay *gdkdisplay;
+- GdkScreen *screen;
+- Window xroot;
+- XEvent ev;
++ if(xevent->type == DeviceButtonPressed) //XXX should use the return type from ButtonPressMacro
++ {
++ Display *xdisplay;
++ GdkDisplay *gdkdisplay;
++ GdkScreen *screen;
++ Window xroot;
++ XEvent ev;
+
+- gdkdisplay = gdk_display_get_default ();
+- xdisplay = GDK_DISPLAY_XDISPLAY (gdkdisplay);
+- screen = gdk_display_get_default_screen (gdkdisplay);
+- xroot = RootWindowOfScreen (gdk_x11_screen_get_xscreen (screen));
++ gdkdisplay = gdk_display_get_default ();
++ xdisplay = GDK_DISPLAY_XDISPLAY (gdkdisplay);
++ screen = gdk_display_get_default_screen (gdkdisplay);
++ xroot = RootWindowOfScreen (gdk_x11_screen_get_xscreen (screen));
+
+- if (action_menu_mapped)
+- {
+- gtk_object_destroy (GTK_OBJECT (action_menu));
+- action_menu_mapped = FALSE;
+- action_menu = NULL;
+- return;
+- }
++ if (action_menu_mapped)
++ {
++ gtk_object_destroy (GTK_OBJECT (action_menu));
++ action_menu_mapped = FALSE;
++ action_menu = NULL;
++ return;
++ }
+
+- ev.xclient.type = ClientMessage;
+- ev.xclient.display = xdisplay;
++ ev.xclient.type = ClientMessage;
++ ev.xclient.display = xdisplay;
+
+- ev.xclient.serial = 0;
+- ev.xclient.send_event = TRUE;
++ ev.xclient.serial = 0;
++ ev.xclient.send_event = TRUE;
+
+- ev.xclient.window = wnck_window_get_xid (win);
+- ev.xclient.message_type = wm_move_resize_atom;
+- ev.xclient.format = 32;
++ ev.xclient.window = wnck_window_get_xid (win);
++ ev.xclient.message_type = wm_move_resize_atom;
++ ev.xclient.format = 32;
+
+- ev.xclient.data.l[0] = xevent->xbutton.x_root;
+- ev.xclient.data.l[1] = xevent->xbutton.y_root;
+- ev.xclient.data.l[2] = direction;
+- ev.xclient.data.l[3] = xevent->xbutton.button;
+- ev.xclient.data.l[4] = 1;
++ XDeviceButtonEvent *bev = xevent;
++ ev.xclient.data.l[0] = bev->x_root;
++ ev.xclient.data.l[1] = bev->y_root;
++ ev.xclient.data.l[2] = direction;
++ ev.xclient.data.l[3] = bev->button;
++ ev.xclient.data.l[4] = bev->deviceid; //breaks spec, I don't care
++
++ fprintf (stderr, "yup: %d \n", bev->deviceid);
++
++// XUngrabPointer (xdisplay, xevent->xbutton.time); //XXX
++ XUngrabKeyboard (xdisplay, xevent->xbutton.time); //XXX
+
+- XUngrabPointer (xdisplay, xevent->xbutton.time);
+- XUngrabKeyboard (xdisplay, xevent->xbutton.time);
++ ResizePointer *dev = resizeFindDeviceFromDeviceid( bev->deviceid);
++
++ XUngrabDevice (xdisplay, dev->device , CurrentTime);
+
+ XSendEvent (xdisplay, xroot, FALSE,
+ SubstructureRedirectMask | SubstructureNotifyMask,
+ &ev);
+
+ XSync (xdisplay, FALSE);
++ }
+ }
+
+ static void
+@@ -4794,14 +4909,17 @@ frame_common_event (WnckWindow *win,
+ int direction,
+ XEvent *xevent)
+ {
+- if (xevent->type != ButtonPress)
++ if(xevent->type == DeviceButtonPressed) //XXX
++ {
++ move_resize_window(win,direction,xevent);
++ restack_window (win, Above);
++ }
++
++ if (xevent->type != DeviceButtonPressed )
+ return;
+
+ switch (xevent->xbutton.button) {
+- case 1:
+- move_resize_window (win, direction, xevent);
+- restack_window (win, Above);
+- break;
++ case 1: break;
+ case 2:
+ handle_title_button_event (win, middle_click_action,
+ &xevent->xbutton);
+@@ -5222,6 +5340,11 @@ event_filter_func (GdkXEvent *gdkxevent,
+ break;
+ }
+
++ if(xevent->type == DeviceButtonPressed)
++ {xid = (gulong)
++ g_hash_table_lookup (frame_table,
++ GINT_TO_POINTER (xevent->xbutton.window));}
++
+ if (xid)
+ {
+ WnckWindow *win;
+@@ -6832,6 +6955,8 @@ main (int argc, char *argv[])
+ gdkdisplay = gdk_display_get_default ();
+ xdisplay = gdk_x11_display_get_xdisplay (gdkdisplay);
+ gdkscreen = gdk_display_get_default_screen (gdkdisplay);
++
++
+
+ frame_window_atom = XInternAtom (xdisplay, "_NET_FRAME_WINDOW", FALSE);
+ win_decor_atom = XInternAtom (xdisplay, DECOR_WINDOW_ATOM_NAME, FALSE);
+--
+1.5.4.2
+