mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 17:40:40 -05:00
Create a MetaAltTabHandler abstraction to allow alternate implementations
http://bugzilla.gnome.org/show_bug.cgi?id=580917
This commit is contained in:
parent
99d0f41d98
commit
1d5117a607
@ -11,6 +11,10 @@ INCLUDES=@METACITY_CFLAGS@ -I $(srcdir)/include -I$(srcdir)/compositor -DMETACIT
|
|||||||
metacity_SOURCES= \
|
metacity_SOURCES= \
|
||||||
core/async-getprop.c \
|
core/async-getprop.c \
|
||||||
core/async-getprop.h \
|
core/async-getprop.h \
|
||||||
|
core/alttabhandler.c \
|
||||||
|
include/alttabhandler.h \
|
||||||
|
core/alttabhandlerdefault.c \
|
||||||
|
include/alttabhandlerdefault.h \
|
||||||
core/bell.c \
|
core/bell.c \
|
||||||
core/bell.h \
|
core/bell.h \
|
||||||
core/boxes.c \
|
core/boxes.c \
|
||||||
@ -142,6 +146,7 @@ libmetacity_private_la_LIBADD = @METACITY_LIBS@
|
|||||||
libmetacityincludedir = $(includedir)/metacity-1/metacity-private
|
libmetacityincludedir = $(includedir)/metacity-1/metacity-private
|
||||||
|
|
||||||
libmetacityinclude_base_headers = \
|
libmetacityinclude_base_headers = \
|
||||||
|
include/alttabhandler.h \
|
||||||
include/boxes.h \
|
include/boxes.h \
|
||||||
ui/gradient.h \
|
ui/gradient.h \
|
||||||
include/util.h \
|
include/util.h \
|
||||||
|
138
src/core/alttabhandler.c
Normal file
138
src/core/alttabhandler.c
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||||
|
|
||||||
|
/* Metacity Alt-Tab abstraction */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2009 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* 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, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
* 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
#include "alttabhandlerdefault.h"
|
||||||
|
#include "screen-private.h"
|
||||||
|
|
||||||
|
static GType handler_type = G_TYPE_INVALID;
|
||||||
|
|
||||||
|
GType meta_alt_tab_handler_default_get_type (void);
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_alt_tab_handler_register (GType type)
|
||||||
|
{
|
||||||
|
handler_type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
MetaAltTabHandler *
|
||||||
|
meta_alt_tab_handler_new (MetaScreen *screen,
|
||||||
|
gboolean immediate)
|
||||||
|
{
|
||||||
|
if (handler_type == G_TYPE_INVALID)
|
||||||
|
handler_type = meta_alt_tab_handler_default_get_type ();
|
||||||
|
|
||||||
|
return g_object_new (handler_type,
|
||||||
|
"screen", screen,
|
||||||
|
"immediate", immediate,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void meta_alt_tab_handler_class_init (GObjectClass *object_class);
|
||||||
|
|
||||||
|
GType
|
||||||
|
meta_alt_tab_handler_get_type (void)
|
||||||
|
{
|
||||||
|
static volatile gsize g_define_type_id__volatile = 0;
|
||||||
|
|
||||||
|
if (g_once_init_enter (&g_define_type_id__volatile))
|
||||||
|
{
|
||||||
|
const GTypeInfo type_info =
|
||||||
|
{
|
||||||
|
sizeof (MetaAltTabHandlerInterface), /* class_size */
|
||||||
|
NULL, /* base_init */
|
||||||
|
NULL, /* base_finalize */
|
||||||
|
(GClassInitFunc)meta_alt_tab_handler_class_init,
|
||||||
|
NULL, /* class_finalize */
|
||||||
|
NULL, /* class_data */
|
||||||
|
0,
|
||||||
|
0, /* n_preallocs */
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
GType g_define_type_id =
|
||||||
|
g_type_register_static (G_TYPE_INTERFACE, "MetaAltTabHandler",
|
||||||
|
&type_info, 0);
|
||||||
|
|
||||||
|
g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_OBJECT);
|
||||||
|
|
||||||
|
g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_define_type_id__volatile;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_alt_tab_handler_class_init (GObjectClass *object_class)
|
||||||
|
{
|
||||||
|
g_object_interface_install_property (object_class,
|
||||||
|
g_param_spec_object ("screen",
|
||||||
|
"Screen",
|
||||||
|
"MetaScreen this is the switcher for",
|
||||||
|
META_TYPE_SCREEN,
|
||||||
|
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
g_object_interface_install_property (object_class,
|
||||||
|
g_param_spec_boolean ("immediate",
|
||||||
|
"Immediate mode",
|
||||||
|
"Whether or not to select windows immediately",
|
||||||
|
FALSE,
|
||||||
|
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_alt_tab_handler_add_window (MetaAltTabHandler *handler,
|
||||||
|
MetaWindow *window)
|
||||||
|
{
|
||||||
|
META_ALT_TAB_HANDLER_GET_INTERFACE (handler)->add_window (handler, window);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_alt_tab_handler_show (MetaAltTabHandler *handler,
|
||||||
|
MetaWindow *initial_selection)
|
||||||
|
{
|
||||||
|
META_ALT_TAB_HANDLER_GET_INTERFACE (handler)->show (handler,
|
||||||
|
initial_selection);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_alt_tab_handler_destroy (MetaAltTabHandler *handler)
|
||||||
|
{
|
||||||
|
META_ALT_TAB_HANDLER_GET_INTERFACE (handler)->destroy (handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_alt_tab_handler_forward (MetaAltTabHandler *handler)
|
||||||
|
{
|
||||||
|
META_ALT_TAB_HANDLER_GET_INTERFACE (handler)->forward (handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_alt_tab_handler_backward (MetaAltTabHandler *handler)
|
||||||
|
{
|
||||||
|
META_ALT_TAB_HANDLER_GET_INTERFACE (handler)->backward (handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
MetaWindow *
|
||||||
|
meta_alt_tab_handler_get_selected (MetaAltTabHandler *handler)
|
||||||
|
{
|
||||||
|
return META_ALT_TAB_HANDLER_GET_INTERFACE (handler)->get_selected (handler);
|
||||||
|
}
|
223
src/core/alttabhandlerdefault.c
Normal file
223
src/core/alttabhandlerdefault.c
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||||
|
|
||||||
|
/* Metacity Alt-Tab abstraction: default implementation */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2009 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* 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, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
* 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
#include "alttabhandlerdefault.h"
|
||||||
|
#include "frame-private.h"
|
||||||
|
#include "window-private.h"
|
||||||
|
|
||||||
|
static void meta_alt_tab_handler_default_interface_init (MetaAltTabHandlerInterface *handler_iface);
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_WITH_CODE (MetaAltTabHandlerDefault, meta_alt_tab_handler_default, G_TYPE_OBJECT,
|
||||||
|
G_IMPLEMENT_INTERFACE (META_TYPE_ALT_TAB_HANDLER,
|
||||||
|
meta_alt_tab_handler_default_interface_init))
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_SCREEN = 1,
|
||||||
|
PROP_IMMEDIATE
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_alt_tab_handler_default_init (MetaAltTabHandlerDefault *hd)
|
||||||
|
{
|
||||||
|
hd->entries = g_array_new (FALSE, FALSE, sizeof (MetaTabEntry));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_alt_tab_handler_default_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
MetaAltTabHandlerDefault *hd = META_ALT_TAB_HANDLER_DEFAULT (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_SCREEN:
|
||||||
|
hd->screen = g_value_get_object (value);
|
||||||
|
break;
|
||||||
|
case PROP_IMMEDIATE:
|
||||||
|
hd->immediate_mode = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_alt_tab_handler_default_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
MetaAltTabHandlerDefault *hd = META_ALT_TAB_HANDLER_DEFAULT (object);
|
||||||
|
|
||||||
|
g_array_free (hd->entries, TRUE);
|
||||||
|
|
||||||
|
if (hd->tab_popup)
|
||||||
|
meta_ui_tab_popup_free (hd->tab_popup);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (meta_alt_tab_handler_default_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_alt_tab_handler_default_add_window (MetaAltTabHandler *handler,
|
||||||
|
MetaWindow *window)
|
||||||
|
{
|
||||||
|
MetaAltTabHandlerDefault *hd = META_ALT_TAB_HANDLER_DEFAULT (handler);
|
||||||
|
MetaTabEntry entry;
|
||||||
|
MetaRectangle r;
|
||||||
|
|
||||||
|
entry.key = (MetaTabEntryKey) window;
|
||||||
|
entry.title = window->title;
|
||||||
|
entry.icon = window->icon;
|
||||||
|
entry.blank = FALSE;
|
||||||
|
entry.hidden = !meta_window_showing_on_its_workspace (window);
|
||||||
|
entry.demands_attention = window->wm_state_demands_attention;
|
||||||
|
|
||||||
|
if (hd->immediate_mode || !entry.hidden ||
|
||||||
|
!meta_window_get_icon_geometry (window, &r))
|
||||||
|
meta_window_get_outer_rect (window, &r);
|
||||||
|
entry.rect = r;
|
||||||
|
|
||||||
|
/* Find inside of highlight rectangle to be used when window is
|
||||||
|
* outlined for tabbing. This should be the size of the
|
||||||
|
* east/west frame, and the size of the south frame, on those
|
||||||
|
* sides. On the top it should be the size of the south frame
|
||||||
|
* edge.
|
||||||
|
*/
|
||||||
|
#define OUTLINE_WIDTH 5
|
||||||
|
/* Top side */
|
||||||
|
if (!entry.hidden &&
|
||||||
|
window->frame && window->frame->bottom_height > 0 &&
|
||||||
|
window->frame->child_y >= window->frame->bottom_height)
|
||||||
|
entry.inner_rect.y = window->frame->bottom_height;
|
||||||
|
else
|
||||||
|
entry.inner_rect.y = OUTLINE_WIDTH;
|
||||||
|
|
||||||
|
/* Bottom side */
|
||||||
|
if (!entry.hidden &&
|
||||||
|
window->frame && window->frame->bottom_height != 0)
|
||||||
|
entry.inner_rect.height = r.height
|
||||||
|
- entry.inner_rect.y - window->frame->bottom_height;
|
||||||
|
else
|
||||||
|
entry.inner_rect.height = r.height
|
||||||
|
- entry.inner_rect.y - OUTLINE_WIDTH;
|
||||||
|
|
||||||
|
/* Left side */
|
||||||
|
if (!entry.hidden && window->frame && window->frame->child_x != 0)
|
||||||
|
entry.inner_rect.x = window->frame->child_x;
|
||||||
|
else
|
||||||
|
entry.inner_rect.x = OUTLINE_WIDTH;
|
||||||
|
|
||||||
|
/* Right side */
|
||||||
|
if (!entry.hidden &&
|
||||||
|
window->frame && window->frame->right_width != 0)
|
||||||
|
entry.inner_rect.width = r.width
|
||||||
|
- entry.inner_rect.x - window->frame->right_width;
|
||||||
|
else
|
||||||
|
entry.inner_rect.width = r.width
|
||||||
|
- entry.inner_rect.x - OUTLINE_WIDTH;
|
||||||
|
|
||||||
|
g_array_append_val (hd->entries, entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_alt_tab_handler_default_show (MetaAltTabHandler *handler,
|
||||||
|
MetaWindow *initial_selection)
|
||||||
|
{
|
||||||
|
MetaAltTabHandlerDefault *hd = META_ALT_TAB_HANDLER_DEFAULT (handler);
|
||||||
|
|
||||||
|
if (hd->tab_popup)
|
||||||
|
return;
|
||||||
|
|
||||||
|
hd->tab_popup = meta_ui_tab_popup_new ((MetaTabEntry *)hd->entries->data,
|
||||||
|
hd->screen->number,
|
||||||
|
hd->entries->len,
|
||||||
|
5, /* FIXME */
|
||||||
|
TRUE);
|
||||||
|
meta_ui_tab_popup_select (hd->tab_popup, (MetaTabEntryKey) initial_selection);
|
||||||
|
meta_ui_tab_popup_set_showing (hd->tab_popup, !hd->immediate_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_alt_tab_handler_default_destroy (MetaAltTabHandler *handler)
|
||||||
|
{
|
||||||
|
MetaAltTabHandlerDefault *hd = META_ALT_TAB_HANDLER_DEFAULT (handler);
|
||||||
|
|
||||||
|
if (hd->tab_popup)
|
||||||
|
{
|
||||||
|
meta_ui_tab_popup_free (hd->tab_popup);
|
||||||
|
hd->tab_popup = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_alt_tab_handler_default_forward (MetaAltTabHandler *handler)
|
||||||
|
{
|
||||||
|
MetaAltTabHandlerDefault *hd = META_ALT_TAB_HANDLER_DEFAULT (handler);
|
||||||
|
|
||||||
|
if (hd->tab_popup)
|
||||||
|
meta_ui_tab_popup_forward (hd->tab_popup);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_alt_tab_handler_default_backward (MetaAltTabHandler *handler)
|
||||||
|
{
|
||||||
|
MetaAltTabHandlerDefault *hd = META_ALT_TAB_HANDLER_DEFAULT (handler);
|
||||||
|
|
||||||
|
if (hd->tab_popup)
|
||||||
|
meta_ui_tab_popup_backward (hd->tab_popup);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MetaWindow *
|
||||||
|
meta_alt_tab_handler_default_get_selected (MetaAltTabHandler *handler)
|
||||||
|
{
|
||||||
|
MetaAltTabHandlerDefault *hd = META_ALT_TAB_HANDLER_DEFAULT (handler);
|
||||||
|
|
||||||
|
if (hd->tab_popup)
|
||||||
|
return (MetaWindow *)meta_ui_tab_popup_get_selected (hd->tab_popup);
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_alt_tab_handler_default_class_init (MetaAltTabHandlerDefaultClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->set_property = meta_alt_tab_handler_default_set_property;
|
||||||
|
object_class->finalize = meta_alt_tab_handler_default_finalize;
|
||||||
|
|
||||||
|
g_object_class_override_property (object_class, PROP_SCREEN, "screen");
|
||||||
|
g_object_class_override_property (object_class, PROP_IMMEDIATE, "immediate");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_alt_tab_handler_default_interface_init (MetaAltTabHandlerInterface *handler_iface)
|
||||||
|
{
|
||||||
|
handler_iface->add_window = meta_alt_tab_handler_default_add_window;
|
||||||
|
handler_iface->show = meta_alt_tab_handler_default_show;
|
||||||
|
handler_iface->destroy = meta_alt_tab_handler_default_destroy;
|
||||||
|
handler_iface->forward = meta_alt_tab_handler_default_forward;
|
||||||
|
handler_iface->backward = meta_alt_tab_handler_default_backward;
|
||||||
|
handler_iface->get_selected = meta_alt_tab_handler_default_get_selected;
|
||||||
|
}
|
@ -2060,7 +2060,7 @@ process_tab_grab (MetaDisplay *display,
|
|||||||
* implementing Alt+Tab & Co., we call this custom handler; we do not
|
* implementing Alt+Tab & Co., we call this custom handler; we do not
|
||||||
* mess about with the grab, as that is up to the handler to deal with.
|
* mess about with the grab, as that is up to the handler to deal with.
|
||||||
*/
|
*/
|
||||||
if (!screen->tab_popup)
|
if (!screen->tab_handler)
|
||||||
{
|
{
|
||||||
MetaKeyHandler *handler = NULL;
|
MetaKeyHandler *handler = NULL;
|
||||||
const gchar *handler_name = NULL;
|
const gchar *handler_name = NULL;
|
||||||
@ -3060,7 +3060,7 @@ do_choose_window (MetaDisplay *display,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
meta_screen_ensure_tab_popup (screen, type,
|
meta_screen_tab_popup_create (screen, type,
|
||||||
show_popup ? META_TAB_SHOW_ICON :
|
show_popup ? META_TAB_SHOW_ICON :
|
||||||
META_TAB_SHOW_INSTANTLY,
|
META_TAB_SHOW_INSTANTLY,
|
||||||
initial_selection);
|
initial_selection);
|
||||||
@ -3440,7 +3440,7 @@ handle_workspace_switch (MetaDisplay *display,
|
|||||||
meta_workspace_activate (next, event->xkey.time);
|
meta_workspace_activate (next, event->xkey.time);
|
||||||
|
|
||||||
if (grabbed_before_release && !meta_prefs_get_no_tab_popup ())
|
if (grabbed_before_release && !meta_prefs_get_no_tab_popup ())
|
||||||
meta_screen_ensure_workspace_popup (screen, next);
|
meta_screen_workspace_popup_create (screen, next);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "display-private.h"
|
#include "display-private.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
#include "alttabhandler.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
|
||||||
typedef struct _MetaXineramaScreenInfo MetaXineramaScreenInfo;
|
typedef struct _MetaXineramaScreenInfo MetaXineramaScreenInfo;
|
||||||
@ -80,7 +81,8 @@ struct _MetaScreen
|
|||||||
Visual *default_xvisual;
|
Visual *default_xvisual;
|
||||||
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;
|
MetaAltTabHandler *tab_handler;
|
||||||
|
MetaTabPopup *ws_popup;
|
||||||
|
|
||||||
MetaWorkspace *active_workspace;
|
MetaWorkspace *active_workspace;
|
||||||
|
|
||||||
@ -164,7 +166,7 @@ void meta_screen_set_cursor (MetaScreen *scree
|
|||||||
MetaCursor cursor);
|
MetaCursor cursor);
|
||||||
void meta_screen_update_cursor (MetaScreen *screen);
|
void meta_screen_update_cursor (MetaScreen *screen);
|
||||||
|
|
||||||
void meta_screen_ensure_tab_popup (MetaScreen *screen,
|
void meta_screen_tab_popup_create (MetaScreen *screen,
|
||||||
MetaTabList list_type,
|
MetaTabList list_type,
|
||||||
MetaTabShowType show_type,
|
MetaTabShowType show_type,
|
||||||
MetaWindow *initial_window);
|
MetaWindow *initial_window);
|
||||||
@ -173,7 +175,7 @@ void meta_screen_tab_popup_backward (MetaScreen *scree
|
|||||||
MetaWindow* meta_screen_tab_popup_get_selected (MetaScreen *screen);
|
MetaWindow* meta_screen_tab_popup_get_selected (MetaScreen *screen);
|
||||||
void meta_screen_tab_popup_destroy (MetaScreen *screen);
|
void meta_screen_tab_popup_destroy (MetaScreen *screen);
|
||||||
|
|
||||||
void meta_screen_ensure_workspace_popup (MetaScreen *screen,
|
void meta_screen_workspace_popup_create (MetaScreen *screen,
|
||||||
MetaWorkspace *initial_selection);
|
MetaWorkspace *initial_selection);
|
||||||
void meta_screen_workspace_popup_select (MetaScreen *screen,
|
void meta_screen_workspace_popup_select (MetaScreen *screen,
|
||||||
MetaWorkspace *workspace);
|
MetaWorkspace *workspace);
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "stack.h"
|
#include "stack.h"
|
||||||
#include "xprops.h"
|
#include "xprops.h"
|
||||||
#include "compositor.h"
|
#include "compositor.h"
|
||||||
|
#include "alttabhandlerdefault.h"
|
||||||
|
|
||||||
#ifdef HAVE_SOLARIS_XINERAMA
|
#ifdef HAVE_SOLARIS_XINERAMA
|
||||||
#include <X11/extensions/xinerama.h>
|
#include <X11/extensions/xinerama.h>
|
||||||
@ -711,7 +712,7 @@ meta_screen_new (MetaDisplay *display,
|
|||||||
screen->ui = meta_ui_new (screen->display->xdisplay,
|
screen->ui = meta_ui_new (screen->display->xdisplay,
|
||||||
screen->xscreen);
|
screen->xscreen);
|
||||||
|
|
||||||
screen->tab_popup = NULL;
|
screen->tab_handler = NULL;
|
||||||
screen->ws_popup = NULL;
|
screen->ws_popup = NULL;
|
||||||
|
|
||||||
screen->stack = meta_stack_new (screen);
|
screen->stack = meta_stack_new (screen);
|
||||||
@ -1424,157 +1425,66 @@ meta_screen_update_cursor (MetaScreen *screen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_screen_ensure_tab_popup (MetaScreen *screen,
|
meta_screen_tab_popup_create (MetaScreen *screen,
|
||||||
MetaTabList list_type,
|
MetaTabList list_type,
|
||||||
MetaTabShowType show_type,
|
MetaTabShowType show_type,
|
||||||
MetaWindow *initial_selection)
|
MetaWindow *initial_selection)
|
||||||
{
|
{
|
||||||
MetaTabEntry *entries;
|
|
||||||
GList *tab_list;
|
GList *tab_list;
|
||||||
GList *tmp;
|
GList *tmp;
|
||||||
int len;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (screen->tab_popup)
|
g_return_if_fail (screen->tab_handler == NULL);
|
||||||
return;
|
|
||||||
|
screen->tab_handler = meta_alt_tab_handler_new (screen,
|
||||||
|
show_type == META_TAB_SHOW_INSTANTLY);
|
||||||
|
|
||||||
tab_list = meta_display_get_tab_list (screen->display,
|
tab_list = meta_display_get_tab_list (screen->display,
|
||||||
list_type,
|
list_type,
|
||||||
screen,
|
screen,
|
||||||
screen->active_workspace);
|
screen->active_workspace);
|
||||||
|
|
||||||
len = g_list_length (tab_list);
|
for (tmp = tab_list; tmp; tmp = tmp->next)
|
||||||
|
meta_alt_tab_handler_add_window (screen->tab_handler, tmp->data);
|
||||||
|
|
||||||
entries = g_new (MetaTabEntry, len + 1);
|
meta_alt_tab_handler_show (screen->tab_handler, initial_selection);
|
||||||
entries[len].key = NULL;
|
|
||||||
entries[len].title = NULL;
|
|
||||||
entries[len].icon = NULL;
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
tmp = tab_list;
|
|
||||||
while (i < len)
|
|
||||||
{
|
|
||||||
MetaWindow *window;
|
|
||||||
MetaRectangle r;
|
|
||||||
GdkPixbuf *win_pixbuf;
|
|
||||||
int width, height;
|
|
||||||
|
|
||||||
window = tmp->data;
|
|
||||||
|
|
||||||
entries[i].key = (MetaTabEntryKey) window;
|
|
||||||
entries[i].title = window->title;
|
|
||||||
entries[i].icon = g_object_ref (window->icon);
|
|
||||||
entries[i].blank = FALSE;
|
|
||||||
entries[i].hidden = !meta_window_showing_on_its_workspace (window);
|
|
||||||
entries[i].demands_attention = window->wm_state_demands_attention;
|
|
||||||
|
|
||||||
if (show_type == META_TAB_SHOW_INSTANTLY ||
|
|
||||||
!entries[i].hidden ||
|
|
||||||
!meta_window_get_icon_geometry (window, &r))
|
|
||||||
meta_window_get_outer_rect (window, &r);
|
|
||||||
|
|
||||||
entries[i].rect = r;
|
|
||||||
|
|
||||||
/* Find inside of highlight rectangle to be used when window is
|
|
||||||
* outlined for tabbing. This should be the size of the
|
|
||||||
* east/west frame, and the size of the south frame, on those
|
|
||||||
* sides. On the top it should be the size of the south frame
|
|
||||||
* edge.
|
|
||||||
*/
|
|
||||||
#define OUTLINE_WIDTH 5
|
|
||||||
/* Top side */
|
|
||||||
if (!entries[i].hidden &&
|
|
||||||
window->frame && window->frame->bottom_height > 0 &&
|
|
||||||
window->frame->child_y >= window->frame->bottom_height)
|
|
||||||
entries[i].inner_rect.y = window->frame->bottom_height;
|
|
||||||
else
|
|
||||||
entries[i].inner_rect.y = OUTLINE_WIDTH;
|
|
||||||
|
|
||||||
/* Bottom side */
|
|
||||||
if (!entries[i].hidden &&
|
|
||||||
window->frame && window->frame->bottom_height != 0)
|
|
||||||
entries[i].inner_rect.height = r.height
|
|
||||||
- entries[i].inner_rect.y - window->frame->bottom_height;
|
|
||||||
else
|
|
||||||
entries[i].inner_rect.height = r.height
|
|
||||||
- entries[i].inner_rect.y - OUTLINE_WIDTH;
|
|
||||||
|
|
||||||
/* Left side */
|
|
||||||
if (!entries[i].hidden && window->frame && window->frame->child_x != 0)
|
|
||||||
entries[i].inner_rect.x = window->frame->child_x;
|
|
||||||
else
|
|
||||||
entries[i].inner_rect.x = OUTLINE_WIDTH;
|
|
||||||
|
|
||||||
/* Right side */
|
|
||||||
if (!entries[i].hidden &&
|
|
||||||
window->frame && window->frame->right_width != 0)
|
|
||||||
entries[i].inner_rect.width = r.width
|
|
||||||
- entries[i].inner_rect.x - window->frame->right_width;
|
|
||||||
else
|
|
||||||
entries[i].inner_rect.width = r.width
|
|
||||||
- entries[i].inner_rect.x - OUTLINE_WIDTH;
|
|
||||||
|
|
||||||
++i;
|
|
||||||
tmp = tmp->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!meta_prefs_get_no_tab_popup ())
|
|
||||||
screen->tab_popup = meta_ui_tab_popup_new (entries,
|
|
||||||
screen->number,
|
|
||||||
len,
|
|
||||||
5, /* FIXME */
|
|
||||||
TRUE);
|
|
||||||
|
|
||||||
for (i = 0; i < len; i++)
|
|
||||||
g_object_unref (entries[i].icon);
|
|
||||||
|
|
||||||
g_free (entries);
|
|
||||||
|
|
||||||
g_list_free (tab_list);
|
|
||||||
|
|
||||||
meta_ui_tab_popup_select (screen->tab_popup,
|
|
||||||
(MetaTabEntryKey) initial_selection);
|
|
||||||
|
|
||||||
if (show_type != META_TAB_SHOW_INSTANTLY)
|
|
||||||
meta_ui_tab_popup_set_showing (screen->tab_popup, TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_screen_tab_popup_forward (MetaScreen *screen)
|
meta_screen_tab_popup_forward (MetaScreen *screen)
|
||||||
{
|
{
|
||||||
g_return_if_fail (screen->tab_popup != NULL);
|
g_return_if_fail (screen->tab_handler != NULL);
|
||||||
|
|
||||||
meta_ui_tab_popup_forward (screen->tab_popup);
|
meta_alt_tab_handler_forward (screen->tab_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_screen_tab_popup_backward (MetaScreen *screen)
|
meta_screen_tab_popup_backward (MetaScreen *screen)
|
||||||
{
|
{
|
||||||
g_return_if_fail (screen->tab_popup != NULL);
|
g_return_if_fail (screen->tab_handler != NULL);
|
||||||
|
|
||||||
meta_ui_tab_popup_backward (screen->tab_popup);
|
meta_alt_tab_handler_backward (screen->tab_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaWindow *
|
MetaWindow *
|
||||||
meta_screen_tab_popup_get_selected (MetaScreen *screen)
|
meta_screen_tab_popup_get_selected (MetaScreen *screen)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (screen->tab_popup != NULL, NULL);
|
g_return_val_if_fail (screen->tab_handler != NULL, NULL);
|
||||||
|
|
||||||
return (MetaWindow *) meta_ui_tab_popup_get_selected (screen->tab_popup);
|
return meta_alt_tab_handler_get_selected (screen->tab_handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_screen_tab_popup_destroy (MetaScreen *screen)
|
meta_screen_tab_popup_destroy (MetaScreen *screen)
|
||||||
{
|
{
|
||||||
if (screen->tab_popup)
|
g_return_if_fail (screen->tab_handler != NULL);
|
||||||
{
|
|
||||||
meta_ui_tab_popup_free (screen->tab_popup);
|
meta_alt_tab_handler_destroy (screen->tab_handler);
|
||||||
screen->tab_popup = NULL;
|
g_object_unref (screen->tab_handler);
|
||||||
}
|
screen->tab_handler = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_screen_ensure_workspace_popup (MetaScreen *screen,
|
meta_screen_workspace_popup_create (MetaScreen *screen,
|
||||||
MetaWorkspace *initial_selection)
|
MetaWorkspace *initial_selection)
|
||||||
{
|
{
|
||||||
MetaTabEntry *entries;
|
MetaTabEntry *entries;
|
||||||
@ -1584,8 +1494,7 @@ meta_screen_ensure_workspace_popup (MetaScreen *screen,
|
|||||||
int n_workspaces;
|
int n_workspaces;
|
||||||
int current_workspace;
|
int current_workspace;
|
||||||
|
|
||||||
if (screen->ws_popup || meta_prefs_get_no_tab_popup ())
|
g_return_if_fail (screen->ws_popup == NULL);
|
||||||
return;
|
|
||||||
|
|
||||||
current_workspace = meta_workspace_index (screen->active_workspace);
|
current_workspace = meta_workspace_index (screen->active_workspace);
|
||||||
n_workspaces = meta_screen_get_n_workspaces (screen);
|
n_workspaces = meta_screen_get_n_workspaces (screen);
|
||||||
|
73
src/include/alttabhandler.h
Normal file
73
src/include/alttabhandler.h
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||||
|
|
||||||
|
/* Metacity Alt-Tab abstraction */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2009 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* 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, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
* 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef META_ALT_TAB_HANDLER_H
|
||||||
|
#define META_ALT_TAB_HANDLER_H
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
#define META_TYPE_ALT_TAB_HANDLER (meta_alt_tab_handler_get_type ())
|
||||||
|
#define META_ALT_TAB_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_ALT_TAB_HANDLER, MetaAltTabHandler))
|
||||||
|
#define META_ALT_TAB_HANDLER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), META_TYPE_ALT_TAB_HANDLER, MetaAltTabHandlerInterface))
|
||||||
|
|
||||||
|
typedef struct _MetaAltTabHandler MetaAltTabHandler;
|
||||||
|
typedef struct _MetaAltTabHandlerInterface MetaAltTabHandlerInterface;
|
||||||
|
|
||||||
|
struct _MetaAltTabHandlerInterface {
|
||||||
|
GTypeInterface g_iface;
|
||||||
|
|
||||||
|
void (*add_window) (MetaAltTabHandler *handler,
|
||||||
|
MetaWindow *window);
|
||||||
|
|
||||||
|
void (*show) (MetaAltTabHandler *handler,
|
||||||
|
MetaWindow *initial_selection);
|
||||||
|
void (*destroy) (MetaAltTabHandler *handler);
|
||||||
|
|
||||||
|
void (*forward) (MetaAltTabHandler *handler);
|
||||||
|
void (*backward) (MetaAltTabHandler *handler);
|
||||||
|
|
||||||
|
MetaWindow * (*get_selected) (MetaAltTabHandler *handler);
|
||||||
|
};
|
||||||
|
|
||||||
|
GType meta_alt_tab_handler_get_type (void);
|
||||||
|
|
||||||
|
void meta_alt_tab_handler_register (GType type);
|
||||||
|
MetaAltTabHandler *meta_alt_tab_handler_new (MetaScreen *screen,
|
||||||
|
gboolean immediate);
|
||||||
|
|
||||||
|
void meta_alt_tab_handler_add_window (MetaAltTabHandler *handler,
|
||||||
|
MetaWindow *window);
|
||||||
|
|
||||||
|
void meta_alt_tab_handler_show (MetaAltTabHandler *handler,
|
||||||
|
MetaWindow *initial_selection);
|
||||||
|
void meta_alt_tab_handler_destroy (MetaAltTabHandler *handler);
|
||||||
|
|
||||||
|
void meta_alt_tab_handler_forward (MetaAltTabHandler *handler);
|
||||||
|
void meta_alt_tab_handler_backward (MetaAltTabHandler *handler);
|
||||||
|
|
||||||
|
MetaWindow *meta_alt_tab_handler_get_selected (MetaAltTabHandler *handler);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
55
src/include/alttabhandlerdefault.h
Normal file
55
src/include/alttabhandlerdefault.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||||
|
|
||||||
|
/* Metacity Alt-Tab abstraction: default implementation */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2009 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* 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, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
* 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef META_ALT_TAB_HANDLER_DEFAULT_H
|
||||||
|
#define META_ALT_TAB_HANDLER_DEFAULT_H
|
||||||
|
|
||||||
|
#include "alttabhandler.h"
|
||||||
|
#include "tabpopup.h"
|
||||||
|
|
||||||
|
#define META_TYPE_ALT_TAB_HANDLER_DEFAULT (meta_alt_tab_handler_default_get_type ())
|
||||||
|
#define META_ALT_TAB_HANDLER_DEFAULT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_ALT_TAB_HANDLER_DEFAULT, MetaAltTabHandlerDefault))
|
||||||
|
|
||||||
|
typedef struct _MetaAltTabHandlerDefault MetaAltTabHandlerDefault;
|
||||||
|
typedef struct _MetaAltTabHandlerDefaultClass MetaAltTabHandlerDefaultClass;
|
||||||
|
|
||||||
|
struct _MetaAltTabHandlerDefault {
|
||||||
|
GObject parent_instance;
|
||||||
|
|
||||||
|
MetaScreen *screen;
|
||||||
|
|
||||||
|
GArray *entries;
|
||||||
|
gboolean immediate_mode;
|
||||||
|
|
||||||
|
MetaTabPopup *tab_popup;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _MetaAltTabHandlerDefaultClass {
|
||||||
|
GObjectClass parent_class;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
GType meta_alt_tab_handler_default_get_type (void);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user