diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index 1d79437e97..a7efa9a781 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2005, Haiku. + * Copyright 2001-2006, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -171,7 +171,7 @@ ServerApp::~ServerApp() // time, but killing it might have desastrous effects if (MessageLooper::WaitForQuit(deathSemaphore, 3000000) != B_OK) { // This really shouldn't happen, as it shows we're buggy -#if __HAIKU__ +#ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST syslog(LOG_ERR, "ServerApp %s: ServerWindow doesn't respond!\n", Signature()); #else @@ -289,17 +289,16 @@ ServerApp::Activate(bool value) fIsActive = value; - if (fIsActive) { - SetAppCursor(); - } + if (fIsActive) + SetCursor(); } //! Sets the cursor to the application cursor, if any. void -ServerApp::SetAppCursor() +ServerApp::SetCursor() { -// TODO: look into custom cursors... +// TODO: custom cursors cannot be drawn by the HWInterface right now (wrong bitmap format) // if (fAppCursor) // fDesktop->HWInterface()->SetCursor(fAppCursor); @@ -310,7 +309,7 @@ ServerApp::SetAppCursor() void ServerApp::_GetLooperName(char* name, size_t length) { -#ifdef __HAIKU__ +#ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST strlcpy(name, Signature(), length); #else strncpy(name, Signature(), length); @@ -891,10 +890,10 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) { STRACE(("ServerApp %s: SetCursor via cursor data\n", Signature())); // Attached data: 68 bytes of fAppCursor data - - int8 cdata[68]; - link.Read(cdata, 68); - + + int8 cursorData[68]; + link.Read(cursorData, 68); + // Because we don't want an overaccumulation of these particular // cursors, we will delete them if there is an existing one. It would // otherwise be easy to crash the server by calling SetCursor a @@ -902,7 +901,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) if (fAppCursor) fDesktop->GetCursorManager().DeleteCursor(fAppCursor->ID()); - fAppCursor = new ServerCursor(cdata); + fAppCursor = new ServerCursor(cursorData); fAppCursor->SetOwningTeam(fClientTeam); fAppCursor->SetAppSignature(Signature()); diff --git a/src/servers/app/ServerApp.h b/src/servers/app/ServerApp.h index a5290ed658..ee07f73851 100644 --- a/src/servers/app/ServerApp.h +++ b/src/servers/app/ServerApp.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2005, Haiku. + * Copyright 2001-2006, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -9,8 +9,8 @@ * Stefano Ceccherini (burton666@libero.it) * Axel Dörfler, axeld@pinc-software.de */ -#ifndef _SERVERAPP_H_ -#define _SERVERAPP_H_ +#ifndef SERVER_APP_H +#define SERVER_APP_H #include "MessageLooper.h" @@ -61,7 +61,8 @@ class ServerApp : public MessageLooper { void SendMessageToClient(BMessage* message) const; - void SetAppCursor(); + void SetCursor(); + ServerCursor* Cursor() const { return fAppCursor; } team_id ClientTeam() const; const char* Signature() const { return fSignature.String(); } @@ -104,9 +105,9 @@ class ServerApp : public MessageLooper { // To send a BMessage to the client // (port + token) - Desktop* fDesktop; - BString fSignature; - team_id fClientTeam; + Desktop* fDesktop; + BString fSignature; + team_id fClientTeam; mutable BLocker fWindowListLock; BObjectList fWindowList; @@ -130,4 +131,4 @@ class ServerApp : public MessageLooper { AreaPool fSharedMem; }; -#endif // _SERVERAPP_H_ +#endif // SERVER_APP_H diff --git a/src/servers/app/ServerScreen.cpp b/src/servers/app/ServerScreen.cpp index f950f9ab27..b16ced15b9 100644 --- a/src/servers/app/ServerScreen.cpp +++ b/src/servers/app/ServerScreen.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2005, Haiku, Inc. + * Copyright (c) 2001-2006, Haiku, Inc. * Distributed under the terms of the MIT license. * * Authors: @@ -165,7 +165,7 @@ Screen::_FindMode(uint16 width, uint16 height, uint32 colorspace, return err; } -#if __HAIKU__ +#ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST int32 index = _FindMode(dm, count, width, height, colorspace, frequency); if (index < 0) { fprintf(stderr, "mode not found (%d, %d, %f) -> ignoring frequency and using B_CMAP8!\n", width, height, frequency); diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index 5beb25f6da..3b21221777 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2005, Haiku. + * Copyright 2001-2006, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -1246,13 +1246,14 @@ ServerWindow::_DispatchViewMessage(int32 code, case AS_LAYER_CURSOR: { DTRACE(("ServerWindow %s: Message AS_LAYER_CURSOR: ViewLayer: %s - NOT IMPLEMENTED\n", Title(), fCurrentLayer->Name())); - int32 token; - + int32 token = -1; link.Read(&token); - // TODO: implement; I think each ViewLayer should have a member pointing - // to this requested cursor. + // TODO: this badly needs reference counting + ServerCursor* cursor = fDesktop->GetCursorManager().FindCursor(token); + fCurrentLayer->SetCursor(cursor); + // TODO: if fCurrentLayer is the view under the cursor, the appearance should change immediately! break; } case AS_LAYER_SET_FLAGS: @@ -1260,7 +1261,7 @@ ServerWindow::_DispatchViewMessage(int32 code, uint32 flags; link.Read(&flags); fCurrentLayer->SetFlags(flags); - + STRACE(("ServerWindow %s: Message AS_LAYER_SET_FLAGS: ViewLayer: %s\n", Title(), fCurrentLayer->Name())); break; } @@ -2402,7 +2403,7 @@ ServerWindow::_MessageLooper() if (code >= 0 && code < AS_LAST_CODE) { diff = system_time() - start; atomic_add(&sMessageProfile[code].count, 1); -#ifdef __HAIKU__ +#ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST atomic_add64(&sMessageProfile[code].time, diff); #else sMessageProfile[code].time += diff; diff --git a/src/servers/app/ViewLayer.cpp b/src/servers/app/ViewLayer.cpp index 8ae6a5a4f5..e060dbfab2 100644 --- a/src/servers/app/ViewLayer.cpp +++ b/src/servers/app/ViewLayer.cpp @@ -1,10 +1,11 @@ /* - * Copyright (c) 2001-2005, Haiku, Inc. + * Copyright (c) 2001-2006, Haiku, Inc. * Distributed under the terms of the MIT license. * * Authors: * DarkWyrm * Adi Oanca + * Axel Dörfler, axeld@pinc-software.de * Stephan Aßmus */ @@ -61,7 +62,8 @@ ViewLayer::ViewLayer(BRect frame, const char* name, fPreviousSibling(NULL), fNextSibling(NULL), fLastChild(NULL), - + + fCursor(NULL), fPicture(NULL), fLocalClipping(Bounds()), @@ -876,6 +878,13 @@ ViewLayer::SetEventMask(uint32 eventMask, uint32 options) } +void +ViewLayer::SetCursor(ServerCursor *cursor) +{ + fCursor = cursor; +} + + void ViewLayer::SetPicture(ServerPicture *picture) { diff --git a/src/servers/app/ViewLayer.h b/src/servers/app/ViewLayer.h index 1151834430..d9c81ece99 100644 --- a/src/servers/app/ViewLayer.h +++ b/src/servers/app/ViewLayer.h @@ -1,10 +1,11 @@ /* - * Copyright (c) 2001-2005, Haiku, Inc. + * Copyright (c) 2001-2006, Haiku, Inc. * Distributed under the terms of the MIT license. * * Authors: * DarkWyrm * Adi Oanca + * Axel Dörfler, axeld@pinc-software.de * Stephan Aßmus */ #ifndef VIEW_LAYER_H @@ -23,6 +24,7 @@ class DrawState; class DrawingEngine; class WindowLayer; class ServerBitmap; +class ServerCursor; class ServerPicture; class ViewLayer { @@ -147,8 +149,11 @@ class ViewLayer { uint32 EventOptions() const { return fEventOptions; } - void SetPicture(ServerPicture *picture); - ServerPicture *Picture() const; + ServerCursor* Cursor() const { return fCursor; } + void SetCursor(ServerCursor* cursor); + + ServerPicture* Picture() const; + void SetPicture(ServerPicture* picture); // for background clearing virtual void Draw(DrawingEngine* drawingEngine, @@ -221,7 +226,9 @@ class ViewLayer { ViewLayer* fNextSibling; ViewLayer* fLastChild; - ServerPicture *fPicture; + ServerCursor* fCursor; + ServerPicture* fPicture; + // clipping BRegion fLocalClipping; diff --git a/src/servers/app/WindowLayer.cpp b/src/servers/app/WindowLayer.cpp index fa94385697..248034f524 100644 --- a/src/servers/app/WindowLayer.cpp +++ b/src/servers/app/WindowLayer.cpp @@ -17,6 +17,7 @@ #include "DecorManager.h" #include "Desktop.h" #include "DrawingEngine.h" +#include "HWInterface.h" #include "MessagePrivate.h" #include "PortLink.h" #include "ServerApp.h" @@ -909,7 +910,8 @@ void WindowLayer::MouseMoved(BMessage *msg, BPoint where, int32* _viewToken, bool isLatestMouseMoved) { - if (ViewLayer* view = ViewAt(where)) + ViewLayer* view = ViewAt(where); + if (view != NULL) *_viewToken = view->Token(); // ignore pointer history @@ -978,6 +980,22 @@ WindowLayer::MouseMoved(BMessage *msg, BPoint where, int32* _viewToken, DesktopSettings desktopSettings(fDesktop); if (desktopSettings.MouseMode() != B_NORMAL_MOUSE && !IsFocus() && !(Flags() & B_AVOID_FOCUS)) fDesktop->SetFocusWindow(this); + + // mouse cursor + + if (IsFocus()) { + // TODO: there is more for real cursor support, ie. if a window is closed, + // new app cursor shouldn't override view cursor, ... + ServerCursor* currentCursor = fDesktop->HWInterface()->Cursor(); + ServerCursor* cursor = ServerWindow()->App()->Cursor(); + if (view != NULL && view->Cursor() != NULL) + cursor = view->Cursor(); + + if (cursor != currentCursor) { +// TODO: custom cursors cannot be drawn by the HWInterface right now (wrong bitmap format) +// fDesktop->HWInterface()->SetCursor(cursor); + } + } } diff --git a/src/servers/app/drawing/AccelerantHWInterface.cpp b/src/servers/app/drawing/AccelerantHWInterface.cpp index fdcdc59c39..51c2b6e865 100644 --- a/src/servers/app/drawing/AccelerantHWInterface.cpp +++ b/src/servers/app/drawing/AccelerantHWInterface.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2001-2005, Haiku. + * Copyright 2001-2006, Haiku. * Distributed under the terms of the MIT License. * * Authors: @@ -45,7 +45,7 @@ using std::nothrow; // This call updates the frame buffer used by the on-screen KDL -#ifdef __HAIKU__ +#ifndef HAIKU_TARGET_PLATFORM_LIBBE_TEST extern "C" status_t _kern_frame_buffer_update(void *baseAddress, int32 width, int32 height, int32 depth, int32 bytesPerRow); diff --git a/src/servers/app/drawing/HWInterface.cpp b/src/servers/app/drawing/HWInterface.cpp index d6f196f898..d70f84a8a1 100644 --- a/src/servers/app/drawing/HWInterface.cpp +++ b/src/servers/app/drawing/HWInterface.cpp @@ -1,9 +1,11 @@ -//------------------------------------------------------------------------------ -// Copyright 2005, Haiku, Inc. All rights reserved. -// Distributed under the terms of the MIT License. -// -// Author: Stephan Aßmus, -//------------------------------------------------------------------------------ +/* + * Copyright 2005-2006, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stephan Aßmus + */ + #include #include diff --git a/src/servers/app/drawing/HWInterface.h b/src/servers/app/drawing/HWInterface.h index 1c4094adc1..7e1eac6e16 100644 --- a/src/servers/app/drawing/HWInterface.h +++ b/src/servers/app/drawing/HWInterface.h @@ -1,13 +1,14 @@ -//------------------------------------------------------------------------------ -// Copyright 2005, Haiku, Inc. All rights reserved. -// Distributed under the terms of the MIT License. -// -// Author: Stephan Aßmus, -//------------------------------------------------------------------------------ - +/* + * Copyright 2005-2006, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * Stephan Aßmus + */ #ifndef HW_INTERFACE_H #define HW_INTERFACE_H + #include #include #include @@ -76,6 +77,7 @@ class HWInterface : public MultiLocker { virtual void InvertRegion(/*const*/ BRegion& region) {} // cursor handling (these do their own Read/Write locking) + ServerCursor* Cursor() const { return fCursor; } virtual void SetCursor(ServerCursor* cursor); virtual void SetCursorVisible(bool visible); bool IsCursorVisible();