]> Dogcows Code - chaz/openbox/commitdiff
let you specify the resize popup to be in a fixed place
authorDana Jansens <danakj@orodu.net>
Sat, 12 Jan 2008 01:24:16 +0000 (20:24 -0500)
committerDana Jansens <danakj@orodu.net>
Sat, 12 Jan 2008 01:24:16 +0000 (20:24 -0500)
data/rc.xml
data/rc.xsd
openbox/config.c
openbox/config.h
openbox/moveresize.c
openbox/moveresize.h

index efbd8a9ca35684ab598f24628b7e27e7b3a7d958..3cd88ee884682eb4d38edd26f68060c4f568ceef 100644 (file)
   <popupShow>Nonpixel</popupShow>
   <!-- 'Always', 'Never', or 'Nonpixel' (xterms and such) -->
   <popupPosition>Center</popupPosition>
-  <!-- 'Center' or 'Top' -->
+  <!-- 'Center', 'Top', or 'Fixed' -->
+  <popupFixedPosition>
+    <!-- these are used if popupPosition is set to 'Fixed' -->
+
+    <x>10</x>
+    <!-- positive number for distance from left edge, negative number for
+         distance from right edge, or 'Center' -->
+    <y>10</y>
+    <!-- positive number for distance from top edge, negative number for
+         distance from bottom edge, or 'Center' -->
+  </popupFixedPosition>
 </resize>
 
 <!-- You can reserve a portion of your screen where windows will not cover when
index ef610bfa1e3554dd05afe02f17ea738d48cd786e..0544cfd4fa199772e9d056c0a790184b40775a54 100644 (file)
         <xsd:element minOccurs="0" name="drawContents" type="ob:bool"/>
         <xsd:element minOccurs="0" name="popupShow" type="ob:popupshow"/>
         <xsd:element minOccurs="0" name="popupPosition" type="ob:popupposition"/>
+        <xsd:element minOccurs="0" name="popupPosition" type="ob:popupfixedposition"/>
+    </xsd:complexType>
+    <xsd:complexType name="popupfixedposition">
+        <xsd:element minOccurs="0" name="x" type="ob:center_or_int"/>
+        <xsd:element minOccurs="0" name="y" type="ob:center_or_int"/>
     </xsd:complexType>
     <xsd:complexType name="dock">
         <xsd:element minOccurs="0" name="position" type="ob:dock_position"/>
index 25e30fff4c6e4b7a19a4c3cff2a80804cb80434d..058536665b20b90f22002266efdf008c47f0357d 100644 (file)
@@ -60,10 +60,16 @@ GSList *config_desktops_names;
 guint   config_screen_firstdesk;
 guint   config_desktop_popup_time;
 
-gboolean config_resize_redraw;
-gboolean config_resize_four_corners;
-gint     config_resize_popup_show;
-gint     config_resize_popup_pos;
+gboolean         config_resize_redraw;
+gboolean         config_resize_four_corners;
+gint             config_resize_popup_show;
+ObResizePopupPos config_resize_popup_pos;
+gboolean         config_resize_popup_x_center;
+gboolean         config_resize_popup_y_center;
+gboolean         config_resize_popup_x_opposite;
+gboolean         config_resize_popup_y_opposite;
+gint             config_resize_popup_x;
+gint             config_resize_popup_y;
 
 ObStackingLayer config_dock_layer;
 gboolean        config_dock_floating;
@@ -661,11 +667,46 @@ static void parse_resize(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
             config_resize_popup_show = 1;
     }
     if ((n = parse_find_node("popupPosition", node))) {
-        config_resize_popup_pos = parse_int(doc, n);
         if (parse_contains("Top", doc, n))
-            config_resize_popup_pos = 1;
+            config_resize_popup_pos = OB_RESIZE_POS_TOP;
         else if (parse_contains("Center", doc, n))
-            config_resize_popup_pos = 0;
+            config_resize_popup_pos = OB_RESIZE_POS_CENTER;
+        else if (parse_contains("Fixed", doc, n)) {
+            config_resize_popup_pos = OB_RESIZE_POS_FIXED;
+
+            if ((n = parse_find_node("popupFixedPosition", node))) {
+                xmlNodePtr n2;
+
+                if ((n2 = parse_find_node("x", n->children))) {
+                    gchar *s = parse_string(doc, n2);
+                    if (!g_ascii_strcasecmp(s, "center"))
+                        config_resize_popup_x_center = TRUE;
+                    else {
+                        if (s[0] == '-')
+                            config_resize_popup_x_opposite = TRUE;
+                        if (s[0] == '-' || s[0] == '+')
+                            config_resize_popup_x = atoi(s+1);
+                        else
+                            config_resize_popup_x = atoi(s);
+                    }
+                }
+                if ((n2 = parse_find_node("y", n->children))) {
+                    gchar *s = parse_string(doc, n2);
+                    if (!g_ascii_strcasecmp(s, "center"))
+                        config_resize_popup_y_center = TRUE;
+                    else {
+                        if (s[0] == '-')
+                            config_resize_popup_y_opposite = TRUE;
+                        if (s[0] == '-' || s[0] == '+')
+                            config_resize_popup_y = atoi(s+1);
+                        else
+                            config_resize_popup_y = atoi(s);
+                    }
+                }
+                g_print("X %d %d %d\n", config_resize_popup_x_center, config_resize_popup_x_opposite, config_resize_popup_x);
+                g_print("Y %d %d %d\n", config_resize_popup_y_center, config_resize_popup_y_opposite, config_resize_popup_y);
+            }
+        }
     }
 }
 
