<div dir="ltr"><div class="gmail_extra">Hardening,<br>By and large, I think it looks good.  I have a few nit-picking comments below that should take ~20 seconds to address.<br><br></div><div class="gmail_extra">I was trying to test it on my machine and nothing seems to resize.  Is this because the xfreerdp client doesn't support resizing or is it from some other reason?<br>
<br></div><div class="gmail_extra">Thanks,<br></div><div class="gmail_extra">--Jason Ekstrand<br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_quote">On Tue, Mar 18, 2014 at 12:15 PM, Hardening <span dir="ltr"><<a href="mailto:rdp.effort@gmail.com" target="_blank">rdp.effort@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This patch removes the extra modes parameter for the RDP compositor. And<br>
make it support any mode that is requested (be aware that RDP client may not<br>
support all possible modes, especially odd resolution).<br>
This is definitely useful for the fullscreen shell.<br>
---<br>
 src/compositor-rdp.c | 105 +++++++++++++++++++--------------------------------<br>
 src/compositor.c     |   1 -<br>
 2 files changed, 38 insertions(+), 68 deletions(-)<br>
<br>
diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c<br>
index e8e4a8d..22380cb 100644<br>
--- a/src/compositor-rdp.c<br>
+++ b/src/compositor-rdp.c<br>
@@ -49,6 +49,7 @@<br>
<br>
 #define MAX_FREERDP_FDS 32<br>
 #define DEFAULT_AXIS_STEP_DISTANCE wl_fixed_from_int(10)<br>
