summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-07-23 21:08:28 +0000
committerHavoc Pennington <hp@src.gnome.org>2003-07-23 21:08:28 +0000
commit80c33bd5cd4b7ae9600fe813e3b6a7fcaab175dc (patch)
tree2bc7e825d83b74bc03d0e34fb51e2f0f78a8d455
parentf58d9fcb9d98e298fd2da2ac3aba575a185127e3 (diff)
downloadmetacity-reduced-mode.tar.gz
no animation if we are in reduced resources modemetacity-reduced-mode
2003-07-23 Havoc Pennington <hp@redhat.com> * src/window.c (implement_showing): no animation if we are in reduced resources mode * src/prefs.c: add REDUCED_RESOURCES pref * src/window.c (meta_window_update_keyboard_resize): fix to modify grab_anchor_window_pos to grab_wireframe_rect if appropriate instead of window->rect * src/display.h (struct _MetaDisplay): add grab_start_serial used to avoid responding to events that occurred prior to the grab initialization.
-rw-r--r--ChangeLog15
-rw-r--r--src/display.c36
-rw-r--r--src/display.h2
-rw-r--r--src/keybindings.c116
-rw-r--r--src/metacity.schemas.in4
-rw-r--r--src/prefs.c47
-rw-r--r--src/prefs.h4
-rwxr-xr-xsrc/run-metacity.sh4
-rw-r--r--src/window.c32
9 files changed, 197 insertions, 63 deletions
diff --git a/ChangeLog b/ChangeLog
index 55046e7f..5f476bce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2003-07-23 Havoc Pennington <hp@redhat.com>
+
+ * src/window.c (implement_showing): no animation if we are
+ in reduced resources mode
+
+ * src/prefs.c: add REDUCED_RESOURCES pref
+
+ * src/window.c (meta_window_update_keyboard_resize): fix to
+ modify grab_anchor_window_pos to grab_wireframe_rect if
+ appropriate instead of window->rect
+
+ * src/display.h (struct _MetaDisplay): add grab_start_serial used
+ to avoid responding to events that occurred prior to the grab
+ initialization.
+
2003-07-20 Havoc Pennington <hp@pobox.com>
Still broken in various ways, specifically EnterNotify that
diff --git a/src/display.c b/src/display.c
index d6b0655f..2e21fb68 100644
--- a/src/display.c
+++ b/src/display.c
@@ -1229,6 +1229,7 @@ event_callback (XEvent *event,
if (display->grab_op != META_GRAB_OP_NONE &&
display->grab_window != NULL &&
+ event->xany.serial > display->grab_start_serial &&
grab_op_is_mouse (display->grab_op))
meta_window_handle_mouse_grab_op_event (display->grab_window, event);
}
@@ -1294,7 +1295,8 @@ event_callback (XEvent *event,
case ButtonPress:
if ((window &&
grab_op_is_mouse (display->grab_op) &&
- display->grab_button != (int) event->xbutton.button &&
+ display->grab_button != (int) event->xbutton.button &&
+ event->xany.serial > display->grab_start_serial &&
display->grab_window == window) ||
grab_op_is_keyboard (display->grab_op))
{
@@ -1444,16 +1446,19 @@ event_callback (XEvent *event,
break;
case ButtonRelease:
if (display->grab_window == window &&
+ event->xany.serial > display->grab_start_serial &&
grab_op_is_mouse (display->grab_op))
meta_window_handle_mouse_grab_op_event (window, event);
break;
case MotionNotify:
if (display->grab_window == window &&
+ event->xany.serial > display->grab_start_serial &&
grab_op_is_mouse (display->grab_op))
meta_window_handle_mouse_grab_op_event (window, event);
break;
case EnterNotify:
if (display->grab_window == window &&
+ event->xany.serial > display->grab_start_serial &&
grab_op_is_mouse (display->grab_op))
meta_window_handle_mouse_grab_op_event (window, event);
/* do this even if window->has_focus to avoid races */
@@ -1517,6 +1522,7 @@ event_callback (XEvent *event,
break;
case LeaveNotify:
if (display->grab_window == window &&
+ event->xany.serial > display->grab_start_serial &&
grab_op_is_mouse (display->grab_op))
meta_window_handle_mouse_grab_op_event (window, event);
else if (window != NULL)
@@ -2793,6 +2799,9 @@ meta_display_begin_grab_op (MetaDisplay *display,
return FALSE;
}
+ /* We'll ignore any events < this serial. */
+ display->grab_start_serial = XNextRequest (display->xdisplay);
+
/* FIXME:
* If we have no MetaWindow we do our best
* and try to do the grab on the RootWindow.
@@ -2806,7 +2815,7 @@ meta_display_begin_grab_op (MetaDisplay *display,
if (pointer_already_grabbed)
display->grab_have_pointer = TRUE;
-
+
meta_display_set_grab_op_cursor (display, screen, op, FALSE, grab_xwindow,
timestamp);
@@ -2853,6 +2862,7 @@ meta_display_begin_grab_op (MetaDisplay *display,
#ifdef HAVE_XSYNC
display->grab_update_alarm = None;
#endif
+ display->grab_was_cancelled = FALSE;
if (display->grab_window)
{
@@ -2862,13 +2872,10 @@ meta_display_begin_grab_op (MetaDisplay *display,
&display->grab_initial_window_pos.y);
display->grab_anchor_window_pos = display->grab_initial_window_pos;
-#if 0
display->grab_wireframe_active =
- meta_grab_op_is_resizing (display->grab_op) ||
- meta_grab_op_is_moving (display->grab_op);
-#else
- display->grab_wireframe_active = FALSE;
-#endif
+ meta_prefs_get_reduced_resources () &&
+ (meta_grab_op_is_resizing (display->grab_op) ||
+ meta_grab_op_is_moving (display->grab_op));
if (display->grab_wireframe_active)
{
@@ -3026,12 +3033,13 @@ meta_display_end_grab_op (MetaDisplay *display,
display->grab_wireframe_active = FALSE;
meta_effects_end_wireframe (display->grab_window->screen,
&display->grab_wireframe_rect);
- meta_window_move_resize (display->grab_window,
- TRUE,
- display->grab_wireframe_rect.x,
- display->grab_wireframe_rect.y,
- display->grab_wireframe_rect.width,
- display->grab_wireframe_rect.height);
+ if (!display->grab_was_cancelled)
+ meta_window_move_resize (display->grab_window,
+ TRUE,
+ display->grab_wireframe_rect.x,
+ display->grab_wireframe_rect.y,
+ display->grab_wireframe_rect.width,
+ display->grab_wireframe_rect.height);
meta_window_calc_showing (display->grab_window);
}
diff --git a/src/display.h b/src/display.h
index b2b2280f..dcf55f9e 100644
--- a/src/display.h
+++ b/src/display.h
@@ -230,6 +230,7 @@ struct _MetaDisplay
MetaScreen *grab_screen;
MetaWindow *grab_window;
Window grab_xwindow;
+ gulong grab_start_serial;
int grab_button;
int grab_anchor_root_x;
int grab_anchor_root_y;
@@ -240,6 +241,7 @@ struct _MetaDisplay
guint grab_have_pointer : 1;
guint grab_have_keyboard : 1;
guint grab_wireframe_active : 1;
+ guint grab_was_cancelled : 1;
MetaRectangle grab_wireframe_rect;
MetaRectangle grab_initial_window_pos;
MetaResizePopup *grab_resize_popup;
diff --git a/src/keybindings.c b/src/keybindings.c
index b59d9878..d70196b0 100644
--- a/src/keybindings.c
+++ b/src/keybindings.c
@@ -1722,13 +1722,18 @@ process_keyboard_move_grab (MetaDisplay *display,
if (keysym == XK_Escape)
{
- /* End move and restore to original position */
+ /* End resize and restore to original state.
+ * The move_resize is only needed when !wireframe
+ * since in wireframe we always moveresize at the end
+ * of the grab only.
+ */
meta_window_move_resize (display->grab_window,
TRUE,
display->grab_initial_window_pos.x,
display->grab_initial_window_pos.y,
display->grab_initial_window_pos.width,
display->grab_initial_window_pos.height);
+ display->grab_was_cancelled = TRUE;
}
/* When moving by increments, we still snap to edges if the move
@@ -1862,13 +1867,18 @@ process_keyboard_resize_grab (MetaDisplay *display,
if (keysym == XK_Escape)
{
- /* End resize and restore to original state */
+ /* End resize and restore to original state.
+ * The move_resize is only needed when !wireframe
+ * since in wireframe we always moveresize at the end
+ * of the grab only.
+ */
meta_window_move_resize (display->grab_window,
TRUE,
display->grab_initial_window_pos.x,
display->grab_initial_window_pos.y,
display->grab_initial_window_pos.width,
display->grab_initial_window_pos.height);
+ display->grab_was_cancelled = TRUE;
return FALSE;
}
@@ -1980,12 +1990,14 @@ process_keyboard_resize_grab (MetaDisplay *display,
{
meta_window_update_keyboard_resize (window, TRUE);
return TRUE;
- }
+ }
if (display->grab_wireframe_active)
{
x = display->grab_wireframe_rect.x;
y = display->grab_wireframe_rect.y;
+ orig_x = x;
+ orig_y = y;
width = display->grab_wireframe_rect.width;
height = display->grab_wireframe_rect.height;
}
@@ -2057,12 +2069,16 @@ process_keyboard_resize_grab (MetaDisplay *display,
case NorthWestGravity:
case NorthEastGravity:
/* Move bottom edge up */
- edge = meta_window_find_next_horizontal_edge (window, TRUE);
height -= height_inc;
- if (smart_snap || ((edge > (y+height)) &&
- ABS (edge - (y+height)) < height_inc))
- height = edge - y;
+ if (!display->grab_wireframe_active)
+ {
+ edge = meta_window_find_next_horizontal_edge (window, TRUE);
+
+ if (smart_snap || ((edge > (y+height)) &&
+ ABS (edge - (y+height)) < height_inc))
+ height = edge - y;
+ }
handled = TRUE;
break;
@@ -2071,11 +2087,15 @@ process_keyboard_resize_grab (MetaDisplay *display,
case SouthWestGravity:
case SouthEastGravity:
/* Move top edge up */
- edge = meta_window_find_next_horizontal_edge (window, FALSE);
y -= height_inc;
-
- if (smart_snap || ((edge > y) && ABS (edge - y) < height_inc))
- y = edge;
+
+ if (!display->grab_wireframe_active)
+ {
+ edge = meta_window_find_next_horizontal_edge (window, FALSE);
+
+ if (smart_snap || ((edge > y) && ABS (edge - y) < height_inc))
+ y = edge;
+ }
height += (orig_y - y);
break;
@@ -2098,12 +2118,16 @@ process_keyboard_resize_grab (MetaDisplay *display,
case NorthWestGravity:
case NorthEastGravity:
/* Move bottom edge down */
- edge = meta_window_find_next_horizontal_edge (window, TRUE);
height += height_inc;
-
- if (smart_snap || ((edge < (y+height)) &&
- ABS (edge - (y+height)) < height_inc))
- height = edge - y;
+
+ if (!display->grab_wireframe_active)
+ {
+ edge = meta_window_find_next_horizontal_edge (window, TRUE);
+
+ if (smart_snap || ((edge < (y+height)) &&
+ ABS (edge - (y+height)) < height_inc))
+ height = edge - y;
+ }
handled = TRUE;
break;
@@ -2112,11 +2136,15 @@ process_keyboard_resize_grab (MetaDisplay *display,
case SouthWestGravity:
case SouthEastGravity:
/* Move top edge down */
- edge = meta_window_find_next_horizontal_edge (window, FALSE);
y += height_inc;
-
- if (smart_snap || ((edge < y) && ABS (edge - y) < height_inc))
- y = edge;
+
+ if (!display->grab_wireframe_active)
+ {
+ edge = meta_window_find_next_horizontal_edge (window, FALSE);
+
+ if (smart_snap || ((edge < y) && ABS (edge - y) < height_inc))
+ y = edge;
+ }
height -= (y - orig_y);
break;
@@ -2139,11 +2167,15 @@ process_keyboard_resize_grab (MetaDisplay *display,
case SouthEastGravity:
case NorthEastGravity:
/* Move left edge left */
- edge = meta_window_find_next_vertical_edge (window, TRUE);
x -= width_inc;
- if (smart_snap || ((edge > x) && ABS (edge - x) < width_inc))
- x = edge;
+ if (!display->grab_wireframe_active)
+ {
+ edge = meta_window_find_next_vertical_edge (window, TRUE);
+
+ if (smart_snap || ((edge > x) && ABS (edge - x) < width_inc))
+ x = edge;
+ }
width += (orig_x - x);
break;
@@ -2152,12 +2184,16 @@ process_keyboard_resize_grab (MetaDisplay *display,
case SouthWestGravity:
case NorthWestGravity:
/* Move right edge left */
- edge = meta_window_find_next_vertical_edge (window, FALSE);
width -= width_inc;
- if (smart_snap || ((edge > (x+width)) &&
- ABS (edge - (x+width)) < width_inc))
- width = edge - x;
+ if (!display->grab_wireframe_active)
+ {
+ edge = meta_window_find_next_vertical_edge (window, FALSE);
+
+ if (smart_snap || ((edge > (x+width)) &&
+ ABS (edge - (x+width)) < width_inc))
+ width = edge - x;
+ }
handled = TRUE;
break;
@@ -2180,11 +2216,15 @@ process_keyboard_resize_grab (MetaDisplay *display,
case SouthEastGravity:
case NorthEastGravity:
/* Move left edge right */
- edge = meta_window_find_next_vertical_edge (window, FALSE);
x += width_inc;
-
- if (smart_snap || ((edge < x) && ABS (edge - x) < width_inc))
- x = edge;
+
+ if (!display->grab_wireframe_active)
+ {
+ edge = meta_window_find_next_vertical_edge (window, FALSE);
+
+ if (smart_snap || ((edge < x) && ABS (edge - x) < width_inc))
+ x = edge;
+ }
width -= (x - orig_x);
break;
@@ -2193,12 +2233,16 @@ process_keyboard_resize_grab (MetaDisplay *display,
case SouthWestGravity:
case NorthWestGravity:
/* Move right edge right */
- edge = meta_window_find_next_vertical_edge (window, TRUE);
width += width_inc;
-
- if (smart_snap || ((edge > (x+width)) &&
- ABS (edge - (x+width)) < width_inc))
- width = edge - x;
+
+ if (!display->grab_wireframe_active)
+ {
+ edge = meta_window_find_next_vertical_edge (window, TRUE);
+
+ if (smart_snap || ((edge > (x+width)) &&
+ ABS (edge - (x+width)) < width_inc))
+ width = edge - x;
+ }
handled = TRUE;
break;
diff --git a/src/metacity.schemas.in b/src/metacity.schemas.in
index 8196deae..5cf9f103 100644
--- a/src/metacity.schemas.in
+++ b/src/metacity.schemas.in
@@ -258,8 +258,8 @@
</schema>
<schema>
- <key>/schemas/apps/metacity/general/reduced_resource_usage</key>
- <applyto>/apps/metacity/general/reduced_resource_usage</applyto>
+ <key>/schemas/apps/metacity/general/reduced_resources</key>
+ <applyto>/apps/metacity/general/reduced_resources</applyto>
<owner>metacity</owner>
<type>bool</type>
<default>false</default>
diff --git a/src/prefs.c b/src/prefs.c
index 9ed41bcd..81af51e3 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -51,6 +51,7 @@
#define KEY_APPLICATION_BASED "/apps/metacity/general/application_based"
#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_COMMAND_PREFIX "/apps/metacity/keybinding_commands/command_"
#define KEY_SCREEN_BINDINGS_PREFIX "/apps/metacity/global_keybindings"
@@ -83,6 +84,8 @@ static gboolean auto_raise = FALSE;
static gboolean auto_raise_delay = 500;
static gboolean provide_visual_bell = TRUE;
static gboolean bell_is_audible = TRUE;
+static gboolean reduced_resources = FALSE;
+
static MetaVisualBellType visual_bell_type = META_VISUAL_BELL_INVALID;
static MetaButtonLayout button_layout = {
{
@@ -129,6 +132,7 @@ static gboolean update_command (const char *name,
const char *value);
static gboolean update_workspace_name (const char *name,
const char *value);
+static gboolean update_reduced_resources (gboolean value);
static void change_notify (GConfClient *client,
guint cnxn_id,
@@ -372,7 +376,6 @@ meta_prefs_init (void)
cleanup_error (&err);
update_button_layout (str_val);
g_free (str_val);
-#endif /* HAVE_GCONF */
bool_val = gconf_client_get_bool (default_client, KEY_VISUAL_BELL,
&err);
@@ -388,6 +391,12 @@ meta_prefs_init (void)
update_visual_bell_type (str_val);
g_free (str_val);
+ bool_val = gconf_client_get_bool (default_client, KEY_REDUCED_RESOURCES,
+ &err);
+ cleanup_error (&err);
+ update_reduced_resources (bool_val);
+#endif /* HAVE_GCONF */
+
/* Load keybindings prefs */
init_bindings ();
@@ -733,6 +742,22 @@ change_notify (GConfClient *client,
if (update_visual_bell_type (str))
queue_changed (META_PREF_VISUAL_BELL_TYPE);
}
+ else if (strcmp (key, KEY_REDUCED_RESOURCES) == 0)
+ {
+ gboolean b;
+
+ if (value && value->type != GCONF_VALUE_BOOL)
+ {
+ meta_warning (_("GConf key \"%s\" is set to an invalid type\n"),
+ KEY_REDUCED_RESOURCES);
+ goto out;
+ }
+
+ b = value ? gconf_value_get_bool (value) : reduced_resources;
+
+ if (update_reduced_resources (b))
+ queue_changed (META_PREF_REDUCED_RESOURCES);
+ }
else
{
meta_topic (META_DEBUG_PREFS, "Key %s doesn't mean anything to Metacity\n",
@@ -1239,6 +1264,16 @@ update_auto_raise_delay (int value)
return old != auto_raise_delay;
}
+
+static gboolean
+update_reduced_resources (gboolean value)
+{
+ gboolean old = reduced_resources;
+
+ reduced_resources = value;
+
+ return old != reduced_resources;
+}
#endif /* HAVE_GCONF */
#ifdef WITH_VERBOSE_MODE
@@ -1305,6 +1340,10 @@ meta_preference_to_string (MetaPreference pref)
case META_PREF_VISUAL_BELL_TYPE:
return "VISUAL_BELL_TYPE";
break;
+
+ case META_PREF_REDUCED_RESOURCES:
+ return "REDUCED_RESOURCES";
+ break;
}
return "(unknown)";
@@ -1974,6 +2013,12 @@ meta_prefs_get_auto_raise_delay ()
return auto_raise_delay;
}
+gboolean
+meta_prefs_get_reduced_resources ()
+{
+ return reduced_resources;
+}
+
MetaKeyBindingAction
meta_prefs_get_keybinding_action (const char *name)
{
diff --git a/src/prefs.h b/src/prefs.h
index 18a20df3..c0a0bc66 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -45,7 +45,8 @@ typedef enum
META_PREF_WORKSPACE_NAMES,
META_PREF_VISUAL_BELL,
META_PREF_AUDIBLE_BELL,
- META_PREF_VISUAL_BELL_TYPE
+ META_PREF_VISUAL_BELL_TYPE,
+ META_PREF_REDUCED_RESOURCES
} MetaPreference;
typedef void (* MetaPrefsChangedFunc) (MetaPreference pref,
@@ -69,6 +70,7 @@ gboolean meta_prefs_get_application_based (void);
gboolean meta_prefs_get_disable_workarounds (void);
gboolean meta_prefs_get_auto_raise (void);
int meta_prefs_get_auto_raise_delay (void);
+gboolean meta_prefs_get_reduced_resources (void);
const char* meta_prefs_get_command (int i);
diff --git a/src/run-metacity.sh b/src/run-metacity.sh
index 98ccbf74..e0d9265a 100755
--- a/src/run-metacity.sh
+++ b/src/run-metacity.sh
@@ -1,11 +1,11 @@
#! /bin/bash
if test -z "$XNEST_DISPLAY"; then
- XNEST_DISPLAY=:1
+ XNEST_DISPLAY=:8
fi
if test -z "$CLIENT_DISPLAY"; then
- CLIENT_DISPLAY=:1
+ CLIENT_DISPLAY=:8
fi
if test -z "$METACITY_DISPLAY"; then
diff --git a/src/window.c b/src/window.c
index 5b537491..01dc12d5 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1245,7 +1245,8 @@ implement_showing (MetaWindow *window,
* if we are mapped now, we are supposed to
* be minimized, and we are on the current workspace.
*/
- if (on_workspace && window->minimized && window->mapped)
+ if (on_workspace && window->minimized && window->mapped &&
+ !meta_prefs_get_reduced_resources ())
{
MetaRectangle icon_rect, window_rect;
gboolean result;
@@ -5596,7 +5597,7 @@ check_moveresize_frequency (MetaWindow *window)
window->display->grab_last_moveresize_time = current_time;
meta_topic (META_DEBUG_RESIZING,
- " Doing move/resize now (%g of %g seconds elapsed)\n",
+ " Checked moveresize freq, allowing move/resize now (%g of %g seconds elapsed)\n",
elapsed / 1000.0, 1.0 / max_resizes_per_second);
return TRUE;
@@ -6561,7 +6562,10 @@ meta_window_begin_grab_op (MetaWindow *window,
Time timestamp)
{
int x, y;
+ gulong grab_start_serial;
+ grab_start_serial = XNextRequest (window->display->xdisplay);
+
meta_window_raise (window);
warp_grab_pointer (window,
@@ -6574,6 +6578,11 @@ meta_window_begin_grab_op (MetaWindow *window,
FALSE, 0, 0,
timestamp,
x, y);
+
+ /* We override the one set in display_begin_grab_op since we
+ * did additional stuff as part of the grabbing process
+ */
+ window->display->grab_start_serial = grab_start_serial;
}
void
@@ -6589,7 +6598,8 @@ meta_window_update_keyboard_resize (MetaWindow *window,
{
/* As we warped the pointer, we have to reset the anchor state,
* since if the mouse moves we want to use those events to do the
- * right thing.
+ * right thing. Also, this means that the motion notify
+ * from the pointer warp comes back as a no-op.
*/
int dx, dy;
@@ -6598,10 +6608,18 @@ meta_window_update_keyboard_resize (MetaWindow *window,
window->display->grab_anchor_root_x += dx;
window->display->grab_anchor_root_y += dy;
- window->display->grab_anchor_window_pos = window->rect;
- meta_window_get_position (window,
- &window->display->grab_anchor_window_pos.x,
- &window->display->grab_anchor_window_pos.y);
+ if (window->display->grab_wireframe_active)
+ {
+ window->display->grab_anchor_window_pos =
+ window->display->grab_wireframe_rect;
+ }
+ else
+ {
+ window->display->grab_anchor_window_pos = window->rect;
+ meta_window_get_position (window,
+ &window->display->grab_anchor_window_pos.x,
+ &window->display->grab_anchor_window_pos.y);
+ }
}
if (update_cursor)