API: screen: Remove gdk_screen_is_composited()

Switch code to use gdk_display_is_composited() instead.

The new code also doesn't use a vfunc to query the property but rather
requires the backend to call set_composited()/set_rgba() to change the
value.
This commit is contained in:
Benjamin Otte 2016-10-29 04:37:20 +02:00
parent a334316d5e
commit d249e77bcb
28 changed files with 123 additions and 238 deletions

View File

@ -180,7 +180,6 @@ GdkScreen
gdk_screen_get_default gdk_screen_get_default
gdk_screen_get_system_visual gdk_screen_get_system_visual
gdk_screen_get_rgba_visual gdk_screen_get_rgba_visual
gdk_screen_is_composited
gdk_screen_get_root_window gdk_screen_get_root_window
gdk_screen_get_display gdk_screen_get_display
gdk_screen_get_number gdk_screen_get_number

View File

@ -101,8 +101,6 @@ _gdk_broadway_display_open (const gchar *display_name)
_gdk_broadway_display_init_dnd (display); _gdk_broadway_display_init_dnd (display);
_gdk_broadway_screen_setup (broadway_display->screens[0]);
if (display_name == NULL) if (display_name == NULL)
display_name = g_getenv ("BROADWAY_DISPLAY"); display_name = g_getenv ("BROADWAY_DISPLAY");

View File

