layout: Restructure input region and struts code
Have two branches, one for input region and one for struts. This makes it easier to skip one of the branches, like in the case where we want to skip input regions if we have a popup menu visible. https://bugzilla.gnome.org/show_bug.cgi?id=633620
This commit is contained in:
parent
978ac65cae
commit
a4e70ba4ca
141
js/ui/layout.js
141
js/ui/layout.js
@ -830,86 +830,87 @@ const LayoutManager = new Lang.Class({
|
|||||||
y = Math.round(y);
|
y = Math.round(y);
|
||||||
w = Math.round(w);
|
w = Math.round(w);
|
||||||
h = Math.round(h);
|
h = Math.round(h);
|
||||||
let rect = new Meta.Rectangle({ x: x, y: y, width: w, height: h});
|
|
||||||
|
|
||||||
if (actorData.affectsInputRegion &&
|
if (actorData.affectsInputRegion) {
|
||||||
actorData.actor.get_paint_visibility() &&
|
let rect = new Meta.Rectangle({ x: x, y: y, width: w, height: h});
|
||||||
!this.uiGroup.get_skip_paint(actorData.actor))
|
|
||||||
rects.push(rect);
|
|
||||||
|
|
||||||
if (!actorData.affectsStruts)
|
if (actorData.actor.get_paint_visibility() &&
|
||||||
continue;
|
!this.uiGroup.get_skip_paint(actorData.actor))
|
||||||
|
rects.push(rect);
|
||||||
|
}
|
||||||
|
|
||||||
// Limit struts to the size of the screen
|
if (actorData.affectsStruts) {
|
||||||
let x1 = Math.max(x, 0);
|
// Limit struts to the size of the screen
|
||||||
let x2 = Math.min(x + w, global.screen_width);
|
let x1 = Math.max(x, 0);
|
||||||
let y1 = Math.max(y, 0);
|
let x2 = Math.min(x + w, global.screen_width);
|
||||||
let y2 = Math.min(y + h, global.screen_height);
|
let y1 = Math.max(y, 0);
|
||||||
|
let y2 = Math.min(y + h, global.screen_height);
|
||||||
|
|
||||||
// NetWM struts are not really powerful enought to handle
|
// NetWM struts are not really powerful enought to handle
|
||||||
// a multi-monitor scenario, they only describe what happens
|
// a multi-monitor scenario, they only describe what happens
|
||||||
// around the outer sides of the full display region. However
|
// around the outer sides of the full display region. However
|
||||||
// it can describe a partial region along each side, so
|
// it can describe a partial region along each side, so
|
||||||
// we can support having the struts only affect the
|
// we can support having the struts only affect the
|
||||||
// primary monitor. This should be enough as we only have
|
// primary monitor. This should be enough as we only have
|
||||||
// chrome affecting the struts on the primary monitor so
|
// chrome affecting the struts on the primary monitor so
|
||||||
// far.
|
// far.
|
||||||
//
|
//
|
||||||
// Metacity wants to know what side of the screen the
|
// Metacity wants to know what side of the screen the
|
||||||
// strut is considered to be attached to. If the actor is
|
// strut is considered to be attached to. If the actor is
|
||||||
// only touching one edge, or is touching the entire
|
// only touching one edge, or is touching the entire
|
||||||
// border of the primary monitor, then it's obvious which
|
// border of the primary monitor, then it's obvious which
|
||||||
// side to call it. If it's in a corner, we pick a side
|
// side to call it. If it's in a corner, we pick a side
|
||||||
// arbitrarily. If it doesn't touch any edges, or it spans
|
// arbitrarily. If it doesn't touch any edges, or it spans
|
||||||
// the width/height across the middle of the screen, then
|
// the width/height across the middle of the screen, then
|
||||||
// we don't create a strut for it at all.
|
// we don't create a strut for it at all.
|
||||||
let side;
|
let side;
|
||||||
let primary = this.primaryMonitor;
|
let primary = this.primaryMonitor;
|
||||||
if (x1 <= primary.x && x2 >= primary.x + primary.width) {
|
if (x1 <= primary.x && x2 >= primary.x + primary.width) {
|
||||||
if (y1 <= primary.y)
|
if (y1 <= primary.y)
|
||||||
|
side = Meta.Side.TOP;
|
||||||
|
else if (y2 >= primary.y + primary.height)
|
||||||
|
side = Meta.Side.BOTTOM;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
} else if (y1 <= primary.y && y2 >= primary.y + primary.height) {
|
||||||
|
if (x1 <= 0)
|
||||||
|
side = Meta.Side.LEFT;
|
||||||
|
else if (x2 >= primary.x + primary.width)
|
||||||
|
side = Meta.Side.RIGHT;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
} else if (x1 <= 0)
|
||||||
|
side = Meta.Side.LEFT;
|
||||||
|
else if (y1 <= 0)
|
||||||
side = Meta.Side.TOP;
|
side = Meta.Side.TOP;
|
||||||
else if (y2 >= primary.y + primary.height)
|
else if (x2 >= global.screen_width)
|
||||||
|
side = Meta.Side.RIGHT;
|
||||||
|
else if (y2 >= global.screen_height)
|
||||||
side = Meta.Side.BOTTOM;
|
side = Meta.Side.BOTTOM;
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
} else if (y1 <= primary.y && y2 >= primary.y + primary.height) {
|
|
||||||
if (x1 <= 0)
|
|
||||||
side = Meta.Side.LEFT;
|
|
||||||
else if (x2 >= primary.x + primary.width)
|
|
||||||
side = Meta.Side.RIGHT;
|
|
||||||
else
|
|
||||||
continue;
|
|
||||||
} else if (x1 <= 0)
|
|
||||||
side = Meta.Side.LEFT;
|
|
||||||
else if (y1 <= 0)
|
|
||||||
side = Meta.Side.TOP;
|
|
||||||
else if (x2 >= global.screen_width)
|
|
||||||
side = Meta.Side.RIGHT;
|
|
||||||
else if (y2 >= global.screen_height)
|
|
||||||
side = Meta.Side.BOTTOM;
|
|
||||||
else
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Ensure that the strut rects goes all the way to the screen edge,
|
// Ensure that the strut rects goes all the way to the screen edge,
|
||||||
// as this really what mutter expects.
|
// as this really what mutter expects.
|
||||||
switch (side) {
|
switch (side) {
|
||||||
case Meta.Side.TOP:
|
case Meta.Side.TOP:
|
||||||
y1 = 0;
|
y1 = 0;
|
||||||
break;
|
break;
|
||||||
case Meta.Side.BOTTOM:
|
case Meta.Side.BOTTOM:
|
||||||
y2 = global.screen_height;
|
y2 = global.screen_height;
|
||||||
break;
|
break;
|
||||||
case Meta.Side.LEFT:
|
case Meta.Side.LEFT:
|
||||||
x1 = 0;
|
x1 = 0;
|
||||||
break;
|
break;
|
||||||
case Meta.Side.RIGHT:
|
case Meta.Side.RIGHT:
|
||||||
x2 = global.screen_width;
|
x2 = global.screen_width;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
let strutRect = new Meta.Rectangle({ x: x1, y: y1, width: x2 - x1, height: y2 - y1});
|
||||||
|
let strut = new Meta.Strut({ rect: strutRect, side: side });
|
||||||
|
struts.push(strut);
|
||||||
}
|
}
|
||||||
|
|
||||||
let strutRect = new Meta.Rectangle({ x: x1, y: y1, width: x2 - x1, height: y2 - y1});
|
|
||||||
let strut = new Meta.Strut({ rect: strutRect, side: side });
|
|
||||||
struts.push(strut);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
global.set_stage_input_region(rects);
|
global.set_stage_input_region(rects);
|
||||||
|
Loading…
Reference in New Issue
Block a user