[PATCH weston] compositor-wayland: Port to xdg-shell

2016-10-09 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 Makefile.am|   8 ++-
 libweston/compositor-wayland.c | 155 ++---
 2 files changed, 102 insertions(+), 61 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index c94c211..f75aa46 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -391,9 +391,11 @@ wayland_backend_la_CFLAGS =\
$(CAIRO_CFLAGS) \
$(WAYLAND_COMPOSITOR_CFLAGS)\
$(AM_CFLAGS)
-wayland_backend_la_SOURCES =   \
-   libweston/compositor-wayland.c  \
-   libweston/compositor-wayland.h  \
+wayland_backend_la_SOURCES =   \
+   libweston/compositor-wayland.c  \
+   libweston/compositor-wayland.h  \
+   protocol/xdg-shell-unstable-v6-protocol.c   \
+   protocol/xdg-shell-unstable-v6-client-protocol.h\
shared/helpers.h
 nodist_wayland_backend_la_SOURCES =\
protocol/fullscreen-shell-unstable-v1-protocol.c\
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 46fdde1..2c33daf 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -51,6 +51,7 @@
 #include "shared/os-compatibility.h"
 #include "shared/cairo-util.h"
 #include "fullscreen-shell-unstable-v1-client-protocol.h"
+#include "xdg-shell-unstable-v6-client-protocol.h"
 #include "presentation-time-server-protocol.h"
 #include "linux-dmabuf.h"
 #include "windowed-output-api.h"
