Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: System cursors  (Read 10510 times)

0 Members and 1 Guest are viewing this topic.

cheeseboy

  • Newbie
  • *
  • Posts: 36
    • View Profile
System cursors
« on: January 19, 2015, 09:43:19 pm »
I would like to be able to set the mouse cursor to the OS's built in cursors (arrow, edit wait, regular etc).

There's example here: https://github.com/SFML/SFML/wiki/Tutorial:-Change-Cursor. Is there some reason this feature isn't included in sfml?

thomas9459

  • Newbie
  • *
  • Posts: 49
    • View Profile
    • Email
Re: System cursors
« Reply #1 on: January 19, 2015, 10:20:07 pm »
Here is a quote from the tutorial you linked to:

Quote
Since SFML is not a framework nor a GUI system providing a native function for changing the mouse cursor doesn't fit its purpose.

So while it would be a useful feature, it just doesn't fit under the scope of SFML. Besides, the tutorial provides you a way to do it easily without needing SFML to do anything to support it.

cheeseboy

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: System cursors
« Reply #2 on: January 19, 2015, 10:26:27 pm »
Yet, sfml has functions to handle the mouse, including one to set the mouse cursor (to img). It seems kind of half-assed to ignore the system cursors, but whatever.

Hapax

  • Hero Member
  • *****
  • Posts: 3383
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: System cursors
« Reply #3 on: January 19, 2015, 10:28:52 pm »
Yes, SFML handles the mouse. The mouse is an input device. The cursor, however, is a GUI element.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: System cursors
« Reply #4 on: January 19, 2015, 10:32:13 pm »
Have you first read the 4 or 5 threads about this feature on this forum (to avoid repeating ourselves ;))?
Laurent Gomila - SFML developer

cheeseboy

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: System cursors
« Reply #5 on: January 19, 2015, 10:32:38 pm »
but it does handle the cursor too, although it can only currently hide it

setMouseCursorVisible()

Edit: I saw only one topic on this here in feature requests and there was no clear explanation why you would support a function to handle the cursor visibility but none to get/ handle the system's built in cursors.
« Last Edit: January 19, 2015, 10:36:49 pm by cheeseboy »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: System cursors
« Reply #6 on: January 19, 2015, 10:51:43 pm »
Searching "cursor" on the "Feature requests" forum yields many answers, and I could count at least 4 relevant threads.

There's even an open issue on the bug tracker...
https://github.com/SFML/SFML/issues/269
Laurent Gomila - SFML developer

cheeseboy

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: System cursors
« Reply #7 on: January 19, 2015, 10:58:13 pm »
My fault. I didn't realize default search only gave 6 or so results. Anyways that issues 3 years old. All the codes there on wiki so why isn't it added?

Hapax

  • Hero Member
  • *****
  • Posts: 3383
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: System cursors
« Reply #8 on: January 20, 2015, 02:56:24 am »
why you would support a function to handle the cursor visibility
So that we can draw a sprite in its place, or just get it out of the way of our beautiful SFML game window, maybe? ;D

All the codes there on wiki so why isn't it added?
Not exactly. I don't see any code for Mac implementation. SFML is cross-platform.
In addition, if the ability to change hardware cursor to inbuilt ones is added to SFML, why wouldn't the ability to use custom hardware cursors be added?
I'd be all for it if it was added but I don't think it's necessary. It's not something I can't live without. It's not something I'd be holding my breath for.
It's not something that already fully exists in a complete state on the wiki :P
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

cheeseboy

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: System cursors
« Reply #9 on: January 20, 2015, 05:03:26 am »
why you would support a function to handle the cursor visibility
So that we can draw a sprite in its place, or just get it out of the way of our beautiful SFML game window, maybe? ;D

Way to take that out of context. You argued that sfml doesn't handle the cursor, From it's ability to show / hide the cursor it clearly does....

cheeseboy

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: System cursors
« Reply #10 on: January 20, 2015, 05:03:47 am »
why you would support a function to handle the cursor visibility
So that we can draw a sprite in its place, or just get it out of the way of our beautiful SFML game window, maybe? ;D
Way to take that out of context. You argued that sfml doesn't handle the cursor, From it's ability to show / hide the cursor it clearly does....

Gambit

  • Sr. Member
  • ****
  • Posts: 283
    • View Profile
Re: System cursors
« Reply #11 on: January 20, 2015, 06:06:28 am »
SFML doesnt support cursors, being the ability to change the cursor. If you want a custom cursor, bundle some cursor images with your game, hide the original cursor, and draw a custom one in it's place.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: System cursors
« Reply #12 on: January 20, 2015, 07:44:20 am »
The issue exists on the tracker, so it's been validated, no need to discuss whether or not it's in SFML's scope. Why isn't it implemented yet? Because it has low priority compared to other important tasks. If you want to submit a pull request, that would certainly help ;)
Laurent Gomila - SFML developer

cheeseboy

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: System cursors
« Reply #13 on: January 20, 2015, 05:18:13 pm »
Well I tried...

static void testCookie (xcb_void_cookie_t cookie, xcb_connection_t *connection, char *errMessage )
{  
        xcb_generic_error_t *error = xcb_request_check (connection, cookie);
        if (error) {
                std::cout << std::string(errMessage) << std::endl;
                xcb_disconnect (connection);
                exit (-1);
        }  
}  


void WindowImplX11::setMouseCursor(int cursorId)
{  
        xcb_font_t font = xcb_generate_id (m_connection);
    xcb_void_cookie_t fontCookie = xcb_open_font_checked (m_connection,
                                                                                                                  font,
                                                                                                                  strlen ("cursor"),
                                                                                                                  "cursor" );
                                                                                                                 
        testCookie (fontCookie, m_connection, "can't open font");

        xcb_cursor_t cursor = xcb_generate_id (m_connection);
        xcb_create_glyph_cursor (m_connection,
                                                         cursor,
                                                         font,
                                                         font,
                                                         cursorId,
                                                         cursorId + 1,
                                                         0, 0, 0, 0, 0, 0 );

        xcb_gcontext_t gc = xcb_generate_id (m_connection);

        uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT;
        uint32_t values_list[3];
        values_list[0] = m_screen->black_pixel;
        values_list[1] = m_screen->white_pixel;
        values_list[2] = font;

        xcb_void_cookie_t gcCookie = xcb_create_gc_checked (m_connection, gc, m_window, mask, values_list);
        testCookie (gcCookie, m_connection, "can't create gc");

        mask = XCB_CW_CURSOR;
        uint32_t value_list = cursor;
        xcb_change_window_attributes (m_connection, m_window, mask, &value_list);

        xcb_free_cursor (m_connection, cursor);

        fontCookie = xcb_close_font_checked (m_connection, font);
        testCookie (fontCookie, m_connection, "can't close font");
        xcb_flush(m_connection);
}

I tried modifying http://xcb.freedesktop.org/tutorial/mousecursors/ but I can't get it to work. I'm not getting any changes in my cursor or any errors. I'm stumped...

cheeseboy

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: System cursors
« Reply #14 on: January 21, 2015, 09:54:50 pm »