[PATCH] rdp-compositor: fix compilation with FreeRDP 2.0-rc4

2018-12-04 Thread David Fort
Some members have been removed from FreeRDP structs, so let's use local
variables.
---
 libweston/compositor-rdp.c | 86 +++---
 1 file changed, 43 insertions(+), 43 deletions(-)

diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
index 134e7298..871a0a3e 100644
--- a/libweston/compositor-rdp.c
+++ b/libweston/compositor-rdp.c
@@ -67,19 +67,19 @@
 #endif
 
 #ifdef HAVE_SURFACE_BITS_BMP
-#define SURFACE_BPP(cmd) cmd->bmp.bpp
-#define SURFACE_CODECID(cmd) cmd->bmp.codecID
-#define SURFACE_WIDTH(cmd) cmd->bmp.width
-#define SURFACE_HEIGHT(cmd) cmd->bmp.height
-#define SURFACE_BITMAP_DATA(cmd) cmd->bmp.bitmapData
-#define SURFACE_BITMAP_DATA_LEN(cmd) cmd->bmp.bitmapDataLength
+#define SURFACE_BPP(cmd) cmd.bmp.bpp
+#define SURFACE_CODECID(cmd) cmd.bmp.codecID
+#define SURFACE_WIDTH(cmd) cmd.bmp.width
+#define SURFACE_HEIGHT(cmd) cmd.bmp.height
+#define SURFACE_BITMAP_DATA(cmd) cmd.bmp.bitmapData
+#define SURFACE_BITMAP_DATA_LEN(cmd) cmd.bmp.bitmapDataLength
 #else
-#define SURFACE_BPP(cmd) cmd->bpp
-#define SURFACE_CODECID(cmd) cmd->codecID
-#define SURFACE_WIDTH(cmd) cmd->width
-#define SURFACE_HEIGHT(cmd) cmd->height
-#define SURFACE_BITMAP_DATA(cmd) cmd->bitmapData
-#define SURFACE_BITMAP_DATA_LEN(cmd) cmd->bitmapDataLength
+#define SURFACE_BPP(cmd) cmd.bpp
+#define SURFACE_CODECID(cmd) cmd.codecID
+#define SURFACE_WIDTH(cmd) cmd.width
+#define SURFACE_HEIGHT(cmd) cmd.height
+#define SURFACE_BITMAP_DATA(cmd) cmd.bitmapData
+#define SURFACE_BITMAP_DATA_LEN(cmd) cmd.bitmapDataLength
 #endif
 
 #include 
