Package: openbox
Version: 3.4.7.2-3
Severity: wishlist
Tags: patch

Heya,

I finally made a patch to make MoveResize understand
BelowCenter/AboveCente/LeftOfCenter/RightOfCenter. With this, moving a
window to a certain quadrant of the screen is trivial:

    <keybind key="C-A-q">
        <keybind key="1">
            <action name="MoveResizeTo">
                <x>LeftOfCenter</x>
                <y>AboveCenter</y>
            </action>
        </keybind>

        <keybind key="2">
            <action name="MoveResizeTo">
                <x>RightOfCenter</x>
                <y>AboveCenter</y>
            </action>
        </keybind>

        <keybind key="3">
            <action name="MoveResizeTo">
                <x>RightOfCenter</x>
                <y>BelowCenter</y>
            </action>
        </keybind>
        
        <keybind key="4">
            <action name="MoveResizeTo">
                <x>LeftOfCenter</x>
                <y>BelowCenter</y>
            </action>
        </keybind>
    </keybind>

Together with the GrowTo(...) actions, this can be used to emulate
something like tiling, which is great for people with big screens.

If you could include this (or a variant of this patch), I would be very
happy. This, obviously, should also be forwarded to upstream after it
was fixed to match any possibly existing coding conventions.

Thanks,
Marc
diff -Nwru openbox-3.4.7.2/data/rc.xsd openbox-3.4.7.2.patched/data/rc.xsd
--- openbox-3.4.7.2/data/rc.xsd	2008-02-29 22:18:07.000000000 +0100
+++ openbox-3.4.7.2.patched/data/rc.xsd	2009-09-01 12:09:53.000000000 +0200
@@ -171,8 +171,8 @@
         <xsd:element minOccurs="0" name="manageDesktops" type="ob:bool"/>
     </xsd:complexType>
     <xsd:complexType name="window_position">
-        <xsd:element name="x" type="ob:center_or_int"/>
-        <xsd:element name="y" type="ob:center_or_int"/>
+        <xsd:element name="x" type="ob:horizontal_center_or_int"/>
+        <xsd:element name="y" type="ob:vertical_center_or_int"/>
 	<xsd:element name="monitor" type="ob:mouse_or_int"/>	
         <xsd:element minOccurs="0" name="head" type="xsd:string"/>
         <xsd:attribute name="force" type="ob:bool"/>
@@ -365,6 +365,20 @@
             <xsd:pattern value="center|0|[1-9][0-9]*"/>
         </xsd:restriction>
     </xsd:simpleType>
+    <xsd:simpleType name="horizontal_center_or_int">
+        <xsd:restriction base="xsd:string">
+            <!-- ob: atoi($_) unless $_ eq 'center'; -->
+            <!-- I think the regexp DTRT WRT atoi. -->
+            <xsd:pattern value="(Below|Above)?center|0|[1-9][0-9]*"/>
+        </xsd:restriction>
+    </xsd:simpleType>
+    <xsd:simpleType name="vertical_center_or_int">
+        <xsd:restriction base="xsd:string">
+            <!-- ob: atoi($_) unless $_ eq 'center'; -->
+            <!-- I think the regexp DTRT WRT atoi. -->
+            <xsd:pattern value="(LeftOf|RightOf)?center|0|[1-9][0-9]*"/>
+        </xsd:restriction>
+    </xsd:simpleType>
     <xsd:simpleType name="mouse_or_int">
         <xsd:restriction base="xsd:string">
             <!-- ob: atoi($_) unless $_ eq 'center'; -->
diff -Nwru openbox-3.4.7.2/openbox/actions/moveresizeto.c openbox-3.4.7.2.patched/openbox/actions/moveresizeto.c
--- openbox-3.4.7.2/openbox/actions/moveresizeto.c	2008-04-14 01:22:11.000000000 +0200
+++ openbox-3.4.7.2.patched/openbox/actions/moveresizeto.c	2009-09-01 12:06:10.000000000 +0200
@@ -12,6 +12,10 @@
 typedef struct {
     gboolean xcenter;
     gboolean ycenter;
+    gboolean rightofcenter;
+    gboolean leftofcenter;
+    gboolean abovecenter;
+    gboolean belowcenter;
     gboolean xopposite;
     gboolean yopposite;
     gint x;
@@ -42,12 +46,22 @@
 }
 
 static void parse_coord(xmlDocPtr doc, xmlNodePtr n, gint *pos,
-                        gboolean *opposite, gboolean *center)
+                        gboolean *opposite, gboolean *rightofcenter,
+                        gboolean *leftofcenter, gboolean *abovecenter,
+                        gboolean *belowcenter, gboolean *center)
 {
     gchar *s = parse_string(doc, n);
     if (g_ascii_strcasecmp(s, "current") != 0) {
         if (!g_ascii_strcasecmp(s, "center"))
             *center = TRUE;
+        else if (!g_ascii_strcasecmp(s, "rightofcenter"))
+            *rightofcenter = TRUE;
+        else if (!g_ascii_strcasecmp(s, "leftofcenter"))
+            *leftofcenter = TRUE;
+        else if (!g_ascii_strcasecmp(s, "belowcenter"))
+            *belowcenter = TRUE;
+        else if (!g_ascii_strcasecmp(s, "abovecenter"))
+            *abovecenter = TRUE;
         else {
             if (s[0] == '-')
                 *opposite = TRUE;
@@ -73,10 +87,14 @@
     o->monitor = CURRENT_MONITOR;
 
     if ((n = parse_find_node("x", node)))
-        parse_coord(doc, n, &o->x, &o->xopposite, &o->xcenter);
+        parse_coord(doc, n, &o->x, &o->xopposite, 
+                    &o->rightofcenter, &o->leftofcenter,
+                    &o->abovecenter, &o->belowcenter, &o->xcenter);
 
     if ((n = parse_find_node("y", node)))
-        parse_coord(doc, n, &o->y, &o->yopposite, &o->ycenter);
+        parse_coord(doc, n, &o->y, &o->yopposite,
+                    &o->rightofcenter, &o->leftofcenter,
+                    &o->abovecenter, &o->belowcenter, &o->ycenter); 
 
     if ((n = parse_find_node("width", node))) {
         gchar *s = parse_string(doc, n);
@@ -165,12 +183,16 @@
 
         x = o->x;
         if (o->xcenter) x = (area->width - w) / 2;
+        else if (o->leftofcenter) x = (area->width / 2) - w;
+        else if (o->rightofcenter) x = area->width / 2;
         else if (x == G_MININT) x = c->frame->area.x - carea->x;
         else if (o->xopposite) x = area->width - w - x;
         x += area->x;
 
         y = o->y;
         if (o->ycenter) y = (area->height - h) / 2;
+        else if (o->abovecenter) y = (area->height / 2) - h;
+        else if (o->belowcenter) y = area->height / 2;
         else if (y == G_MININT) y = c->frame->area.y - carea->y;
         else if (o->yopposite) y = area->height - h - y;
         y += area->y;

Reply via email to