@ -137,23 +137,6 @@ _gdk_broadway_screen_new (GdkDisplay *display,
return screen; return screen;
} }
/*
* It is important that we first request the selection
* notification, and then setup the initial state of
* is_composited to avoid a race condition here.
*/
void
_gdk_broadway_screen_setup (GdkScreen *screen)
{
}
static gboolean
gdk_broadway_screen_is_composited (GdkScreen *screen)
{
return TRUE;
}
static gboolean static gboolean
gdk_broadway_screen_get_setting (GdkScreen *screen, gdk_broadway_screen_get_setting (GdkScreen *screen,
const gchar *name, const gchar *name,
@ -178,7 +161,6 @@ gdk_broadway_screen_class_init (GdkBroadwayScreenClass *klass)
screen_class->get_display = gdk_broadway_screen_get_display; screen_class->get_display = gdk_broadway_screen_get_display;
screen_class->get_root_window = gdk_broadway_screen_get_root_window; screen_class->get_root_window = gdk_broadway_screen_get_root_window;
screen_class->is_composited = gdk_broadway_screen_is_composited;
screen_class->get_setting = gdk_broadway_screen_get_setting; screen_class->get_setting = gdk_broadway_screen_get_setting;
screen_class->get_rgba_visual = gdk_broadway_screen_get_rgba_visual; screen_class->get_rgba_visual = gdk_broadway_screen_get_rgba_visual;
screen_class->get_system_visual = _gdk_broadway_screen_get_system_visual; screen_class->get_system_visual = _gdk_broadway_screen_get_system_visual;

View File

@ -68,7 +68,6 @@ struct _GdkBroadwayScreenClass
GType gdk_broadway_screen_get_type (void); GType gdk_broadway_screen_get_type (void);
GdkScreen * _gdk_broadway_screen_new (GdkDisplay *display, GdkScreen * _gdk_broadway_screen_new (GdkDisplay *display,
gint screen_number); gint screen_number);
void _gdk_broadway_screen_setup (GdkScreen *screen);
G_END_DECLS G_END_DECLS

View File

@ -2158,7 +2158,21 @@ gdk_display_is_composited (GdkDisplay *display)
{ {
g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE); g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
return gdk_screen_is_composited (gdk_display_get_default_screen (display)); return display->composited;
}
void
gdk_display_set_composited (GdkDisplay *display,
gboolean composited)
{
g_return_if_fail (GDK_IS_DISPLAY (display));
if (display->composited == composited)
return;
display->composited = composited;
g_object_notify_by_pspec (G_OBJECT (display), props[PROP_COMPOSITED]);
} }
/** /**
@ -2190,7 +2204,21 @@ gdk_display_is_rgba (GdkDisplay *display)
{ {
g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE); g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
return gdk_screen_get_rgba_visual (gdk_display_get_default_screen (display)) != NULL; return display->rgba;
}
void
gdk_display_set_rgba (GdkDisplay *display,
gboolean rgba)
{
g_return_if_fail (GDK_IS_DISPLAY (display));
if (display->rgba == rgba)
return;
display->rgba = rgba;
g_object_notify_by_pspec (G_OBJECT (display), props[PROP_RGBA]);
} }

View File

@ -123,6 +123,9 @@ struct _GdkDisplay
guint has_gl_extension_texture_non_power_of_two : 1; guint has_gl_extension_texture_non_power_of_two : 1;
guint has_gl_extension_texture_rectangle : 1; guint has_gl_extension_texture_rectangle : 1;
guint rgba : 1;
guint composited : 1;
GdkRenderingMode rendering_mode; GdkRenderingMode rendering_mode;
GList *seats; GList *seats;
@ -328,6 +331,11 @@ GdkWindow * _gdk_display_create_window (GdkDisplay *display
gboolean gdk_display_make_gl_context_current (GdkDisplay *display, gboolean gdk_display_make_gl_context_current (GdkDisplay *display,
GdkGLContext *context); GdkGLContext *context);
void gdk_display_set_rgba (GdkDisplay *display,
gboolean rgba);
void gdk_display_set_composited (GdkDisplay *display,
gboolean composited);
void gdk_display_add_seat (GdkDisplay *display, void gdk_display_add_seat (GdkDisplay *display,
GdkSeat *seat); GdkSeat *seat);
void gdk_display_remove_seat (GdkDisplay *display, void gdk_display_remove_seat (GdkDisplay *display,

View File

@ -65,7 +65,6 @@ enum
enum enum
{ {
SIZE_CHANGED, SIZE_CHANGED,
COMPOSITED_CHANGED,
MONITORS_CHANGED, MONITORS_CHANGED,
LAST_SIGNAL LAST_SIGNAL
}; };
@ -93,25 +92,6 @@ gdk_screen_class_init (GdkScreenClass *klass)
G_PARAM_READWRITE|G_PARAM_STATIC_NAME| G_PARAM_READWRITE|G_PARAM_STATIC_NAME|
G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)); G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
/**
* GdkScreen::composited-changed:
* @screen: the object on which the signal is emitted
*
* The ::composited-changed signal is emitted when the composited
* status of the screen changes
*
* Since: 2.10
*/
signals[COMPOSITED_CHANGED] =
g_signal_new (g_intern_static_string ("composited-changed"),
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdkScreenClass, composited_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
/** /**
* GdkScreen::monitors-changed: * GdkScreen::monitors-changed:
* @screen: the object on which the signal is emitted * @screen: the object on which the signal is emitted
@ -378,30 +358,6 @@ gdk_screen_get_rgba_visual (GdkScreen *screen)
return GDK_SCREEN_GET_CLASS (screen)->get_rgba_visual (screen); return GDK_SCREEN_GET_CLASS (screen)->get_rgba_visual (screen);
} }
/**
* gdk_screen_is_composited:
* @screen: a #GdkScreen
*
* Returns whether windows with an RGBA visual can reasonably
* be expected to have their alpha channel drawn correctly on
* the screen.
*
* On X11 this function returns whether a compositing manager is
* compositing @screen.
*
* Returns: Whether windows with RGBA visuals can reasonably be
* expected to have their alpha channels drawn correctly on the screen.
*
* Since: 2.10
**/
gboolean
gdk_screen_is_composited (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
return GDK_SCREEN_GET_CLASS (screen)->is_composited (screen);
}
/** /**
* gdk_screen_get_setting: * gdk_screen_get_setting:
* @screen: the #GdkScreen where the setting is located * @screen: the #GdkScreen where the setting is located

View File

@ -45,8 +45,6 @@ GDK_AVAILABLE_IN_ALL
GdkVisual * gdk_screen_get_system_visual (GdkScreen *screen); GdkVisual * gdk_screen_get_system_visual (GdkScreen *screen);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GdkVisual * gdk_screen_get_rgba_visual (GdkScreen *screen); GdkVisual * gdk_screen_get_rgba_visual (GdkScreen *screen);
GDK_AVAILABLE_IN_ALL
gboolean gdk_screen_is_composited (GdkScreen *screen);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
GdkWindow * gdk_screen_get_root_window (GdkScreen *screen); GdkWindow * gdk_screen_get_root_window (GdkScreen *screen);

View File

@ -61,7 +61,6 @@ struct _GdkScreenClass
GList * (* list_visuals) (GdkScreen *screen); GList * (* list_visuals) (GdkScreen *screen);
GdkVisual * (* get_system_visual) (GdkScreen *screen); GdkVisual * (* get_system_visual) (GdkScreen *screen);
GdkVisual * (* get_rgba_visual) (GdkScreen *screen); GdkVisual * (* get_rgba_visual) (GdkScreen *screen);
gboolean (* is_composited) (GdkScreen *screen);
gboolean (* get_setting) (GdkScreen *screen, gboolean (* get_setting) (GdkScreen *screen,
const gchar *name, const gchar *name,
GValue *value); GValue *value);

View File

@ -411,14 +411,6 @@ gdk_mir_screen_get_rgba_visual (GdkScreen *screen)
return GDK_MIR_SCREEN (screen)->visual; return GDK_MIR_SCREEN (screen)->visual;
} }
static gboolean
gdk_mir_screen_is_composited (GdkScreen *screen)
{
//g_printerr ("gdk_mir_screen_is_composited\n");
/* We're always composited */
return TRUE;
}
static gboolean static gboolean
gdk_mir_screen_get_setting (GdkScreen *screen, gdk_mir_screen_get_setting (GdkScreen *screen,
const gchar *name, const gchar *name,
@ -720,7 +712,6 @@ gdk_mir_screen_class_init (GdkMirScreenClass *klass)
screen_class->list_visuals = gdk_mir_screen_list_visuals; screen_class->list_visuals = gdk_mir_screen_list_visuals;
screen_class->get_system_visual = gdk_mir_screen_get_system_visual; screen_class->get_system_visual = gdk_mir_screen_get_system_visual;
screen_class->get_rgba_visual = gdk_mir_screen_get_rgba_visual; screen_class->get_rgba_visual = gdk_mir_screen_get_rgba_visual;
screen_class->is_composited = gdk_mir_screen_is_composited;
screen_class->get_setting = gdk_mir_screen_get_setting; screen_class->get_setting = gdk_mir_screen_get_setting;
screen_class->get_monitor_scale_factor = gdk_mir_screen_get_monitor_scale_factor; screen_class->get_monitor_scale_factor = gdk_mir_screen_get_monitor_scale_factor;
} }

View File

@ -448,12 +448,6 @@ _gdk_quartz_screen_get_monitor_scale_factor (GdkScreen *screen,
return scale_factor; return scale_factor;
} }
static gboolean
gdk_quartz_screen_is_composited (GdkScreen *screen)
{
return TRUE;
}
static void static void
gdk_quartz_screen_class_init (GdkQuartzScreenClass *klass) gdk_quartz_screen_class_init (GdkQuartzScreenClass *klass)
{ {
@ -476,7 +470,6 @@ gdk_quartz_screen_class_init (GdkQuartzScreenClass *klass)
screen_class->get_monitor_plug_name = gdk_quartz_screen_get_monitor_plug_name; screen_class->get_monitor_plug_name = gdk_quartz_screen_get_monitor_plug_name;
screen_class->get_monitor_geometry = gdk_quartz_screen_get_monitor_geometry; screen_class->get_monitor_geometry = gdk_quartz_screen_get_monitor_geometry;
screen_class->get_monitor_workarea = gdk_quartz_screen_get_monitor_workarea; screen_class->get_monitor_workarea = gdk_quartz_screen_get_monitor_workarea;
screen_class->is_composited = gdk_quartz_screen_is_composited;
screen_class->get_setting = _gdk_quartz_screen_get_setting; screen_class->get_setting = _gdk_quartz_screen_get_setting;
screen_class->get_rgba_visual = _gdk_quartz_screen_get_rgba_visual; screen_class->get_rgba_visual = _gdk_quartz_screen_get_rgba_visual;
screen_class->get_system_visual = _gdk_quartz_screen_get_system_visual; screen_class->get_system_visual = _gdk_quartz_screen_get_system_visual;

View File

@ -129,12 +129,6 @@ gdk_wayland_screen_get_rgba_visual (GdkScreen *screen)
return (GdkVisual *) GDK_WAYLAND_SCREEN (screen)->visual; return (GdkVisual *) GDK_WAYLAND_SCREEN (screen)->visual;
} }
static gboolean
gdk_wayland_screen_is_composited (GdkScreen *screen)
{
return TRUE;
}
static void static void
notify_setting (GdkScreen *screen, notify_setting (GdkScreen *screen,
const gchar *setting) const gchar *setting)
@ -722,7 +716,6 @@ _gdk_wayland_screen_class_init (GdkWaylandScreenClass *klass)
screen_class->get_root_window = gdk_wayland_screen_get_root_window; screen_class->get_root_window = gdk_wayland_screen_get_root_window;
screen_class->get_system_visual = gdk_wayland_screen_get_system_visual; screen_class->get_system_visual = gdk_wayland_screen_get_system_visual;
screen_class->get_rgba_visual = gdk_wayland_screen_get_rgba_visual; screen_class->get_rgba_visual = gdk_wayland_screen_get_rgba_visual;
screen_class->is_composited = gdk_wayland_screen_is_composited;
screen_class->get_setting = gdk_wayland_screen_get_setting; screen_class->get_setting = gdk_wayland_screen_get_setting;
screen_class->list_visuals = gdk_wayland_screen_list_visuals; screen_class->list_visuals = gdk_wayland_screen_list_visuals;
} }