@@ -198,7 +198,7 @@ rdp_peer_refresh_rfx(pixman_region32_t *damage, 
pixman_image_t *image, freerdp_p
uint32_t *ptr;
RFX_RECT *rfxRect;
rdpUpdate *update = peer->update;
-   SURFACE_BITS_COMMAND *cmd = &update->surface_bits_command;
+   SURFACE_BITS_COMMAND cmd;
RdpPeerContext *context = (RdpPeerContext *)peer->context;
 
Stream_Clear(context->encode_stream);
@@ -208,14 +208,14 @@ rdp_peer_refresh_rfx(pixman_region32_t *damage, 
pixman_image_t *image, freerdp_p
height = (damage->extents.y2 - damage->extents.y1);
 
 #ifdef HAVE_SKIP_COMPRESSION
-   cmd->skipCompression = TRUE;
+   cmd.skipCompression = TRUE;
 #else
-   memset(cmd, 0, sizeof(*cmd));
+   memset(&cmd, 0, sizeof(*cmd));
 #endif
-   cmd->destLeft = damage->extents.x1;
-   cmd->destTop = damage->extents.y1;
-   cmd->destRight = damage->extents.x2;
-   cmd->destBottom = damage->extents.y2;
+   cmd.destLeft = damage->extents.x1;
+   cmd.destTop = damage->extents.y1;
+   cmd.destRight = damage->extents.x2;
+   cmd.destBottom = damage->extents.y2;
SURFACE_BPP(cmd) = 32;
SURFACE_CODECID(cmd) = peer->settings->RemoteFxCodecId;
SURFACE_WIDTH(cmd) = width;
@@ -245,7 +245,7 @@ rdp_peer_refresh_rfx(pixman_region32_t *damage, 
pixman_image_t *image, freerdp_p
SURFACE_BITMAP_DATA_LEN(cmd) = 
Stream_GetPosition(context->encode_stream);
SURFACE_BITMAP_DATA(cmd) = Stream_Buffer(context->encode_stream);
 
-   update->SurfaceBits(update->context, cmd);
+   update->SurfaceBits(update->context, &cmd);
 }
 
 
@@ -255,7 +255,7 @@ rdp_peer_refresh_nsc(pixman_region32_t *damage, 
pixman_image_t *image, freerdp_p
int width, height;
uint32_t *ptr;
rdpUpdate *update = peer->update;
-   SURFACE_BITS_COMMAND *cmd = &update->surface_bits_command;
+   SURFACE_BITS_COMMAND cmd;
RdpPeerContext *context = (RdpPeerContext *)peer->context;
 
Stream_Clear(context->encode_stream);
@@ -265,15 +265,15 @@ rdp_peer_refresh_nsc(pixman_region32_t *damage, 
pixman_image_t *image, freerdp_p
height = (damage->extents.y2 - damage->extents.y1);
 
 #ifdef HAVE_SKIP_COMPRESSION
-   cmd->skipCompression = TRUE;
+   cmd.skipCompression = TRUE;
 #else
memset(cmd, 0, sizeof(*cmd));
 #endif
 
-   cmd->destLeft = damage->extents.x1;
-   cmd->destTop = damage->extents.y1;
-   cmd->destRight = damage->extents.x2;
-   cmd->destBottom = damage->extents.y2;
+   cmd.destLeft = damage->extents.x1;
+   cmd.destTop = damage->extents.y1;
+   cmd.destRight = damage->extents.x2;
+   cmd.destBottom = damage->extents.y2;
SURFACE_BPP(cmd) = 32;
SURFACE_CODECID(cmd) = peer->settings->NSCodecId;
SURFACE_WIDTH(cmd) = width;
@@ -289,7 +289,7 @@ rdp_peer_refresh_nsc(pixman_region32_t *damage, 
pixman_image_t *image, freerdp_p
SURFACE_BITMAP_DATA_LEN(cmd) = 
Stream_GetPosition(context->encode_stream);
SURFACE_BITMAP_DATA(cmd) = Stream_Buffer(context->encode_stream);
 
-   update->SurfaceBits(update->context, cmd);
+   update->SurfaceBits(update->context, &cmd);
 }
 
 static void
@@ -310,8 +310,8 @@ static void
 rdp_peer_refresh_raw(pixman_region32_t *region, pixman_image_t *image, 
freerdp_peer *peer)
 {
rdpUpdate *update = peer->update;
-   SURFACE_BITS_COMMAND *cmd =

[PATCH] rdp-compositor: fix compilation against last FreeRDP 2.0

2018-05-27 Thread David Fort
The SURFACE_BITS_COMMAND struct has changed and some members have been moved in 
the
bmp field.
---
 configure.ac   |  9 -
 libweston/compositor-rdp.c | 69 --
 2 files changed, 52 insertions(+), 26 deletions(-)

diff --git a/configure.ac b/configure.ac
index da3f7342..1dce05fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -264,10 +264,17 @@ if test x$enable_rdp_compositor = xyes; then
 [],
 [PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp >= 1.1.0],[])]
   )
-
   SAVED_CPPFLAGS="$CPPFLAGS"
   CPPFLAGS="$CPPFLAGS $RDP_COMPOSITOR_CFLAGS"
+
   AC_CHECK_HEADERS([freerdp/version.h])
+  AC_CHECK_MEMBER([SURFACE_BITS_COMMAND.bmp],
+   [AC_DEFINE([HAVE_SURFACE_BITS_BMP], [1], [SURFACE_BITS_CMD has bmp 
field])],
+   [],
+   [[#include ]]
+  )
+
+
   CPPFLAGS="$SAVED_CPPFLAGS"
 fi
 
diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
index fd0651af..134e7298 100644
--- a/libweston/compositor-rdp.c
+++ b/libweston/compositor-rdp.c
@@ -66,6 +66,22 @@
 #define FREERDP_CB_RETURN(V) return TRUE
 #endif
 
+#ifdef HAVE_SURFACE_BITS_BMP
+#define SURFACE_BPP(cmd) cmd->bmp.bpp
+#define SURFACE_CODECID(cmd) cmd->bmp.codecID
+#define SURFACE_WIDTH(cmd) cmd->bmp.width
+#define SURFACE_HEIGHT(cmd) cmd->bmp.height
+#define SURFACE_BITMAP_DATA(cmd) cmd->bmp.bitmapData
+#define SURFACE_BITMAP_DATA_LEN(cmd) cmd->bmp.bitmapDataLength
+#else
+#define SURFACE_BPP(cmd) cmd->bpp
+#define SURFACE_CODECID(cmd) cmd->codecID
+#define SURFACE_WIDTH(cmd) cmd->width
+#define SURFACE_HEIGHT(cmd) cmd->height
+#define SURFACE_BITMAP_DATA(cmd) cmd->bitmapData
+#define SURFACE_BITMAP_DATA_LEN(cmd) cmd->bitmapDataLength
+#endif
+
 #include 
 #include 
 #include 
@@ -200,10 +216,10 @@ rdp_peer_refresh_rfx(pixman_region32_t *damage, 
pixman_image_t *image, freerdp_p
cmd->destTop = damage->extents.y1;
cmd->destRight = damage->extents.x2;
cmd->destBottom = damage->extents.y2;
-   cmd->bpp = 32;
-   cmd->codecID = peer->settings->RemoteFxCodecId;
-   cmd->width = width;
-   cmd->height = height;
+   SURFACE_BPP(cmd) = 32;
+   SURFACE_CODECID(cmd) = peer->settings->RemoteFxCodecId;
+   SURFACE_WIDTH(cmd) = width;
+   SURFACE_HEIGHT(cmd) = height;
 
ptr = pixman_image_get_data(image) + damage->extents.x1 +
damage->extents.y1 * 
(pixman_image_get_stride(image) / sizeof(uint32_t));
@@ -226,8 +242,8 @@ rdp_peer_refresh_rfx(pixman_region32_t *damage, 
pixman_image_t *image, freerdp_p
pixman_image_get_stride(image)
);
 
-   cmd->bitmapDataLength = Stream_GetPosition(context->encode_stream);
-   cmd->bitmapData = Stream_Buffer(context->encode_stream);
+   SURFACE_BITMAP_DATA_LEN(cmd) = 
Stream_GetPosition(context->encode_stream);
+   SURFACE_BITMAP_DATA(cmd) = Stream_Buffer(context->encode_stream);
 
update->SurfaceBits(update->context, cmd);
 }
@@ -253,23 +269,26 @@ rdp_peer_refresh_nsc(pixman_region32_t *damage, 
pixman_image_t *image, freerdp_p
 #else
memset(cmd, 0, sizeof(*cmd));
 #endif
+
cmd->destLeft = damage->extents.x1;
cmd->destTop = damage->extents.y1;
cmd->destRight = damage->extents.x2;
cmd->destBottom = damage->extents.y2;
-   cmd->bpp = 32;
-   cmd->codecID = peer->settings->NSCodecId;
-   cmd->width = width;
-   cmd->height = height;
+   SURFACE_BPP(cmd) = 32;
+   SURFACE_CODECID(cmd) = peer->settings->NSCodecId;
+   SURFACE_WIDTH(cmd) = width;
+   SURFACE_HEIGHT(cmd) = height;
 
ptr = pixman_image_get_data(image) + damage->extents.x1 +
damage->extents.y1 * 
(pixman_image_get_stride(image) / sizeof(uint32_t));
 
nsc_compose_message(context->nsc_context, context->encode_stream, (BYTE 
*)ptr,
-   cmd->width, cmd->height,
+   width, height,
pixman_image_get_stride(image));
-   cmd->bitmapDataLength = Stream_GetPosition(context->encode_stream);
-   cmd->bitmapData = Stream_Buffer(context->encode_stream);
+
+   SURFACE_BITMAP_DATA_LEN(cmd) = 
Stream_GetPosition(context->encode_stream);
+   SURFACE_BITMAP_DATA(cmd) = Stream_Buffer(context->encode_stream);
+
update->SurfaceBits(update->context, cmd);
 }
 
@@ -306,16 +325,16 @@ rdp_peer_refresh_raw(pixman_region32_t *region, 
pixman_image_t *image, freerdp_p
update->SurfaceFrameMarker(peer->context, marker);
 
memset(cmd, 0, sizeof(*cmd));
-   cmd->bpp = 32;
-   cmd->codecID = 0;
+   SURFACE_BPP(cmd) = 32;
+   SURFACE_CODECID(cmd) = 0;
 
for (i = 0; i < nrects; i++, rect++) {
/*weston_log("rect(%d,%d, %d,%d)\n", rect->x1, rect->y1, 
rect->x2, rect->y2);*/
cmd->destLeft = rect->x1;
cmd->destRight = rect->x2;
-   cmd->width = rect->x2 - rect->x1;
+   SURFA

[PATCH] rdp-compositor: fix compilation against last FreeRDP 2.0

2018-05-24 Thread David Fort
The SURFACE_BITS_COMMAND struct has changed and some members have been moved in 
the
bmp field.
---
 configure.ac   |  5 ++-
 libweston/compositor-rdp.c | 69 --
 2 files changed, 48 insertions(+), 26 deletions(-)

diff --git a/configure.ac b/configure.ac
index da3f7342..f4450532 100644
--- a/configure.ac
+++ b/configure.ac
@@ -264,10 +264,13 @@ if test x$enable_rdp_compositor = xyes; then
 [],
 [PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp >= 1.1.0],[])]
   )
-
   SAVED_CPPFLAGS="$CPPFLAGS"
   CPPFLAGS="$CPPFLAGS $RDP_COMPOSITOR_CFLAGS"
+
   AC_CHECK_HEADERS([freerdp/version.h])
+  
AC_CHECK_MEMBER([SURFACE_BITS_COMMAND.bmp],[have_bmp=1],[have_bmp=0],[[#include 
]])
+  AC_DEFINE([HAVE_SURFACE_BITS_BMP], $have_bmp, [SURFACE_BITS_CMD has bmp 
field])
+
   CPPFLAGS="$SAVED_CPPFLAGS"
 fi
 
diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
index 693f136a..6e70b303 100644
--- a/libweston/compositor-rdp.c
+++ b/libweston/compositor-rdp.c
@@ -66,6 +66,22 @@
 #define FREERDP_CB_RETURN(V) return TRUE
 #endif
 
+#ifdef HAVE_SURFACE_BITS_BMP
+#define SURFACE_BPP(cmd) cmd->bmp.bpp
+#define SURFACE_CODECID(cmd) cmd->bmp.codecID
+#define SURFACE_WIDTH(cmd) cmd->bmp.width
+#define SURFACE_HEIGHT(cmd) cmd->bmp.height
+#define SURFACE_BITMAP_DATA(cmd) cmd->bmp.bitmapData
+#define SURFACE_BITMAP_DATA_LEN(cmd) cmd->bmp.bitmapDataLength
+#else
+#define SURFACE_BPP(cmd) cmd->bpp
+#define SURFACE_CODECID(cmd) cmd->codecID
+#define SURFACE_WIDTH(cmd) cmd->width
+#define SURFACE_HEIGHT(cmd) cmd->height
+#define SURFACE_BITMAP_DATA(cmd) cmd->bitmapData
+#define SURFACE_BITMAP_DATA_LEN(cmd) cmd->bitmapDataLength
+#endif
+
 #include 
 #include 
 #include 
@@ -200,10 +216,10 @@ rdp_peer_refresh_rfx(pixman_region32_t *damage, 
pixman_image_t *image, freerdp_p
cmd->destTop = damage->extents.y1;
cmd->destRight = damage->extents.x2;
cmd->destBottom = damage->extents.y2;
-   cmd->bpp = 32;
-   cmd->codecID = peer->settings->RemoteFxCodecId;
-   cmd->width = width;
-   cmd->height = height;
+   SURFACE_BPP(cmd) = 32;
+   SURFACE_CODECID(cmd) = peer->settings->RemoteFxCodecId;
+   SURFACE_WIDTH(cmd) = width;
+   SURFACE_HEIGHT(cmd) = height;
 
ptr = pixman_image_get_data(image) + damage->extents.x1 +
damage->extents.y1 * 
(pixman_image_get_stride(image) / sizeof(uint32_t));
@@ -226,8 +242,8 @@ rdp_peer_refresh_rfx(pixman_region32_t *damage, 
pixman_image_t *image, freerdp_p
pixman_image_get_stride(image)
);
 
-   cmd->bitmapDataLength = Stream_GetPosition(context->encode_stream);
-   cmd->bitmapData = Stream_Buffer(context->encode_stream);
+   SURFACE_BITMAP_DATA_LEN(cmd) = 
Stream_GetPosition(context->encode_stream);
+   SURFACE_BITMAP_DATA(cmd) = Stream_Buffer(context->encode_stream);
 
update->SurfaceBits(update->context, cmd);
 }
@@ -253,23 +269,26 @@ rdp_peer_refresh_nsc(pixman_region32_t *damage, 
pixman_image_t *image, freerdp_p
 #else
memset(cmd, 0, sizeof(*cmd));
 #endif
+
cmd->destLeft = damage->extents.x1;
cmd->destTop = damage->extents.y1;
cmd->destRight = damage->extents.x2;
cmd->destBottom = damage->extents.y2;
-   cmd->bpp = 32;
-   cmd->codecID = peer->settings->NSCodecId;
-   cmd->width = width;
-   cmd->height = height;
+   SURFACE_BPP(cmd) = 32;
+   SURFACE_CODECID(cmd) = peer->settings->NSCodecId;
+   SURFACE_WIDTH(cmd) = width;
+   SURFACE_HEIGHT(cmd) = height;
 
ptr = pixman_image_get_data(image) + damage->extents.x1 +
damage->extents.y1 * 
(pixman_image_get_stride(image) / sizeof(uint32_t));
 
nsc_compose_message(context->nsc_context, context->encode_stream, (BYTE 
*)ptr,
-   cmd->width, cmd->height,
+   width, height,
pixman_image_get_stride(image));
-   cmd->bitmapDataLength = Stream_GetPosition(context->encode_stream);
-   cmd->bitmapData = Stream_Buffer(context->encode_stream);
+
+   SURFACE_BITMAP_DATA_LEN(cmd) = 
Stream_GetPosition(context->encode_stream);
+   SURFACE_BITMAP_DATA(cmd) = Stream_Buffer(context->encode_stream);
+
update->SurfaceBits(update->context, cmd);
 }
 
@@ -306,16 +325,16 @@ rdp_peer_refresh_raw(pixman_region32_t *region, 
pixman_image_t *image, freerdp_p
update->SurfaceFrameMarker(peer->context, marker);
 
memset(cmd, 0, sizeof(*cmd));
-   cmd->bpp = 32;
-   cmd->codecID = 0;
+   SURFACE_BPP(cmd) = 32;
+   SURFACE_CODECID(cmd) = 0;
 
for (i = 0; i < nrects; i++, rect++) {
/*weston_log("rect(%d,%d, %d,%d)\n", rect->x1, rect->y1, 
rect->x2, rect->y2);*/
cmd->destLeft = rect->x1;
cmd->destRight = rect->x2;
-   cmd->width = rect->x2 - rect->x1;
+   SURFACE_

[PATCH] rdp compositor: add a man page and add links to that page

2017-12-15 Thread David Fort
---
 Makefile.am|  5 +++
 man/weston-rdp.man | 92 ++
 man/weston.man | 13 
 3 files changed, 110 insertions(+)
 create mode 100644 man/weston-rdp.man

diff --git a/Makefile.am b/Makefile.am
index 7adc625..f67e693 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1563,6 +1563,10 @@ if ENABLE_DRM_COMPOSITOR
 man_MANS += weston-drm.7
 endif
 
+if ENABLE_RDP_COMPOSITOR
+man_MANS += weston-rdp.7
+endif
+
 MAN_SUBSTS =   \
-e 's|__weston_native_backend__|$(WESTON_NATIVE_BACKEND)|g' \
-e 's|__weston_modules_dir__|$(pkglibdir)|g'\
@@ -1577,6 +1581,7 @@ SUFFIXES = .1 .5 .7 .man
 EXTRA_DIST +=  \
man/weston.man  \
man/weston-drm.man  \
+   man/weston-rdp.man  \
man/weston.ini.man
 
 CLEANFILES += $(man_MANS)
diff --git a/man/weston-rdp.man b/man/weston-rdp.man
new file mode 100644
index 000..0916c8d
--- /dev/null
+++ b/man/weston-rdp.man
@@ -0,0 +1,92 @@
+.TH WESTON-RDP 7 "2017-12-14" "Weston __version__"
+.SH NAME
+weston-rdp \- the RDP backend for Weston
+.SH SYNOPSIS
+.B weston --backend=rdp-backend.so
+.
+.\" ***
+.SH DESCRIPTION
+The RDP backend allows to run a
+.B weston
+environment without the need of specific graphic hardware, or input devices. 
Users can interact with
+.B weston
+only by connecting using the RDP protocol.
+
+The RDP backend uses FreeRDP to implement the RDP part, it acts as a RDP server
+listening for incoming connections. It supports different codecs for encoding 
the
+graphical content. Depending on what is supported by the RDP client, the 
backend will
+encode images using remoteFx codec, NS codec or will fallback to raw 
bitmapUpdate.
+
+On the security part, the backend supports RDP security or TLS, keys and 
certificates
+must be provided to the backend depending on which kind of security is 
requested. The RDP
+backend will announce security options based on which files have been given.
+
+The RDP backend is multi-seat aware, so if two clients connect on the backend,
+they will get their own seat.
+
+.\" ***
+.SH OPTIONS
+.
+When the RDP backend is loaded,
+.B weston
+will understand the following additional command line options.
+.TP
+.B \-\-address\fR=\fIaddress\fR
+The IP address on which the RDP backend will listen for RDP connections. By
+default it listens on 0.0.0.0.
+.TP
+\fB\-\-port\fR=\fIport\fR
+The TCP port to listen on for connections, it defaults to 3389.
+.TP
+\fB\-\-no-clients-resize
+By default when a client connects on the RDP backend, it will instruct weston 
to
+resize to the dimensions of the client's announced resolution. When this 
option is
+set, weston will force the client to resize to its own resolution.
+.TP
+\fB\-\-rdp4\-key\fR=\fIfile\fR
+The file containing the RSA key for doing RDP security. As RDP security is 
known
+to be insecure, this option should be avoided in production.
+.TP
+\fB\-\-rdp\-tls\-key\fR=\fIfile\fR
+The file containing the key for doing TLS security. To have TLS security you 
also need
+to ship a file containing a certificate.
+.TP
+\fB\-\-rdp\-tls\-cert\fR=\fIfile\fR
+The file containing the certificate for doing TLS security. To have TLS 
security you also need
+to ship a key file.
+
+
+.\" ***
+.SH Generating cryptographic material for the RDP backend
+.
+To generate a key file to use for RDP security, you need the
+.BR winpr-makecert
+utility shipped with FreeRDP:
+
+.nf
+$ winpr-makecert -rdp -silent -n rdp-security
+.fi
+
+This will create a rdp-security.key file.
+
+
+You can generate a key and certificate file to use with TLS security using a 
typical
+.B openssl
+invocations:
+
+.nf
+$ openssl genrsa -out tls.key 2048
+Generating RSA private key, 2048 bit long modulus
+[...]
+$ openssl req -new -key tls.key -out tls.csr
+[...]
+$ openssl x509 -req -days 365 -signkey tls.key -in tls.csr -out tls.crt
+[...]
+.fi
+
+You will get the tls.key and tls.crt files to use with the RDP backend.
+.
+.\" ***
+.SH "SEE ALSO"
+.BR weston (1)
+.\".BR weston.ini (5)
diff --git a/man/weston.man b/man/weston.man
index cd53df6..7c3416c 100644
--- a/man/weston.man
+++ b/man/weston.man
@@ -46,6 +46,13 @@ the parent server.
 The X11 backend runs on an X server. Each Weston output becomes an
 X window. This is a cheap way to test multi-monitor support of a
 Wayland shell, desktop, or applications.
+.TP
+.I rdp-backend.so
+The RDP backend runs in memory without the need of graphical hardware. Access
+to the desktop is done by using the RDP protocol. Each connecting
+client has its own seat making it a cheap way to test multi

[PATCH] rdp compositor: add a man page

2017-12-14 Thread David Fort
---
 Makefile.am|  5 +++
 man/weston-rdp.man | 92 ++
 2 files changed, 97 insertions(+)
 create mode 100644 man/weston-rdp.man

diff --git a/Makefile.am b/Makefile.am
index 7adc625..f67e693 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1563,6 +1563,10 @@ if ENABLE_DRM_COMPOSITOR
 man_MANS += weston-drm.7
 endif
 
+if ENABLE_RDP_COMPOSITOR
+man_MANS += weston-rdp.7
+endif
+
 MAN_SUBSTS =   \
-e 's|__weston_native_backend__|$(WESTON_NATIVE_BACKEND)|g' \
-e 's|__weston_modules_dir__|$(pkglibdir)|g'\
@@ -1577,6 +1581,7 @@ SUFFIXES = .1 .5 .7 .man
 EXTRA_DIST +=  \
man/weston.man  \
man/weston-drm.man  \
+   man/weston-rdp.man  \
man/weston.ini.man
 
 CLEANFILES += $(man_MANS)
diff --git a/man/weston-rdp.man b/man/weston-rdp.man
new file mode 100644
index 000..88c795a
--- /dev/null
+++ b/man/weston-rdp.man
@@ -0,0 +1,92 @@
+.TH WESTON-RDP 7 "2017-12-14" "Weston __version__"
+.SH NAME
+weston-rdp \- the RDP backend for Weston
+.SH SYNOPSIS
+.B weston --backend=rdp-backend.so
+.
+.\" ***
+.SH DESCRIPTION
+The RDP backend allows to run a
+.B weston
+environment without the need of specific graphic hardware, or input devices. 
Users can interact with
+.B weston
+only by connecting using the RDP protocol.
+
+The RDP backend uses FreeRDP to implement the RDP part, it acts as a RDP server
+listening for incoming connections. It supports different codecs for encoding 
the
+graphical content. Depending on what is supported by the RDP client, the 
backend will
+encode images using remoteFx codec, NS codec or will fallback to raw 
bitmapUpdate.
+
+On the security part, the backend supports RDP security or TLS, keys and 
certificates
+must be provided to the backend depending on which kind of security is 
requested. The RDP
+backend will announced security options based on which files have been given.
+
+The RDP backend is multi-seat aware, so if two clients connect on the backend,
+they will get their own seat.
+
+.\" ***
+.SH OPTIONS
+.
+When the RDP backend is loaded,
+.B weston
+will understand the following additional command line options.
+.TP
+.B \-\-address\fR=\fIaddress\fR
+The IP address on which the RDP backend will listen for RDP connections. By
+default it listens on 0.0.0.0.
+.TP
+\fB\-\-port\fR=\fIport\fR
+The TCP port to listen on for connections, it defaults to 3389.
+.TP
+\fB\-\-no-clients-resize
+By default when a client connects on the RDP backend, it will instruct weston 
to
+resize to the dimensions of the client's announced resolution. When this 
option is
+set, weston will force the client to resize to its own resolution.
+.TP
+\fB\-\-rdp4\-key\fR=\fIfile\fR
+The file containing the RSA key for doing RDP security. As RDP security is 
known
+to be insecure, this option should be avoided in production.
+.TP
+\fB\-\-rdp\-tls\-key\fR=\fIfile\fR
+The file containing the key for doing TLS security. To have TLS security you 
also need
+to ship a file containing a certificate.
+.TP
+\fB\-\-rdp\-tls\-cert\fR=\fIfile\fR
+The file containing the certificate for doing TLS security. To have TLS 
security you also need
+to ship a key file.
+
+
+.\" ***
+.SH Generating cryptographic material for the RDP backend
+.
+To generate a key file to use for RDP security, you need the
+.BR winpr-makecert
+utility shipped with FreeRDP:
+
+.nf
+$ winpr-makecert -rdp -silent -n rdp-security
+.fi
+
+This will create a rdp-security.key file.
+
+
+You can generate a key and certificate file to use with TLS security using a 
typical
+.B openssl
+invocations:
+
+.nf
+$ openssl genrsa -out tls.key 2048
+Generating RSA private key, 2048 bit long modulus
+[...]
+$ openssl req -new -key tls.key -out tls.csr
+[...]
+$ openssl x509 -req -days 365 -signkey tls.key -in tls.csr -out tls.crt
+[...]
+.fi
+
+You will get the tls.key and tls.crt files to use with the RDP backend.
+.
+.\" ***
+.SH "SEE ALSO"
+.BR weston (1)
+.\".BR weston.ini (5)
-- 
2.7.4

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


[PATCH] Fix API troubles with FreeRDP 2.0 v2

2017-09-27 Thread David Fort
With FreeRDP 2.0 the crypto needs to be initialized or we fail as soon as we 
try to
compute a md5. The API also changed for the suppress output callback.
---
 libweston/compositor-rdp.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
index 091472b..ddc49ab 100644
--- a/libweston/compositor-rdp.c
+++ b/libweston/compositor-rdp.c
@@ -76,6 +76,10 @@
 #include 
 #include 
 
+#if FREERDP_VERSION_MAJOR >= 2
+#include 
+#endif
+
 #include "shared/helpers.h"
 #include "compositor.h"
 #include "compositor-rdp.h"
@@ -1013,7 +1017,8 @@ xf_peer_activate(freerdp_peer* client)
return TRUE;
 }
 
-static BOOL xf_peer_post_connect(freerdp_peer *client)
+static BOOL
+xf_peer_post_connect(freerdp_peer *client)
 {
return TRUE;
 }
@@ -1166,7 +1171,7 @@ xf_input_unicode_keyboard_event(rdpInput *input, UINT16 
flags, UINT16 code)
 
 
 static FREERDP_CB_RET_TYPE
-xf_suppress_output(rdpContext *context, BYTE allow, RECTANGLE_16 *area)
+xf_suppress_output(rdpContext *context, BYTE allow, const RECTANGLE_16 *area)
 {
RdpPeerContext *peerContext = (RdpPeerContext *)context;
 
@@ -1227,7 +1232,7 @@ rdp_peer_init(freerdp_peer *client, struct rdp_backend *b)
client->PostConnect = xf_peer_post_connect;
client->Activate = xf_peer_activate;
 
-   client->update->SuppressOutput = xf_suppress_output;
+   client->update->SuppressOutput = (pSuppressOutput)xf_suppress_output;
 
input = client->input;
input->SynchronizeEvent = xf_input_synchronize_event;
@@ -1387,6 +1392,9 @@ weston_backend_init(struct weston_compositor *compositor,
struct weston_rdp_backend_config config = {{ 0, }};
int major, minor, revision;
 
+#if FREERDP_VERSION_MAJOR >= 2
+   winpr_InitializeSSL(0);
+#endif
freerdp_get_version(&major, &minor, &revision);
weston_log("using FreeRDP version %d.%d.%d\n", major, minor, revision);
 
-- 
2.7.4

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


[PATCH] Fix API troubles with FreeRDP 2.0

2017-09-22 Thread David Fort
With FreeRDP 2.0 the crypto needs to be initialized or we fail as soon as we 
try to
compute a md5. The API also changed for the suppress output callback.
---
 libweston/compositor-rdp.c | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c
index 091472b..6706765 100644
--- a/libweston/compositor-rdp.c
+++ b/libweston/compositor-rdp.c
@@ -76,6 +76,10 @@
 #include 
 #include 
 
+#if FREERDP_VERSION_MAJOR >= 2
+#include 
+#endif
+
 #include "shared/helpers.h"
 #include "compositor.h"
 #include "compositor-rdp.h"
@@ -159,6 +163,7 @@ to_rdp_backend(struct weston_compositor *base)
return container_of(base->backend, struct rdp_backend, base);
 }
 
+
 static void
 rdp_peer_refresh_rfx(pixman_region32_t *damage, pixman_image_t *image, 
freerdp_peer *peer)
 {
@@ -1013,7 +1018,8 @@ xf_peer_activate(freerdp_peer* client)
return TRUE;
 }
 
-static BOOL xf_peer_post_connect(freerdp_peer *client)
+static BOOL
+xf_peer_post_connect(freerdp_peer *client)
 {
return TRUE;
 }
@@ -1166,7 +1172,11 @@ xf_input_unicode_keyboard_event(rdpInput *input, UINT16 
flags, UINT16 code)
 
 
 static FREERDP_CB_RET_TYPE
+#if FREERDP_VERSION_MAJOR >= 2
+xf_suppress_output(rdpContext *context, BYTE allow, const RECTANGLE_16 *area)
+#else
 xf_suppress_output(rdpContext *context, BYTE allow, RECTANGLE_16 *area)
+#endif
 {
RdpPeerContext *peerContext = (RdpPeerContext *)context;
 
@@ -1387,6 +1397,9 @@ weston_backend_init(struct weston_compositor *compositor,
struct weston_rdp_backend_config config = {{ 0, }};
int major, minor, revision;
 
+#if FREERDP_VERSION_MAJOR >= 2
+   winpr_InitializeSSL(0);
+#endif
freerdp_get_version(&major, &minor, &revision);
weston_log("using FreeRDP version %d.%d.%d\n", major, minor, revision);
 
-- 
2.7.4

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


[PATCH] desktop-shell: resize background and panel surfaces on output resize v4

2016-06-09 Thread David Fort
When an output is resized (permanent mode switch), we should also notify the
shell client so that the panel and background fits to the new screen dimensions.

Signed-off-by: David Fort 
---
 desktop-shell/shell.c | 80 +++
 desktop-shell/shell.h |  7 +
 2 files changed, 87 insertions(+)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index b1fb2fa..79cf8dd 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -4365,6 +4365,20 @@ configure_static_view(struct weston_view *ev, struct 
weston_layer *layer)
}
 }
 
+
+static struct shell_output *
+find_shell_output_from_weston_output(struct desktop_shell *shell, struct 
weston_output *output)
+{
+   struct shell_output *shell_output;
+
+   wl_list_for_each(shell_output, &shell->output_list, link) {
+   if (shell_output->output == output)
+   return shell_output;
+   }
+
+   return NULL;
+}
+
 static int
 background_get_label(struct weston_surface *surface, char *buf, size_t len)
 {
@@ -4384,6 +4398,16 @@ background_configure(struct weston_surface *es, int32_t 
sx, int32_t sy)
 }
 
 static void
+handle_background_surface_destroy(struct wl_listener *listener, void *data)
+{
+   struct shell_output *output =
+   container_of(listener, struct shell_output, 
background_surface_listener);
+
+   weston_log("background surface gone\n");
+   output->background_surface = NULL;
+}
+
+static void
 desktop_shell_set_background(struct wl_client *client,
 struct wl_resource *resource,
 struct wl_resource *output_resource,
@@ -4392,6 +4416,7 @@ desktop_shell_set_background(struct wl_client *client,
struct desktop_shell *shell = wl_resource_get_user_data(resource);
struct weston_surface *surface =
wl_resource_get_user_data(surface_resource);
+   struct shell_output *sh_output;
struct weston_view *view, *next;
 
if (surface->configure) {
@@ -4414,6 +4439,12 @@ desktop_shell_set_background(struct wl_client *client,
surface_resource,
surface->output->width,
surface->output->height);
+
+   sh_output = find_shell_output_from_weston_output(shell, 
surface->output);
+   sh_output->background_surface = surface;
+
+   sh_output->background_surface_listener.notify = 
handle_background_surface_destroy;
+   wl_signal_add(&surface->destroy_signal, 
&sh_output->background_surface_listener);
 }
 
 static int
@@ -4435,6 +4466,17 @@ panel_configure(struct weston_surface *es, int32_t sx, 
int32_t sy)
 }
 
 static void
+handle_panel_surface_destroy(struct wl_listener *listener, void *data)
+{
+   struct shell_output *output =
+   container_of(listener, struct shell_output, panel_surface_listener);
+
+   weston_log("panel surface gone\n");
+   output->panel_surface = NULL;
+}
+
+
+static void
 desktop_shell_set_panel(struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *output_resource,
@@ -,6 +4486,7 @@ desktop_shell_set_panel(struct wl_client *client,
struct weston_surface *surface =
wl_resource_get_user_data(surface_resource);
struct weston_view *view, *next;
+   struct shell_output *sh_output;
 
if (surface->configure) {
wl_resource_post_error(surface_resource,
@@ -4465,6 +4508,12 @@ desktop_shell_set_panel(struct wl_client *client,
surface_resource,
surface->output->width,
surface->output->height);
+
+   sh_output = find_shell_output_from_weston_output(shell, 
surface->output);
+   sh_output->panel_surface = surface;
+
+   sh_output->panel_surface_listener.notify = handle_panel_surface_destroy;
+   wl_signal_add(&surface->destroy_signal, 
&sh_output->panel_surface_listener);
 }
 
 static int
@@ -6382,6 +6431,33 @@ handle_output_destroy(struct wl_listener *listener, void 
*data)
 }
 
 static void
+shell_resize_surface_to_output(struct desktop_shell *shell,
+   struct weston_surface *surface,
+   const struct weston_output *output)
+{
+   if (!surface)
+   return;
+
+   weston_desktop_shell_send_configure(shell->child.desktop_shell, 0,
+   surface->resource,
+   output->width,
+   output->height);
+}
+
+
+static void
+handle_output_resized(struct wl_listener *listener, void *data)
+{
+   

[PATCH 3/3] desktop-shell: resize background and panel surfaces on output resize

2016-05-27 Thread David Fort
When an output is resized (permanent mode switch), we should also notify the
shell client so that the panel and background fits to the new screen dimensions.

Signed-off-by: David Fort 
---
 desktop-shell/shell.c | 93 +++
 desktop-shell/shell.h |  8 -
 2 files changed, 86 insertions(+), 15 deletions(-)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 7d5bca9..42c0757 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -4364,6 +4364,20 @@ configure_static_view(struct weston_view *ev, struct 
weston_layer *layer)
}
 }
 
+
+static struct shell_output *
+find_shell_output_from_weston_output(struct desktop_shell *shell, struct 
weston_output *output)
+{
+   struct shell_output *shell_output;
+
+   wl_list_for_each(shell_output, &shell->output_list, link) {
+   if (shell_output->output == output)
+   return shell_output;
+   }
+
+   return NULL;
+}
+
 static int
 background_get_label(struct weston_surface *surface, char *buf, size_t len)
 {
@@ -4383,6 +4397,16 @@ background_configure(struct weston_surface *es, int32_t 
sx, int32_t sy)
 }
 
 static void
+handle_background_surface_destroy(struct wl_listener *listener, void *data)
+{
+   struct shell_output *output =
+   container_of(listener, struct shell_output, 
background_surface_listener);
+
+   weston_log("background surface gone\n");
+   output->background_surface = NULL;
+}
+
+static void
 desktop_shell_set_background(struct wl_client *client,
 struct wl_resource *resource,
 struct wl_resource *output_resource,
@@ -4391,6 +4415,7 @@ desktop_shell_set_background(struct wl_client *client,
struct desktop_shell *shell = wl_resource_get_user_data(resource);
struct weston_surface *surface =
wl_resource_get_user_data(surface_resource);
+   struct shell_output *sh_output;
struct weston_view *view, *next;
 
if (surface->configure) {
@@ -4413,6 +4438,12 @@ desktop_shell_set_background(struct wl_client *client,
surface_resource,
surface->output->width,
surface->output->height);
+
+   sh_output = find_shell_output_from_weston_output(shell, 
surface->output);
+   sh_output->background_surface = surface;
+
+   sh_output->background_surface_listener.notify = 
handle_background_surface_destroy;
+   wl_signal_add(&surface->destroy_signal, 
&sh_output->background_surface_listener);
 }
 
 static int
@@ -4434,6 +4465,17 @@ panel_configure(struct weston_surface *es, int32_t sx, 
int32_t sy)
 }
 
 static void
+handle_panel_surface_destroy(struct wl_listener *listener, void *data)
+{
+   struct shell_output *output =
+   container_of(listener, struct shell_output, panel_surface_listener);
+
+   weston_log("panel surface gone\n");
+   output->panel_surface = NULL;
+}
+
+
+static void
 desktop_shell_set_panel(struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *output_resource,
@@ -4443,6 +4485,7 @@ desktop_shell_set_panel(struct wl_client *client,
struct weston_surface *surface =
wl_resource_get_user_data(surface_resource);
struct weston_view *view, *next;
+   struct shell_output *sh_output;
 
if (surface->configure) {
wl_resource_post_error(surface_resource,
@@ -4464,6 +4507,12 @@ desktop_shell_set_panel(struct wl_client *client,
surface_resource,
surface->output->width,
surface->output->height);
+
+   sh_output = find_shell_output_from_weston_output(shell, 
surface->output);
+   sh_output->panel_surface = surface;
+
+   sh_output->panel_surface_listener.notify = handle_panel_surface_destroy;
+   wl_signal_add(&surface->destroy_signal, 
&sh_output->panel_surface_listener);
 }
 
 static int
@@ -4494,16 +4543,6 @@ lock_surface_configure(struct weston_surface *surface, 
int32_t sx, int32_t sy)
 }
 
 static void
-handle_lock_surface_destroy(struct wl_listener *listener, void *data)
-{
-   struct desktop_shell *shell =
-   container_of(listener, struct desktop_shell, lock_surface_listener);
-
-   weston_log("lock surface gone\n");
-   shell->lock_surface = NULL;
-}
-
-static void
 desktop_shell_set_lock_surface(struct wl_client *client,
   struct wl_resource *resource,
   struct wl_resource *surface_resource)
@@ -4519,10 +4558,6 @@ desktop_shell_set_lock_surface(struct wl_client 

[PATCH 2/3] compositor: recompute output position on mode switch

2016-05-27 Thread David Fort
When an output permanently changes its resolution, the output on the right
should be moved accordingly. We also add an event for output resizing so that
plugins can react when an output is resized.

Signed-off-by: David Fort 
Reviewed-by: Pekka Paalanen 
---
 src/compositor.c | 35 +--
 src/compositor.h |  1 +
 2 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index b6ef7f3..37fdd0c 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -143,6 +143,11 @@ static void weston_mode_switch_finish(struct weston_output 
*output,
}
 }
 
+
+static void
+weston_compositor_reflow_outputs(struct weston_compositor *compositor,
+   struct weston_output *resized_output, int 
delta_width);
+
 WL_EXPORT int
 weston_output_mode_set_native(struct weston_output *output,
  struct weston_mode *mode,
@@ -150,6 +155,7 @@ weston_output_mode_set_native(struct weston_output *output,
 {
int ret;
int mode_changed = 0, scale_changed = 0;
+   int32_t old_width;
 
if (!output->switch_mode)
return -1;
@@ -165,11 +171,17 @@ weston_output_mode_set_native(struct weston_output 
*output,
}
}
 
+   old_width = output->width;
output->native_mode = mode;
output->native_scale = scale;
 
weston_mode_switch_finish(output, mode_changed, scale_changed);
 
+   if (mode_changed || scale_changed) {
+   weston_compositor_reflow_outputs(output->compositor, output, 
output->width - old_width);
+
+   wl_signal_emit(&output->compositor->output_resized_signal, 
output);
+   }
return 0;
 }
 
@@ -4062,23 +4074,25 @@ bind_output(struct wl_client *client,
wl_output_send_done(resource);
 }
 
-/* Move other outputs when one is removed so the space remains contiguos. */
+/* Move other outputs when one is resized so the space remains contiguous. */
 static void
-weston_compositor_remove_output(struct weston_compositor *compositor,
-   struct weston_output *remove_output)
+weston_compositor_reflow_outputs(struct weston_compositor *compositor,
+   struct weston_output *resized_output, int 
delta_width)
 {
struct weston_output *output;
-   int offset = 0;
+   bool start_resizing = false;
+
+   if (!delta_width)
+   return;
 
wl_list_for_each(output, &compositor->output_list, link) {
-   if (output == remove_output) {
-   offset = output->width;
+   if (output == resized_output) {
+   start_resizing = true;
continue;
}
 
-   if (offset > 0) {
-   weston_output_move(output,
-  output->x - offset, output->y);
+   if (start_resizing) {
+   weston_output_move(output, output->x + delta_width, 
output->y);
output->dirty = 1;
}
}
@@ -4101,7 +4115,7 @@ weston_output_destroy(struct weston_output *output)
 
weston_presentation_feedback_discard_list(&output->feedback_list);
 
-   weston_compositor_remove_output(output->compositor, output);
+   weston_compositor_reflow_outputs(output->compositor, output, 
output->width);
wl_list_remove(&output->link);
 
wl_signal_emit(&output->compositor->output_destroyed_signal, output);
@@ -4704,6 +4718,7 @@ weston_compositor_create(struct wl_display *display, void 
*user_data)
wl_signal_init(&ec->output_created_signal);
wl_signal_init(&ec->output_destroyed_signal);
wl_signal_init(&ec->output_moved_signal);
+   wl_signal_init(&ec->output_resized_signal);
wl_signal_init(&ec->session_signal);
ec->session_active = 1;
 
diff --git a/src/compositor.h b/src/compositor.h
index 0bbf458..7c6d7d9 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -744,6 +744,7 @@ struct weston_compositor {
struct wl_signal output_created_signal;
struct wl_signal output_destroyed_signal;
struct wl_signal output_moved_signal;
+   struct wl_signal output_resized_signal; /* callback argument: resized 
output */
 
struct wl_signal session_signal;
int session_active;
-- 
2.7.4

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


[PATCH 0/3] RDP compositor needs love v3

2016-05-27 Thread David Fort
So, the RDP compositor were given some love (2 patches integrated). 
I have made the changes for seat releasing.
And I have also modified the handling of output resize and it should be better 
now.

David Fort (3):
  rdp: don't release the seat until it is safe v2
  compositor: recompute output position on mode switch
  desktop-shell: resize background and panel surfaces on output resize

 desktop-shell/shell.c | 93 +++
 desktop-shell/shell.h |  8 -
 src/compositor-rdp.c  | 34 ---
 src/compositor.c  | 35 +--
 src/compositor.h  |  1 +
 5 files changed, 133 insertions(+), 38 deletions(-)

-- 
2.7.4

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


[PATCH 1/3] rdp: don't release the seat until it is safe v2

2016-05-27 Thread David Fort
Releasing a seat is not safe, so let's just announce it without keyboard
and mouse until this is fixed. Without this patch we just can't reconnect on
the RDP compositor as it crashes.

v2: fixed the leak of the xkb_keymap

Signed-off-by: David Fort 
Acked-by: Pekka Paalanen 
Reviewed-by: Sam Spilsbury 
---
 src/compositor-rdp.c | 34 +-
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index 4fc7c74..1e7019f 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -109,7 +109,7 @@ enum peer_item_flags {
 struct rdp_peers_item {
int flags;
freerdp_peer *peer;
-   struct weston_seat seat;
+   struct weston_seat *seat;
 
struct wl_list link;
 };
@@ -640,9 +640,10 @@ rdp_peer_context_free(freerdp_peer* client, 
RdpPeerContext* context)
}
 
if (context->item.flags & RDP_PEER_ACTIVATED) {
-   weston_seat_release_keyboard(&context->item.seat);
-   weston_seat_release_pointer(&context->item.seat);
-   weston_seat_release(&context->item.seat);
+   weston_seat_release_keyboard(context->item.seat);
+   weston_seat_release_pointer(context->item.seat);
+   /* XXX we should weston_seat_release(context->item.seat); here
+* but it would crash on reconnect */
}
 
Stream_Free(context->encode_stream, TRUE);
@@ -911,9 +912,16 @@ xf_peer_activate(freerdp_peer* client)
else
snprintf(seat_name, sizeof(seat_name), "RDP peer @%s", 
settings->ClientAddress);
 
-   weston_seat_init(&peersItem->seat, b->compositor, seat_name);
-   weston_seat_init_keyboard(&peersItem->seat, keymap);
-   weston_seat_init_pointer(&peersItem->seat);
+   peersItem->seat = zalloc(sizeof(*peersItem->seat));
+   if (!peersItem->seat) {
+   xkb_keymap_unref(keymap);
+   weston_log("unable to create a weston_seat\n");
+   return FALSE;
+   }
+
+   weston_seat_init(peersItem->seat, b->compositor, seat_name);
+   weston_seat_init_keyboard(peersItem->seat, keymap);
+   weston_seat_init_pointer(peersItem->seat);
 
peersItem->flags |= RDP_PEER_ACTIVATED;
 
@@ -952,7 +960,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
UINT16 y)
if (flags & PTR_FLAGS_MOVE) {
output = peerContext->rdpBackend->output;
if (x < output->base.width && y < output->base.height) {
-   notify_motion_absolute(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_motion_absolute(peerContext->item.seat, 
weston_compositor_get_time(),
x, y);
need_frame = true;
}
@@ -966,7 +974,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
UINT16 y)
button = BTN_MIDDLE;
 
if (button) {
-   notify_button(&peerContext->item.seat, 
weston_compositor_get_time(), button,
+   notify_button(peerContext->item.seat, 
weston_compositor_get_time(), button,
(flags & PTR_FLAGS_DOWN) ? 
WL_POINTER_BUTTON_STATE_PRESSED : WL_POINTER_BUTTON_STATE_RELEASED
);
need_frame = true;
@@ -991,13 +999,13 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
UINT16 y)
weston_event.discrete = (int)value;
weston_event.has_discrete = true;
 
-   notify_axis(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_axis(peerContext->item.seat, 
weston_compositor_get_time(),
&weston_event);
need_frame = true;
}
 
if (need_frame)
-   notify_pointer_frame(&peerContext->item.seat);
+   notify_pointer_frame(peerContext->item.seat);
 
FREERDP_CB_RETURN(TRUE);
 }
@@ -1010,7 +1018,7 @@ xf_extendedMouseEvent(rdpInput *input, UINT16 flags, 
UINT16 x, UINT16 y)
 
output = peerContext->rdpBackend->output;
if (x < output->base.width && y < output->base.height) {
-   notify_motion_absolute(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_motion_absolute(peerContext->item.seat, 
weston_compositor_get_time(),
x, y);
}
 
@@ -1073,7 +1081,7 @@ xf_input_keyboard_event(rdpInput *input, UINT16 flags, 
UINT16 code)
 
/*weston_log("code=%x ext=%d vk_code=%x scan_code=%x\n", code, 
(flags & KBD_FLAGS_EXTENDED) ? 1 : 0,
vk_code, scan_code);*/
-   notify_key(

[PATCH] rdp: don't release the seat until it is safe v2

2016-05-20 Thread David Fort
Releasing a seat is not safe, so let's just announce it without keyboard
and mouse until this is fixed. Without this patch we just can't reconnect on
the RDP compositor as it crashes.

v2: fixed the leak of the xkb_keymap

Signed-off-by: David Fort 
---
 src/compositor-rdp.c | 33 -
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index 4fc7c74..52cf426 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -109,7 +109,7 @@ enum peer_item_flags {
 struct rdp_peers_item {
int flags;
freerdp_peer *peer;
-   struct weston_seat seat;
+   struct weston_seat *seat;
 
struct wl_list link;
 };
@@ -640,9 +640,9 @@ rdp_peer_context_free(freerdp_peer* client, RdpPeerContext* 
context)
}
 
if (context->item.flags & RDP_PEER_ACTIVATED) {
-   weston_seat_release_keyboard(&context->item.seat);
-   weston_seat_release_pointer(&context->item.seat);
-   weston_seat_release(&context->item.seat);
+   weston_seat_release_keyboard(context->item.seat);
+   weston_seat_release_pointer(context->item.seat);
+   /*weston_seat_release(context->item.seat);*/
}
 
Stream_Free(context->encode_stream, TRUE);
@@ -911,9 +911,16 @@ xf_peer_activate(freerdp_peer* client)
else
snprintf(seat_name, sizeof(seat_name), "RDP peer @%s", 
settings->ClientAddress);
 
-   weston_seat_init(&peersItem->seat, b->compositor, seat_name);
-   weston_seat_init_keyboard(&peersItem->seat, keymap);
-   weston_seat_init_pointer(&peersItem->seat);
+   peersItem->seat = zalloc(sizeof(*peersItem->seat));
+   if (!peersItem->seat) {
+   xkb_keymap_unref(keymap);
+   weston_log("unable to create a weston_seat\n");
+   return FALSE;
+   }
+
+   weston_seat_init(peersItem->seat, b->compositor, seat_name);
+   weston_seat_init_keyboard(peersItem->seat, keymap);
+   weston_seat_init_pointer(peersItem->seat);
 
peersItem->flags |= RDP_PEER_ACTIVATED;
 
@@ -952,7 +959,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
UINT16 y)
if (flags & PTR_FLAGS_MOVE) {
output = peerContext->rdpBackend->output;
if (x < output->base.width && y < output->base.height) {
-   notify_motion_absolute(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_motion_absolute(peerContext->item.seat, 
weston_compositor_get_time(),
x, y);
need_frame = true;
}
@@ -966,7 +973,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
UINT16 y)
button = BTN_MIDDLE;
 
if (button) {
-   notify_button(&peerContext->item.seat, 
weston_compositor_get_time(), button,
+   notify_button(peerContext->item.seat, 
weston_compositor_get_time(), button,
(flags & PTR_FLAGS_DOWN) ? 
WL_POINTER_BUTTON_STATE_PRESSED : WL_POINTER_BUTTON_STATE_RELEASED
);
need_frame = true;
@@ -991,13 +998,13 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
UINT16 y)
weston_event.discrete = (int)value;
weston_event.has_discrete = true;
 
-   notify_axis(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_axis(peerContext->item.seat, 
weston_compositor_get_time(),
&weston_event);
need_frame = true;
}
 
if (need_frame)
-   notify_pointer_frame(&peerContext->item.seat);
+   notify_pointer_frame(peerContext->item.seat);
 
FREERDP_CB_RETURN(TRUE);
 }
@@ -1010,7 +1017,7 @@ xf_extendedMouseEvent(rdpInput *input, UINT16 flags, 
UINT16 x, UINT16 y)
 
output = peerContext->rdpBackend->output;
if (x < output->base.width && y < output->base.height) {
-   notify_motion_absolute(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_motion_absolute(peerContext->item.seat, 
weston_compositor_get_time(),
x, y);
}
 
@@ -1073,7 +1080,7 @@ xf_input_keyboard_event(rdpInput *input, UINT16 flags, 
UINT16 code)
 
/*weston_log("code=%x ext=%d vk_code=%x scan_code=%x\n", code, 
(flags & KBD_FLAGS_EXTENDED) ? 1 : 0,
vk_code, scan_code);*/
-   notify_key(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_key(peerContext->item.seat, w

[PATCH 1/6] rdp: allow to compile against FreeRDP 2.0

2016-05-01 Thread David Fort
FreeRDP 2.0 is about to be released, this allows to compile against this 
version.
The detection is adjusted to prefer FreeRDP 2 against version 1.x.

Signed-off-by: David Fort 
---
 configure.ac |  5 -
 src/compositor-rdp.c | 23 ---
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4199616..6ab9c99 100644
--- a/configure.ac
+++ b/configure.ac
@@ -238,7 +238,10 @@ AM_CONDITIONAL([ENABLE_RDP_COMPOSITOR],
[test x$enable_rdp_compositor = xyes])
 if test x$enable_rdp_compositor = xyes; then
   AC_DEFINE([BUILD_RDP_COMPOSITOR], [1], [Build the RDP compositor])
-  PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp >= 1.1.0])
+  PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp2 >= 2.0.0],
+[],
+[PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp >= 1.1.0],[])]
+  )
 
   SAVED_CPPFLAGS="$CPPFLAGS"
   CPPFLAGS="$CPPFLAGS $RDP_COMPOSITOR_CFLAGS"
diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index 2860556..f6778b6 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -42,15 +42,24 @@
 #define FREERDP_VERSION_NUMBER ((FREERDP_VERSION_MAJOR * 0x1) + \
(FREERDP_VERSION_MINOR * 0x100) + FREERDP_VERSION_REVISION)
 
+
 #if FREERDP_VERSION_NUMBER >= 0x10201
 #define HAVE_SKIP_COMPRESSION
 #endif
 
 #if FREERDP_VERSION_NUMBER < 0x10202
-#define FREERDP_CB_RET_TYPE void
-#define FREERDP_CB_RETURN(V) return
+#  define FREERDP_CB_RET_TYPE void
+#  define FREERDP_CB_RETURN(V) return
+#  define NSC_RESET(C, W, H)
+#  define RFX_RESET(C, W, H) do { rfx_context_reset(C); C->width = W; 
C->height = H; } while(0)
+#else
+#if FREERDP_VERSION_MAJOR >= 2
+#  define NSC_RESET(C, W, H) nsc_context_reset(C, W, H)
+#  define RFX_RESET(C, W, H) rfx_context_reset(C, W, H)
 #else
-#define HAVE_NSC_RESET
+#  define NSC_RESET(C, W, H) do { nsc_context_reset(C); C->width = W; 
C->height = H; } while(0)
+#  define RFX_RESET(C, W, H) do { rfx_context_reset(C); C->width = W; 
C->height = H; } while(0)
+#endif
 #define FREERDP_CB_RET_TYPE BOOL
 #define FREERDP_CB_RETURN(V) return TRUE
 #endif
@@ -795,6 +804,7 @@ xf_peer_activate(freerdp_peer* client)
struct xkb_context *xkbContext;
struct xkb_rule_names xkbRuleNames;
struct xkb_keymap *keymap;
+   struct weston_output *weston_output;
int i;
pixman_box32_t box;
pixman_region32_t damage;
@@ -843,10 +853,9 @@ xf_peer_activate(freerdp_peer* client)
}
}
 
-   rfx_context_reset(peerCtx->rfx_context);
-#ifdef HAVE_NSC_RESET
-   nsc_context_reset(peerCtx->nsc_context);
-#endif
+   weston_output = &output->base;
+   RFX_RESET(peerCtx->rfx_context, weston_output->width, 
weston_output->height);
+   NSC_RESET(peerCtx->nsc_context, weston_output->width, 
weston_output->height);
 
if (peersItem->flags & RDP_PEER_ACTIVATED)
return TRUE;
-- 
1.9.1

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


[PATCH 5/6] compositor: recompute output position on mode switch

2016-04-26 Thread David Fort
When an output permanently changes its resolution, the output on the right
should be moved accordingly. We also add an event for output resizing so that
plugins can react when an output is resized.

Signed-off-by: David Fort 
---
 src/compositor.c | 34 --
 src/compositor.h |  1 +
 2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index b88936b..6653bb2 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -143,6 +143,11 @@ static void weston_mode_switch_finish(struct weston_output 
*output,
}
 }
 
+
+static void
+weston_compositor_reflow_outputs(struct weston_compositor *compositor,
+   struct weston_output *resized_output, int 
delta_width);
+
 WL_EXPORT int
 weston_output_mode_set_native(struct weston_output *output,
  struct weston_mode *mode,
@@ -150,6 +155,7 @@ weston_output_mode_set_native(struct weston_output *output,
 {
int ret;
int mode_changed = 0, scale_changed = 0;
+   struct weston_mode *old_mode;
 
if (!output->switch_mode)
return -1;
@@ -165,11 +171,16 @@ weston_output_mode_set_native(struct weston_output 
*output,
}
}
 
+   old_mode = output->native_mode;
output->native_mode = mode;
output->native_scale = scale;
 
weston_mode_switch_finish(output, mode_changed, scale_changed);
 
+   if (old_mode)
+   weston_compositor_reflow_outputs(output->compositor, output, 
mode->width - old_mode->width);
+
+   wl_signal_emit(&output->compositor->output_resized_signal, output);
return 0;
 }
 
@@ -4047,23 +4058,25 @@ bind_output(struct wl_client *client,
wl_output_send_done(resource);
 }
 
-/* Move other outputs when one is removed so the space remains contiguos. */
+/* Move other outputs when one is resized so the space remains contiguous. */
 static void
-weston_compositor_remove_output(struct weston_compositor *compositor,
-   struct weston_output *remove_output)
+weston_compositor_reflow_outputs(struct weston_compositor *compositor,
+   struct weston_output *resized_output, int 
delta_width)
 {
struct weston_output *output;
-   int offset = 0;
+   bool start_resizing = false;
+
+   if (!delta_width)
+   return;
 
wl_list_for_each(output, &compositor->output_list, link) {
-   if (output == remove_output) {
-   offset = output->width;
+   if (output == resized_output) {
+   start_resizing = true;
continue;
}
 
-   if (offset > 0) {
-   weston_output_move(output,
-  output->x - offset, output->y);
+   if (start_resizing) {
+   weston_output_move(output, output->x + delta_width, 
output->y);
output->dirty = 1;
}
}
@@ -4086,7 +4099,7 @@ weston_output_destroy(struct weston_output *output)
 
weston_presentation_feedback_discard_list(&output->feedback_list);
 
-   weston_compositor_remove_output(output->compositor, output);
+   weston_compositor_reflow_outputs(output->compositor, output, 
output->width);
wl_list_remove(&output->link);
 
wl_signal_emit(&output->compositor->output_destroyed_signal, output);
@@ -4706,6 +4719,7 @@ weston_compositor_create(struct wl_display *display, void 
*user_data)
wl_signal_init(&ec->output_created_signal);
wl_signal_init(&ec->output_destroyed_signal);
wl_signal_init(&ec->output_moved_signal);
+   wl_signal_init(&ec->output_resized_signal);
wl_signal_init(&ec->session_signal);
ec->session_active = 1;
 
diff --git a/src/compositor.h b/src/compositor.h
index cb9df00..b71ade0 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -743,6 +743,7 @@ struct weston_compositor {
struct wl_signal output_created_signal;
struct wl_signal output_destroyed_signal;
struct wl_signal output_moved_signal;
+   struct wl_signal output_resized_signal;
 
struct wl_signal session_signal;
int session_active;
-- 
1.9.1

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


[PATCH 6/6] desktop-shell: resize background, panel and lock surface on output resize

2016-04-26 Thread David Fort
When an output is resized (permanent mode switch), we should also notify the
shell client so that the panel, background and the lock screen fits to the
new screen dimensions.

Signed-off-by: David Fort 
---
 desktop-shell/shell.c | 60 +++
 desktop-shell/shell.h |  7 ++
 2 files changed, 67 insertions(+)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index cd269a8..99dcd3e 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -4375,6 +4375,16 @@ background_configure(struct weston_surface *es, int32_t 
sx, int32_t sy)
 }
 
 static void
+handle_background_surface_destroy(struct wl_listener *listener, void *data)
+{
+   struct desktop_shell *shell =
+   container_of(listener, struct desktop_shell, 
background_surface_listener);
+
+   weston_log("background surface gone\n");
+   shell->background_surface = NULL;
+}
+
+static void
 desktop_shell_set_background(struct wl_client *client,
 struct wl_resource *resource,
 struct wl_resource *output_resource,
@@ -4405,6 +4415,10 @@ desktop_shell_set_background(struct wl_client *client,
surface_resource,
surface->output->width,
surface->output->height);
+   shell->background_surface = surface;
+
+   shell->background_surface_listener.notify = 
handle_background_surface_destroy;
+   wl_signal_add(&surface->destroy_signal, 
&shell->background_surface_listener);
 }
 
 static int
@@ -4426,6 +4440,17 @@ panel_configure(struct weston_surface *es, int32_t sx, 
int32_t sy)
 }
 
 static void
+handle_panel_surface_destroy(struct wl_listener *listener, void *data)
+{
+   struct desktop_shell *shell =
+   container_of(listener, struct desktop_shell, 
panel_surface_listener);
+
+   weston_log("panel surface gone\n");
+   shell->panel_surface = NULL;
+}
+
+
+static void
 desktop_shell_set_panel(struct wl_client *client,
struct wl_resource *resource,
struct wl_resource *output_resource,
@@ -4456,6 +4481,10 @@ desktop_shell_set_panel(struct wl_client *client,
surface_resource,
surface->output->width,
surface->output->height);
+
+   shell->panel_surface_listener.notify = handle_panel_surface_destroy;
+   wl_signal_add(&surface->destroy_signal, &shell->panel_surface_listener);
+   shell->panel_surface = surface;
 }
 
 static int
@@ -6368,11 +6397,40 @@ handle_output_destroy(struct wl_listener *listener, 
void *data)
shell_for_each_layer(shell, shell_output_destroy_move_layer, output);
 
wl_list_remove(&output_listener->destroy_listener.link);
+   wl_list_remove(&output_listener->resized_listener.link);
wl_list_remove(&output_listener->link);
free(output_listener);
 }
 
 static void
+shell_resize_surface_to_output(struct desktop_shell *shell,
+   struct weston_surface *surface,
+   const struct weston_output *output)
+{
+   if (!surface)
+   return;
+
+   weston_desktop_shell_send_configure(shell->child.desktop_shell, 0,
+   surface->resource,
+   output->width,
+   output->height);
+}
+
+
+static void
+handle_output_resized(struct wl_listener *listener, void *data)
+{
+   struct shell_output *output_listener =
+   container_of(listener, struct shell_output, resized_listener);
+   struct weston_output *output = output_listener->output;
+   struct desktop_shell *shell = output_listener->shell;
+
+   shell_resize_surface_to_output(shell, shell->background_surface, 
output);
+   shell_resize_surface_to_output(shell, shell->panel_surface, output);
+   shell_resize_surface_to_output(shell, shell->lock_surface, output);
+}
+
+static void
 create_shell_output(struct desktop_shell *shell,
struct weston_output *output)
 {
@@ -6387,6 +6445,8 @@ create_shell_output(struct desktop_shell *shell,
shell_output->destroy_listener.notify = handle_output_destroy;
wl_signal_add(&output->destroy_signal,
  &shell_output->destroy_listener);
+   shell_output->resized_listener.notify = handle_output_resized;
+   wl_signal_add(&output->compositor->output_resized_signal, 
&shell_output->resized_listener);
wl_list_insert(shell->output_list.prev, &shell_output->link);
 }
 
diff --git a/des

[PATCH 4/6] compositor: use generated constant instead of hardcoded value

2016-04-26 Thread David Fort
Use SINCE macros instead of the hardcoded version value.

Signed-off-by: David Fort 
---
 src/compositor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compositor.c b/src/compositor.c
index 5500197..b88936b 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -4236,7 +4236,7 @@ weston_output_move(struct weston_output *output, int x, 
int y)
output->model,
output->transform);
 
-   if (wl_resource_get_version(resource) >= 2)
+   if (wl_resource_get_version(resource) >= 
WL_OUTPUT_DONE_SINCE_VERSION)
wl_output_send_done(resource);
}
 }
-- 
1.9.1

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


[PATCH 3/6] rdp: Fix the ContextNew callback with recent FreeRDP versions

2016-04-26 Thread David Fort
Since a quite long time FreeRDP expect the ContextNew callback to return TRUE
when it succeeds. Without this we have some arbitrary failures (most probably
when eax is 0 at the end of the function).

Signed-off-by: David Fort 
---
 src/compositor-rdp.c | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index 862eedc..3e7699c 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -587,7 +587,7 @@ int rdp_implant_listener(struct rdp_backend *b, 
freerdp_listener* instance)
 }
 
 
-static void
+static FREERDP_CB_RET_TYPE
 rdp_peer_context_new(freerdp_peer* client, RdpPeerContext* context)
 {
context->item.peer = client;
@@ -598,15 +598,32 @@ rdp_peer_context_new(freerdp_peer* client, 
RdpPeerContext* context)
 #else
context->rfx_context = rfx_context_new(TRUE);
 #endif
+   if (!context->rfx_context) {
+   FREERDP_CB_RETURN(FALSE);
+   }
+
context->rfx_context->mode = RLGR3;
context->rfx_context->width = client->settings->DesktopWidth;
context->rfx_context->height = client->settings->DesktopHeight;
rfx_context_set_pixel_format(context->rfx_context, 
RDP_PIXEL_FORMAT_B8G8R8A8);
 
context->nsc_context = nsc_context_new();
+   if (!context->nsc_context)
+   goto out_error_nsc;
+
nsc_context_set_pixel_format(context->nsc_context, 
RDP_PIXEL_FORMAT_B8G8R8A8);
 
context->encode_stream = Stream_New(NULL, 65536);
+   if (!context->encode_stream)
+   goto out_error_stream;
+
+   FREERDP_CB_RETURN(TRUE);
+
+out_error_nsc:
+   rfx_context_free(context->rfx_context);
+out_error_stream:
+   nsc_context_free(context->nsc_context);
+   FREERDP_CB_RETURN(FALSE);
 }
 
 static void
-- 
1.9.1

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


[PATCH 2/6] rdp: don't release the seat until it is safe

2016-04-26 Thread David Fort
Releasing a seat is not safe, so let's just announce it without keyboard
and mouse until this is fixed. Without this patch we just can't reconnect on
the RDP compositor as it crashes.

Signed-off-by: David Fort 
---
 src/compositor-rdp.c | 32 +++-
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index f6778b6..862eedc 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -109,7 +109,7 @@ enum peer_item_flags {
 struct rdp_peers_item {
int flags;
freerdp_peer *peer;
-   struct weston_seat seat;
+   struct weston_seat *seat;
 
struct wl_list link;
 };
@@ -623,9 +623,9 @@ rdp_peer_context_free(freerdp_peer* client, RdpPeerContext* 
context)
}
 
if (context->item.flags & RDP_PEER_ACTIVATED) {
-   weston_seat_release_keyboard(&context->item.seat);
-   weston_seat_release_pointer(&context->item.seat);
-   weston_seat_release(&context->item.seat);
+   weston_seat_release_keyboard(context->item.seat);
+   weston_seat_release_pointer(context->item.seat);
+   /*weston_seat_release(context->item.seat);*/
}
 
Stream_Free(context->encode_stream, TRUE);
@@ -894,9 +894,15 @@ xf_peer_activate(freerdp_peer* client)
else
snprintf(seat_name, sizeof(seat_name), "RDP peer @%s", 
settings->ClientAddress);
 
-   weston_seat_init(&peersItem->seat, b->compositor, seat_name);
-   weston_seat_init_keyboard(&peersItem->seat, keymap);
-   weston_seat_init_pointer(&peersItem->seat);
+   peersItem->seat = zalloc(sizeof(*peersItem->seat));
+   if (!peersItem->seat) {
+   weston_log("unable to create a weston_seat\n");
+   return FALSE;
+   }
+
+   weston_seat_init(peersItem->seat, b->compositor, seat_name);
+   weston_seat_init_keyboard(peersItem->seat, keymap);
+   weston_seat_init_pointer(peersItem->seat);
 
peersItem->flags |= RDP_PEER_ACTIVATED;
 
@@ -935,7 +941,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
UINT16 y)
if (flags & PTR_FLAGS_MOVE) {
output = peerContext->rdpBackend->output;
if (x < output->base.width && y < output->base.height) {
-   notify_motion_absolute(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_motion_absolute(peerContext->item.seat, 
weston_compositor_get_time(),
x, y);
need_frame = true;
}
@@ -949,7 +955,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
UINT16 y)
button = BTN_MIDDLE;
 
if (button) {
-   notify_button(&peerContext->item.seat, 
weston_compositor_get_time(), button,
+   notify_button(peerContext->item.seat, 
weston_compositor_get_time(), button,
(flags & PTR_FLAGS_DOWN) ? 
WL_POINTER_BUTTON_STATE_PRESSED : WL_POINTER_BUTTON_STATE_RELEASED
);
need_frame = true;
@@ -974,13 +980,13 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
UINT16 y)
weston_event.discrete = (int)value;
weston_event.has_discrete = true;
 
-   notify_axis(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_axis(peerContext->item.seat, 
weston_compositor_get_time(),
&weston_event);
need_frame = true;
}
 
if (need_frame)
-   notify_pointer_frame(&peerContext->item.seat);
+   notify_pointer_frame(peerContext->item.seat);
 
FREERDP_CB_RETURN(TRUE);
 }
@@ -993,7 +999,7 @@ xf_extendedMouseEvent(rdpInput *input, UINT16 flags, UINT16 
x, UINT16 y)
 
output = peerContext->rdpBackend->output;
if (x < output->base.width && y < output->base.height) {
-   notify_motion_absolute(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_motion_absolute(peerContext->item.seat, 
weston_compositor_get_time(),
x, y);
}
 
@@ -1056,7 +1062,7 @@ xf_input_keyboard_event(rdpInput *input, UINT16 flags, 
UINT16 code)
 
/*weston_log("code=%x ext=%d vk_code=%x scan_code=%x\n", code, 
(flags & KBD_FLAGS_EXTENDED) ? 1 : 0,
vk_code, scan_code);*/
-   notify_key(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_key(peerContext->item.seat, weston_compositor_get_time(),
scan_code - 8, keyState, 
STATE_UPDATE_AUTOMATIC);
}
 
-- 
1.9.1

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


[PATCH 1/6] rdp: allow to compile against FreeRDP 2.0

2016-04-26 Thread David Fort
FreeRDP 2.0 is about to be released, this allows to compile against this 
version.
The detection is adjusted to prefer FreeRDP 2 against version 1.x.

Signed-off-by: David Fort 
---
 configure.ac |  8 +++-
 src/compositor-rdp.c | 23 ---
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4199616..c6c4dbb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -238,12 +238,18 @@ AM_CONDITIONAL([ENABLE_RDP_COMPOSITOR],
[test x$enable_rdp_compositor = xyes])
 if test x$enable_rdp_compositor = xyes; then
   AC_DEFINE([BUILD_RDP_COMPOSITOR], [1], [Build the RDP compositor])
-  PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp >= 1.1.0])
+  PKG_CHECK_MODULES(FreeRDP2, [freerdp2 >= 2.0.0],
+[RDP_COMPOSITOR_CFLAGS=$FreeRDP2_CFLAGS; 
RDP_COMPOSITOR_LIBS=$FreeRDP2_LIBS;],
+[PKG_CHECK_MODULES(FreeRDP, [freerdp >= 
1.1.0],[RDP_COMPOSITOR_CFLAGS=$FreeRDP_CFLAGS; 
RDP_COMPOSITOR_LIBS=$FreeRDP_LIBS;])]
+  )
 
   SAVED_CPPFLAGS="$CPPFLAGS"
   CPPFLAGS="$CPPFLAGS $RDP_COMPOSITOR_CFLAGS"
   AC_CHECK_HEADERS([freerdp/version.h])
   CPPFLAGS="$SAVED_CPPFLAGS"
+
+  AC_SUBST(RDP_COMPOSITOR_CFLAGS)
+  AC_SUBST(RDP_COMPOSITOR_LIBS)
 fi
 
 AC_ARG_ENABLE([screen-sharing], [  --enable-screen-sharing],,
diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index 2860556..f6778b6 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -42,15 +42,24 @@
 #define FREERDP_VERSION_NUMBER ((FREERDP_VERSION_MAJOR * 0x1) + \
(FREERDP_VERSION_MINOR * 0x100) + FREERDP_VERSION_REVISION)
 
+
 #if FREERDP_VERSION_NUMBER >= 0x10201
 #define HAVE_SKIP_COMPRESSION
 #endif
 
 #if FREERDP_VERSION_NUMBER < 0x10202
-#define FREERDP_CB_RET_TYPE void
-#define FREERDP_CB_RETURN(V) return
+#  define FREERDP_CB_RET_TYPE void
+#  define FREERDP_CB_RETURN(V) return
+#  define NSC_RESET(C, W, H)
+#  define RFX_RESET(C, W, H) do { rfx_context_reset(C); C->width = W; 
C->height = H; } while(0)
+#else
+#if FREERDP_VERSION_MAJOR >= 2
+#  define NSC_RESET(C, W, H) nsc_context_reset(C, W, H)
+#  define RFX_RESET(C, W, H) rfx_context_reset(C, W, H)
 #else
-#define HAVE_NSC_RESET
+#  define NSC_RESET(C, W, H) do { nsc_context_reset(C); C->width = W; 
C->height = H; } while(0)
+#  define RFX_RESET(C, W, H) do { rfx_context_reset(C); C->width = W; 
C->height = H; } while(0)
+#endif
 #define FREERDP_CB_RET_TYPE BOOL
 #define FREERDP_CB_RETURN(V) return TRUE
 #endif
@@ -795,6 +804,7 @@ xf_peer_activate(freerdp_peer* client)
struct xkb_context *xkbContext;
struct xkb_rule_names xkbRuleNames;
struct xkb_keymap *keymap;
+   struct weston_output *weston_output;
int i;
pixman_box32_t box;
pixman_region32_t damage;
@@ -843,10 +853,9 @@ xf_peer_activate(freerdp_peer* client)
}
}
 
