static void scope_realize(GtkWidget *widget) { Scope *scope; GdkWindowAttr attributes; gint attributes_mask; GdkGCValues gc_values; GtkAllocation allocation; GdkWindow *window; GtkStyle *style; g_return_if_fail(widget != NULL); g_return_if_fail(IS_SCOPE(widget)); scope = SCOPE(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); attributes.colormap = gtk_widget_get_colormap(widget); attributes.event_mask = gtk_widget_get_events(widget) | GDK_EXPOSURE_MASK; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; gtk_widget_set_has_window(widget, TRUE); 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, scope); gtk_widget_style_attach(widget); style = gtk_widget_get_style(widget); gtk_style_set_background(style, window, GTK_STATE_NORMAL); /* gc's if necessary */ if (!gdk_colormap_alloc_color(style->colormap, &scope->tracecol, FALSE, TRUE)) g_warning("unable to allocate color: ( %d %d %d )", scope->tracecol.red, scope->tracecol.green, scope->tracecol.blue); gc_values.foreground = scope->tracecol; scope->trace_gc = gtk_gc_get(style->depth, style->colormap, &gc_values, GDK_GC_FOREGROUND); if (!gdk_colormap_alloc_color(style->colormap, &scope->gridcol, FALSE, TRUE)) g_warning("unable to allocate color: ( %d %d %d )", scope->gridcol.red, scope->gridcol.green, scope->gridcol.blue); gc_values.foreground = scope->gridcol; scope->grid_gc = gtk_gc_get(style->depth, style->colormap, &gc_values, GDK_GC_FOREGROUND); /* create backing store */ scope->pixmap = gdk_pixmap_new(window, SCOPE_WIDTH, SCOPE_HEIGHT, -1); scope_send_configure(SCOPE(widget)); }
static void hand_display_realize (GtkWidget *widget) { GdkWindowAttr attributes; gint attributes_mask; g_return_if_fail (widget != NULL); g_return_if_fail (IS_HAND_DISPLAY (widget)); gtk_widget_set_realized (widget, TRUE); GtkAllocation allocation; 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) | GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK; attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; GdkWindow *window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gtk_widget_set_window (widget, window); gtk_widget_style_attach (widget); gdk_window_set_user_data (window, widget); gtk_style_set_background (gtk_widget_get_style (widget), window, GTK_STATE_ACTIVE); }
static void anjuta_tabber_realize (GtkWidget *widget) { GdkWindow* window; GdkWindowAttr attributes; GtkAllocation allocation; AnjutaTabber* tabber = ANJUTA_TABBER (widget); gtk_widget_set_realized (widget, TRUE); window = gtk_widget_get_parent_window (widget); gtk_widget_set_window (widget, window); g_object_ref (window); 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_ONLY; attributes.event_mask = gtk_widget_get_events (widget); attributes.event_mask |= (GDK_BUTTON_PRESS_MASK); tabber->priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, GDK_WA_X | GDK_WA_Y); gdk_window_set_user_data (tabber->priv->event_window, tabber); gtk_widget_style_attach (widget); }
static void bytes_view_realize(GtkWidget *widget) { BytesView *bv; GdkWindowAttr attributes; GtkAllocation allocation; GdkWindow *win; #if GTK_CHECK_VERSION(3, 0, 0) GtkStyleContext *context; #endif _gtk_widget_set_realized_true(widget); bv = BYTES_VIEW(widget); 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); attributes.event_mask = gtk_widget_get_events(widget) | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK; #if !GTK_CHECK_VERSION(3, 0, 0) attributes.colormap = gtk_widget_get_colormap(widget); win = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP); #else win = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL); #endif gtk_widget_set_window(widget, win); #if GTK_CHECK_VERSION(3, 8, 0) gtk_widget_register_window(widget, win); #else gdk_window_set_user_data(win, widget); #endif #if !GTK_CHECK_VERSION(3, 0, 0) /* XXX, check */ gdk_window_set_back_pixmap(win, NULL, FALSE); #endif #if GTK_CHECK_VERSION(3, 0, 0) context = gtk_widget_get_style_context(widget); gtk_style_context_add_class(context, GTK_STYLE_CLASS_VIEW); /* gtk_style_context_add_class(context, GTK_STYLE_CLASS_ENTRY); */ #elif GTK_CHECK_VERSION(2, 20, 0) gtk_widget_style_attach(widget); #else widget->style = gtk_style_attach(widget->style, win); #endif bytes_view_ensure_layout(bv); }
static void gtk_mirror_bin_realize (GtkWidget *widget) { GtkMirrorBin *bin = GTK_MIRROR_BIN (widget); GdkWindowAttr attributes; GdkWindow *gdk_window; gint attributes_mask; gint border_width; GtkRequisition child_requisition; GtkAllocation widget_allocation, bin_child_allocation; GtkStyle *style; gtk_widget_set_realized (widget, TRUE); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); gtk_widget_get_allocation (widget, &widget_allocation); 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; gdk_window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gtk_widget_set_window (widget, gdk_window); gdk_window_set_user_data (gdk_window, widget); g_signal_connect (gdk_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)) { gtk_widget_get_allocation (bin->child, &bin_child_allocation); 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, gtk_widget_get_window (widget)); 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); gtk_widget_style_attach (widget); style = gtk_widget_get_style (widget); gtk_style_set_background (style, gdk_window, GTK_STATE_NORMAL); gtk_style_set_background (style, bin->offscreen_window, GTK_STATE_NORMAL); gdk_window_show (bin->offscreen_window); }