summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2007-08-24 09:49:46 +0200
committerDanny Baumann <dannybaumann@web.de>2007-08-24 09:49:46 +0200
commit58801a1c23da471749c7d7f880f39b6488bd0117 (patch)
treef34e96e8b1d140f6df54f8cd0169d922e176bf4a
parentff04c3f9757e84bdafe44224ffa8c465fdd1bc75 (diff)
downloadwinrules-58801a1c23da471749c7d7f880f39b6488bd0117.tar.gz
winrules-58801a1c23da471749c7d7f880f39b6488bd0117.tar.bz2
Use one-shot timer instead of MapNotify for applying rules.
-rw-r--r--winrules.c137
1 files changed, 64 insertions, 73 deletions
diff --git a/winrules.c b/winrules.c
index 4d99aaa..8156a87 100644
--- a/winrules.c
+++ b/winrules.c
@@ -56,8 +56,6 @@ typedef struct _WinrulesWindow {
unsigned int allowedActions;
unsigned int stateSetMask;
unsigned int protocolSetMask;
-
- Bool firstMap;
} WinrulesWindow;
typedef struct _WinrulesDisplay {
@@ -438,76 +436,11 @@ winrulesHandleEvent (CompDisplay *d,
WINRULES_DISPLAY (d);
- if (event->type == MapNotify)
+ if (event->type == MapRequest)
{
w = findWindowAtDisplay (d, event->xmap.window);
if (w && w->type & WINRULES_TARGET_WINDOWS)
- {
- WINRULES_WINDOW (w);
- /* Only apply at window creation.
- * Using CreateNotify not working.
- */
- if (ww->firstMap)
- {
- int width, height;
-
- winrulesUpdateState (w,
- WINRULES_SCREEN_OPTION_SKIPTASKBAR_MATCH,
- CompWindowStateSkipTaskbarMask);
-
- winrulesUpdateState (w,
- WINRULES_SCREEN_OPTION_SKIPPAGER_MATCH,
- CompWindowStateSkipPagerMask);
-
- winrulesUpdateState (w,
- WINRULES_SCREEN_OPTION_ABOVE_MATCH,
- CompWindowStateAboveMask);
-
- winrulesUpdateState (w,
- WINRULES_SCREEN_OPTION_BELOW_MATCH,
- CompWindowStateBelowMask);
-
- winrulesUpdateState (w,
- WINRULES_SCREEN_OPTION_STICKY_MATCH,
- CompWindowStateStickyMask);
-
- winrulesUpdateState (w,
- WINRULES_SCREEN_OPTION_FULLSCREEN_MATCH,
- CompWindowStateFullscreenMask);
-
- winrulesSetAllowedActions (w,
- WINRULES_SCREEN_OPTION_NOMOVE_MATCH,
- CompWindowActionMoveMask);
-
- winrulesSetAllowedActions (w,
- WINRULES_SCREEN_OPTION_NORESIZE_MATCH,
- CompWindowActionResizeMask);
-
- winrulesSetAllowedActions (w,
- WINRULES_SCREEN_OPTION_NOMINIMIZE_MATCH,
- CompWindowActionMinimizeMask);
-
- winrulesSetAllowedActions (w,
- WINRULES_SCREEN_OPTION_NOMAXIMIZE_MATCH,
- CompWindowActionMaximizeVertMask|
- CompWindowActionMaximizeHorzMask);
-
- winrulesSetAllowedActions (w,
- WINRULES_SCREEN_OPTION_NOCLOSE_MATCH,
- CompWindowActionCloseMask);
-
- if (winrulesMatchSize (w, &width, &height))
- winrulesUpdateWindowSize (w, width, height);
- }
-
- ww->firstMap = FALSE;
- }
- }
- else if (event->type == MapRequest)
- {
- w = findWindowAtDisplay (d, event->xmap.window);
- if (w && w->type & WINRULES_TARGET_WINDOWS)
- winrulesSetNoFocus (w,WINRULES_SCREEN_OPTION_NOFOCUS_MATCH);
+ winrulesSetNoFocus (w, WINRULES_SCREEN_OPTION_NOFOCUS_MATCH);
}
UNWRAP (wd, d, handleEvent);
@@ -533,6 +466,66 @@ winrulesGetAllowedActionsForWindow (CompWindow *w)
}
static Bool
+winrulesApplyRules (void *closure)
+{
+ CompWindow *w = (CompWindow *) closure;
+ int width, height;
+
+ if (!(w->type & WINRULES_TARGET_WINDOWS))
+ return FALSE;
+
+ winrulesUpdateState (w,
+ WINRULES_SCREEN_OPTION_SKIPTASKBAR_MATCH,
+ CompWindowStateSkipTaskbarMask);
+
+ winrulesUpdateState (w,
+ WINRULES_SCREEN_OPTION_SKIPPAGER_MATCH,
+ CompWindowStateSkipPagerMask);
+
+ winrulesUpdateState (w,
+ WINRULES_SCREEN_OPTION_ABOVE_MATCH,
+ CompWindowStateAboveMask);
+
+ winrulesUpdateState (w,
+ WINRULES_SCREEN_OPTION_BELOW_MATCH,
+ CompWindowStateBelowMask);
+
+ winrulesUpdateState (w,
+ WINRULES_SCREEN_OPTION_STICKY_MATCH,
+ CompWindowStateStickyMask);
+
+ winrulesUpdateState (w,
+ WINRULES_SCREEN_OPTION_FULLSCREEN_MATCH,
+ CompWindowStateFullscreenMask);
+
+ winrulesSetAllowedActions (w,
+ WINRULES_SCREEN_OPTION_NOMOVE_MATCH,
+ CompWindowActionMoveMask);
+
+ winrulesSetAllowedActions (w,
+ WINRULES_SCREEN_OPTION_NORESIZE_MATCH,
+ CompWindowActionResizeMask);
+
+ winrulesSetAllowedActions (w,
+ WINRULES_SCREEN_OPTION_NOMINIMIZE_MATCH,
+ CompWindowActionMinimizeMask);
+
+ winrulesSetAllowedActions (w,
+ WINRULES_SCREEN_OPTION_NOMAXIMIZE_MATCH,
+ CompWindowActionMaximizeVertMask |
+ CompWindowActionMaximizeHorzMask);
+
+ winrulesSetAllowedActions (w,
+ WINRULES_SCREEN_OPTION_NOCLOSE_MATCH,
+ CompWindowActionCloseMask);
+
+ if (winrulesMatchSize (w, &width, &height))
+ winrulesUpdateWindowSize (w, width, height);
+
+ return FALSE;
+}
+
+static Bool
winrulesInitDisplay (CompPlugin *p,
CompDisplay *d)
{
@@ -644,19 +637,17 @@ winrulesInitWindow (CompPlugin *p,
WinrulesWindow *ww = malloc (sizeof (WinrulesWindow));
if (!ww)
- {
return FALSE;
- }
ww->stateSetMask = 0;
ww->protocolSetMask = 0;
ww->allowedActions = ~0;
- ww->firstMap = TRUE;
-
w->privates[ws->windowPrivateIndex].ptr = ww;
+ compAddTimeout (0, winrulesApplyRules, w);
+
return TRUE;
}