View File

@ -808,6 +808,26 @@ gdk_win32_display_init (GdkWin32Display *display)
{ {
display->monitors = g_ptr_array_new_with_free_func (g_object_unref); display->monitors = g_ptr_array_new_with_free_func (g_object_unref);
_gdk_win32_display_init_cursors (display); _gdk_win32_display_init_cursors (display);
gdk_win32_display_check_composited (display);
}
void
gdk_win32_display_check_composited (GdkWin32Display *display)
{
gboolean composited;
/* On Windows 8 and later, DWM (composition) is always enabled */
if (g_win32_check_windows_version (6, 2, 0, G_WIN32_OS_ANY))
{
composited = TRUE;
}
else
{
if (DwmIsCompositionEnabled (&composited) != S_OK)
composited = FALSE;
}
gdk_display_set_composited (GDK_DISPLAY (display), composited);
} }
static void static void

View File

@ -60,4 +60,6 @@ gboolean _gdk_win32_display_init_monitors (GdkWin32Display *display);
GPtrArray *_gdk_win32_display_get_monitor_list (GdkWin32Display *display); GPtrArray *_gdk_win32_display_get_monitor_list (GdkWin32Display *display);
void gdk_win32_display_check_composited (GdkWin32Display *display);
#endif /* __GDK_DISPLAY__WIN32_H__ */ #endif /* __GDK_DISPLAY__WIN32_H__ */

