History log of /haiku/src/kits/app/Cursor.cpp
Revision Date Author Comments
# 0cdb3238 11-Dec-2021 Augustin Cavalier <waddlesplash@gmail.com>

app_server & Application Kit: Fix bitmap cursor handling.

Using a memcpy here is supremely dangerous, because we are writing to
an app_server buffer that we chose the length for, but using a size
that came from the client. And, indeed, because the buffer can contain
padding if the BBitmap was allocated with a non-standard BytesPerRow,
we will overflow the buffer and corrupt memory, causing app_server to crash.

So, instead, reorganize parameters a bit, and pass BytesPerRow along
with the other data needed to instantiate the bitmap, and then use
ImportBits.

Fixes an app_server crash I triggered with the experimental libX11
compatibility layer.


# 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>


# 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


# 19e179ca 19-Jun-2009 Stephan Aßmus <superstippi@gmx.de>

* Moved the implementation of SetViewCursor from the thread of the
window of the view into the application thread. This solves the
race condition with asynchronous SetViewCursor and deleting the
cursor immediately afterwards for real.
* The ServerApp now requires a reference to the current cursor,
just in case...
* Added TODOs for caching the BView token, it's currently resolved
for every single BView call that talks to the server... not good!


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


# 5d62f8e0 20-Jun-2009 Stephan Aßmus <superstippi@gmx.de>

Make it possible to properly use operator= on BCursors by making sure the
reference counting is maintained correctly in the app_server. While reviewing
this code, I have my doubts that my previous solution for handling pending
SetViewCursor() calls is always working as it is intended.


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


# 16ed1e1d 18-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

* Removed headers/private/servers/app - everything is in src/servers/app now.
* Removed DisplaySupport.h, wasn't needed anymore.
* Removed private color set functions from InterfaceDefs.cpp - we might want
something similar, but definitely not like that.
* Minor cleanup, added some missing licenses.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16831 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


# 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


# 1156138b 01-Nov-2005 Axel Dörfler <axeld@pinc-software.de>

Removed unused files like PortMessage.cpp/h and Session.cpp/h.
Renamed LinkMsgReceiver.h and LinkMsgSender.h to LinkReceiver.h and LinkSender.h like
the classes they contain.
Split up PortLink.cpp/h into ServerLink.cpp/h and PortLink.cpp/h.


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


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

Renamed BAppServerLink to AppServerLink, BPortLink to PortLink, LinkMsgReader
to LinkReceiver, LinkMsgSender to LinkSender, and put everything into the
BPrivate namespace.
Made AppServerLink a cheap object - it will use the applications receiver/sender
and not create its own buffers.
Fixed broken communication stuff here and there (mostly Font.cpp).
Put the newly introduced set|get_system_colors() into the BPrivate namespace -
please don't introduce private functions into the public namespace!!!
Also fixed their broken communication use, as Darkwyrm obviously forgot about
it again: the sequence Flush(); GetNextMessage() without error checking is
purely wrong and can make the app hang and/or crash! :-)
Other minor cleanup.
The input_server used some test mode with the haiku build target which is
probably wrong.
Hopefully I did not forget anything this time.


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


# 3ceb31b9 30-Jul-2004 DarkWyrm <darkwyrm@gmail.com>

Pahtz's changes from PortLink/BSession/PortMessage/PortQueue to BPortLink


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


# 917cf3f7 27-Jun-2004 Axel Dörfler <axeld@pinc-software.de>

Constructor no longer crashes when data == NULL.
Now exports B_CURSOR_SYSTEM_DEFAULT and B_CURSOR_I_BEAM - maybe they should
be part of AppDefs.cpp, though.
Style update.


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


# 45799af7 04-Oct-2003 DarkWyrm <darkwyrm@gmail.com>

Tweaked all messaging classes to comply with new message protocol policies
AppServerLink no longer inherits from BSession
Modified client files which talk to the server to sync with changes in messaging classes


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


# 591d280e 03-Oct-2003 DarkWyrm <darkwyrm@gmail.com>

Added PortMessage::ReadString and PortLink::AttachString to support BSession-style string attachments
Tweaks to startup code for BApplication
Tweaked PortQueue to utilize the BSession workaround for PortMessages
Tweaks to message protocol for BCursor


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


# 594cf26a 01-Oct-2003 DarkWyrm <darkwyrm@gmail.com>

Conversion over to BSession API


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


# 1e56330f 17-Sep-2003 DarkWyrm <darkwyrm@gmail.com>

Updated constructor to use newer replay API
Tweaked messaging so that things should work properly now


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


# faa6a273 10-Jul-2003 DarkWyrm <darkwyrm@gmail.com>

Simplfied AppServerLink interface


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


# c27b0019 22-Jun-2003 shadow303 <shadow303@nowhere.fake>

gcc3 cleanup & fix stupid mistake


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


# 364bb57e 24-Feb-2003 DarkWyrm <darkwyrm@gmail.com>

Updated sources to reflect changes in <ServerProtocol.h>


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


# 18d65fb5 11-Nov-2002 shadow303 <shadow303@nowhere.fake>

Include ServerProtocol.h instead of using #define SET_CURSOR_BCURSOR


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


# e4840f5b 02-Nov-2002 DarkWyrm <darkwyrm@gmail.com>

Checkin for Gabe Yoder


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


# 52a38012 08-Jul-2002 ejakowatz <ejakowatz@nowhere.fake>

It is accomplished ...


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10 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


# 19e179ca4ff838084b9abb0dd19932ac5fcd0051 19-Jun-2009 Stephan Aßmus <superstippi@gmx.de>

* Moved the implementation of SetViewCursor from the thread of the
window of the view into the application thread. This solves the
race condition with asynchronous SetViewCursor and deleting the
cursor immediately afterwards for real.
* The ServerApp now requires a reference to the current cursor,
just in case...
* Added TODOs for caching the BView token, it's currently resolved
for every single BView call that talks to the server... not good!


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


# 5d62f8e0e50738a4274fbe53d73795809ac7d2c5 20-Jun-2009 Stephan Aßmus <superstippi@gmx.de>

Make it possible to properly use operator= on BCursors by making sure the
reference counting is maintained correctly in the app_server. While reviewing
this code, I have my doubts that my previous solution for handling pending
SetViewCursor() calls is always working as it is intended.


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


# 16ed1e1d15aac69c945890e5d5990bb41d9f4303 18-Mar-2006 Axel Dörfler <axeld@pinc-software.de>

* Removed headers/private/servers/app - everything is in src/servers/app now.
* Removed DisplaySupport.h, wasn't needed anymore.
* Removed private color set functions from InterfaceDefs.cpp - we might want
something similar, but definitely not like that.
* Minor cleanup, added some missing licenses.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16831 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


# 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


# 1156138b2f9c9c85e0fe2538a1186d522d978d31 01-Nov-2005 Axel Dörfler <axeld@pinc-software.de>

Removed unused files like PortMessage.cpp/h and Session.cpp/h.
Renamed LinkMsgReceiver.h and LinkMsgSender.h to LinkReceiver.h and LinkSender.h like
the classes they contain.
Split up PortLink.cpp/h into ServerLink.cpp/h and PortLink.cpp/h.


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


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

Renamed BAppServerLink to AppServerLink, BPortLink to PortLink, LinkMsgReader
to LinkReceiver, LinkMsgSender to LinkSender, and put everything into the
BPrivate namespace.
Made AppServerLink a cheap object - it will use the applications receiver/sender
and not create its own buffers.
Fixed broken communication stuff here and there (mostly Font.cpp).
Put the newly introduced set|get_system_colors() into the BPrivate namespace -
please don't introduce private functions into the public namespace!!!
Also fixed their broken communication use, as Darkwyrm obviously forgot about
it again: the sequence Flush(); GetNextMessage() without error checking is
purely wrong and can make the app hang and/or crash! :-)
Other minor cleanup.
The input_server used some test mode with the haiku build target which is
probably wrong.
Hopefully I did not forget anything this time.


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


# 3ceb31b96aefa3601ccc51e415da557b00155d4f 30-Jul-2004 DarkWyrm <darkwyrm@gmail.com>

Pahtz's changes from PortLink/BSession/PortMessage/PortQueue to BPortLink


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


# 917cf3f748cfaedabb84d64e97e0289f10fa557c 27-Jun-2004 Axel Dörfler <axeld@pinc-software.de>

Constructor no longer crashes when data == NULL.
Now exports B_CURSOR_SYSTEM_DEFAULT and B_CURSOR_I_BEAM - maybe they should
be part of AppDefs.cpp, though.
Style update.


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


# 45799af7b5a1c99be09517235670c8975e95cb93 04-Oct-2003 DarkWyrm <darkwyrm@gmail.com>

Tweaked all messaging classes to comply with new message protocol policies
AppServerLink no longer inherits from BSession
Modified client files which talk to the server to sync with changes in messaging classes


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


# 591d280e6c7b568f44375d13b8f0fdd33b8bd0eb 03-Oct-2003 DarkWyrm <darkwyrm@gmail.com>

Added PortMessage::ReadString and PortLink::AttachString to support BSession-style string attachments
Tweaks to startup code for BApplication
Tweaked PortQueue to utilize the BSession workaround for PortMessages
Tweaks to message protocol for BCursor


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


# 594cf26a76956cade8fa8134cc9e687fa46d42d9 01-Oct-2003 DarkWyrm <darkwyrm@gmail.com>

Conversion over to BSession API


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


# 1e56330f9abb454b62ea1410b0e497cd17cddd2b 17-Sep-2003 DarkWyrm <darkwyrm@gmail.com>

Updated constructor to use newer replay API
Tweaked messaging so that things should work properly now


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


# faa6a27319bb6ab1226fbb4be156cdfea2124503 10-Jul-2003 DarkWyrm <darkwyrm@gmail.com>

Simplfied AppServerLink interface


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


# c27b0019d6e7abfb3ee648e275185a1ac9329a19 22-Jun-2003 shadow303 <shadow303@nowhere.fake>

gcc3 cleanup & fix stupid mistake


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


# 364bb57e766ce59a1ab1b1bb85a9257df69d127c 24-Feb-2003 DarkWyrm <darkwyrm@gmail.com>

Updated sources to reflect changes in <ServerProtocol.h>


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


# 18d65fb5c01b4ffcc67aea3630e4986d8074ee9f 11-Nov-2002 shadow303 <shadow303@nowhere.fake>

Include ServerProtocol.h instead of using #define SET_CURSOR_BCURSOR


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


# e4840f5bd2af6ad68330af32f9d27e0e81148382 02-Nov-2002 DarkWyrm <darkwyrm@gmail.com>

Checkin for Gabe Yoder


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


# 52a380120846174213ccce9c4aab0dda17c72083 08-Jul-2002 ejakowatz <ejakowatz@nowhere.fake>

It is accomplished ...


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