[gtk+] broadway: Always use client side decorations
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] broadway: Always use client side decorations
- Date: Thu, 7 Nov 2013 13:10:27 +0000 (UTC)
commit bbfe7e0e697fdc9e5921eeaba013843218594f94
Author: Alexander Larsson <alexl redhat com>
Date: Wed Nov 6 13:28:52 2013 +0100
broadway: Always use client side decorations
gdk/broadway/broadway.js | 176 +---------------------------------------------
gdk/broadway/client.html | 61 ----------------
gtk/gtkwindow.c | 9 +++
3 files changed, 12 insertions(+), 234 deletions(-)
---
diff --git a/gdk/broadway/broadway.js b/gdk/broadway/broadway.js
index 97ef309..ddef0f6 100644
--- a/gdk/broadway/broadway.js
+++ b/gdk/broadway/broadway.js
@@ -90,7 +90,6 @@ var grab = new Object();
grab.window = null;
grab.ownerEvents = false;
grab.implicit = false;
-var localGrab = null;
var keyDownList = [];
var lastSerial = 0;
var lastX = 0;
@@ -166,47 +165,6 @@ function sendConfigureNotify(surface)
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;
function cmdCreateSurface(id, x, y, width, height, isTemp)
{
@@ -215,7 +173,6 @@ function cmdCreateSurface(id, x, y, width, height, isTemp)
surface.drawQueue = [];
surface.transientParent = 0;
surface.visible = false;
- surface.frame = null;
var canvas = document.createElement("canvas");
canvas.width = width;
@@ -224,32 +181,8 @@ function cmdCreateSurface(id, x, y, width, height, isTemp)
surface.canvas = canvas;
var toplevelElement;
- if (isTemp) {
- toplevelElement = 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);
- }
+ toplevelElement = canvas;
+ document.body.appendChild(canvas);
surface.toplevelElement = toplevelElement;
toplevelElement.style["position"] = "absolute";
@@ -259,9 +192,7 @@ function cmdCreateSurface(id, x, y, width, height, isTemp)
toplevelElement.style["top"] = surface.y + "px";
toplevelElement.style["display"] = "inline";
- /* We hide the frame with visibility rather than display none
- * so getFrameOffset still works with hidden windows. */
- toplevelElement.style["visibility"] = "hidden";
+ toplevelElement.style["visibility"] = "none";
surfaces[id] = surface;
stackingOrder.push(surface);
@@ -280,12 +211,6 @@ function cmdShowSurface(id)
var xOffset = surface.x;
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["top"] = yOffset + "px";
surface.toplevelElement.style["visibility"] = "visible";
@@ -365,9 +290,6 @@ function cmdDeleteSurface(id)
stackingOrder.splice(i, 1);
var canvas = surface.canvas;
canvas.parentNode.removeChild(canvas);
- var frame = surface.frame;
- if (frame)
- frame.parentNode.removeChild(frame);
delete surfaces[id];
}
@@ -396,12 +318,6 @@ function cmdMoveResizeSurface(id, has_pos, x, y, has_size, w, h)
var yOffset = surface.y;
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["top"] = yOffset + "px";
@@ -703,24 +619,6 @@ function updateForEvent(ev) {
function onMouseMove (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);
id = getEffectiveEventTarget (id);
var pos = getPositionsFromEvent(ev, id);
@@ -730,14 +628,6 @@ function onMouseMove (ev) {
function onMouseOver (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);
realWindowWithMouse = id;
id = getEffectiveEventTarget (id);
@@ -750,13 +640,6 @@ function onMouseOver (ev) {
function onMouseOut (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 origId = id;
id = getEffectiveEventTarget (id);
@@ -810,29 +693,6 @@ function onMouseDown (ev) {
var id = getSurfaceId(ev);
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);
if (grab.window == null)
doGrab (id, false, true);
@@ -848,28 +708,6 @@ function onMouseUp (ev) {
id = getEffectiveEventTarget (evId);
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]);
if (grab.window != null && grab.implicit)
@@ -2421,22 +2259,16 @@ function handleKeyUp(e) {
function onKeyDown (ev) {
updateForEvent(ev);
- if (localGrab)
- return cancelEvent(ev);
return handleKeyDown(ev);
}
function onKeyPress(ev) {
updateForEvent(ev);
- if (localGrab)
- return cancelEvent(ev);
return handleKeyPress(ev);
}
function onKeyUp (ev) {
updateForEvent(ev);
- if (localGrab)
- return cancelEvent(ev);
return handleKeyUp(ev);
}
@@ -2456,8 +2288,6 @@ function cancelEvent(ev)
function onMouseWheel(ev)
{
updateForEvent(ev);
- if (localGrab)
- return false;
ev = ev ? ev : window.event;
var id = getSurfaceId(ev);
diff --git a/gdk/broadway/client.html b/gdk/broadway/client.html
index 85e66cd..a699612 100644
--- a/gdk/broadway/client.html
+++ b/gdk/broadway/client.html
@@ -4,67 +4,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<title>broadway 2.0</title>
<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>
<body onload="connect()">
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 32f5eee..8abc5c1 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -65,6 +65,10 @@
#include "wayland/gdkwayland.h"
#endif
+#ifdef GDK_WINDOWING_BROADWAY
+#include "broadway/gdkbroadway.h"
+#endif
+
/**
* SECTION:gtkwindow
* @title: GtkWindow
@@ -5332,6 +5336,11 @@ gdk_window_should_use_csd (GtkWindow *window)
return TRUE;
#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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]