* the keyboard events are now using the new EventDispatcher, B_KEYBOARD_EVENTS don't

work yet, though, as the dispatcher is not yet notified about those.
* no more mouse cursor jumping - the cursor will now start in the middle of the screen;
  this should be part of the initial input_server handshake, though.
* ServerWindow can now return a BMessenger of its client window.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15017 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-11-18 13:21:07 +00:00
parent 8d8f5950d0
commit f68598780e
6 changed files with 25 additions and 33 deletions

View File

@ -123,33 +123,15 @@ Desktop::Init()
private:
RootLayer* fRootLayer;
};
class KeyFilter : public BMessageFilter {
public:
KeyFilter(RootLayer* layer)
: BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE),
fRootLayer(layer)
{
}
virtual filter_result
Filter(BMessage* message, BHandler** /*_target*/)
{
fRootLayer->Lock();
fRootLayer->KeyboardEventHandler(message);
fRootLayer->Unlock();
return B_SKIP_MESSAGE;
}
private:
RootLayer* fRootLayer;
};
fEventDispatcher.SetMouseFilter(new MouseFilter(fRootLayer));
fEventDispatcher.SetKeyFilter(new KeyFilter(fRootLayer));
// take care of setting the default cursor
ServerCursor *cursor = fCursorManager.GetCursor(B_CURSOR_DEFAULT);
if (cursor)
fVirtualScreen.HWInterface()->SetCursor(cursor);
fVirtualScreen.HWInterface()->MoveCursorTo(fVirtualScreen.Frame().Width() / 2,
fVirtualScreen.Frame().Height() / 2);
fVirtualScreen.HWInterface()->SetCursorVisible(true);
}

View File

@ -146,11 +146,12 @@ EventDispatcher::_Run()
void
EventDispatcher::SetFocus(BMessenger* messenger)
EventDispatcher::SetFocus(const BMessenger* messenger)
{
BAutolock _(this);
if (fFocus == *messenger)
if ((messenger == NULL && !fHasFocus)
|| (messenger != NULL && fFocus == *messenger))
return;
fHasLastFocus = fHasFocus;
@ -166,7 +167,7 @@ EventDispatcher::SetFocus(BMessenger* messenger)
if (fHasFocus) {
fFocus = *messenger;
// add all B_POINTER_EVENTS tokens that target this messenger
for (int32 i = fListeners.CountItems(); i-- > 0;) {
event_target* target = fListeners.ItemAt(i);

View File

@ -27,7 +27,7 @@ class EventDispatcher : public BLocker {
status_t SetTo(EventStream* stream);
status_t InitCheck();
void SetFocus(BMessenger* messenger);
void SetFocus(const BMessenger* messenger);
bool AddListener(BMessenger& messenger, int32 token,
uint32 events, uint32 options);

View File

@ -676,8 +676,11 @@ RootLayer::RevealNewWMState(Workspace::State &oldWMState)
if (oldWMState.Active != fWMState.Active) {
if (oldWMState.Active)
oldWMState.Active->Activated(false);
if (fWMState.Active)
if (fWMState.Active) {
fWMState.Active->Activated(true);
fDesktop->EventDispatcher().SetFocus(&fWMState.Active->Window()->Messenger());
} else
fDesktop->EventDispatcher().SetFocus(NULL);
}
// calculate the region that must be invalidated/redrawn

View File

@ -149,6 +149,9 @@ ServerWindow::ServerWindow(const char *title, ServerApp *app,
SetTitle(title);
fServerToken = BPrivate::gDefaultTokens.NewToken(B_SERVER_TOKEN, this);
BMessenger::Private(fClientMessenger).SetTo(fClientTeam,
looperPort, clientToken, false);
}

View File

@ -13,19 +13,20 @@
#define SERVER_WINDOW_H
#include <GraphicsDefs.h>
#include "MessageLooper.h"
#include "SubWindowList.h"
#include <PortLink.h>
#include <TokenSpace.h>
#include <GraphicsDefs.h>
#include <Locker.h>
#include <Message.h>
#include <OS.h>
#include <Messenger.h>
#include <Rect.h>
#include <String.h>
#include <Window.h>
#include "MessageLooper.h"
#include "SubWindowList.h"
#include "TokenSpace.h"
class BString;
class BMessenger;
class BPoint;
@ -70,7 +71,8 @@ public:
void NotifyScreenModeChanged(const BRect frame,
const color_space cspace);
// util methods.
// util methods.
const BMessenger& Messenger() const { return fClientMessenger; }
status_t SendMessageToClient(const BMessage* msg,
int32 target = B_NULL_TOKEN,
bool usePreferred = false) const;
@ -138,6 +140,7 @@ private:
port_id fMessagePort;
port_id fClientReplyPort;
port_id fClientLooperPort;
BMessenger fClientMessenger;
BMessage fClientViewsWithInvalidCoords;