static void gtk_revealer_real_realize (GtkWidget *widget) { GtkRevealer *revealer = GTK_REVEALER (widget); GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer); GtkAllocation allocation; GdkWindowAttr attributes = { 0 }; GdkWindowAttributesType attributes_mask; GtkAllocation child_allocation; GtkWidget *child; GtkStyleContext *context; GtkRevealerTransitionType transition; gtk_widget_set_realized (widget, TRUE); gtk_widget_get_allocation (widget, &allocation); attributes.x = allocation.x; attributes.y = allocation.y; attributes.width = allocation.width; attributes.height = allocation.height; attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK; attributes_mask = (GDK_WA_X | GDK_WA_Y) | GDK_WA_VISUAL; priv->view_window = gdk_window_new (gtk_widget_get_parent_window ((GtkWidget*) revealer), &attributes, attributes_mask); gtk_widget_set_window (widget, priv->view_window); gtk_widget_register_window (widget, priv->view_window); gtk_revealer_get_child_allocation (revealer, &allocation, &child_allocation); attributes.x = 0; attributes.y = 0; attributes.width = child_allocation.width; attributes.height = child_allocation.height; transition = effective_transition (revealer); if (transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN) attributes.y = allocation.height - child_allocation.height; else if (transition == GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT) attributes.x = allocation.width - child_allocation.width; priv->bin_window = gdk_window_new (priv->view_window, &attributes, attributes_mask); gtk_widget_register_window (widget, priv->bin_window); child = gtk_bin_get_child (GTK_BIN (revealer)); if (child != NULL) gtk_widget_set_parent_window (child, priv->bin_window); context = gtk_widget_get_style_context (widget); gtk_style_context_set_background (context, priv->view_window); gtk_style_context_set_background (context, priv->bin_window); gdk_window_show (priv->bin_window); }
static void ViewOvBoxSetBackground(ViewOvBox *that) // IN { GtkWidget *widget = GTK_WIDGET(that); GtkStyleContext *stylecontext; stylecontext = gtk_widget_get_style_context(widget); gtk_style_context_set_background(stylecontext, gtk_widget_get_window(widget)); gtk_style_context_set_background(stylecontext, that->priv->underWin); gtk_style_context_set_background(stylecontext, that->priv->overWin); }
static void gtk_notification_realize (GtkWidget *widget) { GtkNotification *notification = GTK_NOTIFICATION (widget); GtkNotificationPrivate *priv = notification->priv; GtkBin *bin = GTK_BIN (widget); GtkAllocation allocation; GtkStyleContext *context; GtkWidget *child; GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; gtk_widget_set_realized (widget, TRUE); gtk_widget_get_allocation (widget, &allocation); attributes.x = allocation.x; attributes.y = allocation.y; attributes.width = allocation.width; attributes.height = allocation.height; attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gtk_widget_set_window (widget, window); gdk_window_set_user_data (window, notification); attributes.x = 0; attributes.y = attributes.height + priv->animate_y; attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK | GDK_VISIBILITY_NOTIFY_MASK; priv->bin_window = gdk_window_new (window, &attributes, attributes_mask); gdk_window_set_user_data (priv->bin_window, notification); child = gtk_bin_get_child (bin); if (child) gtk_widget_set_parent_window (child, priv->bin_window); gtk_widget_set_parent_window (priv->close_button, priv->bin_window); context = gtk_widget_get_style_context (widget); gtk_style_context_set_background (context, window); gtk_style_context_set_background (context, priv->bin_window); gdk_window_show (priv->bin_window); }
static void gtk_revealer_real_style_updated (GtkWidget *widget) { GtkRevealer *revealer = GTK_REVEALER (widget); GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer); GtkStyleContext* context; GTK_WIDGET_CLASS (gtk_revealer_parent_class)->style_updated (widget); if (gtk_widget_get_realized (widget)) { context = gtk_widget_get_style_context (widget); gtk_style_context_set_background (context, priv->bin_window); gtk_style_context_set_background (context, priv->view_window); } }
static void rc_ui_scrollable_label_realize(GtkWidget *widget) { RCUiScrollableLabel *label; GdkWindowAttr attributes; GtkAllocation allocation; GdkWindow *window, *parent; gint attr_mask; GtkStyleContext *context; g_return_if_fail(widget!=NULL); g_return_if_fail(RC_UI_IS_SCROLLABLE_LABEL(widget)); label = RC_UI_SCROLLABLE_LABEL(widget); gtk_widget_set_realized(widget, TRUE); gtk_widget_get_allocation(widget, &allocation); attributes.x = allocation.x; attributes.y = allocation.y; attributes.width = allocation.width; attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.window_type = GDK_WINDOW_CHILD; attributes.event_mask = gtk_widget_get_events(widget); attributes.event_mask |= (GDK_EXPOSURE_MASK); attributes.visual = gtk_widget_get_visual(widget); attr_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; gtk_widget_set_has_window(widget, TRUE); parent = gtk_widget_get_parent_window(widget); window = gdk_window_new(parent, &attributes, attr_mask); gtk_widget_set_window(widget, window); gdk_window_set_user_data(window, label); gdk_window_set_background_pattern(window, NULL); context = gtk_widget_get_style_context(widget); gtk_style_context_set_background(context, window); gdk_window_show(window); }
static void gtk_notification_style_updated (GtkWidget *widget) { GTK_WIDGET_CLASS (gtk_notification_parent_class)->style_updated (widget); if (gtk_widget_get_realized (widget)) { GtkStyleContext *context; GtkNotification *notification = GTK_NOTIFICATION (widget); GtkNotificationPrivate *priv = notification->priv; context = gtk_widget_get_style_context (widget); gtk_style_context_set_background (context, priv->bin_window); gtk_style_context_set_background (context, gtk_widget_get_window (widget)); } }
static void ddb_tabstrip_realize (GtkWidget *widget) { DdbTabStrip *darea = DDB_TABSTRIP (widget); GdkWindowAttr attributes; gint attributes_mask; if (!gtk_widget_get_has_window (widget)) { GTK_WIDGET_CLASS (ddb_tabstrip_parent_class)->realize (widget); } else { gtk_widget_set_realized (widget, TRUE); attributes.window_type = GDK_WINDOW_CHILD; GtkAllocation a; gtk_widget_get_allocation (widget, &a); attributes.x = a.x; attributes.y = a.y; attributes.width = a.width; attributes.height = a.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); #if !GTK_CHECK_VERSION(3,0,0) attributes.colormap = gtk_widget_get_colormap (widget); #endif attributes.event_mask = gtk_widget_get_events (widget); attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; #if !GTK_CHECK_VERSION(3,0,0) attributes_mask |= GDK_WA_COLORMAP; #endif GdkWindow *window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gtk_widget_set_window(widget, window); gdk_window_set_user_data (gtk_widget_get_window(widget), darea); #if !GTK_CHECK_VERSION(3,0,0) widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); #else gtk_style_context_set_background (gtk_widget_get_style_context (widget), window); #endif } ddb_tabstrip_send_configure (DDB_TABSTRIP (widget)); GtkTargetEntry entry = { .target = TARGET_PLAYITEMS, .flags = GTK_TARGET_SAME_APP, .info = TARGET_SAMEWIDGET }; gtk_drag_dest_set (widget, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, &entry, 1, GDK_ACTION_COPY | GDK_ACTION_MOVE); gtk_drag_dest_add_uri_targets (widget); gtk_drag_dest_set_track_motion (widget, TRUE); }
static void ViewOvBoxSetBackground(ViewOvBox *that) // IN { GtkWidget *widget = GTK_WIDGET(that); #if GTK_CHECK_VERSION(3, 0, 0) GtkStyleContext *stylecontext; stylecontext = gtk_widget_get_style_context(widget); gtk_style_context_set_background(stylecontext, gtk_widget_get_window(widget)); gtk_style_context_set_background(stylecontext, that->priv->underWin); gtk_style_context_set_background(stylecontext, that->priv->overWin); #else GtkStyle *style; style = gtk_widget_get_style (widget); gtk_style_set_background(style, gtk_widget_get_window(widget), GTK_STATE_NORMAL); gtk_style_set_background(style, that->priv->underWin, GTK_STATE_NORMAL); gtk_style_set_background(style, that->priv->overWin, GTK_STATE_NORMAL); #endif }
static void gtk_rotated_bin_realize (GtkWidget *widget) { GtkRotatedBin *bin = GTK_ROTATED_BIN (widget); GtkAllocation allocation; GtkStyleContext *context; GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; guint border_width; GtkRequisition child_requisition; gtk_widget_set_realized (widget, TRUE); gtk_widget_get_allocation (widget, &allocation); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); attributes.x = allocation.x + border_width; attributes.y = allocation.y + border_width; attributes.width = allocation.width - 2 * border_width; attributes.height = allocation.height - 2 * border_width; attributes.window_type = GDK_WINDOW_CHILD; attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK; attributes.visual = gtk_widget_get_visual (widget); attributes.wclass = GDK_INPUT_OUTPUT; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gtk_widget_set_window (widget, window); gdk_window_set_user_data (window, widget); g_signal_connect (window, "pick-embedded-child", G_CALLBACK (pick_offscreen_child), bin); attributes.window_type = GDK_WINDOW_OFFSCREEN; child_requisition.width = child_requisition.height = 0; if (bin->child && gtk_widget_get_visible (bin->child)) { GtkAllocation child_allocation; gtk_widget_get_allocation (bin->child, &child_allocation); attributes.width = child_allocation.width; attributes.height = child_allocation.height; } bin->offscreen_window = gdk_window_new (gdk_screen_get_root_window (gtk_widget_get_screen (widget)), &attributes, attributes_mask); gdk_window_set_user_data (bin->offscreen_window, widget); if (bin->child) gtk_widget_set_parent_window (bin->child, bin->offscreen_window); gdk_offscreen_window_set_embedder (bin->offscreen_window, window); g_signal_connect (bin->offscreen_window, "to-embedder", G_CALLBACK (offscreen_window_to_parent), bin); g_signal_connect (bin->offscreen_window, "from-embedder", G_CALLBACK (offscreen_window_from_parent), bin); context = gtk_widget_get_style_context (widget); gtk_style_context_set_background (context, window); gtk_style_context_set_background (context, bin->offscreen_window); gdk_window_show (bin->offscreen_window); }
static void gs_theme_window_real_realize (GtkWidget *widget) { GdkWindow *window; Window remote_xwindow; GtkRequisition requisition; GtkAllocation allocation; const char *preview_xid; int x; int y; int width; int height; int event_mask; event_mask = 0; window = NULL; preview_xid = g_getenv ("XSCREENSAVER_WINDOW"); if (preview_xid != NULL) { char *end; remote_xwindow = (Window) strtoul (preview_xid, &end, 0); if ((remote_xwindow != 0) && (end != NULL) && ((*end == ' ') || (*end == '\0')) && ((remote_xwindow < G_MAXULONG) || (errno != ERANGE))) { window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), remote_xwindow); if (window != NULL) { /* This is a kludge; we need to set the same * flags gs-window-x11.c does, to ensure they * don't get unset by gtk_window_map() later. */ gtk_window_set_decorated (GTK_WINDOW (widget), FALSE); gtk_window_set_skip_taskbar_hint (GTK_WINDOW (widget), TRUE); gtk_window_set_skip_pager_hint (GTK_WINDOW (widget), TRUE); gtk_window_set_keep_above (GTK_WINDOW (widget), TRUE); gtk_window_fullscreen (GTK_WINDOW (widget)); event_mask = GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK; gtk_widget_set_events (widget, gtk_widget_get_events (widget) | event_mask); } } } if (window == NULL) { GtkWidgetClass *parent_class; parent_class = GTK_WIDGET_CLASS (gs_theme_window_parent_class); if (parent_class->realize != NULL) parent_class->realize (widget); return; } gtk_style_context_set_background (gtk_widget_get_style_context (widget), window); gdk_window_set_decorations (window, (GdkWMDecoration) 0); gdk_window_set_events (window, gdk_window_get_events (window) | event_mask); gtk_widget_set_window (widget, window); gdk_window_set_user_data (window, widget); gtk_widget_set_realized (widget, TRUE); gdk_window_get_geometry (window, &x, &y, &width, &height); if (width < MIN_SIZE || height < MIN_SIZE) { g_critical ("This window is way too small to use"); exit (1); } gtk_widget_get_preferred_size (widget, &requisition, NULL); allocation.x = x; allocation.y = y; allocation.width = width; allocation.height = height; gtk_widget_size_allocate (widget, &allocation); gtk_window_resize (GTK_WINDOW (widget), width, height); }
static void widget_overlay_realize (GtkWidget *widget) { WidgetOverlay *ovl = WIDGET_OVERLAY (widget); GdkWindowAttr attributes; gint attributes_mask; gint border_width; GtkRequisition child_requisition; GtkAllocation allocation; gtk_widget_set_realized (widget, TRUE); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); gtk_widget_get_allocation (widget, &allocation); attributes.x = allocation.x + border_width; attributes.y = allocation.y + border_width; attributes.width = allocation.width - 2 * border_width; attributes.height = allocation.height - 2 * border_width; attributes.window_type = GDK_WINDOW_CHILD; attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK; attributes.visual = gtk_widget_get_visual (widget); attributes.wclass = GDK_INPUT_OUTPUT; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; GdkWindow *win; win = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gtk_widget_set_window (widget, win); gdk_window_set_user_data (win, widget); g_signal_connect (win, "pick-embedded-child", G_CALLBACK (pick_offscreen_child), ovl); GtkStyleContext *style; style = gtk_widget_get_style_context (widget); gtk_style_context_set_background (style, win); /* offscreen windows */ attributes.window_type = GDK_WINDOW_OFFSCREEN; GList *list; for (list = ovl->priv->children; list; list = list->next) { ChildData *cd = (ChildData*) list->data; child_requisition.width = child_requisition.height = 0; if (gtk_widget_get_visible (cd->child)) { GtkAllocation allocation; gtk_widget_get_allocation (cd->child, &allocation); attributes.width = allocation.width; attributes.height = allocation.height; } cd->offscreen_window = gdk_window_new (NULL, &attributes, attributes_mask); gdk_window_set_user_data (cd->offscreen_window, widget); gtk_widget_set_parent_window (cd->child, cd->offscreen_window); gdk_offscreen_window_set_embedder (cd->offscreen_window, win); g_signal_connect (cd->offscreen_window, "to-embedder", G_CALLBACK (offscreen_window_to_parent), ovl); g_signal_connect (cd->offscreen_window, "from-embedder", G_CALLBACK (offscreen_window_from_parent), ovl); gtk_style_context_set_background (style, cd->offscreen_window); gdk_window_show (cd->offscreen_window); } }
static void gtk_form_attach_child_window(GtkForm *form, GtkFormChild *child) { if (child->window != NULL) return; /* been there, done that */ if (!gtk_widget_get_has_window(child->widget)) { GtkWidget *widget; GdkWindowAttr attributes; gint attributes_mask; GtkRequisition requisition; widget = GTK_WIDGET(form); #if GTK_CHECK_VERSION(3,0,0) gtk_widget_get_preferred_size(child->widget, &requisition, NULL); #else requisition = child->widget->requisition; #endif attributes.window_type = GDK_WINDOW_CHILD; attributes.x = child->x; attributes.y = child->y; attributes.width = requisition.width; attributes.height = requisition.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual(widget); #if !GTK_CHECK_VERSION(3,0,0) attributes.colormap = gtk_widget_get_colormap(widget); #endif attributes.event_mask = GDK_EXPOSURE_MASK; #if GTK_CHECK_VERSION(3,0,0) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; #else attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; #endif child->window = gdk_window_new(form->bin_window, &attributes, attributes_mask); gdk_window_set_user_data(child->window, widget); #if GTK_CHECK_VERSION(3,0,0) { GtkStyleContext * const sctx = gtk_widget_get_style_context(widget); gtk_style_context_set_state(sctx, GTK_STATE_FLAG_NORMAL); # if !GTK_CHECK_VERSION(3,18,0) gtk_style_context_set_background(sctx, child->window); # endif } #else gtk_style_set_background(widget->style, child->window, GTK_STATE_NORMAL); #endif gtk_widget_set_parent_window(child->widget, child->window); /* * Install signal handlers to map/unmap child->window * alongside with the actual widget. */ g_signal_connect(G_OBJECT(child->widget), "map", G_CALLBACK(>k_form_child_map), child); g_signal_connect(G_OBJECT(child->widget), "unmap", G_CALLBACK(>k_form_child_unmap), child); } else if (!gtk_widget_get_realized(child->widget)) { gtk_widget_set_parent_window(child->widget, form->bin_window); } }
static void gtk_form_realize(GtkWidget *widget) { GList *tmp_list; GtkForm *form; GdkWindowAttr attributes; gint attributes_mask; GtkAllocation allocation; g_return_if_fail(GTK_IS_FORM(widget)); form = GTK_FORM(widget); gtk_widget_set_realized(widget, TRUE); gtk_widget_get_allocation(widget, &allocation); attributes.window_type = GDK_WINDOW_CHILD; attributes.x = allocation.x; attributes.y = allocation.y; attributes.width = allocation.width; attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual(widget); #if GTK_CHECK_VERSION(3,0,0) attributes.event_mask = GDK_EXPOSURE_MASK; #else attributes.colormap = gtk_widget_get_colormap(widget); attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK; #endif #if GTK_CHECK_VERSION(3,0,0) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; #else attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; #endif gtk_widget_set_window(widget, gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributes_mask)); gdk_window_set_user_data(gtk_widget_get_window(widget), widget); attributes.x = 0; attributes.y = 0; attributes.event_mask = gtk_widget_get_events(widget); form->bin_window = gdk_window_new(gtk_widget_get_window(widget), &attributes, attributes_mask); gdk_window_set_user_data(form->bin_window, widget); #if GTK_CHECK_VERSION(3,0,0) { GtkStyleContext * const sctx = gtk_widget_get_style_context(widget); gtk_style_context_add_class(sctx, "gtk-form"); gtk_style_context_set_state(sctx, GTK_STATE_FLAG_NORMAL); # if !GTK_CHECK_VERSION(3,18,0) gtk_style_context_set_background(sctx, gtk_widget_get_window(widget)); gtk_style_context_set_background(sctx, form->bin_window); # endif } #else widget->style = gtk_style_attach(widget->style, widget->window); gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL); gtk_style_set_background(widget->style, form->bin_window, GTK_STATE_NORMAL); #endif for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) { GtkFormChild *child = tmp_list->data; gtk_form_attach_child_window(form, child); if (gtk_widget_get_visible(child->widget)) gtk_form_realize_child(form, child); } }