[PATCH weston 08/10] xserver: treat tooltips differently from the others

Kristian Høgsberg hoegsberg at gmail.com
Fri May 18 13:56:03 PDT 2012


On Fri, May 18, 2012 at 06:47:15PM +0300, Tiago Vignatti wrote:
> tooltips follows the pointer, whereas most of the other transient is surface
> relative.
> 
> Signed-off-by: Tiago Vignatti <tiago.vignatti at intel.com>
> ---
>  src/xserver-launcher.c |   31 ++++++++++++++++++++-----------
>  1 file changed, 20 insertions(+), 11 deletions(-)
> 
> diff --git a/src/xserver-launcher.c b/src/xserver-launcher.c
> index 7c7bd0b..2cf5d1f 100644
> --- a/src/xserver-launcher.c
> +++ b/src/xserver-launcher.c
> @@ -133,6 +133,8 @@ struct weston_wm_window {
>  	struct weston_wm_window *transient_for;
>  	uint32_t protocols;
>  	xcb_atom_t type;
> +	const char *atom_name;
> +	uint32_t configured_x, configured_y;

Make these just 'int' and let's just call them x and y.

>  	int width, height;
>  };
>  
> @@ -321,6 +323,7 @@ weston_wm_window_read_properties(struct weston_wm_window *window)
>  			break;
>  		case XCB_ATOM_ATOM:
>  			atom = xcb_get_property_value(reply);
> +			window->atom_name = get_atom_name(wm->conn, *atom);
>  			*(xcb_atom_t *) p = *atom;
>  			break;
>  		case TYPE_WM_PROTOCOLS:

No, this is very broken.  This case handles multiple different window
properties of type atom and fills out the corresponding fields in
weston_wm_window.  Right now, it only handles _NET_WM_WINDOW_TYPE, but
it will also handle, at least _NET_WM_WINDOW_STATE.  So you can't just
set a specific field here.  Also, get_atom_name is a roundtrip and
only for quick and dirty debugging.

Instead, add the atom you want to use in wm->atom and add it to the
list wxs_wm_get_resources.  Then you will be able to say

  if (window->type == wm.atom.net_wm_window_type_tooltip) {
    ...
  }

instead of the get_atom_name() roundtrip and the strcmp in
xserver_map_shell_surface() below.

> @@ -644,6 +647,8 @@ weston_wm_handle_configure_notify(struct weston_wm *wm, xcb_generic_event_t *eve
>  	if (configure_notify->window != window->id)
>  		return;
>  
> +	window->configured_x = configure_notify->x;
> +	window->configured_y = configure_notify->y;
>  	window->width = configure_notify->width;
>  	window->height = configure_notify->height;
>  
> @@ -1788,19 +1793,23 @@ xserver_map_shell_surface(struct weston_wm *wm,
>  	shell_interface->create_shell_surface(shell_interface->shell,
>  					window->surface, &window->shsurf);
>  
> -	if (!window->transient_for)
> +	if (!window->transient_for) {
>  		shell_interface->set_toplevel(window->shsurf);
> -	else {
> -		parent = hash_table_lookup(wm->window_hash,
> -				window->transient_for->id);
> +		return;
> +	}
> +
> +	parent = hash_table_lookup(wm->window_hash, window->transient_for->id);
> +	if (!strcmp(window->atom_name, "_NET_WM_WINDOW_TYPE_TOOLTIP")) {
>  		pointer = wm->server->compositor->seat->pointer;
> -		shell_interface->set_transient(window->shsurf,
> -			parent->shsurf,
> -			wl_fixed_to_int(pointer.x) -
> -			parent->surface->geometry.x,
> -			wl_fixed_to_int(pointer.y) -
> -			parent->surface->geometry.y + offset_y,
> -			WL_SHELL_SURFACE_TRANSIENT_METHOD_INACTIVE);
> +		shell_interface->set_transient(window->shsurf, parent->shsurf,
> +		    wl_fixed_to_int(pointer.x) - parent->surface->geometry.x,
> +		    wl_fixed_to_int(pointer.y) - parent->surface->geometry.y +
> +		    offset_y,
> +		    WL_SHELL_SURFACE_TRANSIENT_METHOD_INACTIVE);
> +	} else {
> +		shell_interface->set_transient(window->shsurf, parent->shsurf,
> +		    window->configured_x, window->configured_y,
> +		    WL_SHELL_SURFACE_TRANSIENT_METHOD_INACTIVE);

We need to treat tooltips like any other transient_for X window, that
is, we get their position based on their relative position to their
parent window.  Toolkits have a lot of logic to place tooltips right,
taking into consideration the position of the pointer and the widget
contents.  We can't just throw that away and place it under the
pointer.

Kristian

>  	}
>  }
>  
> -- 
> 1.7.9.5
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list