From 99045bfaf2dab101c30e26a189e0e56d8f2d76c2 Mon Sep 17 00:00:00 2001 From: David Reveman Date: Mon, 26 Jan 2009 18:41:32 -0500 Subject: Add dbus method attachScreenAt. --- hw/dmx/dmxdbus.c | 119 +++++++++++++++++++++++++++++++++++++++----------- hw/dmx/dmxextension.c | 3 ++ hw/dmx/dmxrandr.c | 9 +++- hw/dmx/dmxwindow.c | 2 + 4 files changed, 106 insertions(+), 27 deletions(-) diff --git a/hw/dmx/dmxdbus.c b/hw/dmx/dmxdbus.c index 0ea462824..130f6a048 100644 --- a/hw/dmx/dmxdbus.c +++ b/hw/dmx/dmxdbus.c @@ -137,34 +137,22 @@ disable_screen (DBusMessage *message, } static int -attach_screen (DBusMessage *message, +attach_screen (uint32_t window, + uint32_t screen, + uint32_t auth_type_len, + uint32_t auth_data_len, + const char *display, + const char *auth_type, + const char *auth_data, + const char *name, + int32_t x, + int32_t y, DBusMessage *reply, DBusError *error) { DMXScreenAttributesRec attr; - uint32_t window, screen, auth_type_len, auth_data_len; - char *display, *auth_type, *auth_data, *name; int ret; - if (!dbus_message_get_args (message, error, - DBUS_TYPE_UINT32, - &screen, - DBUS_TYPE_STRING, - &display, - DBUS_TYPE_STRING, - &name, - DBUS_TYPE_UINT32, - &window, - DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, - &auth_type, &auth_type_len, - DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, - &auth_data, &auth_data_len, - DBUS_TYPE_INVALID)) - { - DebugF (MALFORMED_MSG ": %s, %s", error->name, error->message); - return BadValue; - } - if (!*name) { dbus_set_error (error, @@ -194,8 +182,10 @@ attach_screen (DBusMessage *message, memset (&attr, 0, sizeof (attr)); - attr.name = name; - attr.displayName = display; + attr.name = name; + attr.displayName = display; + attr.rootWindowXoffset = x; + attr.rootWindowYoffset = y; ret = dmxAttachScreen (screen, &attr, @@ -217,6 +207,83 @@ attach_screen (DBusMessage *message, return Success; } +static int +attach_screen_without_offset (DBusMessage *message, + DBusMessage *reply, + DBusError *error) +{ + uint32_t window, screen, auth_type_len, auth_data_len; + char *display, *auth_type, *auth_data, *name; + + if (!dbus_message_get_args (message, error, + DBUS_TYPE_UINT32, + &screen, + DBUS_TYPE_STRING, + &display, + DBUS_TYPE_STRING, + &name, + DBUS_TYPE_UINT32, + &window, + DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, + &auth_type, &auth_type_len, + DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, + &auth_data, &auth_data_len, + DBUS_TYPE_INVALID)) + { + DebugF (MALFORMED_MSG ": %s, %s", error->name, error->message); + return BadValue; + } + + return attach_screen (window, screen, + auth_type_len, auth_data_len, + display, + auth_type, auth_data, + name, + 0, 0, + reply, error); +} + +static int +attach_screen_with_offset (DBusMessage *message, + DBusMessage *reply, + DBusError *error) +{ + uint32_t window, screen, auth_type_len, auth_data_len; + int32_t x, y; + char *display, *auth_type, *auth_data, *name; + + if (!dbus_message_get_args (message, error, + DBUS_TYPE_UINT32, + &screen, + DBUS_TYPE_STRING, + &display, + DBUS_TYPE_STRING, + &name, + DBUS_TYPE_UINT32, + &window, + DBUS_TYPE_INT32, + &x, + DBUS_TYPE_INT32, + &y, + DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, + &auth_type, &auth_type_len, + DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, + &auth_data, &auth_data_len, + DBUS_TYPE_INVALID)) + { + DebugF (MALFORMED_MSG ": %s, %s", error->name, error->message); + return BadValue; + } + + return attach_screen (window, screen, + auth_type_len, auth_data_len, + display, + auth_type, auth_data, + name, + x, y, + reply, error); +} + static int detach_screen (DBusMessage *message, DBusMessage *reply, @@ -425,7 +492,9 @@ message_handler (DBusConnection *connection, else if (strcmp (dbus_message_get_member (message), "disableScreen") == 0) err = disable_screen (message, reply, &error); else if (strcmp (dbus_message_get_member (message), "attachScreen") == 0) - err = attach_screen (message, reply, &error); + err = attach_screen_without_offset (message, reply, &error); + else if (strcmp (dbus_message_get_member (message), "attachScreenAt") == 0) + err = attach_screen_with_offset (message, reply, &error); else if (strcmp (dbus_message_get_member (message), "detachScreen") == 0) err = detach_screen (message, reply, &error); else if (strcmp (dbus_message_get_member (message), "addInput") == 0) diff --git a/hw/dmx/dmxextension.c b/hw/dmx/dmxextension.c index 7bbdb9dd7..1aac09a23 100644 --- a/hw/dmx/dmxextension.c +++ b/hw/dmx/dmxextension.c @@ -1622,6 +1622,9 @@ dmxAttachScreen (int idx, dmxScreen->beAttachedDisplay = dmxScreen->beDisplay; dmxScreen->beDisplay = NULL; + dmxScreen->rootX = attr->rootWindowXoffset; + dmxScreen->rootY = attr->rootWindowYoffset; + return 0; /* Success */ } diff --git a/hw/dmx/dmxrandr.c b/hw/dmx/dmxrandr.c index 18ba73396..a4318aa21 100644 --- a/hw/dmx/dmxrandr.c +++ b/hw/dmx/dmxrandr.c @@ -710,7 +710,9 @@ dmxRRScreenSetSize (ScreenPtr pScreen, int i; for (i = 0; i < dmxNumScreens; i++) - dmxResizeRootWindow (WindowTable[i], 0, 0, width, height); + dmxResizeRootWindow (WindowTable[i], + dmxScreens[i].rootX, dmxScreens[i].rootY, + width, height); for (i = 0; i < dmxNumScreens; i++) dmxUpdateScreenResources (screenInfo.screens[i], @@ -723,7 +725,10 @@ dmxRRScreenSetSize (ScreenPtr pScreen, else #endif { - dmxResizeRootWindow (WindowTable[pScreen->myNum], 0, 0, width, height); + dmxResizeRootWindow (WindowTable[pScreen->myNum], + dmxScreens[pScreen->myNum].rootX, + dmxScreens[pScreen->myNum].rootY, + width, height); dmxUpdateScreenResources (pScreen, 0, 0, width, height); } diff --git a/hw/dmx/dmxwindow.c b/hw/dmx/dmxwindow.c index 3a0ab1601..7a8a8d415 100644 --- a/hw/dmx/dmxwindow.c +++ b/hw/dmx/dmxwindow.c @@ -141,7 +141,9 @@ Window dmxCreateRootWindow(WindowPtr pWindow) XLIB_PROLOGUE (dmxScreen); win = XCreateWindow(dmxScreen->beDisplay, parent, + dmxScreen->rootX + pWindow->origin.x - wBorderWidth(pWindow), + dmxScreen->rootY + pWindow->origin.y - wBorderWidth(pWindow), w, h, -- cgit v1.2.3