소스 검색

Add is_resizable(), set_resizable(), minimize() and restore() to Linux and Android OsWindow implementations

Daniele Bartolini 12 년 전
부모
커밋
c08992e9a4
5개의 변경된 파일112개의 추가작업 그리고 0개의 파일을 삭제
  1. 38 0
      engine/lua/LuaWindow.cpp
  2. 21 0
      engine/os/android/OsWindow.cpp
  3. 12 0
      engine/os/android/OsWindow.h
  4. 34 0
      engine/os/linux/OsWindow.cpp
  5. 7 0
      engine/os/linux/OsWindow.h

+ 38 - 0
engine/lua/LuaWindow.cpp

@@ -108,6 +108,40 @@ CE_EXPORT int window_move(lua_State* L)
 	return 0;
 }
 
+//-----------------------------------------------------------------------------
+CE_EXPORT int window_minimize(lua_State* /*L*/)
+{
+	device()->window()->minimize();
+	return 0;
+}
+
+//-----------------------------------------------------------------------------
+CE_EXPORT int window_restore(lua_State* /*L*/)
+{
+	device()->window()->restore();
+	return 0;
+}
+
+//-----------------------------------------------------------------------------
+CE_EXPORT int window_is_resizable(lua_State* L)
+{
+	LuaStack stack(L);
+
+	stack.push_bool(device()->window()->is_resizable());
+
+	return 1;
+}
+
+//-----------------------------------------------------------------------------
+CE_EXPORT int window_set_resizable(lua_State* L)
+{
+	LuaStack stack(L);
+
+	device()->window()->set_resizable(stack.get_bool(1));
+
+	return 0;
+}
+
 //-----------------------------------------------------------------------------
 CE_EXPORT int window_show_cursor(lua_State* L)
 {
@@ -189,6 +223,10 @@ void load_window(LuaEnvironment& env)
 	env.load_module_function("Window", "get_position",	window_get_position);
 	env.load_module_function("Window", "resize",		window_resize);
 	env.load_module_function("Window", "move",			window_move);
+	env.load_module_function("Window", "minimize",		window_minimize);
+	env.load_module_function("Window", "restore",		window_restore);
+	env.load_module_function("Window", "is_resizable",	window_is_resizable);
+	env.load_module_function("Window", "set_resizable",	window_set_resizable);
 	env.load_module_function("Window", "show_cursor",	window_show_cursor);
 	env.load_module_function("Window", "hide_cursor",	window_hide_cursor);
 	env.load_module_function("Window", "get_cursor_xy",	window_get_cursor_xy);

+ 21 - 0
engine/os/android/OsWindow.cpp

@@ -85,6 +85,27 @@ void OsWindow::move(uint32_t /*x*/, uint32_t /*y*/)
 {
 }
 
+//-----------------------------------------------------------------------------
+void OsWindow::minimize()
+{
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::restore()
+{
+}
+
+//-----------------------------------------------------------------------------
+bool OsWindow::is_resizable() const
+{
+	return false;
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::set_resizable(bool /*resizeable*/)
+{
+}
+
 //-----------------------------------------------------------------------------
 void OsWindow::show_cursor()
 {

+ 12 - 0
engine/os/android/OsWindow.h

@@ -59,6 +59,18 @@ public:
 	/// Stub method, does nothing under Android.
 	void			move(uint32_t x, uint32_t y);
 
+	/// Stub method, does nothing under Android.	
+	void			minimize();
+
+	/// Stub method, does nothing under Android.
+	void			restore();
+
+	/// Returns always false.
+	bool			is_resizable() const;
+
+	/// Stub method, does nothing under Android.	
+	void			set_resizable(bool resizeable);
+
 	/// Stub method, does nothing under Android.
 	void			show_cursor();
 

+ 34 - 0
engine/os/linux/OsWindow.cpp

@@ -100,6 +100,7 @@ OsWindow::OsWindow(uint32_t width, uint32_t height, uint32_t parent) :
 	m_y(0),
 	m_width(width),
 	m_height(height),
+	m_resizable(true),
 	m_x11_detectable_autorepeat(false),
 	m_x11_hidden_cursor(None)
 {
@@ -214,6 +215,39 @@ void OsWindow::move(uint32_t x, uint32_t y)
 	XMoveWindow(m_x11_display, m_x11_window, x, y);
 }
 
+//-----------------------------------------------------------------------------
+void OsWindow::minimize()
+{
+	XIconifyWindow(m_x11_display, m_x11_window, DefaultScreen(m_x11_display));
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::restore()
+{
+	XMapRaised(m_x11_display, m_x11_window);
+}
+
+//-----------------------------------------------------------------------------
+bool OsWindow::is_resizable() const
+{
+	return m_resizable;
+}
+
+//-----------------------------------------------------------------------------
+void OsWindow::set_resizable(bool resizable)
+{
+	XSizeHints hints;
+	hints.flags = PMinSize | PMaxSize;
+	hints.min_width = resizable ? 1 : m_width;
+	hints.min_height = resizable ? 1 : m_height;
+	hints.max_width = resizable ? 65535 : m_width;
+	hints.max_height = resizable ? 65535 : m_height;
+
+	XSetWMNormalHints(m_x11_display, m_x11_window, &hints);
+
+	m_resizable = resizable;
+}
+
 //-----------------------------------------------------------------------------
 void OsWindow::show_cursor()
 {

+ 7 - 0
engine/os/linux/OsWindow.h

@@ -54,6 +54,12 @@ public:
 	void			resize(uint32_t width, uint32_t height);
 	void			move(uint32_t x, uint32_t y);
 
+	void			minimize();
+	void			restore();
+
+	bool			is_resizable() const;
+	void			set_resizable(bool resizable);
+
 	void			show_cursor();
 	void			hide_cursor();
 
@@ -75,6 +81,7 @@ private:
 	uint32_t		m_y;
 	uint32_t		m_width;
 	uint32_t		m_height;
+	bool			m_resizable;
 
 	bool			m_x11_detectable_autorepeat;
 	Cursor			m_x11_hidden_cursor;