mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-13 03:28:03 +00:00
Fix window positioning on Windows when the taskbar is on the top or left (#12933)
* Added win32_desktop.cpp/.h defining a method Win32Desktop::GetWorkArea. Added code to wWinMain in main.cpp to position the window relative to the work area, which may not be at (0, 0) depending on the user's configuration. * Corrected the constraint on the size value calculated by main.cpp. * Fixed references to min to use std::min. * Reworked GetWorkArea in win32_desktop.cpp to treat the supplied origin and size as containing an existing window rectangle, and to find the monitor that contains or is closest to that window. Added function FitToWorkArea to win32_desktop.cpp/.h. Updated main.cpp to use Win32Desktop::FitToWorkArea instead of explicitly constraining the size.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
#include "win32_desktop.h"
|
||||
#include "flutter_window.h"
|
||||
#include "utils.h"
|
||||
|
||||
@@ -126,8 +127,22 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
||||
project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
|
||||
|
||||
FlutterWindow window(project);
|
||||
Win32Window::Point origin(10, 10);
|
||||
Win32Window::Size size(800, 600);
|
||||
|
||||
// Get primary monitor's work area.
|
||||
Win32Window::Point workarea_origin(0, 0);
|
||||
Win32Window::Size workarea_size(0, 0);
|
||||
|
||||
Win32Desktop::GetWorkArea(workarea_origin, workarea_size);
|
||||
|
||||
// Compute window bounds for default main window position: (10, 10) x(800, 600)
|
||||
Win32Window::Point relative_origin(10, 10);
|
||||
|
||||
Win32Window::Point origin(workarea_origin.x + relative_origin.x, workarea_origin.y + relative_origin.y);
|
||||
Win32Window::Size size(800u, 600u);
|
||||
|
||||
// Fit the window to the monitor's work area.
|
||||
Win32Desktop::FitToWorkArea(origin, size);
|
||||
|
||||
std::wstring window_title;
|
||||
if (is_cm_page) {
|
||||
window_title = app_name + L" - Connection Manager";
|
||||
|
||||
Reference in New Issue
Block a user