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

The imgui window can't be moved outside the desktop region #3899

Open
shi-yan opened this issue Mar 11, 2021 · 9 comments
Open

The imgui window can't be moved outside the desktop region #3899

shi-yan opened this issue Mar 11, 2021 · 9 comments

Comments

@shi-yan
Copy link

shi-yan commented Mar 11, 2021

Version/Branch of Dear ImGui:

f1bf642

Version: 1.82 WIP
Branch: docking

Back-end/Renderer/Compiler/OS
Tried both opengl3 and vulkan/ sdl,
gcc-8
ubuntu 18.04 on nvidia / xwindows

Back-ends: imgui_impl_sdl.cpp, vulkan / opengl3
Compiler: gcc-8
Operating System: ubuntu 18.04

My Issue/Question:

I'm testing the docking branch with the official examples. I have tried both the vulkan backend and the opengl3 backend. I have noticed some issues.

One problem is that once an imgui window is detached from the main window, it can't be moved outside the screen region.

This is inconvenient , because the window is very large and always occupies the desktop. Making it difficult to see what's behind. For certain use cases, I need to cross reference multiple application windows.

Screenshots/Video

Screenshot from 2021-03-11 09-56-04

Standalone, minimal, complete and verifiable example:

this is the same official demo, but it has a CMake file

testimgui.zip

@tquante
Copy link

tquante commented Mar 11, 2021

I assume that you are using the x11 implementation of SDL.

Dear ImGui uses the set window position function of SDL to relocate the window. Unfortunately SDL as well as GLFW only communicate with xserver and not with the window manager. Therefore they are unable to move any window border beyond the screen border for some WMs. The main window uses the decoration to be relocated, which is handled by the WM, that has full control over the window position.

I do not have any experience with the wayland implementation.

@shi-yan
Copy link
Author

shi-yan commented Mar 12, 2021

yes, I'm on nvidia gpu, and can only use xwindows with ubuntu.

so which backend would support this function? I'm interested in using imgui to build conventional desktop applications.

@shi-yan
Copy link
Author

shi-yan commented Mar 12, 2021

when a panel is detached from the main window, are we creating a new window for it? I have seen other opensource projects trying to replicate the detachable tabs of the chrome browser, they would create another empty window, similar to the main window, and draw the detached ui there.

It seems that imgui's detachable ui is frameless and created differently.

@shi-yan
Copy link
Author

shi-yan commented Mar 12, 2021

I found this https://lazyfoo.net/tutorials/SDL/36_multiple_windows/index.php

not sure if useful

@tquante
Copy link

tquante commented Mar 12, 2021

The undocked window is a separate window as well. The only difference is the missing decoration. As far as i know the Windows version of GLFW is working as intended. In principle you could alter the window creation in Dear ImGui which need to call the SDL create window function to reenable the window decoration, but i assume that this would break some invariants in Dear ImGui.

@rokups
Copy link
Contributor

rokups commented Mar 22, 2021

As i mentioned in another issue, this is a known bug which we reported to SDL and GLFW and are waiting for fixes.
libsdl-org/SDL#3813
glfw/glfw#1817

rokups added a commit to rokups/imgui that referenced this issue Jun 3, 2021
…een bounds while WM forces window to remain within screen bounds. (ocornut#3898, ocornut#3899)

Only helps GLFW, because glfwGetWindowPos() correctly returns actual window position. SDL_GetWindowPosition() on the other hand returns window position before WM restricting window movement, which does not match actual window position on screen.
@rokups
Copy link
Contributor

rokups commented Jun 7, 2021

Working on better handling this situation. Proof of concept patch linked above ☝🏻. It only works for GLFW as it properly reports window position when window is stuck at the edge of the screen. A PR submitted to SDL fixing a bug which will make SDL_GetWindowPosition() result reliable as well (libsdl-org/SDL#4426). Once all pieces fall into places we will no longer have window/viewport position desync when window is stuck at the edge of the screen.

rokups added a commit to rokups/imgui that referenced this issue Jun 9, 2021
…een bounds while WM forces window to remain within screen bounds. (ocornut#3898, ocornut#3899)
@lucasjinreal
Copy link

Does it supported put Imgui window outside of glfw window now?

@hultsi
Copy link

hultsi commented Jun 30, 2023

This still seems not to be fixed on X11 & GLFW. For a quick hack you can fork GLFW repo,

  • search for x11_window.c file
  • find void _glfwSetWindowPosX11(_GLFWwindow* window, int xpos, int ypos) function from there
  • Wrap XMoveWindow(...) and XFlush(...) in the following manner:
    // Set override_redirect to true
    XSetWindowAttributes wa = { 0 };
    wa.override_redirect = True;
    XChangeWindowAttributes(_glfw.x11.display, window->x11.handle, CWOverrideRedirect, &wa);

    XMoveWindow(_glfw.x11.display, window->x11.handle, xpos, ypos);
    XFlush(_glfw.x11.display);

    // Set override_redirect back to false as leaving it on would create other issues
    wa.override_redirect = False;
    XChangeWindowAttributes(_glfw.x11.display, window->x11.handle, CWOverrideRedirect, &wa);

Not a solution I would create PR out of but it seems to work on X11 while we wait for the actual GLFW fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants