* The ServerApp now has the concept of a current cursor: this is either the cursor
of the view currently under the mouse, or the application cursor, if the view doesn't have its own cursor (ie. it will no longer set the wrong cursor in certain situations). * AS_DELETE_CURSOR has no longer an influence on the application cursor, as this grabs a ref for its own use - this fixes bug #275. * AS_SET_CURSOR no longer sets the cursor when the application is not active. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16678 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -91,6 +91,7 @@ ServerApp::ServerApp(Desktop* desktop, port_id clientReplyPort,
|
|||||||
fClientTeam(clientTeam),
|
fClientTeam(clientTeam),
|
||||||
fWindowListLock("window list"),
|
fWindowListLock("window list"),
|
||||||
fAppCursor(NULL),
|
fAppCursor(NULL),
|
||||||
|
fViewCursor(NULL),
|
||||||
fCursorHideLevel(0),
|
fCursorHideLevel(0),
|
||||||
fIsActive(false),
|
fIsActive(false),
|
||||||
fSharedMem("shared memory", 32768)
|
fSharedMem("shared memory", 32768)
|
||||||
@@ -281,17 +282,29 @@ ServerApp::Activate(bool value)
|
|||||||
|
|
||||||
fIsActive = value;
|
fIsActive = value;
|
||||||
|
|
||||||
if (fIsActive)
|
if (fIsActive) {
|
||||||
SetCursor();
|
// Set the cursor to the application cursor, if any
|
||||||
|
fDesktop->SetCursor(CurrentCursor());
|
||||||
|
fDesktop->HWInterface()->SetCursorVisible(fCursorHideLevel == 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Sets the cursor to the application cursor, if any.
|
|
||||||
void
|
void
|
||||||
ServerApp::SetCursor()
|
ServerApp::SetCurrentCursor(ServerCursor* cursor)
|
||||||
{
|
{
|
||||||
fDesktop->SetCursor(fAppCursor);
|
fViewCursor = cursor;
|
||||||
fDesktop->HWInterface()->SetCursorVisible(fCursorHideLevel == 0);
|
fDesktop->SetCursor(CurrentCursor());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ServerCursor*
|
||||||
|
ServerApp::CurrentCursor() const
|
||||||
|
{
|
||||||
|
if (fViewCursor != NULL)
|
||||||
|
return fViewCursor;
|
||||||
|
|
||||||
|
return fAppCursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -928,6 +941,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
case AS_SET_CURSOR:
|
case AS_SET_CURSOR:
|
||||||
{
|
{
|
||||||
STRACE(("ServerApp %s: SetCursor\n", Signature()));
|
STRACE(("ServerApp %s: SetCursor\n", Signature()));
|
||||||
|
|
||||||
// Attached data:
|
// Attached data:
|
||||||
// 1) bool flag to send a reply
|
// 1) bool flag to send a reply
|
||||||
// 2) int32 token ID of the cursor to set
|
// 2) int32 token ID of the cursor to set
|
||||||
@@ -941,13 +955,11 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
|
|
||||||
ServerCursor* oldCursor = fAppCursor;
|
ServerCursor* oldCursor = fAppCursor;
|
||||||
fAppCursor = fDesktop->GetCursorManager().FindCursor(token);
|
fAppCursor = fDesktop->GetCursorManager().FindCursor(token);
|
||||||
if (fAppCursor != NULL) {
|
if (fAppCursor != NULL)
|
||||||
fAppCursor->Acquire();
|
fAppCursor->Acquire();
|
||||||
fDesktop->HWInterface()->SetCursor(fAppCursor);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: This is wrong: We need to take view cursors into account here!
|
if (fIsActive)
|
||||||
fDesktop->SetCursor(fAppCursor);
|
fDesktop->SetCursor(CurrentCursor());
|
||||||
|
|
||||||
if (oldCursor != NULL)
|
if (oldCursor != NULL)
|
||||||
oldCursor->Release();
|
oldCursor->Release();
|
||||||
@@ -1014,9 +1026,6 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
if (link.Read<bool>(&pendingViewCursor) != B_OK)
|
if (link.Read<bool>(&pendingViewCursor) != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (fAppCursor && fAppCursor->Token() == token)
|
|
||||||
fAppCursor = NULL;
|
|
||||||
|
|
||||||
ServerCursor* cursor = fDesktop->GetCursorManager().FindCursor(token);
|
ServerCursor* cursor = fDesktop->GetCursorManager().FindCursor(token);
|
||||||
if (cursor) {
|
if (cursor) {
|
||||||
if (pendingViewCursor)
|
if (pendingViewCursor)
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ class ServerApp : public MessageLooper {
|
|||||||
|
|
||||||
void SendMessageToClient(BMessage* message) const;
|
void SendMessageToClient(BMessage* message) const;
|
||||||
|
|
||||||
void SetCursor();
|
void SetCurrentCursor(ServerCursor* cursor);
|
||||||
ServerCursor* Cursor() const { return fAppCursor; }
|
ServerCursor* CurrentCursor() const;
|
||||||
|
|
||||||
team_id ClientTeam() const;
|
team_id ClientTeam() const;
|
||||||
const char* Signature() const { return fSignature.String(); }
|
const char* Signature() const { return fSignature.String(); }
|
||||||
@@ -74,16 +74,16 @@ class ServerApp : public MessageLooper {
|
|||||||
|
|
||||||
int32 CountBitmaps() const;
|
int32 CountBitmaps() const;
|
||||||
ServerBitmap* FindBitmap(int32 token) const;
|
ServerBitmap* FindBitmap(int32 token) const;
|
||||||
|
|
||||||
int32 CountPictures() const;
|
int32 CountPictures() const;
|
||||||
ServerPicture* CreatePicture(const ServerPicture* original = NULL);
|
ServerPicture* CreatePicture(const ServerPicture* original = NULL);
|
||||||
ServerPicture* FindPicture(const int32& token) const;
|
ServerPicture* FindPicture(const int32& token) const;
|
||||||
bool DeletePicture(const int32& token);
|
bool DeletePicture(const int32& token);
|
||||||
|
|
||||||
AreaPool* AppAreaPool() { return &fSharedMem; }
|
AreaPool* AppAreaPool() { return &fSharedMem; }
|
||||||
|
|
||||||
Desktop* GetDesktop() const { return fDesktop; }
|
Desktop* GetDesktop() const { return fDesktop; }
|
||||||
|
|
||||||
BPrivate::BTokenSpace& ViewTokens() { return fViewTokens; }
|
BPrivate::BTokenSpace& ViewTokens() { return fViewTokens; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -123,6 +123,7 @@ class ServerApp : public MessageLooper {
|
|||||||
BList fPictureList;
|
BList fPictureList;
|
||||||
|
|
||||||
ServerCursor* fAppCursor;
|
ServerCursor* fAppCursor;
|
||||||
|
ServerCursor* fViewCursor;
|
||||||
int32 fCursorHideLevel;
|
int32 fCursorHideLevel;
|
||||||
// 0 = cursor visible
|
// 0 = cursor visible
|
||||||
|
|
||||||
|
|||||||
@@ -590,7 +590,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
}
|
}
|
||||||
case AS_SEND_BEHIND:
|
case AS_SEND_BEHIND:
|
||||||
{
|
{
|
||||||
STRACE(("ServerWindow %s: Message Send_Behind unimplemented\n", Title()));
|
STRACE(("ServerWindow %s: Message AS_SEND_BEHIND\n", Title()));
|
||||||
int32 token;
|
int32 token;
|
||||||
team_id teamID;
|
team_id teamID;
|
||||||
status_t status;
|
status_t status;
|
||||||
@@ -650,7 +650,7 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
|||||||
}
|
}
|
||||||
case AS_NEEDS_UPDATE:
|
case AS_NEEDS_UPDATE:
|
||||||
{
|
{
|
||||||
STRACE(("ServerWindow %s: Message Needs_Update unimplemented\n", Title()));
|
STRACE(("ServerWindow %s: Message AS_NEEDS_UPDATE\n", Title()));
|
||||||
if (fWindowLayer->NeedsUpdate())
|
if (fWindowLayer->NeedsUpdate())
|
||||||
fLink.StartMessage(B_OK);
|
fLink.StartMessage(B_OK);
|
||||||
else
|
else
|
||||||
@@ -1240,7 +1240,9 @@ ServerWindow::_DispatchViewMessage(int32 code,
|
|||||||
}
|
}
|
||||||
case AS_LAYER_SET_CURSOR:
|
case AS_LAYER_SET_CURSOR:
|
||||||
{
|
{
|
||||||
DTRACE(("ServerWindow %s: Message AS_LAYER_CURSOR: ViewLayer: %s - NOT IMPLEMENTED\n", Title(), fCurrentLayer->Name()));
|
DTRACE(("ServerWindow %s: Message AS_LAYER_CURSOR: ViewLayer: %s\n", Title(),
|
||||||
|
fCurrentLayer->Name()));
|
||||||
|
|
||||||
int32 token;
|
int32 token;
|
||||||
if (link.Read<int32>(&token) != B_OK)
|
if (link.Read<int32>(&token) != B_OK)
|
||||||
break;
|
break;
|
||||||
@@ -1253,7 +1255,7 @@ ServerWindow::_DispatchViewMessage(int32 code,
|
|||||||
fDesktop->UnlockSingleWindow();
|
fDesktop->UnlockSingleWindow();
|
||||||
|
|
||||||
if (fDesktop->EventDispatcher().ViewUnderMouse(fEventTarget) == fCurrentLayer->Token())
|
if (fDesktop->EventDispatcher().ViewUnderMouse(fEventTarget) == fCurrentLayer->Token())
|
||||||
fDesktop->SetCursor(cursor);
|
fServerApp->SetCurrentCursor(cursor);
|
||||||
|
|
||||||
fDesktop->LockSingleWindow();
|
fDesktop->LockSingleWindow();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -990,12 +990,7 @@ WindowLayer::MouseMoved(BMessage *msg, BPoint where, int32* _viewToken,
|
|||||||
if (IsFocus()) {
|
if (IsFocus()) {
|
||||||
// TODO: there is more for real cursor support, ie. if a window is closed,
|
// TODO: there is more for real cursor support, ie. if a window is closed,
|
||||||
// new app cursor shouldn't override view cursor, ...
|
// new app cursor shouldn't override view cursor, ...
|
||||||
ServerCursor* cursor = ServerWindow()->App()->Cursor();
|
ServerWindow()->App()->SetCurrentCursor(view != NULL ? view->Cursor() : NULL);
|
||||||
|
|
||||||
if (view != NULL && view->Cursor() != NULL)
|
|
||||||
cursor = view->Cursor();
|
|
||||||
|
|
||||||
fDesktop->SetCursor(cursor);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user