[Xfce4-commits] r23589 - xfwm4/trunk/src
Olivier Fourdan
olivier at xfce.org
Wed Nov 1 22:14:50 CET 2006
Author: olivier
Date: 2006-11-01 21:14:46 +0000 (Wed, 01 Nov 2006)
New Revision: 23589
Modified:
xfwm4/trunk/src/display.h
xfwm4/trunk/src/events.c
xfwm4/trunk/src/hints.c
xfwm4/trunk/src/misc.c
xfwm4/trunk/src/misc.h
xfwm4/trunk/src/netwm.c
xfwm4/trunk/src/netwm.h
Log:
Add support to NET_WM_MOVERESIZE
Modified: xfwm4/trunk/src/display.h
===================================================================
--- xfwm4/trunk/src/display.h 2006-11-01 21:13:52 UTC (rev 23588)
+++ xfwm4/trunk/src/display.h 2006-11-01 21:14:46 UTC (rev 23589)
@@ -93,6 +93,21 @@
enum
{
+ NET_WM_MOVERESIZE_SIZE_TOPLEFT = 0,
+ NET_WM_MOVERESIZE_SIZE_TOP,
+ NET_WM_MOVERESIZE_SIZE_TOPRIGHT,
+ NET_WM_MOVERESIZE_SIZE_RIGHT,
+ NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT,
+ NET_WM_MOVERESIZE_SIZE_BOTTOM,
+ NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT,
+ NET_WM_MOVERESIZE_SIZE_LEFT,
+ NET_WM_MOVERESIZE_MOVE,
+ NET_WM_MOVERESIZE_SIZE_KEYBOARD,
+ NET_WM_MOVERESIZE_MOVE_KEYBOARD
+};
+
+enum
+{
COMPOSITING_MANAGER = 0,
GNOME_PANEL_DESKTOP_AREA,
KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR,
Modified: xfwm4/trunk/src/events.c
===================================================================
--- xfwm4/trunk/src/events.c 2006-11-01 21:13:52 UTC (rev 23588)
+++ xfwm4/trunk/src/events.c 2006-11-01 21:14:46 UTC (rev 23589)
@@ -2039,8 +2039,7 @@
else if ((ev->message_type == display_info->atoms[NET_WM_MOVERESIZE]) && (ev->format == 32))
{
TRACE ("client \"%s\" (0x%lx) has received a net_wm_moveresize event", c->name, c->window);
- g_warning ("Operation not supported (yet)");
- /* TBD */
+ clientNetMoveResize (c, ev);
}
else if ((ev->message_type == display_info->atoms[NET_ACTIVE_WINDOW]) && (ev->format == 32))
{
Modified: xfwm4/trunk/src/hints.c
===================================================================
--- xfwm4/trunk/src/hints.c 2006-11-01 21:13:52 UTC (rev 23588)
+++ xfwm4/trunk/src/hints.c 2006-11-01 21:14:46 UTC (rev 23589)
@@ -426,6 +426,7 @@
atoms[i++] = display_info->atoms[NET_WM_ICON];
atoms[i++] = display_info->atoms[NET_WM_ICON_GEOMETRY];
atoms[i++] = display_info->atoms[NET_WM_ICON_NAME];
+ atoms[i++] = display_info->atoms[NET_WM_MOVERESIZE];
atoms[i++] = display_info->atoms[NET_WM_NAME];
atoms[i++] = display_info->atoms[NET_WM_STATE];
atoms[i++] = display_info->atoms[NET_WM_STATE_ABOVE];
Modified: xfwm4/trunk/src/misc.c
===================================================================
--- xfwm4/trunk/src/misc.c 2006-11-01 21:13:52 UTC (rev 23588)
+++ xfwm4/trunk/src/misc.c 2006-11-01 21:14:46 UTC (rev 23589)
@@ -42,34 +42,35 @@
#include "client.h"
#include "misc.h"
-void
+unsigned int
getMouseXY (ScreenInfo *screen_info, Window w, int *x2, int *y2)
{
Window w1, w2;
+ unsigned int mask;
int x1, y1;
- unsigned int m;
TRACE ("entering getMouseXY");
- XQueryPointer (myScreenGetXDisplay (screen_info), w, &w1, &w2, &x1, &y1, x2, y2, &m);
+ XQueryPointer (myScreenGetXDisplay (screen_info), w, &w1, &w2, &x1, &y1, x2, y2, &mask);
+ return mask;
}
Window
getMouseWindow (ScreenInfo *screen_info, Window w)
{
Window w1, w2;
+ unsigned int mask;
int x1, y1, x2, y2;
- unsigned int m;
TRACE ("entering getMouseWindow");
- XQueryPointer (myScreenGetXDisplay (screen_info), w, &w1, &w2, &x1, &y1, &x2, &y2, &m);
+ XQueryPointer (myScreenGetXDisplay (screen_info), w, &w1, &w2, &x1, &y1, &x2, &y2, &mask);
return w2;
}
GC
createGC (ScreenInfo *screen_info, char *col, int func, XFontStruct * font,
- int line_width, gboolean inc_sw)
+ int line_width, gboolean inc_sw)
{
XGCValues gv;
XColor xc1, xc2;
Modified: xfwm4/trunk/src/misc.h
===================================================================
--- xfwm4/trunk/src/misc.h 2006-11-01 21:13:52 UTC (rev 23588)
+++ xfwm4/trunk/src/misc.h 2006-11-01 21:14:46 UTC (rev 23589)
@@ -43,7 +43,7 @@
#define Button7 7
#endif
-void getMouseXY (ScreenInfo *, Window, int *, int *);
+unsigned int getMouseXY (ScreenInfo *, Window, int *, int *);
Window getMouseWindow (ScreenInfo *, Window);
GC createGC (ScreenInfo *, char *, int, XFontStruct *, int, gboolean);
void sendClientMessage (ScreenInfo *, Window, int, Time);
Modified: xfwm4/trunk/src/netwm.c
===================================================================
--- xfwm4/trunk/src/netwm.c 2006-11-01 21:13:52 UTC (rev 23588)
+++ xfwm4/trunk/src/netwm.c 2006-11-01 21:14:46 UTC (rev 23589)
@@ -291,9 +291,9 @@
screen_info = c->screen_info;
display_info = screen_info->display_info;
- action = ((XEvent *) ev)->xclient.data.l[0];
- first = ((XEvent *) ev)->xclient.data.l[1];
- second = ((XEvent *) ev)->xclient.data.l[2];
+ action = ev->data.l[0];
+ first = ev->data.l[1];
+ second = ev->data.l[2];
mode = 0;
if ((first == display_info->atoms[NET_WM_STATE_SHADED]) ||
@@ -545,6 +545,135 @@
}
void
+clientNetMoveResize (Client * c, XClientMessageEvent * ev)
+{
+ ScreenInfo *screen_info;
+ DisplayInfo *display_info;
+ unsigned int button_mask;
+ int x_root, y_root, dx, dy, action, button;
+ int corner;
+ gboolean resize; /* true == resize, false == move */
+ XEvent event;
+
+ g_return_if_fail (c != NULL);
+ TRACE ("entering clientNetMoveResize");
+ TRACE ("client \"%s\" (0x%lx)", c->name, c->window);
+
+ screen_info = c->screen_info;
+ display_info = screen_info->display_info;
+
+ x_root = (int) ev->data.l[0];
+ y_root = (int) ev->data.l[1];
+ action = (int) ev->data.l[2];
+ button = (int) ev->data.l[3];
+
+ if (button == 0)
+ {
+ button_mask = getMouseXY (screen_info, c->window, &dx, &dy);
+ if (button_mask & Button1Mask)
+ {
+ button = Button1;
+ }
+ else if (button_mask & Button2Mask)
+ {
+ button = Button2;
+ }
+ else if (button_mask & Button3Mask)
+ {
+ button = Button3;
+ }
+ else
+ {
+ g_warning ("Could not determine the mouse button used");
+ return;
+ }
+ }
+
+ corner = CORNER_BOTTOM_RIGHT;
+ resize = TRUE;
+
+ event.xbutton.button = button;
+ event.xbutton.x_root = event.xkey.x_root = x_root;
+ event.xbutton.y_root = event.xkey.y_root = y_root;
+ event.xbutton.time = event.xkey.time = myDisplayGetCurrentTime (display_info);
+
+ switch (action)
+ {
+ /* Keyboard */
+ case NET_WM_MOVERESIZE_SIZE_KEYBOARD:
+ event.type = KeyPress;
+ corner = CORNER_BOTTOM_RIGHT;
+ resize = TRUE; /* Resize */
+ break;
+ case NET_WM_MOVERESIZE_MOVE_KEYBOARD:
+ event.type = KeyPress;
+ resize = FALSE; /* Move */
+ break;
+
+ /* Sides */
+ case NET_WM_MOVERESIZE_SIZE_TOP:
+ event.type = ButtonPress;
+ corner = CORNER_COUNT + SIDE_TOP;
+ resize = TRUE; /* Resize */
+ break;
+ case NET_WM_MOVERESIZE_SIZE_BOTTOM:
+ event.type = ButtonPress;
+ corner = CORNER_COUNT + SIDE_BOTTOM;
+ resize = TRUE; /* Resize */
+ break;
+ case NET_WM_MOVERESIZE_SIZE_RIGHT:
+ event.type = ButtonPress;
+ corner = CORNER_COUNT + SIDE_RIGHT;
+ resize = TRUE; /* Resize */
+ break;
+ case NET_WM_MOVERESIZE_SIZE_LEFT:
+ event.type = ButtonPress;
+ corner = CORNER_COUNT + SIDE_LEFT;
+ resize = TRUE; /* Resize */
+ break;
+
+ /* Corners */
+ case NET_WM_MOVERESIZE_SIZE_TOPLEFT:
+ event.type = ButtonPress;
+ corner = CORNER_TOP_LEFT;
+ resize = TRUE; /* Resize */
+ break;
+ case NET_WM_MOVERESIZE_SIZE_TOPRIGHT:
+ event.type = ButtonPress;
+ corner = CORNER_TOP_RIGHT;
+ resize = TRUE; /* Resize */
+ break;
+ case NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT:
+ event.type = ButtonPress;
+ corner = CORNER_BOTTOM_LEFT;
+ resize = TRUE; /* Resize */
+ break;
+ case NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT:
+ event.type = ButtonPress;
+ corner = CORNER_BOTTOM_RIGHT;
+ resize = TRUE; /* Resize */
+ break;
+ case NET_WM_MOVERESIZE_MOVE:
+ default:
+ event.type = ButtonPress;
+ resize = FALSE; /* Move */
+ break;
+ }
+
+ if (!FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREEN))
+ {
+ if (resize && FLAG_TEST_ALL (c->xfwm_flags, XFWM_FLAG_HAS_RESIZE | XFWM_FLAG_IS_RESIZABLE))
+ {
+ clientResize (c, corner, &event);
+ }
+ else if (FLAG_TEST (c->xfwm_flags, XFWM_FLAG_HAS_MOVE))
+ {
+ clientMove (c, &event);
+ }
+ }
+}
+
+void
clientUpdateFullscreenState (Client * c)
{
ScreenInfo *screen_info;
Modified: xfwm4/trunk/src/netwm.h
===================================================================
--- xfwm4/trunk/src/netwm.h 2006-11-01 21:13:52 UTC (rev 23588)
+++ xfwm4/trunk/src/netwm.h 2006-11-01 21:14:46 UTC (rev 23589)
@@ -34,6 +34,7 @@
void clientSetNetState (Client *);
void clientGetNetState (Client *);
void clientUpdateNetState (Client *, XClientMessageEvent *);
+void clientNetMoveResize (Client *, XClientMessageEvent *);
void clientUpdateFullscreenState (Client *);
void clientGetNetWmType (Client *);
void clientGetInitialNetWmDesktop (Client *);
More information about the Xfce4-commits
mailing list