History log of /haiku/src/servers/app/CursorManager.cpp
Revision Date Author Comments
# 60d30785 27-Aug-2020 X512 <danger_mail@list.ru>

app_server memory management fixes: use BReference

Use BReference for more automated reference counting in app_server,
fixing some use-after-free and other problems.

Extracted from https://review.haiku-os.org/c/haiku/+/2695

Change-Id: I141bb248229405896b29feff3338447f7257b0b4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3175
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# 06ed32b8 05-Oct-2020 Jérôme Duval <jerome.duval@gmail.com>

BCursor: add a constructor with bitmap and point

* enhancement #15169
* get_mouse_bitmap(): also reads the colorspace from app_server.
* docs and tests

Change-Id: Iba63f8a2789530ae596c30b92f14828f31761d98
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3292
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# eb69155b 04-Aug-2016 Axel Dörfler <axeld@pinc-software.de>

app_server: Fixed/documented uses of new without nothrow.

* This should fix all occurrences except for those in the drawing
sub directory.
* In some cases, the use of new without nothrow was okay, though.


# b809ff1c 20-Mar-2010 Stephan Aßmus <superstippi@gmx.de>

* Tweaked the thumbsize of the pointing hand cursors.
* Repurposed the FollowLink cursor as CreateLink cursor.
* Created a new FollowLink cursor based on a design by Justin Stressman, thanks!

It compiles and I proof-read the commit, otherwise I didn't test, yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35922 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e59dc33e 07-Mar-2010 Stephan Aßmus <superstippi@gmx.de>

* Added BCursorID enumeration in App Kit's Cursor.h and new constructor which
takes such an id.
* Reused the existing mechanism to to have hardcoded tokens for the system
cursors, i.e. removed cursor_which enumeration from ServerProtocol.h and
used BCursorID where cursor_which was previously used.
* Reworked CursorManager.h and CursorSet.h accordingly and removed some methods
that where intended to replace system cursors with client cursors, since
those would break the reference counting and forget to maintain the cursor
list.
* Replaced the cursors in CursorData.h/cpp with the new ones I just designed.
* Removed HaikuSystemCursor.h and HaikuLogo.h from the source, as those are/were
no longer used.

I hope I will not get too much beating for this one... :-) I know the new
default cursor is slightly larger, but I believe the old one was just too small.
Also I noticed that the cursor may be slightly too dark, at least the old one
seems noticeably brighter when compared side by side (the new one has a slight
gradient). That is something I may correct at least. Otherwise I hope nothing
is broken, I've tested in QEMU and so far everything works as intended.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35782 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4b0459b2 04-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Refactored ServerBitmap a bit: it now inherits from Referenceable instead of
roling its own solution.
* Also removed BitmapManager::DeleteBitmap() - you only call
ServerBitmap::RemoveReference(), and that one will notify the manager if
needed.
* Some more cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33878 a95241bf-73f2-0310-859d-f6bbb57e9c96


# efe72444 03-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

Added a comment that should make clear my last accidental commit doesn't fix anything.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19696 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c6f9f65d 03-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

At least temporary fix for the Deskbar not updating additional items (unless you resize it).
The problem was that the view's screen clipping was not updated if its frame did not change
because of a resized parent - but that might be needed if the new parent frame reveals a new
portion of that view.
I added a TODO so that if there is a way to test for this case, we only need to invalidate
the clipping if really needed. For now, we always do it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19695 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 23ae77aa 26-Apr-2006 Axel Dörfler <axeld@pinc-software.de>

* Removed ColorSet, it's no longer needed or used.
* The Decorator are temporarily using ui_color() - this needs to be changed
to use the DesktopSettings (when the decorator stuff gets refactored); right
now, the colors are fixed.
* Added B_WINDOW_TEXT_COLOR, B_WINDOW_INACTIVE_TAB_COLOR, and
B_WINDOW_INACTIVE_TEXT_COLOR to the UI colors, B_WINDOW_TAB_COLOR is no
longer deprecated. Note, however, that not every decorator may use these
colors.
* Removed unused and wrong (ie. hard-coded paths) stuff from ServerConfig.h.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17236 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d7e9392e 19-Mar-2006 Stephan Aßmus <superstippi@gmx.de>

forgot I made this change... added locking to
the lookup of a cursor


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16842 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 52cd65cd 28-Feb-2006 Axel Dörfler <axeld@pinc-software.de>

Fixed build for GCC 4, this closes bug #239.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16546 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 588259b6 26-Feb-2006 Stephan Aßmus <superstippi@gmx.de>

