introduced the scons experimental_wm_api switch:

================================================

Usage:
    scons p=x11 experimental_wm_api=yes
This commit is contained in:
hurikhan 2015-01-13 15:44:39 +08:00
parent 6b6c526048
commit c0d3632667
6 changed files with 50 additions and 3 deletions

View file

@ -176,6 +176,7 @@ bool _OS::is_video_mode_fullscreen(int p_screen) const {
} }
#ifdef EXPERIMENTAL_WM_API
int _OS::get_screen_count() const { int _OS::get_screen_count() const {
return OS::get_singleton()->get_screen_count(); 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 { bool _OS::is_fullscreen() const {
return OS::get_singleton()->is_fullscreen(); return OS::get_singleton()->is_fullscreen();
} }
#endif
void _OS::set_use_file_access_save_and_swap(bool p_enable) { 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("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_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_count"),&_OS::get_screen_count);
ObjectTypeDB::bind_method(_MD("get_screen_size"),&_OS::get_screen_size,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("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_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","screen"),&_OS::set_fullscreen,DEFVAL(0));
ObjectTypeDB::bind_method(_MD("is_fullscreen"),&_OS::is_fullscreen); 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("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("get_iterations_per_second"),&_OS::get_iterations_per_second);

View file

@ -108,6 +108,7 @@ public:
bool is_video_mode_resizable(int p_screen=0) const; bool is_video_mode_resizable(int p_screen=0) const;
Array get_fullscreen_mode_list(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 int get_screen_count() const;
virtual Size2 get_screen_size(int p_screen=0) const; virtual Size2 get_screen_size(int p_screen=0) const;
virtual Point2 get_window_position() const; virtual Point2 get_window_position() const;
@ -116,6 +117,7 @@ public:
virtual void set_window_size(const Size2& p_size); 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, int p_screen=0);
bool is_fullscreen() const; bool is_fullscreen() const;
#endif
Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track); Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
bool native_video_is_playing(); bool native_video_is_playing();

View file

@ -150,6 +150,7 @@ public:
virtual VideoMode get_video_mode(int p_screen=0) const=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; virtual void get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen=0) const=0;
#ifdef EXPERIMENTAL_WM_API
virtual int get_screen_count() const=0; virtual int get_screen_count() const=0;
virtual Size2 get_screen_size(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 Point2 get_window_position() const=0;
@ -158,6 +159,7 @@ public:
virtual void set_window_size(const Size2 p_size)=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,int p_screen=0)=0;
virtual bool is_fullscreen() const=0; virtual bool is_fullscreen() const=0;
#endif
virtual void set_iterations_per_second(int p_ips); virtual void set_iterations_per_second(int p_ips);
virtual int get_iterations_per_second() const; virtual int get_iterations_per_second() const;

View file

@ -47,6 +47,7 @@ def get_opts():
return [ return [
('use_llvm','Use llvm compiler','no'), ('use_llvm','Use llvm compiler','no'),
('use_sanitizer','Use llvm compiler sanitize address','no'), ('use_sanitizer','Use llvm compiler sanitize address','no'),
('experimental_wm_api', 'Use experimental window management API','no'),
] ]
def get_flags(): 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 = { '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') } ) #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'])

View file

@ -182,8 +182,38 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
// borderless fullscreen window mode // borderless fullscreen window mode
if (current_videomode.fullscreen) { 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_border(false);
set_wm_fullscreen(true); set_wm_fullscreen(true);
#endif
} }
// disable resizeable window // disable resizeable window
@ -496,6 +526,7 @@ void OS_X11::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) cons
} }
#ifdef EXPERIMENTAL_WM_API
void OS_X11::set_wm_border(bool p_enabled) { void OS_X11::set_wm_border(bool p_enabled) {
// needed for lxde/openbox, possibly others // needed for lxde/openbox, possibly others
Hints hints; Hints hints;
@ -639,6 +670,7 @@ void OS_X11::set_fullscreen(bool p_enabled,int p_screen) {
bool OS_X11::is_fullscreen() const { bool OS_X11::is_fullscreen() const {
return current_videomode.fullscreen; return current_videomode.fullscreen;
} }
#endif
InputModifierState OS_X11::get_key_modifier_state(unsigned int p_x11_state) { InputModifierState OS_X11::get_key_modifier_state(unsigned int p_x11_state) {

View file

@ -73,7 +73,6 @@ class OS_X11 : public OS_Unix {
Rasterizer *rasterizer; Rasterizer *rasterizer;
VisualServer *visual_server; VisualServer *visual_server;
VideoMode current_videomode; VideoMode current_videomode;
VideoMode pre_videomode;
List<String> args; List<String> args;
Window x11_window; Window x11_window;
MainLoop *main_loop; MainLoop *main_loop;
@ -160,8 +159,11 @@ class OS_X11 : public OS_Unix {
int joystick_count; int joystick_count;
Joystick joysticks[JOYSTICKS_MAX]; Joystick joysticks[JOYSTICKS_MAX];
#ifdef EXPERIMENTAL_WM_API
VideoMode pre_videomode;
void set_wm_border(bool p_enabled); void set_wm_border(bool p_enabled);
void set_wm_fullscreen(bool p_enabled); void set_wm_fullscreen(bool p_enabled);
#endif
protected: protected:
@ -217,6 +219,7 @@ public:
virtual VideoMode get_video_mode(int p_screen=0) const; 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 get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen=0) const;
#ifdef EXPERIMENTAL_WM_API
virtual int get_screen_count() const; virtual int get_screen_count() const;
virtual Size2 get_screen_size(int p_screen=0) const; virtual Size2 get_screen_size(int p_screen=0) const;
virtual Point2 get_window_position() const; virtual Point2 get_window_position() const;
@ -225,7 +228,7 @@ public:
virtual void set_window_size(const Size2 p_size); 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,int p_screen=0);
virtual bool is_fullscreen() const; virtual bool is_fullscreen() const;
#endif
virtual void move_window_to_foreground(); virtual void move_window_to_foreground();
void run(); void run();