static void na_tray_manager_set_visual_property (NaTrayManager *manager) { #ifdef GDK_WINDOWING_X11 GdkWindow *window; GdkDisplay *display; Visual *xvisual; Atom visual_atom; gulong data[1]; if (!manager->invisible) return; window = gtk_widget_get_window (manager->invisible); if (!window) return; /* The visual property is a hint to the tray icons as to what visual they * should use for their windows. If the X server has RGBA colormaps, then * we tell the tray icons to use a RGBA colormap and we'll composite the * icon onto its parents with real transparency. Otherwise, we just tell * the icon to use our colormap, and we'll do some hacks with parent * relative backgrounds to simulate transparency. */ display = gtk_widget_get_display (manager->invisible); visual_atom = gdk_x11_get_xatom_by_name_for_display (display, "_NET_SYSTEM_TRAY_VISUAL"); if (gdk_screen_get_rgba_visual (manager->screen) != NULL && gdk_display_supports_composite (display)) { xvisual = GDK_VISUAL_XVISUAL (gdk_screen_get_rgba_visual (manager->screen)); } else { /* We actually want the visual of the tray where the icons will * be embedded. In almost all cases, this will be the same as the visual * of the screen. */ GdkColormap *colormap; colormap = gdk_screen_get_default_colormap (manager->screen); xvisual = GDK_VISUAL_XVISUAL (gdk_colormap_get_visual (colormap)); } data[0] = XVisualIDFromVisual (xvisual); XChangeProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XWINDOW (window), visual_atom, XA_VISUALID, 32, PropModeReplace, (guchar *) &data, 1); #endif }
GtkWidget * na_tray_child_new (GdkScreen *screen, Window icon_window) { XWindowAttributes window_attributes; Display *xdisplay; NaTrayChild *child; GdkVisual *visual; gboolean visual_has_alpha; int red_prec, green_prec, blue_prec, depth; int result; g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL); g_return_val_if_fail (icon_window != None, NULL); xdisplay = GDK_SCREEN_XDISPLAY (screen); /* We need to determine the visual of the window we are embedding and create * the socket in the same visual. */ gdk_error_trap_push (); result = XGetWindowAttributes (xdisplay, icon_window, &window_attributes); gdk_error_trap_pop_ignored (); if (!result) /* Window already gone */ return NULL; visual = gdk_x11_screen_lookup_visual (screen, window_attributes.visual->visualid); if (!visual) /* Icon window is on another screen? */ return NULL; child = g_object_new (NA_TYPE_TRAY_CHILD, NULL); child->icon_window = icon_window; gtk_widget_set_visual (GTK_WIDGET (child), visual); /* We have alpha if the visual has something other than red, green, * and blue */ gdk_visual_get_red_pixel_details (visual, NULL, NULL, &red_prec); gdk_visual_get_green_pixel_details (visual, NULL, NULL, &green_prec); gdk_visual_get_blue_pixel_details (visual, NULL, NULL, &blue_prec); depth = gdk_visual_get_depth (visual); visual_has_alpha = red_prec + blue_prec + green_prec < depth; child->has_alpha = (visual_has_alpha && gdk_display_supports_composite (gdk_screen_get_display (screen))); child->composited = child->has_alpha; return GTK_WIDGET (child); }
static VALUE rg_supports_composite_p(VALUE self) { return CBOOL2RVAL(gdk_display_supports_composite(_SELF(self))); }
bool Ctrl::IsCompositedGui() { GuiLock __; static bool b = gdk_display_supports_composite(gdk_display_get_default()); return b; }
GtkWidget * na_tray_child_new (GdkScreen *screen, Window icon_window) { XWindowAttributes window_attributes; Display *xdisplay; NaTrayChild *child; GdkVisual *visual; gboolean visual_has_alpha; GdkColormap *colormap; gboolean new_colormap; int result; g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL); g_return_val_if_fail (icon_window != None, NULL); xdisplay = GDK_SCREEN_XDISPLAY (screen); /* We need to determine the visual of the window we are embedding and create * the socket in the same visual. */ gdk_error_trap_push (); result = XGetWindowAttributes (xdisplay, icon_window, &window_attributes); gdk_error_trap_pop (); if (!result) /* Window already gone */ return NULL; visual = gdk_x11_screen_lookup_visual (screen, window_attributes.visual->visualid); if (!visual) /* Icon window is on another screen? */ return NULL; new_colormap = FALSE; if (visual == gdk_screen_get_rgb_visual (screen)) colormap = gdk_screen_get_rgb_colormap (screen); else if (visual == gdk_screen_get_rgba_visual (screen)) colormap = gdk_screen_get_rgba_colormap (screen); else if (visual == gdk_screen_get_system_visual (screen)) colormap = gdk_screen_get_system_colormap (screen); else { colormap = gdk_colormap_new (visual, FALSE); new_colormap = TRUE; } child = g_object_new (NA_TYPE_TRAY_CHILD, NULL); child->icon_window = icon_window; gtk_widget_set_colormap (GTK_WIDGET (child), colormap); /* We have alpha if the visual has something other than red, green, * and blue */ visual_has_alpha = visual->red_prec + visual->blue_prec + visual->green_prec < visual->depth; child->has_alpha = (visual_has_alpha && gdk_display_supports_composite (gdk_screen_get_display (screen))); child->composited = child->has_alpha; if (new_colormap) g_object_unref (colormap); return GTK_WIDGET (child); }