diff --git a/headers/os/interface/InterfaceDefs.h b/headers/os/interface/InterfaceDefs.h index e0dfdda5eb..298c0a6a9d 100644 --- a/headers/os/interface/InterfaceDefs.h +++ b/headers/os/interface/InterfaceDefs.h @@ -10,6 +10,7 @@ #include class BRect; +class BPoint; // some handy UTF-8 characters @@ -380,6 +381,8 @@ mode_mouse mouse_mode(); void set_focus_follows_mouse_mode(mode_focus_follows_mouse mode); mode_focus_follows_mouse focus_follows_mouse_mode(); +status_t get_mouse(BPoint* screenWhere, uint32* buttons); + void set_accept_first_click(bool acceptFirstClick); bool accept_first_click(); diff --git a/headers/private/app/ServerProtocol.h b/headers/private/app/ServerProtocol.h index 69becc6a49..8f5e3238fc 100644 --- a/headers/private/app/ServerProtocol.h +++ b/headers/private/app/ServerProtocol.h @@ -81,6 +81,8 @@ enum { AS_BEGIN_RECT_TRACKING, AS_END_RECT_TRACKING, + + AS_GET_CURSOR_POSITION, // Window definitions AS_SHOW_WINDOW, diff --git a/src/kits/interface/InterfaceDefs.cpp b/src/kits/interface/InterfaceDefs.cpp index 05a871fcf4..0f6e5db09b 100644 --- a/src/kits/interface/InterfaceDefs.cpp +++ b/src/kits/interface/InterfaceDefs.cpp @@ -7,6 +7,7 @@ * Caz * Axel Dörfler, axeld@pinc-software.de * Michael Lotz + * Wim van der Meer */ @@ -23,9 +24,10 @@ #include #include #include +#include #include -#include #include +#include #include #include @@ -925,6 +927,42 @@ focus_follows_mouse_mode() } +status_t +get_mouse(BPoint* screenWhere, uint32* buttons) +{ + if (screenWhere == NULL && buttons == NULL) + return B_BAD_VALUE; + + BPrivate::AppServerLink link; + link.StartMessage(AS_GET_CURSOR_POSITION); + + int32 code; + status_t ret = link.FlushWithReply(code); + if (ret != B_OK) + return ret; + if (code != B_OK) + return code; + + if (screenWhere != NULL) + ret = link.Read(screenWhere); + else { + BPoint dummy; + ret = link.Read(&dummy); + } + if (ret != B_OK) + return ret; + + if (buttons != NULL) + ret = link.Read(buttons); + else { + uint32 dummy; + ret = link.Read(&dummy); + } + + return ret; +} + + void set_accept_first_click(bool acceptFirstClick) { diff --git a/src/servers/app/ProfileMessageSupport.cpp b/src/servers/app/ProfileMessageSupport.cpp index 14f33c3d89..31af3bedbb 100644 --- a/src/servers/app/ProfileMessageSupport.cpp +++ b/src/servers/app/ProfileMessageSupport.cpp @@ -61,6 +61,8 @@ string_for_message_code(uint32 code, BString& string) CODE(AS_BEGIN_RECT_TRACKING); CODE(AS_END_RECT_TRACKING); + + CODE(AS_GET_CURSOR_POSITION); // Window definitions CODE(AS_SHOW_WINDOW); diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index 4f47c92dfb..034044aae5 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -11,6 +11,7 @@ * Jérôme Duval, jerome.duval@free.fr * Andrej Spielmann, * Philippe Saint-Pierre, stpere@gmail.com + * Wim van der Meer, */ @@ -1165,7 +1166,21 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) break; } - + case AS_GET_CURSOR_POSITION: + { + STRACE(("ServerApp %s: Get Cursor position\n", Signature())); + // Returns + // 1) BPoint mouse location + // 2) int32 button state + BPoint where; + int32 buttons; + fDesktop->GetLastMouseState(&where, &buttons); + fLink.StartMessage(B_OK); + fLink.Attach(where); + fLink.Attach(buttons); + fLink.Flush(); + break; + } case AS_GET_SCROLLBAR_INFO: { STRACE(("ServerApp %s: Get ScrollBar info\n", Signature()));