+#define RDP_MODE_FREQ 60 * 1000<br>
<br>
 struct rdp_compositor_config {<br>
        int width;<br>
@@ -58,7 +59,6 @@ struct rdp_compositor_config {<br>
        char *rdp_key;<br>
        char *server_cert;<br>
        char *server_key;<br>
-       char *extra_modes;<br>
        int env_socket;<br>
 };<br>
<br>
@@ -121,7 +121,6 @@ rdp_compositor_config_init(struct rdp_compositor_config *config) {<br>
        config->rdp_key = NULL;<br>
        config->server_cert = NULL;<br>
        config->server_key = NULL;<br>
-       config->extra_modes = NULL;<br>
        config->env_socket = 0;<br>
 }<br>
<br>
@@ -320,11 +319,13 @@ rdp_output_repaint(struct weston_output *output_base, pixman_region32_t *damage)<br>
        pixman_renderer_output_set_buffer(output_base, output->shadow_surface);<br>
        ec->renderer->repaint_output(&output->base, damage);<br>
<br>
-       wl_list_for_each(outputPeer, &output->peers, link) {<br>
-               if ((outputPeer->flags & RDP_PEER_ACTIVATED) &&<br>
-                               (outputPeer->flags & RDP_PEER_OUTPUT_ENABLED))<br>
-               {<br>
-                       rdp_peer_refresh_region(damage, outputPeer->peer);<br>
+       if (pixman_region32_n_rects(damage)) {<br></blockquote><div><br></div><div>use pixman_region32_not_empty here instead<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


+               wl_list_for_each(outputPeer, &output->peers, link) {<br>
+                       if ((outputPeer->flags & RDP_PEER_ACTIVATED) &&<br>
+                                       (outputPeer->flags & RDP_PEER_OUTPUT_ENABLED))<br>
+                       {<br>
+                               rdp_peer_refresh_region(damage, outputPeer->peer);<br>
+                       }<br>
                }<br>
        }<br>
<br>
@@ -352,16 +353,29 @@ finish_frame_handler(void *data)<br>
        return 1;<br>
 }<br>
<br>
+static struct weston_mode *<br>
+rdp_insert_new_mode(struct weston_output *output, int width, int height, int rate) {<br>
+       struct weston_mode *ret;<br>
+       ret = zalloc(sizeof *ret);<br>
+       if(!ret)<br>
+               return ret;<br></blockquote><div><br></div><div>a) Missing the space between "if" and "(".  Also, let's do if (!ret) return NULL;  It makes it easier to read.<br></div><div> </div>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+       ret->width = width;<br>
+       ret->height = height;<br>
+       ret->refresh = rate;<br>
+       wl_list_insert(&output->mode_list, &ret->link);<br>
+       return ret;<br>
+}<br>
<br>
 static struct weston_mode *<br>
-find_matching_mode(struct weston_output *output, struct weston_mode *target) {<br>
+ensure_matching_mode(struct weston_output *output, struct weston_mode *target) {<br>
        struct weston_mode *local;<br>
<br>
        wl_list_for_each(local, &output->mode_list, link) {<br>
                if((local->width == target->width) && (local->height == target->height))<br>
                        return local;<br>
        }<br>
-       return 0;<br>
+<br>
+       return rdp_insert_new_mode(output, target->width, target->height, RDP_MODE_FREQ);<br>
 }<br>
<br>
 static int<br>
@@ -372,7 +386,7 @@ rdp_switch_mode(struct weston_output *output, struct weston_mode *target_mode) {<br>
        pixman_image_t *new_shadow_buffer;<br>
        struct weston_mode *local_mode;<br>
<br>
-       local_mode = find_matching_mode(output, target_mode);<br>
+       local_mode = ensure_matching_mode(output, target_mode);<br>
        if(!local_mode) {<br>
                weston_log("mode %dx%d not available\n", target_mode->width, target_mode->height);<br>
                return -ENOENT;<br>
@@ -398,6 +412,9 @@ rdp_switch_mode(struct weston_output *output, struct weston_mode *target_mode) {<br>
<br>
        wl_list_for_each(rdpPeer, &rdpOutput->peers, link) {<br>
                settings = rdpPeer->peer->settings;<br>
+               if (settings->DesktopWidth == target_mode->width && settings->DesktopHeight == target_mode->height)<br>
+                       continue;<br>
+<br>
                if(!settings->DesktopResize) {<br>
                        /* too bad this peer does not support desktop resize */<br>
                        rdpPeer->peer->Close(rdpPeer->peer);<br>
@@ -411,49 +428,12 @@ rdp_switch_mode(struct weston_output *output, struct weston_mode *target_mode) {<br>
 }<br>
<br>
 static int<br>
-parse_extra_modes(const char *modes_str, struct rdp_output *output) {<br>
-       const char *startAt = modes_str;<br>
-       const char *nextPos;<br>
-       int w, h;<br>
-       struct weston_mode *mode;<br>
-<br>
-       while(startAt && *startAt) {<br>
-               nextPos = strchr(startAt, 'x');<br>
-               if(!nextPos)<br>
-                       return -1;<br>
-<br>
-               w = strtoul(startAt, NULL, 0);<br>
-               startAt = nextPos + 1;<br>
-               if(!*startAt)<br>
-                       return -1;<br>
-<br>
-               h = strtoul(startAt, NULL, 0);<br>
-<br>
-               if(!w || (w > 3000) || !h || (h > 3000))<br>
-                       return -1;<br>
-               mode = malloc(sizeof *mode);<br>
-               if(!mode)<br>
-                       return -1;<br>
-<br>
-               mode->width = w;<br>
-               mode->height = h;<br>
-               mode->refresh = 5;<br>
-               mode->flags = 0;<br>
-               wl_list_insert(&output->base.mode_list, &mode->link);<br>
-<br>
-               startAt = strchr(startAt, ',');<br>
-               if(startAt && *startAt == ',')<br>
-                       startAt++;<br>
-       }<br>
-       return 0;<br>
-}<br>
-static int<br>
-rdp_compositor_create_output(struct rdp_compositor *c, int width, int height,<br>
-               const char *extraModes)<br>
+rdp_compositor_create_output(struct rdp_compositor *c, int width, int height)<br>
 {<br>
        struct rdp_output *output;<br>
        struct wl_event_loop *loop;<br>
-       struct weston_mode *currentMode, *next;<br>
+       struct weston_mode *currentMode;<br>
+       struct weston_mode initMode;<br>
<br>
        output = zalloc(sizeof *output);<br>
        if (output == NULL)<br>
@@ -462,19 +442,14 @@ rdp_compositor_create_output(struct rdp_compositor *c, int width, int height,<br>
        wl_list_init(&output->peers);<br>
        wl_list_init(&output->base.mode_list);<br>
<br>
-       currentMode = malloc(sizeof *currentMode);<br>
+       initMode.flags = WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;<br>
+       initMode.width = width;<br>
+       initMode.height = height;<br>
+       initMode.refresh = RDP_MODE_FREQ;<br>
+<br>
+       currentMode = ensure_matching_mode(&output->base, &initMode);<br>
        if(!currentMode)<br>
                goto out_free_output;<br>
-       currentMode->flags = WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;<br>
-       currentMode->width = width;<br>
-       currentMode->height = height;<br>
-       currentMode->refresh = 5;<br>
-       wl_list_insert(&output->base.mode_list, &currentMode->link);<br>
-<br>
-       if(parse_extra_modes(extraModes, output) < 0) {<br>
-               weston_log("invalid extra modes\n");<br>
-               goto out_free_output_and_modes;<br>
-       }<br>
<br>
        output->base.current_mode = output->base.native_mode = currentMode;<br>
        weston_output_init(&output->base, &c->base, 0, 0, width, height,<br>
@@ -513,9 +488,6 @@ out_shadow_surface:<br>
        pixman_image_unref(output->shadow_surface);<br>
 out_output:<br>
        weston_output_destroy(&output->base);<br>
-out_free_output_and_modes:<br>
-       wl_list_for_each_safe(currentMode, next, &output->base.mode_list, link)<br>
-               free(currentMode);<br>
 out_free_output:<br>
        free(output);<br>
        return -1;<br>
@@ -704,7 +676,7 @@ xf_peer_post_connect(freerdp_peer* client)<br>
                struct weston_mode *target_mode;<br>
                new_mode.width = (int)settings->DesktopWidth;<br>
                new_mode.height = (int)settings->DesktopHeight;<br>
-               target_mode = find_matching_mode(&output->base, &new_mode);<br>
+               target_mode = ensure_matching_mode(&output->base, &new_mode);<br>
                if (!target_mode) {<br>
                        weston_log("client mode not found\n");<br>
                        return FALSE;<br>
@@ -1030,7 +1002,7 @@ rdp_compositor_create(struct wl_display *display,<br>
        if (pixman_renderer_init(&c->base) < 0)<br>
                goto err_compositor;<br>
<br>
-       if (rdp_compositor_create_output(c, config->width, config->height, config->extra_modes) < 0)<br>
+       if (rdp_compositor_create_output(c, config->width, config->height) < 0)<br>
                goto err_compositor;<br>
<br>
        if(!config->env_socket) {<br>
@@ -1093,7 +1065,6 @@ backend_init(struct wl_display *display, int *argc, char *argv[],<br>
                { WESTON_OPTION_BOOLEAN, "env-socket", 0, &config.env_socket },<br>
                { WESTON_OPTION_INTEGER, "width", 0, &config.width },<br>
                { WESTON_OPTION_INTEGER, "height", 0, &config.height },<br>
-               { WESTON_OPTION_STRING,  "extra-modes", 0, &config.extra_modes },<br>
                { WESTON_OPTION_STRING,  "address", 0, &config.bind_address },<br>
                { WESTON_OPTION_INTEGER, "port", 0, &config.port },<br>
                { WESTON_OPTION_STRING,  "rdp4-key", 0, &config.rdp_key },<br>
diff --git a/src/compositor.c b/src/compositor.c<br>
index 7c29d51..803cda6 100644<br>
--- a/src/compositor.c<br>
+++ b/src/compositor.c<br>
@@ -3972,7 +3972,6 @@ usage(int error_code)<br>
        "Options for rdp-backend.so:\n\n"<br>
        "  --width=WIDTH\t\tWidth of desktop\n"<br>
        "  --height=HEIGHT\tHeight of desktop\n"<br>
-       "  --extra-modes=MODES\t\n"<br>
        "  --env-socket=SOCKET\tUse that socket as peer connection\n"<br>
        "  --address=ADDR\tThe address to bind\n"<br>
        "  --port=PORT\tThe port to listen on\n"<br>
<span><font color="#888888">--<br>
1.8.1.2<br>
<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org" target="_blank">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</font></span></blockquote></div><br></div></div>