View File

@ -3511,6 +3511,7 @@ gdk_event_translate (MSG *msg,
break; break;
case WM_DWMCOMPOSITIONCHANGED: case WM_DWMCOMPOSITIONCHANGED:
gdk_win32_display_check_composited (GDK_WIN32_DISPLAY (display));
_gdk_win32_window_enable_transparency (window); _gdk_win32_window_enable_transparency (window);
break; break;

View File

@ -37,8 +37,6 @@ struct _GdkWin32Screen
GdkVisualType available_visual_types[1]; GdkVisualType available_visual_types[1];
GdkWindow *root_window; GdkWindow *root_window;
gint always_composited : 1;
}; };
struct _GdkWin32ScreenClass struct _GdkWin32ScreenClass
@ -353,9 +351,6 @@ gdk_win32_screen_init (GdkWin32Screen *win32_screen)
_gdk_win32_display_init_monitors (GDK_WIN32_DISPLAY (_gdk_display)); _gdk_win32_display_init_monitors (GDK_WIN32_DISPLAY (_gdk_display));
init_root_window (win32_screen); init_root_window (win32_screen);
/* On Windows 8 and later, DWM (composition) is always enabled */
win32_screen->always_composited = g_win32_check_windows_version (6, 2, 0, G_WIN32_OS_ANY);
} }
void void
@ -384,21 +379,6 @@ gdk_win32_screen_get_root_window (GdkScreen *screen)
return GDK_WIN32_SCREEN (screen)->root_window; return GDK_WIN32_SCREEN (screen)->root_window;
} }
static gboolean
gdk_win32_screen_is_composited (GdkScreen *screen)
{
if (GDK_WIN32_SCREEN (screen)->always_composited)
return TRUE;
else
{
gboolean is_composited;
if (DwmIsCompositionEnabled (&is_composited) != S_OK)
return FALSE;
return is_composited;
}
}
static GdkVisual * static GdkVisual *
gdk_win32_screen_get_system_visual (GdkScreen *screen) gdk_win32_screen_get_system_visual (GdkScreen *screen)
{ {
@ -439,7 +419,6 @@ gdk_win32_screen_class_init (GdkWin32ScreenClass *klass)
screen_class->get_display = gdk_win32_screen_get_display; screen_class->get_display = gdk_win32_screen_get_display;
screen_class->get_root_window = gdk_win32_screen_get_root_window; screen_class->get_root_window = gdk_win32_screen_get_root_window;
screen_class->is_composited = gdk_win32_screen_is_composited;
screen_class->get_setting = _gdk_win32_screen_get_setting; screen_class->get_setting = _gdk_win32_screen_get_setting;
screen_class->get_system_visual = gdk_win32_screen_get_system_visual; screen_class->get_system_visual = gdk_win32_screen_get_system_visual;
screen_class->get_rgba_visual = gdk_win32_screen_get_rgba_visual; screen_class->get_rgba_visual = gdk_win32_screen_get_rgba_visual;

View File

@ -464,7 +464,7 @@ _gdk_win32_window_enable_transparency (GdkWindow *window)
screen = gdk_window_get_screen (window); screen = gdk_window_get_screen (window);
if (!gdk_screen_is_composited (screen)) if (!gdk_display_is_composited (gdk_window_get_display (window)))
return FALSE; return FALSE;
if (window == gdk_screen_get_root_window (screen)) if (window == gdk_screen_get_root_window (screen))
@ -4911,7 +4911,7 @@ gdk_win32_window_do_move_resize_drag (GdkWindow *window,
*/ */
if (impl->layered) if (impl->layered)
{ {
if (gdk_screen_is_composited (gdk_window_get_screen (window))) if (gdk_display_is_composited (gdk_window_get_display (window)))
{ {
hdc = NULL; hdc = NULL;
window_size_ptr = NULL; window_size_ptr = NULL;

View File

@ -176,7 +176,6 @@ G_DEFINE_TYPE_WITH_CODE (GdkX11Display, gdk_x11_display, GDK_TYPE_DISPLAY,
G_IMPLEMENT_INTERFACE (GDK_TYPE_EVENT_TRANSLATOR, G_IMPLEMENT_INTERFACE (GDK_TYPE_EVENT_TRANSLATOR,
gdk_x11_display_event_translator_init)) gdk_x11_display_event_translator_init))
static void static void
gdk_x11_display_init (GdkX11Display *display) gdk_x11_display_init (GdkX11Display *display)
{ {
@ -395,6 +394,12 @@ gdk_check_wm_state_changed (GdkWindow *window)
do_net_wm_state_changes (window); do_net_wm_state_changes (window);
} }
static Atom
get_cm_atom (GdkDisplay *display)
{
return _gdk_x11_get_xatom_for_display_printf (display, "_NET_WM_CM_S%d", DefaultScreen (GDK_DISPLAY_XDISPLAY (display)));
}
static Window static Window
get_event_xwindow (XEvent *xevent) get_event_xwindow (XEvent *xevent)
{ {
@ -985,7 +990,12 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
{ {
XFixesSelectionNotifyEvent *selection_notify = (XFixesSelectionNotifyEvent *)xevent; XFixesSelectionNotifyEvent *selection_notify = (XFixesSelectionNotifyEvent *)xevent;
_gdk_x11_screen_process_owner_change (screen, xevent); if (selection_notify->selection == get_cm_atom (display))
{
gboolean composited = selection_notify->owner != None;
gdk_display_set_composited (display, composited);
}
event->owner_change.type = GDK_OWNER_CHANGE; event->owner_change.type = GDK_OWNER_CHANGE;
event->owner_change.window = window; event->owner_change.window = window;
@ -1381,6 +1391,8 @@ _gdk_x11_display_open (const gchar *display_name)
/* initialize the display's screens */ /* initialize the display's screens */
display_x11->screen = _gdk_x11_screen_new (display, DefaultScreen (display_x11->xdisplay)); display_x11->screen = _gdk_x11_screen_new (display, DefaultScreen (display_x11->xdisplay));
if (gdk_screen_get_rgba_visual (display_x11->screen) == NULL)
gdk_display_set_rgba (display, FALSE);
/* We need to initialize events after we have the screen /* We need to initialize events after we have the screen
* structures in places * structures in places
@ -1571,7 +1583,15 @@ _gdk_x11_display_open (const gchar *display_name)
} }
#endif #endif
_gdk_x11_screen_setup (display_x11->screen); /*
* It is important that we first request the selection
* notification, and then setup the initial state of
* is_composited to avoid a race condition here.
*/
gdk_display_request_selection_notification (display,
gdk_x11_xatom_to_atom_for_display (display, get_cm_atom (display)));
gdk_display_set_composited (GDK_DISPLAY (display),
XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display), get_cm_atom (display)) != None);
g_signal_emit_by_name (display, "opened"); g_signal_emit_by_name (display, "opened");

View File

@ -634,7 +634,7 @@ gdk_window_cache_new (GdkScreen *screen)
* the COW. We assume that the CM is using the COW (which is true for pretty * the COW. We assume that the CM is using the COW (which is true for pretty
* much any CM currently in use). * much any CM currently in use).
*/ */
if (gdk_screen_is_composited (screen)) if (gdk_display_is_composited (gdk_screen_get_display (screen)))
{ {
cow = XCompositeGetOverlayWindow (xdisplay, GDK_WINDOW_XID (root_window)); cow = XCompositeGetOverlayWindow (xdisplay, GDK_WINDOW_XID (root_window));
gdk_window_cache_add (result, cow, 0, 0, gdk_window_cache_add (result, cow, 0, 0,

View File

@ -1298,8 +1298,6 @@ gdk_x11_display_make_gl_context_current (GdkDisplay *display,
{ {
GdkX11GLContext *context_x11; GdkX11GLContext *context_x11;
Display *dpy = gdk_x11_display_get_xdisplay (display); Display *dpy = gdk_x11_display_get_xdisplay (display);
GdkWindow *window;
GdkScreen *screen;
gboolean do_frame_sync = FALSE; gboolean do_frame_sync = FALSE;
if (context == NULL) if (context == NULL)
@ -1330,14 +1328,11 @@ gdk_x11_display_make_gl_context_current (GdkDisplay *display,
if (context_x11->is_attached && GDK_X11_DISPLAY (display)->has_glx_swap_interval) if (context_x11->is_attached && GDK_X11_DISPLAY (display)->has_glx_swap_interval)
{ {
window = gdk_gl_context_get_window (context);
/* If the WM is compositing there is no particular need to delay /* If the WM is compositing there is no particular need to delay
* the swap when drawing on the offscreen, rendering to the screen * the swap when drawing on the offscreen, rendering to the screen
* happens later anyway, and its up to the compositor to sync that * happens later anyway, and its up to the compositor to sync that
* to the vblank. */ * to the vblank. */
screen = gdk_window_get_screen (window); do_frame_sync = ! gdk_display_is_composited (display);
do_frame_sync = ! gdk_screen_is_composited (screen);
if (do_frame_sync != context_x11->do_frame_sync) if (do_frame_sync != context_x11->do_frame_sync)
{ {

View File

@ -321,23 +321,6 @@ gdk_x11_screen_get_screen_number (GdkScreen *screen)
return GDK_X11_SCREEN (screen)->screen_num; return GDK_X11_SCREEN (screen)->screen_num;
} }
static Atom
get_cm_atom (GdkX11Screen *x11_screen)
{
return _gdk_x11_get_xatom_for_display_printf (x11_screen->display, "_NET_WM_CM_S%d", x11_screen->screen_num);
}
static gboolean
check_is_composited (GdkDisplay *display,
GdkX11Screen *x11_screen)
{
Window xwindow;
xwindow = XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display), get_cm_atom (x11_screen));
return xwindow != None;
}
static GdkX11Monitor * static GdkX11Monitor *
find_monitor_by_output (GdkX11Display *x11_display, XID output) find_monitor_by_output (GdkX11Display *x11_display, XID output)
{ {
@ -887,29 +870,6 @@ _gdk_x11_screen_set_window_scale (GdkX11Screen *x11_screen,
g_signal_emit_by_name (GDK_SCREEN (x11_screen), "monitors-changed"); g_signal_emit_by_name (GDK_SCREEN (x11_screen), "monitors-changed");
} }
/*
* It is important that we first request the selection
* notification, and then setup the initial state of
* is_composited to avoid a race condition here.
*/
void
_gdk_x11_screen_setup (GdkScreen *screen)
{
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
gdk_display_request_selection_notification (x11_screen->display,
gdk_x11_xatom_to_atom_for_display (x11_screen->display, get_cm_atom (x11_screen)));
x11_screen->is_composited = check_is_composited (x11_screen->display, x11_screen);
}
static gboolean
gdk_x11_screen_is_composited (GdkScreen *screen)
{
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
return x11_screen->is_composited;
}
static void static void
init_randr_support (GdkScreen *screen) init_randr_support (GdkScreen *screen)
{ {
@ -1030,28 +990,6 @@ _gdk_x11_screen_window_manager_changed (GdkScreen *screen)
g_signal_emit (screen, signals[WINDOW_MANAGER_CHANGED], 0); g_signal_emit (screen, signals[WINDOW_MANAGER_CHANGED], 0);
} }
void
_gdk_x11_screen_process_owner_change (GdkScreen *screen,
XEvent *event)
{
#ifdef HAVE_XFIXES
XFixesSelectionNotifyEvent *selection_event = (XFixesSelectionNotifyEvent *)event;
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
if (selection_event->selection == get_cm_atom (x11_screen))
{
gboolean composited = selection_event->owner != None;
if (composited != x11_screen->is_composited)
{
x11_screen->is_composited = composited;
g_signal_emit_by_name (screen, "composited-changed");
}
}
#endif
}
static gboolean static gboolean
gdk_x11_screen_get_setting (GdkScreen *screen, gdk_x11_screen_get_setting (GdkScreen *screen,
const gchar *name, const gchar *name,
@ -1355,7 +1293,6 @@ gdk_x11_screen_class_init (GdkX11ScreenClass *klass)
screen_class->get_root_window = gdk_x11_screen_get_root_window; screen_class->get_root_window = gdk_x11_screen_get_root_window;
screen_class->get_system_visual = _gdk_x11_screen_get_system_visual; screen_class->get_system_visual = _gdk_x11_screen_get_system_visual;
screen_class->get_rgba_visual = gdk_x11_screen_get_rgba_visual; screen_class->get_rgba_visual = gdk_x11_screen_get_rgba_visual;
screen_class->is_composited = gdk_x11_screen_is_composited;
screen_class->get_setting = gdk_x11_screen_get_setting; screen_class->get_setting = gdk_x11_screen_get_setting;
screen_class->list_visuals = _gdk_x11_screen_list_visuals; screen_class->list_visuals = _gdk_x11_screen_list_visuals;

View File

@ -71,7 +71,6 @@ struct _GdkX11Screen
* fetch of window manager name * fetch of window manager name
*/ */
guint need_refetch_wm_name : 1; guint need_refetch_wm_name : 1;
guint is_composited : 1;
guint xft_init : 1; /* Whether we've intialized these values yet */ guint xft_init : 1; /* Whether we've intialized these values yet */
guint xft_antialias : 1; guint xft_antialias : 1;
guint xft_hinting : 1; guint xft_hinting : 1;
@ -102,13 +101,10 @@ GType _gdk_x11_screen_get_type (void);
GdkScreen * _gdk_x11_screen_new (GdkDisplay *display, GdkScreen * _gdk_x11_screen_new (GdkDisplay *display,
gint screen_number); gint screen_number);
void _gdk_x11_screen_setup (GdkScreen *screen);
void _gdk_x11_screen_update_visuals_for_gl (GdkScreen *screen); void _gdk_x11_screen_update_visuals_for_gl (GdkScreen *screen);
void _gdk_x11_screen_window_manager_changed (GdkScreen *screen); void _gdk_x11_screen_window_manager_changed (GdkScreen *screen);
void _gdk_x11_screen_size_changed (GdkScreen *screen, void _gdk_x11_screen_size_changed (GdkScreen *screen,
XEvent *event); XEvent *event);
void _gdk_x11_screen_process_owner_change (GdkScreen *screen,
XEvent *event);
void _gdk_x11_screen_get_edge_monitors (GdkScreen *screen, void _gdk_x11_screen_get_edge_monitors (GdkScreen *screen,
gint *top, gint *top,
gint *bottom, gint *bottom,

View File

@ -1579,9 +1579,11 @@ gtk_drag_set_icon_widget_internal (GdkDragContext *context,
if (!info->icon_window) if (!info->icon_window)
{ {
GdkDisplay *display;
GdkScreen *screen; GdkScreen *screen;
screen = gdk_window_get_screen (gdk_drag_context_get_source_window (context)); screen = gdk_window_get_screen (gdk_drag_context_get_source_window (context));
display = gdk_window_get_display (gdk_drag_context_get_source_window (context));
info->icon_window = gtk_window_new (GTK_WINDOW_POPUP); info->icon_window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_set_type_hint (GTK_WINDOW (info->icon_window), GDK_WINDOW_TYPE_HINT_DND); gtk_window_set_type_hint (GTK_WINDOW (info->icon_window), GDK_WINDOW_TYPE_HINT_DND);
@ -1589,7 +1591,7 @@ gtk_drag_set_icon_widget_internal (GdkDragContext *context,
gtk_widget_set_size_request (info->icon_window, 24, 24); gtk_widget_set_size_request (info->icon_window, 24, 24);
gtk_widget_set_events (info->icon_window, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); gtk_widget_set_events (info->icon_window, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
if (gdk_screen_is_composited (screen)) if (gdk_display_is_composited (display))
gtk_widget_set_app_paintable (info->icon_window, TRUE); gtk_widget_set_app_paintable (info->icon_window, TRUE);
gtk_window_set_hardcoded_window (GTK_WINDOW (info->icon_window), gtk_window_set_hardcoded_window (GTK_WINDOW (info->icon_window),
@ -1779,6 +1781,7 @@ gtk_drag_set_icon_surface (GdkDragContext *context,
cairo_surface_t *surface) cairo_surface_t *surface)
{ {
GtkWidget *window; GtkWidget *window;
GdkDisplay *display;
GdkScreen *screen; GdkScreen *screen;
GdkRectangle extents; GdkRectangle extents;
cairo_pattern_t *pattern; cairo_pattern_t *pattern;
@ -1789,6 +1792,7 @@ gtk_drag_set_icon_surface (GdkDragContext *context,
_gtk_cairo_surface_extents (surface, &extents); _gtk_cairo_surface_extents (surface, &extents);
display = gdk_window_get_display (gdk_drag_context_get_source_window (context));
screen = gdk_window_get_screen (gdk_drag_context_get_source_window (context)); screen = gdk_window_get_screen (gdk_drag_context_get_source_window (context));
window = gtk_window_new (GTK_WINDOW_POPUP); window = gtk_window_new (GTK_WINDOW_POPUP);
@ -1809,8 +1813,8 @@ gtk_drag_set_icon_surface (GdkDragContext *context,
g_signal_connect_data (window, g_signal_connect_data (window,
"draw", "draw",
gdk_screen_is_composited (screen) ? G_CALLBACK (gtk_drag_draw_icon_pattern) gdk_display_is_composited (display) ? G_CALLBACK (gtk_drag_draw_icon_pattern)
: G_CALLBACK (gtk_drag_draw_icon_pattern_and_background), : G_CALLBACK (gtk_drag_draw_icon_pattern_and_background),
pattern, pattern,
(GClosureNotify) cairo_pattern_destroy, (GClosureNotify) cairo_pattern_destroy,
G_CONNECT_AFTER); G_CONNECT_AFTER);

View File

@ -8849,7 +8849,7 @@ gtk_widget_propagate_screen_changed_recurse (GtkWidget *widget,
* *
* Whether @widget can rely on having its alpha channel * Whether @widget can rely on having its alpha channel
* drawn correctly. On X11 this function returns whether a * drawn correctly. On X11 this function returns whether a
* compositing manager is running for @widgets screen. * compositing manager is running for @widgets display.
* *
* Returns: %TRUE if the widget can rely on its alpha * Returns: %TRUE if the widget can rely on its alpha
* channel being drawn correctly. * channel being drawn correctly.
@ -8859,13 +8859,13 @@ gtk_widget_propagate_screen_changed_recurse (GtkWidget *widget,
gboolean gboolean
gtk_widget_is_composited (GtkWidget *widget) gtk_widget_is_composited (GtkWidget *widget)
{ {
GdkScreen *screen; GdkDisplay *display;
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
screen = gtk_widget_get_screen (widget); display = gtk_widget_get_display (widget);
return gdk_screen_is_composited (screen); return gdk_display_is_composited (display);
} }
/** /**

View File

@ -3928,37 +3928,21 @@ gtk_window_supports_client_shadow (GtkWindow *window)
{ {
GdkDisplay *display; GdkDisplay *display;
GdkScreen *screen; GdkScreen *screen;
GdkVisual *visual;
screen = _gtk_window_get_screen (window); screen = _gtk_window_get_screen (window);
display = gdk_screen_get_display (screen); display = gdk_screen_get_display (screen);
if (!gdk_display_is_rgba (display))
return FALSE;
if (!gdk_display_is_composited (display))
return FALSE;
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
if (GDK_IS_X11_DISPLAY (display)) if (GDK_IS_X11_DISPLAY (display))
{ {
if (!gdk_screen_is_composited (screen))
return FALSE;
if (!gdk_x11_screen_supports_net_wm_hint (screen, gdk_atom_intern_static_string ("_GTK_FRAME_EXTENTS"))) if (!gdk_x11_screen_supports_net_wm_hint (screen, gdk_atom_intern_static_string ("_GTK_FRAME_EXTENTS")))
return FALSE; return FALSE;
/* We need a visual with alpha */
visual = gdk_screen_get_rgba_visual (screen);
if (!visual)
return FALSE;
}
#endif
#ifdef GDK_WINDOWING_WIN32
if (GDK_IS_WIN32_DISPLAY (display))
{
if (!gdk_screen_is_composited (screen))
return FALSE;
/* We need a visual with alpha */
visual = gdk_screen_get_rgba_visual (screen);
if (!visual)
return FALSE;
} }
#endif #endif

View File

@ -479,7 +479,6 @@ init_display (GtkInspectorGeneral *gen)
screen = gdk_screen_get_default (); screen = gdk_screen_get_default ();
g_signal_connect (display, "notify", G_CALLBACK (populate_display_notify_cb), gen); g_signal_connect (display, "notify", G_CALLBACK (populate_display_notify_cb), gen);
g_signal_connect (screen, "composited-changed", G_CALLBACK (populate_display), gen);
g_signal_connect (screen, "monitors-changed", G_CALLBACK (populate_display), gen); g_signal_connect (screen, "monitors-changed", G_CALLBACK (populate_display), gen);
populate_display (screen, gen); populate_display (screen, gen);

View File

@ -275,10 +275,10 @@ on_highlight_widget (GtkWidget *button,
static void static void
deemphasize_window (GtkWidget *window) deemphasize_window (GtkWidget *window)
{ {
GdkScreen *screen; GdkDisplay *display;
screen = gtk_widget_get_screen (window); display = gtk_widget_get_display (window);
if (gdk_screen_is_composited (screen)) if (gdk_display_is_composited (display))
{ {
cairo_rectangle_int_t rect; cairo_rectangle_int_t rect;
cairo_region_t *region; cairo_region_t *region;
@ -296,10 +296,10 @@ deemphasize_window (GtkWidget *window)
static void static void
reemphasize_window (GtkWidget *window) reemphasize_window (GtkWidget *window)
{ {
GdkScreen *screen; GdkDisplay *display;
screen = gtk_widget_get_screen (window); display = gtk_widget_get_display (window);
if (gdk_screen_is_composited (screen)) if (gdk_display_is_composited (display))
{ {
gtk_widget_set_opacity (window, 1.0); gtk_widget_set_opacity (window, 1.0);
gtk_widget_input_shape_combine_region (window, NULL); gtk_widget_input_shape_combine_region (window, NULL);

View File

@ -222,15 +222,19 @@ build_alpha_widgets (void)
} }
static void static void
on_composited_changed (GdkScreen *screen, on_composited_changed (GdkDisplay *display,
GtkLabel *label) GParamSpec *pspec,
GtkLabel *label)
{ {
gboolean is_composited = gdk_screen_is_composited (screen); gboolean is_composited = gdk_display_is_composited (display);
if (is_composited) if (is_composited)
gtk_label_set_text (label, "Composited"); gtk_label_set_text (label, "Composited");
else else
gtk_label_set_text (label, "Not composited"); gtk_label_set_text (label, "Not composited");
/* We draw a different background on the GdkWindow */
gtk_widget_queue_draw (gtk_widget_get_toplevel (GTK_WIDGET (label)));
} }
void void
@ -243,7 +247,7 @@ create_alpha_window (GtkWidget *widget)
GtkWidget *content_area; GtkWidget *content_area;
GtkWidget *vbox; GtkWidget *vbox;
GtkWidget *label; GtkWidget *label;
GdkScreen *screen; GdkDisplay *display;
window = gtk_dialog_new_with_buttons ("Alpha Window", window = gtk_dialog_new_with_buttons ("Alpha Window",
GTK_WINDOW (gtk_widget_get_toplevel (widget)), 0, GTK_WINDOW (gtk_widget_get_toplevel (widget)), 0,
@ -265,9 +269,9 @@ create_alpha_window (GtkWidget *widget)
label = gtk_label_new (NULL); label = gtk_label_new (NULL);
gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE); gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE);
screen = gtk_widget_get_screen (window); display = gtk_widget_get_display (window);
on_composited_changed (screen, GTK_LABEL (label)); on_composited_changed (display, NULL, GTK_LABEL (label));
g_signal_connect (screen, "composited_changed", G_CALLBACK (on_composited_changed), label); g_signal_connect (display, "notify::composited", G_CALLBACK (on_composited_changed), label);
gtk_box_pack_start (GTK_BOX (vbox), build_alpha_widgets (), TRUE, TRUE); gtk_box_pack_start (GTK_BOX (vbox), build_alpha_widgets (), TRUE, TRUE);