Coder Social home page Coder Social logo

Comments (5)

damywise avatar damywise commented on June 3, 2024

I had this exact issue except for the top bar.
Basically when the window is maximized, it doesn't leave any gap for the taskbar side.
Here's how I fixed it (should've opened a new PR for that) 81b972a (#374)
If you got time, maybe open a PR and try to experiment with the bottom border.

Don't do that, see below

from window_manager.

roman-yepishev avatar roman-yepishev commented on June 3, 2024

The sample code from Microsoft at https://learn.microsoft.com/en-us/windows/apps/develop/title-bar#full-customization-example also exhibits this problem: microsoft/microsoft-ui-xaml#8431.

The workaround mentioned in that bug is using https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist2-markfullscreenwindow#remarks:

Since Windows 7, call SetProp(hwnd, L”NonRudeHWND”, reinterpret_cast<HANDLE>(TRUE)) before showing a window to indicate to the Shell that the window should not be treated as full-screen. This ensures the taskbar does not adjust itself to be below the window in z-order.

from window_manager.

roman-yepishev avatar roman-yepishev commented on June 3, 2024

Adding a call of SetProp with NonRudeHWND in windows/window_manager.cpp fixes the taskbar visibility:

diff --git a/windows/window_manager.cpp b/windows/window_manager.cpp
index 3484176..5bd0e28 100644
--- a/windows/window_manager.cpp
+++ b/windows/window_manager.cpp
@@ -256,6 +256,7 @@ bool WindowManager::IsFocused() {

 void WindowManager::Show() {
   HWND hWnd = GetMainWindow();
+  SetProp(hWnd, L"NonRudeHWND", reinterpret_cast<HANDLE>(TRUE));
   DWORD gwlStyle = GetWindowLong(hWnd, GWL_STYLE);
   gwlStyle = gwlStyle | WS_VISIBLE;
   if ((gwlStyle & WS_VISIBLE) == 0) {

However, since this is the first time I see the codebase, I am not sure where this call should actually live.

from window_manager.

damywise avatar damywise commented on June 3, 2024

@roman-yepishev If this is only called once ever, you can put that here

void WindowManager::WaitUntilReadyToShow() {
::CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER,
IID_PPV_ARGS(&taskbar_));
}
and if you want, also enable/disable it when going to/from fullscreen here
if (isFullScreen) { // Set to fullscreen
::SendMessage(mainWindow, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
if (!is_frameless_) {
auto monitor = MONITORINFO{};
auto placement = WINDOWPLACEMENT{};
monitor.cbSize = sizeof(MONITORINFO);
placement.length = sizeof(WINDOWPLACEMENT);
::GetWindowPlacement(mainWindow, &placement);
::GetMonitorInfo(
::MonitorFromWindow(mainWindow, MONITOR_DEFAULTTONEAREST), &monitor);
::SetWindowLongPtr(mainWindow, GWL_STYLE,
g_style_before_fullscreen & ~WS_OVERLAPPEDWINDOW);
::SetWindowPos(mainWindow, HWND_TOP, monitor.rcMonitor.left,
monitor.rcMonitor.top,
monitor.rcMonitor.right - monitor.rcMonitor.left,
monitor.rcMonitor.bottom - monitor.rcMonitor.top,
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
}
} else { // Restore from fullscreen
if (!g_maximized_before_fullscreen)
Restore();
::SetWindowLongPtr(mainWindow, GWL_STYLE,
g_style_before_fullscreen | WS_OVERLAPPEDWINDOW);
if (::IsZoomed(mainWindow)) {
// Refresh the parent mainWindow.
::SetWindowPos(mainWindow, nullptr, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
SWP_FRAMECHANGED);
auto rect = RECT{};
::GetClientRect(mainWindow, &rect);
auto flutter_view = ::FindWindowEx(mainWindow, nullptr,
kFlutterViewWindowClassName, nullptr);
::SetWindowPos(flutter_view, nullptr, rect.left, rect.top,
rect.right - rect.left, rect.bottom - rect.top,
SWP_NOACTIVATE | SWP_NOZORDER);
if (g_maximized_before_fullscreen)
PostMessage(mainWindow, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
} else {
::SetWindowPos(
mainWindow, nullptr, g_frame_before_fullscreen.left,
g_frame_before_fullscreen.top,
g_frame_before_fullscreen.right - g_frame_before_fullscreen.left,
g_frame_before_fullscreen.bottom - g_frame_before_fullscreen.top,
SWP_NOACTIVATE | SWP_NOZORDER);
}
}

from window_manager.

roman-yepishev avatar roman-yepishev commented on June 3, 2024

A crude version of how this may work is roman-yepishev@3385880, however it changes the behavior dramatically (hides the window before switching to/from full-screen), which is likely not expected by the clients. Additionally the example app had issues redrawing with this enabled so this does not look like a good solution.

from window_manager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.