haiku/src/servers/app/ServerWindow.h

168 lines
4.5 KiB
C
Raw Normal View History

/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* DarkWyrm <bpmagic@columbus.rr.com>
* Adrian Oanca <adioanca@gmail.com>
* Stephan Aßmus <superstippi@gmx.de>
* Stefano Ceccherini (burton666@libero.it)
* Axel Dörfler, axeld@pinc-software.de
*/
#ifndef SERVER_WINDOW_H
#define SERVER_WINDOW_H
Have I said input event handling is done? * didn't realize that mouse events always go to the view under the mouse, not only if its the focus window (FFM can really do harm, after all :-)). * removed a TODO from the list: EventDispatcher::Target is now a public class EventTarget, and every ServerWindow has one. * as a result, EventDispatcher no longer manages targets itself, it just maintains a list of them. You no longer set messengers, you only set targets. * customization of the message filters, they no longer inherit from BMessageFilter (but EventFilter). * a message target is no longer set explicetly anywhere, it's only changed in the message filters if needed. * therefore, no more locking mess in the EventDispatcher needed. * this also made the EventDispatcher::fLastFocus stuff superfluous. * moved the RootLayer::MouseEventHandler() into the message filter. * Replaced RootLayer::_ChildAt() with WindowAt(). * WindowLayer now has an idea if it has focus or not, it no longer needs to query the RootLayer for this - maybe we should rename "focus" to "active", though (as far as layers are concerned). * the "_view_token" data is now added from the EventDispatcher, not the (Window)Layer class anymore. * removed Layer::MouseWheelChanged() as we currently don't need it (if the need arises, we can add it back later again) * there is still no mouse moved message sent when opening a window under the cursor, though... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15228 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-29 19:01:41 +03:00
#include "EventDispatcher.h"
#include "MessageLooper.h"
#include <PortLink.h>
#include <TokenSpace.h>
#include <GraphicsDefs.h>
#include <Locker.h>
#include <Message.h>
#include <Messenger.h>
#include <Rect.h>
#include <String.h>
#include <Window.h>
class BString;
class BMessenger;
class BPoint;
class BMessage;
class Desktop;
class ServerApp;
class Decorator;
class WindowLayer;
class Workspace;
class ViewLayer;
class ServerPicture;
struct direct_window_data;
struct window_info;
#define AS_UPDATE_DECORATOR 'asud'
#define AS_UPDATE_COLORS 'asuc'
#define AS_UPDATE_FONTS 'asuf'
class ServerWindow : public MessageLooper {
public:
ServerWindow(const char *title, ServerApp *app,
port_id clientPort, port_id looperPort,
int32 clientToken);
virtual ~ServerWindow();
status_t Init(BRect frame, window_look look,
window_feel feel, uint32 flags,
uint32 workspace);
virtual bool Run();
virtual port_id MessagePort() const { return fMessagePort; }
Have I said input event handling is done? * didn't realize that mouse events always go to the view under the mouse, not only if its the focus window (FFM can really do harm, after all :-)). * removed a TODO from the list: EventDispatcher::Target is now a public class EventTarget, and every ServerWindow has one. * as a result, EventDispatcher no longer manages targets itself, it just maintains a list of them. You no longer set messengers, you only set targets. * customization of the message filters, they no longer inherit from BMessageFilter (but EventFilter). * a message target is no longer set explicetly anywhere, it's only changed in the message filters if needed. * therefore, no more locking mess in the EventDispatcher needed. * this also made the EventDispatcher::fLastFocus stuff superfluous. * moved the RootLayer::MouseEventHandler() into the message filter. * Replaced RootLayer::_ChildAt() with WindowAt(). * WindowLayer now has an idea if it has focus or not, it no longer needs to query the RootLayer for this - maybe we should rename "focus" to "active", though (as far as layers are concerned). * the "_view_token" data is now added from the EventDispatcher, not the (Window)Layer class anymore. * removed Layer::MouseWheelChanged() as we currently don't need it (if the need arises, we can add it back later again) * there is still no mouse moved message sent when opening a window under the cursor, though... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15228 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-29 19:01:41 +03:00
::EventTarget& EventTarget() { return fEventTarget; }
void ReplaceDecorator();
void Show();
void Hide();
// methods for sending various messages to client.
void NotifyQuitRequested();
void NotifyMinimize(bool minimize);
void NotifyZoom();
// util methods.
const BMessenger& FocusMessenger() const { return fFocusMessenger; }
const BMessenger& HandlerMessenger() const { return fHandlerMessenger; }
status_t SendMessageToClient(const BMessage* msg,
int32 target = B_NULL_TOKEN) const;
offscreen bitmaps work, tested on Haiku as well, supports all colorspaces that BBitmap::ImportBits() supports. It uses a fallback for non-B_RGB(A)32 bitmaps. Added support for B_SUB_PIXEL_PRECISION view flags, though it is a bit hacky, since I had to add it to LayerData, even though it is not a true part of stack data. Added Layer::SetFlags() to enforce code path and update fLayerData. Cleaned up DisplayDriverPainter and DisplayDriver API (changed some const BRect& rect to simply BRect rect in order to be able to reuse it in the code), moved Painter.h, the test environment only draws the changed part of the frame buffer again - this causes a lot less CPU overhead, Painter special cases stroke width of 1.0 to use square caps, which is similar to R5 implementation and removes a lot of problems with non-straight line drawing, ServerWindow uses the DisplayDriver from it's WinBorder instead of the one from the Desktop (needed for offscreen windows, which have their own DisplayDriverPainter), it also checks for GetRootLayer() == NULL, because offscreen layers are not attached to a RootLayer, there was a fix for scrolling which worked at least in the test environment, it is now defunced, because Adi moved _CopyBits to Layer... I need to reenable it later, LayerData has no more fEscapementDelta, also fixed fFontAliasing (which was thought to overriding the font flags, and now works as such again), Desktop initialises the menu_info and scroll_bar_info stuff, which makes ScrollBars work actually... hope I didn't forget something. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13448 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-07-05 20:17:16 +04:00
virtual WindowLayer* MakeWindowLayer(BRect frame, const char* name,
window_look look, window_feel feel, uint32 flags,
uint32 workspace);
// TODO: Ouch, that's not exactly a nice name
inline BMessage &ClientViewsWithInvalidCoords()
{ return fClientViewsWithInvalidCoords; };
// to who we belong. who do we own. our title.
inline ServerApp* App() const { return fServerApp; }
::Desktop* Desktop() const { return fDesktop; }
inline const WindowLayer* GetWindowLayer() const { return fWindowLayer; }
void SetTitle(const char* newTitle);
inline const char* Title() const { return fTitle; }
// related thread/team_id(s).
inline team_id ClientTeam() const { return fClientTeam; }
void HandleDirectConnection(int32 bufferState = -1,
int32 driverState = -1);
inline int32 ClientToken() const { return fClientToken; }
inline int32 ServerToken() const { return fServerToken; }
void RequestRedraw();
void GetInfo(window_info& info);
private:
// methods for retrieving and creating a tree strcture of Layers.
ViewLayer* CreateLayerTree(BPrivate::LinkReceiver &link,
ViewLayer **_parent);
void SetLayerState(ViewLayer *layer,
BPrivate::LinkReceiver &link);
void SetLayerFontState(ViewLayer *layer,
BPrivate::LinkReceiver &link);
// message handling methods.
void _DispatchMessage(int32 code, BPrivate::LinkReceiver &link);
void _DispatchViewMessage(int32 code,
BPrivate::LinkReceiver &link);
void _DispatchViewDrawingMessage(int32 code,
BPrivate::LinkReceiver &link);
void _MessageLooper();
virtual void _PrepareQuit();
virtual void _GetLooperName(char* name, size_t size);
status_t _EnableDirectWindowMode();
void _SetCurrentLayer(ViewLayer* view);
// TODO: Move me elsewhere
status_t PictureToRegion(ServerPicture *picture,
BRegion &,
bool inverse,
BPoint where);
private:
char* fTitle;
::Desktop* fDesktop;
ServerApp* fServerApp;
WindowLayer* fWindowLayer;
team_id fClientTeam;
port_id fMessagePort;
port_id fClientReplyPort;
port_id fClientLooperPort;
BMessenger fFocusMessenger;
BMessenger fHandlerMessenger;
Have I said input event handling is done? * didn't realize that mouse events always go to the view under the mouse, not only if its the focus window (FFM can really do harm, after all :-)). * removed a TODO from the list: EventDispatcher::Target is now a public class EventTarget, and every ServerWindow has one. * as a result, EventDispatcher no longer manages targets itself, it just maintains a list of them. You no longer set messengers, you only set targets. * customization of the message filters, they no longer inherit from BMessageFilter (but EventFilter). * a message target is no longer set explicetly anywhere, it's only changed in the message filters if needed. * therefore, no more locking mess in the EventDispatcher needed. * this also made the EventDispatcher::fLastFocus stuff superfluous. * moved the RootLayer::MouseEventHandler() into the message filter. * Replaced RootLayer::_ChildAt() with WindowAt(). * WindowLayer now has an idea if it has focus or not, it no longer needs to query the RootLayer for this - maybe we should rename "focus" to "active", though (as far as layers are concerned). * the "_view_token" data is now added from the EventDispatcher, not the (Window)Layer class anymore. * removed Layer::MouseWheelChanged() as we currently don't need it (if the need arises, we can add it back later again) * there is still no mouse moved message sent when opening a window under the cursor, though... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15228 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-29 19:01:41 +03:00
::EventTarget fEventTarget;
BMessage fClientViewsWithInvalidCoords;
int32 fRedrawRequested;
int32 fServerToken;
int32 fClientToken;
ViewLayer* fCurrentLayer;
BRegion fCurrentDrawingRegion;
bool fCurrentDrawingRegionValid;
direct_window_data* fDirectWindowData;
};
#endif // SERVER_WINDOW_H