summaryrefslogtreecommitdiff
path: root/src/core/keybindings.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/keybindings.c')
-rw-r--r--src/core/keybindings.c59
1 files changed, 36 insertions, 23 deletions
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index fb3131c2..45be2353 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -2447,19 +2447,6 @@ error_on_command (int command_index,
}
}
-static void
-set_display_setup_func (void *data)
-{
- const char *screen_name = data;
- char *full;
-
- full = g_strdup_printf ("DISPLAY=%s", screen_name);
-
- putenv (full);
-
- /* do not free full, because putenv is lame */
-}
-
static gboolean
meta_spawn_command_line_async_on_screen (const gchar *command_line,
MetaScreen *screen,
@@ -2467,6 +2454,7 @@ meta_spawn_command_line_async_on_screen (const gchar *command_line,
{
gboolean retval;
gchar **argv = NULL;
+ gchar **envp = NULL;
g_return_val_if_fail (command_line != NULL, FALSE);
@@ -2475,15 +2463,20 @@ meta_spawn_command_line_async_on_screen (const gchar *command_line,
error))
return FALSE;
+ envp = g_get_environ();
+ envp = g_environ_setenv(envp, "DISPLAY", screen->screen_name, TRUE);
+
retval = g_spawn_async (NULL,
argv,
- NULL,
+ envp,
G_SPAWN_SEARCH_PATH,
- set_display_setup_func,
- screen->screen_name,
+ NULL,
+ NULL,
NULL,
error);
+
g_strfreev (argv);
+ g_strfreev (envp);
return retval;
}
@@ -2517,6 +2510,15 @@ handle_run_command (MetaDisplay *display,
return;
}
+ /* Release keyboard grabs immediately for screenshot commands that may need
+ * input grabbing. This prevents race conditions with applications like
+ * mate-screenshot that need to grab input for area selection.
+ */
+ if (which >= SCREENSHOT_COMMAND_IDX && which <= AREA_SCREENSHOT_COMMAND_IDX)
+ {
+ ungrab_keyboard (display, event->xkey.time);
+ }
+
err = NULL;
if (!meta_spawn_command_line_async_on_screen (command, screen, &err))
{
@@ -2703,23 +2705,34 @@ handle_move_to_center (MetaDisplay *display,
const MetaXineramaScreenInfo* current;
MetaRectangle work_area;
MetaRectangle outer;
- int orig_x, orig_y;
- int frame_width, frame_height;
+ MetaFrameBorders borders;
+ int client_x, client_y;
current = meta_screen_get_xinerama_for_window(screen, window);
meta_window_get_work_area_for_xinerama (window,
current->number,
&work_area);
meta_window_get_outer_rect (window, &outer);
- meta_window_get_position (window, &orig_x, &orig_y);
- frame_width = (window->frame ? window->frame->child_x : 0);
- frame_height = (window->frame ? window->frame->child_y : 0);
+ center_rect_in_area (&outer, &work_area);
+
+ /* Convert frame position to client position */
+ if (window->frame)
+ {
+ meta_frame_calc_borders (window->frame, &borders);
+ client_x = outer.x + borders.visible.left;
+ client_y = outer.y + borders.visible.top;
+ }
+ else
+ {
+ client_x = outer.x;
+ client_y = outer.y;
+ }
meta_window_move_resize (window,
TRUE,
- work_area.x + (work_area.width +frame_width -outer.width )/2,
- work_area.y + (work_area.height+frame_height-outer.height)/2,
+ client_x,
+ client_y,
window->rect.width,
window->rect.height);
}