|
@@ -1006,18 +1006,30 @@ void OS_X11::set_wm_fullscreen(bool p_enabled) {
|
|
|
|
|
|
XFlush(x11_display);
|
|
|
|
|
|
- if (!p_enabled && !is_window_resizable()) {
|
|
|
+ if (!p_enabled) {
|
|
|
// Reset the non-resizable flags if we un-set these before.
|
|
|
Size2 size = get_window_size();
|
|
|
XSizeHints *xsh;
|
|
|
-
|
|
|
xsh = XAllocSizeHints();
|
|
|
- xsh->flags = PMinSize | PMaxSize;
|
|
|
- xsh->min_width = size.x;
|
|
|
- xsh->max_width = size.x;
|
|
|
- xsh->min_height = size.y;
|
|
|
- xsh->max_height = size.y;
|
|
|
-
|
|
|
+ if (!is_window_resizable()) {
|
|
|
+ xsh->flags = PMinSize | PMaxSize;
|
|
|
+ xsh->min_width = size.x;
|
|
|
+ xsh->max_width = size.x;
|
|
|
+ xsh->min_height = size.y;
|
|
|
+ xsh->max_height = size.y;
|
|
|
+ } else {
|
|
|
+ xsh->flags = 0L;
|
|
|
+ if (min_size != Size2()) {
|
|
|
+ xsh->flags |= PMinSize;
|
|
|
+ xsh->min_width = min_size.x;
|
|
|
+ xsh->min_height = min_size.y;
|
|
|
+ }
|
|
|
+ if (max_size != Size2()) {
|
|
|
+ xsh->flags |= PMaxSize;
|
|
|
+ xsh->max_width = max_size.x;
|
|
|
+ xsh->max_height = max_size.y;
|
|
|
+ }
|
|
|
+ }
|
|
|
XSetWMNormalHints(x11_display, x11_window, xsh);
|
|
|
XFree(xsh);
|
|
|
}
|
|
@@ -1244,6 +1256,72 @@ Size2 OS_X11::get_real_window_size() const {
|
|
|
return Size2(w, h);
|
|
|
}
|
|
|
|
|
|
+Size2 OS_X11::get_max_window_size() const {
|
|
|
+ return max_size;
|
|
|
+}
|
|
|
+
|
|
|
+Size2 OS_X11::get_min_window_size() const {
|
|
|
+ return min_size;
|
|
|
+}
|
|
|
+
|
|
|
+void OS_X11::set_min_window_size(const Size2 p_size) {
|
|
|
+
|
|
|
+ if ((p_size != Size2()) && (max_size != Size2()) && ((p_size.x > max_size.x) || (p_size.y > max_size.y))) {
|
|
|
+ WARN_PRINT("Minimum window size can't be larger than maximum window size!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ min_size = p_size;
|
|
|
+
|
|
|
+ if (is_window_resizable()) {
|
|
|
+ XSizeHints *xsh;
|
|
|
+ xsh = XAllocSizeHints();
|
|
|
+ xsh->flags = 0L;
|
|
|
+ if (min_size != Size2()) {
|
|
|
+ xsh->flags |= PMinSize;
|
|
|
+ xsh->min_width = min_size.x;
|
|
|
+ xsh->min_height = min_size.y;
|
|
|
+ }
|
|
|
+ if (max_size != Size2()) {
|
|
|
+ xsh->flags |= PMaxSize;
|
|
|
+ xsh->max_width = max_size.x;
|
|
|
+ xsh->max_height = max_size.y;
|
|
|
+ }
|
|
|
+ XSetWMNormalHints(x11_display, x11_window, xsh);
|
|
|
+ XFree(xsh);
|
|
|
+
|
|
|
+ XFlush(x11_display);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void OS_X11::set_max_window_size(const Size2 p_size) {
|
|
|
+
|
|
|
+ if ((p_size != Size2()) && ((p_size.x < min_size.x) || (p_size.y < min_size.y))) {
|
|
|
+ WARN_PRINT("Maximum window size can't be smaller than minimum window size!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ max_size = p_size;
|
|
|
+
|
|
|
+ if (is_window_resizable()) {
|
|
|
+ XSizeHints *xsh;
|
|
|
+ xsh = XAllocSizeHints();
|
|
|
+ xsh->flags = 0L;
|
|
|
+ if (min_size != Size2()) {
|
|
|
+ xsh->flags |= PMinSize;
|
|
|
+ xsh->min_width = min_size.x;
|
|
|
+ xsh->min_height = min_size.y;
|
|
|
+ }
|
|
|
+ if (max_size != Size2()) {
|
|
|
+ xsh->flags |= PMaxSize;
|
|
|
+ xsh->max_width = max_size.x;
|
|
|
+ xsh->max_height = max_size.y;
|
|
|
+ }
|
|
|
+ XSetWMNormalHints(x11_display, x11_window, xsh);
|
|
|
+ XFree(xsh);
|
|
|
+
|
|
|
+ XFlush(x11_display);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void OS_X11::set_window_size(const Size2 p_size) {
|
|
|
|
|
|
if (current_videomode.width == p_size.width && current_videomode.height == p_size.height)
|
|
@@ -1256,17 +1334,29 @@ void OS_X11::set_window_size(const Size2 p_size) {
|
|
|
int old_h = xwa.height;
|
|
|
|
|
|
// If window resizable is disabled we need to update the attributes first
|
|
|
+ XSizeHints *xsh;
|
|
|
+ xsh = XAllocSizeHints();
|
|
|
if (!is_window_resizable()) {
|
|
|
- XSizeHints *xsh;
|
|
|
- xsh = XAllocSizeHints();
|
|
|
xsh->flags = PMinSize | PMaxSize;
|
|
|
xsh->min_width = p_size.x;
|
|
|
xsh->max_width = p_size.x;
|
|
|
xsh->min_height = p_size.y;
|
|
|
xsh->max_height = p_size.y;
|
|
|
- XSetWMNormalHints(x11_display, x11_window, xsh);
|
|
|
- XFree(xsh);
|
|
|
+ } else {
|
|
|
+ xsh->flags = 0L;
|
|
|
+ if (min_size != Size2()) {
|
|
|
+ xsh->flags |= PMinSize;
|
|
|
+ xsh->min_width = min_size.x;
|
|
|
+ xsh->min_height = min_size.y;
|
|
|
+ }
|
|
|
+ if (max_size != Size2()) {
|
|
|
+ xsh->flags |= PMaxSize;
|
|
|
+ xsh->max_width = max_size.x;
|
|
|
+ xsh->max_height = max_size.y;
|
|
|
+ }
|
|
|
}
|
|
|
+ XSetWMNormalHints(x11_display, x11_window, xsh);
|
|
|
+ XFree(xsh);
|
|
|
|
|
|
// Resize the window
|
|
|
XResizeWindow(x11_display, x11_window, p_size.x, p_size.y);
|
|
@@ -1312,20 +1402,37 @@ bool OS_X11::is_window_fullscreen() const {
|
|
|
}
|
|
|
|
|
|
void OS_X11::set_window_resizable(bool p_enabled) {
|
|
|
- XSizeHints *xsh;
|
|
|
- Size2 size = get_window_size();
|
|
|
|
|
|
+ XSizeHints *xsh;
|
|
|
xsh = XAllocSizeHints();
|
|
|
- xsh->flags = p_enabled ? 0L : PMinSize | PMaxSize;
|
|
|
if (!p_enabled) {
|
|
|
+ Size2 size = get_window_size();
|
|
|
+
|
|
|
+ xsh->flags = PMinSize | PMaxSize;
|
|
|
xsh->min_width = size.x;
|
|
|
xsh->max_width = size.x;
|
|
|
xsh->min_height = size.y;
|
|
|
xsh->max_height = size.y;
|
|
|
+ } else {
|
|
|
+ xsh->flags = 0L;
|
|
|
+ if (min_size != Size2()) {
|
|
|
+ xsh->flags |= PMinSize;
|
|
|
+ xsh->min_width = min_size.x;
|
|
|
+ xsh->min_height = min_size.y;
|
|
|
+ }
|
|
|
+ if (max_size != Size2()) {
|
|
|
+ xsh->flags |= PMaxSize;
|
|
|
+ xsh->max_width = max_size.x;
|
|
|
+ xsh->max_height = max_size.y;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
XSetWMNormalHints(x11_display, x11_window, xsh);
|
|
|
XFree(xsh);
|
|
|
+
|
|
|
current_videomode.resizable = p_enabled;
|
|
|
+
|
|
|
+ XFlush(x11_display);
|
|
|
}
|
|
|
|
|
|
bool OS_X11::is_window_resizable() const {
|