@@ -65,7 +66,7 @@ struct wayland_backend {
struct wl_display *wl_display;
struct wl_registry *registry;
struct wl_compositor *compositor;
-   struct wl_shell *shell;
+   struct zxdg_shell_v6 *shell;
struct zwp_fullscreen_shell_v1 *fshell;
struct wl_shm *shm;
 
@@ -97,8 +98,10 @@ struct wayland_output {
struct wl_output *output;
uint32_t global_id;
 
-   struct wl_shell_surface *shell_surface;
+   struct zxdg_surface_v6 *xdg_surface;
+   struct zxdg_toplevel_v6 *xdg_toplevel;
int configure_width, configure_height;
+   bool wait_for_configure;
} parent;
 
int keyboard_count;
@@ -623,8 +626,11 @@ wayland_output_repaint_pixman(struct weston_output 
*output_base,
 static void
 wayland_backend_destroy_output_surface(struct wayland_output *output)
 {
-   if (output->parent.shell_surface)
-   wl_shell_surface_destroy(output->parent.shell_surface);
+   if (output->parent.xdg_toplevel)
+   zxdg_toplevel_v6_destroy(output->parent.xdg_toplevel);
+
+   if (output->parent.xdg_surface)
+   zxdg_surface_v6_destroy(output->parent.xdg_surface);
 
wl_surface_destroy(output->parent.surface);
 }
@@ -677,8 +683,6 @@ wayland_output_destroy(struct weston_output *base)
free(output);
 }
 
-static const struct wl_shell_surface_listener shell_surface_listener;
-
 static int
 wayland_output_init_gl_renderer(struct wayland_output *output)
 {
@@ -838,8 +842,6 @@ wayland_output_set_windowed(struct wayland_output *output)
 
wayland_output_resize_surface(output);
 
-   wl_shell_surface_set_toplevel(output->parent.shell_surface);
-
return 0;
 }
 
@@ -858,9 +860,8 @@ wayland_output_set_fullscreen(struct wayland_output *output,
 
wayland_output_resize_surface(output);
 
-   if (output->parent.shell_surface) {
-   wl_shell_surface_set_fullscreen(output->parent.shell_surface,
-   method, framerate, target);
+   if (output->parent.xdg_toplevel) {
+   zxdg_toplevel_v6_set_fullscreen(output->parent.xdg_toplevel, 
target);
} else if (b->parent.fshell) {
zwp_fullscreen_shell_v1_present_surface(b->parent.fshell,
output->parent.surface,
@@ -959,7 +960,7 @@ wayland_output_switch_mode(struct weston_output 
*output_base,
 
b = to_wayland_backend(output_base->compositor);
 
-   if (output->parent.shell_surface || !b->parent.fshell)
+   if (output->parent.xdg_surface || !b->parent.fshell)
return -1;
 
mode = wayland_output_choose_mode(output, mode);
@@ -1031,6 +1032,41 @@ err_output:
return -1;
 }
 
+static void
+handle_surface_configure(void *data, struct zxdg_surface_v6 *surface,
+uint32_t serial)
+{
+   zxdg_surface_v6_ack_configure(surface, serial);
+}
+
+static const struct zxdg_surface_v6_listener xdg_surface_listener = {
+   handle_surface_configure
+};
+
+static void
+handle_toplevel_configure(void *data, struct zxdg_toplevel_v6 *toplevel,
+ int32_t width, int32_t height,
+ 

Re: [PATCH weston] compositor-wayland: Port to xdg-shell

2016-10-09 Thread Armin Krezović
On 09.10.2016 15:06, Armin Krezović wrote:
> Signed-off-by: Armin Krezović 
> ---
>  Makefile.am|   8 ++-
>  libweston/compositor-wayland.c | 155 
> ++---
>  2 files changed, 102 insertions(+), 61 deletions(-)
> 

Please ignore this one. I have more fixes and I will stash them all together.



signature.asc
Description: OpenPGP digital signature
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 00/10] Wayland backend improvements

2016-10-09 Thread Armin Krezović
This series contains some simple fixes for Wayland backend
for issues discovered by Pekka during the output API series
review.

That includes some cleaning up on output/backend destroy,
converting some flags to boolean (nitpick!) and porting
the backend to xdg-shell-v6!

Armin Krezović (10):
  compositor-wayland: Convert use-pixman flag to boolean
  compositor-wayland: Convert sprawl flag to boolean
  compositor-wayland: Convert fullscreen flag to bool
  compositor-wayland: Convert draw_initial_frame to boolean
  compositor-wayland: Move vfunc setting from set_size to enable
  compositor-wayland: Simplify fullscreen output surface handling
  compositor-wayland: Properly clean up on backend destroy
  compositor-wayland: Destroy shm buffers on output disable
  compositor-wayland: Port to xdg-shell-v6
  compositor-wayland: Simplify fullscreening for sprawl use case

 Makefile.am|   8 +-
 compositor/main.c  |   4 +-
 libweston/compositor-wayland.c | 277 -
 libweston/compositor-wayland.h |   6 +-
 4 files changed, 173 insertions(+), 122 deletions(-)

-- 
2.10.1

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


[PATCH weston 03/10] compositor-wayland: Convert fullscreen flag to bool

2016-10-09 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 libweston/compositor-wayland.c | 2 +-
 libweston/compositor-wayland.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 32c44d4..a5a360c 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -77,7 +77,7 @@ struct wayland_backend {
 
bool use_pixman;
bool sprawl_across_outputs;
-   int fullscreen;
+   bool fullscreen;
 
struct theme *theme;
cairo_device_t *frame_device;
diff --git a/libweston/compositor-wayland.h b/libweston/compositor-wayland.h
index 3ca875a..d5c29f0 100644
--- a/libweston/compositor-wayland.h
+++ b/libweston/compositor-wayland.h
@@ -41,7 +41,7 @@ struct weston_wayland_backend_config {
bool use_pixman;
bool sprawl;
char *display_name;
-   int fullscreen;
+   bool fullscreen;
char *cursor_theme;
int cursor_size;
 };
-- 
2.10.1

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


[PATCH weston 04/10] compositor-wayland: Convert draw_initial_frame to boolean

2016-10-09 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 libweston/compositor-wayland.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index a5a360c..d26360e 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -91,7 +91,7 @@ struct wayland_output {
struct weston_output base;
 
struct {
-   int draw_initial_frame;
+   bool draw_initial_frame;
struct wl_surface *surface;
 
struct wl_output *output;
@@ -461,7 +461,7 @@ wayland_output_start_repaint_loop(struct weston_output 
*output_base)
 * callback won't be invoked. The buffer is transparent and of the
 * same size as the future real output buffer. */
if (output->parent.draw_initial_frame) {
-   output->parent.draw_initial_frame = 0;
+   output->parent.draw_initial_frame = false;
 
draw_initial_frame(output);
}
@@ -989,7 +989,7 @@ wayland_output_switch_mode(struct weston_output 
*output_base,
   &mode_status);
 
/* This should kick-start things again */
-   output->parent.draw_initial_frame = 1;
+   output->parent.draw_initial_frame = true;
wayland_output_start_repaint_loop(&output->base);
 
mode_status = MODE_STATUS_UNKNOWN;
@@ -1043,7 +1043,7 @@ wayland_backend_create_output_surface(struct 
wayland_output *output)
 
wl_surface_set_user_data(output->parent.surface, output);
 
-   output->parent.draw_initial_frame = 1;
+   output->parent.draw_initial_frame = true;
 
if (b->parent.shell) {
output->parent.shell_surface =
-- 
2.10.1

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


[PATCH weston 02/10] compositor-wayland: Convert sprawl flag to boolean

2016-10-09 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 compositor/main.c  | 2 +-
 libweston/compositor-wayland.c | 4 ++--
 libweston/compositor-wayland.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index d081106..320305c 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1578,7 +1578,7 @@ load_wayland_backend(struct weston_compositor *c,
config.cursor_theme = NULL;
config.display_name = NULL;
config.fullscreen = 0;
-   config.sprawl = 0;
+   config.sprawl = false;
config.use_pixman = false;
 
const struct weston_option wayland_options[] = {
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index d1ff8d7..32c44d4 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -76,7 +76,7 @@ struct wayland_backend {
} parent;
 
bool use_pixman;
-   int sprawl_across_outputs;
+   bool sprawl_across_outputs;
int fullscreen;
 
struct theme *theme;
@@ -2448,7 +2448,7 @@ backend_init(struct weston_compositor *compositor,
return -1;
 
if (new_config.sprawl || b->parent.fshell) {
-   b->sprawl_across_outputs = 1;
+   b->sprawl_across_outputs = true;
wl_display_roundtrip(b->parent.wl_display);
 
wl_list_for_each(poutput, &b->parent.output_list, link)
diff --git a/libweston/compositor-wayland.h b/libweston/compositor-wayland.h
index 9a9dde8..3ca875a 100644
--- a/libweston/compositor-wayland.h
+++ b/libweston/compositor-wayland.h
@@ -39,7 +39,7 @@ extern "C" {
 struct weston_wayland_backend_config {
struct weston_backend_config base;
bool use_pixman;
-   int sprawl;
+   bool sprawl;
char *display_name;
int fullscreen;
char *cursor_theme;
-- 
2.10.1

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


[PATCH weston 01/10] compositor-wayland: Convert use-pixman flag to boolean

2016-10-09 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 compositor/main.c  | 2 +-
 libweston/compositor-wayland.c | 6 +++---
 libweston/compositor-wayland.h | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index fca9778..d081106 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -1579,7 +1579,7 @@ load_wayland_backend(struct weston_compositor *c,
config.display_name = NULL;
config.fullscreen = 0;
config.sprawl = 0;
-   config.use_pixman = 0;
+   config.use_pixman = false;
 
const struct weston_option wayland_options[] = {
{ WESTON_OPTION_INTEGER, "width", 0, &parsed_options->width },
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 46fdde1..d1ff8d7 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -75,7 +75,7 @@ struct wayland_backend {
uint32_t event_mask;
} parent;
 
-   int use_pixman;
+   bool use_pixman;
int sprawl_across_outputs;
int fullscreen;
 
@@ -2345,7 +2345,7 @@ wayland_backend_create(struct weston_compositor 
*compositor,
gl_renderer = weston_load_module("gl-renderer.so",
 "gl_renderer_interface");
if (!gl_renderer)
-   b->use_pixman = 1;
+   b->use_pixman = true;
}
 
if (!b->use_pixman) {
@@ -2357,7 +2357,7 @@ wayland_backend_create(struct weston_compositor 
*compositor,
0) < 0) {
weston_log("Failed to initialize the GL renderer; "
   "falling back to pixman.\n");
-   b->use_pixman = 1;
+   b->use_pixman = true;
}
}
 
diff --git a/libweston/compositor-wayland.h b/libweston/compositor-wayland.h
index 58e0fb1..9a9dde8 100644
--- a/libweston/compositor-wayland.h
+++ b/libweston/compositor-wayland.h
@@ -38,7 +38,7 @@ extern "C" {
 
 struct weston_wayland_backend_config {
struct weston_backend_config base;
-   int use_pixman;
+   bool use_pixman;
int sprawl;
char *display_name;
int fullscreen;
-- 
2.10.1

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


[PATCH weston 06/10] compositor-wayland: Simplify fullscreen output surface handling

2016-10-09 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 libweston/compositor-wayland.c | 17 +++--
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 42cebe7..133d0c4 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -645,10 +645,7 @@ wayland_output_disable(struct weston_output *base)
wl_egl_window_destroy(output->gl.egl_window);
}
 
-   /* Done on output->enable when not fullscreen, otherwise
-* done in output_create, to get the proper mode */
-   if (!b->fullscreen)
-   wayland_backend_destroy_output_surface(output);
+   wayland_backend_destroy_output_surface(output);
 
if (output->frame)
frame_destroy(output->frame);
@@ -665,13 +662,9 @@ static void
 wayland_output_destroy(struct weston_output *base)
 {
struct wayland_output *output = to_wayland_output(base);
-   struct wayland_backend *b = to_wayland_backend(base->compositor);
 
wayland_output_disable(&output->base);
 
-   if (b->fullscreen)
-   wayland_backend_destroy_output_surface(output);
-
weston_output_destroy(&output->base);
 
free(output);
@@ -1068,15 +1061,12 @@ wayland_output_enable(struct weston_output *base)
struct wayland_backend *b = to_wayland_backend(base->compositor);
int ret = 0;
 
-
weston_log("Creating %dx%d wayland output at (%d, %d)\n",
   output->base.current_mode->width,
   output->base.current_mode->height,
   output->base.x, output->base.y);
 
-   /* If fullscreen was specified, this needs to be done before
-* enable to get the proper mode */
-   if (!b->fullscreen)
+   if (!output->parent.surface)
ret = wayland_backend_create_output_surface(output);
 
if (ret < 0)
@@ -1132,8 +1122,7 @@ wayland_output_enable(struct weston_output *base)
return 0;
 
 err_output:
-   if (!b->fullscreen)
-   wayland_backend_destroy_output_surface(output);
+   wayland_backend_destroy_output_surface(output);
 
return -1;
 }
-- 
2.10.1

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


[PATCH weston 05/10] compositor-wayland: Move vfunc setting from set_size to enable

2016-10-09 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 libweston/compositor-wayland.c | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index d26360e..42cebe7 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -1088,11 +1088,21 @@ wayland_output_enable(struct weston_output *base)
if (b->use_pixman) {
if (wayland_output_init_pixman_renderer(output) < 0)
goto err_output;
+
+   output->base.repaint = wayland_output_repaint_pixman;
} else {
if (wayland_output_init_gl_renderer(output) < 0)
goto err_output;
+
+   output->base.repaint = wayland_output_repaint_gl;
}
 
+   output->base.start_repaint_loop = wayland_output_start_repaint_loop;
+   output->base.assign_planes = NULL;
+   output->base.set_backlight = NULL;
+   output->base.set_dpms = NULL;
+   output->base.switch_mode = wayland_output_switch_mode;
+
if (b->sprawl_across_outputs) {
wayland_output_set_fullscreen(output,
  
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER,
@@ -1166,7 +1176,6 @@ static int
 wayland_output_set_size(struct weston_output *base, int width, int height)
 {
struct wayland_output *output = to_wayland_output(base);
-   struct wayland_backend *b = to_wayland_backend(base->compositor);
int output_width, output_height;
 
/* We can only be called once. */
@@ -1208,17 +1217,6 @@ wayland_output_set_size(struct weston_output *base, int 
width, int height)
output->base.mm_width = width;
output->base.mm_height = height;
 
-   if (b->use_pixman)
-   output->base.repaint = wayland_output_repaint_pixman;
-   else
-   output->base.repaint = wayland_output_repaint_gl;
-
-   output->base.start_repaint_loop = wayland_output_start_repaint_loop;
-   output->base.assign_planes = NULL;
-   output->base.set_backlight = NULL;
-   output->base.set_dpms = NULL;
-   output->base.switch_mode = wayland_output_switch_mode;
-
return 0;
 }
 
-- 
2.10.1

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


[PATCH weston 07/10] compositor-wayland: Properly clean up on backend destroy

2016-10-09 Thread Armin Krezović
Also remove a wrong XXX comment.

Signed-off-by: Armin Krezović 
---
 libweston/compositor-wayland.c | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 133d0c4..0cfc005 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -1244,7 +1244,6 @@ wayland_output_create_for_parent_output(struct 
wayland_backend *b,
output->base.make = poutput->physical.make;
output->base.model = poutput->physical.model;
 
-   /* XXX: Clear previously added values */
wl_list_init(&output->base.mode_list);
wl_list_insert_list(&output->base.mode_list, &poutput->mode_list);
wl_list_init(&poutput->mode_list);
@@ -2234,11 +2233,31 @@ wayland_destroy(struct weston_compositor *ec)
 {
struct wayland_backend *b = to_wayland_backend(ec);
 
+   wl_event_source_remove(b->parent.wl_source);
+
weston_compositor_shutdown(ec);
 
if (b->parent.shm)
wl_shm_destroy(b->parent.shm);
 
+   if (b->parent.fshell)
+   zwp_fullscreen_shell_v1_release(b->parent.fshell);
+
+   if (b->parent.compositor)
+   wl_compositor_destroy(b->parent.compositor);
+
+   wl_registry_destroy(b->parent.registry);
+   wl_display_flush(b->parent.wl_display);
+   wl_display_disconnect(b->parent.wl_display);
+
+   if (b->theme)
+   theme_destroy(b->theme);
+
+   if (b->frame_device)
+   cairo_device_destroy(b->frame_device);
+
+   wl_cursor_theme_destroy(b->cursor_theme);
+
free(b);
 }
 
-- 
2.10.1

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


[PATCH weston 08/10] compositor-wayland: Destroy shm buffers on output disable

2016-10-09 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 libweston/compositor-wayland.c | 23 ---
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 0cfc005..d1a38fe 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -629,6 +629,19 @@ wayland_backend_destroy_output_surface(struct 
wayland_output *output)
wl_surface_destroy(output->parent.surface);
 }
 
+static void
+wayland_output_destroy_shm_buffers(struct wayland_output *output)
+{
+   struct wayland_shm_buffer *buffer, *next;
+
+   /* Throw away any remaining SHM buffers */
+   wl_list_for_each_safe(buffer, next, &output->shm.free_buffers, 
free_link)
+   wayland_shm_buffer_destroy(buffer);
+   /* These will get thrown away when they get released */
+   wl_list_for_each(buffer, &output->shm.buffers, link)
+   buffer->output = NULL;
+}
+
 static int
 wayland_output_disable(struct weston_output *base)
 {
@@ -645,6 +658,8 @@ wayland_output_disable(struct weston_output *base)
wl_egl_window_destroy(output->gl.egl_window);
}
 
+   wayland_output_destroy_shm_buffers(output);
+
wayland_backend_destroy_output_surface(output);
 
if (output->frame)
@@ -719,7 +734,6 @@ wayland_output_resize_surface(struct wayland_output *output)
 {
struct wayland_backend *b =
to_wayland_backend(output->base.compositor);
-   struct wayland_shm_buffer *buffer, *next;
int32_t ix, iy, iwidth, iheight;
int32_t width, height;
struct wl_region *region;
@@ -783,12 +797,7 @@ wayland_output_resize_surface(struct wayland_output 
*output)
output->gl.border.bottom = NULL;
}
 
-   /* Throw away any remaining SHM buffers */
-   wl_list_for_each_safe(buffer, next, &output->shm.free_buffers, 
free_link)
-   wayland_shm_buffer_destroy(buffer);
-   /* These will get thrown away when they get released */
-   wl_list_for_each(buffer, &output->shm.buffers, link)
-   buffer->output = NULL;
+   wayland_output_destroy_shm_buffers(output);
 }
 
 static int
-- 
2.10.1

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


[PATCH weston 10/10] compositor-wayland: Simplify fullscreening for sprawl use case

2016-10-09 Thread Armin Krezović
wayland_output_set_fullscreen() already takes care of
everything and xdg_shell doesn't use any present methods
so a single call to wayland_output_set_fullscreen() is
sufficient.

Signed-off-by: Armin Krezović 
---
 libweston/compositor-wayland.c | 22 +++---
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 6d91208..328b170 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -853,7 +853,7 @@ wayland_output_set_windowed(struct wayland_output *output)
 static void
 wayland_output_set_fullscreen(struct wayland_output *output,
  enum wl_shell_surface_fullscreen_method method,
- uint32_t framerate, struct wl_output *target)
+ struct wl_output *target)
 {
struct wayland_backend *b =
to_wayland_backend(output->base.compositor);
@@ -1162,25 +1162,17 @@ wayland_output_enable(struct weston_output *base)
 
if (b->sprawl_across_outputs) {
wayland_output_set_fullscreen(output,
- 
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER,
- output->mode.refresh, 
output->parent.output);
-
-   if (output->parent.xdg_toplevel) {
-   
zxdg_toplevel_v6_set_fullscreen(output->parent.xdg_toplevel,
-   output->parent.output);
-   } else if (b->parent.fshell) {
-   
zwp_fullscreen_shell_v1_present_surface(b->parent.fshell,
-   
output->parent.surface,
-   
ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_CENTER,
-   
output->parent.output);
+ 
ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_CENTER,
+ output->parent.output);
+
+   if (b->parent.fshell)
zwp_fullscreen_shell_mode_feedback_v1_destroy(

zwp_fullscreen_shell_v1_present_surface_for_mode(b->parent.fshell,

 output->parent.surface,

 output->parent.output,

 output->mode.refresh));
-   }
} else if (b->fullscreen) {
-   wayland_output_set_fullscreen(output, 0, 0, NULL);
+   wayland_output_set_fullscreen(output, 0, NULL);
} else {
wayland_output_set_windowed(output);
}
@@ -2358,7 +2350,7 @@ fullscreen_binding(struct weston_keyboard *keyboard, 
uint32_t time,
return;
 
if (input->output->frame)
-   wayland_output_set_fullscreen(input->output, 0, 0, NULL);
+   wayland_output_set_fullscreen(input->output, 0, NULL);
else
wayland_output_set_windowed(input->output);
 
-- 
2.10.1

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


[PATCH weston 09/10] compositor-wayland: Port to xdg-shell-v6

2016-10-09 Thread Armin Krezović
Signed-off-by: Armin Krezović 
---
 Makefile.am|   8 ++-
 libweston/compositor-wayland.c | 158 ++---
 2 files changed, 105 insertions(+), 61 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index c94c211..f75aa46 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -391,9 +391,11 @@ wayland_backend_la_CFLAGS =\
$(CAIRO_CFLAGS) \
$(WAYLAND_COMPOSITOR_CFLAGS)\
$(AM_CFLAGS)
-wayland_backend_la_SOURCES =   \
-   libweston/compositor-wayland.c  \
-   libweston/compositor-wayland.h  \
+wayland_backend_la_SOURCES =   \
+   libweston/compositor-wayland.c  \
+   libweston/compositor-wayland.h  \
+   protocol/xdg-shell-unstable-v6-protocol.c   \
+   protocol/xdg-shell-unstable-v6-client-protocol.h\
shared/helpers.h
 nodist_wayland_backend_la_SOURCES =\
protocol/fullscreen-shell-unstable-v1-protocol.c\
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index d1a38fe..6d91208 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -51,6 +51,7 @@
 #include "shared/os-compatibility.h"
 #include "shared/cairo-util.h"
 #include "fullscreen-shell-unstable-v1-client-protocol.h"
+#include "xdg-shell-unstable-v6-client-protocol.h"
 #include "presentation-time-server-protocol.h"
 #include "linux-dmabuf.h"
 #include "windowed-output-api.h"
@@ -65,7 +66,7 @@ struct wayland_backend {
struct wl_display *wl_display;
struct wl_registry *registry;
struct wl_compositor *compositor;
-   struct wl_shell *shell;
+   struct zxdg_shell_v6 *shell;
struct zwp_fullscreen_shell_v1 *fshell;
struct wl_shm *shm;
 
@@ -97,8 +98,10 @@ struct wayland_output {
struct wl_output *output;
uint32_t global_id;
 
-   struct wl_shell_surface *shell_surface;
+   struct zxdg_surface_v6 *xdg_surface;
+   struct zxdg_toplevel_v6 *xdg_toplevel;
int configure_width, configure_height;
+   bool wait_for_configure;
} parent;
 
int keyboard_count;
@@ -623,8 +626,11 @@ wayland_output_repaint_pixman(struct weston_output 
*output_base,
 static void
 wayland_backend_destroy_output_surface(struct wayland_output *output)
 {
-   if (output->parent.shell_surface)
-   wl_shell_surface_destroy(output->parent.shell_surface);
+   if (output->parent.xdg_toplevel)
+   zxdg_toplevel_v6_destroy(output->parent.xdg_toplevel);
+
+   if (output->parent.xdg_surface)
+   zxdg_surface_v6_destroy(output->parent.xdg_surface);
 
wl_surface_destroy(output->parent.surface);
 }
@@ -685,8 +691,6 @@ wayland_output_destroy(struct weston_output *base)
free(output);
 }
 
-static const struct wl_shell_surface_listener shell_surface_listener;
-
 static int
 wayland_output_init_gl_renderer(struct wayland_output *output)
 {
@@ -822,6 +826,9 @@ wayland_output_set_windowed(struct wayland_output *output)
title = strdup(WINDOW_TITLE);
}
 
+   if (output->parent.xdg_toplevel)
+   zxdg_toplevel_v6_set_title(output->parent.xdg_toplevel, title);
+
if (!b->theme) {
b->theme = theme_create();
if (!b->theme) {
@@ -840,8 +847,6 @@ wayland_output_set_windowed(struct wayland_output *output)
 
wayland_output_resize_surface(output);
 
-   wl_shell_surface_set_toplevel(output->parent.shell_surface);
-
return 0;
 }
 
@@ -860,9 +865,8 @@ wayland_output_set_fullscreen(struct wayland_output *output,
 
wayland_output_resize_surface(output);
 
-   if (output->parent.shell_surface) {
-   wl_shell_surface_set_fullscreen(output->parent.shell_surface,
-   method, framerate, target);
+   if (output->parent.xdg_toplevel) {
+   zxdg_toplevel_v6_set_fullscreen(output->parent.xdg_toplevel, 
target);
} else if (b->parent.fshell) {
zwp_fullscreen_shell_v1_present_surface(b->parent.fshell,
output->parent.surface,
@@ -961,7 +965,7 @@ wayland_output_switch_mode(struct weston_output 
*output_base,
 
b = to_wayland_backend(output_base->compositor);
 
-   if (output->parent.shell_surface || !b->parent.fshell)
+   if (output->parent.xdg_surface || !b->parent.fshell)
return -1;
 
mode = wayland_output_choose_mode(output, mode);
@@ -1033,6 +1037,41 @@ err_output:
return -1;
 }
 
+static void
+handle_surface_configure(void *data, struct zxdg_surface_v6 *surface,
+

Re: [PATCH weston 1/4] libweston: Export weston_output_transform_scale_init

2016-10-09 Thread Armin Krezović
On 07.10.2016 11:52, Pekka Paalanen wrote:
> On Fri, 30 Sep 2016 23:25:27 +0200
> Armin Krezović  wrote:
> 
>> This is required for implementing output layout setting
>> which relies on current output width and height, and
>> those are calculated in this function.
>>
>> It also changes the function signature to make use
>> of already stored scale and transform values in the
>> weston_output object.
>>
>> Signed-off-by: Armin Krezović 
>> ---
>>  libweston/compositor.c | 31 ++-
>>  libweston/compositor.h |  2 ++
>>  2 files changed, 20 insertions(+), 13 deletions(-)
> 
> Hi,
> 
> I think this would need a bit more thought on the API.
> 
> The requirement is that one has to set some output parameters (video
> mode, transform, scale) before the output size is available. Output
> size then is needed for doing the layout.
> 
> IMO it would make more sense to add a new function
> weston_output_get_size(), which would take into account the currently
> set (pending) parameters and compute the resulting size.
> 
> This is also good in the long term since we would like to make struct
> weston_output opaque to the libweston user. We are going to need a
> getter for the size anyway.
> 
> 
> Thanks,
> pq
> 

Hi,

It makes sense, yes. Do you think we'd need a similar function to get
the current output coordinates (used for computing new position)?

Thanks, Armin.



signature.asc
Description: OpenPGP digital signature
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 2/4] weston: Move output position setting to compositor

2016-10-09 Thread Armin Krezović
On 07.10.2016 11:58, Pekka Paalanen wrote:
> On Fri, 30 Sep 2016 23:25:28 +0200
> Armin Krezović  wrote:
> 
>> This moves current output positioning code and scale/transform
>> application to the compositor itself, so the compositor
>> can configure output layouts any way it wants.
>>
>> A helper function for setting x and y coordinates is also
>> added, and couple of assertions to weston_output_enable()
>> as well, to make sure everything has been set up.
>>
>> Signed-off-by: Armin Krezović 
>> ---
>>  compositor/main.c  | 26 ++
>>  libweston/compositor.c | 40 ++--
>>  libweston/compositor.h |  3 +++
>>  3 files changed, 51 insertions(+), 18 deletions(-)
> 
> Hi,
> 
> moving the output positioning out from libweston and into the
> compositor is very good. The setter for x,y is good too.
> 
> I'm just not sure we should assume that outputs cannot occupy the
> negative coordinates. If one hotplugs an output to the left, I'd assume
> the existing windows would stay put on the right. If we cannot use
> negative coordinates, everything has to be moved to keep them at the
> same position from the user point of view.
> 
> 
> Thanks,
> pq
> 

Hi,

I'd rather go for the second approach - move everything to the output it
was on, in case an output gets attached on the left of an output that had
something displayed (weston_output_move() can be easily adapted).

Thanks, Armin.



signature.asc
Description: OpenPGP digital signature
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 3/4] compositor: Add internal output object used for layout configuration

2016-10-09 Thread Armin Krezović
On 07.10.2016 12:08, Pekka Paalanen wrote:
> On Fri, 30 Sep 2016 23:25:29 +0200
> Armin Krezović  wrote:
> 
>> This adds weston specific output object, which contains information
>> about output's position, relative to other outputs. DRM and Windowed
>> backends code has been updated to make use of the new code and
>> parse new configuration options for a given output, if it was
>> specified.
>>
>> New configuration file options for [output] section have been added:
>>
>> left-of: Specifies which output should be on the right side of the
>> current output.
>>
>> right-of: Specifies which output should be on the left side of the
>> current output.
>>
>> Signed-off-by: Armin Krezović 
>> ---
>>  compositor/main.c | 81 
>> +++
>>  1 file changed, 81 insertions(+)
>>
>> diff --git a/compositor/main.c b/compositor/main.c
>> index 503016e..e379d8d 100644
>> --- a/compositor/main.c
>> +++ b/compositor/main.c
>> @@ -78,6 +78,18 @@ struct wet_compositor {
>>  struct weston_config *config;
>>  struct wet_output_config *parsed_options;
>>  struct wl_listener pending_output_listener;
>> +struct wl_list output_layout_list;
>> +};
>> +
>> +struct wet_output {
>> +struct weston_output *output;
>> +struct wl_listener output_destroy_listener;
>> +struct wl_list link;
>> +
>> +char *left_output_name;
>> +char *right_output_name;
> 
> Hi
> 

Salut

> Rather than linking by name, would it not be easier to link by pointer
> to struct wet_output?
> 

I can try that, too.

> That means when you encounter a directive like "left-of=F5" and there
> is no output F5 yet, you would create a new struct wet_output for F5
> but leave the weston_output pointer NULL, to be filled out if F5
> actually appears.
> 
> That means you would always have a graph in memory instead of doing
> searches to find if output of this name actually exists. I'm not sure
> if that's actually simpler in the end.
> 

I'd still have to search for a wet_output matching an output when it
gets attached (implement a way of matching an unclaimed wet_output to
weston_output), and if it isn't there, I'll have to create it. That
includes a bit of complexity too. How much however, I can't say
until I try.

> Having the complete graph would allow you to "jump over" outputs that
> do not exist at the moment: e.g. order F1 -> (F2) -> F3.
> 

That could lead to waste of memory, as the output could never get attached,
and I'll have to implement a function free-ing such outputs, as I can't rely
on output destroyed signal as I currently do. Not to mention that the third
output needs to be moved when second one gets attached, so it's not really
a win-win situation, besides having a better picture in the memory.

We could accomplish that using wl_array with this implementation (instead
of wl_list that's currently used).

In the end, the implementation looks more complex than this one, and
we already configure outputs by name, so why not simply keep it?

>> +
>> +bool position_set;
>>  };
>>  
> 
>> +weston_config_section_get_string(section, "left-of", &out, NULL);
>> +wet_output->right_output_name = out ? strdup(out) : NULL;
>> +free(out);
>> +
>> +weston_config_section_get_string(section, "right-of", &out, NULL);
>> +wet_output->left_output_name = out ? strdup(out) : NULL;
>> +free(out);
> 
> Yes, this looks like an intuitive approach, storing the relationship in
> inverse compared to how users write it out in weston.ini.
> 

Heh, this is my bad really. While rushing to finish this part before GSoC
deadline, I managed to invert the intended functionality. I just swapped
these two here, instead of going through the rest of the code as I was
sure the code would be changed anyways as soon as I send it for review.

It will be fixed as soon as we can agree on an approach.

> 
> Thanks,
> pq
> 

Cheers.



signature.asc
Description: OpenPGP digital signature
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH weston 4/4] compositor: Implement horizontal output layout configuration

2016-10-09 Thread Armin Krezović
On 07.10.2016 12:19, Pekka Paalanen wrote:
> On Fri, 30 Sep 2016 23:25:30 +0200
> Armin Krezović  wrote:
> 
>> This patch adds horizontal output layout configuration using
>> the previously added code.
>>
>> When an output is added, it looks for outputs that it should
>> be placed next to, if they are specified. If such output is
>> found, output layout is updated if needed (outputs on a given
>> position are moved right if they collide with the new output)
>> and the output is positioned next to the specified output,
>> either on its left or its right.
>>
>> If a certain position wasn't specified for the current output,
>> the compositor looks for any existing outputs that have
>> current output specified on that position, and updates the
>> positions accordingly, if corresponding output is found.
>>
>> Output positions can only be set once, where config file
>> specified option is always set, even if such output will
>> never be present. If a certain position wasn't set, the
>> compositor may update the position if it finds another
>> output that wants to be placed next to the output that's
>> being configured. In such case, first existing output that
>> matches the position is picked up, rest is ignored.
>>
>> Default behaviour is still to place outputs that have
>> no matching configuration top right.
>>
>> Signed-off-by: Armin Krezović 
>> ---
>>  compositor/main.c | 159 
>> +++---
>>  1 file changed, 153 insertions(+), 6 deletions(-)
>>
>> diff --git a/compositor/main.c b/compositor/main.c
>> index e379d8d..c039ae6 100644
>> --- a/compositor/main.c
>> +++ b/compositor/main.c
>> @@ -480,20 +480,167 @@ wet_init_parsed_options(struct weston_compositor *ec)
>>  return config;
>>  }
>>  
>> +static struct wet_output *
>> +wet_output_from_output(struct wet_compositor *compositor, struct 
>> weston_output *output)
>> +{
>> +struct wet_output *iterator, *next;
>> +
>> +if (wl_list_empty(&compositor->output_layout_list))
>> +return NULL;
>> +
>> +wl_list_for_each_safe(iterator, next, &compositor->output_layout_list, 
>> link) {
>> +if (iterator->output == output)
>> +return iterator;
>> +}
> 
> Hi,
> 
> wet_output uses a destroy listener on the output, so use that:
> 
> listener = wl_signal_get(&output->destroy_signal, handle_output_destroy);
> wet_output = container_of(...);
> 

Thanks for the hint.

>> +
>> +return NULL;
>> +}
>> +
>> +static struct wet_output *
>> +wet_output_from_name(struct wet_compositor *compositor, const char *name)
>> +{
>> +struct wet_output *iterator, *next;
>> +
>> +if (wl_list_empty(&compositor->output_layout_list))
>> +return NULL;
>> +
>> +wl_list_for_each_safe(iterator, next, &compositor->output_layout_list, 
>> link) {
>> +if (!strcmp(iterator->output->name, name))
>> +return iterator;
>> +}
> 
> No need to check for empty list, and no need to use _safe. Applies
> probably to all loop below, too.
> 

I have been burned when using non-safe version in the past (getting
random segfaults with non-safe version and not with safe version),
so I keep on using it. I'll see if it's still needed.

>> +
>> +return NULL;
>> +}
>> +
> 
> I kind of wonder how much sense it makes to do first just 1-D layout
> and then later expand to 2-D layout. I fear the code re-use might be
> non-existant.
> 
> If you are struggling with 2-D layout, maybe X.org could provide some
> example?
> 
> I do not have a suggestion for a good layout algorithm or even a method
> of description. People have been configuring X.org for ages, so
> something similar might be familiar.
> 
> Positioning by absolute coordinates I would like to leave out if
> possible, or at least you would need to check that:
> - all outputs create a single connected region (so pointers can travel
>   everywhere)
> - no outputs overlap (IIRC this is a limitation of Weston's damage
>   tracking)
> 
> 
> Thanks,
> pq
> 

I have thought about 2D layout, but I have ran in a problem that I can't
solve.

I'll try to illustrate.


|||-|
||| |
||| |
  |_|
|--|
|  |
|  |
|__|

Lets say I have an 800x600 output top left, and 1024x768 next to it.
I want to place an 1280x1024 output below 800x600 one. I'd get something
like this, or the output below would overlap with the one on top right.

Now, one of the solutions is to align both of the outputs on the bottom
border, so I get something like this:

   |-|
|-|| |
| || |
|_||_|
|--|
|  |
|  |
|__|

Suggestions welcome.

(Sorry for my bad illustrations).

Thanks, Armin.



signature.asc
Description: OpenPGP digital signature
___
wayl

Re: [PATCH wayland-web v2] qt5: fixed bug tracker link

2016-10-09 Thread Samuel Gaist

> On 31 août 2016, at 17:13, Yong Bakos  wrote:
> 
> On Aug 30, 2016, at 11:50 PM, Samuel Gaist  wrote:
>> 
>> No being used to the by email patch workflow, should I send an updated patch 
>> with the “Reviewed-by” field added ?
>> 
>> Cheers
>> 
>> Samuel
> 
> Samuel, not necessary. Committers will add the R-b line when applying your 
> patch.
> 
> Not sure why the delay, just overlooked I guess. I'm cc'ig Darxus, who would 
> love a distraction from Cairo.
> 
> long

Thanks for the info !

And a small ping :)

Samuel

> 
> 
>>> On 12 août 2016, at 00:03, Yong Bakos  wrote:
>>> 
>>> On Aug 9, 2016, at 11:56 PM, Samuel Gaist  wrote:
 
 Signed-off-by: Samuel Gaist 
>>> 
>>> Reviewed-by: Yong Bakos 
>>> 
>>> yong
>>> 
>>> 
 ---
 qt5.html | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/qt5.html b/qt5.html
 index 752d63b..d67e297 100644
 --- a/qt5.html
 +++ b/qt5.html
 @@ -151,7 +151,7 @@ and for wl_surface:
 Known issues
 
 
 -See the >>> href="https://bugreports.qt-project.org/secure/IssueNavigator.jspa?mode=hide&requestId=13847";>Qt
  bug tracker
 +See the >>> href="https://bugreports.qt.io/browse/QTBUG/component/19921/?selectedTab=com.atlassian.jira.jira-projects-plugin:component-summary-panel";>Qt
  bug tracker
  for a list of QtWayland bugs.
 
 
 --
 2.9.2
 
 ___
 wayland-devel mailing list
 wayland-devel@lists.freedesktop.org
 https://lists.freedesktop.org/mailman/listinfo/wayland-devel
>>> 
>>> 
>> 
> 
> ___
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH weston 1/2] compositor-drm: Construct mode list in create_output_for_connector

2016-10-09 Thread Armin Krezović
And properly deconstruct it in drm_output_destroy.

Might be useful for finding out which modes are supported
before even setting them, in case we want to extend the
modesetting API.

Signed-off-by: Armin Krezović 
---
 libweston/compositor-drm.c | 63 +++---
 1 file changed, 32 insertions(+), 31 deletions(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index f61e3d9..795e9f0 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -2288,29 +2288,19 @@ drm_output_set_mode(struct weston_output *base,
struct drm_output *output = to_drm_output(base);
struct drm_backend *b = to_drm_backend(base->compositor);
 
-   struct drm_mode *drm_mode, *next, *current;
+   struct drm_mode *current;
drmModeModeInfo crtc_mode;
-   int i;
 
output->base.make = "unknown";
output->base.model = "unknown";
output->base.serial_number = "unknown";
-   wl_list_init(&output->base.mode_list);
-
-   output->original_crtc = drmModeGetCrtc(b->drm.fd, output->crtc_id);
 
if (connector_get_current_mode(output->connector, b->drm.fd, 
&crtc_mode) < 0)
-   goto err_free;
-
-   for (i = 0; i < output->connector->count_modes; i++) {
-   drm_mode = drm_output_add_mode(output, 
&output->connector->modes[i]);
-   if (!drm_mode)
-   goto err_free;
-   }
+   return -1;
 
current = drm_output_choose_initial_mode(b, output, mode, modeline, 
&crtc_mode);
if (!current)
-   goto err_free;
+   return -1;
 
output->base.current_mode = ¤t->base;
output->base.current_mode->flags |= WL_OUTPUT_MODE_CURRENT;
@@ -2323,18 +2313,6 @@ drm_output_set_mode(struct weston_output *base,
output->base.mm_height = output->connector->mmHeight;
 
return 0;
-
-err_free:
-   drmModeFreeCrtc(output->original_crtc);
-   output->original_crtc = NULL;
-
-   wl_list_for_each_safe(drm_mode, next, &output->base.mode_list,
-   base.link) {
-   wl_list_remove(&drm_mode->base.link);
-   free(drm_mode);
-   }
-
-   return -1;
 }
 
 static void
@@ -2457,6 +2435,7 @@ drm_output_destroy(struct weston_output *base)
 {
struct drm_output *output = to_drm_output(base);
struct drm_backend *b = to_drm_backend(base->compositor);
+   struct drm_mode *drm_mode, *next;
drmModeCrtcPtr origcrtc = output->original_crtc;
 
if (output->page_flip_pending) {
@@ -2468,6 +2447,12 @@ drm_output_destroy(struct weston_output *base)
if (output->base.enabled)
drm_output_deinit(&output->base);
 
+   wl_list_for_each_safe(drm_mode, next, &output->base.mode_list,
+ base.link) {
+   wl_list_remove(&drm_mode->base.link);
+   free(drm_mode);
+   }
+
if (origcrtc) {
/* Restore original CRTC state */
drmModeSetCrtc(b->drm.fd, origcrtc->crtc_id, 
origcrtc->buffer_id,
@@ -2532,17 +2517,18 @@ create_output_for_connector(struct drm_backend *b,
struct udev_device *drm_device)
 {
struct drm_output *output;
+   struct drm_mode *drm_mode;
int i;
 
i = find_crtc_for_connector(b, resources, connector);
if (i < 0) {
weston_log("No usable crtc/encoder pair for connector.\n");
-   return -1;
+   goto err;
}
 
output = zalloc(sizeof *output);
if (output == NULL)
-   return -1;
+   goto err;
 
output->connector = connector;
output->crtc_id = resources->crtcs[i];
@@ -2552,6 +2538,8 @@ create_output_for_connector(struct drm_backend *b,
output->backlight = backlight_init(drm_device,
   connector->connector_type);
 
+   output->original_crtc = drmModeGetCrtc(b->drm.fd, output->crtc_id);
+
output->base.enable = drm_output_enable;
output->base.destroy = drm_output_destroy;
output->base.disable = drm_output_disable;
@@ -2559,15 +2547,30 @@ create_output_for_connector(struct drm_backend *b,
 
output->destroy_pending = 0;
output->disable_pending = 0;
-   output->original_crtc = NULL;
 
b->crtc_allocator |= (1 << output->crtc_id);
b->connector_allocator |= (1 << output->connector_id);
 
weston_output_init(&output->base, b->compositor);
+
+   wl_list_init(&output->base.mode_list);
+
+   for (i = 0; i < output->connector->count_modes; i++) {
+   drm_mode = drm_output_add_mode(output, 
&output->connector->modes[i]);
+   if (!drm_mode) {
+   drm_output_destroy(&output->base);
+   return -1;
+   }
+   }
+
weston_composito

[PATCH weston 2/2] compositor-drm: Restore use-current-mode functionality

2016-10-09 Thread Armin Krezović
It got lost during the porting to the config API.

Signed-off-by: Armin Krezović 
---
 compositor/main.c  | 9 +++--
 libweston/compositor-drm.c | 3 ---
 libweston/compositor-drm.h | 1 -
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/compositor/main.c b/compositor/main.c
index 320305c..ffeadfb 100644
--- a/compositor/main.c
+++ b/compositor/main.c
@@ -78,6 +78,7 @@ struct wet_compositor {
struct weston_config *config;
struct wet_output_config *parsed_options;
struct wl_listener pending_output_listener;
+   bool drm_use_current_mode;
 };
 
 static FILE *weston_logfile = NULL;
@@ -1116,6 +1117,7 @@ drm_backend_output_configure(struct wl_listener 
*listener, void *data)
 {
struct weston_output *output = data;
struct weston_config *wc = wet_get_config(output->compositor);
+   struct wet_compositor *wet = to_wet_compositor(output->compositor);
struct weston_config_section *section;
const struct weston_drm_output_api *api = 
weston_drm_output_get_api(output->compositor);
enum weston_drm_backend_output_mode mode =
@@ -1138,7 +1140,7 @@ drm_backend_output_configure(struct wl_listener 
*listener, void *data)
weston_output_disable(output);
free(s);
return;
-   } else if (strcmp(s, "current") == 0) {
+   } else if (wet->drm_use_current_mode || strcmp(s, "current") == 0) {
mode = WESTON_DRM_BACKEND_OUTPUT_CURRENT;
} else if (strcmp(s, "preferred") != 0) {
modeline = s;
@@ -1176,13 +1178,16 @@ load_drm_backend(struct weston_compositor *c,
 {
struct weston_drm_backend_config config = {{ 0, }};
struct weston_config_section *section;
+   struct wet_compositor *wet = to_wet_compositor(c);
int ret = 0;
 
+   wet->drm_use_current_mode = false;
+
const struct weston_option options[] = {
{ WESTON_OPTION_INTEGER, "connector", 0, &config.connector },
{ WESTON_OPTION_STRING, "seat", 0, &config.seat_id },
{ WESTON_OPTION_INTEGER, "tty", 0, &config.tty },
-   { WESTON_OPTION_BOOLEAN, "current-mode", 0, 
&config.use_current_mode },
+   { WESTON_OPTION_BOOLEAN, "current-mode", 0, 
&wet->drm_use_current_mode },
{ WESTON_OPTION_BOOLEAN, "use-pixman", 0, &config.use_pixman },
};
 
diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 795e9f0..84da32b 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -122,8 +122,6 @@ struct drm_backend {
 
int32_t cursor_width;
int32_t cursor_height;
-
-   bool use_current_mode;
 };
 
 struct drm_mode {
@@ -3177,7 +3175,6 @@ drm_backend_create(struct weston_compositor *compositor,
b->sprites_are_broken = 1;
b->compositor = compositor;
b->use_pixman = config->use_pixman;
-   b->use_current_mode = config->use_current_mode;
 
if (parse_gbm_format(config->gbm_format, GBM_FORMAT_XRGB, 
&b->gbm_format) < 0)
goto err_compositor;
diff --git a/libweston/compositor-drm.h b/libweston/compositor-drm.h
index 8f89a2b..2e2995a 100644
--- a/libweston/compositor-drm.h
+++ b/libweston/compositor-drm.h
@@ -138,7 +138,6 @@ struct weston_drm_backend_config {
 */
void (*configure_device)(struct weston_compositor *compositor,
 struct libinput_device *device);
-   bool use_current_mode;
 };
 
 #ifdef  __cplusplus
-- 
2.10.1

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