gint8 toplevel_window_type;
struct wl_surface *surface;
+ struct wl_shell_surface *shell_surface;
unsigned int mapped : 1;
GdkWindow *transient_for;
+ GdkWindowTypeHint hint;
cairo_surface_t *cairo_surface;
cairo_surface_t *server_surface;
GLuint texture;
uint32_t resize_edges;
- /* Set if the window, or any descendent of it, is the server's focus window
- */
- guint has_focus_window : 1;
-
- /* Set if window->has_focus_window and the focus isn't grabbed elsewhere.
- */
- guint has_focus : 1;
-
- /* Set if the pointer is inside this window. (This is needed for
- * for focus tracking)
- */
- guint has_pointer : 1;
-
- /* Set if the window is a descendent of the focus window and the pointer is
- * inside it. (This is the case where the window will receive keystroke
- * events even window->has_focus_window is FALSE)
- */
- guint has_pointer_focus : 1;
-
- /* Set if we are requesting these hints */
- guint skip_taskbar_hint : 1;
- guint skip_pager_hint : 1;
- guint urgency_hint : 1;
-
- guint on_all_desktops : 1; /* _NET_WM_STICKY == 0xFFFFFFFF */
-
- guint have_sticky : 1; /* _NET_WM_STATE_STICKY */
- guint have_maxvert : 1; /* _NET_WM_STATE_MAXIMIZED_VERT */
- guint have_maxhorz : 1; /* _NET_WM_STATE_MAXIMIZED_HORZ */
- guint have_fullscreen : 1; /* _NET_WM_STATE_FULLSCREEN */
+ int focus_count;
gulong map_serial; /* Serial of last transition from unmapped */
/* Time of most recent user interaction. */
gulong user_time;
+
+ GdkGeometry geometry_hints;
+ GdkWindowHints geometry_mask;
};
struct _GdkWindowImplWaylandClass
impl->toplevel_window_type = -1;
}
+void
+_gdk_wayland_window_add_focus (GdkWindow *window)
+{
+ GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+
+ impl->focus_count++;
+ if (impl->focus_count == 1)
+ gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FOCUSED);
+}
+
+void
+_gdk_wayland_window_remove_focus (GdkWindow *window)
+{
+ GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+
+ impl->focus_count--;
+ if (impl->focus_count == 0)
+ gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FOCUSED, 0);
+}
+
/**
- * _gdk_wayland_window_update_size:
+ * gdk_wayland_window_update_size:
* @drawable: a #GdkDrawableImplWayland.
*
* Updates the state of the drawable (in particular the drawable's
* cairo surface) when its size has changed.
**/
-void
-_gdk_wayland_window_update_size (GdkWindow *window,
- int32_t width, int32_t height, uint32_t edges)
+static void
+gdk_wayland_window_update_size (GdkWindow *window,
+ int32_t width, int32_t height, uint32_t edges)
{
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
GdkRectangle area;
static void
gdk_wayland_window_attach_image (GdkWindow *window)
{
- GdkDisplayWayland *display =
- GDK_DISPLAY_WAYLAND (gdk_window_get_display (window));
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
GdkWaylandCairoSurfaceData *data;
int32_t server_width, server_height, dx, dy;
&gdk_wayland_cairo_key);
if (!data->buffer)
data->buffer =
- wl_egl_pixmap_create_buffer(display->native_display, data->pixmap);
+ wl_egl_pixmap_create_buffer(data->pixmap);
- if (impl->resize_edges & WL_SHELL_RESIZE_LEFT)
+ if (impl->resize_edges & WL_SHELL_SURFACE_RESIZE_LEFT)
dx = server_width - data->width;
else
dx = 0;
- if (impl->resize_edges & WL_SHELL_RESIZE_TOP)
+ if (impl->resize_edges & WL_SHELL_SURFACE_RESIZE_TOP)
dy = server_height - data->height;
else
dy = 0;
impl = GDK_WINDOW_IMPL_WAYLAND (object);
if (impl->cursor)
- gdk_cursor_unref (impl->cursor);
+ g_object_unref (impl->cursor);
if (impl->server_surface)
cairo_surface_destroy (impl->server_surface);
{
GdkWaylandCairoSurfaceData *data;
cairo_surface_t *surface;
- struct wl_visual *visual;
data = g_new (GdkWaylandCairoSurfaceData, 1);
data->display = display;
data->buffer = NULL;
- visual = wl_display_get_premultiplied_argb_visual(display->wl_display);
data->width = width;
data->height = height;
- data->pixmap =
- wl_egl_pixmap_create(display->native_display, width, height, visual, 0);
+ data->pixmap = wl_egl_pixmap_create(width, height, 0);
data->image =
display->create_image(display->egl_display, NULL, EGL_NATIVE_PIXMAP_KHR,
(EGLClientBuffer) data->pixmap, NULL);
+ cairo_device_acquire(display->cairo_device);
glGenTextures(1, &data->texture);
glBindTexture(GL_TEXTURE_2D, data->texture);
display->image_target_texture_2d(GL_TEXTURE_2D, data->image);
+ cairo_device_release(display->cairo_device);
surface = cairo_gl_surface_create_for_texture(display->cairo_device,
CAIRO_CONTENT_COLOR_ALPHA,
return impl->cairo_surface;
}
+static cairo_surface_t *
+gdk_wayland_window_configure (GdkWindow *window,
+ int width, int height, int edges)
+{
+ GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+ GdkDisplay *display;
+ GdkEvent *event;
+
+ display = gdk_window_get_display (window);
+
+ /* TODO: Only generate a configure event if width or height have actually
+ * changed?
+ */
+ event = gdk_event_new (GDK_CONFIGURE);
+ event->configure.window = window;
+ event->configure.send_event = FALSE;
+ event->configure.width = width;
+ event->configure.height = height;
+
+ _gdk_window_update_size (window);
+ gdk_wayland_window_update_size (window, width, height, edges);
+
+ g_object_ref(window);
+
+ _gdk_wayland_display_deliver_event (display, event);
+}
+
static void
gdk_wayland_window_set_user_time (GdkWindow *window, guint32 user_time)
{
window->y);
parent = GDK_WINDOW_IMPL_WAYLAND (impl->transient_for->impl);
- wl_surface_map_transient (impl->surface, parent->surface,
- window->x, window->y, 0);
+ wl_shell_surface_set_transient (impl->shell_surface, parent->shell_surface,
+ window->x, window->y, 0);
}
else
- wl_surface_map_toplevel (impl->surface);
+ wl_shell_surface_set_toplevel (impl->shell_surface);
impl->mapped = TRUE;
}
}
+static void
+shell_surface_handle_configure(void *data,
+ struct wl_shell_surface *shell_surface,
+ uint32_t time,
+ uint32_t edges,
+ int32_t width,
+ int32_t height)
+{
+ GdkWindow *window = GDK_WINDOW (data);
+ GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+
+ gdk_window_constrain_size (&impl->geometry_hints,
+ impl->geometry_mask,
+ width,
+ height,
+ &width,
+ &height);
+
+ gdk_wayland_window_configure (window, width, height, edges);
+}
+
+static const struct wl_shell_surface_listener shell_surface_listener = {
+ shell_surface_handle_configure,
+};
+
static void
gdk_wayland_window_show (GdkWindow *window, gboolean already_mapped)
{
impl->surface = wl_compositor_create_surface(display_wayland->compositor);
wl_surface_set_user_data(impl->surface, window);
+ impl->shell_surface = wl_shell_get_shell_surface (display_wayland->shell,
+ impl->surface);
+ wl_shell_surface_add_listener(impl->shell_surface,
+ &shell_surface_listener, window);
+
+ gdk_window_set_type_hint (window, impl->hint);
+
_gdk_make_event (window, GDK_MAP, NULL, FALSE);
event = _gdk_make_event (window, GDK_VISIBILITY_NOTIFY, NULL, FALSE);
event->visibility.state = GDK_VISIBILITY_UNOBSCURED;
window->x = x;
window->y = y;
- _gdk_wayland_window_update_size (window, width, height, 0);
+ /* If this function is called with width and height = -1 then that means
+ * just move the window - don't update its size
+ */
+ if (width > 0 && height > 0)
+ gdk_wayland_window_configure (window, width, height, 0);
}
static void
{
if (GDK_WINDOW_IMPL_WAYLAND (window->impl)->surface)
wl_surface_destroy(GDK_WINDOW_IMPL_WAYLAND (window->impl)->surface);
+ wl_shell_surface_destroy(GDK_WINDOW_IMPL_WAYLAND (window->impl)->shell_surface);
}
}
gdk_wayland_window_set_type_hint (GdkWindow *window,
GdkWindowTypeHint hint)
{
+ GdkWindowImplWayland *impl;
+
+ impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+
if (GDK_WINDOW_DESTROYED (window))
return;
+ impl->hint = hint;
+
switch (hint)
{
- case GDK_WINDOW_TYPE_HINT_DIALOG:
case GDK_WINDOW_TYPE_HINT_MENU:
case GDK_WINDOW_TYPE_HINT_TOOLBAR:
case GDK_WINDOW_TYPE_HINT_UTILITY:
- case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
case GDK_WINDOW_TYPE_HINT_DOCK:
case GDK_WINDOW_TYPE_HINT_DESKTOP:
case GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU:
default:
g_warning ("Unknown hint %d passed to gdk_window_set_type_hint", hint);
/* Fall thru */
+ case GDK_WINDOW_TYPE_HINT_DIALOG:
case GDK_WINDOW_TYPE_HINT_NORMAL:
+ case GDK_WINDOW_TYPE_HINT_SPLASHSCREEN:
+ if (impl->shell_surface)
+ wl_shell_surface_set_toplevel (impl->shell_surface);
break;
}
}
const GdkGeometry *geometry,
GdkWindowHints geom_mask)
{
+ GdkWindowImplWayland *impl;
+
if (GDK_WINDOW_DESTROYED (window) ||
!WINDOW_IS_TOPLEVEL_OR_FOREIGN (window))
return;
+ impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+
+ impl->geometry_hints = *geometry;
+ impl->geometry_mask = geom_mask;
+
/*
* GDK_HINT_POS
* GDK_HINT_USER_POS
static void
gdk_wayland_window_begin_resize_drag (GdkWindow *window,
GdkWindowEdge edge,
+ GdkDevice *device,
gint button,
gint root_x,
gint root_y,
guint32 timestamp)
{
- GdkDisplay *display = gdk_window_get_display (window);
- GdkDeviceManager *dm;
GdkWindowImplWayland *impl;
- GdkDevice *device;
uint32_t grab_type;
if (GDK_WINDOW_DESTROYED (window) ||
switch (edge)
{
case GDK_WINDOW_EDGE_NORTH_WEST:
- grab_type = WL_SHELL_RESIZE_TOP_LEFT;
+ grab_type = WL_SHELL_SURFACE_RESIZE_TOP_LEFT;
break;
case GDK_WINDOW_EDGE_NORTH:
- grab_type = WL_SHELL_RESIZE_TOP;
+ grab_type = WL_SHELL_SURFACE_RESIZE_TOP;
break;
case GDK_WINDOW_EDGE_NORTH_EAST:
- grab_type = WL_SHELL_RESIZE_RIGHT;
+ grab_type = WL_SHELL_SURFACE_RESIZE_RIGHT;
break;
case GDK_WINDOW_EDGE_WEST:
- grab_type = WL_SHELL_RESIZE_LEFT;
+ grab_type = WL_SHELL_SURFACE_RESIZE_LEFT;
break;
case GDK_WINDOW_EDGE_EAST:
- grab_type = WL_SHELL_RESIZE_RIGHT;
+ grab_type = WL_SHELL_SURFACE_RESIZE_RIGHT;
break;
case GDK_WINDOW_EDGE_SOUTH_WEST:
- grab_type = WL_SHELL_RESIZE_BOTTOM_LEFT;
+ grab_type = WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT;
break;
case GDK_WINDOW_EDGE_SOUTH:
- grab_type = WL_SHELL_RESIZE_BOTTOM;
+ grab_type = WL_SHELL_SURFACE_RESIZE_BOTTOM;
break;
case GDK_WINDOW_EDGE_SOUTH_EAST:
- grab_type = WL_SHELL_RESIZE_BOTTOM_RIGHT;
+ grab_type = WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT;
break;
default:
}
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
- dm = gdk_display_get_device_manager (display);
- device = gdk_device_manager_get_client_pointer (dm);
- wl_shell_resize(GDK_DISPLAY_WAYLAND (display)->shell, impl->surface,
- _gdk_wayland_device_get_device (device),
- timestamp, grab_type);
+ wl_shell_surface_resize (impl->shell_surface,
+ _gdk_wayland_device_get_device (device),
+ timestamp, grab_type);
+
+ /* This is needed since Wayland will absorb all the pointer events after the
+ * above function - FIXME: Is this always safe..?
+ */
+ gdk_device_ungrab (device, timestamp);
}
static void
gdk_wayland_window_begin_move_drag (GdkWindow *window,
+ GdkDevice *device,
gint button,
gint root_x,
gint root_y,
guint32 timestamp)
{
- GdkDisplay *display = gdk_window_get_display (window);
- GdkDeviceManager *dm;
GdkWindowImplWayland *impl;
- GdkDevice *device;
if (GDK_WINDOW_DESTROYED (window) ||
!WINDOW_IS_TOPLEVEL (window))
impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
- dm = gdk_display_get_device_manager (display);
- device = gdk_device_manager_get_client_pointer (dm);
+ wl_shell_surface_move (impl->shell_surface,
+ _gdk_wayland_device_get_device (device), timestamp);
- wl_shell_move(GDK_DISPLAY_WAYLAND (display)->shell, impl->surface,
- _gdk_wayland_device_get_device (device), timestamp);
+ /* This is needed since Wayland will absorb all the pointer events after the
+ * above function - FIXME: Is this always safe..?
+ */
+ gdk_device_ungrab (device, timestamp);
}
static void