metacity r3715 - in trunk: . src src/compositor src/core src/include src/ui
- From: iain svn gnome org
- To: svn-commits-list gnome org
- Subject: metacity r3715 - in trunk: . src src/compositor src/core src/include src/ui
- Date: Mon, 19 May 2008 00:00:10 +0000 (UTC)
Author: iain
Date: Mon May 19 00:00:09 2008
New Revision: 3715
URL: http://svn.gnome.org/viewvc/metacity?rev=3715&view=rev
Log:
2008-05-19 Iain Holmes <iain gnome org>
* src/include/frame.h
* src/include/display.h
* src/include/xprops.h
* src/include/compositor.h
* src/include/types.h
* src/include/window.h
* src/include/errors.h
* src/include/screen.h: New basic public API for compositor.
* src/compositor/*: Separate the compositor out into its own
separate
directory and set it up for backends. Initial XRender backend.
* src/core/compositor.[ch]: Remove
* src/core/frame.h
* src/core/screen.h
* src/core/display.h
* src/core/window.h: Rename to -private.h so as not to clash
with the
new files in include
* src/core/delete.c
* src/core/workspace.h
* src/core/stack.[ch]
* src/core/keybindings.[ch]
* src/core/errors.c
* src/core/effects.[ch]
* src/core/core.c
* src/core/group.h
* src/core/edge-resistance.[ch]
* src/core/window-props.[ch]
* src/core/constraints.h
* src/core/bell.[ch]
* src/core/iconcache.h
* src/core/session.[ch]
* src/core/main.c
* src/core/place.h
* src/core/xprops.c
* src/ui/tabpopup.c: Use the new -private headers
* src/core/display.c
* src/core/frame.c
* src/core/window.c
* src/core/screen.c: Add the API functions required by the
compositor
* src/Makefile.am: Relocate the new files
Added:
trunk/src/compositor/
trunk/src/compositor/compositor-private.h
trunk/src/compositor/compositor-xrender.c
trunk/src/compositor/compositor-xrender.h
trunk/src/compositor/compositor.c
trunk/src/core/display-private.h
trunk/src/core/frame-private.h
trunk/src/core/screen-private.h
trunk/src/core/window-private.h
trunk/src/include/compositor.h
trunk/src/include/display.h
trunk/src/include/errors.h
trunk/src/include/frame.h
trunk/src/include/screen.h
trunk/src/include/types.h
trunk/src/include/window.h
trunk/src/include/xprops.h
Removed:
trunk/src/core/compositor.c
trunk/src/core/compositor.h
trunk/src/core/display.h
trunk/src/core/errors.h
trunk/src/core/frame.h
trunk/src/core/screen.h
trunk/src/core/window.h
trunk/src/core/xprops.h
Modified:
trunk/ChangeLog
trunk/src/Makefile.am
trunk/src/core/bell.c
trunk/src/core/bell.h
trunk/src/core/constraints.h
trunk/src/core/core.c
trunk/src/core/delete.c
trunk/src/core/display.c
trunk/src/core/edge-resistance.c
trunk/src/core/edge-resistance.h
trunk/src/core/effects.c
trunk/src/core/effects.h
trunk/src/core/errors.c
trunk/src/core/frame.c
trunk/src/core/group.h
trunk/src/core/iconcache.h
trunk/src/core/keybindings.c
trunk/src/core/keybindings.h
trunk/src/core/main.c
trunk/src/core/place.h
trunk/src/core/screen.c
trunk/src/core/session.c
trunk/src/core/session.h
trunk/src/core/stack.c
trunk/src/core/stack.h
trunk/src/core/window-props.c
trunk/src/core/window-props.h
trunk/src/core/window.c
trunk/src/core/workspace.h
trunk/src/core/xprops.c
trunk/src/ui/tabpopup.c
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Mon May 19 00:00:09 2008
@@ -12,14 +12,17 @@
core/bell.h \
core/boxes.c \
include/boxes.h \
- core/compositor.c \
- core/compositor.h \
+ compositor/compositor.c \
+ compositor/compositor-private.h \
+ compositor/compositor-xrender.c \
+ include/compositor.h \
core/constraints.c \
core/constraints.h \
core/core.c \
core/delete.c \
core/display.c \
- core/display.h \
+ core/display-private.h \
+ include/display.h \
ui/draw-workspace.c \
ui/draw-workspace.h \
core/edge-resistance.c \
@@ -27,11 +30,12 @@
core/effects.c \
core/effects.h \
core/errors.c \
- core/errors.h \
+ include/errors.h \
core/eventqueue.c \
core/eventqueue.h \
core/frame.c \
- core/frame.h \
+ core/frame-private.h \
+ include/frame.h \
ui/gradient.c \
ui/gradient.h \
core/group-private.h \
@@ -51,7 +55,8 @@
core/prefs.c \
include/prefs.h \
core/screen.c \
- core/screen.h \
+ core/screen-private.h \
+ include/screen.h \
core/session.c \
core/session.h \
core/stack.c \
@@ -61,11 +66,12 @@
core/window-props.c \
core/window-props.h \
core/window.c \
- core/window.h \
+ core/window-private.h \
+ include/window.h \
core/workspace.c \
core/workspace.h \
core/xprops.c \
- core/xprops.h \
+ include/xprops.h \
include/common.h \
include/core.h \
include/ui.h \
Added: trunk/src/compositor/compositor-private.h
==============================================================================
--- (empty file)
+++ trunk/src/compositor/compositor-private.h Mon May 19 00:00:09 2008
@@ -0,0 +1,54 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2008 Iain Holmes
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef META_COMPOSITOR_PRIVATE_H
+#define META_COMPOSITOR_PRIVATE_H
+
+#include "compositor.h"
+
+struct _MetaCompositor
+{
+ void (* destroy) (MetaCompositor *compositor);
+
+ void (*manage_screen) (MetaCompositor *compositor,
+ MetaScreen *screen);
+ void (*unmanage_screen) (MetaCompositor *compositor,
+ MetaScreen *screen);
+ void (*add_window) (MetaCompositor *compositor,
+ MetaWindow *window,
+ Window xwindow,
+ XWindowAttributes *attrs);
+ void (*remove_window) (MetaCompositor *compositor,
+ Window xwindow);
+ void (*set_updates) (MetaCompositor *compositor,
+ MetaWindow *window,
+ gboolean update);
+ void (*process_event) (MetaCompositor *compositor,
+ XEvent *event,
+ MetaWindow *window);
+ Pixmap (*get_window_pixmap) (MetaCompositor *compositor,
+ MetaWindow *window);
+ void (*set_active_window) (MetaCompositor *compositor,
+ MetaScreen *screen,
+ MetaWindow *window);
+};
+
+#endif
Added: trunk/src/compositor/compositor-xrender.c
==============================================================================
--- (empty file)
+++ trunk/src/compositor/compositor-xrender.c Mon May 19 00:00:09 2008
@@ -0,0 +1,2979 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2007 Iain Holmes
+ * Based on xcompmgr - (c) 2003 Keith Packard
+ * xfwm4 - (c) 2005-2007 Olivier Fourdan
+ *
+ * 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 500 /* for usleep() */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <unistd.h>
+
+#include <gdk/gdk.h>
+
+#include "display.h"
+#include "screen.h"
+#include "frame.h"
+#include "errors.h"
+#include "window.h"
+#include "compositor-private.h"
+#include "compositor-xrender.h"
+#include "xprops.h"
+#include <X11/Xatom.h>
+#include <X11/extensions/shape.h>
+#include <X11/extensions/Xcomposite.h>
+#include <X11/extensions/Xdamage.h>
+#include <X11/extensions/Xfixes.h>
+#include <X11/extensions/Xrender.h>
+
+#if COMPOSITE_MAJOR > 0 || COMPOSITE_MINOR >= 2
+#define HAVE_NAME_WINDOW_PIXMAP 1
+#endif
+
+#if COMPOSITE_MAJOR > 0 || COMPOSITE_MINOR >= 3
+#define HAVE_COW 1
+#else
+/* Don't have a cow man...HAAHAAHAA */
+#endif
+
+#define USE_IDLE_REPAINT 1
+
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+static inline gboolean
+composite_at_least_version (MetaDisplay *display,
+ int maj, int min)
+{
+ static int major = -1;
+ static int minor = -1;
+
+ if (major == -1)
+ meta_display_get_compositor_version (display, &major, &minor);
+
+ return (major > maj || (major == maj && minor >= min));
+}
+
+#define have_name_window_pixmap(display) \
+ composite_at_least_version (display, 0, 2)
+#define have_cow(display) \
+ composite_at_least_version (display, 0, 3)
+
+#endif
+
+typedef enum _MetaCompWindowType
+{
+ META_COMP_WINDOW_NORMAL,
+ META_COMP_WINDOW_DND,
+ META_COMP_WINDOW_DESKTOP,
+ META_COMP_WINDOW_DOCK
+} MetaCompWindowType;
+
+typedef enum _MetaShadowType
+{
+ META_SHADOW_SMALL,
+ META_SHADOW_MEDIUM,
+ META_SHADOW_LARGE,
+ LAST_SHADOW_TYPE
+} MetaShadowType;
+
+typedef struct _MetaCompositorXRender
+{
+ MetaCompositor compositor;
+
+ MetaDisplay *display;
+
+ Atom atom_x_root_pixmap;
+ Atom atom_x_set_root;
+ Atom atom_net_wm_window_opacity;
+ Atom atom_net_wm_window_type_dnd;
+
+ Atom atom_net_wm_window_type;
+ Atom atom_net_wm_window_type_desktop;
+ Atom atom_net_wm_window_type_dock;
+ Atom atom_net_wm_window_type_menu;
+ Atom atom_net_wm_window_type_dialog;
+ Atom atom_net_wm_window_type_normal;
+ Atom atom_net_wm_window_type_utility;
+ Atom atom_net_wm_window_type_splash;
+ Atom atom_net_wm_window_type_toolbar;
+
+#ifdef USE_IDLE_REPAINT
+ guint repaint_id;
+#endif
+ guint enabled : 1;
+ guint show_redraw : 1;
+ guint debug : 1;
+} MetaCompositorXRender;
+
+typedef struct _conv
+{
+ int size;
+ double *data;
+} conv;
+
+typedef struct _shadow
+{
+ conv *gaussian_map;
+ guchar *shadow_corner;
+ guchar *shadow_top;
+} shadow;
+
+typedef struct _MetaCompScreen
+{
+ MetaScreen *screen;
+ GList *windows;
+ GHashTable *windows_by_xid;
+
+ MetaWindow *focus_window;
+
+ Window output;
+
+ gboolean have_shadows;
+ shadow *shadows[LAST_SHADOW_TYPE];
+
+ Picture root_picture;
+ Picture root_buffer;
+ Picture black_picture;
+ Picture trans_black_picture;
+ Picture root_tile;
+ XserverRegion all_damage;
+
+ guint overlays;
+ gboolean compositor_active;
+ gboolean clip_changed;
+
+ GSList *dock_windows;
+} MetaCompScreen;
+
+typedef struct _MetaCompWindow
+{
+ MetaScreen *screen;
+ MetaWindow *window; /* May be NULL if this window isn't managed by Metacity */
+ Window id;
+ XWindowAttributes attrs;
+
+#ifdef HAVE_NAME_WINDOW_PIXMAP
+ Pixmap back_pixmap;
+
+ /* When the window is shaded back_pixmap will be replaced with the pixmap
+ for the shaded window. This is a copy of the original unshaded window
+ so that we can still see what the window looked like when it is needed
+ for the _get_window_pixmap function */
+ Pixmap shaded_back_pixmap;
+#endif
+
+ int mode;
+
+ gboolean damaged;
+ gboolean shaped;
+
+ MetaCompWindowType type;
+
+ Damage damage;
+ Picture picture;
+ Picture alpha_pict;
+
+ gboolean needs_shadow;
+ MetaShadowType shadow_type;
+ Picture shadow_pict;
+
+ XserverRegion border_size;
+ XserverRegion extents;
+
+ Picture shadow;
+ int shadow_dx;
+ int shadow_dy;
+ int shadow_width;
+ int shadow_height;
+
+ guint opacity;
+
+ XserverRegion border_clip;
+
+ gboolean updates_frozen;
+ gboolean update_pending;
+} MetaCompWindow;
+
+#define OPAQUE 0xffffffff
+
+#define WINDOW_SOLID 0
+#define WINDOW_ARGB 1
+
+#define SHADOW_SMALL_RADIUS 3.0
+#define SHADOW_MEDIUM_RADIUS 6.0
+#define SHADOW_LARGE_RADIUS 12.0
+
+#define SHADOW_SMALL_OFFSET_X (SHADOW_SMALL_RADIUS * -3 / 2)
+#define SHADOW_SMALL_OFFSET_Y (SHADOW_SMALL_RADIUS * -3 / 2)
+#define SHADOW_MEDIUM_OFFSET_X (SHADOW_MEDIUM_RADIUS * -3 / 2)
+#define SHADOW_MEDIUM_OFFSET_Y (SHADOW_MEDIUM_RADIUS * -5 / 4)
+#define SHADOW_LARGE_OFFSET_X -15
+#define SHADOW_LARGE_OFFSET_Y -15
+
+#define SHADOW_OPACITY 0.66
+
+#define TRANS_OPACITY 0.75
+
+#define DISPLAY_COMPOSITOR(display) ((MetaCompositorXRender *) meta_display_get_compositor (display))
+
+/* Gaussian stuff for creating the shadows */
+static double
+gaussian (double r,
+ double x,
+ double y)
+{
+ return ((1 / (sqrt (2 * G_PI * r))) *
+ exp ((- (x * x + y * y)) / (2 * r * r)));
+}
+
+static conv *
+make_gaussian_map (double r)
+{
+ conv *c;
+ int size, centre;
+ int x, y;
+ double t, g;
+
+ size = ((int) ceil ((r * 3)) + 1) & ~1;
+ centre = size / 2;
+ c = g_malloc (sizeof (conv) + size * size * sizeof (double));
+ c->size = size;
+ c->data = (double *) (c + 1);
+ t = 0.0;
+
+ for (y = 0; y < size; y++)
+ {
+ for (x = 0; x < size; x++)
+ {
+ g = gaussian (r, (double) (x - centre), (double) (y - centre));
+ t += g;
+ c->data[y * size + x] = g;
+ }
+ }
+
+ for (y = 0; y < size; y++)
+ {
+ for (x = 0; x < size; x++)
+ {
+ c->data[y * size + x] /= t;
+ }
+ }
+
+ return c;
+}
+
+static void
+dump_xserver_region (const char *location,
+ MetaDisplay *display,
+ XserverRegion region)
+{
+ MetaCompositorXRender *compositor = DISPLAY_COMPOSITOR (display);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ int nrects;
+ XRectangle *rects;
+ XRectangle bounds;
+
+ if (!compositor->debug)
+ return;
+
+ if (region)
+ {
+ rects = XFixesFetchRegionAndBounds (xdisplay, region, &nrects, &bounds);
+ if (nrects > 0)
+ {
+ int i;
+ fprintf (stderr, "%s (XSR): %d rects, bounds: %d,%d (%d,%d)\n",
+ location, nrects, bounds.x, bounds.y, bounds.width, bounds.height);
+ for (i = 1; i < nrects; i++)
+ fprintf (stderr, "\t%d,%d (%d,%d)\n",
+ rects[i].x, rects[i].y, rects[i].width, rects[i].height);
+ }
+ else
+ fprintf (stderr, "%s (XSR): empty\n", location);
+ XFree (rects);
+ }
+ else
+ fprintf (stderr, "%s (XSR): null\n", location);
+}
+
+/*
+* A picture will help
+*
+* -center 0 width width+center
+* -center +-----+-------------------+-----+
+* | | | |
+* | | | |
+* 0 +-----+-------------------+-----+
+* | | | |
+* | | | |
+* | | | |
+* height +-----+-------------------+-----+
+* | | | |
+* height+ | | | |
+* center +-----+-------------------+-----+
+*/
+static guchar
+sum_gaussian (conv *map,
+ double opacity,
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ double *g_data, *g_line;
+ double v;
+ int fx, fy;
+ int fx_start, fx_end;
+ int fy_start, fy_end;
+ int g_size, centre;
+
+ g_line = map->data;
+ g_size = map->size;
+ centre = g_size / 2;
+ fx_start = centre - x;
+ if (fx_start < 0)
+ fx_start = 0;
+
+ fx_end = width + centre - x;
+ if (fx_end > g_size)
+ fx_end = g_size;
+
+ fy_start = centre - y;
+ if (fy_start < 0)
+ fy_start = 0;
+
+ fy_end = height + centre - y;
+ if (fy_end > g_size)
+ fy_end = g_size;
+
+ g_line = g_line + fy_start * g_size + fx_start;
+
+ v = 0.0;
+ for (fy = fy_start; fy < fy_end; fy++)
+ {
+ g_data = g_line;
+ g_line += g_size;
+
+ for (fx = fx_start; fx < fx_end; fx++)
+ v += *g_data++;
+ }
+
+ if (v > 1.0)
+ v = 1.0;
+
+ return ((guchar) (v * opacity * 255.0));
+}
+
+/* precompute shadow corners and sides to save time for large windows */
+static void
+presum_gaussian (shadow *shad)
+{
+ int centre;
+ int opacity, x, y;
+ int msize;
+ conv *map;
+
+ map = shad->gaussian_map;
+ msize = map->size;
+ centre = map->size / 2;
+
+ if (shad->shadow_corner)
+ g_free (shad->shadow_corner);
+ if (shad->shadow_top)
+ g_free (shad->shadow_top);
+
+ shad->shadow_corner = (guchar *)(g_malloc ((msize + 1) * (msize + 1) * 26));
+ shad->shadow_top = (guchar *) (g_malloc ((msize + 1) * 26));
+
+ for (x = 0; x <= msize; x++)
+ {
+
+ shad->shadow_top[25 * (msize + 1) + x] =
+ sum_gaussian (map, 1, x - centre, centre, msize * 2, msize * 2);
+ for (opacity = 0; opacity < 25; opacity++)
+ {
+ shad->shadow_top[opacity * (msize + 1) + x] =
+ shad->shadow_top[25 * (msize + 1) + x] * opacity / 25;
+ }
+
+ for (y = 0; y <= x; y++)
+ {
+ shad->shadow_corner[25 * (msize + 1) * (msize + 1)
+ + y * (msize + 1)
+ + x]
+ = sum_gaussian (map, 1, x - centre, y - centre,
+ msize * 2, msize * 2);
+
+ shad->shadow_corner[25 * (msize + 1) * (msize + 1)
+ + x * (msize + 1) + y] =
+ shad->shadow_corner[25 * (msize + 1) * (msize + 1)
+ + y * (msize + 1) + x];
+
+ for (opacity = 0; opacity < 25; opacity++)
+ {
+ shad->shadow_corner[opacity * (msize + 1) * (msize + 1)
+ + y * (msize + 1) + x]
+ = shad->shadow_corner[opacity * (msize + 1) * (msize + 1)
+ + x * (msize + 1) + y]
+ = shad->shadow_corner[25 * (msize + 1) * (msize + 1)
+ + y * (msize + 1) + x] * opacity / 25;
+ }
+ }
+ }
+}
+
+static void
+generate_shadows (MetaCompScreen *info)
+{
+ double radii[LAST_SHADOW_TYPE] = {SHADOW_SMALL_RADIUS,
+ SHADOW_MEDIUM_RADIUS,
+ SHADOW_LARGE_RADIUS};
+ int i;
+
+ for (i = 0; i < LAST_SHADOW_TYPE; i++) {
+ shadow *shad = g_new0 (shadow, 1);
+
+ shad->gaussian_map = make_gaussian_map (radii[i]);
+ presum_gaussian (shad);
+
+ info->shadows[i] = shad;
+ }
+}
+
+static XImage *
+make_shadow (MetaDisplay *display,
+ MetaScreen *screen,
+ MetaShadowType shadow_type,
+ double opacity,
+ int width,
+ int height)
+{
+ MetaCompScreen *info = meta_screen_get_compositor_data (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ XImage *ximage;
+ guchar *data;
+ shadow *shad = info->shadows[shadow_type];
+ int msize = shad->gaussian_map->size;
+ int ylimit, xlimit;
+ int swidth = width + msize;
+ int sheight = height + msize;
+ int centre = msize / 2;
+ int x, y;
+ guchar d;
+ int x_diff;
+ int opacity_int = (int)(opacity * 25);
+ int screen_number = meta_screen_get_screen_number (screen);
+
+ data = g_malloc (swidth * sheight * sizeof (guchar));
+
+ ximage = XCreateImage (xdisplay, DefaultVisual (xdisplay, screen_number),
+ 8, ZPixmap, 0, (char *) data,
+ swidth, sheight, 8, swidth * sizeof (guchar));
+ if (!ximage)
+ {
+ g_free (data);
+ return NULL;
+ }
+
+ /*
+ * Build the gaussian in sections
+ */
+
+ /*
+ * centre (fill the complete data array
+ */
+ if (msize > 0)
+ d = shad->shadow_top[opacity_int * (msize + 1) + msize];
+ else
+ d = sum_gaussian (shad->gaussian_map, opacity, centre,
+ centre, width, height);
+ memset (data, d, sheight * swidth);
+
+ /*
+ * corners
+ */
+ ylimit = msize;
+ if (ylimit > sheight / 2)
+ ylimit = (sheight + 1) / 2;
+
+ xlimit = msize;
+ if (xlimit > swidth / 2)
+ xlimit = (swidth + 1) / 2;
+
+ for (y = 0; y < ylimit; y++)
+ {
+ for (x = 0; x < xlimit; x++)
+ {
+
+ if (xlimit == msize && ylimit == msize)
+ d = shad->shadow_corner[opacity_int * (msize + 1) * (msize + 1) + y * (msize + 1) + x];
+ else
+ d = sum_gaussian (shad->gaussian_map, opacity, x - centre,
+ y - centre, width, height);
+
+ data[y * swidth + x] = d;
+ data[(sheight - y - 1) * swidth + x] = d;
+ data[(sheight - y - 1) * swidth + (swidth - x - 1)] = d;
+ data[y * swidth + (swidth - x - 1)] = d;
+ }
+ }
+
+ /* top/bottom */
+ x_diff = swidth - (msize * 2);
+ if (x_diff > 0 && ylimit > 0)
+ {
+ for (y = 0; y < ylimit; y++)
+ {
+ if (ylimit == msize)
+ d = shad->shadow_top[opacity_int * (msize + 1) + y];
+ else
+ d = sum_gaussian (shad->gaussian_map, opacity, centre,
+ y - centre, width, height);
+
+ memset (&data[y * swidth + msize], d, x_diff);
+ memset (&data[(sheight - y - 1) * swidth + msize], d, x_diff);
+ }
+ }
+
+ /*
+ * sides
+ */
+ for (x = 0; x < xlimit; x++)
+ {
+ if (xlimit == msize)
+ d = shad->shadow_top[opacity_int * (msize + 1) + x];
+ else
+ d = sum_gaussian (shad->gaussian_map, opacity, x - centre,
+ centre, width, height);
+
+ for (y = msize; y < sheight - msize; y++)
+ {
+ data[y * swidth + x] = d;
+ data[y * swidth + (swidth - x - 1)] = d;
+ }
+ }
+
+ return ximage;
+}
+
+static Picture
+shadow_picture (MetaDisplay *display,
+ MetaScreen *screen,
+ MetaShadowType shadow_type,
+ double opacity,
+ Picture alpha_pict,
+ int width,
+ int height,
+ int *wp,
+ int *hp)
+{
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ XImage *shadow_image;
+ Pixmap shadow_pixmap;
+ Picture shadow_picture;
+ Window xroot = meta_screen_get_xroot (screen);
+ GC gc;
+
+ shadow_image = make_shadow (display, screen, shadow_type,
+ opacity, width, height);
+ if (!shadow_image)
+ return None;
+
+ shadow_pixmap = XCreatePixmap (xdisplay, xroot,
+ shadow_image->width, shadow_image->height, 8);
+ if (!shadow_pixmap)
+ {
+ XDestroyImage (shadow_image);
+ return None;
+ }
+
+ shadow_picture = XRenderCreatePicture (xdisplay, shadow_pixmap,
+ XRenderFindStandardFormat (xdisplay,
+PictStandardA8),
+ 0, 0);
+ if (!shadow_picture)
+ {
+ XDestroyImage (shadow_image);
+ XFreePixmap (xdisplay, shadow_pixmap);
+ return None;
+ }
+
+ gc = XCreateGC (xdisplay, shadow_pixmap, 0, 0);
+ if (!gc)
+ {
+ XDestroyImage (shadow_image);
+ XFreePixmap (xdisplay, shadow_pixmap);
+ XRenderFreePicture (xdisplay, shadow_picture);
+ return None;
+ }
+
+ XPutImage (xdisplay, shadow_pixmap, gc, shadow_image, 0, 0, 0, 0,
+ shadow_image->width, shadow_image->height);
+ *wp = shadow_image->width;
+ *hp = shadow_image->height;
+
+ XFreeGC (xdisplay, gc);
+ XDestroyImage (shadow_image);
+ XFreePixmap (xdisplay, shadow_pixmap);
+
+ return shadow_picture;
+}
+
+static MetaCompWindow *
+find_window_for_screen (MetaScreen *screen,
+ Window xwindow)
+{
+ MetaCompScreen *info = meta_screen_get_compositor_data (screen);
+
+ if (info == NULL)
+ return NULL;
+
+ return g_hash_table_lookup (info->windows_by_xid, (gpointer) xwindow);
+}
+
+static MetaCompWindow *
+find_window_in_display (MetaDisplay *display,
+ Window xwindow)
+{
+ GSList *index;
+
+ for (index = meta_display_get_screens (display); index; index = index->next)
+ {
+ MetaCompWindow *cw = find_window_for_screen (index->data, xwindow);
+
+ if (cw != NULL)
+ return cw;
+ }
+
+ return NULL;
+}
+
+static MetaCompWindow *
+find_window_for_child_window_in_display (MetaDisplay *display,
+ Window xwindow)
+{
+ Window ignored1, *ignored2;
+ Window parent;
+ guint ignored_children;
+
+ XQueryTree (meta_display_get_xdisplay (display), xwindow, &ignored1,
+ &parent, &ignored2, &ignored_children);
+
+ if (parent != None)
+ return find_window_in_display (display, parent);
+
+ return NULL;
+}
+
+static Picture
+solid_picture (MetaDisplay *display,
+ MetaScreen *screen,
+ gboolean argb,
+ double a,
+ double r,
+ double g,
+ double b)
+{
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ Pixmap pixmap;
+ Picture picture;
+ XRenderPictureAttributes pa;
+ XRenderPictFormat *render_format;
+ XRenderColor c;
+ Window xroot = meta_screen_get_xroot (screen);
+
+ render_format = XRenderFindStandardFormat (xdisplay,
+ argb ? PictStandardARGB32 : PictStandardA8);
+
+ pixmap = XCreatePixmap (xdisplay, xroot, 1, 1, argb ? 32 : 8);
+ g_return_val_if_fail (pixmap != None, None);
+
+ pa.repeat = TRUE;
+ picture = XRenderCreatePicture (xdisplay, pixmap, render_format,
+ CPRepeat, &pa);
+ if (picture == None)
+ {
+ XFreePixmap (xdisplay, pixmap);
+ g_warning ("(picture != None) failed");
+ return None;
+ }
+
+ c.alpha = a * 0xffff;
+ c.red = r * 0xffff;
+ c.green = g * 0xffff;
+ c.blue = b * 0xffff;
+
+ XRenderFillRectangle (xdisplay, PictOpSrc, picture, &c, 0, 0, 1, 1);
+ XFreePixmap (xdisplay, pixmap);
+
+ return picture;
+}
+
+static Picture
+root_tile (MetaScreen *screen)
+{
+ MetaDisplay *display = meta_screen_get_display (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ Picture picture;
+ Pixmap pixmap;
+ gboolean fill = FALSE;
+ XRenderPictureAttributes pa;
+ XRenderPictFormat *format;
+ int p;
+ Atom background_atoms[2];
+ Atom pixmap_atom;
+ int screen_number = meta_screen_get_screen_number (screen);
+ Window xroot = meta_screen_get_xroot (screen);
+
+ pixmap = None;
+ background_atoms[0] = DISPLAY_COMPOSITOR (display)->atom_x_root_pixmap;
+ background_atoms[1] = DISPLAY_COMPOSITOR (display)->atom_x_set_root;
+
+ pixmap_atom = XInternAtom (xdisplay, "PIXMAP", False);
+ for (p = 0; p < 2; p++)
+ {
+ Atom actual_type;
+ int actual_format;
+ gulong nitems, bytes_after;
+ guchar *prop;
+
+ if (XGetWindowProperty (xdisplay, xroot,
+ background_atoms[p],
+ 0, 4, FALSE, AnyPropertyType,
+ &actual_type, &actual_format,
+ &nitems, &bytes_after, &prop) == Success)
+ {
+ if (actual_type == pixmap_atom &&
+ actual_format == 32 &&
+ nitems == 1)
+ {
+ memcpy (&pixmap, prop, 4);
+ XFree (prop);
+ fill = FALSE;
+ break;
+ }
+ }
+ }
+
+ if (!pixmap)
+ {
+ pixmap = XCreatePixmap (xdisplay, xroot, 1, 1,
+ DefaultDepth (xdisplay, screen_number));
+ g_return_val_if_fail (pixmap != None, None);
+ fill = TRUE;
+ }
+
+ pa.repeat = TRUE;
+ format = XRenderFindVisualFormat (xdisplay, DefaultVisual (xdisplay,
+ screen_number));
+ g_return_val_if_fail (format != NULL, None);
+
+ picture = XRenderCreatePicture (xdisplay, pixmap, format, CPRepeat, &pa);
+ if ((picture != None) && (fill))
+ {
+ XRenderColor c;
+
+ /* Background default to just plain ugly grey */
+ c.red = 0x8080;
+ c.green = 0x8080;
+ c.blue = 0x8080;
+ c.alpha = 0xffff;
+
+ XRenderFillRectangle (xdisplay, PictOpSrc, picture, &c, 0, 0, 1, 1);
+ XFreePixmap (xdisplay, pixmap);
+ }
+
+ return picture;
+}
+
+static Picture
+create_root_buffer (MetaScreen *screen)
+{
+ MetaDisplay *display = meta_screen_get_display (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ MetaCompScreen *info = meta_screen_get_compositor_data (screen);
+ Picture pict;
+ XRenderPictFormat *format;
+ Pixmap root_pixmap;
+ Visual *visual;
+ int depth, screen_width, screen_height, screen_number;
+
+ meta_screen_get_size (screen, &screen_width, &screen_height);
+ screen_number = meta_screen_get_screen_number (screen);
+ visual = DefaultVisual (xdisplay, screen_number);
+ depth = DefaultDepth (xdisplay, screen_number);
+
+ format = XRenderFindVisualFormat (xdisplay, visual);
+ g_return_val_if_fail (format != NULL, None);
+
+ root_pixmap = XCreatePixmap (xdisplay, info->output,
+ screen_width, screen_height, depth);
+ g_return_val_if_fail (root_pixmap != None, None);
+
+ pict = XRenderCreatePicture (xdisplay, root_pixmap, format, 0, NULL);
+ XFreePixmap (xdisplay, root_pixmap);
+
+ return pict;
+}
+
+static void
+paint_root (MetaScreen *screen,
+ Picture root_buffer)
+{
+ MetaDisplay *display = meta_screen_get_display (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ MetaCompScreen *info = meta_screen_get_compositor_data (screen);
+ int width, height;
+
+ g_return_if_fail (root_buffer != None);
+
+ if (info->root_tile == None)
+ {
+ info->root_tile = root_tile (screen);
+ g_return_if_fail (info->root_tile != None);
+ }
+
+ meta_screen_get_size (screen, &width, &height);
+ XRenderComposite (xdisplay, PictOpSrc, info->root_tile, None, root_buffer,
+ 0, 0, 0, 0, 0, 0, width, height);
+}
+
+static gboolean
+window_has_shadow (MetaCompWindow *cw)
+{
+ MetaCompScreen *info = meta_screen_get_compositor_data (cw->screen);
+
+ if (info->have_shadows == FALSE)
+ return FALSE;
+
+ /* Always put a shadow around windows with a frame - This should override
+ the restriction about not putting a shadow around shaped windows
+ as the frame might be the reason the window is shaped */
+ if (cw->window)
+ {
+ if (meta_window_get_frame (cw->window)) {
+ meta_verbose ("Window has shadow because it has a frame\n");
+ return TRUE;
+ }
+ }
+
+ /* Never put a shadow around shaped windows */
+ if (cw->shaped) {
+ meta_verbose ("Window has no shadow as it is shaped\n");
+ return FALSE;
+ }
+
+ /* Don't put shadow around DND icon windows */
+ if (cw->type == META_COMP_WINDOW_DND ||
+ cw->type == META_COMP_WINDOW_DESKTOP) {
+ meta_verbose ("Window has no shadow as it is DND or Desktop\n");
+ return FALSE;
+ }
+
+ if (cw->mode != WINDOW_ARGB) {
+ meta_verbose ("Window has shadow as it is not ARGB\n");
+ return TRUE;
+ }
+
+ meta_verbose ("Window has no shadow as it fell through\n");
+ return FALSE;
+}
+
+double shadow_offsets_x[LAST_SHADOW_TYPE] = {SHADOW_SMALL_OFFSET_X,
+ SHADOW_MEDIUM_OFFSET_X,
+ SHADOW_LARGE_OFFSET_X};
+double shadow_offsets_y[LAST_SHADOW_TYPE] = {SHADOW_SMALL_OFFSET_Y,
+ SHADOW_MEDIUM_OFFSET_Y,
+ SHADOW_LARGE_OFFSET_Y};
+static XserverRegion
+win_extents (MetaCompWindow *cw)
+{
+ MetaScreen *screen = cw->screen;
+ MetaDisplay *display = meta_screen_get_display (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ XRectangle r;
+
+ r.x = cw->attrs.x;
+ r.y = cw->attrs.y;
+ r.width = cw->attrs.width + cw->attrs.border_width * 2;
+ r.height = cw->attrs.height + cw->attrs.border_width * 2;
+
+ if (cw->needs_shadow)
+ {
+ XRectangle sr;
+
+ cw->shadow_dx = shadow_offsets_x [cw->shadow_type];
+ cw->shadow_dy = shadow_offsets_y [cw->shadow_type];
+
+ if (!cw->shadow)
+ {
+ double opacity = SHADOW_OPACITY;
+ if (cw->opacity != (guint) OPAQUE)
+ opacity = opacity * ((double) cw->opacity) / ((double) OPAQUE);
+
+ cw->shadow = shadow_picture (display, screen, cw->shadow_type,
+ opacity, cw->alpha_pict,
+ cw->attrs.width + cw->attrs.border_width * 2,
+ cw->attrs.height + cw->attrs.border_width * 2,
+ &cw->shadow_width, &cw->shadow_height);
+ }
+
+ sr.x = cw->attrs.x + cw->shadow_dx;
+ sr.y = cw->attrs.y + cw->shadow_dy;
+ sr.width = cw->shadow_width;
+ sr.height = cw->shadow_height;
+
+ if (sr.x < r.x)
+ {
+ r.width = (r.x + r.width) - sr.x;
+ r.x = sr.x;
+ }
+
+ if (sr.y < r.y)
+ {
+ r.height = (r.y + r.height) - sr.y;
+ r.y = sr.y;
+ }
+
+ if (sr.x + sr.width > r.x + r.width)
+ r.width = sr.x + sr.width - r.x;
+
+ if (sr.y + sr.height > r.y + r.height)
+ r.height = sr.y + sr.height - r.y;
+ }
+
+ return XFixesCreateRegion (xdisplay, &r, 1);
+}
+
+static XserverRegion
+border_size (MetaCompWindow *cw)
+{
+ MetaScreen *screen = cw->screen;
+ MetaDisplay *display = meta_screen_get_display (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ XserverRegion border;
+
+ meta_error_trap_push (display);
+ border = XFixesCreateRegionFromWindow (xdisplay, cw->id,
+ WindowRegionBounding);
+ meta_error_trap_pop (display, FALSE);
+
+ g_return_val_if_fail (border != None, None);
+ XFixesTranslateRegion (xdisplay, border,
+ cw->attrs.x + cw->attrs.border_width,
+ cw->attrs.y + cw->attrs.border_width);
+ return border;
+}
+
+static XRenderPictFormat *
+get_window_format (MetaCompWindow *cw)
+{
+ MetaScreen *screen = cw->screen;
+ MetaDisplay *display = meta_screen_get_display (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ XRenderPictFormat *format;
+ int screen_number = meta_screen_get_screen_number (screen);
+
+ format = XRenderFindVisualFormat (xdisplay, cw->attrs.visual);
+ if (!format)
+ format = XRenderFindVisualFormat (xdisplay,
+ DefaultVisual (xdisplay, screen_number));
+ return format;
+}
+
+static Picture
+get_window_picture (MetaCompWindow *cw)
+{
+ MetaScreen *screen = cw->screen;
+ MetaDisplay *display = meta_screen_get_display (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ XRenderPictureAttributes pa;
+ XRenderPictFormat *format;
+ Drawable draw;
+
+ draw = cw->id;
+
+ meta_error_trap_push (display);
+
+#ifdef HAVE_NAME_WINDOW_PIXMAP
+ if (have_name_window_pixmap (display))
+ {
+ if (cw->back_pixmap == None)
+ cw->back_pixmap = XCompositeNameWindowPixmap (xdisplay, cw->id);
+
+ if (cw->back_pixmap != None)
+ draw = cw->back_pixmap;
+ }
+#endif
+
+ format = get_window_format (cw);
+ if (format)
+ {
+ Picture pict;
+
+ pa.subwindow_mode = IncludeInferiors;
+
+ pict = XRenderCreatePicture (xdisplay, draw, format, CPSubwindowMode, &pa);
+ meta_error_trap_pop (display, FALSE);
+
+ return pict;
+ }
+
+ meta_error_trap_pop (display, FALSE);
+ return None;
+}
+
+static void
+paint_dock_shadows (MetaScreen *screen,
+ Picture root_buffer,
+ XserverRegion region)
+{
+ MetaDisplay *display = meta_screen_get_display (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ MetaCompScreen *info = meta_screen_get_compositor_data (screen);
+ GSList *d;
+
+ for (d = info->dock_windows; d; d = d->next)
+ {
+ MetaCompWindow *cw = d->data;
+ XserverRegion shadow_clip;
+
+ if (cw->shadow)
+ {
+ shadow_clip = XFixesCreateRegion (xdisplay, NULL, 0);
+ XFixesIntersectRegion (xdisplay, shadow_clip,
+ cw->border_clip, region);
+
+ XFixesSetPictureClipRegion (xdisplay, root_buffer, 0, 0, shadow_clip);
+
+ XRenderComposite (xdisplay, PictOpOver, info->black_picture,
+ cw->shadow, root_buffer,
+ 0, 0, 0, 0,
+ cw->attrs.x + cw->shadow_dx,
+ cw->attrs.y + cw->shadow_dy,
+ cw->shadow_width, cw->shadow_height);
+ XFixesDestroyRegion (xdisplay, shadow_clip);
+ }
+ }
+}
+
+static void
+paint_windows (MetaScreen *screen,
+ GList *windows,
+ Picture root_buffer,
+ XserverRegion region)
+{
+ MetaDisplay *display = meta_screen_get_display (screen);
+ MetaCompScreen *info = meta_screen_get_compositor_data (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ GList *index, *last;
+ int screen_width, screen_height, screen_number;
+ Window xroot;
+ MetaCompWindow *cw;
+ XserverRegion paint_region, desktop_region;
+
+ meta_screen_get_size (screen, &screen_width, &screen_height);
+ screen_number = meta_screen_get_screen_number (screen);
+ xroot = meta_screen_get_xroot (screen);
+
+ if (region == None)
+ {
+ XRectangle r;
+ r.x = 0;
+ r.y = 0;
+ r.width = screen_width;
+ r.height = screen_height;
+ paint_region = XFixesCreateRegion (xdisplay, &r, 1);
+ }
+ else
+ {
+ paint_region = XFixesCreateRegion (xdisplay, NULL, 0);
+ XFixesCopyRegion (xdisplay, paint_region, region);
+ }
+
+ desktop_region = None;
+
+ /*
+ * Painting from top to bottom, reducing the clipping area at
+ * each iteration. Only the opaque windows are painted 1st.
+ */
+ last = NULL;
+ for (index = windows; index; index = index->next)
+ {
+ /* Store the last window we dealt with */
+ last = index;
+
+ cw = (MetaCompWindow *) index->data;
+ if (!cw->damaged)
+ {
+ /* Not damaged */
+ continue;
+ }
+
+#if 0
+ if ((cw->attrs.x + cw->attrs.width < 1) ||
+ (cw->attrs.y + cw->attrs.height < 1) ||
+ (cw->attrs.x >= screen_width) || (cw->attrs.y >= screen_height))
+ {
+ /* Off screen */
+ continue;
+ }
+#endif
+
+ if (cw->picture == None)
+ cw->picture = get_window_picture (cw);
+
+ /* If the clip region of the screen has been changed
+ then we need to recreate the extents of the window */
+ if (info->clip_changed)
+ {
+ if (cw->border_size)
+ {
+ XFixesDestroyRegion (xdisplay, cw->border_size);
+ cw->border_size = None;
+ }
+
+#if 0
+ if (cw->extents)
+ {
+ XFixesDestroyRegion (xdisplay, cw->extents);
+ cw->extents = None;
+ }
+#endif
+ }
+
+ if (cw->border_size == None)
+ cw->border_size = border_size (cw);
+
+ if (cw->extents == None)
+ cw->extents = win_extents (cw);
+
+ if (cw->mode == WINDOW_SOLID)
+ {
+ int x, y, wid, hei;
+
+#ifdef HAVE_NAME_WINDOW_PIXMAP
+ if (have_name_window_pixmap (display))
+ {
+ x = cw->attrs.x;
+ y = cw->attrs.y;
+ wid = cw->attrs.width + cw->attrs.border_width * 2;
+ hei = cw->attrs.height + cw->attrs.border_width * 2;
+ }
+ else
+#endif
+ {
+ x = cw->attrs.x + cw->attrs.border_width;
+ y = cw->attrs.y + cw->attrs.border_width;
+ wid = cw->attrs.width;
+ hei = cw->attrs.height;
+ }
+
+ XFixesSetPictureClipRegion (xdisplay, root_buffer,
+ 0, 0, paint_region);
+ XRenderComposite (xdisplay, PictOpSrc, cw->picture,
+ None, root_buffer, 0, 0, 0, 0,
+ x, y, wid, hei);
+
+ if (cw->type == META_COMP_WINDOW_DESKTOP)
+ {
+ desktop_region = XFixesCreateRegion (xdisplay, 0, 0);
+ XFixesCopyRegion (xdisplay, desktop_region, paint_region);
+ }
+
+ XFixesSubtractRegion (xdisplay, paint_region,
+ paint_region, cw->border_size);
+ }
+
+ if (!cw->border_clip)
+ {
+ cw->border_clip = XFixesCreateRegion (xdisplay, 0, 0);
+ XFixesCopyRegion (xdisplay, cw->border_clip, paint_region);
+ }
+ }
+
+ XFixesSetPictureClipRegion (xdisplay, root_buffer, 0, 0, paint_region);
+ paint_root (screen, root_buffer);
+
+ paint_dock_shadows (screen, root_buffer, desktop_region == None ?
+ paint_region : desktop_region);
+ if (desktop_region != None)
+ XFixesDestroyRegion (xdisplay, desktop_region);
+
+ /*
+ * Painting from bottom to top, translucent windows and shadows are painted
+ */
+ for (index = last; index; index = index->prev)
+ {
+ cw = (MetaCompWindow *) index->data;
+
+ if (cw->picture)
+ {
+ if (cw->shadow && cw->type != META_COMP_WINDOW_DOCK)
+ {
+ XserverRegion shadow_clip;
+
+ shadow_clip = XFixesCreateRegion (xdisplay, NULL, 0);
+ XFixesSubtractRegion (xdisplay, shadow_clip, cw->border_clip,
+ cw->border_size);
+ XFixesSetPictureClipRegion (xdisplay, root_buffer, 0, 0,
+ shadow_clip);
+
+ XRenderComposite (xdisplay, PictOpOver, info->black_picture,
+ cw->shadow, root_buffer,
+ 0, 0, 0, 0,
+ cw->attrs.x + cw->shadow_dx,
+ cw->attrs.y + cw->shadow_dy,
+ cw->shadow_width, cw->shadow_height);
+ if (shadow_clip)
+ XFixesDestroyRegion (xdisplay, shadow_clip);
+ }
+
+ if ((cw->opacity != (guint) OPAQUE) && !(cw->alpha_pict))
+ {
+ cw->alpha_pict = solid_picture (display, screen, FALSE,
+ (double) cw->opacity / OPAQUE,
+ 0, 0, 0);
+ }
+
+ XFixesIntersectRegion (xdisplay, cw->border_clip, cw->border_clip,
+ cw->border_size);
+ XFixesSetPictureClipRegion (xdisplay, root_buffer, 0, 0,
+ cw->border_clip);
+ if (cw->mode == WINDOW_ARGB)
+ {
+ int x, y, wid, hei;
+#ifdef HAVE_NAME_WINDOW_PIXMAP
+ if (have_name_window_pixmap (display))
+ {
+ x = cw->attrs.x;
+ y = cw->attrs.y;
+ wid = cw->attrs.width + cw->attrs.border_width * 2;
+ hei = cw->attrs.height + cw->attrs.border_width * 2;
+ }
+ else
+#endif
+ {
+ x = cw->attrs.x + cw->attrs.border_width;
+ y = cw->attrs.y + cw->attrs.border_width;
+ wid = cw->attrs.width;
+ hei = cw->attrs.height;
+ }
+
+ XRenderComposite (xdisplay, PictOpOver, cw->picture,
+ cw->alpha_pict, root_buffer, 0, 0, 0, 0,
+ x, y, wid, hei);
+ }
+ }
+
+ if (cw->border_clip)
+ {
+ XFixesDestroyRegion (xdisplay, cw->border_clip);
+ cw->border_clip = None;
+ }
+ }
+
+ XFixesDestroyRegion (xdisplay, paint_region);
+}
+
+static void
+paint_all (MetaScreen *screen,
+ XserverRegion region)
+{
+ MetaCompScreen *info = meta_screen_get_compositor_data (screen);
+ MetaDisplay *display = meta_screen_get_display (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ int screen_width, screen_height;
+
+ /* Set clipping to the given region */
+ XFixesSetPictureClipRegion (xdisplay, info->root_picture, 0, 0, region);
+
+ meta_screen_get_size (screen, &screen_width, &screen_height);
+
+ if (DISPLAY_COMPOSITOR (display)->show_redraw)
+ {
+ Picture overlay;
+
+ dump_xserver_region ("paint_all", display, region);
+
+ /* Make a random colour overlay */
+ overlay = solid_picture (display, screen, TRUE, 1, /* 0.3, alpha */
+ ((double) (rand () % 100)) / 100.0,
+ ((double) (rand () % 100)) / 100.0,
+ ((double) (rand () % 100)) / 100.0);
+
+ XRenderComposite (xdisplay, PictOpOver, overlay, None, info->root_picture,
+ 0, 0, 0, 0, 0, 0, screen_width, screen_height);
+ XRenderFreePicture (xdisplay, overlay);
+ XFlush (xdisplay);
+ usleep (100 * 1000);
+ }
+
+ if (info->root_buffer == None)
+ info->root_buffer = create_root_buffer (screen);
+
+ paint_windows (screen, info->windows, info->root_buffer, region);
+
+ XFixesSetPictureClipRegion (xdisplay, info->root_buffer, 0, 0, region);
+ XRenderComposite (xdisplay, PictOpSrc, info->root_buffer, None,
+ info->root_picture, 0, 0, 0, 0, 0, 0,
+ screen_width, screen_height);
+}
+
+static void
+repair_screen (MetaScreen *screen)
+{
+ MetaCompScreen *info = meta_screen_get_compositor_data (screen);
+ MetaDisplay *display = meta_screen_get_display (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+
+ if (info->all_damage != None)
+ {
+ meta_error_trap_push (display);
+ paint_all (screen, info->all_damage);
+ XFixesDestroyRegion (xdisplay, info->all_damage);
+ info->all_damage = None;
+ info->clip_changed = FALSE;
+ meta_error_trap_pop (display, FALSE);
+ }
+}
+
+static void
+repair_display (MetaDisplay *display)
+{
+ GSList *screens = meta_display_get_screens (display);
+ MetaCompositorXRender *compositor = DISPLAY_COMPOSITOR (display);
+
+#ifdef USE_IDLE_REPAINT
+ if (compositor->repaint_id > 0)
+ {
+ g_source_remove (compositor->repaint_id);
+ compositor->repaint_id = 0;
+ }
+#endif
+
+ for (; screens; screens = screens->next)
+ repair_screen ((MetaScreen *) screens->data);
+}
+
+#ifdef USE_IDLE_REPAINT
+static gboolean
+compositor_idle_cb (gpointer data)
+{
+ MetaCompositorXRender *compositor = (MetaCompositorXRender *) data;
+
+ compositor->repaint_id = 0;
+ repair_display (compositor->display);
+
+ return FALSE;
+}
+
+static void
+add_repair (MetaDisplay *display)
+{
+ MetaCompositorXRender *compositor = DISPLAY_COMPOSITOR (display);
+
+ if (compositor->repaint_id > 0)
+ return;
+
+#if 1
+ compositor->repaint_id = g_idle_add_full (G_PRIORITY_HIGH_IDLE,
+ compositor_idle_cb, compositor,
+ NULL);
+#else
+ /* Limit it to 50fps */
+ compositor->repaint_id = g_timeout_add_full (G_PRIORITY_HIGH, 20,
+ compositor_idle_cb, compositor,
+ NULL);
+#endif
+}
+#endif
+
+static void
+add_damage (MetaScreen *screen,
+ XserverRegion damage)
+{
+ MetaDisplay *display = meta_screen_get_display (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ MetaCompScreen *info = meta_screen_get_compositor_data (screen);
+
+ /* dump_xserver_region ("add_damage", display, damage); */
+
+ if (info->all_damage)
+ {
+ XFixesUnionRegion (xdisplay, info->all_damage, info->all_damage, damage);
+ XFixesDestroyRegion (xdisplay, damage);
+ }
+ else
+ info->all_damage = damage;
+
+#ifdef USE_IDLE_REPAINT
+ add_repair (display);
+#endif
+}
+
+static void
+damage_screen (MetaScreen *screen)
+{
+ MetaDisplay *display = meta_screen_get_display (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ XserverRegion region;
+ int width, height;
+ XRectangle r;
+
+ r.x = 0;
+ r.y = 0;
+ meta_screen_get_size (screen, &width, &height);
+ r.width = width;
+ r.height = height;
+
+ region = XFixesCreateRegion (xdisplay, &r, 1);
+ dump_xserver_region ("damage_screen", display, region);
+ add_damage (screen, region);
+}
+
+static void
+repair_win (MetaCompWindow *cw)
+{
+ MetaScreen *screen = cw->screen;
+ MetaDisplay *display = meta_screen_get_display (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ XserverRegion parts;
+
+ meta_error_trap_push (display);
+ if (!cw->damaged)
+ {
+ parts = win_extents (cw);
+ XDamageSubtract (xdisplay, cw->damage, None, None);
+ }
+ else
+ {
+ parts = XFixesCreateRegion (xdisplay, 0, 0);
+ XDamageSubtract (xdisplay, cw->damage, None, parts);
+ XFixesTranslateRegion (xdisplay, parts,
+ cw->attrs.x + cw->attrs.border_width,
+ cw->attrs.y + cw->attrs.border_width);
+ }
+
+ meta_error_trap_pop (display, FALSE);
+
+ dump_xserver_region ("repair_win", display, parts);
+ add_damage (screen, parts);
+ cw->damaged = TRUE;
+}
+
+static void
+free_win (MetaCompWindow *cw,
+ gboolean destroy)
+{
+ MetaDisplay *display = meta_screen_get_display (cw->screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ MetaCompScreen *info = meta_screen_get_compositor_data (cw->screen);
+
+#ifdef HAVE_NAME_WINDOW_PIXMAP
+ if (have_name_window_pixmap (display))
+ {
+ /* See comment in map_win */
+ if (cw->back_pixmap && destroy)
+ {
+ XFreePixmap (xdisplay, cw->back_pixmap);
+ cw->back_pixmap = None;
+ }
+
+ if (cw->shaded_back_pixmap && destroy)
+ {
+ XFreePixmap (xdisplay, cw->shaded_back_pixmap);
+ cw->shaded_back_pixmap = None;
+ }
+ }
+#endif
+
+ if (cw->picture)
+ {
+ XRenderFreePicture (xdisplay, cw->picture);
+ cw->picture = None;
+ }
+
+ if (cw->shadow)
+ {
+ XRenderFreePicture (xdisplay, cw->shadow);
+ cw->shadow = None;
+ }
+
+ if (cw->alpha_pict)
+ {
+ XRenderFreePicture (xdisplay, cw->alpha_pict);
+ cw->alpha_pict = None;
+ }
+
+ if (cw->shadow_pict)
+ {
+ XRenderFreePicture (xdisplay, cw->shadow_pict);
+ cw->shadow_pict = None;
+ }
+
+ if (cw->border_size)
+ {
+ XFixesDestroyRegion (xdisplay, cw->border_size);
+ cw->border_size = None;
+ }
+
+ if (cw->border_clip)
+ {
+ XFixesDestroyRegion (xdisplay, cw->border_clip);
+ cw->border_clip = None;
+ }
+
+ if (cw->extents)
+ {
+ XFixesDestroyRegion (xdisplay, cw->extents);
+ cw->extents = None;
+ }
+
+ if (destroy)
+ {
+ if (cw->damage != None) {
+ meta_error_trap_push (display);
+ XDamageDestroy (xdisplay, cw->damage);
+ meta_error_trap_pop (display, FALSE);
+
+ cw->damage = None;
+ }
+
+ /* The window may not have been added to the list in this case,
+ but we can check anyway */
+ if (cw->type == META_COMP_WINDOW_DOCK)
+ info->dock_windows = g_slist_remove (info->dock_windows, cw);
+
+ g_free (cw);
+ }
+}
+
+static void
+map_win (MetaDisplay *display,
+ MetaScreen *screen,
+ Window id)
+{
+ MetaCompWindow *cw = find_window_for_screen (screen, id);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+
+ if (cw == NULL)
+ return;
+
+#ifdef HAVE_NAME_WINDOW_PIXMAP
+ /* The reason we deallocate this here and not in unmap
+ is so that we will still have a valid pixmap for
+ whenever the window is unmapped */
+ if (cw->back_pixmap)
+ {
+ XFreePixmap (xdisplay, cw->back_pixmap);
+ cw->back_pixmap = None;
+ }
+
+ if (cw->shaded_back_pixmap)
+ {
+ XFreePixmap (xdisplay, cw->shaded_back_pixmap);
+ cw->shaded_back_pixmap = None;
+ }
+#endif
+
+ cw->attrs.map_state = IsViewable;
+ cw->damaged = FALSE;
+}
+
+static void
+unmap_win (MetaDisplay *display,
+ MetaScreen *screen,
+ Window id)
+{
+ MetaCompWindow *cw = find_window_for_screen (screen, id);
+ MetaCompScreen *info = meta_screen_get_compositor_data (screen);
+
+ if (cw == NULL)
+ {
+ return;
+ }
+
+ if (cw->window && cw->window == info->focus_window)
+ info->focus_window = NULL;
+
+ cw->attrs.map_state = IsUnmapped;
+ cw->damaged = FALSE;
+
+ if (cw->extents != None)
+ {
+ dump_xserver_region ("unmap_win", display, cw->extents);
+ add_damage (screen, cw->extents);
+ cw->extents = None;
+ }
+
+ free_win (cw, FALSE);
+ info->clip_changed = TRUE;
+}
+
+static void
+determine_mode (MetaDisplay *display,
+ MetaScreen *screen,
+ MetaCompWindow *cw)
+{
+ XRenderPictFormat *format;
+ Display *xdisplay = meta_display_get_xdisplay (display);
+
+ if (cw->alpha_pict)
+ {
+ XRenderFreePicture (xdisplay, cw->alpha_pict);
+ cw->alpha_pict = None;
+ }
+
+ if (cw->shadow_pict)
+ {
+ XRenderFreePicture (xdisplay, cw->shadow_pict);
+ cw->shadow_pict = None;
+ }
+
+ if (cw->attrs.class == InputOnly)
+ format = NULL;
+ else
+ format = XRenderFindVisualFormat (xdisplay, cw->attrs.visual);
+
+ if ((format && format->type == PictTypeDirect && format->direct.alphaMask)
+ || cw->opacity != (guint) OPAQUE)
+ cw->mode = WINDOW_ARGB;
+ else
+ cw->mode = WINDOW_SOLID;
+
+ if (cw->extents)
+ {
+ XserverRegion damage;
+ damage = XFixesCreateRegion (xdisplay, NULL, 0);
+ XFixesCopyRegion (xdisplay, damage, cw->extents);
+
+ dump_xserver_region ("determine_mode", display, damage);
+ add_damage (screen, damage);
+ }
+}
+
+static gboolean
+is_shaped (MetaDisplay *display,
+ Window xwindow)
+{
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ int xws, yws, xbs, ybs;
+ unsigned wws, hws, wbs, hbs;
+ int bounding_shaped, clip_shaped;
+
+ if (meta_display_has_shape (display))
+ {
+ XShapeQueryExtents (xdisplay, xwindow, &bounding_shaped,
+ &xws, &yws, &wws, &hws, &clip_shaped,
+ &xbs, &ybs, &wbs, &hbs);
+ return (bounding_shaped != 0);
+ }
+
+ return FALSE;
+}
+
+static void
+get_window_type (MetaDisplay *display,
+ MetaCompWindow *cw)
+{
+ MetaCompositorXRender *compositor = DISPLAY_COMPOSITOR (display);
+ int n_atoms;
+ Atom *atoms, type_atom;
+ int i;
+
+ type_atom = None;
+ n_atoms = 0;
+ atoms = NULL;
+
+ meta_prop_get_atom_list (display, cw->id,
+ compositor->atom_net_wm_window_type,
+ &atoms, &n_atoms);
+
+ for (i = 0; i < n_atoms; i++)
+ {
+ if (atoms[i] == compositor->atom_net_wm_window_type_dnd ||
+ atoms[i] == compositor->atom_net_wm_window_type_desktop ||
+ atoms[i] == compositor->atom_net_wm_window_type_dock ||
+ atoms[i] == compositor->atom_net_wm_window_type_toolbar ||
+ atoms[i] == compositor->atom_net_wm_window_type_menu ||
+ atoms[i] == compositor->atom_net_wm_window_type_dialog ||
+ atoms[i] == compositor->atom_net_wm_window_type_normal ||
+ atoms[i] == compositor->atom_net_wm_window_type_utility ||
+ atoms[i] == compositor->atom_net_wm_window_type_splash)
+ {
+ type_atom = atoms[i];
+ break;
+ }
+ }
+
+ meta_XFree (atoms);
+
+ if (type_atom == compositor->atom_net_wm_window_type_dnd)
+ cw->type = META_COMP_WINDOW_DND;
+ else if (type_atom == compositor->atom_net_wm_window_type_desktop)
+ cw->type = META_COMP_WINDOW_DESKTOP;
+ else if (type_atom == compositor->atom_net_wm_window_type_dock)
+ cw->type = META_COMP_WINDOW_DOCK;
+ else
+ cw->type = META_COMP_WINDOW_NORMAL;
+
+/* meta_verbose ("Window is %d\n", cw->type); */
+}
+
+/* Must be called with an error trap in place */
+static void
+add_win (MetaScreen *screen,
+ MetaWindow *window,
+ Window xwindow)
+{
+ MetaDisplay *display = meta_screen_get_display (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ MetaCompScreen *info = meta_screen_get_compositor_data (screen);
+ MetaCompWindow *cw;
+ gulong event_mask;
+
+ if (info == NULL)
+ return;
+
+ if (xwindow == info->output)
+ return;
+
+ cw = g_new0 (MetaCompWindow, 1);
+ cw->screen = screen;
+ cw->window = window;
+ cw->id = xwindow;
+
+ if (!XGetWindowAttributes (xdisplay, xwindow, &cw->attrs))
+ {
+ g_free (cw);
+ return;
+ }
+ get_window_type (display, cw);
+
+ /* If Metacity has decided not to manage this window then the input events
+ won't have been set on the window */
+ event_mask = cw->attrs.your_event_mask | PropertyChangeMask;
+
+ XSelectInput (xdisplay, xwindow, event_mask);
+
+
+#ifdef HAVE_NAME_WINDOW_PIXMAP
+ cw->back_pixmap = None;
+ cw->shaded_back_pixmap = None;
+#endif
+
+ cw->damaged = FALSE;
+ cw->shaped = is_shaped (display, xwindow);
+
+ if (cw->attrs.class == InputOnly)
+ cw->damage = None;
+ else
+ cw->damage = XDamageCreate (xdisplay, xwindow, XDamageReportNonEmpty);
+
+ cw->alpha_pict = None;
+ cw->shadow_pict = None;
+ cw->border_size = None;
+ cw->extents = None;
+ cw->shadow = None;
+ cw->shadow_dx = 0;
+ cw->shadow_dy = 0;
+ cw->shadow_width = 0;
+ cw->shadow_height = 0;
+
+ if (window && meta_window_has_focus (window))
+ cw->shadow_type = META_SHADOW_LARGE;
+ else
+ cw->shadow_type = META_SHADOW_MEDIUM;
+
+ cw->opacity = OPAQUE;
+
+ cw->border_clip = None;
+
+ determine_mode (display, screen, cw);
+ cw->needs_shadow = window_has_shadow (cw);
+
+ /* Only add the window to the list of docks if it needs a shadow */
+ if (cw->type == META_COMP_WINDOW_DOCK && cw->needs_shadow)
+ {
+ meta_verbose ("Appending %p to dock windows\n", cw);
+ info->dock_windows = g_slist_append (info->dock_windows, cw);
+ }
+
+ /* Add this to the list at the top of the stack
+ before it is mapped so that map_win can find it again */
+ info->windows = g_list_prepend (info->windows, cw);
+ g_hash_table_insert (info->windows_by_xid, (gpointer) xwindow, cw);
+
+ if (cw->attrs.map_state == IsViewable)
+ map_win (display, screen, xwindow);
+}
+
+static void
+destroy_win (MetaDisplay *display,
+ Window xwindow,
+ gboolean gone)
+{
+ MetaScreen *screen;
+ MetaCompScreen *info;
+ MetaCompWindow *cw;
+
+ cw = find_window_in_display (display, xwindow);
+
+ if (cw == NULL)
+ return;
+
+ screen = cw->screen;
+
+ if (cw->extents != None)
+ {
+ dump_xserver_region ("destroy_win", display, cw->extents);
+ add_damage (screen, cw->extents);
+ cw->extents = None;
+ }
+
+ info = meta_screen_get_compositor_data (screen);
+ info->windows = g_list_remove (info->windows, (gconstpointer) cw);
+ g_hash_table_remove (info->windows_by_xid, (gpointer) xwindow);
+
+ free_win (cw, TRUE);
+}
+
+static void
+restack_win (MetaCompWindow *cw,
+ Window above)
+{
+ MetaScreen *screen;
+ MetaCompScreen *info;
+ Window previous_above;
+ GList *sibling, *next;
+
+ screen = cw->screen;
+ info = meta_screen_get_compositor_data (screen);
+
+ sibling = g_list_find (info->windows, (gconstpointer) cw);
+ next = g_list_next (sibling);
+ previous_above = None;
+
+ if (next)
+ {
+ MetaCompWindow *ncw = (MetaCompWindow *) next->data;
+ previous_above = ncw->id;
+ }
+
+ /* If above is set to None, the window whose state was changed is on
+ * the bottom of the stack with respect to sibling.
+ */
+ if (above == None)
+ {
+ /* Insert at bottom of window stack */
+ info->windows = g_list_delete_link (info->windows, sibling);
+ info->windows = g_list_append (info->windows, cw);
+ }
+ else if (previous_above != above)
+ {
+ GList *index;
+
+ for (index = info->windows; index; index = index->next) {
+ MetaCompWindow *cw2 = (MetaCompWindow *) index->data;
+ if (cw2->id == above)
+ break;
+ }
+
+ if (index != NULL)
+ {
+ info->windows = g_list_delete_link (info->windows, sibling);
+ info->windows = g_list_insert_before (info->windows, index, cw);
+ }
+ }
+}
+
+static void
+resize_win (MetaCompWindow *cw,
+ int x,
+ int y,
+ int width,
+ int height,
+ int border_width,
+ gboolean override_redirect)
+{
+ MetaScreen *screen = cw->screen;
+ MetaDisplay *display = meta_screen_get_display (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ MetaCompScreen *info = meta_screen_get_compositor_data (screen);
+ XserverRegion damage;
+ gboolean debug;
+
+ debug = DISPLAY_COMPOSITOR (display)->debug;
+
+ if (cw->extents)
+ {
+ damage = XFixesCreateRegion (xdisplay, NULL, 0);
+ XFixesCopyRegion (xdisplay, damage, cw->extents);
+ }
+ else
+ {
+ damage = None;
+ if (debug)
+ fprintf (stderr, "no extents to damage !\n");
+ }
+
+ /* { // Damage whole screen each time ! ;-)
+ XRectangle r;
+
+ r.x = 0;
+ r.y = 0;
+ meta_screen_get_size (screen, &r.width, &r.height);
+ fprintf (stderr, "Damage whole screen %d,%d (%d %d)\n",
+ r.x, r.y, r.width, r.height);
+
+ damage = XFixesCreateRegion (xdisplay, &r, 1);
+ } */
+
+ cw->attrs.x = x;
+ cw->attrs.y = y;
+
+ if (cw->attrs.width != width || cw->attrs.height != height)
+ {
+#ifdef HAVE_NAME_WINDOW_PIXMAP
+ if (have_name_window_pixmap (display))
+ {
+ if (cw->shaded_back_pixmap)
+ {
+ XFreePixmap (xdisplay, cw->shaded_back_pixmap);
+ cw->shaded_back_pixmap = None;
+ }
+
+ if (cw->back_pixmap)
+ {
+ /* If the window is shaded, we store the old backing pixmap
+ so we can return a proper image of the window */
+ if (cw->window && meta_window_is_shaded (cw->window))
+ {
+ cw->shaded_back_pixmap = cw->back_pixmap;
+ cw->back_pixmap = None;
+ }
+ else
+ {
+ XFreePixmap (xdisplay, cw->back_pixmap);
+ cw->back_pixmap = None;
+ }
+ }
+ }
+#endif
+ if (cw->picture)
+ {
+ XRenderFreePicture (xdisplay, cw->picture);
+ cw->picture = None;
+ }
+
+ if (cw->shadow)
+ {
+ XRenderFreePicture (xdisplay, cw->shadow);
+ cw->shadow = None;
+ }
+ }
+
+ cw->attrs.width = width;
+ cw->attrs.height = height;
+ cw->attrs.border_width = border_width;
+ cw->attrs.override_redirect = override_redirect;
+
+ if (cw->extents)
+ XFixesDestroyRegion (xdisplay, cw->extents);
+
+ cw->extents = win_extents (cw);
+
+ if (damage)
+ {
+ if (debug)
+ fprintf (stderr, "Inexplicable intersection with new extents!\n");
+
+ XFixesUnionRegion (xdisplay, damage, damage, cw->extents);
+ }
+ else
+ {
+ damage = XFixesCreateRegion (xdisplay, NULL, 0);
+ XFixesCopyRegion (xdisplay, damage, cw->extents);
+ }
+
+ dump_xserver_region ("resize_win", display, damage);
+ add_damage (screen, damage);
+
+ info->clip_changed = TRUE;
+}
+
+/* event processors must all be called with an error trap in place */
+static void
+process_circulate_notify (MetaCompositorXRender *compositor,
+ XCirculateEvent *event)
+{
+ MetaCompWindow *cw = find_window_in_display (compositor->display,
+ event->window);
+ MetaCompWindow *top;
+ MetaCompScreen *info;
+ MetaScreen *screen;
+ GList *first;
+ Window above;
+
+ if (!cw)
+ return;
+
+ screen = cw->screen;
+ info = meta_screen_get_compositor_data (screen);
+ first = info->windows;
+ top = (MetaCompWindow *) first->data;
+
+ if ((event->place == PlaceOnTop) && top)
+ above = top->id;
+ else
+ above = None;
+ restack_win (cw, above);
+
+ info->clip_changed = TRUE;
+
+#ifdef USE_IDLE_REPAINT
+ add_repair (compositor->display);
+#endif
+}
+
+static void
+process_configure_notify (MetaCompositorXRender *compositor,
+ XConfigureEvent *event)
+{
+ MetaDisplay *display = compositor->display;
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ MetaCompWindow *cw = find_window_in_display (display, event->window);
+
+ if (cw)
+ {
+#if 0
+ int x = -1, y = -1, width = -1, height = -1;
+ int ex = -1, ey = -1, ewidth = -1, eheight = -1;
+ MetaRectangle *rect;
+
+ if (cw->window) {
+ rect = meta_window_get_rect (cw->window);
+ x = rect->x;
+ y = rect->y;
+ width = rect->width;
+ height = rect->height;
+ }
+ fprintf (stderr, "configure notify xy (%d %d) -> (%d %d), wh (%d %d) -> (%d %d)\n",
+ x, y, event->x, event->y,
+ width, height, event->width, event->height);
+#endif
+
+ if (compositor->debug)
+ {
+ fprintf (stderr, "configure notify %d %d %d\n", cw->damaged,
+ cw->shaped, cw->needs_shadow);
+ dump_xserver_region ("\textents", display, cw->extents);
+ fprintf (stderr, "\txy (%d %d), wh (%d %d)\n",
+ event->x, event->y, event->width, event->height);
+ }
+
+ restack_win (cw, event->above);
+ resize_win (cw, event->x, event->y, event->width, event->height,
+ event->border_width, event->override_redirect);
+ }
+ else
+ {
+ MetaScreen *screen;
+ MetaCompScreen *info;
+
+ /* Might be the root window? */
+ screen = meta_display_screen_for_root (display, event->window);
+ if (screen == NULL)
+ return;
+
+ info = meta_screen_get_compositor_data (screen);
+ if (info->root_buffer)
+ {
+ XRenderFreePicture (xdisplay, info->root_buffer);
+ info->root_buffer = None;
+ }
+
+ damage_screen (screen);
+ }
+}
+
+static void
+process_property_notify (MetaCompositorXRender *compositor,
+ XPropertyEvent *event)
+{
+ MetaDisplay *display = compositor->display;
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ MetaScreen *screen;
+ int p;
+ Atom background_atoms[2];
+
+ /* Check for the background property changing */
+ background_atoms[0] = compositor->atom_x_root_pixmap;
+ background_atoms[1] = compositor->atom_x_set_root;
+
+ for (p = 0; p < 2; p++)
+ {
+ if (event->atom == background_atoms[p])
+ {
+ screen = meta_display_screen_for_root (display, event->window);
+ if (screen)
+ {
+ MetaCompScreen *info = meta_screen_get_compositor_data (screen);
+ Window xroot = meta_screen_get_xroot (screen);
+
+ if (info->root_tile)
+ {
+ XClearArea (xdisplay, xroot, 0, 0, 0, 0, TRUE);
+ XRenderFreePicture (xdisplay, info->root_tile);
+ info->root_tile = None;
+
+ /* Damage the whole screen as we may need to redraw the
+ background ourselves */
+ damage_screen (screen);
+#ifdef USE_IDLE_REPAINT
+ add_repair (display);
+#endif
+
+ return;
+ }
+ }
+ }
+ }
+
+ /* Check for the opacity changing */
+ if (event->atom == compositor->atom_net_wm_window_opacity)
+ {
+ MetaCompWindow *cw = find_window_in_display (display, event->window);
+ gulong value;
+
+ if (!cw)
+ {
+ /* Applications can set this for their toplevel windows, so
+ * this must be propagated to the window managed by the compositor
+ */
+ cw = find_window_for_child_window_in_display (display, event->window);
+ }
+
+ if (!cw)
+ return;
+
+ if (meta_prop_get_cardinal (display, event->window,
+ compositor->atom_net_wm_window_opacity,
+ &value) == FALSE)
+ value = OPAQUE;
+
+ cw->opacity = (guint)value;
+ determine_mode (display, cw->screen, cw);
+ cw->needs_shadow = window_has_shadow (cw);
+
+ if (cw->shadow)
+ {
+ XRenderFreePicture (xdisplay, cw->shadow);
+ cw->shadow = None;
+ }
+
+ if (cw->extents)
+ XFixesDestroyRegion (xdisplay, cw->extents);
+ cw->extents = win_extents (cw);
+
+ cw->damaged = TRUE;
+#ifdef USE_IDLE_REPAINT
+ add_repair (display);
+#endif
+
+ return;
+ }
+
+ if (event->atom == compositor->atom_net_wm_window_type) {
+ MetaCompWindow *cw = find_window_in_display (display, event->window);
+
+ if (!cw)
+ return;
+
+ get_window_type (display, cw);
+ cw->needs_shadow = window_has_shadow (cw);
+ return;
+ }
+}
+
+static void
+expose_area (MetaScreen *screen,
+ XRectangle *rects,
+ int nrects)
+{
+ MetaDisplay *display = meta_screen_get_display (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ XserverRegion region;
+
+ region = XFixesCreateRegion (xdisplay, rects, nrects);
+
+ dump_xserver_region ("expose_area", display, region);
+ add_damage (screen, region);
+}
+
+static void
+process_expose (MetaCompositorXRender *compositor,
+ XExposeEvent *event)
+{
+ MetaCompWindow *cw = find_window_in_display (compositor->display,
+ event->window);
+ MetaScreen *screen = NULL;
+ XRectangle rect[1];
+ int origin_x = 0, origin_y = 0;
+
+ if (cw != NULL)
+ {
+ screen = cw->screen;
+ origin_x = cw->attrs.x; /* + cw->attrs.border_width; ? */
+ origin_y = cw->attrs.y; /* + cw->attrs.border_width; ? */
+ }
+ else
+ {
+ screen = meta_display_screen_for_root (compositor->display,
+ event->window);
+ if (screen == NULL)
+ return;
+ }
+
+ rect[0].x = event->x + origin_x;
+ rect[0].y = event->y + origin_y;
+ rect[0].width = event->width;
+ rect[0].height = event->height;
+
+ expose_area (screen, rect, 1);
+}
+
+static void
+process_unmap (MetaCompositorXRender *compositor,
+ XUnmapEvent *event)
+{
+ MetaCompWindow *cw;
+
+ if (event->from_configure)
+ {
+ /* Ignore unmap caused by parent's resize */
+ return;
+ }
+
+
+ cw = find_window_in_display (compositor->display, event->window);
+ if (cw)
+ unmap_win (compositor->display, cw->screen, event->window);
+}
+
+static void
+process_map (MetaCompositorXRender *compositor,
+ XMapEvent *event)
+{
+ MetaCompWindow *cw = find_window_in_display (compositor->display,
+ event->window);
+
+ if (cw)
+ map_win (compositor->display, cw->screen, event->window);
+}
+
+static void
+process_reparent (MetaCompositorXRender *compositor,
+ XReparentEvent *event,
+ MetaWindow *window)
+{
+ MetaScreen *screen;
+
+ screen = meta_display_screen_for_root (compositor->display, event->parent);
+ if (screen != NULL)
+ add_win (screen, window, event->window);
+ else
+ destroy_win (compositor->display, event->window, FALSE);
+}
+
+static void
+process_create (MetaCompositorXRender *compositor,
+ XCreateWindowEvent *event,
+ MetaWindow *window)
+{
+ MetaScreen *screen;
+ /* We are only interested in top level windows, others will
+ be caught by normal metacity functions */
+
+ screen = meta_display_screen_for_root (compositor->display, event->parent);
+ if (screen == NULL)
+ return;
+
+ if (!find_window_in_display (compositor->display, event->window))
+ add_win (screen, window, event->window);
+}
+
+static void
+process_destroy (MetaCompositorXRender *compositor,
+ XDestroyWindowEvent *event)
+{
+ destroy_win (compositor->display, event->window, FALSE);
+}
+
+static void
+process_damage (MetaCompositorXRender *compositor,
+ XDamageNotifyEvent *event)
+{
+ MetaCompWindow *cw = find_window_in_display (compositor->display,
+ event->drawable);
+ if (cw == NULL)
+ return;
+
+ repair_win (cw);
+
+#ifdef USE_IDLE_REPAINT
+ if (event->more == FALSE)
+ add_repair (compositor->display);
+#endif
+}
+
+static void
+process_shape (MetaCompositorXRender *compositor,
+ XShapeEvent *event)
+{
+ MetaCompWindow *cw = find_window_in_display (compositor->display,
+ event->window);
+
+ if (cw == NULL)
+ return;
+
+ if (event->kind == ShapeBounding)
+ {
+ if (!event->shaped && cw->shaped)
+ cw->shaped = FALSE;
+
+ resize_win (cw, cw->attrs.x, cw->attrs.y,
+ event->width + event->x, event->height + event->y,
+ cw->attrs.border_width, cw->attrs.override_redirect);
+
+ if (event->shaped && !cw->shaped)
+ cw->shaped = TRUE;
+ }
+}
+
+static int
+timeout_debug (MetaCompositorXRender *compositor)
+{
+ compositor->show_redraw = (g_getenv ("METACITY_DEBUG_REDRAWS") != NULL);
+ compositor->debug = (g_getenv ("METACITY_DEBUG_COMPOSITOR") != NULL);
+
+ return FALSE;
+}
+
+static void
+xrender_add_window (MetaCompositor *compositor,
+ MetaWindow *window,
+ Window xwindow,
+ XWindowAttributes *attrs)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ MetaCompositorXRender *xrc = (MetaCompositorXRender *) compositor;
+ MetaScreen *screen = meta_screen_for_x_screen (attrs->screen);
+
+ meta_error_trap_push (xrc->display);
+ add_win (screen, window, xwindow);
+ meta_error_trap_pop (xrc->display, FALSE);
+#endif
+}
+
+static void
+xrender_remove_window (MetaCompositor *compositor,
+ Window xwindow)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+#endif
+}
+
+static void
+show_overlay_window (MetaScreen *screen,
+ Window cow)
+{
+ MetaDisplay *display = meta_screen_get_display (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+
+#ifdef HAVE_COW
+ if (have_cow (display))
+ {
+ XserverRegion region;
+
+ region = XFixesCreateRegion (xdisplay, NULL, 0);
+
+ XFixesSetWindowShapeRegion (xdisplay, cow, ShapeBounding, 0, 0, 0);
+ XFixesSetWindowShapeRegion (xdisplay, cow, ShapeInput, 0, 0, region);
+
+ XFixesDestroyRegion (xdisplay, region);
+
+ damage_screen (screen);
+ }
+#endif
+}
+
+static void
+hide_overlay_window (MetaScreen *screen,
+ Window cow)
+{
+#ifdef HAVE_COW
+ MetaDisplay *display = meta_screen_get_display (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ XserverRegion region;
+
+ region = XFixesCreateRegion (xdisplay, NULL, 0);
+ XFixesSetWindowShapeRegion (xdisplay, cow, ShapeBounding, 0, 0, region);
+ XFixesDestroyRegion (xdisplay, region);
+#endif
+}
+
+static Window
+get_output_window (MetaScreen *screen)
+{
+ MetaDisplay *display = meta_screen_get_display (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ Window output, xroot;
+
+ xroot = meta_screen_get_xroot (screen);
+
+#ifdef HAVE_COW
+ if (have_cow (display))
+ {
+ output = XCompositeGetOverlayWindow (xdisplay, xroot);
+ XSelectInput (xdisplay, output, ExposureMask);
+ }
+ else
+#endif
+ {
+ output = xroot;
+ }
+
+ return output;
+}
+
+static void
+xrender_manage_screen (MetaCompositor *compositor,
+ MetaScreen *screen)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ MetaCompScreen *info;
+ MetaDisplay *display = meta_screen_get_display (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ XRenderPictureAttributes pa;
+ XRenderPictFormat *visual_format;
+ int screen_number = meta_screen_get_screen_number (screen);
+ Window xroot = meta_screen_get_xroot (screen);
+
+ /* Check if the screen is already managed */
+ if (meta_screen_get_compositor_data (screen))
+ return;
+
+ gdk_error_trap_push ();
+ XCompositeRedirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
+ XSync (xdisplay, FALSE);
+
+ if (gdk_error_trap_pop ())
+ {
+ g_warning ("Another compositing manager is running on screen %i",
+ screen_number);
+ return;
+ }
+
+ info = g_new0 (MetaCompScreen, 1);
+ info->screen = screen;
+
+ meta_screen_set_compositor_data (screen, info);
+
+ visual_format = XRenderFindVisualFormat (xdisplay, DefaultVisual (xdisplay,
+ screen_number));
+ if (!visual_format)
+ {
+ g_warning ("Cannot find visual format on screen %i", screen_number);
+ return;
+ }
+
+ info->output = get_output_window (screen);
+
+ pa.subwindow_mode = IncludeInferiors;
+ info->root_picture = XRenderCreatePicture (xdisplay, info->output,
+ visual_format,
+ CPSubwindowMode, &pa);
+ if (info->root_picture == None)
+ {
+ g_warning ("Cannot create root picture on screen %i", screen_number);
+ return;
+ }
+
+ info->root_buffer = None;
+ info->black_picture = solid_picture (display, screen, TRUE, 1, 0, 0, 0);
+
+ info->root_tile = None;
+ info->all_damage = None;
+
+ info->windows = NULL;
+ info->windows_by_xid = g_hash_table_new (g_direct_hash, g_direct_equal);
+
+ info->focus_window = meta_display_get_focus_window (display);
+
+ info->compositor_active = TRUE;
+ info->overlays = 0;
+ info->clip_changed = TRUE;
+
+ info->have_shadows = (g_getenv("META_DEBUG_NO_SHADOW") == NULL);
+ if (info->have_shadows)
+ {
+ meta_verbose ("Enabling shadows\n");
+ generate_shadows (info);
+ }
+ else
+ meta_verbose ("Disabling shadows\n");
+
+ XClearArea (xdisplay, info->output, 0, 0, 0, 0, TRUE);
+
+ meta_screen_set_cm_selection (screen);
+
+ /* Now we're up and running we can show the output if needed */
+ show_overlay_window (screen, info->output);
+#endif
+}
+
+static void
+xrender_unmanage_screen (MetaCompositor *compositor,
+ MetaScreen *screen)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ MetaDisplay *display = meta_screen_get_display (screen);
+ Display *xdisplay = meta_display_get_xdisplay (display);
+ MetaCompScreen *info;
+ Window xroot = meta_screen_get_xroot (screen);
+ GList *index;
+
+ info = meta_screen_get_compositor_data (screen);
+
+ /* This screen isn't managed */
+ if (info == NULL)
+ return;
+
+ hide_overlay_window (screen, info->output);
+
+ /* Destroy the windows */
+ for (index = info->windows; index; index = index->next)
+ {
+ MetaCompWindow *cw = (MetaCompWindow *) index->data;
+ free_win (cw, TRUE);
+ }
+ g_list_free (info->windows);
+ g_hash_table_destroy (info->windows_by_xid);
+
+ if (info->root_picture)
+ XRenderFreePicture (xdisplay, info->root_picture);
+
+ if (info->black_picture)
+ XRenderFreePicture (xdisplay, info->black_picture);
+
+ if (info->have_shadows)
+ {
+ int i;
+
+ for (i = 0; i < LAST_SHADOW_TYPE; i++)
+ g_free (info->shadows[i]->gaussian_map);
+ }
+
+ XCompositeUnredirectSubwindows (xdisplay, xroot,
+ CompositeRedirectManual);
+ meta_screen_unset_cm_selection (screen);
+
+#ifdef HAVE_COW
+ XCompositeReleaseOverlayWindow (xdisplay, info->output);
+#endif
+
+ g_free (info);
+
+ meta_screen_set_compositor_data (screen, NULL);
+#endif
+}
+
+static void
+xrender_set_updates (MetaCompositor *compositor,
+ MetaWindow *window,
+ gboolean updates)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+
+#endif
+}
+
+static void
+xrender_destroy (MetaCompositor *compositor)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ g_free (compositor);
+#endif
+}
+
+static void
+xrender_begin_move (MetaCompositor *compositor,
+ MetaWindow *window,
+ MetaRectangle *initial,
+ int grab_x,
+ int grab_y)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+#endif
+}
+
+static void
+xrender_update_move (MetaCompositor *compositor,
+ MetaWindow *window,
+ int x,
+ int y)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+#endif
+}
+
+static void
+xrender_end_move (MetaCompositor *compositor,
+ MetaWindow *window)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+#endif
+}
+
+static void
+xrender_free_window (MetaCompositor *compositor,
+ MetaWindow *window)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ /* FIXME: When an undecorated window is hidden this is called,
+ but the window does not get readded if it is subsequentally shown again
+ See http://bugzilla.gnome.org/show_bug.cgi?id=504876
+
+ I don't *think* theres any need for this call anyway, leaving it out
+ does not seem to cause any side effects so far, but I should check with
+ someone who understands more. */
+ /* destroy_win (compositor->display, window->xwindow, FALSE); */
+#endif
+}
+
+static void
+xrender_process_event (MetaCompositor *compositor,
+ XEvent *event,
+ MetaWindow *window)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ MetaCompositorXRender *xrc = (MetaCompositorXRender *) compositor;
+ /*
+ * This trap is so that none of the compositor functions cause
+ * X errors. This is really a hack, but I'm afraid I don't understand
+ * enough about Metacity/X to know how else you are supposed to do it
+ */
+ meta_error_trap_push (xrc->display);
+ switch (event->type)
+ {
+ case CirculateNotify:
+ process_circulate_notify (xrc, (XCirculateEvent *) event);
+ break;
+
+ case ConfigureNotify:
+ process_configure_notify (xrc, (XConfigureEvent *) event);
+ break;
+
+ case PropertyNotify:
+ process_property_notify (xrc, (XPropertyEvent *) event);
+ break;
+
+ case Expose:
+ process_expose (xrc, (XExposeEvent *) event);
+ break;
+
+ case UnmapNotify:
+ process_unmap (xrc, (XUnmapEvent *) event);
+ break;
+
+ case MapNotify:
+ process_map (xrc, (XMapEvent *) event);
+ break;
+
+ case ReparentNotify:
+ process_reparent (xrc, (XReparentEvent *) event, window);
+ break;
+
+ case CreateNotify:
+ process_create (xrc, (XCreateWindowEvent *) event, window);
+ break;
+
+ case DestroyNotify:
+ process_destroy (xrc, (XDestroyWindowEvent *) event);
+ break;
+
+ default:
+ if (event->type == meta_display_get_damage_event_base (xrc->display) + XDamageNotify)
+ process_damage (xrc, (XDamageNotifyEvent *) event);
+ else if (event->type == meta_display_get_shape_event_base (xrc->display) + ShapeNotify)
+ process_shape (xrc, (XShapeEvent *) event);
+ else
+ {
+ meta_error_trap_pop (xrc->display, FALSE);
+ return;
+ }
+ break;
+ }
+
+ meta_error_trap_pop (xrc->display, FALSE);
+#ifndef USE_IDLE_REPAINT
+ repair_display (xrc->display);
+#endif
+
+ return;
+#endif
+}
+
+static Pixmap
+xrender_get_window_pixmap (MetaCompositor *compositor,
+ MetaWindow *window)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ MetaCompWindow *cw = NULL;
+ MetaScreen *screen = meta_window_get_screen (window);
+ MetaFrame *frame = meta_window_get_frame (window);
+
+ cw = find_window_for_screen (screen, frame ? meta_frame_get_xwindow (frame) :
+ meta_window_get_xwindow (window));
+ if (cw == NULL)
+ return None;
+
+#ifdef HAVE_NAME_WINDOW_PIXMAP
+ if (have_name_window_pixmap (meta_window_get_display (window)))
+ {
+ if (meta_window_is_shaded (window))
+ return cw->shaded_back_pixmap;
+ else
+ return cw->back_pixmap;
+ }
+ else
+#endif
+ return None;
+#endif
+}
+
+static void
+xrender_set_active_window (MetaCompositor *compositor,
+ MetaScreen *screen,
+ MetaWindow *window)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ MetaCompositorXRender *xrc = (MetaCompositorXRender *) compositor;
+ MetaDisplay *display;
+ Display *xdisplay;
+ MetaCompWindow *old_focus = NULL, *new_focus = NULL;
+ MetaCompScreen *info;
+ MetaWindow *old_focus_win;
+
+ if (compositor == NULL)
+ return;
+
+ display = xrc->display;
+ xdisplay = meta_display_get_xdisplay (display);
+ info = meta_screen_get_compositor_data (screen);
+ old_focus_win = info->focus_window;
+
+ if (old_focus_win)
+ {
+ MetaFrame *f = meta_window_get_frame (old_focus_win);
+
+ old_focus = find_window_for_screen (screen,
+ f ? meta_frame_get_xwindow (f) :
+ meta_window_get_xwindow (old_focus_win));
+ }
+
+ if (window)
+ {
+ MetaFrame *f = meta_window_get_frame (window);
+ new_focus = find_window_for_screen (screen,
+ f ? meta_frame_get_xwindow (f) :
+ meta_window_get_xwindow (window));
+ }
+
+ info->focus_window = window;
+ if (old_focus)
+ {
+ XserverRegion damage;
+
+ /* Tear down old shadows */
+ old_focus->shadow_type = META_SHADOW_MEDIUM;
+ determine_mode (display, screen, old_focus);
+ old_focus->needs_shadow = window_has_shadow (old_focus);
+
+ if (old_focus->attrs.map_state == IsViewable)
+ {
+ if (old_focus->shadow)
+ {
+ XRenderFreePicture (xdisplay, old_focus->shadow);
+ old_focus->shadow = None;
+ }
+
+ if (old_focus->extents)
+ {
+ damage = XFixesCreateRegion (xdisplay, NULL, 0);
+ XFixesCopyRegion (xdisplay, damage, old_focus->extents);
+ XFixesDestroyRegion (xdisplay, old_focus->extents);
+ }
+ else
+ damage = None;
+
+ /* Build new extents */
+ old_focus->extents = win_extents (old_focus);
+
+ if (damage)
+ XFixesUnionRegion (xdisplay, damage, damage, old_focus->extents);
+ else
+ {
+ damage = XFixesCreateRegion (xdisplay, NULL, 0);
+ XFixesCopyRegion (xdisplay, damage, old_focus->extents);
+ }
+
+ dump_xserver_region ("resize_win", display, damage);
+ add_damage (screen, damage);
+
+ info->clip_changed = TRUE;
+ }
+ }
+
+ if (new_focus)
+ {
+ XserverRegion damage;
+
+ new_focus->shadow_type = META_SHADOW_LARGE;
+ determine_mode (display, screen, new_focus);
+ new_focus->needs_shadow = window_has_shadow (new_focus);
+
+ if (new_focus->shadow)
+ {
+ XRenderFreePicture (xdisplay, new_focus->shadow);
+ new_focus->shadow = None;
+ }
+
+ if (new_focus->extents)
+ {
+ damage = XFixesCreateRegion (xdisplay, NULL, 0);
+ XFixesCopyRegion (xdisplay, damage, new_focus->extents);
+ XFixesDestroyRegion (xdisplay, new_focus->extents);
+ }
+ else
+ damage = None;
+
+ /* Build new extents */
+ new_focus->extents = win_extents (new_focus);
+
+ if (damage)
+ XFixesUnionRegion (xdisplay, damage, damage, new_focus->extents);
+ else
+ {
+ damage = XFixesCreateRegion (xdisplay, NULL, 0);
+ XFixesCopyRegion (xdisplay, damage, new_focus->extents);
+ }
+
+ dump_xserver_region ("resize_win", display, damage);
+ add_damage (screen, damage);
+
+ info->clip_changed = TRUE;
+ }
+#ifdef USE_IDLE_REPAINT
+ add_repair (display);
+#endif
+#endif
+}
+
+static MetaCompositor comp_info = {
+ xrender_destroy,
+ xrender_manage_screen,
+ xrender_unmanage_screen,
+ xrender_add_window,
+ xrender_remove_window,
+ xrender_set_updates,
+ xrender_process_event,
+ xrender_get_window_pixmap,
+ xrender_set_active_window
+};
+
+MetaCompositor *
+meta_compositor_xrender_new (MetaDisplay *display)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ char *atom_names[] = {
+ "_XROOTPMAP_ID",
+ "_XSETROOT_ID",
+ "_NET_WM_WINDOW_OPACITY",
+ "_NET_WM_WINDOW_TYPE_DND",
+ "_NET_WM_WINDOW_TYPE",
+ "_NET_WM_WINDOW_TYPE_DESKTOP",
+ "_NET_WM_WINDOW_TYPE_DOCK",
+ "_NET_WM_WINDOW_TYPE_MENU",
+ "_NET_WM_WINDOW_TYPE_DIALOG",
+ "_NET_WM_WINDOW_TYPE_NORMAL",
+ "_NET_WM_WINDOW_TYPE_UTILITY",
+ "_NET_WM_WINDOW_TYPE_SPLASH",
+ "_NET_WM_WINDOW_TYPE_TOOLBAR"
+ };
+ Atom atoms[G_N_ELEMENTS(atom_names)];
+ MetaCompositorXRender *xrc;
+ MetaCompositor *compositor;
+ Display *xdisplay = meta_display_get_xdisplay (display);
+
+ xrc = g_new (MetaCompositorXRender, 1);
+ xrc->compositor = comp_info;
+
+ compositor = (MetaCompositor *) xrc;
+
+ xrc->display = display;
+
+ meta_verbose ("Creating %d atoms\n", (int) G_N_ELEMENTS (atom_names));
+ XInternAtoms (xdisplay, atom_names, G_N_ELEMENTS (atom_names),
+ False, atoms);
+
+ xrc->atom_x_root_pixmap = atoms[0];
+ xrc->atom_x_set_root = atoms[1];
+ xrc->atom_net_wm_window_opacity = atoms[2];
+ xrc->atom_net_wm_window_type_dnd = atoms[3];
+ xrc->atom_net_wm_window_type = atoms[4];
+ xrc->atom_net_wm_window_type_desktop = atoms[5];
+ xrc->atom_net_wm_window_type_dock = atoms[6];
+ xrc->atom_net_wm_window_type_menu = atoms[7];
+ xrc->atom_net_wm_window_type_dialog = atoms[8];
+ xrc->atom_net_wm_window_type_normal = atoms[9];
+ xrc->atom_net_wm_window_type_utility = atoms[10];
+ xrc->atom_net_wm_window_type_splash = atoms[11];
+ xrc->atom_net_wm_window_type_toolbar = atoms[12];
+
+#ifdef USE_IDLE_REPAINT
+ meta_verbose ("Using idle repaint\n");
+ xrc->repaint_id = 0;
+#endif
+
+ xrc->enabled = TRUE;
+ g_timeout_add (2000, (GSourceFunc) timeout_debug, xrc);
+
+ return compositor;
+#else
+ return NULL;
+#endif
+}
Added: trunk/src/compositor/compositor-xrender.h
==============================================================================
--- (empty file)
+++ trunk/src/compositor/compositor-xrender.h Mon May 19 00:00:09 2008
@@ -0,0 +1,31 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2007 Iain Holmes
+ * Based on xcompmgr - (c) 2003 Keith Packard
+ * xfwm4 - (c) 2005-2007 Olivier Fourdan
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef META_COMPOSITOR_XRENDER_H_
+#define META_COMPOSITOR_XRENDER_H_
+
+#include "types.h"
+
+MetaCompositor *meta_compositor_xrender_new (MetaDisplay *display);
+
+#endif
Added: trunk/src/compositor/compositor.c
==============================================================================
--- (empty file)
+++ trunk/src/compositor/compositor.c Mon May 19 00:00:09 2008
@@ -0,0 +1,158 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2008 Iain Holmes
+ *
+ * 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 "compositor-private.h"
+
+MetaCompositor *
+meta_compositor_new (MetaDisplay *display)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ /* At some point we would have a way to select between backends */
+ return meta_compositor_xrender_new (display);
+#else
+ return NULL;
+#endif
+}
+
+void
+meta_compositor_destroy (MetaCompositor *compositor)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ if (compositor->destroy)
+ compositor->destroy (compositor);
+#endif
+}
+
+void
+meta_compositor_add_window (MetaCompositor *compositor,
+ MetaWindow *window,
+ Window xwindow,
+ XWindowAttributes *attrs)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ if (compositor->add_window)
+ compositor->add_window (compositor, window, xwindow, attrs);
+#endif
+}
+
+void
+meta_compositor_remove_window (MetaCompositor *compositor,
+ Window xwindow)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ if (compositor->remove_window)
+ compositor->remove_window (compositor, xwindow);
+#endif
+}
+
+void
+meta_compositor_manage_screen (MetaCompositor *compositor,
+ MetaScreen *screen)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ if (compositor->manage_screen)
+ compositor->manage_screen (compositor, screen);
+#endif
+}
+
+void
+meta_compositor_unmanage_screen (MetaCompositor *compositor,
+ MetaScreen *screen)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ if (compositor->unmanage_screen)
+ compositor->unmanage_screen (compositor, screen);
+#endif
+}
+
+void
+meta_compositor_set_updates (MetaCompositor *compositor,
+ MetaWindow *window,
+ gboolean updates)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ if (compositor->set_updates)
+ compositor->set_updates (compositor, window, updates);
+#endif
+}
+
+void
+meta_compositor_process_event (MetaCompositor *compositor,
+ XEvent *event,
+ MetaWindow *window)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ if (compositor->process_event)
+ compositor->process_event (compositor, event, window);
+#endif
+}
+
+Pixmap
+meta_compositor_get_window_pixmap (MetaCompositor *compositor,
+ MetaWindow *window)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ if (compositor->get_window_pixmap)
+ compositor->get_window_pixmap (compositor, window);
+ else
+ return None;
+#else
+ return None;
+#endif
+}
+
+void
+meta_compositor_set_active_window (MetaCompositor *compositor,
+ MetaScreen *screen,
+ MetaWindow *window)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ if (compositor->set_active_window)
+ compositor->set_active_window (compositor, screen, window);
+#endif
+}
+
+/* These functions are unused at the moment */
+void meta_compositor_begin_move (MetaCompositor *compositor,
+ MetaWindow *window,
+ MetaRectangle *initial,
+ int grab_x,
+ int grab_y)
+{
+}
+
+void meta_compositor_update_move (MetaCompositor *compositor,
+ MetaWindow *window,
+ int x,
+ int y)
+{
+}
+
+void meta_compositor_end_move (MetaCompositor *compositor,
+ MetaWindow *window)
+{
+}
+
+void meta_compositor_free_window (MetaCompositor *compositor,
+ MetaWindow *window)
+{
+}
Modified: trunk/src/core/bell.c
==============================================================================
--- trunk/src/core/bell.c (original)
+++ trunk/src/core/bell.c Mon May 19 00:00:09 2008
@@ -52,7 +52,7 @@
#include <config.h>
#include "bell.h"
-#include "screen.h"
+#include "screen-private.h"
#include "prefs.h"
/**
Modified: trunk/src/core/bell.h
==============================================================================
--- trunk/src/core/bell.h (original)
+++ trunk/src/core/bell.h Mon May 19 00:00:09 2008
@@ -24,8 +24,8 @@
#ifdef HAVE_XKB
#include <X11/XKBlib.h>
#endif
-#include "display.h"
-#include "frame.h"
+#include "display-private.h"
+#include "frame-private.h"
#ifdef HAVE_XKB
void meta_bell_notify (MetaDisplay *display, XkbAnyEvent *xkb_ev);
Modified: trunk/src/core/constraints.h
==============================================================================
--- trunk/src/core/constraints.h (original)
+++ trunk/src/core/constraints.h Mon May 19 00:00:09 2008
@@ -26,8 +26,8 @@
#define META_CONSTRAINTS_H
#include "util.h"
-#include "window.h"
-#include "frame.h"
+#include "window-private.h"
+#include "frame-private.h"
typedef enum
{
Modified: trunk/src/core/core.c
==============================================================================
--- trunk/src/core/core.c (original)
+++ trunk/src/core/core.c Mon May 19 00:00:09 2008
@@ -25,7 +25,7 @@
#include <config.h>
#include "core.h"
-#include "frame.h"
+#include "frame-private.h"
#include "workspace.h"
#include "prefs.h"
Modified: trunk/src/core/delete.c
==============================================================================
--- trunk/src/core/delete.c (original)
+++ trunk/src/core/delete.c Mon May 19 00:00:09 2008
@@ -27,7 +27,7 @@
#include <config.h>
#include "util.h"
-#include "window.h"
+#include "window-private.h"
#include "errors.h"
#include "workspace.h"
Added: trunk/src/core/display-private.h
==============================================================================
--- (empty file)
+++ trunk/src/core/display-private.h Mon May 19 00:00:09 2008
@@ -0,0 +1,502 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/* Metacity X display handler */
+
+/*
+ * Copyright (C) 2001 Havoc Pennington
+ * Copyright (C) 2002 Red Hat, Inc.
+ * Copyright (C) 2003 Rob Adams
+ * Copyright (C) 2004-2006 Elijah Newren
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef META_DISPLAY_PRIVATE_H
+#define META_DISPLAY_PRIVATE_H
+
+#ifndef PACKAGE
+#error "config.h not included"
+#endif
+
+#include <glib.h>
+#include <X11/Xlib.h>
+#include "eventqueue.h"
+#include "common.h"
+#include "boxes.h"
+#include "display.h"
+
+#ifdef HAVE_STARTUP_NOTIFICATION
+#include <libsn/sn.h>
+#endif
+
+#ifdef HAVE_XSYNC
+#include <X11/extensions/sync.h>
+#endif
+
+typedef struct _MetaKeyBinding MetaKeyBinding;
+typedef struct _MetaStack MetaStack;
+typedef struct _MetaUISlave MetaUISlave;
+typedef struct _MetaWorkspace MetaWorkspace;
+
+typedef struct _MetaWindowPropHooks MetaWindowPropHooks;
+typedef struct _MetaGroupPropHooks MetaGroupPropHooks;
+
+typedef struct MetaEdgeResistanceData MetaEdgeResistanceData;
+
+typedef void (* MetaWindowPingFunc) (MetaDisplay *display,
+ Window xwindow,
+ guint32 timestamp,
+ gpointer user_data);
+
+
+#define _NET_WM_STATE_REMOVE 0 /* remove/unset property */
+#define _NET_WM_STATE_ADD 1 /* add/set property */
+#define _NET_WM_STATE_TOGGLE 2 /* toggle property */
+
+/* This is basically a bogus number, just has to be large enough
+ * to handle the expected case of the alt+tab operation, where
+ * we want to ignore serials from UnmapNotify on the tab popup,
+ * and the LeaveNotify/EnterNotify from the pointer ungrab
+ */
+#define N_IGNORED_SERIALS 4
+
+struct _MetaDisplay
+{
+ char *name;
+ Display *xdisplay;
+
+ Window leader_window;
+ Window timestamp_pinging_window;
+
+ /* Pull in all the names of atoms as fields; we will intern them when the
+ * class is constructed.
+ */
+#define item(x) Atom atom_##x;
+#include "atomnames.h"
+#undef item
+
+ /* This is the actual window from focus events,
+ * not the one we last set
+ */
+ MetaWindow *focus_window;
+
+ /* window we are expecting a FocusIn event for or the current focus
+ * window if we are not expecting any FocusIn/FocusOut events; not
+ * perfect because applications can call XSetInputFocus directly.
+ * (It could also be messed up if a timestamp later than current
+ * time is sent to meta_display_set_input_focus_window, though that
+ * would be a programming error). See bug 154598 for more info.
+ */
+ MetaWindow *expected_focus_window;
+
+ /* last timestamp passed to XSetInputFocus */
+ guint32 last_focus_time;
+
+ /* last user interaction time in any app */
+ guint32 last_user_time;
+
+ /* whether we're using mousenav (only relevant for sloppy&mouse focus modes;
+ * !mouse_mode means "keynav mode")
+ */
+ guint mouse_mode : 1;
+
+ /* Helper var used when focus_new_windows setting is 'strict'; only
+ * relevant in 'strict' mode and if the focus window is a terminal.
+ * In that case, we don't allow new windows to take focus away from
+ * a terminal, but if the user explicitly did something that should
+ * allow a different window to gain focus (e.g. global keybinding or
+ * clicking on a dock), then we will allow the transfer.
+ */
+ guint allow_terminal_deactivation : 1;
+
+ guint static_gravity_works : 1;
+
+ /*< private-ish >*/
+ guint error_trap_synced_at_last_pop : 1;
+ MetaEventQueue *events;
+ GSList *screens;
+ MetaScreen *active_screen;
+ GHashTable *window_ids;
+ int error_traps;
+ int (* error_trap_handler) (Display *display,
+ XErrorEvent *error);
+ int server_grab_count;
+
+ /* serials of leave/unmap events that may
+ * correspond to an enter event we should
+ * ignore
+ */
+ unsigned long ignored_serials[N_IGNORED_SERIALS];
+ Window ungrab_should_not_cause_focus_window;
+
+ guint32 current_time;
+
+ /* Pings which we're waiting for a reply from */
+ GSList *pending_pings;
+
+ /* Pending autoraise */
+ guint autoraise_timeout_id;
+ MetaWindow* autoraise_window;
+
+ /* Alt+click button grabs */
+ unsigned int window_grab_modifiers;
+
+ /* current window operation */
+ MetaGrabOp grab_op;
+ MetaScreen *grab_screen;
+ MetaWindow *grab_window;
+ Window grab_xwindow;
+ int grab_button;
+ int grab_anchor_root_x;
+ int grab_anchor_root_y;
+ MetaRectangle grab_anchor_window_pos;
+ int grab_latest_motion_x;
+ int grab_latest_motion_y;
+ gulong grab_mask;
+ guint grab_have_pointer : 1;
+ guint grab_have_keyboard : 1;
+ guint grab_wireframe_active : 1;
+ guint grab_was_cancelled : 1; /* Only used in wireframe mode */
+ guint grab_frame_action : 1;
+ MetaRectangle grab_wireframe_rect;
+ MetaRectangle grab_wireframe_last_xor_rect;
+ MetaRectangle grab_initial_window_pos;
+ int grab_initial_x, grab_initial_y; /* These are only relevant for */
+ gboolean grab_threshold_movement_reached; /* raise_on_click == FALSE. */
+ MetaResizePopup *grab_resize_popup;
+ GTimeVal grab_last_moveresize_time;
+ guint32 grab_motion_notify_time;
+ int grab_wireframe_last_display_width;
+ int grab_wireframe_last_display_height;
+ GList* grab_old_window_stacking;
+ MetaEdgeResistanceData *grab_edge_resistance_data;
+ unsigned int grab_last_user_action_was_snap;
+
+ /* we use property updates as sentinels for certain window focus events
+ * to avoid some race conditions on EnterNotify events
+ */
+ int sentinel_counter;
+
+#ifdef HAVE_XKB
+ int xkb_base_event_type;
+ guint32 last_bell_time;
+#endif
+#ifdef HAVE_XSYNC
+ /* alarm monitoring client's _NET_WM_SYNC_REQUEST_COUNTER */
+ XSyncAlarm grab_sync_request_alarm;
+#endif
+ int grab_resize_timeout_id;
+
+ /* Keybindings stuff */
+ MetaKeyBinding *screen_bindings;
+ int n_screen_bindings;
+ MetaKeyBinding *window_bindings;
+ int n_window_bindings;
+ int min_keycode;
+ int max_keycode;
+ KeySym *keymap;
+ int keysyms_per_keycode;
+ XModifierKeymap *modmap;
+ unsigned int ignored_modifier_mask;
+ unsigned int num_lock_mask;
+ unsigned int scroll_lock_mask;
+ unsigned int hyper_mask;
+ unsigned int super_mask;
+ unsigned int meta_mask;
+
+ /* Xinerama cache */
+ unsigned int xinerama_cache_invalidated : 1;
+
+ /* Opening the display */
+ unsigned int display_opening : 1;
+
+ /* Closing down the display */
+ int closing;
+
+ /* Managed by group.c */
+ GHashTable *groups_by_leader;
+
+ /* currently-active window menu if any */
+ MetaWindowMenu *window_menu;
+ MetaWindow *window_with_menu;
+
+ /* Managed by window-props.c */
+ MetaWindowPropHooks *prop_hooks;
+
+ /* Managed by group-props.c */
+ MetaGroupPropHooks *group_prop_hooks;
+
+ /* Managed by compositor.c */
+ MetaCompositor *compositor;
+
+#ifdef HAVE_STARTUP_NOTIFICATION
+ SnDisplay *sn_display;
+#endif
+#ifdef HAVE_XSYNC
+ int xsync_event_base;
+ int xsync_error_base;
+#endif
+#ifdef HAVE_SHAPE
+ int shape_event_base;
+ int shape_error_base;
+#endif
+#ifdef HAVE_RENDER
+ int render_event_base;
+ int render_error_base;
+#endif
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ int composite_event_base;
+ int composite_error_base;
+ int composite_major_version;
+ int composite_minor_version;
+ int damage_event_base;
+ int damage_error_base;
+ int xfixes_event_base;
+ int xfixes_error_base;
+#endif
+#ifdef HAVE_XSYNC
+ unsigned int have_xsync : 1;
+#define META_DISPLAY_HAS_XSYNC(display) ((display)->have_xsync)
+#else
+#define META_DISPLAY_HAS_XSYNC(display) FALSE
+#endif
+#ifdef HAVE_SHAPE
+ unsigned int have_shape : 1;
+#define META_DISPLAY_HAS_SHAPE(display) ((display)->have_shape)
+#else
+#define META_DISPLAY_HAS_SHAPE(display) FALSE
+#endif
+#ifdef HAVE_RENDER
+ unsigned int have_render : 1;
+#define META_DISPLAY_HAS_RENDER(display) ((display)->have_render)
+#else
+#define META_DISPLAY_HAS_RENDER(display) FALSE
+#endif
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ unsigned int have_composite : 1;
+ unsigned int have_damage : 1;
+ unsigned int have_xfixes : 1;
+#define META_DISPLAY_HAS_COMPOSITE(display) ((display)->have_composite)
+#define META_DISPLAY_HAS_DAMAGE(display) ((display)->have_damage)
+#define META_DISPLAY_HAS_XFIXES(display) ((display)->have_xfixes)
+#else
+#define META_DISPLAY_HAS_COMPOSITE(display) FALSE
+#define META_DISPLAY_HAS_DAMAGE(display) FALSE
+#define META_DISPLAY_HAS_XFIXES(display) FALSE
+#endif
+};
+
+/* Xserver time can wraparound, thus comparing two timestamps needs to take
+ * this into account. Here's a little macro to help out. If no wraparound
+ * has occurred, this is equivalent to
+ * time1 < time2
+ * Of course, the rest of the ugliness of this macro comes from accounting
+ * for the fact that wraparound can occur and the fact that a timestamp of
+ * 0 must be special-cased since it means older than anything else.
+ *
+ * Note that this is NOT an equivalent for time1 <= time2; if that's what
+ * you need then you'll need to swap the order of the arguments and negate
+ * the result.
+ */
+#define XSERVER_TIME_IS_BEFORE_ASSUMING_REAL_TIMESTAMPS(time1, time2) \
+ ( (( (time1) < (time2) ) && ( (time2) - (time1) < ((guint32)-1)/2 )) || \
+ (( (time1) > (time2) ) && ( (time1) - (time2) > ((guint32)-1)/2 )) \
+ )
+#define XSERVER_TIME_IS_BEFORE(time1, time2) \
+ ( (time1) == 0 || \
+ (XSERVER_TIME_IS_BEFORE_ASSUMING_REAL_TIMESTAMPS(time1, time2) && \
+ (time2) != 0) \
+ )
+
+gboolean meta_display_open (void);
+void meta_display_close (MetaDisplay *display,
+ guint32 timestamp);
+MetaScreen* meta_display_screen_for_x_screen (MetaDisplay *display,
+ Screen *screen);
+MetaScreen* meta_display_screen_for_xwindow (MetaDisplay *display,
+ Window xindow);
+void meta_display_grab (MetaDisplay *display);
+void meta_display_ungrab (MetaDisplay *display);
+
+void meta_display_unmanage_screen (MetaDisplay *display,
+ MetaScreen *screen,
+ guint32 timestamp);
+
+void meta_display_unmanage_windows_for_screen (MetaDisplay *display,
+ MetaScreen *screen,
+ guint32 timestamp);
+
+/* Utility function to compare the stacking of two windows */
+int meta_display_stack_cmp (const void *a,
+ const void *b);
+
+/* A given MetaWindow may have various X windows that "belong"
+ * to it, such as the frame window.
+ */
+MetaWindow* meta_display_lookup_x_window (MetaDisplay *display,
+ Window xwindow);
+void meta_display_register_x_window (MetaDisplay *display,
+ Window *xwindowp,
+ MetaWindow *window);
+void meta_display_unregister_x_window (MetaDisplay *display,
+ Window xwindow);
+/* Return whether the xwindow is a no focus window for any of the screens */
+gboolean meta_display_xwindow_is_a_no_focus_window (MetaDisplay *display,
+ Window xwindow);
+
+GSList* meta_display_list_windows (MetaDisplay *display);
+
+MetaDisplay* meta_display_for_x_display (Display *xdisplay);
+MetaDisplay* meta_get_display (void);
+
+Cursor meta_display_create_x_cursor (MetaDisplay *display,
+ MetaCursor cursor);
+
+void meta_display_set_grab_op_cursor (MetaDisplay *display,
+ MetaScreen *screen,
+ MetaGrabOp op,
+ gboolean change_pointer,
+ Window grab_xwindow,
+ guint32 timestamp);
+
+gboolean meta_display_begin_grab_op (MetaDisplay *display,
+ MetaScreen *screen,
+ MetaWindow *window,
+ MetaGrabOp op,
+ gboolean pointer_already_grabbed,
+ gboolean frame_action,
+ int button,
+ gulong modmask,
+ guint32 timestamp,
+ int root_x,
+ int root_y);
+void meta_display_end_grab_op (MetaDisplay *display,
+ guint32 timestamp);
+
+void meta_display_check_threshold_reached (MetaDisplay *display,
+ int x,
+ int y);
+void meta_display_grab_window_buttons (MetaDisplay *display,
+ Window xwindow);
+void meta_display_ungrab_window_buttons (MetaDisplay *display,
+ Window xwindow);
+
+void meta_display_grab_focus_window_button (MetaDisplay *display,
+ MetaWindow *window);
+void meta_display_ungrab_focus_window_button (MetaDisplay *display,
+ MetaWindow *window);
+
+/* Next two functions are defined in edge-resistance.c */
+void meta_display_compute_resistance_and_snapping_edges (MetaDisplay *display);
+void meta_display_cleanup_edges (MetaDisplay *display);
+
+/* make a request to ensure the event serial has changed */
+void meta_display_increment_event_serial (MetaDisplay *display);
+
+void meta_display_update_active_window_hint (MetaDisplay *display);
+
+guint32 meta_display_get_current_time (MetaDisplay *display);
+guint32 meta_display_get_current_time_roundtrip (MetaDisplay *display);
+
+/* utility goo */
+const char* meta_event_mode_to_string (int m);
+const char* meta_event_detail_to_string (int d);
+
+void meta_display_queue_retheme_all_windows (MetaDisplay *display);
+void meta_display_retheme_all (void);
+
+void meta_display_set_cursor_theme (const char *theme,
+ int size);
+
+void meta_display_ping_window (MetaDisplay *display,
+ MetaWindow *window,
+ guint32 timestamp,
+ MetaWindowPingFunc ping_reply_func,
+ MetaWindowPingFunc ping_timeout_func,
+ void *user_data);
+gboolean meta_display_window_has_pending_pings (MetaDisplay *display,
+ MetaWindow *window);
+
+typedef enum
+{
+ META_TAB_LIST_NORMAL,
+ META_TAB_LIST_DOCKS,
+ META_TAB_LIST_GROUP
+} MetaTabList;
+
+typedef enum
+{
+ META_TAB_SHOW_ICON, /* Alt-Tab mode */
+ META_TAB_SHOW_INSTANTLY /* Alt-Esc mode */
+} MetaTabShowType;
+
+GList* meta_display_get_tab_list (MetaDisplay *display,
+ MetaTabList type,
+ MetaScreen *screen,
+ MetaWorkspace *workspace);
+
+MetaWindow* meta_display_get_tab_next (MetaDisplay *display,
+ MetaTabList type,
+ MetaScreen *screen,
+ MetaWorkspace *workspace,
+ MetaWindow *window,
+ gboolean backward);
+
+MetaWindow* meta_display_get_tab_current (MetaDisplay *display,
+ MetaTabList type,
+ MetaScreen *screen,
+ MetaWorkspace *workspace);
+
+int meta_resize_gravity_from_grab_op (MetaGrabOp op);
+
+gboolean meta_grab_op_is_moving (MetaGrabOp op);
+gboolean meta_grab_op_is_resizing (MetaGrabOp op);
+
+void meta_display_devirtualize_modifiers (MetaDisplay *display,
+ MetaVirtualModifier modifiers,
+ unsigned int *mask);
+
+void meta_display_increment_focus_sentinel (MetaDisplay *display);
+void meta_display_decrement_focus_sentinel (MetaDisplay *display);
+gboolean meta_display_focus_sentinel_clear (MetaDisplay *display);
+
+/* meta_display_set_input_focus_window is like XSetInputFocus, except
+ * that (a) it can't detect timestamps later than the current time,
+ * since Metacity isn't part of the XServer, and thus gives erroneous
+ * behavior in this circumstance (so don't do it), (b) it uses
+ * display->last_focus_time since we don't have access to the true
+ * Xserver one, (c) it makes use of display->user_time since checking
+ * whether a window should be allowed to be focused should depend
+ * on user_time events (see bug 167358, comment 15 in particular)
+ */
+void meta_display_set_input_focus_window (MetaDisplay *display,
+ MetaWindow *window,
+ gboolean focus_frame,
+ guint32 timestamp);
+
+/* meta_display_focus_the_no_focus_window is called when the
+ * designated no_focus_window should be focused, but is otherwise the
+ * same as meta_display_set_input_focus_window
+ */
+void meta_display_focus_the_no_focus_window (MetaDisplay *display,
+ MetaScreen *screen,
+ guint32 timestamp);
+
+void meta_display_queue_autoraise_callback (MetaDisplay *display,
+ MetaWindow *window);
+void meta_display_remove_autoraise_callback (MetaDisplay *display);
+
+#endif
Modified: trunk/src/core/display.c
==============================================================================
--- trunk/src/core/display.c (original)
+++ trunk/src/core/display.c Mon May 19 00:00:09 2008
@@ -31,14 +31,14 @@
*/
#include <config.h>
-#include "display.h"
+#include "display-private.h"
#include "util.h"
#include "main.h"
-#include "screen.h"
-#include "window.h"
+#include "screen-private.h"
+#include "window-private.h"
#include "window-props.h"
#include "group-props.h"
-#include "frame.h"
+#include "frame-private.h"
#include "errors.h"
#include "keybindings.h"
#include "prefs.h"
@@ -5115,3 +5115,54 @@
display->autoraise_window = NULL;
}
}
+
+void
+meta_display_get_compositor_version (MetaDisplay *display,
+ int *major,
+ int *minor)
+{
+ *major = display->composite_major_version;
+ *minor = display->composite_minor_version;
+}
+
+Display *
+meta_display_get_xdisplay (MetaDisplay *display)
+{
+ return display->xdisplay;
+}
+
+MetaCompositor *
+meta_display_get_compositor (MetaDisplay *display)
+{
+ return display->compositor;
+}
+
+GSList *
+meta_display_get_screens (MetaDisplay *display)
+{
+ return display->screens;
+}
+
+gboolean
+meta_display_has_shape (MetaDisplay *display)
+{
+ return META_DISPLAY_HAS_SHAPE (display);
+}
+
+MetaWindow *
+meta_display_get_focus_window (MetaDisplay *display)
+{
+ return display->focus_window;
+}
+
+int
+meta_display_get_damage_event_base (MetaDisplay *display)
+{
+ return display->damage_event_base;
+}
+
+int
+meta_display_get_shape_event_base (MetaDisplay *display)
+{
+ return display->shape_event_base;
+}
Modified: trunk/src/core/edge-resistance.c
==============================================================================
--- trunk/src/core/edge-resistance.c (original)
+++ trunk/src/core/edge-resistance.c Mon May 19 00:00:09 2008
@@ -21,9 +21,10 @@
* 02111-1307, USA.
*/
+#include <config.h>
#include "edge-resistance.h"
#include "boxes.h"
-#include "display.h"
+#include "display-private.h"
#include "workspace.h"
/* A simple macro for whether a given window's edges are potentially
Modified: trunk/src/core/edge-resistance.h
==============================================================================
--- trunk/src/core/edge-resistance.h (original)
+++ trunk/src/core/edge-resistance.h Mon May 19 00:00:09 2008
@@ -24,7 +24,7 @@
#ifndef META_EDGE_RESISTANCE_H
#define META_EDGE_RESISTANCE_H
-#include "window.h"
+#include "window-private.h"
void meta_window_edge_resistance_for_move (MetaWindow *window,
int old_x,
Modified: trunk/src/core/effects.c
==============================================================================
--- trunk/src/core/effects.c (original)
+++ trunk/src/core/effects.c Mon May 19 00:00:09 2008
@@ -33,9 +33,9 @@
#include <config.h>
#include "effects.h"
-#include "display.h"
+#include "display-private.h"
#include "ui.h"
-#include "window.h"
+#include "window-private.h"
#ifdef HAVE_SHAPE
#include <X11/extensions/shape.h>
Modified: trunk/src/core/effects.h
==============================================================================
--- trunk/src/core/effects.h (original)
+++ trunk/src/core/effects.h Mon May 19 00:00:09 2008
@@ -25,7 +25,7 @@
#define META_EFFECTS_H
#include "util.h"
-#include "screen.h"
+#include "screen-private.h"
typedef struct MetaEffect MetaEffect;
typedef struct MetaEffectPriv MetaEffectPriv;
Modified: trunk/src/core/errors.c
==============================================================================
--- trunk/src/core/errors.c (original)
+++ trunk/src/core/errors.c Mon May 19 00:00:09 2008
@@ -24,6 +24,7 @@
#include <config.h>
#include "errors.h"
+#include "display-private.h"
#include <errno.h>
#include <stdlib.h>
#include <gdk/gdk.h>
Added: trunk/src/core/frame-private.h
==============================================================================
--- (empty file)
+++ trunk/src/core/frame-private.h Mon May 19 00:00:09 2008
@@ -0,0 +1,88 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/* Metacity X window decorations */
+
+/*
+ * 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.
+ */
+
+#ifndef META_FRAME_PRIVATE_H
+#define META_FRAME_PRIVATE_H
+
+#include "frame.h"
+#include "window-private.h"
+
+typedef struct _MetaFrameGeometry MetaFrameGeometry;
+
+struct _MetaFrameGeometry
+{
+ /* border sizes (space between frame and child) */
+ int left_width;
+ int right_width;
+ int top_height;
+ int bottom_height;
+};
+
+struct _MetaFrame
+{
+ /* window we frame */
+ MetaWindow *window;
+
+ /* reparent window */
+ Window xwindow;
+
+ MetaCursor current_cursor;
+
+ /* This rect is trusted info from where we put the
+ * frame, not the result of ConfigureNotify
+ */
+ MetaRectangle rect;
+
+ /* position of client, size of frame */
+ int child_x;
+ int child_y;
+ int right_width;
+ int bottom_height;
+
+ guint mapped : 1;
+ guint need_reapply_frame_shape : 1;
+ guint is_flashing : 1; /* used by the visual bell flash */
+};
+
+void meta_window_ensure_frame (MetaWindow *window);
+void meta_window_destroy_frame (MetaWindow *window);
+void meta_frame_queue_draw (MetaFrame *frame);
+
+MetaFrameFlags meta_frame_get_flags (MetaFrame *frame);
+
+/* These should ONLY be called from meta_window_move_resize_internal */
+void meta_frame_calc_geometry (MetaFrame *frame,
+ MetaFrameGeometry *geomp);
+void meta_frame_sync_to_window (MetaFrame *frame,
+ int gravity,
+ gboolean need_move,
+ gboolean need_resize);
+
+void meta_frame_set_screen_cursor (MetaFrame *frame,
+ MetaCursor cursor);
+
+#endif
+
+
+
+
Modified: trunk/src/core/frame.c
==============================================================================
--- trunk/src/core/frame.c (original)
+++ trunk/src/core/frame.c Mon May 19 00:00:09 2008
@@ -24,7 +24,7 @@
*/
#include <config.h>
-#include "frame.h"
+#include "frame-private.h"
#include "bell.h"
#include "errors.h"
#include "keybindings.h"
@@ -413,3 +413,8 @@
}
}
+Window
+meta_frame_get_xwindow (MetaFrame *frame)
+{
+ return frame->xwindow;
+}
Modified: trunk/src/core/group.h
==============================================================================
--- trunk/src/core/group.h (original)
+++ trunk/src/core/group.h Mon May 19 00:00:09 2008
@@ -24,7 +24,7 @@
#ifndef META_GROUP_H
#define META_GROUP_H
-#include "window.h"
+#include "window-private.h"
/* note, can return NULL */
MetaGroup* meta_window_get_group (MetaWindow *window);
Modified: trunk/src/core/iconcache.h
==============================================================================
--- trunk/src/core/iconcache.h (original)
+++ trunk/src/core/iconcache.h Mon May 19 00:00:09 2008
@@ -24,7 +24,7 @@
#ifndef META_ICON_CACHE_H
#define META_ICON_CACHE_H
-#include "screen.h"
+#include "screen-private.h"
typedef struct _MetaIconCache MetaIconCache;
Modified: trunk/src/core/keybindings.c
==============================================================================
--- trunk/src/core/keybindings.c (original)
+++ trunk/src/core/keybindings.c Mon May 19 00:00:09 2008
@@ -32,7 +32,7 @@
#include "errors.h"
#include "edge-resistance.h"
#include "ui.h"
-#include "frame.h"
+#include "frame-private.h"
#include "place.h"
#include "prefs.h"
#include "effects.h"
Modified: trunk/src/core/keybindings.h
==============================================================================
--- trunk/src/core/keybindings.h (original)
+++ trunk/src/core/keybindings.h Mon May 19 00:00:09 2008
@@ -24,7 +24,7 @@
#ifndef META_KEYBINDINGS_H
#define META_KEYBINDINGS_H
-#include "display.h"
+#include "display-private.h"
#include "window.h"
void meta_display_init_keys (MetaDisplay *display);
Modified: trunk/src/core/main.c
==============================================================================
--- trunk/src/core/main.c (original)
+++ trunk/src/core/main.c Mon May 19 00:00:09 2008
@@ -46,7 +46,7 @@
#include <config.h>
#include "main.h"
#include "util.h"
-#include "display.h"
+#include "display-private.h"
#include "errors.h"
#include "ui.h"
#include "session.h"
Modified: trunk/src/core/place.h
==============================================================================
--- trunk/src/core/place.h (original)
+++ trunk/src/core/place.h Mon May 19 00:00:09 2008
@@ -24,8 +24,8 @@
#ifndef META_PLACE_H
#define META_PLACE_H
-#include "window.h"
-#include "frame.h"
+#include "window-private.h"
+#include "frame-private.h"
void meta_window_place (MetaWindow *window,
MetaFrameGeometry *fgeom,
Added: trunk/src/core/screen-private.h
==============================================================================
--- (empty file)
+++ trunk/src/core/screen-private.h Mon May 19 00:00:09 2008
@@ -0,0 +1,218 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/* Metacity X screen handler */
+
+/*
+ * Copyright (C) 2001 Havoc Pennington
+ * Copyright (C) 2003 Rob Adams
+ * Copyright (C) 2004-2006 Elijah Newren
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef META_SCREEN_PRIVATE_H
+#define META_SCREEN_PRIVATE_H
+
+#include "display-private.h"
+#include "screen.h"
+#include <X11/Xutil.h>
+#include "ui.h"
+
+typedef struct _MetaXineramaScreenInfo MetaXineramaScreenInfo;
+
+struct _MetaXineramaScreenInfo
+{
+ int number;
+ MetaRectangle rect;
+};
+
+typedef void (* MetaScreenWindowFunc) (MetaScreen *screen, MetaWindow *window,
+ gpointer user_data);
+
+typedef enum
+{
+ META_SCREEN_TOPLEFT,
+ META_SCREEN_TOPRIGHT,
+ META_SCREEN_BOTTOMLEFT,
+ META_SCREEN_BOTTOMRIGHT
+} MetaScreenCorner;
+
+typedef enum
+{
+ META_SCREEN_UP,
+ META_SCREEN_DOWN,
+ META_SCREEN_LEFT,
+ META_SCREEN_RIGHT
+} MetaScreenDirection;
+
+#define META_WIREFRAME_XOR_LINE_WIDTH 2
+
+struct _MetaScreen
+{
+ MetaDisplay *display;
+ int number;
+ char *screen_name;
+ Screen *xscreen;
+ Window xroot;
+ int default_depth;
+ Visual *default_xvisual;
+ MetaRectangle rect; /* Size of screen; rect.x & rect.y are always 0 */
+ MetaUI *ui;
+ MetaTabPopup *tab_popup;
+
+ MetaWorkspace *active_workspace;
+
+ /* This window holds the focus when we don't want to focus
+ * any actual clients
+ */
+ Window no_focus_window;
+
+ GList *workspaces;
+
+ MetaStack *stack;
+
+ MetaCursor current_cursor;
+
+ Window flash_window;
+
+ Window wm_sn_selection_window;
+ Atom wm_sn_atom;
+ guint32 wm_sn_timestamp;
+
+ MetaXineramaScreenInfo *xinerama_infos;
+ int n_xinerama_infos;
+
+ /* Cache the current Xinerama */
+ int last_xinerama_index;
+
+#ifdef HAVE_STARTUP_NOTIFICATION
+ SnMonitorContext *sn_context;
+ GSList *startup_sequences;
+ guint startup_sequence_timeout;
+#endif
+
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ Window wm_cm_selection_window;
+#endif
+
+ guint work_area_idle;
+
+ int rows_of_workspaces;
+ int columns_of_workspaces;
+ MetaScreenCorner starting_corner;
+ guint vertical_workspaces : 1;
+
+ guint keys_grabbed : 1;
+ guint all_keys_grabbed : 1;
+
+ int closing;
+
+ /* gc for XOR on root window */
+ GC root_xor_gc;
+
+ /* Managed by compositor.c */
+ gpointer compositor_data;
+};
+
+MetaScreen* meta_screen_new (MetaDisplay *display,
+ int number,
+ guint32 timestamp);
+void meta_screen_free (MetaScreen *screen,
+ guint32 timestamp);
+void meta_screen_manage_all_windows (MetaScreen *screen);
+void meta_screen_foreach_window (MetaScreen *screen,
+ MetaScreenWindowFunc func,
+ gpointer data);
+void meta_screen_queue_frame_redraws (MetaScreen *screen);
+void meta_screen_queue_window_resizes (MetaScreen *screen);
+
+int meta_screen_get_n_workspaces (MetaScreen *screen);
+
+MetaWorkspace* meta_screen_get_workspace_by_index (MetaScreen *screen,
+ int index);
+
+void meta_screen_set_cursor (MetaScreen *screen,
+ MetaCursor cursor);
+void meta_screen_update_cursor (MetaScreen *screen);
+
+void meta_screen_ensure_tab_popup (MetaScreen *screen,
+ MetaTabList list_type,
+ MetaTabShowType show_type);
+void meta_screen_ensure_workspace_popup (MetaScreen *screen);
+
+MetaWindow* meta_screen_get_mouse_window (MetaScreen *screen,
+ MetaWindow *not_this_one);
+
+const MetaXineramaScreenInfo* meta_screen_get_current_xinerama (MetaScreen *screen);
+const MetaXineramaScreenInfo* meta_screen_get_xinerama_for_rect (MetaScreen *screen,
+ MetaRectangle *rect);
+const MetaXineramaScreenInfo* meta_screen_get_xinerama_for_window (MetaScreen *screen,
+ MetaWindow *window);
+
+
+const MetaXineramaScreenInfo* meta_screen_get_xinerama_neighbor (MetaScreen *screen,
+ int which_xinerama,
+ MetaScreenDirection dir);
+void meta_screen_get_natural_xinerama_list (MetaScreen *screen,
+ int** xineramas_list,
+ int* n_xineramas);
+
+void meta_screen_update_workspace_layout (MetaScreen *screen);
+void meta_screen_update_workspace_names (MetaScreen *screen);
+void meta_screen_queue_workarea_recalc (MetaScreen *screen);
+
+Window meta_create_offscreen_window (Display *xdisplay,
+ Window parent,
+ long valuemask);
+
+typedef struct MetaWorkspaceLayout MetaWorkspaceLayout;
+
+struct MetaWorkspaceLayout
+{
+ int rows;
+ int cols;
+ int *grid;
+ int grid_area;
+ int current_row;
+ int current_col;
+};
+
+void meta_screen_calc_workspace_layout (MetaScreen *screen,
+ int num_workspaces,
+ int current_space,
+ MetaWorkspaceLayout *layout);
+void meta_screen_free_workspace_layout (MetaWorkspaceLayout *layout);
+
+void meta_screen_resize (MetaScreen *screen,
+ int width,
+ int height);
+
+void meta_screen_minimize_all_on_active_workspace_except (MetaScreen *screen,
+ MetaWindow *keep);
+
+/* Show/hide the desktop (temporarily hide all windows) */
+void meta_screen_show_desktop (MetaScreen *screen,
+ guint32 timestamp);
+void meta_screen_unshow_desktop (MetaScreen *screen);
+
+/* Update whether the destkop is being shown for the current active_workspace */
+void meta_screen_update_showing_desktop_hint (MetaScreen *screen);
+
+gboolean meta_screen_apply_startup_properties (MetaScreen *screen,
+ MetaWindow *window);
+void meta_screen_composite_all_windows (MetaScreen *screen);
+
+#endif
Modified: trunk/src/core/screen.c
==============================================================================
--- trunk/src/core/screen.c (original)
+++ trunk/src/core/screen.c Mon May 19 00:00:09 2008
@@ -27,11 +27,11 @@
*/
#include <config.h>
-#include "screen.h"
+#include "screen-private.h"
#include "util.h"
#include "errors.h"
-#include "window.h"
-#include "frame.h"
+#include "window-private.h"
+#include "frame-private.h"
#include "prefs.h"
#include "workspace.h"
#include "keybindings.h"
@@ -2735,6 +2735,46 @@
return FALSE;
}
+int
+meta_screen_get_screen_number (MetaScreen *screen)
+{
+ return screen->number;
+}
+
+MetaDisplay *
+meta_screen_get_display (MetaScreen *screen)
+{
+ return screen->display;
+}
+
+Window
+meta_screen_get_xroot (MetaScreen *screen)
+{
+ return screen->xroot;
+}
+
+void
+meta_screen_get_size (MetaScreen *screen,
+ int *width,
+ int *height)
+{
+ *width = screen->rect.width;
+ *height = screen->rect.height;
+}
+
+gpointer
+meta_screen_get_compositor_data (MetaScreen *screen)
+{
+ return screen->compositor_data;
+}
+
+void
+meta_screen_set_compositor_data (MetaScreen *screen,
+ gpointer compositor)
+{
+ screen->compositor_data = compositor;
+}
+
#ifdef HAVE_COMPOSITE_EXTENSIONS
void
meta_screen_set_cm_selection (MetaScreen *screen)
Modified: trunk/src/core/session.c
==============================================================================
--- trunk/src/core/session.c (original)
+++ trunk/src/core/session.c Mon May 19 00:00:09 2008
@@ -70,7 +70,7 @@
#include <stdio.h>
#include "main.h"
#include "util.h"
-#include "display.h"
+#include "display-private.h"
#include "workspace.h"
static void ice_io_error_handler (IceConn connection);
Modified: trunk/src/core/session.h
==============================================================================
--- trunk/src/core/session.h (original)
+++ trunk/src/core/session.h Mon May 19 00:00:09 2008
@@ -24,7 +24,7 @@
#ifndef META_SESSION_H
#define META_SESSION_H
-#include "window.h"
+#include "window-private.h"
typedef struct _MetaWindowSessionInfo MetaWindowSessionInfo;
Modified: trunk/src/core/stack.c
==============================================================================
--- trunk/src/core/stack.c (original)
+++ trunk/src/core/stack.c Mon May 19 00:00:09 2008
@@ -26,9 +26,9 @@
#include <config.h>
#include "stack.h"
-#include "window.h"
+#include "window-private.h"
#include "errors.h"
-#include "frame.h"
+#include "frame-private.h"
#include "group.h"
#include "prefs.h"
#include "workspace.h"
Modified: trunk/src/core/stack.h
==============================================================================
--- trunk/src/core/stack.h (original)
+++ trunk/src/core/stack.h Mon May 19 00:00:09 2008
@@ -25,7 +25,7 @@
#ifndef META_STACK_H
#define META_STACK_H
-#include "screen.h"
+#include "screen-private.h"
/* Layers vs. stack positions
* ==========================
Added: trunk/src/core/window-private.h
==============================================================================
--- (empty file)
+++ trunk/src/core/window-private.h Mon May 19 00:00:09 2008
@@ -0,0 +1,614 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/* Metacity X managed windows */
+
+/*
+ * Copyright (C) 2001 Havoc Pennington
+ * Copyright (C) 2002 Red Hat, Inc.
+ * Copyright (C) 2003, 2004 Rob Adams
+ * Copyright (C) 2004-2006 Elijah Newren
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef META_WINDOW_PRIVATE_H
+#define META_WINDOW_PRIVATE_H
+
+#include <config.h>
+#include "window.h"
+#include "screen-private.h"
+#include "util.h"
+#include "stack.h"
+#include "iconcache.h"
+#include <X11/Xutil.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+typedef struct _MetaGroup MetaGroup;
+typedef struct _MetaWindowQueue MetaWindowQueue;
+
+typedef gboolean (*MetaWindowForeachFunc) (MetaWindow *window,
+ void *data);
+
+typedef enum
+{
+ META_WINDOW_NORMAL,
+ META_WINDOW_DESKTOP,
+ META_WINDOW_DOCK,
+ META_WINDOW_DIALOG,
+ META_WINDOW_MODAL_DIALOG,
+ META_WINDOW_TOOLBAR,
+ META_WINDOW_MENU,
+ META_WINDOW_UTILITY,
+ META_WINDOW_SPLASHSCREEN
+} MetaWindowType;
+
+typedef enum
+{
+ META_MAXIMIZE_HORIZONTAL = 1 << 0,
+ META_MAXIMIZE_VERTICAL = 1 << 1
+} MetaMaximizeFlags;
+
+typedef enum {
+ META_CLIENT_TYPE_UNKNOWN = 0,
+ META_CLIENT_TYPE_APPLICATION = 1,
+ META_CLIENT_TYPE_PAGER = 2,
+ META_CLIENT_TYPE_MAX_RECOGNIZED = 2
+} MetaClientType;
+
+typedef enum {
+ META_QUEUE_CALC_SHOWING = 1 << 0,
+ META_QUEUE_MOVE_RESIZE = 1 << 1,
+ META_QUEUE_UPDATE_ICON = 1 << 2,
+} MetaQueueType;
+
+#define NUMBER_OF_QUEUES 3
+
+struct _MetaWindow
+{
+ MetaDisplay *display;
+ MetaScreen *screen;
+ MetaWorkspace *workspace;
+ Window xwindow;
+ /* may be NULL! not all windows get decorated */
+ MetaFrame *frame;
+ int depth;
+ Visual *xvisual;
+ Colormap colormap;
+ char *desc; /* used in debug spew */
+ char *title;
+
+ char *icon_name;
+ GdkPixbuf *icon;
+ GdkPixbuf *mini_icon;
+ MetaIconCache icon_cache;
+ Pixmap wm_hints_pixmap;
+ Pixmap wm_hints_mask;
+
+ MetaWindowType type;
+ Atom type_atom;
+
+ /* NOTE these five are not in UTF-8, we just treat them as random
+ * binary data
+ */
+ char *res_class;
+ char *res_name;
+ char *role;
+ char *sm_client_id;
+ char *wm_client_machine;
+ char *startup_id;
+
+ int net_wm_pid;
+
+ Window xtransient_for;
+ Window xgroup_leader;
+ Window xclient_leader;
+
+ /* Initial workspace property */
+ int initial_workspace;
+
+ /* Initial timestamp property */
+ guint32 initial_timestamp;
+
+ /* Whether we're maximized */
+ guint maximized_horizontally : 1;
+ guint maximized_vertically : 1;
+
+ /* Whether we have to maximize/minimize after placement */
+ guint maximize_horizontally_after_placement : 1;
+ guint maximize_vertically_after_placement : 1;
+ guint minimize_after_placement : 1;
+
+ /* Whether we're shaded */
+ guint shaded : 1;
+
+ /* Whether we're fullscreen */
+ guint fullscreen : 1;
+
+ /* Whether we're trying to constrain the window to be fully onscreen */
+ guint require_fully_onscreen : 1;
+
+ /* Whether we're trying to constrain the window to be on a single xinerama */
+ guint require_on_single_xinerama : 1;
+
+ /* Whether we're trying to constrain the window's titlebar to be onscreen */
+ guint require_titlebar_visible : 1;
+
+ /* Whether we're sticky in the multi-workspace sense
+ * (vs. the not-scroll-with-viewport sense, we don't
+ * have no stupid viewports)
+ */
+ guint on_all_workspaces : 1;
+
+ /* Minimize is the state controlled by the minimize button */
+ guint minimized : 1;
+ guint was_minimized : 1;
+ guint tab_unminimized : 1;
+
+ /* Whether the window is mapped; actual server-side state
+ * see also unmaps_pending
+ */
+ guint mapped : 1;
+
+ /* Iconic is the state in WM_STATE; happens for workspaces/shading
+ * in addition to minimize
+ */
+ guint iconic : 1;
+ /* initially_iconic is the WM_HINTS setting when we first manage
+ * the window. It's taken to mean initially minimized.
+ */
+ guint initially_iconic : 1;
+
+ /* whether an initial workspace was explicitly set */
+ guint initial_workspace_set : 1;
+
+ /* whether an initial timestamp was explicitly set */
+ guint initial_timestamp_set : 1;
+
+ /* whether net_wm_user_time has been set yet */
+ guint net_wm_user_time_set : 1;
+
+ /* These are the flags from WM_PROTOCOLS */
+ guint take_focus : 1;
+ guint delete_window : 1;
+ guint net_wm_ping : 1;
+ /* Globally active / No input */
+ guint input : 1;
+
+ /* MWM hints about features of window */
+ guint mwm_decorated : 1;
+ guint mwm_border_only : 1;
+ guint mwm_has_close_func : 1;
+ guint mwm_has_minimize_func : 1;
+ guint mwm_has_maximize_func : 1;
+ guint mwm_has_move_func : 1;
+ guint mwm_has_resize_func : 1;
+
+ /* Computed features of window */
+ guint decorated : 1;
+ guint border_only : 1;
+ guint always_sticky : 1;
+ guint has_close_func : 1;
+ guint has_minimize_func : 1;
+ guint has_maximize_func : 1;
+ guint has_shade_func : 1;
+ guint has_move_func : 1;
+ guint has_resize_func : 1;
+ guint has_fullscreen_func : 1;
+
+ /* Weird "_NET_WM_STATE_MODAL" flag */
+ guint wm_state_modal : 1;
+
+ /* TRUE if the client forced these on */
+ guint wm_state_skip_taskbar : 1;
+ guint wm_state_skip_pager : 1;
+
+ /* Computed whether to skip taskbar or not */
+ guint skip_taskbar : 1;
+ guint skip_pager : 1;
+
+ /* TRUE if client set these */
+ guint wm_state_above : 1;
+ guint wm_state_below : 1;
+
+ /* EWHH demands attention flag */
+ guint wm_state_demands_attention : 1;
+
+ /* this flag tracks receipt of focus_in focus_out and
+ * determines whether we draw the focus
+ */
+ guint has_focus : 1;
+
+ /* Have we placed this window? */
+ guint placed : 1;
+
+ /* Is this not a transient of the focus window which is being denied focus? */
+ guint denied_focus_and_not_transient : 1;
+
+ /* Has this window not ever been shown yet? */
+ guint showing_for_first_time : 1;
+
+ /* Are we in meta_window_free()? */
+ guint unmanaging : 1;
+
+ /* Are we in meta_window_new()? */
+ guint constructing : 1;
+
+ /* Are we in the various queues? (Bitfield: see META_WINDOW_IS_IN_QUEUE) */
+ guint is_in_queues : NUMBER_OF_QUEUES;
+
+ /* Used by keybindings.c */
+ guint keys_grabbed : 1; /* normal keybindings grabbed */
+ guint grab_on_frame : 1; /* grabs are on the frame */
+ guint all_keys_grabbed : 1; /* AnyKey grabbed */
+
+ /* Set if the reason for unmanaging the window is that
+ * it was withdrawn
+ */
+ guint withdrawn : 1;
+
+ /* TRUE if constrain_position should calc placement.
+ * only relevant if !window->placed
+ */
+ guint calc_placement : 1;
+
+ /* Transient parent is a root window */
+ guint transient_parent_is_root_window : 1;
+
+ /* Info on which props we got our attributes from */
+ guint using_net_wm_name : 1; /* vs. plain wm_name */
+ guint using_net_wm_visible_name : 1; /* tracked so we can clear it */
+ guint using_net_wm_icon_name : 1; /* vs. plain wm_icon_name */
+ guint using_net_wm_visible_icon_name : 1; /* tracked so we can clear it */
+
+ /* has a shape mask */
+ guint has_shape : 1;
+
+ /* icon props have changed */
+ guint need_reread_icon : 1;
+
+ /* if TRUE, window was maximized at start of current grab op */
+ guint shaken_loose : 1;
+
+ /* if TRUE we have a grab on the focus click buttons */
+ guint have_focus_click_grab : 1;
+
+ /* if TRUE, application is buggy and SYNC resizing is turned off */
+ guint disable_sync : 1;
+
+ /* Note: can be NULL */
+ GSList *struts;
+
+#ifdef HAVE_XSYNC
+ /* XSync update counter */
+ XSyncCounter sync_request_counter;
+ guint sync_request_serial;
+ GTimeVal sync_request_time;
+#endif
+
+ /* Number of UnmapNotify that are caused by us, if
+ * we get UnmapNotify with none pending then the client
+ * is withdrawing the window.
+ */
+ int unmaps_pending;
+
+ /* set to the most recent user-interaction event timestamp that we
+ know about for this window */
+ guint32 net_wm_user_time;
+
+ /* window that gets updated net_wm_user_time values */
+ Window user_time_window;
+
+ /* The size we set the window to last (i.e. what we believe
+ * to be its actual size on the server). The x, y are
+ * the actual server-side x,y so are relative to the frame
+ * (meaning that they just hold the frame width and height)
+ * or the root window (meaning they specify the location
+ * of the top left of the inner window) as appropriate.
+ */
+ MetaRectangle rect;
+
+ /* 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
+ * of the client window (i.e. ignoring the frame).
+ */
+ MetaRectangle saved_rect;
+
+ /* This is the geometry the window had after the last user-initiated
+ * move/resize operations. We use this whenever we are moving the
+ * implicitly (for example, if we move to avoid a panel, we can snap
+ * back to this position if the panel moves again). Note that this
+ * gives the position and size of the client window (i.e. ignoring
+ * the frame).
+ *
+ * Position valid if user_has_moved, size valid if user_has_resized
+ *
+ * Position always in root coords, unlike window->rect.
+ */
+ MetaRectangle user_rect;
+
+ /* Requested geometry */
+ int border_width;
+ /* x/y/w/h here get filled with ConfigureRequest values */
+ XSizeHints size_hints;
+
+ /* Managed by stack.c */
+ MetaStackLayer layer;
+ int stack_position; /* see comment in stack.h */
+
+ /* Current dialog open for this window */
+ int dialog_pid;
+ int dialog_pipe;
+
+ /* maintained by group.c */
+ MetaGroup *group;
+};
+
+/* These differ from window->has_foo_func in that they consider
+ * the dynamic window state such as "maximized", not just the
+ * window's type
+ */
+#define META_WINDOW_MAXIMIZED(w) ((w)->maximized_horizontally && \
+ (w)->maximized_vertically)
+#define META_WINDOW_MAXIMIZED_VERTICALLY(w) ((w)->maximized_vertically)
+#define META_WINDOW_MAXIMIZED_HORIZONTALLY(w) ((w)->maximized_horizontally)
+#define META_WINDOW_ALLOWS_MOVE(w) ((w)->has_move_func && !(w)->fullscreen)
+#define META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS(w) ((w)->has_resize_func && !META_WINDOW_MAXIMIZED (w) && !(w)->fullscreen && !(w)->shaded)
+#define META_WINDOW_ALLOWS_RESIZE(w) (META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS (w) && \
+ (((w)->size_hints.min_width < (w)->size_hints.max_width) || \
+ ((w)->size_hints.min_height < (w)->size_hints.max_height)))
+#define META_WINDOW_ALLOWS_HORIZONTAL_RESIZE(w) (META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS (w) && (w)->size_hints.min_width < (w)->size_hints.max_width)
+#define META_WINDOW_ALLOWS_VERTICAL_RESIZE(w) (META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS (w) && (w)->size_hints.min_height < (w)->size_hints.max_height)
+
+MetaWindow* meta_window_new (MetaDisplay *display,
+ Window xwindow,
+ gboolean must_be_viewable);
+MetaWindow* meta_window_new_with_attrs (MetaDisplay *display,
+ Window xwindow,
+ gboolean must_be_viewable,
+ XWindowAttributes *attrs);
+void meta_window_free (MetaWindow *window,
+ guint32 timestamp);
+void meta_window_calc_showing (MetaWindow *window);
+void meta_window_queue (MetaWindow *window,
+ guint queuebits);
+void meta_window_minimize (MetaWindow *window);
+void meta_window_unminimize (MetaWindow *window);
+void meta_window_maximize (MetaWindow *window,
+ MetaMaximizeFlags directions);
+void meta_window_maximize_internal (MetaWindow *window,
+ MetaMaximizeFlags directions,
+ MetaRectangle *saved_rect);
+void meta_window_unmaximize (MetaWindow *window,
+ MetaMaximizeFlags directions);
+void meta_window_make_above (MetaWindow *window);
+void meta_window_unmake_above (MetaWindow *window);
+void meta_window_shade (MetaWindow *window,
+ guint32 timestamp);
+void meta_window_unshade (MetaWindow *window,
+ guint32 timestamp);
+void meta_window_change_workspace (MetaWindow *window,
+ MetaWorkspace *workspace);
+void meta_window_stick (MetaWindow *window);
+void meta_window_unstick (MetaWindow *window);
+
+void meta_window_activate (MetaWindow *window,
+ guint32 current_time);
+void meta_window_activate_with_workspace (MetaWindow *window,
+ guint32 current_time,
+ MetaWorkspace *workspace);
+void meta_window_make_fullscreen_internal (MetaWindow *window);
+void meta_window_make_fullscreen (MetaWindow *window);
+void meta_window_unmake_fullscreen (MetaWindow *window);
+
+/* args to move are window pos, not frame pos */
+void meta_window_move (MetaWindow *window,
+ gboolean user_op,
+ int root_x_nw,
+ int root_y_nw);
+void meta_window_resize (MetaWindow *window,
+ gboolean user_op,
+ int w,
+ int h);
+void meta_window_move_resize (MetaWindow *window,
+ gboolean user_op,
+ int root_x_nw,
+ int root_y_nw,
+ int w,
+ int h);
+void meta_window_resize_with_gravity (MetaWindow *window,
+ gboolean user_op,
+ int w,
+ int h,
+ int gravity);
+
+
+/* Return whether the window would be showing if we were on its workspace */
+gboolean meta_window_showing_on_its_workspace (MetaWindow *window);
+
+/* Return whether the window should be currently mapped */
+gboolean meta_window_should_be_showing (MetaWindow *window);
+
+/* See warning in window.c about this function */
+gboolean __window_is_terminal (MetaWindow *window);
+
+void meta_window_update_struts (MetaWindow *window);
+
+/* this gets root coords */
+void meta_window_get_position (MetaWindow *window,
+ int *x,
+ int *y);
+
+/* Gets root coords for x, y, width & height of client window; uses
+ * meta_window_get_position for x & y.
+ */
+void meta_window_get_client_root_coords (MetaWindow *window,
+ MetaRectangle *rect);
+
+/* gets position we need to set to stay in current position,
+ * assuming position will be gravity-compensated. i.e.
+ * this is the position a client would send in a configure
+ * request.
+ */
+void meta_window_get_gravity_position (MetaWindow *window,
+ int gravity,
+ int *x,
+ int *y);
+/* Get geometry for saving in the session; x/y are gravity
+ * position, and w/h are in resize inc above the base size.
+ */
+void meta_window_get_geometry (MetaWindow *window,
+ int *x,
+ int *y,
+ int *width,
+ int *height);
+void meta_window_get_outer_rect (const MetaWindow *window,
+ MetaRectangle *rect);
+void meta_window_get_xor_rect (MetaWindow *window,
+ const MetaRectangle *grab_wireframe_rect,
+ MetaRectangle *xor_rect);
+void meta_window_begin_wireframe (MetaWindow *window);
+void meta_window_update_wireframe (MetaWindow *window,
+ int x,
+ int y,
+ int width,
+ int height);
+void meta_window_end_wireframe (MetaWindow *window);
+
+void meta_window_delete (MetaWindow *window,
+ guint32 timestamp);
+void meta_window_kill (MetaWindow *window);
+void meta_window_focus (MetaWindow *window,
+ guint32 timestamp);
+void meta_window_raise (MetaWindow *window);
+void meta_window_lower (MetaWindow *window);
+
+void meta_window_update_unfocused_button_grabs (MetaWindow *window);
+
+/* Sends a client message */
+void meta_window_send_icccm_message (MetaWindow *window,
+ Atom atom,
+ guint32 timestamp);
+
+
+void meta_window_move_resize_request(MetaWindow *window,
+ guint value_mask,
+ int gravity,
+ int x,
+ int y,
+ int width,
+ int height);
+gboolean meta_window_configure_request (MetaWindow *window,
+ XEvent *event);
+gboolean meta_window_property_notify (MetaWindow *window,
+ XEvent *event);
+gboolean meta_window_client_message (MetaWindow *window,
+ XEvent *event);
+gboolean meta_window_notify_focus (MetaWindow *window,
+ XEvent *event);
+
+void meta_window_set_current_workspace_hint (MetaWindow *window);
+
+unsigned long meta_window_get_net_wm_desktop (MetaWindow *window);
+
+void meta_window_show_menu (MetaWindow *window,
+ int root_x,
+ int root_y,
+ int button,
+ guint32 timestamp);
+
+gboolean meta_window_titlebar_is_onscreen (MetaWindow *window);
+void meta_window_shove_titlebar_onscreen (MetaWindow *window);
+
+void meta_window_set_gravity (MetaWindow *window,
+ int gravity);
+
+void meta_window_handle_mouse_grab_op_event (MetaWindow *window,
+ XEvent *event);
+
+GList* meta_window_get_workspaces (MetaWindow *window);
+
+gboolean meta_window_located_on_workspace (MetaWindow *window,
+ MetaWorkspace *workspace);
+
+void meta_window_get_work_area_current_xinerama (MetaWindow *window,
+ MetaRectangle *area);
+void meta_window_get_work_area_for_xinerama (MetaWindow *window,
+ int which_xinerama,
+ MetaRectangle *area);
+void meta_window_get_work_area_all_xineramas (MetaWindow *window,
+ MetaRectangle *area);
+
+
+gboolean meta_window_same_application (MetaWindow *window,
+ MetaWindow *other_window);
+
+#define META_WINDOW_IN_NORMAL_TAB_CHAIN_TYPE(w) \
+ ((w)->type != META_WINDOW_DOCK && (w)->type != META_WINDOW_DESKTOP)
+#define META_WINDOW_IN_NORMAL_TAB_CHAIN(w) \
+ (((w)->input || (w)->take_focus ) && META_WINDOW_IN_NORMAL_TAB_CHAIN_TYPE (w) && (!(w)->skip_taskbar))
+#define META_WINDOW_IN_DOCK_TAB_CHAIN(w) \
+ (((w)->input || (w)->take_focus) && (! META_WINDOW_IN_NORMAL_TAB_CHAIN_TYPE (w) || (w)->skip_taskbar))
+#define META_WINDOW_IN_GROUP_TAB_CHAIN(w, g) \
+ (((w)->input || (w)->take_focus) && (!g || meta_window_get_group(w)==g))
+
+void meta_window_refresh_resize_popup (MetaWindow *window);
+
+void meta_window_free_delete_dialog (MetaWindow *window);
+
+void meta_window_foreach_transient (MetaWindow *window,
+ MetaWindowForeachFunc func,
+ void *data);
+gboolean meta_window_is_ancestor_of_transient (MetaWindow *window,
+ MetaWindow *transient);
+void meta_window_foreach_ancestor (MetaWindow *window,
+ MetaWindowForeachFunc func,
+ void *data);
+MetaWindow* meta_window_find_root_ancestor (MetaWindow *window);
+
+
+void meta_window_begin_grab_op (MetaWindow *window,
+ MetaGrabOp op,
+ gboolean frame_action,
+ guint32 timestamp);
+
+void meta_window_update_keyboard_resize (MetaWindow *window,
+ gboolean update_cursor);
+void meta_window_update_keyboard_move (MetaWindow *window);
+
+void meta_window_update_layer (MetaWindow *window);
+
+gboolean meta_window_get_icon_geometry (MetaWindow *window,
+ MetaRectangle *rect);
+
+const char* meta_window_get_startup_id (MetaWindow *window);
+
+void meta_window_recalc_features (MetaWindow *window);
+void meta_window_recalc_window_type (MetaWindow *window);
+
+void meta_window_stack_just_below (MetaWindow *window,
+ MetaWindow *below_this_one);
+
+void meta_window_set_user_time (MetaWindow *window,
+ guint32 timestamp);
+
+void meta_window_set_demands_attention (MetaWindow *window);
+
+void meta_window_unset_demands_attention (MetaWindow *window);
+
+void meta_window_update_icon_now (MetaWindow *window);
+
+#endif
Modified: trunk/src/core/window-props.c
==============================================================================
--- trunk/src/core/window-props.c (original)
+++ trunk/src/core/window-props.c Mon May 19 00:00:09 2008
@@ -29,7 +29,7 @@
#include "window-props.h"
#include "errors.h"
#include "xprops.h"
-#include "frame.h"
+#include "frame-private.h"
#include "group.h"
#include <X11/Xatom.h>
#include <unistd.h>
Modified: trunk/src/core/window-props.h
==============================================================================
--- trunk/src/core/window-props.h (original)
+++ trunk/src/core/window-props.h Mon May 19 00:00:09 2008
@@ -24,7 +24,7 @@
#ifndef META_WINDOW_PROPS_H
#define META_WINDOW_PROPS_H
-#include "window.h"
+#include "window-private.h"
void meta_window_reload_property (MetaWindow *window,
Atom property);
Modified: trunk/src/core/window.c
==============================================================================
--- trunk/src/core/window.c (original)
+++ trunk/src/core/window.c Mon May 19 00:00:09 2008
@@ -25,10 +25,10 @@
*/
#include <config.h>
-#include "window.h"
+#include "window-private.h"
#include "edge-resistance.h"
#include "util.h"
-#include "frame.h"
+#include "frame-private.h"
#include "errors.h"
#include "workspace.h"
#include "stack.h"
@@ -8132,3 +8132,45 @@
window->wm_state_demands_attention = FALSE;
set_net_wm_state (window);
}
+
+MetaFrame *
+meta_window_get_frame (MetaWindow *window)
+{
+ return window->frame;
+}
+
+gboolean
+meta_window_has_focus (MetaWindow *window)
+{
+ return window->has_focus;
+}
+
+gboolean
+meta_window_is_shaded (MetaWindow *window)
+{
+ return window->shaded;
+}
+
+MetaRectangle *
+meta_window_get_rect (MetaWindow *window)
+{
+ return &window->rect;
+}
+
+MetaScreen *
+meta_window_get_screen (MetaWindow *window)
+{
+ return window->screen;
+}
+
+MetaDisplay *
+meta_window_get_display (MetaWindow *window)
+{
+ return window->display;
+}
+
+Window
+meta_window_get_xwindow (MetaWindow *window)
+{
+ return window->xwindow;
+}
Modified: trunk/src/core/workspace.h
==============================================================================
--- trunk/src/core/workspace.h (original)
+++ trunk/src/core/workspace.h Mon May 19 00:00:09 2008
@@ -25,7 +25,7 @@
#ifndef META_WORKSPACE_H
#define META_WORKSPACE_H
-#include "window.h"
+#include "window-private.h"
/* Negative to avoid conflicting with real workspace
* numbers
Modified: trunk/src/core/xprops.c
==============================================================================
--- trunk/src/core/xprops.c (original)
+++ trunk/src/core/xprops.c Mon May 19 00:00:09 2008
@@ -89,7 +89,7 @@
#include "metacity-Xatomtype.h"
#include <X11/Xatom.h>
#include <string.h>
-#include "window.h"
+#include "window-private.h"
typedef struct
{
Added: trunk/src/include/compositor.h
==============================================================================
--- (empty file)
+++ trunk/src/include/compositor.h Mon May 19 00:00:09 2008
@@ -0,0 +1,76 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2008 Iain Holmes
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef META_COMPOSITOR_H
+#define META_COMPOSITOR_H
+
+#include <glib.h>
+#include <X11/Xlib.h>
+
+#include "types.h"
+#include "boxes.h"
+
+MetaCompositor *meta_compositor_new (MetaDisplay *display);
+void meta_compositor_destroy (MetaCompositor *compositor);
+
+void meta_compositor_manage_screen (MetaCompositor *compositor,
+ MetaScreen *screen);
+void meta_compositor_unmanage_screen (MetaCompositor *compositor,
+ MetaScreen *screen);
+
+void meta_compositor_add_window (MetaCompositor *compositor,
+ MetaWindow *window,
+ Window xwindow,
+ XWindowAttributes *attrs);
+void meta_compositor_remove_window (MetaCompositor *compositor,
+ Window xwindow);
+
+void meta_compositor_set_updates (MetaCompositor *compositor,
+ MetaWindow *window,
+ gboolean updates);
+
+void meta_compositor_process_event (MetaCompositor *compositor,
+ XEvent *event,
+ MetaWindow *window);
+Pixmap meta_compositor_get_window_pixmap (MetaCompositor *compositor,
+ MetaWindow *window);
+void meta_compositor_set_active_window (MetaCompositor *compositor,
+ MetaScreen *screen,
+ MetaWindow *window);
+
+void meta_compositor_begin_move (MetaCompositor *compositor,
+ MetaWindow *window,
+ MetaRectangle *initial,
+ int grab_x, int grab_y);
+void meta_compositor_update_move (MetaCompositor *compositor,
+ MetaWindow *window,
+ int x, int y);
+void meta_compositor_end_move (MetaCompositor *compositor,
+ MetaWindow *window);
+void meta_compositor_free_window (MetaCompositor *compositor,
+ MetaWindow *window);
+
+#endif
+
+
+
+
+
Added: trunk/src/include/display.h
==============================================================================
--- (empty file)
+++ trunk/src/include/display.h Mon May 19 00:00:09 2008
@@ -0,0 +1,48 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2008 Iain Holmes
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef META_DISPLAY_H
+#define META_DISPLAY_H
+
+#include <glib.h>
+#include <X11/Xlib.h>
+
+#include "types.h"
+
+#define meta_XFree(p) do { if ((p)) XFree ((p)); } while (0)
+
+void meta_display_get_compositor_version (MetaDisplay *display,
+ int *major,
+ int *minor);
+Display *meta_display_get_xdisplay (MetaDisplay *display);
+MetaCompositor *meta_display_get_compositor (MetaDisplay *display);
+GSList *meta_display_get_screens (MetaDisplay *display);
+
+gboolean meta_display_has_shape (MetaDisplay *display);
+
+MetaScreen *meta_display_screen_for_root (MetaDisplay *display,
+ Window xroot);
+MetaWindow *meta_display_get_focus_window (MetaDisplay *display);
+
+int meta_display_get_damage_event_base (MetaDisplay *display);
+int meta_display_get_shape_event_base (MetaDisplay *display);
+
+#endif
Added: trunk/src/include/errors.h
==============================================================================
--- (empty file)
+++ trunk/src/include/errors.h Mon May 19 00:00:09 2008
@@ -0,0 +1,51 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/* Metacity X error handling */
+
+/*
+ * 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.
+ */
+
+#ifndef META_ERRORS_H
+#define META_ERRORS_H
+
+#include <X11/Xlib.h>
+
+#include "util.h"
+#include "display.h"
+
+typedef void (* ErrorHandler) (Display *dpy,
+ XErrorEvent *error,
+ gpointer data);
+
+void meta_errors_init (void);
+void meta_errors_register_foreign_display (Display *foreign_dpy,
+ ErrorHandler handler,
+ gpointer data);
+
+void meta_error_trap_push (MetaDisplay *display);
+void meta_error_trap_pop (MetaDisplay *display,
+ gboolean last_request_was_roundtrip);
+
+void meta_error_trap_push_with_return (MetaDisplay *display);
+/* returns X error code, or 0 for no error */
+int meta_error_trap_pop_with_return (MetaDisplay *display,
+ gboolean last_request_was_roundtrip);
+
+
+#endif
Added: trunk/src/include/frame.h
==============================================================================
--- (empty file)
+++ trunk/src/include/frame.h Mon May 19 00:00:09 2008
@@ -0,0 +1,31 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2008 Iain Holmes
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef META_FRAME_H
+#define META_FRAME_H
+
+#include <X11/Xlib.h>
+
+#include "types.h"
+
+Window meta_frame_get_xwindow (MetaFrame *frame);
+
+#endif
Added: trunk/src/include/screen.h
==============================================================================
--- (empty file)
+++ trunk/src/include/screen.h Mon May 19 00:00:09 2008
@@ -0,0 +1,48 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2008 Iain Holmes
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef META_SCREEN_H
+#define META_SCREEN_H
+
+#include <X11/Xlib.h>
+#include <glib.h>
+#include "types.h"
+
+int meta_screen_get_screen_number (MetaScreen *screen);
+MetaDisplay *meta_screen_get_display (MetaScreen *screen);
+
+Window meta_screen_get_xroot (MetaScreen *screen);
+void meta_screen_get_size (MetaScreen *screen,
+ int *width,
+ int *height);
+
+gpointer meta_screen_get_compositor_data (MetaScreen *screen);
+void meta_screen_set_compositor_data (MetaScreen *screen,
+ gpointer info);
+
+MetaScreen *meta_screen_for_x_screen (Screen *xscreen);
+
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+void meta_screen_set_cm_selection (MetaScreen *screen);
+void meta_screen_unset_cm_selection (MetaScreen *screen);
+#endif
+
+#endif
Added: trunk/src/include/types.h
==============================================================================
--- (empty file)
+++ trunk/src/include/types.h Mon May 19 00:00:09 2008
@@ -0,0 +1,31 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2008 Iain Holmes
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef META_TYPES_H
+#define META_TYPES_H
+
+typedef struct _MetaCompositor MetaCompositor;
+typedef struct _MetaDisplay MetaDisplay;
+typedef struct _MetaFrame MetaFrame;
+typedef struct _MetaScreen MetaScreen;
+typedef struct _MetaWindow MetaWindow;
+
+#endif
Added: trunk/src/include/window.h
==============================================================================
--- (empty file)
+++ trunk/src/include/window.h Mon May 19 00:00:09 2008
@@ -0,0 +1,39 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/*
+ * Copyright (C) 2008 Iain Holmes
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef META_WINDOW_H
+#define META_WINDOW_H
+
+#include <glib.h>
+#include <X11/Xlib.h>
+
+#include "boxes.h"
+#include "types.h"
+
+MetaFrame *meta_window_get_frame (MetaWindow *window);
+gboolean meta_window_has_focus (MetaWindow *window);
+gboolean meta_window_is_shaded (MetaWindow *window);
+MetaRectangle *meta_window_get_rect (MetaWindow *window);
+MetaScreen *meta_window_get_screen (MetaWindow *window);
+MetaDisplay *meta_window_get_display (MetaWindow *window);
+Window meta_window_get_xwindow (MetaWindow *window);
+
+#endif
Added: trunk/src/include/xprops.h
==============================================================================
--- (empty file)
+++ trunk/src/include/xprops.h Mon May 19 00:00:09 2008
@@ -0,0 +1,227 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/* Metacity X property convenience routines */
+
+/*
+ * 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.
+ */
+
+#ifndef META_XPROPS_H
+#define META_XPROPS_H
+
+#include <config.h>
+
+#include "display.h"
+#include <X11/Xutil.h>
+
+#ifdef HAVE_XSYNC
+#include <X11/extensions/sync.h>
+#endif
+
+/* Copied from Lesstif by way of GTK. Rudimentary docs can be
+ * found in some Motif reference guides online.
+ */
+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)
+
+#define MWM_FUNC_ALL (1L << 0)
+#define MWM_FUNC_RESIZE (1L << 1)
+#define MWM_FUNC_MOVE (1L << 2)
+#define MWM_FUNC_MINIMIZE (1L << 3)
+#define MWM_FUNC_MAXIMIZE (1L << 4)
+#define MWM_FUNC_CLOSE (1L << 5)
+
+#define MWM_DECOR_ALL (1L << 0)
+#define MWM_DECOR_BORDER (1L << 1)
+#define MWM_DECOR_RESIZEH (1L << 2)
+#define MWM_DECOR_TITLE (1L << 3)
+#define MWM_DECOR_MENU (1L << 4)
+#define MWM_DECOR_MINIMIZE (1L << 5)
+#define MWM_DECOR_MAXIMIZE (1L << 6)
+
+#define MWM_INPUT_MODELESS 0
+#define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
+#define MWM_INPUT_SYSTEM_MODAL 2
+#define MWM_INPUT_FULL_APPLICATION_MODAL 3
+#define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL
+
+#define MWM_TEAROFF_WINDOW (1L<<0)
+
+/* These all return the memory from Xlib, so require an XFree()
+ * when they return TRUE. They return TRUE on success.
+ */
+gboolean meta_prop_get_atom_list (MetaDisplay *display,
+ Window xwindow,
+ Atom xatom,
+ Atom **atoms_p,
+ int *n_atoms_p);
+gboolean meta_prop_get_motif_hints (MetaDisplay *display,
+ Window xwindow,
+ Atom xatom,
+ MotifWmHints **hints_p);
+gboolean meta_prop_get_cardinal_list (MetaDisplay *display,
+ Window xwindow,
+ Atom xatom,
+ gulong **cardinals_p,
+ int *n_cardinals_p);
+gboolean meta_prop_get_latin1_string (MetaDisplay *display,
+ Window xwindow,
+ Atom xatom,
+ char **str_p);
+gboolean meta_prop_get_utf8_string (MetaDisplay *display,
+ Window xwindow,
+ Atom xatom,
+ char **str_p);
+gboolean meta_prop_get_utf8_list (MetaDisplay *display,
+ Window xwindow,
+ Atom xatom,
+ char ***str_p,
+ int *n_str_p);
+void meta_prop_set_utf8_string_hint
+ (MetaDisplay *display,
+ Window xwindow,
+ Atom atom,
+ const char *val);
+gboolean meta_prop_get_window (MetaDisplay *display,
+ Window xwindow,
+ Atom xatom,
+ Window *window_p);
+gboolean meta_prop_get_cardinal (MetaDisplay *display,
+ Window xwindow,
+ Atom xatom,
+ gulong *cardinal_p);
+gboolean meta_prop_get_cardinal_with_atom_type (MetaDisplay *display,
+ Window xwindow,
+ Atom xatom,
+ Atom prop_type,
+ gulong *cardinal_p);
+gboolean meta_prop_get_text_property (MetaDisplay *display,
+ Window xwindow,
+ Atom xatom,
+ char **utf8_str_p);
+
+gboolean meta_prop_get_wm_hints (MetaDisplay *display,
+ Window xwindow,
+ Atom xatom,
+ XWMHints **hints_p);
+
+gboolean meta_prop_get_class_hint (MetaDisplay *display,
+ Window xwindow,
+ Atom xatom,
+ XClassHint *class_hint);
+
+gboolean meta_prop_get_size_hints (MetaDisplay *display,
+ Window xwindow,
+ Atom xatom,
+ XSizeHints **hints_p,
+ gulong *flags_p);
+
+typedef enum
+{
+ META_PROP_VALUE_INVALID,
+ META_PROP_VALUE_UTF8,
+ META_PROP_VALUE_STRING,
+ META_PROP_VALUE_STRING_AS_UTF8,
+ META_PROP_VALUE_MOTIF_HINTS,
+ META_PROP_VALUE_CARDINAL,
+ META_PROP_VALUE_WINDOW,
+ META_PROP_VALUE_CARDINAL_LIST,
+ META_PROP_VALUE_UTF8_LIST,
+ META_PROP_VALUE_ATOM_LIST,
+ META_PROP_VALUE_TEXT_PROPERTY, /* comes back as UTF-8 string */
+ META_PROP_VALUE_WM_HINTS,
+ META_PROP_VALUE_CLASS_HINT,
+ META_PROP_VALUE_SIZE_HINTS,
+ META_PROP_VALUE_SYNC_COUNTER /* comes back as CARDINAL */
+} MetaPropValueType;
+
+/* used to request/return/store property values */
+typedef struct
+{
+ MetaPropValueType type;
+ Atom atom;
+ Atom required_type; /* autofilled if None */
+
+ union
+ {
+ char *str;
+ MotifWmHints *motif_hints;
+ Window xwindow;
+ gulong cardinal;
+ XWMHints *wm_hints;
+ XClassHint class_hint;
+#ifdef HAVE_XSYNC
+ XSyncCounter xcounter;
+#endif
+
+ struct
+ {
+ XSizeHints *hints;
+ unsigned long flags;
+ } size_hints;
+
+ struct
+ {
+ gulong *cardinals;
+ int n_cardinals;
+ } cardinal_list;
+
+ struct
+ {
+ char **strings;
+ int n_strings;
+ } string_list;
+
+ struct
+ {
+ Atom *atoms;
+ int n_atoms;
+ } atom_list;
+
+ } v;
+
+} MetaPropValue;
+
+/* Each value has type and atom initialized. If there's an error,
+ * or property is unset, type comes back as INVALID;
+ * else type comes back as it originated, and the data
+ * is filled in.
+ */
+void meta_prop_get_values (MetaDisplay *display,
+ Window xwindow,
+ MetaPropValue *values,
+ int n_values);
+
+void meta_prop_free_values (MetaPropValue *values,
+ int n_values);
+
+#endif
+
+
+
+
Modified: trunk/src/ui/tabpopup.c
==============================================================================
--- trunk/src/ui/tabpopup.c (original)
+++ trunk/src/ui/tabpopup.c Mon May 19 00:00:09 2008
@@ -31,7 +31,7 @@
/* FIXME these two includes are 100% broken ...
*/
#include "../core/workspace.h"
-#include "../core/frame.h"
+#include "../core/frame-private.h"
#include "draw-workspace.h"
#include <gtk/gtk.h>
#include <math.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]