various changes to handling custom cursors:
* all cursors owned by a team are visually different,
or (iaw) an already existing cursor is reused when
it is set by the client again
* changed various occurances of cursor data from "int8*"
to "uint8*"
* ServerCursors also remember the R5 data from which
they were created
* the reference counting and destruction of
ServerCursors changed: The cursor knows it is attached
to a CursorManager and one can simply use
ServerCursor::Acquire() and Release() and the reference
counting and everything is being taken care of
* destroying a ViewLayer will now correctly release a set
ServerCursor
* fixed a race condition when setting a cursor through
BView::SetViewCursor(): If the client code looks like this:

BCursor cursor(cursorData);
someView->SetViewCursor(&cursor, false);

there is a relatively high chance the BCursor destructor
told the ServerApp thread to destroy the cursor before
the ServerWindow thread got to "acquire" the cursor for
use by the view layer. The very same problem is likely the
reason that SetViewCursor works to unreliably on R5, even
when the "sync" flag is set to "true" (although it should
theoretically work in that case).

all these fixes make WonderBrush work fine again with the
new support of custom cursors.... coded by axeld and myself
(the joys of pair programming :-)



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16521 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 195e980e 05-Feb-2006 Axel Dörfler <axeld@pinc-software.de>

* Cursors are now reference counted, so it shouldn't be possible anymore
to delete them accidently :)
* You should no longer call HWInterface::SetCursor(), but the new Desktop::SetCursor()
if you need to change the cursor.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16238 a95241bf-73f2-0310-859d-f6bbb57e9c96


# aa1f5437 05-Feb-2006 Axel Dörfler <axeld@pinc-software.de>

Some work on cursors:
* Fixed a myriad of bugs all over the place, ranging from locking errors to
deleting objects that don't belong to the one deleting them (hello HWInterface!)
* Almost all ServerWindow cursor stuff was broken; I've replaced all commands
to set a cursor with a single one AS_SET_CURSOR.
* Renamed some cursor commands.
* Changed the (broken) way ServerApp::fAppCursor was maintained - the application
cursor is now NULL as long as possible.
* Removed superfluous ServerCursor app signature stuff.
* The BApplication will no longer duplicate the default/I-beam cursors, it will
just reuse the default ones which now have fixed tokens.
* As a result, changing the cursor is now working as expected, closing bug #102.
* Rewrote Cursor.h, renamed private members to match our style guide.
* Minor cleanup.

What's still left to be done is reference counting the cursor objects to make them
work right and reliable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16237 a95241bf-73f2-0310-859d-f6bbb57e9c96


# be05d56c 14-Nov-2005 Axel Dörfler <axeld@pinc-software.de>

* the app_server now uses a global token space - this should later be changed to
have different token spaces depending on the scope of its objects.
* removed TokenHandler - we're now using BTokenSpace instead.
* removed unused IPoint.cpp - if we ever need it again, it can still easily be
resurrected from the dead.
* some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14925 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f38c001e 04-Nov-2005 Marcus Overhagen <marcusoverhagen@gmail.com>

Assigned names to "some BLocker"s to aid debugging.
Small cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14703 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 22137825 17-Jul-2005 Michael Lotz <mmlr@mlotz.ch>

All cursor related changes:

* Moved setting the default cursor from ServerScreen to Desktop
* Getting the default cursor is now done using the CursorManager
* Removed outdated setcursor from SysCursor.cpp (we have a new implementation by now)
* Renamed SysCursor.cpp to CursorSet.cpp as that's what it is
* Moved headers/private/app/SysCursor.h to headers/private/servers/app/CursorSet.h
* Removed some unneeded header includes along the way

There remains {set|get}_syscursor now in CursorSet.cpp. Serverside for these are not implemented
and they are obvious hacks. Do we need to keep them?
Also this commit _would_ break Appearance, but 1) all the related code is currently commented out
with the comment "cursor set management belongs in another app" and 2) it is already broken
because of ColorSet.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13726 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fc6c82dc 17-Jul-2005 Michael Lotz <mmlr@mlotz.ch>

Cleanup and style changes. Removed global cursormanager as each RootLayer has it's own.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13724 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 13b42e5e 12-Jul-2005 Michael Lotz <mmlr@mlotz.ch>

Just some style cleanups again. Sorry I couldn't resist, won't happen again ;-).

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13646 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c030c6fa 01-Jul-2005 Axel Dörfler <axeld@pinc-software.de>

As the comment says, deleting the cursor is not necessary.
But since every single cursor is owned by a team - why the cursor manager?
I must overlook something...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13385 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 33bbe223 24-Mar-2005 Axel Dörfler <axeld@pinc-software.de>

Moved app_server files to app/.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@11972 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b809ff1c59fc4e92cef50577e726f15cbda042e4 20-Mar-2010 Stephan Aßmus <superstippi@gmx.de>

