summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compositor/compositor-private.h5
-rw-r--r--src/compositor/compositor-xrender.c50
-rw-r--r--src/compositor/compositor.c16
-rw-r--r--src/core/screen.c31
-rw-r--r--src/include/compositor.h6
-rw-r--r--src/include/ui.h4
-rw-r--r--src/ui/ui.c13
7 files changed, 114 insertions, 11 deletions
diff --git a/src/compositor/compositor-private.h b/src/compositor/compositor-private.h
index 61e7ffb0..1eef9633 100644
--- a/src/compositor/compositor-private.h
+++ b/src/compositor/compositor-private.h
@@ -44,8 +44,13 @@ struct _MetaCompositor
void (*process_event) (MetaCompositor *compositor,
XEvent *event,
MetaWindow *window);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_surface_t *(* get_window_surface) (MetaCompositor *compositor,
+ MetaWindow *window);
+#else
Pixmap (*get_window_pixmap) (MetaCompositor *compositor,
MetaWindow *window);
+#endif
void (*set_active_window) (MetaCompositor *compositor,
MetaScreen *screen,
MetaWindow *window);
diff --git a/src/compositor/compositor-xrender.c b/src/compositor/compositor-xrender.c
index 5080f80d..1da598c5 100644
--- a/src/compositor/compositor-xrender.c
+++ b/src/compositor/compositor-xrender.c
@@ -34,6 +34,11 @@
#include <unistd.h>
#include <gdk/gdk.h>
+#include <gtk/gtk.h>
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+#include <cairo/cairo-xlib.h>
+#endif
#include "display.h"
#include "screen.h"
@@ -2797,6 +2802,46 @@ xrender_process_event (MetaCompositor *compositor,
#endif
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static cairo_surface_t *
+xrender_get_window_surface (MetaCompositor *compositor,
+ MetaWindow *window)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ MetaFrame *frame;
+ Window xwindow;
+ MetaScreen *screen;
+ MetaCompWindow *cw;
+ MetaCompositorXRender *xrc;
+ Display *display;
+ Pixmap pixmap;
+
+ frame = meta_window_get_frame (window);
+
+ if (frame)
+ xwindow = meta_frame_get_xwindow (frame);
+ else
+ xwindow = meta_window_get_xwindow (window);
+
+ screen = meta_window_get_screen (window);
+ cw = find_window_for_screen (screen, xwindow);
+
+ if (cw == NULL)
+ return NULL;
+
+ xrc = (MetaCompositorXRender *) compositor;
+ display = meta_display_get_xdisplay (xrc->display);
+
+ if (meta_window_is_shaded (window))
+ pixmap = cw->shaded_back_pixmap;
+ else
+ pixmap = cw->back_pixmap;
+
+ return cairo_xlib_surface_create (display, pixmap, cw->attrs.visual,
+ cw->attrs.width, cw->attrs.height);
+#endif
+}
+#else
static Pixmap
xrender_get_window_pixmap (MetaCompositor *compositor,
MetaWindow *window)
@@ -2817,6 +2862,7 @@ xrender_get_window_pixmap (MetaCompositor *compositor,
return cw->back_pixmap;
#endif
}
+#endif /* GTK_CHECK_VERSION */
static void
xrender_set_active_window (MetaCompositor *compositor,
@@ -3000,7 +3046,11 @@ static MetaCompositor comp_info = {
xrender_remove_window,
xrender_set_updates,
xrender_process_event,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ xrender_get_window_surface,
+#else
xrender_get_window_pixmap,
+#endif
xrender_set_active_window,
xrender_free_window,
xrender_maximize_window,
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index f7a28261..4d3f370b 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -107,6 +107,21 @@ meta_compositor_process_event (MetaCompositor *compositor,
#endif
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+cairo_surface_t *
+meta_compositor_get_window_surface (MetaCompositor *compositor,
+ MetaWindow *window)
+{
+#ifdef HAVE_COMPOSITE_EXTENSIONS
+ if (compositor && compositor->get_window_surface)
+ return compositor->get_window_surface (compositor, window);
+ else
+ return NULL;
+#else
+ return NULL;
+#endif
+}
+#else
Pixmap
meta_compositor_get_window_pixmap (MetaCompositor *compositor,
MetaWindow *window)
@@ -120,6 +135,7 @@ meta_compositor_get_window_pixmap (MetaCompositor *compositor,
return None;
#endif
}
+#endif /* GTK_CHECK_VERSION */
void
meta_compositor_set_active_window (MetaCompositor *compositor,
diff --git a/src/core/screen.c b/src/core/screen.c
index 14fa9953..b4cb5ef7 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -1213,7 +1213,6 @@ meta_screen_update_cursor (MetaScreen *screen)
XFreeCursor (screen->display->xdisplay, xcursor);
}
-#if !GTK_CHECK_VERSION (3, 0, 0)
#define MAX_PREVIEW_SIZE 150.0
static GdkPixbuf *
@@ -1221,16 +1220,38 @@ get_window_pixbuf (MetaWindow *window,
int *width,
int *height)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_surface_t *surface;
+#else
Pixmap pmap;
+#endif
GdkPixbuf *pixbuf, *scaled;
double ratio;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ surface = meta_compositor_get_window_surface (window->display->compositor,
+ window);
+ if (surface == None)
+ return NULL;
+#else
pmap = meta_compositor_get_window_pixmap (window->display->compositor,
window);
if (pmap == None)
return NULL;
+#endif
+
+ meta_error_trap_push (NULL);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ pixbuf = meta_ui_get_pixbuf_from_surface (surface);
+ cairo_surface_destroy (surface);
+#else
pixbuf = meta_ui_get_pixbuf_from_pixmap (pmap);
+#endif
+
+ if (meta_error_trap_pop_with_return (NULL, FALSE) != Success)
+ g_clear_object (&pixbuf);
+
if (pixbuf == NULL)
return NULL;
@@ -1256,7 +1277,6 @@ get_window_pixbuf (MetaWindow *window,
g_object_unref (pixbuf);
return scaled;
}
-#endif
void
meta_screen_ensure_tab_popup (MetaScreen *screen,
@@ -1290,17 +1310,14 @@ meta_screen_ensure_tab_popup (MetaScreen *screen,
{
MetaWindow *window;
MetaRectangle r;
-#if !GTK_CHECK_VERSION (3, 0, 0)
GdkPixbuf *win_pixbuf = NULL;
int width = 0, height = 0;
-#endif
window = tmp->data;
entries[i].key = (MetaTabEntryKey) window->xwindow;
entries[i].title = window->title;
-#if !GTK_CHECK_VERSION (3, 0, 0)
/* Only get the pixbuf if the user does NOT have
compositing-fast-alt-tab-set to true
in GSettings. There is an obvious lag when the pixbuf is
@@ -1333,10 +1350,6 @@ meta_screen_ensure_tab_popup (MetaScreen *screen,
t_width - icon_width, t_height - icon_height,
1.0, 1.0, GDK_INTERP_BILINEAR, 255);
}
-#else
- /* at the moment, thumbnails are disabled for GTK3 */
- entries[i].icon = g_object_ref (window->icon);
-#endif
entries[i].blank = FALSE;
entries[i].hidden = !meta_window_showing_on_its_workspace (window);
diff --git a/src/include/compositor.h b/src/include/compositor.h
index 5c238890..0eebe569 100644
--- a/src/include/compositor.h
+++ b/src/include/compositor.h
@@ -23,6 +23,7 @@
#define META_COMPOSITOR_H
#include <glib.h>
+#include <gtk/gtk.h>
#include <X11/Xlib.h>
#include "types.h"
@@ -50,8 +51,13 @@ void meta_compositor_set_updates (MetaCompositor *compositor,
void meta_compositor_process_event (MetaCompositor *compositor,
XEvent *event,
MetaWindow *window);
+#if GTK_CHECK_VERSION (3, 0, 0)
+cairo_surface_t *meta_compositor_get_window_surface (MetaCompositor *compositor,
+ MetaWindow *window);
+#else
Pixmap meta_compositor_get_window_pixmap (MetaCompositor *compositor,
MetaWindow *window);
+#endif
void meta_compositor_set_active_window (MetaCompositor *compositor,
MetaScreen *screen,
MetaWindow *window);
diff --git a/src/include/ui.h b/src/include/ui.h
index 70987d33..4705eda2 100644
--- a/src/include/ui.h
+++ b/src/include/ui.h
@@ -177,7 +177,9 @@ int meta_ui_get_drag_threshold (MetaUI *ui);
MetaUIDirection meta_ui_get_direction (void);
-#if !GTK_CHECK_VERSION (3, 0, 0)
+#if GTK_CHECK_VERSION (3, 0, 0)
+GdkPixbuf *meta_ui_get_pixbuf_from_surface (cairo_surface_t *surface);
+#else
GdkPixbuf *meta_ui_get_pixbuf_from_pixmap (Pixmap pmap);
#endif
diff --git a/src/ui/ui.c b/src/ui/ui.c
index 731c615b..130a671f 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -1104,7 +1104,18 @@ MetaUIDirection meta_ui_get_direction(void)
return META_UI_DIRECTION_LTR;
}
-#if !GTK_CHECK_VERSION (3, 0, 0)
+#if GTK_CHECK_VERSION (3, 0, 0)
+GdkPixbuf *meta_ui_get_pixbuf_from_surface (cairo_surface_t *surface)
+{
+ gint width;
+ gint height;
+
+ width = cairo_xlib_surface_get_width (surface);
+ height = cairo_xlib_surface_get_height (surface);
+
+ return gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
+}
+#else
GdkPixbuf* meta_ui_get_pixbuf_from_pixmap(Pixmap pmap)
{
GdkPixmap* gpmap;