-   rfx_context_reset(peerCtx->rfx_context);
-#ifdef HAVE_NSC_RESET
-   nsc_context_reset(peerCtx->nsc_context);
-#endif
+   weston_output = &output->base;
+   RFX_RESET(peerCtx->rfx_context, weston_output->width, 
weston_output->height);
+   NSC_RESET(peerCtx->nsc_context, weston_output->width, 
weston_output->height);
 
if (peersItem->flags & RDP_PEER_ACTIVATED)
return TRUE;
-- 
1.9.1

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


[PATCH 0/6] RDP compositor needs love v2

2016-04-26 Thread David Fort
Compared to the first version:
* compilation with FreeRDP 2.0 is now prefered;
* trivial patch using constant instead of hard coded value has its own commit;
* I have splitted the output resized patch so that the shell and the core 
weston 
part are separated. I have also reworked the shell part so that only the right 
surface
is reconfigured;
* I've dropped the presentation fix hack.

David Fort (6):
  rdp: allow to compile against FreeRDP 2.0
  rdp: don't release the seat until it is safe
  rdp: Fix the ContextNew callback with recent FreeRDP versions
  compositor: use generated constant instead of hardcoded value
  compositor: recompute output position on mode switch
  desktop-shell: resize background, panel and lock surface on output
