mirror of
https://github.com/brl/mutter.git
synced 2025-04-15 06:39:38 +00:00
Remove MetaAltTabHandler
gnome-shell is no longer using MetaAltTabHandler, so there's no need to keep that abstraction around. This reverts commit 1d5117a6 (and a comment from 7b0ba87b), with a bit of rebasing and whitespace cleanup. https://bugzilla.gnome.org/show_bug.cgi?id=596210
This commit is contained in:
parent
d6143e4c73
commit
d04b15ee25
@ -16,10 +16,6 @@ mutter_built_sources = \
|
|||||||
mutter_SOURCES= \
|
mutter_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 \
|
||||||
@ -153,7 +149,6 @@ libmutterincludedir = $(includedir)/mutter/mutter-private
|
|||||||
# Headers installed for plugins; introspected information will
|
# Headers installed for plugins; introspected information will
|
||||||
# be extracted into Mutter-<version>.gir
|
# be extracted into Mutter-<version>.gir
|
||||||
libmutterinclude_base_headers = \
|
libmutterinclude_base_headers = \
|
||||||
include/alttabhandler.h \
|
|
||||||
include/boxes.h \
|
include/boxes.h \
|
||||||
ui/gradient.h \
|
ui/gradient.h \
|
||||||
include/main.h \
|
include/main.h \
|
||||||
|
@ -1,138 +0,0 @@
|
|||||||
/* -*- 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);
|
|
||||||
}
|
|
@ -1,223 +0,0 @@
|
|||||||
/* -*- 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;
|
|
||||||
}
|
|
@ -2047,15 +2047,11 @@ process_tab_grab (MetaDisplay *display,
|
|||||||
action = META_KEYBINDING_ACTION_NONE;
|
action = META_KEYBINDING_ACTION_NONE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There are currently two different ways of customizing Alt-Tab, you can either
|
* If there is no tab_pop up object, i.e., there is some custom handler
|
||||||
* provide a replacement AltTabHandler object, or you can hook into the keybindings
|
* implementing Alt+Tab & Co., we call this custom handler; we do not
|
||||||
* meta_keybindings_set_custom_handler() and call meta_display_begin_grab_op()
|
* mess about with the grab, as that is up to the handler to deal with.
|
||||||
* yourself with one of the "tabbing" grab ops META_GRAB_OP_KEYBOARD_TABBING_NORMAL,
|
|
||||||
* etc. See meta_display_process_key_event() for the complete list. If screen->tab_handler
|
|
||||||
* is NULL, the latter mechanism is being used. We skip most of our normal
|
|
||||||
* processing and just make sure that the right custom handlers get called.
|
|
||||||
*/
|
*/
|
||||||
if (!screen->tab_handler)
|
if (!screen->tab_popup)
|
||||||
{
|
{
|
||||||
if (event->type == KeyRelease)
|
if (event->type == KeyRelease)
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,6 @@
|
|||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include "stack-tracker.h"
|
#include "stack-tracker.h"
|
||||||
#include "alttabhandler.h"
|
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
|
||||||
typedef struct _MetaMonitorInfo MetaMonitorInfo;
|
typedef struct _MetaMonitorInfo MetaMonitorInfo;
|
||||||
@ -82,9 +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;
|
||||||
MetaAltTabHandler *tab_handler;
|
MetaTabPopup *tab_popup, *ws_popup;
|
||||||
MetaTabPopup *ws_popup;
|
|
||||||
|
|
||||||
MetaWorkspace *active_workspace;
|
MetaWorkspace *active_workspace;
|
||||||
|
|
||||||
/* This window holds the focus when we don't want to focus
|
/* This window holds the focus when we don't want to focus
|
||||||
|
@ -38,7 +38,6 @@
|
|||||||
#include "stack.h"
|
#include "stack.h"
|
||||||
#include "xprops.h"
|
#include "xprops.h"
|
||||||
#include "compositor.h"
|
#include "compositor.h"
|
||||||
#include "alttabhandlerdefault.h"
|
|
||||||
#include "mutter-marshal.h"
|
#include "mutter-marshal.h"
|
||||||
#include "mutter-enum-types.h"
|
#include "mutter-enum-types.h"
|
||||||
|
|
||||||
@ -781,9 +780,9 @@ 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_handler = NULL;
|
screen->tab_popup = NULL;
|
||||||
screen->ws_popup = NULL;
|
screen->ws_popup = NULL;
|
||||||
|
|
||||||
screen->stack = meta_stack_new (screen);
|
screen->stack = meta_stack_new (screen);
|
||||||
screen->stack_tracker = meta_stack_tracker_new (screen);
|
screen->stack_tracker = meta_stack_tracker_new (screen);
|
||||||
|
|
||||||
@ -1516,58 +1515,146 @@ meta_screen_tab_popup_create (MetaScreen *screen,
|
|||||||
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;
|
||||||
|
|
||||||
g_return_if_fail (screen->tab_handler == NULL);
|
if (screen->tab_popup)
|
||||||
|
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);
|
||||||
|
|
||||||
for (tmp = tab_list; tmp; tmp = tmp->next)
|
len = g_list_length (tab_list);
|
||||||
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;
|
||||||
|
|
||||||
|
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_handler != NULL);
|
g_return_if_fail (screen->tab_popup != NULL);
|
||||||
|
|
||||||
meta_alt_tab_handler_forward (screen->tab_handler);
|
meta_ui_tab_popup_forward (screen->tab_popup);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_screen_tab_popup_backward (MetaScreen *screen)
|
meta_screen_tab_popup_backward (MetaScreen *screen)
|
||||||
{
|
{
|
||||||
g_return_if_fail (screen->tab_handler != NULL);
|
g_return_if_fail (screen->tab_popup != NULL);
|
||||||
|
|
||||||
meta_alt_tab_handler_backward (screen->tab_handler);
|
meta_ui_tab_popup_backward (screen->tab_popup);
|
||||||
}
|
}
|
||||||
|
|
||||||
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_handler != NULL, NULL);
|
g_return_val_if_fail (screen->tab_popup != NULL, NULL);
|
||||||
|
|
||||||
return meta_alt_tab_handler_get_selected (screen->tab_handler);
|
return (MetaWindow *) meta_ui_tab_popup_get_selected (screen->tab_popup);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_screen_tab_popup_destroy (MetaScreen *screen)
|
meta_screen_tab_popup_destroy (MetaScreen *screen)
|
||||||
{
|
{
|
||||||
if (!screen->tab_handler)
|
if (screen->tab_popup)
|
||||||
return;
|
{
|
||||||
|
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
|
||||||
@ -1580,8 +1667,9 @@ meta_screen_workspace_popup_create (MetaScreen *screen,
|
|||||||
MetaWorkspaceLayout layout;
|
MetaWorkspaceLayout layout;
|
||||||
int n_workspaces;
|
int n_workspaces;
|
||||||
int current_workspace;
|
int current_workspace;
|
||||||
|
|
||||||
g_return_if_fail (screen->ws_popup == NULL);
|
if (screen->ws_popup || meta_prefs_get_no_tab_popup ())
|
||||||
|
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);
|
||||||
|
@ -1,73 +0,0 @@
|
|||||||
/* -*- 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
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
|||||||
/* -*- 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…
x
Reference in New Issue
Block a user