Surface autofocus

Claudiu Lupu lupuu.claudiu at
Thu Jun 30 15:07:29 UTC 2016

I am back with my transparent pixels "click-through" and I really want to make weston redirect the touch inputs to a foreground surface in case the top one has transparent pixels.pq made me understand more on how I should use wl_region but this won't work for me(currently).
Anyway I am not familiar with weston code but I know I it works so I did some "reading" on it and stopped in compositor.c/weston_compositor_pick_view... For me this looks like a good place to redirect inputs and I thought I can add weston_surface_copy_content call for one pixel, check it and send the focus to the surface I want.Since I still setting up my wayland "build" environment and can't compile/test I thought to get some thoughts from you.
I don't want to achieve great rendering performance and I know that even copying 4 bytes from GPU is slow but I do this only when I get touch events and I need to stop rendering anyway(stop and render something else depending on what the user does with its fingers).
diff --git a/libweston/compositor.c b/libweston/compositor.cindex 37d94ec..268595c 100644--- a/libweston/compositor.c+++ b/libweston/compositor.c@@ -1702,6 +1702,20 @@ weston_compositor_pick_view(struct weston_compositor *compositor,      view_ix, view_iy, NULL))  continue; + //alpha picking+ unsigned char buffer[4]; + if(!weston_surface_copy_content(struct weston_surface *surface,+ (void)buffer, 4, view_ix, view_iy, 1, 1)) {+ printf("ALPHA %x, B %x, G %x, R %x\n",buffer[0], buffer[1], buffer[2], buffer[3]);+ //IGNORE this surface if the pixel has alpha 0(transparent)+ if(0 == buffer[0])+ continue;+ }+ else+ {+ printf("Error reading pixels.\n");+ }+  *vx = view_x;  *vy = view_y;  return view;

      From: Pekka Paalanen <ppaalanen at>
 To: Claudiu Lupu <lupuu.claudiu at> 
Cc: Wayland Mailing List <wayland-devel at>
 Sent: Tuesday, June 21, 2016 4:47 PM
 Subject: Re: Surface autofocus
On Tue, 21 Jun 2016 14:23:31 +0000 (UTC)
Claudiu Lupu <lupuu.claudiu at> wrote:

> Hello,
> I got weston 1.11.90 installed on Ubuntu desktop. If I start a
> terminal window and weston-flower the focus is not being redirected
> to the terminal in case I click on a transparent zone from flower


The transparent parts of the flower are not marked as "click-through"
by the demo, so this is expected.

> demo.Another odd thing is that if I click on the terminal window, the
> terminal gets focus but the flower changes even if I don't click on
> the flower zone, looks like both surfaces receive mouse down.Same
> thing happens with the touch. This doesn't look like the behavior I
> was used to on older version of compositors.

The flower does not change as a response to a click per se. The flower
changes every time the window is redrawn by the demo (this goes to show
how rarely the window needs redrawing). When window focus changes, a
message gets sent to both the old and new active windows for them to
redraw their decorations as active/inactive. Flower does not have such
decorations, but it redraws anyway.

You can also see it by pressing Mod+Tab to switch between windows.

There was a time when flower was redrawn practically never, but that
has since changed, with the migration to xdg-shell, IIRC.

> Is this intended, can I
> change something in weston.ini and enable the "autofocus".
> Thanks,Claudiu

I'm not sure what you mean by "autofocus".


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the wayland-devel mailing list