1/* 2 * Copyright 2001-2009, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * DarkWyrm <bpmagic@columbus.rr.com> 7 * Adrian Oanca <adioanca@gmail.com> 8 * Stephan A��mus <superstippi@gmx.de> 9 * Stefano Ceccherini (burton666@libero.it) 10 * Axel D��rfler, axeld@pinc-software.de 11 */ 12#ifndef SERVER_WINDOW_H 13#define SERVER_WINDOW_H 14 15 16#include <AutoDeleter.h> 17#include <GraphicsDefs.h> 18#include <Locker.h> 19#include <Message.h> 20#include <Messenger.h> 21#include <Rect.h> 22#include <Region.h> 23#include <String.h> 24#include <Window.h> 25 26#include <PortLink.h> 27#include <TokenSpace.h> 28 29#include "EventDispatcher.h" 30#include "MessageLooper.h" 31 32 33class BString; 34class BMessenger; 35class BPoint; 36class BMessage; 37 38class Desktop; 39class ServerApp; 40class Decorator; 41class Window; 42class Workspace; 43class View; 44class ServerPicture; 45class DirectWindowInfo; 46struct window_info; 47 48#define AS_UPDATE_DECORATOR 'asud' 49#define AS_UPDATE_COLORS 'asuc' 50#define AS_UPDATE_FONTS 'asuf' 51 52 53class ServerWindow : public MessageLooper { 54public: 55 ServerWindow(const char *title, ServerApp *app, 56 port_id clientPort, port_id looperPort, 57 int32 clientToken); 58 virtual ~ServerWindow(); 59 60 status_t Init(BRect frame, window_look look, 61 window_feel feel, uint32 flags, 62 uint32 workspace); 63 64 virtual port_id MessagePort() const { return fMessagePort; } 65 66 ::EventTarget& EventTarget() { return fEventTarget; } 67 68 inline ServerApp* App() const { return fServerApp; } 69 ::Desktop* Desktop() const { return fDesktop; } 70 ::Window* Window() const; 71 72 // methods for sending various messages to client. 73 void NotifyQuitRequested(); 74 void NotifyMinimize(bool minimize); 75 void NotifyZoom(); 76 77 // util methods. 78 const BMessenger& FocusMessenger() const 79 { return fFocusMessenger; } 80 const BMessenger& HandlerMessenger() const 81 { return fHandlerMessenger; } 82 83 void ScreenChanged(const BMessage* message); 84 status_t SendMessageToClient(const BMessage* message, 85 int32 target = B_NULL_TOKEN) const; 86 87 virtual ::Window* MakeWindow(BRect frame, const char* name, 88 window_look look, window_feel feel, 89 uint32 flags, uint32 workspace); 90 91 void SetTitle(const char* newTitle); 92 inline const char* Title() const { return fTitle; } 93 94 // related thread/team_id(s). 95 inline team_id ClientTeam() const { return fClientTeam; } 96 97 inline port_id ClientLooperPort () const 98 { return fClientLooperPort; } 99 100 inline int32 ClientToken() const { return fClientToken; } 101 inline int32 ServerToken() const { return fServerToken; } 102 103 void RequestRedraw(); 104 105 void GetInfo(window_info& info); 106 107 void HandleDirectConnection(int32 bufferState, 108 int32 driverState = 0); 109 bool HasDirectFrameBufferAccess() const 110 { return fDirectWindowInfo.IsSet(); } 111 bool IsDirectlyAccessing() const 112 { return fIsDirectlyAccessing; } 113 114 void ResyncDrawState(); 115 116 // TODO: Change this 117 inline void UpdateCurrentDrawingRegion() 118 { _UpdateCurrentDrawingRegion(); }; 119 120private: 121 View* _CreateView(BPrivate::LinkReceiver &link, 122 View **_parent); 123 124 void _Show(); 125 void _Hide(); 126 127 // message handling methods. 128 void _DispatchMessage(int32 code, 129 BPrivate::LinkReceiver &link); 130 void _DispatchViewMessage(int32 code, 131 BPrivate::LinkReceiver &link); 132 void _DispatchViewDrawingMessage(int32 code, 133 BPrivate::LinkReceiver &link); 134 bool _DispatchPictureMessage(int32 code, 135 BPrivate::LinkReceiver &link); 136 void _MessageLooper(); 137 virtual void _PrepareQuit(); 138 virtual void _GetLooperName(char* name, size_t size); 139 140 void _ResizeToFullScreen(); 141 status_t _EnableDirectWindowMode(); 142 void _DirectWindowSetFullScreen(bool set); 143 144 void _SetCurrentView(View* view); 145 void _UpdateDrawState(View* view); 146 void _UpdateCurrentDrawingRegion(); 147 148 bool _MessageNeedsAllWindowsLocked( 149 uint32 code) const; 150 151private: 152 char* fTitle; 153 154 ::Desktop* fDesktop; 155 ServerApp* fServerApp; 156 ObjectDeleter< ::Window> 157 fWindow; 158 bool fWindowAddedToDesktop; 159 160 team_id fClientTeam; 161 162 port_id fMessagePort; 163 port_id fClientReplyPort; 164 port_id fClientLooperPort; 165 BMessenger fFocusMessenger; 166 BMessenger fHandlerMessenger; 167 ::EventTarget fEventTarget; 168 169 int32 fRedrawRequested; 170 171 int32 fServerToken; 172 int32 fClientToken; 173 174 View* fCurrentView; 175 BRegion fCurrentDrawingRegion; 176 bool fCurrentDrawingRegionValid; 177 178 ObjectDeleter<DirectWindowInfo> 179 fDirectWindowInfo; 180 bool fIsDirectlyAccessing; 181}; 182 183#endif // SERVER_WINDOW_H 184