1 /* 2 * Copyright 2010, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Clemens Zeidler <haiku@clemens-zeidler.de> 7 */ 8 #ifndef DESKTOP_LISTENER_H 9 #define DESKTOP_LISTENER_H 10 11 12 #include <util/DoublyLinkedList.h> 13 14 #include <Point.h> 15 16 #include <ServerLink.h> 17 #include "Window.h" 18 19 20 class BMessage; 21 class Desktop; 22 class Window; 23 24 25 class DesktopListener : public DoublyLinkedListLinkImpl<DesktopListener> { 26 public: 27 virtual ~DesktopListener(); 28 29 virtual int32 Identifier() = 0; 30 31 virtual void ListenerRegistered(Desktop* desktop) = 0; 32 virtual void ListenerUnregistered() = 0; 33 34 virtual bool HandleMessage(Window* sender, 35 BPrivate::LinkReceiver& link, 36 BPrivate::LinkSender& reply) = 0; 37 38 virtual void WindowAdded(Window* window) = 0; 39 virtual void WindowRemoved(Window* window) = 0; 40 41 virtual bool KeyPressed(uint32 what, int32 key, 42 int32 modifiers) = 0; 43 virtual void MouseEvent(BMessage* message) = 0; 44 virtual void MouseDown(Window* window, BMessage* message, 45 const BPoint& where) = 0; 46 virtual void MouseUp(Window* window, BMessage* message, 47 const BPoint& where) = 0; 48 virtual void MouseMoved(Window* window, BMessage* message, 49 const BPoint& where) = 0; 50 51 virtual void WindowMoved(Window* window) = 0; 52 virtual void WindowResized(Window* window) = 0; 53 virtual void WindowActivated(Window* window) = 0; 54 virtual void WindowSentBehind(Window* window, 55 Window* behindOf) = 0; 56 virtual void WindowWorkspacesChanged(Window* window, 57 uint32 workspaces) = 0; 58 virtual void WindowHidden(Window* window, 59 bool fromMinimize) = 0; 60 virtual void WindowMinimized(Window* window, 61 bool minimize) = 0; 62 63 virtual void WindowTabLocationChanged(Window* window, 64 float location, bool isShifting) = 0; 65 virtual void SizeLimitsChanged(Window* window, 66 int32 minWidth, int32 maxWidth, 67 int32 minHeight, int32 maxHeight) = 0; 68 virtual void WindowLookChanged(Window* window, 69 window_look look) = 0; 70 virtual void WindowFeelChanged(Window* window, 71 window_feel feel) = 0; 72 73 virtual bool SetDecoratorSettings(Window* window, 74 const BMessage& settings) = 0; 75 virtual void GetDecoratorSettings(Window* window, 76 BMessage& settings) = 0; 77 }; 78 79 80 typedef DoublyLinkedList<DesktopListener> DesktopListenerDLList; 81 82 83 class DesktopObservable { 84 public: 85 DesktopObservable(); 86 87 void RegisterListener(DesktopListener* listener, 88 Desktop* desktop); 89 void UnregisterListener(DesktopListener* listener); 90 const DesktopListenerDLList& GetDesktopListenerList(); 91 92 bool MessageForListener(Window* sender, 93 BPrivate::LinkReceiver& link, 94 BPrivate::LinkSender& reply); 95 96 void NotifyWindowAdded(Window* window); 97 void NotifyWindowRemoved(Window* window); 98 99 bool NotifyKeyPressed(uint32 what, int32 key, 100 int32 modifiers); 101 void NotifyMouseEvent(BMessage* message); 102 void NotifyMouseDown(Window* window, 103 BMessage* message, const BPoint& where); 104 void NotifyMouseUp(Window* window, BMessage* message, 105 const BPoint& where); 106 void NotifyMouseMoved(Window* window, 107 BMessage* message, const BPoint& where); 108 109 void NotifyWindowMoved(Window* window); 110 void NotifyWindowResized(Window* window); 111 void NotifyWindowActivated(Window* window); 112 void NotifyWindowSentBehind(Window* window, 113 Window* behindOf); 114 void NotifyWindowWorkspacesChanged(Window* window, 115 uint32 workspaces); 116 void NotifyWindowHidden(Window* window, 117 bool fromMinimize); 118 void NotifyWindowMinimized(Window* window, 119 bool minimize); 120 121 void NotifyWindowTabLocationChanged(Window* window, 122 float location, bool isShifting); 123 void NotifySizeLimitsChanged(Window* window, 124 int32 minWidth, int32 maxWidth, 125 int32 minHeight, int32 maxHeight); 126 void NotifyWindowLookChanged(Window* window, 127 window_look look); 128 void NotifyWindowFeelChanged(Window* window, 129 window_feel feel); 130 131 bool SetDecoratorSettings(Window* window, 132 const BMessage& settings); 133 void GetDecoratorSettings(Window* window, 134 BMessage& settings); 135 136 private: 137 class InvokeGuard { 138 public: 139 InvokeGuard(bool& invoking); 140 ~InvokeGuard(); 141 private: 142 bool& fInvoking; 143 }; 144 145 DesktopListenerDLList fDesktopListenerList; 146 147 // prevent recursive invokes 148 bool fWeAreInvoking; 149 }; 150 151 #endif 152