summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/bind/core_bind.cpp6
-rw-r--r--core/bind/core_bind.h6
-rw-r--r--core/os/os.h6
-rw-r--r--platform/haiku/os_haiku.h4
-rw-r--r--platform/javascript/os_javascript.cpp2
-rw-r--r--platform/javascript/os_javascript.h2
-rw-r--r--platform/osx/os_osx.h6
-rw-r--r--platform/osx/os_osx.mm12
-rw-r--r--platform/windows/os_windows.cpp6
-rw-r--r--platform/windows/os_windows.h6
-rw-r--r--platform/x11/os_x11.cpp11
-rw-r--r--platform/x11/os_x11.h6
12 files changed, 47 insertions, 26 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index c69fe17049..5f534f63a8 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -978,9 +978,9 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_screen_count"), &_OS::get_screen_count);
ClassDB::bind_method(D_METHOD("get_current_screen"), &_OS::get_current_screen);
ClassDB::bind_method(D_METHOD("set_current_screen", "screen"), &_OS::set_current_screen);
- ClassDB::bind_method(D_METHOD("get_screen_position", "screen"), &_OS::get_screen_position, DEFVAL(0));
- ClassDB::bind_method(D_METHOD("get_screen_size", "screen"), &_OS::get_screen_size, DEFVAL(0));
- ClassDB::bind_method(D_METHOD("get_screen_dpi", "screen"), &_OS::get_screen_dpi, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("get_screen_position", "screen"), &_OS::get_screen_position, DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("get_screen_size", "screen"), &_OS::get_screen_size, DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("get_screen_dpi", "screen"), &_OS::get_screen_dpi, DEFVAL(-1));
ClassDB::bind_method(D_METHOD("get_window_position"), &_OS::get_window_position);
ClassDB::bind_method(D_METHOD("set_window_position", "position"), &_OS::set_window_position);
ClassDB::bind_method(D_METHOD("get_window_size"), &_OS::get_window_size);
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 41653c8846..fc280bd7ef 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -140,9 +140,9 @@ public:
virtual int get_screen_count() const;
virtual int get_current_screen() const;
virtual void set_current_screen(int p_screen);
- virtual Point2 get_screen_position(int p_screen = 0) const;
- virtual Size2 get_screen_size(int p_screen = 0) const;
- virtual int get_screen_dpi(int p_screen = 0) const;
+ virtual Point2 get_screen_position(int p_screen = -1) const;
+ virtual Size2 get_screen_size(int p_screen = -1) const;
+ virtual int get_screen_dpi(int p_screen = -1) const;
virtual Point2 get_window_position() const;
virtual void set_window_position(const Point2 &p_position);
virtual Size2 get_window_size() const;
diff --git a/core/os/os.h b/core/os/os.h
index 4d64e4a9f0..0fcf465655 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -164,9 +164,9 @@ public:
virtual int get_screen_count() const { return 1; }
virtual int get_current_screen() const { return 0; }
virtual void set_current_screen(int p_screen) {}
- virtual Point2 get_screen_position(int p_screen = 0) const { return Point2(); }
- virtual Size2 get_screen_size(int p_screen = 0) const { return get_window_size(); }
- virtual int get_screen_dpi(int p_screen = 0) const { return 72; }
+ virtual Point2 get_screen_position(int p_screen = -1) const { return Point2(); }
+ virtual Size2 get_screen_size(int p_screen = -1) const { return get_window_size(); }
+ virtual int get_screen_dpi(int p_screen = -1) const { return 72; }
virtual Point2 get_window_position() const { return Vector2(); }
virtual void set_window_position(const Point2 &p_position) {}
virtual Size2 get_window_size() const = 0;
diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h
index 256c9eecf7..4440f2843d 100644
--- a/platform/haiku/os_haiku.h
+++ b/platform/haiku/os_haiku.h
@@ -96,8 +96,8 @@ public:
virtual int get_screen_count() const;
virtual int get_current_screen() const;
virtual void set_current_screen(int p_screen);
- virtual Point2 get_screen_position(int p_screen = 0) const;
- virtual Size2 get_screen_size(int p_screen = 0) const;
+ virtual Point2 get_screen_position(int p_screen = -1) const;
+ virtual Size2 get_screen_size(int p_screen = -1) const;
virtual void set_window_title(const String &p_title);
virtual Size2 get_window_size() const;
virtual void set_window_size(const Size2 p_size);
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index d339baf024..f49acb04de 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -687,8 +687,6 @@ OS::VideoMode OS_JavaScript::get_video_mode(int p_screen) const {
Size2 OS_JavaScript::get_screen_size(int p_screen) const {
- ERR_FAIL_COND_V(p_screen != 0, Size2());
-
EmscriptenFullscreenChangeEvent ev;
EMSCRIPTEN_RESULT result = emscripten_get_fullscreen_status(&ev);
ERR_FAIL_COND_V(result != EMSCRIPTEN_RESULT_SUCCESS, Size2());
diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h
index 13c500b3dc..ff484204c7 100644
--- a/platform/javascript/os_javascript.h
+++ b/platform/javascript/os_javascript.h
@@ -124,7 +124,7 @@ public:
virtual VideoMode get_video_mode(int p_screen = 0) const;
virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const;
- virtual Size2 get_screen_size(int p_screen = 0) const;
+ virtual Size2 get_screen_size(int p_screen = -1) const;
virtual void set_window_size(const Size2);
virtual Size2 get_window_size() const;
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 56e6802eeb..827114cd2b 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -187,9 +187,9 @@ public:
virtual int get_screen_count() const;
virtual int get_current_screen() const;
virtual void set_current_screen(int p_screen);
- virtual Point2 get_screen_position(int p_screen = 0) const;
- virtual Size2 get_screen_size(int p_screen = 0) const;
- virtual int get_screen_dpi(int p_screen = 0) const;
+ virtual Point2 get_screen_position(int p_screen = -1) const;
+ virtual Size2 get_screen_size(int p_screen = -1) const;
+ virtual int get_screen_dpi(int p_screen = -1) const;
virtual Point2 get_window_position() const;
virtual void set_window_position(const Point2 &p_position);
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 34f1a93f3b..a0fc53d517 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -1433,6 +1433,10 @@ void OS_OSX::set_current_screen(int p_screen) {
};
Point2 OS_OSX::get_screen_position(int p_screen) const {
+ if (p_screen == -1) {
+ p_screen = get_current_screen();
+ }
+
NSArray *screenArray = [NSScreen screens];
if (p_screen < [screenArray count]) {
float displayScale = 1.0;
@@ -1449,6 +1453,10 @@ Point2 OS_OSX::get_screen_position(int p_screen) const {
}
int OS_OSX::get_screen_dpi(int p_screen) const {
+ if (p_screen == -1) {
+ p_screen = get_current_screen();
+ }
+
NSArray *screenArray = [NSScreen screens];
if (p_screen < [screenArray count]) {
float displayScale = 1.0;
@@ -1469,6 +1477,10 @@ int OS_OSX::get_screen_dpi(int p_screen) const {
}
Size2 OS_OSX::get_screen_size(int p_screen) const {
+ if (p_screen == -1) {
+ p_screen = get_current_screen();
+ }
+
NSArray *screenArray = [NSScreen screens];
if (p_screen < [screenArray count]) {
float displayScale = 1.0;
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 2e908b82ab..db453a5f46 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -1384,7 +1384,7 @@ static BOOL CALLBACK _MonitorEnumProcPos(HMONITOR hMonitor, HDC hdcMonitor, LPRE
Point2 OS_Windows::get_screen_position(int p_screen) const {
- EnumPosData data = { 0, p_screen, Point2() };
+ EnumPosData data = { 0, p_screen == -1 ? get_current_screen() : p_screen, Point2() };
EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcPos, (LPARAM)&data);
return data.pos;
}
@@ -1409,7 +1409,7 @@ static BOOL CALLBACK _MonitorEnumProcSize(HMONITOR hMonitor, HDC hdcMonitor, LPR
Size2 OS_Windows::get_screen_size(int p_screen) const {
- EnumSizeData data = { 0, p_screen, Size2() };
+ EnumSizeData data = { 0, p_screen == -1 ? get_current_screen() : p_screen, Size2() };
EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcSize, (LPARAM)&data);
return data.size;
}
@@ -1433,7 +1433,7 @@ static BOOL CALLBACK _MonitorEnumProcDpi(HMONITOR hMonitor, HDC hdcMonitor, LPRE
int OS_Windows::get_screen_dpi(int p_screen) const {
- EnumDpiData data = { 0, p_screen, 72 };
+ EnumDpiData data = { 0, p_screen == -1 ? get_current_screen() : p_screen, 72 };
EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcDpi, (LPARAM)&data);
return data.dpi;
}
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index e9af14f11c..deb1ae0982 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -194,9 +194,9 @@ public:
virtual int get_screen_count() const;
virtual int get_current_screen() const;
virtual void set_current_screen(int p_screen);
- virtual Point2 get_screen_position(int p_screen = 0) const;
- virtual Size2 get_screen_size(int p_screen = 0) const;
- virtual int get_screen_dpi(int p_screen = 0) const;
+ virtual Point2 get_screen_position(int p_screen = -1) const;
+ virtual Size2 get_screen_size(int p_screen = -1) const;
+ virtual int get_screen_dpi(int p_screen = -1) const;
virtual Point2 get_window_position() const;
virtual void set_window_position(const Point2 &p_position);
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 8b4253c72c..dbc3914410 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -761,6 +761,10 @@ void OS_X11::set_current_screen(int p_screen) {
}
Point2 OS_X11::get_screen_position(int p_screen) const {
+ if (p_screen == -1) {
+ p_screen = get_current_screen();
+ }
+
// Using Xinerama Extension
int event_base, error_base;
const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base);
@@ -782,6 +786,10 @@ Point2 OS_X11::get_screen_position(int p_screen) const {
}
Size2 OS_X11::get_screen_size(int p_screen) const {
+ if (p_screen == -1) {
+ p_screen = get_current_screen();
+ }
+
// Using Xinerama Extension
int event_base, error_base;
const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base);
@@ -797,6 +805,9 @@ Size2 OS_X11::get_screen_size(int p_screen) const {
}
int OS_X11::get_screen_dpi(int p_screen) const {
+ if (p_screen == -1) {
+ p_screen = get_current_screen();
+ }
//invalid screen?
ERR_FAIL_INDEX_V(p_screen, get_screen_count(), 0);
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index db70f8f84a..497ce1dde2 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -233,9 +233,9 @@ public:
virtual int get_screen_count() const;
virtual int get_current_screen() const;
virtual void set_current_screen(int p_screen);
- virtual Point2 get_screen_position(int p_screen = 0) const;
- virtual Size2 get_screen_size(int p_screen = 0) const;
- virtual int get_screen_dpi(int p_screen = 0) const;
+ virtual Point2 get_screen_position(int p_screen = -1) const;
+ virtual Size2 get_screen_size(int p_screen = -1) const;
+ virtual int get_screen_dpi(int p_screen = -1) const;
virtual Point2 get_window_position() const;
virtual void set_window_position(const Point2 &p_position);
virtual Size2 get_window_size() const;