--- x11vnc-0.9.13.orig/x11vnc/solid.c 2011-08-11 00:31:32.000000000 +0200 +++ x11vnc-0.9.13/x11vnc/solid.c 2016-06-17 13:57:49.445335368 +0200 @@ -39,6 +39,8 @@ #include "cleanup.h" #include "xevents.h" +#include + char *guess_desktop(void); void solid_bg(int restore); char *dbus_session(void); @@ -874,6 +876,136 @@ #endif /* NO_X11 */ } +static void solid_xfce_multi_monitor (char *color) { +#if NO_X11 + RAWFB_RET_VOID + if (!color) {} + return; +#else + typedef struct _output output_t; + struct _output { + char *name; + int connection; + char *color_style; // xfce color style of the monitor connected to output + char *image_style; // xfce image style of the monitor connected to output + }; + static output_t *all_outputs; + static int num_outputs; + int o; + + char get_image_show[] = "%s xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor%s/workspace0/image-style"; + char set_image_show[] = "%s xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor%s/workspace0/image-style -s %s"; + char get_color_style[] = "%s xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor%s/workspace0/color-style"; + char set_color_style[] = "%s xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor%s/workspace0/color-style -s %s"; + char *orig_image_show = "0"; + char *orig_color_style = "0"; + char *cmd, *dbus = ""; + + RAWFB_RET_VOID + + dbus = dbus_session(); + rfbLog("guessed dbus: %s\n", dbus); + + if (!all_outputs) { + Window root = RootWindow (dpy, DefaultScreen (dpy)); + XRRScreenResources *res = XRRGetScreenResourcesCurrent (dpy, root); + num_outputs = res->noutput; + all_outputs = calloc (num_outputs, sizeof (output_t)); + if (!all_outputs) { + printf ("Error in func 'get_outputs': out of memory\n"); + return; + } + for (o = 0; o < num_outputs; o++) + { + XRROutputInfo *output_info = XRRGetOutputInfo (dpy, res, res->outputs[o]); + all_outputs[o].name = output_info->name; + all_outputs[o].connection = output_info->connection; + } + } + + for (o = 0; o < num_outputs; o++) + { + output_t *output = &all_outputs[o]; + + if (output->connection != RR_Connected) { + continue; + } + + if (!color) { // Restore xfce4 settings + + if (output->image_style) + orig_image_show = output->image_style; + cmd = (char *) malloc(strlen(set_image_show) - 4 + strlen(orig_image_show) + strlen(output->name) + strlen(dbus) + 1); + sprintf(cmd, set_image_show, dbus, output->name, orig_image_show); + dt_cmd(cmd); + free(cmd); + + if (output->color_style) + orig_color_style = output->color_style; + cmd = (char *) malloc(strlen(set_color_style) - 4 + strlen(orig_color_style) + strlen(output->name) + strlen(dbus) + 1); + sprintf(cmd, set_color_style, dbus, output->name, orig_color_style); + dt_cmd(cmd); + free(cmd); + + } else { // Save xfce4 settings and disable wallpaper + + if (cmd_ok("dt")) { + char *q; + cmd = (char *) malloc(strlen(get_image_show) - 2 + strlen(output->name) + strlen(dbus) + 1); + sprintf(cmd, get_image_show, dbus, output->name); + output->image_style = strdup(cmd_output(cmd)); + if ((q = strrchr(output->image_style, '\n')) != NULL) { + *q = '\0'; + } + fprintf(stderr, "get_image_show returned: '%s'\n\n", output->image_style); + free(cmd); + if (strlen(output->image_style) > 1 || !isdigit((unsigned char) (*output->image_style))) { + fprintf(stderr, "unrecognized image_show, disabling.\n"); + free(output->image_style); + output->image_style = ""; + } + } + + if (cmd_ok("dt")) { + char *q; + cmd = (char *) malloc(strlen(get_color_style) - 2 + strlen(output->name) + strlen(dbus) + 1); + sprintf(cmd, get_color_style, dbus, output->name); + output->color_style = strdup(cmd_output(cmd)); + if ((q = strrchr(output->color_style, '\n')) != NULL) { + *q = '\0'; + } + fprintf(stderr, "get_color_style returned: '%s'\n\n", output->color_style); + free(cmd); + if (strlen(output->color_style) > 1 || !isdigit((unsigned char) (*output->color_style))) { + fprintf(stderr, "unrecognized color_style, disabling.\n"); + free(output->color_style); + output->color_style = ""; + } + } + + if (strstr(color, "'") != NULL) { + rfbLog("invalid color: %s\n", color); + return; + } + + cmd = (char *) malloc(strlen(set_color_style) - 4 + strlen("0") + strlen(output->name) + strlen(dbus) + 1); + sprintf(cmd, set_color_style, dbus, output->name, "0"); + dt_cmd(cmd); + free(cmd); + + cmd = (char *) malloc(strlen(set_image_show) - 4 + strlen("0") + strlen(output->name) + strlen(dbus) + 1); + sprintf(cmd, set_image_show, dbus, output->name, "0"); + dt_cmd(cmd); + free(cmd); + } + } + + if (!color) { + free(all_outputs); + all_outputs = NULL; + } +#endif /* NO_X11 */ +} static char *dcop_session(void) { char *empty = strdup(""); @@ -1360,7 +1492,8 @@ } else if (desktop == 3) { solid_cde(NULL); } else if (desktop == 4) { - solid_xfce(NULL); + //solid_xfce(NULL); + solid_xfce_multi_monitor(NULL); } solid_on = 0; return; @@ -1414,7 +1547,8 @@ solid_cde(color); } else if (!strcmp(dtname, "xfce")) { desktop = 4; - solid_xfce(color); + //solid_xfce(color); + solid_xfce_multi_monitor(color); } else { desktop = 0; solid_root(color);