resize

 configure.ac  |  8 +-
 desktop-shell/shell.c | 60 +
 desktop-shell/shell.h |  7 +
 src/compositor-rdp.c  | 74 ---
 src/compositor.c  | 36 +
 src/compositor.h  |  1 +
 6 files changed, 153 insertions(+), 33 deletions(-)

-- 
1.9.1

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


[PATCH 3/5] rdp: fix presentation for the RDP compositor

2016-04-22 Thread David Fort
Set an update delay that is a multiple of the output frequency, or we may do
incorrect weston_output_finish_frame calls.
---
 src/compositor-rdp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index 9274674..4cbc1c3 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -378,7 +378,7 @@ rdp_output_repaint(struct weston_output *output_base, 
pixman_region32_t *damage)
pixman_region32_subtract(&ec->primary_plane.damage,
 &ec->primary_plane.damage, damage);
 
-   wl_event_source_timer_update(output->finish_frame_timer, 16);
+   wl_event_source_timer_update(output->finish_frame_timer, 10);
return 0;
 }
 
-- 
1.9.1

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


[PATCH 2/5] rdp: don't release the seat until it is safe

2016-04-22 Thread David Fort
Releasing a seat is not safe, so let's just announce it without keyboard
and mouse until this is fixed. Without this patch we just can't reconnect on
the RDP compositor as it crashes.

