summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/bind/core_bind.cpp12
-rw-r--r--core/bind/core_bind.h4
-rw-r--r--core/os/os.h9
-rw-r--r--main/main.cpp7
-rw-r--r--platform/x11/os_x11.cpp118
-rw-r--r--platform/x11/os_x11.h11
6 files changed, 128 insertions, 33 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 0c5d21b4f6..62d93745a0 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_enabled,int p_screen) {
+ OS::get_singleton()->set_fullscreen(p_enabled, p_screen);
+}
+
+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","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);
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..fedd03c3a9 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_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);
bool native_video_is_playing();
void native_video_pause();
diff --git a/core/os/os.h b/core/os/os.h
index d4deff2f5e..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;
@@ -149,6 +150,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<VideoMode> *p_list,int p_screen=0) const=0;
+
+ //MSC
+ 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);
virtual int get_iterations_per_second() const;
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 a40af8d2a9..5a05455918 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(800,600,false);
+ return OS::VideoMode(0,0,800,600,false);
}
int OS_X11::get_audio_driver_count() const {
@@ -162,6 +162,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();
@@ -181,33 +193,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
@@ -520,6 +507,81 @@ void OS_X11::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) cons
}
+void OS_X11::set_wm_border(bool p_enabled) {
+ // needed for lxde/openbox, possibly others
+ Hints hints;
+ Atom property;
+ hints.flags = 2;
+ 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);
+ 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) {
+ // 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] = 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) {
+
+ 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
+ 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 {
+ 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;
+
+ set_wm_fullscreen(false);
+ set_wm_border(true);
+ }
+
+ visual_server->init();
+}
+
+bool OS_X11::is_fullscreen() const {
+ return current_videomode.fullscreen;
+}
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..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<String> 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:
@@ -166,8 +169,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();
@@ -178,6 +181,7 @@ protected:
void process_joysticks();
void close_joystick(int p_id = -1);
+
public:
virtual String get_name();
@@ -213,6 +217,9 @@ public:
virtual VideoMode get_video_mode(int p_screen=0) const;
virtual void get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen=0) const;
+ virtual void set_fullscreen(bool p_enabled,int p_screen=0);
+ virtual bool is_fullscreen() const;
+
virtual void move_window_to_foreground();
void run();