Add facility to communicate with the desktop listener over an app server link. The ServerWindow dispatch the message to the DesktopObservable which dispatch it to the correct listener.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38169 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -333,6 +333,9 @@ enum {
|
||||
AS_DIRECT_WINDOW_SET_FULLSCREEN,
|
||||
AS_DIRECT_SCREEN_LOCK,
|
||||
|
||||
// desktop listener communications
|
||||
AS_TALK_TO_DESKTOP_LISTENER,
|
||||
|
||||
AS_LAST_CODE
|
||||
};
|
||||
|
||||
|
||||
@@ -47,9 +47,22 @@ DesktopObservable::GetDesktopListenerList()
|
||||
}
|
||||
|
||||
|
||||
#define FOR_ALL_DESKTOP_LISTENER \
|
||||
for (DesktopListener* listener = fDesktopListenerList.First(); \
|
||||
listener != NULL; listener = fDesktopListenerList.GetNext(listener))
|
||||
bool
|
||||
DesktopObservable::MessageForListener(Window* sender,
|
||||
BPrivate::ServerLink& link)
|
||||
{
|
||||
int32 identifier;
|
||||
link.Read<int32>(&identifier);
|
||||
for (DesktopListener* listener = fDesktopListenerList.First();
|
||||
listener != NULL; listener = fDesktopListenerList.GetNext(listener)) {
|
||||
if (listener->Identifier() == identifier) {
|
||||
if (!listener->HandleMessage(sender, link))
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
#include <Point.h>
|
||||
|
||||
#include <ServerLink.h>
|
||||
|
||||
|
||||
class BMessage;
|
||||
class Desktop;
|
||||
@@ -23,9 +25,14 @@ class DesktopListener : public DoublyLinkedListLinkImpl<DesktopListener> {
|
||||
public:
|
||||
virtual ~DesktopListener();
|
||||
|
||||
virtual int32 Identifier() = 0;
|
||||
|
||||
virtual void ListenerRegistered(Desktop* desktop) = 0;
|
||||
virtual void ListenerUnregistered() = 0;
|
||||
|
||||
virtual bool HandleMessage(Window* sender,
|
||||
BPrivate::ServerLink& link) = 0;
|
||||
|
||||
virtual void WindowAdded(Window* window) = 0;
|
||||
virtual void WindowRemoved(Window* window) = 0;
|
||||
|
||||
@@ -71,6 +78,9 @@ public:
|
||||
void UnregisterListener(DesktopListener* listener);
|
||||
const DesktopListenerDLList& GetDesktopListenerList();
|
||||
|
||||
bool MessageForListener(Window* sender,
|
||||
BPrivate::ServerLink& link);
|
||||
|
||||
void WindowAdded(Window* window);
|
||||
void WindowRemoved(Window* window);
|
||||
|
||||
|
||||
@@ -1156,6 +1156,22 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
break;
|
||||
}
|
||||
|
||||
case AS_TALK_TO_DESKTOP_LISTENER:
|
||||
{
|
||||
port_id senderPort;
|
||||
link.Read<port_id>(&senderPort);
|
||||
BPrivate::LinkSender sender(senderPort);
|
||||
BPrivate::PortLinkRef listenerLink(&sender, &link);
|
||||
if (fDesktop->MessageForListener(fWindow, listenerLink))
|
||||
break;
|
||||
// unhandled message at least send an error if needed
|
||||
if (link.NeedsReply()) {
|
||||
sender.StartMessage(B_ERROR);
|
||||
sender.Flush();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
if (fCurrentView == NULL) {
|
||||
BString codeName;
|
||||
@@ -3635,6 +3651,7 @@ ServerWindow::_MessageNeedsAllWindowsLocked(uint32 code) const
|
||||
case AS_DIRECT_WINDOW_SET_FULLSCREEN:
|
||||
// case AS_VIEW_SET_EVENT_MASK:
|
||||
// case AS_VIEW_SET_MOUSE_EVENT_MASK:
|
||||
case AS_TALK_TO_DESKTOP_LISTENER:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
||||
@@ -93,6 +93,9 @@ public:
|
||||
// related thread/team_id(s).
|
||||
inline team_id ClientTeam() const { return fClientTeam; }
|
||||
|
||||
inline port_id ClientLooperPort () const
|
||||
{ return fClientLooperPort; }
|
||||
|
||||
inline int32 ClientToken() const { return fClientToken; }
|
||||
inline int32 ServerToken() const { return fServerToken; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user