[metacity] Add disable-mouse-button-modifiers message
- From: Daniel Drake <dsd src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] Add disable-mouse-button-modifiers message
- Date: Thu, 7 Jun 2012 15:20:35 +0000 (UTC)
commit 86fd12cbf06f693405650b9d6f7c6234757cc354
Author: Daniel Drake <dsd laptop org>
Date: Wed May 30 09:42:34 2012 -0600
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
src/core/atomnames.h | 1 +
src/core/display.c | 23 ++++++++++++++++++++++-
src/tools/metacity-message.c | 34 +++++++++++++++++++++++++++++++++-
3 files changed, 56 insertions(+), 2 deletions(-)
---
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]