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
+4
View File
@@ -53,4 +53,8 @@
#define IS_ADD_METHOD 'MRa!' #define IS_ADD_METHOD 'MRa!'
#define IS_REMOVE_METHOD 'MRr!' #define IS_REMOVE_METHOD 'MRr!'
// Change screen resolution
#define IS_SCREEN_BOUNDS_UPDATED '_FMM'
// R5 compatible definition
#endif /* INPUT_SERVER_TYPES_H */ #endif /* INPUT_SERVER_TYPES_H */
+10
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 bool
InputServerStream::GetNextEvent(BMessage** _event) InputServerStream::GetNextEvent(BMessage** _event)
{ {
+4
View File
@@ -27,6 +27,8 @@ class EventStream {
virtual bool SupportsCursorThread() const; virtual bool SupportsCursorThread() const;
virtual void UpdateScreenBounds(BRect bounds) = 0;
virtual bool GetNextEvent(BMessage** _event) = 0; virtual bool GetNextEvent(BMessage** _event) = 0;
virtual bool GetNextCursorPosition(BPoint& where); virtual bool GetNextCursorPosition(BPoint& where);
}; };
@@ -46,6 +48,8 @@ class InputServerStream : public EventStream {
virtual bool SupportsCursorThread() const { return fCursorSemaphore >= B_OK; } virtual bool SupportsCursorThread() const { return fCursorSemaphore >= B_OK; }
virtual void UpdateScreenBounds(BRect bounds);
virtual bool GetNextEvent(BMessage** _event); virtual bool GetNextEvent(BMessage** _event);
virtual bool GetNextCursorPosition(BPoint& where); virtual bool GetNextCursorPosition(BPoint& where);
+16
View File
@@ -85,3 +85,19 @@ InputManager::PutStream(EventStream* stream)
delete 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);
}
}
+2
View File
@@ -20,6 +20,8 @@ class InputManager : public BLocker {
InputManager(); InputManager();
virtual ~InputManager(); virtual ~InputManager();
void UpdateScreenBounds(BRect bounds);
bool AddStream(EventStream* stream); bool AddStream(EventStream* stream);
void RemoveStream(EventStream* stream); void RemoveStream(EventStream* stream);
+2
View File
@@ -2107,6 +2107,8 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
BRect bounds = rootLayer->Bounds(); BRect bounds = rootLayer->Bounds();
rootLayer->ResizeBy(mode.virtual_width - 1 - bounds.Width(), rootLayer->ResizeBy(mode.virtual_width - 1 - bounds.Width(),
mode.virtual_height - 1 - bounds.Height()); mode.virtual_height - 1 - bounds.Height());
gInputManager->UpdateScreenBounds(rootLayer->Bounds());
} }
rootLayer->Unlock(); rootLayer->Unlock();
+29 -9
View File
@@ -32,15 +32,10 @@
#include "SystemKeymap.cpp" #include "SystemKeymap.cpp"
// this is an automatically generated file // this is an automatically generated file
#ifndef USE_R5_STYLE_COMM
#include <ServerProtocol.h> #include <ServerProtocol.h>
#endif
using std::nothrow; 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 #ifdef HAIKU_TARGET_PLATFORM_HAIKU
extern "C" status_t _kern_get_safemode_option(const char *parameter, extern "C" status_t _kern_get_safemode_option(const char *parameter,
@@ -549,6 +544,26 @@ InputServer::MessageReceived(BMessage* message)
case IS_RELEASE_INPUT: case IS_RELEASE_INPUT:
_ReleaseInput(message); _ReleaseInput(message);
return; 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 // device looper related
case IS_FIND_DEVICES: case IS_FIND_DEVICES:
@@ -1348,11 +1363,15 @@ InputServer::_SanitizeEvents(EventList& events)
while ((event = (BMessage*)events.ItemAt(index)) != NULL) { while ((event = (BMessage*)events.ItemAt(index)) != NULL) {
switch (event->what) { 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, // This is what the R5 app_server sends us when the screen
// screen resolution change could have happened // configuration changes
BRect frame = fScreen.Frame(); BRect frame;
if (event->FindRect("screen_bounds", &frame) != B_OK)
frame = fScreen.Frame();
if (frame != fFrame) { if (frame != fFrame) {
fMousePos.x = fMousePos.x * frame.Width() / fFrame.Width(); fMousePos.x = fMousePos.x * frame.Width() / fFrame.Width();
fMousePos.y = fMousePos.y * frame.Height() / fFrame.Height(); fMousePos.y = fMousePos.y * frame.Height() / fFrame.Height();
@@ -1365,6 +1384,7 @@ InputServer::_SanitizeEvents(EventList& events)
event->AddPoint("where", fMousePos); event->AddPoint("where", fMousePos);
// supposed to fall through // supposed to fall through
} }
#endif
case B_MOUSE_MOVED: case B_MOUSE_MOVED:
case B_MOUSE_DOWN: case B_MOUSE_DOWN:
{ {