2006-10-01 22:30:10 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
Comprehensively rename to Mutter
Code:
All references in the code not related to themes, keybindings, or
GConf were changed from 'metacity' to 'mutter'. This includes, among other
things, strings, comments, the atoms used in the message protocol, and
the envvars used for debugging. The GConf schema file was reduced to
the 3 settings new to mutter.
The overall version was brought up to 2.27 to match current gnome.
Structure:
All files named '*metacity*' were renamed '*mutter*' with appropriate
changes in the automake system. Files removed are
doc/creating_themes, src/themes, doc/metacity-theme.dtd,
metacity.doap. These files will eventually end up in an external
gnome-wm-data module.
Installation location:
On the filesystem the mutter-plugindir was change from
$(libdir)/metacity/plugins/clutter to just $(libdir)/mutter/plugins.
The mutter-plugins.pc.in reflects these changes.
Note:
mutter.desktop.in and mutter-wm.desktop both continue to have
X-GNOME-WMSettingsModule=metacity set. This allows
gnome-control-center to continue using libmetacity.so for
configuration. This is fine since most the general keybindings and wm
settings are being read from /apps/metacity/* in gconf.
2009-06-10 10:29:20 +00:00
|
|
|
/* Mutter interface for talking to GTK+ UI module */
|
2001-06-17 19:53:45 +00:00
|
|
|
|
2014-05-02 13:34:02 +00:00
|
|
|
/*
|
2002-08-10 16:47:43 +00:00
|
|
|
* Copyright (C) 2002 Havoc Pennington
|
2014-05-02 13:34:02 +00:00
|
|
|
*
|
2001-06-17 19:53:45 +00:00
|
|
|
* 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.
|
2014-05-02 13:34:02 +00:00
|
|
|
*
|
2001-06-17 19:53:45 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-12 01:42:06 +00:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2001-06-17 19:53:45 +00:00
|
|
|
*/
|
|
|
|
|
2008-08-20 09:31:10 +00:00
|
|
|
#include <config.h>
|
2011-03-06 00:29:12 +00:00
|
|
|
#include <meta/prefs.h>
|
2001-06-17 19:53:45 +00:00
|
|
|
#include "ui.h"
|
2001-06-18 03:24:25 +00:00
|
|
|
#include "frames.h"
|
2011-03-06 00:29:12 +00:00
|
|
|
#include <meta/util.h>
|
2001-08-31 06:13:07 +00:00
|
|
|
#include "core.h"
|
2010-10-18 18:34:14 +00:00
|
|
|
#include "theme-private.h"
|
2001-06-18 03:24:25 +00:00
|
|
|
|
2002-04-28 04:52:26 +00:00
|
|
|
#include <string.h>
|
Patch from Ed Catmur to fix keybindings with hex-values (coming from
2006-08-21 Elijah Newren <newren gmail com>
Patch from Ed Catmur to fix keybindings with hex-values (coming
from special extended keyboard keys). #140448.
* src/keybindings.c (struct _MetaKeyBinding): change keycode from
KeyCode to unsigned int (comment from Elijah: why???),
(reload_keycodes): only grab keysyms for keybindings that have
them, (count_bindings, rebuild_binding_table): bindings can be
valid either due to a valid keysym or a valid keycode,
(display_get_keybinding_action, meta_change_keygrab,
process_tab_grab, process_workspace_switch_grab): handle keycode
as well as keysym
* src/prefs.[ch] (struct MetaKeyCombo, update_binding,
update_list_binding): handle keycode as well as keysym
* src/ui.[ch] (meta_ui_accelerator_parse): new function special
cases strings of the form "0x[0-9a-fA-F]+" and otherwise calling
gtk_accelerator_parse(), (meta_ui_parse_accelerator,
meta_ui_parse_modifier): call meta_ui_accelerator_parse instead of
gtk_accelerator_parse.
2006-08-21 19:06:26 +00:00
|
|
|
#include <stdlib.h>
|
2010-09-24 11:30:40 +00:00
|
|
|
#include <cairo-xlib.h>
|
2002-04-28 04:52:26 +00:00
|
|
|
|
2001-06-18 03:24:25 +00:00
|
|
|
struct _MetaUI
|
|
|
|
{
|
|
|
|
Display *xdisplay;
|
|
|
|
Screen *xscreen;
|
|
|
|
MetaFrames *frames;
|
2014-05-05 22:56:56 +00:00
|
|
|
|
|
|
|
/* For double-click tracking */
|
|
|
|
gint button_click_number;
|
|
|
|
Window button_click_window;
|
|
|
|
int button_click_x;
|
|
|
|
int button_click_y;
|
|
|
|
guint32 button_click_time;
|
2001-06-18 03:24:25 +00:00
|
|
|
};
|
2001-06-17 19:53:45 +00:00
|
|
|
|
|
|
|
void
|
2011-03-05 21:16:26 +00:00
|
|
|
meta_ui_init (void)
|
2001-06-17 19:53:45 +00:00
|
|
|
{
|
2015-01-08 10:14:38 +00:00
|
|
|
const char *gdk_gl_env = NULL;
|
2013-08-19 11:01:55 +00:00
|
|
|
gdk_set_allowed_backends ("x11");
|
|
|
|
|
2015-01-08 10:14:38 +00:00
|
|
|
gdk_gl_env = g_getenv ("GDK_GL");
|
|
|
|
g_setenv("GDK_GL", "disable", TRUE);
|
|
|
|
|
2011-03-05 21:16:26 +00:00
|
|
|
if (!gtk_init_check (NULL, NULL))
|
2001-09-11 03:54:54 +00:00
|
|
|
meta_fatal ("Unable to open X display %s\n", XDisplayName (NULL));
|
2013-08-20 12:03:42 +00:00
|
|
|
|
2015-01-08 10:14:38 +00:00
|
|
|
if (gdk_gl_env)
|
|
|
|
g_setenv("GDK_GL", gdk_gl_env, TRUE);
|
|
|
|
else
|
|
|
|
unsetenv("GDK_GL");
|
|
|
|
|
2013-08-20 12:03:42 +00:00
|
|
|
/* We need to be able to fully trust that the window and monitor sizes
|
|
|
|
that Gdk reports corresponds to the X ones, so we disable the automatic
|
|
|
|
scale handling */
|
|
|
|
gdk_x11_display_set_window_scale (gdk_display_get_default (), 1);
|
2001-06-17 19:53:45 +00:00
|
|
|
}
|
2001-06-18 03:24:25 +00:00
|
|
|
|
2001-06-20 03:01:26 +00:00
|
|
|
Display*
|
2006-05-04 17:32:26 +00:00
|
|
|
meta_ui_get_display (void)
|
2001-06-20 03:01:26 +00:00
|
|
|
{
|
2010-09-10 07:17:55 +00:00
|
|
|
return GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
|
2001-06-20 03:01:26 +00:00
|
|
|
}
|
|
|
|
|
2012-09-10 18:19:21 +00:00
|
|
|
gint
|
|
|
|
meta_ui_get_screen_number (void)
|
|
|
|
{
|
|
|
|
return gdk_screen_get_number (gdk_screen_get_default ());
|
|
|
|
}
|
|
|
|
|
2001-06-18 03:24:25 +00:00
|
|
|
MetaUI*
|
|
|
|
meta_ui_new (Display *xdisplay,
|
|
|
|
Screen *screen)
|
|
|
|
{
|
2010-06-09 23:38:35 +00:00
|
|
|
GdkDisplay *gdisplay;
|
2001-06-18 03:24:25 +00:00
|
|
|
MetaUI *ui;
|
|
|
|
|
2010-06-09 23:38:35 +00:00
|
|
|
ui = g_new0 (MetaUI, 1);
|
2001-06-18 03:24:25 +00:00
|
|
|
ui->xdisplay = xdisplay;
|
|
|
|
ui->xscreen = screen;
|
|
|
|
|
2010-06-09 23:38:35 +00:00
|
|
|
gdisplay = gdk_x11_lookup_xdisplay (xdisplay);
|
|
|
|
g_assert (gdisplay == gdk_display_get_default ());
|
|
|
|
|
2002-05-08 16:24:28 +00:00
|
|
|
ui->frames = meta_frames_new (XScreenNumberOfScreen (screen));
|
2014-03-05 20:23:46 +00:00
|
|
|
/* GTK+ needs the frame-sync protocol to work in order to properly
|
|
|
|
* handle style changes. This means that the dummy widget we create
|
|
|
|
* to get the style for title bars actually needs to be mapped
|
|
|
|
* and fully tracked as a MetaWindow. Horrible, but mostly harmless -
|
|
|
|
* the window is a 1x1 overide redirect window positioned offscreen.
|
|
|
|
*/
|
2010-09-21 10:31:32 +00:00
|
|
|
gtk_widget_show (GTK_WIDGET (ui->frames));
|
2010-06-09 23:38:35 +00:00
|
|
|
|
2014-05-05 22:56:56 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdisplay), "meta-ui", ui);
|
|
|
|
|
2001-06-18 03:24:25 +00:00
|
|
|
return ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_ui_free (MetaUI *ui)
|
|
|
|
{
|
2014-05-05 22:56:56 +00:00
|
|
|
GdkDisplay *gdisplay;
|
|
|
|
|
2001-06-18 03:24:25 +00:00
|
|
|
gtk_widget_destroy (GTK_WIDGET (ui->frames));
|
2014-05-05 22:56:56 +00:00
|
|
|
|
|
|
|
gdisplay = gdk_x11_lookup_xdisplay (ui->xdisplay);
|
|
|
|
g_object_set_data (G_OBJECT (gdisplay), "meta-ui", NULL);
|
|
|
|
|
2001-06-18 03:24:25 +00:00
|
|
|
g_free (ui);
|
|
|
|
}
|
|
|
|
|
2014-07-31 15:41:39 +00:00
|
|
|
static void
|
|
|
|
set_background_none (Display *xdisplay,
|
|
|
|
Window xwindow)
|
|
|
|
{
|
|
|
|
XSetWindowAttributes attrs;
|
|
|
|
|
|
|
|
attrs.background_pixmap = None;
|
|
|
|
XChangeWindowAttributes (xdisplay, xwindow,
|
|
|
|
CWBackPixmap, &attrs);
|
|
|
|
}
|
|
|
|
|
2015-01-01 05:55:36 +00:00
|
|
|
MetaUIFrame *
|
|
|
|
meta_ui_create_frame (MetaUI *ui,
|
|
|
|
Display *xdisplay,
|
2015-01-01 19:39:55 +00:00
|
|
|
MetaWindow *meta_window,
|
2015-01-01 05:55:36 +00:00
|
|
|
Visual *xvisual,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gint screen_no,
|
|
|
|
gulong *create_serial)
|
2003-08-16 16:32:10 +00:00
|
|
|
{
|
|
|
|
GdkDisplay *display = gdk_x11_lookup_xdisplay (xdisplay);
|
|
|
|
GdkScreen *screen = gdk_display_get_screen (display, screen_no);
|
|
|
|
GdkWindowAttr attrs;
|
|
|
|
gint attributes_mask;
|
|
|
|
GdkWindow *window;
|
2003-11-16 04:19:18 +00:00
|
|
|
GdkVisual *visual;
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2003-08-16 16:32:10 +00:00
|
|
|
/* Default depth/visual handles clients with weird visuals; they can
|
|
|
|
* always be children of the root depth/visual obviously, but
|
|
|
|
* e.g. DRI games can't be children of a parent that has the same
|
|
|
|
* visual as the client.
|
|
|
|
*/
|
2003-11-16 04:19:18 +00:00
|
|
|
if (!xvisual)
|
|
|
|
visual = gdk_screen_get_system_visual (screen);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
visual = gdk_x11_screen_lookup_visual (screen,
|
|
|
|
XVisualIDFromVisual (xvisual));
|
|
|
|
}
|
2003-08-16 16:32:10 +00:00
|
|
|
|
|
|
|
attrs.title = NULL;
|
|
|
|
|
2015-03-12 20:00:24 +00:00
|
|
|
attrs.event_mask = GDK_EXPOSURE_MASK;
|
2003-08-16 16:32:10 +00:00
|
|
|
attrs.x = x;
|
|
|
|
attrs.y = y;
|
|
|
|
attrs.wclass = GDK_INPUT_OUTPUT;
|
2003-11-16 04:19:18 +00:00
|
|
|
attrs.visual = visual;
|
2003-08-16 16:32:10 +00:00
|
|
|
attrs.window_type = GDK_WINDOW_CHILD;
|
|
|
|
attrs.cursor = NULL;
|
|
|
|
attrs.wmclass_name = NULL;
|
|
|
|
attrs.wmclass_class = NULL;
|
|
|
|
attrs.override_redirect = FALSE;
|
|
|
|
|
2004-09-22 18:57:36 +00:00
|
|
|
attrs.width = width;
|
|
|
|
attrs.height = height;
|
|
|
|
|
2010-09-24 11:30:40 +00:00
|
|
|
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
|
2003-08-16 16:32:10 +00:00
|
|
|
|
2009-06-13 20:45:32 +00:00
|
|
|
/* We make an assumption that gdk_window_new() is going to call
|
|
|
|
* XCreateWindow as it's first operation; this seems to be true currently
|
|
|
|
* as long as you pass in a colormap.
|
|
|
|
*/
|
|
|
|
if (create_serial)
|
|
|
|
*create_serial = XNextRequest (xdisplay);
|
2003-08-16 16:32:10 +00:00
|
|
|
window =
|
|
|
|
gdk_window_new (gdk_screen_get_root_window(screen),
|
|
|
|
&attrs, attributes_mask);
|
|
|
|
|
|
|
|
gdk_window_resize (window, width, height);
|
2014-07-31 15:41:39 +00:00
|
|
|
set_background_none (xdisplay, GDK_WINDOW_XID (window));
|
2014-05-02 13:34:02 +00:00
|
|
|
|
2015-01-01 19:39:55 +00:00
|
|
|
return meta_frames_manage_window (ui->frames, meta_window, GDK_WINDOW_XID (window), window);
|
2003-08-16 16:32:10 +00:00
|
|
|
}
|
2001-06-18 03:24:25 +00:00
|
|
|
|
2001-06-20 03:01:26 +00:00
|
|
|
void
|
|
|
|
meta_ui_map_frame (MetaUI *ui,
|
|
|
|
Window xwindow)
|
|
|
|
{
|
|
|
|
GdkWindow *window;
|
2010-12-22 00:20:31 +00:00
|
|
|
GdkDisplay *display;
|
2001-06-20 03:01:26 +00:00
|
|
|
|
2010-12-22 00:20:31 +00:00
|
|
|
display = gdk_x11_lookup_xdisplay (ui->xdisplay);
|
|
|
|
window = gdk_x11_window_lookup_for_display (display, xwindow);
|
2001-06-20 03:01:26 +00:00
|
|
|
|
|
|
|
if (window)
|
2001-06-29 15:33:21 +00:00
|
|
|
gdk_window_show_unraised (window);
|
2001-06-20 03:01:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_ui_unmap_frame (MetaUI *ui,
|
|
|
|
Window xwindow)
|
|
|
|
{
|
|
|
|
GdkWindow *window;
|
2010-12-22 00:20:31 +00:00
|
|
|
GdkDisplay *display;
|
2001-06-20 03:01:26 +00:00
|
|
|
|
2010-12-22 00:20:31 +00:00
|
|
|
display = gdk_x11_lookup_xdisplay (ui->xdisplay);
|
|
|
|
window = gdk_x11_window_lookup_for_display (display, xwindow);
|
2001-06-20 03:01:26 +00:00
|
|
|
|
2001-08-30 04:01:38 +00:00
|
|
|
if (window)
|
2001-06-20 03:01:26 +00:00
|
|
|
gdk_window_hide (window);
|
|
|
|
}
|
|
|
|
|
2001-08-30 04:01:38 +00:00
|
|
|
gboolean
|
|
|
|
meta_ui_window_should_not_cause_focus (Display *xdisplay,
|
|
|
|
Window xwindow)
|
|
|
|
{
|
|
|
|
GdkWindow *window;
|
2010-12-22 00:20:31 +00:00
|
|
|
GdkDisplay *display;
|
2001-08-30 04:01:38 +00:00
|
|
|
|
2010-12-22 00:20:31 +00:00
|
|
|
display = gdk_x11_lookup_xdisplay (xdisplay);
|
|
|
|
window = gdk_x11_window_lookup_for_display (display, xwindow);
|
2001-08-30 04:01:38 +00:00
|
|
|
|
|
|
|
/* we shouldn't cause focus if we're an override redirect
|
|
|
|
* toplevel which is not foreign
|
|
|
|
*/
|
2009-04-30 17:45:17 +00:00
|
|
|
if (window && gdk_window_get_window_type (window) == GDK_WINDOW_TEMP)
|
2001-08-30 04:01:38 +00:00
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-09-11 04:37:10 +00:00
|
|
|
|
2004-01-10 17:16:07 +00:00
|
|
|
void
|
|
|
|
meta_ui_theme_get_frame_borders (MetaUI *ui,
|
|
|
|
MetaFrameType type,
|
|
|
|
MetaFrameFlags flags,
|
2011-07-12 04:37:41 +00:00
|
|
|
MetaFrameBorders *borders)
|
2004-01-10 17:16:07 +00:00
|
|
|
{
|
|
|
|
int text_height;
|
2014-09-25 04:44:45 +00:00
|
|
|
MetaStyleInfo *style_info = NULL;
|
2004-01-10 17:16:07 +00:00
|
|
|
PangoContext *context;
|
|
|
|
const PangoFontDescription *font_desc;
|
2012-12-16 23:41:42 +00:00
|
|
|
PangoFontDescription *free_font_desc = NULL;
|
2004-01-10 17:16:07 +00:00
|
|
|
|
2015-01-01 05:33:54 +00:00
|
|
|
GdkDisplay *display = gdk_x11_lookup_xdisplay (ui->xdisplay);
|
|
|
|
GdkScreen *screen = gdk_display_get_screen (display, XScreenNumberOfScreen (ui->xscreen));
|
2014-09-23 02:20:22 +00:00
|
|
|
|
2015-01-01 05:33:54 +00:00
|
|
|
style_info = meta_theme_create_style_info (screen, NULL);
|
2014-09-23 02:20:22 +00:00
|
|
|
|
2015-01-01 05:33:54 +00:00
|
|
|
context = gtk_widget_get_pango_context (GTK_WIDGET (ui->frames));
|
|
|
|
font_desc = meta_prefs_get_titlebar_font ();
|
2004-01-10 17:16:07 +00:00
|
|
|
|
2015-01-01 05:33:54 +00:00
|
|
|
if (!font_desc)
|
|
|
|
{
|
|
|
|
free_font_desc = meta_style_info_create_font_desc (style_info);
|
|
|
|
font_desc = (const PangoFontDescription *) free_font_desc;
|
|
|
|
}
|
2004-01-10 17:16:07 +00:00
|
|
|
|
2015-01-01 05:33:54 +00:00
|
|
|
text_height = meta_pango_font_desc_get_text_height (font_desc, context);
|
2004-01-10 17:16:07 +00:00
|
|
|
|
2015-01-01 05:33:54 +00:00
|
|
|
meta_theme_get_frame_borders (meta_theme_get_default (),
|
|
|
|
style_info, type, text_height, flags,
|
|
|
|
borders);
|
2012-12-16 23:41:42 +00:00
|
|
|
|
2015-01-01 05:33:54 +00:00
|
|
|
if (free_font_desc)
|
|
|
|
pango_font_description_free (free_font_desc);
|
2010-12-09 13:52:16 +00:00
|
|
|
|
2014-09-25 04:44:45 +00:00
|
|
|
if (style_info != NULL)
|
|
|
|
meta_style_info_unref (style_info);
|
2004-01-10 17:16:07 +00:00
|
|
|
}
|
|
|
|
|
2002-08-10 15:55:18 +00:00
|
|
|
gboolean
|
|
|
|
meta_ui_window_is_widget (MetaUI *ui,
|
|
|
|
Window xwindow)
|
|
|
|
{
|
2010-12-22 00:20:31 +00:00
|
|
|
GdkDisplay *display;
|
2002-08-10 15:55:18 +00:00
|
|
|
GdkWindow *window;
|
|
|
|
|
2010-12-22 00:20:31 +00:00
|
|
|
display = gdk_x11_lookup_xdisplay (ui->xdisplay);
|
|
|
|
window = gdk_x11_window_lookup_for_display (display, xwindow);
|
2002-08-10 15:55:18 +00:00
|
|
|
|
2003-08-16 16:32:10 +00:00
|
|
|
if (window)
|
2002-08-10 15:55:18 +00:00
|
|
|
{
|
|
|
|
void *user_data = NULL;
|
|
|
|
gdk_window_get_user_data (window, &user_data);
|
2003-08-16 16:32:10 +00:00
|
|
|
return user_data != NULL && user_data != ui->frames;
|
2002-08-10 15:55:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
2014-09-11 14:18:21 +00:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
meta_ui_window_is_dummy (MetaUI *ui,
|
|
|
|
Window xwindow)
|
|
|
|
{
|
|
|
|
GdkWindow *frames_window = gtk_widget_get_window (GTK_WIDGET (ui->frames));
|
|
|
|
return xwindow == gdk_x11_window_get_xid (frames_window);
|
|
|
|
}
|