Skip to content

Commit d6f9f4a

Browse files
committed
Hide desktop window icon from the Dock and adjust window creation parameters
1 parent 68a63dd commit d6f9f4a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

choc/gui/choc_DesktopWindow.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ struct DesktopWindow::Pimpl
340340
{
341341
using namespace choc::objc;
342342
CHOC_AUTORELEASE_BEGIN
343-
call<void> (getSharedNSApplication(), "setActivationPolicy:", NSApplicationActivationPolicyRegular);
343+
call<void> (getSharedNSApplication(), "setActivationPolicy:", 1); // NSApplicationActivationPolicyAccessory - hides from Dock
344344

345345
window = call<id> (callClass<id> ("NSWindow", "alloc"),
346346
"initWithContentRect:styleMask:backing:defer:",
@@ -765,11 +765,21 @@ struct DesktopWindow::Pimpl
765765
{
766766
Pimpl (DesktopWindow& w, Bounds b) : owner (w)
767767
{
768-
hwnd = windowClass.createWindow (WS_OVERLAPPEDWINDOW, 640, 480, this);
768+
hwnd = HWNDHolder (CreateWindowExW (WS_EX_TOOLWINDOW,
769+
+ windowClass.getClassName(),
770+
+ L"",
771+
+ WS_OVERLAPPEDWINDOW,
772+
+ CW_USEDEFAULT, CW_USEDEFAULT,
773+
+ b.width > 0 ? b.width : 640,
774+
+ b.height > 0 ? b.height : 480,
775+
+ nullptr, nullptr,
776+
+ windowClass.moduleHandle,
777+
+ nullptr));
769778

770779
if (hwnd.hwnd == nullptr)
771780
return;
772781

782+
SetWindowLongPtr (hwnd.hwnd, GWLP_USERDATA, (LONG_PTR) this);
773783
setBounds (b);
774784
ShowWindow (hwnd, SW_SHOW);
775785
UpdateWindow (hwnd);

0 commit comments

Comments
 (0)