@@ -914,7 +955,13 @@ void config_startup(ObParseInst *i)
     config_resize_redraw = TRUE;
     config_resize_four_corners = FALSE;
     config_resize_popup_show = 1; /* nonpixel increments */
-    config_resize_popup_pos = 0;  /* center of client */
+    config_resize_popup_pos = OB_RESIZE_POS_CENTER;
+    config_resize_popup_x_center = FALSE;
+    config_resize_popup_x_opposite = FALSE;
+    config_resize_popup_x = 0;
+    config_resize_popup_y_center = FALSE;
+    config_resize_popup_y_opposite = FALSE;
+    config_resize_popup_y = 0;
 
     parse_register(i, "resize", parse_resize, NULL);
 
index 2c4b4dba3aaa1a163b7783a6f4b3b4071cbadf00..4fa9c70b15eb230df205b46d8a457b3beef1f044 100644 (file)
@@ -24,6 +24,7 @@
 #include "stacking.h"
 #include "place.h"
 #include "geom.h"
+#include "moveresize.h"
 #include "render/render.h"
 
 #include <glib.h>
@@ -92,8 +93,24 @@ extern gboolean config_resize_redraw;
 /*! show move/resize popups? 0 = no, 1 = always, 2 = only
   resizing !1 increments */
 extern gint config_resize_popup_show;
-/*! where to show the popup, currently above the window or centered */
-extern gint config_resize_popup_pos;
+/*! where to show the resize popup */
+extern ObResizePopupPos config_resize_popup_pos;
+/*! if the resize popup should be centered horizontally if it is being
+  placed in a fixed position */
+extern gboolean config_resize_popup_x_center;
+/*! if the resize popup should be centered vertically if it is being
+  placed in a fixed position */
+extern gboolean config_resize_popup_y_center;
+/*! if the resize popup should be placed from the right side of the screen when
+  placed in a fixed position */
+extern gboolean config_resize_popup_x_opposite;
+/*! if the resize popup should be placed from the bottom side of the screen
+  when placed in a fixed position */
+extern gboolean config_resize_popup_y_opposite;
+/*! where the resize popup should be if it is placed in a fixed position */
+extern gint config_resize_popup_x;
+/*! where the resize popup should be if it is placed in a fixed position */
+extern gint config_resize_popup_y;
 
 /*! The stacking layer the dock will reside in */
 extern ObStackingLayer config_dock_layer;
index bb17d4a04f3f7b0153820c16dfaf2e23352001d2..07b8e22b5d163837240ff41f51ca8d29a60f6743 100644 (file)
@@ -101,17 +101,60 @@ static void popup_coords(ObClient *c, const gchar *format, gint a, gint b)
     gchar *text;
 
     text = g_strdup_printf(format, a, b);
-    if (config_resize_popup_pos == 1) /* == "Top" */
+    if (config_resize_popup_pos == OB_RESIZE_POS_TOP)
         popup_position(popup, SouthGravity,
                        c->frame->area.x
                      + c->frame->area.width/2,
                        c->frame->area.y - ob_rr_theme->fbwidth);
-    else /* == "Center" */
+    else if (config_resize_popup_pos == OB_RESIZE_POS_CENTER)
         popup_position(popup, CenterGravity,
                        c->frame->area.x + c->frame->size.left +
                        c->area.width / 2,
                        c->frame->area.y + c->frame->size.top +
                        c->area.height / 2);
+    else /* Fixed */ {
+        Rect *area = screen_physical_area_active();
+        gint gravity, x, y;
+
+        x = config_resize_popup_x;
+        if (config_resize_popup_x_center) x = area->x + area->width/2;
+        else if (config_resize_popup_x_opposite) x = RECT_RIGHT(*area) - x;
+        else x = area->x + x;
+
+        y = config_resize_popup_y;
+        if (config_resize_popup_y_center) y = area->y + area->height/2;
+        else if (config_resize_popup_y_opposite) y = RECT_BOTTOM(*area) - y;
+        else y = area->y + y;
+
+        if (config_resize_popup_x_center) {
+            if (config_resize_popup_y_center)
+                gravity = CenterGravity;
+            else if (config_resize_popup_y_opposite)
+                gravity = SouthGravity;
+            else
+                gravity = NorthGravity;
+        }
+        else if (config_resize_popup_x_opposite) {
+            if (config_resize_popup_y_center)
+                gravity = EastGravity;
+            else if (config_resize_popup_y_opposite)
+                gravity = SouthEastGravity;
+            else
+                gravity = NorthEastGravity;
+        }
+        else {
+            if (config_resize_popup_y_center)
+                gravity = WestGravity;
+            else if (config_resize_popup_y_opposite)
+                gravity = SouthWestGravity;
+            else
+                gravity = NorthWestGravity;
+        }
+
+        popup_position(popup, gravity, x, y);
+
+        g_free(area);
+    }
     popup_show(popup, text);
     g_free(text);
 }
index 2f8d3e6a02cb781fc395a2d5087614d9cfd1075a..2d0f7dced493644a2804cab6291cfba424ffaf1d 100644 (file)
 
 struct _ObClient;
 
+typedef enum {
+    OB_RESIZE_POS_CENTER,
+    OB_RESIZE_POS_TOP,
+    OB_RESIZE_POS_FIXED
+} ObResizePopupPos;
+
 extern gboolean moveresize_in_progress;
 extern struct _ObClient *moveresize_client;
 #ifdef SYNC
This page took 0.040895 seconds and 4 git commands to generate.