The input_server is now notified when the screen resolution is changed.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15165 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-11-26 16:22:06 +00:00
parent b635c022cb
commit 26b02ddc80
7 changed files with 67 additions and 9 deletions

View File

@ -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 */

View File

@ -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)
{

View File

@ -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);

View File

@ -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);
}
}

View File

@ -20,6 +20,8 @@ class InputManager : public BLocker {
InputManager();
virtual ~InputManager();
void UpdateScreenBounds(BRect bounds);
bool AddStream(EventStream* stream);
void RemoveStream(EventStream* stream);

View File

@ -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();

View File

@ -32,15 +32,10 @@
#include "SystemKeymap.cpp"
// this is an automatically generated file
#ifndef USE_R5_STYLE_COMM
#include <ServerProtocol.h>
#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:
{