Skip to content

Commit 99ee757

Browse files
committed
Add win32 support for current platform functions in the window interface
1 parent 9f44d9e commit 99ee757

File tree

2 files changed

+58
-15
lines changed

2 files changed

+58
-15
lines changed

Framework/Core/Interfaces/WindowInterface.hpp

+17-15
Original file line numberDiff line numberDiff line change
@@ -65,41 +65,43 @@ namespace UImGui
6565
void operator=(Platform const&) = delete;
6666

6767
// Event Safety - begin, style, post-begin
68-
// Available for platforms - X11
69-
// Platforms to be supported - Wayland, Win32
68+
// Available for platforms - X11, Win32
69+
// Platforms to be supported - Wayland
7070
static void setWindowAlwaysOnTop() noexcept;
7171

7272
// Event Safety - begin, style, post-begin
73-
// Available for platforms - X11
74-
// Platforms to be supported - Wayland, Win32
73+
// Available for platforms - X11, Win32
74+
// Platforms to be supported - Wayland
7575
static void setWindowAlwaysOnBottom() noexcept;
7676

7777
// Event Safety - begin, style, post-begin
78-
// Available for platforms - X11
79-
// Platforms to be supported - Wayland, Win32
78+
// Available for platforms - X11, Win32
79+
// Platforms to be supported - Wayland
8080
static void disableWindowMovement() noexcept;
8181

8282
// Event Safety - begin, style, post-begin
83-
// Available for platforms - X11
84-
// Platforms to be supported - Wayland, Win32
83+
// Platform note: On Win32 "setWindowShowingOnPager" and "setWindowShowingOnTaskbar" run the same code,
84+
// as it is not possible to disable the window from showing on both the taskbar and window switcher
85+
// Available for platforms - X11, Win32
86+
// Platforms to be supported - Wayland
8587
static void setWindowShowingOnPager(bool bShowInPager) noexcept;
8688
// Event Safety - begin, style, post-begin
87-
// Available for platforms - X11
88-
// Platforms to be supported - Wayland, Win32
89+
// Available for platforms - X11, Win32
90+
// Platforms to be supported - Wayland
8991
static bool getWindowShowingOnPager() noexcept;
9092

9193
// Event Safety - begin, style, post-begin
92-
// Available for platforms - X11
93-
// Platforms to be supported - Wayland, Win32
94+
// Available for platforms - X11, Win32
95+
// Platforms to be supported - Wayland
9496
static void setWindowShowingOnTaskbar(bool bShowOnTaskbar) noexcept;
9597
// Event Safety - begin, style, post-begin
96-
// Available for platforms - X11
97-
// Platforms to be supported - Wayland, Win32
98+
// Available for platforms - X11, Win32
99+
// Platforms to be supported - Wayland
98100
static bool getWindowShowingOnTaskbar() noexcept;
99101

100102
// Event Safety - begin, style, post-begin
101103
// Available for platforms - X11
102-
// Platforms to be supported - Wayland, Win32
104+
// Platforms to be supported - Wayland
103105
// Sets the X11 window type
104106
static void setWindowType(String type) noexcept;
105107
};

Framework/Renderer/Utils/Window.cpp

+41
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,11 @@ void UImGui::WindowInternal::setWindowAlwaysOnTop() noexcept
412412
XSendEvent(display, root, false, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent*)&xclient);
413413
XFlush(display);
414414
}
415+
#else
416+
#ifdef GLFW_EXPOSE_NATIVE_WIN32
417+
auto window = glfwGetWin32Window(windowMain);
418+
SetWindowPos(window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
419+
#endif
415420
#endif
416421
}
417422

@@ -464,6 +469,12 @@ void UImGui::WindowInternal::setWindowAlwaysBelow() noexcept
464469

465470
XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&xclient);
466471
XFlush(display);
472+
#else
473+
#ifdef GLFW_EXPOSE_NATIVE_WIN32
474+
auto window = glfwGetWin32Window(windowMain);
475+
SetWindowPos(window, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
476+
//DefWindowProcA(window, WM_WINDOWPOSCHANGING, 0, 0);
477+
#endif
467478
#endif
468479
}
469480

@@ -535,6 +546,21 @@ void UImGui::WindowInternal::setShowWindowInPager(bool bShowInPagerr) noexcept
535546
XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&xclient);
536547
XFlush(display);
537548
}
549+
#else
550+
#ifdef GLFW_EXPOSE_NATIVE_WIN32
551+
if (!bShowOnPager)
552+
{
553+
auto window = glfwGetWin32Window(windowMain);
554+
LONG_PTR style = GetWindowLongPtr(window, GWL_EXSTYLE);
555+
SetWindowLongPtr(window, GWL_EXSTYLE, (style & ~WS_EX_APPWINDOW) | WS_EX_TOOLWINDOW);
556+
}
557+
else
558+
{
559+
auto window = glfwGetWin32Window(windowMain);
560+
LONG_PTR style = GetWindowLongPtr(window, GWL_EXSTYLE);
561+
SetWindowLongPtr(window, GWL_EXSTYLE, (style & WS_EX_APPWINDOW) | ~WS_EX_TOOLWINDOW);
562+
}
563+
#endif
538564
#endif
539565
}
540566

@@ -575,6 +601,21 @@ void UImGui::WindowInternal::setShowWindowOnTaskbar(bool bShowOnTaskbarr) noexce
575601
XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&xclient);
576602
XFlush(display);
577603
}
604+
#else
605+
#ifdef GLFW_EXPOSE_NATIVE_WIN32
606+
if (!bShowOnPager)
607+
{
608+
auto window = glfwGetWin32Window(windowMain);
609+
LONG_PTR style = GetWindowLongPtr(window, GWL_EXSTYLE);
610+
SetWindowLongPtr(window, GWL_EXSTYLE, (style & ~WS_EX_APPWINDOW) | WS_EX_TOOLWINDOW);
611+
}
612+
else
613+
{
614+
auto window = glfwGetWin32Window(windowMain);
615+
LONG_PTR style = GetWindowLongPtr(window, GWL_EXSTYLE);
616+
SetWindowLongPtr(window, GWL_EXSTYLE, (style & WS_EX_APPWINDOW) | ~WS_EX_TOOLWINDOW);
617+
}
618+
#endif
578619
#endif
579620
}
580621

0 commit comments

Comments
 (0)