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 launcher_grid_create (struct desktop *desktop) { struct element *launcher_grid; GdkWindow *gdk_window; launcher_grid = malloc (sizeof *launcher_grid); memset (launcher_grid, 0, sizeof *launcher_grid); launcher_grid->window = maynard_launcher_new (desktop->background->window); gdk_window = gtk_widget_get_window (launcher_grid->window); launcher_grid->surface = gdk_wayland_window_get_wl_surface (gdk_window); gdk_wayland_window_set_use_custom_surface (gdk_window); shell_helper_add_surface_to_layer (desktop->helper, launcher_grid->surface, desktop->panel->surface); g_signal_connect (launcher_grid->window, "app-launched", G_CALLBACK (launcher_grid_toggle), desktop); gtk_widget_show_all (launcher_grid->window); desktop->launcher_grid = launcher_grid; }
static GtkWidget * clock_create (struct desktop *desktop) { struct element *clock; GdkWindow *gdk_window; clock = malloc (sizeof *clock); memset (clock, 0, sizeof *clock); clock->window = maynard_clock_new (); g_signal_connect (clock->window, "volume-changed", G_CALLBACK (volume_changed_cb), desktop); gdk_window = gtk_widget_get_window (clock->window); clock->surface = gdk_wayland_window_get_wl_surface (gdk_window); gdk_wayland_window_set_use_custom_surface (gdk_window); shell_helper_add_surface_to_layer (desktop->helper, clock->surface, desktop->panel->surface); gtk_widget_show_all (clock->window); desktop->clock = clock; }
static VkResult gdk_wayland_vulkan_context_create_surface (GdkVulkanContext *context, VkSurfaceKHR *surface) { GdkWindow *window = gdk_draw_context_get_window (GDK_DRAW_CONTEXT (context)); GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context)); /* This is necessary so that Vulkan sees the Window. * Usually, vkCreateXlibSurfaceKHR() will not cause a problem to happen as * it just creates resources, but futher calls with the resulting surface * do cause issues. */ gdk_display_sync (display); return GDK_VK_CHECK (vkCreateWaylandSurfaceKHR, gdk_vulkan_context_get_instance (context), &(VkWaylandSurfaceCreateInfoKHR) { VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR, NULL, 0, gdk_wayland_display_get_wl_display (display), gdk_wayland_window_get_wl_surface (window) }, NULL, surface); }
bool WaylandEGLContext::attach (GtkWidget *widget) { GdkWindow *window = gtk_widget_get_window (widget); if (!GDK_IS_WAYLAND_WINDOW (window)) return false; gdk_window = window; gdk_window_get_geometry (gdk_window, &x, &y, &width, &height); display = gdk_wayland_display_get_wl_display (gdk_window_get_display (gdk_window)); parent = gdk_wayland_window_get_wl_surface (gdk_window); registry = wl_display_get_registry (display); wl_registry_add_listener (registry, &wl_registry_listener, this); wl_display_roundtrip (display); if (!compositor || !subcompositor) return false; child = wl_compositor_create_surface (compositor); region = wl_compositor_create_region (compositor); subsurface = wl_subcompositor_get_subsurface (subcompositor, child, parent); wl_surface_set_input_region (child, region); wl_subsurface_set_desync (subsurface); wl_subsurface_set_position (subsurface, x, y); return true; }
static void background_create (struct desktop *desktop) { GdkWindow *gdk_window; struct element *background; const gchar *filename; GdkPixbuf *unscaled_background; background = malloc (sizeof *background); memset (background, 0, sizeof *background); filename = g_getenv ("BACKGROUND"); if (filename == NULL) filename = DEFAULT_BACKGROUND; unscaled_background = gdk_pixbuf_new_from_file (filename, NULL); if (!unscaled_background) { g_message ("Could not load background. " "Do you have kdewallpapers installed?"); exit (EXIT_FAILURE); } background->pixbuf = scale_background (unscaled_background); g_object_unref (unscaled_background); background->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_signal_connect (background->window, "destroy", G_CALLBACK (destroy_cb), NULL); g_signal_connect (background->window, "draw", G_CALLBACK (draw_cb), desktop); gtk_window_set_title (GTK_WINDOW (background->window), "maynard"); gtk_window_set_decorated (GTK_WINDOW (background->window), FALSE); gtk_widget_realize (background->window); gdk_window = gtk_widget_get_window (background->window); gdk_wayland_window_set_use_custom_surface (gdk_window); background->surface = gdk_wayland_window_get_wl_surface (gdk_window); desktop_shell_set_user_data (desktop->shell, desktop); desktop_shell_set_background (desktop->shell, desktop->output, background->surface); desktop->background = background; gtk_widget_show_all (background->window); }
void consort_shell_set_panel_window (ConsortShell *shell, gpointer panel_window) { GdkWindow *window; ConsortShellPrivate *priv; struct element *panel; struct desktop *desktop; priv = CONSORT_SHELL_GET_PRIVATE (shell); desktop = priv->desktop; panel = malloc(sizeof *panel); memset(panel, 0, sizeof *panel); window = gtk_widget_get_window (GTK_WINDOW (panel_window)); gdk_wayland_window_set_use_custom_surface (window); panel->surface = gdk_wayland_window_get_wl_surface (window); desktop_shell_set_user_data(desktop->shell, desktop); desktop_shell_set_panel(desktop->shell, desktop->output, panel->surface); }
void consort_shell_set_background_window (ConsortShell *shell, gpointer background_window) { GdkWindow *window; ConsortShellPrivate *priv; struct element *background; struct desktop *desktop; priv = CONSORT_SHELL_GET_PRIVATE (shell); desktop = priv->desktop; background = malloc(sizeof *background); memset(background, 0, sizeof *background); window = gtk_widget_get_window (GTK_WINDOW (background_window)); gdk_wayland_window_set_use_custom_surface (window); background->surface = gdk_wayland_window_get_wl_surface (window); desktop_shell_set_user_data (desktop->shell, desktop); desktop_shell_set_background (desktop->shell, desktop->output, background->surface); desktop->background = background; }
static void panel_create (struct desktop *desktop) { struct element *panel; GdkWindow *gdk_window; panel = malloc (sizeof *panel); memset (panel, 0, sizeof *panel); panel->window = maynard_panel_new (); g_signal_connect (panel->window, "app-menu-toggled", G_CALLBACK (launcher_grid_toggle), desktop); g_signal_connect (panel->window, "system-toggled", G_CALLBACK (system_toggled_cb), desktop); g_signal_connect (panel->window, "volume-toggled", G_CALLBACK (volume_toggled_cb), desktop); g_signal_connect (panel->window, "favorite-launched", G_CALLBACK (favorite_launched_cb), desktop); desktop->initial_panel_timeout_id = g_timeout_add_seconds (2, panel_hide_timeout_cb, desktop); /* set it up as the panel */ gdk_window = gtk_widget_get_window (panel->window); gdk_wayland_window_set_use_custom_surface (gdk_window); panel->surface = gdk_wayland_window_get_wl_surface (gdk_window); desktop_shell_set_user_data (desktop->shell, desktop); desktop_shell_set_panel (desktop->shell, desktop->output, panel->surface); desktop_shell_set_panel_position (desktop->shell, DESKTOP_SHELL_PANEL_POSITION_LEFT); gtk_widget_show_all (panel->window); desktop->panel = panel; }
operator wl_surface *() { return gdk_wayland_window_get_wl_surface( gtk_widget_get_window(win_) ); }
static gboolean clutter_stage_gdk_realize (ClutterStageWindow *stage_window) { ClutterStageGdk *stage_gdk = CLUTTER_STAGE_GDK (stage_window); ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window); ClutterBackend *backend = CLUTTER_BACKEND (stage_cogl->backend); ClutterBackendGdk *backend_gdk = CLUTTER_BACKEND_GDK (backend); GdkWindowAttr attributes; gboolean cursor_visible; gboolean use_alpha; gfloat width, height; if (stage_gdk->foreign_window) { width = gdk_window_get_width (stage_gdk->window); height = gdk_window_get_height (stage_gdk->window); } else { if (stage_gdk->window != NULL) { /* complete realizing the stage */ cairo_rectangle_int_t geometry; clutter_stage_gdk_get_geometry (stage_window, &geometry); clutter_actor_set_size (CLUTTER_ACTOR (stage_cogl->wrapper), geometry.width, geometry.height); gdk_window_ensure_native (stage_gdk->window); gdk_window_set_events (stage_gdk->window, CLUTTER_STAGE_GDK_EVENT_MASK); return TRUE; } else { attributes.title = NULL; g_object_get (stage_cogl->wrapper, "cursor-visible", &cursor_visible, "title", &attributes.title, "width", &width, "height", &height, "use-alpha", &use_alpha, NULL); attributes.width = width; attributes.height = height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.window_type = GDK_WINDOW_TOPLEVEL; attributes.event_mask = CLUTTER_STAGE_GDK_EVENT_MASK; attributes.cursor = NULL; if (!cursor_visible) { if (stage_gdk->blank_cursor == NULL) stage_gdk->blank_cursor = gdk_cursor_new_for_display (backend_gdk->display, GDK_BLANK_CURSOR); attributes.cursor = stage_gdk->blank_cursor; } attributes.visual = NULL; if (use_alpha) { attributes.visual = gdk_screen_get_rgba_visual (backend_gdk->screen); if (attributes.visual == NULL) clutter_stage_set_use_alpha (stage_cogl->wrapper, FALSE); } if (attributes.visual == NULL) { /* This could still be an RGBA visual, although normally it's not */ attributes.visual = gdk_screen_get_system_visual (backend_gdk->screen); } stage_gdk->foreign_window = FALSE; stage_gdk->window = gdk_window_new (NULL, &attributes, GDK_WA_TITLE | GDK_WA_CURSOR | GDK_WA_VISUAL); g_free (attributes.title); } clutter_stage_gdk_set_gdk_geometry (stage_gdk); } gdk_window_ensure_native (stage_gdk->window); g_object_set_data (G_OBJECT (stage_gdk->window), "clutter-stage-window", stage_gdk); stage_cogl->onscreen = cogl_onscreen_new (backend->cogl_context, width, height); #if defined(GDK_WINDOWING_X11) && defined(COGL_HAS_XLIB_SUPPORT) if (GDK_IS_X11_WINDOW (stage_gdk->window)) { cogl_x11_onscreen_set_foreign_window_xid (stage_cogl->onscreen, GDK_WINDOW_XID (stage_gdk->window), clutter_stage_gdk_update_foreign_event_mask, stage_gdk); } else #endif #if defined(GDK_WINDOWING_WAYLAND) && defined(COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT) if (GDK_IS_WAYLAND_WINDOW (stage_gdk->window)) { cogl_wayland_onscreen_set_foreign_surface (stage_cogl->onscreen, gdk_wayland_window_get_wl_surface (stage_gdk->window)); } else #endif #if defined(GDK_WINDOWING_WIN32) && defined(COGL_HAS_WIN32_SUPPORT) if (GDK_IS_WIN32_WINDOW (stage_gdk->window)) { cogl_win32_onscreen_set_foreign_window (stage_cogl->onscreen, gdk_win32_window_get_handle (stage_gdk->window)); } else #endif { g_warning ("Cannot find an appropriate CoglWinsys for a " "GdkWindow of type %s", G_OBJECT_TYPE_NAME (stage_gdk->window)); cogl_object_unref (stage_cogl->onscreen); stage_cogl->onscreen = NULL; if (!stage_gdk->foreign_window) gdk_window_destroy (stage_gdk->window); stage_gdk->window = NULL; return FALSE; } return clutter_stage_window_parent_iface->realize (stage_window); }
static void wayland_set_window(CoglOnscreen* onscreen, GdkWindow *window) { cogl_wayland_onscreen_set_foreign_surface(onscreen, gdk_wayland_window_get_wl_surface(GDK_WAYLAND_WINDOW(window))); }