mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-14 06:10:21 +00:00
broadway: Always use client side decorations
This commit is contained in:
parent
c6a3c0e4eb
commit
bbfe7e0e69
@ -90,7 +90,6 @@ var grab = new Object();
|
|||||||
grab.window = null;
|
grab.window = null;
|
||||||
grab.ownerEvents = false;
|
grab.ownerEvents = false;
|
||||||
grab.implicit = false;
|
grab.implicit = false;
|
||||||
var localGrab = null;
|
|
||||||
var keyDownList = [];
|
var keyDownList = [];
|
||||||
var lastSerial = 0;
|
var lastSerial = 0;
|
||||||
var lastX = 0;
|
var lastX = 0;
|
||||||
@ -166,47 +165,6 @@ function sendConfigureNotify(surface)
|
|||||||
sendInput("w", [surface.id, surface.x, surface.y, surface.width, surface.height]);
|
sendInput("w", [surface.id, surface.x, surface.y, surface.width, surface.height]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStyle(el, styleProp)
|
|
||||||
{
|
|
||||||
if (el.currentStyle) {
|
|
||||||
return el.currentStyle[styleProp];
|
|
||||||
} else if (window.getComputedStyle) {
|
|
||||||
var win = el.ownerDocument.defaultView;
|
|
||||||
return win.getComputedStyle(el, null).getPropertyValue(styleProp);
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseOffset(value)
|
|
||||||
{
|
|
||||||
var px = value.indexOf("px");
|
|
||||||
if (px > 0)
|
|
||||||
return parseInt(value.slice(0,px));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getFrameOffset(surface) {
|
|
||||||
var x = 0;
|
|
||||||
var y = 0;
|
|
||||||
var el = surface.canvas;
|
|
||||||
while (el != null && el != surface.frame) {
|
|
||||||
x += el.offsetLeft;
|
|
||||||
y += el.offsetTop;
|
|
||||||
|
|
||||||
/* For some reason the border is not includes in the offsets.. */
|
|
||||||
x += parseOffset(getStyle(el, "border-left-width"));
|
|
||||||
y += parseOffset(getStyle(el, "border-top-width"));
|
|
||||||
|
|
||||||
el = el.offsetParent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Also include frame border as per above */
|
|
||||||
x += parseOffset(getStyle(el, "border-left-width"));
|
|
||||||
y += parseOffset(getStyle(el, "border-top-width"));
|
|
||||||
|
|
||||||
return {x: x, y: y};
|
|
||||||
}
|
|
||||||
|
|
||||||
var positionIndex = 0;
|
var positionIndex = 0;
|
||||||
function cmdCreateSurface(id, x, y, width, height, isTemp)
|
function cmdCreateSurface(id, x, y, width, height, isTemp)
|
||||||
{
|
{
|
||||||
@ -215,7 +173,6 @@ function cmdCreateSurface(id, x, y, width, height, isTemp)
|
|||||||
surface.drawQueue = [];
|
surface.drawQueue = [];
|
||||||
surface.transientParent = 0;
|
surface.transientParent = 0;
|
||||||
surface.visible = false;
|
surface.visible = false;
|
||||||
surface.frame = null;
|
|
||||||
|
|
||||||
var canvas = document.createElement("canvas");
|
var canvas = document.createElement("canvas");
|
||||||
canvas.width = width;
|
canvas.width = width;
|
||||||
@ -224,32 +181,8 @@ function cmdCreateSurface(id, x, y, width, height, isTemp)
|
|||||||
surface.canvas = canvas;
|
surface.canvas = canvas;
|
||||||
var toplevelElement;
|
var toplevelElement;
|
||||||
|
|
||||||
if (isTemp) {
|
toplevelElement = canvas;
|
||||||
toplevelElement = canvas;
|
document.body.appendChild(canvas);
|
||||||
document.body.appendChild(canvas);
|
|
||||||
} else {
|
|
||||||
var frame = document.createElement("div");
|
|
||||||
frame.frameFor = surface;
|
|
||||||
frame.className = "frame-window";
|
|
||||||
surface.frame = frame;
|
|
||||||
|
|
||||||
var button = document.createElement("center");
|
|
||||||
button.closeFor = surface;
|
|
||||||
var X = document.createTextNode("\u00d7");
|
|
||||||
button.appendChild(X);
|
|
||||||
button.className = "frame-close";
|
|
||||||
frame.appendChild(button);
|
|
||||||
|
|
||||||
var contents = document.createElement("div");
|
|
||||||
contents.className = "frame-contents";
|
|
||||||
frame.appendChild(contents);
|
|
||||||
|
|
||||||
canvas.style["display"] = "block";
|
|
||||||
contents.appendChild(canvas);
|
|
||||||
|
|
||||||
toplevelElement = frame;
|
|
||||||
document.body.appendChild(frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
surface.toplevelElement = toplevelElement;
|
surface.toplevelElement = toplevelElement;
|
||||||
toplevelElement.style["position"] = "absolute";
|
toplevelElement.style["position"] = "absolute";
|
||||||
@ -259,9 +192,7 @@ function cmdCreateSurface(id, x, y, width, height, isTemp)
|
|||||||
toplevelElement.style["top"] = surface.y + "px";
|
toplevelElement.style["top"] = surface.y + "px";
|
||||||
toplevelElement.style["display"] = "inline";
|
toplevelElement.style["display"] = "inline";
|
||||||
|
|
||||||
/* We hide the frame with visibility rather than display none
|
toplevelElement.style["visibility"] = "none";
|
||||||
* so getFrameOffset still works with hidden windows. */
|
|
||||||
toplevelElement.style["visibility"] = "hidden";
|
|
||||||
|
|
||||||
surfaces[id] = surface;
|
surfaces[id] = surface;
|
||||||
stackingOrder.push(surface);
|
stackingOrder.push(surface);
|
||||||
@ -280,12 +211,6 @@ function cmdShowSurface(id)
|
|||||||
var xOffset = surface.x;
|
var xOffset = surface.x;
|
||||||
var yOffset = surface.y;
|
var yOffset = surface.y;
|
||||||
|
|
||||||
if (surface.frame) {
|
|
||||||
var offset = getFrameOffset(surface);
|
|
||||||
xOffset -= offset.x;
|
|
||||||
yOffset -= offset.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
surface.toplevelElement.style["left"] = xOffset + "px";
|
surface.toplevelElement.style["left"] = xOffset + "px";
|
||||||
surface.toplevelElement.style["top"] = yOffset + "px";
|
surface.toplevelElement.style["top"] = yOffset + "px";
|
||||||
surface.toplevelElement.style["visibility"] = "visible";
|
surface.toplevelElement.style["visibility"] = "visible";
|
||||||
@ -365,9 +290,6 @@ function cmdDeleteSurface(id)
|
|||||||
stackingOrder.splice(i, 1);
|
stackingOrder.splice(i, 1);
|
||||||
var canvas = surface.canvas;
|
var canvas = surface.canvas;
|
||||||
canvas.parentNode.removeChild(canvas);
|
canvas.parentNode.removeChild(canvas);
|
||||||
var frame = surface.frame;
|
|
||||||
if (frame)
|
|
||||||
frame.parentNode.removeChild(frame);
|
|
||||||
delete surfaces[id];
|
delete surfaces[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,12 +318,6 @@ function cmdMoveResizeSurface(id, has_pos, x, y, has_size, w, h)
|
|||||||
var yOffset = surface.y;
|
var yOffset = surface.y;
|
||||||
|
|
||||||
var element = surface.canvas;
|
var element = surface.canvas;
|
||||||
if (surface.frame) {
|
|
||||||
element = surface.frame;
|
|
||||||
var offset = getFrameOffset(surface);
|
|
||||||
xOffset -= offset.x;
|
|
||||||
yOffset -= offset.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
element.style["left"] = xOffset + "px";
|
element.style["left"] = xOffset + "px";
|
||||||
element.style["top"] = yOffset + "px";
|
element.style["top"] = yOffset + "px";
|
||||||
@ -703,24 +619,6 @@ function updateForEvent(ev) {
|
|||||||
|
|
||||||
function onMouseMove (ev) {
|
function onMouseMove (ev) {
|
||||||
updateForEvent(ev);
|
updateForEvent(ev);
|
||||||
if (localGrab) {
|
|
||||||
if (localGrab.type == "move") {
|
|
||||||
var dx = ev.pageX - localGrab.lastX;
|
|
||||||
var dy = ev.pageY - localGrab.lastY;
|
|
||||||
var surface = localGrab.surface;
|
|
||||||
surface.x += dx;
|
|
||||||
surface.y += dy;
|
|
||||||
var offset = getFrameOffset(surface);
|
|
||||||
if (surface.y < offset.y)
|
|
||||||
surface.y = offset.y;
|
|
||||||
localGrab.frame.style["left"] = (surface.x - offset.x) + "px";
|
|
||||||
localGrab.frame.style["top"] = (surface.y - offset.y) + "px";
|
|
||||||
sendConfigureNotify(surface);
|
|
||||||
localGrab.lastX = ev.pageX;
|
|
||||||
localGrab.lastY = ev.pageY;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var id = getSurfaceId(ev);
|
var id = getSurfaceId(ev);
|
||||||
id = getEffectiveEventTarget (id);
|
id = getEffectiveEventTarget (id);
|
||||||
var pos = getPositionsFromEvent(ev, id);
|
var pos = getPositionsFromEvent(ev, id);
|
||||||
@ -730,14 +628,6 @@ function onMouseMove (ev) {
|
|||||||
function onMouseOver (ev) {
|
function onMouseOver (ev) {
|
||||||
updateForEvent(ev);
|
updateForEvent(ev);
|
||||||
|
|
||||||
if (!grab.window && ev.target.closeFor) {
|
|
||||||
ev.target.className = ev.target.className + " frame-hover";
|
|
||||||
if (ev.target.isDown)
|
|
||||||
ev.target.className = ev.target.className + " frame-active";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (localGrab)
|
|
||||||
return;
|
|
||||||
var id = getSurfaceId(ev);
|
var id = getSurfaceId(ev);
|
||||||
realWindowWithMouse = id;
|
realWindowWithMouse = id;
|
||||||
id = getEffectiveEventTarget (id);
|
id = getEffectiveEventTarget (id);
|
||||||
@ -750,13 +640,6 @@ function onMouseOver (ev) {
|
|||||||
|
|
||||||
function onMouseOut (ev) {
|
function onMouseOut (ev) {
|
||||||
updateForEvent(ev);
|
updateForEvent(ev);
|
||||||
if (ev.target.closeFor) {
|
|
||||||
ev.target.className = ev.target.className.replace(" frame-hover", "");
|
|
||||||
if (ev.target.isDown)
|
|
||||||
ev.target.className = ev.target.className.replace(" frame-active", "");
|
|
||||||
}
|
|
||||||
if (localGrab)
|
|
||||||
return;
|
|
||||||
var id = getSurfaceId(ev);
|
var id = getSurfaceId(ev);
|
||||||
var origId = id;
|
var origId = id;
|
||||||
id = getEffectiveEventTarget (id);
|
id = getEffectiveEventTarget (id);
|
||||||
@ -810,29 +693,6 @@ function onMouseDown (ev) {
|
|||||||
var id = getSurfaceId(ev);
|
var id = getSurfaceId(ev);
|
||||||
id = getEffectiveEventTarget (id);
|
id = getEffectiveEventTarget (id);
|
||||||
|
|
||||||
if (id == 0 && ev.target.frameFor) { /* mouse click on frame */
|
|
||||||
localGrab = new Object();
|
|
||||||
localGrab.surface = ev.target.frameFor;
|
|
||||||
localGrab.type = "move";
|
|
||||||
localGrab.frame = ev.target;
|
|
||||||
localGrab.lastX = ev.pageX;
|
|
||||||
localGrab.lastY = ev.pageY;
|
|
||||||
moveToTop(localGrab.frame.frameFor);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (id == 0 && ev.target.closeFor) { /* mouse click on frame */
|
|
||||||
ev.target.isDown = true;
|
|
||||||
ev.target.className = ev.target.className + " frame-active";
|
|
||||||
localGrab = new Object();
|
|
||||||
localGrab.surface = ev.target.closeFor;
|
|
||||||
localGrab.type = "close";
|
|
||||||
localGrab.button = ev.target;
|
|
||||||
localGrab.lastX = ev.pageX;
|
|
||||||
localGrab.lastY = ev.pageY;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var pos = getPositionsFromEvent(ev, id);
|
var pos = getPositionsFromEvent(ev, id);
|
||||||
if (grab.window == null)
|
if (grab.window == null)
|
||||||
doGrab (id, false, true);
|
doGrab (id, false, true);
|
||||||
@ -848,28 +708,6 @@ function onMouseUp (ev) {
|
|||||||
id = getEffectiveEventTarget (evId);
|
id = getEffectiveEventTarget (evId);
|
||||||
var pos = getPositionsFromEvent(ev, id);
|
var pos = getPositionsFromEvent(ev, id);
|
||||||
|
|
||||||
if (localGrab) {
|
|
||||||
realWindowWithMouse = evId;
|
|
||||||
if (windowWithMouse != id) {
|
|
||||||
if (windowWithMouse != 0) {
|
|
||||||
sendInput ("l", [realWindowWithMouse, windowWithMouse, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_NORMAL]);
|
|
||||||
}
|
|
||||||
windowWithMouse = id;
|
|
||||||
if (windowWithMouse != 0) {
|
|
||||||
sendInput ("e", [realWindowWithMouse, id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, GDK_CROSSING_NORMAL]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (localGrab.type == "close") {
|
|
||||||
localGrab.button.isDown = false;
|
|
||||||
localGrab.button.className = localGrab.button.className.replace( " frame-active", "");
|
|
||||||
if (ev.target == localGrab.button)
|
|
||||||
sendInput ("W", [localGrab.surface.id]);
|
|
||||||
}
|
|
||||||
localGrab = null;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
sendInput ("B", [realWindowWithMouse, id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, button]);
|
sendInput ("B", [realWindowWithMouse, id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, button]);
|
||||||
|
|
||||||
if (grab.window != null && grab.implicit)
|
if (grab.window != null && grab.implicit)
|
||||||
@ -2421,22 +2259,16 @@ function handleKeyUp(e) {
|
|||||||
|
|
||||||
function onKeyDown (ev) {
|
function onKeyDown (ev) {
|
||||||
updateForEvent(ev);
|
updateForEvent(ev);
|
||||||
if (localGrab)
|
|
||||||
return cancelEvent(ev);
|
|
||||||
return handleKeyDown(ev);
|
return handleKeyDown(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onKeyPress(ev) {
|
function onKeyPress(ev) {
|
||||||
updateForEvent(ev);
|
updateForEvent(ev);
|
||||||
if (localGrab)
|
|
||||||
return cancelEvent(ev);
|
|
||||||
return handleKeyPress(ev);
|
return handleKeyPress(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onKeyUp (ev) {
|
function onKeyUp (ev) {
|
||||||
updateForEvent(ev);
|
updateForEvent(ev);
|
||||||
if (localGrab)
|
|
||||||
return cancelEvent(ev);
|
|
||||||
return handleKeyUp(ev);
|
return handleKeyUp(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2456,8 +2288,6 @@ function cancelEvent(ev)
|
|||||||
function onMouseWheel(ev)
|
function onMouseWheel(ev)
|
||||||
{
|
{
|
||||||
updateForEvent(ev);
|
updateForEvent(ev);
|
||||||
if (localGrab)
|
|
||||||
return false;
|
|
||||||
ev = ev ? ev : window.event;
|
ev = ev ? ev : window.event;
|
||||||
|
|
||||||
var id = getSurfaceId(ev);
|
var id = getSurfaceId(ev);
|
||||||
|
@ -4,67 +4,6 @@
|
|||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
|
||||||
<title>broadway 2.0</title>
|
<title>broadway 2.0</title>
|
||||||
<script type="text/javascript" src="broadway.js"></script>
|
<script type="text/javascript" src="broadway.js"></script>
|
||||||
<style type="text/css">
|
|
||||||
|
|
||||||
.frame-window {
|
|
||||||
background-color: rgb(248, 248, 248);
|
|
||||||
background-image: -moz-linear-gradient(rgb(255, 255, 255) 1px, rgb(247, 247, 247) 1px, rgb(237, 236, 235) 32px);
|
|
||||||
/* background-image: -webkit-gradient(linear, left top, left 50, from(rgba(250, 253, 255, 0.9)), to(rgba(250, 253, 255, 0)), color-stop(88%, rgba(250, 253, 255, 0.75))); */
|
|
||||||
border-radius: 5px 5px 0 0;
|
|
||||||
-moz-border-radius: 5px 5px 0 0;
|
|
||||||
border: 1px solid rgb(142, 142, 142);
|
|
||||||
padding: 0 0 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.frame-contents {
|
|
||||||
clear: both;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.frame-close {
|
|
||||||
margin: 0 0 4px;
|
|
||||||
background-color: #BFC1C1;
|
|
||||||
background-image: -moz-linear-gradient(#D1D2D2 0%, #BABBBC 65%, #D4D4D5 100%);
|
|
||||||
/* background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(255, 255, 255, 0.35)), to(rgba(255, 255, 255, 0.5)), color-stop(50%, rgba(255, 255, 255, 0.5)), color-stop(50%, rgba(255, 255, 255, 0))); */
|
|
||||||
border-radius: 0 4px 0 5px;
|
|
||||||
/* border-top-left-radius: 0;
|
|
||||||
border-top-right-radius: 4px;
|
|
||||||
-moz-border-radius: 2px;
|
|
||||||
-moz-border-top-left-radius: 0;
|
|
||||||
-moz-border-top-right-radius: 0; */
|
|
||||||
border-top: none;
|
|
||||||
border-right: none;
|
|
||||||
border-bottom: 1px solid #BEBEBE;
|
|
||||||
border-left: 1px solid #8E8E8E;
|
|
||||||
float: right;
|
|
||||||
color: white;
|
|
||||||
line-height: 30px;
|
|
||||||
width: 30px;
|
|
||||||
text-shadow: 0 1px 0 #8E8E8E;
|
|
||||||
font-weight: bold;
|
|
||||||
font-family: sans-serif;
|
|
||||||
font-size: 190%;
|
|
||||||
cursor: pointer;
|
|
||||||
-webkit-user-select: none;
|
|
||||||
-khtml-user-select: none;
|
|
||||||
-moz-user-select: none;
|
|
||||||
-o-user-select: none;
|
|
||||||
user-select: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.frame-close.frame-hover {
|
|
||||||
background-image: -moz-linear-gradient(#E8E8E8 0%, #C7C8C9 65%, #D6D6D6 100%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.frame-close.frame-active {
|
|
||||||
background-image: -moz-linear-gradient(#8E8E8E 1px, #BEBEBE 100%);
|
|
||||||
text-shadow: none;
|
|
||||||
/* this is a gross hack, remove if it break things */
|
|
||||||
margin: -1px 0 4px;
|
|
||||||
padding-top: 1px;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body onload="connect()">
|
<body onload="connect()">
|
||||||
|
@ -65,6 +65,10 @@
|
|||||||
#include "wayland/gdkwayland.h"
|
#include "wayland/gdkwayland.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef GDK_WINDOWING_BROADWAY
|
||||||
|
#include "broadway/gdkbroadway.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SECTION:gtkwindow
|
* SECTION:gtkwindow
|
||||||
* @title: GtkWindow
|
* @title: GtkWindow
|
||||||
@ -5332,6 +5336,11 @@ gdk_window_should_use_csd (GtkWindow *window)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef GDK_WINDOWING_BROADWAY
|
||||||
|
if (GDK_IS_BROADWAY_DISPLAY (gtk_widget_get_display (GTK_WIDGET (window))))
|
||||||
|
return TRUE;
|
||||||
|
#endif
|
||||||
|
|
||||||
return (g_strcmp0 (g_getenv ("GTK_CSD"), "1") == 0);
|
return (g_strcmp0 (g_getenv ("GTK_CSD"), "1") == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user