summaryrefslogtreecommitdiffstats
path: root/disable-mouse-button-modifiers.patch
blob: 51ff41151fae1808420ef3036c93d7d3893a6945 (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
From 86fd12cbf06f693405650b9d6f7c6234757cc354 Mon Sep 17 00:00:00 2001
From: Daniel Drake <dsd@laptop.org>
Date: Wed, 30 May 2012 15:42:34 +0000
Subject: Add disable-mouse-button-modifiers message

Similar to the disable-keybindings message, Sugar would like to be able
to disable this specific part of the metacity functionality without
changing the GSettings configuration (which would also affect GNOME).

Add a new metacity-message command to disable mouse button modifiers,
which ordinarily let windows be dragged around the screen when a specific
modifier is pressed.

https://bugzilla.gnome.org/show_bug.cgi?id=677115
---
diff --git a/src/core/atomnames.h b/src/core/atomnames.h
index 338d055..14dbd8f 100644
--- a/src/core/atomnames.h
+++ b/src/core/atomnames.h
@@ -57,6 +57,7 @@ item(_KWM_WIN_ICON)
 item(_METACITY_RESTART_MESSAGE)    
 item(_METACITY_RELOAD_THEME_MESSAGE)
 item(_METACITY_SET_KEYBINDINGS_MESSAGE)
+item(_METACITY_SET_MOUSEMODS_MESSAGE)
 item(_METACITY_TOGGLE_VERBOSE)
 item(_GNOME_PANEL_ACTION)
 item(_GNOME_PANEL_ACTION_MAIN_MENU)
diff --git a/src/core/display.c b/src/core/display.c
index b70112d..440f2fb 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -135,6 +135,8 @@ typedef struct
  */
 static MetaDisplay *the_display = NULL;
 
+static gboolean mousemods_disabled = FALSE;
+
 #ifdef WITH_VERBOSE_MODE
 static void   meta_spew_event           (MetaDisplay    *display,
                                          XEvent         *event);
@@ -157,6 +159,9 @@ static void    process_selection_clear   (MetaDisplay   *display,
 
 static void    update_window_grab_modifiers (MetaDisplay *display);
 
+static void    set_mousemods_disabled (MetaDisplay *display,
+                                       gboolean     setting);
+
 static void    prefs_changed_callback    (MetaPreference pref,
                                           void          *data);
 
@@ -2271,6 +2276,13 @@ event_callback (XEvent   *event,
                   meta_set_keybindings_disabled (display, !event->xclient.data.l[0]);
                 }
               else if (event->xclient.message_type ==
+                       display->atom__METACITY_SET_MOUSEMODS_MESSAGE)
+                {
+                  meta_verbose ("Received set mousemods request = %d\n",
+                                (int) event->xclient.data.l[0]);
+                  set_mousemods_disabled (display, !event->xclient.data.l[0]);
+                }
+              else if (event->xclient.message_type ==
                        display->atom__METACITY_TOGGLE_VERBOSE)
                 {
                   meta_verbose ("Received toggle verbose message\n");
@@ -3701,7 +3713,7 @@ meta_display_grab_window_buttons (MetaDisplay *display,
    * XSync()
    */
 
-  if (display->window_grab_modifiers != 0)
+  if (display->window_grab_modifiers != 0 && !mousemods_disabled)
     {
       gboolean debug = g_getenv ("METACITY_DEBUG_BUTTON_GRABS") != NULL;
       int i;
@@ -3835,6 +3847,15 @@ meta_display_ungrab_focus_window_button (MetaDisplay *display,
   }
 }
 
+static void
+set_mousemods_disabled (MetaDisplay *display,
+                        gboolean     setting)
+{
+  mousemods_disabled = setting;
+  prefs_changed_callback(META_PREF_MOUSE_BUTTON_MODS, display);
+  meta_verbose ("Mouse button modifiers %s\n", mousemods_disabled ? "disabled" : "enabled");
+}
+
 void
 meta_display_increment_event_serial (MetaDisplay *display)
 {
diff --git a/src/tools/metacity-message.c b/src/tools/metacity-message.c
index 8d5548c..9aae733 100644
--- a/src/tools/metacity-message.c
+++ b/src/tools/metacity-message.c
@@ -114,6 +114,34 @@ send_set_keybindings (gboolean enabled)
   XSync (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), False);
 }
 
+static void
+send_set_mousemods (gboolean enabled)
+{
+  XEvent xev;
+
+  xev.xclient.type = ClientMessage;
+  xev.xclient.serial = 0;
+  xev.xclient.send_event = True;
+  xev.xclient.display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+  xev.xclient.window = gdk_x11_get_default_root_xwindow ();
+  xev.xclient.message_type = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+                                          "_METACITY_SET_MOUSEMODS_MESSAGE",
+                                          False);
+  xev.xclient.format = 32;
+  xev.xclient.data.l[0] = enabled;
+  xev.xclient.data.l[1] = 0;
+  xev.xclient.data.l[2] = 0;
+
+  XSendEvent (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
+              gdk_x11_get_default_root_xwindow (),
+              False,
+	      SubstructureRedirectMask | SubstructureNotifyMask,
+	      &xev);
+
+  XFlush (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
+  XSync (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), False);
+}
+
 #ifdef WITH_VERBOSE_MODE
 static void
 send_toggle_verbose (void)
@@ -148,7 +176,7 @@ static void
 usage (void)
 {
   g_printerr (_("Usage: %s\n"),
-              "metacity-message (restart|reload-theme|enable-keybindings|disable-keybindings|toggle-verbose)");
+              "metacity-message (restart|reload-theme|enable-keybindings|disable-keybindings|enable-mouse-button-modifiers|disable-mouse-button-modifiers|toggle-verbose)");
   exit (1);
 }
 
@@ -170,6 +198,10 @@ main (int argc, char **argv)
     send_set_keybindings (TRUE);
   else if (strcmp (argv[1], "disable-keybindings") == 0)
     send_set_keybindings (FALSE);
+  else if (strcmp (argv[1], "enable-mouse-button-modifiers") == 0)
+    send_set_mousemods (TRUE);
+  else if (strcmp (argv[1], "disable-mouse-button-modifiers") == 0)
+    send_set_mousemods (FALSE);
   else if (strcmp (argv[1], "toggle-verbose") == 0)
     {
 #ifndef WITH_VERBOSE_MODE
--
cgit v0.9.0.2