Signed-off-by: David Fort 
---
 src/compositor-rdp.c | 32 +++-
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index 0649bee..9274674 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -119,7 +119,7 @@ enum peer_item_flags {
 struct rdp_peers_item {
int flags;
freerdp_peer *peer;
-   struct weston_seat seat;
+   struct weston_seat *seat;
 
struct wl_list link;
 };
@@ -647,9 +647,9 @@ rdp_peer_context_free(freerdp_peer* client, RdpPeerContext* 
context)
}
 
if (context->item.flags & RDP_PEER_ACTIVATED) {
-   weston_seat_release_keyboard(&context->item.seat);
-   weston_seat_release_pointer(&context->item.seat);
-   weston_seat_release(&context->item.seat);
+   weston_seat_release_keyboard(context->item.seat);
+   weston_seat_release_pointer(context->item.seat);
+   /*weston_seat_release(context->item.seat);*/
}
 
Stream_Free(context->encode_stream, TRUE);
@@ -918,9 +918,15 @@ xf_peer_activate(freerdp_peer* client)
else
snprintf(seat_name, sizeof(seat_name), "RDP peer @%s", 
settings->ClientAddress);
 
-   weston_seat_init(&peersItem->seat, b->compositor, seat_name);
-   weston_seat_init_keyboard(&peersItem->seat, keymap);
-   weston_seat_init_pointer(&peersItem->seat);
+   peersItem->seat = zalloc(sizeof(*peersItem->seat));
+   if (!peersItem->seat) {
+   weston_log("unable to create a weston_seat\n");
+   return FALSE;
+   }
+
+   weston_seat_init(peersItem->seat, b->compositor, seat_name);
+   weston_seat_init_keyboard(peersItem->seat, keymap);
+   weston_seat_init_pointer(peersItem->seat);
 
peersItem->flags |= RDP_PEER_ACTIVATED;
 
@@ -959,7 +965,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
UINT16 y)
if (flags & PTR_FLAGS_MOVE) {
output = peerContext->rdpBackend->output;
if (x < output->base.width && y < output->base.height) {
-   notify_motion_absolute(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_motion_absolute(peerContext->item.seat, 
weston_compositor_get_time(),
x, y);
need_frame = true;
}
@@ -973,7 +979,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
UINT16 y)
button = BTN_MIDDLE;
 
if (button) {
-   notify_button(&peerContext->item.seat, 
weston_compositor_get_time(), button,
+   notify_button(peerContext->item.seat, 
weston_compositor_get_time(), button,
(flags & PTR_FLAGS_DOWN) ? 
WL_POINTER_BUTTON_STATE_PRESSED : WL_POINTER_BUTTON_STATE_RELEASED
);
need_frame = true;
@@ -998,13 +1004,13 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
UINT16 y)
weston_event.discrete = (int)value;
weston_event.has_discrete = true;
 
-   notify_axis(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_axis(peerContext->item.seat, 
weston_compositor_get_time(),
&weston_event);
need_frame = true;
}
 
if (need_frame)
-   notify_pointer_frame(&peerContext->item.seat);
+   notify_pointer_frame(peerContext->item.seat);
 
FREERDP_CB_RETURN(TRUE);
 }
@@ -1017,7 +1023,7 @@ xf_extendedMouseEvent(rdpInput *input, UINT16 flags, 
UINT16 x, UINT16 y)
 
output = peerContext->rdpBackend->output;
if (x < output->base.width && y < output->base.height) {
-   notify_motion_absolute(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_motion_absolute(peerContext->item.seat, 
weston_compositor_get_time(),
x, y);
}
 
@@ -1080,7 +1086,7 @@ xf_input_keyboard_event(rdpInput *input, UINT16 flags, 
UINT16 code)
 
/*weston_log("code=%x ext=%d vk_code=%x scan_code=%x\n", code, 
(flags & KBD_FLAGS_EXTENDED) ? 1 : 0,
vk_code, scan_code);*/
-   notify_key(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_key(peerContext->item.seat, weston_compositor_get_time(),
scan_code - 8, keyState, 
STATE_UPDATE_AUTOMATIC);
}
 
-- 
1.9.1

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


[PATCH 5/5] desktop shell: resize background and panel when an output switches mode

2016-04-22 Thread David Fort
When an output permanently switches mode, the desktop shell must be notified so
that the misc components can resize to the new size of the output. This patch 
also
fixes the coodinates of "other" outputs when the resize occurs.

Signed-off-by: David Fort 
---
 desktop-shell/shell.c | 34 ++
 desktop-shell/shell.h |  1 +
 src/compositor.c  | 33 ++---
 src/compositor.h  |  1 +
 4 files changed, 58 insertions(+), 11 deletions(-)

diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index cd269a8..1c1c993 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -6368,11 +6368,43 @@ handle_output_destroy(struct wl_listener *listener, 
void *data)
shell_for_each_layer(shell, shell_output_destroy_move_layer, output);
 
wl_list_remove(&output_listener->destroy_listener.link);
+   wl_list_remove(&output_listener->resized_listener.link);
wl_list_remove(&output_listener->link);
free(output_listener);
 }
 
 static void
+shell_output_resize_layer(struct desktop_shell *shell,
+   struct weston_layer *layer,
+   void *data)
+{
+   struct weston_output *output = data;
+   struct weston_view *view;
+
+   wl_list_for_each(view, &layer->view_list.link, layer_link.link) {
+   if (view->output != output)
+   continue;
+
+   weston_desktop_shell_send_configure(shell->child.desktop_shell, 
0,
+   view->surface->resource,
+   output->width,
+   output->height);
+   }
+}
+
+
+static void
+handle_output_resized(struct wl_listener *listener, void *data)
+{
+   struct shell_output *output_listener =
+   container_of(listener, struct shell_output, resized_listener);
+   struct weston_output *output = output_listener->output;
+   struct desktop_shell *shell = output_listener->shell;
+
+   shell_for_each_layer(shell, shell_output_resize_layer, output);
+}
+
+static void
 create_shell_output(struct desktop_shell *shell,
struct weston_output *output)
 {
@@ -6387,6 +6419,8 @@ create_shell_output(struct desktop_shell *shell,
shell_output->destroy_listener.notify = handle_output_destroy;
wl_signal_add(&output->destroy_signal,
  &shell_output->destroy_listener);
+   shell_output->resized_listener.notify = handle_output_resized;
+   wl_signal_add(&output->compositor->output_resized_signal, 
&shell_output->resized_listener);
wl_list_insert(shell->output_list.prev, &shell_output->link);
 }
 
diff --git a/desktop-shell/shell.h b/desktop-shell/shell.h
index b430fa2..5457923 100644
--- a/desktop-shell/shell.h
+++ b/desktop-shell/shell.h
@@ -112,6 +112,7 @@ struct shell_output {
struct desktop_shell  *shell;
struct weston_output  *output;
struct exposay_output eoutput;
+   struct wl_listenerresized_listener;
struct wl_listenerdestroy_listener;
struct wl_listlink;
 };
diff --git a/src/compositor.c b/src/compositor.c
index 5500197..a747945 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -143,6 +143,11 @@ static void weston_mode_switch_finish(struct weston_output 
*output,
}
 }
 
+
+static void
+weston_compositor_resize_output(struct weston_compositor *compositor,
+   struct weston_output *resized_output, int 
delta_width);
+
 WL_EXPORT int
 weston_output_mode_set_native(struct weston_output *output,
  struct weston_mode *mode,
@@ -150,6 +155,7 @@ weston_output_mode_set_native(struct weston_output *output,
 {
int ret;
int mode_changed = 0, scale_changed = 0;
+   struct weston_mode *old_mode;
 
if (!output->switch_mode)
return -1;
@@ -165,11 +171,16 @@ weston_output_mode_set_native(struct weston_output 
*output,
}
}
 
+   old_mode = output->native_mode;
output->native_mode = mode;
output->native_scale = scale;
 
weston_mode_switch_finish(output, mode_changed, scale_changed);
 
+   if (old_mode && (old_mode->width != mode->width))
+   weston_compositor_resize_output(output->compositor, output, 
mode->width - old_mode->width);
+
+   wl_signal_emit(&output->compositor->output_resized_signal, output);
return 0;
 }
 
@@ -4047,23 +4058,22 @@ bind_output(struct wl_client *client,
wl_output_send_done(resource);
 }
 
-/* Move other outputs when one is removed so the space remains contiguos. */
+/* Move other outputs when one is resized so the space remains contiguous. */
 static void
-weston_compositor_remove

[PATCH 1/5] rdp: allow to compile against FreeRDP 2.0

2016-04-22 Thread David Fort
FreeRDP 2.0 is about to be released, this allows to compile against this 
version.

Signed-off-by: David Fort 
---
 configure.ac |  8 +++-
 src/compositor-rdp.c | 23 ---
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/configure.ac b/configure.ac
index 670200c..9c70b2e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -242,12 +242,18 @@ AM_CONDITIONAL([ENABLE_RDP_COMPOSITOR],
[test x$enable_rdp_compositor = xyes])
 if test x$enable_rdp_compositor = xyes; then
   AC_DEFINE([BUILD_RDP_COMPOSITOR], [1], [Build the RDP compositor])
-  PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp >= 1.1.0])
+  PKG_CHECK_MODULES(FreeRDP, [freerdp >= 1.1.0],
+[RDP_COMPOSITOR_CFLAGS=$FreeRDP_CFLAGS; 
RDP_COMPOSITOR_LIBS=$FreeRDP_LIBS;],
+[PKG_CHECK_MODULES(FreeRDP2, [freerdp2 >= 
2.0.0],[RDP_COMPOSITOR_CFLAGS=$FreeRDP2_CFLAGS; 
RDP_COMPOSITOR_LIBS=$FreeRDP2_LIBS;])]
+  )
 
   SAVED_CPPFLAGS="$CPPFLAGS"
   CPPFLAGS="$CPPFLAGS $RDP_COMPOSITOR_CFLAGS"
   AC_CHECK_HEADERS([freerdp/version.h])
   CPPFLAGS="$SAVED_CPPFLAGS"
+
+  AC_SUBST(RDP_COMPOSITOR_CFLAGS)
+  AC_SUBST(RDP_COMPOSITOR_LIBS)
 fi
 
 AC_ARG_ENABLE([screen-sharing], [  --enable-screen-sharing],,
diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index 773b6b5..0649bee 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -42,15 +42,24 @@
 #define FREERDP_VERSION_NUMBER ((FREERDP_VERSION_MAJOR * 0x1) + \
(FREERDP_VERSION_MINOR * 0x100) + FREERDP_VERSION_REVISION)
 
+
 #if FREERDP_VERSION_NUMBER >= 0x10201
 #define HAVE_SKIP_COMPRESSION
 #endif
 
 #if FREERDP_VERSION_NUMBER < 0x10202
