Merge pull request #19130 from guilhermefelipecgs/fix_borderless
More fixes to set_borderless_window
This commit is contained in:
commit
0fa3e30263
4 changed files with 10 additions and 16 deletions
|
@ -109,6 +109,7 @@ public:
|
||||||
bool minimized;
|
bool minimized;
|
||||||
bool maximized;
|
bool maximized;
|
||||||
bool zoomed;
|
bool zoomed;
|
||||||
|
bool resizable;
|
||||||
|
|
||||||
Size2 window_size;
|
Size2 window_size;
|
||||||
Rect2 restore_rect;
|
Rect2 restore_rect;
|
||||||
|
|
|
@ -1184,6 +1184,7 @@ Error OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
|
||||||
if (p_desired.borderless_window) {
|
if (p_desired.borderless_window) {
|
||||||
styleMask = NSWindowStyleMaskBorderless;
|
styleMask = NSWindowStyleMaskBorderless;
|
||||||
} else {
|
} else {
|
||||||
|
resizable = p_desired.resizable;
|
||||||
styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | (p_desired.resizable ? NSWindowStyleMaskResizable : 0);
|
styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | (p_desired.resizable ? NSWindowStyleMaskResizable : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2114,6 +2115,8 @@ void OS_OSX::set_window_resizable(bool p_enabled) {
|
||||||
[window_object setStyleMask:[window_object styleMask] | NSWindowStyleMaskResizable];
|
[window_object setStyleMask:[window_object styleMask] | NSWindowStyleMaskResizable];
|
||||||
else
|
else
|
||||||
[window_object setStyleMask:[window_object styleMask] & ~NSWindowStyleMaskResizable];
|
[window_object setStyleMask:[window_object styleMask] & ~NSWindowStyleMaskResizable];
|
||||||
|
|
||||||
|
resizable = p_enabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool OS_OSX::is_window_resizable() const {
|
bool OS_OSX::is_window_resizable() const {
|
||||||
|
@ -2223,7 +2226,7 @@ void OS_OSX::set_borderless_window(bool p_borderless) {
|
||||||
if (layered_window)
|
if (layered_window)
|
||||||
set_window_per_pixel_transparency_enabled(false);
|
set_window_per_pixel_transparency_enabled(false);
|
||||||
|
|
||||||
[window_object setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable];
|
[window_object setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | (resizable ? NSWindowStyleMaskResizable : 0)];
|
||||||
|
|
||||||
// Force update of the window styles
|
// Force update of the window styles
|
||||||
NSRect frameRect = [window_object frame];
|
NSRect frameRect = [window_object frame];
|
||||||
|
@ -2619,6 +2622,7 @@ OS_OSX::OS_OSX() {
|
||||||
minimized = false;
|
minimized = false;
|
||||||
window_size = Vector2(1024, 600);
|
window_size = Vector2(1024, 600);
|
||||||
zoomed = false;
|
zoomed = false;
|
||||||
|
resizable = false;
|
||||||
|
|
||||||
Vector<Logger *> loggers;
|
Vector<Logger *> loggers;
|
||||||
loggers.push_back(memnew(OSXTerminalLogger));
|
loggers.push_back(memnew(OSXTerminalLogger));
|
||||||
|
|
|
@ -628,21 +628,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
video_mode.height = window_h;
|
video_mode.height = window_h;
|
||||||
} else {
|
} else {
|
||||||
preserve_window_size = false;
|
preserve_window_size = false;
|
||||||
int w = video_mode.width;
|
set_window_size(Size2(video_mode.width, video_mode.height));
|
||||||
int h = video_mode.height;
|
|
||||||
|
|
||||||
RECT rect;
|
|
||||||
GetWindowRect(hWnd, &rect);
|
|
||||||
|
|
||||||
if (video_mode.borderless_window == false) {
|
|
||||||
RECT crect;
|
|
||||||
GetClientRect(hWnd, &crect);
|
|
||||||
|
|
||||||
w += (rect.right - rect.left) - (crect.right - crect.left);
|
|
||||||
h += (rect.bottom - rect.top) - (crect.bottom - crect.top);
|
|
||||||
}
|
|
||||||
|
|
||||||
MoveWindow(hWnd, rect.left, rect.top, w, h, TRUE);
|
|
||||||
}
|
}
|
||||||
if (wParam == SIZE_MAXIMIZED) {
|
if (wParam == SIZE_MAXIMIZED) {
|
||||||
maximized = true;
|
maximized = true;
|
||||||
|
|
|
@ -1292,6 +1292,9 @@ void OS_X11::set_borderless_window(bool p_borderless) {
|
||||||
hints.decorations = current_videomode.borderless_window ? 0 : 1;
|
hints.decorations = current_videomode.borderless_window ? 0 : 1;
|
||||||
property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True);
|
property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True);
|
||||||
XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5);
|
XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5);
|
||||||
|
|
||||||
|
// Preserve window size
|
||||||
|
set_window_size(Size2(current_videomode.width, current_videomode.height));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OS_X11::get_borderless_window() {
|
bool OS_X11::get_borderless_window() {
|
||||||
|
|
Loading…
Reference in a new issue