Ver Fonte

unstub linux OsWindow

mikymod há 12 anos atrás
pai
commit
cff82720e9
3 ficheiros alterados com 48 adições e 76 exclusões
  1. 42 72
      engine/os/linux/OsWindow.cpp
  2. 5 4
      engine/os/linux/OsWindow.h
  3. 1 0
      engine/os/linux/main.cpp

+ 42 - 72
engine/os/linux/OsWindow.cpp

@@ -30,20 +30,25 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 namespace crown
 {
 {
 
 
-//-----------------------------------------------------------------------------
-OsWindow::OsWindow(uint32_t , uint32_t , uint32_t )
-	// m_x11_display(NULL),
-	// m_x11_window(None),
-	// m_x11_parent_window(None),
-	// m_x(0),
-	// m_y(0),
-	// m_width(width),
-	// m_height(height),
-	// m_resizable(true),
-	// m_x11_detectable_autorepeat(false),
-	// m_x11_hidden_cursor(None)
+Display* m_x11_display = NULL;
+Window m_x11_window = None;
+
+void oswindow_set_window(Display* dpy, Window win)
 {
 {
+	m_x11_display = dpy;
+	m_x11_window = win;	
+}
 
 
+//-----------------------------------------------------------------------------
+OsWindow::OsWindow()
+	: m_x(0)
+	, m_y(0)
+	, m_width(0)
+	, m_height(0)
+	, m_resizable(true)
+	, m_x11_detectable_autorepeat(false)
+{
+	set_title("");
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
@@ -54,13 +59,13 @@ OsWindow::~OsWindow()
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 void OsWindow::show()
 void OsWindow::show()
 {
 {
-	// XMapRaised(m_x11_display, m_x11_window);
+	XMapRaised(m_x11_display, m_x11_window);
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 void OsWindow::hide()
 void OsWindow::hide()
 {
 {
-	//XUnmapWindow(m_x11_display, m_x11_window);
+	XUnmapWindow(m_x11_display, m_x11_window);
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
@@ -78,27 +83,27 @@ void OsWindow::get_position(uint32_t& x, uint32_t& y)
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-void OsWindow::resize(uint32_t , uint32_t )
+void OsWindow::resize(uint32_t width, uint32_t height)
 {
 {
-	//XResizeWindow(m_x11_display, m_x11_window, width, height);
+	XResizeWindow(m_x11_display, m_x11_window, width, height);
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-void OsWindow::move(uint32_t , uint32_t )
+void OsWindow::move(uint32_t x, uint32_t y)
 {
 {
-	//XMoveWindow(m_x11_display, m_x11_window, x, y);
+	XMoveWindow(m_x11_display, m_x11_window, x, y);
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 void OsWindow::minimize()
 void OsWindow::minimize()
 {
 {
-	//XIconifyWindow(m_x11_display, m_x11_window, DefaultScreen(m_x11_display));
+	XIconifyWindow(m_x11_display, m_x11_window, DefaultScreen(m_x11_display));
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 void OsWindow::restore()
 void OsWindow::restore()
 {
 {
-	//XMapRaised(m_x11_display, m_x11_window);
+	XMapRaised(m_x11_display, m_x11_window);
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
@@ -108,73 +113,38 @@ bool OsWindow::is_resizable() const
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-void OsWindow::set_resizable(bool )
+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;
+	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(bool )
-{
-	// if (show)
-	// {
-	// 	XDefineCursor(m_x11_display, m_x11_window, None);
-	// }
-	// else
-	// {
-	// 	XDefineCursor(m_x11_display, m_x11_window, m_x11_hidden_cursor);
-	// }
-}
-
-//-----------------------------------------------------------------------------
-void OsWindow::get_cursor_xy(int32_t& , int32_t& )
-{
-	// Window unused;
-	// int32_t pointer_x, pointer_y, dummy;
-	// uint32_t dummy2;
-
-	// XQueryPointer(m_x11_display, m_x11_window, &unused, &unused, &dummy, &dummy, &pointer_x, &pointer_y, &dummy2);
-
-	// x = pointer_x;
-	// y = pointer_y;
-}
-
-//-----------------------------------------------------------------------------
-void OsWindow::set_cursor_xy(int32_t , int32_t )
-{
-	// XWarpPointer(m_x11_display, None, m_x11_window, 0, 0, m_width, m_height, x, y);
+	XSetWMNormalHints(m_x11_display, m_x11_window, &hints);
 
 
-	// XFlush(m_x11_display);
+	m_resizable = resizable;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 char* OsWindow::title()
 char* OsWindow::title()
 {
 {
-	// static char title[1024];
+	static char title[1024];
 
 
-	// char* tmp_title;
-	// XFetchName(m_x11_display, m_x11_window, &tmp_title);
+	char* tmp_title;
+	XFetchName(m_x11_display, m_x11_window, &tmp_title);
 
 
-	// string::strncpy(title, tmp_title, 1024);
-	// XFree(tmp_title);
+	string::strncpy(title, tmp_title, 1024);
+	XFree(tmp_title);
 
 
-	// return title;
-	return NULL;
+	return title;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-void OsWindow::set_title(const char* )
+void OsWindow::set_title(const char* title)
 {
 {
-	// XStoreName(m_x11_display, m_x11_window, title);
+	XStoreName(m_x11_display, m_x11_window, title);
 }
 }
 
 
 } // namespace crown
 } // namespace crown

+ 5 - 4
engine/os/linux/OsWindow.h

@@ -36,6 +36,9 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 namespace crown
 {
 {
 
 
+void oswindow_set_window(Display* dpy, Window win);
+
+
 class OsWindow
 class OsWindow
 {
 {
 public:
 public:
@@ -43,9 +46,9 @@ public:
 	/// Creates the window with the given @a width and @a height.
 	/// Creates the window with the given @a width and @a height.
 	/// When @a parent is != 0, it is interpreted as the OS-specific
 	/// When @a parent is != 0, it is interpreted as the OS-specific
 	/// handle of the parent window.
 	/// handle of the parent window.
-					OsWindow(uint32_t width, uint32_t height, uint32_t parent);
+					OsWindow();
 					~OsWindow();
 					~OsWindow();
-
+					
 	void			show();
 	void			show();
 	void			hide();
 	void			hide();
 
 
@@ -71,8 +74,6 @@ public:
 
 
 private:
 private:
 
 
-
-
 	uint32_t		m_x;
 	uint32_t		m_x;
 	uint32_t		m_y;
 	uint32_t		m_y;
 	uint32_t		m_width;
 	uint32_t		m_width;

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

@@ -240,6 +240,7 @@ public:
 
 
 		XMapRaised(m_x11_display, m_x11_window);
 		XMapRaised(m_x11_display, m_x11_window);
 
 
+		oswindow_set_window(m_x11_display, m_x11_window);
 		set_x11_display_and_window(m_x11_display, m_x11_window);
 		set_x11_display_and_window(m_x11_display, m_x11_window);
 
 
 		OsThread game_thread("game-thread");
 		OsThread game_thread("game-thread");