Daniele Bartolini 11 лет назад
Родитель
Сommit
65d130b70b

+ 3 - 0
engine/Device.h

@@ -133,6 +133,9 @@ public:
 	/// @note See video_modes().
 	virtual void set_display_mode(uint32_t id) = 0;
 
+	/// Sets whether in fullscreen or not.
+	virtual void set_fullscreen(bool full) = 0;
+
 	/// Updates all the subsystems
 	void frame();
 

+ 8 - 0
engine/lua/LuaDevice.cpp

@@ -191,6 +191,13 @@ static int device_set_display_mode(lua_State* L)
 	return 0;
 }
 
+//-----------------------------------------------------------------------------
+static int device_set_fullscreen(lua_State* L)
+{
+	LuaStack stack(L);
+	device()->set_fullscreen(stack.get_bool(1));
+	return 0;
+}
 
 //-----------------------------------------------------------------------------
 void load_device(LuaEnvironment& env)
@@ -208,6 +215,7 @@ void load_device(LuaEnvironment& env)
 	env.load_module_function("Device", "destroy_resource_package", device_destroy_resource_package);
 	env.load_module_function("Device", "display_modes",            device_display_modes);
 	env.load_module_function("Device", "set_display_mode",         device_set_display_mode);
+	env.load_module_function("Device", "set_fullscreen",           device_set_fullscreen);
 }
 
 } // namespace crown

+ 6 - 0
engine/os/android/AndroidDevice.cpp

@@ -61,6 +61,12 @@ public:
 		// Do nothing
 	}
 
+	//-----------------------------------------------------------------------------
+	void set_fullscreen(bool /*full*/)
+	{
+		// Do nothing
+	}
+
 	//-----------------------------------------------------------------------------
 	int32_t run(int, char**)
 	{

+ 14 - 0
engine/os/linux/main.cpp

@@ -223,6 +223,20 @@ public:
 							CurrentTime);
 	}
 
+	//-----------------------------------------------------------------------------
+	void set_fullscreen(bool full)
+	{
+		XEvent e;
+		e.xclient.type = ClientMessage;
+		e.xclient.window = m_x11_window;
+		e.xclient.message_type = XInternAtom(m_x11_display, "_NET_WM_STATE", False );
+		e.xclient.format = 32;
+		e.xclient.data.l[0] = full ? 1 : 0;
+		e.xclient.data.l[1] = XInternAtom(m_x11_display, "_NET_WM_STATE_FULLSCREEN", False);
+
+		XSendEvent(m_x11_display, DefaultRootWindow(m_x11_display), False, SubstructureNotifyMask, &e);
+	}
+
 	//-----------------------------------------------------------------------------
 	int32_t run(int argc, char** argv)
 	{

+ 6 - 0
engine/os/win/main.cpp

@@ -197,6 +197,12 @@ public:
 		#error "Implement me"
 	}
 
+	//-----------------------------------------------------------------------------
+	void set_fullscreen(bool full)
+	{
+		#error "Implement me"
+	}
+
 	//-----------------------------------------------------------------------------
 	int32_t	run(int argc, char** argv)
 	{