summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2008-09-01 09:15:09 +0200
committerDanny Baumann <dannybaumann@web.de>2008-09-01 09:15:09 +0200
commit839122dcdb592adc0aa1040d42c9c3f064272f16 (patch)
treea9e1e4963eb25a4695cbeae3f68bffb74f6d68c6 /plugins
parent0d71c5e3cfd7fe0ae30f97dc0ba549bed035428d (diff)
parent41353bae026fbd12b222e21151310e80844e2b13 (diff)
Merge branch 'master' of git+ssh://maniac@git.freedesktop.org/git/xorg/app/compiz
Diffstat (limited to 'plugins')
-rw-r--r--plugins/dbus.c150
-rw-r--r--plugins/resize.c26
2 files changed, 116 insertions, 60 deletions
diff --git a/plugins/dbus.c b/plugins/dbus.c
index fd2f4c66..bcc6f280 100644
--- a/plugins/dbus.c
+++ b/plugins/dbus.c
@@ -57,6 +57,7 @@ static CompMetadata dbusMetadata;
#define DBUS_FILE_WATCH_NUM 3
static int corePrivateIndex;
+static int displayPrivateIndex;
typedef struct _DbusCore {
DBusConnection *connection;
@@ -68,6 +69,11 @@ typedef struct _DbusCore {
SetOptionForPluginProc setOptionForPlugin;
} DbusCore;
+typedef struct _DbusDisplay {
+ char **pluginList;
+ unsigned int nPlugins;
+} DbusDisplay;
+
static DBusHandlerResult dbusHandleMessage (DBusConnection *,
DBusMessage *,
void *);
@@ -83,6 +89,37 @@ static DBusObjectPathVTable dbusMessagesVTable = {
#define DBUS_CORE(c) \
DbusCore *dc = GET_DBUS_CORE (c)
+#define GET_DBUS_DISPLAY(d) \
+ ((DbusDisplay *) (d)->base.privates[displayPrivateIndex].ptr)
+
+#define DBUS_DISPLAY(d) \
+ DbusDisplay *dd = GET_DBUS_DISPLAY (d)
+
+static void
+dbusUpdatePluginList (CompDisplay *d)
+{
+ CompListValue *pl;
+ unsigned int i;
+
+ DBUS_DISPLAY (d);
+
+ pl = &d->opt[COMP_DISPLAY_OPTION_ACTIVE_PLUGINS].value.list;
+
+ for (i = 0; i < dd->nPlugins; i++)
+ free (dd->pluginList[i]);
+
+ dd->pluginList = realloc (dd->pluginList, pl->nValue * sizeof (char *));
+ if (!dd->pluginList)
+ {
+ dd->nPlugins = 0;
+ return;
+ }
+
+ for (i = 0; i < pl->nValue; i++)
+ dd->pluginList[i] = strdup (pl->value[i].s);
+
+ dd->nPlugins = pl->nValue;
+}
static CompOption *
dbusGetOptionsFromPath (char **path,
@@ -2043,19 +2080,17 @@ static void
dbusRegisterPluginsForDisplay (DBusConnection *connection,
CompDisplay *d)
{
- CompListValue *pl;
- int nPlugins;
- char path[256];
+ unsigned int i;
+ char path[256];
- pl = &d->opt[COMP_DISPLAY_OPTION_ACTIVE_PLUGINS].value.list;
+ DBUS_DISPLAY (d);
- nPlugins = pl->nValue;
-
- while (nPlugins--)
+ for (i = 0; i < dd->nPlugins; i++)
{
- snprintf (path, 256, "%s/%s/allscreens", COMPIZ_DBUS_ROOT_PATH,
- pl->value[nPlugins].s);
- dbusRegisterPluginForDisplay (connection, d, pl->value[nPlugins].s);
+ snprintf (path, 256, "%s/%s/allscreens",
+ COMPIZ_DBUS_ROOT_PATH, dd->pluginList[i]);
+
+ dbusRegisterPluginForDisplay (connection, d, dd->pluginList[i]);
dbusRegisterOptions (connection, path);
}
}
@@ -2064,20 +2099,16 @@ static void
dbusRegisterPluginsForScreen (DBusConnection *connection,
CompScreen *s)
{
- CompListValue *pl;
- int nPlugins;
- char path[256];
+ unsigned int i;
+ char path[256];
- pl = &s->display->opt[COMP_DISPLAY_OPTION_ACTIVE_PLUGINS].value.list;
+ DBUS_DISPLAY (s->display);
- nPlugins = pl->nValue;
-
- while (nPlugins--)
+ for (i = 0; i < dd->nPlugins; i++)
{
- snprintf (path, 256, "%s/%s/screen%d", COMPIZ_DBUS_ROOT_PATH,
- pl->value[nPlugins].s,
- s->screenNum);
- dbusRegisterPluginForScreen (connection, s, pl->value[nPlugins].s);
+ snprintf (path, 256, "%s/%s/screen%d",
+ COMPIZ_DBUS_ROOT_PATH, dd->pluginList[i], s->screenNum);
+ dbusRegisterPluginForScreen (connection, s, dd->pluginList[i]);
dbusRegisterOptions (connection, path);
}
}
@@ -2103,15 +2134,12 @@ static void
dbusUnregisterPluginsForDisplay (DBusConnection *connection,
CompDisplay *d)
{
- CompListValue *pl;
- int nPlugins;
-
- pl = &d->opt[COMP_DISPLAY_OPTION_ACTIVE_PLUGINS].value.list;
+ unsigned int i;
- nPlugins = pl->nValue;
+ DBUS_DISPLAY (d);
- while (nPlugins--)
- dbusUnregisterPluginForDisplay (connection, d, pl->value[nPlugins].s);
+ for (i = 0; i < dd->nPlugins; i++)
+ dbusUnregisterPluginForDisplay (connection, d, dd->pluginList[i]);
}
static void
@@ -2132,15 +2160,12 @@ static void
dbusUnregisterPluginsForScreen (DBusConnection *connection,
CompScreen *s)
{
- CompListValue *pl;
- int nPlugins;
-
- pl = &s->display->opt[COMP_DISPLAY_OPTION_ACTIVE_PLUGINS].value.list;
+ unsigned int i;
- nPlugins = pl->nValue;
+ DBUS_DISPLAY (s->display);
- while (nPlugins--)
- dbusUnregisterPluginForScreen (connection, s, pl->value[nPlugins].s);
+ for (i = 0; i < dd->nPlugins; i++)
+ dbusUnregisterPluginForScreen (connection, s, dd->pluginList[i]);
}
static CompBool
@@ -2239,13 +2264,14 @@ dbusSetOptionForPlugin (CompObject *object,
CORE_DISPLAY (object);
dbusUnregisterPluginsForDisplay (dc->connection, d);
- dbusRegisterPluginsForDisplay (dc->connection, d);
-
for (s = d->screens; s; s = s->next)
- {
dbusUnregisterPluginsForScreen (dc->connection, s);
+
+ dbusUpdatePluginList (d);
+
+ dbusRegisterPluginsForDisplay (dc->connection, d);
+ for (s = d->screens; s; s = s->next)
dbusRegisterPluginsForScreen (dc->connection, s);
- }
}
}
}
@@ -2288,6 +2314,13 @@ dbusInitCore (CompPlugin *p,
if (!dc)
return FALSE;
+ displayPrivateIndex = allocateDisplayPrivateIndex ();
+ if (displayPrivateIndex < 0)
+ {
+ free (dc);
+ return FALSE;
+ }
+
dbus_error_init (&error);
dc->connection = dbus_bus_get (DBUS_BUS_SESSION, &error);
@@ -2406,6 +2439,8 @@ dbusFiniCore (CompPlugin *p,
for (i = 0; i < DBUS_FILE_WATCH_NUM; i++)
removeFileWatch (dc->fileWatch[i]);
+ freeDisplayPrivateIndex (displayPrivateIndex);
+
compRemoveWatchFd (dc->watchFdHandle);
dbus_bus_release_name (dc->connection, COMPIZ_DBUS_SERVICE_NAME, NULL);
@@ -2427,17 +2462,21 @@ static Bool
dbusInitDisplay (CompPlugin *p,
CompDisplay *d)
{
- char objectPath[256];
+ DbusDisplay *dd;
DBUS_CORE (&core);
- /* register core 'plugin' */
- dbusRegisterPluginForDisplay (dc->connection, d, "core");
- dbusRegisterPluginsForDisplay (dc->connection, d);
+ dd = malloc (sizeof (DbusDisplay));
+ if (!dd)
+ return FALSE;
- snprintf (objectPath, 256, "%s/core/allscreens", COMPIZ_DBUS_ROOT_PATH);
+ dd->pluginList = NULL;
+ dd->nPlugins = 0;
- dbusRegisterOptions (dc->connection, objectPath);
+ d->base.privates[displayPrivateIndex].ptr = dd;
+
+ dbusUpdatePluginList (d);
+ dbusRegisterPluginsForDisplay (dc->connection, d);
return TRUE;
}
@@ -2447,25 +2486,29 @@ dbusFiniDisplay (CompPlugin *p,
CompDisplay *d)
{
DBUS_CORE (&core);
+ DBUS_DISPLAY (d);
- dbusUnregisterPluginForDisplay (dc->connection, d, "core");
dbusUnregisterPluginsForDisplay (dc->connection, d);
+
+ if (dd->pluginList)
+ {
+ unsigned int i;
+
+ for (i = 0; i < dd->nPlugins; i++)
+ free (dd->pluginList[i]);
+ free (dd->pluginList);
+ }
+
+ free (dd);
}
static Bool
dbusInitScreen (CompPlugin *p,
CompScreen *s)
{
- char objectPath[256];
-
DBUS_CORE (&core);
- snprintf (objectPath, 256, "%s/%s/screen%d", COMPIZ_DBUS_ROOT_PATH,
- "core", s->screenNum);
-
- dbusRegisterPluginForScreen (dc->connection, s, "core");
dbusRegisterPluginsForScreen (dc->connection, s);
- dbusRegisterOptions (dc->connection, objectPath);
return TRUE;
}
@@ -2476,7 +2519,6 @@ dbusFiniScreen (CompPlugin *p,
{
DBUS_CORE (&core);
- dbusUnregisterPluginForScreen (dc->connection, s, "core");
dbusUnregisterPluginsForScreen (dc->connection, s);
}
diff --git a/plugins/resize.c b/plugins/resize.c
index 6cb263b4..5b8b12b3 100644
--- a/plugins/resize.c
+++ b/plugins/resize.c
@@ -339,7 +339,7 @@ resizeInitiate (CompDisplay *d,
mask = getIntOptionNamed (option, nOption, "direction", 0);
/* Initiate the resize in the direction suggested by the
- * quarter of the window the mouse is in, eg drag in top left
+ * sector of the window the mouse is in, eg drag in top left
* will resize up and to the left. Keyboard resize starts out
* with the cursor in the middle of the window and then starts
* resizing the edge corresponding to the next key press. */
@@ -349,11 +349,25 @@ resizeInitiate (CompDisplay *d,
}
else if (!mask)
{
- mask |= ((x - w->serverX) < (w->serverWidth / 2)) ?
- ResizeLeftMask : ResizeRightMask;
-
- mask |= ((y - w->serverY) < (w->serverHeight / 2)) ?
- ResizeUpMask : ResizeDownMask;
+ unsigned int sectorSizeX = w->serverWidth / 3;
+ unsigned int sectorSizeY = w->serverHeight / 3;
+ unsigned int posX = x - w->serverX;
+ unsigned int posY = y - w->serverY;
+
+ if (posX < sectorSizeX)
+ mask |= ResizeLeftMask;
+ else if (posX > (2 * sectorSizeX))
+ mask |= ResizeRightMask;
+
+ if (posY < sectorSizeY)
+ mask |= ResizeUpMask;
+ else if (posY > (2 * sectorSizeY))
+ mask |= ResizeDownMask;
+
+ /* if the pointer was in the middle of the window,
+ do nothing */
+ if (!mask)
+ return FALSE;
}
if (otherScreenGrabExist (w->screen, "resize", 0))