From 97d290e466bfdf1bb0fa68d828c3a3cb13f138de Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sat, 10 Jan 2015 15:47:34 +0800 Subject: [PATCH 01/35] x11-fullscreen support through GDScript( OS.set_fullscreen(bool) ) --- core/bind/core_bind.cpp | 12 ++++++++++ core/bind/core_bind.h | 4 ++++ core/os/os.h | 4 ++++ platform/x11/os_x11.cpp | 49 +++++++++++++++++++++++++++++++++++++++++ platform/x11/os_x11.h | 3 +++ 5 files changed, 72 insertions(+) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 0c5d21b4f6..0d24486e90 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -176,6 +176,14 @@ bool _OS::is_video_mode_fullscreen(int p_screen) const { } +void _OS::set_fullscreen(bool p_fullscreen) { + OS::get_singleton()->set_fullscreen(p_fullscreen); +} + +bool _OS::is_fullscreen() const { + return OS::get_singleton()->is_fullscreen(); +} + void _OS::set_use_file_access_save_and_swap(bool p_enable) { FileAccess::set_backup_save(p_enable); @@ -632,6 +640,10 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_video_mode_resizable","screen"),&_OS::is_video_mode_resizable,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0)); + //MSC + ObjectTypeDB::bind_method(_MD("set_fullscreen","fullscreen"),&_OS::set_fullscreen); + ObjectTypeDB::bind_method(_MD("is_fullscreen"),&_OS::is_fullscreen); + ObjectTypeDB::bind_method(_MD("set_iterations_per_second","iterations_per_second"),&_OS::set_iterations_per_second); ObjectTypeDB::bind_method(_MD("get_iterations_per_second"),&_OS::get_iterations_per_second); ObjectTypeDB::bind_method(_MD("set_target_fps","target_fps"),&_OS::set_target_fps); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 12a4ae86eb..97aff87bca 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -108,6 +108,10 @@ public: bool is_video_mode_resizable(int p_screen=0) const; Array get_fullscreen_mode_list(int p_screen=0) const; + //MSC + void set_fullscreen(bool p_fullscreen); + bool is_fullscreen() const; + Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track); bool native_video_is_playing(); void native_video_pause(); diff --git a/core/os/os.h b/core/os/os.h index d4deff2f5e..e8de28e86a 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -149,6 +149,10 @@ public: virtual void set_video_mode(const VideoMode& p_video_mode,int p_screen=0)=0; virtual VideoMode get_video_mode(int p_screen=0) const=0; virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const=0; + + //MSC + virtual void set_fullscreen(bool fullscreen)=0; + virtual bool is_fullscreen() const=0; virtual void set_iterations_per_second(int p_ips); virtual int get_iterations_per_second() const; diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index aa9e4c63c9..bf0bef15db 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -521,6 +521,55 @@ void OS_X11::get_fullscreen_mode_list(List *p_list,int p_screen) cons } +void OS_X11::set_fullscreen(bool p_fullscreen) { + + long wm_action; + + if(p_fullscreen) { + current_videomode.fullscreen = True; + wm_action = 1; + } else { + current_videomode.fullscreen = False; + wm_action = 0; + } + + /* + // MSC: Disabled until I can test it with lxde + // + // needed for lxde/openbox, possibly others + Hints hints; + Atom property; + hints.flags = 2; + hints.decorations = 0; + property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True); + XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5); + XMapRaised(x11_display, x11_window); + XWindowAttributes xwa; + XGetWindowAttributes(x11_display, DefaultRootWindow(x11_display), &xwa); + XMoveResizeWindow(x11_display, x11_window, 0, 0, xwa.width, xwa.height); + */ + + // code for netwm-compliants + XEvent xev; + Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False); + Atom wm_fullscreen = XInternAtom(x11_display, "_NET_WM_STATE_FULLSCREEN", False); + + memset(&xev, 0, sizeof(xev)); + xev.type = ClientMessage; + xev.xclient.window = x11_window; + xev.xclient.message_type = wm_state; + xev.xclient.format = 32; + xev.xclient.data.l[0] = wm_action; + xev.xclient.data.l[1] = wm_fullscreen; + xev.xclient.data.l[2] = 0; + + XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureNotifyMask, &xev); + + visual_server->init(); +} + +bool OS_X11::is_fullscreen() const { +} InputModifierState OS_X11::get_key_modifier_state(unsigned int p_x11_state) { diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index dd2476ec1b..e92bd6e081 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -213,6 +213,9 @@ public: virtual VideoMode get_video_mode(int p_screen=0) const; virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const; + virtual void set_fullscreen(bool p_fullscreen); + virtual bool is_fullscreen() const; + virtual void move_window_to_foreground(); void run(); From cd90215ceca03b456aad761da935c92058b0da6a Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sat, 10 Jan 2015 16:01:01 +0800 Subject: [PATCH 02/35] Make GDScript-Function ( bool OS.is_fullscreen() ) work --- platform/x11/os_x11.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index bf0bef15db..79051b2ac5 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -569,6 +569,7 @@ void OS_X11::set_fullscreen(bool p_fullscreen) { } bool OS_X11::is_fullscreen() const { + return current_videomode.fullscreen; } InputModifierState OS_X11::get_key_modifier_state(unsigned int p_x11_state) { From 0d2ec19082e9ebff07ab1ab8e365e2db9ee3268b Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sat, 10 Jan 2015 18:38:30 +0800 Subject: [PATCH 03/35] API change to set_fullscreen(enabled,screen) --- core/bind/core_bind.cpp | 6 +++--- core/bind/core_bind.h | 2 +- core/os/os.h | 2 +- platform/x11/os_x11.cpp | 4 ++-- platform/x11/os_x11.h | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 0d24486e90..62d93745a0 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -176,8 +176,8 @@ bool _OS::is_video_mode_fullscreen(int p_screen) const { } -void _OS::set_fullscreen(bool p_fullscreen) { - OS::get_singleton()->set_fullscreen(p_fullscreen); +void _OS::set_fullscreen(bool p_enabled,int p_screen) { + OS::get_singleton()->set_fullscreen(p_enabled, p_screen); } bool _OS::is_fullscreen() const { @@ -641,7 +641,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0)); //MSC - ObjectTypeDB::bind_method(_MD("set_fullscreen","fullscreen"),&_OS::set_fullscreen); + ObjectTypeDB::bind_method(_MD("set_fullscreen","enabled","screen"),&_OS::set_fullscreen,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("is_fullscreen"),&_OS::is_fullscreen); ObjectTypeDB::bind_method(_MD("set_iterations_per_second","iterations_per_second"),&_OS::set_iterations_per_second); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 97aff87bca..fedd03c3a9 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -109,7 +109,7 @@ public: Array get_fullscreen_mode_list(int p_screen=0) const; //MSC - void set_fullscreen(bool p_fullscreen); + void set_fullscreen(bool p_enabled, int p_screen=0); bool is_fullscreen() const; Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track); diff --git a/core/os/os.h b/core/os/os.h index e8de28e86a..b86b122623 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -151,7 +151,7 @@ public: virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const=0; //MSC - virtual void set_fullscreen(bool fullscreen)=0; + virtual void set_fullscreen(bool p_enabled,int p_screen=0)=0; virtual bool is_fullscreen() const=0; virtual void set_iterations_per_second(int p_ips); diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 79051b2ac5..6dd2d7426f 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -521,11 +521,11 @@ void OS_X11::get_fullscreen_mode_list(List *p_list,int p_screen) cons } -void OS_X11::set_fullscreen(bool p_fullscreen) { +void OS_X11::set_fullscreen(bool p_enabled,int p_screen) { long wm_action; - if(p_fullscreen) { + if(p_enabled) { current_videomode.fullscreen = True; wm_action = 1; } else { diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index e92bd6e081..f382e21edc 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -166,8 +166,8 @@ protected: virtual const char * get_video_driver_name(int p_driver) const; virtual VideoMode get_default_video_mode() const; - virtual int get_audio_driver_count() const; - virtual const char * get_audio_driver_name(int p_driver) const; + virtual int get_audio_driver_count() const; + virtual const char * get_audio_driver_name(int p_driver) const; virtual void initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver); virtual void finalize(); @@ -213,7 +213,7 @@ public: virtual VideoMode get_video_mode(int p_screen=0) const; virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const; - virtual void set_fullscreen(bool p_fullscreen); + virtual void set_fullscreen(bool p_enabled,int p_screen=0); virtual bool is_fullscreen() const; virtual void move_window_to_foreground(); From 5d9de48d8d35961835135a7310840cdc9cbacb63 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sat, 10 Jan 2015 21:50:31 +0800 Subject: [PATCH 04/35] Make fullscreen-switching is working with LXDE/Openbox --- platform/x11/os_x11.cpp | 90 +++++++++++++++++++---------------------- platform/x11/os_x11.h | 4 ++ 2 files changed, 46 insertions(+), 48 deletions(-) diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 6dd2d7426f..707868ccb0 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -182,33 +182,8 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi // borderless fullscreen window mode if (current_videomode.fullscreen) { - // needed for lxde/openbox, possibly others - Hints hints; - Atom property; - hints.flags = 2; - hints.decorations = 0; - property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True); - XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5); - XMapRaised(x11_display, x11_window); - XWindowAttributes xwa; - XGetWindowAttributes(x11_display, DefaultRootWindow(x11_display), &xwa); - XMoveResizeWindow(x11_display, x11_window, 0, 0, xwa.width, xwa.height); - - // code for netwm-compliants - XEvent xev; - Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False); - Atom fullscreen = XInternAtom(x11_display, "_NET_WM_STATE_FULLSCREEN", False); - - memset(&xev, 0, sizeof(xev)); - xev.type = ClientMessage; - xev.xclient.window = x11_window; - xev.xclient.message_type = wm_state; - xev.xclient.format = 32; - xev.xclient.data.l[0] = 1; - xev.xclient.data.l[1] = fullscreen; - xev.xclient.data.l[2] = 0; - - XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureNotifyMask, &xev); + set_wm_border(false); + set_wm_fullscreen(true); } // disable resizeable window @@ -521,34 +496,19 @@ void OS_X11::get_fullscreen_mode_list(List *p_list,int p_screen) cons } -void OS_X11::set_fullscreen(bool p_enabled,int p_screen) { - - long wm_action; - - if(p_enabled) { - current_videomode.fullscreen = True; - wm_action = 1; - } else { - current_videomode.fullscreen = False; - wm_action = 0; - } - - /* - // MSC: Disabled until I can test it with lxde - // +void OS_X11::set_wm_border(bool p_enabled) { // needed for lxde/openbox, possibly others Hints hints; Atom property; hints.flags = 2; - hints.decorations = 0; + hints.decorations = p_enabled ? 1L : 0L;; property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True); XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5); XMapRaised(x11_display, x11_window); - XWindowAttributes xwa; - XGetWindowAttributes(x11_display, DefaultRootWindow(x11_display), &xwa); - XMoveResizeWindow(x11_display, x11_window, 0, 0, xwa.width, xwa.height); - */ + XMoveResizeWindow(x11_display, x11_window, 0, 0, current_videomode.width, current_videomode.height); +} +void OS_X11::set_wm_fullscreen(bool p_enabled) { // code for netwm-compliants XEvent xev; Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False); @@ -559,11 +519,45 @@ void OS_X11::set_fullscreen(bool p_enabled,int p_screen) { xev.xclient.window = x11_window; xev.xclient.message_type = wm_state; xev.xclient.format = 32; - xev.xclient.data.l[0] = wm_action; + xev.xclient.data.l[0] = p_enabled ? 1L : 0L; xev.xclient.data.l[1] = wm_fullscreen; xev.xclient.data.l[2] = 0; XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureNotifyMask, &xev); +} + +void OS_X11::set_fullscreen(bool p_enabled,int p_screen) { + + long wm_action; + long wm_decoration; + + if(p_enabled) { + wm_action = 1L; + wm_decoration = 0L; // Removes all decorations + + pre_videomode = current_videomode; + + // Get Desktop resolutuion + XWindowAttributes xwa; + XGetWindowAttributes(x11_display, DefaultRootWindow(x11_display), &xwa); + + current_videomode.fullscreen = True; + current_videomode.width = xwa.width; + current_videomode.height = xwa.height; + + set_wm_border(false); + set_wm_fullscreen(true); + } else { + wm_action = 0L; + wm_decoration = 1L; // MWM_DECORE_ALL (1L << 0) + + current_videomode.fullscreen = False; + current_videomode.width = pre_videomode.width; + current_videomode.height = pre_videomode.height; + + set_wm_fullscreen(false); + set_wm_border(true); + } visual_server->init(); } diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index f382e21edc..11842ace83 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -73,6 +73,7 @@ class OS_X11 : public OS_Unix { Rasterizer *rasterizer; VisualServer *visual_server; VideoMode current_videomode; + VideoMode pre_videomode; List args; Window x11_window; MainLoop *main_loop; @@ -159,6 +160,8 @@ class OS_X11 : public OS_Unix { int joystick_count; Joystick joysticks[JOYSTICKS_MAX]; + void set_wm_border(bool p_enabled); + void set_wm_fullscreen(bool p_enabled); protected: @@ -178,6 +181,7 @@ protected: void process_joysticks(); void close_joystick(int p_id = -1); + public: virtual String get_name(); From a8e3c5c0b7fb202bcceb06b9373b5b6a4ff8f9b8 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sun, 11 Jan 2015 01:07:23 +0800 Subject: [PATCH 05/35] First attempt of restoring the window at the old position --- core/os/os.h | 5 +++-- main/main.cpp | 7 ++++++- platform/x11/os_x11.cpp | 40 +++++++++++++++++++++++++++++----------- 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/core/os/os.h b/core/os/os.h index b86b122623..9de2e3556b 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -69,11 +69,12 @@ public: }; struct VideoMode { - int width,height; + int x,y,width,height; bool fullscreen; bool resizable; float get_aspect() const { return (float)width/(float)height; } - VideoMode(int p_width=640,int p_height=480,bool p_fullscreen=false, bool p_resizable = true) { width=p_width; height=p_height; fullscreen=p_fullscreen; resizable = p_resizable; } + VideoMode(int p_x=0, int p_y=0,int p_width=640,int p_height=480,bool p_fullscreen=false, bool p_resizable = true) + { x=p_x; y=p_y; width=p_width; height=p_height; fullscreen=p_fullscreen; resizable = p_resizable; } }; protected: friend class Main; diff --git a/main/main.cpp b/main/main.cpp index f0e376a045..b6638a3ad0 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -609,6 +609,10 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas if (video_driver=="") // specified in engine.cfg video_driver=_GLOBAL_DEF("display/driver",Variant((const char*)OS::get_singleton()->get_video_driver_name(0))); + if (!force_res && use_custom_res && globals->has("display/x")) + video_mode.width=globals->get("display/y"); + if (!force_res && use_custom_res && globals->has("display/width")) + video_mode.width=globals->get("display/width"); if (!force_res && use_custom_res && globals->has("display/width")) video_mode.width=globals->get("display/width"); if (!force_res &&use_custom_res && globals->has("display/height")) @@ -627,7 +631,8 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas } } - + GLOBAL_DEF("display/x",video_mode.x); + GLOBAL_DEF("display/y",video_mode.y); GLOBAL_DEF("display/width",video_mode.width); GLOBAL_DEF("display/height",video_mode.height); GLOBAL_DEF("display/fullscreen",video_mode.fullscreen); diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 707868ccb0..9e02f54dd4 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -71,7 +71,7 @@ const char * OS_X11::get_video_driver_name(int p_driver) const { } OS::VideoMode OS_X11::get_default_video_mode() const { - return OS::VideoMode(800,600,false); + return OS::VideoMode(0,0,800,600,false); } int OS_X11::get_audio_driver_count() const { @@ -163,6 +163,18 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi // maybe contextgl wants to be in charge of creating the window //print_line("def videomode "+itos(current_videomode.width)+","+itos(current_videomode.height)); #if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) + if( current_videomode.x > current_videomode.width || + current_videomode.y > current_videomode.height || + current_videomode.width==0 || + current_videomode.height==0) { + + current_videomode.x = 0; + current_videomode.y = 0; + current_videomode.width = 640; + current_videomode.height = 480; + } + + context_gl = memnew( ContextGL_X11( x11_display, x11_window,current_videomode, false ) ); context_gl->initialize(); @@ -505,7 +517,7 @@ void OS_X11::set_wm_border(bool p_enabled) { property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True); XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5); XMapRaised(x11_display, x11_window); - XMoveResizeWindow(x11_display, x11_window, 0, 0, current_videomode.width, current_videomode.height); + XMoveResizeWindow(x11_display, x11_window, current_videomode.x, current_videomode.y, current_videomode.width, current_videomode.height); } void OS_X11::set_wm_fullscreen(bool p_enabled) { @@ -528,17 +540,24 @@ void OS_X11::set_wm_fullscreen(bool p_enabled) { void OS_X11::set_fullscreen(bool p_enabled,int p_screen) { - long wm_action; - long wm_decoration; - if(p_enabled) { - wm_action = 1L; - wm_decoration = 0L; // Removes all decorations + XWindowAttributes xwa; + XGetWindowAttributes(x11_display, x11_window, &xwa); + + print_line(itos(xwa.x)); + print_line(itos(xwa.y)); + print_line(itos(xwa.width)); + print_line(itos(xwa.height)); + + current_videomode.x = xwa.x; + current_videomode.y = xwa.y; + current_videomode.width = xwa.width; + current_videomode.height = xwa.height; + pre_videomode = current_videomode; // Get Desktop resolutuion - XWindowAttributes xwa; XGetWindowAttributes(x11_display, DefaultRootWindow(x11_display), &xwa); current_videomode.fullscreen = True; @@ -548,10 +567,9 @@ void OS_X11::set_fullscreen(bool p_enabled,int p_screen) { set_wm_border(false); set_wm_fullscreen(true); } else { - wm_action = 0L; - wm_decoration = 1L; // MWM_DECORE_ALL (1L << 0) - current_videomode.fullscreen = False; + current_videomode.x = pre_videomode.x; + current_videomode.y = pre_videomode.y; current_videomode.width = pre_videomode.width; current_videomode.height = pre_videomode.height; From ac558c15eaeb45b3e7ae2604e26ca1dffb60b779 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sun, 11 Jan 2015 15:47:27 +0800 Subject: [PATCH 06/35] get_window_position() + set_window_position() added --- core/bind/core_bind.cpp | 10 +++++ core/bind/core_bind.h | 2 + core/os/os.h | 7 ++-- main/main.cpp | 6 --- platform/x11/os_x11.cpp | 86 +++++++++++++++++++++++++++-------------- platform/x11/os_x11.h | 2 + 6 files changed, 74 insertions(+), 39 deletions(-) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 62d93745a0..3109b8bc84 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -176,6 +176,14 @@ bool _OS::is_video_mode_fullscreen(int p_screen) const { } +Point2 _OS::get_window_position() const { + return OS::get_singleton()->get_window_position(); +} + +void _OS::set_window_position(const Point2& p_position) { + OS::get_singleton()->set_window_position(p_position); +} + void _OS::set_fullscreen(bool p_enabled,int p_screen) { OS::get_singleton()->set_fullscreen(p_enabled, p_screen); } @@ -641,6 +649,8 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0)); //MSC + ObjectTypeDB::bind_method(_MD("get_window_position"),&_OS::get_window_position); + ObjectTypeDB::bind_method(_MD("set_window_position"),&_OS::set_window_position); ObjectTypeDB::bind_method(_MD("set_fullscreen","enabled","screen"),&_OS::set_fullscreen,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("is_fullscreen"),&_OS::is_fullscreen); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index fedd03c3a9..92056aa0d6 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -109,6 +109,8 @@ public: Array get_fullscreen_mode_list(int p_screen=0) const; //MSC + virtual Point2 get_window_position() const; + virtual void set_window_position(const Point2& p_position); void set_fullscreen(bool p_enabled, int p_screen=0); bool is_fullscreen() const; diff --git a/core/os/os.h b/core/os/os.h index 9de2e3556b..9089e7de76 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -69,12 +69,11 @@ public: }; struct VideoMode { - int x,y,width,height; + int width,height; bool fullscreen; bool resizable; float get_aspect() const { return (float)width/(float)height; } - VideoMode(int p_x=0, int p_y=0,int p_width=640,int p_height=480,bool p_fullscreen=false, bool p_resizable = true) - { x=p_x; y=p_y; width=p_width; height=p_height; fullscreen=p_fullscreen; resizable = p_resizable; } + VideoMode(int p_width=640,int p_height=480,bool p_fullscreen=false, bool p_resizable = true) {width=p_width; height=p_height; fullscreen=p_fullscreen; resizable = p_resizable; } }; protected: friend class Main; @@ -152,6 +151,8 @@ public: virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const=0; //MSC + virtual Point2 get_window_position() const=0; + virtual void set_window_position(const Point2& p_position)=0; virtual void set_fullscreen(bool p_enabled,int p_screen=0)=0; virtual bool is_fullscreen() const=0; diff --git a/main/main.cpp b/main/main.cpp index b6638a3ad0..27d7d97e85 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -609,10 +609,6 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas if (video_driver=="") // specified in engine.cfg video_driver=_GLOBAL_DEF("display/driver",Variant((const char*)OS::get_singleton()->get_video_driver_name(0))); - if (!force_res && use_custom_res && globals->has("display/x")) - video_mode.width=globals->get("display/y"); - if (!force_res && use_custom_res && globals->has("display/width")) - video_mode.width=globals->get("display/width"); if (!force_res && use_custom_res && globals->has("display/width")) video_mode.width=globals->get("display/width"); if (!force_res &&use_custom_res && globals->has("display/height")) @@ -631,8 +627,6 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas } } - GLOBAL_DEF("display/x",video_mode.x); - GLOBAL_DEF("display/y",video_mode.y); GLOBAL_DEF("display/width",video_mode.width); GLOBAL_DEF("display/height",video_mode.height); GLOBAL_DEF("display/fullscreen",video_mode.fullscreen); diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 5a05455918..502d510f5b 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -70,7 +70,7 @@ const char * OS_X11::get_video_driver_name(int p_driver) const { } OS::VideoMode OS_X11::get_default_video_mode() const { - return OS::VideoMode(0,0,800,600,false); + return OS::VideoMode(800,600,false); } int OS_X11::get_audio_driver_count() const { @@ -162,17 +162,6 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi // maybe contextgl wants to be in charge of creating the window //print_line("def videomode "+itos(current_videomode.width)+","+itos(current_videomode.height)); #if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) - if( current_videomode.x > current_videomode.width || - current_videomode.y > current_videomode.height || - current_videomode.width==0 || - current_videomode.height==0) { - - current_videomode.x = 0; - current_videomode.y = 0; - current_videomode.width = 640; - current_videomode.height = 480; - } - context_gl = memnew( ContextGL_X11( x11_display, x11_window,current_videomode, false ) ); context_gl->initialize(); @@ -516,7 +505,7 @@ void OS_X11::set_wm_border(bool p_enabled) { property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True); XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5); XMapRaised(x11_display, x11_window); - XMoveResizeWindow(x11_display, x11_window, current_videomode.x, current_videomode.y, current_videomode.width, current_videomode.height); + XMoveResizeWindow(x11_display, x11_window, 0, 0, current_videomode.width, current_videomode.height); } void OS_X11::set_wm_fullscreen(bool p_enabled) { @@ -537,26 +526,65 @@ void OS_X11::set_wm_fullscreen(bool p_enabled) { XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureNotifyMask, &xev); } +Point2 OS_X11::get_window_position() const { + int x,y; + XWindowAttributes xwa; + Window child; + XTranslateCoordinates( x11_display, x11_window, DefaultRootWindow(x11_display), 0, 0, &x, &y, &child); + XGetWindowAttributes(x11_display, x11_window, &xwa); + + return Point2i(x,y); +} + +void OS_X11::set_window_position(const Point2& p_position) { + // _NET_FRAME_EXTENTS + + Atom property = XInternAtom(x11_display,"_NET_FRAME_EXTENTS", True); + Atom type; + int format; + unsigned long len; + unsigned long remaining; + unsigned char *data = NULL; + //long *extends; + int result; + + result = XGetWindowProperty( + x11_display, + x11_window, + property, + 0, + 32, + False, + AnyPropertyType, + &type, + &format, + &len, + &remaining, + &data + ); + + long left = 0L; + long top = 0L; + + if( result == Success ) { + long *extends = (long *) data; + + left = extends[0]; + top = extends[2]; + + XFree(data); + data = NULL; + } + + XMoveWindow(x11_display,x11_window,p_position.x - left,p_position.y - top); +} + void OS_X11::set_fullscreen(bool p_enabled,int p_screen) { if(p_enabled) { - XWindowAttributes xwa; - XGetWindowAttributes(x11_display, x11_window, &xwa); - - print_line(itos(xwa.x)); - print_line(itos(xwa.y)); - print_line(itos(xwa.width)); - print_line(itos(xwa.height)); - - current_videomode.x = xwa.x; - current_videomode.y = xwa.y; - current_videomode.width = xwa.width; - current_videomode.height = xwa.height; - - pre_videomode = current_videomode; - // Get Desktop resolutuion + XWindowAttributes xwa; XGetWindowAttributes(x11_display, DefaultRootWindow(x11_display), &xwa); current_videomode.fullscreen = True; @@ -567,8 +595,6 @@ void OS_X11::set_fullscreen(bool p_enabled,int p_screen) { set_wm_fullscreen(true); } else { current_videomode.fullscreen = False; - current_videomode.x = pre_videomode.x; - current_videomode.y = pre_videomode.y; current_videomode.width = pre_videomode.width; current_videomode.height = pre_videomode.height; diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 11842ace83..ad7364f999 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -217,6 +217,8 @@ public: virtual VideoMode get_video_mode(int p_screen=0) const; virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const; + virtual Point2 get_window_position() const; + virtual void set_window_position(const Point2& p_position); virtual void set_fullscreen(bool p_enabled,int p_screen=0); virtual bool is_fullscreen() const; From 466e251abecf3686f0caac40ab886155e43cc0a6 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sun, 11 Jan 2015 17:36:56 +0800 Subject: [PATCH 07/35] get_window_size() + set_window_size() added --- core/bind/core_bind.cpp | 11 ++++++++++- core/bind/core_bind.h | 3 ++- core/os/os.h | 3 ++- platform/x11/os_x11.cpp | 18 +++++++++++++++++- platform/x11/os_x11.h | 2 ++ 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 3109b8bc84..2b4e2e1239 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -184,6 +184,14 @@ void _OS::set_window_position(const Point2& p_position) { OS::get_singleton()->set_window_position(p_position); } +Size2 _OS::get_window_size() const { + return OS::get_singleton()->get_window_size(); +} + +void _OS::set_window_size(const Size2& p_size) { + OS::get_singleton()->set_window_size(p_size); +} + void _OS::set_fullscreen(bool p_enabled,int p_screen) { OS::get_singleton()->set_fullscreen(p_enabled, p_screen); } @@ -648,9 +656,10 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_video_mode_resizable","screen"),&_OS::is_video_mode_resizable,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0)); - //MSC ObjectTypeDB::bind_method(_MD("get_window_position"),&_OS::get_window_position); ObjectTypeDB::bind_method(_MD("set_window_position"),&_OS::set_window_position); + ObjectTypeDB::bind_method(_MD("get_window_size"),&_OS::get_window_size); + ObjectTypeDB::bind_method(_MD("set_window_size"),&_OS::set_window_size); ObjectTypeDB::bind_method(_MD("set_fullscreen","enabled","screen"),&_OS::set_fullscreen,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("is_fullscreen"),&_OS::is_fullscreen); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 92056aa0d6..e60bb5e66a 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -108,9 +108,10 @@ public: bool is_video_mode_resizable(int p_screen=0) const; Array get_fullscreen_mode_list(int p_screen=0) const; - //MSC virtual Point2 get_window_position() const; virtual void set_window_position(const Point2& p_position); + virtual Size2 get_window_size() const; + virtual void set_window_size(const Size2& p_size); void set_fullscreen(bool p_enabled, int p_screen=0); bool is_fullscreen() const; diff --git a/core/os/os.h b/core/os/os.h index 9089e7de76..7e9fdcc579 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -150,9 +150,10 @@ public: virtual VideoMode get_video_mode(int p_screen=0) const=0; virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const=0; - //MSC virtual Point2 get_window_position() const=0; virtual void set_window_position(const Point2& p_position)=0; + virtual Size2 get_window_size() const=0; + virtual void set_window_size(const Size2 p_size)=0; virtual void set_fullscreen(bool p_enabled,int p_screen=0)=0; virtual bool is_fullscreen() const=0; diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 502d510f5b..f21ea4c9a2 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -537,8 +537,11 @@ Point2 OS_X11::get_window_position() const { } void OS_X11::set_window_position(const Point2& p_position) { - // _NET_FRAME_EXTENTS + if( current_videomode.fullscreen ) + return; + + // _NET_FRAME_EXTENTS Atom property = XInternAtom(x11_display,"_NET_FRAME_EXTENTS", True); Atom type; int format; @@ -579,6 +582,19 @@ void OS_X11::set_window_position(const Point2& p_position) { XMoveWindow(x11_display,x11_window,p_position.x - left,p_position.y - top); } +Size2 OS_X11::get_window_size() const { + XWindowAttributes xwa; + XGetWindowAttributes(x11_display, x11_window, &xwa); + return Size2i(xwa.width, xwa.height); +} + +void OS_X11::set_window_size(const Size2 p_size) { + if( current_videomode.fullscreen ) + return; + + XResizeWindow(x11_display, x11_window, p_size.x, p_size.y); +} + void OS_X11::set_fullscreen(bool p_enabled,int p_screen) { if(p_enabled) { diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index ad7364f999..1cedea4223 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -219,6 +219,8 @@ public: virtual Point2 get_window_position() const; virtual void set_window_position(const Point2& p_position); + virtual Size2 get_window_size() const; + virtual void set_window_size(const Size2 p_size); virtual void set_fullscreen(bool p_enabled,int p_screen=0); virtual bool is_fullscreen() const; From 3c8b047b111cf20b3823851e298ce42bdf941871 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sun, 11 Jan 2015 18:52:42 +0800 Subject: [PATCH 08/35] get_screen_count() added --- core/bind/core_bind.cpp | 5 +++++ core/bind/core_bind.h | 1 + core/os/os.h | 1 + platform/x11/os_x11.cpp | 7 +++++++ platform/x11/os_x11.h | 1 + 5 files changed, 15 insertions(+) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 2b4e2e1239..3f86efc879 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -176,6 +176,10 @@ bool _OS::is_video_mode_fullscreen(int p_screen) const { } +int _OS::get_screen_count() const { + return OS::get_singleton()->get_screen_count(); +} + Point2 _OS::get_window_position() const { return OS::get_singleton()->get_window_position(); } @@ -656,6 +660,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_video_mode_resizable","screen"),&_OS::is_video_mode_resizable,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0)); + ObjectTypeDB::bind_method(_MD("get_screen_count"),&_OS::get_screen_count); ObjectTypeDB::bind_method(_MD("get_window_position"),&_OS::get_window_position); ObjectTypeDB::bind_method(_MD("set_window_position"),&_OS::set_window_position); ObjectTypeDB::bind_method(_MD("get_window_size"),&_OS::get_window_size); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index e60bb5e66a..cb9a5da479 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -108,6 +108,7 @@ public: bool is_video_mode_resizable(int p_screen=0) const; Array get_fullscreen_mode_list(int p_screen=0) const; + virtual int get_screen_count() const; virtual Point2 get_window_position() const; virtual void set_window_position(const Point2& p_position); virtual Size2 get_window_size() const; diff --git a/core/os/os.h b/core/os/os.h index 7e9fdcc579..68769e7ad4 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -150,6 +150,7 @@ public: virtual VideoMode get_video_mode(int p_screen=0) const=0; virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const=0; + virtual int get_screen_count() const=0; virtual Point2 get_window_position() const=0; virtual void set_window_position(const Point2& p_position)=0; virtual Size2 get_window_size() const=0; diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index f21ea4c9a2..c37358139c 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -526,6 +526,10 @@ void OS_X11::set_wm_fullscreen(bool p_enabled) { XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureNotifyMask, &xev); } +int OS_X11::get_screen_count() const { + return XScreenCount(x11_display); +} + Point2 OS_X11::get_window_position() const { int x,y; XWindowAttributes xwa; @@ -597,6 +601,9 @@ void OS_X11::set_window_size(const Size2 p_size) { void OS_X11::set_fullscreen(bool p_enabled,int p_screen) { + if(p_enabled && current_videomode.fullscreen) + return; + if(p_enabled) { pre_videomode = current_videomode; diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 1cedea4223..f55b7dc0e3 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -217,6 +217,7 @@ public: virtual VideoMode get_video_mode(int p_screen=0) const; virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const; + virtual int get_screen_count() const; virtual Point2 get_window_position() const; virtual void set_window_position(const Point2& p_position); virtual Size2 get_window_size() const; From f9d0de0d2a82456f3553499fcbc1c487b59fed1c Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sun, 11 Jan 2015 19:35:53 +0800 Subject: [PATCH 09/35] get_screen_size() added --- core/bind/core_bind.cpp | 5 +++++ core/bind/core_bind.h | 1 + core/os/os.h | 1 + platform/x11/os_x11.cpp | 8 ++++++++ platform/x11/os_x11.h | 1 + 5 files changed, 16 insertions(+) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 3f86efc879..47bfba1cbb 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -180,6 +180,10 @@ int _OS::get_screen_count() const { return OS::get_singleton()->get_screen_count(); } +Size2 _OS::get_screen_size(int p_screen) const { + return OS::get_singleton()->get_screen_size(p_screen); +} + Point2 _OS::get_window_position() const { return OS::get_singleton()->get_window_position(); } @@ -661,6 +665,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_screen_count"),&_OS::get_screen_count); + ObjectTypeDB::bind_method(_MD("get_screen_size"),&_OS::get_screen_size,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_window_position"),&_OS::get_window_position); ObjectTypeDB::bind_method(_MD("set_window_position"),&_OS::set_window_position); ObjectTypeDB::bind_method(_MD("get_window_size"),&_OS::get_window_size); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index cb9a5da479..2a87f85ec7 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -109,6 +109,7 @@ public: Array get_fullscreen_mode_list(int p_screen=0) const; virtual int get_screen_count() const; + virtual Size2 get_screen_size(int p_screen=0) const; virtual Point2 get_window_position() const; virtual void set_window_position(const Point2& p_position); virtual Size2 get_window_size() const; diff --git a/core/os/os.h b/core/os/os.h index 68769e7ad4..edb5d57c5f 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -151,6 +151,7 @@ public: virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const=0; virtual int get_screen_count() const=0; + virtual Size2 get_screen_size(int p_screen=0) const=0; virtual Point2 get_window_position() const=0; virtual void set_window_position(const Point2& p_position)=0; virtual Size2 get_window_size() const=0; diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index c37358139c..063fb17c26 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -530,6 +530,14 @@ int OS_X11::get_screen_count() const { return XScreenCount(x11_display); } +Size2 OS_X11::get_screen_size(int p_screen) const { + Window root = XRootWindow(x11_display, p_screen); + XWindowAttributes xwa; + XGetWindowAttributes(x11_display, root, &xwa); + return Size2i(xwa.width, xwa.height); +} + + Point2 OS_X11::get_window_position() const { int x,y; XWindowAttributes xwa; diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index f55b7dc0e3..a38d511003 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -218,6 +218,7 @@ public: virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const; virtual int get_screen_count() const; + virtual Size2 get_screen_size(int p_screen=0) const; virtual Point2 get_window_position() const; virtual void set_window_position(const Point2& p_position); virtual Size2 get_window_size() const; From 107d2a373a4a66bc237cc47128f815c2624c35bb Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sun, 11 Jan 2015 20:30:57 +0800 Subject: [PATCH 10/35] Demo misc/window_management added --- demos/misc/window_management/control.gd | 39 ++++++++++++++++++ demos/misc/window_management/engine.cfg | 5 +++ demos/misc/window_management/icon.png | Bin 0 -> 3639 bytes demos/misc/window_management/icon.png.flags | 1 + .../window_management/window_management.scn | Bin 0 -> 3276 bytes 5 files changed, 45 insertions(+) create mode 100644 demos/misc/window_management/control.gd create mode 100644 demos/misc/window_management/engine.cfg create mode 100644 demos/misc/window_management/icon.png create mode 100644 demos/misc/window_management/icon.png.flags create mode 100644 demos/misc/window_management/window_management.scn diff --git a/demos/misc/window_management/control.gd b/demos/misc/window_management/control.gd new file mode 100644 index 0000000000..3e74f24e42 --- /dev/null +++ b/demos/misc/window_management/control.gd @@ -0,0 +1,39 @@ + +extends Control + +func _fixed_process(delta): + if(OS.is_fullscreen()): + get_node("Label_Fullscreen").set_text("Mode:\nFullscreen") + else: + get_node("Label_Fullscreen").set_text("Mode:\nWindowed") + + get_node("Label_Position").set_text( str("Position:\n", OS.get_window_position() ) ) + + get_node("Label_Size").set_text(str("Size:\n", OS.get_window_size() ) ) + + get_node("Label_Screen_Count").set_text( str("Screens:\n", OS.get_screen_count() ) ) + + get_node("Label_Screen0_Resolution").set_text( str("Screen0 Resolution:\n", OS.get_screen_size() ) ) + + if(OS.get_screen_count() > 1): + get_node("Label_Screen1_Resolution").show() + get_node("Label_Screen1_Resolution").set_text( str("Screen0 Resolution:\n", OS.get_screen_size(1) ) ) + + +func _ready(): + set_fixed_process(true) + + +func _on_Fullscreen_toggled( pressed ): + if(pressed): + OS.set_fullscreen(true) + else: + OS.set_fullscreen(false) + + +func _on_Button_MoveTo_pressed(): + OS.set_window_position( Vector2(100,100) ) + + +func _on_Button_Resize_pressed(): + OS.set_window_size( Vector2(1024,768) ) diff --git a/demos/misc/window_management/engine.cfg b/demos/misc/window_management/engine.cfg new file mode 100644 index 0000000000..7b6dddce96 --- /dev/null +++ b/demos/misc/window_management/engine.cfg @@ -0,0 +1,5 @@ +[application] + +name="window_management" +main_scene="res://window_management.scn" +icon="icon.png" diff --git a/demos/misc/window_management/icon.png b/demos/misc/window_management/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..0c422e37b0ea9e6ad2901c8d425cb12f4d37694f GIT binary patch literal 3639 zcmeAS@N?(olHy`uVBq!ia0y~yU~m9o4mJh`hE|9QGNhE&XXIy*XF+OzC< zedt|Zv-e9}VspKxrDQ+(*z>j`ZL|0rCPtwrxeYbVZ^S(&^c(a$%1zdv@Rz6Z#&rfx zwb_xkXH3+MPd&Y>TSzr<&*uE8?Rh~#c{Cw7uyl3A@_gEnOc)2lO;b){rEQ0 zwM65=y-SDdS^qt3=G0@+C_SpD;-&c@>#u{i;QwuZKAp5TTc3GWUp}USL9s*4U2^uU z#Zj7zY|1wrUvliq86l3&t1CVzwy>`-e>LObiSz24f*0@n^X|RkhK2)g{{MC6$e&?2 zX=b6@rAW2MC$D|IUOoGXSv>z0_q3#G`e}Jv>)wZZ$;_20D%#Q?svSG?_yM81-G4rv zd_RjTLR+LiKW=I8;hw_R*QPHyq}Fz&YTM8E$NzT*-D^Gk$lU&Sw$0KBi!Qs~T<3jr zTSV=4r@ci*qGg`y#_y-c+s(Y(wEh3>s>O9L&$V3nakV*K_)>|9VnBmH>_1W4d5i@lp@qTKM}l{1Gy>D9}^2^RQSE@N{ibF5w_vLD`1f5uC z&ijv0AV6 zy6U2@-(=GtR>(2DdbRoRmUE%Xdm7qTB@18e<(~aINV)Eqr&Q4E*A~?aAMOm7V`6k- zzH!U-gXGGH-qq!%3a_@kz5JKK$|9bTxhG$+C*0iNbU))#kyD=qiWvSEH}X8!a=6T9 z@N&XQ@%VpTCo6>BAD;2F^@LmUo&Eo_dkVfB+IEZeaM0`%ezmu?*-rGF|M2vYZHwgc zl1c0#)6I_O>lEex;|o;2VqEZZT=9EjOaAhwnn(ZK z5K->rIUoK{;0#ySlNTcK=k8{1{hO23mbKL5r^WTF(|2tD60nussZH{!c>F)1+r@@U z+LnvV3wjYWX?RU)3!$E7sjRYoY4N6$ZRSeiU%>-E{TyMw$ECD?W?Og7hv z*}i>|i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ztaD0e0st}18>9dL literal 0 HcmV?d00001 diff --git a/demos/misc/window_management/icon.png.flags b/demos/misc/window_management/icon.png.flags new file mode 100644 index 0000000000..5130fd1aab --- /dev/null +++ b/demos/misc/window_management/icon.png.flags @@ -0,0 +1 @@ +gen_mipmaps=false diff --git a/demos/misc/window_management/window_management.scn b/demos/misc/window_management/window_management.scn new file mode 100644 index 0000000000000000000000000000000000000000..6eaf62ff9f6a9cf0cff2b4e2d38f0441855b7035 GIT binary patch literal 3276 zcmWFvc6Md}0RaYvDmey*-|P$wTUi(w7#SEE7#SEF*b*2RcobN<0uqz6Q&WPIQ}a?4 zcpsQDFt8}tCB!rEDRA%=r55Lx7A2?Z=OyN*GH@ygvd1Tt=B4DMrXuq!Ar1Sg0xG6*VgDcJK^>FX!w=am%Y=jf%UBq%d*DM+y7TQC`d6GFx*k# zbzpeFe%zs%fk{DvK}vzyA(Vktft`U(f!U#xshB}Yfs-Lifti6rfte$?Ah9GfF^7Ry zftx)(Gq)hWs3cxNh$(|X=mC=eS4mM~UU6D}Q7(h9f+$y6W^raxW=>{FrG5ezL(YOb zZ1K6NC5iFz2`|}0Qj1HROOsL)YFTpvv}BN02zbCC!jhX< zl3JwD%N3trmReMlnUcyN`hZ!ECpodWB)&K!F(tp8LGl5!1Y1#Ra%yH->H=wo;s>mz z3cK0UQ{$6T(=+oD_B~+8ZIEC}%}aT}DyDFYH76-Qu_)yMtJ?zxF~<1H2doloDX9e| z8S%x6lbBK&q}{W6)0$WMtr05auc<%FjwoF3HT#V{qzW zO3N=x{KK4=npo5zpup~=%buN@S`eRDT%e$x#LkgiT2z#pSHi%r;Cx`m!tD-v?5TNW znML_|xeiKBC)qOM^V8CbQyX{~$`0^2ZDn-HRP1%AXG+ZRNx0$=$XSqBl$cwrpPHAb zq}!N(K!`IXvn0PLK0hy~GQntzsJ|(lbBrz}f0gE_8u|hU;Nql)~V)z5*C5=4` zmN;KyaBeY8n3j01c|CJ}L1MDs5=H?c@Lk6FJYzaT+j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+iGnj%cFasNBzJQ&(l+1DRj&Je7S@086DqQLIBogs7qJ44t4c7|{Tb_aQe2nBYB&kT_Z*d2wPiyeMD z?PiEl5O>(l5Us%Opw1ApfSn;$f!!${lCPcE8R8T;9Hkw@AIeKRay$HX6s!|aFb+>h9IKVoKg(0|0t?&AJPot+_m!Rtr%><4~3ayzj*gg=n}{m7r)RsNAa zJ5vG!!y^-RH|a;r?5>L+N^?72e`L(=#thPwxZt(p`bYAgp9u3G_m|Ykh7#vj{ h#2GRaco@ Date: Sun, 11 Jan 2015 22:02:18 +0800 Subject: [PATCH 11/35] Update README.md --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 3456290f74..57068bf39c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ +### x11-window-management branch + +#### New GDScript Methods for the OS Class: +* int OS.get_screen_count() +* Vector2 OS.get_screen_size(int screen=0) +* Vector2 OS.get_window_position() +* void OS.set_window_position(Vector2 position) +* Vector2 OS.get_window_size() +* void OS.set_window_size(Vector2 size) +* void OS.set_fullscreen(bool enabled, int screen=0) +* bool OS.is_fullscreen() + +#### Demo +A demo/test is available at "demos/misc/window-management" + +#### Warning +Just only works for X11. It breaks other platforms at the moment. + ![GODOT](/logo.png) ### The Engine From c0d363266755de3ac87f61600f23921d881d99e2 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Tue, 13 Jan 2015 15:44:39 +0800 Subject: [PATCH 12/35] introduced the scons experimental_wm_api switch: ================================================ Usage: scons p=x11 experimental_wm_api=yes --- core/bind/core_bind.cpp | 4 ++++ core/bind/core_bind.h | 2 ++ core/os/os.h | 4 +++- platform/x11/detect.py | 4 ++++ platform/x11/os_x11.cpp | 32 ++++++++++++++++++++++++++++++++ platform/x11/os_x11.h | 7 +++++-- 6 files changed, 50 insertions(+), 3 deletions(-) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 47bfba1cbb..b8fc63dc43 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -176,6 +176,7 @@ bool _OS::is_video_mode_fullscreen(int p_screen) const { } +#ifdef EXPERIMENTAL_WM_API int _OS::get_screen_count() const { return OS::get_singleton()->get_screen_count(); } @@ -207,6 +208,7 @@ void _OS::set_fullscreen(bool p_enabled,int p_screen) { bool _OS::is_fullscreen() const { return OS::get_singleton()->is_fullscreen(); } +#endif void _OS::set_use_file_access_save_and_swap(bool p_enable) { @@ -664,6 +666,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_video_mode_resizable","screen"),&_OS::is_video_mode_resizable,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0)); +#ifdef EXPERIMENTAL_WM_API ObjectTypeDB::bind_method(_MD("get_screen_count"),&_OS::get_screen_count); ObjectTypeDB::bind_method(_MD("get_screen_size"),&_OS::get_screen_size,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_window_position"),&_OS::get_window_position); @@ -672,6 +675,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_window_size"),&_OS::set_window_size); ObjectTypeDB::bind_method(_MD("set_fullscreen","enabled","screen"),&_OS::set_fullscreen,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("is_fullscreen"),&_OS::is_fullscreen); +#endif ObjectTypeDB::bind_method(_MD("set_iterations_per_second","iterations_per_second"),&_OS::set_iterations_per_second); ObjectTypeDB::bind_method(_MD("get_iterations_per_second"),&_OS::get_iterations_per_second); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 2a87f85ec7..62f9913556 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -108,6 +108,7 @@ public: bool is_video_mode_resizable(int p_screen=0) const; Array get_fullscreen_mode_list(int p_screen=0) const; +#ifdef EXPERIMENTAL_WM_API virtual int get_screen_count() const; virtual Size2 get_screen_size(int p_screen=0) const; virtual Point2 get_window_position() const; @@ -116,6 +117,7 @@ public: virtual void set_window_size(const Size2& p_size); void set_fullscreen(bool p_enabled, int p_screen=0); bool is_fullscreen() const; +#endif Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track); bool native_video_is_playing(); diff --git a/core/os/os.h b/core/os/os.h index edb5d57c5f..c2534287bc 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -150,6 +150,7 @@ public: virtual VideoMode get_video_mode(int p_screen=0) const=0; virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const=0; +#ifdef EXPERIMENTAL_WM_API virtual int get_screen_count() const=0; virtual Size2 get_screen_size(int p_screen=0) const=0; virtual Point2 get_window_position() const=0; @@ -158,7 +159,8 @@ public: virtual void set_window_size(const Size2 p_size)=0; virtual void set_fullscreen(bool p_enabled,int p_screen=0)=0; virtual bool is_fullscreen() const=0; - +#endif + virtual void set_iterations_per_second(int p_ips); virtual int get_iterations_per_second() const; diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 621a0c66a0..954e5270e8 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -47,6 +47,7 @@ def get_opts(): return [ ('use_llvm','Use llvm compiler','no'), ('use_sanitizer','Use llvm compiler sanitize address','no'), + ('experimental_wm_api', 'Use experimental window management API','no'), ] def get_flags(): @@ -148,3 +149,6 @@ def configure(env): env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) #env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } ) + if(env["experimental_wm_api"]=="yes"): + env.Append(CPPFLAGS=['-DEXPERIMENTAL_WM_API']) + diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 063fb17c26..e20d0731e1 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -182,8 +182,38 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi // borderless fullscreen window mode if (current_videomode.fullscreen) { +#ifndef EXPERIMENTAL_WM_API + // needed for lxde/openbox, possibly others + Hints hints; + Atom property; + hints.flags = 2; + hints.decorations = 0; + property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True); + XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5); + XMapRaised(x11_display, x11_window); + XWindowAttributes xwa; + XGetWindowAttributes(x11_display, DefaultRootWindow(x11_display), &xwa); + XMoveResizeWindow(x11_display, x11_window, 0, 0, xwa.width, xwa.height); + + // code for netwm-compliants + XEvent xev; + Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False); + Atom fullscreen = XInternAtom(x11_display, "_NET_WM_STATE_FULLSCREEN", False); + + memset(&xev, 0, sizeof(xev)); + xev.type = ClientMessage; + xev.xclient.window = x11_window; + xev.xclient.message_type = wm_state; + xev.xclient.format = 32; + xev.xclient.data.l[0] = 1; + xev.xclient.data.l[1] = fullscreen; + xev.xclient.data.l[2] = 0; + + XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureNotifyMask, &xev); +#else set_wm_border(false); set_wm_fullscreen(true); +#endif } // disable resizeable window @@ -496,6 +526,7 @@ void OS_X11::get_fullscreen_mode_list(List *p_list,int p_screen) cons } +#ifdef EXPERIMENTAL_WM_API void OS_X11::set_wm_border(bool p_enabled) { // needed for lxde/openbox, possibly others Hints hints; @@ -639,6 +670,7 @@ void OS_X11::set_fullscreen(bool p_enabled,int p_screen) { bool OS_X11::is_fullscreen() const { return current_videomode.fullscreen; } +#endif InputModifierState OS_X11::get_key_modifier_state(unsigned int p_x11_state) { diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index a38d511003..4aca996fdc 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -73,7 +73,6 @@ class OS_X11 : public OS_Unix { Rasterizer *rasterizer; VisualServer *visual_server; VideoMode current_videomode; - VideoMode pre_videomode; List args; Window x11_window; MainLoop *main_loop; @@ -160,8 +159,11 @@ class OS_X11 : public OS_Unix { int joystick_count; Joystick joysticks[JOYSTICKS_MAX]; +#ifdef EXPERIMENTAL_WM_API + VideoMode pre_videomode; void set_wm_border(bool p_enabled); void set_wm_fullscreen(bool p_enabled); +#endif protected: @@ -217,6 +219,7 @@ public: virtual VideoMode get_video_mode(int p_screen=0) const; virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const; +#ifdef EXPERIMENTAL_WM_API virtual int get_screen_count() const; virtual Size2 get_screen_size(int p_screen=0) const; virtual Point2 get_window_position() const; @@ -225,7 +228,7 @@ public: virtual void set_window_size(const Size2 p_size); virtual void set_fullscreen(bool p_enabled,int p_screen=0); virtual bool is_fullscreen() const; - +#endif virtual void move_window_to_foreground(); void run(); From ce7c7a862ebe37fada7708c342c07d70fa80465a Mon Sep 17 00:00:00 2001 From: hurikhan Date: Tue, 13 Jan 2015 17:25:50 +0800 Subject: [PATCH 13/35] get_screen_position() added --- core/bind/core_bind.cpp | 5 +++++ core/bind/core_bind.h | 1 + core/os/os.h | 1 + demos/misc/window_management/control.gd | 11 ++++++++--- .../window_management/window_management.scn | Bin 3276 -> 3582 bytes platform/x11/os_x11.cpp | 12 ++++++++++++ platform/x11/os_x11.h | 1 + 7 files changed, 28 insertions(+), 3 deletions(-) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index b8fc63dc43..a2aca7e11f 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -181,6 +181,10 @@ int _OS::get_screen_count() const { return OS::get_singleton()->get_screen_count(); } +Point2 _OS::get_screen_position(int p_screen) const { + return OS::get_singleton()->get_screen_position(p_screen); +} + Size2 _OS::get_screen_size(int p_screen) const { return OS::get_singleton()->get_screen_size(p_screen); } @@ -668,6 +672,7 @@ void _OS::_bind_methods() { #ifdef EXPERIMENTAL_WM_API ObjectTypeDB::bind_method(_MD("get_screen_count"),&_OS::get_screen_count); + ObjectTypeDB::bind_method(_MD("get_screen_position"),&_OS::get_screen_position,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_screen_size"),&_OS::get_screen_size,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_window_position"),&_OS::get_window_position); ObjectTypeDB::bind_method(_MD("set_window_position"),&_OS::set_window_position); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 62f9913556..9d9f25691e 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -110,6 +110,7 @@ public: #ifdef EXPERIMENTAL_WM_API virtual int get_screen_count() const; + virtual Point2 get_screen_position(int p_screen=0) const; virtual Size2 get_screen_size(int p_screen=0) const; virtual Point2 get_window_position() const; virtual void set_window_position(const Point2& p_position); diff --git a/core/os/os.h b/core/os/os.h index c2534287bc..1ef05e45c8 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -152,6 +152,7 @@ public: #ifdef EXPERIMENTAL_WM_API virtual int get_screen_count() const=0; + virtual Point2 get_screen_position(int p_screen=0) const=0; virtual Size2 get_screen_size(int p_screen=0) const=0; virtual Point2 get_window_position() const=0; virtual void set_window_position(const Point2& p_position)=0; diff --git a/demos/misc/window_management/control.gd b/demos/misc/window_management/control.gd index 3e74f24e42..ad15a74731 100644 --- a/demos/misc/window_management/control.gd +++ b/demos/misc/window_management/control.gd @@ -15,11 +15,16 @@ func _fixed_process(delta): get_node("Label_Screen0_Resolution").set_text( str("Screen0 Resolution:\n", OS.get_screen_size() ) ) + get_node("Label_Screen0_Position").set_text(str("Screen0 Position:\n",OS.get_screen_position())) + if(OS.get_screen_count() > 1): get_node("Label_Screen1_Resolution").show() - get_node("Label_Screen1_Resolution").set_text( str("Screen0 Resolution:\n", OS.get_screen_size(1) ) ) - - + get_node("Label_Screen1_Resolution").set_text( str("Screen1 Resolution:\n", OS.get_screen_size(1) ) ) + get_node("Label_Screen1_Position").show() + get_node("Label_Screen1_Position").set_text( str("Screen1 Position:\n", OS.get_screen_size(1) ) ) + else: + get_node("Label_Screen1_Resolution").hide() + get_node("Label_Screen1_Position").hide() func _ready(): set_fixed_process(true) diff --git a/demos/misc/window_management/window_management.scn b/demos/misc/window_management/window_management.scn index 6eaf62ff9f6a9cf0cff2b4e2d38f0441855b7035..3a6426f3ee9d00f23132c6fc321fcda325f6bf24 100644 GIT binary patch delta 2277 zcmX>j`A=FZDA?JV0R#jX7*rJ*7=ExbF#KX+V0gnYQEUZc_Qw75nCe|P6)IRV@{9C~ z5;7b;76`B=<(HJ?=O$$^2QurIfkWXwLrGGZ zf-XaWiv>eT>Q9D5l|+WTL@5@Z#H7@m2h5AzBoagtN*2CMSmd-fRh3acSJh_nVirw1 z=PwBt8H@7O1yuees4x^K>MC$KtaRjIPb@9TFE2_gNT_5iEl{>lV{Croz^&5F5TA5J zwZds}V>)BJubRzdE>_!mr}+<9Wgal(yDfgeEX82>K-iqY@ByQ_Ly+UMM~v#A1t~=` z<;5o_axyS0NI5VckYdPFUHE`W%592+l;a-8vPAWhOnD{6>B0=A3g-3BjRzQ<7qKuf zG}tpdU}1P5%I|UBVVc941I>2+&dk7I;^ZLgki=Y;nOg3p+$iQC>zL{oE9{`?a7g7~+ja*T z<~Qr!I66qUBu!q(CU5>W(ez-AQ>>!`V`|sh6aZNs~#{;{>dgC>(+Q!wtbUx*P-1GvdYa2iCPA$UpwtQAnVb@ zoS2)G>2|SsS=N~ZapqYwCG9|3Rh1mFojX~JGxE#h({)uIuy{IuPLR~Nugdd)McTQA zq3R6-2lLr8XKWq3J=!K0vdh_}YzJMV0JkN$1sOk4h) zd&Xx$Is-!jzXHPnV}|_>Bphb}#V@M@D+9LzGbgBMC{8X)P0d@N#mM8_pf!0V zM|)s`4ukLmCY=WiOAcr;G&N{3HgqItJzxxHFnqur&M<9(4#S)T9SEN}+~I`7J+8d` zl+u*3{}(VQ@Fg%f@HrMbo^fDsyfZn5Q#rocL7IU>LB+w`G0uVCajgTp z6NiH~1CN5d13Lq+0=t7T1K$F62L1)?4%rUk&K?fz3_=Rx4#5wY860^Wm>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|er9@Jevy-} zlcv+61~GMNa<5Vq5R*{eW49!SDgIjME;+ z4UZTF8R8qSFr*|OI>7CI*g@?9%fZH{3p5iyDsVqw(`-2QfI-uP*+oj}FhjA!2L@(k zYY%k?aW_jPWv0CNDw>FiAQ3J4iXUF_tB&Z(zzRDNg&vps!%= z?0ta2IfsRTp~0TvK|Kq@15tjDZ4T2M&KziVbYqB5l2FrPD#$5SiDrmbm1QbPE!N0$ z&~PwunCM`@XylS0~M>zAhSa86=QLplCFcM1A~K<12aRF`qXp@=4Q3I_6`CL zS5$-_aO%4IG3KYWUShxU&+zb$8q32D1`f;#Q4TfEYz_hr+ziGs4IR#F9E6;gFr}oX zDIHM1z*Ll9qT%ik#8h)rA)(wsiJ{7Uu7e0O1H&(8kPi1l4(!Yf3?@zv!VXEyWtpkv zo~s(m9Aq6?Prh_Gq@vws=ODxUX5AY{2P@|@lTWkBTb3l6I!!6@{Q zIn?2~gS?g}Q$~Ke2m1pSIfs76g8Yuq2h0o)L=G@BFf=$gR6k&ytjI1M>oWVWY`cte z*P-1GvdYa2iJIG27dh=bAnX2yIWadW)6KehSypg@IP$Wa*Rc#s?toU zB_&$7pR&t3Ow}yYT*45qIln{M;V_GCj)F?Dx*#t7##Qg4P0=t7ggOvii0|SG#1B(I! zgN*{S0|SFCm~E%P?BK2vo+!=az`&5Wo567bJA;z~yMsG}vjV&0X$J;}dz~ck#41o&53;_zv4zHcuAIQIE2vRV1 za6Y));kVQ42h6`6nH_#R{eB?*+u`&>_VovsGXyK-J7qJ3D6l(jX9!)u&QKq=fSn;+ zf!#r#Awq%O;WI=?J)ZxJNF~@-H({r9rPbDv%9!IQfFs~U-0^o zJ^O**j@(Y{4&e`^e?RhPcdeIyq|eTjz`*dxgxyX05i`5%;)l}Qj@KU= XScreenCount(x11_display) ) + return Point2i(0,0); + + Window root = XRootWindow(x11_display, p_screen); + XWindowAttributes xwa; + XGetWindowAttributes(x11_display, root, &xwa); + return Point2i(xwa.x, xwa.y); +} + Size2 OS_X11::get_screen_size(int p_screen) const { + if( p_screen >= XScreenCount(x11_display) ) + return Size2i(0,0); Window root = XRootWindow(x11_display, p_screen); XWindowAttributes xwa; XGetWindowAttributes(x11_display, root, &xwa); diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 4aca996fdc..ca35bf2c0a 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -221,6 +221,7 @@ public: #ifdef EXPERIMENTAL_WM_API virtual int get_screen_count() const; + virtual Point2 get_screen_position(int p_screen=0) const; virtual Size2 get_screen_size(int p_screen=0) const; virtual Point2 get_window_position() const; virtual void set_window_position(const Point2& p_position); From f55c0e928580de63af55ac22f045bb4380a1df2e Mon Sep 17 00:00:00 2001 From: hurikhan Date: Tue, 13 Jan 2015 21:01:24 +0800 Subject: [PATCH 14/35] Using Xinerama extension for getting screen info --- demos/misc/window_management/control.gd | 2 +- platform/x11/detect.py | 6 ++++ platform/x11/os_x11.cpp | 42 ++++++++++++++++--------- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/demos/misc/window_management/control.gd b/demos/misc/window_management/control.gd index ad15a74731..34df5dd92c 100644 --- a/demos/misc/window_management/control.gd +++ b/demos/misc/window_management/control.gd @@ -21,7 +21,7 @@ func _fixed_process(delta): get_node("Label_Screen1_Resolution").show() get_node("Label_Screen1_Resolution").set_text( str("Screen1 Resolution:\n", OS.get_screen_size(1) ) ) get_node("Label_Screen1_Position").show() - get_node("Label_Screen1_Position").set_text( str("Screen1 Position:\n", OS.get_screen_size(1) ) ) + get_node("Label_Screen1_Position").set_text( str("Screen1 Position:\n", OS.get_screen_position(1) ) ) else: get_node("Label_Screen1_Resolution").hide() get_node("Label_Screen1_Position").hide() diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 954e5270e8..1eb615893b 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -38,6 +38,11 @@ def can_build(): if (x11_error): print("xcursor not found.. x11 disabled.") return False + + x11_error=os.system("pkg-config xinerama --modversion > /dev/null ") + if (x11_error): + print("xinerama not found.. x11 disabled.") + return False return True # X11 enabled @@ -151,4 +156,5 @@ def configure(env): if(env["experimental_wm_api"]=="yes"): env.Append(CPPFLAGS=['-DEXPERIMENTAL_WM_API']) + env.ParseConfig('pkg-config xinerama --cflags --libs') diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 01d62f333d..533e57d5c7 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -36,6 +36,9 @@ #include "servers/physics/physics_server_sw.h" #include "X11/Xutil.h" +#ifdef EXPERIMENTAL_WM_API +#include "X11/extensions/Xinerama.h" +#endif #include "main/main.h" @@ -558,26 +561,37 @@ void OS_X11::set_wm_fullscreen(bool p_enabled) { } int OS_X11::get_screen_count() const { - return XScreenCount(x11_display); + int event_base, error_base; + const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base); + if( !ext_okay ) return 0; + int count; + XineramaScreenInfo* xsi = XineramaQueryScreens(x11_display, &count); + XFree(xsi); + return count; } Point2 OS_X11::get_screen_position(int p_screen) const { - if( p_screen >= XScreenCount(x11_display) ) - return Point2i(0,0); - - Window root = XRootWindow(x11_display, p_screen); - XWindowAttributes xwa; - XGetWindowAttributes(x11_display, root, &xwa); - return Point2i(xwa.x, xwa.y); + int event_base, error_base; + const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base); + if( !ext_okay ) return Point2i(0,0); + int count; + XineramaScreenInfo* xsi = XineramaQueryScreens(x11_display, &count); + if( p_screen >= count ) return Point2i(0,0); + Point2i position = Point2i(xsi[p_screen].x_org, xsi[p_screen].y_org); + XFree(xsi); + return position; } Size2 OS_X11::get_screen_size(int p_screen) const { - if( p_screen >= XScreenCount(x11_display) ) - return Size2i(0,0); - Window root = XRootWindow(x11_display, p_screen); - XWindowAttributes xwa; - XGetWindowAttributes(x11_display, root, &xwa); - return Size2i(xwa.width, xwa.height); + int event_base, error_base; + const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base); + if( !ext_okay ) return Size2i(0,0); + int count; + XineramaScreenInfo* xsi = XineramaQueryScreens(x11_display, &count); + if( p_screen >= count ) return Size2i(0,0); + Size2i size = Point2i(xsi[p_screen].width, xsi[p_screen].height); + XFree(xsi); + return size; } From 790d8ecbb9a0a0ac67520b84fc621c34f910d817 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Wed, 14 Jan 2015 12:02:59 +0800 Subject: [PATCH 15/35] get_screen() + set_screen() added --- core/bind/core_bind.cpp | 16 +++- core/bind/core_bind.h | 4 +- core/os/os.h | 4 +- demos/misc/window_management/control.gd | 27 ++++++- demos/misc/window_management/engine.cfg | 4 + .../window_management/window_management.scn | Bin 3582 -> 3787 bytes platform/x11/os_x11.cpp | 71 ++++++++++++++---- platform/x11/os_x11.h | 7 +- 8 files changed, 109 insertions(+), 24 deletions(-) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index a2aca7e11f..48cd43ccdc 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -181,6 +181,14 @@ int _OS::get_screen_count() const { return OS::get_singleton()->get_screen_count(); } +int _OS::get_screen() const { + return OS::get_singleton()->get_screen(); +} + +void _OS::set_screen(int p_screen) { + OS::get_singleton()->set_screen(p_screen); +} + Point2 _OS::get_screen_position(int p_screen) const { return OS::get_singleton()->get_screen_position(p_screen); } @@ -205,8 +213,8 @@ void _OS::set_window_size(const Size2& p_size) { OS::get_singleton()->set_window_size(p_size); } -void _OS::set_fullscreen(bool p_enabled,int p_screen) { - OS::get_singleton()->set_fullscreen(p_enabled, p_screen); +void _OS::set_fullscreen(bool p_enabled) { + OS::get_singleton()->set_fullscreen(p_enabled); } bool _OS::is_fullscreen() const { @@ -672,13 +680,15 @@ void _OS::_bind_methods() { #ifdef EXPERIMENTAL_WM_API ObjectTypeDB::bind_method(_MD("get_screen_count"),&_OS::get_screen_count); + ObjectTypeDB::bind_method(_MD("get_screen"),&_OS::get_screen); + ObjectTypeDB::bind_method(_MD("set_screen"),&_OS::set_screen); ObjectTypeDB::bind_method(_MD("get_screen_position"),&_OS::get_screen_position,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_screen_size"),&_OS::get_screen_size,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_window_position"),&_OS::get_window_position); ObjectTypeDB::bind_method(_MD("set_window_position"),&_OS::set_window_position); ObjectTypeDB::bind_method(_MD("get_window_size"),&_OS::get_window_size); ObjectTypeDB::bind_method(_MD("set_window_size"),&_OS::set_window_size); - ObjectTypeDB::bind_method(_MD("set_fullscreen","enabled","screen"),&_OS::set_fullscreen,DEFVAL(0)); + ObjectTypeDB::bind_method(_MD("set_fullscreen","enabled"),&_OS::set_fullscreen); ObjectTypeDB::bind_method(_MD("is_fullscreen"),&_OS::is_fullscreen); #endif diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 9d9f25691e..99ecb765c7 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -110,13 +110,15 @@ public: #ifdef EXPERIMENTAL_WM_API virtual int get_screen_count() const; + virtual int get_screen() const; + virtual void set_screen(int p_screen); virtual Point2 get_screen_position(int p_screen=0) const; virtual Size2 get_screen_size(int p_screen=0) const; virtual Point2 get_window_position() const; virtual void set_window_position(const Point2& p_position); virtual Size2 get_window_size() const; virtual void set_window_size(const Size2& p_size); - void set_fullscreen(bool p_enabled, int p_screen=0); + void set_fullscreen(bool p_enabled); bool is_fullscreen() const; #endif diff --git a/core/os/os.h b/core/os/os.h index 1ef05e45c8..2d4e937974 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -152,13 +152,15 @@ public: #ifdef EXPERIMENTAL_WM_API virtual int get_screen_count() const=0; + virtual int get_screen() const=0; + virtual void set_screen(int p_screen)=0; virtual Point2 get_screen_position(int p_screen=0) const=0; virtual Size2 get_screen_size(int p_screen=0) const=0; virtual Point2 get_window_position() const=0; virtual void set_window_position(const Point2& p_position)=0; virtual Size2 get_window_size() const=0; virtual void set_window_size(const Size2 p_size)=0; - virtual void set_fullscreen(bool p_enabled,int p_screen=0)=0; + virtual void set_fullscreen(bool p_enabled)=0; virtual bool is_fullscreen() const=0; #endif diff --git a/demos/misc/window_management/control.gd b/demos/misc/window_management/control.gd index 34df5dd92c..ce17db6b00 100644 --- a/demos/misc/window_management/control.gd +++ b/demos/misc/window_management/control.gd @@ -13,18 +13,35 @@ func _fixed_process(delta): get_node("Label_Screen_Count").set_text( str("Screens:\n", OS.get_screen_count() ) ) + get_node("Label_Screen_Current").set_text( str("Current:\n", OS.get_screen() ) ) + get_node("Label_Screen0_Resolution").set_text( str("Screen0 Resolution:\n", OS.get_screen_size() ) ) get_node("Label_Screen0_Position").set_text(str("Screen0 Position:\n",OS.get_screen_position())) if(OS.get_screen_count() > 1): + get_node("Button_Screen1").show() get_node("Label_Screen1_Resolution").show() - get_node("Label_Screen1_Resolution").set_text( str("Screen1 Resolution:\n", OS.get_screen_size(1) ) ) get_node("Label_Screen1_Position").show() + get_node("Label_Screen1_Resolution").set_text( str("Screen1 Resolution:\n", OS.get_screen_size(1) ) ) get_node("Label_Screen1_Position").set_text( str("Screen1 Position:\n", OS.get_screen_position(1) ) ) else: + get_node("Button_Screen1").hide() get_node("Label_Screen1_Resolution").hide() get_node("Label_Screen1_Position").hide() + + if( Input.is_action_pressed("ui_right")): + OS.set_screen(1) + + if( Input.is_action_pressed("ui_left")): + OS.set_screen(0) + + if( Input.is_action_pressed("ui_up")): + OS.set_fullscreen(true) + + if( Input.is_action_pressed("ui_down")): + OS.set_fullscreen(false) + func _ready(): set_fixed_process(true) @@ -42,3 +59,11 @@ func _on_Button_MoveTo_pressed(): func _on_Button_Resize_pressed(): OS.set_window_size( Vector2(1024,768) ) + + +func _on_Button_Screen0_pressed(): + OS.set_screen(0) + + +func _on_Button_Screen1_pressed(): + OS.set_screen(1) diff --git a/demos/misc/window_management/engine.cfg b/demos/misc/window_management/engine.cfg index 7b6dddce96..44ad30ea14 100644 --- a/demos/misc/window_management/engine.cfg +++ b/demos/misc/window_management/engine.cfg @@ -3,3 +3,7 @@ name="window_management" main_scene="res://window_management.scn" icon="icon.png" + +[display] + +fullscreen=true diff --git a/demos/misc/window_management/window_management.scn b/demos/misc/window_management/window_management.scn index 3a6426f3ee9d00f23132c6fc321fcda325f6bf24..9d55174dcec9ff01ca27f20c4461a89722a12c69 100644 GIT binary patch delta 2133 zcmew-eOgv3DA?JV0R#jX82+m;Fg#{wU@&B5V3^K0QECNa!N$Yem^~A=HS{sY`>G~0 zgfyI3AjlY$>hLZhbAg~*kHQfKg9n^K42Fp*EIx@zsW}gr-?}9wh$QS=WSsEEnLRb1 zQ9oC;?Ew=nV`4>;@8tO`lJ)Z%_?c5H3gTVt66P@$<*P@jdL*bY6epG|a5;Q-3}a6$ zEy*u0N-RjIWGpREZc_7ZF>~Nnxylfq%%^(DF(ctHOMF0nai-#HhP;G{4MGgTO6o~v z3-}V{8RMN5s+;>Cu!=1Wa$EI)S%Sg9F_S4jr!*nj>D~iYnFkDI57^D?84Mo?n==?b zU^I6Ka#DT7*v1gw!JoY+>yPa3M#*`PIoS4ACtRUqe=D_SA#gL~a z_kc;th1WsK@jYW%qJ|q&UP*m%`UD0W1#{=_=gFgy_D_w;d?=E!xR z-Elrcd{U#@0j7eSQdK^Nc-75JC8@=lEDxA9JR23oG~XtOIe0s)aQJq-%pur;;edFT zWy5}latCpT?aDtie<+Ha5_XVquwgWENr-mfb6|FqXDZ07P&&$3oTv27p}xq0!9mJ_ znW0LfJA;q8S#7SpgMg!ns@eliT@M$={Is?c>{tF79^O%7dDy|gfjJ?{p~m^VgMb4! zgK1IZ^4j)H8TsiRe;=^OIrK9Y@^;~pVwnN{! z>(FioS>CV!;EZcK(BDfq{pCfg!oH zxP&J^H$Jf_y_f+c$fdx{p_`+iQk?9 zy44H{ z3u+je8cY})Iudl4gc%qX~=tXiPMupvPQ z!esMc1QaA3^c@%;uvKxa4>f)ci?wi@4)U9>7dQPqu}De&cLg{F5qCy zz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^}*>5pPep0VE*jz+u^g* z;|J289S%QapMP*VLy$tgQ!qoY0=wgKhL8p94516y8Nw9U9po9p71$kKGej(4cjR`C zcKGbHm?2U@++jOIlmfehIz#jVc7_-Qb|-%a1_yZu2FLFVu?idv{}t*P9JfCd7j|TJ z`0U8+tp1SsyYuyj(##H%AF?w)Vqg4_`MZPuL+0;}yC155XNqHBNOSST zp}@=#sld#@qQJ}$rNHbU4-0<=5d~%k1_o9I76)&(~TJ6;AM1!f0P2TO)@ z1#X5k1!jk(4h#;i4&n@%3Oo!M3d{$@88{WV4~R2lDR6UxvO1`Q2nr5z235rXYE?-~ diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 533e57d5c7..0ed8c80162 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -214,6 +214,10 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureNotifyMask, &xev); #else + old_window_position.x = 0; + old_window_position.y = 0; + old_window_size.width = 800; + old_window_size.height = 600; set_wm_border(false); set_wm_fullscreen(true); #endif @@ -539,7 +543,7 @@ void OS_X11::set_wm_border(bool p_enabled) { property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True); XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5); XMapRaised(x11_display, x11_window); - XMoveResizeWindow(x11_display, x11_window, 0, 0, current_videomode.width, current_videomode.height); + //XMoveResizeWindow(x11_display, x11_window, 0, 0, 800, 800); } void OS_X11::set_wm_fullscreen(bool p_enabled) { @@ -564,19 +568,55 @@ int OS_X11::get_screen_count() const { int event_base, error_base; const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base); if( !ext_okay ) return 0; + int count; XineramaScreenInfo* xsi = XineramaQueryScreens(x11_display, &count); XFree(xsi); return count; } +int OS_X11::get_screen() const { + int x,y; + Window child; + XTranslateCoordinates( x11_display, x11_window, DefaultRootWindow(x11_display), 0, 0, &x, &y, &child); + + int count = get_screen_count(); + for(int i=0; i= pos.x && x = pos.y && y < pos.y + size.height) ) + return i; + } + return 0; +} + +void OS_X11::set_screen(int p_screen) { + int count = get_screen_count(); + if(p_screen >= count) return; + + if( current_videomode.fullscreen ) { + Point2i position = get_screen_position(p_screen); + Size2i size = get_screen_size(p_screen); + + XMoveResizeWindow(x11_display, x11_window, position.x, position.y, size.x, size.y); + } + else { + if( p_screen != get_screen() ) { + Point2i position = get_screen_position(p_screen); + XMoveWindow(x11_display, x11_window, position.x, position.y); + } + } +} + Point2 OS_X11::get_screen_position(int p_screen) const { int event_base, error_base; const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base); if( !ext_okay ) return Point2i(0,0); + int count; XineramaScreenInfo* xsi = XineramaQueryScreens(x11_display, &count); if( p_screen >= count ) return Point2i(0,0); + Point2i position = Point2i(xsi[p_screen].x_org, xsi[p_screen].y_org); XFree(xsi); return position; @@ -586,9 +626,11 @@ Size2 OS_X11::get_screen_size(int p_screen) const { int event_base, error_base; const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base); if( !ext_okay ) return Size2i(0,0); + int count; XineramaScreenInfo* xsi = XineramaQueryScreens(x11_display, &count); if( p_screen >= count ) return Size2i(0,0); + Size2i size = Point2i(xsi[p_screen].width, xsi[p_screen].height); XFree(xsi); return size; @@ -597,11 +639,8 @@ Size2 OS_X11::get_screen_size(int p_screen) const { Point2 OS_X11::get_window_position() const { int x,y; - XWindowAttributes xwa; Window child; XTranslateCoordinates( x11_display, x11_window, DefaultRootWindow(x11_display), 0, 0, &x, &y, &child); - XGetWindowAttributes(x11_display, x11_window, &xwa); - return Point2i(x,y); } @@ -664,30 +703,30 @@ void OS_X11::set_window_size(const Size2 p_size) { XResizeWindow(x11_display, x11_window, p_size.x, p_size.y); } -void OS_X11::set_fullscreen(bool p_enabled,int p_screen) { +void OS_X11::set_fullscreen(bool p_enabled) { if(p_enabled && current_videomode.fullscreen) return; if(p_enabled) { - pre_videomode = current_videomode; + old_window_size = get_window_size(); + old_window_position = get_window_position(); - XWindowAttributes xwa; - XGetWindowAttributes(x11_display, DefaultRootWindow(x11_display), &xwa); - - current_videomode.fullscreen = True; - current_videomode.width = xwa.width; - current_videomode.height = xwa.height; + int screen = get_screen(); + Size2i size = get_screen_size(screen); + Point2i position = get_screen_position(screen); set_wm_border(false); set_wm_fullscreen(true); - } else { - current_videomode.fullscreen = False; - current_videomode.width = pre_videomode.width; - current_videomode.height = pre_videomode.height; + XMoveResizeWindow(x11_display, x11_window, position.x, position.y, size.x, size.y); + current_videomode.fullscreen = True; + } else { set_wm_fullscreen(false); set_wm_border(true); + XMoveResizeWindow(x11_display, x11_window, old_window_position.x, old_window_position.y, old_window_size.width, old_window_size.height); + + current_videomode.fullscreen = False; } visual_server->init(); diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index ca35bf2c0a..bb0fd38387 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -160,7 +160,8 @@ class OS_X11 : public OS_Unix { Joystick joysticks[JOYSTICKS_MAX]; #ifdef EXPERIMENTAL_WM_API - VideoMode pre_videomode; + Point2i old_window_position; + Size2i old_window_size; void set_wm_border(bool p_enabled); void set_wm_fullscreen(bool p_enabled); #endif @@ -221,13 +222,15 @@ public: #ifdef EXPERIMENTAL_WM_API virtual int get_screen_count() const; + virtual int get_screen() const; + virtual void set_screen(int p_screen); virtual Point2 get_screen_position(int p_screen=0) const; virtual Size2 get_screen_size(int p_screen=0) const; virtual Point2 get_window_position() const; virtual void set_window_position(const Point2& p_position); virtual Size2 get_window_size() const; virtual void set_window_size(const Size2 p_size); - virtual void set_fullscreen(bool p_enabled,int p_screen=0); + virtual void set_fullscreen(bool p_enabled); virtual bool is_fullscreen() const; #endif virtual void move_window_to_foreground(); From 7222e195e549cc9a08c06fb30fb4d3d9051c818e Mon Sep 17 00:00:00 2001 From: hurikhan Date: Wed, 14 Jan 2015 13:19:27 +0800 Subject: [PATCH 16/35] minor cleanup --- platform/x11/os_x11.cpp | 24 ++++++++++++++---------- platform/x11/os_x11.h | 6 ++++-- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 0ed8c80162..d395e99210 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -214,10 +214,10 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureNotifyMask, &xev); #else - old_window_position.x = 0; - old_window_position.y = 0; - old_window_size.width = 800; - old_window_size.height = 600; + window_data.position.x = 0; + window_data.position.y = 0; + window_data.size.width = 800; + window_data.size.height = 600; set_wm_border(false); set_wm_fullscreen(true); #endif @@ -709,8 +709,8 @@ void OS_X11::set_fullscreen(bool p_enabled) { return; if(p_enabled) { - old_window_size = get_window_size(); - old_window_position = get_window_position(); + window_data.size = get_window_size(); + window_data.position = get_window_position(); int screen = get_screen(); Size2i size = get_screen_size(screen); @@ -724,7 +724,11 @@ void OS_X11::set_fullscreen(bool p_enabled) { } else { set_wm_fullscreen(false); set_wm_border(true); - XMoveResizeWindow(x11_display, x11_window, old_window_position.x, old_window_position.y, old_window_size.width, old_window_size.height); + XMoveResizeWindow(x11_display, x11_window, + window_data.position.x, + window_data.position.y, + window_data.size.width, + window_data.size.height); current_videomode.fullscreen = False; } @@ -1072,7 +1076,7 @@ void OS_X11::process_xevents() { if (mouse_mode==MOUSE_MODE_CAPTURED) { #if 1 - Vector2 c = Point2i(current_videomode.width/2,current_videomode.height/2); + //Vector2 c = Point2i(current_videomode.width/2,current_videomode.height/2); if (pos==Point2i(current_videomode.width/2,current_videomode.height/2)) { //this sucks, it's a hack, etc and is a little inaccurate, etc. //but nothing I can do, X11 sucks. @@ -1081,9 +1085,9 @@ void OS_X11::process_xevents() { break; } - Point2i ncenter = pos; + Point2i new_center = pos; pos = last_mouse_pos + ( pos-center ); - center=ncenter; + center=new_center; do_mouse_warp=true; #else //Dear X11, thanks for making my life miserable diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index bb0fd38387..72d212c131 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -160,8 +160,10 @@ class OS_X11 : public OS_Unix { Joystick joysticks[JOYSTICKS_MAX]; #ifdef EXPERIMENTAL_WM_API - Point2i old_window_position; - Size2i old_window_size; + struct { + Point2i position; + Size2i size; + } window_data; void set_wm_border(bool p_enabled); void set_wm_fullscreen(bool p_enabled); #endif From 2203ba5fe3f7cdca078dd557ec532b7f335d3670 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Wed, 14 Jan 2015 13:27:03 +0800 Subject: [PATCH 17/35] don't start demo in fullscreen mode --- demos/misc/window_management/engine.cfg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/demos/misc/window_management/engine.cfg b/demos/misc/window_management/engine.cfg index 44ad30ea14..bdc8ec3ed7 100644 --- a/demos/misc/window_management/engine.cfg +++ b/demos/misc/window_management/engine.cfg @@ -6,4 +6,5 @@ icon="icon.png" [display] -fullscreen=true +fullscreen=false +resizable=false From 1576dc5215c107e6966ceace2f3979ff12f2dd62 Mon Sep 17 00:00:00 2001 From: MSC Date: Wed, 14 Jan 2015 13:49:10 +0800 Subject: [PATCH 18/35] Update README.md --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 57068bf39c..35841c8b29 100644 --- a/README.md +++ b/README.md @@ -2,19 +2,22 @@ #### New GDScript Methods for the OS Class: * int OS.get_screen_count() +* int OS.get_screen() +* void OS.set_screen(int screen) +* Vector2 OS.get_screen_position(int screen=0) * Vector2 OS.get_screen_size(int screen=0) * Vector2 OS.get_window_position() * void OS.set_window_position(Vector2 position) * Vector2 OS.get_window_size() * void OS.set_window_size(Vector2 size) -* void OS.set_fullscreen(bool enabled, int screen=0) +* void OS.set_fullscreen(bool enabled) * bool OS.is_fullscreen() #### Demo A demo/test is available at "demos/misc/window-management" -#### Warning -Just only works for X11. It breaks other platforms at the moment. +#### Scons Commandline +'''scons p=x11 experimental_wm_api=yes''' ![GODOT](/logo.png) From 07b8d9136a6ccea1587d27ca30db1ec10aca0ed1 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Wed, 14 Jan 2015 15:44:47 +0800 Subject: [PATCH 19/35] demo window set to resizeable (need a bugfix her) --- demos/misc/window_management/engine.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/misc/window_management/engine.cfg b/demos/misc/window_management/engine.cfg index bdc8ec3ed7..2accafe43e 100644 --- a/demos/misc/window_management/engine.cfg +++ b/demos/misc/window_management/engine.cfg @@ -7,4 +7,4 @@ icon="icon.png" [display] fullscreen=false -resizable=false +resizable=true From d269344bbd19d9653fff3c2a230261b8fa00d7f6 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Thu, 15 Jan 2015 22:50:23 +0900 Subject: [PATCH 20/35] WIP -- set_resizable() + is_resizable added --- core/bind/core_bind.cpp | 11 +++- core/bind/core_bind.h | 2 + core/os/os.h | 2 + demos/misc/window_management/control.gd | 28 ++++++++- .../window_management/window_management.scn | Bin 3787 -> 3897 bytes platform/x11/os_x11.cpp | 57 +++++++++++++----- platform/x11/os_x11.h | 9 ++- 7 files changed, 91 insertions(+), 18 deletions(-) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 48cd43ccdc..1fb6f96e71 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -220,6 +220,14 @@ void _OS::set_fullscreen(bool p_enabled) { bool _OS::is_fullscreen() const { return OS::get_singleton()->is_fullscreen(); } + +void _OS::set_resizable(bool p_enabled) { + OS::get_singleton()->set_resizable(p_enabled); +} + +bool _OS::is_resizable() const { + return OS::get_singleton()->is_resizable(); +} #endif void _OS::set_use_file_access_save_and_swap(bool p_enable) { @@ -232,7 +240,6 @@ bool _OS::is_video_mode_resizable(int p_screen) const { OS::VideoMode vm; vm = OS::get_singleton()->get_video_mode(p_screen); return vm.resizable; - } Array _OS::get_fullscreen_mode_list(int p_screen) const { @@ -690,6 +697,8 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_window_size"),&_OS::set_window_size); ObjectTypeDB::bind_method(_MD("set_fullscreen","enabled"),&_OS::set_fullscreen); ObjectTypeDB::bind_method(_MD("is_fullscreen"),&_OS::is_fullscreen); + ObjectTypeDB::bind_method(_MD("set_resizable","enabled"),&_OS::set_resizable); + ObjectTypeDB::bind_method(_MD("is_resizable"),&_OS::is_resizable); #endif ObjectTypeDB::bind_method(_MD("set_iterations_per_second","iterations_per_second"),&_OS::set_iterations_per_second); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 99ecb765c7..7ffd7e9e7c 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -120,6 +120,8 @@ public: virtual void set_window_size(const Size2& p_size); void set_fullscreen(bool p_enabled); bool is_fullscreen() const; + void set_resizable(bool p_enabled); + bool is_resizable() const; #endif Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track); diff --git a/core/os/os.h b/core/os/os.h index 2d4e937974..f1a9de1edf 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -162,6 +162,8 @@ public: virtual void set_window_size(const Size2 p_size)=0; virtual void set_fullscreen(bool p_enabled)=0; virtual bool is_fullscreen() const=0; + virtual void set_resizable(bool p_enabled)=0; + virtual bool is_resizable() const=0; #endif virtual void set_iterations_per_second(int p_ips); diff --git a/demos/misc/window_management/control.gd b/demos/misc/window_management/control.gd index ce17db6b00..c867bd21db 100644 --- a/demos/misc/window_management/control.gd +++ b/demos/misc/window_management/control.gd @@ -2,10 +2,18 @@ extends Control func _fixed_process(delta): + + var modetext = "Mode:\n" + if(OS.is_fullscreen()): - get_node("Label_Fullscreen").set_text("Mode:\nFullscreen") + modetext += "Fullscreen\n" else: - get_node("Label_Fullscreen").set_text("Mode:\nWindowed") + modetext += "Windowed\n" + + if(!OS.is_resizable()): + modetext += "FixedSize\n" + + get_node("Label_Mode").set_text(modetext) get_node("Label_Position").set_text( str("Position:\n", OS.get_window_position() ) ) @@ -19,6 +27,7 @@ func _fixed_process(delta): get_node("Label_Screen0_Position").set_text(str("Screen0 Position:\n",OS.get_screen_position())) + if(OS.get_screen_count() > 1): get_node("Button_Screen1").show() get_node("Label_Screen1_Resolution").show() @@ -42,6 +51,9 @@ func _fixed_process(delta): if( Input.is_action_pressed("ui_down")): OS.set_fullscreen(false) + get_node("Button_FixedSize").set_pressed( !OS.is_resizable() ) + + func _ready(): set_fixed_process(true) @@ -67,3 +79,15 @@ func _on_Button_Screen0_pressed(): func _on_Button_Screen1_pressed(): OS.set_screen(1) + + + + + +func _on_Button_FixedSize_pressed(): + if(OS.is_resizable()): + OS.set_resizable(false) + else: + OS.set_resizable(true) + + diff --git a/demos/misc/window_management/window_management.scn b/demos/misc/window_management/window_management.scn index 9d55174dcec9ff01ca27f20c4461a89722a12c69..befc177b5e09d4c07cc3657e1cc5da662998c3d3 100644 GIT binary patch delta 2588 zcmX>tyHidwDA?JV0R#jX7*f?37;dvOFqE+}Fr1huxstJHjO+NL2Nu0g7q$sr{IU`>2E@NhXqDkwmqYqsJ z7@bNL?OF5U-AZ$E6l9oEQ}dE9HHaq3PBvxHuiwW|l2oRk%TVBA!BCR=lOa(hks&W( zYC|q#ysv69LrBB&1%ix0sSaloWfurCxn)+UODc*a)GZKETd1&u!QcU>5QAY7JBv?Z zQfiJutnx0m!UVpAvx}UP44lPM>lpQORi{2+;$=*%NN{P8W-cyCEqK7h$6Sz@o|@p< zAj@1|mY7r8Fr$H=Iklo7-o-az24hjadZuc4f(k=%VyXg{Ba_Qs_QcYX{PLp2f`m%O z(gNj)YEdn&4%{kF7~+#4MIcht!J7hQ>V2Dpzr1pWS zAg5H-jv-$4F;huuv8KrbW)07cieg%_31SZ34)zY;jxTcvc3?Ol-j&&~-=W+=++n+l zhL(n+$SG$B2?rZSBbS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0@BM6s=)4G&0xBKoxxRs-J#x`!CZlzL0^HH!A*gg!9anT!9szV z!BByj!4hl;_7sxNV7Gvs!Crx#K~#a6!BK(PA)g^kft`U(ftev(f!To{GbkM%gMtzi z{|rV7%nW`C%nTd~%=HYh3e2!DeJC!>kfxvx@&-5%9qk`73p=_$EEaa$4ho#~hjzjY zW(w{PnT4IK9~KKctpm6t(If!RUSxs)MGf!moOQ-Rs}r2~V5rh_;`jsg!uwgU43ap#!_#2IoQ pFo`=KJRr`H_kc;9fm4C|fH*_G0yj4ksHMihzz`H1min_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(); From d42fa511a51db582849470316dfd1f0eee459350 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Fri, 16 Jan 2015 13:49:46 +0900 Subject: [PATCH 21/35] rearrange the demo --- demos/misc/window_management/control.gd | 4 +--- .../window_management/window_management.scn | Bin 3897 -> 3931 bytes 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/demos/misc/window_management/control.gd b/demos/misc/window_management/control.gd index c867bd21db..043db8d489 100644 --- a/demos/misc/window_management/control.gd +++ b/demos/misc/window_management/control.gd @@ -19,9 +19,7 @@ func _fixed_process(delta): get_node("Label_Size").set_text(str("Size:\n", OS.get_window_size() ) ) - get_node("Label_Screen_Count").set_text( str("Screens:\n", OS.get_screen_count() ) ) - - get_node("Label_Screen_Current").set_text( str("Current:\n", OS.get_screen() ) ) + get_node("Label_Screen_Info").set_text( str("Screens:\n", OS.get_screen_count(),"\n\nCurrent:\n", OS.get_screen() ) ) get_node("Label_Screen0_Resolution").set_text( str("Screen0 Resolution:\n", OS.get_screen_size() ) ) diff --git a/demos/misc/window_management/window_management.scn b/demos/misc/window_management/window_management.scn index befc177b5e09d4c07cc3657e1cc5da662998c3d3..a83897f9a08af20a0ee92b9f52f8c358fa1b1ab7 100644 GIT binary patch delta 1939 zcmdlfcUw*}DA?JV0R#jX7(!JU7@o5;Fsx!_U|6+LvV%n{@yjAHMb`(MiVTJciYz{f zNvSysIm##98WQ*t?kuoMvUgTZ?Pb)@Rb4XqD2rnK@&3zQeAWwwMkaI1V~h)>p0ec;%ZaF``NAip?M z@dZO(!o&ulL`}zM3-}T>SmHhN((;qEA25qD7&zuK<>!=sfq8w_RuQ>=fa5ES;bhtcm5ONM>N=Z#qo}lrXsVKihGsz){sph6a zLb-zyLzTx42N7llhF{Jg4IXzL*qIp^Oq?8q9g@VE%Q92Ty^c1DImkMuI>tIEIvi3> zZjYS&hfPbPKhgAHjpr0c1;*68myEg(nL{0(JIHINFlFSYdn!F(k#p#0EXeOHnC!={ zt#bUZY)6Q5*P-1GvdYa2iCUM|^g8W4AnVD@oS2)G>CWA}EIV)VTz1LWV-Hw7oj)f? zY9^@iJYbP_Zegf;!?23^?3pvR4&Gi94$NdOE=o^IFmhmUkZ}%DkZG9gV#QFA?8ao} zR+!MvCBeYJ5FekKl39{3S`=SYnipT3T2hjkmtGtn&mc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O2h19t8x_U0 zWD~?3ydCTvz8zoY5bVHkK)frnVZTGUgSf+X6%8#7MUhj^4iXMFj7BaA(GGkL%#KzJ z^##grnRDWc^OVIMiX0dmq#T$Tsx)?I*fHC3rQ16QIGU)MKH${#C}GS`Yx}{@AoS|6 zZ_l>F4h9a)2~iF;&L12E9Jm>b8#-LxI|w=FGo_@aDX-G_##EGFqM7Ru#8h)rA)(ws ziJ{8lu!9IQ1H&(8kOq$z4(!Yf3?@zvQo;^N%w?IWID88sPFTOanq$D#hy*NIeL5g9r7>Bdf1BNt~f}GOyOodFA zbIpoyWr zq0yJIp(8o7!_!h7;@GoF@$aWBSy5qpkAfzDf5d46d!I8&-*+yeFo%nS^Z z`MJ+Cx=g;$eW?C{-eXth2h5LMxgU5xe#E}oHT!}3V}@Xm@OhB%^#{?9-OL{-KV}G3 zxX%!x!0b}&9RE~2oFPm>+hzSRY1eeO#ZQ^jUGrVj-8Mgv{_NEKj9vH`H&ZwRL)vwQ z2nBXGX@<5M2w?8Zv_RxQ*FU*kq&`#J% z{~@!m$L@#4!k)$;v6P2)!bgPz|6p=z|0V% zz|6p|z--G9tHA8Q&fulM&S0d#%;2ZM%)p_*%n+x*%)p|+%n+}@>>v+!6N88XGsIO4 zp$aSvsgv3HWOb_>ppJBYeEGGr@oGh`_+ zyZm)vaL{xRXUJ9HVaQQnJ|OOT@PIf&-UB9a*Ov#x8S)=6i8F92a32t7C{W-&;LgAW XW)~`Ob2EYJSOx}$px_{9P@M|^>lrYq From f1b9953d0b321a5564109e11b5326efa4624c70c Mon Sep 17 00:00:00 2001 From: hurikhan Date: Fri, 16 Jan 2015 14:44:41 +0900 Subject: [PATCH 22/35] fixing the warnings in os_x11.cpp --- platform/x11/os_x11.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index f33c2556ba..c6fdc24768 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -59,7 +59,7 @@ #include -#include "os/pc_joystick_map.h" +//#include "os/pc_joystick_map.h" #undef CursorShape @@ -120,10 +120,10 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi if (xim == NULL) { WARN_PRINT("XOpenIM failed"); - xim_style=NULL; + xim_style=0L; } else { ::XIMStyles *xim_styles=NULL; - xim_style=0; + xim_style=0L; char *imvalret=NULL; imvalret = XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL); if (imvalret != NULL || xim_styles == NULL) { @@ -131,7 +131,7 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi } if (xim_styles) { - xim_style = 0; + xim_style = 0L; for (int i=0;icount_styles;i++) { if (xim_styles->supported_styles[i] == @@ -241,7 +241,6 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi XSetWMNormalHints(x11_display, x11_window, xsh); XFree(xsh); } - current_videomode.resizable; AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton(); @@ -287,8 +286,9 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi /* set the name and class hints for the window manager to use */ classHint = XAllocClassHint(); if (classHint) { - classHint->res_name = "Godot"; - classHint->res_class = "Godot"; + char wmclass[] = "Godot"; + classHint->res_name = wmclass; + classHint->res_class = wmclass; } XSetClassHint(x11_display, x11_window, classHint); XFree(classHint); @@ -845,11 +845,9 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) { KeySym keysym_keycode=0; // keysym used to find a keycode KeySym keysym_unicode=0; // keysym used to find unicode - int nbytes=0; // bytes the string takes - // XLookupString returns keysyms usable as nice scancodes/ char str[256+1]; - nbytes=XLookupString(xkeyevent, str, 256, &keysym_keycode, NULL); + XLookupString(xkeyevent, str, 256, &keysym_keycode, NULL); // Meanwhile, XLookupString returns keysyms useful for unicode. @@ -946,7 +944,7 @@ void OS_X11::handle_key_event(XKeyEvent *p_event, bool p_echo) { ::Time tresh=ABS(peek_event.xkey.time-xkeyevent->time); if (peek_event.type == KeyPress && tresh<5 ) { KeySym rk; - nbytes=XLookupString((XKeyEvent*)&peek_event, str, 256, &rk, NULL); + XLookupString((XKeyEvent*)&peek_event, str, 256, &rk, NULL); if (rk==keysym_keycode) { XEvent event; XNextEvent(x11_display, &event); //erase next event @@ -1605,6 +1603,7 @@ void OS_X11::process_joysticks() { #endif }; + void OS_X11::set_cursor_shape(CursorShape p_shape) { ERR_FAIL_INDEX(p_shape,CURSOR_MAX); @@ -1717,6 +1716,7 @@ OS_X11::OS_X11() { #endif minimized = false; - xim_style=NULL; + xim_style=0L; mouse_mode=MOUSE_MODE_VISIBLE; }; + From 716971655eb9ab7909447e2f5d4911b6f45164bb Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sat, 17 Jan 2015 00:18:45 +0900 Subject: [PATCH 23/35] added the following methods: * set_minimized(bool) * bool is_minimized() * set_maximized(bool) * bool is_maximized() --- core/bind/core_bind.cpp | 22 ++- core/bind/core_bind.h | 12 +- core/os/os.h | 4 + demos/misc/window_management/control.gd | 33 ++++- .../window_management/window_management.scn | Bin 3931 -> 4111 bytes platform/x11/os_x11.cpp | 137 +++++++++++++++++- platform/x11/os_x11.h | 4 + 7 files changed, 194 insertions(+), 18 deletions(-) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 1fb6f96e71..6919c70a5f 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -228,6 +228,22 @@ void _OS::set_resizable(bool p_enabled) { bool _OS::is_resizable() const { return OS::get_singleton()->is_resizable(); } + +void _OS::set_minimized(bool p_enabled) { + OS::get_singleton()->set_minimized(p_enabled); +} + +bool _OS::is_minimized() const { + return OS::get_singleton()->is_minimized(); +} + +void _OS::set_maximized(bool p_enabled) { + OS::get_singleton()->set_maximized(p_enabled); +} + +bool _OS::is_maximized() const { + return OS::get_singleton()->is_maximized(); +} #endif void _OS::set_use_file_access_save_and_swap(bool p_enable) { @@ -698,7 +714,11 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_fullscreen","enabled"),&_OS::set_fullscreen); ObjectTypeDB::bind_method(_MD("is_fullscreen"),&_OS::is_fullscreen); ObjectTypeDB::bind_method(_MD("set_resizable","enabled"),&_OS::set_resizable); - ObjectTypeDB::bind_method(_MD("is_resizable"),&_OS::is_resizable); + ObjectTypeDB::bind_method(_MD("is_resizable"),&_OS::is_resizable); + ObjectTypeDB::bind_method(_MD("set_minimized", "enabled"),&_OS::set_minimized); + ObjectTypeDB::bind_method(_MD("is_minimized"),&_OS::is_minimized); + ObjectTypeDB::bind_method(_MD("set_maximized", "enabled"),&_OS::set_maximized); + ObjectTypeDB::bind_method(_MD("is_maximized"),&_OS::is_maximized); #endif ObjectTypeDB::bind_method(_MD("set_iterations_per_second","iterations_per_second"),&_OS::set_iterations_per_second); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 7ffd7e9e7c..b6f4f8eef4 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -118,10 +118,14 @@ public: virtual void set_window_position(const Point2& p_position); virtual Size2 get_window_size() const; virtual void set_window_size(const Size2& p_size); - void set_fullscreen(bool p_enabled); - bool is_fullscreen() const; - void set_resizable(bool p_enabled); - bool is_resizable() const; + virtual void set_fullscreen(bool p_enabled); + virtual bool is_fullscreen() const; + virtual void set_resizable(bool p_enabled); + virtual bool is_resizable() const; + virtual void set_minimized(bool p_enabled); + virtual bool is_minimized() const; + virtual void set_maximized(bool p_enabled); + virtual bool is_maximized() const; #endif Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track); diff --git a/core/os/os.h b/core/os/os.h index f1a9de1edf..c04a91e302 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -164,6 +164,10 @@ public: virtual bool is_fullscreen() const=0; virtual void set_resizable(bool p_enabled)=0; virtual bool is_resizable() const=0; + virtual void set_minimized(bool p_enabled)=0; + virtual bool is_minimized() const=0; + virtual void set_maximized(bool p_enabled)=0; + virtual bool is_maximized() const=0; #endif virtual void set_iterations_per_second(int p_ips); diff --git a/demos/misc/window_management/control.gd b/demos/misc/window_management/control.gd index 043db8d489..fd746cf036 100644 --- a/demos/misc/window_management/control.gd +++ b/demos/misc/window_management/control.gd @@ -13,17 +13,25 @@ func _fixed_process(delta): if(!OS.is_resizable()): modetext += "FixedSize\n" + if(OS.is_minimized()): + modetext += "Minimized\n" + + if(OS.is_maximized()): + modetext += "Maximized\n" + get_node("Label_Mode").set_text(modetext) get_node("Label_Position").set_text( str("Position:\n", OS.get_window_position() ) ) get_node("Label_Size").set_text(str("Size:\n", OS.get_window_size() ) ) - get_node("Label_Screen_Info").set_text( str("Screens:\n", OS.get_screen_count(),"\n\nCurrent:\n", OS.get_screen() ) ) + get_node("Label_Screen_Count").set_text( str("Screens:\n", OS.get_screen_count() ) ) + + get_node("Label_Screen_Current").set_text( str("Current:\n", OS.get_screen() ) ) get_node("Label_Screen0_Resolution").set_text( str("Screen0 Resolution:\n", OS.get_screen_size() ) ) - get_node("Label_Screen0_Position").set_text(str("Screen0 Position:\n",OS.get_screen_position())) + get_node("Label_Screen0_Position").set_text(str("Screen0 Position:\n",OS.get_screen_position() ) ) if(OS.get_screen_count() > 1): @@ -50,8 +58,9 @@ func _fixed_process(delta): OS.set_fullscreen(false) get_node("Button_FixedSize").set_pressed( !OS.is_resizable() ) - - + get_node("Button_Minimized").set_pressed( OS.is_minimized() ) + get_node("Button_Maximized").set_pressed( OS.is_maximized() ) + func _ready(): set_fixed_process(true) @@ -79,9 +88,6 @@ func _on_Button_Screen1_pressed(): OS.set_screen(1) - - - func _on_Button_FixedSize_pressed(): if(OS.is_resizable()): OS.set_resizable(false) @@ -89,3 +95,16 @@ func _on_Button_FixedSize_pressed(): OS.set_resizable(true) + +func _on_Button_Minimized_pressed(): + if(OS.is_minimized()): + OS.set_minimized(false) + else: + OS.set_minimized(true) + + +func _on_Button_Maximized_pressed(): + if(OS.is_maximized()): + OS.set_maximized(false) + else: + OS.set_maximized(true) diff --git a/demos/misc/window_management/window_management.scn b/demos/misc/window_management/window_management.scn index a83897f9a08af20a0ee92b9f52f8c358fa1b1ab7..635f6f6f28ba59ae2a8af372b4d8e9d43f5e397d 100644 GIT binary patch delta 2301 zcmcaD*RLQI6zuHG00IIG3`&{|4Exy`7+BdD7_^xtO08fl-+1^6v*!b55f zuu95w_D|i;sGqBPZt`gsh5E*T27cz$ih_8TwuBjsMfvKBR3{{;Fcc@wQ{Zy6cKODh zSXz=_UX)mnP{~+YpnOVga!Z{9x2h~dd~%o?mm_<^VV3xS{NhX{A%?t!i48)D!A^4* z@Fi+6#ycxiH(!6iDzpioWbw` zqq#$nQ|=?iwG8o16B$xck`8ctBs-`r{L&QOv}l25(mDn12W*;6`41R08Dy1@KVWiy z#8CZ!U*Qo$`vU=mLz5pcD0t*NU`lE%V=#CiD#u{>fI-gF#Wh-mfuY#(90Rk$2G0x! zarY|aMy9;@P~#3wyb&t@vfDOKIc5U&=;RFYb(x&8sO zhL?__nAVI0F$Zr4dxz5}6di&c7!HVcJ!#nQQ0^e^uw7-b)?!7GQ~Mkw9Bk?tja(9< z9rzrW9jzD&R5F-z;*0Z?BOQty7#yS=m>H@x%`$c}FerR?5O6e6-SB`@*W*27ep-7m z`-C3#!?(3e4?7q*FegMg)VLTq2sm&v7&mmdW;qBsZ)8eIO;diOS;$nBU!wWKA&9Bw zrb0rwgAzlPr=5ccGXujfX9ocX18&b`2XjnITa-Vy&>#&I7WZoy>{3Nty2H z&C9aCB#1N5nki{_fSG||iI#IGM{!1ed3<_NW(q3<69WSSqXIJns{%6vj{-9nSSr6L zGd(l!0gE&Pn}Rf3RbFah5d(_?C-d1eXKWn|8F&@Axl>Zp5=(PR65@-C(vuR592gvA z82A-96lAz^GSf3k;*0W2;wuuYnXTLk?H%M8BoyQ%;^R|OGE4G{;)_c2;)_#DN;31( zi{s-Nq!gqXm=u^D)E%aBC6^YLy?^)e4D^gQ}A23QX z{CdD32`v#M4$NWTX$WFuP)!JOux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sh->max_height = xwa.height; - printf("%d %d\n", xwa.width, xwa.height); } XSetWMNormalHints(x11_display, x11_window, xsh); XFree(xsh); @@ -770,6 +783,119 @@ void OS_X11::set_resizable(bool p_enabled) { bool OS_X11::is_resizable() const { return current_videomode.resizable; } + +void OS_X11::set_minimized(bool p_enabled) { + // Using ICCCM -- Inter-Client Communication Conventions Manual + XEvent xev; + Atom wm_change = XInternAtom(x11_display, "WM_CHANGE_STATE", False); + + memset(&xev, 0, sizeof(xev)); + xev.type = ClientMessage; + xev.xclient.window = x11_window; + xev.xclient.message_type = wm_change; + xev.xclient.format = 32; + xev.xclient.data.l[0] = p_enabled ? WM_IconicState : WM_NormalState; + + XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureNotifyMask, &xev); +} + +bool OS_X11::is_minimized() const { + // Using ICCCM -- Inter-Client Communication Conventions Manual + Atom property = XInternAtom(x11_display,"WM_STATE", True); + Atom type; + int format; + unsigned long len; + unsigned long remaining; + unsigned char *data = NULL; + + int result = XGetWindowProperty( + x11_display, + x11_window, + property, + 0, + 32, + False, + AnyPropertyType, + &type, + &format, + &len, + &remaining, + &data + ); + + if( result == Success ) { + long *state = (long *) data; + if( state[0] == 3L ) + return true; + } + return false; +} + +void OS_X11::set_maximized(bool p_enabled) { + // Using EWMH -- Extended Window Manager Hints + XEvent xev; + Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False); + Atom wm_max_horz = XInternAtom(x11_display, "_NET_WM_STATE_MAXIMIZED_HORZ", False); + Atom wm_max_vert = XInternAtom(x11_display, "_NET_WM_STATE_MAXIMIZED_VERT", False); + + memset(&xev, 0, sizeof(xev)); + xev.type = ClientMessage; + xev.xclient.window = x11_window; + xev.xclient.message_type = wm_state; + xev.xclient.format = 32; + xev.xclient.data.l[0] = p_enabled ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; + xev.xclient.data.l[1] = wm_max_horz; + xev.xclient.data.l[2] = wm_max_vert; + + XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureNotifyMask, &xev); + + maximized = p_enabled; +} + +bool OS_X11::is_maximized() const { + // Using EWMH -- Extended Window Manager Hints + Atom property = XInternAtom(x11_display,"_NET_WM_STATE",False ); + Atom type; + int format; + unsigned long len; + unsigned long remaining; + unsigned char *data = NULL; + + int result = XGetWindowProperty( + x11_display, + x11_window, + property, + 0, + 1024, + False, + XA_ATOM, + &type, + &format, + &len, + &remaining, + &data + ); + + if(result == Success) { + Atom *atoms = (Atom*) data; + Atom wm_max_horz = XInternAtom(x11_display, "_NET_WM_STATE_MAXIMIZED_HORZ", False); + Atom wm_max_vert = XInternAtom(x11_display, "_NET_WM_STATE_MAXIMIZED_VERT", False); + bool found_wm_max_horz = false; + bool found_wm_max_vert = false; + + for( unsigned int i=0; i < len; i++ ) { + if( atoms[i] == wm_max_horz ) + found_wm_max_horz = true; + if( atoms[i] == wm_max_vert ) + found_wm_max_vert = true; + + if( found_wm_max_horz && found_wm_max_vert ) + return true; + } + } + + return false; +} #endif InputModifierState OS_X11::get_key_modifier_state(unsigned int p_x11_state) { @@ -1719,4 +1845,3 @@ OS_X11::OS_X11() { xim_style=0L; mouse_mode=MOUSE_MODE_VISIBLE; }; - diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index d286efe7b8..557052ab69 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -241,6 +241,10 @@ public: virtual bool is_fullscreen() const; virtual void set_resizable(bool p_enabled); virtual bool is_resizable() const; + virtual void set_minimized(bool p_enabled); + virtual bool is_minimized() const; + virtual void set_maximized(bool p_enabled); + virtual bool is_maximized() const; #endif virtual void move_window_to_foreground(); From 6185949f6a4f6eae78d8afca2dd787dbf063d675 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sat, 17 Jan 2015 02:36:07 +0900 Subject: [PATCH 24/35] Make it set_minimized() + set_maximized() work in both worlds: Unity and LXDE --- platform/x11/os_x11.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index ef92d190c9..fd2470a37a 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -552,7 +552,7 @@ void OS_X11::set_wm_border(bool p_enabled) { Hints hints; Atom property; hints.flags = 2; - hints.decorations = p_enabled ? 1L : 0L;; + hints.decorations = p_enabled ? 1L : 0L; property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True); XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5); XMapRaised(x11_display, x11_window); @@ -700,7 +700,6 @@ void OS_X11::set_window_position(const Point2& p_position) { top = extends[2]; XFree(data); - data = NULL; } XMoveWindow(x11_display,x11_window,p_position.x - left,p_position.y - top); @@ -785,6 +784,10 @@ bool OS_X11::is_resizable() const { } void OS_X11::set_minimized(bool p_enabled) { + + if( is_fullscreen() ) + set_fullscreen(false); + // Using ICCCM -- Inter-Client Communication Conventions Manual XEvent xev; Atom wm_change = XInternAtom(x11_display, "WM_CHANGE_STATE", False); @@ -797,6 +800,20 @@ void OS_X11::set_minimized(bool p_enabled) { xev.xclient.data.l[0] = p_enabled ? WM_IconicState : WM_NormalState; XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureNotifyMask, &xev); + + //XEvent xev; + Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False); + Atom wm_hidden = XInternAtom(x11_display, "_NET_WM_STATE_HIDDEN", False); + + memset(&xev, 0, sizeof(xev)); + xev.type = ClientMessage; + xev.xclient.window = x11_window; + xev.xclient.message_type = wm_state; + xev.xclient.format = 32; + xev.xclient.data.l[0] = _NET_WM_STATE_ADD; + xev.xclient.data.l[1] = wm_hidden; + + XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); } bool OS_X11::is_minimized() const { @@ -825,7 +842,7 @@ bool OS_X11::is_minimized() const { if( result == Success ) { long *state = (long *) data; - if( state[0] == 3L ) + if( state[0] == WM_IconicState ) return true; } return false; @@ -847,7 +864,7 @@ void OS_X11::set_maximized(bool p_enabled) { xev.xclient.data.l[1] = wm_max_horz; xev.xclient.data.l[2] = wm_max_vert; - XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureNotifyMask, &xev); + XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); maximized = p_enabled; } @@ -892,6 +909,7 @@ bool OS_X11::is_maximized() const { if( found_wm_max_horz && found_wm_max_vert ) return true; } + XFree(atoms); } return false; From f1dc00e380439078c93d00af2f85d138a9400b2e Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sat, 17 Jan 2015 19:43:12 +0900 Subject: [PATCH 25/35] * cleanup window state handling * first attemps in handling ALT+TABa (WIP) --- demos/misc/window_management/control.gd | 28 ++++---- .../window_management/window_management.scn | Bin 4111 -> 4052 bytes platform/x11/os_x11.cpp | 62 +++++++++--------- 3 files changed, 47 insertions(+), 43 deletions(-) diff --git a/demos/misc/window_management/control.gd b/demos/misc/window_management/control.gd index fd746cf036..4929b1376c 100644 --- a/demos/misc/window_management/control.gd +++ b/demos/misc/window_management/control.gd @@ -25,9 +25,9 @@ func _fixed_process(delta): get_node("Label_Size").set_text(str("Size:\n", OS.get_window_size() ) ) - get_node("Label_Screen_Count").set_text( str("Screens:\n", OS.get_screen_count() ) ) + get_node("Label_Screen_Count").set_text( str("Screen_Count:\n", OS.get_screen_count() ) ) - get_node("Label_Screen_Current").set_text( str("Current:\n", OS.get_screen() ) ) + get_node("Label_Screen_Current").set_text( str("Screen:\n", OS.get_screen() ) ) get_node("Label_Screen0_Resolution").set_text( str("Screen0 Resolution:\n", OS.get_screen_size() ) ) @@ -35,12 +35,14 @@ func _fixed_process(delta): if(OS.get_screen_count() > 1): + get_node("Button_Screen0").show() get_node("Button_Screen1").show() get_node("Label_Screen1_Resolution").show() get_node("Label_Screen1_Position").show() get_node("Label_Screen1_Resolution").set_text( str("Screen1 Resolution:\n", OS.get_screen_size(1) ) ) get_node("Label_Screen1_Position").set_text( str("Screen1 Position:\n", OS.get_screen_position(1) ) ) else: + get_node("Button_Screen0").hide() get_node("Button_Screen1").hide() get_node("Label_Screen1_Resolution").hide() get_node("Label_Screen1_Position").hide() @@ -57,21 +59,16 @@ func _fixed_process(delta): if( Input.is_action_pressed("ui_down")): OS.set_fullscreen(false) + get_node("Button_Fullscreen").set_pressed( OS.is_fullscreen() ) get_node("Button_FixedSize").set_pressed( !OS.is_resizable() ) get_node("Button_Minimized").set_pressed( OS.is_minimized() ) get_node("Button_Maximized").set_pressed( OS.is_maximized() ) - + + func _ready(): set_fixed_process(true) -func _on_Fullscreen_toggled( pressed ): - if(pressed): - OS.set_fullscreen(true) - else: - OS.set_fullscreen(false) - - func _on_Button_MoveTo_pressed(): OS.set_window_position( Vector2(100,100) ) @@ -88,12 +85,18 @@ func _on_Button_Screen1_pressed(): OS.set_screen(1) +func _on_Button_Fullscreen_pressed(): + if(OS.is_fullscreen()): + OS.set_fullscreen(false) + else: + OS.set_fullscreen(true) + + func _on_Button_FixedSize_pressed(): if(OS.is_resizable()): OS.set_resizable(false) else: OS.set_resizable(true) - func _on_Button_Minimized_pressed(): @@ -108,3 +111,6 @@ func _on_Button_Maximized_pressed(): OS.set_maximized(false) else: OS.set_maximized(true) + + + diff --git a/demos/misc/window_management/window_management.scn b/demos/misc/window_management/window_management.scn index 635f6f6f28ba59ae2a8af372b4d8e9d43f5e397d..3d62d4ecc14d44d7cc6d425432a75a4460d991a4 100644 GIT binary patch delta 2212 zcmeBIxFRnZ6zuHG00IIG3=*0Q42Rem7@o2+Fz`;4T*+9r@$hG6l?R+c42DUDEIx@z zsW}Sm%1_*8C-5bFUzC#+A$Lb^qiCEQ3+5_!1=<Do6@}-xeL!eV%*YHuf*VznbfVo?UD6>Nw+EP z0fXiPHrb}E2Mn?dvJcoY50yROS9rwG^gux2P~QUv1&{OxO!FEW7z`eW$}t!|V36~) zcX*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z1150>P6h4* v;ta(K+y~rUIuD35lz;@e!Gfg<+z0d-c);v31#WIoSr2O51O*2init(); @@ -760,23 +757,20 @@ bool OS_X11::is_fullscreen() const { } 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; - } - XSetWMNormalHints(x11_display, x11_window, xsh); - XFree(xsh); - current_videomode.resizable = p_enabled; + 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; } + XSetWMNormalHints(x11_display, x11_window, xsh); + XFree(xsh); + current_videomode.resizable = p_enabled; } bool OS_X11::is_resizable() const { @@ -784,10 +778,6 @@ bool OS_X11::is_resizable() const { } void OS_X11::set_minimized(bool p_enabled) { - - if( is_fullscreen() ) - set_fullscreen(false); - // Using ICCCM -- Inter-Client Communication Conventions Manual XEvent xev; Atom wm_change = XInternAtom(x11_display, "WM_CHANGE_STATE", False); @@ -799,7 +789,7 @@ void OS_X11::set_minimized(bool p_enabled) { xev.xclient.format = 32; xev.xclient.data.l[0] = p_enabled ? WM_IconicState : WM_NormalState; - XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureNotifyMask, &xev); + XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev); //XEvent xev; Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False); @@ -1152,13 +1142,16 @@ void OS_X11::process_xevents() { break; case VisibilityNotify: { - XVisibilityEvent * visibility = (XVisibilityEvent *)&event; minimized = (visibility->state == VisibilityFullyObscured); - } break; case FocusIn: + if(current_videomode.fullscreen) { + set_minimized(false); + set_wm_fullscreen(true); + visual_server->init(); + } main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN); if (mouse_mode==MOUSE_MODE_CAPTURED) { XGrabPointer(x11_display, x11_window, True, @@ -1169,6 +1162,11 @@ void OS_X11::process_xevents() { break; case FocusOut: + if(current_videomode.fullscreen) { + set_wm_fullscreen(false); + set_minimized(true); + visual_server->init(); + } main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT); if (mouse_mode==MOUSE_MODE_CAPTURED) { //dear X11, I try, I really try, but you never work, you do whathever you want. From dfb5a1d5e1318d91f26c0f7663afe861005104c8 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sun, 18 Jan 2015 00:28:04 +0900 Subject: [PATCH 26/35] * multi_screen testing + bugfixes * ALT-TAB is working * tested on Ubuntu 14.10 Unity + LXDE * minor cleanup --- demos/misc/window_management/engine.cfg | 2 + .../window_management/window_management.scn | Bin 4052 -> 4030 bytes platform/x11/os_x11.cpp | 48 ++++++++++++------ platform/x11/os_x11.h | 10 +--- 4 files changed, 35 insertions(+), 25 deletions(-) diff --git a/demos/misc/window_management/engine.cfg b/demos/misc/window_management/engine.cfg index 2accafe43e..6ce3d51aee 100644 --- a/demos/misc/window_management/engine.cfg +++ b/demos/misc/window_management/engine.cfg @@ -8,3 +8,5 @@ icon="icon.png" fullscreen=false resizable=true +width=800 +height=600 diff --git a/demos/misc/window_management/window_management.scn b/demos/misc/window_management/window_management.scn index 3d62d4ecc14d44d7cc6d425432a75a4460d991a4..baf03bdfd16bbff6221d71f493bfcd44e5d7533a 100644 GIT binary patch delta 1166 zcmca2zfWE&DA?JV0R#jX7+5tK81}IBhr5Sn7q%84MpVnls2L zdpgA}-1mraX;XpXN0+Fi8U=2T=m$)?P5uuUG#{|ZHbp;RkY$j4z?OL^{Q1h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Z+|f z2LT6e2IGbf*Hi}~=iN*xscFjJG;^4W@=G)yI|MP++*C*?cTi%e^0agiVP;_XzL{o>!9dxNcBnkEe9FqH|yRwI!L%OO;%)= z*APfFJy_!<>Zrh&n)i}%-9zS3hvyFR+E1A>^3y#RKVXq_=w~d*@BBD9gI&Ac3J4@fhxDR8q@<)tPTF|a6b zGM_zj#@4}*fmeZ>J0&$Ov2-#YhmVNERIcRG;*$K__{5_0;sjv^E(Q6?1soPu4D1RD ztij1enFS>Y<_;emW;rl8ymDZ0=yG5<5Y8azz{3oSX+eJGX_*Th8oU_`oE+F4?Iz#j zh+}=oBea7#TmvfrSCUGiBF&G>uT_De}?E#xS zgW&>s2FV0*XK4msrSi$YIde=HRb3jFGngzeVz`lD^nfv*!SDfBJY&O~1eFJj;S7ck zn8O|4JA7uyQ&eUvW>8>YVECkvGmjUndsomAg18r(9a;Q!0yoRJi(#g<%GjwSLw~V+-*z}tda~23|0(m z3=BpL3=Gx^%nl3;HV!NblMnD-;(1ss?6CNuzA!_Y!v4vt_&n>MWcxc5g9I`awlMrx zV0dJ%?rQ&#S=iP6VX?65evnMoLnUE`Yz6J7?8$D%&gyQ)51EA-ofsaL3cKwF$>%8S z2J4hoe<&>MR{xM$n88IM{86zwgR4UQLuFwGRt0_c>ukySd3nVQ3JSao1`5m$qE4&~ zc?#T747m!-?!68S4w?tV8S)hb4v4$IJRr_c@PJ9&L-2q&L*WA^aRyEW?gQcsMGD*p i+!?sQ>|!v<4JJ!Kr2E$c;tZt^n8cZbf`gnvr4j(g#bqD> diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index d4328d9da3..d711cea42e 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -42,7 +42,6 @@ // ICCCM #define WM_NormalState 1L // window normal state #define WM_IconicState 3L // window minimized - // EWMH #define _NET_WM_STATE_REMOVE 0L // remove/unset property #define _NET_WM_STATE_ADD 1L // add/set property @@ -192,9 +191,9 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD)); } +#ifndef EXPERIMENTAL_WM_API // borderless fullscreen window mode if (current_videomode.fullscreen) { -#ifndef EXPERIMENTAL_WM_API // needed for lxde/openbox, possibly others Hints hints; Atom property; @@ -222,16 +221,6 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi xev.xclient.data.l[2] = 0; XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureNotifyMask, &xev); -#else - minimized = false; - minimized = false; - window_data.position.x = 0; - window_data.position.y = 0; - window_data.size.width = 800; - window_data.size.height = 600; - //set_wm_border(false); - set_wm_fullscreen(true); -#endif } // disable resizable window @@ -252,6 +241,21 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi XSetWMNormalHints(x11_display, x11_window, xsh); XFree(xsh); } +#else + if (current_videomode.fullscreen) { + minimized = false; + maximized = false; + //set_wm_border(false); + set_wm_fullscreen(true); + } + if (!current_videomode.resizable) { + int screen = get_screen(); + Size2i screen_size = get_screen_size(screen); + set_window_size(screen_size); + set_resizable(false); + } +#endif + AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton(); @@ -519,7 +523,6 @@ OS::MouseMode OS_X11::get_mouse_mode() const { int OS_X11::get_mouse_button_state() const { - return last_button_state; } @@ -547,6 +550,8 @@ void OS_X11::get_fullscreen_mode_list(List *p_list,int p_screen) cons } #ifdef EXPERIMENTAL_WM_API +#if 0 +// Just now not needed. Can be used for a possible OS.set_border(bool) method void OS_X11::set_wm_border(bool p_enabled) { // needed for lxde/openbox, possibly others Hints hints; @@ -558,6 +563,7 @@ void OS_X11::set_wm_border(bool p_enabled) { XMapRaised(x11_display, x11_window); //XMoveResizeWindow(x11_display, x11_window, 0, 0, 800, 800); } +#endif void OS_X11::set_wm_fullscreen(bool p_enabled) { // Using EWMH -- Extened Window Manager Hints @@ -657,7 +663,11 @@ Point2 OS_X11::get_window_position() const { int x,y; Window child; XTranslateCoordinates( x11_display, x11_window, DefaultRootWindow(x11_display), 0, 0, &x, &y, &child); - return Point2i(x,y); + + int screen = get_screen(); + Point2i screen_position = get_screen_position(screen); + + return Point2i(x-screen_position.x, y-screen_position.y); } void OS_X11::set_window_position(const Point2& p_position) { @@ -698,6 +708,12 @@ void OS_X11::set_window_position(const Point2& p_position) { XFree(data); } + int screen = get_screen(); + Point2i screen_position = get_screen_position(screen); + + left -= screen_position.x; + top -= screen_position.y; + XMoveWindow(x11_display,x11_window,p_position.x - left,p_position.y - top); } @@ -1146,9 +1162,9 @@ void OS_X11::process_xevents() { minimized = (visibility->state == VisibilityFullyObscured); } break; - case FocusIn: + case FocusIn: + minimized = false; if(current_videomode.fullscreen) { - set_minimized(false); set_wm_fullscreen(true); visual_server->init(); } diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 557052ab69..b47c5db069 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -160,16 +160,8 @@ 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; - bool maximized; - void set_wm_border(bool p_enabled); + //void set_wm_border(bool p_enabled); void set_wm_fullscreen(bool p_enabled); #endif From 94d94a08558c83fb6e447c3e1ed858cf39c0e1ba Mon Sep 17 00:00:00 2001 From: hurikhan Date: Thu, 22 Jan 2015 01:14:50 +0900 Subject: [PATCH 27/35] * fix compilation without scons experimental_wm_api=yes * Extended the demo with an addional MouseGrab Test --- demos/misc/window_management/control.gd | 6 ++++-- demos/misc/window_management/engine.cfg | 7 +++++++ .../window_management/window_management.scn | Bin 4030 -> 4268 bytes platform/x11/os_x11.cpp | 10 +++++----- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/demos/misc/window_management/control.gd b/demos/misc/window_management/control.gd index 4929b1376c..6dc9282149 100644 --- a/demos/misc/window_management/control.gd +++ b/demos/misc/window_management/control.gd @@ -33,7 +33,6 @@ func _fixed_process(delta): get_node("Label_Screen0_Position").set_text(str("Screen0 Position:\n",OS.get_screen_position() ) ) - if(OS.get_screen_count() > 1): get_node("Button_Screen0").show() get_node("Button_Screen1").show() @@ -63,6 +62,7 @@ func _fixed_process(delta): get_node("Button_FixedSize").set_pressed( !OS.is_resizable() ) get_node("Button_Minimized").set_pressed( OS.is_minimized() ) get_node("Button_Maximized").set_pressed( OS.is_maximized() ) + get_node("Button_Mouse_Grab").set_pressed( Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED ) func _ready(): @@ -113,4 +113,6 @@ func _on_Button_Maximized_pressed(): OS.set_maximized(true) - +func _on_Button_Mouse_Grab_pressed(): + var observer = get_node("../Observer") + observer.state = observer.STATE_GRAB diff --git a/demos/misc/window_management/engine.cfg b/demos/misc/window_management/engine.cfg index 6ce3d51aee..c53bd45fb7 100644 --- a/demos/misc/window_management/engine.cfg +++ b/demos/misc/window_management/engine.cfg @@ -10,3 +10,10 @@ fullscreen=false resizable=true width=800 height=600 + +[input] + +move_forward=[key(W)] +move_backwards=[key(S)] +move_left=[key(A)] +move_right=[key(D)] diff --git a/demos/misc/window_management/window_management.scn b/demos/misc/window_management/window_management.scn index baf03bdfd16bbff6221d71f493bfcd44e5d7533a..40e6e64cef93a1b4cf0c8dd4d84a91c40582b950 100644 GIT binary patch delta 3948 zcmdldzeZ6iDA?JV0R#jX7>z%S_YX13@YsTNyVu}WvN9E7&w^qij(saIvKbWlv#4} zlM{0kyqF9acoOC?Fg)P!bP#iBWROyjc4%c_RbXdeQ($)3$yCgsq`=7#t-#E{p}@=$ zT##6jnV7>c@se@ELLRpG+|-i9`1nLg2LA;I5+zx@GxJh&71G#}o$^yE83YuZ9xwzj z=qH>`Fk%l$EiQ2`O-fDJz?zd-nOanwXvUPDny(PSQ1pN?he2Aw;Q@n)LO5e;k-`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p +++ b/platform/x11/os_x11.cpp @@ -177,11 +177,7 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi context_gl = memnew( ContextGL_X11( x11_display, x11_window,current_videomode, false ) ); context_gl->initialize(); - if (true) { - rasterizer = memnew( RasterizerGLES2 ); - } else { - //rasterizer = memnew( RasterizerGLES1 ); - }; + rasterizer = memnew( RasterizerGLES2 ); #endif visual_server = memnew( VisualServerRaster(rasterizer) ); @@ -1164,10 +1160,12 @@ void OS_X11::process_xevents() { case FocusIn: minimized = false; +#ifdef EXPERIMENTAL_WM_API if(current_videomode.fullscreen) { set_wm_fullscreen(true); visual_server->init(); } +#endif main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN); if (mouse_mode==MOUSE_MODE_CAPTURED) { XGrabPointer(x11_display, x11_window, True, @@ -1178,11 +1176,13 @@ void OS_X11::process_xevents() { break; case FocusOut: +#ifdef EXPERIMENTAL_WM_API if(current_videomode.fullscreen) { set_wm_fullscreen(false); set_minimized(true); visual_server->init(); } +#endif main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT); if (mouse_mode==MOUSE_MODE_CAPTURED) { //dear X11, I try, I really try, but you never work, you do whathever you want. From 2204914abfc939e16cc595a6b175ff74b6552a6c Mon Sep 17 00:00:00 2001 From: hurikhan Date: Thu, 22 Jan 2015 01:54:17 +0900 Subject: [PATCH 28/35] * observer scene for the demo --- .../window_management/observer/observer.gd | 78 ++++++++++++++ .../window_management/observer/observer.scn | Bin 0 -> 1786 bytes .../observer/observer_hud.gd | 98 ++++++++++++++++++ 3 files changed, 176 insertions(+) create mode 100644 demos/misc/window_management/observer/observer.gd create mode 100644 demos/misc/window_management/observer/observer.scn create mode 100644 demos/misc/window_management/observer/observer_hud.gd diff --git a/demos/misc/window_management/observer/observer.gd b/demos/misc/window_management/observer/observer.gd new file mode 100644 index 0000000000..7bec0f5301 --- /dev/null +++ b/demos/misc/window_management/observer/observer.gd @@ -0,0 +1,78 @@ + +extends Spatial + +var r_pos = Vector2() +var state + +const STATE_MENU=0 +const STATE_GRAB=1 + +func direction(vector): + var v = get_node("Camera").get_global_transform().basis * vector + v = v.normalized() + + return v + + +func impulse(event, action): + if(event.is_action(action) && event.is_pressed() && !event.is_echo()): + return true + else: + return false + + +func _fixed_process(delta): + + if(state != STATE_GRAB): + return + + if(Input.get_mouse_mode() != Input.MOUSE_MODE_CAPTURED): + Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) + + var dir = Vector3() + var cam = get_global_transform() + var org = get_translation() + + if (Input.is_action_pressed("move_forward")): + dir += direction(Vector3(0,0,-1)) + if (Input.is_action_pressed("move_backwards")): + dir += direction(Vector3(0,0,1)) + if (Input.is_action_pressed("move_left")): + dir += direction(Vector3(-1,0,0)) + if (Input.is_action_pressed("move_right")): + dir += direction(Vector3(1,0,0)) + + dir = dir.normalized() + + move(dir * 10 * delta) + var d = delta * 0.1 + + var yaw = get_transform().rotated(Vector3(0,1,0), d * r_pos.x) + set_transform(yaw) + + var cam = get_node("Camera") + var pitch = cam.get_transform().rotated(Vector3(1,0,0), d * r_pos.y) + cam.set_transform(pitch) + + r_pos.x = 0.0 + r_pos.y = 0.0 + + +func _input( event ): + if(event.type == InputEvent.MOUSE_MOTION): + r_pos = event.relative_pos + + if(impulse(event, "ui_cancel")): + if(state == STATE_GRAB): + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + state = STATE_MENU + else: + Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) + state = STATE_GRAB + + +func _ready(): + set_fixed_process(true) + set_process_input(true) + + state = STATE_MENU diff --git a/demos/misc/window_management/observer/observer.scn b/demos/misc/window_management/observer/observer.scn new file mode 100644 index 0000000000000000000000000000000000000000..da29ad62b8d0d7033ef8c40af78e0fd7b4602ad3 GIT binary patch literal 1786 zcmWFvc6Md}0RaYvb-WA=kJuO(7#SEE7#SEF*b*2RcobN<0uqz6Q&WPIQ}a?4cpsQD zFt8}tCB!rEDRA%=r55Lx7A2?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;a1 z{HYj+gOYnlPj_xwA7onszv6M#mus0|(}WD2E!S6bAtZZU*Cq4(BxvLe9sTQ&Q7% zoI6?Li}Fk2D-(j4YHlhdlshOfRJm|Fq%$)x{Bj0qa4~RTXJ%k9adHrLNMbI_Of7e9 zYE*ELb&POKcTjXV#F&z)*u|8WoSGoRd}3d{ql1L&TZRgU>I6}ycR{KNl@6i|l@Az1 znXHT_Cx|+@sC-lUtsLaI>0q1l14o4?%nc6m4h#+{4$mFr)fCw>^3(J45_2A~$T_TG zEXZ#;%m0J3JK2ge^2_7Xi!@xFnGbk6e@>8O$oEKO$a}yd?R1!->N&$- z=Cfzc*gAN7h98*8TwIi%lwjn*;2`51q#%>9(Rl@9d_}Swla*UxLc8m+rwkp8MWw2( zOsOR$>H$aF9cDVXIZS0sE-fy}&yCkO!BCta>~NSxH%CFGIO~gpsq0m9v!PP<7 zVTl8~gQtVEtAT^GTc?Ax!!HMUM-c~hH){uWM+*mb$0ZKd4#^JIj?*2iA22hx#5yoL zbUWxfm^&~y+w7Zl! zus>jCaMyHTc4&6+f56}Du-hS-K}NyGL772Tf!!h7qupUPgS-O2!(+#Mhs%tL3=Ql) z+79Xr$_o4r)eI^M?2h6LstW85{0wRe><*V1)D_qr>=`r^*c~=AXezKfgfnOFM9OMkD^#HTcB`W{` literal 0 HcmV?d00001 diff --git a/demos/misc/window_management/observer/observer_hud.gd b/demos/misc/window_management/observer/observer_hud.gd new file mode 100644 index 0000000000..24e81b02ba --- /dev/null +++ b/demos/misc/window_management/observer/observer_hud.gd @@ -0,0 +1,98 @@ +var parent + +func printdebug(): + + var s + + if(parent.state == parent.STATE_GAME): + s = str( "TIME_FPS: ", Performance.get_monitor(Performance.TIME_FPS), "\n") + s += str("OBJECT_COUNT: ", Performance.get_monitor(Performance.OBJECT_COUNT), "\n") + s += str("OBJECT_RESOURCE_COUNT : ", Performance.get_monitor(Performance.OBJECT_RESOURCE_COUNT), "\n") + s += str("OBJECT_NODE_COUNT : ", Performance.get_monitor(Performance.OBJECT_NODE_COUNT), "\n") + s += str("RENDER_OBJECTS_IN_FRAME : ", Performance.get_monitor(Performance.RENDER_OBJECTS_IN_FRAME), "\n") + s += str("RENDER_VERTICES_IN_FRAME : ", Performance.get_monitor(Performance.RENDER_VERTICES_IN_FRAME), "\n") + s += str("RENDER_DRAW_CALLS_IN_FRAME : ", Performance.get_monitor(Performance.RENDER_DRAW_CALLS_IN_FRAME), "\n") + s += str("RENDER_VERTICES_IN_FRAME : ", Performance.get_monitor(Performance.RENDER_VERTICES_IN_FRAME), "\n") + # s += str("RENDER_USAGE_VIDEO_MEM_TOTAL : ", Performance.get_monitor(Performance.RENDER_USAGE_VIDEO_MEM_TOTAL), "\n") + # s += str("RENDER_VIDEO_MEM_USED : ", Performance.get_monitor(Performance.RENDER_VIDEO_MEM_USED), "\n") + # s += str("RENDER_TEXTURE_MEM_USED : ", Performance.get_monitor(Performance.RENDER_TEXTURE_MEM_USED), "\n") + # s += str("RENDER_VERTEX_MEM_USED : ", Performance.get_monitor(Performance.RENDER_VERTEX_MEM_USED), "\n") + s += str("CUBES: ", get_node("/root/World").world.size(), "\n") + else: + s = "" + + get_node("Label_Debug").set_text(s) + + +func _fixed_process(delta): + parent = get_parent() + + printdebug() + + if( parent.state == parent.STATE_MENU ): + get_node("Menu").show() + else: + get_node("Menu").hide() + + + +func _ready(): + set_fixed_process(true) + + +func _on_Fullscreen_toggled( pressed ): + if( pressed ): + OS.set_fullscreen(true) + else: + OS.set_fullscreen(false) + + +func _on_DebugInfo_toggled( pressed ): + if( pressed ): + get_node("Label_Debug").show() + else: + get_node("Label_Debug").hide() + + +func _on_Save_pressed(): + var file_dialog = get_node("Menu/SaveDialog") + file_dialog.clear_filters() + file_dialog.add_filter("*.json") + file_dialog.set_mode(3) + file_dialog.show() + file_dialog._update_file_list() + + +func _on_SaveDialog_file_selected( path ): + get_node("/root/World").save_world( path ) + + +func _on_Load_pressed(): + var file_dialog = get_node("Menu/LoadDialog") + file_dialog.clear_filters() + file_dialog.add_filter("*.json") + file_dialog.set_mode(0) + file_dialog.show() + file_dialog._update_file_list() + + +func _on_LoadDialog_file_selected( path ): + get_node("/root/World").load_world( path ) + + +func _on_Server_toggled( pressed ): + if pressed: + get_node("/root/World/Server").start() + get_node("Menu/Client").hide() + else: + get_node("/root/World/Server").stop() + get_node("Menu/Client").show() + + +func _on_Client_toggled( pressed ): + if pressed: + get_node("/root/World/Client").start() + get_node("Menu/Server").hide() + else: + get_node("/root/World/Client").stop() + get_node("Menu/Server").show() \ No newline at end of file From 03c453ac7dc2b22bfb864e563b7f3b8424bbcff4 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Thu, 22 Jan 2015 05:35:39 +0900 Subject: [PATCH 29/35] * Cleanup for PR * Demo shows a Dialog with not implemented methods at startup --- README.md | 21 ---- demos/misc/window_management/control.gd | 68 +++++++++++- .../window_management/observer/observer.gd | 1 + .../observer/observer_hud.gd | 98 ------------------ .../window_management/window_management.scn | Bin 4268 -> 4744 bytes main/main.cpp | 1 + 6 files changed, 69 insertions(+), 120 deletions(-) delete mode 100644 demos/misc/window_management/observer/observer_hud.gd diff --git a/README.md b/README.md index 35841c8b29..3456290f74 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,3 @@ -### x11-window-management branch - -#### New GDScript Methods for the OS Class: -* int OS.get_screen_count() -* int OS.get_screen() -* void OS.set_screen(int screen) -* Vector2 OS.get_screen_position(int screen=0) -* Vector2 OS.get_screen_size(int screen=0) -* Vector2 OS.get_window_position() -* void OS.set_window_position(Vector2 position) -* Vector2 OS.get_window_size() -* void OS.set_window_size(Vector2 size) -* void OS.set_fullscreen(bool enabled) -* bool OS.is_fullscreen() - -#### Demo -A demo/test is available at "demos/misc/window-management" - -#### Scons Commandline -'''scons p=x11 experimental_wm_api=yes''' - ![GODOT](/logo.png) ### The Engine diff --git a/demos/misc/window_management/control.gd b/demos/misc/window_management/control.gd index 6dc9282149..d329237aed 100644 --- a/demos/misc/window_management/control.gd +++ b/demos/misc/window_management/control.gd @@ -19,6 +19,9 @@ func _fixed_process(delta): if(OS.is_maximized()): modetext += "Maximized\n" + if(Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED): + modetext += "MouseGrab\n" + get_node("Label_Mode").set_text(modetext) get_node("Label_Position").set_text( str("Position:\n", OS.get_window_position() ) ) @@ -65,8 +68,71 @@ func _fixed_process(delta): get_node("Button_Mouse_Grab").set_pressed( Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED ) +func check_wm_api(): + var s = "" + if( !OS.has_method("get_screen_count") ): + s += " - get_screen_count()\n" + + if( !OS.has_method("get_screen") ): + s += " - get_screen()\n" + + if( !OS.has_method("set_screen") ): + s += " - set_screen()\n" + + if( !OS.has_method("get_screen_position") ): + s += " - get_screen_position()\n" + + if( !OS.has_method("get_screen_size") ): + s += " - get_screen_size()\n" + + if( !OS.has_method("get_window_position") ): + s += " - get_window_position()\n" + + if( !OS.has_method("set_window_position") ): + s += " - set_window_position()\n" + + if( !OS.has_method("get_window_size") ): + s += " - get_window_size()\n" + + if( !OS.has_method("set_window_size") ): + s += " - set_window_size()\n" + + if( !OS.has_method("set_fullscreen") ): + s += " - set_fullscreen()\n" + + if( !OS.has_method("is_fullscreen") ): + s += " - is_fullscreen()\n" + + if( !OS.has_method("set_resizable") ): + s += " - set_resizable()\n" + + if( !OS.has_method("is_resizable") ): + s += " - is_resizable()\n" + + if( !OS.has_method("set_minimized") ): + s += " - set_minimized()\n" + + if( !OS.has_method("is_minimized") ): + s += " - is_minimized()\n" + + if( !OS.has_method("set_maximized") ): + s += " - set_maximized()\n" + + if( !OS.has_method("is_maximized") ): + s += " - is_maximized()\n" + + if( s.length() == 0 ): + return true + else: + var text = get_node("ImplementationDialog/Text").get_text() + get_node("ImplementationDialog/Text").set_text( text + s ) + get_node("ImplementationDialog").show() + return false + + func _ready(): - set_fixed_process(true) + if( check_wm_api() ): + set_fixed_process(true) func _on_Button_MoveTo_pressed(): diff --git a/demos/misc/window_management/observer/observer.gd b/demos/misc/window_management/observer/observer.gd index 7bec0f5301..d27912a670 100644 --- a/demos/misc/window_management/observer/observer.gd +++ b/demos/misc/window_management/observer/observer.gd @@ -76,3 +76,4 @@ func _ready(): set_process_input(true) state = STATE_MENU + diff --git a/demos/misc/window_management/observer/observer_hud.gd b/demos/misc/window_management/observer/observer_hud.gd deleted file mode 100644 index 24e81b02ba..0000000000 --- a/demos/misc/window_management/observer/observer_hud.gd +++ /dev/null @@ -1,98 +0,0 @@ -var parent - -func printdebug(): - - var s - - if(parent.state == parent.STATE_GAME): - s = str( "TIME_FPS: ", Performance.get_monitor(Performance.TIME_FPS), "\n") - s += str("OBJECT_COUNT: ", Performance.get_monitor(Performance.OBJECT_COUNT), "\n") - s += str("OBJECT_RESOURCE_COUNT : ", Performance.get_monitor(Performance.OBJECT_RESOURCE_COUNT), "\n") - s += str("OBJECT_NODE_COUNT : ", Performance.get_monitor(Performance.OBJECT_NODE_COUNT), "\n") - s += str("RENDER_OBJECTS_IN_FRAME : ", Performance.get_monitor(Performance.RENDER_OBJECTS_IN_FRAME), "\n") - s += str("RENDER_VERTICES_IN_FRAME : ", Performance.get_monitor(Performance.RENDER_VERTICES_IN_FRAME), "\n") - s += str("RENDER_DRAW_CALLS_IN_FRAME : ", Performance.get_monitor(Performance.RENDER_DRAW_CALLS_IN_FRAME), "\n") - s += str("RENDER_VERTICES_IN_FRAME : ", Performance.get_monitor(Performance.RENDER_VERTICES_IN_FRAME), "\n") - # s += str("RENDER_USAGE_VIDEO_MEM_TOTAL : ", Performance.get_monitor(Performance.RENDER_USAGE_VIDEO_MEM_TOTAL), "\n") - # s += str("RENDER_VIDEO_MEM_USED : ", Performance.get_monitor(Performance.RENDER_VIDEO_MEM_USED), "\n") - # s += str("RENDER_TEXTURE_MEM_USED : ", Performance.get_monitor(Performance.RENDER_TEXTURE_MEM_USED), "\n") - # s += str("RENDER_VERTEX_MEM_USED : ", Performance.get_monitor(Performance.RENDER_VERTEX_MEM_USED), "\n") - s += str("CUBES: ", get_node("/root/World").world.size(), "\n") - else: - s = "" - - get_node("Label_Debug").set_text(s) - - -func _fixed_process(delta): - parent = get_parent() - - printdebug() - - if( parent.state == parent.STATE_MENU ): - get_node("Menu").show() - else: - get_node("Menu").hide() - - - -func _ready(): - set_fixed_process(true) - - -func _on_Fullscreen_toggled( pressed ): - if( pressed ): - OS.set_fullscreen(true) - else: - OS.set_fullscreen(false) - - -func _on_DebugInfo_toggled( pressed ): - if( pressed ): - get_node("Label_Debug").show() - else: - get_node("Label_Debug").hide() - - -func _on_Save_pressed(): - var file_dialog = get_node("Menu/SaveDialog") - file_dialog.clear_filters() - file_dialog.add_filter("*.json") - file_dialog.set_mode(3) - file_dialog.show() - file_dialog._update_file_list() - - -func _on_SaveDialog_file_selected( path ): - get_node("/root/World").save_world( path ) - - -func _on_Load_pressed(): - var file_dialog = get_node("Menu/LoadDialog") - file_dialog.clear_filters() - file_dialog.add_filter("*.json") - file_dialog.set_mode(0) - file_dialog.show() - file_dialog._update_file_list() - - -func _on_LoadDialog_file_selected( path ): - get_node("/root/World").load_world( path ) - - -func _on_Server_toggled( pressed ): - if pressed: - get_node("/root/World/Server").start() - get_node("Menu/Client").hide() - else: - get_node("/root/World/Server").stop() - get_node("Menu/Client").show() - - -func _on_Client_toggled( pressed ): - if pressed: - get_node("/root/World/Client").start() - get_node("Menu/Server").hide() - else: - get_node("/root/World/Client").stop() - get_node("Menu/Server").show() \ No newline at end of file diff --git a/demos/misc/window_management/window_management.scn b/demos/misc/window_management/window_management.scn index 40e6e64cef93a1b4cf0c8dd4d84a91c40582b950..bf7a0871e7c6ad7c8ab50d4335408fc8eb7f8867 100644 GIT binary patch delta 2736 zcmZ3Z*r6&H6zuHG00IIG3?~g37!I*BFx+QjVDMySV5nl4D0Ps9C4qrq5O=Lr{>zjXpPXdDz^owUwB&#kL!PqN112fgUk*|Z zN{nTR>h4T=CB+H97+I9Bwli6YtC{|a)@U%a!IIj;B#PhjAbZL%4N=pFV0i`=#c8b z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Ejd50q$oefjm7zlgStZ>gOGy4vB`Yg z5@Ag)ZpO@Rr8zkbcNb_e6f96;Se2CSXwKlK7RHeR{A+;{4k!=36JJ~QMg zDl-)`C@9o0JW>3?@P7e=0$&1y1D}Fe(gp_xrx#9p4t;TucHn-%%-|5}5bGfA!0e#! zz;M9YiT{ASgZ2Yv2FE}LW`}Zjp9k#L4%rUwE{qQDPV*i3o%tNhUF;qBU3whY9rrtE zyX|Qbs(-~wG z)E%ZX$SSZqsC!L*!h5}5{V{{t1HH#C>JOM7yXZUAJ1{s%J1{s1J1{&^cYZ9~@8JDF z{V{{NLd#?AewWW6MZX_NK4xNI;9_QAU{FzDW?)iaW>8gNW)M(dW>8aLc3@{vS72x0 zQDA1!R$yk}QebA#0gLJ`U}w-%V0SQP&{tq*;80*@Fi>EwcaUc=T)@s?q`=O=uE6ZT zz`*RlqQJnQrNGQ!p}@@WUjdX)*%=r?at`ti%?#oSJPySS5)0TFq!rj1gcX<>WE7Yo zeqs<&U}lh0V0M_#Ag{pgz`&@$(7?c;*ucifpajy-psc{+F!_P;V+IWcXOOon73z%@ z9zD=_%%G`Y{($+hqyB^F$BvIdQdSD9!7@(n511c2`9Fw$?6m%Y@?!=Yh5HQF3d{All+2X?334$qxH@xknL+G)2#yF;)8!z1C{&cct_cRPJ|R%Wqd zU|`@>U}msaV0PeVbYN&;XK)1h!%2bNL7u@`f!&#z!DRuvBfIlz=lPR;1>~fh=Q}Vs z3Nv^raDW2BVgEy8VdvKmnT1`|y+{SlDCrLuFwGRz-FOHU(yuMFgPcK)2LS3jbpQYW diff --git a/main/main.cpp b/main/main.cpp index 27d7d97e85..f0e376a045 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -627,6 +627,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas } } + GLOBAL_DEF("display/width",video_mode.width); GLOBAL_DEF("display/height",video_mode.height); GLOBAL_DEF("display/fullscreen",video_mode.fullscreen); From df7d26ff5b89ce9852813abd370d1357aab1501b Mon Sep 17 00:00:00 2001 From: hurikhan Date: Thu, 12 Feb 2015 15:58:00 +0100 Subject: [PATCH 30/35] cleanup + MouseGrab --- demos/misc/window_management/control.gd | 2 + .../window_management/window_management.scn | Bin 4744 -> 4850 bytes platform/x11/os_x11.cpp | 79 +++++++----------- platform/x11/os_x11.h | 1 + 4 files changed, 35 insertions(+), 47 deletions(-) diff --git a/demos/misc/window_management/control.gd b/demos/misc/window_management/control.gd index d329237aed..50fc3a3765 100644 --- a/demos/misc/window_management/control.gd +++ b/demos/misc/window_management/control.gd @@ -28,6 +28,8 @@ func _fixed_process(delta): get_node("Label_Size").set_text(str("Size:\n", OS.get_window_size() ) ) + get_node("Label_MousePosition").set_text(str("Mouse Position:\n", Input.get_mouse_pos() ) ) + get_node("Label_Screen_Count").set_text( str("Screen_Count:\n", OS.get_screen_count() ) ) get_node("Label_Screen_Current").set_text( str("Screen:\n", OS.get_screen() ) ) diff --git a/demos/misc/window_management/window_management.scn b/demos/misc/window_management/window_management.scn index bf7a0871e7c6ad7c8ab50d4335408fc8eb7f8867..14d0da04151608996f142d02c9c55befed508601 100644 GIT binary patch delta 2672 zcmeBB{iG@v6zuHG00IIG4EGHg7!I>DFx+EfV0g>Kz~I0*QSKlML!tun#>W}V^>Gb+ ziNOyT)SUJ-h&LKC#ycxaW++Lve84KkR9aM|P?*&BfLVgUz_FSsKc_UI*jeQPtIPw2 zbf;qvn57sD9|)T>7(QS$cRs}GnOl&PnyXOj^qDcwMRf{eetPmhCdcGtl@AL9T>r5Y zjQq- zX2AyxvTnB?Fj+UgW-xdlD#u{>fI-gD)R9kR3PZ7CBO?Q|BA*ARgShKd6;YP}5l{^?zi!}lsFl%_6RTR_AOb~PM zcCdH&#*n<|w?nW)`~mUKtquDR=sRpzH5b%$Q4~4Z?_l8A*dXzevsrV~T z=kVM?UTYmoMt*vJo_gct>ujdd-Ykb@J107K9op?6tK7_-SejF^dWqAl1G4T9C#$n- zDBOL(;_3W3K~ih3s{R8OX{W)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~SZ2kr;V3=W|RUJ23;@(%hA38`47lD zXg^?Pa0+x_b|_~MP>^`QZtalm;O@%k;O;!%f!~GC!Q9o}f#0>qfj!h|zk{~xZU=UU zUC$v6nGq%9cDYoADDe$GK08+yhFV!hXcE7 zkHcb@4-V|!G7i%jWE9jLrZdPYusf)GJ4}AXYvtuw?Qq|L!C|oj1A~?V3xlQtv%_JB z`47YoJ8X88cG&E|?y%WW*)X{gWPu<#vX6jaz3b+O%)+kHATsztg&hw+low|5 zVqkb^Bg`PB;Qo+Vn88?q|6#E(gNZ`@Lw#WeZv|_H{|XEa`yUyr9~C}q&0wk!4l?9X zwz^0ALw#W;AFyUe?nlh(9_9~=h21ZMwD~@?6FwI1UhSIfHveIe)TR9T*tIK(Xh%m?2bwU11Z$f5+wr%$q&GKj7Z%eBNQR!(#_y&&dv(J=z~g zZ*~ZOz`ohn-%;9mv6s2Cy8B^gc?WT)set_mouse_pos(center); + } } void OS_X11::warp_mouse_pos(const Point2& p_to) { @@ -724,44 +727,10 @@ void OS_X11::set_window_size(const Size2 p_size) { } void OS_X11::set_fullscreen(bool p_enabled) { - -#if 0 - 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(); - - int screen = get_screen(); - Size2i size = get_screen_size(screen); - Point2i position = get_screen_position(screen); - - set_wm_border(false); - set_wm_fullscreen(true); - XMoveResizeWindow(x11_display, x11_window, position.x, position.y, size.x, size.y); - - current_videomode.fullscreen = True; - } else { - set_wm_fullscreen(false); - set_wm_border(true); - XMoveResizeWindow(x11_display, x11_window, - window_data.position.x, - window_data.position.y, - window_data.size.width, - window_data.size.height); - - current_videomode.fullscreen = False; - } -#endif set_wm_fullscreen(p_enabled); current_videomode.fullscreen = p_enabled; visual_server->init(); - } bool OS_X11::is_fullscreen() const { @@ -1209,7 +1178,7 @@ void OS_X11::process_xevents() { event.xbutton.x=last_mouse_pos.x; event.xbutton.y=last_mouse_pos.y; } - + InputEvent mouse_event; mouse_event.ID=++event_id; mouse_event.type = InputEvent::MOUSE_BUTTON; @@ -1244,7 +1213,7 @@ void OS_X11::process_xevents() { last_click_ms+=diff; last_click_pos = Point2(event.xbutton.x,event.xbutton.y); } - } + } input->parse_input_event( mouse_event); @@ -1254,11 +1223,10 @@ void OS_X11::process_xevents() { last_timestamp=event.xmotion.time; - + // Motion is also simple. // A little hack is in order // to be able to send relative motion events. - Point2i pos( event.xmotion.x, event.xmotion.y ); if (mouse_mode==MOUSE_MODE_CAPTURED) { @@ -1273,7 +1241,7 @@ void OS_X11::process_xevents() { } Point2i new_center = pos; - pos = last_mouse_pos + ( pos-center ); + pos = last_mouse_pos + ( pos - center ); center=new_center; do_mouse_warp=true; #else @@ -1287,9 +1255,7 @@ void OS_X11::process_xevents() { XWarpPointer(x11_display, None, x11_window, 0,0,0,0, (int)center.x, (int)center.y); #endif - } - if (!last_mouse_pos_valid) { @@ -1298,7 +1264,14 @@ void OS_X11::process_xevents() { } Point2i rel = pos - last_mouse_pos; - + +#ifdef EXPERIMENTAL_WM_API + if (mouse_mode==MOUSE_MODE_CAPTURED) { + pos.x = current_videomode.width / 2; + pos.y = current_videomode.height / 2; + } +#endif + InputEvent motion_event; motion_event.ID=++event_id; motion_event.type=InputEvent::MOUSE_MOTION; @@ -1309,7 +1282,7 @@ void OS_X11::process_xevents() { motion_event.mouse_motion.x=pos.x; motion_event.mouse_motion.y=pos.y; input->set_mouse_pos(pos); - motion_event.mouse_motion.global_x=pos.x; + motion_event.mouse_motion.global_x=pos.y; motion_event.mouse_motion.global_y=pos.y; motion_event.mouse_motion.speed_x=input->get_mouse_speed().x; motion_event.mouse_motion.speed_y=input->get_mouse_speed().y; @@ -1318,6 +1291,8 @@ void OS_X11::process_xevents() { motion_event.mouse_motion.relative_y=rel.y; last_mouse_pos=pos; + + // printf("rel: %d,%d\n", rel.x, rel.y ); input->parse_input_event( motion_event); @@ -1392,8 +1367,18 @@ void OS_X11::process_xevents() { if (do_mouse_warp) { XWarpPointer(x11_display, None, x11_window, - 0,0,0,0, (int)current_videomode.width/2, (int)current_videomode.height/2); + 0,0,0,0, (int)current_videomode.width/2, (int)current_videomode.height/2); + /* + Window root, child; + int root_x, root_y; + int win_x, win_y; + unsigned int mask; + XQueryPointer( x11_display, x11_window, &root, &child, &root_x, &root_y, &win_x, &win_y, &mask ); + + printf("Root: %d,%d\n", root_x, root_y); + printf("Win: %d,%d\n", win_x, win_y); + */ } } diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index b47c5db069..7518c93562 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -160,6 +160,7 @@ class OS_X11 : public OS_Unix { Joystick joysticks[JOYSTICKS_MAX]; #ifdef EXPERIMENTAL_WM_API + unsigned int capture_idle; bool maximized; //void set_wm_border(bool p_enabled); void set_wm_fullscreen(bool p_enabled); From f5d2e1f42cca1c5b078073133fccda63c556a0da Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sun, 15 Feb 2015 18:26:49 +0800 Subject: [PATCH 31/35] Renamed EXPERIMENTAL_WM_API to NEW_WM_API --- core/bind/core_bind.cpp | 4 ++-- core/bind/core_bind.h | 2 +- core/os/os.h | 2 +- platform/x11/detect.py | 6 +++--- platform/x11/os_x11.cpp | 12 ++++++------ platform/x11/os_x11.h | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 39c5761d67..858f5cec27 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -176,7 +176,7 @@ bool _OS::is_video_mode_fullscreen(int p_screen) const { } -#ifdef EXPERIMENTAL_WM_API +#ifdef NEW_WM_API int _OS::get_screen_count() const { return OS::get_singleton()->get_screen_count(); } @@ -706,7 +706,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_video_mode_resizable","screen"),&_OS::is_video_mode_resizable,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0)); -#ifdef EXPERIMENTAL_WM_API +#ifdef NEW_WM_API ObjectTypeDB::bind_method(_MD("get_screen_count"),&_OS::get_screen_count); ObjectTypeDB::bind_method(_MD("get_screen"),&_OS::get_screen); ObjectTypeDB::bind_method(_MD("set_screen"),&_OS::set_screen); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index e77ed9e40f..1a80e35221 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -108,7 +108,7 @@ public: bool is_video_mode_resizable(int p_screen=0) const; Array get_fullscreen_mode_list(int p_screen=0) const; -#ifdef EXPERIMENTAL_WM_API +#ifdef NEW_WM_API virtual int get_screen_count() const; virtual int get_screen() const; virtual void set_screen(int p_screen); diff --git a/core/os/os.h b/core/os/os.h index c04a91e302..6301bd495f 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -150,7 +150,7 @@ public: virtual VideoMode get_video_mode(int p_screen=0) const=0; virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const=0; -#ifdef EXPERIMENTAL_WM_API +#ifdef NEW_WM_API virtual int get_screen_count() const=0; virtual int get_screen() const=0; virtual void set_screen(int p_screen)=0; diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 0601c59981..2519dd6fdf 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -53,7 +53,7 @@ def get_opts(): ('use_llvm','Use llvm compiler','no'), ('use_sanitizer','Use llvm compiler sanitize address','no'), ('pulseaudio','Detect & Use pulseaudio','yes'), - ('experimental_wm_api', 'Use experimental window management API','no'), + ('new_wm_api', 'Use experimental window management API','no'), ] def get_flags(): @@ -153,7 +153,7 @@ def configure(env): env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } ) #env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } ) - if(env["experimental_wm_api"]=="yes"): - env.Append(CPPFLAGS=['-DEXPERIMENTAL_WM_API']) + if(env["new_wm_api"]=="yes"): + env.Append(CPPFLAGS=['-DNEW_WM_API']) env.ParseConfig('pkg-config xinerama --cflags --libs') diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 4c86f5a82f..8def564562 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -36,7 +36,7 @@ #include "servers/physics/physics_server_sw.h" #include "X11/Xutil.h" -#ifdef EXPERIMENTAL_WM_API +#ifdef NEW_WM_API #include "X11/Xatom.h" #include "X11/extensions/Xinerama.h" // ICCCM @@ -187,7 +187,7 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi visual_server =memnew(VisualServerWrapMT(visual_server,get_render_thread_mode()==RENDER_SEPARATE_THREAD)); } -#ifndef EXPERIMENTAL_WM_API +#ifndef NEW_WM_API // borderless fullscreen window mode if (current_videomode.fullscreen) { // needed for lxde/openbox, possibly others @@ -552,7 +552,7 @@ void OS_X11::get_fullscreen_mode_list(List *p_list,int p_screen) cons } -#ifdef EXPERIMENTAL_WM_API +#ifdef NEW_WM_API #if 0 // Just now not needed. Can be used for a possible OS.set_border(bool) method void OS_X11::set_wm_border(bool p_enabled) { @@ -1133,7 +1133,7 @@ void OS_X11::process_xevents() { case FocusIn: minimized = false; -#ifdef EXPERIMENTAL_WM_API +#ifdef NEW_WM_API if(current_videomode.fullscreen) { set_wm_fullscreen(true); visual_server->init(); @@ -1149,7 +1149,7 @@ void OS_X11::process_xevents() { break; case FocusOut: -#ifdef EXPERIMENTAL_WM_API +#ifdef NEW_WM_API if(current_videomode.fullscreen) { set_wm_fullscreen(false); set_minimized(true); @@ -1269,7 +1269,7 @@ void OS_X11::process_xevents() { Point2i rel = pos - last_mouse_pos; -#ifdef EXPERIMENTAL_WM_API +#ifdef NEW_WM_API if (mouse_mode==MOUSE_MODE_CAPTURED) { pos.x = current_videomode.width / 2; pos.y = current_videomode.height / 2; diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index 7518c93562..ffa1ce00b3 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -159,7 +159,7 @@ class OS_X11 : public OS_Unix { int joystick_count; Joystick joysticks[JOYSTICKS_MAX]; -#ifdef EXPERIMENTAL_WM_API +#ifdef NEW_WM_API unsigned int capture_idle; bool maximized; //void set_wm_border(bool p_enabled); @@ -220,7 +220,7 @@ public: virtual VideoMode get_video_mode(int p_screen=0) const; virtual void get_fullscreen_mode_list(List *p_list,int p_screen=0) const; -#ifdef EXPERIMENTAL_WM_API +#ifdef NEW_WM_API virtual int get_screen_count() const; virtual int get_screen() const; virtual void set_screen(int p_screen); From ba74e45027f795238323c3667dfdb660608d7484 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sun, 8 Mar 2015 01:27:36 -0600 Subject: [PATCH 32/35] added Label_MouseGrab_KeyInfo --- demos/misc/window_management/control.gd | 3 +++ .../window_management/window_management.scn | Bin 4850 -> 5072 bytes 2 files changed, 3 insertions(+) diff --git a/demos/misc/window_management/control.gd b/demos/misc/window_management/control.gd index 50fc3a3765..7f805a1a21 100644 --- a/demos/misc/window_management/control.gd +++ b/demos/misc/window_management/control.gd @@ -21,6 +21,9 @@ func _fixed_process(delta): if(Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED): modetext += "MouseGrab\n" + get_node("Label_MouseGrab_KeyInfo").show() + else: + get_node("Label_MouseGrab_KeyInfo").hide() get_node("Label_Mode").set_text(modetext) diff --git a/demos/misc/window_management/window_management.scn b/demos/misc/window_management/window_management.scn index 14d0da04151608996f142d02c9c55befed508601..0cb7030ffc1164ffae0fbb6b719294118e7ffa56 100644 GIT binary patch delta 3899 zcmeyQdO=+-DA?JV0R#jX7&=WD7!I;CFc`2iFsx!?U=U=QD0h&}QJR56fqmlhyY(%M zsTB$rIO3B_b8_Ny6N?^jm@4Y9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jfC6{9`5t1_o9JEd~Y#GX-Xb{|XEYk_zmgQr3Zifw^9Rg@H+dnL!*<=rTws zFgvg_NGpKClbJzAftf*Gftf*8ftf*Aftf*0ftgW(p+VSz!GRkyfEc(Gm>EuFl zLBt@Sz|5cqHVza_=?vPSAO?F}ok3Rt>hF4oV35Z_?Og@~1!jcT8Q4ML?r<0yrsfLF z3XdLWJa*U)^4org?+y$PoF6+J28D?H1NFyD77PpzbRIi4g9N%CL_c}(B^*#1EIF@uf5eFkfgT@3#n=06cH zX0TPzcE0Q~-+|qw*`@vfv%_bX$u7+<@(#fc43CB9y97IfQr-V2%+)M*3=9mM3d{`l z3d}Cuj1CM9>`X3exGZ-secW8E!cT#_-EX?4oU=1Q&QK$z?KQtFUrhZVE!Bim}WWnQXYfq2`kCfG!e8I*$azAFa_Vj*OEbQ_8p}sJK z-$Og$ Date: Sun, 8 Mar 2015 03:32:13 -0500 Subject: [PATCH 33/35] fixing a typo in the demo --- .../window_management/window_management.scn | Bin 5072 -> 5068 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/demos/misc/window_management/window_management.scn b/demos/misc/window_management/window_management.scn index 0cb7030ffc1164ffae0fbb6b719294118e7ffa56..9b963a0a15f5941d7632581cb655a9f6fd50175e 100644 GIT binary patch delta 826 zcmcbhenwq3DA?JV0R#jX7`jXt7!I;CFzB;0Fsxu=U=Y|SE6iDM&y<#5mcY);z+mF! zAnd@*T$Pqsv_ORMm$QR_gEMpseo;vyql1;hWk(MOMTfT*uiuL z0R&)}3}{62X*r%k<6Eqh98T25wqMv2p9#`wylLZ+IV z3Q1QP_!KuDwt31Jbm*3Ytbz?oVrfoEe1c=r&I7UxA_~^biMdIcN*@|zS>u!QbMlK4 z#F=N!l(aj*%)p?k;?U*1f}=PizdSy@C^O{&i>LGF1WBg+qD<9o4_Ks~9x+wrr7r%$ zeD=&4TQ3K1MqY*oj5C>wi_()4j2svoWFByQW~fN`%w*+On9%OV@Qgvj&5Nx#wWK67 zFa2n{^BxB`hp7z7&w~10<}H2h^4~GcVU`1fi^$~LTn;L&Ic}WHZlyUn?am9d7z!3B zF|11Mcf82prl!N35}aAp8mSsR*`8ZM{3*jeCf~%02P}#VCJPi9d>=3>GUTf|P0r^I zV4OMm0Jkb*>EvhJXPJXlc23^LW9qnufq@|;BePgRfr&jaPr);{ASc!R4@073Ca-Qt zYH^9KOKNUD7nf&=gObvIt`vome1(kEoC1Z+13D^YLJElrleKu2>R+(t7VB|wMQXl$ zz#zb=kfZQbp_ZjYp(G31J8(Z>W>9cTh;@*5V0O@VU^rmy zJkRlpgS3P817-%N6Ao(34&^S39~(N=DRSUG^qyIS*LmI2_h6733EuoSS@w(nStS#vx9)sB=(flw4BWJ zj1s38jPaETa!fTh6_Q>#O=3#RFH2x&W?(RJaxh}xQ{YrEVo5B`DTz-oPdaj#*+KSj z^Haux1F{Sv3f9btxk;JIk`30A1Gq%%vz;$;6ldg@$EO!%raWLtcY4oMm6y8U9P`;T zXKWqxT{si;nevM=RnI(NF?_)BilHLm8k3b^)VGgq#7#vqQFgSn$K;D6&Ve%6$ zQCId{L-jDN!iNNLA!_s7v5tNz2d4$yW$uPFKiH z)tJkiQf$SQRP5Bqkf*efshB}QVGjeB0w2Tw1q=#&2@DQ=j*>1m4h$|n4%|l~9Hbq% zA22g0xFy6oNINh)=sPeRuy&s7c-cYPLHhwSgVS*bCuWComxT}5tsSx*+&!K;xVz{& z@Vm@$Fn3+-!0-COf!*2ELEBBA;*E;A=<&3K}dn$f!%4A1H0Q{2X-gM$vk{g z+&K>IJ`E1+Cl$RLCL8kI Date: Sun, 8 Mar 2015 04:24:21 -0500 Subject: [PATCH 34/35] fix introduced bug --- platform/x11/os_x11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 8def564562..8196281732 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -1286,7 +1286,7 @@ void OS_X11::process_xevents() { motion_event.mouse_motion.x=pos.x; motion_event.mouse_motion.y=pos.y; input->set_mouse_pos(pos); - motion_event.mouse_motion.global_x=pos.y; + motion_event.mouse_motion.global_x=pos.x; motion_event.mouse_motion.global_y=pos.y; motion_event.mouse_motion.speed_x=input->get_mouse_speed().x; motion_event.mouse_motion.speed_y=input->get_mouse_speed().y; From f7621810a2f072a5d77563b6018023c575f355bf Mon Sep 17 00:00:00 2001 From: hurikhan Date: Sun, 8 Mar 2015 09:26:58 -0500 Subject: [PATCH 35/35] removed up, down, left, right keys from the demo. were used before for fast multiscreen setup testing. --- demos/misc/window_management/control.gd | 12 ------------ .../window_management/window_management.scn | Bin 5068 -> 5087 bytes 2 files changed, 12 deletions(-) diff --git a/demos/misc/window_management/control.gd b/demos/misc/window_management/control.gd index 7f805a1a21..bca13c5a0c 100644 --- a/demos/misc/window_management/control.gd +++ b/demos/misc/window_management/control.gd @@ -54,18 +54,6 @@ func _fixed_process(delta): get_node("Label_Screen1_Resolution").hide() get_node("Label_Screen1_Position").hide() - if( Input.is_action_pressed("ui_right")): - OS.set_screen(1) - - if( Input.is_action_pressed("ui_left")): - OS.set_screen(0) - - if( Input.is_action_pressed("ui_up")): - OS.set_fullscreen(true) - - if( Input.is_action_pressed("ui_down")): - OS.set_fullscreen(false) - get_node("Button_Fullscreen").set_pressed( OS.is_fullscreen() ) get_node("Button_FixedSize").set_pressed( !OS.is_resizable() ) get_node("Button_Minimized").set_pressed( OS.is_minimized() ) diff --git a/demos/misc/window_management/window_management.scn b/demos/misc/window_management/window_management.scn index 9b963a0a15f5941d7632581cb655a9f6fd50175e..b8b0ee210bd9249622682ba85d0ae7915e63b24f 100644 GIT binary patch delta 1148 zcmX@3eqUWSDA?JV0R#jX82U^Y7>=zX#+06#uMojd^nfvkL0ZA# z0fUG_IAdy&!U4wkd_}*>4UF?eiykoSeZVBa7GIKD5ucfo#Khp-lsMUh>AgK;YHEvR zgJ`lBb4q4$qVhC`l*A%WJ=_ne23YcDdomyRh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