-#define FREERDP_CB_RET_TYPE void
-#define FREERDP_CB_RETURN(V) return
+#  define FREERDP_CB_RET_TYPE void
+#  define FREERDP_CB_RETURN(V) return
+#  define NSC_RESET(C, W, H)
+#  define RFX_RESET(C, W, H) do { rfx_context_reset(C); C->width = W; 
C->height = H; } while(0)
+#else
+#if FREERDP_VERSION_MAJOR >= 2
+#  define NSC_RESET(C, W, H) nsc_context_reset(C, W, H)
+#  define RFX_RESET(C, W, H) rfx_context_reset(C, W, H)
 #else
-#define HAVE_NSC_RESET
+#  define NSC_RESET(C, W, H) do { nsc_context_reset(C); C->width = W; 
C->height = H; } while(0)
+#  define RFX_RESET(C, W, H) do { rfx_context_reset(C); C->width = W; 
C->height = H; } while(0)
+#endif
 #define FREERDP_CB_RET_TYPE BOOL
 #define FREERDP_CB_RETURN(V) return TRUE
 #endif
@@ -819,6 +828,7 @@ xf_peer_activate(freerdp_peer* client)
struct xkb_context *xkbContext;
struct xkb_rule_names xkbRuleNames;
struct xkb_keymap *keymap;
+   struct weston_output *weston_output;
int i;
pixman_box32_t box;
pixman_region32_t damage;
@@ -867,10 +877,9 @@ xf_peer_activate(freerdp_peer* client)
}
}
 
-   rfx_context_reset(peerCtx->rfx_context);
-#ifdef HAVE_NSC_RESET
-   nsc_context_reset(peerCtx->nsc_context);
-#endif
+   weston_output = &output->base;
+   RFX_RESET(peerCtx->rfx_context, weston_output->width, 
weston_output->height);
+   NSC_RESET(peerCtx->nsc_context, weston_output->width, 
weston_output->height);
 
if (peersItem->flags & RDP_PEER_ACTIVATED)
return TRUE;
-- 
1.9.1

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


[PATCH 0/5] RDP compositor needs love

2016-04-22 Thread David Fort
This serie address some issues around the RDP compositor. Some are compilation 
fixes
against FreeRDP 2.0 (and now we search for FreeRDP 2.0 too). 
As seat releasing is still not safe, I'm proposing again the patch to _not_ 
release the seat 
in the RDP compositor (and so we can reconnect at the cost of leaking the 
seat). 
And finally there's a fix for output mode switching, and the panel and 
background 
not resizing when it happens. This bug is there since the beginning of the RDP 
compositor (looks
like it's the only one that actually changes output modes).

David Fort (5):
  rdp: allow to compile against FreeRDP 2.0
  rdp: don't release the seat until it is safe
  rdp: fix presentation for the RDP compositor
  rdp: Fix the ContextNew callback with recent FreeRDP versions
  desktop shell: resize background and panel when an output switches
mode

 configure.ac  |  8 +-
 desktop-shell/shell.c | 34 +++
 desktop-shell/shell.h |  1 +
 src/compositor-rdp.c  | 76 ---
 src/compositor.c  | 33 ++
 src/compositor.h  |  1 +
 6 files changed, 119 insertions(+), 34 deletions(-)

-- 
1.9.1

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


[PATCH 4/5] rdp: Fix the ContextNew callback with recent FreeRDP versions

2016-04-22 Thread David Fort
Since a quite long time FreeRDP expect the ContextNew callback to return TRUE
when it succeeds. Without this we have some arbitrary failures (most probably
when eax is 0 at the end of the function).

Signed-off-by: David Fort 
---
 src/compositor-rdp.c | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index 4cbc1c3..7d2da83 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -611,7 +611,7 @@ int rdp_implant_listener(struct rdp_backend *b, 
freerdp_listener* instance)
 }
 
 
-static void
+static FREERDP_CB_RET_TYPE
 rdp_peer_context_new(freerdp_peer* client, RdpPeerContext* context)
 {
context->item.peer = client;
@@ -622,15 +622,32 @@ rdp_peer_context_new(freerdp_peer* client, 
RdpPeerContext* context)
 #else
context->rfx_context = rfx_context_new(TRUE);
 #endif
+   if (!context->rfx_context) {
+   FREERDP_CB_RETURN(FALSE);
+   }
+
context->rfx_context->mode = RLGR3;
context->rfx_context->width = client->settings->DesktopWidth;
context->rfx_context->height = client->settings->DesktopHeight;
rfx_context_set_pixel_format(context->rfx_context, 
RDP_PIXEL_FORMAT_B8G8R8A8);
 
context->nsc_context = nsc_context_new();
+   if (!context->nsc_context)
+   goto out_error_nsc;
+
nsc_context_set_pixel_format(context->nsc_context, 
RDP_PIXEL_FORMAT_B8G8R8A8);
 
context->encode_stream = Stream_New(NULL, 65536);
+   if (!context->encode_stream)
+   goto out_error_stream;
+
+   FREERDP_CB_RETURN(TRUE);
+
+out_error_nsc:
+   rfx_context_free(context->rfx_context);
+out_error_stream:
+   nsc_context_free(context->nsc_context);
+   FREERDP_CB_RETURN(FALSE);
 }
 
 static void
-- 
1.9.1

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


[RFC] weston: implement inert objects for keyboard/pointer/touch

2015-10-19 Thread David FORT
This is the second version. I have restored the ref counting of input devices,
I think with the name weston_seat_init_pointer is not accurate, perhaps 
weston_seat_add_pointer_device would be better. I'm really wondering if it's
the weston core that should do that refcounting, or if the input backend should
do it itself. I can't see any case where we would have 2 input backends (which
would be a justification for weston doing it).
Note that with this patch, we don't save the last position of the pointer. I'm
wondering why we wanna do this, does that mean that we want the same kind of 
behaviour for other input devices (saving locks state for keyboard device for 
example) ?

David FORT (1):
  weston: implement inert objects for keyboard/pointer/touch

 desktop-shell/exposay.c  |  16 ++--
 desktop-shell/shell.c|  21 ++--
 src/compositor-wayland.c |  10 +-
 src/compositor-x11.c |  12 ++-
 src/input.c  | 242 +++
 src/libinput-device.c|   2 +-
 src/screen-share.c   |   2 +
 src/text-backend.c   |  44 +
 src/zoom.c   |   7 +-
 tests/weston-test.c  |  18 ++--
 xwayland/dnd.c   |   3 +-
 11 files changed, 224 insertions(+), 153 deletions(-)

-- 
1.9.1

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


[PATCH] weston: implement inert objects for keyboard/pointer/touch

2015-10-19 Thread David FORT
This patch implements inert objects for wl_keyboard, wl_pointer and wl_touch.
The target case is when the server has just send a capability event about a
disappearing object, and the client binds the corresponding object. We bind an
inert object: an object does nothing when it is requested. If the client behave
correctly, this object should be released when the capability event is received
and treated (calling the corresponding release request).
As a consequence, we can rely on seat->[keyboard|pointer|touch]_state to know
if the seat has the corresponding object.
---
 desktop-shell/exposay.c  |  16 ++--
 desktop-shell/shell.c|  21 ++--
 src/compositor-wayland.c |  10 +-
 src/compositor-x11.c |  12 ++-
 src/input.c  | 242 +++
 src/libinput-device.c|   2 +-
 src/screen-share.c   |   2 +
 src/text-backend.c   |  44 +
 src/zoom.c   |   7 +-
 tests/weston-test.c  |  18 ++--
 xwayland/dnd.c   |   3 +-
 11 files changed, 224 insertions(+), 153 deletions(-)

diff --git a/desktop-shell/exposay.c b/desktop-shell/exposay.c
index 08b86a3..d6919b3 100644
--- a/desktop-shell/exposay.c
+++ b/desktop-shell/exposay.c
@@ -574,21 +574,23 @@ exposay_transition_active(struct desktop_shell *shell)
bool animate = false;
 
shell->exposay.workspace = get_current_workspace(shell);
-   shell->exposay.focus_prev = get_default_view(keyboard->focus);
-   shell->exposay.focus_current = get_default_view(keyboard->focus);
+   if (keyboard) {
+   shell->exposay.focus_prev = get_default_view(keyboard->focus);
+   shell->exposay.focus_current = 
get_default_view(keyboard->focus);
+   }
shell->exposay.clicked = NULL;
wl_list_init(&shell->exposay.surface_list);
 
lower_fullscreen_layer(shell, NULL);
shell->exposay.grab_kbd.interface = &exposay_kbd_grab;
-   weston_keyboard_start_grab(keyboard,
-  &shell->exposay.grab_kbd);
-   weston_keyboard_set_focus(keyboard, NULL);
+   if (keyboard) {
+   weston_keyboard_start_grab(keyboard, &shell->exposay.grab_kbd);
+   weston_keyboard_set_focus(keyboard, NULL);
+   }
 
