Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the situation of Drag-and-Drop on X11 #40096

Merged
merged 1 commit into from
Jul 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion platform/linuxbsd/display_server_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,18 @@ void DisplayServerX11::mouse_warp_to_position(const Point2i &p_to) {
}

Point2i DisplayServerX11::mouse_get_position() const {
return last_mouse_pos;
int root_x, root_y;
int win_x, win_y;
unsigned int mask_return;
Window window_returned;

Bool result = XQueryPointer(x11_display, RootWindow(x11_display, DefaultScreen(x11_display)), &window_returned,
&window_returned, &root_x, &root_y, &win_x, &win_y,
&mask_return);
if (result == True) {
return Point2i(root_x, root_y);
}
return Point2i();
}

Point2i DisplayServerX11::mouse_get_absolute_position() const {
Expand Down Expand Up @@ -718,6 +729,14 @@ ObjectID DisplayServerX11::window_get_attached_instance_id(WindowID p_window) co
}

DisplayServerX11::WindowID DisplayServerX11::get_window_at_screen_position(const Point2i &p_position) const {
#warning This is an incorrect implementation, if windows overlap, it should return the topmost visible one or none if occluded by a foreign window

for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
Rect2i win_rect = Rect2i(window_get_position(E->key()), window_get_size(E->key()));
if (win_rect.has_point(p_position)) {
return E->key();
}
}
return INVALID_WINDOW_ID;
}

Expand Down
2 changes: 2 additions & 0 deletions platform/osx/display_server_osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -3374,6 +3374,8 @@ void _update_keyboard_layouts() {
}

DisplayServer::WindowID DisplayServerOSX::get_window_at_screen_position(const Point2i &p_position) const {
#warning This is an incorrect implementation, if windows overlap, it should return the topmost visible one or none if occluded by a foreign window
akien-mga marked this conversation as resolved.
Show resolved Hide resolved

for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) {
Rect2i win_rect = Rect2i(window_get_position(E->key()), window_get_size(E->key()));
if (win_rect.has_point(p_position)) {
Expand Down