Re: [PATCH weston 2/2] input: Update to-be-restored focus when unfocused

2018-08-02 Thread Quentin Glidic

On 8/2/18 10:29 AM, Quentin Glidic wrote:

From: Quentin Glidic 

If we start a special (grabbing) client when Weston is unfocused, it
would lose focus when coming back to Weston.

A first attempt to fix this was 85d55540cb64bf97a08b40f79dc66843f8295d3b
but it messed with VT switching.

This fix just updates the saved focus, so when Weston gets focused back,
it will focus the correct client.

Signed-off-by: Quentin Glidic 
---

Sorry for the delay, I hoped I could make a Gitlab MR but sadly it
didn’t happen yet. :-)

I think this patch won’t conflict with VT switching, and it does fix the
issue I had initially.

Cheers,


Forgot to CC everyone.


  libweston/input.c | 38 +-
  1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/libweston/input.c b/libweston/input.c
index f1017dc1b..6a7f584fd 100644
--- a/libweston/input.c
+++ b/libweston/input.c
@@ -1507,6 +1507,17 @@ weston_pointer_set_focus(struct weston_pointer *pointer,
wl_signal_emit(>focus_signal, pointer);
  }
  
+static void

+destroy_device_saved_kbd_focus(struct wl_listener *listener, void *data)
+{
+   struct weston_seat *ws;
+
+   ws = container_of(listener, struct weston_seat,
+ saved_kbd_focus_listener);
+
+   ws->saved_kbd_focus = NULL;
+}
+
  static void
  send_enter_to_resource_list(struct wl_list *list,
struct weston_keyboard *keyboard,
@@ -1528,7 +1539,8 @@ weston_keyboard_set_focus(struct weston_keyboard 
*keyboard,
  struct weston_surface *surface)
  {
struct wl_resource *resource;
-   struct wl_display *display = keyboard->seat->compositor->wl_display;
+   struct weston_seat *seat = keyboard->seat;
+   struct wl_display *display = seat->compositor->wl_display;
uint32_t serial;
struct wl_list *focus_resource_list;
  
@@ -1540,6 +1552,17 @@ weston_keyboard_set_focus(struct weston_keyboard *keyboard,

if (surface && !surface->resource)
surface = NULL;
  
+	/* If we have a saved focus, this means Weston itself is unfocused.

+* In this case, we just want to update our to-be-restored focus.
+*/
+   if (seat->saved_kbd_focus != NULL && surface != NULL) {
+   wl_list_remove(>saved_kbd_focus_listener.link);
+   seat->saved_kbd_focus = surface;
+   wl_signal_add(>destroy_signal,
+ >saved_kbd_focus_listener);
+   return;
+   }
+
focus_resource_list = >focus_resource_list;
  
  	if (!wl_list_empty(focus_resource_list) && keyboard->focus != surface) {

@@ -2229,17 +2252,6 @@ notify_pointer_focus(struct weston_seat *seat, struct 
weston_output *output,
}
  }
  
-static void

-destroy_device_saved_kbd_focus(struct wl_listener *listener, void *data)
-{
-   struct weston_seat *ws;
-
-   ws = container_of(listener, struct weston_seat,
- saved_kbd_focus_listener);
-
-   ws->saved_kbd_focus = NULL;
-}
-
  WL_EXPORT void
  notify_keyboard_focus_in(struct weston_seat *seat, struct wl_array *keys,
 enum weston_key_state_update update_state)
@@ -2262,8 +2274,8 @@ notify_keyboard_focus_in(struct weston_seat *seat, struct 
wl_array *keys,
  
  	if (surface) {

wl_list_remove(>saved_kbd_focus_listener.link);
-   weston_keyboard_set_focus(keyboard, surface);
seat->saved_kbd_focus = NULL;
+   weston_keyboard_set_focus(keyboard, surface);
}
  }
  




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 2/2] input: Update to-be-restored focus when unfocused

2018-08-02 Thread Quentin Glidic
From: Quentin Glidic 

If we start a special (grabbing) client when Weston is unfocused, it
would lose focus when coming back to Weston.

A first attempt to fix this was 85d55540cb64bf97a08b40f79dc66843f8295d3b
but it messed with VT switching.

This fix just updates the saved focus, so when Weston gets focused back,
it will focus the correct client.

Signed-off-by: Quentin Glidic 
---

Sorry for the delay, I hoped I could make a Gitlab MR but sadly it
didn’t happen yet. :-)

I think this patch won’t conflict with VT switching, and it does fix the
issue I had initially.

Cheers,

 libweston/input.c | 38 +-
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/libweston/input.c b/libweston/input.c
index f1017dc1b..6a7f584fd 100644
--- a/libweston/input.c
+++ b/libweston/input.c
@@ -1507,6 +1507,17 @@ weston_pointer_set_focus(struct weston_pointer *pointer,
wl_signal_emit(>focus_signal, pointer);
 }
 
+static void
+destroy_device_saved_kbd_focus(struct wl_listener *listener, void *data)
+{
+   struct weston_seat *ws;
+
+   ws = container_of(listener, struct weston_seat,
+ saved_kbd_focus_listener);
+
+   ws->saved_kbd_focus = NULL;
+}
+
 static void
 send_enter_to_resource_list(struct wl_list *list,
struct weston_keyboard *keyboard,
@@ -1528,7 +1539,8 @@ weston_keyboard_set_focus(struct weston_keyboard 
*keyboard,
  struct weston_surface *surface)
 {
struct wl_resource *resource;
-   struct wl_display *display = keyboard->seat->compositor->wl_display;
+   struct weston_seat *seat = keyboard->seat;
+   struct wl_display *display = seat->compositor->wl_display;
uint32_t serial;
struct wl_list *focus_resource_list;
 
@@ -1540,6 +1552,17 @@ weston_keyboard_set_focus(struct weston_keyboard 
*keyboard,
if (surface && !surface->resource)
surface = NULL;
 
+   /* If we have a saved focus, this means Weston itself is unfocused.
+* In this case, we just want to update our to-be-restored focus.
+*/
+   if (seat->saved_kbd_focus != NULL && surface != NULL) {
+   wl_list_remove(>saved_kbd_focus_listener.link);
+   seat->saved_kbd_focus = surface;
+   wl_signal_add(>destroy_signal,
+ >saved_kbd_focus_listener);
+   return;
+   }
+
focus_resource_list = >focus_resource_list;
 
if (!wl_list_empty(focus_resource_list) && keyboard->focus != surface) {
@@ -2229,17 +2252,6 @@ notify_pointer_focus(struct weston_seat *seat, struct 
weston_output *output,
}
 }
 
-static void
-destroy_device_saved_kbd_focus(struct wl_listener *listener, void *data)
-{
-   struct weston_seat *ws;
-
-   ws = container_of(listener, struct weston_seat,
- saved_kbd_focus_listener);
-
-   ws->saved_kbd_focus = NULL;
-}
-
 WL_EXPORT void
 notify_keyboard_focus_in(struct weston_seat *seat, struct wl_array *keys,
 enum weston_key_state_update update_state)
@@ -2262,8 +2274,8 @@ notify_keyboard_focus_in(struct weston_seat *seat, struct 
wl_array *keys,
 
if (surface) {
wl_list_remove(>saved_kbd_focus_listener.link);
-   weston_keyboard_set_focus(keyboard, surface);
seat->saved_kbd_focus = NULL;
+   weston_keyboard_set_focus(keyboard, surface);
}
 }
 
-- 
2.18.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 1/2] Revert "input: Do not override keyboard focus on restore"

2018-08-02 Thread Quentin Glidic
From: Quentin Glidic 

This reverts commit 85d55540cb64bf97a08b40f79dc66843f8295d3b.
It brought issues for proper VT switching focus handling.

Signed-off-by: Quentin Glidic 
---
 libweston/input.c | 26 +++---
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/libweston/input.c b/libweston/input.c
index 04c114199..f1017dc1b 100644
--- a/libweston/input.c
+++ b/libweston/input.c
@@ -1527,7 +1527,6 @@ WL_EXPORT void
 weston_keyboard_set_focus(struct weston_keyboard *keyboard,
  struct weston_surface *surface)
 {
-   struct weston_seat *seat = keyboard->seat;
struct wl_resource *resource;
struct wl_display *display = keyboard->seat->compositor->wl_display;
uint32_t serial;
@@ -1569,11 +1568,6 @@ weston_keyboard_set_focus(struct weston_keyboard 
*keyboard,
keyboard->focus_serial = serial;
}
 
-   if (seat->saved_kbd_focus) {
-   wl_list_remove(>saved_kbd_focus_listener.link);
-   seat->saved_kbd_focus = NULL;
-   }
-
wl_list_remove(>focus_resource_listener.link);
wl_list_init(>focus_resource_listener.link);
if (surface)
@@ -2265,8 +2259,11 @@ notify_keyboard_focus_in(struct weston_seat *seat, 
struct wl_array *keys,
}
 
surface = seat->saved_kbd_focus;
+
if (surface) {
+   wl_list_remove(>saved_kbd_focus_listener.link);
weston_keyboard_set_focus(keyboard, surface);
+   seat->saved_kbd_focus = NULL;
}
 }
 
@@ -2276,7 +2273,6 @@ notify_keyboard_focus_out(struct weston_seat *seat)
struct weston_compositor *compositor = seat->compositor;
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
-   struct weston_surface *focus = keyboard->focus;
uint32_t *k, serial;
 
serial = wl_display_next_serial(compositor->wl_display);
@@ -2288,18 +2284,18 @@ notify_keyboard_focus_out(struct weston_seat *seat)
 
seat->modifier_state = 0;
 
-   weston_keyboard_set_focus(keyboard, NULL);
-   weston_keyboard_cancel_grab(keyboard);
-   if (pointer)
-   weston_pointer_cancel_grab(pointer);
-
-   if (focus) {
-   seat->saved_kbd_focus = focus;
+   if (keyboard->focus) {
+   seat->saved_kbd_focus = keyboard->focus;
seat->saved_kbd_focus_listener.notify =
destroy_device_saved_kbd_focus;
-   wl_signal_add(>destroy_signal,
+   wl_signal_add(>focus->destroy_signal,
  >saved_kbd_focus_listener);
}
+
+   weston_keyboard_set_focus(keyboard, NULL);
+   weston_keyboard_cancel_grab(keyboard);
+   if (pointer)
+   weston_pointer_cancel_grab(pointer);
 }
 
 WL_EXPORT void
-- 
2.18.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 3/4] README: Move to Markdown, rewrite introduction

2018-07-20 Thread Quentin Glidic

On 7/14/18 3:09 PM, Daniel Stone wrote:

Move the README file to Markdown, and update it to attempt to explain
the current status and use of Weston.


From patch 1:
> The patch is a single logical change. If the commit message addresses
> multiple points, it is a hint that the commit might need splitting up.

Ultimately, I’d split the markdown move to its own commit, but I’m 
probably nitpicky here.




The first sections are user-facing, so they can quickly understand what
Weston is, what it does, what it doesn't do, and how to go about using
it. The following sections on libweston and for distribution packagers
are left intact, but should probably be moved to separate documents.

Signed-off-by: Daniel Stone 
---
  README => README.md| 108 ++---
  doc/wayland-screenshot.jpg | Bin 0 -> 143832 bytes
  2 files changed, 78 insertions(+), 30 deletions(-)
  rename README => README.md (69%)
  create mode 100644 doc/wayland-screenshot.jpg

diff --git a/README b/README.md
similarity index 69%
rename from README
rename to README.md
index a0a078c46..404859548 100644
--- a/README
+++ b/README.md
@@ -1,33 +1,81 @@
-   Weston
-   ==
-
-Weston is the reference implementation of a Wayland compositor, and a
-useful compositor in its own right.  Weston has various backends that
-lets it run on Linux kernel modesetting and evdev input as well as
-under X11.  Weston ships with a few example clients, from simple
-clients that demonstrate certain aspects of the protocol to more
-complete clients and a simplistic toolkit.  There is also a quite
-capable terminal emulator (weston-terminal) and an toy/example desktop
-shell.  Finally, weston also provides integration with the Xorg server
-and can pull X clients into the Wayland desktop and act as an X window
-manager.
-
-Refer to https://wayland.freedesktop.org/building.html for building
-weston and its dependencies.
-
-The test suite can be invoked via `make check`; see
-https://wayland.freedesktop.org/testing.html for additional details.
-
-Developer documentation can be built via `make doc`. Output will be in
-the build root under
-
-docs/developer/html/index.html
-docs/tools/html/index.html
-
-
-
-   Libweston
-   =
+Weston
+==
+
+![screenshot of skeletal Weston 
desktop](https://gitlab.freedesktop.org/wayland/weston/tree/master/doc/weston-screenshot.jpg)
+
+Weston is the reference implementation of a Wayland compositor, as well as a
+useful environment in and of itself.
+
+Out of the box, Weston provides a partly-featured desktop, or a full-featured
+environment for non-desktop uses such as automotive, embedded, in-flight,
+industrial, kiosks, set-top boxes and TVs. It also provides a library allowing
+other projects to build their own full-featured environments on top of Weston's
+core and provide their own full-featured environments.


That’s way too full of features, don’t you think? :-)

Then, all four patches are:
Reviewed-by: Quentin Glidic 
(With or without the split.)

Thanks,



+The core focus of Weston is correctness and reliability. Weston aims to be lean
+and fast, but more importantly, to be predictable. Whilst Weston does have 
known
+bugs and shortcomings, we avoid unknown or variable behaviour as much as
+possible. The core compositor's performance should always be predictable and
+measurable.
+
+A small suite of example or demo clients are also provided: though they can be
+useful in themselves, their main purpose is to be an example or test case for
+others building compositors or clients.
+
+If you are after a more mainline desktop experience, the
+[GNOME](https://www.gnome.org) and [KDE](https://www.kde.org) projects provide
+full-featured desktop environments built on the Wayland protocol. Many other
+projects also exist providing Wayland clients and desktop environments: you are
+not limited to just what you can find in Weston.
+
+Reporting issues and contributing
+=
+
+Weston's development is
+[hosted on freedesktop.org 
GitLab](https://gitlab.freedesktop.org/wayland/weston/).
+Please also see [the contributing document](CONTRIBUTING.md), which details how
+to make code or non-technical contributions to Weston.
+
+Building Weston
+===
+
+Weston is built using autotools, with `autogen.sh` and `make`. It often depends
+on the current release versions of
+[Wayland](https://gitlab.freedesktop.org/wayland/wayland) and
+[wayland-protocols](https://cgit.freedesktop.org/wayland/wayland-protocols).
+
+Every commit of Weston is built using GitLab CI.
+[Reading the configuration](.gitlab-ci.yml) may provide a useful example of how
+to build and install Weston.
+
+More [detailed documentation on building 
Weston](https://wayland.freedesktop.org/building.html)
+is available on the Wayland site. There are also more details on
+[how to run and write tests](https://wayland.

Re: [PATCH weston] build: don't manually parse the weston.ini.in templates

2018-06-28 Thread Quentin Glidic

On 6/27/18 3:04 PM, Emil Velikov wrote:

From: Emil Velikov 

Adding those to configure.ac ensures that:
  - the weston.ini files are {re,}generated only when needed
  - the .in files are shipped in the tarball
  - all the manual handling of the above can be removed ;-)


Did you actually test that?
In configure.ac, "bindir" is "${prefix}/bin" (default value), so you’d 
end up with "path=${prefix}/bin/weston-flower", and obviously, it won’t 
launch.
Also, though it’s not that used, you can override directories at "make" 
time.
In the end, Makefile is the only place we know the full usable value for 
directories. (Otherwise, the only case it’ll work is when you pass all 
the directories as full paths to "./configure".)


Thanks,


Note: the abs_top_builddir for weston-flower was swapped with the correct
bindir. Squashed in here since it was never worked correctly :-\

Signed-off-by: Emil Velikov 
---
Shout if you feel strongly about splitting the weston-flower fix.

Based on top of Emre's "ivi-shell: use install paths in example config"
patch.
---
  Makefile.am   | 22 ++
  configure.ac  |  2 +-
  weston.ini.in |  2 +-
  3 files changed, 4 insertions(+), 22 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 637dd239..2095aa5a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,23 +12,7 @@ BUILT_SOURCES =
  
  AM_DISTCHECK_CONFIGURE_FLAGS = --disable-setuid-install
  
-EXTRA_DIST = weston.ini.in ivi-shell/weston.ini.in

-
-weston.ini : $(srcdir)/weston.ini.in
-   $(AM_V_GEN)$(SED) \
-   -e 's|@bindir[@]|$(bindir)|g' \
-   -e 's|@abs_top_builddir[@]|$(abs_top_builddir)|g' \
-   -e 's|@libexecdir[@]|$(libexecdir)|g' \
-   $< > $@
-
-ivi-shell/weston.ini : $(srcdir)/ivi-shell/weston.ini.in
-   $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(SED) \
-   -e 's|@bindir[@]|$(bindir)|g' \
-   -e 's|@libexecdir[@]|$(libexecdir)|g' \
-   -e 's|@westondatadir[@]|$(westondatadir)|g' \
-   $< > $@
-
-all-local : weston.ini ivi-shell/weston.ini
+EXTRA_DIST =
  
  AM_CFLAGS = $(GCC_CFLAGS)
  
@@ -43,9 +27,7 @@ AM_CPPFLAGS = 	\

-DLIBEXECDIR='"$(libexecdir)"'\
-DBINDIR='"$(bindir)"'
  
-CLEANFILES = weston.ini\

-   ivi-shell/weston.ini\
-   internal-screenshot-00.png  \
+CLEANFILES = internal-screenshot-00.png\
$(BUILT_SOURCES)
  
  # Libtool race fix

diff --git a/configure.ac b/configure.ac
index 2a62b62a..9b7071e7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -680,7 +680,7 @@ if test "x$enable_systemd_notify" = "xyes"; then
PKG_CHECK_MODULES(SYSTEMD_DAEMON, [libsystemd])
  fi
  
-AC_CONFIG_FILES([Makefile libweston/version.h compositor/weston.pc])

+AC_CONFIG_FILES([Makefile weston.ini ivi-shell/weston.ini libweston/version.h 
compositor/weston.pc])
  
  # AC_CONFIG_FILES needs the full name when running autoconf, so we need to use

  # libweston_abi_version here, and outside [] because of m4 quoting rules
diff --git a/weston.ini.in b/weston.ini.in
index 257c4ec4..e743cc49 100644
--- a/weston.ini.in
+++ b/weston.ini.in
@@ -38,7 +38,7 @@ path=/usr/bin/google-chrome
  
  [launcher]

  icon=/usr/share/icons/gnome/24x24/apps/arts.png
-path=@abs_top_builddir@/weston-flower
+path=@bindir@/weston-flower
  
  [input-method]

  path=@libexecdir@/weston-keyboard




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [writing a compositor] Displaying something on the screen

2018-05-31 Thread Quentin Glidic

Hi,

On 5/31/18 5:42 AM, adlo wrote:

I am attempting to write a simple test compositor using libweston.

Here is my code so far:

https://github.com/adlocode/test-libweston-desktop

What else do I need to do in order to get it to the point where something 
appears on the screen, such as a rectangle of solid colour?


For regular (desktop) clients, you’ll need to properly implement the 
libweston-desktop hooks (at least the two mandatory ones), create views 
for surfaces, put them in a layer, and making sure a repaint will 
happen. You can find the very minimal libweston(-desktop) compositor 
here[1].


For other more specific clients, you’ll need to implement the relevant 
protocols and view creation. Or you can use libweston/Weston plugins[2] 
handling that.


libweston allows to create a solid colour surface, which is used for the 
black-surface-under-fullscreen requirement[3] and by some compositors to 
give a default black background.


I hope this helps.

Cheers,


[1] 
[2] 
[3] 



--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH v2 weston] Partially revert "xwm: Add icon support to the frame" and friends

2018-04-02 Thread Quentin Glidic

On 3/30/18 6:56 PM, Derek Foreman wrote:

This (partially) reverts commit bef761796c2ada6344d227142af4a0f40b9760dd.
This (partially) reverts commit 4d1cd36c9ea041688f92cd8981e43b5fe3b52409.
This (partially) reverts commit 44fc1be913ab2faad0414f50e51d58310302d065.
This (partially) reverts commit 6b58ea8c43ac81e519bd418efbf24687a5d731b8.

The new xwm icon code has proven to be leaky and incomplete, and while
we have patches under consideration to fix the rest of its known problems
they still require changes and review cycles.  Currently the known
leaks have been squashed, but it still picks wrong sized icons and
does no scaling, which can lead to very strange rendering.  At window
close time the wrong sized icon appears above the window during fade out.

This patch reverts the mostly solid bits and keeps the unfinished
bits behind in favor of a simpler revert than removing the whole
thing.

Signed-off-by: Derek Foreman <der...@osg.samsung.com> > ---

Changes from v1:

Only reverts the changes in window-manager.c (and updates frame_create call
to pass NULL for icon surface.


Yeah, looks safer to me:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

I’m sure Scott will submit a complete feature soon, this way we can 
focus the review on the real bits. :-)


Thanks,




  xwayland/window-manager.c | 88 ++-
  1 file changed, 2 insertions(+), 86 deletions(-)

diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
index 62087941..06370b70 100644
--- a/xwayland/window-manager.c
+++ b/xwayland/window-manager.c
@@ -138,8 +138,6 @@ struct weston_wm_window {
xcb_window_t frame_id;
struct frame *frame;
cairo_surface_t *cairo_surface;
-   int icon;
-   cairo_surface_t *icon_surface; /* A temporary slot, to be passed to 
frame on creation */
uint32_t surface_id;
struct weston_surface *surface;
struct weston_desktop_xwayland_surface *shsurf;
@@ -475,7 +473,6 @@ weston_wm_window_read_properties(struct weston_wm_window 
*window)
{ wm->atom.net_wm_state,   TYPE_NET_WM_STATE,  NULL 
},
{ wm->atom.net_wm_window_type, XCB_ATOM_ATOM,  
F(type) },
{ wm->atom.net_wm_name,XCB_ATOM_STRING,
F(name) },
-   { wm->atom.net_wm_icon,XCB_ATOM_CARDINAL,  
F(icon) },
{ wm->atom.net_wm_pid, XCB_ATOM_CARDINAL,  
F(pid) },
{ wm->atom.motif_wm_hints, TYPE_MOTIF_WM_HINTS,NULL 
},
{ wm->atom.wm_client_machine,  XCB_ATOM_WM_CLIENT_MACHINE, 
F(machine) },
@@ -976,10 +973,8 @@ weston_wm_window_create_frame(struct weston_wm_window 
*window)
buttons |= FRAME_BUTTON_MAXIMIZE;
  
  	window->frame = frame_create(window->wm->theme,

-window->width, window->height,
-buttons, window->name,
-window->icon_surface);
-   window->icon_surface = NULL;
+window->width, window->height,
+buttons, window->name, NULL);
frame_resize_inside(window->frame, window->width, window->height);
  
  	weston_wm_window_get_frame_size(window, , );

@@ -1318,70 +1313,6 @@ weston_wm_window_schedule_repaint(struct 
weston_wm_window *window)
   weston_wm_window_do_repaint, window);
  }
  
-static void

-handle_icon_surface_destroy(void *data)
-{
-   free(data);
-}
-
-static void
-weston_wm_handle_icon(struct weston_wm *wm, struct weston_wm_window *window)
-{
-   xcb_get_property_reply_t *reply;
-   xcb_get_property_cookie_t cookie;
-   uint32_t length;
-   uint32_t *data, width, height;
-   cairo_surface_t *new_surface;
-
-   /* TODO: icons don’t have any specified order, we should pick the
-* closest one to the target dimension instead of the first one. */
-
-   cookie = xcb_get_property(wm->conn, 0, window->id,
- wm->atom.net_wm_icon, XCB_ATOM_ANY, 0,
- UINT32_MAX);
-   reply = xcb_get_property_reply(wm->conn, cookie, NULL);
-   length = xcb_get_property_value_length(reply);
-
-   /* This is in 32-bit words, not in bytes. */
-   if (length < 2) {
-   free(reply);
-   return;
-   }
-
-   data = xcb_get_property_value(reply);
-   width = *data++;
-   height = *data++;
-
-   /* Some checks against malformed input. */
-   if (width == 0 || height == 0 || length < 2 + width * height) {
-   free(reply);
-   return;
-   }
-
-   new_surface =
-   cairo_image_surface_create_for_data((unsigned char *)data,
- 

Re: [PATCH wayland 2/2] wayland-egl: Make symbol test fail on failure

2018-03-19 Thread Quentin Glidic

On 3/19/18 1:31 PM, Daniel Stone wrote:

The previous rewrite of the wayland-egl ABI checker introduced checks
for removed symbols as well as added symbols, but broke some failure
conditions. Add an explict return-code variable set in failure paths,
rather than chaining or conditions.

If we cannot find the binary or nm, we regard this as an error
condition, rather than test failure.

Signed-off-by: Daniel Stone 
Reported-by: Pekka Paalanen 
Fixes: 21b1f22eb056 ("wayland-egl: enhance the symbol test")
Cc: Emil Velikov 
---
  egl/wayland-egl-symbols-check | 27 +--
  1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/egl/wayland-egl-symbols-check b/egl/wayland-egl-symbols-check
index c47026b2..d1a4a6be 100755
--- a/egl/wayland-egl-symbols-check
+++ b/egl/wayland-egl-symbols-check
@@ -1,11 +1,17 @@
  #!/bin/sh
  set -eu
  
+RET=0

  LIB=${WAYLAND_EGL_LIB}
  
-if [ ! -f "$LIB" ]; then

-   echo "The test binary \"$LIB\" does no exist"
-   exit 1
+if ! test -f "$LIB"; then
+   echo "Test binary \"$LIB\" does not exist"
+   exit 99
+fi


Not a big fan of replacing [!-f] with !test-f but it’s a cosmetic issue 
so not a big deal.




+
+if ! test -x "$NM"; then
+   echo "nm binary \"$NM\" does not exist"
+   exit 99
  fi


Here, however, you are introducing an -x test, which is not good for all 
the people (including packagers) that set NM to e.g. -nm (so not 
the full path).




  AVAIL_FUNCS="$($NM -D --format=bsd --defined-only $LIB | awk '{print $3}')"


Maybe just checking for -n "$NM" then -n "$AVAIL_FUNCS" would be enough?


Cheers,



@@ -32,7 +38,11 @@ NEW_ABI=$(echo "$AVAIL_FUNCS" | while read func; do
  echo $func
  done)
  
-test ! -n "$NEW_ABI" || echo "New ABI detected - If intentional, update the test."; echo "$NEW_ABI"

+if test -n "$NEW_ABI"; then
+   echo "New ABI detected - If intentional, update the test."
+   echo "$NEW_ABI"
+   RET=1
+fi
  
  REMOVED_ABI=$(echo "$REQ_FUNCS" | while read func; do

  echo "$AVAIL_FUNCS" | grep -q "^$func$" && continue
@@ -40,5 +50,10 @@ REMOVED_ABI=$(echo "$REQ_FUNCS" | while read func; do
  echo $func
  done)
  
-test ! -n "$REMOVED_ABI" || echo "ABI break detected - Required symbol(s) no longer exported!"; echo "$REMOVED_ABI"

-test ! -n "$NEW_ABI" || test ! -n "$REMOVED_ABI"
+if test -n "$REMOVED_ABI"; then
+   echo "ABI break detected - Required symbol(s) no longer exported!"
+   echo "$REMOVED_ABI"
+   RET=1
+fi
+
+exit $RET




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH wayland 1/2] wayland-egl: Pass nm path to check script

2018-03-19 Thread Quentin Glidic

On 3/19/18 1:31 PM, Daniel Stone wrote:

A previous patch used $NM as an environment variable, but this was only
set as a make variable. Make sure it is passed through from make to the
environment we use to run tests.

Signed-off-by: Daniel Stone <dani...@collabora.com>
Reported-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>
Fixes: 6903e4d53925 ("wayland-egl: use correct `nm` path when cross-compiling")
Cc: Emil Velikov <emil.veli...@collabora.com>


Straightforward:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

Thanks,


---
  Makefile.am | 1 +
  1 file changed, 1 insertion(+)

diff --git a/Makefile.am b/Makefile.am
index 6f59c369..514468aa 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -198,6 +198,7 @@ AM_TESTS_ENVIRONMENT =  
\
TEST_OUTPUT_DIR='$(top_builddir)/tests/output'  \
WAYLAND_EGL_LIB='$(top_builddir)/.libs/libwayland-egl.so'   \
SED=$(SED)  \
+   NM=$(NM)\
;
  
  TESTS = $(built_test_programs)			\





--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston] libweston-desktop/xdg-shell-v6: Fix crash when surface has buffer at creation

2018-03-13 Thread Quentin Glidic

On 3/13/18 5:34 PM, Derek Foreman wrote:

When a surface has a buffer at creation time we send an error, which results
in a disconnection and all resources being destroyed.

Since we send that error and return before performing the configure_list init
weston_desktop_xdg_surface_destroy() will walk an uninitialized list and
dereference a NULL pointer.

Initializing the list earlier prevents this from happening.

Signed-off-by: Derek Foreman <der...@osg.samsung.com>


Good catch:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

Thanks,


---
  libweston-desktop/xdg-shell-v6.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c
index f9902ff0..8fa01a32 100644
--- a/libweston-desktop/xdg-shell-v6.c
+++ b/libweston-desktop/xdg-shell-v6.c
@@ -1370,6 +1370,7 @@ weston_desktop_xdg_shell_protocol_get_xdg_surface(struct 
wl_client *wl_client,
  
  	surface->desktop = weston_desktop_client_get_desktop(client);

surface->surface = wsurface;
+   wl_list_init(>configure_list);
  
  	surface->desktop_surface =

weston_desktop_surface_create(surface->desktop, client,
@@ -1395,8 +1396,6 @@ weston_desktop_xdg_shell_protocol_get_xdg_surface(struct 
wl_client *wl_client,
   "xdg_surface must not have a buffer at 
creation");
return;
}
-
-   wl_list_init(>configure_list);
  }
  
  static void





--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH wayland-protcols v2] unstable: add xdg-toplevel-decoration protocol

2018-03-11 Thread Quentin Glidic

On 3/11/18 9:49 PM, Simon Ser wrote:

[snip]

+
+  
+
+  This interface permits choosing between client-side and server-side
+  window decorations for a toplevel surface.
+
+  A window decoration is a user interface component used to move, resize 
and
+  change a window's state. It can be managed either by the client (part of
+  the surface) or by the server.


You mention decorations only, but this (or some other text below maybe)
should mention shadows as well. You may consider them as part of the
decoration, but xdg_surface.set_window_geometry() is designed to include
decoration and exclude shadows. Yet, e.g. GTK+ allows to resize using
shadows IIRC.

Nit: I think GTK+ allows to move from any dead zone in the surface too. :-)


xdg-shell's wording includes drop-shadows as part of decorations:


Client-side decorations often have invisible portions like drop-shadows which
should be ignored for the purposes of aligning, placing and constraining
windows.


So "decorations" here stand for both visible parts such as the titlebar and
invisible parts such as drop-shadows. Do you think the protocol needs to
disambiguate these concepts?


You’re right, though I would rather be too precise (while not 
exhaustive) that not enough, just in case. But others may have a 
different opinion so let’s wait for more reviews here.




[snip]

+
+
+  
+Set the toplevel surface decoration mode.
+
+After requesting a decoration mode, the compositor will respond by
+emitting a xdg_surface.configure event. The client should then update
+its content, drawing it with or without decorations depending on the
+received mode. The client must also acknowledge the configure when
+committing the new content (see xdg_surface.ack_configure).
+
+The compositor can ignore this request.
+  
+  
+


This request I’m still not sure about it.
Why would an SSD-capable client would want to switch from CSD
back-and-forth? What is the use case here? (Preferably a user use case.)


One reason is consistency with xdg-shell.


Not all states can be client-initiated though.



But there are also real use-cases:
- A compositor might prefer SSDs or CSDs depending of the window container. For
   instance, a tiled compositor might prefer SSDs for tiled windows and CSDs for
   floating windows. Windows can be moved between a tiling and a floating
   container at run-time.


That I’m 100% ok with, your point is clear and makes a lot of sense. I 
would even object if someone wanted to remove that. :-)




- Clients might expose a user setting that allows toggling SSDs. For instance,
   Chrome/Chromium already has such a feature. Requiring the user to restart the
   app or to quickly close and reopen the main window offers poor UX.


I’m not convinced a client should have such a setting. For consistency 
and UX, I would rather have a central point of setting (the compositor). 
If we make it harder (though possible) to switch, then we can hopefully 
limit the number of clients wanting to support such a setting.
Since we must have the destructor support anyway, on both sides, I think 
it is enough for this feature.




[snip]

Last but not least: it should be much much clearer that the compositor
is in charge here. This is not about magic SSD, clients must support CSD
in all cases and should not error out if this global is not here. And
even then, it may want CSD in some cases.


I've added this in the protocol description:


Note that even if the server supports server-side window decorations, clients
must still support client-side decorations.


I think people already got that part, though it does no harm to say it 
again, but I was speaking about the configure event. It may happen *at 
any time* and the client must be prepared (e.g for the cases you mentioned).



Cheers,

--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH wayland-protcols v2] unstable: add xdg-toplevel-decoration protocol

2018-03-03 Thread Quentin Glidic

On 3/2/18 4:33 PM, Simon Ser wrote:

This adds a new protocol to negotiate server- and client-side rendering of
window decorations for xdg-toplevels. This allows compositors that want
to draw decorations themselves to send their preference to clients, and
clients that prefer server-side decorations to request them.

This is inspired by a protocol from KDE [1] which has been implemented in
KDE and Sway and was submitted for consideration in 2017 [2]. This patch
provides an updated protocol with those concerns taken into account.

Signed-off-by: Simon Ser 
Reviewed-by: Drew DeVault 
Reviewed-by: David Edmundson 
Reviewed-by: Alan Griffiths 
Reviewed-by: Tony Crisci 

[1] 
https://github.com/KDE/kwayland/blob/master/src/client/protocols/server-decoration.xml
[2] 
https://lists.freedesktop.org/archives/wayland-devel/2017-October/035564.html


This is a nice protocol, and I would implement it (in clients) in its 
current form, but I still have a few comments.




---

This was iterated on privately between representatives of Sway and wlroots
(Simon Ser, Drew DeVault and Tony Crisci), KDE and Qt (David Edmundson),
and Mir (Alan Griffiths).

A proof-of-concept of a client and server implementation is available at [1].

Changes from v1 to v2: moved the enum above in the protocol, added
Signed-off-by and Reviewed-by tags, updated the commit message.

[1] https://github.com/swaywm/wlroots/pull/638

  Makefile.am|   1 +
  unstable/xdg-toplevel-decoration/README|   4 +
  .../xdg-toplevel-decoration-unstable-v1.xml| 127 +
  3 files changed, 132 insertions(+)
  create mode 100644 unstable/xdg-toplevel-decoration/README
  create mode 100644 
unstable/xdg-toplevel-decoration/xdg-toplevel-decoration-unstable-v1.xml

diff --git a/Makefile.am b/Makefile.am
index 4b9a901..07744e9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -17,6 +17,7 @@ unstable_protocols =  
\

unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml \
unstable/xdg-output/xdg-output-unstable-v1.xml  
\
unstable/input-timestamps/input-timestamps-unstable-v1.xml  \
+   
unstable/xdg-toplevel-decoration/xdg-toplevel-decoration-unstable-v1.xml
\
$(NULL)
  
  stable_protocols =\

diff --git a/unstable/xdg-toplevel-decoration/README 
b/unstable/xdg-toplevel-decoration/README
new file mode 100644
index 000..e927110
--- /dev/null
+++ b/unstable/xdg-toplevel-decoration/README
@@ -0,0 +1,4 @@
+xdg_toplevel_decoration protocol
+
+Maintainers:
+Simon Ser 
diff --git 
a/unstable/xdg-toplevel-decoration/xdg-toplevel-decoration-unstable-v1.xml 
b/unstable/xdg-toplevel-decoration/xdg-toplevel-decoration-unstable-v1.xml
new file mode 100644
index 000..acc1ed2
--- /dev/null
+++ b/unstable/xdg-toplevel-decoration/xdg-toplevel-decoration-unstable-v1.xml
@@ -0,0 +1,127 @@
+
+
+  
+Copyright © 2018 Simon Ser
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+  
+
+  
+
+  This interface permits choosing between client-side and server-side
+  window decorations for a toplevel surface.
+
+  A window decoration is a user interface component used to move, resize 
and
+  change a window's state. It can be managed either by the client (part of
+  the surface) or by the server.


You mention decorations only, but this (or some other text below maybe) 
should mention shadows as well. You may consider them as part of the 
decoration, but xdg_surface.set_window_geometry() is designed to include 
decoration and exclude shadows. Yet, e.g. GTK+ allows to resize using 
shadows IIRC.


Nit: I think GTK+ allows to move 

Re: [PATCH wayland-protocols] unstable: add xdg-toplevel-decoration protocol

2018-03-03 Thread Quentin Glidic
(I wonder if Pekka or Daniel would like to be dropped off the CC list as 
it may be too desktop-ish for them?)


On 3/3/18 10:58 AM, Simon Ser wrote:

Hi,

Thanks for taking time reviewing the protocol and suggesting an alternative 
design.

On March 2, 2018 4:36 PM, Mike Blumenkrantz  
wrote:

Hi,

I agree with your point regarding a SSD-capable compositor not always wanting 
them, and certainly I can see the usefulness for cases such as what you've 
cited. However, in the example you provided, it's easy enough for an 
application to determine what desktop it's running in and then determine 
whether to use SSD--if the compositor implements and advertises this protocol 
then it's ultimately a client decision whether to use it.


I don't think "detecting the desktop environment" is a good idea. Some other 
DEs (elementary, Unity) might also prefer GTK+ CSDs even if they're not GNOME, and - 
supposing there's a good way to know which DE is currently running ­- hardcoding the 
names of DEs is a slippery slope.


Just a side note here: it is a slope clients slipped on already if they 
want to integrate with some DE settings. But I agree that it should be 
as limited as possible (and hopefully in some helper library/toolkit).




My issue is in the inconsistency of the protocol that has been proposed here. 
This is a protocol for enabling SSD; there should be no need for anything 
related to CSD, and I don't think there is a need for clients to have any form 
of protocol request to toggle between CSD and SSD.


This is not a protocol to enable SSDs, this is a protocol to negotiate client- 
or server-side decorations. This is stated in the protocol description.


Based on your assertion that borderless mode would be achieved in this protocol 
in the CSD mode, I would raise the counterpoint that in this case the client 
should just destroy the zxdg\_toplevel\_decoration_v1 object which, according 
to the destroy request, would revert to the surface using CSD anyway, 
furthering my assessment that there is indeed no need for any mention of CSD in 
the protocol requests.


This is racy - there will be frames with both client-side and server-side 
decorations.


(Will answer and elaborate on v2.)


This change allows for everything except the destroy request to be removed from 
zxdg\_toplevel\_decoration_v1, greatly simplifying the protocol as well as 
implementations of it. The case of the compositor "ignoring" the request to 
create SSD also becomes moot as well, since all that would mean is the compositor has 
chosen to use a borderless state at this time (e.g., tiling layout) which is irrelevant 
to the client anyway.


I don't understand your last point. A tiling layout would be exposed as SSD to 
the client.


Or not, tiling is orthogonal to CSD/SSD. We will have a tiling state in 
xdg-shell at some point, hopefully, that will enable nicer visuals for 
CSD too.




This aside, there's some other items of note here, such as the lack of 
precision related to when the change in decoration management state takes 
effect: most likely it should be applied on the next surface commit? I think 
this should be specified in the zxdg\_toplevel\_decoration_v1 interface 
description. Also, I would think that destroying the 
zxdg\_toplevel\_decoration\_manager\_v1 object while any 
zxdg\_toplevel\_decoration_v1 objects exist should be a client error, but this 
is similarly not specified anywhere.


The protocol integrates with the xdg-shell configuration mechanism, and I've been using 
the same wording as xdg-shell. xdg-toplevel-decoration just adds one property to the set 
of double-buffered xdg-surface properties (just like xdg-toplevel adds properties to 
xdg-surface). There are a bunch of "See xdg_surface.configure" in the 
description and as an extension of xdg-shell the protocol assumes the reader knows how 
xdg-shell works.


And it integrates rather well, IMO.
I have a few more comments that I will post on v2.

Thanks,

> [snip]

--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[RFC weston 2/2] compositor-x11: Use event loop abstraction API

2018-02-19 Thread Quentin Glidic
From: Quentin Glidic <sardemff7+...@sardemff7.net>

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
 libweston/compositor-x11.c | 64 +-
 1 file changed, 29 insertions(+), 35 deletions(-)

diff --git a/libweston/compositor-x11.c b/libweston/compositor-x11.c
index 14faeda03..7675b7275 100644
--- a/libweston/compositor-x11.c
+++ b/libweston/compositor-x11.c
@@ -81,7 +81,7 @@ struct x11_backend {
xcb_screen_t*screen;
xcb_cursor_t null_cursor;
struct wl_array  keys;
-   struct wl_event_source  *xcb_source;
+   void*xcb_source;
struct xkb_keymap   *xkb_keymap;
unsigned int has_xkb;
uint8_t  xkb_event_base;
@@ -122,7 +122,7 @@ struct x11_output {
xcb_window_twindow;
struct weston_mode  mode;
struct weston_mode  native;
-   struct wl_event_source *finish_frame_timer;
+   void   *finish_frame_timer;
 
xcb_gc_tgc;
xcb_shm_seg_t   segment;
@@ -411,7 +411,9 @@ x11_output_repaint_gl(struct weston_output *output_base,
pixman_region32_subtract(>primary_plane.damage,
 >primary_plane.damage, damage);
 
-   wl_event_source_timer_update(output->finish_frame_timer, 10);
+   weston_compositor_event_source_update_timeout(ec,
+ 
output->finish_frame_timer,
+ 10);
return 0;
 }
 
@@ -498,11 +500,13 @@ x11_output_repaint_shm(struct weston_output *output_base,
free(err);
}
 
-   wl_event_source_timer_update(output->finish_frame_timer, 10);
+   weston_compositor_event_source_update_timeout(ec,
+ 
output->finish_frame_timer,
+ 10);
return 0;
 }
 
-static int
+static enum weston_event_source_status
 finish_frame_handler(void *data)
 {
struct x11_output *output = data;
@@ -511,7 +515,7 @@ finish_frame_handler(void *data)
weston_compositor_read_presentation_clock(output->base.compositor, );
weston_output_finish_frame(>base, , 0);
 
-   return 1;
+   return WESTON_EVENT_SOURCE_CONTINUE;
 }
 
 static void
@@ -874,7 +878,8 @@ x11_output_disable(struct weston_output *base)
if (!output->base.enabled)
return 0;
 
-   wl_event_source_remove(output->finish_frame_timer);
+   weston_compositor_event_source_remove(base->compositor,
+ output->finish_frame_timer);
 
if (backend->use_pixman) {
pixman_renderer_output_destroy(>base);
@@ -1044,7 +1049,11 @@ x11_output_enable(struct weston_output *base)
 
loop = wl_display_get_event_loop(b->compositor->wl_display);
output->finish_frame_timer =
-   wl_event_loop_add_timer(loop, finish_frame_handler, output);
+   weston_compositor_event_source_add_timeout(base->compositor,
+  
WESTON_EVENT_SOURCE_PRIORITY_TIMEOUT,
+  0,
+  finish_frame_handler,
+  output);
 
weston_log("x11 output %dx%d, window id %d\n",
   output->base.current_mode->width,
@@ -1394,20 +1403,8 @@ x11_backend_deliver_enter_event(struct x11_backend *b,
b->prev_y = y;
 }
 
-static int
-x11_backend_next_event(struct x11_backend *b,
-  xcb_generic_event_t **event, uint32_t mask)
-{
-   if (mask & WL_EVENT_READABLE)
-   *event = xcb_poll_for_event(b->conn);
-   else
-   *event = xcb_poll_for_queued_event(b->conn);
-
-   return *event != NULL;
-}
-
-static int
-x11_backend_handle_event(int fd, uint32_t mask, void *data)
+static enum weston_event_source_status
+x11_backend_handle_event(int fd, enum weston_event_source_fd_events mask, void 
*data)
 {
struct x11_backend *b = data;
struct x11_output *output;
@@ -1424,12 +1421,10 @@ x11_backend_handle_event(int fd, uint32_t mask, void 
*data)
uint32_t *k;
uint32_t i, set;
uint8_t response_type;
-   int count;
struct timespec time;
 
prev = NULL;
-   count = 0;
-   while (x11_backend_next_event(b, , mask)) {
+   while ((event = xcb_poll_for_event(b->conn)) != NULL) {
response_type = event->response_type & ~0x80;
 
switch (prev ? prev->response_type & ~0x80 : 0x80) {
@@ -1637,7 +1632,6 @@ x11_backend_handle_event(i

[RFC weston 0/2] Event loop abstraction API

2018-02-19 Thread Quentin Glidic
From: Quentin Glidic <sardemff7+...@sardemff7.net>

We discussed on IRC about races between the several event sources that
exist in libweston, libwayland and compositor code. Adding a priority
system in the event loop is a first step to fix these potential races
and help cope with bad clients.
A second issue is that compositor writers are usually used to some
specific event loop library (GLib, Qt, libev or any other) with
differences in APIs and some frameworks are tied to one.

To make things easier to compositor writers, here is a draft for an
event loop API abstraction that should allow to pick any library to work
with libweston.
(Still lacking the signal handling part.)

Sending as RFC to check if the API is fine by Weston contributors before
migrating all the codebase to it.

Cheers,

Quentin Glidic (2):
  libweston: Add event loop abstraction API
  compositor-x11: Use event loop abstraction API

 compositor/main.c  | 182 +++--
 libweston/compositor-x11.c |  64 
 libweston/compositor.c |  86 +
 libweston/compositor.h |  67 +
 4 files changed, 358 insertions(+), 41 deletions(-)

-- 
2.15.1

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[RFC weston 1/2] libweston: Add event loop abstraction API

2018-02-19 Thread Quentin Glidic
From: Quentin Glidic <sardemff7+...@sardemff7.net>

This will allow compositors to pick any event loop implementation they
want, and integrating the libweston components with it.
Specifically, idle and timeout sources can now have proper priorities to
avoid being ghosted by client event processing.

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
 compositor/main.c  | 182 +++--
 libweston/compositor.c |  86 +++
 libweston/compositor.h |  67 ++
 3 files changed, 329 insertions(+), 6 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index 18810f288..c0a5ba506 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -76,6 +76,180 @@ struct wet_compositor {
bool drm_use_current_mode;
 };
 
+static struct wet_compositor *
+to_wet_compositor(struct weston_compositor *compositor)
+{
+   return weston_compositor_get_user_data(compositor);
+}
+
+struct wet_event_source {
+   struct wl_event_loop *loop;
+   struct wl_event_source *source;
+   weston_event_source_callback cb;
+   weston_event_source_fd_callback fd_cb;
+   void *user_data;
+};
+
+static void
+wet_event_source_idle_cb(void *data)
+{
+   struct wet_event_source *wsource = data;
+   enum weston_event_source_status ret;
+
+   ret = wsource->cb(wsource->user_data);
+   if (ret == WESTON_EVENT_SOURCE_REMOVE)
+   return;
+
+   wsource->source = wl_event_loop_add_idle(wsource->loop, 
wet_event_source_idle_cb, wsource);
+   if (wsource->source == NULL)
+   free(wsource);
+}
+
+static void *
+wet_event_source_add_idle(struct weston_compositor *compositor,
+ enum weston_event_source_priority priority,
+ weston_event_source_callback cb, void *user_data)
+{
+   struct wet_event_source *wsource = malloc(sizeof(struct 
wet_event_source));
+   if (wsource == NULL)
+   return NULL;
+
+   wsource->loop = wl_display_get_event_loop(compositor->wl_display);
+   wsource->cb = cb;
+   wsource->user_data = user_data;
+
+   wsource->source = wl_event_loop_add_idle(wsource->loop, 
wet_event_source_idle_cb, wsource);
+   if (wsource->source == NULL) {
+   free(wsource);
+   return NULL;
+   }
+
+   return wsource;
+}
+
+static int
+wet_event_source_timeout_cb(void *data)
+{
+   struct wet_event_source *wsource = data;
+   enum weston_event_source_status ret;
+
+   ret = wsource->cb(wsource->user_data);
+   if (ret == WESTON_EVENT_SOURCE_CONTINUE)
+   return 0;
+
+   wl_event_source_remove(wsource->source);
+   free(wsource);
+   return 0;
+}
+
+static void *
+wet_event_source_add_timeout(struct weston_compositor *compositor,
+enum weston_event_source_priority priority,
+uint32_t milliseconds,
+weston_event_source_callback cb, void *user_data)
+{
+   struct wet_event_source *wsource = malloc(sizeof(struct 
wet_event_source));
+   if (wsource == NULL)
+   return NULL;
+
+   wsource->loop = wl_display_get_event_loop(compositor->wl_display);
+   wsource->cb = cb;
+   wsource->user_data = user_data;
+
+   wsource->source = wl_event_loop_add_timer(wsource->loop, 
wet_event_source_timeout_cb, wsource);
+   if (wsource->source == NULL) {
+   free(wsource);
+   return NULL;
+   }
+
+   if (milliseconds > 0)
+   wl_event_source_timer_update(wsource->source, milliseconds);
+
+   return wsource;
+}
+
+static void
+wet_event_source_update_timeout(struct weston_compositor *compositor,
+   void *source, uint32_t milliseconds)
+{
+   struct wet_event_source *wsource = source;
+
+   wl_event_source_timer_update(wsource->source, milliseconds);
+}
+
+static int
+wet_event_source_fd_cb(int fd, uint32_t mask, void *data)
+{
+   struct wet_event_source *wsource = data;
+   enum weston_event_source_status ret;
+
+   ret = wsource->fd_cb(fd, mask, wsource->user_data);
+   if (ret == WESTON_EVENT_SOURCE_CONTINUE)
+   return 0;
+
+   wl_event_source_remove(wsource->source);
+   free(wsource);
+   return 0;
+}
+
+static void *
+wet_event_source_add_fd(struct weston_compositor *compositor,
+   enum weston_event_source_priority priority,
+   int fd, enum weston_event_source_fd_events events,
+   weston_event_source_fd_callback cb, void *user_data)
+{
+   struct wet_event_source *wsource = malloc(sizeof(struct 
wet_event_source));
+   if (wsource == NULL)
+   return NULL;
+
+   wsource->loop = wl_display_get_event_loop(compositor-&

Re: [PATCH weston v3 3/7] libweston: Make weston_seat release safe

2018-02-15 Thread Quentin Glidic
will
+* avoid posting an error, and we will instead gracefully fail the
+* grab and dismiss the surface.
+* FIXME: this is a hack because currently we cannot check the topmost
+* parent with a destroyed weston_seat */
+   if (seat == NULL)
+   parent_is_toplevel = true;
+


Good comment. Now I’m not sure if it belongs here or in 
weston_desktop_seat_popup_grab_get_topmost_surface() (with a separate if).

Probably no big deal anyway.

With these 3 (not counting the comment) things fixed, the 
libweston-desktop stuff is:

Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

Thanks,



topmost = weston_desktop_seat_popup_grab_get_topmost_surface(seat);
if ((topmost == NULL && !parent_is_toplevel) ||
(topmost != NULL && topmost != popup->parent->desktop_surface)) {
diff --git a/libweston/data-device.c b/libweston/data-device.c
index b4bb4b37..e3dbee3e 100644
--- a/libweston/data-device.c
+++ b/libweston/data-device.c
@@ -1167,9 +1167,10 @@ data_device_set_selection(struct wl_client *client,
  struct wl_resource *resource,
  struct wl_resource *source_resource, uint32_t serial)
  {
+   struct weston_seat *seat = wl_resource_get_user_data(resource);
struct weston_data_source *source;
  
-	if (!source_resource)

+   if (!seat || !source_resource)
return;
  
  	source = wl_resource_get_user_data(source_resource);

@@ -1182,8 +1183,7 @@ data_device_set_selection(struct wl_client *client,
}
  
  	/* FIXME: Store serial and check against incoming serial here. */

-   weston_seat_set_selection(wl_resource_get_user_data(resource),
- source, serial);
+   weston_seat_set_selection(seat, source, serial);
  }
  static void
  data_device_release(struct wl_client *client, struct wl_resource *resource)
@@ -1296,8 +1296,13 @@ get_data_device(struct wl_client *client,
return;
}
  
-	wl_list_insert(>drag_resource_list,

-  wl_resource_get_link(resource));
+   if (seat) {
+   wl_list_insert(>drag_resource_list,
+  wl_resource_get_link(resource));
+   } else {
+   wl_list_init(wl_resource_get_link(resource));
+   }
+
wl_resource_set_implementation(resource, _device_interface,
   seat, unbind_data_device);
  }
diff --git a/libweston/input.c b/libweston/input.c
index 647268af..da002548 100644
--- a/libweston/input.c
+++ b/libweston/input.c
@@ -2420,13 +2420,10 @@ seat_get_pointer(struct wl_client *client, struct 
wl_resource *resource,
 * This prevents a race between the compositor sending new
 * capabilities and the client trying to use the old ones.
 */
-   struct weston_pointer *pointer = seat->pointer_state;
+   struct weston_pointer *pointer = seat ? seat->pointer_state : NULL;
struct wl_resource *cr;
struct weston_pointer_client *pointer_client;
  
-	if (!pointer)

-   return;
-
  cr = wl_resource_create(client, _pointer_interface,
wl_resource_get_version(resource), id);
if (cr == NULL) {
@@ -2434,6 +2431,15 @@ seat_get_pointer(struct wl_client *client, struct 
wl_resource *resource,
return;
}
  
+	wl_list_init(wl_resource_get_link(cr));

+   wl_resource_set_implementation(cr, _interface, pointer,
+  unbind_pointer_client_resource);
+
+   /* If we don't have a pointer_state, the resource is inert, so there
+* is nothing more to set up */
+   if (!pointer)
+   return;
+
pointer_client = weston_pointer_ensure_pointer_client(pointer, client);
if (!pointer_client) {
wl_client_post_no_memory(client);
@@ -2442,8 +2448,6 @@ seat_get_pointer(struct wl_client *client, struct 
wl_resource *resource,
  
  	wl_list_insert(_client->pointer_resources,

   wl_resource_get_link(cr));
-   wl_resource_set_implementation(cr, _interface, pointer,
-  unbind_pointer_client_resource);
  
  	if (pointer->focus && pointer->focus->surface->resource &&

wl_resource_get_client(pointer->focus->surface->resource) == 
client) {
@@ -2507,12 +2511,9 @@ seat_get_keyboard(struct wl_client *client, struct 
wl_resource *resource,
 * This prevents a race between the compositor sending new
 * capabilities and the client trying to use the old ones.
 */
-   struct weston_keyboard *keyboard = seat->keyboard_state;
+   struct weston_keyboard *keyboard = seat ? seat->keyboard_state : NULL;
struct wl_resource *cr;
  
-	if (!keyboard)

-   return;
-
  cr = wl_resource_create(c

Re: [PATCH weston v2 3/7] libweston: Make weston_seat release safe

2018-02-13 Thread Quentin Glidic
x, y);
  }
@@ -438,6 +441,9 @@ weston_desktop_xdg_surface_protocol_move(struct wl_client 
*wl_client,
struct weston_desktop_xdg_surface *surface =
weston_desktop_surface_get_implementation_data(dsurface);
  
+	if (seat == NULL)

+   return;
+
weston_desktop_xdg_surface_ensure_added(surface);
weston_desktop_api_move(surface->desktop, dsurface, seat, serial);
  }
@@ -458,6 +464,9 @@ weston_desktop_xdg_surface_protocol_resize(struct wl_client 
*wl_client,
enum weston_desktop_surface_edge surf_edges =
(enum weston_desktop_surface_edge) edges;
  
+	if (seat == NULL)

+   return;
+
weston_desktop_xdg_surface_ensure_added(surface);
weston_desktop_api_resize(surface->desktop, dsurface, seat, serial, 
surf_edges);
  }
@@ -766,11 +775,16 @@ weston_desktop_xdg_shell_protocol_get_xdg_popup(struct 
wl_client *wl_client,
struct weston_surface *wparent =
wl_resource_get_user_data(parent_resource);
struct weston_seat *wseat = wl_resource_get_user_data(seat_resource);
-   struct weston_desktop_seat *seat = weston_desktop_seat_from_seat(wseat);
+   struct weston_desktop_seat *seat;
struct weston_desktop_surface *parent, *topmost;
bool parent_is_popup, parent_is_xdg;
struct weston_desktop_xdg_popup *popup;
  
+	if (wseat == NULL)

+   return;


See comment on v6.



+
+   seat = weston_desktop_seat_from_seat(wseat);
+
if (weston_surface_set_role(wsurface, "xdg_popup", resource, 
XDG_SHELL_ERROR_ROLE) < 0)
return;
  
diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c

index 4db3748b..3bf15e7a 100644
--- a/libweston-desktop/xdg-shell-v6.c
+++ b/libweston-desktop/xdg-shell-v6.c
@@ -371,6 +371,9 @@ 
weston_desktop_xdg_toplevel_protocol_show_window_menu(struct wl_client *wl_clien
struct weston_desktop_xdg_toplevel *toplevel =
weston_desktop_surface_get_implementation_data(dsurface);
  
+	if (seat == NULL)

+   return;
+
if (!toplevel->base.configured) {
wl_resource_post_error(toplevel->resource,
   ZXDG_SURFACE_V6_ERROR_NOT_CONSTRUCTED,
@@ -395,6 +398,9 @@ weston_desktop_xdg_toplevel_protocol_move(struct wl_client 
*wl_client,
struct weston_desktop_xdg_toplevel *toplevel =
weston_desktop_surface_get_implementation_data(dsurface);
  
+	if (seat == NULL)

+   return;
+
if (!toplevel->base.configured) {
wl_resource_post_error(toplevel->resource,
   ZXDG_SURFACE_V6_ERROR_NOT_CONSTRUCTED,
@@ -421,6 +427,9 @@ weston_desktop_xdg_toplevel_protocol_resize(struct 
wl_client *wl_client,
enum weston_desktop_surface_edge surf_edges =
(enum weston_desktop_surface_edge) edges;
  
+	if (seat == NULL)

+   return;
+
if (!toplevel->base.configured) {
wl_resource_post_error(toplevel->resource,
   ZXDG_SURFACE_V6_ERROR_NOT_CONSTRUCTED,
@@ -757,11 +766,18 @@ weston_desktop_xdg_popup_protocol_grab(struct wl_client 
*wl_client,
struct weston_desktop_xdg_popup *popup =
weston_desktop_surface_get_implementation_data(dsurface);
struct weston_seat *wseat = wl_resource_get_user_data(seat_resource);
-   struct weston_desktop_seat *seat = weston_desktop_seat_from_seat(wseat);
+   struct weston_desktop_seat *seat;
struct weston_desktop_surface *topmost;
bool parent_is_toplevel =
popup->parent->role == WESTON_DESKTOP_XDG_SURFACE_ROLE_TOPLEVEL;
  
+	if (wseat == NULL) {

+   
weston_desktop_surface_popup_dismiss(popup->base.desktop_surface);


This is good.
You need to do the same for v5 and wl_shell, otherwise the client will 
be out of sync. Specifically for v5 where it creates an xdg_popup object 
while this patch would not.


With that fixed (or v5 just left as unmaintained/unused), the 
libweston-desktop stuff is:

Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>


Thanks,


+   return;
+   }
+
+   seat = weston_desktop_seat_from_seat(wseat);
+
if (popup->committed) {
wl_resource_post_error(popup->resource,
   ZXDG_POPUP_V6_ERROR_INVALID_GRAB,



--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH] Unconditionally add linux-dmabuf’s protocol to BUILT_SOURCES

2018-01-07 Thread Quentin Glidic

On 1/7/18 12:09 PM, Emmanuel Gil Peyrot wrote:

This was preventing weston-info from building if both
weston-simple-dmabuf-drm and weston-simple-dmabuf-v4l2 were disabled at
build-time.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
Reported-by: Cedric Sodhi <man...@openmail.cc>
Tested-by: Cedric Sodhi <man...@openmail.cc>


Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>
And pushed:
14a7e371f..0a5439961  master -> master

Thanks,



---
  Makefile.am | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 883249c0..64cceec4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -638,7 +638,6 @@ nodist_weston_simple_dmabuf_drm_SOURCES =   \
protocol/linux-dmabuf-unstable-v1-client-protocol.h
  weston_simple_dmabuf_drm_CFLAGS = $(AM_CFLAGS) 
$(SIMPLE_DMABUF_DRM_CLIENT_CFLAGS)
  weston_simple_dmabuf_drm_LDADD = $(SIMPLE_DMABUF_DRM_CLIENT_LIBS) 
$(LIBDRM_PLATFORM_LIBS) libshared.la
-BUILT_SOURCES += protocol/linux-dmabuf-unstable-v1-client-protocol.h
  endif
  
  if BUILD_SIMPLE_DMABUF_V4L_CLIENT

@@ -653,7 +652,6 @@ nodist_weston_simple_dmabuf_v4l_SOURCES =   \
protocol/linux-dmabuf-unstable-v1-client-protocol.h
  weston_simple_dmabuf_v4l_CFLAGS = $(AM_CFLAGS) 
$(SIMPLE_DMABUF_V4L_CLIENT_CFLAGS)
  weston_simple_dmabuf_v4l_LDADD = $(SIMPLE_DMABUF_V4L_CLIENT_LIBS) libshared.la
-BUILT_SOURCES += protocol/linux-dmabuf-unstable-v1-client-protocol.h
  endif
  
  noinst_LTLIBRARIES += libtoytoolkit.la

@@ -894,7 +892,9 @@ BUILT_SOURCES +=\
protocol/ivi-hmi-controller-protocol.c  \
protocol/ivi-hmi-controller-client-protocol.h   \
protocol/ivi-application-protocol.c \
-   protocol/ivi-application-client-protocol.h
+   protocol/ivi-application-client-protocol.h  \
+   protocol/linux-dmabuf-unstable-v1-protocol.c\
+   protocol/linux-dmabuf-unstable-v1-client-protocol.h
  
  westondatadir = $(datadir)/weston

  dist_westondata_DATA =\




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston v3] libweston-desktop: add signal for title/app-id changes

2017-12-08 Thread Quentin Glidic

On 12/8/17 3:13 PM, Matt Hoosier wrote:

On Fri, Dec 8, 2017 at 4:26 AM, Quentin Glidic
<sardemff7+wayl...@sardemff7.net> wrote:

On 12/8/17 11:22 AM, Quentin Glidic wrote:


From: Matt Hoosier <matt.hoos...@gmail.com>

As discussed on

https://lists.freedesktop.org/archives/wayland-devel/2017-August/034720.html,
it's useful for the shell implementation to know when these change,
for example to relay the information on to taskbars or similar.

To avoid ABI changes or the need to make the weston_desktop_surface
definition public, new functions are introduced for attaching
listeners to these signals.

Signed-off-by: Matt Hoosier <matt.hoos...@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>
Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---



(Err, wanted to drop the Sob send-email added via command line and I just
closed vim…)

I made this v3 to rename the signal to "metadata" instead of "title", but
also to tweak a tiny bit the signal sending. I wanted the shell not to have
to strdup() these, so now, it can listen to the signal, and compare old and
new values (and even use both) without extra cost.
Do you ack that change?

Still not sure I prefer a signal to just adding to the callbacks struct, but
we can always break API/ABI again later if we need to. :-)


I like the change, and prefer the name "metadata" for the signal
anyway. The v3 changes are:

Acked-by: Matt Hoosier <matt.hoos...@gmail.com>

(Not sure whether you actually want to put it into the commit message,
since I'm the original author. But I approve.)

Thanks for the review.



It was just a matter of making sure you understand the change. :-)

And finally, pushed !
037f056ec..555c548c7  master -> master

Thanks,

--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston v3] libweston-desktop: add signal for title/app-id changes

2017-12-08 Thread Quentin Glidic

On 12/8/17 11:22 AM, Quentin Glidic wrote:

From: Matt Hoosier <matt.hoos...@gmail.com>

As discussed on
https://lists.freedesktop.org/archives/wayland-devel/2017-August/034720.html,
it's useful for the shell implementation to know when these change,
for example to relay the information on to taskbars or similar.

To avoid ABI changes or the need to make the weston_desktop_surface
definition public, new functions are introduced for attaching
listeners to these signals.

Signed-off-by: Matt Hoosier <matt.hoos...@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>
Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---


(Err, wanted to drop the Sob send-email added via command line and I 
just closed vim…)


I made this v3 to rename the signal to "metadata" instead of "title", 
but also to tweak a tiny bit the signal sending. I wanted the shell not 
to have to strdup() these, so now, it can listen to the signal, and 
compare old and new values (and even use both) without extra cost.

Do you ack that change?

Still not sure I prefer a signal to just adding to the callbacks struct, 
but we can always break API/ABI again later if we need to. :-)


Cheers,



  libweston-desktop/libweston-desktop.h |  3 +++
  libweston-desktop/surface.c   | 22 ++
  2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/libweston-desktop/libweston-desktop.h 
b/libweston-desktop/libweston-desktop.h
index 03b04c7bc..a0fb9381b 100644
--- a/libweston-desktop/libweston-desktop.h
+++ b/libweston-desktop/libweston-desktop.h
@@ -164,6 +164,9 @@ weston_desktop_surface_set_size(struct 
weston_desktop_surface *surface,
int32_t width, int32_t height);
  void
  weston_desktop_surface_close(struct weston_desktop_surface *surface);
+void
+weston_desktop_surface_add_metadata_listener(struct weston_desktop_surface 
*surface,
+struct wl_listener *listener);
  
  void *

  weston_desktop_surface_get_user_data(struct weston_desktop_surface *surface);
diff --git a/libweston-desktop/surface.c b/libweston-desktop/surface.c
index d3be93640..cbfa5ee00 100644
--- a/libweston-desktop/surface.c
+++ b/libweston-desktop/surface.c
@@ -64,6 +64,7 @@ struct weston_desktop_surface {
char *title;
char *app_id;
pid_t pid;
+   struct wl_signal metadata_signal;
};
struct {
struct weston_desktop_surface *parent;
@@ -287,6 +288,8 @@ weston_desktop_surface_create(struct weston_desktop 
*desktop,
wl_list_init(>view_list);
wl_list_init(>grab_link);
  
+	wl_signal_init(>metadata_signal);

+
return surface;
  }
  
@@ -511,6 +514,13 @@ weston_desktop_surface_close(struct weston_desktop_surface *surface)

   surface->implementation_data);
  }
  
+WL_EXPORT void

+weston_desktop_surface_add_metadata_listener(struct weston_desktop_surface 
*surface,
+struct wl_listener *listener)
+{
+   wl_signal_add(>metadata_signal, listener);
+}
+
  struct weston_desktop_surface *
  weston_desktop_surface_from_client_link(struct wl_list *link)
  {
@@ -679,28 +689,32 @@ void
  weston_desktop_surface_set_title(struct weston_desktop_surface *surface,
 const char *title)
  {
-   char *tmp;
+   char *tmp, *old;
  
  	tmp = strdup(title);

if (tmp == NULL)
return;
  
-	free(surface->title);

+   old = surface->title;
surface->title = tmp;
+   wl_signal_emit(>metadata_signal, surface);
+   free(old);
  }
  
  void

  weston_desktop_surface_set_app_id(struct weston_desktop_surface *surface,
  const char *app_id)
  {
-   char *tmp;
+   char *tmp, *old;
  
  	tmp = strdup(app_id);

if (tmp == NULL)
return;
  
-	free(surface->app_id);

+   old = surface->app_id;
surface->app_id = tmp;
+   wl_signal_emit(>metadata_signal, surface);
+   free(old);
  }
  
  void





--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v3] libweston-desktop: add signal for title/app-id changes

2017-12-08 Thread Quentin Glidic
From: Matt Hoosier <matt.hoos...@gmail.com>

As discussed on
https://lists.freedesktop.org/archives/wayland-devel/2017-August/034720.html,
it's useful for the shell implementation to know when these change,
for example to relay the information on to taskbars or similar.

To avoid ABI changes or the need to make the weston_desktop_surface
definition public, new functions are introduced for attaching
listeners to these signals.

Signed-off-by: Matt Hoosier <matt.hoos...@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>
Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
 libweston-desktop/libweston-desktop.h |  3 +++
 libweston-desktop/surface.c   | 22 ++
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/libweston-desktop/libweston-desktop.h 
b/libweston-desktop/libweston-desktop.h
index 03b04c7bc..a0fb9381b 100644
--- a/libweston-desktop/libweston-desktop.h
+++ b/libweston-desktop/libweston-desktop.h
@@ -164,6 +164,9 @@ weston_desktop_surface_set_size(struct 
weston_desktop_surface *surface,
int32_t width, int32_t height);
 void
 weston_desktop_surface_close(struct weston_desktop_surface *surface);
+void
+weston_desktop_surface_add_metadata_listener(struct weston_desktop_surface 
*surface,
+struct wl_listener *listener);
 
 void *
 weston_desktop_surface_get_user_data(struct weston_desktop_surface *surface);
diff --git a/libweston-desktop/surface.c b/libweston-desktop/surface.c
index d3be93640..cbfa5ee00 100644
--- a/libweston-desktop/surface.c
+++ b/libweston-desktop/surface.c
@@ -64,6 +64,7 @@ struct weston_desktop_surface {
char *title;
char *app_id;
pid_t pid;
+   struct wl_signal metadata_signal;
};
struct {
struct weston_desktop_surface *parent;
@@ -287,6 +288,8 @@ weston_desktop_surface_create(struct weston_desktop 
*desktop,
wl_list_init(>view_list);
wl_list_init(>grab_link);
 
+   wl_signal_init(>metadata_signal);
+
return surface;
 }
 
@@ -511,6 +514,13 @@ weston_desktop_surface_close(struct weston_desktop_surface 
*surface)
   surface->implementation_data);
 }
 
+WL_EXPORT void
+weston_desktop_surface_add_metadata_listener(struct weston_desktop_surface 
*surface,
+struct wl_listener *listener)
+{
+   wl_signal_add(>metadata_signal, listener);
+}
+
 struct weston_desktop_surface *
 weston_desktop_surface_from_client_link(struct wl_list *link)
 {
@@ -679,28 +689,32 @@ void
 weston_desktop_surface_set_title(struct weston_desktop_surface *surface,
 const char *title)
 {
-   char *tmp;
+   char *tmp, *old;
 
tmp = strdup(title);
if (tmp == NULL)
return;
 
-   free(surface->title);
+   old = surface->title;
surface->title = tmp;
+   wl_signal_emit(>metadata_signal, surface);
+   free(old);
 }
 
 void
 weston_desktop_surface_set_app_id(struct weston_desktop_surface *surface,
  const char *app_id)
 {
-   char *tmp;
+   char *tmp, *old;
 
tmp = strdup(app_id);
if (tmp == NULL)
return;
 
-   free(surface->app_id);
+   old = surface->app_id;
surface->app_id = tmp;
+   wl_signal_emit(>metadata_signal, surface);
+   free(old);
 }
 
 void
-- 
2.15.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v2] libweston-desktop/xwayland: Make sure racy surfaces are properly mapped

2017-12-08 Thread Quentin Glidic
From: Quentin Glidic <sardemff7+...@sardemff7.net>

This fixes a race between Xwayland committing the surface content via
the wl_surface, and the XWM setting the role of the surface.
We now keep track of the (first) content commit on the surface and
forward it to the shell when we finally get the role.
There is no need to track later changes, as the only way for Xwayland to
unmap a surface is to destroy it.

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>
---
v2: a brand new commit message :-)

 libweston-desktop/xwayland.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/libweston-desktop/xwayland.c b/libweston-desktop/xwayland.c
index 002e2523c..4b4407b9c 100644
--- a/libweston-desktop/xwayland.c
+++ b/libweston-desktop/xwayland.c
@@ -61,6 +61,7 @@ struct weston_desktop_xwayland_surface {
const struct weston_xwayland_client_interface *client_interface;
struct weston_geometry next_geometry;
bool has_next_geometry;
+   bool committed;
bool added;
enum weston_desktop_xwayland_surface_state state;
 };
@@ -99,6 +100,14 @@ weston_desktop_xwayland_surface_change_state(struct 
weston_desktop_xwayland_surf
weston_desktop_api_surface_added(surface->desktop,
 surface->surface);
surface->added = true;
+   if (surface->state == NONE && surface->committed)
+   /* We had a race, and wl_surface.commit() was
+* faster, just fake a commit to map the
+* surface */
+   weston_desktop_api_committed(surface->desktop,
+surface->surface,
+0, 0);
+
} else if (surface->added) {
weston_desktop_api_surface_removed(surface->desktop,
   surface->surface);
@@ -133,6 +142,7 @@ weston_desktop_xwayland_surface_committed(struct 
weston_desktop_surface *dsurfac
struct weston_geometry oldgeom;
 
assert(dsurface == surface->surface);
+   surface->committed = true;
 
 #ifdef WM_DEBUG
weston_log("%s: xwayland surface %p\n", __func__, surface);
-- 
2.15.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston v4] xwm: Add icon support to the frame

2017-12-01 Thread Quentin Glidic

On 12/1/17 7:20 PM, Emmanuel Gil Peyrot wrote:

This fetches the _NET_WM_ICON property of the X11 window, and use the
first image found as the frame icon.

This has been tested with various X11 programs, and improves usability
and user-friendliness a bit.

Changes since v1:
- Changed frame_button_create() to use
   frame_button_create_from_surface() internally.
- Removed a check that should never have been commited.

Changes since v2:
- Request UINT32_MAX items instead of 2048, to avoid cutting valid
   icons.
- Strengthen checks against malformed input.
- Handle XCB_PROPERTY_DELETE to remove the icon.
- Schedule a repaint if the icon changed.

Changes since v3:
- Keep the previous Cairo surface until the new one has been
   successfully loaded.
- Use uint32_t for cardinals.  Unsigned is the same type except on
   16-bit machines, but uint32_t is clearer.
- Declare length as uint32_t too, like in xcb_get_property_reply_t.

Signed-off-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr>
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>


Just re-checked to be sure, found a tiny thing I overlooked (see below), 
but the Rb still stands anyway.




---
  clients/window.c   |  4 +--
  libweston/compositor-wayland.c |  2 +-
  shared/cairo-util.h|  2 +-
  shared/frame.c | 54 ++-
  xwayland/window-manager.c  | 65 --
  5 files changed, 107 insertions(+), 20 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index 95796d46..15a86e15 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -2546,7 +2546,7 @@ window_frame_create(struct window *window, void *data)
  
  	frame = xzalloc(sizeof *frame);

frame->frame = frame_create(window->display->theme, 0, 0,
-   buttons, window->title);
+   buttons, window->title, NULL);
  
  	frame->widget = window_add_widget(window, frame);

frame->child = widget_add_widget(frame->widget, data);
@@ -5449,7 +5449,7 @@ create_menu(struct display *display,
menu->user_data = user_data;
menu->widget = window_add_widget(menu->window, menu);
menu->frame = frame_create(window->display->theme, 0, 0,
-  FRAME_BUTTON_NONE, NULL);
+  FRAME_BUTTON_NONE, NULL, NULL);
fail_on_null(menu->frame, 0, __FILE__, __LINE__);
menu->entries = entries;
menu->count = count;
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 3bdfb03e..c5290d85 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -869,7 +869,7 @@ wayland_output_set_windowed(struct wayland_output *output)
return -1;
}
output->frame = frame_create(b->theme, 100, 100,
-FRAME_BUTTON_CLOSE, output->title);
+FRAME_BUTTON_CLOSE, output->title, NULL);
if (!output->frame)
return -1;
  
diff --git a/shared/cairo-util.h b/shared/cairo-util.h

index 84cf005e..7893ca24 100644
--- a/shared/cairo-util.h
+++ b/shared/cairo-util.h
@@ -126,7 +126,7 @@ enum {
  
  struct frame *

  frame_create(struct theme *t, int32_t width, int32_t height, uint32_t buttons,
-const char *title);
+ const char *title, cairo_surface_t *icon);
  
  void

  frame_destroy(struct frame *frame);
diff --git a/shared/frame.c b/shared/frame.c
index eb0cd77a..32779856 100644
--- a/shared/frame.c
+++ b/shared/frame.c
@@ -106,9 +106,9 @@ struct frame {
  };
  
  static struct frame_button *

-frame_button_create(struct frame *frame, const char *icon,
-   enum frame_status status_effect,
-   enum frame_button_flags flags)
+frame_button_create_from_surface(struct frame *frame, cairo_surface_t *icon,
+ enum frame_status status_effect,
+ enum frame_button_flags flags)
  {
struct frame_button *button;
  
@@ -116,12 +116,7 @@ frame_button_create(struct frame *frame, const char *icon,

if (!button)
return NULL;
  
-	button->icon = cairo_image_surface_create_from_png(icon);

-   if (!button->icon) {
-   free(button);
-   return NULL;
-   }
-
+   button->icon = icon;
button->frame = frame;
button->flags = flags;
button->status_effect = status_effect;
@@ -131,6 +126,30 @@ frame_button_create(struct frame *frame, const char *icon,
return button;
  }
  
+static struct frame_button *

+frame_button_create(struct frame *frame, const char *icon_name,
+enum frame_status status_effect,
+enum frame_button_flags flags)
+{
+   struct frame_but

[PATCH libinput 1/2] meson: Fix absolute libdir case in install script

2017-11-30 Thread Quentin Glidic
From: Quentin Glidic <sardemff7+...@sardemff7.net>

If libdir is an absolute path (which means it’s outside of prefix) we
would wrongly add the prefix to it in the install script. Just pass the
correct libdir from Meson directly thanks to join_paths() magic.

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
Just found this one while doing patch 2, I didn’t actually test it.

 meson.build | 2 +-
 src/libinput-restore-selinux-context.sh | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/meson.build b/meson.build
index 9b0fa246..6c5b9a84 100644
--- a/meson.build
+++ b/meson.build
@@ -225,7 +225,7 @@ pkgconfig.generate(
 # Restore the SELinux context for the libinput.so.a.b.c on install
 # meson bug https://github.com/mesonbuild/meson/issues/1967
 meson.add_install_script('src/libinput-restore-selinux-context.sh',
-get_option('libdir'),
+join_paths(get_option('prefix'), get_option('libdir')),
 lib_libinput.full_path())
 
  documentation 
diff --git a/src/libinput-restore-selinux-context.sh 
b/src/libinput-restore-selinux-context.sh
index 3b1c555b..606b5b08 100644
--- a/src/libinput-restore-selinux-context.sh
+++ b/src/libinput-restore-selinux-context.sh
@@ -7,6 +7,6 @@ libdir="$1"
 sofile=$(basename "$2")
 
 if command -v restorecon >/dev/null; then
-   echo "Restoring SELinux context on 
$MESON_INSTALL_DESTDIR_PREFIX/$libdir/$sofile"
-   restorecon "$MESON_INSTALL_DESTDIR_PREFIX/$libdir/$sofile"
+   echo "Restoring SELinux context on ${DESTDIR}${libdir}/${sofile}"
+   restorecon "${DESTDIR}${libdir}/${sofile}"
 fi
-- 
2.15.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH libinput 2/2] meson: Fix bindir usage in install script

2017-11-30 Thread Quentin Glidic
From: Quentin Glidic <sardemff7+...@sardemff7.net>

Since the install script cannot know the correct bindir, just pass it
from Meson directly.

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
 meson.build |  3 ++-
 tools/install-compat-scripts.sh | 10 --
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/meson.build b/meson.build
index 6c5b9a84..734bf1a5 100644
--- a/meson.build
+++ b/meson.build
@@ -473,7 +473,8 @@ configure_file(input : 'tools/libinput.man',
   install_dir : join_paths(get_option('mandir'), 'man1')
   )
 
-meson.add_install_script('tools/install-compat-scripts.sh')
+meson.add_install_script('tools/install-compat-scripts.sh',
+join_paths(get_option('prefix'), get_option('bindir')))
 
 ptraccel_debug_sources = [ 'tools/ptraccel-debug.c' ]
 executable('ptraccel-debug',
diff --git a/tools/install-compat-scripts.sh b/tools/install-compat-scripts.sh
index 0d8b3adb..b046b849 100755
--- a/tools/install-compat-scripts.sh
+++ b/tools/install-compat-scripts.sh
@@ -1,9 +1,7 @@
 #!/bin/sh
-#
-# This does not honor $bindir properly, because we cannot get to it
-# here. Does anyone build to something but prefix/bin?
-#
-bindir="${DESTDIR}/${MESON_INSTALL_PREFIX}/bin"
-mkdir -p "$bindir"
+
+bindir="${DESTDIR}${1}"
+
+# Do not create bindir, because if it is not there now, we have a problem
 cp "${MESON_SOURCE_ROOT}/tools/libinput-list-devices.compat" 
"${bindir}/libinput-list-devices"
 cp "${MESON_SOURCE_ROOT}/tools/libinput-debug-events.compat" 
"${bindir}/libinput-debug-events"
-- 
2.15.0

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: {RFC weston] 3D window manager using libweston

2017-11-16 Thread Quentin Glidic

On 11/16/17 4:04 PM, Harsha Manjula Mallikarjun (RBEI/ECF3) wrote:

Hi All,

we are developing a middleware frame work for a 3D window manager.
The window manager should be able to map the client buffers to
3D shapes (cube, cylinder and so on).

Our idea is that "3D window manager" uses libweston to get client
buffers and composites them on 3D shapes. Essentially, "3D window manager"
  acts as a compositor for the system by making use of libweston
(i.e. 3D window manager is a process with libweston loaded under it and
it is the ultimate compositor of the system).

Short summary of concept implementation:
To achieve this using libweston we exported eglImages from gl-renderer
  and give control of swapping display buffer to window manager. Backend and
renderer are changed to support different modes of operation so that control to
  swap display buffer can be with window manager whenever needed.

Window manager listens to surface_commit, surface_finalize_signal,
  subsurface_add/remove Signals. Using these signals window manager will get to
  know if  there is an update to the surface OR sub-surfaces under it, and 
queries
  the respective eglImages from gl-renderer. Gl-renderer will be put into a mode
where it will not do composition. Window manager takes total control of
  composition and swapping buffer to display.

Development was started on Weston 2.0. Following patches give the
  idea of changes:

1) Make additional library to reuse code for loading backend from main.c
https://github.com/HarshaMM/weston/commit/1b193d62db53b22cc195bfe694f6b4bde07d0fd3


I have to object strongly on this one. What is the needed feature here?
Not to mention you didn’t properly namespace all the functions.

Of course, it doesn’t force people to use it, but it is just yet another 
command line options and INI parsing library with a few wrappers around 
libweston. That does not sound like a good idea to me. Also, it’s more 
public API/ABI to support.


Please note that I want to add the concept of libweston plugins, but 
these should not need argc/argv. This is just in case you used mainly 
this part.




2) To export EGLImages of each of the client buffers to window manager
   (same process space). Implementation primarily involves gl-renderer.
https://github.com/HarshaMM/weston/commit/d43f42aa06715b52d37df3d5d0d7fa97638d1dfc


I don’t have enough knowledge to comment on this one about implementation.
I have no strong objection to put gl-renderer in a public plugin, but it 
should be done with extra care, regarding making sure it’s loaded.




3) Changes to compositor.c for additional signals of surface and sub-surfaces.
https://github.com/HarshaMM/weston/commit/db335535a8b4abfee52dc1d6099e7db03e6973d4
https://github.com/HarshaMM/weston/commit/6a2f071bde56abed69c7ab827135d1cef5ea35bc
https://github.com/HarshaMM/weston/commit/a51ff22c8fab534e475fa671b1b7ed77ffc8571c
https://github.com/HarshaMM/weston/commit/d5646de516b635f5d01aa925c0c02275126e132d


These don’t seem bad, but at one point, we’d want to make struct 
opaques, so we probably want wrappers for listeners here.




4) Changes to Backend to enable swap from an external renderer (window manager).
https://github.com/HarshaMM/weston/commit/013e2e4eda6d67d5e32ce4aa74e0d6e18c3770f2

Same as 1.



It would be great if you can provide your thoughts about the implementation 
concept. It would
be helpful to know if there are any hard constraints/different design, due to 
which this concept
  should be entirely changed OR it is not a way to realize this using libweston.

Based on your feedback we will decide whether to continue the development, 
rebase and improve
the above patches and submit it to community.


Thanks,


--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [weston v2 5/8] xwm: Make sure we respect the window's size hints

2017-11-13 Thread Quentin Glidic

On 11/13/17 10:20 PM, Louis-Francis Ratté-Boulianne wrote:

Don't just ignore the minimal and maximal sizes requested
by the application.

Signed-off-by: Louis-Francis Ratté-Boulianne 
---
  xwayland/window-manager.c | 14 ++
  1 file changed, 14 insertions(+)

diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
index 3cc6fa24..a0ff6b62 100644
--- a/xwayland/window-manager.c
+++ b/xwayland/window-manager.c
@@ -2801,6 +2801,20 @@ send_configure(struct weston_surface *surface, int32_t 
width, int32_t height)
else
new_height = 1;
  
+	/* Make sure we respect the window's size hints */

+   if (window->size_hints.min_width > 0 &&
+   new_width < window->size_hints.min_width)
+   new_width = window->size_hints.min_width;
+   if (window->size_hints.min_height > 0 &&
+   new_height < window->size_hints.min_height)
+   new_height = window->size_hints.min_height;
+   if (window->size_hints.max_width > 0 &&
+   new_width > window->size_hints.max_width)
+   new_width = window->size_hints.max_width;
+   if (window->size_hints.max_height > 0 &&
+   new_height > window->size_hints.max_height)
+   new_height = window->size_hints.max_height;
+
if (window->width == new_width && window->height == new_height)
return;
  



This one is wrong. Ultimately, it’s up to the shell to decide.
We should forward these hints to libweston-desktop that will provide 
them just like xdg_shell min/max size.
If the shell decide to configure a size outside these hints, it’s up to 
it. A tiling compositor could also use it to e.g. not expand a tile too 
much and expand the other tiles instead.


Thanks,


--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 00/14] Desktop Protocol Support for IVI-Shell

2017-11-07 Thread Quentin Glidic

On 11/7/17 6:01 PM, Matt Hoosier wrote:

Hi Pekka,

On Wed, Oct 25, 2017 at 10:09 AM, Ucan, Emre (ADITG/ESB) 
 wrote:

Actually,  IMO ivi-shell is not a proper wayland compositor.
Because it is violating wayland protocol by not supporting wl_shell
interface.


The wl_shell protocol was designed for the desktop use case. So not 
supporting it is perfectly fine on non-desktop.




Therefore, we have to at least support wl_shell interface in
ivi-shell. Why not support it via libweston-desktop ?


I'm wondering if you have any thoughts on this one specific point
that Emre made. I know there's a lot of heartburn over the inclusion
of wl_shell into the core protocol, and you wouldn't do it that way
if that decision were getting made today.

But given the history that actually happened, is there a reason not
to go ahead and allow the ivi-shell to implement wl_shell simply on
the grounds that it is part of the defined core protocol? I think
that some potentially reasonable answers were made above to your
concerns that the API offered by wl_shell targeted toward desktops
wouldn't be meaningful on an IVI system.  All the mandatory
operations seem to be possible to support,


Except the current patch doesn’t say that. xdg_shell allows the 
compositor to ignore the fullscreen/maximize requests. libweston-desktop 
API was designed around xdg_shell, with best effort for wl_shell (and I 
am in the process of fixing that). With wl_shell, the compositor cannot 
deny the client the fullscreen or maximized state.




and the IVI shell just needs to come up with sensible definitions
(i.e., documented for its users) about how the anonymous wl_shell
clients' surfaces will be integrated with the explicit IVI clients.

Note, I'm not for the moment trying to expand this line of reasoning 
into a grounds for justifying the support of xdg-shell. That

protocol is (deliberately) not part of the core, and I understand
that. If a magic wand were to be waved and use of libweston-desktop
didn't automatically mean that xdg-shell is supported too, would that
be tolerable?


xdg_shell was not added to core to avoid the wl_shell situation. We 
cannot drop wl_shell support because it’s in core wayland.xml, and it’s 
hurting us already, because wl_shell clients will always prevent a full 
migration to xdg_shell. We are lucky that libweston-desktop (and others) 
doesn’t need too much code to support it.



Thanks,

--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 3/3] weston-launch: improve help text for -u and -t

2017-11-01 Thread Quentin Glidic

On 11/1/17 3:24 PM, Pekka Paalanen wrote:

From: Pekka Paalanen <pekka.paala...@collabora.co.uk>

Explain that -u requires root and -t requires -u. Most importantly,
document in what format does -t expect the tty to be given.

It has been confusing, because Weston's --tty option takes an integer,
weston-launch takes a full device path.

Signed-off-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>


Seems good:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

Thanks,



---
  libweston/weston-launch.c | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libweston/weston-launch.c b/libweston/weston-launch.c
index 6a7a7649..79a02506 100644
--- a/libweston/weston-launch.c
+++ b/libweston/weston-launch.c
@@ -676,8 +676,10 @@ static void
  help(const char *name)
  {
fprintf(stderr, "Usage: %s [args...] [-- [weston args..]]\n", name);
-   fprintf(stderr, "  -u, --user  Start session as specified 
username\n");
-   fprintf(stderr, "  -t, --tty   Start session on alternative tty\n");
+   fprintf(stderr, "  -u, --user  Start session as specified 
username,\n"
+   "  e.g. -u joe, requires root.\n");
+   fprintf(stderr, "  -t, --tty   Start session on alternative tty,\n"
+   "  e.g. -t /dev/tty4, requires -u 
option.\n");
fprintf(stderr, "  -v, --verbose   Be verbose\n");
fprintf(stderr, "  -h, --help  Display this help message\n");
  }




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 2/3] weston-launch: fix -t option parsing

2017-11-01 Thread Quentin Glidic

On 11/1/17 3:24 PM, Pekka Paalanen wrote:

From: Pekka Paalanen <pekka.paala...@collabora.co.uk>

Fix an issue introduced in:

  commit ab4999492ce630e6bb1c93215fc052c2c29913bd
  Author: Kristian Høgsberg <k...@bitplanet.net>
  Date:   Fri Jul 19 21:26:24 2013 -0700

  weston-launch: Drop sleep_fork option

where the option string accidentally became "t::". That causes

$ weston-lauch -t /dev/tty4

to be parsed incorrectly, as if -t option had no argument and the tty
path gets passed to weston which errors out because of it.

This patch fixes the above to work as expected.

Signed-off-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>


Good catch!
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

Thanks,



---
  libweston/weston-launch.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libweston/weston-launch.c b/libweston/weston-launch.c
index bc50de74..6a7a7649 100644
--- a/libweston/weston-launch.c
+++ b/libweston/weston-launch.c
@@ -698,7 +698,7 @@ main(int argc, char *argv[])
  
  	memset(, 0, sizeof wl);
  
-	while ((c = getopt_long(argc, argv, "u:t::vh", opts, )) != -1) {

+   while ((c = getopt_long(argc, argv, "u:t:vh", opts, )) != -1) {
switch (c) {
case 'u':
wl.new_user = optarg;




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 1/3] weston-launch: quit if -t without -u

2017-11-01 Thread Quentin Glidic

On 11/1/17 3:24 PM, Pekka Paalanen wrote:

From: Pekka Paalanen <pekka.paala...@collabora.co.uk>

setup_tty() function uses the tty argument for choosing the tty/VT only
if wl->new_user (the -u option) is given. If the tty option is given
without -u, it will only be used for misleading error messages.

To make it clear to the user that -t without -u does not work the way
one might think, let weston-launch exit with an error in that case.

Signed-off-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>
---
  libweston/weston-launch.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/libweston/weston-launch.c b/libweston/weston-launch.c
index aa7e0711..bc50de74 100644
--- a/libweston/weston-launch.c
+++ b/libweston/weston-launch.c
@@ -722,6 +722,9 @@ main(int argc, char *argv[])
if ((argc - optind) > (MAX_ARGV_SIZE - 6))
error(1, E2BIG, "Too many arguments to pass to weston");
  
+	if (tty && !wl.new_user)

+   error(1, 0, "tty option requires -u option as well.");


Nit: maybe EINVAL?
And maybe "-t/--tty … -u/--user", at least use the same format to make 
it clearer?

Anyway, this one is:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

Thanks,



+
if (wl.new_user)
wl.pw = getpwnam(wl.new_user);
else




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston] weston: add wait-for-debugger option

2017-11-01 Thread Quentin Glidic

On 11/1/17 3:23 PM, Pekka Paalanen wrote:

From: Pekka Paalanen <pekka.paala...@collabora.co.uk>

When you need to start Weston via weston-launch, systemd unit, or any
other runner, it is annoying to try to get in with a debugger,
especially if the thing you are interested in happens at start-up. To
make it easy, a new option is introduced.

The new option, implemented both as a command line option and a
weston.ini option, raises SIGSTOP early in the start-up, before the
weston_compositor has been created. This allows one to attach a debugger
at a known point in execution, and resume execution with SIGCONT.

Signed-off-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>


Quite useful indeed:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

Thanks,



---
  compositor/main.c  | 13 +
  man/weston.ini.man |  8 
  man/weston.man |  8 
  3 files changed, 29 insertions(+)

diff --git a/compositor/main.c b/compositor/main.c
index 9e4451e5..78178e99 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -557,6 +557,7 @@ usage(int error_code)
"  --log=FILE\t\tLog to the given file\n"
"  -c, --config=FILE\tConfig file to load, defaults to 
weston.ini\n"
"  --no-config\t\tDo not read weston.ini\n"
+   "  --wait-for-debugger\tRaise SIGSTOP on start-up\n"
"  -h, --help\t\tThis help message\n\n");
  
  #if defined(BUILD_DRM_COMPOSITOR)

@@ -1786,6 +1787,7 @@ int main(int argc, char *argv[])
struct weston_seat *seat;
struct wet_compositor user_data;
int require_input;
+   int32_t wait_for_debugger = 0;
  
  	const struct weston_option core_options[] = {

{ WESTON_OPTION_STRING, "backend", 'B',  },
@@ -1799,6 +1801,7 @@ int main(int argc, char *argv[])
{ WESTON_OPTION_BOOLEAN, "version", 0,  },
{ WESTON_OPTION_BOOLEAN, "no-config", 0,  },
{ WESTON_OPTION_STRING, "config", 'c', _file },
+   { WESTON_OPTION_BOOLEAN, "wait-for-debugger", 0, 
_for_debugger },
};
  
  	if (os_fd_set_cloexec(fileno(stdin))) {

@@ -1860,6 +1863,16 @@ int main(int argc, char *argv[])
  
  	section = weston_config_get_section(config, "core", NULL, NULL);
  
+	if (!wait_for_debugger)

+   weston_config_section_get_bool(section, "wait-for-debugger",
+  _for_debugger, 0);
+   if (wait_for_debugger) {
+   weston_log("Weston PID is %ld - "
+  "waiting for debugger, send SIGCONT to 
continue...\n",
+  (long)getpid());
+   raise(SIGSTOP);
+   }
+
if (!backend) {
weston_config_section_get_string(section, "backend", ,
 NULL);
diff --git a/man/weston.ini.man b/man/weston.ini.man
index 4cfefc91..f237fd60 100644
--- a/man/weston.ini.man
+++ b/man/weston.ini.man
@@ -181,6 +181,14 @@ require an input device for launch
  sets Weston's pageflip timeout in milliseconds.  This sets a timer to exit
  gracefully with a log message and an exit code of 1 in case the DRM driver is
  non-responsive.  Setting it to 0 disables this feature.
+.TP 7
+.BI "wait-for-debugger=" true
+Raises SIGSTOP before initializing the compositor. This allows the user to
+attach with a debugger and continue execution by sending SIGCONT. This is
+useful for debugging a crash on start-up when it would be inconvenient to
+launch weston directly from a debugger. Boolean, defaults to
+.BR false .
+There is also a command line option to do the same.
  
  .SH "LIBINPUT SECTION"

  The
diff --git a/man/weston.man b/man/weston.man
index d19c2d4b..cd53df69 100644
--- a/man/weston.man
+++ b/man/weston.man
@@ -168,6 +168,14 @@ Weston will export
  .B WAYLAND_DISPLAY
  with this value in the environment for all child processes to allow them to
  connect to the right server automatically.
+.TP
+\fB\-\-wait-for-debugger\fR
+Raises SIGSTOP before initializing the compositor. This allows the user to
+attach with a debugger and continue execution by sending SIGCONT. This is
+useful for debugging a crash on start-up when it would be inconvenient to
+launch weston directly from a debugger. There is also a
+.IR weston.ini " option to do the same."
+.
  .SS DRM backend options:
  See
  .BR weston-drm (7).




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston v3 06/36] libweston: refactor weston_mode_switch_finish

2017-10-31 Thread Quentin Glidic

On 10/31/17 12:48 PM, Pekka Paalanen wrote:

From: Pekka Paalanen <pekka.paala...@collabora.co.uk>

Split out a new function. This is a pure refactoring, no change in
behaviour.

This helps a following patch that adds a loop over output->head_list.

Signed-off-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>



Quite obvious:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

Thanks,



---
  libweston/compositor.c | 57 +++---
  1 file changed, 36 insertions(+), 21 deletions(-)

diff --git a/libweston/compositor.c b/libweston/compositor.c
index c3c7e27c..d96c96d4 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -76,15 +76,45 @@ weston_output_transform_scale_init(struct weston_output 
*output,
  static void
  weston_compositor_build_view_list(struct weston_compositor *compositor);
  
-static void weston_mode_switch_finish(struct weston_output *output,

- int mode_changed,
- int scale_changed)
+/** Send wl_output events for mode and scale changes
+ *
+ * \param head Send on all resources bound to this head.
+ * \param mode_changed If true, send the current mode.
+ * \param scale_changed If true, send the current scale.
+ */
+static void
+weston_mode_switch_send_events(struct weston_head *head,
+  bool mode_changed, bool scale_changed)
+{
+   struct weston_output *output = head->output;
+   struct wl_resource *resource;
+   int version;
+
+   wl_resource_for_each(resource, >resource_list) {
+   if (mode_changed) {
+   wl_output_send_mode(resource,
+   output->current_mode->flags,
+   output->current_mode->width,
+   output->current_mode->height,
+   output->current_mode->refresh);
+   }
+
+   version = wl_resource_get_version(resource);
+   if (version >= WL_OUTPUT_SCALE_SINCE_VERSION && scale_changed)
+   wl_output_send_scale(resource, output->current_scale);
+
+   if (version >= WL_OUTPUT_DONE_SINCE_VERSION)
+   wl_output_send_done(resource);
+   }
+}
+
+static void
+weston_mode_switch_finish(struct weston_output *output,
+ int mode_changed, int scale_changed)
  {
struct weston_seat *seat;
struct weston_head *head;
-   struct wl_resource *resource;
pixman_region32_t old_output_region;
-   int version;
  
  	pixman_region32_init(_output_region);

pixman_region32_copy(_output_region, >region);
@@ -133,22 +163,7 @@ static void weston_mode_switch_finish(struct weston_output 
*output,
head = >head;
  
  	/* notify clients of the changes */

-   wl_resource_for_each(resource, >resource_list) {
-   if (mode_changed) {
-   wl_output_send_mode(resource,
-   output->current_mode->flags,
-   output->current_mode->width,
-   output->current_mode->height,
-   output->current_mode->refresh);
-   }
-
-   version = wl_resource_get_version(resource);
-   if (version >= WL_OUTPUT_SCALE_SINCE_VERSION && scale_changed)
-   wl_output_send_scale(resource, output->current_scale);
-
-   if (version >= WL_OUTPUT_DONE_SINCE_VERSION)
-   wl_output_send_done(resource);
-   }
+   weston_mode_switch_send_events(head, mode_changed, scale_changed);
  }
  
  




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston v3 08/36] libweston: strdup head make, model, serial_number

2017-10-31 Thread Quentin Glidic

On 10/31/17 12:48 PM, Pekka Paalanen wrote:

From: Pekka Paalanen <pekka.paala...@collabora.co.uk>

Duplicate these strings to decouple their lifetime from whatever the
backends used. This should prevent hard to catch use after frees and
such problems in the future.

Signed-off-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>


Straightforward:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

As a nitpick, maybe we could add xstrdup or safe_strdup to handle the 
NULL case?


Thanks,



---
  libweston/compositor.c | 14 +++---
  1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/libweston/compositor.c b/libweston/compositor.c
index 1cc5050a..de667cfa 100644
--- a/libweston/compositor.c
+++ b/libweston/compositor.c
@@ -4479,6 +4479,10 @@ static void
  weston_head_release(struct weston_head *head)
  {
weston_head_detach(head);
+
+   free(head->make);
+   free(head->model);
+   free(head->serial_number);
  }
  
  /** Store monitor make, model and serial number

@@ -4500,9 +4504,13 @@ weston_head_set_monitor_strings(struct weston_head *head,
const char *model,
const char *serialno)
  {
-   head->make = (char *)make;
-   head->model = (char *)model;
-   head->serial_number = (char *)serialno;
+   free(head->make);
+   free(head->model);
+   free(head->serial_number);
+
+   head->make = make ? strdup(make) : NULL;
+   head->model = model ? strdup(model) : NULL;
+   head->serial_number = serialno ? strdup(serialno) : NULL;
  }
  
  /** Store physical image size





--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston v3 01/36] weston: arm SEGV handler earlier

2017-10-31 Thread Quentin Glidic

On 10/31/17 12:48 PM, Pekka Paalanen wrote:

From: Pekka Paalanen <pekka.paala...@collabora.co.uk>

It is useful to print the backtrace regardless of whether we have a
compositor and a backend initialized yet. Move catch_signals() to the
earliest point in main() and protect the SEGV handler from dereferencing
NULL when we don't yet have a compositor or a backend.

The SEGV handler uses weston_log(), so cannot move catch_signals() any
earlier.

Signed-off-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>


Sounds good:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

Thanks,



---
  compositor/main.c | 9 +
  1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index 9e4451e5..9f00ee3a 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -656,7 +656,8 @@ on_caught_signal(int s, siginfo_t *siginfo, void *context)
  
  	print_backtrace();
  
-	segv_compositor->backend->restore(segv_compositor);

+   if (segv_compositor && segv_compositor->backend)
+   segv_compositor->backend->restore(segv_compositor);
  
  	raise(SIGTRAP);

  }
@@ -1824,6 +1825,8 @@ int main(int argc, char *argv[])
weston_log_set_handler(vlog, vlog_continue);
weston_log_file_open(log);
  
+	catch_signals();

+
weston_log("%s\n"
   STAMP_SPACE "%s\n"
   STAMP_SPACE "Bug reports to: %s\n"
@@ -1872,6 +1875,7 @@ int main(int argc, char *argv[])
weston_log("fatal: failed to create compositor\n");
goto out;
}
+   segv_compositor = ec;
  
  	if (weston_compositor_init_config(ec, config) < 0)

goto out;
@@ -1887,9 +1891,6 @@ int main(int argc, char *argv[])
  
  	weston_pending_output_coldplug(ec);
  
-	catch_signals();

-   segv_compositor = ec;
-
if (idle_time < 0)
weston_config_section_get_int(section, "idle-time", _time, 
-1);
if (idle_time < 0)




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 00/10] wayland-backend fixes

2017-10-24 Thread Quentin Glidic

On 10/24/17 12:15 PM, Pekka Paalanen wrote:

From: Pekka Paalanen <pekka.paala...@collabora.co.uk>

Hi,

as part of my clone mode work[1] I obviously should test that I don't regress
the backends. The Wayland backend made regression testing hard by being already
broken in many ways. Here is a series to fix the issues I found. The series can
also be found at:

https://gitlab.collabora.com/pq/weston/commits/wayland-fixes-v1

The Wayland-backend testing I did for this series was with a weston.ini that
made the two parent outputs of different height. The parent compositor was
using the x11 backend.

Wayland-backend testing:

parent: $ weston --output-count=2 --width=700

tests:

weston --use-pixman
weston --use-pixman --fullscreen
weston --use-pixman --output-count=2
weston --use-pixman --sprawl
- close parent outputs one by one

parent: $ weston --output-count=2 --width=700 --shell=fullscreen-shell.so

tests:

weston --use-pixman
- close parent outputs one by one

All the above work fine after the fixes. The hotkey to switch between windowed
and fullscreen (ctrl+alt+f) causes the switch from windowed to fullscreen to
make the parent xdg-shell unhappy, I did not look into that.

Thanks to Armin for providing the fix to the black secondary window issue.


Thanks,
pq

[1] https://phabricator.freedesktop.org/T7727


Armin Krezović (1):
   compositor-wayland: fix damage coordinates with pixman renderer

Pekka Paalanen (9):
   weston: fix boolean wayland backend options
   compositor-wayland: avoid recursive dispatch with wl_outputs
   compositor-wayland: remove unused 'scale'
   compositor-wayland: fix mode_list corruption on --sprawl
   compositor-wayland: actually free parent_output
   compositor-wayland: allow to unset fullscreen
   compositor-wayland: windowed/fullscreen not on fullscreen-shell
   compositor-wayland: clarify wl_display_connect() error
   compositor-wayland: fix shm_buffer damage init

  compositor/main.c  | 15 +---
  libweston/compositor-wayland.c | 84 ++
  2 files changed, 70 insertions(+), 29 deletions(-)



Great work!

The whole series is:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

Thanks,

--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston v4 1/9] protocol: add weston-debug.xml

2017-10-23 Thread Quentin Glidic

On 10/23/17 8:55 AM, Pekka Paalanen wrote:

Hi,

I'm CC'ing Quentin for the automake comments below.


On Thu, 12 Oct 2017 13:13:41 +0200
Emre Ucan  wrote:


From: Pekka Paalanen 

This is a new debugging extension for non-production environments. The
aim is to replace all build-time choosable debug prints in the
compositor with runtime subscribable debug streams.

Signed-off-by: Pekka Paalanen 

Added new libweston-$MAJOR-protocols.pc file and install that
for external projects to find the XML files installed by libweston.

Signed-off-by: Maniraj Devadoss 
---
  Makefile.am |   8 +++
  configure.ac|   1 +
  libweston/libweston-protocols.pc.in |   7 ++
  protocol/weston-debug.xml   | 128 
  4 files changed, 144 insertions(+)
  create mode 100644 libweston/libweston-protocols.pc.in
  create mode 100644 protocol/weston-debug.xml

diff --git a/Makefile.am b/Makefile.am
index 1d3eedb..026cc58 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -116,6 +116,10 @@ libweston_@LIBWESTON_MAJOR@_la_SOURCES =   
\
shared/platform.h   \
shared/weston-egl-ext.h
  
+libweston_@LIBWESTON_MAJOR@_datadir = $(datadir)/weston/protocols

+dist_libweston_@LIBWESTON_MAJOR@_data_DATA =   \
+   protocol/weston-debug.xml
+


wayland-protocols uses nobase_dist_pkgdata_DATA for this, is there a
difference? What is the exact correct form?


nobase_ would put the file in $(datadir)/weston/protocols/protocol, 
wayland-protocols repo is mirroring the installation tree, here, nobase_ 
would be wrong.




  lib_LTLIBRARIES += libweston-desktop-@LIBWESTON_MAJOR@.la
  libweston_desktop_@LIBWESTON_MAJOR@_la_CPPFLAGS = $(AM_CPPFLAGS) -DIN_WESTON
  libweston_desktop_@LIBWESTON_MAJOR@_la_CFLAGS = $(AM_CFLAGS) 
$(COMPOSITOR_CFLAGS)
@@ -166,6 +170,8 @@ endif
  nodist_libweston_@LIBWESTON_MAJOR@_la_SOURCES =   
\
protocol/weston-screenshooter-protocol.c\
protocol/weston-screenshooter-server-protocol.h \
+   protocol/weston-debug-protocol.c\
+   protocol/weston-debug-server-protocol.h \
protocol/text-cursor-position-protocol.c\
protocol/text-cursor-position-server-protocol.h \
protocol/text-input-unstable-v1-protocol.c  \
@@ -283,6 +289,7 @@ endif # BUILD_WESTON_LAUNCH
  pkgconfigdir = $(libdir)/pkgconfig
  pkgconfig_DATA = \
libweston/libweston-${LIBWESTON_MAJOR}.pc \
+   libweston/libweston-${LIBWESTON_MAJOR}-protocols.pc \


Should the protocol.pc not go into noarch?
wayland-protocols does noarch_pkgconfig_DATA = wayland-protocols.pc.


Oh, yes it should. Using PKG_NOARCH_INSTALLDIR would be nice too (but we 
don’t use PKG_INSTALLDIR, and Meson doesn’t have equivalents so may not 
be worth it).




libweston-desktop/libweston-desktop-${LIBWESTON_MAJOR}.pc \
compositor/weston.pc
  
@@ -1528,6 +1535,7 @@ BUILT_SOURCES +=\

protocol/text-input-unstable-v1-client-protocol.h
  
  EXTRA_DIST +=	\

+   protocol/weston-debug.xml   \
protocol/weston-desktop-shell.xml   \
protocol/weston-screenshooter.xml   \
protocol/text-cursor-position.xml   \
diff --git a/configure.ac b/configure.ac
index 21e3a41..e514944 100644
--- a/configure.ac
+++ b/configure.ac
@@ -687,6 +687,7 @@ AC_CONFIG_FILES([Makefile libweston/version.h 
compositor/weston.pc])
  # AC_CONFIG_FILES needs the full name when running autoconf, so we need to use
  # libweston_abi_version here, and outside [] because of m4 quoting rules
  
AC_CONFIG_FILES([libweston/libweston-]libweston_major_version[.pc:libweston/libweston.pc.in])
+AC_CONFIG_FILES([libweston/libweston-]libweston_major_version[-protocols.pc:libweston/libweston-protocols.pc.in])
  
AC_CONFIG_FILES([libweston-desktop/libweston-desktop-]libweston_major_version[.pc:libweston-desktop/libweston-desktop.pc.in])
  
  AM_CONDITIONAL([HAVE_GIT_REPO], [test -f $srcdir/.git/logs/HEAD])

diff --git a/libweston/libweston-protocols.pc.in 
b/libweston/libweston-protocols.pc.in
new file mode 100644
index 000..46fd586
--- /dev/null
+++ b/libweston/libweston-protocols.pc.in
@@ -0,0 +1,7 @@
+prefix=@prefix@
+datarootdir=@datarootdir@
+pkgdatadir=@datadir@/@PACKAGE@/protocols


In wayland-protocols we have

pkgdatadir=${pc_sysrootdir}@datadir@/@PACKAGE@

so I think this here should be

pkgdatadir=${pc_sysrootdir}@datadir@/@PACKAGE@/protocols


I still think we should just drop it in prefix, as pkg-config will strip 
it when necessary, but hey. :-)




+
+Name: libWeston Protocols
+Description: libWeston protocol files
+Version: @WESTON_VERSION@
diff --git a/protocol/weston-debug.xml b/protocol/weston-debug.xml
new file mode 

[PATCH wayland] cursor: Use shm_open() instead of XDG_RUNTIME_DIR files

2017-10-18 Thread Quentin Glidic
From: Quentin Glidic <sardemff7+...@sardemff7.net>

Using XDG_RUNTIME_DIR to create anonymous files is problematic when
XDG_RUNTIME_DIR is not a tmpfs. OTOH, shm_open is in POSIX.1-2001, so it
should be available on all platforms we care about.
As a bonus, the created fd is already CLOEXEC.

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
 configure.ac  |  2 +-
 cursor/os-compatibility.c | 68 +++
 2 files changed, 5 insertions(+), 65 deletions(-)

diff --git a/configure.ac b/configure.ac
index fcb9718..71ed420 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,7 +61,7 @@ if test "x$GCC" = "xyes"; then
 fi
 AC_SUBST(GCC_CFLAGS)
 
-AC_CHECK_FUNCS([accept4 mkostemp posix_fallocate])
+AC_CHECK_FUNCS([accept4 posix_fallocate])
 
 AC_ARG_ENABLE([libraries],
  [AC_HELP_STRING([--disable-libraries],
diff --git a/cursor/os-compatibility.c b/cursor/os-compatibility.c
index e972d21..69aeab9 100644
--- a/cursor/os-compatibility.c
+++ b/cursor/os-compatibility.c
@@ -26,6 +26,7 @@
 #define _GNU_SOURCE
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -35,60 +36,13 @@
 #include "config.h"
 #include "os-compatibility.h"
 
-#ifndef HAVE_MKOSTEMP
-static int
-set_cloexec_or_close(int fd)
-{
-   long flags;
-
-   if (fd == -1)
-   return -1;
-
-   flags = fcntl(fd, F_GETFD);
-   if (flags == -1)
-   goto err;
-
-   if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1)
-   goto err;
-
-   return fd;
-
-err:
-   close(fd);
-   return -1;
-}
-#endif
-
-static int
-create_tmpfile_cloexec(char *tmpname)
-{
-   int fd;
-
-#ifdef HAVE_MKOSTEMP
-   fd = mkostemp(tmpname, O_CLOEXEC);
-   if (fd >= 0)
-   unlink(tmpname);
-#else
-   fd = mkstemp(tmpname);
-   if (fd >= 0) {
-   fd = set_cloexec_or_close(fd);
-   unlink(tmpname);
-   }
-#endif
-
-   return fd;
-}
-
 /*
  * Create a new, unique, anonymous file of the given size, and
  * return the file descriptor for it. The file descriptor is set
  * CLOEXEC. The file is immediately suitable for mmap()'ing
  * the given size at offset zero.
  *
- * The file should not have a permanent backing store like a disk,
- * but may have if XDG_RUNTIME_DIR is not properly implemented in OS.
- *
- * The file name is deleted from the file system.
+ * The file will not have a permanent backing store like a disk.
  *
  * The file is suitable for buffer sharing between processes by
  * transmitting the file descriptor over Unix sockets using the
@@ -109,22 +63,8 @@ os_create_anonymous_file(off_t size)
int fd;
int ret;
 
-   path = getenv("XDG_RUNTIME_DIR");
-   if (!path) {
-   errno = ENOENT;
-   return -1;
-   }
-
-   name = malloc(strlen(path) + sizeof(template));
-   if (!name)
-   return -1;
-
-   strcpy(name, path);
-   strcat(name, template);
-
-   fd = create_tmpfile_cloexec(name);
-
-   free(name);
+   fd = shm_open("/wayland-cursor-shared", O_CREAT | O_RDWR, 0);
+   shm_unlink("/wayland-cursor-shared");
 
if (fd < 0)
return -1;
-- 
2.13.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston v2] libweston-desktop/xdg-shell-v6: Actually send same-as-current configure if needed

2017-10-18 Thread Quentin Glidic

On 10/18/17 11:01 AM, Jonas Ådahl wrote:

On Wed, Oct 18, 2017 at 10:58:44AM +0200, Quentin Glidic wrote:

From: Quentin Glidic <sardemff7+...@sardemff7.net>

If a surface is in state A, and we just sent a configure for state B,
setting back state A would be ignored, because state B has not been
committed yet.
Now, we check against the latest configured state (which is current
state if configure list is empty).

Reported on wlroots https://github.com/swaywm/wlroots/pull/280

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>


Reviewed-by: Jonas Ådahl <jad...@gmail.com>


Thanks, and pushed:
71ebc0525..efade28db  master -> master

Cheers,



---
v2: Actually check against latest configure, as Jonas suggested


  libweston-desktop/xdg-shell-v6.c | 31 +--
  1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c
index d82a507fa..4db3748b7 100644
--- a/libweston-desktop/xdg-shell-v6.c
+++ b/libweston-desktop/xdg-shell-v6.c
@@ -903,20 +903,39 @@ weston_desktop_xdg_surface_send_configure(void *user_data)
  static bool
  weston_desktop_xdg_toplevel_state_compare(struct weston_desktop_xdg_toplevel 
*toplevel)
  {
+   struct {
+   struct weston_desktop_xdg_toplevel_state state;
+   struct weston_size size;
+   } configured;
+
if (!toplevel->base.configured)
return false;
  
-	if (toplevel->pending.state.activated != toplevel->current.state.activated)

+   if (wl_list_empty(>base.configure_list)) {
+   /* Last configure is actually the current state, just use it */
+   configured.state = toplevel->current.state;
+   configured.size.width = toplevel->base.surface->width;
+   configured.size.height = toplevel->base.surface->height;
+   } else {
+   struct weston_desktop_xdg_toplevel_configure *configure =
+   wl_container_of(toplevel->base.configure_list.prev,
+   configure, base.link);
+
+   configured.state = configure->state;
+   configured.size = configure->size;
+   }
+
+   if (toplevel->pending.state.activated != configured.state.activated)
return false;
-   if (toplevel->pending.state.fullscreen != 
toplevel->current.state.fullscreen)
+   if (toplevel->pending.state.fullscreen != configured.state.fullscreen)
return false;
-   if (toplevel->pending.state.maximized != 
toplevel->current.state.maximized)
+   if (toplevel->pending.state.maximized != configured.state.maximized)
return false;
-   if (toplevel->pending.state.resizing != 
toplevel->current.state.resizing)
+   if (toplevel->pending.state.resizing != configured.state.resizing)
return false;
  
-	if (toplevel->base.surface->width == toplevel->pending.size.width &&

-   toplevel->base.surface->height == toplevel->pending.size.height)
+   if (toplevel->pending.size.width == configured.size.width &&
+   toplevel->pending.size.height == configured.size.height)
return true;
  
  	if (toplevel->pending.size.width == 0 &&

--
2.13.4


___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v2] libweston-desktop/xdg-shell-v6: Actually send same-as-current configure if needed

2017-10-18 Thread Quentin Glidic
From: Quentin Glidic <sardemff7+...@sardemff7.net>

If a surface is in state A, and we just sent a configure for state B,
setting back state A would be ignored, because state B has not been
committed yet.
Now, we check against the latest configured state (which is current
state if configure list is empty).

Reported on wlroots https://github.com/swaywm/wlroots/pull/280

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
v2: Actually check against latest configure, as Jonas suggested


 libweston-desktop/xdg-shell-v6.c | 31 +--
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c
index d82a507fa..4db3748b7 100644
--- a/libweston-desktop/xdg-shell-v6.c
+++ b/libweston-desktop/xdg-shell-v6.c
@@ -903,20 +903,39 @@ weston_desktop_xdg_surface_send_configure(void *user_data)
 static bool
 weston_desktop_xdg_toplevel_state_compare(struct weston_desktop_xdg_toplevel 
*toplevel)
 {
+   struct {
+   struct weston_desktop_xdg_toplevel_state state;
+   struct weston_size size;
+   } configured;
+
if (!toplevel->base.configured)
return false;
 
-   if (toplevel->pending.state.activated != 
toplevel->current.state.activated)
+   if (wl_list_empty(>base.configure_list)) {
+   /* Last configure is actually the current state, just use it */
+   configured.state = toplevel->current.state;
+   configured.size.width = toplevel->base.surface->width;
+   configured.size.height = toplevel->base.surface->height;
+   } else {
+   struct weston_desktop_xdg_toplevel_configure *configure =
+   wl_container_of(toplevel->base.configure_list.prev,
+   configure, base.link);
+
+   configured.state = configure->state;
+   configured.size = configure->size;
+   }
+
+   if (toplevel->pending.state.activated != configured.state.activated)
return false;
-   if (toplevel->pending.state.fullscreen != 
toplevel->current.state.fullscreen)
+   if (toplevel->pending.state.fullscreen != configured.state.fullscreen)
return false;
-   if (toplevel->pending.state.maximized != 
toplevel->current.state.maximized)
+   if (toplevel->pending.state.maximized != configured.state.maximized)
return false;
-   if (toplevel->pending.state.resizing != 
toplevel->current.state.resizing)
+   if (toplevel->pending.state.resizing != configured.state.resizing)
return false;
 
-   if (toplevel->base.surface->width == toplevel->pending.size.width &&
-   toplevel->base.surface->height == toplevel->pending.size.height)
+   if (toplevel->pending.size.width == configured.size.width &&
+   toplevel->pending.size.height == configured.size.height)
return true;
 
if (toplevel->pending.size.width == 0 &&
-- 
2.13.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston] libweston-desktop/xdg-shell-v6: Actually send same-as-current configure if needed

2017-10-17 Thread Quentin Glidic
From: Quentin Glidic <sardemff7+...@sardemff7.net>

If a surface is in state A, and we just sent a configure for state B,
setting back state A would be ignored, because state B has not been
committed yet.
Since we only send a configure event if the state was different,
consider pending as different if the configure list is not empty.

Reported on wlroots https://github.com/swaywm/wlroots/pull/280

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
 libweston-desktop/xdg-shell-v6.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c
index d82a507fa..2abd02a3e 100644
--- a/libweston-desktop/xdg-shell-v6.c
+++ b/libweston-desktop/xdg-shell-v6.c
@@ -906,6 +906,9 @@ weston_desktop_xdg_toplevel_state_compare(struct 
weston_desktop_xdg_toplevel *to
if (!toplevel->base.configured)
return false;
 
+   if (!wl_list_empty(>base.configure_list))
+   return false;
+
if (toplevel->pending.state.activated != 
toplevel->current.state.activated)
return false;
if (toplevel->pending.state.fullscreen != 
toplevel->current.state.fullscreen)
-- 
2.13.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 8/14] ivi-shell: added libweston-desktop-api implementation

2017-10-17 Thread Quentin Glidic

Hi,

I will limit my review to the libweston-desktop usage, as it’s the only 
part I know.



On 10/17/17 11:59 AM, Michael Teyfel wrote:

Signed-off-by: Michael Teyfel 
---
  ivi-shell/ivi-shell.c | 172 ++
  1 file changed, 172 insertions(+)

diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c
index 84db2c9..049aa43 100644
--- a/ivi-shell/ivi-shell.c
+++ b/ivi-shell/ivi-shell.c
@@ -490,6 +490,178 @@ shell_add_bindings(struct weston_compositor *compositor,
  }
  
  /*

+ * libweston-desktop
+ */
+
+static void
+desktop_surface_ping_timeout(struct weston_desktop_client *client,
+void *user_data)
+{
+   weston_log("ivi-shell: desktop_surface_ping_timeout is not 
supported\n");


You can just let these functions to NULL, if you want, as only 
surface_added and surface_removed are mandatory.




+}
+
+static void
+desktop_surface_pong(struct weston_desktop_client *client,
+void *user_data)
+{
+   weston_log("ivi-shell: desktop_surface_pong is not supported\n");
+}
+
+static void
+desktop_surface_added(struct weston_desktop_surface *surface,
+ void *user_data)
+{
+   struct ivi_shell *shell = (struct ivi_shell *) user_data;
+   struct ivi_layout_surface *layout_surface;
+   struct ivi_shell_surface *ivisurf;
+   struct weston_surface *weston_surf =
+   weston_desktop_surface_get_surface(surface);
+
+   layout_surface = ivi_layout_desktop_surface_create(weston_surf,
+  IVI_INVALID_ID);
+   if (!layout_surface) {
+   return;
+   }
+
+   layout_surface->weston_desktop_surface = surface;
+
+   ivisurf = zalloc(sizeof *ivisurf);
+   if (!ivisurf) {
+   return;
+   }
+
+   wl_list_init(>link);
+   wl_list_insert(>ivi_surface_list, >link);
+
+   ivisurf->shell = shell;
+   ivisurf->id_surface = IVI_INVALID_ID;
+
+   ivisurf->width = 0;
+   ivisurf->height = 0;
+   ivisurf->layout_surface = layout_surface;
+   ivisurf->surface = weston_surf;


Here, you have a big issue. libweston-desktop handles popups internally, 
but to do that, it needs to know when you create a view for a toplevel 
surface. This is done via weston_desktop_surface_create_view(), which 
you never call (I traced the full call stack to ivi_view_create()).
One solution is to change ivi_view_create() to check for 
weston_surface_is_desktop_surface(), and calling 
weston_desktop_surface_create_view() instead of weston_view_create() in 
this case.




+}
+
+static void
+desktop_surface_removed(struct weston_desktop_surface *surface,
+   void *user_data)
+{
+   struct ivi_shell *shell = (struct ivi_shell *) user_data;
+   struct ivi_shell_surface *ivisurf = NULL;
+
+   wl_list_for_each(ivisurf, >ivi_surface_list, link) {
+   if(ivisurf->layout_surface->weston_desktop_surface == surface)


This loop (and the same in committed) are not needed. Just use 
weston_desktop_surface_set_user_data(surface, ivisurf); in surface_added 
and use get_user_data() in other callbacks. you can check for NULL since 
you have 1 code path that may let it NULL, but otherwise, surface_added 
is guaranteed to be call before any other callback.



Thanks,



+   {
+   assert(ivisurf != NULL);
+
+   if (ivisurf->layout_surface)
+   layout_surface_cleanup(ivisurf);
+
+   break;
+   }
+   }
+}
+
+static void
+desktop_surface_committed(struct weston_desktop_surface *surface,
+ int32_t sx, int32_t sy, void *user_data)
+{
+   struct ivi_shell_surface *ivisurf = NULL;
+   struct ivi_shell *shell = user_data;
+   struct weston_surface *weston_surf =
+   weston_desktop_surface_get_surface(surface);
+   int found = 0;
+
+   wl_list_for_each(ivisurf, >ivi_surface_list, link) {
+   if (ivisurf->surface == weston_surf) {
+   found = 1;
+   break;
+   }
+   }
+
+   if(!found)
+   return;
+
+   if (weston_surf->width == 0 || weston_surf->height == 0)
+   return;
+
+   if (ivisurf->width != weston_surf->width ||
+   ivisurf->height != weston_surf->height) {
+   ivisurf->width  = weston_surf->width;
+   ivisurf->height = weston_surf->height;
+
+   ivi_layout_desktop_surface_configure(ivisurf->layout_surface,
+weston_surf->width,
+weston_surf->height);
+   }
+}
+
+static void
+desktop_surface_move(struct weston_desktop_surface *surface,
+struct weston_seat *seat, uint32_t serial, void 

Re: [PATCH wayland v2 6/8] build: wire-up wayland-egl

2017-10-10 Thread Quentin Glidic

On 10/10/17 5:21 PM, Emil Velikov wrote:

On 10 October 2017 at 15:19, Quentin Glidic
<sardemff7+wayl...@sardemff7.net> wrote:

On 10/10/17 3:43 PM, Emil Velikov wrote:


From: Emil Velikov <emil.veli...@collabora.com>

Wire-up the imported sources, test and pkg-config files.

v2:
   - Don't mangle with existing EXTRA_DIST list
   - Add the symbols check script to the `make check' target
   - Rename wayland-egl-{priv,backend}.h

Signed-off-by: Emil Velikov <emil.veli...@collabora.com>
---
   Makefile.am  | 22 --
   configure.ac |  2 ++
   2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 0eedb10..eba9e81 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -118,6 +118,7 @@ BUILT_SOURCES = \
 CLEANFILES = $(BUILT_SOURCES) doc/doxygen/doxygen_sqlite3.db
   DISTCLEANFILES = src/wayland-version.h
+EXTRA_DIST =
   @@ -142,6 +143,16 @@ libwayland_cursor_la_CFLAGS =
\
 -I$(top_srcdir)/src \
 -DICONDIR=\"$(ICONDIR)\"
   +lib_LTLIBRARIES += libwayland-egl.la
+
+libwayland_egl_la_SOURCES = egl/wayland-egl.c
+libwayland_egl_la_LDFLAGS = -version-info 1
+
+pkgconfig_DATA += egl/wayland-egl.pc
+
+## XXX: backend interface
+include_HEADERS += egl/wayland-egl-backend.h
+pkgconfig_DATA += egl/wayland-egl-backend.pc
 built_test_programs =   \
 array-test  \
@@ -163,7 +174,13 @@ built_test_programs =  \
 message-test\
 headers-test\
 compositor-introspection-test   \
-   protocol-logger-test
+   protocol-logger-test\
+   wayland-egl-abi-check
+
+EXTRA_DIST += egl/wayland-egl-symbols-check



Nit: dist_check_SCRIPTS


Existing code uses EXTRA_DIST. Can we update everything as a follow-up?


A follow-up to fix existing uses would be nice, but not introducing more 
stuff to fix is good too :-)


In this regard, you can even put "dist_check_SCRIPTS =" in your patch 
(to avoid moving the initial declaration around like you had to do with 
EXTRA_DIST).


--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH wayland v2 6/8] build: wire-up wayland-egl

2017-10-10 Thread Quentin Glidic

On 10/10/17 3:43 PM, Emil Velikov wrote:

From: Emil Velikov 

Wire-up the imported sources, test and pkg-config files.

v2:
  - Don't mangle with existing EXTRA_DIST list
  - Add the symbols check script to the `make check' target
  - Rename wayland-egl-{priv,backend}.h

Signed-off-by: Emil Velikov 
---
  Makefile.am  | 22 --
  configure.ac |  2 ++
  2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 0eedb10..eba9e81 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -118,6 +118,7 @@ BUILT_SOURCES = \
  
  CLEANFILES = $(BUILT_SOURCES) doc/doxygen/doxygen_sqlite3.db

  DISTCLEANFILES = src/wayland-version.h
+EXTRA_DIST =
  
  
  
@@ -142,6 +143,16 @@ libwayland_cursor_la_CFLAGS =			\

-I$(top_srcdir)/src \
-DICONDIR=\"$(ICONDIR)\"
  
+lib_LTLIBRARIES += libwayland-egl.la

+
+libwayland_egl_la_SOURCES = egl/wayland-egl.c
+libwayland_egl_la_LDFLAGS = -version-info 1
+
+pkgconfig_DATA += egl/wayland-egl.pc
+
+## XXX: backend interface
+include_HEADERS += egl/wayland-egl-backend.h
+pkgconfig_DATA += egl/wayland-egl-backend.pc
  
  built_test_programs =\

array-test  \
@@ -163,7 +174,13 @@ built_test_programs =  \
message-test\
headers-test\
compositor-introspection-test   \
-   protocol-logger-test
+   protocol-logger-test\
+   wayland-egl-abi-check
+
+EXTRA_DIST += egl/wayland-egl-symbols-check


Nit: dist_check_SCRIPTS


+
+check_PROGRAMS = wayland-egl-abi-check
+wayland_egl_abi_check_SOURCES = egl/wayland-egl-abi-check.c
  
  if ENABLE_CPP_TEST

  built_test_programs += cpp-compile-test
@@ -177,6 +194,7 @@ AM_TESTS_ENVIRONMENT =  
\
;
  
  TESTS = $(built_test_programs)			\

+   egl/wayland-egl-symbols-check   \
tests/scanner-test.sh
  
  noinst_PROGRAMS =\

@@ -258,7 +276,7 @@ os_wrappers_test_LDADD = libtest-runner.la
  exec_fd_leak_checker_SOURCES = tests/exec-fd-leak-checker.c
  exec_fd_leak_checker_LDADD = libtest-runner.la
  
-EXTRA_DIST = tests/scanner-test.sh			\

+EXTRA_DIST += tests/scanner-test.sh\
tests/data/example.xml  \
tests/data/example-client.h \
tests/data/example-server.h \
diff --git a/configure.ac b/configure.ac
index fcb9718..2542243 100644
--- a/configure.ac
+++ b/configure.ac
@@ -193,6 +193,8 @@ AC_CONFIG_FILES([Makefile
 doc/publican/Makefile
 doc/doxygen/Makefile
 doc/man/Makefile
+egl/wayland-egl.pc
+egl/wayland-egl-backend.pc
 src/wayland-server-uninstalled.pc
 src/wayland-client-uninstalled.pc
 src/wayland-scanner-uninstalled.pc




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston] libweston-desktop/xdg-shell-v6: Ensure first configure is sent

2017-08-28 Thread Quentin Glidic
From: Quentin Glidic <sardemff7+...@sardemff7.net>

The old code for scheduling configure events on idle looked like:
if (configure_scheduled) {
if (this_event_is_the_same) {
remove_timer();
return;
}
}

If we queued one new event (either changed, or the client had never
received any configure event), followed immediately by one event which
was the same as the first, we would delete the scheduled send of the
first event.

Fix this by treating unconfigured surface as never the same.

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
 libweston-desktop/xdg-shell-v6.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c
index 10274e07d..d82a507fa 100644
--- a/libweston-desktop/xdg-shell-v6.c
+++ b/libweston-desktop/xdg-shell-v6.c
@@ -303,8 +303,7 @@ static const struct zxdg_positioner_v6_interface 
weston_desktop_xdg_positioner_i
 };
 
 static void
-weston_desktop_xdg_surface_schedule_configure(struct 
weston_desktop_xdg_surface *surface,
- bool force);
+weston_desktop_xdg_surface_schedule_configure(struct 
weston_desktop_xdg_surface *surface);
 
 static void
 weston_desktop_xdg_toplevel_ensure_added(struct weston_desktop_xdg_toplevel 
*toplevel)
@@ -314,7 +313,7 @@ weston_desktop_xdg_toplevel_ensure_added(struct 
weston_desktop_xdg_toplevel *top
 
weston_desktop_api_surface_added(toplevel->base.desktop,
 toplevel->base.desktop_surface);
-   weston_desktop_xdg_surface_schedule_configure(>base, true);
+   weston_desktop_xdg_surface_schedule_configure(>base);
toplevel->added = true;
 }
 
@@ -584,7 +583,7 @@ weston_desktop_xdg_toplevel_set_maximized(struct 
weston_desktop_surface *dsurfac
struct weston_desktop_xdg_toplevel *toplevel = user_data;
 
toplevel->pending.state.maximized = maximized;
-   weston_desktop_xdg_surface_schedule_configure(>base, false);
+   weston_desktop_xdg_surface_schedule_configure(>base);
 }
 
 static void
@@ -594,7 +593,7 @@ weston_desktop_xdg_toplevel_set_fullscreen(struct 
weston_desktop_surface *dsurfa
struct weston_desktop_xdg_toplevel *toplevel = user_data;
 
toplevel->pending.state.fullscreen = fullscreen;
-   weston_desktop_xdg_surface_schedule_configure(>base, false);
+   weston_desktop_xdg_surface_schedule_configure(>base);
 }
 
 static void
@@ -604,7 +603,7 @@ weston_desktop_xdg_toplevel_set_resizing(struct 
weston_desktop_surface *dsurface
struct weston_desktop_xdg_toplevel *toplevel = user_data;
 
toplevel->pending.state.resizing = resizing;
-   weston_desktop_xdg_surface_schedule_configure(>base, false);
+   weston_desktop_xdg_surface_schedule_configure(>base);
 }
 
 static void
@@ -614,7 +613,7 @@ weston_desktop_xdg_toplevel_set_activated(struct 
weston_desktop_surface *dsurfac
struct weston_desktop_xdg_toplevel *toplevel = user_data;
 
toplevel->pending.state.activated = activated;
-   weston_desktop_xdg_surface_schedule_configure(>base, false);
+   weston_desktop_xdg_surface_schedule_configure(>base);
 }
 
 static void
@@ -627,7 +626,7 @@ weston_desktop_xdg_toplevel_set_size(struct 
weston_desktop_surface *dsurface,
toplevel->pending.size.width = width;
toplevel->pending.size.height = height;
 
-   weston_desktop_xdg_surface_schedule_configure(>base, false);
+   weston_desktop_xdg_surface_schedule_configure(>base);
 }
 
 static void
@@ -807,7 +806,7 @@ static void
 weston_desktop_xdg_popup_committed(struct weston_desktop_xdg_popup *popup)
 {
if (!popup->committed)
-   weston_desktop_xdg_surface_schedule_configure(>base, 
true);
+   weston_desktop_xdg_surface_schedule_configure(>base);
popup->committed = true;
weston_desktop_xdg_popup_update_position(popup->base.desktop_surface,
 popup);
@@ -904,6 +903,9 @@ weston_desktop_xdg_surface_send_configure(void *user_data)
 static bool
 weston_desktop_xdg_toplevel_state_compare(struct weston_desktop_xdg_toplevel 
*toplevel)
 {
+   if (!toplevel->base.configured)
+   return false;
+
if (toplevel->pending.state.activated != 
toplevel->current.state.activated)
return false;
if (toplevel->pending.state.fullscreen != 
toplevel->current.state.fullscreen)
@@ -925,20 +927,18 @@ weston_desktop_xdg_toplevel_state_compare(struct 
weston_desktop_xdg_toplevel *to
 }
 
 static void
-weston_desktop_xdg_surface_schedule_configure(struct 
weston_desktop_xdg_surface *surface,
- bool force)
+weston_desktop_xdg_surface_schedule_configure(struct 
weston_desktop_xdg_surface *surface)
 {
   

Re: [PATCH wayland] scanner: Add autoconf macro to check for the proper scanner

2017-08-18 Thread Quentin Glidic

On 8/18/17 11:30 AM, Quentin Glidic wrote:

From: Quentin Glidic <sardemff7+...@sardemff7.net>

Projects have been using various ways to check for the wayland-scanner,
mostly based on their developper own use case, and often not allowing
others use cases to work without a workaround.

Hopefully this macro will support all use cases without needing user
action.

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---

Everyone should test this macro for their own project and use cases.
Using the ${WAYLAND_SCANNER} variable should just work (assuming you have the 
proper
wayland package built in the expected env). In very very rare cases, setting the
WAYLAND_SCANNER variable as a ./configure argument may be needed, but nothing 
else.

Please let me know with enough details if your use case is not working with it.


Forgot the CCs while sending the patch.



  wayland-scanner.m4 | 54 ++
  1 file changed, 54 insertions(+)

diff --git a/wayland-scanner.m4 b/wayland-scanner.m4
index 4e4222a..37e0548 100644
--- a/wayland-scanner.m4
+++ b/wayland-scanner.m4
@@ -1,3 +1,5 @@
+#serial 2
+
  AC_DEFUN([WAYLAND_SCANNER_RULES], [
  PKG_PROG_PKG_CONFIG
  
@@ -11,3 +13,55 @@ AC_DEFUN([WAYLAND_SCANNER_RULES], [
  
  AC_SUBST([wayland_protocoldir], [$1])

  ])
+
+
+AC_DEFUN([_WL_PROG_WAYLAND_SCANNER_VERSION_CHECK], [
+wl_cv_scanner_version=`${WAYLAND_SCANNER} --version 2>&1 | sed 
's/^wayland-scanner //'`
+AS_VERSION_COMPARE([${wl_cv_scanner_version}], 
[${wl_cv_scanner_wanted_version}], [], [
+wl_cv_scanner_found=yes
+], [])
+])
+
+# WL_PROG_WAYLAND_SCANNER()
+AC_DEFUN([WL_PROG_WAYLAND_SCANNER], [
+AC_REQUIRE([AC_CANONICAL_BUILD])
+AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+wl_cv_native_pkg_config=
+AS_IF([test x${cross_compiling} = xyes], [
+wl_cv_native_pkg_config=${build}-pkg-config
+AC_PATH_PROGS([wl_cv_native_pkg_config], [${build}-pkg-config])
+])
+AC_ARG_VAR([WAYLAND_SCANNER], [wayland-scanner executable])
+wl_cv_scanner_found=no
+wl_cv_scanner_wanted_version=`${PKG_CONFIG} --modversion wayland-server`
+AC_MSG_CHECKING([that wayland-client and wayland-server versions are the 
same])
+AS_IF([test ${wl_cv_scanner_wanted_version} = `${PKG_CONFIG} --modversion 
wayland-client`], [
+AC_MSG_RESULT([ok])
+], [
+AC_MSG_ERROR([mismatch])
+])
+AC_MSG_CHECKING([for wayland-scanner ${wl_cv_scanner_wanted_version}])
+AS_IF([test x${ac_cv_env_WAYLAND_SCANNER_set} = xset], [
+_WL_PROG_WAYLAND_SCANNER_VERSION_CHECK()
+])
+AS_IF([test x${cross_compiling} = xyes -a x${wl_cv_native_pkg_config} != 
xno], [
+AS_IF([AC_RUN_LOG([${wl_cv_native_pkg_config} --exists --print-errors 
wayland-scanner = ${wl_cv_scanner_wanted_version}])], [
+WAYLAND_SCANNER=`${wl_cv_native_pkg_config} 
--variable=wayland_scanner wayland-scanner = ${wl_cv_scanner_wanted_version}`
+_WL_PROG_WAYLAND_SCANNER_VERSION_CHECK()
+])
+])
+AS_IF([test x${wl_cv_scanner_found} = xno], [
+AS_IF([AC_RUN_LOG([${PKG_CONFIG} --exists --print-errors 
wayland-scanner = ${wl_cv_scanner_wanted_version}])], [
+WAYLAND_SCANNER=`${PKG_CONFIG} --variable=wayland_scanner 
wayland-scanner = ${wl_cv_scanner_wanted_version}`
+_WL_PROG_WAYLAND_SCANNER_VERSION_CHECK()
+])
+])
+AS_IF([test x${wl_cv_scanner_found} = xno], [
+AC_PATH_PROG([WAYLAND_SCANNER], [wayland-scanner])
+_WL_PROG_WAYLAND_SCANNER_VERSION_CHECK()
+])
+AS_IF([test x${wl_cv_scanner_found} = xno], [
+AC_MSG_ERROR([no usable wayland-scanner executable version 
${wl_cv_scanner_wanted_version}])
+])
+AC_MSG_RESULT([${WAYLAND_SCANNER}])
+])




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH wayland] scanner: Add autoconf macro to check for the proper scanner

2017-08-18 Thread Quentin Glidic
From: Quentin Glidic <sardemff7+...@sardemff7.net>

Projects have been using various ways to check for the wayland-scanner,
mostly based on their developper own use case, and often not allowing
others use cases to work without a workaround.

Hopefully this macro will support all use cases without needing user
action.

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---

Everyone should test this macro for their own project and use cases.
Using the ${WAYLAND_SCANNER} variable should just work (assuming you have the 
proper
wayland package built in the expected env). In very very rare cases, setting the
WAYLAND_SCANNER variable as a ./configure argument may be needed, but nothing 
else.

Please let me know with enough details if your use case is not working with it.

 wayland-scanner.m4 | 54 ++
 1 file changed, 54 insertions(+)

diff --git a/wayland-scanner.m4 b/wayland-scanner.m4
index 4e4222a..37e0548 100644
--- a/wayland-scanner.m4
+++ b/wayland-scanner.m4
@@ -1,3 +1,5 @@
+#serial 2
+
 AC_DEFUN([WAYLAND_SCANNER_RULES], [
 PKG_PROG_PKG_CONFIG
 
@@ -11,3 +13,55 @@ AC_DEFUN([WAYLAND_SCANNER_RULES], [
 
 AC_SUBST([wayland_protocoldir], [$1])
 ])
+
+
+AC_DEFUN([_WL_PROG_WAYLAND_SCANNER_VERSION_CHECK], [
+wl_cv_scanner_version=`${WAYLAND_SCANNER} --version 2>&1 | sed 
's/^wayland-scanner //'`
+AS_VERSION_COMPARE([${wl_cv_scanner_version}], 
[${wl_cv_scanner_wanted_version}], [], [
+wl_cv_scanner_found=yes
+], [])
+])
+
+# WL_PROG_WAYLAND_SCANNER()
+AC_DEFUN([WL_PROG_WAYLAND_SCANNER], [
+AC_REQUIRE([AC_CANONICAL_BUILD])
+AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+wl_cv_native_pkg_config=
+AS_IF([test x${cross_compiling} = xyes], [
+wl_cv_native_pkg_config=${build}-pkg-config
+AC_PATH_PROGS([wl_cv_native_pkg_config], [${build}-pkg-config])
+])
+AC_ARG_VAR([WAYLAND_SCANNER], [wayland-scanner executable])
+wl_cv_scanner_found=no
+wl_cv_scanner_wanted_version=`${PKG_CONFIG} --modversion wayland-server`
+AC_MSG_CHECKING([that wayland-client and wayland-server versions are the 
same])
+AS_IF([test ${wl_cv_scanner_wanted_version} = `${PKG_CONFIG} --modversion 
wayland-client`], [
+AC_MSG_RESULT([ok])
+], [
+AC_MSG_ERROR([mismatch])
+])
+AC_MSG_CHECKING([for wayland-scanner ${wl_cv_scanner_wanted_version}])
+AS_IF([test x${ac_cv_env_WAYLAND_SCANNER_set} = xset], [
+_WL_PROG_WAYLAND_SCANNER_VERSION_CHECK()
+])
+AS_IF([test x${cross_compiling} = xyes -a x${wl_cv_native_pkg_config} != 
xno], [
+AS_IF([AC_RUN_LOG([${wl_cv_native_pkg_config} --exists --print-errors 
wayland-scanner = ${wl_cv_scanner_wanted_version}])], [
+WAYLAND_SCANNER=`${wl_cv_native_pkg_config} 
--variable=wayland_scanner wayland-scanner = ${wl_cv_scanner_wanted_version}`
+_WL_PROG_WAYLAND_SCANNER_VERSION_CHECK()
+])
+])
+AS_IF([test x${wl_cv_scanner_found} = xno], [
+AS_IF([AC_RUN_LOG([${PKG_CONFIG} --exists --print-errors 
wayland-scanner = ${wl_cv_scanner_wanted_version}])], [
+WAYLAND_SCANNER=`${PKG_CONFIG} --variable=wayland_scanner 
wayland-scanner = ${wl_cv_scanner_wanted_version}`
+_WL_PROG_WAYLAND_SCANNER_VERSION_CHECK()
+])
+])
+AS_IF([test x${wl_cv_scanner_found} = xno], [
+AC_PATH_PROG([WAYLAND_SCANNER], [wayland-scanner])
+_WL_PROG_WAYLAND_SCANNER_VERSION_CHECK()
+])
+AS_IF([test x${wl_cv_scanner_found} = xno], [
+AC_MSG_ERROR([no usable wayland-scanner executable version 
${wl_cv_scanner_wanted_version}])
+])
+AC_MSG_RESULT([${WAYLAND_SCANNER}])
+])
-- 
2.13.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 4/4] libweston-desktop/xdg-shell-v5: initialize configure list

2017-08-11 Thread Quentin Glidic

On 8/5/17 4:38 PM, Quentin Glidic wrote:

Pushed this one as a critical bug fix (since we are in RC1):
18e77af6..3000a1c7  master -> master

I’ll let someone else push the others while in RC if they find them 
critical enough. Otherwise, I’ll push them after the release.

Release done, pushed the 3 others:
94e664d9..167bbb6d  master -> master

Thanks,

--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 4/4] libweston-desktop/xdg-shell-v5: initialize configure list

2017-08-05 Thread Quentin Glidic

On 8/5/17 1:59 PM, Arnaud Vrac wrote:

Without this weston crashes when a client using xdg-shell-v5 is run.

Signed-off-by: Arnaud Vrac 
---
  libweston-desktop/xdg-shell-v5.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/libweston-desktop/xdg-shell-v5.c b/libweston-desktop/xdg-shell-v5.c
index dd360862..ebe7940e 100644
--- a/libweston-desktop/xdg-shell-v5.c
+++ b/libweston-desktop/xdg-shell-v5.c
@@ -745,6 +745,8 @@ weston_desktop_xdg_shell_protocol_get_xdg_surface(struct 
wl_client *wl_client,
wl_event_loop_add_idle(loop,
   
weston_desktop_xdg_surface_add_idle_callback,
   surface);
+
+   wl_list_init(>configure_list);
  }
  
  static void




Pushed this one as a critical bug fix (since we are in RC1):
18e77af6..3000a1c7  master -> master

I’ll let someone else push the others while in RC if they find them 
critical enough. Otherwise, I’ll push them after the release.


Cheers,

--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 4/4] libweston-desktop/xdg-shell-v5: initialize configure list

2017-08-05 Thread Quentin Glidic

On 8/5/17 1:59 PM, Arnaud Vrac wrote:

Without this weston crashes when a client using xdg-shell-v5 is run.

Signed-off-by: Arnaud Vrac <raw...@gmail.com>


Oops. Good catch:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

Thanks,


---
  libweston-desktop/xdg-shell-v5.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/libweston-desktop/xdg-shell-v5.c b/libweston-desktop/xdg-shell-v5.c
index dd360862..ebe7940e 100644
--- a/libweston-desktop/xdg-shell-v5.c
+++ b/libweston-desktop/xdg-shell-v5.c
@@ -745,6 +745,8 @@ weston_desktop_xdg_shell_protocol_get_xdg_surface(struct 
wl_client *wl_client,
wl_event_loop_add_idle(loop,
   
weston_desktop_xdg_surface_add_idle_callback,
   surface);
+
+   wl_list_init(>configure_list);
  }
  
  static void





--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 3/4] configure.ac: remove dependency on mtdev

2017-08-05 Thread Quentin Glidic

On 8/5/17 1:59 PM, Arnaud Vrac wrote:

It's been unused since the legacy (non-libinput) input backends have
been removed.

Signed-off-by: Arnaud Vrac <raw...@gmail.com>


Sounds good:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

Thanks,


---
  configure.ac| 4 ++--
  libweston/libinput-device.c | 1 -
  2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 5179dfed..ba7b5cee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -199,7 +199,7 @@ AC_ARG_ENABLE(drm-compositor, [  --enable-drm-compositor],,
  AM_CONDITIONAL(ENABLE_DRM_COMPOSITOR, test x$enable_drm_compositor = xyes)
  if test x$enable_drm_compositor = xyes; then
AC_DEFINE([BUILD_DRM_COMPOSITOR], [1], [Build the DRM compositor])
-  PKG_CHECK_MODULES(DRM_COMPOSITOR, [libudev >= 136 libdrm >= 2.4.30 gbm mtdev 
>= 1.1.0])
+  PKG_CHECK_MODULES(DRM_COMPOSITOR, [libudev >= 136 libdrm >= 2.4.30 gbm])
PKG_CHECK_MODULES(DRM_COMPOSITOR_GBM, [gbm >= 10.2],
[AC_DEFINE([HAVE_GBM_FD_IMPORT], 1, [gbm supports dmabuf 
import])],
[AC_MSG_WARN([gbm does not support dmabuf import, will omit 
that capability])])
@@ -242,7 +242,7 @@ AM_CONDITIONAL([ENABLE_FBDEV_COMPOSITOR],
 [test x$enable_fbdev_compositor = xyes])
  AS_IF([test x$enable_fbdev_compositor = xyes], [
AC_DEFINE([BUILD_FBDEV_COMPOSITOR], [1], [Build the fbdev compositor])
-  PKG_CHECK_MODULES([FBDEV_COMPOSITOR], [libudev >= 136 mtdev >= 1.1.0])
+  PKG_CHECK_MODULES([FBDEV_COMPOSITOR], [libudev >= 136])
  ])
  
  AC_ARG_ENABLE([rdp-compositor], [  --enable-rdp-compositor],,

diff --git a/libweston/libinput-device.c b/libweston/libinput-device.c
index 5e7182da..b1d269db 100644
--- a/libweston/libinput-device.c
+++ b/libweston/libinput-device.c
@@ -33,7 +33,6 @@
  #include 
  #include 
  #include 
-#include 
  #include 
  #include 
  




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 1/4] gl-renderer: fix leak on dmabuf image destroy

2017-08-05 Thread Quentin Glidic

On 8/5/17 1:58 PM, Arnaud Vrac wrote:

Signed-off-by: Arnaud Vrac <raw...@gmail.com>
---
  libweston/gl-renderer.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index da29b072..5768f05a 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -337,6 +337,7 @@ dmabuf_image_destroy(struct dmabuf_image *image)
linux_dmabuf_buffer_set_user_data(image->dmabuf, NULL, NULL);
  
  	wl_list_remove(>link);

+   free(image);
  }
  
  static const char *




Good:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

Thanks,

--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 2/4] configure.ac: fix linking when using compiler sanitizers

2017-08-05 Thread Quentin Glidic

On 8/5/17 1:58 PM, Arnaud Vrac wrote:

The GCC address sanitizer overrides dlopen and dlclose, so the configure
test does not detect libdl as a needed dependency for linking. It is
still needed though, as dlsym is not exported by the sanitizer. The
result is that linking fails in the end.

Fix this by checking for dlsym instead of dlopen.

This can be reproduced by configuring the build with:
CFLAGS="-fsanitize=address -fsanitize=undefined"
LDFLAGS="-fsanitize=address -fsanitize=undefined"

Signed-off-by: Arnaud Vrac <raw...@gmail.com>


Well explained:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

Thanks,


---
  Makefile.am  | 4 ++--
  configure.ac | 3 ++-
  2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index e9679e68..58a5c596 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -74,7 +74,7 @@ libweston_@LIBWESTON_MAJOR@_la_CPPFLAGS = $(AM_CPPFLAGS) 
-DIN_WESTON
  libweston_@LIBWESTON_MAJOR@_la_CFLAGS = $(AM_CFLAGS) \
$(COMPOSITOR_CFLAGS) $(EGL_CFLAGS) $(LIBUNWIND_CFLAGS) $(LIBDRM_CFLAGS)
  libweston_@LIBWESTON_MAJOR@_la_LIBADD = $(COMPOSITOR_LIBS) $(LIBUNWIND_LIBS) \
-   $(DLOPEN_LIBS) -lm $(CLOCK_GETTIME_LIBS) \
+   $(DL_LIBS) -lm $(CLOCK_GETTIME_LIBS) \
$(LIBINPUT_BACKEND_LIBS) libshared.la
  libweston_@LIBWESTON_MAJOR@_la_LDFLAGS = -version-info $(LT_VERSION_INFO)
  
@@ -194,7 +194,7 @@ weston_CPPFLAGS = $(AM_CPPFLAGS) -DIN_WESTON 		\

  weston_CFLAGS = $(AM_CFLAGS) $(COMPOSITOR_CFLAGS) $(LIBUNWIND_CFLAGS)
  weston_LDADD = libshared.la libweston-@LIBWESTON_MAJOR@.la \
$(COMPOSITOR_LIBS) $(LIBUNWIND_LIBS) \
-   $(DLOPEN_LIBS) $(LIBINPUT_BACKEND_LIBS) \
+   $(DL_LIBS) $(LIBINPUT_BACKEND_LIBS) \
$(CLOCK_GETRES_LIBS) \
-lm
  
diff --git a/configure.ac b/configure.ac

index 61d7f37b..5179dfed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -86,7 +86,8 @@ AC_ARG_VAR([WESTON_SHELL_CLIENT],
  
  PKG_PROG_PKG_CONFIG()
  
-WESTON_SEARCH_LIBS([DLOPEN], [dl], [dlopen])

+# Check for dlsym instead of dlopen because ASAN hijacks the latter
+WESTON_SEARCH_LIBS([DL], [dl], [dlsym])
  
  # In old glibc versions (< 2.17) clock_gettime() and clock_getres() are in librt

  WESTON_SEARCH_LIBS([CLOCK_GETTIME], [rt], [clock_gettime])




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston] desktop-shell: Set surface resizing state during interactive resize

2017-07-28 Thread Quentin Glidic

On 7/28/17 2:11 PM, Philipp Kerling wrote:

xdg_shell requires this information to be shared with the client in
order to conform with the specification.

The code to forward this to the client by way of a configure() event
is already in place and works fine, it was just never being used until
now.

Signed-off-by: Philipp Kerling <pkerl...@casix.org>


I’ll take that as a bug fix, so let’s land it in beta.

Added a couple of variables to avoid the long lines breaks and:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

Then pushed:
e3715527..c5f12416  master -> master

Thanks!


---
  desktop-shell/shell.c | 5 +
  1 file changed, 5 insertions(+)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 4608cf2f..f0b76352 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -1638,6 +1638,8 @@ resize_grab_button(struct weston_pointer_grab *grab,
  
  	if (pointer->button_count == 0 &&

state == WL_POINTER_BUTTON_STATE_RELEASED) {
+   weston_desktop_surface_set_resizing(
+   resize->base.shsurf->desktop_surface, false);
shell_grab_end(>base);
free(grab);
}
@@ -1648,6 +1650,8 @@ resize_grab_cancel(struct weston_pointer_grab *grab)
  {
struct weston_resize_grab *resize = (struct weston_resize_grab *) grab;
  
+	weston_desktop_surface_set_resizing(resize->base.shsurf->desktop_surface,

+   false);
shell_grab_end(>base);
free(grab);
  }
@@ -1731,6 +1735,7 @@ surface_resize(struct shell_surface *shsurf,
resize->height = geometry.height;
  
  	shsurf->resize_edges = edges;

+   weston_desktop_surface_set_resizing(shsurf->desktop_surface, true);
shell_grab_start(>base, _grab_interface, shsurf,
 pointer, edges);
  
___

wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston] libweston-desktop: fix the size of unmaximized xdg surfaces

2017-07-27 Thread Quentin Glidic

On 7/27/17 3:01 PM, Giulio Camuffo wrote:

When unmaximizing a surface the configure event should send 0,0 as the
requested size, so that the client can use the size that it had before
maximizing


Hi,

I disagree on this patch for a few reasons:
- the size can be ignored in this case, so there is no harm in keeping 
it non-0

- it’s up to the shell/compositor to decide, not a protocol library
- I am working on a not-so-tiny rewrite of the state code, based on the 
size_requested patch, that will make it clear that the shell/compositor 
is in charge here


What do you think?

Cheers,



---
  libweston-desktop/xdg-shell-v6.c | 31 ++-
  1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c
index 1344dda0..3a02815f 100644
--- a/libweston-desktop/xdg-shell-v6.c
+++ b/libweston-desktop/xdg-shell-v6.c
@@ -578,11 +578,29 @@ weston_desktop_xdg_toplevel_send_configure(struct 
weston_desktop_xdg_toplevel *t
  };
  
  static void

+weston_desktop_xdg_toplevel_set_size(struct weston_desktop_surface *dsurface,
+void *user_data,
+int32_t width, int32_t height)
+{
+   struct weston_desktop_xdg_toplevel *toplevel = user_data;
+
+   toplevel->pending.size.width = width;
+   toplevel->pending.size.height = height;
+
+   weston_desktop_xdg_surface_schedule_configure(>base, false);
+}
+
+static void
  weston_desktop_xdg_toplevel_set_maximized(struct weston_desktop_surface 
*dsurface,
  void *user_data, bool maximized)
  {
struct weston_desktop_xdg_toplevel *toplevel = user_data;
  
+	/* if we're unmaximizing set the size to 0 so that when the configure event is sent

+  it will tell the client to use the size it wants */
+   if (toplevel->pending.state.maximized && !maximized)
+   weston_desktop_xdg_toplevel_set_size(dsurface, toplevel, 0, 0);
+
toplevel->pending.state.maximized = maximized;
weston_desktop_xdg_surface_schedule_configure(>base, false);
  }
@@ -618,19 +636,6 @@ weston_desktop_xdg_toplevel_set_activated(struct 
weston_desktop_surface *dsurfac
  }
  
  static void

-weston_desktop_xdg_toplevel_set_size(struct weston_desktop_surface *dsurface,
-void *user_data,
-int32_t width, int32_t height)
-{
-   struct weston_desktop_xdg_toplevel *toplevel = user_data;
-
-   toplevel->pending.size.width = width;
-   toplevel->pending.size.height = height;
-
-   weston_desktop_xdg_surface_schedule_configure(>base, false);
-}
-
-static void
  weston_desktop_xdg_toplevel_committed(struct weston_desktop_xdg_toplevel 
*toplevel,
  int32_t sx, int32_t sy)
  {




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH] libweston-desktop/xdg-shell: Check window geometry instead of surface size against configured size

2017-07-26 Thread Quentin Glidic

Nit:
You should do "git config format.subjectprefix 'PATCH weston'" to your 
repo, to keep patches linked to Weston.


On 7/26/17 2:02 PM, Philipp Kerling wrote:

Shell surfaces may have a geometry that is different to the size of
their main surface, e.g. due to subcompositing.

In states where size is strictly enforced (fullscreen and maximized),
the size that the compositor wants must be checked against the window
geometry and not just the main surface size.

Fix by calling weston_desktop_surface_get_geometry and using that size
instead of main surface size.

Signed-off-by: Philipp Kerling <pkerl...@casix.org>
---
  libweston-desktop/xdg-shell-v5.c | 7 +--
  libweston-desktop/xdg-shell-v6.c | 7 +--
  2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/libweston-desktop/xdg-shell-v5.c b/libweston-desktop/xdg-shell-v5.c
index d7c49b15..3f97cd23 100644
--- a/libweston-desktop/xdg-shell-v5.c
+++ b/libweston-desktop/xdg-shell-v5.c
@@ -264,9 +264,12 @@ weston_desktop_xdg_surface_committed(struct 
weston_desktop_surface *dsurface,
weston_desktop_surface_get_surface(surface->surface);
bool reconfigure = false;
  
+	struct weston_geometry geometry =

+   weston_desktop_surface_get_geometry(surface->surface);
+
if (surface->next.state.maximized || surface->next.state.fullscreen)
-   reconfigure = surface->next.size.width != wsurface->width ||
- surface->next.size.height != wsurface->height;
+   reconfigure = surface->next.size.width != geometry.width ||
+ surface->next.size.height != geometry.height;
  


Actually, there is more to do on this part, and we /might/ ditch v5 
support on the next cycle, so I’ll replace this hunk with a TODO comment 
and push it.




if (reconfigure) {
weston_desktop_xdg_surface_schedule_configure(surface, true);
diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c
index dda0bf92..1344dda0 100644
--- a/libweston-desktop/xdg-shell-v6.c
+++ b/libweston-desktop/xdg-shell-v6.c
@@ -644,9 +644,12 @@ weston_desktop_xdg_toplevel_committed(struct 
weston_desktop_xdg_toplevel *toplev
if (!wsurface->buffer_ref.buffer)
return;
  
+	struct weston_geometry geometry =

+   
weston_desktop_surface_get_geometry(toplevel->base.desktop_surface);
+
if ((toplevel->next.state.maximized || toplevel->next.state.fullscreen) 
&&
-   (toplevel->next.size.width != wsurface->width ||
-toplevel->next.size.height != wsurface->height)) {
+   (toplevel->next.size.width != geometry.width ||
+toplevel->next.size.height != geometry.height)) {
struct weston_desktop_client *client =

weston_desktop_surface_get_client(toplevel->base.desktop_surface);
struct wl_resource *client_resource =


So:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

And pushed:
ba8a0d04..c623902e  master -> master

Thanks,


--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH] desktop-shell: Track focused shell surface by main surface

2017-07-26 Thread Quentin Glidic

On 7/26/17 12:02 PM, Philipp Kerling wrote:

The focused surface is used for determining whether shell surfaces
are activated. They should also be considered activated when a
subsurface has focus. Inserting a call to
weston_surface_get_main_surface fixes this.

seat->focused_surface is only used for shell_surface keyboard focus
tracking.


As said on IRC, added your Sob, and:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

And pushed:
4c4b9cfb..ba8a0d04  master -> master

Thanks!


---
  desktop-shell/shell.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 832a7b74..4608cf2f 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -1852,7 +1852,7 @@ handle_keyboard_focus(struct wl_listener *listener, void 
*data)
shell_surface_lose_keyboard_focus(shsurf);
}
  
-	seat->focused_surface = keyboard->focus;

+   seat->focused_surface = 
weston_surface_get_main_surface(keyboard->focus);
  
  	if (seat->focused_surface) {

struct shell_surface *shsurf = 
get_shell_surface(seat->focused_surface);
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston] libweston-desktop/xwayland: Make sure racy surfaces are properly mapped

2017-07-21 Thread Quentin Glidic

On 5/15/17 4:40 PM, Pekka Paalanen wrote:

On Mon, 15 May 2017 15:29:29 +0200
Quentin Glidic <sardemff7+wayl...@sardemff7.net> wrote:


From: Quentin Glidic <sardemff7+...@sardemff7.net>

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
  libweston-desktop/xwayland.c | 10 ++
  1 file changed, 10 insertions(+)

diff --git a/libweston-desktop/xwayland.c b/libweston-desktop/xwayland.c
index 4f4b453f..4dcb5f03 100644
--- a/libweston-desktop/xwayland.c
+++ b/libweston-desktop/xwayland.c
@@ -61,6 +61,7 @@ struct weston_desktop_xwayland_surface {
const struct weston_xwayland_client_interface *client_interface;
struct weston_geometry next_geometry;
bool has_next_geometry;
+   bool committed;
bool added;
enum weston_desktop_xwayland_surface_state state;
  };
@@ -99,6 +100,14 @@ weston_desktop_xwayland_surface_change_state(struct 
weston_desktop_xwayland_surf
weston_desktop_api_surface_added(surface->desktop,
 surface->surface);
surface->added = true;
+   if (surface->state == NONE && surface->committed)
+   /* We had a race, and wl_surface.commit() was
+* faster, just fake a commit to map the
+* surface */
+   weston_desktop_api_committed(surface->desktop,
+surface->surface,
+0, 0);
+
} else if (surface->added) {
weston_desktop_api_surface_removed(surface->desktop,
   surface->surface);
@@ -134,6 +143,7 @@ weston_desktop_xwayland_surface_committed(struct 
weston_desktop_surface *dsurfac
struct weston_geometry oldgeom;
  
  	assert(dsurface == surface->surface);

+   surface->committed = true;
  
  #ifdef WM_DEBUG

weston_log("%s: xwayland surface %p\n", __func__, surface);


Hi Quentin,

thanks for making the patch so fast! It clarified my thoughts.

I wonder, could it become a problem to never unset 'committed'? In case
something causes XWM or Xwayland to "unmap" the surface and later map
again.

>

We'd want to check for "has content", and checking for a buffer is not
always right as the renderer may have made a copy and released the
buffer, so... weston_surface width and height > 0?

Calling weston_desktop_api_commit() sounds like the right solution.

Is surface->state reset back to NONE when the surface is unmapped? What
about !weston_surface_is_mapped()?


I feel I should explain more background for the bug we are trying to
fix here, as I have no reliable way to reproduce. Hopefully that
inspires a commit message. ;-)

The question is about a fundamental race between the Wayland and X11
protocol streams for XWM. Wayland carries the surface content, which is
latched in with wl_surface.commit that leads to calling into the shell
plugin to map the window. X11 carries the window management
information, essentially the shell role for the window/surface.
Obviously we cannot actually map a window until it has both content and
role.

So the race is between setting the content and setting the role. IIRC
e.g. xdg_shell simply forbids this race, requiring role to be set
first. Unfortunately with Xwayland I don't think we have the luxury of
that. There is the _XWAYLAND_ALLOW_COMMITS feature which could mitigate
the problem, but it is not yet in any xorg-xserver release, and we need
to be able to do without it.

The actual bug is, that if content is set first, setting the role does
not complete mapping the surface. As the surface is not mapped, the frame
callbacks are not sent, and Xwayland will never commit again. The
window is lost in an unmapped limbo.

At least, I believe we have that bug. Actually I am helping to fix this
bug on Weston 1.11 which is before the introduction of
libweston-desktop. I have had reports of this issue on 1.11, and when I
looked at the code in master, I believe the problem is still there, but
have not been able to reproduce it. Doesn't help that I'm generally
running with _XWAYLAND_ALLOW_COMMITS support too.


Actually, the concepts involved don’t match the code perfectly.
In libweston-desktop, the commit does *not* depend on content. It just 
happens that Xwayland commit for content only (since the rest is done 
via XWM). The compositor/shell has to deal with NULL-buffer surfaces 
anyway, since wl_shell mandates that.


Mapping the surface needs this sequence:
1. libweston-desktop surface_added callback
2. libweston-desktop committed callback

Unmapping a surface, if I understand XWM enough, will destroy the 
wl_surface and reset the desktop surface to N

Re: [RFC weston] xwm: update override-redirect surface's position upon configure_notify

2017-07-21 Thread Quentin Glidic

On 6/27/17 11:08 PM, Ilia Bozhinov wrote:

When we receive configure_notify we should update the surface's
position by calling xwayland_api->set_xwayland(). Otherwise some surfaces
like dnd surfaces from xwayland views are "stuck" at one place. When
setting XWAYLAND state though we should always call view_set_position(),
not just the first time we set this state.

Signed-off-by: Ilia Bozhinov <amme...@gmail.com>


Good:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

And pushed:
749637a8..3e5303da  master -> master

Thanks,



---
  libweston-desktop/xwayland.c | 2 +-
  xwayland/window-manager.c| 7 +++
  2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/libweston-desktop/xwayland.c b/libweston-desktop/xwayland.c
index 4f4b453f..002e2523 100644
--- a/libweston-desktop/xwayland.c
+++ b/libweston-desktop/xwayland.c
@@ -112,7 +112,6 @@ weston_desktop_xwayland_surface_change_state(struct 
weston_desktop_xwayland_surf

weston_desktop_surface_create_view(surface->surface);

weston_layer_entry_insert(>xwayland->layer.view_list,
  >view->layer_link);
-   weston_view_set_position(surface->view, x, y);
surface->view->is_mapped = true;
wsurface->is_mapped = true;
}
@@ -316,6 +315,7 @@ set_xwayland(struct weston_desktop_xwayland_surface 
*surface, int x, int y)
  {
weston_desktop_xwayland_surface_change_state(surface, XWAYLAND, NULL,
 x, y);
+   weston_view_set_position(surface->view, x, y);
  }
  
  static int

diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
index 25008539..05e78a7e 100644
--- a/xwayland/window-manager.c
+++ b/xwayland/window-manager.c
@@ -739,6 +739,8 @@ weston_wm_handle_configure_notify(struct weston_wm *wm, 
xcb_generic_event_t *eve
  {
xcb_configure_notify_event_t *configure_notify =
(xcb_configure_notify_event_t *) event;
+   const struct weston_desktop_xwayland_interface *xwayland_api =
+   wm->server->compositor->xwayland_interface;
struct weston_wm_window *window;
  
  	wm_log("XCB_CONFIGURE_NOTIFY (window %d) %d,%d @ %dx%d%s\n",

@@ -760,6 +762,11 @@ weston_wm_handle_configure_notify(struct weston_wm *wm, 
xcb_generic_event_t *eve
if (window->frame)
frame_resize_inside(window->frame,
window->width, window->height);
+
+   /* We should check if shsurf has been created because sometimes
+* there are races(configure_notify is sent before 
xserver_map_surface) */
+   if (window->shsurf)
+   xwayland_api->set_xwayland(window->shsurf, window->x, 
window->y);
}
  }
  




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH] libweston-desktop: add signals for title, app_id

2017-07-21 Thread Quentin Glidic

On 7/20/17 4:33 PM, Matt Hoosier wrote:

It's useful for the shell implementation to know when these change,
for example to relay the information on to taskbars or similar.


The idea is good, we need something like that. (But maybe not, see below).



To avoid ABI changes or the need to make the weston_desktop_surface
definition public, new functions are introduced for attaching
listeners to these signals.


We don’t care that much about ABI changes, but you’re right that I do 
care about the struct staying private.




Signed-off-by: Matt Hoosier 
---
  libweston-desktop/libweston-desktop.h |  6 ++
  libweston-desktop/surface.c   | 21 +
  2 files changed, 27 insertions(+)

diff --git a/libweston-desktop/libweston-desktop.h 
b/libweston-desktop/libweston-desktop.h
index 03b04c7..e38257e 100644
--- a/libweston-desktop/libweston-desktop.h
+++ b/libweston-desktop/libweston-desktop.h
@@ -164,6 +164,12 @@ weston_desktop_surface_set_size(struct 
weston_desktop_surface *surface,
int32_t width, int32_t height);
  void
  weston_desktop_surface_close(struct weston_desktop_surface *surface);
+void
+weston_desktop_surface_add_title_listener(struct weston_desktop_surface 
*surface,
+ struct wl_listener *listener);
+void
+weston_desktop_surface_add_app_id_listener(struct weston_desktop_surface 
*surface,
+  struct wl_listener *listener);
  
  void *

  weston_desktop_surface_get_user_data(struct weston_desktop_surface *surface);
diff --git a/libweston-desktop/surface.c b/libweston-desktop/surface.c
index d3be936..97a455c 100644
--- a/libweston-desktop/surface.c
+++ b/libweston-desktop/surface.c
@@ -64,6 +64,8 @@ struct weston_desktop_surface {
char *title;
char *app_id;
pid_t pid;
+   struct wl_signal title_signal;
+   struct wl_signal app_id_signal;
};
struct {
struct weston_desktop_surface *parent;
@@ -287,6 +289,9 @@ weston_desktop_surface_create(struct weston_desktop 
*desktop,
wl_list_init(>view_list);
wl_list_init(>grab_link);
  
+	wl_signal_init(>title_signal);

+   wl_signal_init(>app_id_signal);
+
return surface;
  }
  
@@ -511,6 +516,20 @@ weston_desktop_surface_close(struct weston_desktop_surface *surface)

   surface->implementation_data);
  }
  
+WL_EXPORT void

+weston_desktop_surface_add_title_listener(struct weston_desktop_surface 
*surface,
+ struct wl_listener *listener)
+{
+   wl_signal_add(>title_signal, listener);
+}
+
+WL_EXPORT void
+weston_desktop_surface_add_app_id_listener(struct weston_desktop_surface 
*surface,
+  struct wl_listener *listener)
+{
+   wl_signal_add(>app_id_signal, listener);
+}
+
  struct weston_desktop_surface *
  weston_desktop_surface_from_client_link(struct wl_list *link)
  {
@@ -687,6 +706,7 @@ weston_desktop_surface_set_title(struct 
weston_desktop_surface *surface,
  
  	free(surface->title);

surface->title = tmp;
+   wl_signal_emit(>title_signal, surface->title);


I would rather pass the surface as the signal data. Just in case we have 
in the future a value that doesn’t fit in a pointer. And calling a 
getter is not that bad.


Also, I prefer to have one signal only, it would reduce the API size 
(and avoid it growing too much in the future, since it could work in 
this case).
We can move the free() to keep both pointer around until after the 
signal fired, and a simple pointer comparison will work (if you stored 
the "const char *" directly, which you should as with the signal, we 
guarantee it will exist until destroy or signal).



But it raised a question : Jonas, are set_title() and set_app_id() 
supposed to be active without a commit()?


If so, maybe should we test equality in libweston-desktop, to avoid 
sending useless signals? (Just in case a client would be lazy and send 
the title on every frame.)

And I would like to know if one signal sounds good to you?

If *not*, then the committed callback is already the place to check for 
changes, and we need to adjust the code to match that. (And to keep old 
pointers around for safe comparison.)



Cheers,


  }
  
  void

@@ -701,6 +721,7 @@ weston_desktop_surface_set_app_id(struct 
weston_desktop_surface *surface,
  
  	free(surface->app_id);

surface->app_id = tmp;
+   wl_signal_emit(>app_id_signal, surface->app_id);
  }
  
  void





--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston v2] input: Do not override keyboard focus on restore

2017-07-21 Thread Quentin Glidic
From: Quentin Glidic <sardemff7+...@sardemff7.net>

If we start a special (grabbing) client when Weston is unfocused, it
would lose focus when coming back to Weston.

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
v2:
 Reset saved focus in weston_keybord_set_focus()
 Shuffled the focus saving code (since it calls set_focus() to NULLify it)

 libweston/input.c | 26 +++---
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/libweston/input.c b/libweston/input.c
index 4fedc558..d506623a 100644
--- a/libweston/input.c
+++ b/libweston/input.c
@@ -1317,6 +1317,7 @@ WL_EXPORT void
 weston_keyboard_set_focus(struct weston_keyboard *keyboard,
  struct weston_surface *surface)
 {
+   struct weston_seat *seat = keyboard->seat;
struct wl_resource *resource;
struct wl_display *display = keyboard->seat->compositor->wl_display;
uint32_t serial;
@@ -1350,6 +1351,11 @@ weston_keyboard_set_focus(struct weston_keyboard 
*keyboard,
keyboard->focus_serial = serial;
}
 
+   if (seat->saved_kbd_focus) {
+   wl_list_remove(>saved_kbd_focus_listener.link);
+   seat->saved_kbd_focus = NULL;
+   }
+
wl_list_remove(>focus_resource_listener.link);
wl_list_init(>focus_resource_listener.link);
if (surface && surface->resource)
@@ -2067,11 +2073,8 @@ notify_keyboard_focus_in(struct weston_seat *seat, 
struct wl_array *keys,
}
 
surface = seat->saved_kbd_focus;
-
if (surface) {
-   wl_list_remove(>saved_kbd_focus_listener.link);
weston_keyboard_set_focus(keyboard, surface);
-   seat->saved_kbd_focus = NULL;
}
 }
 
@@ -2081,6 +2084,7 @@ notify_keyboard_focus_out(struct weston_seat *seat)
struct weston_compositor *compositor = seat->compositor;
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
+   struct weston_surface *focus = keyboard->focus;
uint32_t *k, serial;
 
serial = wl_display_next_serial(compositor->wl_display);
@@ -2092,18 +2096,18 @@ notify_keyboard_focus_out(struct weston_seat *seat)
 
seat->modifier_state = 0;
 
-   if (keyboard->focus) {
-   seat->saved_kbd_focus = keyboard->focus;
-   seat->saved_kbd_focus_listener.notify =
-   destroy_device_saved_kbd_focus;
-   wl_signal_add(>focus->destroy_signal,
- >saved_kbd_focus_listener);
-   }
-
weston_keyboard_set_focus(keyboard, NULL);
weston_keyboard_cancel_grab(keyboard);
if (pointer)
weston_pointer_cancel_grab(pointer);
+
+   if (focus) {
+   seat->saved_kbd_focus = focus;
+   seat->saved_kbd_focus_listener.notify =
+   destroy_device_saved_kbd_focus;
+   wl_signal_add(>destroy_signal,
+ >saved_kbd_focus_listener);
+   }
 }
 
 WL_EXPORT void
-- 
2.13.3

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH][weston] configure.ac: Add --with-wayland-scanner-path

2017-07-20 Thread Quentin Glidic

On 7/18/17 3:58 PM, Pekka Paalanen wrote:

On Wed, 24 May 2017 11:32:21 +0300
Jussi Kukkonen <jussi.kukko...@intel.com> wrote:


On 23 May 2017 at 14:51, Quentin Glidic <sardemff7+wayl...@sardemff7.net>
wrote:



So you want to break the simple (cross-compiling) cases to fix
something that doesn’t need fixing?


I think that is not warranted.
* My issue was that every wayland-scanner user was doing something
different, often in a way that required patching in Yocto
* Weston was fine for us but Pekka gave me feedback that lead me to
believe the weston method was not the best solution either

I did my best to try and resolve both issues. It looks like my
attempt was not successful but there should be no reason to say I
"want to break" something.


Hi,

I'm with Jussi here.


If you want to make a patch, it should not introduce a regression.


I think _if_ the goal is to use the same scanner lookup in e.g. mesa
and weston, some use case in one or the other is just bound to have a
regression.


Quentin, do you see any way unifying the usage of wayland-scanner
without regressing at least one user?


Yes, we can just do what we do now in Weston, *adding* the Yocto style.
IOW, we want to support, without passing any variable:
- native and cross-compiling as a system package
  just wayland-scanner from (native) path is good
- native in a custom prefix (system may be different version)
  prefer the pkg-config file
- cross-compiling in a custom prefix (system may be different version)
  we need to check for the native (custom prefix) pkg-config here

In all three cases, checking for the version would be much better. We 
could even use the native system scanner in some cases if the version 
matches, avoiding another build in cross-compiling case.


In pseudo-code, here is what I suggest:

get_wayland_version()

# macro WL_PROG_SCANNER([version])
if $cross_compiling; then
get_native_pkg_config_scanner_path()
else
get_pkg_config_scanner_path()
fi
if scanner == ""; then
get_PATH_scanner_path()
if scanner == "" || ! check_scanner_version(); then
error()
fi
fi
# macro end

You can call "pkg-config --variable=wayland_scanner 'wayland-scanner = 
"version'" directly to let pkg-config do the version check.


That would support all use cases listed above, with no variable. And we 
can still add the configure switch for very specific corner cases that 
might exist.




So at this point, we should make a generic patch, ideally (IMO) in
wayland-scanner.m4, and have people test it in all their different
setup to see if it works as expected.


Is anyone actually using wayland-scanner.m4?

I did not find any evidence of Weston using it. Certainly no-one is
using wayland-scanner.mk anymore because of the structure or
wayland-protocols and the need to search for XML files in both local
and system paths. Since wayland-scanner.m4 has a reference to
wayland-scanner.mk, I doubt anyone is using wayland-scanner.m4 either.

We should make a plan to get rid of wayland-scanner.mk and
wayland-scanner.m4, I do not think they are fixable.


We can deprecate the current macro while adding new ones. Or have a new 
file. It doesn’t matter much, it’s just a (autoreconf) build time dep on 
the newer Wayland.
I see no issue with wayland-scanner.m4 not being used. We can make *new* 
versions use it, it’s adding API/ABI.




If you’re not comfortable making one, I’ll do it by this week-end
so you can test it in yours.


Did anything come out of that?


We need to agree on the “good” way to do the checks first, but if you 
feel better doing so with a real patch as a basis, I can do it.




There is also the sysroot patch from Tomek Bury that no-one has
commented on yet.
https://patchwork.freedesktop.org/patch/165478/


Ack.


--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH wayland-protocols] sysroot prefix

2017-07-20 Thread Quentin Glidic

On 7/20/17 11:25 AM, Daniel Stone wrote:

Hi,

On 20 July 2017 at 10:14, Quentin Glidic
<sardemff7+wayl...@sardemff7.net> wrote:

Using ${pc_sysrootdir} sounds like the correct thing to do. However, your
patch introduces a triple / when PKG_CONFIG_SYSROOT_DIR is not set.
Having two / is already trouble on some platform (though the one we
currently work on should be fine, I think), three / would break even more.
Please just use "${pc_sysrootdir}@datadir@".


Yeah, this all LGTM, and gets my:
Reviewed-by: Daniel Stone <dani...@collabora.com>


Also, using this variable should be in prefix=, IMO, since all the paths
should be fixed.


I'm wary of doing that, if only because it establishes a pattern. It's
fine for wayland-protocols itself, but when doing sysroot builds,
includedir/libdir/etc already get prefixed by the compiler/linker. So
I wouldn't want anyone to look at wayland-protocols and blindly copy
the prepend to prefix. Containing it to just variables we know will be
used and queried directly seems more safe.


pkg-config already prepends PKG_CONFIG_SYSROOT_DIR to --cflags and 
--libs (and properly handle it if you put it in prefix, i.e. no 
dublicate), so it is completely safe to have in all variables.


--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH wayland-protocols] sysroot prefix

2017-07-20 Thread Quentin Glidic

On 7/6/17 11:02 AM, Tomek Bury wrote:

Hi,

I've attached a trivial patch we discussed yesterday on #wayland 
channel. The patch adds a sysroot prefix to the "pkgdatadir" variable. 
The pkg-config automatically adds sysroot to paths returned by --cflags 
and --libs but *NOT* to --variable.


The "pkgdatadir" in wayland-protocols.pc is actually a path pointing to 
the protocol installation directory on the target system but in a 
cross-compilation scenario we need pkg-config to return a temporary 
location in the staging area on the build system just as it does for 
--cflags and --libs.


The change only influences builds with PKG_CONFIG_SYSROOT_DIR 
environment variable set.


There's another pkg-confing variable containing a path to the 
wayland-scanner tool but I'm not sure how to handle that one correctly 
in cross-compilation scenario.  The cross-compiled wayland-scanner is 
likely to be useless on the build system. The pre-existing 
wayland-scanner on the build system, if any, is also likely to be 
useless. The only scanner that would actually work is the scanner 
compiled from wayland sources for the build system architecture and 
installed somewhere with its own .pc file. This implies that libs using 
scanner would need 2 independent pkg-config setups.


My call would be to get rid of that variable and add 
--with-wayland-scanner=/path/to/the/right/wayland-scanner config 
variable to xkbcommon, wayland, weston and whatever uses wayland-scanner.


Cheers,
Tomek



Nit: please use git send-email to send patches, so we can comment on 
them inline in the email.


> -pkgdatadir=@datadir@/@PACKAGE@
> +pkgdatadir=${pc_sysrootdir}/@datadir@/@PACKAGE@

Using ${pc_sysrootdir} sounds like the correct thing to do. However, 
your patch introduces a triple / when PKG_CONFIG_SYSROOT_DIR is not set.
Having two / is already trouble on some platform (though the one we 
currently work on should be fine, I think), three / would break even more.

Please just use "${pc_sysrootdir}@datadir@".

Also, using this variable should be in prefix=, IMO, since all the paths 
should be fixed.
But that would break builds where you directly specify --datadir, so we 
probably want to do that for now. (Until we use Meson *and* Meson 
pkg-config module gets proper custom variables support.)


Cheers,

--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston v4] libweston-desktop/xdg-shell: Properly handle ack_configure

2017-07-20 Thread Quentin Glidic

On 7/20/17 10:49 AM, Jonas Ådahl wrote:

On Thu, Jul 20, 2017 at 10:45:38AM +0200, Quentin Glidic wrote:

From: Quentin Glidic <sardemff7+...@sardemff7.net>

Now we keep track of serial->state association and we discard the states
that the client ignored.

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>


Reviewed-by: Jonas Ådahl <jad...@gmail.com>


Thanks. And pushed:
19d1f6ef..749637a8  master -> master

Cheers,


---

On 7/20/17 10:24 AM, Jonas Ådahl wrote:

Noticed one more thing I missed in the previous review: cleanup of the
pending configure allocations on surface destruction.


Oh, good catch, thanks.

v3:
  Fixed a tiny style issue
  Now send an error on wrong serial
v4:
  Free configure_list on destroy

  libweston-desktop/xdg-shell-v5.c | 60 ++
  libweston-desktop/xdg-shell-v6.c | 79 +++-
  2 files changed, 122 insertions(+), 17 deletions(-)

diff --git a/libweston-desktop/xdg-shell-v5.c b/libweston-desktop/xdg-shell-v5.c
index b32b7812..c91c2590 100644
--- a/libweston-desktop/xdg-shell-v5.c
+++ b/libweston-desktop/xdg-shell-v5.c
@@ -46,6 +46,13 @@ struct weston_desktop_xdg_surface_state {
bool activated;
  };
  
+struct weston_desktop_xdg_surface_configure {

+   struct wl_list link; /* weston_desktop_xdg_surface::configure_list */
+   uint32_t serial;
+   struct weston_desktop_xdg_surface_state state;
+   struct weston_size size;
+};
+
  struct weston_desktop_xdg_surface {
struct wl_resource *resource;
struct weston_desktop_surface *surface;
@@ -53,7 +60,7 @@ struct weston_desktop_xdg_surface {
bool added;
struct wl_event_source *add_idle;
struct wl_event_source *configure_idle;
-   uint32_t configure_serial;
+   struct wl_list configure_list; /* 
weston_desktop_xdg_surface_configure::link */
struct {
struct weston_desktop_xdg_surface_state state;
struct weston_size size;
@@ -94,13 +101,26 @@ static void
  weston_desktop_xdg_surface_send_configure(void *data)
  {
struct weston_desktop_xdg_surface *surface = data;
+   struct weston_desktop_xdg_surface_configure *configure;
uint32_t *s;
struct wl_array states;
  
  	surface->configure_idle = NULL;
  
-	surface->configure_serial =

+   configure = zalloc(sizeof(struct weston_desktop_xdg_surface_configure));
+   if (configure == NULL) {
+   struct weston_desktop_client *client =
+   weston_desktop_surface_get_client(surface->surface);
+   struct wl_client *wl_client =
+   weston_desktop_client_get_client(client);
+   wl_client_post_no_memory(wl_client);
+   return;
+   }
+   wl_list_insert(surface->configure_list.prev, >link);
+   configure->serial =

wl_display_next_serial(weston_desktop_get_display(surface->desktop));
+   configure->state = surface->pending.state;
+   configure->size = surface->pending.size;
  
  	wl_array_init();

if (surface->pending.state.maximized) {
@@ -124,7 +144,7 @@ weston_desktop_xdg_surface_send_configure(void *data)
   surface->pending.size.width,
   surface->pending.size.height,
   ,
-  surface->configure_serial);
+  configure->serial);
  
  	wl_array_release();

  };
@@ -325,6 +345,7 @@ weston_desktop_xdg_surface_destroy(struct 
weston_desktop_surface *dsurface,
   void *user_data)
  {
struct weston_desktop_xdg_surface *surface = user_data;
+   struct weston_desktop_xdg_surface_configure *configure, *temp;
  
  	if (surface->added)

weston_desktop_api_surface_removed(surface->desktop,
@@ -336,6 +357,9 @@ weston_desktop_xdg_surface_destroy(struct 
weston_desktop_surface *dsurface,
if (surface->configure_idle != NULL)
wl_event_source_remove(surface->configure_idle);
  
+	wl_list_for_each_safe(configure, temp, >configure_list, link)

+   free(configure);
+
free(surface);
  }
  
@@ -443,12 +467,34 @@ weston_desktop_xdg_surface_protocol_ack_configure(struct wl_client *wl_client,

wl_resource_get_user_data(resource);
struct weston_desktop_xdg_surface *surface =
weston_desktop_surface_get_implementation_data(dsurface);
-
-   if (surface->configure_serial != serial)
+   struct weston_desktop_xdg_surface_configure *configure, *temp;
+   bool found = false;
+
+   wl_list_for_each_safe(configure, temp, >configure_list, link) {
+   if (configure->serial < serial) {
+   wl_list_remove(>link);
+   free(config

[PATCH weston v3] libweston-desktop/xdg-shell: Properly handle ack_configure

2017-07-20 Thread Quentin Glidic
From: Quentin Glidic <sardemff7+...@sardemff7.net>

Now we keep track of serial->state association and we discard the states
that the client ignored.

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
v3:
 Fixed a tiny style issue
 Now send an error on wrong serial

 libweston-desktop/xdg-shell-v5.c | 56 ++
 libweston-desktop/xdg-shell-v6.c | 75 ++--
 2 files changed, 114 insertions(+), 17 deletions(-)

diff --git a/libweston-desktop/xdg-shell-v5.c b/libweston-desktop/xdg-shell-v5.c
index b32b7812..f428e02e 100644
--- a/libweston-desktop/xdg-shell-v5.c
+++ b/libweston-desktop/xdg-shell-v5.c
@@ -46,6 +46,13 @@ struct weston_desktop_xdg_surface_state {
bool activated;
 };
 
+struct weston_desktop_xdg_surface_configure {
+   struct wl_list link; /* weston_desktop_xdg_surface::configure_list */
+   uint32_t serial;
+   struct weston_desktop_xdg_surface_state state;
+   struct weston_size size;
+};
+
 struct weston_desktop_xdg_surface {
struct wl_resource *resource;
struct weston_desktop_surface *surface;
@@ -53,7 +60,7 @@ struct weston_desktop_xdg_surface {
bool added;
struct wl_event_source *add_idle;
struct wl_event_source *configure_idle;
-   uint32_t configure_serial;
+   struct wl_list configure_list; /* 
weston_desktop_xdg_surface_configure::link */
struct {
struct weston_desktop_xdg_surface_state state;
struct weston_size size;
@@ -94,13 +101,26 @@ static void
 weston_desktop_xdg_surface_send_configure(void *data)
 {
struct weston_desktop_xdg_surface *surface = data;
+   struct weston_desktop_xdg_surface_configure *configure;
uint32_t *s;
struct wl_array states;
 
surface->configure_idle = NULL;
 
-   surface->configure_serial =
+   configure = zalloc(sizeof(struct weston_desktop_xdg_surface_configure));
+   if (configure == NULL) {
+   struct weston_desktop_client *client =
+   weston_desktop_surface_get_client(surface->surface);
+   struct wl_client *wl_client =
+   weston_desktop_client_get_client(client);
+   wl_client_post_no_memory(wl_client);
+   return;
+   }
+   wl_list_insert(surface->configure_list.prev, >link);
+   configure->serial =

wl_display_next_serial(weston_desktop_get_display(surface->desktop));
+   configure->state = surface->pending.state;
+   configure->size = surface->pending.size;
 
wl_array_init();
if (surface->pending.state.maximized) {
@@ -124,7 +144,7 @@ weston_desktop_xdg_surface_send_configure(void *data)
   surface->pending.size.width,
   surface->pending.size.height,
   ,
-  surface->configure_serial);
+  configure->serial);
 
wl_array_release();
 };
@@ -443,12 +463,34 @@ weston_desktop_xdg_surface_protocol_ack_configure(struct 
wl_client *wl_client,
wl_resource_get_user_data(resource);
struct weston_desktop_xdg_surface *surface =
weston_desktop_surface_get_implementation_data(dsurface);
-
-   if (surface->configure_serial != serial)
+   struct weston_desktop_xdg_surface_configure *configure, *temp;
+   bool found = false;
+
+   wl_list_for_each_safe(configure, temp, >configure_list, link) {
+   if (configure->serial < serial) {
+   wl_list_remove(>link);
+   free(configure);
+   } else if (configure->serial == serial) {
+   wl_list_remove(>link);
+   found = true;
+   }
+   break;
+   }
+   if (!found) {
+   struct weston_desktop_client *client =
+   weston_desktop_surface_get_client(dsurface);
+   struct wl_resource *client_resource =
+   weston_desktop_client_get_resource(client);
+   wl_resource_post_error(client_resource,
+  XDG_SHELL_ERROR_DEFUNCT_SURFACES,
+  "Wrong configure serial: %u", serial);
return;
+   }
+
+   surface->next.state = configure->state;
+   surface->next.size = configure->size;
 
-   surface->next.state = surface->pending.state;
-   surface->next.size = surface->pending.size;
+   free(configure);
 }
 
 static void
diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c
index f5e46daa..cd02ec76 100644
--- a/libweston-desktop/xdg-shell-v6.c
+++ b/libweston-desktop/xdg-shell-v6.c
@@ -69,7 +69,7 

Re: [PATCH weston v2 2/2] libweston-desktop/xdg-shell: Properly handle ack_configure

2017-07-20 Thread Quentin Glidic

On 7/20/17 5:56 AM, Jonas Ådahl wrote:

On Tue, Jul 18, 2017 at 01:14:49PM +0200, Quentin Glidic wrote:

From: Quentin Glidic <sardemff7+...@sardemff7.net>

Now we keep track of serial->state association and we discard the states
that the client ignored.

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
  libweston-desktop/xdg-shell-v5.c | 45 +++-
  libweston-desktop/xdg-shell-v6.c | 64 +---
  2 files changed, 92 insertions(+), 17 deletions(-)

diff --git a/libweston-desktop/xdg-shell-v5.c b/libweston-desktop/xdg-shell-v5.c
index b32b7812..f9f7a5d1 100644
--- a/libweston-desktop/xdg-shell-v5.c
+++ b/libweston-desktop/xdg-shell-v5.c
@@ -46,6 +46,13 @@ struct weston_desktop_xdg_surface_state {
bool activated;
  };
  
+struct weston_desktop_xdg_surface_configure {

+   struct wl_list link; /* weston_desktop_xdg_surface::configure_list */
+   uint32_t serial;
+   struct weston_desktop_xdg_surface_state state;
+   struct weston_size size;
+};
+
  struct weston_desktop_xdg_surface {
struct wl_resource *resource;
struct weston_desktop_surface *surface;
@@ -53,7 +60,7 @@ struct weston_desktop_xdg_surface {
bool added;
struct wl_event_source *add_idle;
struct wl_event_source *configure_idle;
-   uint32_t configure_serial;
+   struct wl_list configure_list; /* 
weston_desktop_xdg_surface_configure::link */
struct {
struct weston_desktop_xdg_surface_state state;
struct weston_size size;
@@ -94,13 +101,26 @@ static void
  weston_desktop_xdg_surface_send_configure(void *data)
  {
struct weston_desktop_xdg_surface *surface = data;
+   struct weston_desktop_xdg_surface_configure *configure;
uint32_t *s;
struct wl_array states;
  
  	surface->configure_idle = NULL;
  
-	surface->configure_serial =

+   configure = zalloc(sizeof(struct weston_desktop_xdg_surface_configure));
+   if ( configure == NULL ) {


No spacing around expression.


Oops, fixed.



+   struct weston_desktop_client *client =
+   weston_desktop_surface_get_client(surface->surface);
+   struct wl_client *wl_client =
+   weston_desktop_client_get_client(client);
+   wl_client_post_no_memory(wl_client);
+   return;
+   }
+   wl_list_insert(surface->configure_list.prev, >link);
+   configure->serial =

wl_display_next_serial(weston_desktop_get_display(surface->desktop));
+   configure->state = surface->pending.state;
+   configure->size = surface->pending.size;
  
  	wl_array_init();

if (surface->pending.state.maximized) {
@@ -124,7 +144,7 @@ weston_desktop_xdg_surface_send_configure(void *data)
   surface->pending.size.width,
   surface->pending.size.height,
   ,
-  surface->configure_serial);
+  configure->serial);
  
  	wl_array_release();

  };
@@ -443,12 +463,23 @@ weston_desktop_xdg_surface_protocol_ack_configure(struct 
wl_client *wl_client,
wl_resource_get_user_data(resource);
struct weston_desktop_xdg_surface *surface =
weston_desktop_surface_get_implementation_data(dsurface);
-
-   if (surface->configure_serial != serial)
+   struct weston_desktop_xdg_surface_configure *configure, *temp;
+
+   wl_list_for_each_safe(configure, temp, >configure_list, link) {
+   if (configure->serial < serial) {
+   wl_list_remove(>link);
+   free(configure);
+   } else if (configure->serial == serial) {
+   wl_list_remove(>link);
+   break;
+   }
return;
+   }
+
+   surface->next.state = configure->state;
+   surface->next.size = configure->size;


Must check that we found the acked configure. Bad clients can send a
bogus ack serial.

  
-	surface->next.state = surface->pending.state;

-   surface->next.size = surface->pending.size;
+   free(configure);
  }
  
  static void

diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c
index f5e46daa..9094260e 100644
--- a/libweston-desktop/xdg-shell-v6.c
+++ b/libweston-desktop/xdg-shell-v6.c
@@ -69,7 +69,7 @@ struct weston_desktop_xdg_surface {
struct weston_desktop_surface *desktop_surface;
bool configured;
struct wl_event_source *configure_idle;
-   uint32_t configure_serial;
+   struct wl_list configure_list; /* 
weston_desktop_xdg_surface_configure::link */
  
  	bool has_next_geometry;

struct weston_geometry next_geomet

[PATCH weston v2 2/2] libweston-desktop/xdg-shell: Properly handle ack_configure

2017-07-18 Thread Quentin Glidic
From: Quentin Glidic <sardemff7+...@sardemff7.net>

Now we keep track of serial->state association and we discard the states
that the client ignored.

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
 libweston-desktop/xdg-shell-v5.c | 45 +++-
 libweston-desktop/xdg-shell-v6.c | 64 +---
 2 files changed, 92 insertions(+), 17 deletions(-)

diff --git a/libweston-desktop/xdg-shell-v5.c b/libweston-desktop/xdg-shell-v5.c
index b32b7812..f9f7a5d1 100644
--- a/libweston-desktop/xdg-shell-v5.c
+++ b/libweston-desktop/xdg-shell-v5.c
@@ -46,6 +46,13 @@ struct weston_desktop_xdg_surface_state {
bool activated;
 };
 
+struct weston_desktop_xdg_surface_configure {
+   struct wl_list link; /* weston_desktop_xdg_surface::configure_list */
+   uint32_t serial;
+   struct weston_desktop_xdg_surface_state state;
+   struct weston_size size;
+};
+
 struct weston_desktop_xdg_surface {
struct wl_resource *resource;
struct weston_desktop_surface *surface;
@@ -53,7 +60,7 @@ struct weston_desktop_xdg_surface {
bool added;
struct wl_event_source *add_idle;
struct wl_event_source *configure_idle;
-   uint32_t configure_serial;
+   struct wl_list configure_list; /* 
weston_desktop_xdg_surface_configure::link */
struct {
struct weston_desktop_xdg_surface_state state;
struct weston_size size;
@@ -94,13 +101,26 @@ static void
 weston_desktop_xdg_surface_send_configure(void *data)
 {
struct weston_desktop_xdg_surface *surface = data;
+   struct weston_desktop_xdg_surface_configure *configure;
uint32_t *s;
struct wl_array states;
 
surface->configure_idle = NULL;
 
-   surface->configure_serial =
+   configure = zalloc(sizeof(struct weston_desktop_xdg_surface_configure));
+   if ( configure == NULL ) {
+   struct weston_desktop_client *client =
+   weston_desktop_surface_get_client(surface->surface);
+   struct wl_client *wl_client =
+   weston_desktop_client_get_client(client);
+   wl_client_post_no_memory(wl_client);
+   return;
+   }
+   wl_list_insert(surface->configure_list.prev, >link);
+   configure->serial =

wl_display_next_serial(weston_desktop_get_display(surface->desktop));
+   configure->state = surface->pending.state;
+   configure->size = surface->pending.size;
 
wl_array_init();
if (surface->pending.state.maximized) {
@@ -124,7 +144,7 @@ weston_desktop_xdg_surface_send_configure(void *data)
   surface->pending.size.width,
   surface->pending.size.height,
   ,
-  surface->configure_serial);
+  configure->serial);
 
wl_array_release();
 };
@@ -443,12 +463,23 @@ weston_desktop_xdg_surface_protocol_ack_configure(struct 
wl_client *wl_client,
wl_resource_get_user_data(resource);
struct weston_desktop_xdg_surface *surface =
weston_desktop_surface_get_implementation_data(dsurface);
-
-   if (surface->configure_serial != serial)
+   struct weston_desktop_xdg_surface_configure *configure, *temp;
+
+   wl_list_for_each_safe(configure, temp, >configure_list, link) {
+   if (configure->serial < serial) {
+   wl_list_remove(>link);
+   free(configure);
+   } else if (configure->serial == serial) {
+   wl_list_remove(>link);
+   break;
+   }
return;
+   }
+
+   surface->next.state = configure->state;
+   surface->next.size = configure->size;
 
-   surface->next.state = surface->pending.state;
-   surface->next.size = surface->pending.size;
+   free(configure);
 }
 
 static void
diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c
index f5e46daa..9094260e 100644
--- a/libweston-desktop/xdg-shell-v6.c
+++ b/libweston-desktop/xdg-shell-v6.c
@@ -69,7 +69,7 @@ struct weston_desktop_xdg_surface {
struct weston_desktop_surface *desktop_surface;
bool configured;
struct wl_event_source *configure_idle;
-   uint32_t configure_serial;
+   struct wl_list configure_list; /* 
weston_desktop_xdg_surface_configure::link */
 
bool has_next_geometry;
struct weston_geometry next_geometry;
@@ -77,6 +77,11 @@ struct weston_desktop_xdg_surface {
enum weston_desktop_xdg_surface_role role;
 };
 
+struct weston_desktop_xdg_surface_configure {
+   struct wl_list link; /* weston_desktop_xdg_surface::configure_list */
+  

[PATCH weston v2 1/2] libweston-desktop/xdg-shell: Check surface size against acknowledged size

2017-07-18 Thread Quentin Glidic
From: Quentin Glidic <sardemff7+...@sardemff7.net>

We were checking against the pending size, which lead some clients
(simple-egl) to crash because they sent a buffer before acknowledging
the latest configure event.

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
Tested-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>
Reviewed-by: Jonas Ådahl <jad...@gmail.com>
---

Added your Rb as you said on IRC, but I’ll wait for the second patch to be
reviewed to push both.

 libweston-desktop/xdg-shell-v5.c | 6 --
 libweston-desktop/xdg-shell-v6.c | 6 --
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/libweston-desktop/xdg-shell-v5.c b/libweston-desktop/xdg-shell-v5.c
index 0fb067ab..b32b7812 100644
--- a/libweston-desktop/xdg-shell-v5.c
+++ b/libweston-desktop/xdg-shell-v5.c
@@ -60,6 +60,7 @@ struct weston_desktop_xdg_surface {
} pending;
struct {
struct weston_desktop_xdg_surface_state state;
+   struct weston_size size;
} next;
struct {
struct weston_desktop_xdg_surface_state state;
@@ -244,8 +245,8 @@ weston_desktop_xdg_surface_committed(struct 
weston_desktop_surface *dsurface,
bool reconfigure = false;
 
if (surface->next.state.maximized || surface->next.state.fullscreen)
-   reconfigure = surface->pending.size.width != wsurface->width ||
- surface->pending.size.height != wsurface->height;
+   reconfigure = surface->next.size.width != wsurface->width ||
+ surface->next.size.height != wsurface->height;
 
if (reconfigure) {
weston_desktop_xdg_surface_schedule_configure(surface, true);
@@ -447,6 +448,7 @@ weston_desktop_xdg_surface_protocol_ack_configure(struct 
wl_client *wl_client,
return;
 
surface->next.state = surface->pending.state;
+   surface->next.size = surface->pending.size;
 }
 
 static void
diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c
index db894d4a..f5e46daa 100644
--- a/libweston-desktop/xdg-shell-v6.c
+++ b/libweston-desktop/xdg-shell-v6.c
@@ -95,6 +95,7 @@ struct weston_desktop_xdg_toplevel {
} pending;
struct {
struct weston_desktop_xdg_toplevel_state state;
+   struct weston_size size;
struct weston_size min_size, max_size;
} next;
struct {
@@ -424,6 +425,7 @@ static void
 weston_desktop_xdg_toplevel_ack_configure(struct weston_desktop_xdg_toplevel 
*toplevel)
 {
toplevel->next.state = toplevel->pending.state;
+   toplevel->next.size = toplevel->pending.size;
 }
 
 static void
@@ -626,8 +628,8 @@ weston_desktop_xdg_toplevel_committed(struct 
weston_desktop_xdg_toplevel *toplev
return;
 
if ((toplevel->next.state.maximized || toplevel->next.state.fullscreen) 
&&
-   (toplevel->pending.size.width != wsurface->width ||
-toplevel->pending.size.height != wsurface->height)) {
+   (toplevel->next.size.width != wsurface->width ||
+toplevel->next.size.height != wsurface->height)) {
struct weston_desktop_client *client =

weston_desktop_surface_get_client(toplevel->base.desktop_surface);
struct wl_resource *client_resource =
-- 
2.13.3

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 2/3] libweston-desktop/xdg-shell: Add pending/next/current structs

2017-07-18 Thread Quentin Glidic

On 7/12/17 11:09 AM, Jonas Ådahl wrote:

On Wed, Jul 12, 2017 at 09:53:03AM +0200, Quentin Glidic wrote:

From: Quentin Glidic <sardemff7+...@sardemff7.net>

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>


Reviewed-by: Jonas Ådahl <jad...@gmail.com>


Thanks. Added Emmanuel Tb from IRC and pushed:
1170c663..19d1f6ef  master -> master

Patch 3 not pushed, as the full real fix will need a fourth patch.



---
  libweston-desktop/xdg-shell-v5.c | 80 ++---
  libweston-desktop/xdg-shell-v6.c | 97 ++--
  2 files changed, 98 insertions(+), 79 deletions(-)

diff --git a/libweston-desktop/xdg-shell-v5.c b/libweston-desktop/xdg-shell-v5.c
index 161a4891..0fb067ab 100644
--- a/libweston-desktop/xdg-shell-v5.c
+++ b/libweston-desktop/xdg-shell-v5.c
@@ -39,6 +39,13 @@
  
  #define WD_XDG_SHELL_PROTOCOL_VERSION 1
  
+struct weston_desktop_xdg_surface_state {

+   bool maximized;
+   bool fullscreen;
+   bool resizing;
+   bool activated;
+};
+
  struct weston_desktop_xdg_surface {
struct wl_resource *resource;
struct weston_desktop_surface *surface;
@@ -47,13 +54,16 @@ struct weston_desktop_xdg_surface {
struct wl_event_source *add_idle;
struct wl_event_source *configure_idle;
uint32_t configure_serial;
-   struct weston_size pending_size;
struct {
-   bool maximized;
-   bool fullscreen;
-   bool resizing;
-   bool activated;
-   } pending_state, next_state, state;
+   struct weston_desktop_xdg_surface_state state;
+   struct weston_size size;
+   } pending;
+   struct {
+   struct weston_desktop_xdg_surface_state state;
+   } next;
+   struct {
+   struct weston_desktop_xdg_surface_state state;
+   } current;
bool has_next_geometry;
struct weston_geometry next_geometry;
  };
@@ -92,26 +102,26 @@ weston_desktop_xdg_surface_send_configure(void *data)

wl_display_next_serial(weston_desktop_get_display(surface->desktop));
  
  	wl_array_init();

-   if (surface->pending_state.maximized) {
+   if (surface->pending.state.maximized) {
s = wl_array_add(, sizeof(uint32_t));
*s = XDG_SURFACE_STATE_MAXIMIZED;
}
-   if (surface->pending_state.fullscreen) {
+   if (surface->pending.state.fullscreen) {
s = wl_array_add(, sizeof(uint32_t));
*s = XDG_SURFACE_STATE_FULLSCREEN;
}
-   if (surface->pending_state.resizing) {
+   if (surface->pending.state.resizing) {
s = wl_array_add(, sizeof(uint32_t));
*s = XDG_SURFACE_STATE_RESIZING;
}
-   if (surface->pending_state.activated) {
+   if (surface->pending.state.activated) {
s = wl_array_add(, sizeof(uint32_t));
*s = XDG_SURFACE_STATE_ACTIVATED;
}
  
  	xdg_surface_send_configure(surface->resource,

-  surface->pending_size.width,
-  surface->pending_size.height,
+  surface->pending.size.width,
+  surface->pending.size.height,
   ,
   surface->configure_serial);
  
@@ -124,21 +134,21 @@ weston_desktop_xdg_surface_state_compare(struct weston_desktop_xdg_surface *surf

struct weston_surface *wsurface =
weston_desktop_surface_get_surface(surface->surface);
  
-	if (surface->pending_state.activated != surface->state.activated)

+   if (surface->pending.state.activated != 
surface->current.state.activated)
return false;
-   if (surface->pending_state.fullscreen != surface->state.fullscreen)
+   if (surface->pending.state.fullscreen != 
surface->current.state.fullscreen)
return false;
-   if (surface->pending_state.maximized != surface->state.maximized)
+   if (surface->pending.state.maximized != 
surface->current.state.maximized)
return false;
-   if (surface->pending_state.resizing != surface->state.resizing)
+   if (surface->pending.state.resizing != surface->current.state.resizing)
return false;
  
-	if (wsurface->width == surface->pending_size.width &&

-   wsurface->height == surface->pending_size.height)
+   if (wsurface->width == surface->pending.size.width &&
+   wsurface->height == surface->pending.size.height)
return true;
  
-	if (surface->pending_size.width == 0 &&

-   surface->pending_size.height == 0)
+   if (surface->pending.size.width == 0 &&
+   surf

Re: [PATCH weston 3/3] libweston-desktop/xdg-shell: Check surface size against acknowledged size

2017-07-12 Thread Quentin Glidic

On 7/12/17 12:07 PM, Jonas Ådahl wrote:

On Wed, Jul 12, 2017 at 12:02:29PM +0200, Quentin Glidic wrote:

On 7/12/17 11:23 AM, Jonas Ådahl wrote:

On Wed, Jul 12, 2017 at 09:53:04AM +0200, Quentin Glidic wrote:

From: Quentin Glidic <sardemff7+...@sardemff7.net>

We were checking against the pending size, which lead some clients
(simple-egl) to crash because they sent a buffer before acknowledging
the latest configure event.

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
   libweston-desktop/xdg-shell-v5.c | 6 --
   libweston-desktop/xdg-shell-v6.c | 6 --
   2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/libweston-desktop/xdg-shell-v5.c b/libweston-desktop/xdg-shell-v5.c
index 0fb067ab..b32b7812 100644
--- a/libweston-desktop/xdg-shell-v5.c
+++ b/libweston-desktop/xdg-shell-v5.c
@@ -60,6 +60,7 @@ struct weston_desktop_xdg_surface {
} pending;
struct {
struct weston_desktop_xdg_surface_state state;
+   struct weston_size size;
} next;
struct {
struct weston_desktop_xdg_surface_state state;
@@ -244,8 +245,8 @@ weston_desktop_xdg_surface_committed(struct 
weston_desktop_surface *dsurface,
bool reconfigure = false;
if (surface->next.state.maximized || surface->next.state.fullscreen)
-   reconfigure = surface->pending.size.width != wsurface->width ||
- surface->pending.size.height != wsurface->height;
+   reconfigure = surface->next.size.width != wsurface->width ||
+ surface->next.size.height != wsurface->height;
if (reconfigure) {
weston_desktop_xdg_surface_schedule_configure(surface, true);
@@ -447,6 +448,7 @@ weston_desktop_xdg_surface_protocol_ack_configure(struct 
wl_client *wl_client,
return;
surface->next.state = surface->pending.state;
+   surface->next.size = surface->pending.size;
   }
   static void
diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c
index db894d4a..f5e46daa 100644
--- a/libweston-desktop/xdg-shell-v6.c
+++ b/libweston-desktop/xdg-shell-v6.c
@@ -95,6 +95,7 @@ struct weston_desktop_xdg_toplevel {
} pending;
struct {
struct weston_desktop_xdg_toplevel_state state;
+   struct weston_size size;
struct weston_size min_size, max_size;
} next;
struct {
@@ -424,6 +425,7 @@ static void
   weston_desktop_xdg_toplevel_ack_configure(struct weston_desktop_xdg_toplevel 
*toplevel)
   {
toplevel->next.state = toplevel->pending.state;
+   toplevel->next.size = toplevel->pending.size;
   }
   static void
@@ -626,8 +628,8 @@ weston_desktop_xdg_toplevel_committed(struct 
weston_desktop_xdg_toplevel *toplev
return;
if ((toplevel->next.state.maximized || toplevel->next.state.fullscreen) 
&&
-   (toplevel->pending.size.width != wsurface->width ||
-toplevel->pending.size.height != wsurface->height)) {
+   (toplevel->next.size.width != wsurface->width ||
+toplevel->next.size.height != wsurface->height)) {


Unrelated to this patch, but wsurface->width/height should rather be the
geometry, not the size, because IIRC the surface size comes from the
buffer or wp_viewporter, while the next.size.width/height is window
geometry size. We only enforce the window geometry.


True, just need to make sure we update the geometry before calling the
sub-type function.



Shouldn't we also compare the serial here? If I understand things
correctly, "next" is the state+size the last time a client
ack_configure:ed a serial without any more pending one on the way. >
So if that next state is fullscreen+WxH from when the client acked that
at some point in time, then we quickly went toplevel->fullscreen but
fullscreen on another output. In the intermediate state, the client acks
the old configure, thus we won't update next, end next will still be
fullscreen+WxH, while the surface size will be wxh (w != W, h != H).

Maybe could be fixed by adding the serial to the next and pending
structsand only enforce if the next (that is being committed) state is
the pending one.


I see two separate issues here:

1. We only consider the last configure.
I plan to fix that by keeping a list of configure states, dropping older
states until the acked one. That would fix a number of racy scenarii, not
just this one.

2. The shell/compositor cannot know which (fullscreen) output is being
associated with a commit.
This may be tricky to get right, because there may be more than one. The
client can only ask for one output in set_fullscreen, but the compositor is
free to ignore that and have 2 views fullscreened on differently-sized
outputs.
I would wait until we have a real use case trigge

Re: [PATCH weston 3/3] libweston-desktop/xdg-shell: Check surface size against acknowledged size

2017-07-12 Thread Quentin Glidic

On 7/12/17 11:23 AM, Jonas Ådahl wrote:

On Wed, Jul 12, 2017 at 09:53:04AM +0200, Quentin Glidic wrote:

From: Quentin Glidic <sardemff7+...@sardemff7.net>

We were checking against the pending size, which lead some clients
(simple-egl) to crash because they sent a buffer before acknowledging
the latest configure event.

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
  libweston-desktop/xdg-shell-v5.c | 6 --
  libweston-desktop/xdg-shell-v6.c | 6 --
  2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/libweston-desktop/xdg-shell-v5.c b/libweston-desktop/xdg-shell-v5.c
index 0fb067ab..b32b7812 100644
--- a/libweston-desktop/xdg-shell-v5.c
+++ b/libweston-desktop/xdg-shell-v5.c
@@ -60,6 +60,7 @@ struct weston_desktop_xdg_surface {
} pending;
struct {
struct weston_desktop_xdg_surface_state state;
+   struct weston_size size;
} next;
struct {
struct weston_desktop_xdg_surface_state state;
@@ -244,8 +245,8 @@ weston_desktop_xdg_surface_committed(struct 
weston_desktop_surface *dsurface,
bool reconfigure = false;
  
  	if (surface->next.state.maximized || surface->next.state.fullscreen)

-   reconfigure = surface->pending.size.width != wsurface->width ||
- surface->pending.size.height != wsurface->height;
+   reconfigure = surface->next.size.width != wsurface->width ||
+ surface->next.size.height != wsurface->height;
  
  	if (reconfigure) {

weston_desktop_xdg_surface_schedule_configure(surface, true);
@@ -447,6 +448,7 @@ weston_desktop_xdg_surface_protocol_ack_configure(struct 
wl_client *wl_client,
return;
  
  	surface->next.state = surface->pending.state;

+   surface->next.size = surface->pending.size;
  }
  
  static void

diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c
index db894d4a..f5e46daa 100644
--- a/libweston-desktop/xdg-shell-v6.c
+++ b/libweston-desktop/xdg-shell-v6.c
@@ -95,6 +95,7 @@ struct weston_desktop_xdg_toplevel {
} pending;
struct {
struct weston_desktop_xdg_toplevel_state state;
+   struct weston_size size;
struct weston_size min_size, max_size;
} next;
struct {
@@ -424,6 +425,7 @@ static void
  weston_desktop_xdg_toplevel_ack_configure(struct weston_desktop_xdg_toplevel 
*toplevel)
  {
toplevel->next.state = toplevel->pending.state;
+   toplevel->next.size = toplevel->pending.size;
  }
  
  static void

@@ -626,8 +628,8 @@ weston_desktop_xdg_toplevel_committed(struct 
weston_desktop_xdg_toplevel *toplev
return;
  
  	if ((toplevel->next.state.maximized || toplevel->next.state.fullscreen) &&

-   (toplevel->pending.size.width != wsurface->width ||
-toplevel->pending.size.height != wsurface->height)) {
+   (toplevel->next.size.width != wsurface->width ||
+toplevel->next.size.height != wsurface->height)) {


Unrelated to this patch, but wsurface->width/height should rather be the
geometry, not the size, because IIRC the surface size comes from the
buffer or wp_viewporter, while the next.size.width/height is window
geometry size. We only enforce the window geometry.


True, just need to make sure we update the geometry before calling the 
sub-type function.




Shouldn't we also compare the serial here? If I understand things
correctly, "next" is the state+size the last time a client
ack_configure:ed a serial without any more pending one on the way. >
So if that next state is fullscreen+WxH from when the client acked that
at some point in time, then we quickly went toplevel->fullscreen but
fullscreen on another output. In the intermediate state, the client acks
the old configure, thus we won't update next, end next will still be
fullscreen+WxH, while the surface size will be wxh (w != W, h != H).

Maybe could be fixed by adding the serial to the next and pending
structsand only enforce if the next (that is being committed) state is
the pending one.


I see two separate issues here:

1. We only consider the last configure.
I plan to fix that by keeping a list of configure states, dropping older 
states until the acked one. That would fix a number of racy scenarii, 
not just this one.


2. The shell/compositor cannot know which (fullscreen) output is being 
associated with a commit.
This may be tricky to get right, because there may be more than one. The 
client can only ask for one output in set_fullscreen, but the compositor 
is free to ignore that and have 2 views fullscreened on 
differently-sized outputs.
I would wait until we have a real use case triggering that issue. Most 
clients should answer in a timely fashion to avoid that.


This patch just fix

[PATCH weston 1/3] libweston-desktop/xdg-shell: Rename requested_ to pending_

2017-07-12 Thread Quentin Glidic
From: Quentin Glidic <sardemff7+...@sardemff7.net>

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
 libweston-desktop/xdg-shell-v5.c | 56 +++---
 libweston-desktop/xdg-shell-v6.c | 58 
 2 files changed, 57 insertions(+), 57 deletions(-)

diff --git a/libweston-desktop/xdg-shell-v5.c b/libweston-desktop/xdg-shell-v5.c
index 1ec796e1..161a4891 100644
--- a/libweston-desktop/xdg-shell-v5.c
+++ b/libweston-desktop/xdg-shell-v5.c
@@ -47,13 +47,13 @@ struct weston_desktop_xdg_surface {
struct wl_event_source *add_idle;
struct wl_event_source *configure_idle;
uint32_t configure_serial;
-   struct weston_size requested_size;
+   struct weston_size pending_size;
struct {
bool maximized;
bool fullscreen;
bool resizing;
bool activated;
-   } requested_state, next_state, state;
+   } pending_state, next_state, state;
bool has_next_geometry;
struct weston_geometry next_geometry;
 };
@@ -92,26 +92,26 @@ weston_desktop_xdg_surface_send_configure(void *data)

wl_display_next_serial(weston_desktop_get_display(surface->desktop));
 
wl_array_init();
-   if (surface->requested_state.maximized) {
+   if (surface->pending_state.maximized) {
s = wl_array_add(, sizeof(uint32_t));
*s = XDG_SURFACE_STATE_MAXIMIZED;
}
-   if (surface->requested_state.fullscreen) {
+   if (surface->pending_state.fullscreen) {
s = wl_array_add(, sizeof(uint32_t));
*s = XDG_SURFACE_STATE_FULLSCREEN;
}
-   if (surface->requested_state.resizing) {
+   if (surface->pending_state.resizing) {
s = wl_array_add(, sizeof(uint32_t));
*s = XDG_SURFACE_STATE_RESIZING;
}
-   if (surface->requested_state.activated) {
+   if (surface->pending_state.activated) {
s = wl_array_add(, sizeof(uint32_t));
*s = XDG_SURFACE_STATE_ACTIVATED;
}
 
xdg_surface_send_configure(surface->resource,
-  surface->requested_size.width,
-  surface->requested_size.height,
+  surface->pending_size.width,
+  surface->pending_size.height,
   ,
   surface->configure_serial);
 
@@ -124,21 +124,21 @@ weston_desktop_xdg_surface_state_compare(struct 
weston_desktop_xdg_surface *surf
struct weston_surface *wsurface =
weston_desktop_surface_get_surface(surface->surface);
 
-   if (surface->requested_state.activated != surface->state.activated)
+   if (surface->pending_state.activated != surface->state.activated)
return false;
-   if (surface->requested_state.fullscreen != surface->state.fullscreen)
+   if (surface->pending_state.fullscreen != surface->state.fullscreen)
return false;
-   if (surface->requested_state.maximized != surface->state.maximized)
+   if (surface->pending_state.maximized != surface->state.maximized)
return false;
-   if (surface->requested_state.resizing != surface->state.resizing)
+   if (surface->pending_state.resizing != surface->state.resizing)
return false;
 
-   if (wsurface->width == surface->requested_size.width &&
-   wsurface->height == surface->requested_size.height)
+   if (wsurface->width == surface->pending_size.width &&
+   wsurface->height == surface->pending_size.height)
return true;
 
-   if (surface->requested_size.width == 0 &&
-   surface->requested_size.height == 0)
+   if (surface->pending_size.width == 0 &&
+   surface->pending_size.height == 0)
return true;
 
return false;
@@ -150,17 +150,17 @@ weston_desktop_xdg_surface_schedule_configure(struct 
weston_desktop_xdg_surface
 {
struct wl_display *display = 
weston_desktop_get_display(surface->desktop);
struct wl_event_loop *loop = wl_display_get_event_loop(display);
-   bool requested_same =
+   bool pending_same =
!force && weston_desktop_xdg_surface_state_compare(surface);
 
if (surface->configure_idle != NULL) {
-   if (!requested_same)
+   if (!pending_same)
return;
 
wl_event_source_remove(surface->configure_idle);
surface->configure_idle = NULL;
} else {
-   if (requested_same)
+   if (pending_same)

[PATCH weston 2/3] libweston-desktop/xdg-shell: Add pending/next/current structs

2017-07-12 Thread Quentin Glidic
From: Quentin Glidic <sardemff7+...@sardemff7.net>

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
 libweston-desktop/xdg-shell-v5.c | 80 ++---
 libweston-desktop/xdg-shell-v6.c | 97 ++--
 2 files changed, 98 insertions(+), 79 deletions(-)

diff --git a/libweston-desktop/xdg-shell-v5.c b/libweston-desktop/xdg-shell-v5.c
index 161a4891..0fb067ab 100644
--- a/libweston-desktop/xdg-shell-v5.c
+++ b/libweston-desktop/xdg-shell-v5.c
@@ -39,6 +39,13 @@
 
 #define WD_XDG_SHELL_PROTOCOL_VERSION 1
 
+struct weston_desktop_xdg_surface_state {
+   bool maximized;
+   bool fullscreen;
+   bool resizing;
+   bool activated;
+};
+
 struct weston_desktop_xdg_surface {
struct wl_resource *resource;
struct weston_desktop_surface *surface;
@@ -47,13 +54,16 @@ struct weston_desktop_xdg_surface {
struct wl_event_source *add_idle;
struct wl_event_source *configure_idle;
uint32_t configure_serial;
-   struct weston_size pending_size;
struct {
-   bool maximized;
-   bool fullscreen;
-   bool resizing;
-   bool activated;
-   } pending_state, next_state, state;
+   struct weston_desktop_xdg_surface_state state;
+   struct weston_size size;
+   } pending;
+   struct {
+   struct weston_desktop_xdg_surface_state state;
+   } next;
+   struct {
+   struct weston_desktop_xdg_surface_state state;
+   } current;
bool has_next_geometry;
struct weston_geometry next_geometry;
 };
@@ -92,26 +102,26 @@ weston_desktop_xdg_surface_send_configure(void *data)

wl_display_next_serial(weston_desktop_get_display(surface->desktop));
 
wl_array_init();
-   if (surface->pending_state.maximized) {
+   if (surface->pending.state.maximized) {
s = wl_array_add(, sizeof(uint32_t));
*s = XDG_SURFACE_STATE_MAXIMIZED;
}
-   if (surface->pending_state.fullscreen) {
+   if (surface->pending.state.fullscreen) {
s = wl_array_add(, sizeof(uint32_t));
*s = XDG_SURFACE_STATE_FULLSCREEN;
}
-   if (surface->pending_state.resizing) {
+   if (surface->pending.state.resizing) {
s = wl_array_add(, sizeof(uint32_t));
*s = XDG_SURFACE_STATE_RESIZING;
}
-   if (surface->pending_state.activated) {
+   if (surface->pending.state.activated) {
s = wl_array_add(, sizeof(uint32_t));
*s = XDG_SURFACE_STATE_ACTIVATED;
}
 
xdg_surface_send_configure(surface->resource,
-  surface->pending_size.width,
-  surface->pending_size.height,
+  surface->pending.size.width,
+  surface->pending.size.height,
   ,
   surface->configure_serial);
 
@@ -124,21 +134,21 @@ weston_desktop_xdg_surface_state_compare(struct 
weston_desktop_xdg_surface *surf
struct weston_surface *wsurface =
weston_desktop_surface_get_surface(surface->surface);
 
-   if (surface->pending_state.activated != surface->state.activated)
+   if (surface->pending.state.activated != 
surface->current.state.activated)
return false;
-   if (surface->pending_state.fullscreen != surface->state.fullscreen)
+   if (surface->pending.state.fullscreen != 
surface->current.state.fullscreen)
return false;
-   if (surface->pending_state.maximized != surface->state.maximized)
+   if (surface->pending.state.maximized != 
surface->current.state.maximized)
return false;
-   if (surface->pending_state.resizing != surface->state.resizing)
+   if (surface->pending.state.resizing != surface->current.state.resizing)
return false;
 
-   if (wsurface->width == surface->pending_size.width &&
-   wsurface->height == surface->pending_size.height)
+   if (wsurface->width == surface->pending.size.width &&
+   wsurface->height == surface->pending.size.height)
return true;
 
-   if (surface->pending_size.width == 0 &&
-   surface->pending_size.height == 0)
+   if (surface->pending.size.width == 0 &&
+   surface->pending.size.height == 0)
return true;
 
return false;
@@ -176,7 +186,7 @@ weston_desktop_xdg_surface_set_maximized(struct 
weston_desktop_surface *dsurface
 {
struct weston_desktop_xdg_surface *surface = user_data;
 
-   surface->pend

[PATCH weston 3/3] libweston-desktop/xdg-shell: Check surface size against acknowledged size

2017-07-12 Thread Quentin Glidic
From: Quentin Glidic <sardemff7+...@sardemff7.net>

We were checking against the pending size, which lead some clients
(simple-egl) to crash because they sent a buffer before acknowledging
the latest configure event.

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
 libweston-desktop/xdg-shell-v5.c | 6 --
 libweston-desktop/xdg-shell-v6.c | 6 --
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/libweston-desktop/xdg-shell-v5.c b/libweston-desktop/xdg-shell-v5.c
index 0fb067ab..b32b7812 100644
--- a/libweston-desktop/xdg-shell-v5.c
+++ b/libweston-desktop/xdg-shell-v5.c
@@ -60,6 +60,7 @@ struct weston_desktop_xdg_surface {
} pending;
struct {
struct weston_desktop_xdg_surface_state state;
+   struct weston_size size;
} next;
struct {
struct weston_desktop_xdg_surface_state state;
@@ -244,8 +245,8 @@ weston_desktop_xdg_surface_committed(struct 
weston_desktop_surface *dsurface,
bool reconfigure = false;
 
if (surface->next.state.maximized || surface->next.state.fullscreen)
-   reconfigure = surface->pending.size.width != wsurface->width ||
- surface->pending.size.height != wsurface->height;
+   reconfigure = surface->next.size.width != wsurface->width ||
+ surface->next.size.height != wsurface->height;
 
if (reconfigure) {
weston_desktop_xdg_surface_schedule_configure(surface, true);
@@ -447,6 +448,7 @@ weston_desktop_xdg_surface_protocol_ack_configure(struct 
wl_client *wl_client,
return;
 
surface->next.state = surface->pending.state;
+   surface->next.size = surface->pending.size;
 }
 
 static void
diff --git a/libweston-desktop/xdg-shell-v6.c b/libweston-desktop/xdg-shell-v6.c
index db894d4a..f5e46daa 100644
--- a/libweston-desktop/xdg-shell-v6.c
+++ b/libweston-desktop/xdg-shell-v6.c
@@ -95,6 +95,7 @@ struct weston_desktop_xdg_toplevel {
} pending;
struct {
struct weston_desktop_xdg_toplevel_state state;
+   struct weston_size size;
struct weston_size min_size, max_size;
} next;
struct {
@@ -424,6 +425,7 @@ static void
 weston_desktop_xdg_toplevel_ack_configure(struct weston_desktop_xdg_toplevel 
*toplevel)
 {
toplevel->next.state = toplevel->pending.state;
+   toplevel->next.size = toplevel->pending.size;
 }
 
 static void
@@ -626,8 +628,8 @@ weston_desktop_xdg_toplevel_committed(struct 
weston_desktop_xdg_toplevel *toplev
return;
 
if ((toplevel->next.state.maximized || toplevel->next.state.fullscreen) 
&&
-   (toplevel->pending.size.width != wsurface->width ||
-toplevel->pending.size.height != wsurface->height)) {
+   (toplevel->next.size.width != wsurface->width ||
+toplevel->next.size.height != wsurface->height)) {
struct weston_desktop_client *client =

weston_desktop_surface_get_client(toplevel->base.desktop_surface);
struct wl_resource *client_resource =
-- 
2.13.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston] libweston-desktop/xdg-shell: Consolidate configure event sending

2017-06-25 Thread Quentin Glidic

On 6/23/17 1:11 PM, Daniel Stone wrote:

Hi Quentin,

On 13 April 2017 at 20:15, Quentin Glidic
<sardemff7+wayl...@sardemff7.net> wrote:

When switching a state twice in a row, we were overwriting the old value
without setting it back, sending a wrong state to the client.

Now we update our requested state, then check if we need to schedule a
configure event, if we have one scheduled already or even if we can
cancel it.


Most of this looks fine, but:


  static void
-weston_desktop_xdg_surface_schedule_configure(struct 
weston_desktop_xdg_surface *surface)
+weston_desktop_xdg_surface_schedule_configure(struct 
weston_desktop_xdg_surface *surface,
+ bool force)
  {
 struct wl_display *display = 
weston_desktop_get_display(surface->desktop);
 struct wl_event_loop *loop = wl_display_get_event_loop(display);
+   bool requested_same = !force;

-   if (surface->configure_idle != NULL)
-   return;
-   surface->configure_idle =
-   wl_event_loop_add_idle(loop,
-  
weston_desktop_xdg_surface_send_configure,
-  surface);
+   switch (surface->role) {
+   case WESTON_DESKTOP_XDG_SURFACE_ROLE_NONE:
+   assert(0 && "not reached");
+   break;
+   case WESTON_DESKTOP_XDG_SURFACE_ROLE_TOPLEVEL:
+   requested_same = requested_same &&
+   weston_desktop_xdg_toplevel_state_compare((struct 
weston_desktop_xdg_toplevel *) surface);
+   break;
+   case WESTON_DESKTOP_XDG_SURFACE_ROLE_POPUP:
+   break;
+   }
+
+   if (surface->configure_idle != NULL) {
+   if (!requested_same)
+   return;
+
+   wl_event_source_remove(surface->configure_idle);
+   surface->configure_idle = NULL;
+   } else {
+   if (requested_same)
+   return;


So, we'll never send a configure event for popups, unless force is
true. Was this intended / is this OK? If so, then:
Reviewed-by: Daniel Stone <dani...@collabora.com>


It is intended, as we never call it with false for popups.

Pushed:
c84423ba..d51f826c  master -> master

Thanks,

--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston] libweston-desktop/xdg_shell_v6: Send error on wrongly-sized buffer

2017-06-25 Thread Quentin Glidic

On 6/23/17 12:59 PM, Daniel Stone wrote:

Hi Quentin,

On 10 March 2017 at 10:50, Quentin Glidic
<sardemff7+wayl...@sardemff7.net> wrote:

@@ -634,22 +633,27 @@ weston_desktop_xdg_toplevel_committed(struct 
weston_desktop_xdg_toplevel *toplev
+   if ((toplevel->next_state.maximized || toplevel->next_state.fullscreen) 
&&
+   (toplevel->requested_size.width != wsurface->width ||
+toplevel->requested_size.height != wsurface->height)) {


This one did worry me a little bit, but after reading through and
seeing it was only for windows wishing to go maximised or fullscreen,
it's fine indeed. So:
Reviewed-by: Daniel Stone <dani...@collabora.com>


Pushed:
ee589119..c84423ba  master -> master

Thanks,

--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: libweston versions and tutorials

2017-05-31 Thread Quentin Glidic

On 5/31/17 2:37 PM, adlo wrote:

Is libweston 1.0 good enough for writing a compositor?


Yes, but each major version is adding or changing API to make it simpler 
to write a compositor. Specifically, libweston 2 has introduced a much 
nicer output API, thanks to Armin’s GSoC work.



Are there any tutorials or simple examples for writing a compositor 
using any version of libweston?


I think someone started something, but it’s probably outdated by now.

One advice I’d have to give is to use libweston-desktop, that abstract a 
lot of protocol stuff and just let you manage toplevel surfaces without 
worrying about shell protocols, popups and other boring things like 
that. :-)



Cheers,


--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: Return values in Wayland XML specification

2017-05-24 Thread Quentin Glidic

On 5/24/17 8:37 PM, adlo wrote:

On 24 May 2017, at 16:43, Quentin Glidic <sardemff7+wayl...@sardemff7.net> 
wrote:

There is no need, because the compositor is supposed to list only relevant 
surfaces.


What I would like to do is get the desktop window so that I can display a fake 
live image of the empty desktop as a background to my full-screen window 
switcher, so that I can imply that the windows have flown up and rearranged 
themselves on the window switcher, similar to GNOME Shell, but without the 3D 
effects or GL stuff.

At the moment I have something like this:

WnckWindow * lightdash_compositor_get_root_window (LightdashCompositor 
*compositor)
{
GList *li;

for (li = wnck_screen_get_windows (compositor->screen); li != NULL; li = 
li->next)
{
WnckWindow *win = WNCK_WINDOW (li->data);

if (wnck_window_get_window_type (win) == WNCK_WINDOW_DESKTOP)
{
return win;
}
}
return NULL;
}

How could I do this?


You don’t, the compositor does. If you need that, you ask the compositor 
to do it, because only the compositor knows the content of other 
clients’ surfaces.
That would require additions to the protocol. If you are interested, 
please file an issue on GitHub so we can discuss the details.


--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: Return values in Wayland XML specification

2017-05-24 Thread Quentin Glidic

On 5/24/17 5:41 PM, adlo wrote:

On 15 May 2017, at 10:52, Quentin Glidic <sardemff7+wayl...@sardemff7.net> 
wrote:

If you are writing/porting a window switcher, please consider using Wayland Wall window-switcher 
protocol[1]. If you are not, please don’t, as this protocol is very specific to switchers (it has 
"switch_to" and "close" requests).
If you need for more than this protocol offers, or something doesn’t fit your 
software, just fill an issue and we will discuss the possible designs.


Can your protocol get the type hint of a window? For example, can I find out if 
a window is a desktop, panel, or normal window, or whether it is skip tasklist, 
skip pager etc?


There is no need, because the compositor is supposed to list only 
relevant surfaces.



--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH][weston] configure.ac: Add --with-wayland-scanner-path

2017-05-23 Thread Quentin Glidic

On 5/23/17 1:21 PM, Jussi Kukkonen wrote:

Thanks for feedback,

Anything I didn't comment on I think I agree with -- the 
wayland-scanner.m4 proposal I'll have to consider but I'd like to be 
_really_ sure of what most wayland-scanner users want before going that way.


If we cannot find a way that works for everyone, then we failed at 
defining what wayland-scanner is and how it should be used.



Jussi


On 23 May 2017 at 11:56, Quentin Glidic <sardemff7+wayl...@sardemff7.net 
<mailto:sardemff7%2bwayl...@sardemff7.net>> wrote:

 >
 > On 5/23/17 10:05 AM, Jussi Kukkonen wrote:
 >>
 >> Modify wayland-scanner lookup: Use the path given by pkg-config
 >> but offer an option to override the path with
 >> "--with-wayland-scanner-path=PATH". The latter is useful for
 >> cross-compile situations.
 >
 >
 > I would rather use --with-wayland-scanner.

Name was chosen to match "--with-xserver-path" that already existed. 
"--with-wayland-scanner" works for me too.


Nevermind, let’s go with -path.



 >> AC_PATH_PROG is no longer used.
 >
 > I disagree with that, but you can at least make it work for 
cross-compiling (to an incompatible host) *without* the need to add 
--with-wayland-scanner-path in most cases.


If you take a look at the "Double-checking the correct way to find 
wayland-scanner" thread from last week (sorry, forgot to mention that in 
the patch), you'll see that my original proposal was based on 
AC_PATH_PROG. But pq had some comments:


| The obvious caveat of Weston style is that if you have wayland-scanner
| installed in your system, and you are building another version into a
| $prefix, you must set PATH to find things in $prefix or they will
| silently use the system version. This is problematic, because sometimes
| (rarely) the scanner changes and it is assumed that the scanner matches
| the libwayland you are building for. So, casual contributors can easily
| shoot their foot in Weston style, while in Mesa style they get the
| right one automatically - the one pkg-config is pointing to.

https://lists.freedesktop.org/archives/wayland-devel/2017-May/034136.html

So the idea was that looking in the path could accidentally lead one to 
find an installed wayland-scanner that does not match the libwayland 
we're trying to build against. So I tried to make the "casual case" 
always work safely even if it means the rest of us have to set a 
configure flag a little more often.


I read that, and I just disagree, no big deal. :-)
IMO, we must limit the extra flags to case that wouldn’t work otherwise. 
The simplest cross-compiling case (with correctly named tools and in 
system) must work without extra args.




 >> Also add a AC_SUBST-call (it seems previously the pkg-config value was
 >> never substituted into Makefiles).
 >
 > It was, AC_PATH_PROG() does call AC_SUBST().

Sure, AC_PATH_PROG() works. As I said, it's the value _from pkg-config_ 
(if wayland-scanner was not in path) that never makes it into Makefiles.


That’s not how m4 works.
AC_SUBST() is expanded at m4 time, so just having AC_PATH_PROG() will 
expand AC_SUBST() and thus, the pkg-config value *will* make it to 
Makefile just fine.




 >> My goal is to standardize wayland-scanner usage in a way that does
 >> not require patching when cross-compiling in Yocto. I'm sending a
 >> similar patch to mesa and will fix other projects if these two patches
 >> are well received.
 >>
 >> I did not check that wayland-scanner can actually run as pq suggested:
 >> I don't think that's typically a problem and the error on make should
 >> be fairly good in that case.
 >>
 >> Thanks,
 >>   Jussi
 >>
 >> configure.ac <http://configure.ac> | 19 ++-
 >>   1 file changed, 14 insertions(+), 5 deletions(-)
 >>
 >> diff --git a/configure.ac <http://configure.ac> b/configure.ac 
<http://configure.ac>

 >> index db757f20..e17135a9 100644
 >> --- a/configure.ac <http://configure.ac>
 >> +++ b/configure.ac <http://configure.ac>
 >> @@ -653,11 +653,20 @@ if test "x$enable_lcms" != "xno"; then
 >>   fi
 >>   AM_CONDITIONAL(HAVE_LCMS, [test "x$enable_lcms" = xyes])
 >>   -AC_PATH_PROG([wayland_scanner], [wayland-scanner])
 >> -if test x$wayland_scanner = x; then
 >> -   PKG_CHECK_MODULES(WAYLAND_SCANNER, [wayland-scanner])
 >> -   wayland_scanner=`$PKG_CONFIG --variable=wayland_scanner 
wayland-scanner`

 >> -fi
 >> +AC_ARG_WITH([wayland-scanner-path],
 >> +[AS_HELP_STRING([--with-wayland-scanner-path=PATH],
 >> +[Path to wayland-scanner (by default 
the path from
 >> + 'pkg-config --

Re: [PATCH weston v6 0/6] Implement screensaver/idle inhibition

2017-05-23 Thread Quentin Glidic

On 9/9/16 4:31 AM, Bryce Harrington wrote:

Updated to include review feedback from Quentin on the v5.  That
involves refinements to the destructor behavior, reorganizing patches a
bit, and noting that if the idle manager is destroyed by the client, the
individual inhibitor objects remain active.  The libweston-desktop API
is renamed from surface_drop_idle_inhibitor to just drop_idle_inhibitor.


I’ve been trying to make up my mind of this series for quite some time 
now, and I’m sad that we hit v6 and still not have something usable.


Let’s start with global patches comments:

1. I merged it because it was nice and standalone, so we can stop 
worrying about it.

2.
3. This one seems odd to me. It patches stuff added in 2, that would be 
better squashed directly. And the protocol handling code looks too 
different from what it usually is (e.g. emitting the signal in the 
destroy request, not in the resource destroy handler).
4. As I said in v5, this patch is wrong. It will not work if you add an 
inhibitor to a popup, it will just crash (didn’t test that, but I’m 
pretty confident).

5. Mostly good, except for the libweston-desktop stuff.
6. It should allow to test for popup inhibition, and subsurface too.


To get the implementation right, we first need to define what it should do.

The first question is: when is an inhibitor “active”? The answer from 
the protocol file is:
“If the surface is destroyed, unmapped, becomes occluded, loses 
visibility, or otherwise becomes not visually relevant for the user, the 
idle inhibitor will not be honored by the compositor”
This means only visibility is taken into account. The shell has no 
checks to add to the inhibitor.


In libweston, this effectively means we can just check the 
weston_surface and ignore role-specific structures.

So all the *inhibitor* related code should be hidden in libweston.


Now, we want the compositor (the shell in weston’s case) to drive the 
fade in/out animation.


That means we need the shell to know when an *output* is being inhibited 
or not. Not individual surfaces.




I suggest a few things for the next round.
First, implement the client directly, this way we can merge it quickly 
to help other compositors to run tests. (And implement subsurface/popup 
testing.)


Then, reworking the output code to something like that (in pseudo-code):

output_set_on(output) {
  if output.compositor.inhibitor_handler != NULL
output.compositor.inhibitor_handler(output, ON)
  else
output.set_dpms(ON)
}

output_set_off(output) {
  if output.inhibited || output.compositor.idle
return

  if output.compositor.inhibitor_handler != NULL
output.compositor.inhibitor_handler(output, OFF)
  else
output.set_dpms(OFF)
}

idle_handler(compositor) {
  for output in compositor.outputs {
if compositor.idle
  output_set_off(output)
else
  output_set_on(output)
  }
}

output_check_inhibit(output) {
  was_inhibited = output.inhibited
  output.inhibited = false
  for v in output.views {
if v.surface.inhibit {
  output.inhibited = true
  break
}
  }
  if was_inhibited
output_set_off(output)
}

protocol_create_inhibitor(surface) {
  surface.inhibit = true
  for v in surface.views {
output_check_inhibit(v.output)
  }
}

protocol_destroy_inhibitor(surface) {
  surface.inhibit = false
  for v in surface.views {
output_check_inhibit(v.output)
  }
}

The shell/compositor would set the compositor.inhibitor_handler to drive 
fade in/out.

Does that seem sensible to you?

Cheers,

--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH] configure.ac: use AC_HEADER_MAJOR to detect major()/minor()

2017-05-23 Thread Quentin Glidic

On 3/13/17 11:40 AM, Sergei Trofimovich wrote:

Before the change build failed on Gentoo as:

   libweston/weston_launch-weston-launch.o: In function `handle_open':
   weston/libweston/weston-launch.c:363: undefined reference to `major'
   weston/libweston/weston-launch.c:365: undefined reference to `major'
   weston/libweston/weston-launch.c:325: undefined reference to `major'
   weston/libweston/weston-launch.c:326: undefined reference to `major'
   libweston/weston_launch-weston-launch.o: In function `setup_tty':
   weston/libweston/weston-launch.c:548: undefined reference to `major'
   weston/libweston/weston-launch.c:548: undefined reference to `minor'
   weston/libweston/weston-launch.c:555: undefined reference to `major'
   weston/libweston/weston-launch.c:558: undefined reference to `minor'
   libweston/weston_launch-weston-launch.o: In function `close_input_fds':
   weston/libweston/weston-launch.c:451: undefined reference to `major'

glibc plans to remove  from glibc's :
 https://sourceware.org/ml/libc-alpha/2015-11/msg00253.html

Gentoo already applied glibc patch to experimental glibc-2.24
to start preparingfor the change.

Autoconf has AC_HEADER_MAJOR to find out which header defines
reqiured macros:
 
https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Particular-Headers.html

This change should also increase portability across other libcs.

Bug: https://bugs.gentoo.org/610652
Signed-off-by: Sergei Trofimovich 


We added sys/sysmacros.h includes in 
c4d7f66c12853b9575366dd9f4a7960ec5694934.

This patch is still relevant, but needs rebasing.

Also, please move the #ifdef and #include where we currently have the 
sysmacros.h #include. And no "#include" indentation.


Thanks,



---
  configure.ac   | 1 +
  libweston/launcher-direct.c| 8 
  libweston/launcher-logind.c| 8 
  libweston/launcher-weston-launch.c | 7 +++
  libweston/weston-launch.c  | 8 
  5 files changed, 32 insertions(+)

diff --git a/configure.ac b/configure.ac
index 9df85d20..b99e7fdd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,6 +34,7 @@ AC_CONFIG_MACRO_DIR([m4])
  
  AC_USE_SYSTEM_EXTENSIONS

  AC_SYS_LARGEFILE
+AC_HEADER_MAJOR
  
  AM_INIT_AUTOMAKE([1.11 parallel-tests foreign no-dist-gzip dist-xz color-tests subdir-objects])
  
diff --git a/libweston/launcher-direct.c b/libweston/launcher-direct.c

index 4195cf65..16bac5f4 100644
--- a/libweston/launcher-direct.c
+++ b/libweston/launcher-direct.c
@@ -46,6 +46,14 @@
  #define KDSKBMUTE 0x4B51
  #endif
  
+/* major()/minor() */

+#ifdef MAJOR_IN_MKDEV
+#include 
+#endif
+#ifdef MAJOR_IN_SYSMACROS
+#include 
+#endif
+
  #ifdef HAVE_LIBDRM
  
  #include 

diff --git a/libweston/launcher-logind.c b/libweston/launcher-logind.c
index 8de1ed11..663cff28 100644
--- a/libweston/launcher-logind.c
+++ b/libweston/launcher-logind.c
@@ -44,6 +44,14 @@
  
  #define DRM_MAJOR 226
  
+/* major()/minor() */

+#ifdef MAJOR_IN_MKDEV
+#include 
+#endif
+#ifdef MAJOR_IN_SYSMACROS
+#include 
+#endif
+
  struct launcher_logind {
struct weston_launcher base;
struct weston_compositor *compositor;
diff --git a/libweston/launcher-weston-launch.c 
b/libweston/launcher-weston-launch.c
index 930f4e0c..3f7dde50 100644
--- a/libweston/launcher-weston-launch.c
+++ b/libweston/launcher-weston-launch.c
@@ -74,6 +74,13 @@ drmSetMaster(int drm_fd)
  
  #endif
  
+/* major()/minor() */

+#ifdef MAJOR_IN_MKDEV
+#include 
+#endif
+#ifdef MAJOR_IN_SYSMACROS
+#include 
+#endif
  
  union cmsg_data { unsigned char b[4]; int fd; };
  
diff --git a/libweston/weston-launch.c b/libweston/weston-launch.c

index 140fde1d..5fe0c4a9 100644
--- a/libweston/weston-launch.c
+++ b/libweston/weston-launch.c
@@ -92,6 +92,14 @@ drmSetMaster(int drm_fd)
  
  #endif
  
+/* major()/minor() */

+#ifdef MAJOR_IN_MKDEV
+#include 
+#endif
+#ifdef MAJOR_IN_SYSMACROS
+#include 
+#endif
+
  struct weston_launch {
struct pam_conv pc;
pam_handle_t *ph;




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston v3] xwm: Add icon support to the frame

2017-05-23 Thread Quentin Glidic
gt;icon_surface)
+   cairo_surface_destroy(window->icon_surface);


Do we want to destroy here?



+   window->icon_surface =
+   cairo_image_surface_create_for_data((unsigned char *)data,
+   CAIRO_FORMAT_ARGB32,
+   width, height, width * 4);
+
+   /* Bail out in case anything wrong happened during surface creation. */
+   if (cairo_surface_status(window->icon_surface) != CAIRO_STATUS_SUCCESS) 
{
+   cairo_surface_destroy(window->icon_surface);
+   window->icon_surface = NULL;
+   }


If we wait until success to replace the icon, we could keep a good 
(though outdated) icon if we failed to import the new one.


With the uint32_t fix and that shifted around:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>


As a side thought, we probably want to handle net_wm_icon_name at some 
point, but it requires XDG icon theme code (I think?) and that would 
rather be in the compositor code (so it can share caching and stuff).



Thanks,


+}
+
+static void
  weston_wm_handle_property_notify(struct weston_wm *wm, xcb_generic_event_t 
*event)
  {
xcb_property_notify_event_t *property_notify =
@@ -1290,6 +1337,16 @@ weston_wm_handle_property_notify(struct weston_wm *wm, 
xcb_generic_event_t *even
read_and_dump_property(wm, property_notify->window,
   property_notify->atom);
  
+	if (property_notify->atom == wm->atom.net_wm_icon) {

+   if (property_notify->state != XCB_PROPERTY_DELETE) {
+   weston_wm_handle_icon(wm, window);
+   } else {
+   cairo_surface_destroy(window->icon_surface);
+   window->icon_surface = NULL;
+   }
+   weston_wm_window_schedule_repaint(window);
+   }
+
if (property_notify->atom == wm->atom.net_wm_name ||
property_notify->atom == XCB_ATOM_WM_NAME)
weston_wm_window_schedule_repaint(window);




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH] weston fbdev: Instead of less than 1 Hz use default refresh rate

2017-05-23 Thread Quentin Glidic

On 4/17/17 1:11 PM, Oliver Smith wrote:

I ran Weston on a Nexus 4 mobile phone, with a native GNU/Linux userland,
and the latest Android kernel for that device from LineageOS [1].

calculate_refresh_rate() returned 1 (mHz), which gets rounded to 0 Hz later
and results in nothing being drawn to the screen.

This patch makes sure, that there is at least a refresh rate of 1 Hz, because
it returns the default refresh rate of 60 Hz otherwise.

[1]: https://github.com/LineageOS/lge-kernel-mako

Signed-off-by: Oliver Smith <ollieparan...@bitmessage.ch>


We’ll just pretend I know what I’m doing:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

And pushed:
47bbdc72..a5066e00  master -> master

Thanks,



---
  libweston/compositor-fbdev.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libweston/compositor-fbdev.c b/libweston/compositor-fbdev.c
index 32d71e0..e80a504 100644
--- a/libweston/compositor-fbdev.c
+++ b/libweston/compositor-fbdev.c
@@ -253,7 +253,8 @@ calculate_refresh_rate(struct fb_var_screeninfo *vinfo)
if (refresh_rate > 20)
refresh_rate = 20; /* cap at 200 Hz */
  
-		return refresh_rate;

+   if (refresh_rate >= 1000) /* at least 1 Hz */
+   return refresh_rate;
}
  
  	return 60 * 1000; /* default to 60 Hz */





--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH v2] weston: Add support for "--foo bar" style options

2017-05-23 Thread Quentin Glidic

On 5/8/17 6:47 PM, Lyude wrote:

A little earlier today I ended up spending a lot of time trying to
figure out why weston wasn't managing to launch over SSH and telling me
that I did not have a --tty option specified, despite me passing the
option strings ["--tty", "3"]. Turns out weston just doesn't support
that.

So, add support for this kind of format in addition to "--foo=bar" to
save others from making the same mistake I did.

Changes since v1:
  - Add comment about unreachable boolean check in long_option_with_arg()
  - Convert boolean check in long_option_with_arg() to assert

Signed-off-by: Lyude <ly...@redhat.com>
Reviewed-by: Eric Engestrom <e...@engestrom.ch>


Nice one, I had one a lng time ago but never really rebased it:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

Changed the style a tiny bit (line wrapping) and pushed:
dbfd248d..47bbdc72  master -> master

Thanks,



---
  shared/option-parser.c | 30 ++
  1 file changed, 30 insertions(+)

diff --git a/shared/option-parser.c b/shared/option-parser.c
index eee7546..831bd56 100644
--- a/shared/option-parser.c
+++ b/shared/option-parser.c
@@ -87,6 +87,30 @@ long_option(const struct weston_option *options, int count, 
char *arg)
  }
  
  static int

+long_option_with_arg(const struct weston_option *options, int count, char 
*arg, char *param)
+{
+   int k, len;
+
+   for (k = 0; k < count; k++) {
+   if (!options[k].name)
+   continue;
+
+   len = strlen(options[k].name);
+   if (strncmp(options[k].name, arg + 2, len) != 0)
+   continue;
+
+   /* Since long_option() should handle all booleans, we should
+* never reach this
+*/
+   assert(options[k].type != WESTON_OPTION_BOOLEAN);
+
+   return handle_option(options + k, param);
+   }
+
+   return 0;
+}
+
+static int
  short_option(const struct weston_option *options, int count, char *arg)
  {
int k;
@@ -148,6 +172,12 @@ parse_options(const struct weston_option *options,
if (long_option(options, count, argv[i]))
continue;
  
+/* ...also handle --foo bar */

+   if (i + 1 < *argc &&
+   long_option_with_arg(options, count, 
argv[i], argv[i+1])) {
+   i++;
+   continue;
+   }
} else {
/* Short option, e.g -f or -f42 */
if (short_option(options, count, argv[i]))




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH][weston] configure.ac: Add --with-wayland-scanner-path

2017-05-23 Thread Quentin Glidic

On 5/23/17 10:05 AM, Jussi Kukkonen wrote:

Modify wayland-scanner lookup: Use the path given by pkg-config
but offer an option to override the path with
"--with-wayland-scanner-path=PATH". The latter is useful for
cross-compile situations.


I would rather use --with-wayland-scanner.



AC_PATH_PROG is no longer used.


I disagree with that, but you can at least make it work for 
cross-compiling (to an incompatible host) *without* the need to add 
--with-wayland-scanner-path in most cases.




Also add a AC_SUBST-call (it seems previously the pkg-config value was
never substituted into Makefiles).


It was, AC_PATH_PROG() does call AC_SUBST().


---

My goal is to standardize wayland-scanner usage in a way that does
not require patching when cross-compiling in Yocto. I'm sending a
similar patch to mesa and will fix other projects if these two patches
are well received.

I did not check that wayland-scanner can actually run as pq suggested:
I don't think that's typically a problem and the error on make should
be fairly good in that case.

Thanks,
  Jussi

  configure.ac | 19 ++-
  1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index db757f20..e17135a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -653,11 +653,20 @@ if test "x$enable_lcms" != "xno"; then
  fi
  AM_CONDITIONAL(HAVE_LCMS, [test "x$enable_lcms" = xyes])
  
-AC_PATH_PROG([wayland_scanner], [wayland-scanner])

-if test x$wayland_scanner = x; then
-   PKG_CHECK_MODULES(WAYLAND_SCANNER, [wayland-scanner])
-   wayland_scanner=`$PKG_CONFIG --variable=wayland_scanner wayland-scanner`
-fi
+AC_ARG_WITH([wayland-scanner-path],
+[AS_HELP_STRING([--with-wayland-scanner-path=PATH],
+[Path to wayland-scanner (by default the path from
+ 'pkg-config --variable=wayland_scanner 
wayland-scanner'
+ is used)])],
+[wayland_scanner="$withval"],


Drop that [].


+[wayland_scanner="auto"])


And use "with_wayland_scanner=yes" here. Then, (see post-fi comment)



+if test x$wayland_scanner = xauto; then
+PKG_CHECK_MODULES([WAYLAND_SCANNER],
+  [wayland-scanner],
+  [wayland_scanner=`$PKG_CONFIG 
--variable=wayland_scanner wayland-scanner`],


Here, $PKG_CONFIG is wrong. Specifically in cross-compiling case, which 
is what your patch is supposed to fix.

Having a way to override the value is nice, but we already had.
Running "./configure 
ac_cv_path_wayland_scanner=/usr/yocto/bin/wayland-scanner" should work. 
Doing nothing works in most cases.


With this patch, you’re breaking cross-compilation to incompatible host 
in the default case, to add something you can already do.


At the very least, you should be using the *build* pkg-config, with 
something like that:

AC_CANONICAL_BUILD
AC_ARG_VAR([BUILD_PKG_CONFIG])
AC_PATH_PROGS([BUILD_PKG_CONFIG],
[${build}-pkg-config pkg-config], [${PKG_CONFIG}])
# We’re safe, ${PKG_CONFIG} is used elsewhere so it’s a good fallback
wayland_scanner=`${BUILD_PKG_CONFIG} --variable=wayland_scanner 
wayland-scanner`
# But using ${PKG_CONFIG} can lead to unusable executable here, we 
*must* check it works

wl_scanner_version=`${wayland_scanner} --version 2>/dev/null`
AS_IF([test "x$?" != "x0"], [AC_MSG_ERROR([${wayland_scanner} is not 
usable])])




+  [AC_MSG_ERROR([wayland-scanner was not found and 
--with-wayland-scanner-path was not used])])
+fi


Use AS_CASE, for "yes" (= "auto"), "no" (= error, to make 
--without-wayland-scanner fails) and "*" (= do nothing, consider the 
path is ok).




+AC_SUBST(wayland_scanner)


Adding a run test would be nice, indeed, but we should have a working value.


  AC_ARG_ENABLE(systemd_notify,
AS_HELP_STRING([--enable-systemd-notify],



I think this patch should be in Wayland, to wayland-scanner.m4 for other 
projects to use (they would depend on a recent Wayland for "make dist" 
and Git builds only, so the “extra dep” should be fine, one can always 
backport the .m4 to their tree if needed).

The proper macro name is WAYLAND_PROG_WAYLAND_SCANNER (or WL_PROG…).

A nice thing would be to check the version too.

Once we’ve figured out the proper algorithm to use, I’ll make a match to 
create a wayland module in Meson to do the same thing.


--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: Return values in Wayland XML specification

2017-05-19 Thread Quentin Glidic

On 5/19/17 4:57 PM, adlo wrote:

Do any compositors support this protocol?


Any compositor based on libweston and capable of loading weston plugins 
(and later libweston plugins), using Weston Wall[1].
The implementation is limited (no workspaces support) but that is 
something fixable in the future (I have a few ideas on how to solve that 
while still sharing most of the code).


It was drafted to start porting rofi. For now, no other switcher 
developer commented on it, so all I can do is use it because it works 
for rofi and have rofi users happy with it.



Cheers,


--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston] libweston-desktop/xwayland: Make sure racy surfaces are properly mapped

2017-05-15 Thread Quentin Glidic
From: Quentin Glidic <sardemff7+...@sardemff7.net>

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
 libweston-desktop/xwayland.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/libweston-desktop/xwayland.c b/libweston-desktop/xwayland.c
index 4f4b453f..4dcb5f03 100644
--- a/libweston-desktop/xwayland.c
+++ b/libweston-desktop/xwayland.c
@@ -61,6 +61,7 @@ struct weston_desktop_xwayland_surface {
const struct weston_xwayland_client_interface *client_interface;
struct weston_geometry next_geometry;
bool has_next_geometry;
+   bool committed;
bool added;
enum weston_desktop_xwayland_surface_state state;
 };
@@ -99,6 +100,14 @@ weston_desktop_xwayland_surface_change_state(struct 
weston_desktop_xwayland_surf
weston_desktop_api_surface_added(surface->desktop,
 surface->surface);
surface->added = true;
+   if (surface->state == NONE && surface->committed)
+   /* We had a race, and wl_surface.commit() was
+* faster, just fake a commit to map the
+* surface */
+   weston_desktop_api_committed(surface->desktop,
+surface->surface,
+0, 0);
+
} else if (surface->added) {
weston_desktop_api_surface_removed(surface->desktop,
   surface->surface);
@@ -134,6 +143,7 @@ weston_desktop_xwayland_surface_committed(struct 
weston_desktop_surface *dsurfac
struct weston_geometry oldgeom;
 
assert(dsurface == surface->surface);
+   surface->committed = true;
 
 #ifdef WM_DEBUG
weston_log("%s: xwayland surface %p\n", __func__, surface);
-- 
2.12.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: Return values in Wayland XML specification

2017-05-15 Thread Quentin Glidic

On 5/15/17 3:13 PM, adlo wrote:

On 15 May 2017, at 10:52, Quentin Glidic
<sardemff7+wayl...@sardemff7.net> wrote:

If you are writing/porting a window switcher, please consider using
Wayland Wall window-switcher protocol[1]. If you are not, please
don’t, as this protocol is very specific to switchers (it has
"switch_to" and "close" requests). If you need for more than this
protocol offers, or something doesn’t fit your software, just fill
an issue and we will discuss the possible designs.


Does your protocol have window thumbnails and damage events for these
thumbnails? How does your protocol compare to KDE's
org_kde_plasma_windowmanagement?


KDE protocol seems to be designed for window managers, not window
switchers. My protocol does allow to display thumbnails, but everything
is on the compositor side, the client just ask it to display them at a
specific position of its own surface.

I believe KDE’s protocol is too complex for simple compositors to use it 
easily.


Cheers,

--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: Return values in Wayland XML specification

2017-05-15 Thread Quentin Glidic

On 5/15/17 9:46 AM, Pekka Paalanen wrote:

On Mon, 15 May 2017 07:05:26 +0200
Wojciech Kluczka  wrote:


In Wayland array can contain only integers.


Hi,

not exactly. The data type inside an array is unspecified by the XML
language. You can use literally anything, it's just a binary blob with
a size, with some array-like helpers around.

The helpers are the ones that impose the most restrictions, which is
that each element in the "array" must be of the same size. But if you
never use wl_arrat_for_each(), even that is not strictly necessary.

Of course, one should use some common sense when defining (in
documentation!) what array contents are. Getting too creative with
array type arguments is probably not good.


See how listing of outputs is done. Server creates one global `wl_output`
per output, client binds to the global, server sends events with output
parameters (list of modes among them) and then event `done` to indicate it
stopped sending info about this output. You probably don't want one global
per window. I'd go with one global `window_manager` which sends events (one
per window) after bind and after creation of window (or on request,
depending on your needs).


Yes, that is a good design suggestion.

If the events are always sent only as a response to a request, then
there is no need for a 'done' event. The client can send the request
followed by wl_display.sync, and once the sync callback arrives, all
responses have been received.

But, if the server can spontaneously send a series of events, then you
probably need a 'done' for the client to know when the series is
complete again.

On Mon, 15 May 2017 04:05:43 +0100
adlo  wrote:


For example, getting a list of windows and returning it as an array.
How would this be done? How are arrays represented in Wayland XML?


The above is one design.

I would perhaps not use an array to list windows, because when you get
to around a thousand simultaneous windows maybe, it's possible you
cannot send the event anymore. There are limits to how big one message
can be.

You also need to update the window list over time, which is much better
done by sending events just for new and removed windows, rather than
sending the whole list every time.

Also, if you need to transmit meta-data for each window, it might be
useful to write a protocol interface for a window, and create a
protocol object to represent each window. When the meta-data changes,
the server can send an event on that protocol object rather than a
tuple { window id, attribute }.


If you are writing/porting a window switcher, please consider using 
Wayland Wall window-switcher protocol[1]. If you are not, please don’t, 
as this protocol is very specific to switchers (it has "switch_to" and 
"close" requests).
If you need for more than this protocol offers, or something doesn’t fit 
your software, just fill an issue and we will discuss the possible designs.


Cheers,


[1] 



--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH libinput 5/5] Add meson.build file

2017-04-30 Thread Quentin Glidic

On 4/26/17 4:20 AM, Peter Hutterer wrote:

Signed-off-by: Peter Hutterer 
---
  meson.build   | 596 ++
  meson_options.txt |  16 ++
  2 files changed, 612 insertions(+)
  create mode 100644 meson.build
  create mode 100644 meson_options.txt

diff --git a/meson.build b/meson.build
new file mode 100644
index 000..a6cbb81
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,596 @@
+project('libinput', 'c', 'cpp',
+   version : '1.7.0',
+   license: 'MIT/Expat',
+   default_options : [ 'c_std=gnu99' ],


As suggested by Jussi Pakkanen (Meson maintainer) you should use 
warning_level=2 here and …




[snip]
+cppflags = ['-Wall', '-Wextra', '-Wno-unused-parameter', '-g', 
'-fvisibility=hidden']


… drop -Wall and -Wextra here, as these are set by Meson.

-g too, for debug and debugoptimized build (default is debug).

Cheers,

--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH libinput 5/5] Add meson.build file

2017-04-26 Thread Quentin Glidic

On 4/26/17 4:20 AM, Peter Hutterer wrote:

Signed-off-by: Peter Hutterer 
---
  meson.build   | 596 ++
  meson_options.txt |  16 ++
  2 files changed, 612 insertions(+)
  create mode 100644 meson.build
  create mode 100644 meson_options.txt


I’m not reviewing the libinput aspect of this patch, only the Meson one.



diff --git a/meson.build b/meson.build
new file mode 100644
index 000..a6cbb81
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,596 @@
+project('libinput', 'c', 'cpp',
+   version : '1.7.0',
+   license: 'MIT/Expat',
+   default_options : [ 'c_std=gnu99' ],
+   meson_version : '>= 0.38.0')
+
+libinput_version = meson.project_version().split('.')
+
+# We use libtool-version numbers because it's easier to understand.


Actually it’s version-info, version-number is the equivalent to Meson 
so_version.




+# Before making a release, the libinput_so_*
+# numbers should be modified. The components are of the form C:R:A.
+# a) If binary compatibility has been broken (eg removed or changed interfaces)
+#change to C+1:0:0.
+# b) If interfaces have been changed or added, but binary compatibility has
+#been preserved, change to C+1:0:A+1
+# c) If the interface is the same as the previous version, change to C:R+1:A
+libinput_lt_c=22
+libinput_lt_r=2
+libinput_lt_a=12
+
+# convert to soname
+libinput_so_version = '@0@.@1@.@2@'.format((libinput_lt_c - libinput_lt_a),
+libinput_lt_a, libinput_lt_r)
+
+# Compiler setup
+cc = meson.get_compiler('c')
+cppflags = ['-Wall', '-Wextra', '-Wno-unused-parameter', '-g', 
'-fvisibility=hidden']
+cflags = cppflags + ['-Wmissing-prototypes', '-Wstrict-prototypes']
+add_global_arguments(cflags, language: 'c')
+add_global_arguments(cppflags, language: 'cpp')
+
+config_h = configuration_data()
+config_h.set('_GNU_SOURCE', '1')


This one is set already by the "std=gnu99" you have.



+code = '''
+#define _GNU_SOURCE
+#include 
+static_assert(1 == 1, "msg");
+'''
+if not cc.compiles(code,
+  name : 'static_assert check',
+  args : [ '-Werror' ])
+   config_h.set('static_assert(...)', '/* */')
There is cc.get_define('static_assert') (if static_assert is a #define, 
don’t know) in Meson 0.40.0.




+endif
+
+# Dependencies
+pkgconfig = import('pkgconfig')
+dep_udev = dependency('libudev')
+dep_mtdev = dependency('mtdev', version: '>= 1.1.0')
+dep_libevdev = dependency('libevdev', version: '>= 0.4')
+dep_lm = cc.find_library('m')
+dep_rt = cc.find_library('rt')


Both with required: false, since non-glibc doesn’t always require them?



+
+ libwacom configuration 
+
+if get_option('libwacom')
+   dep_libwacom = dependency('libwacom', version : '>= 0.20')
+
+   code = '''
+   #include 
+   int main(void) { libwacom_get_paired_device(NULL); }
+   '''
+   result = cc.links(code,
+ args : '-lwacom',


It has dep_libwacom already, it shouldn’t be needed?



+ name : 'libwacom_get_paired_device check',
+ dependencies : dep_libwacom)
+   if result
+   config_h.set('HAVE_LIBWACOM_GET_PAIRED_DEVICE', '1')


.set01('HAVE_LIBWACOM_GET_PAIRED_DEVICE', result)?
Or even .set('HAVE_LIBWACOM_GET_PAIRED_DEVICE', result) if you use 
#ifdef and not #if.




+   endif
+endif
+
+ udev bits 
+
+udev_dir = get_option('udev-dir')
+if udev_dir == ''
+   udev_dir = '@0@/lib/udev'.format(get_option('prefix'))


Here you should use:
join_paths(get_option('prefix'), get_option('libdir'), udev)
That’ll do exactly what you mean (join_paths() will drop the prefix if 
libdir is absolute).


As a side note, maybe could you simply defaults to:
dependency('udev').get_pkgconfig_variable('udevdir')



+endif
+udev_rules_dir = '@0@/rules.d'.format(udev_dir)
+udev_hwdb_dir = '@0@/hwdb.d'.format(udev_dir)


join_paths() is not a bad choice for these either, but not a big deal.



+executable('libinput-device-group',
+  'udev/libinput-device-group.c',
+  dependencies : [dep_udev, dep_libwacom],
+  include_directories : include_directories('src'),
+  install : true,
+  install_dir : udev_dir)
+executable('libinput-model-quirks',
+  'udev/libinput-model-quirks.c',
+  dependencies : dep_udev,
+  include_directories : include_directories('src'),
+  install : true,
+  install_dir : udev_dir)
+
+model_quirks = 'udev/90-libinput-model-quirks.hwdb'
+install_data(model_quirks,
+install_dir : udev_hwdb_dir)
+
+parse_hwdb_py = find_program('udev/parse_hwdb.py')
+test('parse-hwdb',
+ parse_hwdb_py,
+ args : ['@0@/@1@'.format(meson.source_root(), model_quirks)])


I think you can make model_quirks a files() and use .full_path() on it 
(didn’t test).




+udev_rules_config = 

Re: [PATCH weston 1/6 v7] desktop-shell: Enable per-output fade animations

2017-04-21 Thread Quentin Glidic

On 9/9/16 10:16 PM, Bryce Harrington wrote:

Instead of creating a single global fade surface across all outputs,
create a separate surface for each output.  This will permit
e.g. individual fades for each output (or blocking the fade-outs if
inhibiting idling as will come in a later patch.)

This also fixes a potential issue if on multihead layout spanning a
desktop wider than 8096 (or higher than 8096), the fade animation may
not completely cover all surfaces.

This assumes the output geometry doesn't change to become larger during
the course of the fade animation.

Signed-off-by: Bryce Harrington <br...@osg.samsung.com>
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>


Let’s start small and push this one for now:
2cd87fe8..9ad4de1f  master -> master

Thanks,


---
  desktop-shell/shell.c | 137 --
  desktop-shell/shell.h |  14 +++---
  2 files changed, 84 insertions(+), 67 deletions(-)

v7: Changed a couple returns to continues inside a loop
 Restored a log message that was accidentally dropped

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index a43c2e2..88a05f6 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -196,6 +196,9 @@ surface_rotate(struct shell_surface *surface, struct 
weston_pointer *pointer);
  static void
  shell_fade_startup(struct desktop_shell *shell);
  
+static void

+shell_fade(struct desktop_shell *shell, enum fade_type type);
+
  static struct shell_seat *
  get_shell_seat(struct weston_seat *seat);
  
@@ -2811,9 +2814,6 @@ static const struct weston_desktop_api shell_desktop_api = {

   * end of libweston-desktop *
   *  */
  static void
-shell_fade(struct desktop_shell *shell, enum fade_type type);
-
-static void
  configure_static_view(struct weston_view *ev, struct weston_layer *layer)
  {
struct weston_view *v, *next;
@@ -3796,16 +3796,16 @@ unlock(struct desktop_shell *shell)
  }
  
  static void

-shell_fade_done(struct weston_view_animation *animation, void *data)
+shell_fade_done_for_output(struct weston_view_animation *animation, void *data)
  {
-   struct desktop_shell *shell = data;
+   struct shell_output *shell_output = data;
+   struct desktop_shell *shell = shell_output->shell;
  
-	shell->fade.animation = NULL;

-
-   switch (shell->fade.type) {
+   shell_output->fade.animation = NULL;
+   switch (shell_output->fade.type) {
case FADE_IN:
-   weston_surface_destroy(shell->fade.view->surface);
-   shell->fade.view = NULL;
+   weston_surface_destroy(shell_output->fade.view->surface);
+   shell_output->fade.view = NULL;
break;
case FADE_OUT:
lock(shell);
@@ -3816,7 +3816,7 @@ shell_fade_done(struct weston_view_animation *animation, 
void *data)
  }
  
  static struct weston_view *

-shell_fade_create_surface(struct desktop_shell *shell)
+shell_fade_create_surface_for_output(struct desktop_shell *shell, struct 
shell_output *shell_output)
  {
struct weston_compositor *compositor = shell->compositor;
struct weston_surface *surface;
@@ -3832,8 +3832,8 @@ shell_fade_create_surface(struct desktop_shell *shell)
return NULL;
}
  
-	weston_surface_set_size(surface, 8192, 8192);

-   weston_view_set_position(view, 0, 0);
+   weston_surface_set_size(surface, shell_output->output->width, 
shell_output->output->height);
+   weston_view_set_position(view, shell_output->output->x, 
shell_output->output->y);
weston_surface_set_color(surface, 0.0, 0.0, 0.0, 1.0);
weston_layer_entry_insert(>fade_layer.view_list,
  >layer_link);
@@ -3848,6 +3848,7 @@ static void
  shell_fade(struct desktop_shell *shell, enum fade_type type)
  {
float tint;
+   struct shell_output *shell_output;
  
  	switch (type) {

case FADE_IN:
@@ -3861,32 +3862,35 @@ shell_fade(struct desktop_shell *shell, enum fade_type 
type)
return;
}
  
-	shell->fade.type = type;

+   /* Create a separate fade surface for each output */
+   wl_list_for_each(shell_output, >output_list, link) {
+   shell_output->fade.type = type;
  
-	if (shell->fade.view == NULL) {

-   shell->fade.view = shell_fade_create_surface(shell);
-   if (!shell->fade.view)
-   return;
+   if (shell_output->fade.view == NULL) {
+   shell_output->fade.view = 
shell_fade_create_surface_for_output(shell, shell_output);
+   if (!shell_output->fade.view)
+   continue;
  
-		shell->fade.view->alpha = 1.0 - tint;

-   weston_view_update_transform(shell->fade.view);
-   }
+   shel

[PATCH weston] libweston-desktop/xdg-shell: Consolidate configure event sending

2017-04-13 Thread Quentin Glidic
From: Quentin Glidic <sardemff7+...@sardemff7.net>

When switching a state twice in a row, we were overwriting the old value
without setting it back, sending a wrong state to the client.

Now we update our requested state, then check if we need to schedule a
configure event, if we have one scheduled already or even if we can
cancel it.

Signed-off-by: Quentin Glidic <sardemff7+...@sardemff7.net>
---
 libweston-desktop/xdg-shell-v5.c | 81 +
 libweston-desktop/xdg-shell-v6.c | 98 ++--
 2 files changed, 115 insertions(+), 64 deletions(-)

diff --git a/libweston-desktop/xdg-shell-v5.c b/libweston-desktop/xdg-shell-v5.c
index 08cf71ee..bec314ba 100644
--- a/libweston-desktop/xdg-shell-v5.c
+++ b/libweston-desktop/xdg-shell-v5.c
@@ -118,18 +118,56 @@ weston_desktop_xdg_surface_send_configure(void *data)
wl_array_release();
 };
 
+static bool
+weston_desktop_xdg_surface_state_compare(struct weston_desktop_xdg_surface 
*surface)
+{
+   struct weston_surface *wsurface =
+   weston_desktop_surface_get_surface(surface->surface);
+
+   if (surface->requested_state.activated != surface->state.activated)
+   return false;
+   if (surface->requested_state.fullscreen != surface->state.fullscreen)
+   return false;
+   if (surface->requested_state.maximized != surface->state.maximized)
+   return false;
+   if (surface->requested_state.resizing != surface->state.resizing)
+   return false;
+
+   if (wsurface->width == surface->requested_size.width &&
+   wsurface->height == surface->requested_size.height)
+   return true;
+
+   if (surface->requested_size.width == 0 &&
+   surface->requested_size.height == 0)
+   return true;
+
+   return true;
+}
+
 static void
-weston_desktop_xdg_surface_schedule_configure(struct 
weston_desktop_xdg_surface *surface)
+weston_desktop_xdg_surface_schedule_configure(struct 
weston_desktop_xdg_surface *surface,
+ bool force)
 {
struct wl_display *display = 
weston_desktop_get_display(surface->desktop);
struct wl_event_loop *loop = wl_display_get_event_loop(display);
+   bool requested_same =
+   !force && weston_desktop_xdg_surface_state_compare(surface);
 
-   if (surface->configure_idle != NULL)
-   return;
-   surface->configure_idle =
-   wl_event_loop_add_idle(loop,
-  
weston_desktop_xdg_surface_send_configure,
-  surface);
+   if (surface->configure_idle != NULL) {
+   if (!requested_same)
+   return;
+
+   wl_event_source_remove(surface->configure_idle);
+   surface->configure_idle = NULL;
+   } else {
+   if (requested_same)
+   return;
+
+   surface->configure_idle =
+   wl_event_loop_add_idle(loop,
+  
weston_desktop_xdg_surface_send_configure,
+  surface);
+   }
 }
 
 static void
@@ -138,11 +176,8 @@ weston_desktop_xdg_surface_set_maximized(struct 
weston_desktop_surface *dsurface
 {
struct weston_desktop_xdg_surface *surface = user_data;
 
-   if (surface->state.maximized == maximized)
-   return;
-
surface->requested_state.maximized = maximized;
-   weston_desktop_xdg_surface_schedule_configure(surface);
+   weston_desktop_xdg_surface_schedule_configure(surface, false);
 }
 
 static void
@@ -151,11 +186,8 @@ weston_desktop_xdg_surface_set_fullscreen(struct 
weston_desktop_surface *dsurfac
 {
struct weston_desktop_xdg_surface *surface = user_data;
 
-   if (surface->state.fullscreen == fullscreen)
-   return;
-
surface->requested_state.fullscreen = fullscreen;
-   weston_desktop_xdg_surface_schedule_configure(surface);
+   weston_desktop_xdg_surface_schedule_configure(surface, false);
 }
 
 static void
@@ -164,11 +196,8 @@ weston_desktop_xdg_surface_set_resizing(struct 
weston_desktop_surface *dsurface,
 {
struct weston_desktop_xdg_surface *surface = user_data;
 
-   if (surface->state.resizing == resizing)
-   return;
-
surface->requested_state.resizing = resizing;
-   weston_desktop_xdg_surface_schedule_configure(surface);
+   weston_desktop_xdg_surface_schedule_configure(surface, false);
 }
 
 static void
@@ -177,11 +206,8 @@ weston_desktop_xdg_surface_set_activated(struct 
weston_desktop_surface *dsurface
 {
struct weston_desktop_xdg_surface *surface = user_data;
 
-   if (surface->state.activated == activated)
-   

Re: [PATCH weston v2] desktop-shell: Position maximized surfaces on the correct output.

2017-04-06 Thread Quentin Glidic

On 4/4/17 7:49 PM, Emmanuel Gil Peyrot wrote:

During a maximize event, a surface was previously always put back to
the primary output after one frame on the correct output, while keeping
its size.  This was caused by the shell surface’s last_{width,height}
not being reset when it was either fullscreen or maximized, leading to
the unmaximize/maximize dance being done at each commit.

This was introduced in 8f9d90a84bb2888b074fea93c4a28778bc6439c6.

Changes since v1:
- Fix the actual issue instead of a symptom.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.pey...@collabora.com>


Nice fix:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

And pushed:
597dde5c..c3941794  master -> master

As said on IRC (and written in my TODO), these “was there a change” 
checks should eventually be in libweston-desktop, to conditionally call 
the committed callback.


Thanks,


---
  desktop-shell/shell.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index c9058795..6b1876d2 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -2545,9 +2545,6 @@ desktop_surface_committed(struct weston_desktop_surface 
*desktop_surface,
if (shsurf->resize_edges & WL_SHELL_SURFACE_RESIZE_TOP)
sy = shsurf->last_height - surface->height;
  
-		shsurf->last_width = surface->width;

-   shsurf->last_height = surface->height;
-
weston_view_to_global_float(shsurf->view, 0, 0, _x, 
_y);
weston_view_to_global_float(shsurf->view, sx, sy, _x, _y);
x = shsurf->view->geometry.x + to_x - from_x;
@@ -2556,6 +2553,9 @@ desktop_surface_committed(struct weston_desktop_surface 
*desktop_surface,
weston_view_set_position(shsurf->view, x, y);
}
  
+	shsurf->last_width = surface->width;

+   shsurf->last_height = surface->height;
+
/* XXX: would a fullscreen surface need the same handling? */
if (surface->output) {
wl_list_for_each(view, >views, surface_link)




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 3/3] build: make libdrm a hard build-time dependency

2017-04-06 Thread Quentin Glidic

On 4/6/17 2:09 PM, Pekka Paalanen wrote:

From: Pekka Paalanen <pekka.paala...@collabora.co.uk>

Libdrm provides headers that are useful even without libdrm.so itself,
particularly drm_fourcc.h. Therefore promote libdrm as a hard build-time
dependency of libweston core so that we can always rely on libdrm
headers.

This does not affect any runtime dependencies. Specifically, no runtime
dependency to libdrm.so is added in any build configuration.

Currently only gl-renderer is using drm_fourcc.h. Now we can drop the
GL_RENDERER check from configure.ac and just use LIBDRM_CFLAGS.

Signed-off-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>


Nice(ly documented) cleanup :-)
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

(Nitpick below, for the sake of nitpicking. ;-) )

Thanks,


---
  Makefile.am  |  2 +-
  configure.ac | 12 +---
  2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index ff927c1..8ecc90c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -324,7 +324,7 @@ gl_renderer_la_LIBADD = \
  gl_renderer_la_CFLAGS =   \
$(COMPOSITOR_CFLAGS)\
$(EGL_CFLAGS)   \
-   $(GL_RENDERER_CFLAGS)   \
+   $(LIBDRM_CFLAGS)\
$(AM_CFLAGS)
  gl_renderer_la_SOURCES =  \
libweston/gl-renderer.h \
diff --git a/configure.ac b/configure.ac
index 39c0531..2da3e05 100644
--- a/configure.ac
+++ b/configure.ac
@@ -105,6 +105,15 @@ AC_CHECK_HEADERS([execinfo.h])
  
  AC_CHECK_FUNCS([mkostemp strchrnul initgroups posix_fallocate])
  
+# check for libdrm as a build-time dependency only

+# libdrm 2.4.30 introduced drm_fourcc.h.
+PKG_CHECK_MODULES(LIBDRM, [libdrm >= 2.4.30], have_libdrm=yes, have_libdrm=no)
+AS_IF([test "x$have_libdrm" != "xyes"],
+  [AC_MSG_ERROR([libdrm is a hard build-time dependency for libweston core,
+ but a sufficient version was not found. However, libdrm
+ is not a runtime dependency unless you have features
+ enabled that require it.])])
+


FTR, as said on IRC, could have been

PKG_CHECK_MODULES(LIBDRM, [libdrm >= 2.4.30], [], [AC_MSG_ERROR([
libdrm is a hard build-time dependency for libweston core,
but a sufficient version was not found. However, libdrm
is not a runtime dependency unless you have features
enabled that require it.])])

or similar.


+
  COMPOSITOR_MODULES="wayland-server >= $WAYLAND_PREREQ_VERSION pixman-1 >= 
0.25.2"
  
  AC_CONFIG_FILES([doc/doxygen/tools.doxygen doc/doxygen/tooldev.doxygen])

@@ -133,7 +142,6 @@ if test x$enable_egl = xyes; then
AC_DEFINE([ENABLE_EGL], [1], [Build Weston with EGL support])
PKG_CHECK_MODULES(EGL, [egl glesv2])
  PKG_CHECK_MODULES([EGL_TESTS], [egl glesv2 wayland-client 
wayland-egl])
-   PKG_CHECK_MODULES([GL_RENDERER], [libdrm])
  fi
  
  AC_ARG_ENABLE(xkbcommon,

@@ -177,8 +185,6 @@ if test x$enable_xwayland = xyes; then
fi
  fi
  
-PKG_CHECK_MODULES(LIBDRM, [libdrm], have_libdrm=yes, have_libdrm=no)

-
  AC_ARG_ENABLE(x11-compositor, [  --enable-x11-compositor],,
  enable_x11_compositor=yes)
  AM_CONDITIONAL(ENABLE_X11_COMPOSITOR, test x$enable_x11_compositor = xyes)




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 2/3] build: do not link libdrm without DRM backend

2017-04-06 Thread Quentin Glidic

On 4/6/17 2:09 PM, Pekka Paalanen wrote:

From: Pekka Paalanen <pekka.paala...@collabora.co.uk>

The pkg-config test for LIBDRM is independent of whether the DRM backend
is enabled or not. Therefore it is possible to have libdrm available and
found, even though it is not needed.

Do not link libdrm.so into the launchers unless it is really needed,
that is, DRM compositor is built. Otherwise you end up with
fbdev-backend.so and weston-launch depending on libdrm.so.

Signed-off-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>


I would even have squashed this one to the first one, but both ways:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

Thanks,



---
  Makefile.am | 12 ++--
  1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 7ee613b..ff927c1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -219,7 +219,11 @@ libsession_helper_la_SOURCES = \
libweston/launcher-weston-launch.c  \
libweston/launcher-direct.c
  libsession_helper_la_CFLAGS = $(AM_CFLAGS) $(LIBDRM_CFLAGS) $(PIXMAN_CFLAGS) 
$(COMPOSITOR_CFLAGS)
-libsession_helper_la_LIBADD = libweston-@LIBWESTON_MAJOR@.la $(LIBDRM_LIBS)
+libsession_helper_la_LIBADD = libweston-@LIBWESTON_MAJOR@.la
+
+if ENABLE_DRM_COMPOSITOR
+libsession_helper_la_LIBADD += $(LIBDRM_LIBS)
+endif
  
  if ENABLE_DBUS

  if HAVE_SYSTEMD_LOGIN
@@ -252,7 +256,11 @@ weston_launch_CFLAGS=  \
$(PAM_CFLAGS)   \
$(SYSTEMD_LOGIN_CFLAGS) \
$(LIBDRM_CFLAGS)
-weston_launch_LDADD = $(PAM_LIBS) $(SYSTEMD_LOGIN_LIBS) $(LIBDRM_LIBS)
+weston_launch_LDADD = $(PAM_LIBS) $(SYSTEMD_LOGIN_LIBS)
+
+if ENABLE_DRM_COMPOSITOR
+weston_launch_LDADD += $(LIBDRM_LIBS)
+endif
  
  if ENABLE_SETUID_INSTALL

  install-exec-hook:




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 1/3] configure: replace HAVE_LIBDRM with BUILD_DRM_COMPOSITOR

2017-04-06 Thread Quentin Glidic

On 4/6/17 2:09 PM, Pekka Paalanen wrote:

From: Pekka Paalanen <pekka.paala...@collabora.co.uk>

HAVE_LIBDRM was used as a condition for the launcher infrastructure to
call libdrm.so functions. It was set by an independent test for libdrm,
which would silently continue if libdrm was not found. It was assumed
that if you enabled a feature that used libdrm at runtime, the test for
that feature would imply that HAVE_LIBDRM is also set. This was quite
subtle.

The only feature that actually uses libdrm.so at runtime is the DRM
backend. No other backend needs the libdrm calls in the launcher
infrastructure.

Therefore to simplify things, stop using HAVE_LIBDRM and use
BUILD_DRM_COMPOSITOR instead. If you enable the DRM compositor, you
automatically also get libdrm support in the launchers.

There are still things depending on LIBDRM_CFLAGS and LIBDRM_LIBS, so
the test cannot be removed completely.

Signed-off-by: Pekka Paalanen <pekka.paala...@collabora.co.uk>


It makes clear these are DRM-specific:
Reviewed-by: Quentin Glidic <sardemff7+...@sardemff7.net>

Thanks,


---
  configure.ac   | 3 +--
  libweston/launcher-direct.c| 2 +-
  libweston/launcher-weston-launch.c | 2 +-
  libweston/weston-launch.c  | 2 +-
  4 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6cc9f26..39c0531 100644
--- a/configure.ac
+++ b/configure.ac
@@ -177,8 +177,7 @@ if test x$enable_xwayland = xyes; then
fi
  fi
  
-PKG_CHECK_MODULES(LIBDRM, [libdrm],

-  [AC_DEFINE(HAVE_LIBDRM, 1, [Define if libdrm is available]) 
have_libdrm=yes], have_libdrm=no)
+PKG_CHECK_MODULES(LIBDRM, [libdrm], have_libdrm=yes, have_libdrm=no)
  
  AC_ARG_ENABLE(x11-compositor, [  --enable-x11-compositor],,

  enable_x11_compositor=yes)
diff --git a/libweston/launcher-direct.c b/libweston/launcher-direct.c
index 3d8f5f6..a5d3ee5 100644
--- a/libweston/launcher-direct.c
+++ b/libweston/launcher-direct.c
@@ -47,7 +47,7 @@
  #define KDSKBMUTE 0x4B51
  #endif
  
-#ifdef HAVE_LIBDRM

+#ifdef BUILD_DRM_COMPOSITOR
  
  #include 
  
diff --git a/libweston/launcher-weston-launch.c b/libweston/launcher-weston-launch.c

index a7535ce..97da18c 100644
--- a/libweston/launcher-weston-launch.c
+++ b/libweston/launcher-weston-launch.c
@@ -55,7 +55,7 @@
  #define KDSKBMUTE 0x4B51
  #endif
  
-#ifdef HAVE_LIBDRM

+#ifdef BUILD_DRM_COMPOSITOR
  
  #include 
  
diff --git a/libweston/weston-launch.c b/libweston/weston-launch.c

index eecb911..aa7e071 100644
--- a/libweston/weston-launch.c
+++ b/libweston/weston-launch.c
@@ -73,7 +73,7 @@
  
  #define MAX_ARGV_SIZE 256
  
-#ifdef HAVE_LIBDRM

+#ifdef BUILD_DRM_COMPOSITOR
  
  #include 
  




--

Quentin “Sardem FF7” Glidic
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


  1   2   3   4   5   6   >