diff --git a/headers/private/input/InputServerTypes.h b/headers/private/input/InputServerTypes.h index 814fa775f9..55b3526b8a 100644 --- a/headers/private/input/InputServerTypes.h +++ b/headers/private/input/InputServerTypes.h @@ -53,4 +53,8 @@ #define IS_ADD_METHOD 'MRa!' #define IS_REMOVE_METHOD 'MRr!' +// Change screen resolution +#define IS_SCREEN_BOUNDS_UPDATED '_FMM' + // R5 compatible definition + #endif /* INPUT_SERVER_TYPES_H */ diff --git a/src/servers/app/EventStream.cpp b/src/servers/app/EventStream.cpp index 1fa4b1e1bc..ffa0b006d6 100644 --- a/src/servers/app/EventStream.cpp +++ b/src/servers/app/EventStream.cpp @@ -105,6 +105,16 @@ InputServerStream::SendQuit() } +void +InputServerStream::UpdateScreenBounds(BRect bounds) +{ + BMessage update(IS_SCREEN_BOUNDS_UPDATED); + update.AddRect("screen_bounds", bounds); + + fInputServer.SendMessage(&update); +} + + bool InputServerStream::GetNextEvent(BMessage** _event) { diff --git a/src/servers/app/EventStream.h b/src/servers/app/EventStream.h index 5e3a8f552f..d24d51531e 100644 --- a/src/servers/app/EventStream.h +++ b/src/servers/app/EventStream.h @@ -27,6 +27,8 @@ class EventStream { virtual bool SupportsCursorThread() const; + virtual void UpdateScreenBounds(BRect bounds) = 0; + virtual bool GetNextEvent(BMessage** _event) = 0; virtual bool GetNextCursorPosition(BPoint& where); }; @@ -46,6 +48,8 @@ class InputServerStream : public EventStream { virtual bool SupportsCursorThread() const { return fCursorSemaphore >= B_OK; } + virtual void UpdateScreenBounds(BRect bounds); + virtual bool GetNextEvent(BMessage** _event); virtual bool GetNextCursorPosition(BPoint& where); diff --git a/src/servers/app/InputManager.cpp b/src/servers/app/InputManager.cpp index 1115f8c797..de87fa99c8 100644 --- a/src/servers/app/InputManager.cpp +++ b/src/servers/app/InputManager.cpp @@ -85,3 +85,19 @@ InputManager::PutStream(EventStream* stream) delete stream; } + +void +InputManager::UpdateScreenBounds(BRect bounds) +{ + BAutolock _(this); + + for (int32 i = fUsedStreams.CountItems(); i-- > 0;) { + fUsedStreams.ItemAt(i)->UpdateScreenBounds(bounds); + } + + for (int32 i = fFreeStreams.CountItems(); i-- > 0;) { + fFreeStreams.ItemAt(i)->UpdateScreenBounds(bounds); + } +} + + diff --git a/src/servers/app/InputManager.h b/src/servers/app/InputManager.h index 8aa3385868..2cea81f698 100644 --- a/src/servers/app/InputManager.h +++ b/src/servers/app/InputManager.h @@ -20,6 +20,8 @@ class InputManager : public BLocker { InputManager(); virtual ~InputManager(); + void UpdateScreenBounds(BRect bounds); + bool AddStream(EventStream* stream); void RemoveStream(EventStream* stream); diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index 978ca3ceba..24d6a7cbb5 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -2107,6 +2107,8 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) BRect bounds = rootLayer->Bounds(); rootLayer->ResizeBy(mode.virtual_width - 1 - bounds.Width(), mode.virtual_height - 1 - bounds.Height()); + + gInputManager->UpdateScreenBounds(rootLayer->Bounds()); } rootLayer->Unlock(); diff --git a/src/servers/input/InputServer.cpp b/src/servers/input/InputServer.cpp index 27b636c9ad..1b7f3aa9fe 100644 --- a/src/servers/input/InputServer.cpp +++ b/src/servers/input/InputServer.cpp @@ -32,15 +32,10 @@ #include "SystemKeymap.cpp" // this is an automatically generated file -#ifndef USE_R5_STYLE_COMM #include -#endif using std::nothrow; -#define FAST_MOUSE_MOVED '_FMM' - // received from app_server when screen res changed, but could be sent to too. - #ifdef HAIKU_TARGET_PLATFORM_HAIKU extern "C" status_t _kern_get_safemode_option(const char *parameter, @@ -549,6 +544,26 @@ InputServer::MessageReceived(BMessage* message) case IS_RELEASE_INPUT: _ReleaseInput(message); return; + case IS_SCREEN_BOUNDS_UPDATED: + { + // This is what the R5 app_server sends us when the screen + // configuration changes + BRect frame; + if (message->FindRect("screen_bounds", &frame) != B_OK) + frame = fScreen.Frame(); + + if (frame == fFrame) + break; + + BPoint pos(fMousePos.x * frame.Width() / fFrame.Width(), + fMousePos.y * frame.Height() / fFrame.Height()); + fFrame = frame; + + BMessage set; + set.AddPoint("where", pos); + HandleSetMousePosition(&set, NULL); + break; + } // device looper related case IS_FIND_DEVICES: @@ -1348,11 +1363,15 @@ InputServer::_SanitizeEvents(EventList& events) while ((event = (BMessage*)events.ItemAt(index)) != NULL) { switch (event->what) { - case FAST_MOUSE_MOVED: +#ifndef HAIKU_TARGET_PLATFORM_HAIKU + case IS_SCREEN_BOUNDS_UPDATED: { - // here we test for a message coming from app_server, - // screen resolution change could have happened - BRect frame = fScreen.Frame(); + // This is what the R5 app_server sends us when the screen + // configuration changes + BRect frame; + if (event->FindRect("screen_bounds", &frame) != B_OK) + frame = fScreen.Frame(); + if (frame != fFrame) { fMousePos.x = fMousePos.x * frame.Width() / fFrame.Width(); fMousePos.y = fMousePos.y * frame.Height() / fFrame.Height(); @@ -1365,6 +1384,7 @@ InputServer::_SanitizeEvents(EventList& events) event->AddPoint("where", fMousePos); // supposed to fall through } +#endif case B_MOUSE_MOVED: case B_MOUSE_DOWN: {