summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDenis Gorodnichev <[email protected]>2015-01-13 21:19:25 +0300
committerinfirit <[email protected]>2015-01-14 19:06:47 +0100
commitda4f7675d08c49301f0048e0b72ced8e9a5ea375 (patch)
tree5a18ad6eac9b0e031f169a742f769ab1292fb63f /src
parentbe94f8e1788788920c7473ecefe2ee28526f8388 (diff)
downloadmarco-da4f7675d08c49301f0048e0b72ced8e9a5ea375.tar.bz2
marco-da4f7675d08c49301f0048e0b72ced8e9a5ea375.tar.xz
check compositor status
Diffstat (limited to 'src')
-rw-r--r--src/core/screen-private.h1
-rw-r--r--src/core/screen.c27
-rw-r--r--src/include/screen.h1
-rw-r--r--src/include/tile-preview.h4
-rw-r--r--src/ui/tile-preview.c31
5 files changed, 34 insertions, 30 deletions
diff --git a/src/core/screen-private.h b/src/core/screen-private.h
index 0103c6ad..ee014ff2 100644
--- a/src/core/screen-private.h
+++ b/src/core/screen-private.h
@@ -115,6 +115,7 @@ struct _MetaScreen
#endif
#ifdef HAVE_COMPOSITE_EXTENSIONS
+ Atom wm_cm_atom;
Window wm_cm_selection_window;
guint32 wm_cm_timestamp;
#endif
diff --git a/src/core/screen.c b/src/core/screen.c
index 6c555126..66461d4a 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -485,6 +485,8 @@ meta_screen_new (MetaDisplay *display,
screen->wm_sn_timestamp = manager_timestamp;
#ifdef HAVE_COMPOSITE_EXTENSIONS
+ g_snprintf (buf, sizeof(buf), "_NET_WM_CM_S%d", screen->number);
+ screen->wm_cm_atom = XInternAtom (screen->display->xdisplay, buf, FALSE);
screen->wm_cm_selection_window = meta_create_offscreen_window (xdisplay,
xroot,
NoEventMask);
@@ -1508,7 +1510,7 @@ meta_screen_tile_preview_update_timeout (gpointer data)
MetaRectangle tile_rect;
meta_window_get_current_tile_area (window, &tile_rect);
- meta_tile_preview_show (screen->tile_preview, &tile_rect);
+ meta_tile_preview_show (screen->tile_preview, &tile_rect, screen);
}
else
meta_tile_preview_hide (screen->tile_preview);
@@ -2894,28 +2896,25 @@ meta_screen_set_compositor_data (MetaScreen *screen,
void
meta_screen_set_cm_selection (MetaScreen *screen)
{
- char selection[32];
- Atom a;
-
screen->wm_cm_timestamp = meta_display_get_current_time_roundtrip (
screen->display);
- g_snprintf (selection, sizeof(selection), "_NET_WM_CM_S%d", screen->number);
- meta_verbose ("Setting selection: %s\n", selection);
- a = XInternAtom (screen->display->xdisplay, selection, FALSE);
- XSetSelectionOwner (screen->display->xdisplay, a,
+ meta_verbose ("Setting selection for screen: %d\n", screen->number);
+ XSetSelectionOwner (screen->display->xdisplay, screen->wm_cm_atom,
screen->wm_cm_selection_window, screen->wm_cm_timestamp);
}
void
meta_screen_unset_cm_selection (MetaScreen *screen)
{
- char selection[32];
- Atom a;
-
- g_snprintf (selection, sizeof(selection), "_NET_WM_CM_S%d", screen->number);
- a = XInternAtom (screen->display->xdisplay, selection, FALSE);
- XSetSelectionOwner (screen->display->xdisplay, a,
+ XSetSelectionOwner (screen->display->xdisplay, screen->wm_cm_atom,
None, screen->wm_cm_timestamp);
}
+
+gboolean
+meta_screen_is_cm_selected (MetaScreen *screen)
+{
+ Window owner = XGetSelectionOwner (screen->display->xdisplay, screen->wm_cm_atom);
+ return owner != None;
+}
#endif /* HAVE_COMPOSITE_EXTENSIONS */
diff --git a/src/include/screen.h b/src/include/screen.h
index 759c1fd2..34f4d008 100644
--- a/src/include/screen.h
+++ b/src/include/screen.h
@@ -43,6 +43,7 @@ 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);
+gboolean meta_screen_is_cm_selected (MetaScreen *screen);
#endif
#endif
diff --git a/src/include/tile-preview.h b/src/include/tile-preview.h
index 88af4f49..70ceec9e 100644
--- a/src/include/tile-preview.h
+++ b/src/include/tile-preview.h
@@ -24,13 +24,15 @@
#define META_TILE_PREVIEW_H
#include "boxes.h"
+#include "types.h"
typedef struct _MetaTilePreview MetaTilePreview;
MetaTilePreview *meta_tile_preview_new (int screen_number);
void meta_tile_preview_free (MetaTilePreview *preview);
void meta_tile_preview_show (MetaTilePreview *preview,
- MetaRectangle *rect);
+ MetaRectangle *rect,
+ MetaScreen *screen);
void meta_tile_preview_hide (MetaTilePreview *preview);
#endif /* META_TILE_PREVIEW_H */
diff --git a/src/ui/tile-preview.c b/src/ui/tile-preview.c
index 75eba055..ee58600d 100644
--- a/src/ui/tile-preview.c
+++ b/src/ui/tile-preview.c
@@ -28,6 +28,8 @@
#include "tile-preview.h"
#include "core.h"
+#include "types.h"
+#include "core/screen-private.h"
#define OUTLINE_WIDTH 5 /* frame width in non-composite case */
@@ -206,23 +208,14 @@ meta_tile_preview_new (int screen_number)
preview->tile_rect.width = preview->tile_rect.height = 0;
#if GTK_CHECK_VERSION (3, 0, 0)
- preview->has_alpha = gdk_screen_is_composited (screen) && (gdk_screen_get_rgba_visual (screen) != NULL);
+ gtk_widget_set_visual (preview->preview_window,
+ gdk_screen_get_rgba_visual (screen));
#else
- preview->has_alpha = rgba_colormap && gdk_screen_is_composited (screen);
+ gtk_widget_set_colormap (preview->preview_window, rgba_colormap);
#endif
- if (preview->has_alpha)
- {
-#if GTK_CHECK_VERSION (3, 0, 0)
- gtk_widget_set_visual (preview->preview_window,
- gdk_screen_get_rgba_visual (screen));
-#else
- gtk_widget_set_colormap (preview->preview_window, rgba_colormap);
-#endif
-
- g_signal_connect (preview->preview_window, "style-set",
- G_CALLBACK (on_preview_window_style_set), preview);
- }
+ g_signal_connect (preview->preview_window, "style-set",
+ G_CALLBACK (on_preview_window_style_set), preview);
gtk_widget_realize (preview->preview_window);
#if !GTK_CHECK_VERSION (3, 0, 0)
@@ -258,7 +251,8 @@ meta_tile_preview_free (MetaTilePreview *preview)
void
meta_tile_preview_show (MetaTilePreview *preview,
- MetaRectangle *tile_rect)
+ MetaRectangle *tile_rect,
+ MetaScreen *screen)
{
GdkWindow *window;
GdkRectangle old_rect;
@@ -291,6 +285,11 @@ meta_tile_preview_show (MetaTilePreview *preview,
gdk_window_move_resize (window,
preview->tile_rect.x, preview->tile_rect.y,
preview->tile_rect.width, preview->tile_rect.height);
+#if HAVE_COMPOSITE_EXTENSIONS
+ preview->has_alpha = meta_screen_is_cm_selected (screen);
+#else
+ preview->has_alpha = FALSE;
+#endif
if (!preview->has_alpha)
{
@@ -337,6 +336,8 @@ meta_tile_preview_show (MetaTilePreview *preview,
gdk_window_shape_combine_region (window, outer_region, 0, 0);
gdk_region_destroy (outer_region);
#endif
+ } else {
+ gdk_window_shape_combine_region (window, NULL, 0, 0);
}
}