Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Wayland] Be more explicit about min/max size for xdg-shell #4047

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 1 comment
Closed

[Wayland] Be more explicit about min/max size for xdg-shell #4047

SDLBugzilla opened this issue Feb 11, 2021 · 1 comment

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 2.0
Reported for operating system, platform: Linux, All

Comments on the original bug report:

On 2021-02-06 23:22:42 +0000, Ethan Lee wrote:

As of the latest SDL revision, Wayland support with compositors that support XDG-Shell is nearly at feature parity - two notable absences are window position and border sizes, which we probably won't ever get Because Wayland, but a third notable issue is that the desktop has no way of knowing what our window bounds really are. As a result, a fixed-size window will still have resize UI at the borders and a maximize button that does some really strange things to the window when you click it.

Luckily this is very easy for us to fix: Much like X11 we can explicitly set the min/max size via toplevel_set_min/max_size, and the desktop will know to avoid the resize UI (on KDE it still shows a maximize button but it thankfully does nothing, not sure if making this button disappear is something for KDE to fix or what...).

I believe the places we have to add this are identical to X11, and for the most part the logic will also be the same minus skipping a few X quirks here and there:

  • CreateWindow
  • SetWindowSize
  • SetWindowResizable
  • SetWindowFullscreen
  • New SetWindowMinimum/SetWindowMaximum implementations

The callbacks should be able to stay as they are with no problems.

On 2021-02-07 06:20:03 +0000, Ethan Lee wrote:

Created attachment 4770
Min/Max patch for xdg-shell

This patch does the work to set min/max as described in the OP. Functionally it seems fine but Plasma's having trouble with it for some reason. I suspect we're just missing a message somewhere that will fix it, if you toggle the border (either via SetWindowBordered or SetWindowFullscreen) it correctly toggles the maximize button once it's been refreshed.

To make testing easier, here's a quick program... mind the uninitialized framebuffer:


#include <SDL.h>

int main(int argc, char **argv)
{
SDL_Window *window;
SDL_GLContext context;
SDL_Event evt;
int w;
Uint8 run = 1;

SDL_Init(SDL_INIT_VIDEO);
window = SDL_CreateWindow(
"Shell Test",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
800,
600,
SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL
);
context = SDL_GL_CreateContext(window);

while (run)
{
const Uint32 flags = SDL_GetWindowFlags(window);
while (SDL_PollEvent(&evt) > 0)
{
if (evt.type == SDL_QUIT)
{
run = 0;
}
if (evt.type == SDL_KEYDOWN)
{
if (evt.key.keysym.sym == SDLK_1)
{
SDL_SetWindowResizable(
window,
(flags & SDL_WINDOW_RESIZABLE) != SDL_WINDOW_RESIZABLE
);
}
else if (evt.key.keysym.sym == SDLK_2)
{
SDL_SetWindowBordered(
window,
(flags & SDL_WINDOW_BORDERLESS) == SDL_WINDOW_BORDERLESS
);
}
else if (evt.key.keysym.sym == SDLK_3)
{
SDL_SetWindowFullscreen(
window,
(flags & SDL_WINDOW_FULLSCREEN_DESKTOP) ?
0 :
SDL_WINDOW_FULLSCREEN_DESKTOP
);
SDL_SetWindowSize(window, 800, 600);
SDL_SetWindowPosition(
window,
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED
);
}
else if (evt.key.keysym.sym == SDLK_4)
{
SDL_GetWindowMinimumSize(window, &w, NULL);
if (w < 2)
{
SDL_SetWindowMinimumSize(window, 600, 400);
SDL_SetWindowMaximumSize(window, 1000, 800);
}
else
{
SDL_SetWindowMinimumSize(window, 1, 1);
SDL_SetWindowMaximumSize(window, 0x7FFFFFFF, 0x7FFFFFFF);
}
}
else if (evt.key.keysym.sym == SDLK_5)
{
SDL_SetWindowSize(window, 800, 600);
SDL_SetWindowPosition(
window,
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED
);
}
}
}
SDL_GL_SwapWindow(window);
}

SDL_GL_DeleteContext(context);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}


@flibitijibibo
Copy link
Collaborator

Resolved by #4065, can be closed now

@slouken slouken closed this as completed Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants