[PATCH weston 3/6] xwm: set appropriate cursors for the frame window

Kristian Høgsberg krh at bitplanet.net
Thu Jul 12 06:36:37 PDT 2012


On Thu, Jul 12, 2012 at 9:02 AM, Tiago Vignatti
<tiago.vignatti at linux.intel.com> wrote:
> On 07/12/2012 05:39 AM, Kristian Høgsberg wrote:
>>
>> On Thu, Jul 12, 2012 at 12:46:12AM +0300, Tiago Vignatti wrote:
>>>
>>> +static void
>>> +weston_wm_handle_leave(struct weston_wm *wm, xcb_generic_event_t *event)
>>> +{
>>> +       xcb_leave_notify_event_t *leave_notify =
>>> +                               (xcb_leave_notify_event_t *) event;
>>> +       struct weston_wm_window *window;
>>> +
>>> +       window = hash_table_lookup(wm->window_hash, leave_notify->event);
>>> +       if (!window)
>>> +               return;
>>> +
>>> +       weston_wm_frame_set_cursor(wm, window, XWM_CURSOR_LEFT_PTR);
>>> +}
>>
>>
>> We don't need to set the cursor on leave, whatever window the cursor
>> moves into will set it.  But we do need to set it on enter.
>
> I believe this is not true.
>
> Say we're moving the cursor from the desktop to an internal window of a X
> client; this client has borders created by XWM and the client didn't set
> cursor for its window. So first, the cursor is set to whatever the location
> of the frame is and then the frame has to prepare a cursor because the
> client window (which didn't set any cursor) will pick the last one available
> (ChangeWindowDeviceCursor() in xserver). Therefore the cursor has to be
> prepared on frame leave.
>
> Check yourself. The counter-example is gtk3-demo-application (move the
> cursor over the gray area).

Ok, yes I see, clients that set their cursor to revert-to-parent (like
most toolkits do in inactive areas) will revert to the pointer we set
on the frame window.  Ok, that's good.

We still need to set the cursor on enter too though. Motion event only
handle when you actively move the cursor into another window, but when
the cursor can enter a window is mapped on an obscuring window is
unmapped, and the enter event is how we handle those cases.

>> I'd
>> suggest making weston_wm_frame_set_cursor take wm, window id, and x
>> and y.  We can look up the window and the cursor for the location
>> there.  Then both the motion and enter handlers can call this with the
>> window id and coordinates they receive.
>
>
> that doesn't work. What we do when we want to force a particular cursor,
> like LEFT_PTR for the leave or root window? What do you think about what
> I've introduce in the 4/6:
>
>     weston_wm_window_set_cursor(struct weston_wm *wm, xcb_window_t
> window_id, int cursor)

Yeah, that's probably fine.  I was mostly thinking that if we didn't
need to handle leave, we could consolidate more of the lookup code in
the set_cursor function, but that's moot now.

Kristian


More information about the wayland-devel mailing list