[openbox] DesktopUp functionality

Mikael Magnusson mangosoft at comhem.se
Sat Jun 12 08:01:19 EDT 2004


On Sat, 12 Jun 2004, M.Zdila/EpiSoftware Ltd. wrote:

> Hi
>
> How does DesktopUp and DesktopDown action work? In the default configuration 
> (after apt-get in debian) it just does nothing except for displaying that 
> small dialog showing that I am trying to switch desktop. I'd like to 
> configure Openbox to have something like 2D desktop switching, not only 1D as 
> I have now.
>
> Imagine 3x3 2D desktop layout (as nombers 1 - 9 on numeric keyboard). If I 
> press C-A-Up, it should switch from desktop 1 to desktop 4. Is this possible?

Yes, currently you have to use a pager to set the desktop layout. There is 
also a patch that lets you set it in rc.xml, but it needs some work before 
it will be included, I'll attach it here.

> Thanks in advance

--
Mikael Magnusson
-------------- next part --------------
diff -wrup openbox-3.2/openbox/config.c openbox-3.2_vmx/openbox/config.c
--- openbox-3.2/openbox/config.c	2004-04-17 14:12:49.000000000 +0200
+++ openbox-3.2_vmx/openbox/config.c	2004-04-28 20:08:39.000000000 +0200
@@ -39,6 +39,7 @@ gboolean config_theme_keepborder;
 gchar *config_title_layout;

 gint    config_desktops_num;
+gint    config_desktops_rows;
 GSList *config_desktops_names;
 gint    config_screen_firstdesk;

@@ -266,6 +267,11 @@ static void parse_desktops(ObParseInst *
         if (d > 0)
             config_desktops_num = d;
     }
+    if ((n = parse_find_node("rows", node))) {
+        gint d = parse_int(doc, n);
+        if (d > 0)
+            config_desktops_rows = d;
+    }
     if ((n = parse_find_node("firstdesk", node))) {
         gint d = parse_int(doc, n);
         if (d > 0)
@@ -549,6 +555,7 @@ void config_startup(ObParseInst *i)
     parse_register(i, "theme", parse_theme, NULL);

     config_desktops_num = 4;
+    config_desktops_rows = 1;
     config_screen_firstdesk = 1;
     config_desktops_names = NULL;

diff -wrup openbox-3.2/openbox/config.h openbox-3.2_vmx/openbox/config.h
--- openbox-3.2/openbox/config.h	2004-03-21 21:06:40.000000000 +0100
+++ openbox-3.2_vmx/openbox/config.h	2004-04-28 20:10:07.000000000 +0200
@@ -84,6 +84,8 @@ extern gchar *config_title_layout;

 /*! The number of desktops */
 extern gint config_desktops_num;
+/*! The number of desktops rows */
+extern gint config_desktops_rows;
 /*! Desktop to start on, put 5 to start in the center of a 3x3 grid */
 extern gint config_screen_firstdesk;
 /*! Names for the desktops */

diff -wrup openbox-3.2/openbox/screen.c openbox-3.2_vmx/openbox/screen.c
--- openbox-3.2/openbox/screen.c	2004-04-06 19:58:54.000000000 +0200
+++ openbox-3.2_vmx/openbox/screen.c	2004-04-28 20:11:49.000000000 +0200
@@ -156,7 +156,7 @@ gboolean screen_annex()
     XSetWindowAttributes attrib;
     pid_t pid;
     gint i, num_support;
-    guint32 *supported;
+    guint32 *supported, layout[4];

     /* create the netwm support window */
     attrib.override_redirect = TRUE;
@@ -194,6 +194,14 @@ gboolean screen_annex()
     PROP_SET32(RootWindow(ob_display, ob_screen),
                openbox_pid, cardinal, pid);

+    /* set desktop layout */
+    layout[0] = screen_desktop_layout.orientation;
+    layout[1] = screen_desktop_layout.columns;
+    layout[2] = screen_desktop_layout.rows;
+    layout[3] = screen_desktop_layout.start_corner;
+    PROP_SETA32(RootWindow(ob_display, ob_screen),
+               net_desktop_layout, cardinal, layout, 4);
+
     /* set supporting window */
     PROP_SET32(RootWindow(ob_display, ob_screen),
                net_supporting_wm_check, window, screen_support_win);
@@ -825,8 +833,10 @@ void screen_update_layout()
         /* defaults */
         orient = OB_ORIENTATION_HORZ;
         corner = OB_CORNER_TOPLEFT;
-        rows = 1;
-        cols = screen_num_desktops;
+        rows = config_desktops_rows;
+        cols = screen_num_desktops / config_desktops_rows;
+        if (screen_num_desktops % config_desktops_rows)
+            cols += 1;
     }

     screen_desktop_layout.orientation = orient;


More information about the openbox mailing list