xfwm: support for 2d pagers

Brian J. Tarricone bjt23 at cornell.edu
Tue Sep 21 06:39:09 CEST 2004


Paramjit Oberoi wrote:

>Updated patch attached.  This time I have the REAL cvs head, hopefully.
>
>The following must be added to share/xfwm4/defaults:
>
>wrap_layout=false
>up_workspace_key=Control+Up
>down_workspace_key=Control+Down
>left_workspace_key=Control+Left
>right_workspace_key=Control+Right
>move_window_up_workspace_key=Alt+Control+Up
>move_window_down_workspace_key=Alt+Control+Down
>move_window_left_workspace_key=Alt+Control+Left
>move_window_right_workspace_key=Alt+Control+Right
>
>(modify keybindings as appropriate - note that Alt+Ctrl+Left/Right
>conflict with the default next/prev workspace hotkey (I recommend
>changing that to Atl+Ctrl+PgDn/PgUp))
>  
>
i'm curious as to why you made that choice.  why not leave the alt+ctrl 
combos the same, and add up and down for navigation?  i think the 
navigation shortcuts are used much more frequently than the move window 
shortcuts.  seems like it would make sense to learn new move window 
shortcuts than navigation.

    -brian


>I removed the hand-modification to xfwm4.xml.  None of the settings are
>exposed to the settings manager yet---I can add that if the patch is
>accepted and people agree that breaking the string freeze is worth it.
>
>-param
>
>Olivier Fourdan wrote (Mon, Sep 20, 2004 at 11:17:15PM +0200) :
>  
>
>>From: Olivier Fourdan <fourdan at xfce.org>
>>To: xfce4 devel list <xfce4-dev at xfce.org>
>>X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) 
>>Date: Mon, 20 Sep 2004 23:17:15 +0200
>>Subject: Re: xfwm: support for 2d pagers
>>Sender: xfce4-dev-bounces at xfce.org
>>
>>Hi
>>
>>No new feature is being added to the 4.0 release and your patch doesn't
>>apply on CVS HEAD.
>>
>>Cheers,
>>Olivier.
>>
>>On Mon, 2004-09-20 at 08:50, Paramjit Oberoi wrote:
>>    
>>
>>>xfwm4 currently does not support 2d pagers very well: i.e., say that
>>>your desktop pager/switcher displays 8 virtual desktops in 2 rows, 4
>>>columns.  It is natural in this situation to want to move the virtual
>>>desktop up/down/left/right.  However, xfwm only supports moving to the
>>>next/previous desktop.  (the xfce pager doesn't support multiple rows;
>>>I am using xfwm with GNOME, as a replacement for metacity)
>>>
>>>According to the NetWM specification, pagers can communicate the layout
>>>of the virtual desktops using the _NET_DESKTOP_LAYOUT property.  This
>>>property is described in detail here:
>>>http://freedesktop.org/Standards/wm-spec/1.3/ar01s03.html#id2503159
>>>
>>>Attached to this email is a patch that adds support for this to xfwm.
>>>The patch is against the current CVS head (I think).  Here's a summary
>>>of the changes:
>>>      
>>>
>>>------------------------------------------------------------------------
>>>
>>>Index: client.c
>>>===================================================================
>>>RCS file: /cvsroot/xfce/xfce4/xfwm4/src/client.c,v
>>>retrieving revision 1.418
>>>diff -u -r1.418 client.c
>>>--- client.c	19 Sep 2004 19:58:06 -0000	1.418
>>>+++ client.c	21 Sep 2004 03:56:56 -0000
>>>@@ -326,6 +326,14 @@
>>>     grabKey (clientGetXDisplay (c), &screen_info->params->keys[KEY_WORKSPACE_7], c->window);
>>>     grabKey (clientGetXDisplay (c), &screen_info->params->keys[KEY_WORKSPACE_8], c->window);
>>>     grabKey (clientGetXDisplay (c), &screen_info->params->keys[KEY_WORKSPACE_9], c->window);
>>>+    grabKey (clientGetXDisplay (c), &screen_info->params->keys[KEY_UP_WORKSPACE], c->window);
>>>+    grabKey (clientGetXDisplay (c), &screen_info->params->keys[KEY_DOWN_WORKSPACE], c->window);
>>>+    grabKey (clientGetXDisplay (c), &screen_info->params->keys[KEY_LEFT_WORKSPACE], c->window);
>>>+    grabKey (clientGetXDisplay (c), &screen_info->params->keys[KEY_RIGHT_WORKSPACE], c->window);
>>>+    grabKey (clientGetXDisplay (c), &screen_info->params->keys[KEY_MOVE_UP_WORKSPACE], c->window);
>>>+    grabKey (clientGetXDisplay (c), &screen_info->params->keys[KEY_MOVE_DOWN_WORKSPACE], c->window);
>>>+    grabKey (clientGetXDisplay (c), &screen_info->params->keys[KEY_MOVE_LEFT_WORKSPACE], c->window);
>>>+    grabKey (clientGetXDisplay (c), &screen_info->params->keys[KEY_MOVE_RIGHT_WORKSPACE], c->window);
>>> }
>>> 
>>> void
>>>Index: events.c
>>>===================================================================
>>>RCS file: /cvsroot/xfce/xfce4/xfwm4/src/events.c,v
>>>retrieving revision 1.244
>>>diff -u -r1.244 events.c
>>>--- events.c	5 Sep 2004 20:57:46 -0000	1.244
>>>+++ events.c	21 Sep 2004 03:56:57 -0000
>>>@@ -396,6 +396,18 @@
>>>             case KEY_MOVE_PREV_WORKSPACE:
>>>                 workspaceSwitch (screen_info, screen_info->current_ws - 1, c);
>>>                 break;
>>>+            case KEY_MOVE_UP_WORKSPACE:
>>>+                workspaceMove (screen_info, -1, 0, c);
>>>+                break;
>>>+            case KEY_MOVE_DOWN_WORKSPACE:
>>>+                workspaceMove (screen_info, 1, 0, c);
>>>+                break;
>>>+            case KEY_MOVE_LEFT_WORKSPACE:
>>>+                workspaceMove (screen_info, 0, -1, c);
>>>+                break;
>>>+            case KEY_MOVE_RIGHT_WORKSPACE:
>>>+                workspaceMove (screen_info, 0, 1, c);
>>>+                break;
>>>             case KEY_MOVE_WORKSPACE_1:
>>>             case KEY_MOVE_WORKSPACE_2:
>>>             case KEY_MOVE_WORKSPACE_3:
>>>@@ -445,6 +457,18 @@
>>>         case KEY_PREV_WORKSPACE:
>>>             workspaceSwitch (screen_info, screen_info->current_ws - 1, NULL);
>>>             break;
>>>+        case KEY_UP_WORKSPACE:
>>>+            workspaceMove(screen_info, -1, 0, NULL);
>>>+            break;
>>>+        case KEY_DOWN_WORKSPACE:
>>>+            workspaceMove(screen_info, 1, 0, NULL);
>>>+            break;
>>>+        case KEY_LEFT_WORKSPACE:
>>>+            workspaceMove(screen_info, 0, -1, NULL);
>>>+            break;
>>>+        case KEY_RIGHT_WORKSPACE:
>>>+            workspaceMove(screen_info, 0, 1, NULL);
>>>+            break;
>>>         case KEY_ADD_WORKSPACE:
>>>             workspaceSetCount (screen_info, screen_info->workspace_count + 1);
>>>             break;
>>>@@ -1529,6 +1553,11 @@
>>>         getGnomeDesktopMargins (display_info->dpy, screen_info->screen, screen_info->gnome_margins);
>>>         workspaceUpdateArea (screen_info);
>>>     }
>>>+    else if (ev->atom == net_desktop_layout)
>>>+    {
>>>+        TRACE ("root has received a net_desktop_layout notify");
>>>+        getDesktopLayout(display_info->dpy, screen_info->xroot, screen_info->workspace_count, &screen_info->desktop_layout);
>>>+    }
>>> }
>>> 
>>> static void
>>>Index: hints.c
>>>===================================================================
>>>RCS file: /cvsroot/xfce/xfce4/xfwm4/src/hints.c,v
>>>retrieving revision 1.85
>>>diff -u -r1.85 hints.c
>>>--- hints.c	28 Aug 2004 23:10:17 -0000	1.85
>>>+++ hints.c	21 Sep 2004 03:56:58 -0000
>>>@@ -70,6 +70,7 @@
>>> Atom net_desktop_geometry;
>>> Atom net_desktop_viewport;
>>> Atom net_desktop_names;
>>>+Atom net_desktop_layout;
>>> Atom net_number_of_desktops;
>>> Atom net_showing_desktop;
>>> Atom net_startup_id;
>>>@@ -396,6 +397,60 @@
>>> }
>>> 
>>> void
>>>+getDesktopLayout (Display * dpy, Window root, int ws_count, NetWmDesktopLayout * layout)
>>>+{
>>>+    Atom real_type;
>>>+    int real_format;
>>>+    gboolean success = FALSE;
>>>+    unsigned long items_read, items_left;
>>>+    unsigned long orientation, cols, rows, start;
>>>+    unsigned long *data = NULL;
>>>+
>>>+    TRACE ("entering getDesktopLayout");
>>>+
>>>+    if ((XGetWindowProperty (dpy, root, net_desktop_layout,
>>>+                0L, 4L, FALSE, XA_CARDINAL,
>>>+                &real_type, &real_format, &items_read, &items_left,
>>>+                (unsigned char **) &data) == Success) && (items_read >= 3))
>>>+    {
>>>+        do
>>>+        {
>>>+            orientation = data[0];
>>>+            cols = data[1];
>>>+            rows = data[2];
>>>+            start = (items_read >= 4) ? data[3] : NET_WM_TOPLEFT;
>>>+
>>>+            if (orientation > NET_WM_ORIENTATION_VERT) break;
>>>+            if (start > NET_WM_BOTTOMLEFT) break;
>>>+            if ((rows == 0) && (cols == 0)) break;
>>>+
>>>+            if (rows == 0)
>>>+                rows = (ws_count-1) / cols + 1;
>>>+
>>>+            if (cols == 0)
>>>+                cols = (ws_count-1) / rows + 1;
>>>+
>>>+            layout->orientation = orientation;
>>>+            layout->cols = cols;
>>>+            layout->rows = rows;
>>>+            layout->start = start;
>>>+            success = TRUE;
>>>+        } while (0);
>>>+
>>>+        XFree (data);
>>>+    }
>>>+
>>>+    if (!success)
>>>+    {
>>>+        /* Assume HORZ, TOPLEFT, one row by default */
>>>+        layout->orientation = NET_WM_ORIENTATION_HORZ;
>>>+        layout->cols = ws_count;
>>>+        layout->rows = 1;
>>>+        layout->start = NET_WM_TOPLEFT;
>>>+    }
>>>+}
>>>+
>>>+void
>>> getGnomeDesktopMargins (Display * dpy, int screen, int * m)
>>> {
>>>     Atom real_type;
>>>@@ -458,6 +513,8 @@
>>>         XInternAtom (dpy, "_NET_DESKTOP_VIEWPORT", FALSE);
>>>     net_desktop_names = 
>>>         XInternAtom (dpy, "_NET_DESKTOP_NAMES", FALSE);
>>>+    net_desktop_layout =
>>>+        XInternAtom (dpy, "_NET_DESKTOP_LAYOUT", FALSE);
>>>     net_number_of_desktops =
>>>         XInternAtom (dpy, "_NET_NUMBER_OF_DESKTOPS", FALSE);
>>>     net_showing_desktop = 
>>>@@ -569,6 +626,7 @@
>>>     atoms[i++] = net_desktop_geometry;
>>>     atoms[i++] = net_desktop_viewport;
>>>     atoms[i++] = net_desktop_names;
>>>+    atoms[i++] = net_desktop_layout;
>>>     atoms[i++] = net_number_of_desktops;
>>>     atoms[i++] = net_showing_desktop;
>>>     atoms[i++] = net_supported;
>>>Index: hints.h
>>>===================================================================
>>>RCS file: /cvsroot/xfce/xfce4/xfwm4/src/hints.h,v
>>>retrieving revision 1.49
>>>diff -u -r1.49 hints.h
>>>--- hints.h	28 Aug 2004 23:10:17 -0000	1.49
>>>+++ hints.h	21 Sep 2004 03:56:59 -0000
>>>@@ -98,6 +98,23 @@
>>> #define NET_WM_STATE_ADD                        1
>>> #define NET_WM_STATE_TOGGLE                     2
>>> 
>>>+#define NET_WM_ORIENTATION_HORZ                 0
>>>+#define NET_WM_ORIENTATION_VERT                 1
>>>+
>>>+#define NET_WM_TOPLEFT                          0
>>>+#define NET_WM_TOPRIGHT                         1
>>>+#define NET_WM_BOTTOMRIGHT                      2
>>>+#define NET_WM_BOTTOMLEFT                       3
>>>+
>>>+typedef struct
>>>+{
>>>+    unsigned long orientation;
>>>+    unsigned long start;
>>>+    unsigned long rows;
>>>+    unsigned long cols;
>>>+}
>>>+NetWmDesktopLayout;
>>>+
>>> #define LEFT                            0
>>> #define RIGHT                           1
>>> #define TOP                             2
>>>@@ -151,6 +168,7 @@
>>> extern Atom net_desktop_geometry;
>>> extern Atom net_desktop_viewport;
>>> extern Atom net_desktop_names;
>>>+extern Atom net_desktop_layout;
>>> extern Atom net_number_of_desktops;
>>> extern Atom net_showing_desktop;
>>> extern Atom net_startup_id;
>>>@@ -219,6 +237,7 @@
>>> Atom initSystrayHints (Display *, int);
>>> gboolean getHint (Display *, Window, Atom, long *);
>>> void setHint (Display *, Window, Atom, long);
>>>+void getDesktopLayout (Display *, Window, int, NetWmDesktopLayout *);
>>> void getGnomeDesktopMargins (Display *, int, int *);
>>> void setGnomeProtocols (Display *, int, Window);
>>> void initNetHints (Display * dpy);
>>>Index: screen.h
>>>===================================================================
>>>RCS file: /cvsroot/xfce/xfce4/xfwm4/src/screen.h,v
>>>retrieving revision 1.7
>>>diff -u -r1.7 screen.h
>>>--- screen.h	19 Sep 2004 20:16:01 -0000	1.7
>>>+++ screen.h	21 Sep 2004 03:56:59 -0000
>>>@@ -95,6 +95,7 @@
>>>     int workspace_count;
>>>     gchar *workspace_names;
>>>     int workspace_names_length;
>>>+    NetWmDesktopLayout desktop_layout;
>>> 
>>>     /* Button handler for GTK */
>>>     gulong button_handler_id;
>>>Index: settings.c
>>>===================================================================
>>>RCS file: /cvsroot/xfce/xfce4/xfwm4/src/settings.c,v
>>>retrieving revision 1.105
>>>diff -u -r1.105 settings.c
>>>--- settings.c	14 Sep 2004 20:32:30 -0000	1.105
>>>+++ settings.c	21 Sep 2004 03:57:00 -0000
>>>@@ -909,13 +909,21 @@
>>>     parseKeyString (dpy, &screen_info->params->keys[KEY_RAISE_WINDOW], getValue ("raise_window_key", rc));
>>>     parseKeyString (dpy, &screen_info->params->keys[KEY_LOWER_WINDOW], getValue ("lower_window_key", rc));
>>>     parseKeyString (dpy, &screen_info->params->keys[KEY_TOGGLE_FULLSCREEN], getValue ("fullscreen_key", rc));
>>>+    parseKeyString (dpy, &screen_info->params->keys[KEY_UP_WORKSPACE], getValue ("up_workspace_key", rc));
>>>+    parseKeyString (dpy, &screen_info->params->keys[KEY_DOWN_WORKSPACE], getValue ("down_workspace_key", rc));
>>>+    parseKeyString (dpy, &screen_info->params->keys[KEY_LEFT_WORKSPACE], getValue ("left_workspace_key", rc));
>>>+    parseKeyString (dpy, &screen_info->params->keys[KEY_RIGHT_WORKSPACE], getValue ("right_workspace_key", rc));
>>>+    parseKeyString (dpy, &screen_info->params->keys[KEY_MOVE_UP_WORKSPACE], getValue ("move_window_up_workspace_key", rc));
>>>+    parseKeyString (dpy, &screen_info->params->keys[KEY_MOVE_DOWN_WORKSPACE], getValue ("move_window_down_workspace_key", rc));
>>>+    parseKeyString (dpy, &screen_info->params->keys[KEY_MOVE_LEFT_WORKSPACE], getValue ("move_window_left_workspace_key", rc));
>>>+    parseKeyString (dpy, &screen_info->params->keys[KEY_MOVE_RIGHT_WORKSPACE], getValue ("move_window_right_workspace_key", rc));
>>> 
>>>     ungrabKeys (dpy, screen_info->gnome_win);
>>>     grabKey (dpy, &screen_info->params->keys[KEY_CYCLE_WINDOWS], screen_info->gnome_win);
>>>     grabKey (dpy, &screen_info->params->keys[KEY_NEXT_WORKSPACE], screen_info->gnome_win);
>>>     grabKey (dpy, &screen_info->params->keys[KEY_PREV_WORKSPACE], screen_info->gnome_win);
>>>     grabKey (dpy, &screen_info->params->keys[KEY_ADD_WORKSPACE], screen_info->gnome_win);
>>>-    grabKey (dpy, &screen_info->params->keys[KEY_NEXT_WORKSPACE], screen_info->gnome_win);
>>>+    grabKey (dpy, &screen_info->params->keys[KEY_DEL_WORKSPACE], screen_info->gnome_win);
>>>     grabKey (dpy, &screen_info->params->keys[KEY_WORKSPACE_1], screen_info->gnome_win);
>>>     grabKey (dpy, &screen_info->params->keys[KEY_WORKSPACE_2], screen_info->gnome_win);
>>>     grabKey (dpy, &screen_info->params->keys[KEY_WORKSPACE_3], screen_info->gnome_win);
>>>@@ -935,6 +943,11 @@
>>>     grabKey (dpy, &screen_info->params->keys[KEY_SHORTCUT_8], screen_info->gnome_win);
>>>     grabKey (dpy, &screen_info->params->keys[KEY_SHORTCUT_9], screen_info->gnome_win);
>>>     grabKey (dpy, &screen_info->params->keys[KEY_SHORTCUT_10], screen_info->gnome_win);
>>>+    grabKey (dpy, &screen_info->params->keys[KEY_UP_WORKSPACE], screen_info->gnome_win);
>>>+    grabKey (dpy, &screen_info->params->keys[KEY_DOWN_WORKSPACE], screen_info->gnome_win);
>>>+    grabKey (dpy, &screen_info->params->keys[KEY_LEFT_WORKSPACE], screen_info->gnome_win);
>>>+    grabKey (dpy, &screen_info->params->keys[KEY_RIGHT_WORKSPACE], screen_info->gnome_win);
>>>+
>>> 
>>>     return TRUE;
>>> }
>>>@@ -1001,6 +1014,7 @@
>>>         {"workspace_count", NULL, TRUE},
>>>         {"wrap_windows", NULL, TRUE},
>>>         {"wrap_workspaces", NULL, TRUE},
>>>+        {"wrap_layout", NULL, TRUE},
>>>         {"wrap_resistance", NULL, TRUE},
>>>         /* Keys */
>>>         {"add_workspace_key", NULL, TRUE},
>>>@@ -1066,6 +1080,14 @@
>>>         {"shortcut_10_exec", NULL, FALSE},
>>>         {"raise_window_key", NULL, TRUE},
>>>         {"lower_window_key", NULL, TRUE},
>>>+        {"up_workspace_key", NULL, TRUE},
>>>+        {"down_workspace_key", NULL, TRUE},
>>>+        {"left_workspace_key", NULL, TRUE},
>>>+        {"right_workspace_key", NULL, TRUE},
>>>+        {"move_window_up_workspace_key", NULL, TRUE},
>>>+        {"move_window_down_workspace_key", NULL, TRUE},
>>>+        {"move_window_left_workspace_key", NULL, TRUE},
>>>+        {"move_window_right_workspace_key", NULL, TRUE},
>>>         {NULL, NULL, FALSE}
>>>     };
>>> 
>>>@@ -1145,6 +1167,8 @@
>>> 
>>>     screen_info->params->wrap_workspaces =
>>>         !g_ascii_strcasecmp ("true", getValue ("wrap_workspaces", rc));
>>>+    screen_info->params->wrap_layout =
>>>+        !g_ascii_strcasecmp ("true", getValue ("wrap_layout", rc));
>>>     screen_info->params->wrap_windows =
>>>         !g_ascii_strcasecmp ("true", getValue ("wrap_windows", rc));
>>>     screen_info->params->wrap_resistance = abs (TOINT (getValue ("wrap_resistance", rc)));
>>>@@ -1305,6 +1329,8 @@
>>>         screen_info->workspace_names_length = 0;
>>>     }
>>> 
>>>+    getDesktopLayout(myScreenGetXDisplay (screen_info), screen_info->xroot, screen_info->workspace_count, &screen_info->desktop_layout);
>>>+
>>>     if (!loadSettings (screen_info))
>>>     {
>>>         return FALSE;
>>>Index: settings.h
>>>===================================================================
>>>RCS file: /cvsroot/xfce/xfce4/xfwm4/src/settings.h,v
>>>retrieving revision 1.40
>>>diff -u -r1.40 settings.h
>>>--- settings.h	8 Sep 2004 15:59:31 -0000	1.40
>>>+++ settings.h	21 Sep 2004 03:57:00 -0000
>>>@@ -28,6 +28,7 @@
>>> #include "screen.h"
>>> #include "keyboard.h"
>>> #include "mypixmap.h"
>>>+#include "hints.h"
>>> 
>>> #ifndef INC_SETTINGS_H
>>> #define INC_SETTINGS_H
>>>@@ -107,7 +108,15 @@
>>> #define KEY_LOWER_WINDOW                50
>>> #define KEY_RAISE_WINDOW                51
>>> #define KEY_TOGGLE_FULLSCREEN           52
>>>-#define KEY_COUNT                       53
>>>+#define KEY_UP_WORKSPACE                53
>>>+#define KEY_DOWN_WORKSPACE              54
>>>+#define KEY_LEFT_WORKSPACE              55
>>>+#define KEY_RIGHT_WORKSPACE             56
>>>+#define KEY_MOVE_UP_WORKSPACE           57
>>>+#define KEY_MOVE_DOWN_WORKSPACE         58
>>>+#define KEY_MOVE_LEFT_WORKSPACE         59
>>>+#define KEY_MOVE_RIGHT_WORKSPACE        60
>>>+#define KEY_COUNT                       61
>>> #define NB_KEY_SHORTCUTS                10
>>> 
>>> #define ALIGN_LEFT                      0
>>>@@ -164,6 +173,7 @@
>>>     gboolean title_vertical_offset_active;
>>>     gboolean title_vertical_offset_inactive;
>>>     gboolean wrap_workspaces;
>>>+    gboolean wrap_layout;
>>>     gboolean wrap_windows;
>>> };
>>> 
>>>Index: workspaces.c
>>>===================================================================
>>>RCS file: /cvsroot/xfce/xfce4/xfwm4/src/workspaces.c,v
>>>retrieving revision 1.79
>>>diff -u -r1.79 workspaces.c
>>>--- workspaces.c	28 Aug 2004 23:10:17 -0000	1.79
>>>+++ workspaces.c	21 Sep 2004 03:57:00 -0000
>>>@@ -42,6 +42,151 @@
>>> #include "hints.h"
>>> 
>>> void
>>>+workspaceGetPosition (ScreenInfo *screen_info, int n, int * row, int * col)
>>>+{
>>>+    NetWmDesktopLayout * l = &screen_info->desktop_layout;
>>>+    int major_length, minor_length, tmp;
>>>+
>>>+    if (l->orientation == NET_WM_ORIENTATION_HORZ)
>>>+    {
>>>+        major_length = l->cols;
>>>+        minor_length = l->rows;
>>>+    }
>>>+    else
>>>+    {
>>>+        major_length = l->rows;
>>>+        minor_length = l->cols;
>>>+    }
>>>+
>>>+    *row = n / major_length;
>>>+    *col = n % major_length;
>>>+
>>>+    switch (l->start)
>>>+    {
>>>+        case NET_WM_TOPRIGHT:
>>>+            *col = major_length - *col - 1;
>>>+            break;
>>>+        case NET_WM_BOTTOMLEFT:
>>>+            *row = minor_length - *row - 1;
>>>+            break;
>>>+        case NET_WM_BOTTOMRIGHT:
>>>+            *col = major_length - *col - 1;
>>>+            *row = minor_length - *row - 1;
>>>+            break;
>>>+    }
>>>+
>>>+    if (l->orientation == NET_WM_ORIENTATION_VERT)
>>>+    {
>>>+        tmp = *row;
>>>+        *row = *col;
>>>+        *col = tmp;
>>>+        if ((l->start == NET_WM_TOPRIGHT) || (l->start == NET_WM_BOTTOMLEFT))
>>>+        {
>>>+            *row = l->rows - *row - 1;
>>>+            *col = l->cols - *col - 1;
>>>+        }
>>>+    }
>>>+}
>>>+
>>>+int
>>>+workspaceGetNumber (ScreenInfo *screen_info, int row, int col)
>>>+{
>>>+    NetWmDesktopLayout * l = &screen_info->desktop_layout;
>>>+    int major_length, minor_length, n, tmp;
>>>+
>>>+    if (l->orientation == NET_WM_ORIENTATION_HORZ)
>>>+    {
>>>+        major_length = l->cols;
>>>+        minor_length = l->rows;
>>>+    }
>>>+    else
>>>+    {
>>>+        major_length = l->rows;
>>>+        minor_length = l->cols;
>>>+    }
>>>+
>>>+    if (l->orientation == NET_WM_ORIENTATION_VERT)
>>>+    {
>>>+        tmp = row;
>>>+        row = col;
>>>+        col = tmp;
>>>+        if ((l->start == NET_WM_TOPRIGHT) || (l->start == NET_WM_BOTTOMLEFT))
>>>+        {
>>>+            row = minor_length - row - 1;
>>>+            col = major_length - col - 1;
>>>+        }
>>>+    }
>>>+
>>>+    switch (l->start)
>>>+    {
>>>+        case NET_WM_TOPRIGHT:
>>>+            col = major_length - col - 1;
>>>+            break;
>>>+        case NET_WM_BOTTOMLEFT:
>>>+            row = minor_length - row - 1;
>>>+            break;
>>>+        case NET_WM_BOTTOMRIGHT:
>>>+            col = major_length - col - 1;
>>>+            row = minor_length - row - 1;
>>>+            break;
>>>+    }
>>>+
>>>+    n = row*major_length + col;
>>>+    return n;
>>>+}
>>>+
>>>+int
>>>+modify_with_wrap (int value, int by, int limit, gboolean wrap)
>>>+{
>>>+    if (by >= limit) by = limit - 1;
>>>+    value += by;
>>>+    if (value >= limit)
>>>+    {
>>>+        if (!wrap) value = limit - 1;
>>>+        else value = value % limit;
>>>+    }
>>>+    else if (value < 0)
>>>+    {
>>>+        if (!wrap) value = 0;
>>>+        else value = (value+limit) % limit;
>>>+    }
>>>+    return value;
>>>+}
>>>+
>>>+void
>>>+workspaceMove (ScreenInfo *screen_info, int rowmod, int colmod, Client * c2)
>>>+{
>>>+    int row, col, newrow, newcol, n;
>>>+
>>>+    workspaceGetPosition(screen_info, screen_info->current_ws, &row, &col);
>>>+    newrow = modify_with_wrap(row, rowmod, screen_info->desktop_layout.rows, screen_info->params->wrap_layout);
>>>+    newcol = modify_with_wrap(col, colmod, screen_info->desktop_layout.cols, screen_info->params->wrap_layout);
>>>+    n = workspaceGetNumber(screen_info, newrow, newcol);
>>>+
>>>+    if (n == screen_info->current_ws) return;
>>>+
>>>+    if (n < screen_info->workspace_count)
>>>+    {
>>>+        workspaceSwitch(screen_info, n, c2);
>>>+    }
>>>+    else if (screen_info->params->wrap_layout)
>>>+    {
>>>+        if (colmod < 0) n = screen_info->workspace_count - 1;
>>>+        else
>>>+        {
>>>+            if (colmod > 0) newcol = 0;
>>>+            else if (rowmod > 0) newrow = 0;
>>>+            else if (rowmod < 0) newrow--;
>>>+            else g_return_if_fail(FALSE);
>>>+
>>>+            n = workspaceGetNumber(screen_info, newrow, newcol);
>>>+        }
>>>+        g_return_if_fail(n < screen_info->workspace_count);
>>>+        workspaceSwitch(screen_info, n, c2);
>>>+    }
>>>+}
>>>+
>>>+void
>>> workspaceSwitch (ScreenInfo *screen_info, int new_ws, Client * c2)
>>> {
>>>     Client *c, *new_focus = NULL;
>>>Index: workspaces.h
>>>===================================================================
>>>RCS file: /cvsroot/xfce/xfce4/xfwm4/src/workspaces.h,v
>>>retrieving revision 1.19
>>>diff -u -r1.19 workspaces.h
>>>--- workspaces.h	22 Aug 2004 22:18:50 -0000	1.19
>>>+++ workspaces.h	21 Sep 2004 03:57:00 -0000
>>>@@ -32,6 +32,7 @@
>>> #include "screen.h"
>>> #include "client.h"
>>> 
>>>+void workspaceMove (ScreenInfo *, int, int, Client *);
>>> void workspaceSwitch (ScreenInfo *, int, Client *);
>>> void workspaceSetNames (ScreenInfo *, char *, int);
>>> void workspaceSetCount (ScreenInfo *, int);
>>>      
>>>
>>>------------------------------------------------------------------------
>>>
>>>_______________________________________________
>>>Xfce4-dev mailing list
>>>Xfce4-dev at xfce.org
>>>http://lunar-linux.org/mailman/listinfo/xfce4-dev
>>>



More information about the Xfce4-dev mailing list