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

[SDL 3.2.4 - Linux 64bit X11] SDL_SetWindowPosition failure #12220

Open
sechshelme opened this issue Feb 8, 2025 · 2 comments
Open

[SDL 3.2.4 - Linux 64bit X11] SDL_SetWindowPosition failure #12220

sechshelme opened this issue Feb 8, 2025 · 2 comments
Milestone

Comments

@sechshelme
Copy link

sechshelme commented Feb 8, 2025

In the following test program, the window pops up briefly at the default location before jumping to the position specified with SDL_SetWindowPosition. I only added the delay as a test to see if that was the cause.

// gcc main.c -o main -lSDL3

#include <SDL3/SDL.h>

int main(int argc, char *argv[])
{
  int quit = 0;
    SDL_Window *win = SDL_CreateWindow("SDL3 Window", 640, 480, SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN);
    SDL_SetWindowPosition(win, 500, 500);
    SDL_Delay(1000); //  with test
    SDL_ShowWindow(win);
    SDL_Log("Version: %s", SDL_GetRevision());  
    SDL_Renderer *renderer = SDL_CreateRenderer(win, NULL);

  while (!quit) {
    SDL_Event ev;
    while (SDL_PollEvent(&ev) != 0) {
      switch(ev.type) {
        case SDL_EVENT_QUIT:
        quit = 1;
        break;
      }
    }
    SDL_SetRenderDrawColor(renderer, 20, 0, 0, 255);
    SDL_RenderClear(renderer);

    SDL_RenderPresent(renderer);
  }

  SDL_DestroyRenderer(renderer);
  SDL_DestroyWindow(win);
  SDL_Quit();
  return 0;
}
@slouken
Copy link
Collaborator

slouken commented Feb 8, 2025

SDL/include/SDL3/SDL_video.h

Lines 1101 to 1103 in 5d1bbd9

* If you intend to use this window with an SDL_Renderer, you should use
* SDL_CreateWindowAndRenderer() instead of this function, to avoid window
* flicker.

@slouken slouken closed this as completed Feb 8, 2025
@slouken slouken closed this as not planned Won't fix, can't repro, duplicate, stale Feb 8, 2025
@sechshelme
Copy link
Author

I have now changed it, but the problem still exists.
I have tried leaving out SDL_WINDOW_HIDDEN and SDL_ShowWindow(win);, but it doesn't help.

// gcc main.c -o main -lSDL3

#include <SDL3/SDL.h>

int main(int argc, char *argv[])
{
  int quit = 0;
//    SDL_Window *win = SDL_CreateWindow("SDL3 Window", 640, 480, SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN);
//    SDL_Renderer *renderer = SDL_CreateRenderer(win, NULL);
    SDL_Window *win;
    SDL_Renderer *renderer;

    SDL_CreateWindowAndRenderer("SDL3 Window", 640, 480, SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIDDEN, &win, &renderer);

    SDL_SetWindowPosition(win, 500, 500);
    SDL_ShowWindow(win);
    SDL_Log("Version: %s", SDL_GetRevision());  


  while (!quit) {
    SDL_Event ev;
    while (SDL_PollEvent(&ev) != 0) {
      switch(ev.type) {
        case SDL_EVENT_QUIT:
        quit = 1;
        break;
      }
    }
    SDL_SetRenderDrawColor(renderer, 200, 200, 0, 255);
    SDL_RenderClear(renderer);

    SDL_RenderPresent(renderer);
  }

  SDL_DestroyRenderer(renderer);
  SDL_DestroyWindow(win);
  SDL_Quit();
  return 0;
}
System:
  Host: xxx-B660M-DS3H-DDR4 Kernel: 6.8.0-51-generic arch: x86_64 bits: 64
  Desktop: Cinnamon v: 6.4.6 Distro: Linux Mint 22.1 Xia
Machine:
  Type: Desktop Mobo: Gigabyte model: B660M DS3H DDR4 v: x.x
    serial: <superuser required> UEFI: American Megatrends LLC. v: F5
    date: 01/17/2022
CPU:
  Info: 12-core (8-mt/4-st) model: 12th Gen Intel Core i7-12700 bits: 64
    type: MST AMCP cache: L2: 12 MiB
  Speed (MHz): avg: 814 min/max: 800/4800:4900:3600 cores: 1: 800 2: 800
    3: 866 4: 800 5: 838 6: 800 7: 800 8: 800 9: 800 10: 800 11: 900 12: 800
    13: 800 14: 800 15: 800 16: 800 17: 800 18: 800 19: 881 20: 800
Graphics:
  Device-1: Intel AlderLake-S GT1 driver: i915 v: kernel
  Device-2: Generic HD camera driver: uvcvideo type: USB
  Display: x11 server: X.Org v: 21.1.11 with: Xwayland v: 23.2.6 driver: X:
    loaded: modesetting unloaded: fbdev,vesa dri: iris gpu: i915
    resolution: 3440x1440~60Hz
  API: EGL v: 1.5 drivers: iris,swrast platforms: x11,surfaceless,device
  API: OpenGL v: 4.6 compat-v: 4.5 vendor: intel mesa v: 24.0.9-0ubuntu0.3
    renderer: Mesa Intel UHD Graphics 770 (ADL-S GT1)
....

@slouken slouken reopened this Feb 8, 2025
@slouken slouken added this to the 3.2.6 milestone Feb 8, 2025
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