[compiz] Suggested patch for scale of current output
Mike Cook
mcook at novell.com
Wed Dec 6 13:21:37 PST 2006
Here's a patch to add the option of initiating scale on windows
only on the current output. With two or three monitors I often
want to scale only the few windows in a specific output, instead
of the current default of all the windows on all outputs.
Also, after experimenting I tried limiting the hiding of non-scaled
windows to only the current output (used in group and now
output scale mode) and I think it looks better. With multiple
outputs to have all the windows on the other outputs disappear
was distracting, but it's helpful on the current output in the case
of group mode. Any thoughts?
Cheers!
...MC
-------------- next part --------------
--- plugins/scale.c
+++ plugins/scale.c
@@ -111,10 +111,11 @@ typedef struct _ScaleSlot {
float scale;
} ScaleSlot;
-#define SCALE_DISPLAY_OPTION_INITIATE 0
-#define SCALE_DISPLAY_OPTION_INITIATE_ALL 1
-#define SCALE_DISPLAY_OPTION_INITIATE_GROUP 2
-#define SCALE_DISPLAY_OPTION_NUM 3
+#define SCALE_DISPLAY_OPTION_INITIATE 0
+#define SCALE_DISPLAY_OPTION_INITIATE_ALL 1
+#define SCALE_DISPLAY_OPTION_INITIATE_GROUP 2
+#define SCALE_DISPLAY_OPTION_INITIATE_OUTPUT 3
+#define SCALE_DISPLAY_OPTION_NUM 4
typedef struct _ScaleDisplay {
int screenPrivateIndex;
@@ -140,6 +141,7 @@ typedef struct _ScaleDisplay {
typedef enum {
ScaleTypeNormal = 0,
+ ScaleTypeOutput,
ScaleTypeGroup,
ScaleTypeAll
} ScaleType;
@@ -466,6 +468,12 @@ isScaleWin (CompWindow *w)
return FALSE;
}
+ if (ss->type == ScaleTypeOutput)
+ {
+ if (outputDeviceForWindow(w) != w->screen->currentOutputDev)
+ return FALSE;
+ }
+
return TRUE;
}
@@ -509,9 +517,12 @@ scalePaintWindow (CompWindow *w,
sAttrib.brightness = sAttrib.brightness / 2;
}
- /* hide windows that are currently not in scale mode */
- if (!isNeverScaleWin (w))
+ /* hide windows on this output that are not in scale mode */
+ if (!isNeverScaleWin (w) &&
+ outputDeviceForWindow(w) == s->currentOutputDev)
+ {
sAttrib.opacity = 0;
+ }
}
UNWRAP (ss, s, paintWindow);
@@ -1391,6 +1402,33 @@ scaleInitiateGroup (CompDisplay *d,
}
static Bool
+scaleInitiateOutput (CompDisplay *d,
+ CompAction *action,
+ CompActionState state,
+ CompOption *option,
+ int nOption)
+{
+ CompScreen *s;
+ Window xid;
+
+ xid = getIntOptionNamed (option, nOption, "root", 0);
+
+ s = findScreenAtDisplay (d, xid);
+ if (s)
+ {
+ SCALE_SCREEN (s);
+
+ if (ss->state != SCALE_STATE_WAIT && ss->state != SCALE_STATE_OUT)
+ {
+ ss->type = ScaleTypeOutput;
+ return scaleInitiateCommon (s, action, state, option, nOption);
+ }
+ }
+
+ return FALSE;
+}
+
+static Bool
scaleSelectWindowAt (CompScreen *s,
int x,
int y)
@@ -1787,6 +1825,7 @@ scaleSetDisplayOption (CompDisplay *
case SCALE_DISPLAY_OPTION_INITIATE:
case SCALE_DISPLAY_OPTION_INITIATE_ALL:
case SCALE_DISPLAY_OPTION_INITIATE_GROUP:
+ case SCALE_DISPLAY_OPTION_INITIATE_OUTPUT:
if (setDisplayAction (display, o, value))
return TRUE;
default:
@@ -1851,6 +1890,23 @@ scaleDisplayInitOptions (ScaleDisplay *s
o->value.action.type = 0;
o->value.action.state |= CompActionStateInitKey;
o->value.action.state |= CompActionStateInitButton;
+
+ o = &sd->opt[SCALE_DISPLAY_OPTION_INITIATE_OUTPUT];
+ o->name = "initiate_output";
+ o->shortDesc = N_("Initiate Window Picker For Windows on "
+ "Current Output");
+ o->longDesc = N_("Layout and start transforming "
+ "windows on current output");
+ o->type = CompOptionTypeAction;
+ o->value.action.initiate = scaleInitiateOutput;
+ o->value.action.terminate = scaleTerminate;
+ o->value.action.bell = FALSE;
+ o->value.action.edgeMask = 0;
+ o->value.action.state = CompActionStateInitEdge;
+ o->value.action.state |= CompActionStateInitEdgeDnd;
+ o->value.action.type = 0;
+ o->value.action.state |= CompActionStateInitKey;
+ o->value.action.state |= CompActionStateInitButton;
}
static Bool
@@ -1950,6 +2006,8 @@ scaleInitScreen (CompPlugin *p,
&sd->opt[SCALE_DISPLAY_OPTION_INITIATE_ALL].value.action);
addScreenAction (s,
&sd->opt[SCALE_DISPLAY_OPTION_INITIATE_GROUP].value.action);
+ addScreenAction (s,
+ &sd->opt[SCALE_DISPLAY_OPTION_INITIATE_OUTPUT].value.action);
WRAP (ss, s, preparePaintScreen, scalePreparePaintScreen);
WRAP (ss, s, donePaintScreen, scaleDonePaintScreen);
More information about the compiz
mailing list