* Tweaked the thumbsize of the pointing hand cursors.
* Repurposed the FollowLink cursor as CreateLink cursor.
* Created a new FollowLink cursor based on a design by Justin Stressman, thanks!

It compiles and I proof-read the commit, otherwise I didn't test, yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35922 a95241bf-73f2-0310-859d-f6bbb57e9c96


# e59dc33e215e8ae0a90b051e88c70f8aaff296a0 07-Mar-2010 Stephan Aßmus <superstippi@gmx.de>

* Added BCursorID enumeration in App Kit's Cursor.h and new constructor which
takes such an id.
* Reused the existing mechanism to to have hardcoded tokens for the system
cursors, i.e. removed cursor_which enumeration from ServerProtocol.h and
used BCursorID where cursor_which was previously used.
* Reworked CursorManager.h and CursorSet.h accordingly and removed some methods
that where intended to replace system cursors with client cursors, since
those would break the reference counting and forget to maintain the cursor
list.
* Replaced the cursors in CursorData.h/cpp with the new ones I just designed.
* Removed HaikuSystemCursor.h and HaikuLogo.h from the source, as those are/were
no longer used.

I hope I will not get too much beating for this one... :-) I know the new
default cursor is slightly larger, but I believe the old one was just too small.
Also I noticed that the cursor may be slightly too dark, at least the old one
seems noticeably brighter when compared side by side (the new one has a slight
gradient). That is something I may correct at least. Otherwise I hope nothing
is broken, I've tested in QEMU and so far everything works as intended.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35782 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4b0459b2eef38f07b8c0c4426860dccb61a1134a 04-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* Refactored ServerBitmap a bit: it now inherits from Referenceable instead of
roling its own solution.
* Also removed BitmapManager::DeleteBitmap() - you only call
ServerBitmap::RemoveReference(), and that one will notify the manager if
needed.
* Some more cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33878 a95241bf-73f2-0310-859d-f6bbb57e9c96


# efe72444365818f326d6d8e8fe17113ce2eb9f62 03-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

Added a comment that should make clear my last accidental commit doesn't fix anything.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19696 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c6f9f65dff468f7f1a495f49b547f2833ace03dd 03-Jan-2007 Axel Dörfler <axeld@pinc-software.de>

At least temporary fix for the Deskbar not updating additional items (unless you resize it).
The problem was that the view's screen clipping was not updated if its frame did not change
because of a resized parent - but that might be needed if the new parent frame reveals a new
portion of that view.
I added a TODO so that if there is a way to test for this case, we only need to invalidate
the clipping if really needed. For now, we always do it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19695 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 23ae77aa566566465e1fca7aedbf0f1139acca1e 26-Apr-2006 Axel Dörfler <axeld@pinc-software.de>

* Removed ColorSet, it's no longer needed or used.
* The Decorator are temporarily using ui_color() - this needs to be changed
to use the DesktopSettings (when the decorator stuff gets refactored); right
now, the colors are fixed.
* Added B_WINDOW_TEXT_COLOR, B_WINDOW_INACTIVE_TAB_COLOR, and
B_WINDOW_INACTIVE_TEXT_COLOR to the UI colors, B_WINDOW_TAB_COLOR is no
longer deprecated. Note, however, that not every decorator may use these
colors.
* Removed unused and wrong (ie. hard-coded paths) stuff from ServerConfig.h.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17236 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d7e9392e255f938ea409c481adafa03257b2b811 19-Mar-2006 Stephan Aßmus <superstippi@gmx.de>

forgot I made this change... added locking to
the lookup of a cursor


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16842 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 52cd65cdf488228e1244fcdaafb25ad505aae095 28-Feb-2006 Axel Dörfler <axeld@pinc-software.de>

Fixed build for GCC 4, this closes bug #239.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16546 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 588259b66d15a3bde1fae53833230bbe28a4e8b0 26-Feb-2006 Stephan Aßmus <superstippi@gmx.de>

various changes to handling custom cursors:
* all cursors owned by a team are visually different,
or (iaw) an already existing cursor is reused when
it is set by the client again
* changed various occurances of cursor data from "int8*"
to "uint8*"
* ServerCursors also remember the R5 data from which
they were created
* the reference counting and destruction of
ServerCursors changed: The cursor knows it is attached
to a CursorManager and one can simply use
ServerCursor::Acquire() and Release() and the reference
counting and everything is being taken care of
* destroying a ViewLayer will now correctly release a set
ServerCursor
* fixed a race condition when setting a cursor through
BView::SetViewCursor(): If the client code looks like this:

BCursor cursor(cursorData);
someView->SetViewCursor(&cursor, false);

