summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2007-04-06 14:26:26 +0200
committerDanny Baumann <dannybaumann@web.de>2007-04-06 14:26:26 +0200
commit04bf048e8358a7dab1690caae03975f84bfae540 (patch)
tree28d93605bee6ac65eb2b5ce93be80ab7e8d1c008
parent9582a7b1bdf911f5c804eed6de06b1d1f8fc6089 (diff)
downloadberyl-premerge-04bf048e8358a7dab1690caae03975f84bfae540.tar.gz
beryl-premerge-04bf048e8358a7dab1690caae03975f84bfae540.tar.bz2
added extrawm plugin
-rw-r--r--src/Makefile.am5
-rw-r--r--src/extrawm.c221
-rw-r--r--src/extrawm.options24
3 files changed, 250 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 35eaa60..35fbc66 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -21,6 +21,10 @@ libaddhelper_la_LDFLAGS = $(PFLAGS)
libaddhelper_la_LIBADD = @COMPIZ_LIBS@
libaddhelper_la_SOURCES = addhelper_options.c addhelper.c
+libextrawm_la_LDFLAGS = $(PFLAGS)
+libextrawm_la_LIBADD = @COMPIZ_LIBS@
+libextrawm_la_SOURCES = extrawm_options.c extrawm.c
+
if WALL_PLUGIN
libwall_la_LDFLAGS = $(PFLAGS)
libwall_la_LIBADD = @COMPIZ_LIBS@ @WALL_LIBS@ -lGLU
@@ -105,6 +109,7 @@ module_LTLIBRARIES = \
libshowdesktop.la \
libtrailfocus.la \
libbench.la \
+ libextrawm.la \
libaddhelper.la \
$(libwall_module) \
$(libimgjpeg_module) \
diff --git a/src/extrawm.c b/src/extrawm.c
new file mode 100644
index 0000000..acd0a2e
--- /dev/null
+++ b/src/extrawm.c
@@ -0,0 +1,221 @@
+/*
+ * extrawm.c
+ * Compit extra WM actions plugins
+ * Copyright: (C) 2007 Danny Baumann <maniac@beryl-project.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <compiz.h>
+#include "extrawm_options.h"
+
+
+static Bool
+activateWin (CompDisplay * d,
+ CompAction * action,
+ CompActionState state,
+ CompOption * option,
+ int nOption)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = getIntOptionNamed(option, nOption, "window", 0);
+
+ w = findWindowAtDisplay(d, xid);
+ if (w)
+ sendWindowActivationRequest(w->screen, w->id);
+
+ return TRUE;
+}
+
+static void
+fullscreenWindow (CompWindow * w,
+ int state)
+{
+ unsigned int newState = w->state;
+
+ if (w->attrib.override_redirect)
+ return;
+
+ /* It would be a bug, to put a shaded window to fullscreen. */
+ if (w->shaded)
+ return;
+
+ state = constrainWindowState(state, w->actions);
+ state &= CompWindowStateFullscreenMask;
+
+ if (state == (w->state & CompWindowStateFullscreenMask))
+ return;
+
+ newState &= ~CompWindowStateFullscreenMask;
+ newState |= state;
+
+ recalcWindowType(w);
+ recalcWindowActions(w);
+ changeWindowState(w, newState);
+ updateWindowAttributes(w, FALSE);
+}
+
+static Bool
+toggleFullscreen (CompDisplay * d,
+ CompAction * action,
+ CompActionState state,
+ CompOption * option,
+ int nOption)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = getIntOptionNamed(option, nOption, "window", 0);
+
+ w = findTopLevelWindowAtDisplay(d, xid);
+ if (w)
+ fullscreenWindow(w, w->state ^ CompWindowStateFullscreenMask);
+
+ return TRUE;
+}
+
+static Bool
+toggleRedirect (CompDisplay * d,
+ CompAction * action,
+ CompActionState state,
+ CompOption * option,
+ int nOption)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = getIntOptionNamed(option, nOption, "window", 0);
+
+ w = findTopLevelWindowAtDisplay(d, xid);
+ if (w)
+ {
+ if (w->redirected)
+ unredirectWindow(w);
+ else
+ redirectWindow(w);
+ }
+
+ return TRUE;
+}
+
+static Bool
+toggleAlwaysOnTop (CompDisplay * d,
+ CompAction * action,
+ CompActionState state,
+ CompOption * option,
+ int nOption)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = getIntOptionNamed(option, nOption, "window", 0);
+
+ w = findTopLevelWindowAtDisplay(d, xid);
+ if (w)
+ {
+ unsigned int newState;
+ newState = w->state ^ CompWindowStateAboveMask;
+ changeWindowState (w, newState);
+ }
+
+ return TRUE;
+}
+
+static Bool
+toggleSticky (CompDisplay * d,
+ CompAction * action,
+ CompActionState state,
+ CompOption * option,
+ int nOption)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = getIntOptionNamed(option, nOption, "window", 0);
+
+ w = findTopLevelWindowAtDisplay(d, xid);
+ if (w)
+ {
+ unsigned int newState;
+ newState = w->state ^ CompWindowStateStickyMask;
+ changeWindowState(w, newState);
+ }
+
+ return TRUE;
+}
+
+static Bool
+extraWMInit(CompPlugin * p)
+{
+ return TRUE;
+}
+
+static void
+extraWMFini(CompPlugin * p)
+{
+}
+
+static Bool
+extraWMInitDisplay (CompPlugin *p,
+ CompDisplay *d)
+{
+ extrawmSetToggleRedirectInitiate (d, toggleRedirect);
+ extrawmSetToggleAlwaysOnTopInitiate (d, toggleAlwaysOnTop);
+ extrawmSetToggleStickyInitiate (d, toggleSticky);
+ extrawmSetToggleFullscreenInitiate (d, toggleFullscreen);
+ extrawmSetActivateInitiate (d, activateWin);
+
+ return TRUE;
+}
+
+static int extraWMGetVersion (CompPlugin * p,
+ int version)
+{
+ return ABIVERSION;
+}
+
+CompPluginVTable extraWMVTable = {
+ "extrawm",
+ N_("Extra WM Actions"),
+ N_("Provides less commonly used WM actions"),
+ extraWMGetVersion,
+ extraWMInit,
+ extraWMFini,
+ extraWMInitDisplay,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0
+};
+
+CompPluginVTable *getCompPluginInfo(void)
+{
+ return &extraWMVTable;
+}
diff --git a/src/extrawm.options b/src/extrawm.options
new file mode 100644
index 0000000..a3e7c77
--- /dev/null
+++ b/src/extrawm.options
@@ -0,0 +1,24 @@
+<plugin name="extrawm">
+ <display>
+ <option name="activate" type="action">
+ <short>Activate Window</short>
+ <long>Activate a given window</long>
+ </option>
+ <option name="toggle_redirect" type="action">
+ <short>Toggle Redirect</short>
+ <long>Toggle window redirect</long>
+ </option>
+ <option name="toggle_fullscreen" type="action">
+ <short>Toggle Fullscreen</short>
+ <long>Toggle window fullscreen</long>
+ </option>
+ <option name="toggle_always_on_top" type="action">
+ <short>Toggle Always-On-Top</short>
+ <long>Toggle always on top for the active window</long>
+ </option>
+ <option name="toggle_sticky" type="action">
+ <short>Toggle Sticky</short>
+ <long>Toggle window stickyness</long>
+ </option>
+ </display>
+</plugin>