Преглед на файлове

introduced the scons experimental_wm_api switch:
================================================

Usage:
scons p=x11 experimental_wm_api=yes

hurikhan преди 10 години
родител
ревизия
c0d3632667
променени са 6 файла, в които са добавени 50 реда и са изтрити 3 реда
  1. 4 0
      core/bind/core_bind.cpp
  2. 2 0
      core/bind/core_bind.h
  3. 3 1
      core/os/os.h
  4. 4 0
      platform/x11/detect.py
  5. 32 0
      platform/x11/os_x11.cpp
  6. 5 2
      platform/x11/os_x11.h

+ 4 - 0
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);

+ 2 - 0
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();

+ 3 - 1
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<VideoMode> *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;
 

+ 4 - 0
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'])
+

+ 32 - 0
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<VideoMode> *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) {
 	

+ 5 - 2
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<String> 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<VideoMode> *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();