summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/display-private.h5
-rw-r--r--src/core/display.c40
-rw-r--r--src/core/edge-resistance.c18
-rw-r--r--src/core/keybindings.c8
-rw-r--r--src/core/place.c52
-rw-r--r--src/core/prefs.c16
-rw-r--r--src/core/screen-private.h3
-rw-r--r--src/core/window-private.h3
-rw-r--r--src/core/window.c25
-rw-r--r--src/core/workspace.c18
-rw-r--r--src/core/workspace.h3
-rw-r--r--src/core/xprops.c40
12 files changed, 184 insertions, 47 deletions
diff --git a/src/core/display-private.h b/src/core/display-private.h
index dc270a96..069e0ccf 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -276,8 +276,6 @@ struct _MetaDisplay {
#ifdef HAVE_COMPOSITE_EXTENSIONS
int composite_event_base;
int composite_error_base;
- int composite_major_version;
- int composite_minor_version;
int damage_event_base;
int damage_error_base;
int xfixes_event_base;
@@ -420,8 +418,7 @@ void meta_display_ungrab_focus_window_button (MetaDisplay *display,
MetaWindow *window);
/* Next two functions are defined in edge-resistance.c */
-void meta_display_compute_resistance_and_snapping_edges (MetaDisplay *display);
-void meta_display_cleanup_edges (MetaDisplay *display);
+void meta_display_cleanup_edges (MetaDisplay *display);
/* make a request to ensure the event serial has changed */
void meta_display_increment_event_serial (MetaDisplay *display);
diff --git a/src/core/display.c b/src/core/display.c
index 6a4831fb..caa76247 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -558,6 +558,9 @@ meta_display_open (void)
#ifdef HAVE_COMPOSITE_EXTENSIONS
{
+ int composite_major_version = 0;
+ int composite_minor_version = 0;
+
the_display->have_composite = FALSE;
the_display->composite_error_base = 0;
@@ -572,18 +575,16 @@ meta_display_open (void)
}
else
{
- the_display->composite_major_version = 0;
- the_display->composite_minor_version = 0;
if (XCompositeQueryVersion (the_display->xdisplay,
- &the_display->composite_major_version,
- &the_display->composite_minor_version))
+ &composite_major_version,
+ &composite_minor_version))
{
the_display->have_composite = TRUE;
}
else
{
- the_display->composite_major_version = 0;
- the_display->composite_minor_version = 0;
+ composite_major_version = 0;
+ composite_minor_version = 0;
}
}
@@ -591,8 +592,8 @@ meta_display_open (void)
"extn ver %d %d\n",
the_display->composite_error_base,
the_display->composite_event_base,
- the_display->composite_major_version,
- the_display->composite_minor_version);
+ composite_major_version,
+ composite_minor_version);
the_display->have_damage = FALSE;
@@ -3662,18 +3663,6 @@ meta_display_begin_grab_op (MetaDisplay *display,
g_assert (display->grab_window != NULL || display->grab_screen != NULL);
g_assert (display->grab_op != META_GRAB_OP_NONE);
- /* If this is a move or resize, cache the window edges for
- * resistance/snapping
- */
- if (meta_grab_op_is_resizing (display->grab_op) ||
- meta_grab_op_is_moving (display->grab_op))
- {
- meta_topic (META_DEBUG_WINDOW_OPS,
- "Computing edges to resist-movement or snap-to for %s.\n",
- window->desc);
- meta_display_compute_resistance_and_snapping_edges (display);
- }
-
/* Save the old stacking */
if (GRAB_OP_IS_WINDOW_SWITCH (display->grab_op))
{
@@ -5401,17 +5390,6 @@ meta_display_remove_autoraise_callback (MetaDisplay *display)
}
}
-#ifdef HAVE_COMPOSITE_EXTENSIONS
-void
-meta_display_get_compositor_version (MetaDisplay *display,
- int *major,
- int *minor)
-{
- *major = display->composite_major_version;
- *minor = display->composite_minor_version;
-}
-#endif
-
Display *
meta_display_get_xdisplay (MetaDisplay *display)
{
diff --git a/src/core/edge-resistance.c b/src/core/edge-resistance.c
index 51e77d54..aa4fcb6a 100644
--- a/src/core/edge-resistance.c
+++ b/src/core/edge-resistance.c
@@ -63,6 +63,8 @@ struct MetaEdgeResistanceData
ResistanceDataForAnEdge bottom_data;
};
+static void compute_resistance_and_snapping_edges (MetaDisplay *display);
+
/* !WARNING!: this function can return invalid indices (namely, either -1 or
* edges->len); this is by design, but you need to remember this.
*/
@@ -550,7 +552,9 @@ apply_edge_resistance_to_each_side (MetaDisplay *display,
gboolean modified;
int new_left, new_right, new_top, new_bottom;
- g_assert (display->grab_edge_resistance_data != NULL);
+ if (display->grab_edge_resistance_data == NULL)
+ compute_resistance_and_snapping_edges (display);
+
edge_data = display->grab_edge_resistance_data;
if (auto_snap)
@@ -671,7 +675,8 @@ meta_display_cleanup_edges (MetaDisplay *display)
MetaEdgeResistanceData *edge_data = display->grab_edge_resistance_data;
GHashTable *edges_to_be_freed;
- g_assert (edge_data != NULL);
+ if (edge_data == NULL) /* Not currently cached */
+ return;
/* We first need to clean out any window edges */
edges_to_be_freed = g_hash_table_new_full (g_direct_hash, g_direct_equal,
@@ -938,8 +943,8 @@ initialize_grab_edge_resistance_data (MetaDisplay *display)
edge_data->bottom_data.keyboard_buildup = 0;
}
-void
-meta_display_compute_resistance_and_snapping_edges (MetaDisplay *display)
+static void
+compute_resistance_and_snapping_edges (MetaDisplay *display)
{
GList *stacked_windows;
GList *cur_window_iter;
@@ -952,6 +957,11 @@ meta_display_compute_resistance_and_snapping_edges (MetaDisplay *display)
*/
GSList *rem_windows, *rem_win_stacking;
+ g_assert (display->grab_window != NULL);
+ meta_topic (META_DEBUG_WINDOW_OPS,
+ "Computing edges to resist-movement or snap-to for %s.\n",
+ display->grab_window->desc);
+
/*
* 1st: Get the list of relevant windows, from bottom to top
*/
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 9e602a91..068199b8 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -2288,6 +2288,14 @@ handle_switch_to_workspace (MetaDisplay *display,
{
gint which = binding->handler->data;
MetaWorkspace *workspace;
+
+ if (which == META_MOTION_PREV)
+ {
+ workspace = screen->prev_workspace;
+ if (workspace)
+ meta_workspace_activate (workspace, event->xkey.time);
+ return;
+ }
if (which < 0)
{
diff --git a/src/core/place.c b/src/core/place.c
index 99cedd14..bcfafe42 100644
--- a/src/core/place.c
+++ b/src/core/place.c
@@ -87,6 +87,47 @@ northwestcmp (gconstpointer a, gconstpointer b)
return 0;
}
+static gboolean
+place_by_pointer(MetaWindow *window,
+ MetaFrameGeometry *fgeom,
+ MetaPlacementMode placement_mode,
+ int *new_x,
+ int *new_y)
+{
+ int window_width, window_height;
+ Window root_return, child_return;
+ int root_x_return, root_y_return;
+ int win_x_return, win_y_return;
+ unsigned int mask_return;
+
+ XQueryPointer (window->display->xdisplay,
+ window->screen->xroot,
+ &root_return,
+ &child_return,
+ &root_x_return,
+ &root_y_return,
+ &win_x_return,
+ &win_y_return,
+ &mask_return);
+
+ window_width = window->frame ? window->frame->rect.width : window->rect.width;
+ window_height = window->frame ? window->frame->rect.height : window->rect.height;
+
+ if (fgeom) {
+ *new_x = root_x_return + fgeom->left_width - window_width / 2;
+ *new_y = root_y_return + fgeom->top_height - window_height / 2;
+ }
+ else {
+ *new_x = root_x_return - window_width / 2;
+ *new_y = root_y_return - window_height / 2;
+ }
+
+ if (placement_mode == META_PLACEMENT_MODE_MANUAL)
+ window->move_after_placement = TRUE;
+
+ return TRUE;
+}
+
static void
find_next_cascade (MetaWindow *window,
MetaFrameGeometry *fgeom,
@@ -663,6 +704,7 @@ meta_window_place (MetaWindow *window,
{
GList *windows;
const MetaXineramaScreenInfo *xi;
+ MetaPlacementMode placement_mode;
/* frame member variables should NEVER be used in here, only
* MetaFrameGeometry. But remember fgeom == NULL
@@ -853,6 +895,16 @@ meta_window_place (MetaWindow *window,
x = xi->rect.x;
y = xi->rect.y;
+ /* Placement based on pointer position */
+ placement_mode = meta_prefs_get_placement_mode();
+
+ if (placement_mode == META_PLACEMENT_MODE_POINTER ||
+ placement_mode == META_PLACEMENT_MODE_MANUAL)
+ {
+ if (place_by_pointer (window, fgeom, placement_mode, &x, &y))
+ goto done_check_denied_focus;
+ }
+
if (find_first_fit (window, fgeom, windows,
xi->number,
x, y, &x, &y))
diff --git a/src/core/prefs.c b/src/core/prefs.c
index 8fa28b83..2f3e9392 100644
--- a/src/core/prefs.c
+++ b/src/core/prefs.c
@@ -168,6 +168,8 @@ static void init_window_bindings (void);
static void init_commands (void);
static void init_workspace_names (void);
+static MetaPlacementMode placement_mode = META_PLACEMENT_MODE_AUTOMATIC;
+
typedef struct
{
MetaPrefsChangedFunc func;
@@ -317,6 +319,11 @@ static MetaEnumPreference preferences_enum[] =
META_PREF_ACTION_RIGHT_CLICK_TITLEBAR,
(gint *) &action_right_click_titlebar,
},
+ { "placement-mode",
+ KEY_GENERAL_SCHEMA,
+ META_PREF_PLACEMENT_MODE,
+ (gint *) &placement_mode,
+ },
{ NULL, NULL, 0, NULL },
};
@@ -1556,6 +1563,9 @@ meta_preference_to_string (MetaPreference pref)
case META_PREF_SIDE_BY_SIDE_TILING:
return "SIDE_BY_SIDE_TILING";
+
+ case META_PREF_PLACEMENT_MODE:
+ return "PLACEMENT_MODE";
}
return "(unknown)";
@@ -2241,6 +2251,12 @@ meta_prefs_get_force_fullscreen (void)
return force_fullscreen;
}
+MetaPlacementMode
+meta_prefs_get_placement_mode (void)
+{
+ return placement_mode;
+}
+
void
meta_prefs_set_force_compositing_manager (gboolean whether)
{
diff --git a/src/core/screen-private.h b/src/core/screen-private.h
index ee014ff2..c1552ab0 100644
--- a/src/core/screen-private.h
+++ b/src/core/screen-private.h
@@ -85,6 +85,9 @@ struct _MetaScreen
MetaWorkspace *active_workspace;
+ /* Previous active workspace */
+ MetaWorkspace *prev_workspace;
+
/* This window holds the focus when we don't want to focus
* any actual clients
*/
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 20e619cb..0b3cf594 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -139,6 +139,9 @@ struct _MetaWindow
guint maximize_vertically_after_placement : 1;
guint minimize_after_placement : 1;
+ /* Whether to move after placement */
+ guint move_after_placement : 1;
+
/* The current or requested tile mode. If maximized_vertically is true,
* this is the current mode. If not, it is the mode which will be
* requested after the window grab is released */
diff --git a/src/core/window.c b/src/core/window.c
index 9b2ad926..30ebfa85 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -461,6 +461,7 @@ meta_window_new_with_attrs (MetaDisplay *display,
window->maximize_horizontally_after_placement = FALSE;
window->maximize_vertically_after_placement = FALSE;
window->minimize_after_placement = FALSE;
+ window->move_after_placement = FALSE;
window->fullscreen = FALSE;
window->fullscreen_after_placement = FALSE;
window->fullscreen_monitors[0] = -1;
@@ -2346,6 +2347,13 @@ meta_window_show (MetaWindow *window)
if (takes_focus_on_map)
{
meta_window_focus (window, timestamp);
+
+ if (window->move_after_placement)
+ {
+ meta_window_begin_grab_op(window, META_GRAB_OP_KEYBOARD_MOVING,
+ FALSE, timestamp);
+ window->move_after_placement = FALSE;
+ }
}
else
{
@@ -5181,8 +5189,7 @@ meta_window_client_message (MetaWindow *window,
{
meta_verbose ("WM_CHANGE_STATE client message, state: %ld\n",
event->xclient.data.l[0]);
- if (event->xclient.data.l[0] == IconicState &&
- window->has_minimize_func)
+ if (event->xclient.data.l[0] == IconicState)
meta_window_minimize (window);
return TRUE;
@@ -5586,6 +5593,8 @@ static gboolean
process_property_notify (MetaWindow *window,
XPropertyEvent *event)
{
+ Window xid = window->xwindow;
+
if (meta_is_verbose ()) /* avoid looking up the name if we don't have to */
{
char *property_name = XGetAtomName (window->display->xdisplay,
@@ -5596,7 +5605,13 @@ process_property_notify (MetaWindow *window,
XFree (property_name);
}
- meta_window_reload_property (window, event->atom, FALSE);
+ if (event->atom == window->display->atom__NET_WM_USER_TIME &&
+ window->user_time_window)
+ {
+ xid = window->user_time_window;
+ }
+
+ meta_window_reload_property_from_xwindow (window, xid, event->atom, FALSE);
return TRUE;
}
@@ -6722,8 +6737,8 @@ meta_window_show_menu (MetaWindow *window,
if (!window->has_maximize_func)
insensitive |= META_MENU_OP_UNMAXIMIZE | META_MENU_OP_MAXIMIZE;
- /*if (!window->has_minimize_func)
- insensitive |= META_MENU_OP_MINIMIZE;*/
+ if (!window->has_minimize_func)
+ insensitive |= META_MENU_OP_MINIMIZE;
/*if (!window->has_close_func)
insensitive |= META_MENU_OP_DELETE;*/
diff --git a/src/core/workspace.c b/src/core/workspace.c
index b85ab53c..e2a397a0 100644
--- a/src/core/workspace.c
+++ b/src/core/workspace.c
@@ -382,9 +382,16 @@ meta_workspace_activate_with_focus (MetaWorkspace *workspace,
if (workspace->screen->active_workspace)
workspace_switch_sound(workspace->screen->active_workspace, workspace);
+ /* Free any cached pointers to the workspaces's edges from
+ * a current resize or move operation */
+ meta_display_cleanup_edges (workspace->screen->display);
+
/* Note that old can be NULL; e.g. when starting up */
old = workspace->screen->active_workspace;
+ /* Save old workspace, to be able to switch back. */
+ workspace->screen->prev_workspace = old;
+
workspace->screen->active_workspace = workspace;
set_active_space_hint (workspace->screen);
@@ -542,6 +549,11 @@ meta_workspace_invalidate_work_area (MetaWorkspace *workspace)
"Invalidating work area for workspace %d\n",
meta_workspace_index (workspace));
+ /* If we are in the middle of a resize or move operation, we
+ * might have cached pointers to the workspace's edges */
+ if (workspace == workspace->screen->active_workspace)
+ meta_display_cleanup_edges (workspace->screen->display);
+
g_free (workspace->work_area_xinerama);
workspace->work_area_xinerama = NULL;
@@ -798,6 +810,8 @@ meta_motion_direction_to_string (MetaMotionDirection direction)
return "Left";
case META_MOTION_RIGHT:
return "Right";
+ case META_MOTION_PREV:
+ return "Previous";
}
return "Unknown";
@@ -838,6 +852,8 @@ meta_workspace_get_neighbor (MetaWorkspace *workspace,
case META_MOTION_DOWN:
layout.current_row += 1;
break;
+ case META_MOTION_PREV:
+ break;
}
/* LEFT */
@@ -914,6 +930,8 @@ meta_workspace_get_neighbor (MetaWorkspace *workspace,
if (wrap == META_WRAP_TOROIDAL)
layout.current_col = layout.current_col < layout.cols - 1 ? layout.current_col + 1 : 0;
break;
+ case META_MOTION_PREV:
+ break;
}
i = layout.grid[layout.current_row * layout.cols + layout.current_col];
diff --git a/src/core/workspace.h b/src/core/workspace.h
index 40942e1a..4b52f96e 100644
--- a/src/core/workspace.h
+++ b/src/core/workspace.h
@@ -43,7 +43,8 @@ typedef enum
META_MOTION_UP = -1,
META_MOTION_DOWN = -2,
META_MOTION_LEFT = -3,
- META_MOTION_RIGHT = -4
+ META_MOTION_RIGHT = -4,
+ META_MOTION_PREV = -5
} MetaMotionDirection;
struct _MetaWorkspace
diff --git a/src/core/xprops.c b/src/core/xprops.c
index f9b4578a..a54e2185 100644
--- a/src/core/xprops.c
+++ b/src/core/xprops.c
@@ -264,6 +264,16 @@ cardinal_list_from_results (GetPropertyResults *results,
*n_cardinals_p = results->n_items;
results->prop = NULL;
+#if GLIB_SIZEOF_LONG == 8
+ /* Xlib sign-extends format=32 items, but we want them unsigned */
+ {
+ int i;
+
+ for (i = 0; i < *n_cardinals_p; i++)
+ (*cardinals_p)[i] = (*cardinals_p)[i] & 0xffffffff;
+ }
+#endif
+
return TRUE;
}
@@ -608,6 +618,10 @@ cardinal_with_atom_type_from_results (GetPropertyResults *results,
return FALSE;
*cardinal_p = *(gulong*) results->prop;
+#if GLIB_SIZEOF_LONG == 8
+ /* Xlib sign-extends format=32 items, but we want them unsigned */
+ *cardinal_p &= 0xffffffff;
+#endif
XFree (results->prop);
results->prop = NULL;
@@ -632,6 +646,29 @@ meta_prop_get_cardinal_with_atom_type (MetaDisplay *display,
return cardinal_with_atom_type_from_results (&results, prop_type, cardinal_p);
}
+static char *
+text_property_to_utf8 (Display *xdisplay,
+ const XTextProperty *prop)
+{
+ char *ret = NULL;
+ char **local_list = NULL;
+ int count = 0;
+ int res;
+
+ res = XmbTextPropertyToTextList (xdisplay, prop, &local_list, &count);
+ if (res == XNoMemory || res == XLocaleNotSupported || res == XConverterNotFound)
+ goto out;
+
+ if (count == 0)
+ goto out;
+
+ ret = g_strdup (local_list[0]);
+
+ out:
+ meta_XFree (local_list);
+ return ret;
+}
+
static gboolean
text_property_from_results (GetPropertyResults *results,
char **utf8_str_p)
@@ -646,8 +683,7 @@ text_property_from_results (GetPropertyResults *results,
tp.format = results->format;
tp.nitems = results->n_items;
- *utf8_str_p = meta_text_property_to_utf8 (results->display->xdisplay,
- &tp);
+ *utf8_str_p = text_property_to_utf8 (results->display->xdisplay, &tp);
if (tp.value != NULL)
XFree (tp.value);