Merge remote-tracking branch 'origin/master' into wayland
This commit is contained in:
commit
0e098249b1
1
.gitignore
vendored
1
.gitignore
vendored
@ -46,7 +46,6 @@ POTFILES
|
||||
po/*.pot
|
||||
50-metacity-desktop-key.xml
|
||||
50-metacity-key.xml
|
||||
inlinepixbufs.h
|
||||
libmutter.pc
|
||||
mutter
|
||||
mutter-theme-viewer
|
||||
|
@ -138,9 +138,6 @@ AM_GLIB_GNU_GETTEXT
|
||||
## here we get the flags we'll actually use
|
||||
# GRegex requires Glib-2.14.0
|
||||
PKG_CHECK_MODULES(ALL, glib-2.0 >= 2.14.0)
|
||||
# gtk_window_set_icon_name requires gtk2+-2.6.0
|
||||
PKG_CHECK_MODULES(MUTTER_MESSAGE, gtk+-3.0)
|
||||
PKG_CHECK_MODULES(MUTTER_WINDOW_DEMO, gtk+-3.0)
|
||||
|
||||
# Unconditionally use this dir to avoid a circular dep with gnomecc
|
||||
GNOME_KEYBINDINGS_KEYSDIR="${datadir}/gnome-control-center/keybindings"
|
||||
@ -350,9 +347,6 @@ if test "x$found_xsync" = "xyes"; then
|
||||
fi
|
||||
|
||||
MUTTER_LIBS="$MUTTER_LIBS $XSYNC_LIBS $RANDR_LIBS $SHAPE_LIBS $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lm"
|
||||
MUTTER_MESSAGE_LIBS="$MUTTER_MESSAGE_LIBS $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
|
||||
MUTTER_WINDOW_DEMO_LIBS="$MUTTER_WINDOW_DEMO_LIBS $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS -lm"
|
||||
MUTTER_PROPS_LIBS="$MUTTER_PROPS_LIBS $X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
|
||||
|
||||
found_sm=no
|
||||
case "$MUTTER_LIBS" in
|
||||
@ -482,10 +476,8 @@ doc/man/Makefile
|
||||
doc/reference/Makefile
|
||||
doc/reference/meta-docs.sgml
|
||||
src/Makefile
|
||||
src/wm-tester/Makefile
|
||||
src/libmutter.pc
|
||||
src/mutter-plugins.pc
|
||||
src/tools/Makefile
|
||||
src/compositor/plugins/Makefile
|
||||
protocol/Makefile
|
||||
data/Makefile
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
lib_LTLIBRARIES = libmutter.la
|
||||
|
||||
SUBDIRS=wm-tester tools compositor/plugins
|
||||
SUBDIRS=compositor/plugins
|
||||
|
||||
INCLUDES= \
|
||||
-DCLUTTER_ENABLE_EXPERIMENTAL_API \
|
||||
@ -152,7 +152,6 @@ libmutter_la_SOURCES = \
|
||||
meta/common.h \
|
||||
core/core.h \
|
||||
ui/ui.h \
|
||||
inlinepixbufs.h \
|
||||
ui/frames.c \
|
||||
ui/frames.h \
|
||||
ui/menu.c \
|
||||
@ -170,8 +169,6 @@ libmutter_la_SOURCES = \
|
||||
meta/theme.h \
|
||||
ui/theme-private.h \
|
||||
ui/ui.c \
|
||||
meta/preview-widget.h \
|
||||
ui/preview-widget.c \
|
||||
$(mutter_built_sources)
|
||||
|
||||
if HAVE_WAYLAND
|
||||
@ -227,7 +224,6 @@ libmutterinclude_base_headers = \
|
||||
# Excluded from scanning for introspection but installed
|
||||
# atomnames.h: macros cause problems for scanning process
|
||||
libmutterinclude_extra_headers = \
|
||||
meta/preview-widget.h \
|
||||
meta/atomnames.h
|
||||
|
||||
libmutterincludedir = $(includedir)/mutter/meta
|
||||
@ -236,10 +232,7 @@ libmutterinclude_HEADERS = \
|
||||
$(libmutterinclude_base_headers) \
|
||||
$(libmutterinclude_extra_headers)
|
||||
|
||||
mutter_theme_viewer_SOURCES= \
|
||||
ui/theme-viewer.c
|
||||
|
||||
bin_PROGRAMS=mutter mutter-theme-viewer
|
||||
bin_PROGRAMS=mutter
|
||||
|
||||
mutter_SOURCES = core/mutter.c
|
||||
mutter_LDADD = $(MUTTER_LIBS) libmutter.la
|
||||
@ -277,8 +270,6 @@ Meta-$(api_version).gir: libmutter.la
|
||||
|
||||
endif
|
||||
|
||||
mutter_theme_viewer_LDADD= $(MUTTER_LIBS) libmutter.la
|
||||
|
||||
testboxes_SOURCES = core/testboxes.c
|
||||
testgradient_SOURCES = ui/testgradient.c
|
||||
testasyncgetprop_SOURCES = core/testasyncgetprop.c
|
||||
@ -315,14 +306,7 @@ gsettings_SCHEMAS = org.gnome.mutter.gschema.xml
|
||||
convertdir = $(datadir)/GConf/gsettings
|
||||
convert_DATA = mutter-schemas.convert
|
||||
|
||||
IMAGES=stock_maximize.png stock_minimize.png stock_delete.png
|
||||
VARIABLES=stock_maximize_data $(srcdir)/stock_maximize.png \
|
||||
stock_minimize_data $(srcdir)/stock_minimize.png \
|
||||
stock_delete_data $(srcdir)/stock_delete.png
|
||||
|
||||
BUILT_SOURCES = inlinepixbufs.h
|
||||
CLEANFILES = \
|
||||
inlinepixbufs.h \
|
||||
mutter.desktop \
|
||||
mutter-wm.desktop \
|
||||
org.gnome.mutter.gschema.xml \
|
||||
@ -331,9 +315,6 @@ CLEANFILES = \
|
||||
$(typelib_DATA) \
|
||||
$(gir_DATA)
|
||||
|
||||
inlinepixbufs.h: $(IMAGES)
|
||||
$(GDK_PIXBUF_CSOURCE) --raw --build-list $(VARIABLES) >$(srcdir)/inlinepixbufs.h
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
|
||||
pkgconfig_DATA = libmutter.pc mutter-plugins.pc
|
||||
@ -351,7 +332,7 @@ EXTRA_DIST=$(desktopfiles_files) \
|
||||
mutter-enum-types.h.in \
|
||||
mutter-enum-types.c.in
|
||||
|
||||
BUILT_SOURCES += $(mutter_built_sources)
|
||||
BUILT_SOURCES = $(mutter_built_sources)
|
||||
MUTTER_STAMP_FILES = stamp-mutter-enum-types.h
|
||||
CLEANFILES += $(MUTTER_STAMP_FILES)
|
||||
|
||||
|
@ -3098,27 +3098,6 @@ meta_display_handle_event (MetaDisplay *display,
|
||||
meta_workspace_focus_default_window (screen->active_workspace, NULL, timestamp);
|
||||
}
|
||||
}
|
||||
else if (event->xclient.message_type ==
|
||||
display->atom__MUTTER_RELOAD_THEME_MESSAGE)
|
||||
{
|
||||
meta_verbose ("Received reload theme request\n");
|
||||
meta_ui_set_current_theme (meta_prefs_get_theme (),
|
||||
TRUE);
|
||||
meta_display_retheme_all ();
|
||||
}
|
||||
else if (event->xclient.message_type ==
|
||||
display->atom__MUTTER_SET_KEYBINDINGS_MESSAGE)
|
||||
{
|
||||
meta_verbose ("Received set keybindings request = %d\n",
|
||||
(int) event->xclient.data.l[0]);
|
||||
meta_set_keybindings_disabled (!event->xclient.data.l[0]);
|
||||
}
|
||||
else if (event->xclient.message_type ==
|
||||
display->atom__MUTTER_TOGGLE_VERBOSE)
|
||||
{
|
||||
meta_verbose ("Received toggle verbose message\n");
|
||||
meta_set_verbose (!meta_is_verbose ());
|
||||
}
|
||||
else if (event->xclient.message_type ==
|
||||
display->atom_WM_PROTOCOLS)
|
||||
{
|
||||
|
@ -69,7 +69,6 @@ void meta_window_ungrab_all_keys (MetaWindow *window,
|
||||
gboolean meta_display_process_key_event (MetaDisplay *display,
|
||||
MetaWindow *window,
|
||||
XIDeviceEvent *event);
|
||||
void meta_set_keybindings_disabled (gboolean setting);
|
||||
void meta_display_process_mapping_event (MetaDisplay *display,
|
||||
XEvent *event);
|
||||
|
||||
|
@ -56,8 +56,6 @@
|
||||
#define SCHEMA_COMMON_KEYBINDINGS "org.gnome.desktop.wm.keybindings"
|
||||
#define SCHEMA_MUTTER_KEYBINDINGS "org.gnome.mutter.keybindings"
|
||||
|
||||
static gboolean all_bindings_disabled = FALSE;
|
||||
|
||||
static gboolean add_builtin_keybinding (MetaDisplay *display,
|
||||
const char *name,
|
||||
GSettings *settings,
|
||||
@ -2046,21 +2044,6 @@ meta_display_process_key_event (MetaDisplay *display,
|
||||
const char *str;
|
||||
MetaScreen *screen;
|
||||
|
||||
if (all_bindings_disabled)
|
||||
{
|
||||
/* In this mode, we try to pretend we don't have grabs, so we
|
||||
* immediately replay events and drop the grab. (This still
|
||||
* messes up global passive grabs from other clients.) The
|
||||
* FALSE return here is a little suspect, but we don't really
|
||||
* know if we'll see the event again or not, and it's pretty
|
||||
* poorly defined how this mode is supposed to interact with
|
||||
* plugins.
|
||||
*/
|
||||
XIAllowEvents (display->xdisplay, event->deviceid,
|
||||
XIReplayDevice, event->time);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* if key event was on root window, we have a shortcut */
|
||||
screen = meta_display_screen_for_root (display, event->event);
|
||||
|
||||
@ -4098,14 +4081,6 @@ handle_set_spew_mark (MetaDisplay *display,
|
||||
meta_verbose ("-- MARK MARK MARK MARK --\n");
|
||||
}
|
||||
|
||||
void
|
||||
meta_set_keybindings_disabled (gboolean setting)
|
||||
{
|
||||
all_bindings_disabled = setting;
|
||||
meta_topic (META_DEBUG_KEYBINDINGS,
|
||||
"Keybindings %s\n", all_bindings_disabled ? "disabled" : "enabled");
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_keybindings_set_custom_handler:
|
||||
* @name: The name of the keybinding to set
|
||||
|
@ -586,14 +586,14 @@ meta_run (void)
|
||||
if (g_getenv ("MUTTER_G_FATAL_WARNINGS") != NULL)
|
||||
g_log_set_always_fatal (G_LOG_LEVEL_MASK);
|
||||
|
||||
meta_ui_set_current_theme (meta_prefs_get_theme (), FALSE);
|
||||
meta_ui_set_current_theme (meta_prefs_get_theme ());
|
||||
|
||||
/* Try to find some theme that'll work if the theme preference
|
||||
* doesn't exist. First try Simple (the default theme) then just
|
||||
* try anything in the themes directory.
|
||||
*/
|
||||
if (!meta_ui_have_a_theme ())
|
||||
meta_ui_set_current_theme ("Simple", FALSE);
|
||||
meta_ui_set_current_theme ("Simple");
|
||||
|
||||
if (!meta_ui_have_a_theme ())
|
||||
{
|
||||
@ -611,7 +611,7 @@ meta_run (void)
|
||||
while (((dir_entry = g_dir_read_name (themes_dir)) != NULL) &&
|
||||
(!meta_ui_have_a_theme ()))
|
||||
{
|
||||
meta_ui_set_current_theme (dir_entry, FALSE);
|
||||
meta_ui_set_current_theme (dir_entry);
|
||||
}
|
||||
|
||||
g_dir_close (themes_dir);
|
||||
@ -670,7 +670,7 @@ prefs_changed_callback (MetaPreference pref,
|
||||
{
|
||||
case META_PREF_THEME:
|
||||
case META_PREF_DRAGGABLE_BORDER_WIDTH:
|
||||
meta_ui_set_current_theme (meta_prefs_get_theme (), FALSE);
|
||||
meta_ui_set_current_theme (meta_prefs_get_theme ());
|
||||
meta_display_retheme_all ();
|
||||
break;
|
||||
|
||||
|
@ -412,6 +412,9 @@ struct _MetaWindow
|
||||
*/
|
||||
MetaRectangle rect;
|
||||
|
||||
gboolean has_custom_frame_extents;
|
||||
GtkBorder custom_frame_extents;
|
||||
|
||||
/* The geometry to restore when we unmaximize. The position is in
|
||||
* root window coords, even if there's a frame, which contrasts with
|
||||
* window->rect above. Note that this gives the position and size
|
||||
|
@ -289,6 +289,35 @@ reload_icon_geometry (MetaWindow *window,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
reload_gtk_frame_extents (MetaWindow *window,
|
||||
MetaPropValue *value,
|
||||
gboolean initial)
|
||||
{
|
||||
if (value->type != META_PROP_VALUE_INVALID)
|
||||
{
|
||||
if (value->v.cardinal_list.n_cardinals != 4)
|
||||
{
|
||||
meta_verbose ("_GTK_FRAME_EXTENTS on %s has %d values instead of 4\n",
|
||||
window->desc, value->v.cardinal_list.n_cardinals);
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkBorder *extents = &window->custom_frame_extents;
|
||||
|
||||
window->has_custom_frame_extents = TRUE;
|
||||
extents->left = (int)value->v.cardinal_list.cardinals[0];
|
||||
extents->right = (int)value->v.cardinal_list.cardinals[1];
|
||||
extents->top = (int)value->v.cardinal_list.cardinals[2];
|
||||
extents->bottom = (int)value->v.cardinal_list.cardinals[3];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
window->has_custom_frame_extents = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
reload_struts (MetaWindow *window,
|
||||
MetaPropValue *value,
|
||||
@ -1766,6 +1795,7 @@ meta_display_init_window_prop_hooks (MetaDisplay *display)
|
||||
{ display->atom__GTK_WINDOW_OBJECT_PATH, META_PROP_VALUE_UTF8, reload_gtk_window_object_path, TRUE, FALSE },
|
||||
{ display->atom__GTK_APP_MENU_OBJECT_PATH, META_PROP_VALUE_UTF8, reload_gtk_app_menu_object_path, TRUE, FALSE },
|
||||
{ display->atom__GTK_MENUBAR_OBJECT_PATH, META_PROP_VALUE_UTF8, reload_gtk_menubar_object_path, TRUE, FALSE },
|
||||
{ display->atom__GTK_FRAME_EXTENTS, META_PROP_VALUE_CARDINAL_LIST,reload_gtk_frame_extents, TRUE, FALSE },
|
||||
{ display->atom__NET_WM_USER_TIME_WINDOW, META_PROP_VALUE_WINDOW, reload_net_wm_user_time_window, TRUE, FALSE },
|
||||
{ display->atom_WM_STATE, META_PROP_VALUE_INVALID, NULL, FALSE, FALSE },
|
||||
{ display->atom__NET_WM_ICON, META_PROP_VALUE_INVALID, reload_net_wm_icon, FALSE, FALSE },
|
||||
|
@ -6002,7 +6002,18 @@ meta_window_get_outer_rect (const MetaWindow *window,
|
||||
rect->height -= borders.invisible.top + borders.invisible.bottom;
|
||||
}
|
||||
else
|
||||
*rect = window->rect;
|
||||
{
|
||||
*rect = window->rect;
|
||||
|
||||
if (window->has_custom_frame_extents)
|
||||
{
|
||||
GtkBorder *extents = &window->custom_frame_extents;
|
||||
rect->x += extents->left;
|
||||
rect->y += extents->top;
|
||||
rect->width -= extents->left + extents->right;
|
||||
rect->height -= extents->top + extents->bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char*
|
||||
|
@ -54,9 +54,6 @@ item(WM_WINDOW_ROLE)
|
||||
item(UTF8_STRING)
|
||||
item(WM_ICON_SIZE)
|
||||
item(_KWM_WIN_ICON)
|
||||
item(_MUTTER_RELOAD_THEME_MESSAGE)
|
||||
item(_MUTTER_SET_KEYBINDINGS_MESSAGE)
|
||||
item(_MUTTER_TOGGLE_VERBOSE)
|
||||
item(_MUTTER_HINTS)
|
||||
item(_GTK_THEME_VARIANT)
|
||||
item(_GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED)
|
||||
@ -66,6 +63,7 @@ item(_GTK_APPLICATION_OBJECT_PATH)
|
||||
item(_GTK_WINDOW_OBJECT_PATH)
|
||||
item(_GTK_APP_MENU_OBJECT_PATH)
|
||||
item(_GTK_MENUBAR_OBJECT_PATH)
|
||||
item(_GTK_FRAME_EXTENTS)
|
||||
item(_GNOME_WM_KEYBINDINGS)
|
||||
item(_GNOME_PANEL_ACTION)
|
||||
item(_GNOME_PANEL_ACTION_MAIN_MENU)
|
||||
|
@ -1,87 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/* Metacity theme preview widget */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2002 Havoc Pennington
|
||||
*
|
||||
* 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 <meta/common.h>
|
||||
#include <meta/theme.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#ifndef META_PREVIEW_WIDGET_H
|
||||
#define META_PREVIEW_WIDGET_H
|
||||
|
||||
#define META_TYPE_PREVIEW (meta_preview_get_type ())
|
||||
#define META_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_PREVIEW, MetaPreview))
|
||||
#define META_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_PREVIEW, MetaPreviewClass))
|
||||
#define META_IS_PREVIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_PREVIEW))
|
||||
#define META_IS_PREVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_PREVIEW))
|
||||
#define META_PREVIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_PREVIEW, MetaPreviewClass))
|
||||
|
||||
typedef struct _MetaPreview MetaPreview;
|
||||
typedef struct _MetaPreviewClass MetaPreviewClass;
|
||||
|
||||
struct _MetaPreview
|
||||
{
|
||||
GtkBin bin;
|
||||
|
||||
GtkStyleContext *style_context;
|
||||
|
||||
MetaTheme *theme;
|
||||
char *title;
|
||||
MetaFrameType type;
|
||||
MetaFrameFlags flags;
|
||||
|
||||
PangoLayout *layout;
|
||||
int text_height;
|
||||
|
||||
MetaFrameBorders borders;
|
||||
guint borders_cached : 1;
|
||||
|
||||
MetaButtonLayout button_layout;
|
||||
};
|
||||
|
||||
struct _MetaPreviewClass
|
||||
{
|
||||
/*< private >*/
|
||||
GtkBinClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType meta_preview_get_type (void) G_GNUC_CONST;
|
||||
GtkWidget* meta_preview_new (void);
|
||||
|
||||
void meta_preview_set_theme (MetaPreview *preview,
|
||||
MetaTheme *theme);
|
||||
void meta_preview_set_title (MetaPreview *preview,
|
||||
const char *title);
|
||||
void meta_preview_set_frame_type (MetaPreview *preview,
|
||||
MetaFrameType type);
|
||||
void meta_preview_set_frame_flags (MetaPreview *preview,
|
||||
MetaFrameFlags flags);
|
||||
void meta_preview_set_button_layout (MetaPreview *preview,
|
||||
const MetaButtonLayout *button_layout);
|
||||
|
||||
GdkPixbuf* meta_preview_get_icon (void);
|
||||
GdkPixbuf* meta_preview_get_mini_icon (void);
|
||||
|
||||
#endif
|
@ -33,8 +33,7 @@
|
||||
typedef struct _MetaTheme MetaTheme;
|
||||
|
||||
MetaTheme* meta_theme_get_current (void);
|
||||
void meta_theme_set_current (const char *name,
|
||||
gboolean force_reload);
|
||||
void meta_theme_set_current (const char *name);
|
||||
|
||||
MetaTheme* meta_theme_new (void);
|
||||
void meta_theme_free (MetaTheme *theme);
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 220 B |
Binary file not shown.
Before Width: | Height: | Size: 166 B |
Binary file not shown.
Before Width: | Height: | Size: 145 B |
@ -1,8 +0,0 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
metacity-grayscale
|
||||
metacity-message
|
||||
metacity-mag
|
||||
metacity-properties
|
||||
metacity-properties.desktop
|
||||
metacity-window-demo
|
@ -1,34 +0,0 @@
|
||||
@INTLTOOL_DESKTOP_RULE@
|
||||
|
||||
icondir=$(pkgdatadir)/icons
|
||||
icon_DATA=mutter-window-demo.png
|
||||
|
||||
INCLUDES=@MUTTER_WINDOW_DEMO_CFLAGS@ @MUTTER_MESSAGE_CFLAGS@ \
|
||||
-I$(top_srcdir)/src \
|
||||
-DMUTTER_ICON_DIR=\"$(pkgdatadir)/icons\" \
|
||||
-DMUTTER_LOCALEDIR=\"$(prefix)/@DATADIRNAME@/locale\"
|
||||
|
||||
mutter_message_SOURCES= \
|
||||
mutter-message.c
|
||||
|
||||
mutter_window_demo_SOURCES= \
|
||||
mutter-window-demo.c
|
||||
|
||||
mutter_mag_SOURCES= \
|
||||
mutter-mag.c
|
||||
|
||||
mutter_grayscale_SOURCES= \
|
||||
mutter-grayscale.c
|
||||
|
||||
bin_PROGRAMS=mutter-message mutter-window-demo
|
||||
|
||||
## cheesy hacks I use, don't really have any business existing. ;-)
|
||||
noinst_PROGRAMS=mutter-mag mutter-grayscale
|
||||
|
||||
mutter_message_LDADD= @MUTTER_MESSAGE_LIBS@
|
||||
mutter_window_demo_LDADD= @MUTTER_WINDOW_DEMO_LIBS@
|
||||
mutter_mag_LDADD= @MUTTER_WINDOW_DEMO_LIBS@
|
||||
mutter_grayscale_LDADD = @MUTTER_WINDOW_DEMO_LIBS@
|
||||
|
||||
EXTRA_DIST=$(icon_DATA)
|
||||
|
@ -1,107 +0,0 @@
|
||||
/* Hack for grayscaling an image */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2002 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 <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#define INTENSITY(r, g, b) ((r) * 0.30 + (g) * 0.59 + (b) * 0.11)
|
||||
|
||||
static GdkPixbuf*
|
||||
grayscale_pixbuf (GdkPixbuf *pixbuf)
|
||||
{
|
||||
GdkPixbuf *gray;
|
||||
guchar *pixels;
|
||||
int rowstride;
|
||||
int pixstride;
|
||||
int row;
|
||||
int n_rows;
|
||||
int width;
|
||||
|
||||
gray = gdk_pixbuf_copy (pixbuf);
|
||||
rowstride = gdk_pixbuf_get_rowstride (gray);
|
||||
pixstride = gdk_pixbuf_get_has_alpha (gray) ? 4 : 3;
|
||||
|
||||
pixels = gdk_pixbuf_get_pixels (gray);
|
||||
n_rows = gdk_pixbuf_get_height (gray);
|
||||
width = gdk_pixbuf_get_width (gray);
|
||||
|
||||
row = 0;
|
||||
while (row < n_rows)
|
||||
{
|
||||
guchar *p = pixels + row * rowstride;
|
||||
guchar *end = p + (pixstride * width);
|
||||
|
||||
while (p != end)
|
||||
{
|
||||
double v = INTENSITY (p[0], p[1], p[2]);
|
||||
|
||||
p[0] = (guchar) v;
|
||||
p[1] = (guchar) v;
|
||||
p[2] = (guchar) v;
|
||||
|
||||
p += pixstride;
|
||||
}
|
||||
|
||||
++row;
|
||||
}
|
||||
|
||||
return gray;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkPixbuf *gray;
|
||||
GError *err;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
g_printerr ("specify a single image on the command line\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
err = NULL;
|
||||
pixbuf = gdk_pixbuf_new_from_file (argv[1], &err);
|
||||
if (err != NULL)
|
||||
{
|
||||
g_printerr ("failed to load image: %s\n", err->message);
|
||||
g_error_free (err);
|
||||
return 1;
|
||||
}
|
||||
|
||||
gray = grayscale_pixbuf (pixbuf);
|
||||
|
||||
err = NULL;
|
||||
gdk_pixbuf_save (gray, "grayscale.png", "png", &err, NULL);
|
||||
if (err != NULL)
|
||||
{
|
||||
g_printerr ("failed to save image: %s\n", err->message);
|
||||
g_error_free (err);
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_print ("wrote grayscale.png\n");
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,299 +0,0 @@
|
||||
/* Hack for use instead of xmag */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2002 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.
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#define _XOPEN_SOURCE 600 /* C99 -- for rint() */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
static GtkWidget *grab_widget = NULL;
|
||||
static GtkWidget *display_window = NULL;
|
||||
static int last_grab_x = 0;
|
||||
static int last_grab_y = 0;
|
||||
static int last_grab_width = 150;
|
||||
static int last_grab_height = 150;
|
||||
static GtkAllocation last_grab_allocation;
|
||||
static double width_factor = 4.0;
|
||||
static double height_factor = 4.0;
|
||||
static GdkInterpType interp_mode = GDK_INTERP_NEAREST;
|
||||
static guint regrab_idle_id = 0;
|
||||
|
||||
static GdkPixbuf*
|
||||
get_pixbuf (void)
|
||||
{
|
||||
GdkPixbuf *screenshot;
|
||||
GdkPixbuf *magnified;
|
||||
|
||||
#if 0
|
||||
g_print ("Size %d x %d\n",
|
||||
last_grab_width, last_grab_height);
|
||||
#endif
|
||||
|
||||
screenshot = gdk_pixbuf_get_from_window (gdk_get_default_root_window (),
|
||||
last_grab_x, last_grab_y,
|
||||
last_grab_width, last_grab_height);
|
||||
|
||||
if (screenshot == NULL)
|
||||
{
|
||||
g_printerr ("Screenshot failed\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
magnified = gdk_pixbuf_scale_simple (screenshot, last_grab_width * width_factor,
|
||||
last_grab_height * height_factor,
|
||||
interp_mode);
|
||||
|
||||
|
||||
g_object_unref (G_OBJECT (screenshot));
|
||||
|
||||
return magnified;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
regrab_idle (GtkWidget *image)
|
||||
{
|
||||
GtkAllocation allocation;
|
||||
GdkPixbuf *magnified;
|
||||
|
||||
gtk_widget_get_allocation (image, &allocation);
|
||||
|
||||
if (allocation.width != last_grab_allocation.width ||
|
||||
allocation.height != last_grab_allocation.height)
|
||||
{
|
||||
last_grab_width = rint (allocation.width / width_factor);
|
||||
last_grab_height = rint (allocation.height / height_factor);
|
||||
last_grab_allocation = allocation;
|
||||
|
||||
magnified = get_pixbuf ();
|
||||
|
||||
gtk_image_set_from_pixbuf (GTK_IMAGE (image), magnified);
|
||||
|
||||
g_object_unref (G_OBJECT (magnified));
|
||||
}
|
||||
|
||||
regrab_idle_id = 0;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
image_resized (GtkWidget *image)
|
||||
{
|
||||
if (regrab_idle_id == 0)
|
||||
regrab_idle_id = g_idle_add_full (G_PRIORITY_LOW + 100, (GSourceFunc) regrab_idle,
|
||||
image, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
grab_area_at_mouse (GtkWidget *invisible,
|
||||
int x_root,
|
||||
int y_root)
|
||||
{
|
||||
GdkPixbuf *magnified;
|
||||
int width, height;
|
||||
GtkWidget *widget;
|
||||
|
||||
width = last_grab_width;
|
||||
height = last_grab_height;
|
||||
|
||||
last_grab_x = x_root;
|
||||
last_grab_y = y_root;
|
||||
last_grab_width = width;
|
||||
last_grab_height = height;
|
||||
|
||||
magnified = get_pixbuf ();
|
||||
|
||||
display_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_default_size (GTK_WINDOW (display_window),
|
||||
last_grab_width, last_grab_height);
|
||||
widget = gtk_image_new_from_pixbuf (magnified);
|
||||
gtk_widget_set_size_request (widget, 40, 40);
|
||||
gtk_container_add (GTK_CONTAINER (display_window), widget);
|
||||
g_object_unref (G_OBJECT (magnified));
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (display_window),
|
||||
(gpointer) &display_window);
|
||||
|
||||
g_signal_connect (G_OBJECT (display_window), "destroy",
|
||||
G_CALLBACK (gtk_main_quit), NULL);
|
||||
|
||||
g_signal_connect_after (G_OBJECT (widget), "size_allocate", G_CALLBACK (image_resized), NULL);
|
||||
|
||||
gtk_widget_show_all (display_window);
|
||||
}
|
||||
|
||||
static void
|
||||
shutdown_grab (void)
|
||||
{
|
||||
GdkDeviceManager *manager;
|
||||
GdkDevice *device;
|
||||
|
||||
manager = gdk_display_get_device_manager (gdk_display_get_default ());
|
||||
device = gdk_device_manager_get_client_pointer (manager);
|
||||
|
||||
gdk_device_ungrab (device, gtk_get_current_event_time ());
|
||||
gdk_device_ungrab (gdk_device_get_associated_device (device),
|
||||
gtk_get_current_event_time ());
|
||||
gtk_grab_remove (grab_widget);
|
||||
}
|
||||
|
||||
static void
|
||||
mouse_motion (GtkWidget *invisible,
|
||||
GdkEventMotion *event,
|
||||
gpointer data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static gboolean
|
||||
mouse_release (GtkWidget *invisible,
|
||||
GdkEventButton *event,
|
||||
gpointer data)
|
||||
{
|
||||
if (event->button != 1)
|
||||
return FALSE;
|
||||
|
||||
grab_area_at_mouse (invisible, event->x_root, event->y_root);
|
||||
|
||||
shutdown_grab ();
|
||||
|
||||
g_signal_handlers_disconnect_by_func (invisible, mouse_motion, NULL);
|
||||
g_signal_handlers_disconnect_by_func (invisible, mouse_release, NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Helper Functions */
|
||||
|
||||
static gboolean mouse_press (GtkWidget *invisible,
|
||||
GdkEventButton *event,
|
||||
gpointer data);
|
||||
|
||||
static gboolean
|
||||
key_press (GtkWidget *invisible,
|
||||
GdkEventKey *event,
|
||||
gpointer data)
|
||||
{
|
||||
if (event->keyval == GDK_KEY_Escape)
|
||||
{
|
||||
shutdown_grab ();
|
||||
|
||||
g_signal_handlers_disconnect_by_func (invisible, mouse_press, NULL);
|
||||
g_signal_handlers_disconnect_by_func (invisible, key_press, NULL);
|
||||
|
||||
gtk_main_quit ();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
mouse_press (GtkWidget *invisible,
|
||||
GdkEventButton *event,
|
||||
gpointer data)
|
||||
{
|
||||
if (event->type == GDK_BUTTON_PRESS &&
|
||||
event->button == 1)
|
||||
{
|
||||
g_signal_connect (invisible, "motion_notify_event",
|
||||
G_CALLBACK (mouse_motion), NULL);
|
||||
g_signal_connect (invisible, "button_release_event",
|
||||
G_CALLBACK (mouse_release), NULL);
|
||||
g_signal_handlers_disconnect_by_func (invisible, mouse_press, NULL);
|
||||
g_signal_handlers_disconnect_by_func (invisible, key_press, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
begin_area_grab (void)
|
||||
{
|
||||
GdkWindow *window;
|
||||
GdkDeviceManager *manager;
|
||||
GdkDevice *device;
|
||||
|
||||
if (grab_widget == NULL)
|
||||
{
|
||||
grab_widget = gtk_invisible_new ();
|
||||
|
||||
gtk_widget_add_events (grab_widget,
|
||||
GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK);
|
||||
|
||||
gtk_widget_show (grab_widget);
|
||||
}
|
||||
|
||||
window = gtk_widget_get_window (grab_widget);
|
||||
manager = gdk_display_get_device_manager (gdk_display_get_default ());
|
||||
device = gdk_device_manager_get_client_pointer (manager);
|
||||
|
||||
if (gdk_device_grab (device,
|
||||
window,
|
||||
GDK_OWNERSHIP_NONE,
|
||||
FALSE,
|
||||
GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK,
|
||||
NULL,
|
||||
gtk_get_current_event_time ()) != GDK_GRAB_SUCCESS)
|
||||
{
|
||||
g_warning ("Failed to grab pointer to do eyedropper");
|
||||
return;
|
||||
}
|
||||
|
||||
if (gdk_device_grab (gdk_device_get_associated_device (device),
|
||||
window,
|
||||
GDK_OWNERSHIP_NONE,
|
||||
FALSE,
|
||||
GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
|
||||
NULL,
|
||||
gtk_get_current_event_time ()) != GDK_GRAB_SUCCESS)
|
||||
{
|
||||
gdk_device_ungrab (device, gtk_get_current_event_time ());
|
||||
g_warning ("Failed to grab keyboard to do eyedropper");
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_grab_add (grab_widget);
|
||||
|
||||
g_signal_connect (grab_widget, "button_press_event",
|
||||
G_CALLBACK (mouse_press), NULL);
|
||||
g_signal_connect (grab_widget, "key_press_event",
|
||||
G_CALLBACK (key_press), NULL);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
begin_area_grab ();
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,160 +0,0 @@
|
||||
/* Mutter send-magic-messages app */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2002 Havoc Pennington
|
||||
*
|
||||
* 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 <gtk/gtk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <libintl.h>
|
||||
#define _(x) dgettext (GETTEXT_PACKAGE, x)
|
||||
#define N_(x) x
|
||||
|
||||
static Display *display;
|
||||
|
||||
static void
|
||||
send_reload_theme (void)
|
||||
{
|
||||
XEvent xev;
|
||||
|
||||
xev.xclient.type = ClientMessage;
|
||||
xev.xclient.serial = 0;
|
||||
xev.xclient.send_event = True;
|
||||
xev.xclient.display = display;
|
||||
xev.xclient.window = gdk_x11_get_default_root_xwindow ();
|
||||
xev.xclient.message_type = XInternAtom (display,
|
||||
"_MUTTER_RELOAD_THEME_MESSAGE",
|
||||
False);
|
||||
xev.xclient.format = 32;
|
||||
xev.xclient.data.l[0] = 0;
|
||||
xev.xclient.data.l[1] = 0;
|
||||
xev.xclient.data.l[2] = 0;
|
||||
|
||||
XSendEvent (display,
|
||||
gdk_x11_get_default_root_xwindow (),
|
||||
False,
|
||||
SubstructureRedirectMask | SubstructureNotifyMask,
|
||||
&xev);
|
||||
|
||||
XFlush (display);
|
||||
XSync (display, False);
|
||||
}
|
||||
|
||||
static void
|
||||
send_set_keybindings (gboolean enabled)
|
||||
{
|
||||
XEvent xev;
|
||||
|
||||
xev.xclient.type = ClientMessage;
|
||||
xev.xclient.serial = 0;
|
||||
xev.xclient.send_event = True;
|
||||
xev.xclient.display = display;
|
||||
xev.xclient.window = gdk_x11_get_default_root_xwindow ();
|
||||
xev.xclient.message_type = XInternAtom (display,
|
||||
"_MUTTER_SET_KEYBINDINGS_MESSAGE",
|
||||
False);
|
||||
xev.xclient.format = 32;
|
||||
xev.xclient.data.l[0] = enabled;
|
||||
xev.xclient.data.l[1] = 0;
|
||||
xev.xclient.data.l[2] = 0;
|
||||
|
||||
XSendEvent (display,
|
||||
gdk_x11_get_default_root_xwindow (),
|
||||
False,
|
||||
SubstructureRedirectMask | SubstructureNotifyMask,
|
||||
&xev);
|
||||
|
||||
XFlush (display);
|
||||
XSync (display, False);
|
||||
}
|
||||
|
||||
#ifdef WITH_VERBOSE_MODE
|
||||
static void
|
||||
send_toggle_verbose (void)
|
||||
{
|
||||
XEvent xev;
|
||||
|
||||
xev.xclient.type = ClientMessage;
|
||||
xev.xclient.serial = 0;
|
||||
xev.xclient.send_event = True;
|
||||
xev.xclient.display = display;
|
||||
xev.xclient.window = gdk_x11_get_default_root_xwindow ();
|
||||
xev.xclient.message_type = XInternAtom (display,
|
||||
"_MUTTER_TOGGLE_VERBOSE",
|
||||
False);
|
||||
xev.xclient.format = 32;
|
||||
xev.xclient.data.l[0] = 0;
|
||||
xev.xclient.data.l[1] = 0;
|
||||
xev.xclient.data.l[2] = 0;
|
||||
|
||||
XSendEvent (display,
|
||||
gdk_x11_get_default_root_xwindow (),
|
||||
False,
|
||||
SubstructureRedirectMask | SubstructureNotifyMask,
|
||||
&xev);
|
||||
|
||||
XFlush (display);
|
||||
XSync (display, False);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
usage (void)
|
||||
{
|
||||
g_printerr (_("Usage: %s\n"),
|
||||
"mutter-message (reload-theme|enable-keybindings|disable-keybindings|toggle-verbose)");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
if (argc < 2)
|
||||
usage ();
|
||||
|
||||
display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
|
||||
|
||||
if (strcmp (argv[1], "reload-theme") == 0)
|
||||
send_reload_theme ();
|
||||
else if (strcmp (argv[1], "enable-keybindings") == 0)
|
||||
send_set_keybindings (TRUE);
|
||||
else if (strcmp (argv[1], "disable-keybindings") == 0)
|
||||
send_set_keybindings (FALSE);
|
||||
else if (strcmp (argv[1], "toggle-verbose") == 0)
|
||||
{
|
||||
#ifndef WITH_VERBOSE_MODE
|
||||
g_printerr (_("Mutter was compiled without support for verbose mode\n"));
|
||||
return 1;
|
||||
#else
|
||||
send_toggle_verbose ();
|
||||
#endif
|
||||
}
|
||||
else
|
||||
usage ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 3.4 KiB |
@ -40,7 +40,6 @@ typedef enum
|
||||
{
|
||||
MENU_ITEM_SEPARATOR = 0,
|
||||
MENU_ITEM_NORMAL,
|
||||
MENU_ITEM_IMAGE,
|
||||
MENU_ITEM_CHECKBOX,
|
||||
MENU_ITEM_RADIOBUTTON,
|
||||
MENU_ITEM_WORKSPACE_LIST,
|
||||
@ -50,7 +49,6 @@ struct _MenuItem
|
||||
{
|
||||
MetaMenuOp op;
|
||||
MetaMenuItemType type;
|
||||
const char *stock_id;
|
||||
const gboolean checked;
|
||||
const char *label;
|
||||
};
|
||||
@ -66,42 +64,42 @@ static void activate_cb (GtkWidget *menuitem, gpointer data);
|
||||
|
||||
static MenuItem menuitems[] = {
|
||||
/* Translators: Translate this string the same way as you do in libwnck! */
|
||||
{ META_MENU_OP_MINIMIZE, MENU_ITEM_IMAGE, METACITY_STOCK_MINIMIZE, FALSE, N_("Mi_nimize") },
|
||||
{ META_MENU_OP_MINIMIZE, MENU_ITEM_NORMAL, FALSE, N_("Mi_nimize") },
|
||||
/* Translators: Translate this string the same way as you do in libwnck! */
|
||||
{ META_MENU_OP_MAXIMIZE, MENU_ITEM_IMAGE, METACITY_STOCK_MAXIMIZE, FALSE, N_("Ma_ximize") },
|
||||
{ META_MENU_OP_MAXIMIZE, MENU_ITEM_NORMAL, FALSE, N_("Ma_ximize") },
|
||||
/* Translators: Translate this string the same way as you do in libwnck! */
|
||||
{ META_MENU_OP_UNMAXIMIZE, MENU_ITEM_NORMAL, NULL, FALSE, N_("Unma_ximize") },
|
||||
{ META_MENU_OP_UNMAXIMIZE, MENU_ITEM_NORMAL, FALSE, N_("Unma_ximize") },
|
||||
/* Translators: Translate this string the same way as you do in libwnck! */
|
||||
{ META_MENU_OP_SHADE, MENU_ITEM_NORMAL, NULL, FALSE, N_("Roll _Up") },
|
||||
{ META_MENU_OP_SHADE, MENU_ITEM_NORMAL, FALSE, N_("Roll _Up") },
|
||||
/* Translators: Translate this string the same way as you do in libwnck! */
|
||||
{ META_MENU_OP_UNSHADE, MENU_ITEM_NORMAL, NULL, FALSE, N_("_Unroll") },
|
||||
{ META_MENU_OP_UNSHADE, MENU_ITEM_NORMAL, FALSE, N_("_Unroll") },
|
||||
/* Translators: Translate this string the same way as you do in libwnck! */
|
||||
{ META_MENU_OP_MOVE, MENU_ITEM_NORMAL, NULL, FALSE, N_("_Move") },
|
||||
{ META_MENU_OP_MOVE, MENU_ITEM_NORMAL, FALSE, N_("_Move") },
|
||||
/* Translators: Translate this string the same way as you do in libwnck! */
|
||||
{ META_MENU_OP_RESIZE, MENU_ITEM_NORMAL, NULL, FALSE, N_("_Resize") },
|
||||
{ META_MENU_OP_RESIZE, MENU_ITEM_NORMAL, FALSE, N_("_Resize") },
|
||||
/* Translators: Translate this string the same way as you do in libwnck! */
|
||||
{ META_MENU_OP_RECOVER, MENU_ITEM_NORMAL, NULL, FALSE, N_("Move Titlebar On_screen") },
|
||||
{ META_MENU_OP_WORKSPACES, MENU_ITEM_SEPARATOR, NULL, FALSE, NULL }, /* separator */
|
||||
{ META_MENU_OP_RECOVER, MENU_ITEM_NORMAL, FALSE, N_("Move Titlebar On_screen") },
|
||||
{ META_MENU_OP_WORKSPACES, MENU_ITEM_SEPARATOR, FALSE, NULL }, /* separator */
|
||||
/* Translators: Translate this string the same way as you do in libwnck! */
|
||||
{ META_MENU_OP_ABOVE, MENU_ITEM_CHECKBOX, NULL, FALSE, N_("Always on _Top") },
|
||||
{ META_MENU_OP_ABOVE, MENU_ITEM_CHECKBOX, FALSE, N_("Always on _Top") },
|
||||
/* Translators: Translate this string the same way as you do in libwnck! */
|
||||
{ META_MENU_OP_UNABOVE, MENU_ITEM_CHECKBOX, NULL, TRUE, N_("Always on _Top") },
|
||||
{ META_MENU_OP_UNABOVE, MENU_ITEM_CHECKBOX, TRUE, N_("Always on _Top") },
|
||||
/* Translators: Translate this string the same way as you do in libwnck! */
|
||||
{ META_MENU_OP_STICK, MENU_ITEM_RADIOBUTTON, NULL, FALSE, N_("_Always on Visible Workspace") },
|
||||
{ META_MENU_OP_STICK, MENU_ITEM_RADIOBUTTON, FALSE, N_("_Always on Visible Workspace") },
|
||||
/* Translators: Translate this string the same way as you do in libwnck! */
|
||||
{ META_MENU_OP_UNSTICK, MENU_ITEM_RADIOBUTTON, NULL, FALSE, N_("_Only on This Workspace") },
|
||||
{ META_MENU_OP_UNSTICK, MENU_ITEM_RADIOBUTTON, FALSE, N_("_Only on This Workspace") },
|
||||
/* Translators: Translate this string the same way as you do in libwnck! */
|
||||
{ META_MENU_OP_MOVE_LEFT, MENU_ITEM_NORMAL, NULL, FALSE, N_("Move to Workspace _Left") },
|
||||
{ META_MENU_OP_MOVE_LEFT, MENU_ITEM_NORMAL, FALSE, N_("Move to Workspace _Left") },
|
||||
/* Translators: Translate this string the same way as you do in libwnck! */
|
||||
{ META_MENU_OP_MOVE_RIGHT, MENU_ITEM_NORMAL, NULL, FALSE, N_("Move to Workspace R_ight") },
|
||||
{ META_MENU_OP_MOVE_RIGHT, MENU_ITEM_NORMAL, FALSE, N_("Move to Workspace R_ight") },
|
||||
/* Translators: Translate this string the same way as you do in libwnck! */
|
||||
{ META_MENU_OP_MOVE_UP, MENU_ITEM_NORMAL, NULL, FALSE, N_("Move to Workspace _Up") },
|
||||
{ META_MENU_OP_MOVE_UP, MENU_ITEM_NORMAL, FALSE, N_("Move to Workspace _Up") },
|
||||
/* Translators: Translate this string the same way as you do in libwnck! */
|
||||
{ META_MENU_OP_MOVE_DOWN, MENU_ITEM_NORMAL, NULL, FALSE, N_("Move to Workspace _Down") },
|
||||
{ 0, MENU_ITEM_WORKSPACE_LIST, NULL, FALSE, NULL },
|
||||
{ 0, MENU_ITEM_SEPARATOR, NULL, FALSE, NULL }, /* separator */
|
||||
{ META_MENU_OP_MOVE_DOWN, MENU_ITEM_NORMAL, FALSE, N_("Move to Workspace _Down") },
|
||||
{ 0, MENU_ITEM_WORKSPACE_LIST, FALSE, NULL },
|
||||
{ 0, MENU_ITEM_SEPARATOR, FALSE, NULL }, /* separator */
|
||||
/* Translators: Translate this string the same way as you do in libwnck! */
|
||||
{ META_MENU_OP_DELETE, MENU_ITEM_IMAGE, METACITY_STOCK_DELETE, FALSE, N_("_Close") }
|
||||
{ META_MENU_OP_DELETE, MENU_ITEM_NORMAL, FALSE, N_("_Close") }
|
||||
};
|
||||
|
||||
static void
|
||||
@ -274,16 +272,6 @@ menu_item_new (MenuItem *menuitem, int workspace_id)
|
||||
{
|
||||
mi = gtk_menu_item_new ();
|
||||
}
|
||||
else if (menuitem->type == MENU_ITEM_IMAGE)
|
||||
{
|
||||
GtkWidget *image;
|
||||
|
||||
image = gtk_image_new_from_stock (menuitem->stock_id, GTK_ICON_SIZE_MENU);
|
||||
mi = gtk_image_menu_item_new ();
|
||||
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), image);
|
||||
gtk_widget_show (image);
|
||||
}
|
||||
else if (menuitem->type == MENU_ITEM_CHECKBOX)
|
||||
{
|
||||
mi = gtk_check_menu_item_new ();
|
||||
@ -392,8 +380,7 @@ meta_window_menu_new (MetaFrames *frames,
|
||||
int j;
|
||||
|
||||
MenuItem to_another_workspace = {
|
||||
0, MENU_ITEM_NORMAL,
|
||||
NULL, FALSE,
|
||||
0, MENU_ITEM_NORMAL, FALSE,
|
||||
N_("Move to Another _Workspace")
|
||||
};
|
||||
|
||||
|
@ -27,11 +27,6 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include "frames.h"
|
||||
|
||||
/* Stock icons */
|
||||
#define METACITY_STOCK_DELETE "metacity-delete"
|
||||
#define METACITY_STOCK_MINIMIZE "metacity-minimize"
|
||||
#define METACITY_STOCK_MAXIMIZE "metacity-maximize"
|
||||
|
||||
struct _MetaWindowMenu
|
||||
{
|
||||
MetaFrames *frames;
|
||||
|
@ -1,496 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2002 Havoc Pennington
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* SECTION:preview-widget
|
||||
* @title: MetaPreview
|
||||
* @short_description: Mutter theme preview widget
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#define _XOPEN_SOURCE 600 /* for the maths routines over floats */
|
||||
|
||||
#include <math.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <meta/preview-widget.h>
|
||||
#include "theme-private.h"
|
||||
|
||||
static void meta_preview_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural);
|
||||
static void meta_preview_get_preferred_height (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural);
|
||||
static void meta_preview_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation);
|
||||
static gboolean meta_preview_draw (GtkWidget *widget,
|
||||
cairo_t *cr);
|
||||
static void meta_preview_realize (GtkWidget *widget);
|
||||
static void meta_preview_dispose (GObject *object);
|
||||
static void meta_preview_finalize (GObject *object);
|
||||
|
||||
G_DEFINE_TYPE (MetaPreview, meta_preview, GTK_TYPE_BIN);
|
||||
|
||||
static void
|
||||
meta_preview_class_init (MetaPreviewClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
||||
GtkWidgetClass *widget_class;
|
||||
|
||||
widget_class = (GtkWidgetClass*) class;
|
||||
|
||||
gobject_class->dispose = meta_preview_dispose;
|
||||
gobject_class->finalize = meta_preview_finalize;
|
||||
|
||||
widget_class->realize = meta_preview_realize;
|
||||
widget_class->draw = meta_preview_draw;
|
||||
widget_class->get_preferred_width = meta_preview_get_preferred_width;
|
||||
widget_class->get_preferred_height = meta_preview_get_preferred_height;
|
||||
widget_class->size_allocate = meta_preview_size_allocate;
|
||||
|
||||
gtk_container_class_handle_border_width (GTK_CONTAINER_CLASS (class));
|
||||
}
|
||||
|
||||
static void
|
||||
meta_preview_init (MetaPreview *preview)
|
||||
{
|
||||
int i;
|
||||
|
||||
gtk_widget_set_has_window (GTK_WIDGET (preview), FALSE);
|
||||
|
||||
i = 0;
|
||||
while (i < MAX_BUTTONS_PER_CORNER)
|
||||
{
|
||||
preview->button_layout.left_buttons[i] = META_BUTTON_FUNCTION_LAST;
|
||||
preview->button_layout.right_buttons[i] = META_BUTTON_FUNCTION_LAST;
|
||||
++i;
|
||||
}
|
||||
|
||||
preview->button_layout.left_buttons[0] = META_BUTTON_FUNCTION_MENU;
|
||||
|
||||
preview->button_layout.right_buttons[0] = META_BUTTON_FUNCTION_MINIMIZE;
|
||||
preview->button_layout.right_buttons[1] = META_BUTTON_FUNCTION_MAXIMIZE;
|
||||
preview->button_layout.right_buttons[2] = META_BUTTON_FUNCTION_CLOSE;
|
||||
|
||||
preview->type = META_FRAME_TYPE_NORMAL;
|
||||
preview->flags =
|
||||
META_FRAME_ALLOWS_DELETE |
|
||||
META_FRAME_ALLOWS_MENU |
|
||||
META_FRAME_ALLOWS_MINIMIZE |
|
||||
META_FRAME_ALLOWS_MAXIMIZE |
|
||||
META_FRAME_ALLOWS_VERTICAL_RESIZE |
|
||||
META_FRAME_ALLOWS_HORIZONTAL_RESIZE |
|
||||
META_FRAME_HAS_FOCUS |
|
||||
META_FRAME_ALLOWS_SHADE |
|
||||
META_FRAME_ALLOWS_MOVE;
|
||||
|
||||
preview->borders_cached = FALSE;
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
meta_preview_new (void)
|
||||
{
|
||||
MetaPreview *preview;
|
||||
|
||||
preview = g_object_new (META_TYPE_PREVIEW, NULL);
|
||||
|
||||
return GTK_WIDGET (preview);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_preview_dispose (GObject *object)
|
||||
{
|
||||
MetaPreview *preview = META_PREVIEW (object);
|
||||
|
||||
g_clear_object (&preview->style_context);
|
||||
|
||||
G_OBJECT_CLASS (meta_preview_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_preview_finalize (GObject *object)
|
||||
{
|
||||
MetaPreview *preview;
|
||||
|
||||
preview = META_PREVIEW (object);
|
||||
|
||||
g_free (preview->title);
|
||||
preview->title = NULL;
|
||||
|
||||
G_OBJECT_CLASS (meta_preview_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_info (MetaPreview *preview)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = GTK_WIDGET (preview);
|
||||
|
||||
if (preview->layout == NULL)
|
||||
{
|
||||
PangoFontDescription *font_desc;
|
||||
double scale;
|
||||
PangoAttrList *attrs;
|
||||
PangoAttribute *attr;
|
||||
|
||||
if (preview->theme)
|
||||
scale = meta_theme_get_title_scale (preview->theme,
|
||||
preview->type,
|
||||
preview->flags);
|
||||
else
|
||||
scale = 1.0;
|
||||
|
||||
preview->layout = gtk_widget_create_pango_layout (widget,
|
||||
preview->title);
|
||||
|
||||
font_desc = meta_gtk_widget_get_font_desc (widget, scale, NULL);
|
||||
|
||||
preview->text_height =
|
||||
meta_pango_font_desc_get_text_height (font_desc,
|
||||
gtk_widget_get_pango_context (widget));
|
||||
|
||||
attrs = pango_attr_list_new ();
|
||||
|
||||
attr = pango_attr_size_new (pango_font_description_get_size (font_desc));
|
||||
attr->start_index = 0;
|
||||
attr->end_index = G_MAXINT;
|
||||
|
||||
pango_attr_list_insert (attrs, attr);
|
||||
|
||||
pango_layout_set_attributes (preview->layout, attrs);
|
||||
|
||||
pango_attr_list_unref (attrs);
|
||||
|
||||
pango_font_description_free (font_desc);
|
||||
}
|
||||
|
||||
if (!preview->borders_cached)
|
||||
{
|
||||
if (preview->theme)
|
||||
meta_theme_get_frame_borders (preview->theme,
|
||||
preview->type,
|
||||
preview->text_height,
|
||||
preview->flags,
|
||||
&preview->borders);
|
||||
else
|
||||
meta_frame_borders_clear (&preview->borders);
|
||||
preview->borders_cached = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_preview_draw (GtkWidget *widget,
|
||||
cairo_t *cr)
|
||||
{
|
||||
MetaPreview *preview = META_PREVIEW (widget);
|
||||
GtkAllocation allocation;
|
||||
|
||||
gtk_widget_get_allocation (widget, &allocation);
|
||||
|
||||
if (preview->theme)
|
||||
{
|
||||
int client_width;
|
||||
int client_height;
|
||||
MetaButtonState button_states[META_BUTTON_TYPE_LAST] =
|
||||
{
|
||||
META_BUTTON_STATE_NORMAL,
|
||||
META_BUTTON_STATE_NORMAL,
|
||||
META_BUTTON_STATE_NORMAL,
|
||||
META_BUTTON_STATE_NORMAL
|
||||
};
|
||||
|
||||
ensure_info (preview);
|
||||
cairo_save (cr);
|
||||
|
||||
client_width = allocation.width - preview->borders.total.left - preview->borders.total.right;
|
||||
client_height = allocation.height - preview->borders.total.top - preview->borders.total.bottom;
|
||||
|
||||
if (client_width < 0)
|
||||
client_width = 1;
|
||||
if (client_height < 0)
|
||||
client_height = 1;
|
||||
|
||||
meta_theme_draw_frame (preview->theme,
|
||||
preview->style_context,
|
||||
cr,
|
||||
preview->type,
|
||||
preview->flags,
|
||||
client_width, client_height,
|
||||
preview->layout,
|
||||
preview->text_height,
|
||||
&preview->button_layout,
|
||||
button_states,
|
||||
meta_preview_get_mini_icon (),
|
||||
meta_preview_get_icon ());
|
||||
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
/* draw child */
|
||||
return GTK_WIDGET_CLASS (meta_preview_parent_class)->draw (widget, cr);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_preview_realize (GtkWidget *widget)
|
||||
{
|
||||
MetaPreview *preview = META_PREVIEW (widget);
|
||||
|
||||
GTK_WIDGET_CLASS (meta_preview_parent_class)->realize (widget);
|
||||
|
||||
preview->style_context = meta_theme_create_style_context (gtk_widget_get_screen (widget),
|
||||
NULL);
|
||||
}
|
||||
|
||||
#define NO_CHILD_WIDTH 80
|
||||
#define NO_CHILD_HEIGHT 20
|
||||
|
||||
static void
|
||||
meta_preview_get_preferred_width (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
MetaPreview *preview;
|
||||
GtkWidget *child;
|
||||
|
||||
preview = META_PREVIEW (widget);
|
||||
|
||||
ensure_info (preview);
|
||||
|
||||
*minimum = *natural = preview->borders.total.left + preview->borders.total.right;
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (preview));
|
||||
if (child && gtk_widget_get_visible (child))
|
||||
{
|
||||
gint child_min, child_nat;
|
||||
|
||||
gtk_widget_get_preferred_width (child, &child_min, &child_nat);
|
||||
|
||||
*minimum += child_min;
|
||||
*natural += child_nat;
|
||||
}
|
||||
else
|
||||
{
|
||||
*minimum += NO_CHILD_WIDTH;
|
||||
*natural += NO_CHILD_WIDTH;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_preview_get_preferred_height (GtkWidget *widget,
|
||||
gint *minimum,
|
||||
gint *natural)
|
||||
{
|
||||
MetaPreview *preview;
|
||||
GtkWidget *child;
|
||||
|
||||
preview = META_PREVIEW (widget);
|
||||
|
||||
ensure_info (preview);
|
||||
|
||||
*minimum = *natural = preview->borders.total.top + preview->borders.total.bottom;
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (preview));
|
||||
if (child && gtk_widget_get_visible (child))
|
||||
{
|
||||
gint child_min, child_nat;
|
||||
|
||||
gtk_widget_get_preferred_height (child, &child_min, &child_nat);
|
||||
|
||||
*minimum += child_min;
|
||||
*natural += child_nat;
|
||||
}
|
||||
else
|
||||
{
|
||||
*minimum += NO_CHILD_HEIGHT;
|
||||
*natural += NO_CHILD_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_preview_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
{
|
||||
MetaPreview *preview;
|
||||
GtkAllocation widget_allocation, child_allocation;
|
||||
GtkWidget *child;
|
||||
|
||||
preview = META_PREVIEW (widget);
|
||||
|
||||
ensure_info (preview);
|
||||
|
||||
gtk_widget_set_allocation (widget, allocation);
|
||||
|
||||
child = gtk_bin_get_child (GTK_BIN (widget));
|
||||
if (child && gtk_widget_get_visible (child))
|
||||
{
|
||||
gtk_widget_get_allocation (widget, &widget_allocation);
|
||||
child_allocation.x = widget_allocation.x + preview->borders.total.left;
|
||||
child_allocation.y = widget_allocation.y + preview->borders.total.top;
|
||||
|
||||
child_allocation.width = MAX (1, widget_allocation.width - preview->borders.total.left - preview->borders.total.right);
|
||||
child_allocation.height = MAX (1, widget_allocation.height - preview->borders.total.top - preview->borders.total.bottom);
|
||||
|
||||
gtk_widget_size_allocate (child, &child_allocation);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clear_cache (MetaPreview *preview)
|
||||
{
|
||||
if (preview->layout)
|
||||
{
|
||||
g_object_unref (G_OBJECT (preview->layout));
|
||||
preview->layout = NULL;
|
||||
}
|
||||
|
||||
preview->borders_cached = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
meta_preview_set_theme (MetaPreview *preview,
|
||||
MetaTheme *theme)
|
||||
{
|
||||
g_return_if_fail (META_IS_PREVIEW (preview));
|
||||
|
||||
preview->theme = theme;
|
||||
|
||||
clear_cache (preview);
|
||||
|
||||
gtk_widget_queue_resize (GTK_WIDGET (preview));
|
||||
}
|
||||
|
||||
void
|
||||
meta_preview_set_title (MetaPreview *preview,
|
||||
const char *title)
|
||||
{
|
||||
g_return_if_fail (META_IS_PREVIEW (preview));
|
||||
|
||||
g_free (preview->title);
|
||||
preview->title = g_strdup (title);
|
||||
|
||||
clear_cache (preview);
|
||||
|
||||
gtk_widget_queue_resize (GTK_WIDGET (preview));
|
||||
}
|
||||
|
||||
void
|
||||
meta_preview_set_frame_type (MetaPreview *preview,
|
||||
MetaFrameType type)
|
||||
{
|
||||
g_return_if_fail (META_IS_PREVIEW (preview));
|
||||
|
||||
preview->type = type;
|
||||
|
||||
clear_cache (preview);
|
||||
|
||||
gtk_widget_queue_resize (GTK_WIDGET (preview));
|
||||
}
|
||||
|
||||
void
|
||||
meta_preview_set_frame_flags (MetaPreview *preview,
|
||||
MetaFrameFlags flags)
|
||||
{
|
||||
g_return_if_fail (META_IS_PREVIEW (preview));
|
||||
|
||||
preview->flags = flags;
|
||||
|
||||
clear_cache (preview);
|
||||
|
||||
gtk_widget_queue_resize (GTK_WIDGET (preview));
|
||||
}
|
||||
|
||||
void
|
||||
meta_preview_set_button_layout (MetaPreview *preview,
|
||||
const MetaButtonLayout *button_layout)
|
||||
{
|
||||
g_return_if_fail (META_IS_PREVIEW (preview));
|
||||
|
||||
preview->button_layout = *button_layout;
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (preview));
|
||||
}
|
||||
|
||||
GdkPixbuf*
|
||||
meta_preview_get_icon (void)
|
||||
{
|
||||
static GdkPixbuf *default_icon = NULL;
|
||||
|
||||
if (default_icon == NULL)
|
||||
{
|
||||
GtkIconTheme *theme;
|
||||
gboolean icon_exists;
|
||||
|
||||
theme = gtk_icon_theme_get_default ();
|
||||
|
||||
icon_exists = gtk_icon_theme_has_icon (theme, META_DEFAULT_ICON_NAME);
|
||||
|
||||
if (icon_exists)
|
||||
default_icon = gtk_icon_theme_load_icon (theme,
|
||||
META_DEFAULT_ICON_NAME,
|
||||
META_ICON_WIDTH,
|
||||
0,
|
||||
NULL);
|
||||
else
|
||||
default_icon = gtk_icon_theme_load_icon (theme,
|
||||
"gtk-missing-image",
|
||||
META_ICON_WIDTH,
|
||||
0,
|
||||
NULL);
|
||||
|
||||
g_assert (default_icon);
|
||||
}
|
||||
|
||||
return default_icon;
|
||||
}
|
||||
|
||||
GdkPixbuf*
|
||||
meta_preview_get_mini_icon (void)
|
||||
{
|
||||
static GdkPixbuf *default_icon = NULL;
|
||||
|
||||
if (default_icon == NULL)
|
||||
{
|
||||
GtkIconTheme *theme;
|
||||
gboolean icon_exists;
|
||||
|
||||
theme = gtk_icon_theme_get_default ();
|
||||
|
||||
icon_exists = gtk_icon_theme_has_icon (theme, META_DEFAULT_ICON_NAME);
|
||||
|
||||
if (icon_exists)
|
||||
default_icon = gtk_icon_theme_load_icon (theme,
|
||||
META_DEFAULT_ICON_NAME,
|
||||
META_MINI_ICON_WIDTH,
|
||||
0,
|
||||
NULL);
|
||||
else
|
||||
default_icon = gtk_icon_theme_load_icon (theme,
|
||||
"gtk-missing-image",
|
||||
META_MINI_ICON_WIDTH,
|
||||
0,
|
||||
NULL);
|
||||
|
||||
g_assert (default_icon);
|
||||
}
|
||||
|
||||
return default_icon;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -5063,16 +5063,14 @@ meta_theme_get_current (void)
|
||||
}
|
||||
|
||||
void
|
||||
meta_theme_set_current (const char *name,
|
||||
gboolean force_reload)
|
||||
meta_theme_set_current (const char *name)
|
||||
{
|
||||
MetaTheme *new_theme;
|
||||
GError *err;
|
||||
|
||||
meta_topic (META_DEBUG_THEMES, "Setting current theme to \"%s\"\n", name);
|
||||
|
||||
if (!force_reload &&
|
||||
meta_current_theme &&
|
||||
if (meta_current_theme &&
|
||||
strcmp (name, meta_current_theme->name) == 0)
|
||||
return;
|
||||
|
||||
|
53
src/ui/ui.c
53
src/ui/ui.c
@ -4,7 +4,6 @@
|
||||
|
||||
/*
|
||||
* Copyright (C) 2002 Havoc Pennington
|
||||
* stock icon code Copyright (C) 2002 Jorn Baayen <jorn@nl.linux.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
@ -31,13 +30,10 @@
|
||||
#include "core.h"
|
||||
#include "theme-private.h"
|
||||
|
||||
#include "inlinepixbufs.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <cairo-xlib.h>
|
||||
|
||||
static void meta_stock_icons_init (void);
|
||||
static void meta_ui_accelerator_parse (const char *accel,
|
||||
guint *keysym,
|
||||
guint *keycode,
|
||||
@ -62,8 +58,6 @@ meta_ui_init (void)
|
||||
{
|
||||
if (!gtk_init_check (NULL, NULL))
|
||||
meta_fatal ("Unable to open X display %s\n", XDisplayName (NULL));
|
||||
|
||||
meta_stock_icons_init ();
|
||||
}
|
||||
|
||||
Display*
|
||||
@ -775,10 +769,9 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
|
||||
}
|
||||
|
||||
void
|
||||
meta_ui_set_current_theme (const char *name,
|
||||
gboolean force_reload)
|
||||
meta_ui_set_current_theme (const char *name)
|
||||
{
|
||||
meta_theme_set_current (name, force_reload);
|
||||
meta_theme_set_current (name);
|
||||
meta_invalidate_default_icons ();
|
||||
}
|
||||
|
||||
@ -998,48 +991,6 @@ meta_ui_window_is_widget (MetaUI *ui,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* stock icon code Copyright (C) 2002 Jorn Baayen <jorn@nl.linux.org> */
|
||||
typedef struct
|
||||
{
|
||||
char *stock_id;
|
||||
const guint8 *icon_data;
|
||||
} MetaStockIcon;
|
||||
|
||||
static void
|
||||
meta_stock_icons_init (void)
|
||||
{
|
||||
GtkIconFactory *factory;
|
||||
int i;
|
||||
|
||||
MetaStockIcon items[] =
|
||||
{
|
||||
{ METACITY_STOCK_DELETE, stock_delete_data },
|
||||
{ METACITY_STOCK_MINIMIZE, stock_minimize_data },
|
||||
{ METACITY_STOCK_MAXIMIZE, stock_maximize_data }
|
||||
};
|
||||
|
||||
factory = gtk_icon_factory_new ();
|
||||
gtk_icon_factory_add_default (factory);
|
||||
|
||||
for (i = 0; i < (gint) G_N_ELEMENTS (items); i++)
|
||||
{
|
||||
GtkIconSet *icon_set;
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_inline (-1, items[i].icon_data,
|
||||
FALSE,
|
||||
NULL);
|
||||
|
||||
icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
|
||||
gtk_icon_factory_add (factory, items[i].stock_id, icon_set);
|
||||
gtk_icon_set_unref (icon_set);
|
||||
|
||||
g_object_unref (G_OBJECT (pixbuf));
|
||||
}
|
||||
|
||||
g_object_unref (G_OBJECT (factory));
|
||||
}
|
||||
|
||||
int
|
||||
meta_ui_get_drag_threshold (MetaUI *ui)
|
||||
{
|
||||
|
@ -154,8 +154,7 @@ gboolean meta_ui_window_should_not_cause_focus (Display *xdisplay,
|
||||
char* meta_text_property_to_utf8 (Display *xdisplay,
|
||||
const XTextProperty *prop);
|
||||
|
||||
void meta_ui_set_current_theme (const char *name,
|
||||
gboolean force_reload);
|
||||
void meta_ui_set_current_theme (const char *name);
|
||||
gboolean meta_ui_have_a_theme (void);
|
||||
|
||||
/* Not a real key symbol but means "key above the tab key"; this is
|
||||
|
@ -1,7 +0,0 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
focus-window
|
||||
test-gravity
|
||||
test-resizing
|
||||
wm-tester
|
||||
test-size-hints
|
@ -1,33 +0,0 @@
|
||||
|
||||
INCLUDES=@MUTTER_CFLAGS@
|
||||
|
||||
wm_tester_SOURCES= \
|
||||
main.c
|
||||
|
||||
test_gravity_SOURCES= \
|
||||
test-gravity.c
|
||||
|
||||
focus_window_SOURCES= \
|
||||
focus-window.c
|
||||
|
||||
test_resizing_SOURCES= \
|
||||
test-resizing.c
|
||||
|
||||
test_size_hints_SOURCES= \
|
||||
test-size-hints.c
|
||||
|
||||
test_attached_SOURCES= \
|
||||
test-attached.c
|
||||
|
||||
test_focus_SOURCES= \
|
||||
test-focus.c
|
||||
|
||||
noinst_PROGRAMS=wm-tester test-gravity test-resizing focus-window test-size-hints test-attached test-focus
|
||||
|
||||
wm_tester_LDADD= @MUTTER_LIBS@
|
||||
test_gravity_LDADD= @MUTTER_LIBS@
|
||||
test_resizing_LDADD= @MUTTER_LIBS@
|
||||
test_size_hints_LDADD= @MUTTER_LIBS@
|
||||
focus_window_LDADD= @MUTTER_LIBS@
|
||||
test_attached_LDADD= @MUTTER_LIBS@
|
||||
test_focus_LDADD= @MUTTER_LIBS@
|
@ -1,37 +0,0 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
Display *d;
|
||||
Window w;
|
||||
const char *w_str;
|
||||
char *end;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
fprintf (stderr, "Usage: focus-window WINDOWID\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
d = XOpenDisplay (NULL);
|
||||
|
||||
w_str = argv[1];
|
||||
end = NULL;
|
||||
|
||||
w = strtoul (w_str, &end, 16);
|
||||
if (end == w_str)
|
||||
{
|
||||
fprintf (stderr, "Usage: focus-window WINDOWID\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
printf ("Setting input focus to 0x%lx\n", w);
|
||||
XSetInputFocus (d, w, RevertToPointerRoot, CurrentTime);
|
||||
XFlush (d);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,245 +0,0 @@
|
||||
/* WM tester main() */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2001 Havoc Pennington
|
||||
*
|
||||
* 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 <gtk/gtk.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void set_up_the_evil (void);
|
||||
static void set_up_icon_windows (void);
|
||||
|
||||
static void
|
||||
usage (void)
|
||||
{
|
||||
g_print ("wm-tester [--evil] [--icon-windows]\n");
|
||||
exit (0);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
gboolean do_evil;
|
||||
gboolean do_icon_windows;
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
do_evil = FALSE;
|
||||
do_icon_windows = FALSE;
|
||||
|
||||
i = 1;
|
||||
while (i < argc)
|
||||
{
|
||||
const char *arg = argv[i];
|
||||
|
||||
if (strcmp (arg, "--help") == 0 ||
|
||||
strcmp (arg, "-h") == 0 ||
|
||||
strcmp (arg, "-?") == 0)
|
||||
usage ();
|
||||
else if (strcmp (arg, "--evil") == 0)
|
||||
do_evil = TRUE;
|
||||
else if (strcmp (arg, "--icon-windows") == 0)
|
||||
do_icon_windows = TRUE;
|
||||
else
|
||||
usage ();
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
/* Be sure some option was provided */
|
||||
if (! (do_evil || do_icon_windows))
|
||||
return 1;
|
||||
|
||||
if (do_evil)
|
||||
set_up_the_evil ();
|
||||
|
||||
if (do_icon_windows)
|
||||
set_up_icon_windows ();
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static GSList *evil_windows = NULL;
|
||||
|
||||
static gint
|
||||
evil_timeout (gpointer data)
|
||||
{
|
||||
int i;
|
||||
int n_windows;
|
||||
int len;
|
||||
int create_count;
|
||||
int destroy_count;
|
||||
|
||||
len = g_slist_length (evil_windows);
|
||||
|
||||
if (len > 35)
|
||||
{
|
||||
create_count = 2;
|
||||
destroy_count = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
create_count = 5;
|
||||
destroy_count = 5;
|
||||
}
|
||||
|
||||
/* Create some windows */
|
||||
n_windows = g_random_int_range (0, create_count);
|
||||
|
||||
i = 0;
|
||||
while (i < n_windows)
|
||||
{
|
||||
GtkWidget *w;
|
||||
GtkWidget *c;
|
||||
int t;
|
||||
GtkWidget *parent;
|
||||
|
||||
w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
gtk_window_move (GTK_WINDOW (w),
|
||||
g_random_int_range (0,
|
||||
gdk_screen_width ()),
|
||||
g_random_int_range (0,
|
||||
gdk_screen_height ()));
|
||||
|
||||
parent = NULL;
|
||||
|
||||
/* set transient for random window (may create all kinds of weird cycles) */
|
||||
if (len > 0)
|
||||
{
|
||||
t = g_random_int_range (- (len / 3), len);
|
||||
if (t >= 0)
|
||||
{
|
||||
parent = g_slist_nth_data (evil_windows, t);
|
||||
|
||||
if (parent != NULL)
|
||||
gtk_window_set_transient_for (GTK_WINDOW (w), GTK_WINDOW (parent));
|
||||
}
|
||||
}
|
||||
|
||||
if (parent != NULL)
|
||||
c = gtk_button_new_with_label ("Evil Transient!");
|
||||
else
|
||||
c = gtk_button_new_with_label ("Evil Window!");
|
||||
gtk_container_add (GTK_CONTAINER (w), c);
|
||||
|
||||
gtk_widget_show_all (w);
|
||||
|
||||
evil_windows = g_slist_prepend (evil_windows, w);
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
/* Destroy some windows */
|
||||
if (len > destroy_count)
|
||||
{
|
||||
n_windows = g_random_int_range (0, destroy_count);
|
||||
i = 0;
|
||||
while (i < n_windows)
|
||||
{
|
||||
GtkWidget *w;
|
||||
|
||||
w = g_slist_nth_data (evil_windows,
|
||||
g_random_int_range (0, len));
|
||||
if (w)
|
||||
{
|
||||
--len;
|
||||
evil_windows = g_slist_remove (evil_windows, w);
|
||||
gtk_widget_destroy (w);
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
set_up_the_evil (void)
|
||||
{
|
||||
g_timeout_add (400, evil_timeout, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
set_up_icon_windows (void)
|
||||
{
|
||||
int i;
|
||||
int n_windows;
|
||||
|
||||
/* Create some windows */
|
||||
n_windows = 9;
|
||||
|
||||
i = 0;
|
||||
while (i < n_windows)
|
||||
{
|
||||
GtkWidget *w;
|
||||
GtkWidget *c;
|
||||
GList *icons;
|
||||
GdkPixbuf *pix;
|
||||
|
||||
w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
c = gtk_button_new_with_label ("Icon window");
|
||||
gtk_container_add (GTK_CONTAINER (w), c);
|
||||
|
||||
icons = NULL;
|
||||
|
||||
pix = gtk_widget_render_icon (w,
|
||||
GTK_STOCK_SAVE,
|
||||
GTK_ICON_SIZE_LARGE_TOOLBAR,
|
||||
NULL);
|
||||
|
||||
icons = g_list_append (icons, pix);
|
||||
|
||||
if (i % 2)
|
||||
{
|
||||
pix = gtk_widget_render_icon (w,
|
||||
GTK_STOCK_SAVE,
|
||||
GTK_ICON_SIZE_DIALOG,
|
||||
NULL);
|
||||
icons = g_list_append (icons, pix);
|
||||
}
|
||||
|
||||
if (i % 3)
|
||||
{
|
||||
pix = gtk_widget_render_icon (w,
|
||||
GTK_STOCK_SAVE,
|
||||
GTK_ICON_SIZE_MENU,
|
||||
NULL);
|
||||
icons = g_list_append (icons, pix);
|
||||
}
|
||||
|
||||
gtk_window_set_icon_list (GTK_WINDOW (w), icons);
|
||||
|
||||
g_list_foreach (icons, (GFunc) g_object_unref, NULL);
|
||||
g_list_free (icons);
|
||||
|
||||
gtk_widget_show_all (w);
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
@ -1,100 +0,0 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
enum {
|
||||
DESTROY_PARENT,
|
||||
DETACH,
|
||||
ATTACH_1,
|
||||
ATTACH_2
|
||||
};
|
||||
|
||||
GtkWidget *window1, *window2;
|
||||
|
||||
static void
|
||||
dialog_response (GtkDialog *dialog, int response, gpointer user_data)
|
||||
{
|
||||
if (response == DESTROY_PARENT)
|
||||
{
|
||||
GtkWidget *window = GTK_WIDGET (gtk_window_get_transient_for (GTK_WINDOW (dialog)));
|
||||
|
||||
if (window == window1)
|
||||
{
|
||||
gtk_dialog_set_response_sensitive (dialog, ATTACH_1, FALSE);
|
||||
window1 = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_dialog_set_response_sensitive (dialog, ATTACH_2, FALSE);
|
||||
window2 = NULL;
|
||||
}
|
||||
|
||||
gtk_dialog_set_response_sensitive (dialog, DESTROY_PARENT, FALSE);
|
||||
gtk_dialog_set_response_sensitive (dialog, DETACH, FALSE);
|
||||
gtk_widget_destroy (window);
|
||||
}
|
||||
else if (response == DETACH)
|
||||
{
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog), NULL);
|
||||
gtk_dialog_set_response_sensitive (dialog, DESTROY_PARENT, FALSE);
|
||||
gtk_dialog_set_response_sensitive (dialog, DETACH, FALSE);
|
||||
gtk_dialog_set_response_sensitive (dialog, ATTACH_1, window1 != NULL);
|
||||
gtk_dialog_set_response_sensitive (dialog, ATTACH_2, window2 != NULL);
|
||||
}
|
||||
else if (response == ATTACH_1)
|
||||
{
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window1));
|
||||
gtk_dialog_set_response_sensitive (dialog, DESTROY_PARENT, TRUE);
|
||||
gtk_dialog_set_response_sensitive (dialog, DETACH, TRUE);
|
||||
gtk_dialog_set_response_sensitive (dialog, ATTACH_1, FALSE);
|
||||
gtk_dialog_set_response_sensitive (dialog, ATTACH_2, window2 != NULL);
|
||||
}
|
||||
else if (response == ATTACH_2)
|
||||
{
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window2));
|
||||
gtk_dialog_set_response_sensitive (dialog, DESTROY_PARENT, TRUE);
|
||||
gtk_dialog_set_response_sensitive (dialog, DETACH, TRUE);
|
||||
gtk_dialog_set_response_sensitive (dialog, ATTACH_1, window1 != NULL);
|
||||
gtk_dialog_set_response_sensitive (dialog, ATTACH_2, FALSE);
|
||||
}
|
||||
else if (response == GTK_RESPONSE_CLOSE)
|
||||
gtk_main_quit ();
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (window1), "Parent 1");
|
||||
gtk_widget_show (window1);
|
||||
|
||||
window2 = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (window2), "Parent 2");
|
||||
gtk_widget_show (window2);
|
||||
|
||||
dialog = gtk_dialog_new_with_buttons ("Child",
|
||||
NULL,
|
||||
GTK_DIALOG_MODAL,
|
||||
"Destroy Parent",
|
||||
DESTROY_PARENT,
|
||||
"Detach",
|
||||
DETACH,
|
||||
"Attach to 1",
|
||||
ATTACH_1,
|
||||
"Attach to 2",
|
||||
ATTACH_2,
|
||||
GTK_STOCK_QUIT,
|
||||
GTK_RESPONSE_CLOSE,
|
||||
NULL);
|
||||
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), DESTROY_PARENT, FALSE);
|
||||
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), DETACH, FALSE);
|
||||
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (dialog_response), NULL);
|
||||
gtk_widget_show (dialog);
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,362 +0,0 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
GtkWidget *main_window;
|
||||
GtkWidget *noinput_window, *passive_window, *local_window;
|
||||
GtkWidget *global_window, *lame_window, *grabby_window, *dying_window;
|
||||
|
||||
static void
|
||||
clear_on_destroy (GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
GtkWidget **widget_pointer = user_data;
|
||||
|
||||
*widget_pointer = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
disable_take_focus (GtkWidget *window)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
GdkWindow *gdkwindow;
|
||||
Atom *protocols, wm_take_focus;
|
||||
int n_protocols, i;
|
||||
|
||||
gtk_widget_realize (window);
|
||||
gdkwindow = gtk_widget_get_window (window);
|
||||
display = gdk_window_get_display (gdkwindow);
|
||||
|
||||
wm_take_focus = gdk_x11_get_xatom_by_name_for_display (display, "WM_TAKE_FOCUS");
|
||||
XGetWMProtocols (GDK_DISPLAY_XDISPLAY (display),
|
||||
GDK_WINDOW_XID (gdkwindow),
|
||||
&protocols, &n_protocols);
|
||||
for (i = 0; i < n_protocols; i++)
|
||||
{
|
||||
if (protocols[i] == wm_take_focus)
|
||||
{
|
||||
protocols[i] = protocols[n_protocols - 1];
|
||||
n_protocols--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
XSetWMProtocols (GDK_DISPLAY_XDISPLAY (display),
|
||||
GDK_WINDOW_XID (gdkwindow),
|
||||
protocols, n_protocols);
|
||||
XFree (protocols);
|
||||
}
|
||||
|
||||
static void
|
||||
clear_input_hint (GtkWidget *window)
|
||||
{
|
||||
/* This needs to be called after gtk_widget_show, otherwise
|
||||
* GTK+ will overwrite it. */
|
||||
GdkWindow *gdkwindow = gtk_widget_get_window (window);
|
||||
XWMHints *wm_hints;
|
||||
|
||||
wm_hints = XGetWMHints (GDK_DISPLAY_XDISPLAY (gdk_window_get_display (gdkwindow)),
|
||||
GDK_WINDOW_XID (gdkwindow));
|
||||
|
||||
wm_hints->flags |= InputHint;
|
||||
wm_hints->input = False;
|
||||
|
||||
XSetWMHints (GDK_DISPLAY_XDISPLAY (gdk_window_get_display (gdkwindow)),
|
||||
GDK_WINDOW_XID (gdkwindow),
|
||||
wm_hints);
|
||||
|
||||
XFree (wm_hints);
|
||||
}
|
||||
|
||||
static void
|
||||
active_notify (GObject *obj,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkLabel *label = user_data;
|
||||
|
||||
if (gtk_window_is_active (GTK_WINDOW (obj)))
|
||||
gtk_label_set_text (label, "Focused");
|
||||
else
|
||||
gtk_label_set_text (label, "Not focused");
|
||||
}
|
||||
|
||||
static void
|
||||
make_focused_label (GtkWidget *toplevel,
|
||||
GtkWidget *parent)
|
||||
{
|
||||
GtkWidget *label;
|
||||
|
||||
label = gtk_label_new ("");
|
||||
gtk_widget_show (label);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (parent), label);
|
||||
|
||||
g_signal_connect (toplevel, "notify::is-active",
|
||||
G_CALLBACK (active_notify), label);
|
||||
active_notify (G_OBJECT (toplevel), NULL, label);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_test_dialog (GtkWidget *toplevel)
|
||||
{
|
||||
make_focused_label (toplevel, toplevel);
|
||||
gtk_widget_set_size_request (toplevel, 200, 200);
|
||||
}
|
||||
|
||||
static void
|
||||
noinput_clicked (GtkButton *button, gpointer user_data)
|
||||
{
|
||||
if (noinput_window)
|
||||
gtk_window_present_with_time (GTK_WINDOW (noinput_window), gtk_get_current_event_time ());
|
||||
else
|
||||
{
|
||||
noinput_window = g_object_new (GTK_TYPE_WINDOW,
|
||||
"type", GTK_WINDOW_TOPLEVEL,
|
||||
"title", "No Input",
|
||||
"accept-focus", FALSE,
|
||||
NULL);
|
||||
setup_test_dialog (noinput_window);
|
||||
g_signal_connect (noinput_window, "destroy",
|
||||
G_CALLBACK (clear_on_destroy), &noinput_window);
|
||||
disable_take_focus (noinput_window);
|
||||
gtk_widget_show (noinput_window);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
passive_clicked (GtkButton *button, gpointer user_data)
|
||||
{
|
||||
if (passive_window)
|
||||
gtk_window_present_with_time (GTK_WINDOW (passive_window), gtk_get_current_event_time ());
|
||||
else
|
||||
{
|
||||
passive_window = g_object_new (GTK_TYPE_WINDOW,
|
||||
"type", GTK_WINDOW_TOPLEVEL,
|
||||
"title", "Passive Input",
|
||||
"accept-focus", TRUE,
|
||||
NULL);
|
||||
setup_test_dialog (passive_window);
|
||||
g_signal_connect (passive_window, "destroy",
|
||||
G_CALLBACK (clear_on_destroy), &passive_window);
|
||||
disable_take_focus (passive_window);
|
||||
gtk_widget_show (passive_window);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
local_clicked (GtkButton *button, gpointer user_data)
|
||||
{
|
||||
if (local_window)
|
||||
gtk_window_present_with_time (GTK_WINDOW (local_window), gtk_get_current_event_time ());
|
||||
else
|
||||
{
|
||||
local_window = g_object_new (GTK_TYPE_WINDOW,
|
||||
"type", GTK_WINDOW_TOPLEVEL,
|
||||
"title", "Locally Active Input",
|
||||
"accept-focus", TRUE,
|
||||
NULL);
|
||||
setup_test_dialog (local_window);
|
||||
g_signal_connect (local_window, "destroy",
|
||||
G_CALLBACK (clear_on_destroy), &local_window);
|
||||
gtk_widget_show (local_window);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
global_clicked (GtkButton *button, gpointer user_data)
|
||||
{
|
||||
if (global_window)
|
||||
gtk_window_present_with_time (GTK_WINDOW (global_window), gtk_get_current_event_time ());
|
||||
else
|
||||
{
|
||||
/* gtk will only process WM_TAKE_FOCUS messages if accept-focus
|
||||
* is TRUE. So we set that property and then manually clear the
|
||||
* Input WMHint.
|
||||
*/
|
||||
global_window = g_object_new (GTK_TYPE_WINDOW,
|
||||
"type", GTK_WINDOW_TOPLEVEL,
|
||||
"title", "Globally Active Input",
|
||||
"accept-focus", TRUE,
|
||||
NULL);
|
||||
setup_test_dialog (global_window);
|
||||
g_signal_connect (global_window, "destroy",
|
||||
G_CALLBACK (clear_on_destroy), &global_window);
|
||||
gtk_widget_show (global_window);
|
||||
clear_input_hint (global_window);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
lame_clicked (GtkButton *button, gpointer user_data)
|
||||
{
|
||||
if (lame_window)
|
||||
gtk_window_present_with_time (GTK_WINDOW (lame_window), gtk_get_current_event_time ());
|
||||
else
|
||||
{
|
||||
lame_window = g_object_new (GTK_TYPE_WINDOW,
|
||||
"type", GTK_WINDOW_TOPLEVEL,
|
||||
"title", "Lame Globally Active Input",
|
||||
"accept-focus", FALSE,
|
||||
NULL);
|
||||
setup_test_dialog (lame_window);
|
||||
g_signal_connect (lame_window, "destroy",
|
||||
G_CALLBACK (clear_on_destroy), &lame_window);
|
||||
gtk_widget_show (lame_window);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
grabby_active_changed (GObject *object, GParamSpec *param, gpointer user_data)
|
||||
{
|
||||
if (gtk_window_is_active (GTK_WINDOW (grabby_window)))
|
||||
{
|
||||
GdkWindow *gdkwindow = gtk_widget_get_window (grabby_window);
|
||||
guint32 now = gdk_x11_get_server_time (gdkwindow);
|
||||
|
||||
gtk_window_present_with_time (GTK_WINDOW (main_window), now - 1);
|
||||
XSetInputFocus (GDK_DISPLAY_XDISPLAY (gdk_window_get_display (gdkwindow)),
|
||||
GDK_WINDOW_XID (gdkwindow),
|
||||
RevertToParent,
|
||||
now);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
grabby_clicked (GtkButton *button, gpointer user_data)
|
||||
{
|
||||
if (grabby_window)
|
||||
gtk_window_present_with_time (GTK_WINDOW (grabby_window), gtk_get_current_event_time ());
|
||||
else
|
||||
{
|
||||
grabby_window = g_object_new (GTK_TYPE_WINDOW,
|
||||
"type", GTK_WINDOW_TOPLEVEL,
|
||||
"title", "Focus-grabbing Window",
|
||||
"accept-focus", TRUE,
|
||||
/* Because mutter maps windows
|
||||
* asynchronously, our trick won't
|
||||
* work if we try to do it when the
|
||||
* window is first mapped.
|
||||
*/
|
||||
"focus-on-map", FALSE,
|
||||
NULL);
|
||||
setup_test_dialog (grabby_window);
|
||||
g_signal_connect (grabby_window, "destroy",
|
||||
G_CALLBACK (clear_on_destroy), &grabby_window);
|
||||
g_signal_connect (grabby_window, "notify::is-active",
|
||||
G_CALLBACK (grabby_active_changed), NULL);
|
||||
gtk_widget_show (grabby_window);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
dying_clicked (GtkButton *button, gpointer user_data)
|
||||
{
|
||||
if (dying_window)
|
||||
{
|
||||
gtk_window_present_with_time (GTK_WINDOW (dying_window), gtk_get_current_event_time ());
|
||||
gtk_widget_destroy (dying_window);
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkWidget *label;
|
||||
|
||||
dying_window = g_object_new (GTK_TYPE_WINDOW,
|
||||
"type", GTK_WINDOW_TOPLEVEL,
|
||||
"title", "Dying Window",
|
||||
"accept-focus", TRUE,
|
||||
/* As with grabby window */
|
||||
"focus-on-map", FALSE,
|
||||
NULL);
|
||||
setup_test_dialog (dying_window);
|
||||
g_signal_connect (dying_window, "destroy",
|
||||
G_CALLBACK (clear_on_destroy), &dying_window);
|
||||
|
||||
label = gtk_label_new ("Click button again to test");
|
||||
gtk_container_add (GTK_CONTAINER (dying_window), label);
|
||||
gtk_widget_set_size_request (dying_window, 200, 200);
|
||||
|
||||
gtk_widget_show_all (dying_window);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
main_window_destroyed (GtkWidget *widget, gpointer user_data)
|
||||
{
|
||||
gtk_main_quit ();
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
GtkWidget *vbox, *button;
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title (GTK_WINDOW (main_window), "Focus Tester");
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||
gtk_box_set_homogeneous (GTK_BOX (vbox), 8);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
|
||||
gtk_container_add (GTK_CONTAINER (main_window), vbox);
|
||||
|
||||
make_focused_label (main_window, vbox);
|
||||
|
||||
/* ICCCM "No Input" mode; Input hint False, WM_TAKE_FOCUS absent */
|
||||
button = gtk_button_new_with_label ("No Input Window");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (noinput_clicked), NULL);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), button);
|
||||
|
||||
/* ICCCM "Passive" mode; Input hint True, WM_TAKE_FOCUS absent */
|
||||
button = gtk_button_new_with_label ("Passive Input Window");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (passive_clicked), NULL);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), button);
|
||||
|
||||
/* ICCCM "Locally Active" mode; Input hint True, WM_TAKE_FOCUS present.
|
||||
* This is the behavior of GtkWindows with accept_focus==TRUE.
|
||||
*/
|
||||
button = gtk_button_new_with_label ("Locally Active Window");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (local_clicked), NULL);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), button);
|
||||
|
||||
/* ICCCM "Globally Active" mode; Input hint False, WM_TAKE_FOCUS present,
|
||||
* and the window responds to WM_TAKE_FOCUS by calling XSetInputFocus.
|
||||
*/
|
||||
button = gtk_button_new_with_label ("Globally Active Window");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (global_clicked), NULL);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), button);
|
||||
|
||||
/* "Lame" Globally Active mode; like "Globally Active", except that
|
||||
* the window does not respond to WM_TAKE_FOCUS. This is the
|
||||
* behavior of GtkWindows with accept_focus==FALSE.
|
||||
*/
|
||||
button = gtk_button_new_with_label ("Globally Lame Window");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (lame_clicked), NULL);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), button);
|
||||
|
||||
/* "Grabby" window; when you activate the window, it asks the wm to
|
||||
* focus the main window, but then forcibly grabs focus back with
|
||||
* a newer timestamp, causing the wm to be temporarily confused
|
||||
* about what window is focused and triggering the "Earlier attempt
|
||||
* to focus ... failed" codepath.
|
||||
*/
|
||||
button = gtk_button_new_with_label ("Grabby Window");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (grabby_clicked), NULL);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), button);
|
||||
|
||||
/* "Dying" window; we create the window on the first click, then
|
||||
* activate it and destroy it on the second click, causing mutter to
|
||||
* do an XSetInputFocus but not receive the corresponding FocusIn.
|
||||
*/
|
||||
button = gtk_button_new_with_label ("Dying Window");
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (dying_clicked), NULL);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), button);
|
||||
|
||||
gtk_widget_show_all (main_window);
|
||||
|
||||
g_signal_connect (main_window, "destroy",
|
||||
G_CALLBACK (main_window_destroyed), NULL);
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,308 +0,0 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static int gravities[10] = {
|
||||
NorthWestGravity,
|
||||
NorthGravity,
|
||||
NorthEastGravity,
|
||||
WestGravity,
|
||||
CenterGravity,
|
||||
EastGravity,
|
||||
SouthWestGravity,
|
||||
SouthGravity,
|
||||
SouthEastGravity,
|
||||
StaticGravity
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int x, y, width, height;
|
||||
} Rectangle;
|
||||
|
||||
static Window windows[10];
|
||||
static int doubled[10] = { 0, };
|
||||
static Rectangle window_rects[10];
|
||||
|
||||
#define WINDOW_WIDTH 100
|
||||
#define WINDOW_HEIGHT 100
|
||||
|
||||
static int x_offset[3] = { 0, - WINDOW_WIDTH/2, -WINDOW_WIDTH };
|
||||
static int y_offset[3] = { 0, - WINDOW_HEIGHT/2, -WINDOW_HEIGHT };
|
||||
static double screen_x_fraction[3] = { 0, 0.5, 1.0 };
|
||||
static double screen_y_fraction[3] = { 0, 0.5, 1.0 };
|
||||
static int screen_width;
|
||||
static int screen_height;
|
||||
|
||||
static const char*
|
||||
window_gravity_to_string (int gravity)
|
||||
{
|
||||
switch (gravity)
|
||||
{
|
||||
case NorthWestGravity:
|
||||
return "NorthWestGravity";
|
||||
case NorthGravity:
|
||||
return "NorthGravity";
|
||||
case NorthEastGravity:
|
||||
return "NorthEastGravity";
|
||||
case WestGravity:
|
||||
return "WestGravity";
|
||||
case CenterGravity:
|
||||
return "CenterGravity";
|
||||
case EastGravity:
|
||||
return "EastGravity";
|
||||
case SouthWestGravity:
|
||||
return "SouthWestGravity";
|
||||
case SouthGravity:
|
||||
return "SouthGravity";
|
||||
case SouthEastGravity:
|
||||
return "SouthEastGravity";
|
||||
case StaticGravity:
|
||||
return "StaticGravity";
|
||||
default:
|
||||
return "NorthWestGravity";
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
calculate_position (int i, int doubled, int *x, int *y)
|
||||
{
|
||||
if (i == 9)
|
||||
{
|
||||
*x = 150;
|
||||
*y = 150;
|
||||
}
|
||||
else
|
||||
{
|
||||
int xoff = x_offset[i % 3];
|
||||
int yoff = y_offset[i / 3];
|
||||
if (doubled)
|
||||
{
|
||||
xoff *= 2;
|
||||
yoff *= 2;
|
||||
}
|
||||
|
||||
*x = screen_x_fraction[i % 3] * screen_width + xoff;
|
||||
*y = screen_y_fraction[i / 3] * screen_height + yoff;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
find_window (Window window)
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<10; i++)
|
||||
{
|
||||
if (windows[i] == window)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
unsigned long flags;
|
||||
unsigned long functions;
|
||||
unsigned long decorations;
|
||||
long input_mode;
|
||||
unsigned long status;
|
||||
} MotifWmHints, MwmHints;
|
||||
|
||||
#define MWM_HINTS_FUNCTIONS (1L << 0)
|
||||
#define MWM_HINTS_DECORATIONS (1L << 1)
|
||||
#define MWM_HINTS_INPUT_MODE (1L << 2)
|
||||
#define MWM_HINTS_STATUS (1L << 3)
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
Display *d;
|
||||
Window w;
|
||||
XSizeHints hints;
|
||||
int i;
|
||||
int screen;
|
||||
XEvent ev;
|
||||
int noframes;
|
||||
|
||||
if (argc > 1 && strcmp (argv[1], "--noframes") == 0)
|
||||
noframes = 1;
|
||||
else
|
||||
noframes = 0;
|
||||
|
||||
d = XOpenDisplay (NULL);
|
||||
|
||||
screen = DefaultScreen (d);
|
||||
screen_width = DisplayWidth (d, screen);
|
||||
screen_height = DisplayHeight (d, screen);
|
||||
|
||||
for (i=0; i<10; i++)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
calculate_position (i, doubled[i], &x, &y);
|
||||
|
||||
w = XCreateSimpleWindow (d, RootWindow (d, screen),
|
||||
x, y, WINDOW_WIDTH, WINDOW_HEIGHT, 0,
|
||||
WhitePixel (d, screen), WhitePixel (d, screen));
|
||||
|
||||
windows[i] = w;
|
||||
window_rects[i].x = x;
|
||||
window_rects[i].y = y;
|
||||
window_rects[i].width = WINDOW_WIDTH;
|
||||
window_rects[i].height = WINDOW_HEIGHT;
|
||||
|
||||
XSelectInput (d, w, ButtonPressMask | ExposureMask | StructureNotifyMask);
|
||||
|
||||
hints.flags = USPosition | PMinSize | PMaxSize | PWinGravity;
|
||||
|
||||
hints.min_width = WINDOW_WIDTH / 2;
|
||||
hints.min_height = WINDOW_HEIGHT / 2;
|
||||
|
||||
#if 1
|
||||
/* we constrain max size below the "doubled" size so that
|
||||
* the WM will have to deal with constraints
|
||||
* at the same time it's dealing with configure request
|
||||
*/
|
||||
hints.max_width = WINDOW_WIDTH * 2 - WINDOW_WIDTH / 2;
|
||||
hints.max_height = WINDOW_HEIGHT * 2 - WINDOW_HEIGHT / 2;
|
||||
#else
|
||||
hints.max_width = WINDOW_WIDTH * 2 + WINDOW_WIDTH / 2;
|
||||
hints.max_height = WINDOW_HEIGHT * 2 + WINDOW_HEIGHT / 2;
|
||||
#endif
|
||||
hints.win_gravity = gravities[i];
|
||||
|
||||
XSetWMNormalHints (d, w, &hints);
|
||||
|
||||
XStoreName (d, w, window_gravity_to_string (hints.win_gravity));
|
||||
|
||||
if (noframes)
|
||||
{
|
||||
MotifWmHints mwm;
|
||||
Atom mwm_atom;
|
||||
|
||||
mwm.decorations = 0;
|
||||
mwm.flags = MWM_HINTS_DECORATIONS;
|
||||
|
||||
mwm_atom = XInternAtom (d, "_MOTIF_WM_HINTS", False);
|
||||
|
||||
XChangeProperty (d, w, mwm_atom, mwm_atom,
|
||||
32, PropModeReplace,
|
||||
(unsigned char *)&mwm,
|
||||
sizeof (MotifWmHints)/sizeof (long));
|
||||
}
|
||||
|
||||
XMapWindow (d, w);
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
XNextEvent (d, &ev);
|
||||
|
||||
if (ev.xany.type == ConfigureNotify)
|
||||
{
|
||||
i = find_window (ev.xconfigure.window);
|
||||
|
||||
if (i >= 0)
|
||||
{
|
||||
Window ignored;
|
||||
|
||||
window_rects[i].width = ev.xconfigure.width;
|
||||
window_rects[i].height = ev.xconfigure.height;
|
||||
|
||||
XClearArea (d, windows[i], 0, 0,
|
||||
ev.xconfigure.width,
|
||||
ev.xconfigure.height,
|
||||
True);
|
||||
|
||||
if (!ev.xconfigure.send_event)
|
||||
XTranslateCoordinates (d, windows[i], DefaultRootWindow (d),
|
||||
0, 0,
|
||||
&window_rects[i].x, &window_rects[i].y,
|
||||
&ignored);
|
||||
else
|
||||
{
|
||||
window_rects[i].x = ev.xconfigure.x;
|
||||
window_rects[i].y = ev.xconfigure.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ev.xany.type == Expose)
|
||||
{
|
||||
i = find_window (ev.xexpose.window);
|
||||
|
||||
if (i >= 0)
|
||||
{
|
||||
GC gc;
|
||||
XGCValues values;
|
||||
char buf[256];
|
||||
|
||||
values.foreground = BlackPixel (d, screen);
|
||||
|
||||
gc = XCreateGC (d, windows[i],
|
||||
GCForeground, &values);
|
||||
|
||||
sprintf (buf,
|
||||
"%d,%d",
|
||||
window_rects[i].x,
|
||||
window_rects[i].y);
|
||||
|
||||
XDrawString (d, windows[i], gc, 10, 15,
|
||||
buf, strlen (buf));
|
||||
|
||||
sprintf (buf,
|
||||
"%dx%d",
|
||||
window_rects[i].width,
|
||||
window_rects[i].height);
|
||||
|
||||
XDrawString (d, windows[i], gc, 10, 35,
|
||||
buf, strlen (buf));
|
||||
|
||||
XFreeGC (d, gc);
|
||||
}
|
||||
}
|
||||
else if (ev.xany.type == ButtonPress)
|
||||
{
|
||||
i = find_window (ev.xbutton.window);
|
||||
|
||||
if (i >= 0)
|
||||
{
|
||||
/* Button 1 = move, 2 = resize, 3 = both at once */
|
||||
|
||||
if (ev.xbutton.button == Button1)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
calculate_position (i, doubled[i], &x, &y);
|
||||
XMoveWindow (d, windows[i], x, y);
|
||||
}
|
||||
else if (ev.xbutton.button == Button2)
|
||||
{
|
||||
if (doubled[i])
|
||||
XResizeWindow (d, windows[i], WINDOW_WIDTH, WINDOW_HEIGHT);
|
||||
else
|
||||
XResizeWindow (d, windows[i], WINDOW_WIDTH*2, WINDOW_HEIGHT*2);
|
||||
|
||||
doubled[i] = !doubled[i];
|
||||
}
|
||||
else if (ev.xbutton.button == Button3)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
calculate_position (i, !doubled[i], &x, &y);
|
||||
|
||||
if (doubled[i])
|
||||
XMoveResizeWindow (d, windows[i], x, y, WINDOW_WIDTH, WINDOW_HEIGHT);
|
||||
else
|
||||
XMoveResizeWindow (d, windows[i], x, y, WINDOW_WIDTH*2, WINDOW_HEIGHT*2);
|
||||
|
||||
doubled[i] = !doubled[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* This program has an infinite loop above so a return statement would
|
||||
* just cause compiler warnings.
|
||||
*/
|
||||
}
|
||||
|
@ -1,257 +0,0 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
|
||||
static void
|
||||
calc_rects (XRectangle *rects, int width, int height)
|
||||
{
|
||||
int w = (width - 21) / 3;
|
||||
int h = (height - 21) / 3;
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (i < 9)
|
||||
{
|
||||
rects[i].width = w;
|
||||
rects[i].height = h;
|
||||
++i;
|
||||
}
|
||||
|
||||
/* NW */
|
||||
rects[0].x = 0;
|
||||
rects[0].y = 0;
|
||||
|
||||
/* N */
|
||||
rects[1].x = width / 2 - w / 2;
|
||||
rects[1].y = 0;
|
||||
|
||||
/* NE */
|
||||
rects[2].x = width - w;
|
||||
rects[2].y = 0;
|
||||
|
||||
/* E */
|
||||
rects[3].x = width - w;
|
||||
rects[3].y = height / 2 - h / 2;
|
||||
|
||||
/* SE */
|
||||
rects[4].x = width - w;
|
||||
rects[4].y = height - h;
|
||||
|
||||
/* S */
|
||||
rects[5].x = width / 2 - w / 2;
|
||||
rects[5].y = height - h;
|
||||
|
||||
/* SW */
|
||||
rects[6].x = 0;
|
||||
rects[6].y = height - h;
|
||||
|
||||
/* W */
|
||||
rects[7].x = 0;
|
||||
rects[7].y = height / 2 - h / 2;
|
||||
|
||||
/* Center */
|
||||
rects[8].x = width / 2 - w / 2;
|
||||
rects[8].y = height / 2 - h / 2;
|
||||
}
|
||||
|
||||
static Bool
|
||||
all_events (Display *display,
|
||||
XEvent *event,
|
||||
XPointer arg)
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
static void
|
||||
get_size (Display *d, Drawable draw,
|
||||
int *xp, int *yp, int *widthp, int *heightp)
|
||||
{
|
||||
int x, y;
|
||||
unsigned int width=0, height=0, border=0, depth=0;
|
||||
Window root;
|
||||
|
||||
XGetGeometry (d, draw, &root, &x, &y, &width, &height, &border, &depth);
|
||||
|
||||
if (xp)
|
||||
*xp = x;
|
||||
if (yp)
|
||||
*yp = y;
|
||||
if (widthp)
|
||||
*widthp = width;
|
||||
if (heightp)
|
||||
*heightp = height;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
Display *d;
|
||||
Window w, cw;
|
||||
XSizeHints hints;
|
||||
int screen;
|
||||
XEvent ev;
|
||||
int x, y, width, height;
|
||||
Pixmap pix;
|
||||
GC gc;
|
||||
XGCValues gc_vals;
|
||||
XSetWindowAttributes set_attrs;
|
||||
XWindowChanges changes;
|
||||
XRectangle rects[9];
|
||||
gboolean redraw_pending;
|
||||
unsigned int mask;
|
||||
|
||||
d = XOpenDisplay (NULL);
|
||||
|
||||
screen = DefaultScreen (d);
|
||||
|
||||
/* Print some debug spew to show how StaticGravity works */
|
||||
w = XCreateSimpleWindow (d, RootWindow (d, screen),
|
||||
0, 0, 100, 100, 0,
|
||||
WhitePixel (d, screen),
|
||||
WhitePixel (d, screen));
|
||||
cw = XCreateSimpleWindow (d, w,
|
||||
0, 0, 100, 100, 0,
|
||||
WhitePixel (d, screen),
|
||||
WhitePixel (d, screen));
|
||||
set_attrs.win_gravity = StaticGravity;
|
||||
|
||||
XChangeWindowAttributes (d, cw,
|
||||
CWWinGravity,
|
||||
&set_attrs);
|
||||
|
||||
get_size (d, w, &x, &y, &width, &height);
|
||||
|
||||
g_print ("Parent is %d,%d %d x %d before configuring parent\n",
|
||||
x, y, width, height);
|
||||
|
||||
get_size (d, cw, &x, &y, &width, &height);
|
||||
|
||||
g_print ("Child is %d,%d %d x %d before configuring parent\n",
|
||||
x, y, width, height);
|
||||
|
||||
changes.x = 10;
|
||||
changes.y = 10;
|
||||
changes.width = 110;
|
||||
changes.height = 110;
|
||||
/* last mask wins */
|
||||
mask = CWX | CWY;
|
||||
mask = CWWidth | CWHeight;
|
||||
mask = CWX | CWY | CWWidth | CWHeight;
|
||||
|
||||
XConfigureWindow (d, w, mask, &changes);
|
||||
XSync (d, False);
|
||||
|
||||
get_size (d, w, &x, &y, &width, &height);
|
||||
|
||||
g_print ("Parent is %d,%d %d x %d after configuring parent\n",
|
||||
x, y, width, height);
|
||||
|
||||
get_size (d, cw, &x, &y, &width, &height);
|
||||
|
||||
g_print ("Child is %d,%d %d x %d after configuring parent\n",
|
||||
x, y, width, height);
|
||||
|
||||
XDestroyWindow (d, w);
|
||||
|
||||
/* The window that gets displayed */
|
||||
|
||||
x = 20;
|
||||
y = 20;
|
||||
width = 100;
|
||||
height = 100;
|
||||
|
||||
calc_rects (rects, width, height);
|
||||
|
||||
w = XCreateSimpleWindow (d, RootWindow (d, screen),
|
||||
x, y, width, height, 0,
|
||||
WhitePixel (d, screen),
|
||||
WhitePixel (d, screen));
|
||||
|
||||
set_attrs.bit_gravity = StaticGravity;
|
||||
|
||||
XChangeWindowAttributes (d, w,
|
||||
CWBitGravity,
|
||||
&set_attrs);
|
||||
|
||||
XSelectInput (d, w,
|
||||
ButtonPressMask | ExposureMask | StructureNotifyMask);
|
||||
|
||||
hints.flags = PMinSize;
|
||||
|
||||
hints.min_width = 100;
|
||||
hints.min_height = 100;
|
||||
|
||||
XSetWMNormalHints (d, w, &hints);
|
||||
XMapWindow (d, w);
|
||||
|
||||
redraw_pending = FALSE;
|
||||
while (1)
|
||||
{
|
||||
XNextEvent (d, &ev);
|
||||
|
||||
switch (ev.xany.type)
|
||||
{
|
||||
case ButtonPress:
|
||||
if (ev.xbutton.button == 3)
|
||||
{
|
||||
g_print ("Exiting on button 3 press\n");
|
||||
exit (0);
|
||||
}
|
||||
break;
|
||||
|
||||
case ConfigureNotify:
|
||||
x = ev.xconfigure.x;
|
||||
y = ev.xconfigure.y;
|
||||
width = ev.xconfigure.width;
|
||||
height = ev.xconfigure.height;
|
||||
|
||||
redraw_pending = TRUE;
|
||||
break;
|
||||
|
||||
case Expose:
|
||||
redraw_pending = TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Primitive event compression */
|
||||
if (XCheckIfEvent (d, &ev, all_events, NULL))
|
||||
{
|
||||
XPutBackEvent (d, &ev);
|
||||
}
|
||||
else if (redraw_pending)
|
||||
{
|
||||
calc_rects (rects, width, height);
|
||||
|
||||
pix = XCreatePixmap (d, w, width, height,
|
||||
DefaultDepth (d, screen));
|
||||
|
||||
gc_vals.foreground = WhitePixel (d, screen);
|
||||
|
||||
gc = XCreateGC (d, pix, GCForeground, &gc_vals);
|
||||
|
||||
XFillRectangle (d, pix, gc, 0, 0, width, height);
|
||||
|
||||
/* Draw rectangles at each gravity point */
|
||||
gc_vals.foreground = BlackPixel (d, screen);
|
||||
XChangeGC (d, gc, GCForeground, &gc_vals);
|
||||
|
||||
XFillRectangles (d, pix, gc, rects, G_N_ELEMENTS (rects));
|
||||
|
||||
XCopyArea (d, pix, w, gc, 0, 0, width, height, 0, 0);
|
||||
|
||||
XFreePixmap (d, pix);
|
||||
XFreeGC (d, gc);
|
||||
|
||||
redraw_pending = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* This program has an infinite loop above so a return statement would
|
||||
* just cause compiler warnings.
|
||||
*/
|
||||
}
|
||||
|
@ -1,136 +0,0 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
|
||||
static Bool
|
||||
all_events (Display *display,
|
||||
XEvent *event,
|
||||
XPointer arg)
|
||||
{
|
||||
return True;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
get_size (Display *d, Drawable draw,
|
||||
int *xp, int *yp, int *widthp, int *heightp)
|
||||
{
|
||||
int x, y;
|
||||
unsigned int width, height, border, depth;
|
||||
Window root;
|
||||
|
||||
XGetGeometry (d, draw, &root, &x, &y, &width, &height, &border, &depth);
|
||||
|
||||
if (xp)
|
||||
*xp = x;
|
||||
if (yp)
|
||||
*yp = y;
|
||||
if (widthp)
|
||||
*widthp = width;
|
||||
if (*heightp)
|
||||
*heightp = height;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
Display *d;
|
||||
Window zero_min_size;
|
||||
XSizeHints hints;
|
||||
int screen;
|
||||
XEvent ev;
|
||||
int x, y, width, height;
|
||||
Pixmap pix;
|
||||
GC gc;
|
||||
XGCValues gc_vals;
|
||||
gboolean redraw_pending;
|
||||
|
||||
d = XOpenDisplay (NULL);
|
||||
|
||||
screen = DefaultScreen (d);
|
||||
|
||||
x = 0;
|
||||
y = 0;
|
||||
width = 100;
|
||||
height = 100;
|
||||
|
||||
zero_min_size = XCreateSimpleWindow (d, RootWindow (d, screen),
|
||||
x, y, width, height, 0,
|
||||
WhitePixel (d, screen),
|
||||
WhitePixel (d, screen));
|
||||
|
||||
XSelectInput (d, zero_min_size,
|
||||
ButtonPressMask | ExposureMask | StructureNotifyMask);
|
||||
|
||||
hints.flags = PMinSize;
|
||||
|
||||
hints.min_width = 0;
|
||||
hints.min_height = 0;
|
||||
|
||||
XSetWMNormalHints (d, zero_min_size, &hints);
|
||||
XMapWindow (d, zero_min_size);
|
||||
|
||||
redraw_pending = FALSE;
|
||||
while (1)
|
||||
{
|
||||
XNextEvent (d, &ev);
|
||||
|
||||
switch (ev.xany.type)
|
||||
{
|
||||
case ButtonPress:
|
||||
if (ev.xbutton.button == 1)
|
||||
{
|
||||
g_print ("Exiting on button 1 press\n");
|
||||
exit (0);
|
||||
}
|
||||
break;
|
||||
|
||||
case ConfigureNotify:
|
||||
x = ev.xconfigure.x;
|
||||
y = ev.xconfigure.y;
|
||||
width = ev.xconfigure.width;
|
||||
height = ev.xconfigure.height;
|
||||
|
||||
redraw_pending = TRUE;
|
||||
break;
|
||||
|
||||
case Expose:
|
||||
redraw_pending = TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Primitive event compression */
|
||||
if (XCheckIfEvent (d, &ev, all_events, NULL))
|
||||
{
|
||||
XPutBackEvent (d, &ev);
|
||||
}
|
||||
else if (redraw_pending)
|
||||
{
|
||||
pix = XCreatePixmap (d, zero_min_size, width, height,
|
||||
DefaultDepth (d, screen));
|
||||
|
||||
gc_vals.foreground = WhitePixel (d, screen);
|
||||
|
||||
gc = XCreateGC (d, pix, GCForeground, &gc_vals);
|
||||
|
||||
XFillRectangle (d, pix, gc, 0, 0, width, height);
|
||||
|
||||
XCopyArea (d, pix, zero_min_size, gc, 0, 0, width, height, 0, 0);
|
||||
|
||||
XFreePixmap (d, pix);
|
||||
XFreeGC (d, gc);
|
||||
|
||||
redraw_pending = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* This program has an infinite loop above so a return statement would
|
||||
* just cause compiler warnings.
|
||||
*/
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user