wok-next view openbox/stuff/patches/03_place_windows_in_quadrants.patch @ rev 21727

created recipe for vbindiff
author Hans-G?nter Theisgen
date Sat Nov 21 14:32:44 2020 +0100 (2020-11-21)
parents
children
line source
1 patch by Marc Brockschmidt to allow placing windows in certain screen
2 quadrants using key bindings - #544538
3 Index: openbox-3.4.11.1/data/rc.xsd
4 ===================================================================
5 --- openbox-3.4.11.1.orig/data/rc.xsd 2010-04-23 16:49:08.000000000 +0200
6 +++ openbox-3.4.11.1/data/rc.xsd 2010-04-23 16:49:56.000000000 +0200
7 @@ -171,8 +171,8 @@
8 <xsd:element minOccurs="0" name="manageDesktops" type="ob:bool"/>
9 </xsd:complexType>
10 <xsd:complexType name="window_position">
11 - <xsd:element name="x" type="ob:center_or_int"/>
12 - <xsd:element name="y" type="ob:center_or_int"/>
13 + <xsd:element name="x" type="ob:horizontal_center_or_int"/>
14 + <xsd:element name="y" type="ob:vertical_center_or_int"/>
15 <xsd:element name="monitor" type="ob:mouse_or_int"/>
16 <xsd:element minOccurs="0" name="head" type="xsd:string"/>
17 <xsd:attribute name="force" type="ob:bool"/>
18 @@ -365,6 +365,20 @@
19 <xsd:pattern value="center|0|[1-9][0-9]*"/>
20 </xsd:restriction>
21 </xsd:simpleType>
22 + <xsd:simpleType name="horizontal_center_or_int">
23 + <xsd:restriction base="xsd:string">
24 + <!-- ob: atoi($_) unless $_ eq 'center'; -->
25 + <!-- I think the regexp DTRT WRT atoi. -->
26 + <xsd:pattern value="(Below|Above)?center|0|[1-9][0-9]*"/>
27 + </xsd:restriction>
28 + </xsd:simpleType>
29 + <xsd:simpleType name="vertical_center_or_int">
30 + <xsd:restriction base="xsd:string">
31 + <!-- ob: atoi($_) unless $_ eq 'center'; -->
32 + <!-- I think the regexp DTRT WRT atoi. -->
33 + <xsd:pattern value="(LeftOf|RightOf)?center|0|[1-9][0-9]*"/>
34 + </xsd:restriction>
35 + </xsd:simpleType>
36 <xsd:simpleType name="mouse_or_int">
37 <xsd:restriction base="xsd:string">
38 <!-- ob: atoi($_) unless $_ eq 'center'; -->
39 Index: openbox-3.4.11.1/openbox/actions/moveresizeto.c
40 ===================================================================
41 --- openbox-3.4.11.1.orig/openbox/actions/moveresizeto.c 2010-04-23 16:49:24.000000000 +0200
42 +++ openbox-3.4.11.1/openbox/actions/moveresizeto.c 2010-04-23 16:49:56.000000000 +0200
43 @@ -14,6 +14,10 @@
44 typedef struct {
45 gboolean xcenter;
46 gboolean ycenter;
47 + gboolean rightofcenter;
48 + gboolean leftofcenter;
49 + gboolean abovecenter;
50 + gboolean belowcenter;
51 gboolean xopposite;
52 gboolean yopposite;
53 gint x;
54 @@ -44,12 +48,22 @@
55 }
57 static void parse_coord(xmlDocPtr doc, xmlNodePtr n, gint *pos,
58 - gboolean *opposite, gboolean *center)
59 + gboolean *opposite, gboolean *rightofcenter,
60 + gboolean *leftofcenter, gboolean *abovecenter,
61 + gboolean *belowcenter, gboolean *center)
62 {
63 gchar *s = parse_string(doc, n);
64 if (g_ascii_strcasecmp(s, "current") != 0) {
65 if (!g_ascii_strcasecmp(s, "center"))
66 *center = TRUE;
67 + else if (!g_ascii_strcasecmp(s, "rightofcenter"))
68 + *rightofcenter = TRUE;
69 + else if (!g_ascii_strcasecmp(s, "leftofcenter"))
70 + *leftofcenter = TRUE;
71 + else if (!g_ascii_strcasecmp(s, "belowcenter"))
72 + *belowcenter = TRUE;
73 + else if (!g_ascii_strcasecmp(s, "abovecenter"))
74 + *abovecenter = TRUE;
75 else {
76 if (s[0] == '-')
77 *opposite = TRUE;
78 @@ -75,10 +89,14 @@
79 o->monitor = CURRENT_MONITOR;
81 if ((n = parse_find_node("x", node)))
82 - parse_coord(doc, n, &o->x, &o->xopposite, &o->xcenter);
83 + parse_coord(doc, n, &o->x, &o->xopposite,
84 + &o->rightofcenter, &o->leftofcenter,
85 + &o->abovecenter, &o->belowcenter, &o->xcenter);
87 if ((n = parse_find_node("y", node)))
88 - parse_coord(doc, n, &o->y, &o->yopposite, &o->ycenter);
89 + parse_coord(doc, n, &o->y, &o->yopposite,
90 + &o->rightofcenter, &o->leftofcenter,
91 + &o->abovecenter, &o->belowcenter, &o->ycenter);
93 if ((n = parse_find_node("width", node))) {
94 gchar *s = parse_string(doc, n);
95 @@ -182,12 +200,16 @@
97 x = o->x;
98 if (o->xcenter) x = (area->width - w) / 2;
99 + else if (o->leftofcenter) x = (area->width / 2) - w;
100 + else if (o->rightofcenter) x = area->width / 2;
101 else if (x == G_MININT) x = c->frame->area.x - carea->x;
102 else if (o->xopposite) x = area->width - w - x;
103 x += area->x;
105 y = o->y;
106 if (o->ycenter) y = (area->height - h) / 2;
107 + else if (o->abovecenter) y = (area->height / 2) - h;
108 + else if (o->belowcenter) y = area->height / 2;
109 else if (y == G_MININT) y = c->frame->area.y - carea->y;
110 else if (o->yopposite) y = area->height - h - y;
111 y += area->y;