shell->exposay.grab_ptr.interface = &exposay_ptr_grab;
if (pointer) {
-   weston_pointer_start_grab(pointer,
- &shell->exposay.grab_ptr);
+   weston_pointer_start_grab(pointer, &shell->exposay.grab_ptr);
weston_pointer_clear_focus(pointer);
}
wl_list_for_each(shell_output, &shell->output_list, link) {
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 3eb3f5c..cdddf09 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -380,7 +380,8 @@ shell_grab_start(struct shell_grab *grab,
struct desktop_shell *shell = shsurf->shell;
struct weston_touch *touch = weston_seat_get_touch(pointer->seat);
 
-   popup_grab_end(pointer);
+   if (pointer)
+   popup_grab_end(pointer);
if (touch)
touch_popup_grab_end(touch);
 
@@ -391,11 +392,13 @@ shell_grab_start(struct shell_grab *grab,
  &grab->shsurf_destroy_listener);
 
shsurf->grabbed = 1;
-   weston_pointer_start_grab(pointer, &grab->grab);
+   if (pointer)
+   weston_pointer_start_grab(pointer, &grab->grab);
if (shell->child.desktop_shell) {
desktop_shell_send_grab_cursor(shell->child.desktop_shell,
   cursor);
-   weston_pointer_set_focus(pointer,
+   if (pointer)
+   weston_pointer_set_focus(pointer,
 get_default_view(shell->grab_surface),
 wl_fixed_from_int(0),
 wl_fixed_from_int(0));
@@ -925,12 +928,10 @@ restore_focus_state(struct desktop_shell *shell, struct 
workspace *ws)
wl_list_insert(&shell->compositor->seat_list,
   &state->seat->link);
 
-   if (!keyboard)
-   continue;
-
surface = state->keyboard_focus;
 
-   weston_keyboard_set_focus(keyboard, surface);
+   if (keyboard)
+   weston_keyboard_set_focus(keyboard, surface);
}
 
/* For any remaining seats that we don't have a focus state
@@ -955,6 +956,9 @@ replace_focus_state(struct desktop_shell *shell, struct 
workspace *ws,
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
struct focus_state *state;
 
+   if (!keyboard)
+   return;
+
wl_list_for_each(state, &ws->focus_list, link) {
if (state->seat == seat) {
focus_state_set_focus(state, keyboard->focus);
@@ -148

[RFC] weston: implement inert objects for keyboard/pointer/touch

2015-10-16 Thread David FORT
This patch implements inert objects for wl_keyboard, wl_pointer and wl_touch.
The target case is when the server has just send a capability event about a
disappearing object, and the client binds the corresponding object. We bind an
inert object: an object does nothing when it is requested. If the client behave
correctly, this object should be released when the capability event is received
and treated (calling the corresponding release request).
As a consequence, we can rely on seat->[keyboard|pointer|touch]_state to know
if the seat has the corresponding object.
Weston doesn't really handle multiple mice for one wl_pointer, so I have removed
the corresponding code and tests (it was quite a weston_test hack BTW).
Finally I have fixed a wrong behaviour: the capabilities event's documentation 
states
that the capabilities should be sent when a new capability is set on the seat. 
So
attaching a second mouse to an existing wl_pointer should not broadcast seat
capabilities (and the same for keyboard and touch).
---
 desktop-shell/exposay.c  |  16 ++--
 desktop-shell/shell.c|  21 +++--
 src/compositor-wayland.c |  10 +-
 src/compositor-x11.c |  12 ++-
 src/compositor.h |   3 -
 src/input.c  | 235 ++-
 src/libinput-device.c|   2 +-
 src/screen-share.c   |   2 +
 src/text-backend.c   |  44 +
 src/zoom.c   |   7 +-
 tests/devices-test.c |  20 
 tests/weston-test.c  |  18 ++--
 xwayland/dnd.c   |   3 +-
 13 files changed, 216 insertions(+), 177 deletions(-)

diff --git a/desktop-shell/exposay.c b/desktop-shell/exposay.c
index 08b86a3..d6919b3 100644
--- a/desktop-shell/exposay.c
+++ b/desktop-shell/exposay.c
@@ -574,21 +574,23 @@ exposay_transition_active(struct desktop_shell *shell)
bool animate = false;
 
shell->exposay.workspace = get_current_workspace(shell);
-   shell->exposay.focus_prev = get_default_view(keyboard->focus);
-   shell->exposay.focus_current = get_default_view(keyboard->focus);
+   if (keyboard) {
+   shell->exposay.focus_prev = get_default_view(keyboard->focus);
+   shell->exposay.focus_current = 
get_default_view(keyboard->focus);
+   }
shell->exposay.clicked = NULL;
wl_list_init(&shell->exposay.surface_list);
 
lower_fullscreen_layer(shell, NULL);
shell->exposay.grab_kbd.interface = &exposay_kbd_grab;
-   weston_keyboard_start_grab(keyboard,
-  &shell->exposay.grab_kbd);
-   weston_keyboard_set_focus(keyboard, NULL);
+   if (keyboard) {
+   weston_keyboard_start_grab(keyboard, &shell->exposay.grab_kbd);
+   weston_keyboard_set_focus(keyboard, NULL);
+   }
 
shell->exposay.grab_ptr.interface = &exposay_ptr_grab;
if (pointer) {
-   weston_pointer_start_grab(pointer,
- &shell->exposay.grab_ptr);
+   weston_pointer_start_grab(pointer, &shell->exposay.grab_ptr);
weston_pointer_clear_focus(pointer);
}
wl_list_for_each(shell_output, &shell->output_list, link) {
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 3eb3f5c..cdddf09 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -380,7 +380,8 @@ shell_grab_start(struct shell_grab *grab,
struct desktop_shell *shell = shsurf->shell;
struct weston_touch *touch = weston_seat_get_touch(pointer->seat);
 
-   popup_grab_end(pointer);
+   if (pointer)
+   popup_grab_end(pointer);
if (touch)
touch_popup_grab_end(touch);
 
@@ -391,11 +392,13 @@ shell_grab_start(struct shell_grab *grab,
  &grab->shsurf_destroy_listener);
 
shsurf->grabbed = 1;
-   weston_pointer_start_grab(pointer, &grab->grab);
+   if (pointer)
+   weston_pointer_start_grab(pointer, &grab->grab);
if (shell->child.desktop_shell) {
desktop_shell_send_grab_cursor(shell->child.desktop_shell,
   cursor);
-   weston_pointer_set_focus(pointer,
+   if (pointer)
+   weston_pointer_set_focus(pointer,
 get_default_view(shell->grab_surface),
 wl_fixed_from_int(0),
 wl_fixed_from_int(0));
@@ -925,12 +928,10 @@ restore_focus_state(struct desktop_shell *shell, struct 
workspace *ws)
wl_list_insert(&shell->compositor->seat_list,
   &state->seat->link);
 
-   if (!keyboard)
-   continue;
-
surface = state->keyboard_focus;
 
-   weston_keyboard_set_focus(keyboard, surface);
+   if (keyboard)
+   weston_keyboard_set_focus(keyboar

[PATCH wayland] scanner: server-side also emit SINCE macros for requests

2015-10-09 Thread David FORT
Server-side we need to know the versions for destructor requests.

Signed-off-by: David FORT 
---
 src/scanner.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/scanner.c b/src/scanner.c
index f456aa5..406ba82 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -1266,6 +1266,7 @@ emit_header(struct protocol *protocol, enum side side)
emit_structs(&i->request_list, i, side);
emit_opcodes(&i->event_list, i);
emit_opcode_versions(&i->event_list, i);
+   emit_opcode_versions(&i->request_list, i);
emit_event_wrappers(&i->event_list, i);
} else {
emit_structs(&i->event_list, i, side);
-- 
1.9.1

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


[PATCH] weston: release keyboard/touch/pointer objects

2015-10-09 Thread David FORT
This patch adds the missing calls to release when the seat has capabilities
changes. It also fixes a missing release of the touch object and a leak with
old clients.

Signed-off-by: David FORT 
---
 clients/window.c | 26 ++
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index 47a79aa..6d3e944 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -3256,7 +3256,10 @@ seat_handle_capabilities(void *data, struct wl_seat 
*seat,
wl_pointer_add_listener(input->pointer, &pointer_listener,
input);
} else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && input->pointer) {
-   wl_pointer_destroy(input->pointer);
+   if (input->display->seat_version >= 
WL_POINTER_RELEASE_SINCE_VERSION)
+   wl_pointer_release(input->pointer);
+   else
+   wl_pointer_destroy(input->pointer);
input->pointer = NULL;
}
 
@@ -3266,7 +3269,10 @@ seat_handle_capabilities(void *data, struct wl_seat 
*seat,
wl_keyboard_add_listener(input->keyboard, &keyboard_listener,
 input);
} else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && input->keyboard) {
-   wl_keyboard_destroy(input->keyboard);
+   if (input->display->seat_version >= 
WL_KEYBOARD_RELEASE_SINCE_VERSION)
+   wl_keyboard_release(input->keyboard);
+   else
+   wl_keyboard_destroy(input->keyboard);
input->keyboard = NULL;
}
 
@@ -3275,7 +3281,10 @@ seat_handle_capabilities(void *data, struct wl_seat 
*seat,
wl_touch_set_user_data(input->touch, input);
wl_touch_add_listener(input->touch, &touch_listener, input);
} else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && input->touch) {
-   wl_touch_destroy(input->touch);
+   if (input->display->seat_version >= 
WL_TOUCH_RELEASE_SINCE_VERSION)
+   wl_touch_release(input->touch);
+   else
+   wl_touch_destroy(input->touch);
input->touch = NULL;
}
 }
@@ -5269,11 +5278,20 @@ input_destroy(struct input *input)
else
wl_data_device_destroy(input->data_device);
}
-   if (input->display->seat_version >= 3) {
+   if (input->display->seat_version >= WL_POINTER_RELEASE_SINCE_VERSION) {
+   if (input->touch)
+   wl_touch_release(input->touch);
if (input->pointer)
wl_pointer_release(input->pointer);
if (input->keyboard)
wl_keyboard_release(input->keyboard);
+   } else {
+   if (input->touch)
+   wl_touch_destroy(input->touch);
+   if (input->pointer)
+   wl_pointer_destroy(input->pointer);
+   if (input->keyboard)
+   wl_keyboard_destroy(input->keyboard);
}
 
fini_xkb(input);
-- 
1.9.1

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


[PATCH] weston: release keyboard/touch/pointer objects

2015-10-06 Thread David FORT
This patch adds the missing calls to release when the seat has capabilities
changes. It also fixes a missing release of the touch object.
---
 clients/window.c | 23 +++
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index 47a79aa..7469259 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -79,6 +79,10 @@ typedef void *EGLContext;
 #include "ivi-application-client-protocol.h"
 #define IVI_SURFACE_ID 9000
 
+#define WL_KEYBOARD_RELEASE_SINCE_VERSION 3
+#define WL_POINTER_RELEASE_SINCE_VERSION 3
+#define WL_TOUCH_RELEASE_SINCE_VERSION 3
+
 struct shm_pool;
 
 struct global {
@@ -3256,7 +3260,10 @@ seat_handle_capabilities(void *data, struct wl_seat 
*seat,
wl_pointer_add_listener(input->pointer, &pointer_listener,
input);
} else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && input->pointer) {
-   wl_pointer_destroy(input->pointer);
+   if (input->display->seat_version >= 
WL_POINTER_RELEASE_SINCE_VERSION)
+   wl_pointer_release(input->pointer);
+   else
+   wl_pointer_destroy(input->pointer);
input->pointer = NULL;
}
 
@@ -3266,7 +3273,10 @@ seat_handle_capabilities(void *data, struct wl_seat 
*seat,
wl_keyboard_add_listener(input->keyboard, &keyboard_listener,
 input);
} else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && input->keyboard) {
-   wl_keyboard_destroy(input->keyboard);
+   if (input->display->seat_version >= 
WL_KEYBOARD_RELEASE_SINCE_VERSION)
+   wl_keyboard_release(input->keyboard);
+   else
+   wl_keyboard_destroy(input->keyboard);
input->keyboard = NULL;
}
 
@@ -3275,7 +3285,10 @@ seat_handle_capabilities(void *data, struct wl_seat 
*seat,
wl_touch_set_user_data(input->touch, input);
wl_touch_add_listener(input->touch, &touch_listener, input);
} else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && input->touch) {
-   wl_touch_destroy(input->touch);
+   if (input->display->seat_version >= 
WL_TOUCH_RELEASE_SINCE_VERSION)
+   wl_touch_release(input->touch);
+   else
+   wl_touch_destroy(input->touch);
input->touch = NULL;
}
 }
@@ -5269,7 +5282,9 @@ input_destroy(struct input *input)
else
wl_data_device_destroy(input->data_device);
}
-   if (input->display->seat_version >= 3) {
+   if (input->display->seat_version >= WL_POINTER_RELEASE_SINCE_VERSION) {
+   if (input->touch)
+   wl_touch_release(input->touch);
if (input->pointer)
wl_pointer_release(input->pointer);
if (input->keyboard)
-- 
1.9.1

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


[PATCH] wayland: add a release request on wl_seat v3

2015-10-02 Thread David FORT
This version takes in account last Jonas Ådahl's remarks.


David FORT (1):
  wayland: add a release request on wl_seat

 protocol/wayland.xml | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

-- 
1.9.1

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


[PATCH] wayland: add a release request on wl_seat

2015-10-02 Thread David FORT
This is required if we want to correctly remove a wl_seat compositor-side. A
wl_seat is announced as a global object, then it is bound by the client. When
the compositor wants to remove the seat, it shall announce the global removal of
the object. The client can then call the release request on the wl_seat (which
means I won't use that object anymore).
---
 protocol/wayland.xml | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index 42c9309..59819e9 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -1329,7 +1329,7 @@
 

 
-  
+  
 
   A seat is a group of keyboards, pointer and touch devices. This
   object is published as a global during start up, or when such a
@@ -1400,6 +1400,15 @@
   
 
 
+
+
+
+  
+  Using this request client can tell the server that it is not going to
+   use the seat object anymore.
+  
+
+
   
 
   
-- 
1.9.1

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


[PATCH] wayland: add release request on wl_seat v2

2015-09-30 Thread David FORT
Compared to the first version, I changed the description according to
Jonas's comment. No real consensus have emerged on IRC or on the mailing
list about version numbering. So I choosed to keep them as it is done now.

David FORT (1):
  Add a release request on wl_seat

 protocol/wayland.xml | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

-- 
1.9.1

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


[PATCH] wayland: add a release request on wl_seat

2015-09-30 Thread David FORT
This is required if we want to correctly remove a wl_seat compositor-side. A
wl_seat is announced as a global object, then it is bound by the client. When
the compositor wants to remove the seat, it shall announce the global removal of
the object. The client can then call the release request on the wl_seat (which
means I won't use that object anymore). When all clients have released the
wl_seat, it can be destroyed by the compositor.
---
 protocol/wayland.xml | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index 42c9309..6764565 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -1329,7 +1329,7 @@
 

 
-  
+  
 
   A seat is a group of keyboards, pointer and touch devices. This
   object is published as a global during start up, or when such a
@@ -1400,6 +1400,15 @@
   
 
 
+
+
+
+  
+  This request is called by the client to inform that it will not use the 
seat
+  object.
+  
+
+
   
 
   
-- 
1.9.1

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


[PATCH] wayland: add release request on wl_seat

2015-09-29 Thread David FORT
This is required if we want to correctly remove a wl_seat compositor-side. A
wl_seat is announced as a global object, then it is bound by the client. When
the compositor wants to remove the seat, it shall announce the global removal of
the object. The client can then call the release request on the wl_seat (which
means it won't use that object anymore). When all clients have released the
wl_seat, it can be destroyed by the compositor.
---
 protocol/wayland.xml | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index 42c9309..2c7a675 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -1329,7 +1329,7 @@
 

 
-  
+  
 
   A seat is a group of keyboards, pointer and touch devices. This
   object is published as a global during start up, or when such a
@@ -1400,6 +1400,16 @@
   
 
 
+
+
+
+  
+  This request is called by the client to inform that it will not address 
the seat
+  object. The compositor can destroy this seat when all clients have called
+  this request.
+  
+
+
   
 
   
-- 
1.9.1

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


[PATCH weston] RDP compositor: make the seat dynamic and don't destroy it on removal

2015-09-24 Thread David FORT
This patch makes the seat dynamic and leak it on purpose during seat removal to
prevent the ghost object case.
---
 src/compositor-rdp.c | 39 +++
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index c221eb9..7abffee 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -110,7 +110,7 @@ enum peer_item_flags {
 struct rdp_peers_item {
int flags;
freerdp_peer *peer;
-   struct weston_seat seat;
+   struct weston_seat *seat;
 
struct wl_list link;
 };
@@ -628,6 +628,7 @@ static void
 rdp_peer_context_free(freerdp_peer* client, RdpPeerContext* context)
 {
int i;
+   struct weston_seat *seat;
if (!context)
return;
 
@@ -638,9 +639,17 @@ rdp_peer_context_free(freerdp_peer* client, 
RdpPeerContext* context)
}
 
if (context->item.flags & RDP_PEER_ACTIVATED) {
-   weston_seat_release_keyboard(&context->item.seat);
-   weston_seat_release_pointer(&context->item.seat);
-   weston_seat_release(&context->item.seat);
+   seat = context->item.seat;
+   weston_seat_release_keyboard(seat);
+   weston_seat_release_pointer(seat);
+
+   /* picked from weston_seat_release(context->item.seat); */
+   wl_list_remove(&seat->link);
+   if (seat->saved_kbd_focus)
+   wl_list_remove(&seat->saved_kbd_focus_listener.link);
+   wl_global_destroy(seat->global);
+   wl_signal_emit(&seat->destroy_signal, seat);
+
}
 
Stream_Free(context->encode_stream, TRUE);
@@ -910,9 +919,15 @@ xf_peer_activate(freerdp_peer* client)
else
snprintf(seat_name, sizeof(seat_name), "RDP peer @%s", 
settings->ClientAddress);
 
-   weston_seat_init(&peersItem->seat, b->compositor, seat_name);
-   weston_seat_init_keyboard(&peersItem->seat, keymap);
-   weston_seat_init_pointer(&peersItem->seat);
+   peersItem->seat = zalloc(sizeof(*peersItem->seat));
+   if (!peersItem->seat) {
+   weston_log("unable to allocate the seat for %s", seat_name);
+   return FALSE;
+   }
+
+   weston_seat_init(peersItem->seat, &b->compositor, seat_name);
+   weston_seat_init_keyboard(peersItem->seat, keymap);
+   weston_seat_init_pointer(peersItem->seat);
 
peersItem->flags |= RDP_PEER_ACTIVATED;
 
@@ -953,7 +968,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
UINT16 y)
if (x < output->base.width && y < output->base.height) {
wl_x = wl_fixed_from_int((int)x);
wl_y = wl_fixed_from_int((int)y);
-   notify_motion_absolute(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_motion_absolute(peerContext->item.seat, 
weston_compositor_get_time(),
wl_x, wl_y);
}
}
@@ -966,7 +981,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
UINT16 y)
button = BTN_MIDDLE;
 
if (button) {
-   notify_button(&peerContext->item.seat, 
weston_compositor_get_time(), button,
+   notify_button(peerContext->item.seat, 
weston_compositor_get_time(), button,
(flags & PTR_FLAGS_DOWN) ? 
WL_POINTER_BUTTON_STATE_PRESSED : WL_POINTER_BUTTON_STATE_RELEASED
);
}
@@ -982,7 +997,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
UINT16 y)
if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
axis = -axis;
 
