window: Set window type as it changes, not on every attach
It was always a bit sloppy, and the new fullscreen request doesn't work that way.
This commit is contained in:
+18
-41
@@ -782,35 +782,6 @@ window_get_resize_dx_dy(struct window *window, int *x, int *y)
|
|||||||
window->resize_edges = 0;
|
window->resize_edges = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
window_set_type(struct window *window)
|
|
||||||
{
|
|
||||||
if (!window->shell_surface)
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch (window->type) {
|
|
||||||
case TYPE_FULLSCREEN:
|
|
||||||
wl_shell_surface_set_fullscreen(window->shell_surface,
|
|
||||||
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, NULL);
|
|
||||||
break;
|
|
||||||
case TYPE_MAXIMIZED:
|
|
||||||
wl_shell_surface_set_maximized(window->shell_surface, NULL);
|
|
||||||
break;
|
|
||||||
case TYPE_TOPLEVEL:
|
|
||||||
wl_shell_surface_set_toplevel(window->shell_surface);
|
|
||||||
break;
|
|
||||||
case TYPE_TRANSIENT:
|
|
||||||
wl_shell_surface_set_transient(window->shell_surface,
|
|
||||||
window->parent->shell_surface,
|
|
||||||
window->x, window->y, 0);
|
|
||||||
break;
|
|
||||||
case TYPE_MENU:
|
|
||||||
break;
|
|
||||||
case TYPE_CUSTOM:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
window_attach_surface(struct window *window)
|
window_attach_surface(struct window *window)
|
||||||
{
|
{
|
||||||
@@ -822,9 +793,6 @@ window_attach_surface(struct window *window)
|
|||||||
#endif
|
#endif
|
||||||
int32_t x, y;
|
int32_t x, y;
|
||||||
|
|
||||||
if (display->shell)
|
|
||||||
window_set_type(window);
|
|
||||||
|
|
||||||
switch (window->buffer_type) {
|
switch (window->buffer_type) {
|
||||||
#ifdef HAVE_CAIRO_EGL
|
#ifdef HAVE_CAIRO_EGL
|
||||||
case WINDOW_BUFFER_TYPE_EGL_WINDOW:
|
case WINDOW_BUFFER_TYPE_EGL_WINDOW:
|
||||||
@@ -2157,25 +2125,25 @@ window_set_custom(struct window *window)
|
|||||||
void
|
void
|
||||||
window_set_fullscreen(struct window *window, int fullscreen)
|
window_set_fullscreen(struct window *window, int fullscreen)
|
||||||
{
|
{
|
||||||
int32_t width, height;
|
if (!window->display->shell)
|
||||||
struct output *output;
|
return;
|
||||||
|
|
||||||
if ((window->type == TYPE_FULLSCREEN) == fullscreen)
|
if ((window->type == TYPE_FULLSCREEN) == fullscreen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fullscreen) {
|
if (fullscreen) {
|
||||||
output = display_get_output(window->display);
|
|
||||||
window->type = TYPE_FULLSCREEN;
|
window->type = TYPE_FULLSCREEN;
|
||||||
window->saved_allocation = window->allocation;
|
window->saved_allocation = window->allocation;
|
||||||
width = output->allocation.width;
|
wl_shell_surface_set_fullscreen(window->shell_surface,
|
||||||
height = output->allocation.height;
|
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
|
||||||
|
0, NULL);
|
||||||
} else {
|
} else {
|
||||||
window->type = TYPE_TOPLEVEL;
|
window->type = TYPE_TOPLEVEL;
|
||||||
width = window->saved_allocation.width;
|
wl_shell_surface_set_toplevel(window->shell_surface);
|
||||||
height = window->saved_allocation.height;
|
window_schedule_resize(window,
|
||||||
|
window->saved_allocation.width,
|
||||||
|
window->saved_allocation.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
window_schedule_resize(window, width, height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -2339,6 +2307,10 @@ window_create(struct display *display)
|
|||||||
if (!window)
|
if (!window)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
window->type = TYPE_TOPLEVEL;
|
||||||
|
if (display->shell)
|
||||||
|
wl_shell_surface_set_toplevel(window->shell_surface);
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2356,6 +2328,11 @@ window_create_transient(struct display *display, struct window *parent,
|
|||||||
window->x = x;
|
window->x = x;
|
||||||
window->y = y;
|
window->y = y;
|
||||||
|
|
||||||
|
if (display->shell)
|
||||||
|
wl_shell_surface_set_transient(window->shell_surface,
|
||||||
|
window->parent->shell_surface,
|
||||||
|
window->x, window->y, 0);
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user