mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
Make tile preview a compositor plugin effect
https://bugzilla.gnome.org/show_bug.cgi?id=665758
This commit is contained in:
parent
17462c21e8
commit
4de3f7ca29
@ -182,8 +182,6 @@ libmutter_wayland_la_SOURCES = \
|
|||||||
ui/resizepopup.h \
|
ui/resizepopup.h \
|
||||||
ui/tabpopup.c \
|
ui/tabpopup.c \
|
||||||
ui/tabpopup.h \
|
ui/tabpopup.h \
|
||||||
ui/tile-preview.c \
|
|
||||||
ui/tile-preview.h \
|
|
||||||
ui/theme-parser.c \
|
ui/theme-parser.c \
|
||||||
ui/theme.c \
|
ui/theme.c \
|
||||||
meta/theme.h \
|
meta/theme.h \
|
||||||
|
@ -1695,3 +1695,31 @@ meta_compositor_monotonic_time_to_server_time (MetaDisplay *display,
|
|||||||
else
|
else
|
||||||
return monotonic_time + compositor->server_time_offset;
|
return monotonic_time + compositor->server_time_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_compositor_show_tile_preview (MetaCompositor *compositor,
|
||||||
|
MetaScreen *screen,
|
||||||
|
MetaWindow *window,
|
||||||
|
MetaRectangle *tile_rect,
|
||||||
|
int tile_monitor_number)
|
||||||
|
{
|
||||||
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||||
|
|
||||||
|
if (!info->plugin_mgr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
meta_plugin_manager_show_tile_preview (info->plugin_mgr,
|
||||||
|
window, tile_rect, tile_monitor_number);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_compositor_hide_tile_preview (MetaCompositor *compositor,
|
||||||
|
MetaScreen *screen)
|
||||||
|
{
|
||||||
|
MetaCompScreen *info = meta_screen_get_compositor_data (screen);
|
||||||
|
|
||||||
|
if (!info->plugin_mgr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
meta_plugin_manager_hide_tile_preview (info->plugin_mgr);
|
||||||
|
}
|
||||||
|
@ -324,3 +324,44 @@ meta_plugin_manager_confirm_display_change (MetaPluginManager *plugin_mgr)
|
|||||||
else
|
else
|
||||||
return meta_plugin_complete_display_change (plugin, TRUE);
|
return meta_plugin_complete_display_change (plugin, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
meta_plugin_manager_show_tile_preview (MetaPluginManager *plugin_mgr,
|
||||||
|
MetaWindow *window,
|
||||||
|
MetaRectangle *tile_rect,
|
||||||
|
int tile_monitor_number)
|
||||||
|
{
|
||||||
|
MetaPlugin *plugin = plugin_mgr->plugin;
|
||||||
|
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
||||||
|
MetaDisplay *display = meta_screen_get_display (plugin_mgr->screen);
|
||||||
|
|
||||||
|
if (display->display_opening)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (klass->show_tile_preview)
|
||||||
|
{
|
||||||
|
klass->show_tile_preview (plugin, window, tile_rect, tile_monitor_number);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
meta_plugin_manager_hide_tile_preview (MetaPluginManager *plugin_mgr)
|
||||||
|
{
|
||||||
|
MetaPlugin *plugin = plugin_mgr->plugin;
|
||||||
|
MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
|
||||||
|
MetaDisplay *display = meta_screen_get_display (plugin_mgr->screen);
|
||||||
|
|
||||||
|
if (display->display_opening)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (klass->hide_tile_preview)
|
||||||
|
{
|
||||||
|
klass->hide_tile_preview (plugin);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
@ -75,4 +75,9 @@ gboolean _meta_plugin_xevent_filter (MetaPlugin *plugin,
|
|||||||
|
|
||||||
void meta_plugin_manager_confirm_display_change (MetaPluginManager *mgr);
|
void meta_plugin_manager_confirm_display_change (MetaPluginManager *mgr);
|
||||||
|
|
||||||
|
gboolean meta_plugin_manager_show_tile_preview (MetaPluginManager *mgr,
|
||||||
|
MetaWindow *window,
|
||||||
|
MetaRectangle *tile_rect,
|
||||||
|
int tile_monitor_number);
|
||||||
|
gboolean meta_plugin_manager_hide_tile_preview (MetaPluginManager *mgr);
|
||||||
#endif
|
#endif
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#define SWITCH_TIMEOUT 500
|
#define SWITCH_TIMEOUT 500
|
||||||
|
|
||||||
#define ACTOR_DATA_KEY "MCCP-Default-actor-data"
|
#define ACTOR_DATA_KEY "MCCP-Default-actor-data"
|
||||||
|
#define SCREEN_TILE_PREVIEW_DATA_KEY "MCCP-Default-screen-tile-preview-data"
|
||||||
|
|
||||||
#define META_TYPE_DEFAULT_PLUGIN (meta_default_plugin_get_type ())
|
#define META_TYPE_DEFAULT_PLUGIN (meta_default_plugin_get_type ())
|
||||||
#define META_DEFAULT_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_DEFAULT_PLUGIN, MetaDefaultPlugin))
|
#define META_DEFAULT_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_DEFAULT_PLUGIN, MetaDefaultPlugin))
|
||||||
@ -67,6 +68,7 @@ struct _MetaDefaultPluginClass
|
|||||||
};
|
};
|
||||||
|
|
||||||
static GQuark actor_data_quark = 0;
|
static GQuark actor_data_quark = 0;
|
||||||
|
static GQuark screen_tile_preview_data_quark = 0;
|
||||||
|
|
||||||
static void start (MetaPlugin *plugin);
|
static void start (MetaPlugin *plugin);
|
||||||
static void minimize (MetaPlugin *plugin,
|
static void minimize (MetaPlugin *plugin,
|
||||||
@ -97,6 +99,12 @@ static void kill_window_effects (MetaPlugin *plugin,
|
|||||||
MetaWindowActor *actor);
|
MetaWindowActor *actor);
|
||||||
static void kill_switch_workspace (MetaPlugin *plugin);
|
static void kill_switch_workspace (MetaPlugin *plugin);
|
||||||
|
|
||||||
|
static void show_tile_preview (MetaPlugin *plugin,
|
||||||
|
MetaWindow *window,
|
||||||
|
MetaRectangle *tile_rect,
|
||||||
|
int tile_monitor_number);
|
||||||
|
static void hide_tile_preview (MetaPlugin *plugin);
|
||||||
|
|
||||||
static void confirm_display_change (MetaPlugin *plugin);
|
static void confirm_display_change (MetaPlugin *plugin);
|
||||||
|
|
||||||
static const MetaPluginInfo * plugin_info (MetaPlugin *plugin);
|
static const MetaPluginInfo * plugin_info (MetaPlugin *plugin);
|
||||||
@ -143,6 +151,15 @@ typedef struct
|
|||||||
} EffectCompleteData;
|
} EffectCompleteData;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _ScreenTilePreview
|
||||||
|
{
|
||||||
|
ClutterActor *actor;
|
||||||
|
|
||||||
|
GdkRGBA *preview_color;
|
||||||
|
|
||||||
|
MetaRectangle tile_rect;
|
||||||
|
} ScreenTilePreview;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_default_plugin_dispose (GObject *object)
|
meta_default_plugin_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
@ -203,6 +220,8 @@ meta_default_plugin_class_init (MetaDefaultPluginClass *klass)
|
|||||||
plugin_class->unmaximize = unmaximize;
|
plugin_class->unmaximize = unmaximize;
|
||||||
plugin_class->destroy = destroy;
|
plugin_class->destroy = destroy;
|
||||||
plugin_class->switch_workspace = switch_workspace;
|
plugin_class->switch_workspace = switch_workspace;
|
||||||
|
plugin_class->show_tile_preview = show_tile_preview;
|
||||||
|
plugin_class->hide_tile_preview = hide_tile_preview;
|
||||||
plugin_class->plugin_info = plugin_info;
|
plugin_class->plugin_info = plugin_info;
|
||||||
plugin_class->kill_window_effects = kill_window_effects;
|
plugin_class->kill_window_effects = kill_window_effects;
|
||||||
plugin_class->kill_switch_workspace = kill_switch_workspace;
|
plugin_class->kill_switch_workspace = kill_switch_workspace;
|
||||||
@ -749,6 +768,82 @@ destroy (MetaPlugin *plugin, MetaWindowActor *window_actor)
|
|||||||
meta_plugin_destroy_completed (plugin, window_actor);
|
meta_plugin_destroy_completed (plugin, window_actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Tile preview private data accessor
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
free_screen_tile_preview (gpointer data)
|
||||||
|
{
|
||||||
|
ScreenTilePreview *preview = data;
|
||||||
|
|
||||||
|
if (G_LIKELY (preview != NULL)) {
|
||||||
|
clutter_actor_destroy (preview->actor);
|
||||||
|
g_slice_free (ScreenTilePreview, preview);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static ScreenTilePreview *
|
||||||
|
get_screen_tile_preview (MetaScreen *screen)
|
||||||
|
{
|
||||||
|
ScreenTilePreview *preview = g_object_get_qdata (G_OBJECT (screen), screen_tile_preview_data_quark);
|
||||||
|
|
||||||
|
if (G_UNLIKELY (screen_tile_preview_data_quark == 0))
|
||||||
|
screen_tile_preview_data_quark = g_quark_from_static_string (SCREEN_TILE_PREVIEW_DATA_KEY);
|
||||||
|
|
||||||
|
if (G_UNLIKELY (!preview))
|
||||||
|
{
|
||||||
|
preview = g_slice_new0 (ScreenTilePreview);
|
||||||
|
|
||||||
|
preview->actor = clutter_actor_new ();
|
||||||
|
clutter_actor_set_background_color (preview->actor, CLUTTER_COLOR_Blue);
|
||||||
|
clutter_actor_set_opacity (preview->actor, 100);
|
||||||
|
|
||||||
|
clutter_actor_add_child (meta_get_window_group_for_screen (screen), preview->actor);
|
||||||
|
g_object_set_qdata_full (G_OBJECT (screen),
|
||||||
|
screen_tile_preview_data_quark, preview,
|
||||||
|
free_screen_tile_preview);
|
||||||
|
}
|
||||||
|
|
||||||
|
return preview;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
show_tile_preview (MetaPlugin *plugin,
|
||||||
|
MetaWindow *window,
|
||||||
|
MetaRectangle *tile_rect,
|
||||||
|
int tile_monitor_number)
|
||||||
|
{
|
||||||
|
MetaScreen *screen = meta_plugin_get_screen (plugin);
|
||||||
|
ScreenTilePreview *preview = get_screen_tile_preview (screen);
|
||||||
|
ClutterActor *window_actor;
|
||||||
|
|
||||||
|
if (CLUTTER_ACTOR_IS_VISIBLE (preview->actor)
|
||||||
|
&& preview->tile_rect.x == tile_rect->x
|
||||||
|
&& preview->tile_rect.y == tile_rect->y
|
||||||
|
&& preview->tile_rect.width == tile_rect->width
|
||||||
|
&& preview->tile_rect.height == tile_rect->height)
|
||||||
|
return; /* nothing to do */
|
||||||
|
|
||||||
|
clutter_actor_set_position (preview->actor, tile_rect->x, tile_rect->y);
|
||||||
|
clutter_actor_set_size (preview->actor, tile_rect->width, tile_rect->height);
|
||||||
|
|
||||||
|
clutter_actor_show (preview->actor);
|
||||||
|
|
||||||
|
window_actor = CLUTTER_ACTOR (meta_window_get_compositor_private (window));
|
||||||
|
clutter_actor_lower (preview->actor, window_actor);
|
||||||
|
|
||||||
|
preview->tile_rect = *tile_rect;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
hide_tile_preview (MetaPlugin *plugin)
|
||||||
|
{
|
||||||
|
MetaScreen *screen = meta_plugin_get_screen (plugin);
|
||||||
|
ScreenTilePreview *preview = get_screen_tile_preview (screen);
|
||||||
|
|
||||||
|
clutter_actor_hide (preview->actor);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
kill_switch_workspace (MetaPlugin *plugin)
|
kill_switch_workspace (MetaPlugin *plugin)
|
||||||
{
|
{
|
||||||
|
@ -2165,7 +2165,7 @@ process_mouse_move_resize_grab (MetaDisplay *display,
|
|||||||
{
|
{
|
||||||
/* Hide the tiling preview if necessary */
|
/* Hide the tiling preview if necessary */
|
||||||
if (window->tile_mode != META_TILE_NONE)
|
if (window->tile_mode != META_TILE_NONE)
|
||||||
meta_screen_tile_preview_hide (screen);
|
meta_screen_hide_tile_preview (screen);
|
||||||
|
|
||||||
/* Restore the original tile mode */
|
/* Restore the original tile mode */
|
||||||
window->tile_mode = display->grab_tile_mode;
|
window->tile_mode = display->grab_tile_mode;
|
||||||
|
@ -65,7 +65,6 @@ struct _MetaScreen
|
|||||||
MetaRectangle rect; /* Size of screen; rect.x & rect.y are always 0 */
|
MetaRectangle rect; /* Size of screen; rect.x & rect.y are always 0 */
|
||||||
MetaUI *ui;
|
MetaUI *ui;
|
||||||
MetaTabPopup *tab_popup, *ws_popup;
|
MetaTabPopup *tab_popup, *ws_popup;
|
||||||
MetaTilePreview *tile_preview;
|
|
||||||
|
|
||||||
guint tile_preview_timeout_id;
|
guint tile_preview_timeout_id;
|
||||||
|
|
||||||
@ -167,9 +166,9 @@ void meta_screen_workspace_popup_select (MetaScreen *screen,
|
|||||||
MetaWorkspace*meta_screen_workspace_popup_get_selected (MetaScreen *screen);
|
MetaWorkspace*meta_screen_workspace_popup_get_selected (MetaScreen *screen);
|
||||||
void meta_screen_workspace_popup_destroy (MetaScreen *screen);
|
void meta_screen_workspace_popup_destroy (MetaScreen *screen);
|
||||||
|
|
||||||
void meta_screen_tile_preview_update (MetaScreen *screen,
|
void meta_screen_update_tile_preview (MetaScreen *screen,
|
||||||
gboolean delay);
|
gboolean delay);
|
||||||
void meta_screen_tile_preview_hide (MetaScreen *screen);
|
void meta_screen_hide_tile_preview (MetaScreen *screen);
|
||||||
|
|
||||||
MetaWindow* meta_screen_get_mouse_window (MetaScreen *screen,
|
MetaWindow* meta_screen_get_mouse_window (MetaScreen *screen,
|
||||||
MetaWindow *not_this_one);
|
MetaWindow *not_this_one);
|
||||||
|
@ -762,7 +762,6 @@ meta_screen_new (MetaDisplay *display,
|
|||||||
|
|
||||||
screen->tab_popup = NULL;
|
screen->tab_popup = NULL;
|
||||||
screen->ws_popup = NULL;
|
screen->ws_popup = NULL;
|
||||||
screen->tile_preview = NULL;
|
|
||||||
|
|
||||||
screen->tile_preview_timeout_id = 0;
|
screen->tile_preview_timeout_id = 0;
|
||||||
|
|
||||||
@ -868,9 +867,6 @@ meta_screen_free (MetaScreen *screen,
|
|||||||
if (screen->tile_preview_timeout_id)
|
if (screen->tile_preview_timeout_id)
|
||||||
g_source_remove (screen->tile_preview_timeout_id);
|
g_source_remove (screen->tile_preview_timeout_id);
|
||||||
|
|
||||||
if (screen->tile_preview)
|
|
||||||
meta_tile_preview_free (screen->tile_preview);
|
|
||||||
|
|
||||||
g_free (screen->screen_name);
|
g_free (screen->screen_name);
|
||||||
|
|
||||||
g_object_unref (screen);
|
g_object_unref (screen);
|
||||||
@ -1680,7 +1676,7 @@ meta_screen_workspace_popup_destroy (MetaScreen *screen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
meta_screen_tile_preview_update_timeout (gpointer data)
|
meta_screen_update_tile_preview_timeout (gpointer data)
|
||||||
{
|
{
|
||||||
MetaScreen *screen = data;
|
MetaScreen *screen = data;
|
||||||
MetaWindow *window = screen->display->grab_window;
|
MetaWindow *window = screen->display->grab_window;
|
||||||
@ -1688,22 +1684,6 @@ meta_screen_tile_preview_update_timeout (gpointer data)
|
|||||||
|
|
||||||
screen->tile_preview_timeout_id = 0;
|
screen->tile_preview_timeout_id = 0;
|
||||||
|
|
||||||
if (!screen->tile_preview)
|
|
||||||
{
|
|
||||||
Window xwindow;
|
|
||||||
gulong create_serial;
|
|
||||||
MetaStackWindow stack_window;
|
|
||||||
|
|
||||||
screen->tile_preview = meta_tile_preview_new (screen->number);
|
|
||||||
xwindow = meta_tile_preview_get_xwindow (screen->tile_preview,
|
|
||||||
&create_serial);
|
|
||||||
stack_window.any.type = META_WINDOW_CLIENT_TYPE_X11;
|
|
||||||
stack_window.x11.xwindow = xwindow;
|
|
||||||
meta_stack_tracker_record_add (screen->stack_tracker,
|
|
||||||
&stack_window,
|
|
||||||
create_serial);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window)
|
if (window)
|
||||||
{
|
{
|
||||||
switch (window->tile_mode)
|
switch (window->tile_mode)
|
||||||
@ -1728,12 +1708,16 @@ meta_screen_tile_preview_update_timeout (gpointer data)
|
|||||||
if (needs_preview)
|
if (needs_preview)
|
||||||
{
|
{
|
||||||
MetaRectangle tile_rect;
|
MetaRectangle tile_rect;
|
||||||
|
int monitor;
|
||||||
|
|
||||||
|
monitor = meta_window_get_current_tile_monitor_number (window);
|
||||||
meta_window_get_current_tile_area (window, &tile_rect);
|
meta_window_get_current_tile_area (window, &tile_rect);
|
||||||
meta_tile_preview_show (screen->tile_preview, &tile_rect);
|
meta_compositor_show_tile_preview (screen->display->compositor,
|
||||||
|
screen, window, &tile_rect, monitor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
meta_tile_preview_hide (screen->tile_preview);
|
meta_compositor_hide_tile_preview (screen->display->compositor,
|
||||||
|
screen);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -1741,7 +1725,7 @@ meta_screen_tile_preview_update_timeout (gpointer data)
|
|||||||
#define TILE_PREVIEW_TIMEOUT_MS 200
|
#define TILE_PREVIEW_TIMEOUT_MS 200
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_screen_tile_preview_update (MetaScreen *screen,
|
meta_screen_update_tile_preview (MetaScreen *screen,
|
||||||
gboolean delay)
|
gboolean delay)
|
||||||
{
|
{
|
||||||
if (delay)
|
if (delay)
|
||||||
@ -1751,7 +1735,7 @@ meta_screen_tile_preview_update (MetaScreen *screen,
|
|||||||
|
|
||||||
screen->tile_preview_timeout_id =
|
screen->tile_preview_timeout_id =
|
||||||
g_timeout_add (TILE_PREVIEW_TIMEOUT_MS,
|
g_timeout_add (TILE_PREVIEW_TIMEOUT_MS,
|
||||||
meta_screen_tile_preview_update_timeout,
|
meta_screen_update_tile_preview_timeout,
|
||||||
screen);
|
screen);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1759,18 +1743,18 @@ meta_screen_tile_preview_update (MetaScreen *screen,
|
|||||||
if (screen->tile_preview_timeout_id > 0)
|
if (screen->tile_preview_timeout_id > 0)
|
||||||
g_source_remove (screen->tile_preview_timeout_id);
|
g_source_remove (screen->tile_preview_timeout_id);
|
||||||
|
|
||||||
meta_screen_tile_preview_update_timeout ((gpointer)screen);
|
meta_screen_update_tile_preview_timeout ((gpointer)screen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_screen_tile_preview_hide (MetaScreen *screen)
|
meta_screen_hide_tile_preview (MetaScreen *screen)
|
||||||
{
|
{
|
||||||
if (screen->tile_preview_timeout_id > 0)
|
if (screen->tile_preview_timeout_id > 0)
|
||||||
g_source_remove (screen->tile_preview_timeout_id);
|
g_source_remove (screen->tile_preview_timeout_id);
|
||||||
|
|
||||||
if (screen->tile_preview)
|
meta_compositor_hide_tile_preview (screen->display->compositor,
|
||||||
meta_tile_preview_hide (screen->tile_preview);
|
screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaWindow*
|
MetaWindow*
|
||||||
|
@ -652,6 +652,7 @@ void meta_window_handle_mouse_grab_op_xevent (MetaWindow *window,
|
|||||||
|
|
||||||
GList* meta_window_get_workspaces (MetaWindow *window);
|
GList* meta_window_get_workspaces (MetaWindow *window);
|
||||||
|
|
||||||
|
int meta_window_get_current_tile_monitor_number (MetaWindow *window);
|
||||||
void meta_window_get_current_tile_area (MetaWindow *window,
|
void meta_window_get_current_tile_area (MetaWindow *window,
|
||||||
MetaRectangle *tile_area);
|
MetaRectangle *tile_area);
|
||||||
|
|
||||||
|
@ -1177,9 +1177,6 @@ _meta_window_shared_new (MetaDisplay *display,
|
|||||||
if (!window->override_redirect)
|
if (!window->override_redirect)
|
||||||
meta_stack_add (window->screen->stack,
|
meta_stack_add (window->screen->stack,
|
||||||
window);
|
window);
|
||||||
else if (window->screen->tile_preview != NULL &&
|
|
||||||
meta_tile_preview_get_xwindow (window->screen->tile_preview, NULL) == xwindow)
|
|
||||||
window->layer = META_LAYER_NORMAL;
|
|
||||||
else
|
else
|
||||||
window->layer = META_LAYER_OVERRIDE_REDIRECT; /* otherwise set by MetaStack */
|
window->layer = META_LAYER_OVERRIDE_REDIRECT; /* otherwise set by MetaStack */
|
||||||
|
|
||||||
@ -3369,7 +3366,7 @@ meta_window_tile (MetaWindow *window)
|
|||||||
directions = META_MAXIMIZE_VERTICAL;
|
directions = META_MAXIMIZE_VERTICAL;
|
||||||
|
|
||||||
meta_window_maximize_internal (window, directions, NULL);
|
meta_window_maximize_internal (window, directions, NULL);
|
||||||
meta_screen_tile_preview_update (window->screen, FALSE);
|
meta_screen_update_tile_preview (window->screen, FALSE);
|
||||||
|
|
||||||
if (window->display->compositor)
|
if (window->display->compositor)
|
||||||
{
|
{
|
||||||
@ -8108,7 +8105,7 @@ update_move (MetaWindow *window,
|
|||||||
* trigger it unwittingly, e.g. when shaking loose the window or moving
|
* trigger it unwittingly, e.g. when shaking loose the window or moving
|
||||||
* it to another monitor.
|
* it to another monitor.
|
||||||
*/
|
*/
|
||||||
meta_screen_tile_preview_update (window->screen,
|
meta_screen_update_tile_preview (window->screen,
|
||||||
window->tile_mode != META_TILE_NONE);
|
window->tile_mode != META_TILE_NONE);
|
||||||
|
|
||||||
meta_window_get_client_root_coords (window, &old);
|
meta_window_get_client_root_coords (window, &old);
|
||||||
@ -8956,6 +8953,20 @@ meta_window_get_work_area_all_monitors (MetaWindow *window,
|
|||||||
window->desc, area->x, area->y, area->width, area->height);
|
window->desc, area->x, area->y, area->width, area->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
meta_window_get_current_tile_monitor_number (MetaWindow *window)
|
||||||
|
{
|
||||||
|
int tile_monitor_number = window->tile_monitor_number;
|
||||||
|
|
||||||
|
if (tile_monitor_number < 0)
|
||||||
|
{
|
||||||
|
meta_warning ("%s called with an invalid monitor number; using 0 instead\n", G_STRFUNC);
|
||||||
|
tile_monitor_number = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tile_monitor_number;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_window_get_current_tile_area (MetaWindow *window,
|
meta_window_get_current_tile_area (MetaWindow *window,
|
||||||
MetaRectangle *tile_area)
|
MetaRectangle *tile_area)
|
||||||
@ -8964,12 +8975,7 @@ meta_window_get_current_tile_area (MetaWindow *window,
|
|||||||
|
|
||||||
g_return_if_fail (window->tile_mode != META_TILE_NONE);
|
g_return_if_fail (window->tile_mode != META_TILE_NONE);
|
||||||
|
|
||||||
tile_monitor_number = window->tile_monitor_number;
|
tile_monitor_number = meta_window_get_current_tile_monitor_number (window);
|
||||||
if (tile_monitor_number < 0)
|
|
||||||
{
|
|
||||||
meta_warning ("%s called with an invalid monitor number; using 0 instead\n", G_STRFUNC);
|
|
||||||
tile_monitor_number = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
meta_window_get_work_area_for_monitor (window, tile_monitor_number, tile_area);
|
meta_window_get_work_area_for_monitor (window, tile_monitor_number, tile_area);
|
||||||
|
|
||||||
|
@ -121,4 +121,12 @@ void meta_compositor_sync_screen_size (MetaCompositor *compositor,
|
|||||||
void meta_compositor_flash_screen (MetaCompositor *compositor,
|
void meta_compositor_flash_screen (MetaCompositor *compositor,
|
||||||
MetaScreen *screen);
|
MetaScreen *screen);
|
||||||
|
|
||||||
|
void meta_compositor_show_tile_preview (MetaCompositor *compositor,
|
||||||
|
MetaScreen *screen,
|
||||||
|
MetaWindow *window,
|
||||||
|
MetaRectangle *tile_rect,
|
||||||
|
int tile_monitor_number);
|
||||||
|
void meta_compositor_hide_tile_preview (MetaCompositor *compositor,
|
||||||
|
MetaScreen *screen);
|
||||||
|
|
||||||
#endif /* META_COMPOSITOR_H */
|
#endif /* META_COMPOSITOR_H */
|
||||||
|
@ -158,6 +158,11 @@ struct _MetaPluginClass
|
|||||||
gint to,
|
gint to,
|
||||||
MetaMotionDirection direction);
|
MetaMotionDirection direction);
|
||||||
|
|
||||||
|
void (*show_tile_preview) (MetaPlugin *plugin,
|
||||||
|
MetaWindow *window,
|
||||||
|
MetaRectangle *tile_rect,
|
||||||
|
int tile_monitor_number);
|
||||||
|
void (*hide_tile_preview) (MetaPlugin *plugin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MetaPluginClass::kill_window_effects:
|
* MetaPluginClass::kill_window_effects:
|
||||||
|
@ -1,196 +0,0 @@
|
|||||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
||||||
|
|
||||||
/* Mutter tile-preview marks the area a window will *ehm* snap to */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2010 Florian Müllner
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#include <cairo.h>
|
|
||||||
|
|
||||||
#include "tile-preview.h"
|
|
||||||
#include "core.h"
|
|
||||||
|
|
||||||
#define OUTLINE_WIDTH 5 /* frame width in non-composite case */
|
|
||||||
|
|
||||||
|
|
||||||
struct _MetaTilePreview {
|
|
||||||
GtkWidget *preview_window;
|
|
||||||
gulong create_serial;
|
|
||||||
|
|
||||||
GdkRGBA *preview_color;
|
|
||||||
|
|
||||||
MetaRectangle tile_rect;
|
|
||||||
};
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
meta_tile_preview_draw (GtkWidget *widget,
|
|
||||||
cairo_t *cr,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
MetaTilePreview *preview = user_data;
|
|
||||||
|
|
||||||
cairo_set_line_width (cr, 1.0);
|
|
||||||
|
|
||||||
/* Fill the preview area with a transparent color */
|
|
||||||
gdk_cairo_set_source_rgba (cr, preview->preview_color);
|
|
||||||
|
|
||||||
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
|
|
||||||
cairo_paint (cr);
|
|
||||||
|
|
||||||
/* Use the opaque color for the border */
|
|
||||||
cairo_set_source_rgb (cr,
|
|
||||||
preview->preview_color->red,
|
|
||||||
preview->preview_color->green,
|
|
||||||
preview->preview_color->blue);
|
|
||||||
|
|
||||||
cairo_rectangle (cr,
|
|
||||||
0.5, 0.5,
|
|
||||||
preview->tile_rect.width - 1,
|
|
||||||
preview->tile_rect.height - 1);
|
|
||||||
cairo_stroke (cr);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
MetaTilePreview *
|
|
||||||
meta_tile_preview_new (int screen_number)
|
|
||||||
{
|
|
||||||
MetaTilePreview *preview;
|
|
||||||
GdkScreen *screen;
|
|
||||||
GtkStyleContext *context;
|
|
||||||
GtkWidgetPath *path;
|
|
||||||
guchar selection_alpha = 0xFF;
|
|
||||||
|
|
||||||
screen = gdk_display_get_screen (gdk_display_get_default (), screen_number);
|
|
||||||
|
|
||||||
preview = g_new (MetaTilePreview, 1);
|
|
||||||
|
|
||||||
preview->preview_window = gtk_window_new (GTK_WINDOW_POPUP);
|
|
||||||
|
|
||||||
gtk_window_set_screen (GTK_WINDOW (preview->preview_window), screen);
|
|
||||||
gtk_widget_set_app_paintable (preview->preview_window, TRUE);
|
|
||||||
|
|
||||||
preview->preview_color = NULL;
|
|
||||||
|
|
||||||
preview->tile_rect.x = preview->tile_rect.y = 0;
|
|
||||||
preview->tile_rect.width = preview->tile_rect.height = 0;
|
|
||||||
|
|
||||||
gtk_widget_set_visual (preview->preview_window,
|
|
||||||
gdk_screen_get_rgba_visual (screen));
|
|
||||||
|
|
||||||
path = gtk_widget_path_new ();
|
|
||||||
gtk_widget_path_append_type (path, GTK_TYPE_ICON_VIEW);
|
|
||||||
|
|
||||||
context = gtk_style_context_new ();
|
|
||||||
gtk_style_context_set_path (context, path);
|
|
||||||
gtk_style_context_add_class (context,
|
|
||||||
GTK_STYLE_CLASS_RUBBERBAND);
|
|
||||||
|
|
||||||
gtk_widget_path_free (path);
|
|
||||||
|
|
||||||
gtk_style_context_get (context, GTK_STATE_FLAG_SELECTED,
|
|
||||||
"background-color", &preview->preview_color,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
/* The background-color for the .rubberband class should probably
|
|
||||||
* contain the correct alpha value - unfortunately, at least for now
|
|
||||||
* it doesn't. Hopefully the following workaround can be removed
|
|
||||||
* when GtkIconView gets ported to GtkStyleContext.
|
|
||||||
*/
|
|
||||||
gtk_style_context_get_style (context,
|
|
||||||
"selection-box-alpha", &selection_alpha,
|
|
||||||
NULL);
|
|
||||||
preview->preview_color->alpha = (double)selection_alpha / 0xFF;
|
|
||||||
|
|
||||||
g_object_unref (context);
|
|
||||||
|
|
||||||
/* We make an assumption that XCreateWindow will be the first operation
|
|
||||||
* when calling gtk_widget_realize() (via gdk_window_new()), or that it
|
|
||||||
* is at least "close enough".
|
|
||||||
*/
|
|
||||||
preview->create_serial = XNextRequest (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
|
|
||||||
gtk_widget_realize (preview->preview_window);
|
|
||||||
g_signal_connect (preview->preview_window, "draw",
|
|
||||||
G_CALLBACK (meta_tile_preview_draw), preview);
|
|
||||||
|
|
||||||
return preview;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
meta_tile_preview_free (MetaTilePreview *preview)
|
|
||||||
{
|
|
||||||
gtk_widget_destroy (preview->preview_window);
|
|
||||||
|
|
||||||
if (preview->preview_color)
|
|
||||||
gdk_rgba_free (preview->preview_color);
|
|
||||||
|
|
||||||
g_free (preview);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
meta_tile_preview_show (MetaTilePreview *preview,
|
|
||||||
MetaRectangle *tile_rect)
|
|
||||||
{
|
|
||||||
GdkWindow *window;
|
|
||||||
GdkRectangle old_rect;
|
|
||||||
|
|
||||||
if (gtk_widget_get_visible (preview->preview_window)
|
|
||||||
&& preview->tile_rect.x == tile_rect->x
|
|
||||||
&& preview->tile_rect.y == tile_rect->y
|
|
||||||
&& preview->tile_rect.width == tile_rect->width
|
|
||||||
&& preview->tile_rect.height == tile_rect->height)
|
|
||||||
return; /* nothing to do */
|
|
||||||
|
|
||||||
gtk_widget_show (preview->preview_window);
|
|
||||||
window = gtk_widget_get_window (preview->preview_window);
|
|
||||||
meta_core_lower_beneath_grab_window (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
|
|
||||||
GDK_WINDOW_XID (window),
|
|
||||||
gtk_get_current_event_time ());
|
|
||||||
|
|
||||||
old_rect.x = old_rect.y = 0;
|
|
||||||
old_rect.width = preview->tile_rect.width;
|
|
||||||
old_rect.height = preview->tile_rect.height;
|
|
||||||
|
|
||||||
gdk_window_invalidate_rect (window, &old_rect, FALSE);
|
|
||||||
|
|
||||||
preview->tile_rect = *tile_rect;
|
|
||||||
|
|
||||||
gdk_window_move_resize (window,
|
|
||||||
preview->tile_rect.x, preview->tile_rect.y,
|
|
||||||
preview->tile_rect.width, preview->tile_rect.height);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
meta_tile_preview_hide (MetaTilePreview *preview)
|
|
||||||
{
|
|
||||||
gtk_widget_hide (preview->preview_window);
|
|
||||||
}
|
|
||||||
|
|
||||||
Window
|
|
||||||
meta_tile_preview_get_xwindow (MetaTilePreview *preview,
|
|
||||||
gulong *create_serial)
|
|
||||||
{
|
|
||||||
GdkWindow *window = gtk_widget_get_window (preview->preview_window);
|
|
||||||
|
|
||||||
if (create_serial)
|
|
||||||
*create_serial = preview->create_serial;
|
|
||||||
|
|
||||||
return GDK_WINDOW_XID (window);
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
||||||
|
|
||||||
/* Meta tile preview */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2010 Florian Müllner
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License as
|
|
||||||
* published by the Free Software Foundation; either version 2 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#ifndef META_TILE_PREVIEW_H
|
|
||||||
#define META_TILE_PREVIEW_H
|
|
||||||
|
|
||||||
#include <meta/boxes.h>
|
|
||||||
|
|
||||||
typedef struct _MetaTilePreview MetaTilePreview;
|
|
||||||
|
|
||||||
MetaTilePreview *meta_tile_preview_new (int screen_number);
|
|
||||||
void meta_tile_preview_free (MetaTilePreview *preview);
|
|
||||||
void meta_tile_preview_show (MetaTilePreview *preview,
|
|
||||||
MetaRectangle *rect);
|
|
||||||
void meta_tile_preview_hide (MetaTilePreview *preview);
|
|
||||||
Window meta_tile_preview_get_xwindow (MetaTilePreview *preview,
|
|
||||||
gulong *create_serial);
|
|
||||||
|
|
||||||
#endif /* META_TILE_PREVIEW_H */
|
|
@ -179,6 +179,5 @@ int meta_ui_get_drag_threshold (MetaUI *ui);
|
|||||||
MetaUIDirection meta_ui_get_direction (void);
|
MetaUIDirection meta_ui_get_direction (void);
|
||||||
|
|
||||||
#include "tabpopup.h"
|
#include "tabpopup.h"
|
||||||
#include "tile-preview.h"
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user