summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorhurikhan <m4r10.5ch14ck@gmail.com>2015-01-15 22:50:23 +0900
committerhurikhan <m4r10.5ch14ck@gmail.com>2015-01-15 22:50:23 +0900
commitd269344bbd19d9653fff3c2a230261b8fa00d7f6 (patch)
treeb15fb40ac8e7a85de8fd03902cd084de8e27a764 /platform
parent07b8d9136a6ccea1587d27ca30db1ec10aca0ed1 (diff)
WIP -- set_resizable() + is_resizable added
Diffstat (limited to 'platform')
-rw-r--r--platform/x11/os_x11.cpp57
-rw-r--r--platform/x11/os_x11.h9
2 files changed, 51 insertions, 15 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index d395e99210..f33c2556ba 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -223,7 +223,7 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
#endif
}
- // disable resizeable window
+ // disable resizable window
if (!current_videomode.resizable) {
XSizeHints *xsh;
xsh = XAllocSizeHints();
@@ -239,7 +239,9 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
xsh->min_height = xwa.height;
xsh->max_height = xwa.height;
XSetWMNormalHints(x11_display, x11_window, xsh);
+ XFree(xsh);
}
+ current_videomode.resizable;
AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton();
@@ -277,19 +279,19 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
XChangeWindowAttributes(x11_display, x11_window,CWEventMask,&new_attr);
- XClassHint* classHint;
+ XClassHint* classHint;
- /* set the titlebar name */
- XStoreName(x11_display, x11_window, "Godot");
+ /* set the titlebar name */
+ XStoreName(x11_display, x11_window, "Godot");
- /* set the name and class hints for the window manager to use */
- classHint = XAllocClassHint();
- if (classHint) {
- classHint->res_name = "Godot";
- classHint->res_class = "Godot";
- }
- XSetClassHint(x11_display, x11_window, classHint);
- XFree(classHint);
+ /* set the name and class hints for the window manager to use */
+ classHint = XAllocClassHint();
+ if (classHint) {
+ classHint->res_name = "Godot";
+ classHint->res_class = "Godot";
+ }
+ XSetClassHint(x11_display, x11_window, classHint);
+ XFree(classHint);
wm_delete = XInternAtom(x11_display, "WM_DELETE_WINDOW", true);
XSetWMProtocols(x11_display, x11_window, &wm_delete, 1);
@@ -708,6 +710,9 @@ void OS_X11::set_fullscreen(bool p_enabled) {
if(p_enabled && current_videomode.fullscreen)
return;
+ if(!current_videomode.resizable)
+ set_resizable(true);
+
if(p_enabled) {
window_data.size = get_window_size();
window_data.position = get_window_position();
@@ -734,11 +739,37 @@ void OS_X11::set_fullscreen(bool p_enabled) {
}
visual_server->init();
+
}
bool OS_X11::is_fullscreen() const {
return current_videomode.fullscreen;
}
+
+void OS_X11::set_resizable(bool p_enabled) {
+
+ if(!current_videomode.fullscreen) {
+ XSizeHints *xsh;
+ xsh = XAllocSizeHints();
+ xsh->flags = p_enabled ? 0L : PMinSize | PMaxSize;
+ if(!p_enabled) {
+ XWindowAttributes xwa;
+ XGetWindowAttributes(x11_display,x11_window,&xwa);
+ xsh->min_width = xwa.width;
+ xsh->max_width = xwa.width;
+ xsh->min_height = xwa.height;
+ xsh->max_height = xwa.height;
+ printf("%d %d\n", xwa.width, xwa.height);
+ }
+ XSetWMNormalHints(x11_display, x11_window, xsh);
+ XFree(xsh);
+ current_videomode.resizable = p_enabled;
+ }
+}
+
+bool OS_X11::is_resizable() const {
+ return current_videomode.resizable;
+}
#endif
InputModifierState OS_X11::get_key_modifier_state(unsigned int p_x11_state) {
@@ -1688,6 +1719,4 @@ OS_X11::OS_X11() {
minimized = false;
xim_style=NULL;
mouse_mode=MOUSE_MODE_VISIBLE;
-
-
};
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index 72d212c131..d286efe7b8 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -160,10 +160,15 @@ class OS_X11 : public OS_Unix {
Joystick joysticks[JOYSTICKS_MAX];
#ifdef EXPERIMENTAL_WM_API
+ // This struct saves the values of the window before going fullscreen
+ // to be able to restore the same state after leaving fullscreen
struct {
+ bool resizable;
Point2i position;
Size2i size;
- } window_data;
+ } window_data;
+
+ bool maximized;
void set_wm_border(bool p_enabled);
void set_wm_fullscreen(bool p_enabled);
#endif
@@ -234,6 +239,8 @@ public:
virtual void set_window_size(const Size2 p_size);
virtual void set_fullscreen(bool p_enabled);
virtual bool is_fullscreen() const;
+ virtual void set_resizable(bool p_enabled);
+ virtual bool is_resizable() const;
#endif
virtual void move_window_to_foreground();