-   notify_axis(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_axis(peerContext->item.seat, 
weston_compositor_get_time(),
WL_POINTER_AXIS_VERTICAL_SCROLL,
axis);
}
@@ -1001,7 +1016,7 @@ xf_extendedMouseEvent(rdpInput *input, UINT16 flags, 
UINT16 x, UINT16 y)
if (x < output->base.width && y < output->base.height) {
wl_x = wl_fixed_from_int((int)x);
wl_y = wl_fixed_from_int((int)y);
-   notify_motion_absolute(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_motion_absolute(peerContext->item.seat, 
weston_compositor_get_time(),
wl_x, wl_y);
}
 
@@ -1064,7 +1079,7 @@ xf_input_keyboard_event(rdpInput *input, UINT16 flags, 
UINT16 code)
 
/*weston_log("code=%x ext=%d vk_code=%x scan_code=%x\n", code, 
(flags & KBD_FLAGS_EXTENDED) ? 1 : 0,
vk_code, scan_code);*/
-   notify_key(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_key(peerContext->item.seat, weston_compositor_get_time(),
  

[PATCH weston] RDP compositor: dynamic seat v2

2015-09-24 Thread David FORT
This is the updated version patched for libweston.
I had a discussion with Pekka about the seat removal announce.
Previously valgrind was detecting nasty things with text-input. But some 
cleanups have been done since in text-input and it works like a charm now.
So I feel like the seat removal announce is done the right way(TM) in 
this patch. If you disagree, comments are more than welcome.


David FORT (1):
  RDP compositor: make the seat dynamic and don't destroy it on removal

 src/compositor-rdp.c | 39 +++
 1 file changed, 27 insertions(+), 12 deletions(-)

-- 
1.9.1

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


[PATCH] [RDP compositor] don't crash when the key file doesn't exist

2015-08-01 Thread David FORT
This allows to close the remaining issue in
https://bugs.freedesktop.org/show_bug.cgi?id=91390
---
 src/compositor-rdp.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index 4ef0dd1..c76af61 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -1102,7 +1102,10 @@ rdp_peer_init(freerdp_peer *client, struct rdp_backend 
*b)
}
settings->NlaSecurity = FALSE;
 
-   client->Initialize(client);
+   if (!client->Initialize(client)) {
+   weston_log("peer initialization failed\n");
+   goto error_initialize;
+   }
 
settings->OsMajorType = OSMAJORTYPE_UNIX;
settings->OsMinorType = OSMINORTYPE_PSEUDO_XSERVER;
@@ -1113,7 +1116,6 @@ rdp_peer_init(freerdp_peer *client, struct rdp_backend *b)
settings->FrameMarkerCommandEnabled = TRUE;
settings->SurfaceFrameMarkerEnabled = TRUE;
 
-
client->Capabilities = xf_peer_capabilities;
client->PostConnect = xf_peer_post_connect;
client->Activate = xf_peer_activate;
@@ -1129,7 +1131,7 @@ rdp_peer_init(freerdp_peer *client, struct rdp_backend *b)
 
if (!client->GetFileDescriptor(client, rfds, &rcount)) {
weston_log("unable to retrieve client fds\n");
-   return -1;
+   goto error_initialize;
}
 
loop = wl_display_get_event_loop(b->compositor->wl_display);
@@ -1144,6 +1146,10 @@ rdp_peer_init(freerdp_peer *client, struct rdp_backend 
*b)
 
wl_list_insert(&b->output->peers, &peerCtx->item.link);
return 0;
+
+error_initialize:
+   client->Close(client);
+   return -1;
 }
 
 
@@ -1152,7 +1158,7 @@ rdp_incoming_peer(freerdp_listener *instance, 
freerdp_peer *client)
 {
struct rdp_backend *b = (struct rdp_backend *)instance->param4;
if (rdp_peer_init(client, b) < 0) {
-   weston_log("error when treating incoming peer");
+   weston_log("error when treating incoming peer\n");
FREERDP_CB_RETURN(FALSE);
}
 
-- 
1.9.1

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


[PATCH 2/2] [rdp compositor] Fix crash when using RDP4 security

2015-07-20 Thread David FORT
The initialization of the freerdp_peer was done too early.
This fixes https://bugs.freedesktop.org/show_bug.cgi?id=91390.
---
 src/compositor-rdp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index 70d290b..4ef0dd1 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -1090,8 +1090,6 @@ rdp_peer_init(freerdp_peer *client, struct rdp_backend *b)
peerCtx = (RdpPeerContext *) client->context;
peerCtx->rdpBackend = b;
 
-   client->Initialize(client);
-
settings = client->settings;
/* configure security settings */
if (b->rdp_key)
@@ -1104,6 +1102,8 @@ rdp_peer_init(freerdp_peer *client, struct rdp_backend *b)
}
settings->NlaSecurity = FALSE;
 
+   client->Initialize(client);
+
settings->OsMajorType = OSMAJORTYPE_UNIX;
settings->OsMinorType = OSMINORTYPE_PSEUDO_XSERVER;
settings->ColorDepth = 32;
@@ -1113,6 +1113,7 @@ rdp_peer_init(freerdp_peer *client, struct rdp_backend *b)
settings->FrameMarkerCommandEnabled = TRUE;
settings->SurfaceFrameMarkerEnabled = TRUE;
 
+
client->Capabilities = xf_peer_capabilities;
client->PostConnect = xf_peer_post_connect;
client->Activate = xf_peer_activate;
-- 
1.9.1

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


[PATCH 1/2] [rdp compositor] remove a warning during compilation

2015-07-20 Thread David FORT
backend_init now returns an int not a pointer.
---
 src/compositor-rdp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index 86c5b2a..70d290b 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -1270,7 +1270,7 @@ backend_init(struct weston_compositor *compositor, int 
*argc, char *argv[],
if (!config.rdp_key && (!config.server_cert || !config.server_key)) {
weston_log("the RDP compositor requires keys and an optional 
certificate for RDP or TLS security ("
"--rdp4-key or 
--rdp-tls-cert/--rdp-tls-key)\n");
-   return NULL;
+   return -1;
}
 
b = rdp_backend_create(compositor, &config, argc, argv, wconfig);
-- 
1.9.1

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


[PATCH 0/2] Misc fixes for the RDP compositor

2015-07-20 Thread David FORT
Misc things fixed in the RDP compositor:
* bad return value in backend_init, introduced by the libweston refactoring;
* an initialization that was done too early and was crashing when using RDP4
security

David FORT (2):
  [rdp compositor] remove a warning during compilation
  [rdp compositor] Fix crash when using RDP4 security

 src/compositor-rdp.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

-- 
1.9.1

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


[PATCH 1/2] RDP compositor: make the seat dynamic and don't destroy it on removal

2015-05-19 Thread David FORT
This patch makes the seat dynamic and leak it on purpose during seat removal to
prevent the ghost object case.
---
 src/compositor-rdp.c | 39 +++
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index 3185141..f1dcda0 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -105,7 +105,7 @@ enum peer_item_flags {
 struct rdp_peers_item {
int flags;
freerdp_peer *peer;
-   struct weston_seat seat;
+   struct weston_seat *seat;
 
struct wl_list link;
 };
@@ -606,6 +606,7 @@ static void
 rdp_peer_context_free(freerdp_peer* client, RdpPeerContext* context)
 {
int i;
+   struct weston_seat *seat;
if (!context)
return;
 
@@ -616,9 +617,17 @@ rdp_peer_context_free(freerdp_peer* client, 
RdpPeerContext* context)
}
 
if (context->item.flags & RDP_PEER_ACTIVATED) {
-   weston_seat_release_keyboard(&context->item.seat);
-   weston_seat_release_pointer(&context->item.seat);
-   weston_seat_release(&context->item.seat);
+   seat = context->item.seat;
+   weston_seat_release_keyboard(seat);
+   weston_seat_release_pointer(seat);
+
+   /* picked from weston_seat_release(context->item.seat); */
+   wl_list_remove(&seat->link);
+   if (seat->saved_kbd_focus)
+   wl_list_remove(&seat->saved_kbd_focus_listener.link);
+   wl_global_destroy(seat->global);
+   wl_signal_emit(&seat->destroy_signal, seat);
+
}
 
Stream_Free(context->encode_stream, TRUE);
@@ -887,9 +896,15 @@ xf_peer_activate(freerdp_peer* client)
else
snprintf(seat_name, sizeof(seat_name), "RDP peer @%s", 
settings->ClientAddress);
 
-   weston_seat_init(&peersItem->seat, &c->base, seat_name);
-   weston_seat_init_keyboard(&peersItem->seat, keymap);
-   weston_seat_init_pointer(&peersItem->seat);
+   peersItem->seat = zalloc(sizeof(*peersItem->seat));
+   if (!peersItem->seat) {
+   weston_log("unable to allocate the seat for %s", seat_name);
+   return FALSE;
+   }
+
+   weston_seat_init(peersItem->seat, &c->base, seat_name);
+   weston_seat_init_keyboard(peersItem->seat, keymap);
+   weston_seat_init_pointer(peersItem->seat);
 
peersItem->flags |= RDP_PEER_ACTIVATED;
 
@@ -929,7 +944,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
UINT16 y) {
if (x < output->base.width && y < output->base.height) {
wl_x = wl_fixed_from_int((int)x);
wl_y = wl_fixed_from_int((int)y);
-   notify_motion_absolute(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_motion_absolute(peerContext->item.seat, 
weston_compositor_get_time(),
wl_x, wl_y);
}
}
@@ -942,7 +957,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
UINT16 y) {
button = BTN_MIDDLE;
 
if (button) {
-   notify_button(&peerContext->item.seat, 
weston_compositor_get_time(), button,
+   notify_button(peerContext->item.seat, 
weston_compositor_get_time(), button,
(flags & PTR_FLAGS_DOWN) ? 
WL_POINTER_BUTTON_STATE_PRESSED : WL_POINTER_BUTTON_STATE_RELEASED
);
}
@@ -958,7 +973,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, 
UINT16 y) {
if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
axis = -axis;
 
-   notify_axis(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_axis(peerContext->item.seat, 
weston_compositor_get_time(),
WL_POINTER_AXIS_VERTICAL_SCROLL,
axis);
}
@@ -976,7 +991,7 @@ xf_extendedMouseEvent(rdpInput *input, UINT16 flags, UINT16 
x, UINT16 y) {
if (x < output->base.width && y < output->base.height) {
wl_x = wl_fixed_from_int((int)x);
wl_y = wl_fixed_from_int((int)y);
-   notify_motion_absolute(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_motion_absolute(peerContext->item.seat, 
weston_compositor_get_time(),
wl_x, wl_y);
}
 
@@ -1039,7 +1054,7 @@ xf_input_keyboard_event(rdpInput *input, UINT16 flags, 
UINT16 code)
 
/*weston_log("code=%x ext=%d vk_code=%x scan_code=%x\n", code, 
(flags & KBD_FLAGS_EXTENDED) ? 1 : 0,
vk_code, scan_code);*/
-   notify_key(&peerContext->item.seat, 
weston_compositor_get_time(),
+   notify_key(peerContext->item.seat, weston_compositor_get_time(),
   

[PATCH 0/2] Misc fixes for the RDP compositor

2015-05-19 Thread David FORT
This serie contains a patch to force keys and certificates with the RDP
compositor as it is almost unusable without them. It also makes dynamic the 
seat allocated per connection, so that we can free the RDP context and
keep alive the seat (to workaround the fact that we can't safely free a seat).

David FORT (2):
  RDP compositor: make the seat dynamic and don't destroy it on removal
  RDP compositor: enforce certificate and key

 src/compositor-rdp.c | 45 +
 1 file changed, 33 insertions(+), 12 deletions(-)

-- 
1.9.1

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


[PATCH 2/2] RDP compositor: enforce certificate and key

2015-05-19 Thread David FORT
The RDP compositor is usable without certificates and key in a very limited
number of cases (local usage using xfreerdp), so let's force the presence of
keys and certificates.
---
 src/compositor-rdp.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index f1dcda0..261fa4b 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -1278,5 +1278,11 @@ backend_init(struct wl_display *display, int *argc, char 
*argv[],
};
 
parse_options(rdp_options, ARRAY_LENGTH(rdp_options), argc, argv);
+   if (!config.rdp_key && (!config.server_cert || !config.server_key)) {
+   weston_log("the RDP compositor requires keys and an optional 
certificate for RDP or TLS security ("
+   "--rdp4-key or 
--rdp-tls-cert/--rdp-tls-key)\n");
+   return NULL;
+   }
+
return rdp_compositor_create(display, &config, argc, argv, wconfig);
 }
-- 
1.9.1

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


[PATCH RDP compositor] v3 fixes for multiple connections and mstsc

2015-05-06 Thread David FORT
This v3 should fix the detection of nsc_context_reset(). It also allows to 
compile
against FreeRDP master, with the callbacks that now return BOOLs.


Hardening (1):
  RDP compositor: fixes for multiple connections, mstsc and FreeRDP
master compilation

 src/compositor-rdp.c | 127 +++
 1 file changed, 97 insertions(+), 30 deletions(-)

-- 
1.9.1

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


[PATCH] RDP compositor: fixes for multiple connections, mstsc and FreeRDP master compilation

2015-05-06 Thread David FORT
From: Hardening 

This patch fixes the problem reported on the mailing list
(http://lists.freedesktop.org/archives/wayland-devel/2015-January/019575.html).
All certificate and key paths were not copied when given to FreeRDP, so they
were freed when the peer was disconnecting. And so the next connection was 
failing.

All the initialization stuffs have been moved to the activate callback, as when 
it is
called the peer is ready for graphics.

We also differ the creation of the seat, so that a seat is initialized only the
peer really do the activation sequence. That helps when mstsc just connects to 
see
the certificate, ask if the certificate should be trusted, and then reconnects.

This patch also adds configuration settings for recent versions of FreeRDP that
comes with everything disabled. This makes remoteFx functionnal again.

The patch also handles the skipCompression flag for last FreeRDP versions, that
allows to skip bulk compression for surfaces that have been already compressed 
by
the remoteFx or NS codec.

This also fixes the compilation against FreeRDP master with callback that now 
return
BOOL.
---
 src/compositor-rdp.c | 127 +++
 1 file changed, 97 insertions(+), 30 deletions(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index 6955d49..76f342b 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -33,6 +33,23 @@
 /* assume it's a early 1.1 version */
 #define FREERDP_VERSION_MAJOR 1
 #define FREERDP_VERSION_MINOR 1
+#define FREERDP_VERSION_REVISION 0
+#endif
+
+#define FREERDP_VERSION_NUMBER ((FREERDP_VERSION_MAJOR * 0x1) + \
+   (FREERDP_VERSION_MINOR * 0x100) + FREERDP_VERSION_REVISION)
+
+#if FREERDP_VERSION_NUMBER >= 0x10201
+#define HAVE_SKIP_COMPRESSION
+#endif
+
+#if FREERDP_VERSION_NUMBER < 0x10202
+#define FREERDP_CB_RET_TYPE void
+#define FREERDP_CB_RETURN(V) return
+#else
+#define HAVE_NSC_RESET
+#define FREERDP_CB_RET_TYPE BOOL
+#define FREERDP_CB_RETURN(V) return TRUE
 #endif
 
 #include 
@@ -145,6 +162,11 @@ rdp_peer_refresh_rfx(pixman_region32_t *damage, 
pixman_image_t *image, freerdp_p
width = (damage->extents.x2 - damage->extents.x1);
height = (damage->extents.y2 - damage->extents.y1);
 
+#ifdef HAVE_SKIP_COMPRESSION
+   cmd->skipCompression = TRUE;
+#else
+   memset(cmd, 0, sizeof(*cmd));
+#endif
cmd->destLeft = damage->extents.x1;
cmd->destTop = damage->extents.y1;
cmd->destRight = damage->extents.x2;
@@ -197,6 +219,11 @@ rdp_peer_refresh_nsc(pixman_region32_t *damage, 
pixman_image_t *image, freerdp_p
width = (damage->extents.x2 - damage->extents.x1);
height = (damage->extents.y2 - damage->extents.y1);
 
+#ifdef HAVE_SKIP_COMPRESSION
+   cmd->skipCompression = TRUE;
+#else
+   memset(cmd, 0, sizeof(*cmd));
+#endif
cmd->destLeft = damage->extents.x1;
cmd->destTop = damage->extents.y1;
cmd->destRight = damage->extents.x2;
@@ -248,6 +275,7 @@ rdp_peer_refresh_raw(pixman_region32_t *region, 
pixman_image_t *image, freerdp_p
marker->frameAction = SURFACECMD_FRAMEACTION_BEGIN;
update->SurfaceFrameMarker(peer->context, marker);
 
+   memset(cmd, 0, sizeof(*cmd));
cmd->bpp = 32;
cmd->codecID = 0;
 
@@ -592,6 +620,7 @@ rdp_peer_context_free(freerdp_peer* client, RdpPeerContext* 
context)
weston_seat_release_pointer(&context->item.seat);
weston_seat_release(&context->item.seat);
}
+
Stream_Free(context->encode_stream, TRUE);
nsc_context_free(context->nsc_context);
rfx_context_free(context->rfx_context);
@@ -757,23 +786,26 @@ static char *rdp_keyboard_types[] = {
 };
 
 static BOOL
-xf_peer_post_connect(freerdp_peer* client)
+xf_peer_activate(freerdp_peer* client)
 {
RdpPeerContext *peerCtx;
struct rdp_compositor *c;
struct rdp_output *output;
rdpSettings *settings;
rdpPointerUpdate *pointer;
+   struct rdp_peers_item *peersItem;
struct xkb_context *xkbContext;
struct xkb_rule_names xkbRuleNames;
struct xkb_keymap *keymap;
int i;
pixman_box32_t box;
pixman_region32_t damage;
+   char seat_name[50];
 
 
peerCtx = (RdpPeerContext *)client->context;
c = peerCtx->rdpCompositor;
+   peersItem = &peerCtx->item;
output = c->output;
settings = client->settings;
 
@@ -813,7 +845,16 @@ xf_peer_post_connect(freerdp_peer* client)
}
}
 
-   weston_log("kbd_layout:%x kbd_type:%x kbd_subType:%x 
kbd_functionKeys:%x\n",
+   rfx_context_reset(peerCtx->rfx_context);
+#ifdef HAVE_NSC_RESET
+   nsc_context_reset(peerCtx->nsc_context);
+#endif
+
+   if (peersItem->flags & RDP_PEER_ACTIVATED)
+   return TRUE;
+
+   /* when here it's the first reactivation, we need to setup a little 
more */
+   weston_log("kbd_layout:0x%x kbd_type:0x%x 

[PATCH 0/3][RFC] introducing inert objects to allow to release server-side objects

2015-02-25 Thread David FORT
This serie of patches tries to address the problem of removing a seat and 
really deleting
it server-side. First I have added the corresponding method in the protocol 
definition.
Second I have modified the scanner to emit some code to create inert objects: 
objects
with requests that do nothing, and only return inert objects.
This is a preliminary work and comments are more than welcome.

David FORT (3):
  Modify wayland-scanner to generate inert objects
  Add a release request on wl_seat
  wayland.xml: fixed a typo

 protocol/wayland.xml |   8 ++-
 src/scanner.c| 173 ---
 wayland-scanner.mk   |   3 +
 3 files changed, 173 insertions(+), 11 deletions(-)

-- 
1.9.1

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


[PATCH 2/3] Modify wayland-scanner to generate inert objects

2015-02-25 Thread David FORT
As stated in the very good blog post[1] of Pekka Paalanen, server-side we can 
have
sometime troubles with object that the server has deleted but that the client
is still requesting. This patch complements the scanner to create some code
that will return inert objects, ie objects that will do nothing and will never
return anything else but an inert object. An example is a get_pointer() on
a wl_seat, with an unplugged mouse (and so no pointer). Instead of keeping alive
the old pointer, we could bind that inert object and wait that the client 
release
it (which should happen very quickly as a wl_global_remove should be in the 
wire).

[1]: 
http://ppaalanen.blogspot.fi/2014/07/wayland-protocol-design-object-lifespan.html
---
 src/scanner.c  | 173 +
 wayland-scanner.mk |   3 +
 2 files changed, 166 insertions(+), 10 deletions(-)

diff --git a/src/scanner.c b/src/scanner.c
index 1f1e59a..dbdd1f6 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -39,7 +39,7 @@ enum side {
 static int
 usage(int ret)
 {
-   fprintf(stderr, "usage: ./scanner 
[client-header|server-header|code]\n");
+   fprintf(stderr, "usage: ./scanner 
[client-header|server-header|code|server-inert]\n");
fprintf(stderr, "\n");
fprintf(stderr, "Converts XML protocol descriptions supplied on "
"stdin to client headers,\n"
@@ -626,6 +626,18 @@ emit_type(struct arg *a)
}
 }
 
+static struct arg *
+get_return_type(struct message *m)
+{
+   struct arg *a, *ret = NULL;
+
+   wl_list_for_each(a, &m->arg_list, link) {
+   if (a->type == NEW_ID)
+   ret = a;
+   }
+   return ret;
+}
+
 static void
 emit_stubs(struct wl_list *message_list, struct interface *interface)
 {
@@ -688,11 +700,7 @@ emit_stubs(struct wl_list *message_list, struct interface 
*interface)
continue;
}
 
-   ret = NULL;
-   wl_list_for_each(a, &m->arg_list, link) {
-   if (a->type == NEW_ID)
-   ret = a;
-   }
+   ret = get_return_type(m);
 
if (ret && ret->interface_name == NULL)
printf("static inline void *\n");
@@ -1103,8 +,7 @@ emit_types(struct protocol *protocol, struct wl_list 
*message_list)
case NEW_ID:
case OBJECT:
if (a->interface_name)
-   printf("\t&%s_interface,\n",
-  a->interface_name);
+   printf("\t&%s_interface,\n", 
a->interface_name);
else
printf("\tNULL,\n");
break;
@@ -1248,6 +1255,140 @@ emit_code(struct protocol *protocol)
}
 }
 
+static void
+emit_inert_request(struct protocol *protocol, struct interface *interface, 
struct wl_list *message_list)
+{
+   struct message *m;
+   struct arg *a, *ret;
+   const char *newid_name;
+
+   wl_list_for_each(m, message_list, link) {
+   ret = get_return_type(m);
+
+   /* forward declaration for the returned object */
+   if (ret && ret->interface_name) {
+   printf("static void\n"
+   "create_inert_%s(struct wl_client 
*client, uint32_t version, uint32_t id);\n"
+   "\n",
+   ret->interface_name);
+   }
+
+   printf("static inline void inert_%s_%s(struct wl_client 
*client, struct wl_resource *resource",
+  interface->name, m->name
+  );
+
+   wl_list_for_each(a, &m->arg_list, link) {
+   if (a->type == NEW_ID) {
+   newid_name = a->name;
+
+   if (a->interface_name == NULL) {
+   printf(", const struct wl_interface 
*interface"
+  ", uint32_t version");
+   continue;
+   }
+   }
+
+   if (a->type == OBJECT) {
+   printf(", struct wl_resource *");
+   } else {
+   printf(", ");
+   emit_type(a);
+   }
+   printf("%s", a->name);
+   }
+
+   printf(")\n"
+  "{\n");
+
+   if (ret && ret->interface_name) {
+   printf("\tcreate_inert_%s(client, 
wl_resource_get_version(resource), %s);\n",
+   ret->interface_name, newid_name);
+   

[PATCH 3/3] Add a release request on wl_seat

2015-02-25 Thread David FORT
This is required if we want to correctly remove a wl_seat server-side.
---
 protocol/wayland.xml | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index 4fb8035..8f63ebf 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -1400,6 +1400,12 @@
   
 
 
+
+
+
+  
+
+
   
 
   
-- 
1.9.1

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


[PATCH 1/3] wayland.xml: fixed a typo

2015-02-25 Thread David FORT
From: Hardening 

---
 protocol/wayland.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index 2a49805..4fb8035 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -1389,7 +1389,7 @@
   
 
 
-
+
 
 
   
-- 
1.9.1

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


Re: [RDP compositor] peer's output is enabled at connexion The peer's flags were badly set when the peer had just connect, this patch sets the output as enable at connection.

2013-08-10 Thread David FORT

On 10/08/2013 22:53, Hardening wrote:

---
  src/compositor-rdp.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)



[...]

Sorry for the bad header formatting.

I forgot to precise it was for stable-1.2 and for master and to say that 
all credits goes to Marek Romanowicz who does all the inquiry job.


Regards, Hardening.
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: Possible bug in compositor-rdp.c (Marek Romanowicz)

2013-08-06 Thread David FORT

On 06/08/2013 17:28, Marek Romanowicz wrote:


Hi all,

I am not sure if compositor-rdp.c acts as authors intended it to. I 
managed to make it running after several attempts together with 
wayland and connect to it over RDP protocol using xfreerdp from 
another machine running Ubuntu 13.10. Xfreerdp client obtained initial 
Wayland desktop image over the network however it did not seem to be 
receiving any screen updates until I moved its window on the client 
side so I investigated it further and noticed  these lines within 
rdp_output_repaint function:


if ((outputPeer->flags & RDP_PEER_ACTIVATED) &&
(outputPeer->flags & RDP_PEER_OUTPUT_ENABLED))
{
rdp_peer_refresh_region(damage, outputPeer->peer);
}

As it turned out, compositor-rdp.c  wanted to send an update of the 
display having received every input signal or changed display but 
these two flags don't seem to be both set at the same time except for 
when I move a window on the client side. Looking into it further I 
noticed that the problem was with RDP_PEER_OUTPUT_ENABLED flag as the 
other one appeared to be set whenever there is a repaint request. Has 
anyone encountered a similar problem?



Good catch, the flags should be initialized with 
RDP_PEER_OUTPUT_ENABLED. I've never seen it because when the xfreerdp 
client window is focused/unfocused it sends appropriate "suspend output" 
messages.


A patch will follow.

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