summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhurikhan <m4r10.5ch14ck@gmail.com>2015-01-13 17:25:50 +0800
committerhurikhan <m4r10.5ch14ck@gmail.com>2015-01-13 17:25:50 +0800
commitce7c7a862ebe37fada7708c342c07d70fa80465a (patch)
treec2cf4799ae9cf9351b1e4f7d15249ddbf4dbd95d
parent1445b6806b8a359594b1789726aa87d64b279286 (diff)
get_screen_position() added
-rw-r--r--core/bind/core_bind.cpp5
-rw-r--r--core/bind/core_bind.h1
-rw-r--r--core/os/os.h1
-rw-r--r--demos/misc/window_management/control.gd11
-rw-r--r--demos/misc/window_management/window_management.scnbin3276 -> 3582 bytes
-rw-r--r--platform/x11/os_x11.cpp12
-rw-r--r--platform/x11/os_x11.h1
7 files changed, 28 insertions, 3 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index b8fc63dc43..a2aca7e11f 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -181,6 +181,10 @@ int _OS::get_screen_count() const {
return OS::get_singleton()->get_screen_count();
}
+Point2 _OS::get_screen_position(int p_screen) const {
+ return OS::get_singleton()->get_screen_position(p_screen);
+}
+
Size2 _OS::get_screen_size(int p_screen) const {
return OS::get_singleton()->get_screen_size(p_screen);
}
@@ -668,6 +672,7 @@ void _OS::_bind_methods() {
#ifdef EXPERIMENTAL_WM_API
ObjectTypeDB::bind_method(_MD("get_screen_count"),&_OS::get_screen_count);
+ ObjectTypeDB::bind_method(_MD("get_screen_position"),&_OS::get_screen_position,DEFVAL(0));
ObjectTypeDB::bind_method(_MD("get_screen_size"),&_OS::get_screen_size,DEFVAL(0));
ObjectTypeDB::bind_method(_MD("get_window_position"),&_OS::get_window_position);
ObjectTypeDB::bind_method(_MD("set_window_position"),&_OS::set_window_position);
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 62f9913556..9d9f25691e 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -110,6 +110,7 @@ public:
#ifdef EXPERIMENTAL_WM_API
virtual int get_screen_count() const;
+ virtual Point2 get_screen_position(int p_screen=0) const;
virtual Size2 get_screen_size(int p_screen=0) const;
virtual Point2 get_window_position() const;
virtual void set_window_position(const Point2& p_position);
diff --git a/core/os/os.h b/core/os/os.h
index c2534287bc..1ef05e45c8 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -152,6 +152,7 @@ public:
#ifdef EXPERIMENTAL_WM_API
virtual int get_screen_count() const=0;
+ virtual Point2 get_screen_position(int p_screen=0) const=0;
virtual Size2 get_screen_size(int p_screen=0) const=0;
virtual Point2 get_window_position() const=0;
virtual void set_window_position(const Point2& p_position)=0;
diff --git a/demos/misc/window_management/control.gd b/demos/misc/window_management/control.gd
index 3e74f24e42..ad15a74731 100644
--- a/demos/misc/window_management/control.gd
+++ b/demos/misc/window_management/control.gd
@@ -15,11 +15,16 @@ func _fixed_process(delta):
get_node("Label_Screen0_Resolution").set_text( str("Screen0 Resolution:\n", OS.get_screen_size() ) )
+ get_node("Label_Screen0_Position").set_text(str("Screen0 Position:\n",OS.get_screen_position()))
+
if(OS.get_screen_count() > 1):
get_node("Label_Screen1_Resolution").show()
- get_node("Label_Screen1_Resolution").set_text( str("Screen0 Resolution:\n", OS.get_screen_size(1) ) )
-
-
+ get_node("Label_Screen1_Resolution").set_text( str("Screen1 Resolution:\n", OS.get_screen_size(1) ) )
+ get_node("Label_Screen1_Position").show()
+ get_node("Label_Screen1_Position").set_text( str("Screen1 Position:\n", OS.get_screen_size(1) ) )
+ else:
+ get_node("Label_Screen1_Resolution").hide()
+ get_node("Label_Screen1_Position").hide()
func _ready():
set_fixed_process(true)
diff --git a/demos/misc/window_management/window_management.scn b/demos/misc/window_management/window_management.scn
index 6eaf62ff9f..3a6426f3ee 100644
--- a/demos/misc/window_management/window_management.scn
+++ b/demos/misc/window_management/window_management.scn
Binary files differ
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index e20d0731e1..01d62f333d 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -561,7 +561,19 @@ int OS_X11::get_screen_count() const {
return XScreenCount(x11_display);
}
+Point2 OS_X11::get_screen_position(int p_screen) const {
+ if( p_screen >= XScreenCount(x11_display) )
+ return Point2i(0,0);
+
+ Window root = XRootWindow(x11_display, p_screen);
+ XWindowAttributes xwa;
+ XGetWindowAttributes(x11_display, root, &xwa);
+ return Point2i(xwa.x, xwa.y);
+}
+
Size2 OS_X11::get_screen_size(int p_screen) const {
+ if( p_screen >= XScreenCount(x11_display) )
+ return Size2i(0,0);
Window root = XRootWindow(x11_display, p_screen);
XWindowAttributes xwa;
XGetWindowAttributes(x11_display, root, &xwa);
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index 4aca996fdc..ca35bf2c0a 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -221,6 +221,7 @@ public:
#ifdef EXPERIMENTAL_WM_API
virtual int get_screen_count() const;
+ virtual Point2 get_screen_position(int p_screen=0) const;
virtual Size2 get_screen_size(int p_screen=0) const;
virtual Point2 get_window_position() const;
virtual void set_window_position(const Point2& p_position);