summaryrefslogtreecommitdiffstats
path: root/metacity-3.14-bgo738562.patch
blob: 92096125f6178a6b2e8a5a521f05bf8c7dc33789 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
From 5e694c3935c838bb2d1179d3cbb6da61f433a5c1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alberts=20Muktup=C4=81vels?= <alberts.muktupavels@gmail.com>
Date: Thu, 4 Jun 2015 17:04:51 +0300
Subject: prefs: use button layout from GtkSettings

This is needed to make sure that client-side and server-side
decorations have same button layout.

GNOME Settings Daemon will update Gtk/DecorationLayout from
button-layout. At this point everything should be ok.

But then it is possible to override Gtk/DecorationLayout from
xsettings plugin in GNOME Settings Daemon. At this point we can
end up with different button layouts between client-side and
server-side decorations. I can not think any reason why someone
would want different button layouts.

diff --git a/src/core/prefs.c b/src/core/prefs.c
index 6278fdd..f404aff 100644
--- a/src/core/prefs.c
+++ b/src/core/prefs.c
@@ -129,6 +129,7 @@ static gboolean button_layout_handler (GVariant*, gpointer*, gpointer);
 static void     init_bindings             (void);
 static void     init_workspace_names      (void);
 
+static void update_button_layout (const gchar *string_value);
 
 typedef struct
 {
@@ -759,6 +760,71 @@ queue_changed (MetaPreference pref)
                                     changed_idle_handler, NULL, NULL);
 }
 
+static void
+gtk_decoration_layout_changed (GtkSettings *settings,
+                               GParamSpec  *pspec,
+                               gpointer     user_data)
+{
+  gchar *layout;
+  gchar **sides;
+  gint i;
+  gint j;
+
+  g_object_get (settings, "gtk-decoration-layout", &layout, NULL);
+
+  sides = g_strsplit (layout, ":", -1);
+  g_free (layout);
+
+  for (i = 0; sides[i]; i++)
+    {
+      gchar **buttons;
+
+      buttons = g_strsplit (sides[i], ",", -1);
+
+      for (j = 0; buttons[j]; j++)
+        {
+          const gchar *button;
+
+          if (g_strcmp0 (buttons[j], "icon") == 0)
+            button = "menu";
+          else if (g_strcmp0 (buttons[j], "menu") == 0)
+            button = "appmenu";
+          else
+            button = NULL;
+
+          if (button)
+            {
+              g_free (buttons[j]);
+              buttons[j] = g_strdup (button);
+            }
+        }
+
+      g_free (sides[i]);
+      sides[i] = g_strjoinv (",", buttons);
+
+      g_strfreev (buttons);
+    }
+
+  layout = g_strjoinv (":", sides);
+  g_strfreev (sides);
+
+  update_button_layout (layout);
+  g_free (layout);
+}
+
+static void
+init_gtk_decoration_layout (void)
+{
+  GtkSettings *settings;
+
+  settings = gtk_settings_get_default ();
+
+  g_signal_connect (settings, "notify::gtk-decoration-layout",
+                    G_CALLBACK (gtk_decoration_layout_changed), NULL);
+
+  gtk_decoration_layout_changed (settings, NULL, NULL);
+}
+
 /****************************************************************************/
 /* Initialisation.                                                          */
 /****************************************************************************/
@@ -799,6 +865,8 @@ meta_prefs_init (void)
 
   init_bindings ();
   init_workspace_names ();
+
+  init_gtk_decoration_layout ();
 }
 
 /****************************************************************************/
@@ -1118,13 +1186,10 @@ button_opposite_function (MetaButtonFunction ofwhat)
     }
 }
 
-static gboolean
-button_layout_handler (GVariant *value,
-                       gpointer *result,
-                       gpointer  data)
+static void
+update_button_layout (const gchar *string_value)
 {
   MetaButtonLayout new_layout;
-  const gchar *string_value;
   char **sides = NULL;
   int i;
 
@@ -1132,12 +1197,7 @@ button_layout_handler (GVariant *value,
    * compat with future versions
    */
 
-  *result = NULL; /* ignored */
-  string_value = g_variant_get_string (value, NULL);
-
-  if (string_value)
-    sides = g_strsplit (string_value, ":", 2);
-
+  sides = g_strsplit (string_value, ":", 2);
   i = 0;
 
   if (sides != NULL && sides[0] != NULL)
@@ -1303,7 +1363,23 @@ button_layout_handler (GVariant *value,
       button_layout = new_layout;
       emit_changed (META_PREF_BUTTON_LAYOUT);
     }
+}
 
+static gboolean
+button_layout_handler (GVariant *value,
+                       gpointer *result,
+                       gpointer  data)
+{
+#if 0
+  const gchar *string_value;
+
+  string_value = g_variant_get_string (value, NULL);
+
+  if (string_value)
+    update_button_layout (string_value);
+#endif
+
+  *result = NULL; /* ignored */
   return TRUE;
 }
 
-- 
cgit v0.10.2