static void gtk_offscreen_box_realize (GtkWidget *widget) { GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (widget); GdkWindowAttr attributes; gint attributes_mask; gint border_width; GtkRequisition child_requisition; int start_y = 0; gtk_widget_set_realized (widget, TRUE); border_width = GTK_CONTAINER (widget)->border_width; attributes.x = widget->allocation.x + border_width; attributes.y = widget->allocation.y + border_width; attributes.width = widget->allocation.width - 2 * border_width; attributes.height = widget->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.colormap = gtk_widget_get_colormap (widget); attributes.wclass = GDK_INPUT_OUTPUT; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, widget); g_signal_connect (widget->window, "pick-embedded-child", G_CALLBACK (pick_offscreen_child), offscreen_box); attributes.window_type = GDK_WINDOW_OFFSCREEN; /* Child 1 */ attributes.x = attributes.y = 0; if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1)) { attributes.width = offscreen_box->child1->allocation.width; attributes.height = offscreen_box->child1->allocation.height; start_y += offscreen_box->child1->allocation.height; } offscreen_box->offscreen_window1 = gdk_window_new (gtk_widget_get_root_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (offscreen_box->offscreen_window1, widget); if (offscreen_box->child1) gtk_widget_set_parent_window (offscreen_box->child1, offscreen_box->offscreen_window1); gdk_offscreen_window_set_embedder (offscreen_box->offscreen_window1, widget->window); g_signal_connect (offscreen_box->offscreen_window1, "to-embedder", G_CALLBACK (offscreen_window_to_parent1), offscreen_box); g_signal_connect (offscreen_box->offscreen_window1, "from-embedder", G_CALLBACK (offscreen_window_from_parent1), offscreen_box); /* Child 2 */ attributes.y = start_y; child_requisition.width = child_requisition.height = 0; if (offscreen_box->child2 && gtk_widget_get_visible (offscreen_box->child2)) { attributes.width = offscreen_box->child2->allocation.width; attributes.height = offscreen_box->child2->allocation.height; } offscreen_box->offscreen_window2 = gdk_window_new (gtk_widget_get_root_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (offscreen_box->offscreen_window2, widget); if (offscreen_box->child2) gtk_widget_set_parent_window (offscreen_box->child2, offscreen_box->offscreen_window2); gdk_offscreen_window_set_embedder (offscreen_box->offscreen_window2, widget->window); g_signal_connect (offscreen_box->offscreen_window2, "to-embedder", G_CALLBACK (offscreen_window_to_parent2), offscreen_box); g_signal_connect (offscreen_box->offscreen_window2, "from-embedder", G_CALLBACK (offscreen_window_from_parent2), offscreen_box); 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, offscreen_box->offscreen_window1, GTK_STATE_NORMAL); gtk_style_set_background (widget->style, offscreen_box->offscreen_window2, GTK_STATE_NORMAL); gdk_window_show (offscreen_box->offscreen_window1); gdk_window_show (offscreen_box->offscreen_window2); }
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 gtk_mirror_bin_realize (GtkWidget *widget) { GtkMirrorBin *bin = GTK_MIRROR_BIN (widget); GdkWindowAttr attributes; gint attributes_mask; gint border_width; GtkRequisition child_requisition; gtk_widget_set_realized (widget, TRUE); border_width = GTK_CONTAINER (widget)->border_width; attributes.x = widget->allocation.x + border_width; attributes.y = widget->allocation.y + border_width; attributes.width = widget->allocation.width - 2 * border_width; attributes.height = widget->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.colormap = gtk_widget_get_colormap (widget); attributes.wclass = GDK_INPUT_OUTPUT; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, widget); g_signal_connect (widget->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)) { attributes.width = bin->child->allocation.width; attributes.height = bin->child->allocation.height; } bin->offscreen_window = gdk_window_new (gtk_widget_get_root_window (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, widget->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); 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, bin->offscreen_window, GTK_STATE_NORMAL); gdk_window_show (bin->offscreen_window); }
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); } }
void gimp_overlay_child_realize (GimpOverlayBox *box, GimpOverlayChild *child) { GtkWidget *widget; GdkDisplay *display; GdkScreen *screen; GdkColormap *colormap; GtkAllocation child_allocation; GdkWindowAttr attributes; gint attributes_mask; g_return_if_fail (GIMP_IS_OVERLAY_BOX (box)); g_return_if_fail (child != NULL); widget = GTK_WIDGET (box); display = gtk_widget_get_display (widget); screen = gtk_widget_get_screen (widget); colormap = gdk_screen_get_rgba_colormap (screen); if (colormap) gtk_widget_set_colormap (child->widget, colormap); gtk_widget_get_allocation (child->widget, &child_allocation); if (gtk_widget_get_visible (child->widget)) { attributes.width = child_allocation.width; attributes.height = child_allocation.height; } else { attributes.width = 1; attributes.height = 1; } attributes.x = child_allocation.x; attributes.y = child_allocation.y; attributes.window_type = GDK_WINDOW_OFFSCREEN; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (child->widget); attributes.colormap = gtk_widget_get_colormap (child->widget); attributes.event_mask = GDK_EXPOSURE_MASK; attributes.cursor = gdk_cursor_new_for_display (display, GDK_LEFT_PTR); attributes_mask = (GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_CURSOR); child->window = gdk_window_new (gtk_widget_get_root_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (child->window, widget); gtk_widget_set_parent_window (child->widget, child->window); gdk_offscreen_window_set_embedder (child->window, gtk_widget_get_window (widget)); gdk_cursor_unref (attributes.cursor); g_signal_connect (child->window, "from-embedder", G_CALLBACK (gimp_overlay_child_from_embedder), child); g_signal_connect (child->window, "to-embedder", G_CALLBACK (gimp_overlay_child_to_embedder), child); gtk_style_set_background (gtk_widget_get_style (widget), child->window, GTK_STATE_NORMAL); gdk_window_show (child->window); }
static void gtk_offscreen_box_realize (GtkWidget *widget) { GtkOffscreenBox *offscreen_box = GTK_OFFSCREEN_BOX (widget); GtkAllocation allocation, child_area; GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; guint border_width; GtkRequisition child_requisition; int start_y = 0; 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; 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), offscreen_box); attributes.window_type = GDK_WINDOW_OFFSCREEN; /* Child 1 */ attributes.x = attributes.y = 0; if (offscreen_box->child1 && gtk_widget_get_visible (offscreen_box->child1)) { gtk_widget_get_allocation (offscreen_box->child1, &child_area); attributes.width = child_area.width; attributes.height = child_area.height; start_y += child_area.height; } offscreen_box->offscreen_window1 = gdk_window_new (gdk_screen_get_root_window (gtk_widget_get_screen (widget)), &attributes, attributes_mask); gdk_window_set_user_data (offscreen_box->offscreen_window1, widget); if (offscreen_box->child1) gtk_widget_set_parent_window (offscreen_box->child1, offscreen_box->offscreen_window1); gdk_offscreen_window_set_embedder (offscreen_box->offscreen_window1, window); g_signal_connect (offscreen_box->offscreen_window1, "to-embedder", G_CALLBACK (offscreen_window_to_parent1), offscreen_box); g_signal_connect (offscreen_box->offscreen_window1, "from-embedder", G_CALLBACK (offscreen_window_from_parent1), offscreen_box); /* Child 2 */ attributes.y = start_y; child_requisition.width = child_requisition.height = 0; if (offscreen_box->child2 && gtk_widget_get_visible (offscreen_box->child2)) { gtk_widget_get_allocation (offscreen_box->child2, &child_area); attributes.width = child_area.width; attributes.height = child_area.height; } offscreen_box->offscreen_window2 = gdk_window_new (gdk_screen_get_root_window (gtk_widget_get_screen (widget)), &attributes, attributes_mask); gdk_window_set_user_data (offscreen_box->offscreen_window2, widget); if (offscreen_box->child2) gtk_widget_set_parent_window (offscreen_box->child2, offscreen_box->offscreen_window2); gdk_offscreen_window_set_embedder (offscreen_box->offscreen_window2, window); g_signal_connect (offscreen_box->offscreen_window2, "create-surface", G_CALLBACK (gdk_offscreen_box_create_alpha_image_surface), offscreen_box); g_signal_connect (offscreen_box->offscreen_window2, "to-embedder", G_CALLBACK (offscreen_window_to_parent2), offscreen_box); g_signal_connect (offscreen_box->offscreen_window2, "from-embedder", G_CALLBACK (offscreen_window_from_parent2), offscreen_box); gdk_window_show (offscreen_box->offscreen_window1); gdk_window_show (offscreen_box->offscreen_window2); }