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: SDL_RaiseWindow() does not raise the window on KDE #9199

Closed
weirddan455 opened this issue Mar 5, 2024 · 1 comment
Closed

Wayland: SDL_RaiseWindow() does not raise the window on KDE #9199

weirddan455 opened this issue Mar 5, 2024 · 1 comment

Comments

@weirddan455
Copy link
Contributor

System is Arch Linux using KDE Plasma 5.27.10. When SDL_RaiseWindow() is called, the window does not get moved above any other window and it does not take keyboard input focus. All that happens is the icon in the title bar turns orange.

Both trip of tree main and release 2.30 have the same behavior.

Repro case:

#include <SDL3/SDL.h>
#include <unistd.h>
#include <stdio.h>

int main(void)
{
    SDL_Init(SDL_INIT_VIDEO);
    SDL_Window *window = SDL_CreateWindow("Test", 200, 300, SDL_WINDOW_RESIZABLE);
    SDL_Renderer *renderer = SDL_CreateRenderer(window, NULL, 0);
    while (1) {
        SDL_RenderClear(renderer);
        SDL_RenderPresent(renderer);
        SDL_Event event;
        SDL_WaitEvent(&event);
        if (event.type == SDL_EVENT_QUIT) {
            return 0;
        }
        if (event.type == SDL_EVENT_KEY_DOWN) {
            sleep(2);
            puts("Raising Window");
            SDL_RaiseWindow(window);
        }
    }
    return 0;
}

This comment explains the situation. I'm assuming it's up to the compositor what ends up happening but maybe there is something different SDL can do to convince it to raise the window. Have not researched that far into it.

/* The xdg-activation protocol considers "activation" to be one of two things:
*
* 1: Raising a window to the top and flashing the titlebar
* 2: Flashing the titlebar while keeping the window where it is
*
* As you might expect from Wayland, the general policy is to go with #2 unless
* the client can prove to the compositor beyond a reasonable doubt that raising
* the window will not be malicuous behavior.
*
* For SDL this means RaiseWindow and FlashWindow both use the same protocol,
* but in different ways: RaiseWindow will provide as _much_ information as
* possible while FlashWindow will provide as _little_ information as possible,
* to nudge the compositor into doing what we want.
*
* This isn't _strictly_ what the protocol says will happen, but this is what
* current implementations are doing (as of writing, YMMV in the far distant
* future).
*
* -flibit
*/
static void Wayland_activate_window(SDL_VideoData *data, SDL_WindowData *target_wind, SDL_bool set_serial)

@Kontrabant
Copy link
Contributor

All that can be done is the request as is done now. Window managers generally don’t allow apps to raise themselves to prevent focus stealing.

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

2 participants