JNIEXPORT jint JNICALL Java_org_gnome_gdk_GdkWindow_gdk_1window_1get_1window_1type ( JNIEnv* env, jclass cls, jlong _self ) { GdkWindowType result; jint _result; GdkWindow* self; // convert parameter self self = (GdkWindow*) _self; // call function result = gdk_window_get_window_type(self); // cleanup parameter self // translate return value to JNI type _result = (jint) result; // and finally return _result; }
/** * gnome_bg_crossfade_start: * @fade: a #GnomeBGCrossfade * @window: The #GdkWindow to draw crossfade on * * This function initiates a quick crossfade between two surfaces on * the background of @window. Before initiating the crossfade both * gnome_bg_crossfade_start() and gnome_bg_crossfade_end() need to * be called. If animations are disabled, the crossfade is skipped, * and the window background is set immediately to the end surface. **/ void gnome_bg_crossfade_start (GnomeBGCrossfade *fade, GdkWindow *window) { GSource *source; GMainContext *context; cairo_pattern_t *pattern; g_return_if_fail (GNOME_IS_BG_CROSSFADE (fade)); g_return_if_fail (window != NULL); g_return_if_fail (fade->priv->fading_surface != NULL); g_return_if_fail (fade->priv->end_surface != NULL); g_return_if_fail (!gnome_bg_crossfade_is_started (fade)); g_return_if_fail (gdk_window_get_window_type (window) != GDK_WINDOW_FOREIGN); source = g_timeout_source_new (1000 / 60.0); g_source_set_callback (source, (GSourceFunc) on_tick, fade, (GDestroyNotify) on_finished); context = g_main_context_default (); fade->priv->timeout_id = g_source_attach (source, context); g_source_unref (source); fade->priv->window = window; pattern = cairo_pattern_create_for_surface (fade->priv->fading_surface); gdk_window_set_background_pattern (fade->priv->window, pattern); cairo_pattern_destroy (pattern); draw_background (fade); fade->priv->is_first_frame = TRUE; fade->priv->total_duration = .75; fade->priv->start_time = get_current_time (); }
static GtkForeignExported * gtk_foreign_impl_wayland_export_window (GtkForeignImpl *impl, GdkWindow *window) { GtkForeign *foreign = gtk_foreign_impl_get_foreign (impl); GtkForeignImplWayland *impl_wayland = GTK_FOREIGN_IMPL_WAYLAND (impl); struct wl_surface *wl_surface; struct zxdg_exported_v1 *xdg_exported; if (gdk_window_get_window_type (window) != GDK_WINDOW_TOPLEVEL) { g_warning ("Can only export GDK_WINDOW_TOPLEVEL\n"); return NULL; } wl_surface = gdk_wayland_window_get_wl_surface (window); if (!wl_surface) { g_warning ("No wl_surface to export\n"); return NULL; } discover_globals (impl_wayland); if (!impl_wayland->xdg_exporter) { g_warning ("Wayland server doesn't support exporting\n"); return NULL; } xdg_exported = zxdg_exporter_v1_export (impl_wayland->xdg_exporter, wl_surface); return gtk_foreign_exported_wayland_new (foreign, xdg_exported); }
static void draw_background (MateBGCrossfade *fade) { if (fade->priv->widget != NULL) { gtk_widget_queue_draw (fade->priv->widget); } else if (gdk_window_get_window_type (fade->priv->window) != GDK_WINDOW_ROOT) { cairo_t *cr; cairo_region_t *region; GdkDrawingContext *draw_context; region = gdk_window_get_visible_region (fade->priv->window); draw_context = gdk_window_begin_draw_frame (fade->priv->window, region); cr = gdk_drawing_context_get_cairo_context (draw_context); cairo_set_operator (cr, CAIRO_OPERATOR_OVER); cairo_set_source_surface (cr, fade->priv->fading_surface, 0, 0); cairo_paint (cr); gdk_window_end_draw_frame (fade->priv->window, draw_context); cairo_region_destroy (region); } else { Display *xdisplay = GDK_WINDOW_XDISPLAY (fade->priv->window); GdkDisplay *display; display = gdk_display_get_default (); gdk_x11_display_error_trap_push (display); XGrabServer (xdisplay); XClearWindow (xdisplay, GDK_WINDOW_XID (fade->priv->window)); send_root_property_change_notification (fade); XFlush (xdisplay); XUngrabServer (xdisplay); gdk_x11_display_error_trap_pop_ignored (display); } }
static void draw_background (MateBGCrossfade *fade) { if (gdk_window_get_window_type (fade->priv->window) == GDK_WINDOW_ROOT) { XClearArea (GDK_WINDOW_XDISPLAY (fade->priv->window), GDK_WINDOW_XID (fade->priv->window), 0, 0, gdk_window_get_width (fade->priv->window), gdk_window_get_height (fade->priv->window), False); gdk_flush (); } else { gdk_window_invalidate_rect (fade->priv->window, NULL, FALSE); gdk_window_process_updates (fade->priv->window, FALSE); } }
gboolean meta_ui_window_should_not_cause_focus (Display *xdisplay, Window xwindow) { GdkWindow *window; GdkDisplay *display; display = gdk_x11_lookup_xdisplay (xdisplay); window = gdk_x11_window_lookup_for_display (display, xwindow); /* we shouldn't cause focus if we're an override redirect * toplevel which is not foreign */ if (window && gdk_window_get_window_type (window) == GDK_WINDOW_TEMP) return TRUE; else return FALSE; }
static void draw_background (GnomeBGCrossfade *fade) { if (gdk_window_get_window_type (fade->priv->window) == GDK_WINDOW_ROOT) { gdk_error_trap_push (); XClearArea (GDK_WINDOW_XDISPLAY (fade->priv->window), GDK_WINDOW_XID (fade->priv->window), 0, 0, gdk_window_get_width (fade->priv->window), gdk_window_get_height (fade->priv->window), False); send_root_property_change_notification (fade); gdk_flush (); gdk_error_trap_pop (); // ignore errors } else { gdk_window_invalidate_rect (fade->priv->window, NULL, FALSE); gdk_window_process_updates (fade->priv->window, FALSE); } }
GdkWindow* gfc_gdk_window_new (GdkWindow * parent, gchar const* first_attribute, ...) { GdkWindowAttr attributes; gchar const * attribute; GdkWindow * result = NULL; va_list argv; gint valid_attributes; /* FIXME: we could also hardcode this */ memset (&attributes, '\0', sizeof (&attributes)); valid_attributes = 0; /* defaults for required attributes */ attributes.width = 1; attributes.height = 1; attributes.event_mask = 0; attributes.wclass = GDK_INPUT_OUTPUT; attributes.window_type = gdk_window_get_window_type (parent) == GDK_WINDOW_ROOT ? GDK_WINDOW_TOPLEVEL : GDK_WINDOW_CHILD; va_start (argv, first_attribute); for (attribute = first_attribute; attribute; attribute = va_arg (argv, gchar const*)) { if (!strcmp (attribute, "class")) { attributes.wclass = va_arg (argv, GdkWindowClass); } else if (!strcmp (attribute, "colormap")) { attributes.colormap = va_arg (argv, GdkColormap*); valid_attributes |= GDK_WA_COLORMAP; } else if (!strcmp (attribute, "cursor"))
static VALUE gdkwin_get_window_type(VALUE self) { return GENUM2RVAL(gdk_window_get_window_type(_SELF(self)), GDK_TYPE_WINDOW_TYPE); }
static gboolean gdk_broadway_device_query_state (GdkDevice *device, GdkWindow *window, GdkWindow **root_window, GdkWindow **child_window, gint *root_x, gint *root_y, gint *win_x, gint *win_y, GdkModifierType *mask) { GdkDisplay *display; GdkBroadwayDisplay *broadway_display; GdkWindowImplBroadway *impl; guint32 serial; GdkScreen *screen; char *reply; gint device_root_x, device_root_y, device_win_x, device_win_y, id; if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE) return FALSE; display = gdk_device_get_display (device); broadway_display = GDK_BROADWAY_DISPLAY (display); if (root_window) { screen = gdk_window_get_screen (window); *root_window = gdk_screen_get_root_window (screen); } if (mask) *mask = 0; /* TODO */ if (broadway_display->output) { impl = GDK_WINDOW_IMPL_BROADWAY (window->impl); serial = broadway_output_query_pointer (broadway_display->output, impl->id); reply = _gdk_broadway_display_block_for_input (display, 'q', serial, TRUE); if (reply != NULL) { char *p; char cmd; guint32 reply_serial; p = reply; cmd = *p++; reply_serial = (guint32)strtol(p, &p, 10); p++; /* Skip , */ device_root_x = strtol(p, &p, 10); p++; /* Skip , */ device_root_y = strtol(p, &p, 10); p++; /* Skip , */ device_win_x = strtol(p, &p, 10); p++; /* Skip , */ device_win_y = strtol(p, &p, 10); p++; /* Skip , */ id = strtol(p, &p, 10); if (root_x) *root_x = device_root_x; if (root_y) *root_y = device_root_y; if (win_x) *win_x = device_win_x; if (win_y) *win_y = device_win_y; if (child_window) { if (gdk_window_get_window_type (window) == GDK_WINDOW_ROOT) *child_window = g_hash_table_lookup (broadway_display->id_ht, GINT_TO_POINTER (id)); else *child_window = window; /* No native children */ } g_free (reply); return TRUE; } } /* Fallback when unconnected */ device_root_x = broadway_display->last_x; device_root_y = broadway_display->last_y; if (root_x) *root_x = device_root_x; if (root_y) *root_y = device_root_y; if (win_x) *win_x = device_root_y - window->x; if (win_y) *win_y = device_root_y - window->y; if (child_window) { if (gdk_window_get_window_type (window) == GDK_WINDOW_ROOT) { *child_window = broadway_display->mouse_in_toplevel; if (*child_window == NULL) *child_window = window; } else { /* No native children */ *child_window = window; } } return TRUE; }
static cairo_surface_t * snapshot_widget (GtkWidget *widget, SnapshotMode mode) { cairo_surface_t *surface; cairo_pattern_t *bg; GMainLoop *loop; cairo_t *cr; g_assert (gtk_widget_get_realized (widget)); surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget), CAIRO_CONTENT_COLOR, gtk_widget_get_allocated_width (widget), gtk_widget_get_allocated_height (widget)); loop = g_main_loop_new (NULL, FALSE); /* We wait until the widget is drawn for the first time. * We can not wait for a GtkWidget::draw event, because that might not * happen if the window is fully obscured by windowed child widgets. * Alternatively, we could wait for an expose event on widget's window. * Both of these are rather hairy, not sure what's best. */ gdk_event_handler_set (check_for_draw, loop, NULL); g_main_loop_run (loop); cr = cairo_create (surface); switch (mode) { case SNAPSHOT_WINDOW: { GdkWindow *window = gtk_widget_get_window (widget); if (gdk_window_get_window_type (window) == GDK_WINDOW_TOPLEVEL || gdk_window_get_window_type (window) == GDK_WINDOW_FOREIGN) { /* give the WM/server some time to sync. They need it. * Also, do use popups instead of toplevls in your tests * whenever you can. */ gdk_display_sync (gdk_window_get_display (window)); g_timeout_add (500, quit_when_idle, loop); g_main_loop_run (loop); } gdk_cairo_set_source_window (cr, window, 0, 0); cairo_paint (cr); } break; case SNAPSHOT_DRAW: bg = gdk_window_get_background_pattern (gtk_widget_get_window (widget)); if (bg) { cairo_set_source (cr, bg); cairo_paint (cr); } gtk_widget_draw (widget, cr); break; default: g_assert_not_reached(); break; } cairo_destroy (cr); g_main_loop_unref (loop); gtk_widget_destroy (widget); return surface; }
static void gdk_broadway_device_query_state (GdkDevice *device, GdkWindow *window, GdkWindow **root_window, GdkWindow **child_window, gdouble *root_x, gdouble *root_y, gdouble *win_x, gdouble *win_y, GdkModifierType *mask) { GdkWindow *toplevel; GdkWindowImplBroadway *impl; GdkDisplay *display; GdkBroadwayDisplay *broadway_display; GdkScreen *screen; gint32 device_root_x, device_root_y; guint32 mouse_toplevel_id; GdkWindow *mouse_toplevel; guint32 mask32; if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE) return; display = gdk_device_get_display (device); broadway_display = GDK_BROADWAY_DISPLAY (display); impl = GDK_WINDOW_IMPL_BROADWAY (window->impl); toplevel = impl->wrapper; if (root_window) { screen = gdk_window_get_screen (window); *root_window = gdk_screen_get_root_window (screen); } _gdk_broadway_server_query_mouse (broadway_display->server, &mouse_toplevel_id, &device_root_x, &device_root_y, &mask32); mouse_toplevel = g_hash_table_lookup (broadway_display->id_ht, GUINT_TO_POINTER (mouse_toplevel_id)); if (root_x) *root_x = device_root_x; if (root_y) *root_y = device_root_y; if (win_x) *win_x = device_root_x - toplevel->x; if (win_y) *win_y = device_root_y - toplevel->y; if (mask) *mask = mask32; if (child_window) { if (gdk_window_get_window_type (toplevel) == GDK_WINDOW_ROOT) { *child_window = mouse_toplevel; if (*child_window == NULL) *child_window = toplevel; } else { /* No native children */ *child_window = toplevel; } } return; }
/** * mate_bg_crossfade_start: * @fade: a #MateBGCrossfade * @window: The #GdkWindow to draw crossfade on * * This function initiates a quick crossfade between two surfaces on * the background of @window. Before initiating the crossfade both * mate_bg_crossfade_set_start_surface() and * mate_bg_crossfade_set_end_surface() need to be called. If animations * are disabled, the crossfade is skipped, and the window background is * set immediately to the end surface. **/ void mate_bg_crossfade_start (MateBGCrossfade *fade, GdkWindow *window) { GSource *source; GMainContext *context; g_return_if_fail (MATE_IS_BG_CROSSFADE (fade)); g_return_if_fail (window != NULL); g_return_if_fail (fade->priv->start_surface != NULL); g_return_if_fail (fade->priv->end_surface != NULL); g_return_if_fail (!mate_bg_crossfade_is_started (fade)); g_return_if_fail (gdk_window_get_window_type (window) != GDK_WINDOW_FOREIGN); /* If drawing is done on the root window, * it is essential to have the root pixmap. */ if (gdk_window_get_window_type (window) == GDK_WINDOW_ROOT) { GdkDisplay *display = gdk_window_get_display (window); cairo_surface_t *surface = get_root_pixmap_id_surface (display); g_return_if_fail (surface != NULL); cairo_surface_destroy (surface); } if (fade->priv->fading_surface != NULL) { cairo_surface_destroy (fade->priv->fading_surface); fade->priv->fading_surface = NULL; } fade->priv->window = window; if (gdk_window_get_window_type (fade->priv->window) != GDK_WINDOW_ROOT) { fade->priv->fading_surface = tile_surface (fade->priv->start_surface, fade->priv->width, fade->priv->height); if (fade->priv->widget != NULL) { g_signal_connect (fade->priv->widget, "draw", (GCallback) on_widget_draw, fade); } } else { cairo_t *cr; GdkDisplay *display = gdk_window_get_display (fade->priv->window); fade->priv->fading_surface = get_root_pixmap_id_surface (display); cr = cairo_create (fade->priv->fading_surface); cairo_set_source_surface (cr, fade->priv->start_surface, 0, 0); cairo_paint (cr); cairo_destroy (cr); } draw_background (fade); source = g_timeout_source_new (1000 / 60.0); g_source_set_callback (source, (GSourceFunc) on_tick, fade, (GDestroyNotify) on_finished); context = g_main_context_default (); fade->priv->timeout_id = g_source_attach (source, context); g_source_unref (source); fade->priv->is_first_frame = TRUE; fade->priv->total_duration = .75; fade->priv->start_time = get_current_time (); }
static VALUE rg_window_type(VALUE self) { return GDKWINDOWTYPE2RVAL(gdk_window_get_window_type(_SELF(self))); }