mikymod 12 سال پیش
والد
کامیت
fc29393213
3فایلهای تغییر یافته به همراه20 افزوده شده و 27 حذف شده
  1. 14 19
      engine/os/linux/OsWindow.cpp
  2. 2 4
      engine/os/linux/OsWindow.h
  3. 4 4
      engine/os/linux/main.cpp

+ 14 - 19
engine/os/linux/OsWindow.cpp

@@ -42,21 +42,12 @@ void oswindow_set_window(Display* dpy, Window win)
 
 //-----------------------------------------------------------------------------
 OsWindow::OsWindow()
-	: m_x(0)
-	, m_y(0)
-	, m_width(0)
-	, m_height(0)
-	, m_resizable(true)
+	: m_resizable(true)
 	, m_x11_detectable_autorepeat(false)
 {
 	set_title("");
 
-	XWindowAttributes win_attr;
-
-	XGetWindowAttributes(m_x11_display, m_x11_window, &win_attr);
-	
-	m_width = win_attr.width;
-	m_height = win_attr.height;
+	XGetWindowAttributes(m_x11_display, m_x11_window, &m_win_attr);
 }
 
 //-----------------------------------------------------------------------------
@@ -79,15 +70,19 @@ void OsWindow::hide()
 //-----------------------------------------------------------------------------
 void OsWindow::get_size(uint32_t& width, uint32_t& height)
 {
-	width = m_width;
-	height = m_height;
+	XGetWindowAttributes(m_x11_display, m_x11_window, &m_win_attr);
+
+	width = m_win_attr.width;
+	height = m_win_attr.height;
 }
 
 //-----------------------------------------------------------------------------
 void OsWindow::get_position(uint32_t& x, uint32_t& y)
 {
-	x = m_x;
-	y = m_y;
+	XGetWindowAttributes(m_x11_display, m_x11_window, &m_win_attr);
+
+	x = m_win_attr.x;
+	y = m_win_attr.y;
 }
 
 //-----------------------------------------------------------------------------
@@ -125,10 +120,10 @@ 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;
+	hints.min_width = resizable ? 1 : m_win_attr.width;
+	hints.min_height = resizable ? 1 : m_win_attr.height;
+	hints.max_width = resizable ? 65535 : m_win_attr.width;
+	hints.max_height = resizable ? 65535 : m_win_attr.height;
 
 	XSetWMNormalHints(m_x11_display, m_x11_window, &hints);
 

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

@@ -70,10 +70,8 @@ public:
 
 public:
 
-	uint32_t		m_x;
-	uint32_t		m_y;
-	uint32_t		m_width;
-	uint32_t		m_height;
+	XWindowAttributes m_win_attr;
+
 	bool			m_resizable;
 
 	bool			m_x11_detectable_autorepeat;

+ 4 - 4
engine/os/linux/main.cpp

@@ -325,10 +325,10 @@ public:
 				{
 					const OsMetricsEvent& ev = event.metrics;
 					m_mouse->set_metrics(ev.width, ev.height);
-					m_window->m_x = ev.x;
-					m_window->m_y = ev.y;
-					m_window->m_width = ev.width;
-					m_window->m_height = ev.height;
+					m_window->m_win_attr.x = ev.x;
+					m_window->m_win_attr.y = ev.y;
+					m_window->m_win_attr.width = ev.width;
+					m_window->m_win_attr.height = ev.height;
 					break;
 				}
 				case OsEvent::EXIT: