diff -dcr metacity/src/common.h metacity-resistance/src/common.h *** metacity/src/common.h 2004-06-21 12:47:27.000000000 -0400 --- metacity-resistance/src/common.h 2004-09-11 18:25:07.380908281 -0400 *************** *** 210,215 **** --- 210,222 ---- MetaButtonFunction right_buttons[MAX_BUTTONS_PER_CORNER]; }; + typedef enum + { + META_MOVE_ASSISTANCE_NONE, + META_MOVE_ASSISTANCE_RESISTANCE, + META_MOVE_ASSISTANCE_SNAP + } MetaMoveAssistance; + /* should investigate changing these to whatever most apps use */ #define META_ICON_WIDTH 32 #define META_ICON_HEIGHT 32 diff -dcr metacity/src/metacity.schemas.in metacity-resistance/src/metacity.schemas.in *** metacity/src/metacity.schemas.in 2004-07-22 19:27:51.000000000 -0400 --- metacity-resistance/src/metacity.schemas.in 2004-09-11 18:25:07.821878483 -0400 *************** *** 62,67 **** --- 62,95 ---- + /schemas/apps/metacity/general/move_assistance + /apps/metacity/general/move_assistance + metacity + string + none + + Window move assistance mode + + none/resistance/snap + + + + + + /schemas/apps/metacity/general/move_assistance + /apps/metacity/general/move_assistance + metacity + string + none + + Window move assistance mode + + none/resistance/snap + + + + + /schemas/apps/metacity/general/action_double_click_titlebar /apps/metacity/general/action_double_click_titlebar metacity diff -dcr metacity/src/prefs.c metacity-resistance/src/prefs.c *** metacity/src/prefs.c 2004-04-29 20:26:48.000000000 -0400 --- metacity-resistance/src/prefs.c 2004-09-11 18:27:12.580451132 -0400 *************** *** 52,57 **** --- 52,58 ---- #define KEY_DISABLE_WORKAROUNDS "/apps/metacity/general/disable_workarounds" #define KEY_BUTTON_LAYOUT "/apps/metacity/general/button_layout" #define KEY_REDUCED_RESOURCES "/apps/metacity/general/reduced_resources" + #define KEY_MOVE_ASSISTANCE "/apps/metacity/general/move_assistance" #define KEY_COMMAND_PREFIX "/apps/metacity/keybinding_commands/command_" #define KEY_SCREEN_BINDINGS_PREFIX "/apps/metacity/global_keybindings" *************** *** 101,106 **** --- 102,108 ---- META_BUTTON_FUNCTION_LAST } }; + static MetaMoveAssistance move_assistance = META_MOVE_ASSISTANCE_NONE; /* The screenshot commands are at the end */ static char *commands[MAX_COMMANDS] = { NULL, }; *************** *** 122,127 **** --- 124,130 ---- static gboolean update_auto_raise (gboolean value); static gboolean update_auto_raise_delay (int value); static gboolean update_button_layout (const char *value); + static gboolean update_move_assistance (const char *value); static gboolean update_window_binding (const char *name, const char *value); static gboolean update_screen_binding (const char *name, *************** *** 377,382 **** --- 380,392 ---- update_button_layout (str_val); g_free (str_val); + + str_val = gconf_client_get_string (default_client, KEY_MOVE_ASSISTANCE, + &err); + cleanup_error (&err); + update_move_assistance (str_val); + g_free (str_val); + bool_val = gconf_client_get_bool (default_client, KEY_VISUAL_BELL, &err); cleanup_error (&err); *************** *** 711,716 **** --- 721,742 ---- if (update_button_layout (str)) queue_changed (META_PREF_BUTTON_LAYOUT); } + else if (strcmp (key, KEY_MOVE_ASSISTANCE) == 0) + { + const char *str; + + if (value && value->type != GCONF_VALUE_STRING) + { + meta_warning (_("GConf key \"%s\" is set to an invalid type\n"), + KEY_MOVE_ASSISTANCE); + goto out; + } + + str = value ? gconf_value_get_string (value) : NULL; + + if (update_move_assistance (str)) + queue_changed (META_PREF_MOVE_ASSISTANCE); + } else if (strcmp (key, KEY_VISUAL_BELL) == 0) { gboolean b; *************** *** 1126,1131 **** --- 1152,1186 ---- } #endif /* HAVE_GCONF */ + #ifdef HAVE_GCONF + static gboolean + update_move_assistance (const char *value) + { + MetaMoveAssistance old_mode = move_assistance; + + if (value != NULL) + { + if (g_ascii_strcasecmp (value, "resistance") == 0) + move_assistance = META_MOVE_ASSISTANCE_RESISTANCE; + else if (g_ascii_strcasecmp (value, "snap") == 0) + move_assistance = META_MOVE_ASSISTANCE_SNAP; + else if (g_ascii_strcasecmp (value, "none") == 0) + move_assistance = META_MOVE_ASSISTANCE_NONE; + else + meta_warning (_("GConf key '%s' is set to an invalid value\n"), + KEY_MOVE_ASSISTANCE); + } + + return (old_mode != move_assistance); + } + #endif /* HAVE_GCONF */ + + MetaMoveAssistance + meta_prefs_get_move_assistance (void) + { + return move_assistance; + } + const PangoFontDescription* meta_prefs_get_titlebar_font (void) { *************** *** 1339,1344 **** --- 1394,1403 ---- return "BUTTON_LAYOUT"; break; + case META_PREF_MOVE_ASSISTANCE: + return "MOVE_ASSISTANCE"; + break; + case META_PREF_WORKSPACE_NAMES: return "WORKSPACE_NAMES"; break; diff -dcr metacity/src/prefs.h metacity-resistance/src/prefs.h *** metacity/src/prefs.h 2004-02-19 13:36:14.000000000 -0500 --- metacity-resistance/src/prefs.h 2004-09-11 18:27:29.380316761 -0400 *************** *** 46,52 **** META_PREF_VISUAL_BELL, META_PREF_AUDIBLE_BELL, META_PREF_VISUAL_BELL_TYPE, ! META_PREF_REDUCED_RESOURCES } MetaPreference; typedef void (* MetaPrefsChangedFunc) (MetaPreference pref, --- 46,53 ---- META_PREF_VISUAL_BELL, META_PREF_AUDIBLE_BELL, META_PREF_VISUAL_BELL_TYPE, ! META_PREF_REDUCED_RESOURCES, ! META_PREF_MOVE_ASSISTANCE } MetaPreference; typedef void (* MetaPrefsChangedFunc) (MetaPreference pref, *************** *** 77,82 **** --- 78,84 ---- char* meta_prefs_get_gconf_key_for_command (int i); void meta_prefs_get_button_layout (MetaButtonLayout *button_layout); + MetaMoveAssistance meta_prefs_get_move_assistance (void); MetaActionDoubleClickTitlebar meta_prefs_get_action_double_click_titlebar (void); void meta_prefs_set_num_workspaces (int n_workspaces); diff -dcr metacity/src/window.c metacity-resistance/src/window.c *** metacity/src/window.c 2004-08-30 00:56:07.000000000 -0400 --- metacity-resistance/src/window.c 2004-09-11 18:28:03.922984675 -0400 *************** *** 6130,6136 **** { int dx, dy; int new_x, new_y; ! int shake_threshold; window->display->grab_latest_motion_x = x; window->display->grab_latest_motion_y = y; --- 6130,6136 ---- { int dx, dy; int new_x, new_y; ! int drag_threshold, shake_threshold; window->display->grab_latest_motion_x = x; window->display->grab_latest_motion_y = y; *************** *** 6154,6161 **** */ #define DRAG_THRESHOLD_TO_SHAKE_THRESHOLD_FACTOR 6 ! shake_threshold = meta_ui_get_drag_threshold (window->screen->ui) * ! DRAG_THRESHOLD_TO_SHAKE_THRESHOLD_FACTOR; if (window->maximized && ABS (dy) >= shake_threshold) { --- 6154,6161 ---- */ #define DRAG_THRESHOLD_TO_SHAKE_THRESHOLD_FACTOR 6 ! drag_threshold = meta_ui_get_drag_threshold (window->screen->ui); ! shake_threshold = drag_threshold * DRAG_THRESHOLD_TO_SHAKE_THRESHOLD_FACTOR; if (window->maximized && ABS (dy) >= shake_threshold) { *************** *** 6269,6275 **** new_x = meta_window_find_nearest_vertical_edge (window, new_x); new_y = meta_window_find_nearest_horizontal_edge (window, new_y); } ! meta_window_move (window, TRUE, new_x, new_y); } } --- 6269,6320 ---- new_x = meta_window_find_nearest_vertical_edge (window, new_x); new_y = meta_window_find_nearest_horizontal_edge (window, new_y); } ! else ! { ! MetaMoveAssistance move_assist = meta_prefs_get_move_assistance (); ! if (move_assist != META_MOVE_ASSISTANCE_NONE) ! { ! # define DRAG_THRESHOLD_TO_SNAP_THRESHOLD_FACTOR 2 ! int snap_threshold = drag_threshold * ! DRAG_THRESHOLD_TO_SNAP_THRESHOLD_FACTOR; ! ! int nearest_x, nearest_y; ! nearest_x = meta_window_find_nearest_vertical_edge (window, new_x); ! nearest_y = meta_window_find_nearest_horizontal_edge (window, new_y); ! ! if (move_assist == META_MOVE_ASSISTANCE_RESISTANCE) ! { ! MetaRectangle old_rect; ! meta_window_get_position (window, &old_rect.x, &old_rect.y); ! ! if (nearest_x == old_rect.x && ! ABS (new_x - nearest_x) <= snap_threshold) ! { ! /* snaped and below threshold -- don't change x */ ! new_x = nearest_x; ! } ! if (nearest_y == old_rect.y && ! ABS (new_y - nearest_y) <= snap_threshold) ! { ! /* snaped and below threshold -- don't change y */ ! new_y = nearest_y; ! } ! } ! else if (move_assist == META_MOVE_ASSISTANCE_SNAP) ! { ! if (ABS (new_x - nearest_x) <= snap_threshold) ! { ! /* below threshold -- snap in */ ! new_x = nearest_x; ! } ! if (ABS (new_y - nearest_y) <= snap_threshold) ! { ! /* below threshold -- snap in */ ! new_y = nearest_y; ! } ! } ! } ! } meta_window_move (window, TRUE, new_x, new_y); } }