summaryrefslogtreecommitdiff
path: root/platform/windows
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2020-03-19 23:32:09 -0300
committerJuan Linietsky <reduzio@gmail.com>2020-03-26 15:49:44 +0100
commitb3080bc2f4d7bc5c15b3a0ff7b67690c4677577e (patch)
tree0487e2d739133015048b1e0dd1fd9abaf7bbb18a /platform/windows
parent09ba290364aaa5b54528e82144ec0a40e10b497b (diff)
Popups have also been converted to windows
Controls using the old modal API have been replaced to use popups.
Diffstat (limited to 'platform/windows')
-rw-r--r--platform/windows/display_server_windows.cpp44
-rw-r--r--platform/windows/display_server_windows.h1
2 files changed, 42 insertions, 3 deletions
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp
index 9696e71630..3f0c565277 100644
--- a/platform/windows/display_server_windows.cpp
+++ b/platform/windows/display_server_windows.cpp
@@ -125,7 +125,10 @@ void DisplayServerWindows::mouse_warp_to_position(const Point2i &p_to) {
}
}
Point2i DisplayServerWindows::mouse_get_position() const {
- return Point2(old_x, old_y);
+ POINT p;
+ GetCursorPos(&p);
+ return Point2i(p.x, p.y);
+ //return Point2(old_x, old_y);
}
int DisplayServerWindows::mouse_get_button_state() const {
return last_button_state;
@@ -280,6 +283,12 @@ typedef struct {
Size2 size;
} EnumSizeData;
+typedef struct {
+ int count;
+ int screen;
+ Rect2i rect;
+} EnumRectData;
+
static BOOL CALLBACK _MonitorEnumProcSize(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
EnumSizeData *data = (EnumSizeData *)dwData;
@@ -301,6 +310,34 @@ Size2i DisplayServerWindows::screen_get_size(int p_screen) const {
return data.size;
}
+static BOOL CALLBACK _MonitorEnumProcUsableSize(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
+
+ EnumRectData *data = (EnumRectData *)dwData;
+ if (data->count == data->screen) {
+ MONITORINFO minfo;
+ zeromem(&minfo, sizeof(MONITORINFO));
+ minfo.cbSize = sizeof(MONITORINFO);
+ GetMonitorInfoA(hMonitor, &minfo);
+
+ data->rect.position.x = minfo.rcWork.left;
+ data->rect.position.y = minfo.rcWork.top;
+ data->rect.size.x = minfo.rcWork.right - minfo.rcWork.left;
+ data->rect.size.y = minfo.rcWork.bottom - minfo.rcWork.top;
+ }
+
+ data->count++;
+ return TRUE;
+}
+
+Rect2i DisplayServerWindows::screen_get_usable_rect(int p_screen) const {
+
+ _THREAD_SAFE_METHOD_
+
+ EnumRectData data = { 0, p_screen == SCREEN_OF_MAIN_WINDOW ? window_get_current_screen() : p_screen, Rect2i() };
+ EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcUsableSize, (LPARAM)&data);
+ return data.rect;
+}
+
typedef struct {
int count;
int screen;
@@ -691,6 +728,7 @@ void DisplayServerWindows::window_set_size(const Size2i p_size, WindowID p_windo
wd.width = w;
wd.height = h;
+
#if defined(VULKAN_ENABLED)
if (rendering_driver == "vulkan") {
context_vulkan->window_resize(p_window, w, h);
@@ -2232,8 +2270,8 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
case WM_MOVE: {
if (!IsIconic(windows[window_id].hWnd)) {
- int x = LOWORD(lParam);
- int y = HIWORD(lParam);
+ int x = int16_t(LOWORD(lParam));
+ int y = int16_t(HIWORD(lParam));
windows[window_id].last_pos = Point2(x, y);
if (!windows[window_id].rect_changed_callback.is_null()) {
diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h
index 70878ae0dc..b300ae74b5 100644
--- a/platform/windows/display_server_windows.h
+++ b/platform/windows/display_server_windows.h
@@ -280,6 +280,7 @@ public:
virtual int get_screen_count() const;
virtual Point2i screen_get_position(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
virtual Size2i screen_get_size(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
+ virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const;
virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const;