summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/50-marco-window-key.xml.in8
-rw-r--r--src/core/keybindings.c40
-rw-r--r--src/core/prefs.c61
-rw-r--r--src/core/screen-private.h1
-rw-r--r--src/core/screen.c31
-rw-r--r--src/core/window.c19
-rw-r--r--src/include/all-keybindings.h5
-rw-r--r--src/include/screen.h1
-rw-r--r--src/include/tile-preview.h9
-rw-r--r--src/marco.convert2
-rw-r--r--src/org.mate.marco.gschema.xml10
-rw-r--r--src/ui/preview-widget.c4
-rw-r--r--src/ui/tile-preview.c34
13 files changed, 127 insertions, 98 deletions
diff --git a/src/50-marco-window-key.xml.in b/src/50-marco-window-key.xml.in
index 2dcfabc3..0b3ecef4 100644
--- a/src/50-marco-window-key.xml.in
+++ b/src/50-marco-window-key.xml.in
@@ -70,6 +70,14 @@
_description="Maximize window horizontally" />
<KeyListEntry
+ name="tile-to-side-e"
+ _description="Tile window to east (right) side of screen" />
+
+ <KeyListEntry
+ name="tile-to-side-w"
+ _description="Tile window to west (left) side of screen" />
+
+ <KeyListEntry
name="move-to-corner-nw"
_description="Move window to north-west (top left) corner" />
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 041d96fc..9e602a91 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -2321,7 +2321,7 @@ static void
error_on_command (int command_index,
const char *command,
const char *message,
- int screen_number,
+ const char *screen_name,
guint32 timestamp)
{
if (command_index < 0)
@@ -2350,7 +2350,7 @@ error_on_command (int command_index,
meta_show_dialog ("--error",
text,
NULL,
- screen_number,
+ screen_name,
NULL, NULL, 0,
NULL, NULL);
@@ -2362,7 +2362,7 @@ error_on_command (int command_index,
meta_show_dialog ("--error",
message,
NULL,
- screen_number,
+ screen_name,
NULL, NULL, 0,
NULL, NULL);
}
@@ -2433,7 +2433,7 @@ handle_run_command (MetaDisplay *display,
s = g_strdup_printf (_("No command %d has been defined.\n"),
which + 1);
- error_on_command (which, NULL, s, screen->number, event->xkey.time);
+ error_on_command (which, NULL, s, screen->screen_name, event->xkey.time);
g_free (s);
return;
@@ -2442,7 +2442,7 @@ handle_run_command (MetaDisplay *display,
err = NULL;
if (!meta_spawn_command_line_async_on_screen (command, screen, &err))
{
- error_on_command (which, command, err->message, screen->number, event->xkey.time);
+ error_on_command (which, command, err->message, screen->screen_name, event->xkey.time);
g_error_free (err);
}
@@ -3050,7 +3050,6 @@ handle_toggle_above (MetaDisplay *display,
meta_window_make_above (window);
}
-/* TODO: actually use this keybinding, without messing up the existing keybinding schema */
static void
handle_toggle_tiled (MetaDisplay *display,
MetaScreen *screen,
@@ -3063,14 +3062,20 @@ handle_toggle_tiled (MetaDisplay *display,
if ((META_WINDOW_TILED_LEFT (window) && mode == META_TILE_LEFT) ||
(META_WINDOW_TILED_RIGHT (window) && mode == META_TILE_RIGHT))
{
- window->tile_mode = META_TILE_NONE;
-
if (window->saved_maximize)
- meta_window_maximize (window, META_MAXIMIZE_VERTICAL |
- META_MAXIMIZE_HORIZONTAL);
- else
- meta_window_unmaximize (window, META_MAXIMIZE_VERTICAL |
+ {
+ window->tile_mode = META_TILE_MAXIMIZED;
+ window->tile_monitor_number = meta_screen_get_xinerama_for_window (window->screen, window)->number;
+ meta_window_maximize (window, META_MAXIMIZE_VERTICAL |
META_MAXIMIZE_HORIZONTAL);
+ }
+ else
+ {
+ window->tile_mode = META_TILE_NONE;
+ window->tile_monitor_number = -1;
+ meta_window_unmaximize (window, META_MAXIMIZE_VERTICAL |
+ META_MAXIMIZE_HORIZONTAL);
+ }
}
else if (meta_window_can_tile (window))
{
@@ -3082,6 +3087,13 @@ handle_toggle_tiled (MetaDisplay *display,
* we just set the flag and rely on meta_window_tile() syncing it to
* save an additional roundtrip.
*/
+
+ /* If we skip meta_window_unmaximize we have to manually reset the
+ * window->saved_maximize flag.
+ */
+ if (!META_WINDOW_MAXIMIZED (window))
+ window->saved_maximize = FALSE;
+
window->maximized_horizontally = FALSE;
meta_window_tile (window);
}
@@ -3431,7 +3443,7 @@ handle_run_terminal (MetaDisplay *display,
"keybinding press\n");
s = g_strdup_printf (_("No terminal command has been defined.\n"));
- error_on_command (-1, NULL, s, screen->number, event->xkey.time);
+ error_on_command (-1, NULL, s, screen->screen_name, event->xkey.time);
g_free (s);
return;
@@ -3440,7 +3452,7 @@ handle_run_terminal (MetaDisplay *display,
err = NULL;
if (!meta_spawn_command_line_async_on_screen (command, screen, &err))
{
- error_on_command (-1, command, err->message, screen->number,
+ error_on_command (-1, command, err->message, screen->screen_name,
event->xkey.time);
g_error_free (err);
diff --git a/src/core/prefs.c b/src/core/prefs.c
index 8847614e..8fa28b83 100644
--- a/src/core/prefs.c
+++ b/src/core/prefs.c
@@ -162,7 +162,9 @@ static void button_layout_handler (MetaPreference, const gchar*, gboolean*);
static gboolean update_binding (MetaKeyPref *binding,
gchar *value);
-static void init_bindings (void);
+static void init_bindings (GSettings *);
+static void init_screen_bindings (void);
+static void init_window_bindings (void);
static void init_commands (void);
static void init_workspace_names (void);
@@ -890,13 +892,6 @@ meta_prefs_init (void)
g_hash_table_insert (settings_schemas, KEY_MATE_TERMINAL_SCHEMA, settings_mate_terminal);
g_hash_table_insert (settings_schemas, KEY_MATE_MOUSE_SCHEMA, settings_mate_mouse);
- /* Pick up initial values. */
-
- handle_preference_init_enum ();
- handle_preference_init_bool ();
- handle_preference_init_string ();
- handle_preference_init_int ();
-
g_signal_connect (settings_general, "changed", G_CALLBACK (change_notify), NULL);
g_signal_connect (settings_command, "changed", G_CALLBACK (change_notify), NULL);
g_signal_connect (settings_screen_bindings, "changed", G_CALLBACK (change_notify), NULL);
@@ -909,7 +904,15 @@ meta_prefs_init (void)
g_signal_connect (settings_mate_mouse, "changed::" KEY_MATE_MOUSE_CURSOR_THEME, G_CALLBACK (change_notify), NULL);
g_signal_connect (settings_mate_mouse, "changed::" KEY_MATE_MOUSE_CURSOR_SIZE, G_CALLBACK (change_notify), NULL);
- init_bindings ();
+ /* Pick up initial values. */
+
+ handle_preference_init_enum ();
+ handle_preference_init_bool ();
+ handle_preference_init_string ();
+ handle_preference_init_int ();
+
+ init_screen_bindings ();
+ init_window_bindings ();
init_commands ();
init_workspace_names ();
}
@@ -972,7 +975,7 @@ change_notify (GSettings *settings,
g_free(str);
}
- else if (g_strcmp0 (schema_name, KEY_WORKSPACE_NAME_SCHEMA))
+ else if (g_strcmp0 (schema_name, KEY_WORKSPACE_NAME_SCHEMA) == 0)
{
gchar *str;
str = g_settings_get_string (settings, key);
@@ -1582,32 +1585,32 @@ static MetaKeyPref key_bindings[] = {
#undef keybind
static void
-init_bindings (void)
+init_bindings (GSettings *settings)
{
- const char *prefix[] = {
- KEY_WINDOW_BINDINGS_SCHEMA,
- KEY_SCREEN_BINDINGS_SCHEMA,
- NULL
- };
- int i;
gchar **list = NULL;
gchar *str_val = NULL;
- GSettings *bindings_settings = NULL;
- for (i = 0; prefix[i]; i++)
+ list = g_settings_list_keys (settings);
+ while (*list != NULL)
{
- bindings_settings = g_settings_new (prefix [i]);
- list = g_settings_list_keys (bindings_settings);
- while (*list != NULL)
- {
- str_val = g_settings_get_string (bindings_settings, *list);
- update_key_binding (*list, str_val);
- list++;
- }
+ str_val = g_settings_get_string (settings, *list);
+ update_key_binding (*list, str_val);
+ list++;
}
+
g_free (str_val);
- g_object_unref (bindings_settings);
+}
+static void
+init_screen_bindings (void)
+{
+ init_bindings (settings_screen_bindings);
+}
+
+static void
+init_window_bindings (void)
+{
+ init_bindings (settings_window_bindings);
}
static void
@@ -1623,6 +1626,7 @@ init_commands (void)
update_command (*list, str_val);
list++;
}
+
g_free (str_val);
}
@@ -1639,6 +1643,7 @@ init_workspace_names (void)
update_workspace_name (*list, str_val);
list++;
}
+
g_free (str_val);
}
diff --git a/src/core/screen-private.h b/src/core/screen-private.h
index 0103c6ad..ee014ff2 100644
--- a/src/core/screen-private.h
+++ b/src/core/screen-private.h
@@ -115,6 +115,7 @@ struct _MetaScreen
#endif
#ifdef HAVE_COMPOSITE_EXTENSIONS
+ Atom wm_cm_atom;
Window wm_cm_selection_window;
guint32 wm_cm_timestamp;
#endif
diff --git a/src/core/screen.c b/src/core/screen.c
index bd3667e8..66461d4a 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -485,6 +485,8 @@ meta_screen_new (MetaDisplay *display,
screen->wm_sn_timestamp = manager_timestamp;
#ifdef HAVE_COMPOSITE_EXTENSIONS
+ g_snprintf (buf, sizeof(buf), "_NET_WM_CM_S%d", screen->number);
+ screen->wm_cm_atom = XInternAtom (screen->display->xdisplay, buf, FALSE);
screen->wm_cm_selection_window = meta_create_offscreen_window (xdisplay,
xroot,
NoEventMask);
@@ -1475,14 +1477,12 @@ meta_screen_tile_preview_update_timeout (gpointer data)
{
MetaScreen *screen = data;
MetaWindow *window = screen->display->grab_window;
- gboolean composited = screen->display->compositor != NULL;
gboolean needs_preview = FALSE;
screen->tile_preview_timeout_id = 0;
if (!screen->tile_preview)
- screen->tile_preview = meta_tile_preview_new (screen->number,
- composited);
+ screen->tile_preview = meta_tile_preview_new (screen->number);
if (window)
{
@@ -1510,7 +1510,7 @@ meta_screen_tile_preview_update_timeout (gpointer data)
MetaRectangle tile_rect;
meta_window_get_current_tile_area (window, &tile_rect);
- meta_tile_preview_show (screen->tile_preview, &tile_rect);
+ meta_tile_preview_show (screen->tile_preview, &tile_rect, screen);
}
else
meta_tile_preview_hide (screen->tile_preview);
@@ -2896,28 +2896,25 @@ meta_screen_set_compositor_data (MetaScreen *screen,
void
meta_screen_set_cm_selection (MetaScreen *screen)
{
- char selection[32];
- Atom a;
-
screen->wm_cm_timestamp = meta_display_get_current_time_roundtrip (
screen->display);
- g_snprintf (selection, sizeof(selection), "_NET_WM_CM_S%d", screen->number);
- meta_verbose ("Setting selection: %s\n", selection);
- a = XInternAtom (screen->display->xdisplay, selection, FALSE);
- XSetSelectionOwner (screen->display->xdisplay, a,
+ meta_verbose ("Setting selection for screen: %d\n", screen->number);
+ XSetSelectionOwner (screen->display->xdisplay, screen->wm_cm_atom,
screen->wm_cm_selection_window, screen->wm_cm_timestamp);
}
void
meta_screen_unset_cm_selection (MetaScreen *screen)
{
- char selection[32];
- Atom a;
-
- g_snprintf (selection, sizeof(selection), "_NET_WM_CM_S%d", screen->number);
- a = XInternAtom (screen->display->xdisplay, selection, FALSE);
- XSetSelectionOwner (screen->display->xdisplay, a,
+ XSetSelectionOwner (screen->display->xdisplay, screen->wm_cm_atom,
None, screen->wm_cm_timestamp);
}
+
+gboolean
+meta_screen_is_cm_selected (MetaScreen *screen)
+{
+ Window owner = XGetSelectionOwner (screen->display->xdisplay, screen->wm_cm_atom);
+ return owner != None;
+}
#endif /* HAVE_COMPOSITE_EXTENSIONS */
diff --git a/src/core/window.c b/src/core/window.c
index 95d49885..9b2ad926 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -2670,14 +2670,9 @@ meta_window_maximize (MetaWindow *window,
if (window->tile_mode != META_TILE_NONE)
{
saved_rect = &window->saved_rect;
- window->maximized_vertically = FALSE;
- }
-
- if (window->tile_mode != META_TILE_NONE)
- {
- saved_rect = &window->saved_rect;
window->maximized_vertically = FALSE;
+ window->tile_mode = META_TILE_NONE;
}
meta_window_maximize_internal (window,
@@ -2751,7 +2746,7 @@ meta_window_can_tile (MetaWindow *window)
MetaRectangle tile_area;
/*if (!META_WINDOW_ALLOWS_RESIZE (window))*/
- if (!META_WINDOW_ALLOWS_RESIZE (window))
+ if (!meta_window_can_tile_maximized (window) || window->shaded)
return FALSE;
monitor = meta_screen_get_current_xinerama (window->screen);
@@ -2780,15 +2775,6 @@ meta_window_unmaximize (MetaWindow *window,
/* At least one of the two directions ought to be set */
gboolean unmaximize_horizontally, unmaximize_vertically;
- /* Restore tiling if necessary */
- if (window->tile_mode == META_TILE_LEFT ||
- window->tile_mode == META_TILE_RIGHT)
- {
- window->maximized_horizontally = FALSE;
- meta_window_tile (window);
- return;
- }
-
unmaximize_horizontally = directions & META_MAXIMIZE_HORIZONTAL;
unmaximize_vertically = directions & META_MAXIMIZE_VERTICAL;
g_assert (unmaximize_horizontally || unmaximize_vertically);
@@ -3333,6 +3319,7 @@ send_sync_request (MetaWindow *window)
ev.data.l[1] = meta_display_get_current_time (window->display);
ev.data.l[2] = XSyncValueLow32 (value);
ev.data.l[3] = XSyncValueHigh32 (value);
+ ev.data.l[4] = 0;
/* We don't need to trap errors here as we are already
* inside an error_trap_push()/pop() pair.
diff --git a/src/include/all-keybindings.h b/src/include/all-keybindings.h
index 5b030280..a14777e9 100644
--- a/src/include/all-keybindings.h
+++ b/src/include/all-keybindings.h
@@ -252,6 +252,11 @@ keybind (maximize-vertically, handle_maximize_vertically, 0,
keybind (maximize-horizontally, handle_maximize_horizontally, 0,
BINDING_PER_WINDOW)
+keybind (tile-to-side-e, handle_toggle_tiled, META_TILE_RIGHT,
+ BINDING_PER_WINDOW)
+keybind (tile-to-side-w, handle_toggle_tiled, META_TILE_LEFT,
+ BINDING_PER_WINDOW)
+
keybind (move-to-corner-nw, handle_move_to_corner_nw, 0,
BINDING_PER_WINDOW)
keybind (move-to-corner-ne, handle_move_to_corner_ne, 0,
diff --git a/src/include/screen.h b/src/include/screen.h
index 759c1fd2..34f4d008 100644
--- a/src/include/screen.h
+++ b/src/include/screen.h
@@ -43,6 +43,7 @@ MetaScreen *meta_screen_for_x_screen (Screen *xscreen);
#ifdef HAVE_COMPOSITE_EXTENSIONS
void meta_screen_set_cm_selection (MetaScreen *screen);
void meta_screen_unset_cm_selection (MetaScreen *screen);
+gboolean meta_screen_is_cm_selected (MetaScreen *screen);
#endif
#endif
diff --git a/src/include/tile-preview.h b/src/include/tile-preview.h
index b0ca3b01..70ceec9e 100644
--- a/src/include/tile-preview.h
+++ b/src/include/tile-preview.h
@@ -24,14 +24,15 @@
#define META_TILE_PREVIEW_H
#include "boxes.h"
+#include "types.h"
typedef struct _MetaTilePreview MetaTilePreview;
-MetaTilePreview *meta_tile_preview_new (int screen_number,
- gboolean composited);
+MetaTilePreview *meta_tile_preview_new (int screen_number);
void meta_tile_preview_free (MetaTilePreview *preview);
void meta_tile_preview_show (MetaTilePreview *preview,
- MetaRectangle *rect);
+ MetaRectangle *rect,
+ MetaScreen *screen);
void meta_tile_preview_hide (MetaTilePreview *preview);
-#endif /* META_TILE_PREVIEW_H */ \ No newline at end of file
+#endif /* META_TILE_PREVIEW_H */
diff --git a/src/marco.convert b/src/marco.convert
index eb1f623b..21c8799f 100644
--- a/src/marco.convert
+++ b/src/marco.convert
@@ -142,6 +142,8 @@ raise = /apps/marco/window_keybindings/raise
lower = /apps/marco/window_keybindings/lower
maximize-vertically = /apps/marco/window_keybindings/maximize_vertically
maximize-horizontally = /apps/marco/window_keybindings/maximize_horizontally
+tile-to-side-e = /apps/marco/window_keybindings/tile_to_side_e
+tile-to-side-w = /apps/marco/window_keybindings/tile_to_side_w
move-to-corner-nw = /apps/marco/window_keybindings/move_to_corner_nw
move-to-corner-ne = /apps/marco/window_keybindings/move_to_corner_ne
move-to-corner-sw = /apps/marco/window_keybindings/move_to_corner_sw
diff --git a/src/org.mate.marco.gschema.xml b/src/org.mate.marco.gschema.xml
index a0725382..4108355c 100644
--- a/src/org.mate.marco.gschema.xml
+++ b/src/org.mate.marco.gschema.xml
@@ -838,6 +838,16 @@
<summary>Maximize window horizontally</summary>
<description>The format looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1". The parser is fairly liberal and allows lower or upper case, and also abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;". If you set the option to the special string "disabled", then there will be no keybinding for this action.</description>
</key>
+ <key name="tile-to-side-e" type="s">
+ <default>'disabled'</default>
+ <summary>Tile window to east (right) side of screen</summary>
+ <description>The format looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1". The parser is fairly liberal and allows lower or upper case, and also abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;". If you set the option to the special string "disabled", then there will be no keybinding for this action.</description>
+ </key>
+ <key name="tile-to-side-w" type="s">
+ <default>'disabled'</default>
+ <summary>Tile window to west (left) side of screen</summary>
+ <description>The format looks like "&lt;Control&gt;a" or "&lt;Shift&gt;&lt;Alt&gt;F1". The parser is fairly liberal and allows lower or upper case, and also abbreviations such as "&lt;Ctl&gt;" and "&lt;Ctrl&gt;". If you set the option to the special string "disabled", then there will be no keybinding for this action.</description>
+ </key>
<key name="move-to-corner-nw" type="s">
<default>'disabled'</default>
<summary>Move window to north-west (top left) corner</summary>
diff --git a/src/ui/preview-widget.c b/src/ui/preview-widget.c
index 58122706..da8593d4 100644
--- a/src/ui/preview-widget.c
+++ b/src/ui/preview-widget.c
@@ -620,7 +620,7 @@ meta_preview_get_icon (void)
NULL);
else
default_icon = gtk_icon_theme_load_icon (theme,
- "gtk-missing-image",
+ "image-missing",
META_ICON_WIDTH,
0,
NULL);
@@ -653,7 +653,7 @@ meta_preview_get_mini_icon (void)
NULL);
else
default_icon = gtk_icon_theme_load_icon (theme,
- "gtk-missing-image",
+ "image-missing",
META_MINI_ICON_WIDTH,
0,
NULL);
diff --git a/src/ui/tile-preview.c b/src/ui/tile-preview.c
index e85d2e64..c938317b 100644
--- a/src/ui/tile-preview.c
+++ b/src/ui/tile-preview.c
@@ -28,6 +28,8 @@
#include "tile-preview.h"
#include "core.h"
+#include "types.h"
+#include "core/screen-private.h"
#define OUTLINE_WIDTH 5 /* frame width in non-composite case */
@@ -177,8 +179,7 @@ on_preview_window_style_set (GtkWidget *widget,
}
MetaTilePreview *
-meta_tile_preview_new (int screen_number,
- gboolean composited)
+meta_tile_preview_new (int screen_number)
{
MetaTilePreview *preview;
#if !GTK_CHECK_VERSION (3, 0, 0)
@@ -207,23 +208,14 @@ meta_tile_preview_new (int screen_number,
preview->tile_rect.width = preview->tile_rect.height = 0;
#if GTK_CHECK_VERSION (3, 0, 0)
- preview->has_alpha = composited && (gdk_screen_get_rgba_visual (screen) != NULL);
+ gtk_widget_set_visual (preview->preview_window,
+ gdk_screen_get_rgba_visual (screen));
#else
- preview->has_alpha = rgba_colormap && composited;
+ gtk_widget_set_colormap (preview->preview_window, rgba_colormap);
#endif
- if (preview->has_alpha)
- {
-#if GTK_CHECK_VERSION (3, 0, 0)
- gtk_widget_set_visual (preview->preview_window,
- gdk_screen_get_rgba_visual (screen));
-#else
- gtk_widget_set_colormap (preview->preview_window, rgba_colormap);
-#endif
-
- g_signal_connect (preview->preview_window, "style-set",
- G_CALLBACK (on_preview_window_style_set), preview);
- }
+ g_signal_connect (preview->preview_window, "style-set",
+ G_CALLBACK (on_preview_window_style_set), preview);
gtk_widget_realize (preview->preview_window);
#if !GTK_CHECK_VERSION (3, 0, 0)
@@ -259,7 +251,8 @@ meta_tile_preview_free (MetaTilePreview *preview)
void
meta_tile_preview_show (MetaTilePreview *preview,
- MetaRectangle *tile_rect)
+ MetaRectangle *tile_rect,
+ MetaScreen *screen)
{
GdkWindow *window;
GdkRectangle old_rect;
@@ -293,6 +286,11 @@ meta_tile_preview_show (MetaTilePreview *preview,
gdk_window_move_resize (window,
preview->tile_rect.x, preview->tile_rect.y,
preview->tile_rect.width, preview->tile_rect.height);
+#if HAVE_COMPOSITE_EXTENSIONS
+ preview->has_alpha = meta_screen_is_cm_selected (screen);
+#else
+ preview->has_alpha = FALSE;
+#endif
if (!preview->has_alpha)
{
@@ -339,6 +337,8 @@ meta_tile_preview_show (MetaTilePreview *preview,
gdk_window_shape_combine_region (window, outer_region, 0, 0);
gdk_region_destroy (outer_region);
#endif
+ } else {
+ gdk_window_shape_combine_region (window, NULL, 0, 0);
}
}