uint32_t reposition_token;
uint32_t received_reposition_token;
- PopupState popup_state;
-
- unsigned int popup_thaw_upon_show : 1;
unsigned int initial_configure_received : 1;
unsigned int has_uncommitted_ack_configure : 1;
unsigned int mapped : 1;
gboolean has_bounds;
} toplevel;
- struct {
- GdkPopupLayout *layout;
- int unconstrained_width;
- int unconstrained_height;
- } popup;
-
struct {
struct {
int width;
gboolean has_bounds;
} toplevel;
- struct {
- int x;
- int y;
- int width;
- int height;
- uint32_t repositioned_token;
- gboolean has_repositioned_token;
- } popup;
-
gboolean is_initial_configure;
uint32_t serial;
struct _GdkWaylandPopup
{
GdkWaylandSurface parent_instance;
+
+ PopupState state;
+ unsigned int thaw_upon_show : 1;
+ GdkPopupLayout *layout;
+ int unconstrained_width;
+ int unconstrained_height;
+
+ struct {
+ int x;
+ int y;
+ int width;
+ int height;
+ uint32_t repositioned_token;
+ gboolean has_repositioned_token;
+ } pending;
};
typedef struct
static void
finish_pending_relayout (GdkWaylandPopup *wayland_popup)
{
- GdkWaylandSurface *wayland_surface = GDK_WAYLAND_SURFACE (wayland_popup);
-
- g_assert (wayland_surface->popup_state == POPUP_STATE_WAITING_FOR_FRAME);
- wayland_surface->popup_state = POPUP_STATE_IDLE;
+ g_assert (wayland_popup->state == POPUP_STATE_WAITING_FOR_FRAME);
+ wayland_popup->state = POPUP_STATE_IDLE;
thaw_popup_toplevel_state (wayland_popup);
}
if (!impl->awaiting_frame)
return;
- switch (impl->popup_state)
+ if (GDK_IS_WAYLAND_POPUP (surface))
{
- case POPUP_STATE_IDLE:
- case POPUP_STATE_WAITING_FOR_REPOSITIONED:
- case POPUP_STATE_WAITING_FOR_CONFIGURE:
- break;
- case POPUP_STATE_WAITING_FOR_FRAME:
- g_return_if_fail (GDK_IS_WAYLAND_POPUP (surface));
GdkWaylandPopup *wayland_popup = GDK_WAYLAND_POPUP (surface);
- finish_pending_relayout (wayland_popup);
- break;
- default:
- g_assert_not_reached ();
+
+ switch (wayland_popup->state)
+ {
+ case POPUP_STATE_IDLE:
+ case POPUP_STATE_WAITING_FOR_REPOSITIONED:
+ case POPUP_STATE_WAITING_FOR_CONFIGURE:
+ break;
+ case POPUP_STATE_WAITING_FOR_FRAME:
+ finish_pending_relayout (wayland_popup);
+ break;
+ default:
+ g_assert_not_reached ();
+ }
}
impl->awaiting_frame = FALSE;
wayland_surface->pending.serial);
}
- if (wayland_surface->pending.popup.has_repositioned_token)
- wayland_surface->received_reposition_token = wayland_surface->pending.popup.repositioned_token;
+ if (wayland_popup->pending.has_repositioned_token)
+ wayland_surface->received_reposition_token = wayland_popup->pending.repositioned_token;
- switch (wayland_surface->popup_state)
+ switch (wayland_popup->state)
{
case POPUP_STATE_WAITING_FOR_REPOSITIONED:
if (wayland_surface->received_reposition_token != wayland_surface->reposition_token)
gdk_surface_thaw_updates (surface);
G_GNUC_FALLTHROUGH;
case POPUP_STATE_WAITING_FOR_CONFIGURE:
- wayland_surface->popup_state = POPUP_STATE_WAITING_FOR_FRAME;
+ wayland_popup->state = POPUP_STATE_WAITING_FOR_FRAME;
break;
case POPUP_STATE_IDLE:
case POPUP_STATE_WAITING_FOR_FRAME:
g_assert_not_reached ();
}
- x = wayland_surface->pending.popup.x;
- y = wayland_surface->pending.popup.y;
- width = wayland_surface->pending.popup.width;
- height = wayland_surface->pending.popup.height;
+ x = wayland_popup->pending.x;
+ y = wayland_popup->pending.y;
+ width = wayland_popup->pending.width;
+ height = wayland_popup->pending.height;
gdk_wayland_surface_get_window_geometry (surface->parent, &parent_geometry);
x += parent_geometry.x;
update_popup_layout_state (wayland_popup,
x, y,
width, height,
- wayland_surface->popup.layout);
+ wayland_popup->layout);
wayland_surface->next_layout.popup.x = x;
wayland_surface->next_layout.popup.y = y;
int32_t width,
int32_t height)
{
- GdkWaylandSurface *wayland_surface = GDK_WAYLAND_SURFACE (wayland_popup);
-
- wayland_surface->pending.popup.x = x;
- wayland_surface->pending.popup.y = y;
- wayland_surface->pending.popup.width = width;
- wayland_surface->pending.popup.height = height;
+ wayland_popup->pending.x = x;
+ wayland_popup->pending.y = y;
+ wayland_popup->pending.width = width;
+ wayland_popup->pending.height = height;
}
static void
uint32_t token)
{
GdkWaylandPopup *wayland_popup = GDK_WAYLAND_POPUP (data);
- GdkWaylandSurface *wayland_surface = GDK_WAYLAND_SURFACE (wayland_popup);
- GdkSurface *surface = GDK_SURFACE (wayland_popup);
- GDK_DISPLAY_DEBUG (gdk_surface_get_display (surface), EVENTS,
- "repositioned %p", surface);
+ GDK_DISPLAY_DEBUG (gdk_surface_get_display (GDK_SURFACE (wayland_popup)), EVENTS,
+ "repositioned %p", wayland_popup);
- if (wayland_surface->popup_state != POPUP_STATE_WAITING_FOR_REPOSITIONED)
+ if (wayland_popup->state != POPUP_STATE_WAITING_FOR_REPOSITIONED)
{
g_warning ("Unexpected xdg_popup.repositioned event, probably buggy compositor");
return;
}
- wayland_surface->pending.popup.repositioned_token = token;
- wayland_surface->pending.popup.has_repositioned_token = TRUE;
+ wayland_popup->pending.repositioned_token = token;
+ wayland_popup->pending.has_repositioned_token = TRUE;
}
static const struct xdg_popup_listener xdg_popup_listener = {
GdkPopupLayout *layout,
GdkRectangle *out_rect)
{
- GdkWaylandSurface *wayland_surface = GDK_WAYLAND_SURFACE (wayland_popup);
int width, height;
GdkRectangle anchor_rect;
int dx, dy;
&shadow_top,
&shadow_bottom);
- width = (wayland_surface->popup.unconstrained_width - (shadow_left + shadow_right));
- height = (wayland_surface->popup.unconstrained_height - (shadow_top + shadow_bottom));
+ width = (wayland_popup->unconstrained_width - (shadow_left + shadow_right));
+ height = (wayland_popup->unconstrained_height - (shadow_top + shadow_bottom));
anchor_rect = *gdk_popup_layout_get_anchor_rect (layout);
gdk_popup_layout_get_offset (layout, &dx, &dy);
if (GDK_IS_POPUP (surface))
{
- g_assert (impl->popup_state == POPUP_STATE_IDLE);
- impl->popup_state = POPUP_STATE_WAITING_FOR_CONFIGURE;
+ g_assert (wayland_popup->state == POPUP_STATE_IDLE);
+ wayland_popup->state = POPUP_STATE_WAITING_FOR_CONFIGURE;
freeze_popup_toplevel_state (wayland_popup);
}
{
GdkWaylandPopup *wayland_popup = GDK_WAYLAND_POPUP (surface);
- impl->popup_thaw_upon_show = TRUE;
+ wayland_popup->thaw_upon_show = TRUE;
gdk_surface_freeze_updates (surface);
- switch (impl->popup_state)
+ switch (wayland_popup->state)
{
case POPUP_STATE_WAITING_FOR_REPOSITIONED:
gdk_surface_thaw_updates (surface);
g_assert_not_reached ();
}
- impl->popup_state = POPUP_STATE_IDLE;
+ wayland_popup->state = POPUP_STATE_IDLE;
}
if (impl->display_server.gtk_surface)
impl->display_server.outputs = NULL;
g_clear_pointer (&impl->toplevel.layout, gdk_toplevel_layout_unref);
- g_clear_pointer (&impl->popup.layout, gdk_popup_layout_unref);
+ if (GDK_IS_WAYLAND_POPUP (surface))
+ {
+ GdkWaylandPopup *wayland_popup = GDK_WAYLAND_POPUP (surface);
+ g_clear_pointer (&wayland_popup->layout, gdk_popup_layout_unref);
+ }
}
impl->has_uncommitted_ack_configure = FALSE;
queue_relayout_fallback (GdkWaylandPopup *wayland_popup,
GdkPopupLayout *layout)
{
- GdkWaylandSurface *wayland_surface = GDK_WAYLAND_SURFACE (wayland_popup);
-
if (!is_fallback_relayout_possible (wayland_popup))
return;
gdk_wayland_surface_hide_surface (GDK_SURFACE (wayland_popup));
gdk_wayland_surface_present_popup (wayland_popup,
- wayland_surface->popup.unconstrained_width,
- wayland_surface->popup.unconstrained_height,
+ wayland_popup->unconstrained_width,
+ wayland_popup->unconstrained_height,
layout);
}
struct xdg_positioner *positioner;
g_assert (is_realized_popup (wayland_surface));
- g_assert (wayland_surface->popup_state == POPUP_STATE_IDLE ||
- wayland_surface->popup_state == POPUP_STATE_WAITING_FOR_FRAME);
+ g_assert (wayland_popup->state == POPUP_STATE_IDLE ||
+ wayland_popup->state == POPUP_STATE_WAITING_FOR_FRAME);
- g_clear_pointer (&wayland_surface->popup.layout, gdk_popup_layout_unref);
- wayland_surface->popup.layout = gdk_popup_layout_copy (layout);
- wayland_surface->popup.unconstrained_width = width;
- wayland_surface->popup.unconstrained_height = height;
+ g_clear_pointer (&wayland_popup->layout, gdk_popup_layout_unref);
+ wayland_popup->layout = gdk_popup_layout_copy (layout);
+ wayland_popup->unconstrained_width = width;
+ wayland_popup->unconstrained_height = height;
if (!wayland_surface->display_server.xdg_popup ||
xdg_popup_get_version (wayland_surface->display_server.xdg_popup) <
gdk_surface_freeze_updates (GDK_SURFACE (wayland_popup));
- switch (wayland_surface->popup_state)
+ switch (wayland_popup->state)
{
case POPUP_STATE_IDLE:
freeze_popup_toplevel_state (wayland_popup);
g_assert_not_reached ();
}
- wayland_surface->popup_state = POPUP_STATE_WAITING_FOR_REPOSITIONED;
+ wayland_popup->state = POPUP_STATE_WAITING_FOR_REPOSITIONED;
}
static gboolean
layout))
return;
- wayland_surface->popup.layout = gdk_popup_layout_copy (layout);
- wayland_surface->popup.unconstrained_width = width;
- wayland_surface->popup.unconstrained_height = height;
+ wayland_popup->layout = gdk_popup_layout_copy (layout);
+ wayland_popup->unconstrained_width = width;
+ wayland_popup->unconstrained_height = height;
wayland_surface->mapped = TRUE;
}
if (!wayland_surface->display_server.wl_surface)
gdk_wayland_surface_create_surface (GDK_SURFACE (wayland_popup));
- if (wayland_surface->popup_thaw_upon_show)
+ if (wayland_popup->thaw_upon_show)
{
- wayland_surface->popup_thaw_upon_show = FALSE;
+ wayland_popup->thaw_upon_show = FALSE;
gdk_surface_thaw_updates (GDK_SURFACE (wayland_popup));
}
int height,
GdkPopupLayout *layout)
{
- GdkWaylandSurface *wayland_surface = GDK_WAYLAND_SURFACE (wayland_popup);
-
- switch (wayland_surface->popup_state)
+ switch (wayland_popup->state)
{
case POPUP_STATE_IDLE:
case POPUP_STATE_WAITING_FOR_FRAME:
}
else
{
- if (wayland_surface->popup.unconstrained_width == width &&
- wayland_surface->popup.unconstrained_height == height &&
- gdk_popup_layout_equal (wayland_surface->popup.layout, layout))
+ if (wayland_popup->unconstrained_width == width &&
+ wayland_popup->unconstrained_height == height &&
+ gdk_popup_layout_equal (wayland_popup->layout, layout))
return TRUE;
reposition_popup (wayland_popup, width, height, layout);