michael.griebel Posted April 7, 2025 Posted April 7, 2025 Hi all, I was wondering whether I can force the Unigine Engine to render the MainWindow above the Windows Taskbar if not started with -main_window_fullscreen 1. I'd like to switch between "fullscreen (no taskbar, no borders)", "maximized windows (taskbar and borders (specially top border for with close button)" and "non-maximized window (all borders visible, not topmost)", but my borderless fullscreen is still rendering behind the taskbar. This is the code that I am currently using... in my key down event handler. if (main_window->isMaximized() && main_window->isBordersEnabled()) { main_window->setBordersEnabled(false); main_window->setAlwaysOnTop(true); // Restoring is required here to force maximize to be executed by Unigine // Otherwise, the window won't resize but just remove borders which looks // strange main_window->restore(); main_window->maximize(); } else if (main_window->isMaximized()) { main_window->setBordersEnabled(true); main_window->setAlwaysOnTop(false); main_window->restore(); } else { main_window->maximize(); } Any ideas?
mifril Posted April 8, 2025 Posted April 8, 2025 Hi, In fact, when you call maximize you do not expand the window to the full screen, it opens just to the size of the full window without taking into account the task bar, if you want the window to open truly to the full screen, for this you need to set the borderless mode, select the monitor you are going to open the window to the full screen, put this window in the upper left corner of this monitor and set the window size as the size of this monitor #include <UnigineDisplays.h> void setFullscreen() { int display_index = 0; ivec2 position = Displays::getPosition(display_index); ivec2 size = Displays::getResolution(display_index); auto window = WindowManager::getMainWindow(); window->setBordersEnabled(false); window->setPosition(position); window->setSize(size); }
michael.griebel Posted April 14, 2025 Author Posted April 14, 2025 Thanks for reply. I got it working, although I have don't know why I have to call restore() before calling setSize. I guess that Unigine uses some offset otherwise which results in a partially overwritten taskbar... Could you please explain why this is required? if (auto main_window = UE::WindowManager::getMainWindow(); main_window) { if (main_window->isMaximized() && main_window->isBordersEnabled()) { // identify the current window auto windowCenter = main_window->getPosition() + main_window->getSize() / 2; auto display_index = Unigine::Displays::getByPoint(windowCenter); auto position = Unigine::Displays::getPosition(display_index); auto size = Unigine::Displays::getResolution(display_index); // Calling restore() is required here otherwise, // Unigine considers some offset which results in that the taskbar is only // partially overwritten. main_window->restore(); main_window->setBordersEnabled(false); main_window->setPosition(position); main_window->setSize(size); main_window->setAlwaysOnTop(true); } else if (main_window->isMaximized()) { main_window->setBordersEnabled(true); main_window->setAlwaysOnTop(false); main_window->restore(); } else { main_window->maximize(); }
mifril Posted April 14, 2025 Posted April 14, 2025 Hi, Yes, you need to restore the window in your case because the window is maximized and the OS is trying to maximize the window but not overlap the taskbar. You can read about showing the window here. Also to understand the differences between a borderless window and full-screen mode read answer in this article. 1
Recommended Posts