From 398b640c3b90b2c916db7a873ea56d20b06a8b85 Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Sun, 13 Mar 2022 19:25:05 -0500 Subject: [PATCH 1/5] f --- src/windy/platforms/win32/platform.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/windy/platforms/win32/platform.nim b/src/windy/platforms/win32/platform.nim index a4fdc01..b3d22d6 100644 --- a/src/windy/platforms/win32/platform.nim +++ b/src/windy/platforms/win32/platform.nim @@ -432,7 +432,7 @@ proc `fullscreen=`*(window: Window, fullscreen: bool) = let mi = window.monitorInfo discard SetWindowPos( window.hWnd, - HWND_TOPMOST, + HWND_TOP, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right - mi.rcMonitor.left, From bd4fc2e011d27a8a690a83d40c9028ac2b0448a7 Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Sun, 13 Mar 2022 19:40:50 -0500 Subject: [PATCH 2/5] win32 floating window --- src/windy/platforms/win32/platform.nim | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/windy/platforms/win32/platform.nim b/src/windy/platforms/win32/platform.nim index b3d22d6..ffc650d 100644 --- a/src/windy/platforms/win32/platform.nim +++ b/src/windy/platforms/win32/platform.nim @@ -63,6 +63,7 @@ type state: WindowState trackMouseEventRegistered: bool exitFullscreenInfo: ExitFullscreenInfo + isFloating: bool hWnd: HWND hdc: HDC @@ -328,6 +329,9 @@ proc style*(window: Window): WindowStyle = proc fullscreen*(window: Window): bool = window.exitFullscreenInfo != nil +proc floating*(window: Window): bool = + window.isFloating + proc contentScale*(window: Window): float32 = let dpi = GetDpiForWindow(window.hWnd) result = dpi.float32 / defaultScreenDpi @@ -470,6 +474,22 @@ proc `fullscreen=`*(window: Window, fullscreen: bool) = if maximized: discard SendMessageW(window.hWnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0) +proc `floating=`*(window: Window, floating: bool) = + if window.floating == floating: + return + + window.isFloating = true + + discard SetWindowPos( + window.hWnd, + HWND_TOPMOST, + 0, + 0, + 0, + 0, + SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE + ) + proc `size=`*(window: Window, size: IVec2) = if window.fullscreen: return From 74faf6ae1c3d4b319284cfef22705a31040402fd Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Sun, 13 Mar 2022 19:44:21 -0500 Subject: [PATCH 3/5] f --- src/windy/platforms/win32/platform.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/windy/platforms/win32/platform.nim b/src/windy/platforms/win32/platform.nim index ffc650d..0342bde 100644 --- a/src/windy/platforms/win32/platform.nim +++ b/src/windy/platforms/win32/platform.nim @@ -478,11 +478,11 @@ proc `floating=`*(window: Window, floating: bool) = if window.floating == floating: return - window.isFloating = true + window.isFloating = floating discard SetWindowPos( window.hWnd, - HWND_TOPMOST, + if floating: HWND_TOPMOST else: HWND_TOP, 0, 0, 0, From 7365d1f4c6d9145807c844733308bd56a30d8363 Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Sun, 13 Mar 2022 19:50:50 -0500 Subject: [PATCH 4/5] macos floating window --- src/windy/platforms/macos/macdefs.nim | 5 +++++ src/windy/platforms/macos/platform.nim | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/windy/platforms/macos/macdefs.nim b/src/windy/platforms/macos/macdefs.nim index 0493956..d8624b1 100644 --- a/src/windy/platforms/macos/macdefs.nim +++ b/src/windy/platforms/macos/macdefs.nim @@ -31,6 +31,7 @@ type NSStringEncoding* = uint NSStringEncodingConversionOptions* = uint NSBitmapImageFileType* = uint + NSWindowLevel* = int NSRect* = CGRect NSPoint* = CGPoint @@ -104,6 +105,8 @@ const NSTrackingEnabledDuringMouseDrag* = 0x400.NSTrackingAreaOptions NSUTF32StringEncoding* = 0x8c000100.NSStringEncoding NSBitmapImageFileTypePNG* = 4.NSBitmapImageFileType + NSNormalWindowLevel* = 0.NSWindowLevel + NSFloatingWindowLevel* = 3.NSWindowLevel var NSApp* {.importc.}: NSApplication @@ -218,6 +221,8 @@ objc: proc toggleFullscreen*(self: NSWindow, _: ID) proc invalidateCursorRectsForView*(self: NSWindow, _: NSView) proc mouseLocationOutsideOfEventStream*(self: NSWindow): NSPoint + proc level*(self: NSWindow): NSWindowLevel + proc setLevel*(self: NSWindow, _: NSWindowLevel) proc convertRectToBacking*(self: NSView, _: NSRect): NSRect proc window*(self: NSView): NSWindow proc bounds*(self: NSView): NSRect diff --git a/src/windy/platforms/macos/platform.nim b/src/windy/platforms/macos/platform.nim index d5eee31..07dbcaa 100644 --- a/src/windy/platforms/macos/platform.nim +++ b/src/windy/platforms/macos/platform.nim @@ -67,6 +67,9 @@ proc style*(window: Window): WindowStyle = proc fullscreen*(window: Window): bool = (window.inner.styleMask and NSWindowStyleMaskFullScreen) != 0 +proc floating*(window: Window): bool = + window.inner.level == NSFloatingWindowLevel + proc contentScale*(window: Window): float32 = autoreleasepool: let @@ -151,6 +154,17 @@ proc `fullscreen=`*(window: Window, fullscreen: bool) = autoreleasepool: window.inner.toggleFullscreen(0.ID) +proc `floating=`*(window: Window, floating: bool) = + if window.floating == floating: + return + autoreleasepool: + let level = + if floating: + NSFloatingWindowLevel + else: + NSNormalWindowLevel + window.inner.setLevel(level) + proc `size=`*(window: Window, size: IVec2) = autoreleasepool: let virtualSize = (size.vec2 / window.contentScale) From b56fb2c725d9e9f19d750e9e1f98195cee284564 Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Sun, 13 Mar 2022 20:18:56 -0500 Subject: [PATCH 5/5] f --- src/windy/platforms/win32/platform.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/windy/platforms/win32/platform.nim b/src/windy/platforms/win32/platform.nim index 0342bde..841eeef 100644 --- a/src/windy/platforms/win32/platform.nim +++ b/src/windy/platforms/win32/platform.nim @@ -482,7 +482,7 @@ proc `floating=`*(window: Window, floating: bool) = discard SetWindowPos( window.hWnd, - if floating: HWND_TOPMOST else: HWND_TOP, + if floating: HWND_TOPMOST else: HWND_NOTOPMOST, 0, 0, 0,