diff -Nur metacity-2.20.0/src/display.c metacity-2.20.0.new/src/display.c --- metacity-2.20.0/src/display.c 2007-08-31 21:48:55.000000000 +0200 +++ metacity-2.20.0.new/src/display.c 2007-11-12 23:06:40.000000000 +0100 @@ -114,6 +114,9 @@ static void update_window_grab_modifiers (MetaDisplay *display); +static void update_window_button_operations (MetaDisplay *display, + gboolean swapped); + static void prefs_changed_callback (MetaPreference pref, void *data); @@ -397,6 +400,8 @@ update_window_grab_modifiers (display); + update_window_button_operations (display, meta_prefs_get_mouse_button_swap_behaviour()); + meta_prefs_add_listener (prefs_changed_callback, display); XInternAtoms (display->xdisplay, atom_names, G_N_ELEMENTS (atom_names), @@ -1625,7 +1630,7 @@ unmodified = (event->xbutton.state & grab_mask) == 0; if (unmodified || - event->xbutton.button == 1) + event->xbutton.button == display->window_move_button) { /* don't focus if frame received, will be lowered in * frames.c or special-cased if the click was on a @@ -1662,7 +1667,7 @@ if (!unmodified) begin_move = TRUE; } - else if (!unmodified && event->xbutton.button == 2) + else if (!unmodified && event->xbutton.button == display->window_resize_button) { if (window->has_resize_func) { @@ -1711,7 +1716,7 @@ event->xbutton.y_root); } } - else if (event->xbutton.button == 3) + else if (event->xbutton.button == display->window_popup_button) { if (meta_prefs_get_raise_on_click ()) meta_window_raise (window); @@ -4777,6 +4782,23 @@ } static void +update_window_button_operations (MetaDisplay *display, gboolean swapped) + +{ + display->window_move_button = 1; + if (swapped) + { + display->window_resize_button = 3; + display->window_popup_button = 2; + } + else + { + display->window_resize_button = 2; + display->window_popup_button = 3; + } +} + +static void prefs_changed_callback (MetaPreference pref, void *data) { @@ -4821,6 +4843,10 @@ g_slist_free (windows); } + else if (pref == META_PREF_MOUSE_BUTTON_SWAP_BEHAVIOUR) + { + update_window_button_operations (display, meta_prefs_get_mouse_button_swap_behaviour()); + } else if (pref == META_PREF_AUDIBLE_BELL) { meta_bell_set_audible (display, meta_prefs_bell_is_audible ()); diff -Nur metacity-2.20.0/src/display.h metacity-2.20.0.new/src/display.h --- metacity-2.20.0/src/display.h 2007-08-31 21:48:55.000000000 +0200 +++ metacity-2.20.0.new/src/display.h 2007-11-12 23:06:40.000000000 +0100 @@ -250,6 +250,11 @@ /* Alt+click button grabs */ unsigned int window_grab_modifiers; + + /* Window button operations */ + unsigned int window_move_button; + unsigned int window_resize_button; + unsigned int window_popup_button; /* current window operation */ MetaGrabOp grab_op; diff -Nur metacity-2.20.0/src/metacity.schemas.in metacity-2.20.0.new/src/metacity.schemas.in --- metacity-2.20.0/src/metacity.schemas.in 2007-08-31 21:48:55.000000000 +0200 +++ metacity-2.20.0.new/src/metacity.schemas.in 2007-11-12 23:06:40.000000000 +0100 @@ -339,6 +339,20 @@ + /schemas/apps/metacity/general/mouse_button_swap_behaviour + /apps/metacity/general/mouse_button_swap_behaviour + metacity + bool + false + + Buttons behaviour + + Determines whether Metacity uses button3 for popup menu or resize. + + + + + /schemas/apps/metacity/workspace_names/name /apps/metacity/workspace_names/name_1 /apps/metacity/workspace_names/name_2 diff -Nur metacity-2.20.0/src/prefs.c metacity-2.20.0.new/src/prefs.c --- metacity-2.20.0/src/prefs.c 2007-08-31 21:48:55.000000000 +0200 +++ metacity-2.20.0.new/src/prefs.c 2007-11-12 23:06:40.000000000 +0100 @@ -77,6 +77,7 @@ #define KEY_CURSOR_THEME "/desktop/gnome/peripherals/mouse/cursor_theme" #define KEY_CURSOR_SIZE "/desktop/gnome/peripherals/mouse/cursor_size" #define KEY_COMPOSITING_MANAGER "/apps/metacity/general/compositing_manager" +#define KEY_MOUSE_BUTTON_SWAP_BEHAVIOUR "/apps/metacity/general/mouse_button_swap_behaviour" #ifdef HAVE_GCONF static GConfClient *default_client = NULL; @@ -107,6 +108,7 @@ static char *cursor_theme = NULL; static int cursor_size = 24; static gboolean compositing_manager = FALSE; +static gboolean mouse_button_swap_behaviour = FALSE; static MetaVisualBellType visual_bell_type = META_VISUAL_BELL_FULLSCREEN_FLASH; static MetaButtonLayout button_layout; @@ -156,6 +158,7 @@ static gboolean update_cursor_theme (const char *value); static gboolean update_cursor_size (int size); static gboolean update_compositing_manager (gboolean value); +static gboolean update_mouse_button_swap (gboolean value); static void change_notify (GConfClient *client, guint cnxn_id, @@ -484,6 +487,10 @@ bool_val = compositing_manager; if (get_bool (KEY_COMPOSITING_MANAGER, &bool_val)) update_compositing_manager (bool_val); + + bool_val = mouse_button_swap_behaviour; + if (get_bool (KEY_MOUSE_BUTTON_SWAP_BEHAVIOUR, &bool_val)) + update_mouse_button_swap (bool_val); str_val = gconf_client_get_string (default_client, KEY_VISUAL_BELL_TYPE, &err); @@ -1065,6 +1072,22 @@ if (update_compositing_manager (b)) queue_changed (META_PREF_COMPOSITING_MANAGER); } + else if (strcmp (key, KEY_MOUSE_BUTTON_SWAP_BEHAVIOUR) == 0) + { + gboolean b; + + if (value && value->type != GCONF_VALUE_BOOL) + { + meta_warning (_("GConf key \"%s\" is set to an invalid type\n"), + KEY_MOUSE_BUTTON_SWAP_BEHAVIOUR); + goto out; + } + + b = value ? gconf_value_get_bool (value) : mouse_button_swap_behaviour; + + if (update_mouse_button_swap (b)) + queue_changed (META_PREF_MOUSE_BUTTON_SWAP_BEHAVIOUR); + } else { meta_topic (META_DEBUG_PREFS, "Key %s doesn't mean anything to Metacity\n", @@ -1850,6 +1873,9 @@ case META_PREF_COMPOSITING_MANAGER: return "COMPOSITING_MANAGER"; + + case META_PREF_MOUSE_BUTTON_SWAP_BEHAVIOUR: + return "MOUSE_BUTTON_SWAP_BEHAVIOUR"; } return "(unknown)"; @@ -3044,6 +3070,24 @@ return compositing_manager; } +#ifdef HAVE_GCONF +static gboolean +update_mouse_button_swap (gboolean value) +{ + gboolean old = mouse_button_swap_behaviour; + + mouse_button_swap_behaviour = value; + + return old != mouse_button_swap_behaviour; +} +#endif + +gboolean +meta_prefs_get_mouse_button_swap_behaviour (void) +{ + return mouse_button_swap_behaviour; +} + static void init_button_layout(void) { diff -Nur metacity-2.20.0/src/prefs.h metacity-2.20.0.new/src/prefs.h --- metacity-2.20.0/src/prefs.h 2007-08-31 21:48:55.000000000 +0200 +++ metacity-2.20.0.new/src/prefs.h 2007-11-12 23:06:40.000000000 +0100 @@ -58,7 +58,8 @@ META_PREF_GNOME_ACCESSIBILITY, META_PREF_CURSOR_THEME, META_PREF_CURSOR_SIZE, - META_PREF_COMPOSITING_MANAGER + META_PREF_COMPOSITING_MANAGER, + META_PREF_MOUSE_BUTTON_SWAP_BEHAVIOUR } MetaPreference; typedef void (* MetaPrefsChangedFunc) (MetaPreference pref, @@ -316,6 +317,8 @@ gboolean meta_prefs_bell_is_audible (void); MetaVisualBellType meta_prefs_get_visual_bell_type (void); +gboolean meta_prefs_get_mouse_button_swap_behaviour (void); + #endif