there is a relatively high chance the BCursor destructor
told the ServerApp thread to destroy the cursor before
the ServerWindow thread got to "acquire" the cursor for
use by the view layer. The very same problem is likely the
reason that SetViewCursor works to unreliably on R5, even
when the "sync" flag is set to "true" (although it should
theoretically work in that case).

all these fixes make WonderBrush work fine again with the
new support of custom cursors.... coded by axeld and myself
(the joys of pair programming :-)



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16521 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 195e980ef10d42d13bf8f4360d81eebda3b8417e 05-Feb-2006 Axel Dörfler <axeld@pinc-software.de>

* Cursors are now reference counted, so it shouldn't be possible anymore
to delete them accidently :)
* You should no longer call HWInterface::SetCursor(), but the new Desktop::SetCursor()
if you need to change the cursor.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16238 a95241bf-73f2-0310-859d-f6bbb57e9c96


# aa1f5437999ab8531f33139c129c6bcaceb74e7a 05-Feb-2006 Axel Dörfler <axeld@pinc-software.de>

Some work on cursors:
* Fixed a myriad of bugs all over the place, ranging from locking errors to
deleting objects that don't belong to the one deleting them (hello HWInterface!)
* Almost all ServerWindow cursor stuff was broken; I've replaced all commands
to set a cursor with a single one AS_SET_CURSOR.
* Renamed some cursor commands.
* Changed the (broken) way ServerApp::fAppCursor was maintained - the application
cursor is now NULL as long as possible.
* Removed superfluous ServerCursor app signature stuff.
* The BApplication will no longer duplicate the default/I-beam cursors, it will
just reuse the default ones which now have fixed tokens.
* As a result, changing the cursor is now working as expected, closing bug #102.
* Rewrote Cursor.h, renamed private members to match our style guide.
* Minor cleanup.

What's still left to be done is reference counting the cursor objects to make them
work right and reliable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16237 a95241bf-73f2-0310-859d-f6bbb57e9c96


# be05d56c7eea834b5983ba3411d79fabd8b616b7 14-Nov-2005 Axel Dörfler <axeld@pinc-software.de>

* the app_server now uses a global token space - this should later be changed to
have different token spaces depending on the scope of its objects.
* removed TokenHandler - we're now using BTokenSpace instead.
* removed unused IPoint.cpp - if we ever need it again, it can still easily be
resurrected from the dead.
* some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14925 a95241bf-73f2-0310-859d-f6bbb57e9c96


# f38c001e5661d4664cf31ea429ef1bc7f87e7dd0 04-Nov-2005 Marcus Overhagen <marcusoverhagen@gmail.com>

Assigned names to "some BLocker"s to aid debugging.
Small cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14703 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2213782534a8b17fdea5d7fc603360f4c9ac317e 17-Jul-2005 Michael Lotz <mmlr@mlotz.ch>

All cursor related changes:

* Moved setting the default cursor from ServerScreen to Desktop
* Getting the default cursor is now done using the CursorManager
* Removed outdated setcursor from SysCursor.cpp (we have a new implementation by now)
* Renamed SysCursor.cpp to CursorSet.cpp as that's what it is
* Moved headers/private/app/SysCursor.h to headers/private/servers/app/CursorSet.h
* Removed some unneeded header includes along the way

There remains {set|get}_syscursor now in CursorSet.cpp. Serverside for these are not implemented
and they are obvious hacks. Do we need to keep them?
Also this commit _would_ break Appearance, but 1) all the related code is currently commented out
with the comment "cursor set management belongs in another app" and 2) it is already broken
because of ColorSet.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13726 a95241bf-73f2-0310-859d-f6bbb57e9c96


# fc6c82dc354bd21e1b3e18e9f3f202d885ca511f 17-Jul-2005 Michael Lotz <mmlr@mlotz.ch>

Cleanup and style changes. Removed global cursormanager as each RootLayer has it's own.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13724 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 13b42e5eb43bd33904633f3a14d058fe4ec5b695 12-Jul-2005 Michael Lotz <mmlr@mlotz.ch>

Just some style cleanups again. Sorry I couldn't resist, won't happen again ;-).

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13646 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c030c6fa68e6c6622abfbf769a5101c3b0ce0a31 01-Jul-2005 Axel Dörfler <axeld@pinc-software.de>

As the comment says, deleting the cursor is not necessary.
But since every single cursor is owned by a team - why the cursor manager?
I must overlook something...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13385 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 33bbe223914093509b4bc56bea8a90c81af80a37 24-Mar-2005 Axel Dörfler <axeld@pinc-software.de>

Moved app_server files to app/.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@11972 a95241bf-73f2-0310-859d-f6bbb57e9c96