From 69b3136545dac1a06fe750eaf89c2415574a455c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 23 Sep 2014 19:39:57 +0200 Subject: CompizUtils: don't (shadow)decorate windows that have a region mismatching their geometry This means that windows using XShape extensions to define a region that is different to the actual window geometry, should not be decorated Fixes LP: #1364225 (bzr r3806.12.6) --- unity-shared/CompizUtils.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'unity-shared') diff --git a/unity-shared/CompizUtils.cpp b/unity-shared/CompizUtils.cpp index be197c73e..c150b1451 100644 --- a/unity-shared/CompizUtils.cpp +++ b/unity-shared/CompizUtils.cpp @@ -179,6 +179,8 @@ bool IsWindowShadowDecorable(CompWindow* win) if (win->region().numRects() != 1) // Non rectangular windows return false; + else if (win->region().boundingRect() != win->geometry()) + return false; if (win->alpha()) return WindowHasMotifDecorations(win); -- cgit v1.2.3 From 3e0b9918eb6c7643e9bd443752d324f14577debf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 23 Sep 2014 19:47:25 +0200 Subject: CompizUtils: undecorate windows in showDesktop mode Fixes LP: #1324104 (bzr r3806.12.7) --- unity-shared/CompizUtils.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'unity-shared') diff --git a/unity-shared/CompizUtils.cpp b/unity-shared/CompizUtils.cpp index c150b1451..53b08de82 100644 --- a/unity-shared/CompizUtils.cpp +++ b/unity-shared/CompizUtils.cpp @@ -177,6 +177,9 @@ bool IsWindowShadowDecorable(CompWindow* win) if (win->wmType() & (CompWindowTypeDockMask | CompWindowTypeDesktopMask)) return false; + if (win->inShowDesktopMode()) + return false; + if (win->region().numRects() != 1) // Non rectangular windows return false; else if (win->region().boundingRect() != win->geometry()) -- cgit v1.2.3 From d5518e6302eff102383a612bcecc3a3457e025f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 24 Sep 2014 02:46:09 +0200 Subject: CompizUtils: initialize a MatrixList for each TextureQuad, so we avoid to create one at each draw Keep a reference not to break old code (bzr r3806.12.10) --- unity-shared/CompizUtils.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'unity-shared') diff --git a/unity-shared/CompizUtils.h b/unity-shared/CompizUtils.h index bab45a532..f60070cea 100644 --- a/unity-shared/CompizUtils.h +++ b/unity-shared/CompizUtils.h @@ -31,8 +31,14 @@ namespace compiz_utils struct TextureQuad { + TextureQuad() + : matrices(1) + , matrix(matrices[0]) + {} + CompRect box; - GLTexture::Matrix matrix; + GLTexture::MatrixList matrices; + GLTexture::Matrix& matrix; }; struct SimpleTexture -- cgit v1.2.3 From 85f535335b1ae316eee7971bb9049c08b8ecc37c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 24 Sep 2014 02:46:40 +0200 Subject: CompizUtils: avoid matrix updates when only a texture size changes (bzr r3806.12.11) --- unity-shared/CompizUtils.cpp | 27 +++++++++++++++------------ unity-shared/CompizUtils.h | 7 ++++--- 2 files changed, 19 insertions(+), 15 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/CompizUtils.cpp b/unity-shared/CompizUtils.cpp index 53b08de82..3139f3725 100644 --- a/unity-shared/CompizUtils.cpp +++ b/unity-shared/CompizUtils.cpp @@ -39,7 +39,7 @@ SimpleTexture::SimpleTexture(GLTexture::List const& tex) // SimpleTextureQuad::SimpleTextureQuad() - : scale(DEFAULT_SCALE) + : scale_(DEFAULT_SCALE) {} bool SimpleTextureQuad::SetTexture(SimpleTexture::Ptr const& simple_texture) @@ -52,24 +52,27 @@ bool SimpleTextureQuad::SetTexture(SimpleTexture::Ptr const& simple_texture) if (st && st->texture()) { auto* tex = st->texture(); - CompPoint old_coords(quad.box.x(), quad.box.y()); - short invalid = std::numeric_limits::min(); - quad.box.setGeometry(invalid, invalid, tex->width() * scale, tex->height() * scale); - SetCoords(old_coords.x(), old_coords.y()); + CompSize size(tex->width() * scale_, tex->height() * scale_); + + if (quad.box.width() != size.width() || quad.box.height() != size.height()) + { + quad.box.setSize(size); + UpdateMatrix(); + } } return true; } -bool SimpleTextureQuad::SetScale(float s) +bool SimpleTextureQuad::SetScale(double s) { - if (!st || scale == s) + if (!st || scale_ == s) return false; - scale = s; + scale_ = s; auto* tex = st->texture(); - quad.box.setWidth(tex->width() * scale); - quad.box.setHeight(tex->height() * scale); + quad.box.setWidth(tex->width() * scale_); + quad.box.setHeight(tex->height() * scale_); UpdateMatrix(); return true; } @@ -91,8 +94,8 @@ void SimpleTextureQuad::UpdateMatrix() int y = quad.box.y(); quad.matrix = (st && st->texture()) ? st->texture()->matrix() : GLTexture::Matrix(); - quad.matrix.xx /= scale; - quad.matrix.yy /= scale; + quad.matrix.xx /= scale_; + quad.matrix.yy /= scale_; quad.matrix.x0 = 0.0f - COMP_TEX_COORD_X(quad.matrix, x); quad.matrix.y0 = 0.0f - COMP_TEX_COORD_Y(quad.matrix, y); } diff --git a/unity-shared/CompizUtils.h b/unity-shared/CompizUtils.h index f60070cea..5dafd7b82 100644 --- a/unity-shared/CompizUtils.h +++ b/unity-shared/CompizUtils.h @@ -65,11 +65,13 @@ struct SimpleTextureQuad { SimpleTextureQuad(); bool SetTexture(SimpleTexture::Ptr const&); - bool SetScale(float scale); + bool SetScale(double scale); bool SetCoords(int x, int y); bool SetX(int x); bool SetY(int y); + void UpdateMatrix(); + operator SimpleTexture::Ptr() const { return st; } operator bool() const { return st && st->texture(); } operator GLTexture*() const { return st ? st->texture() : nullptr; } @@ -79,8 +81,7 @@ struct SimpleTextureQuad TextureQuad quad; private: - void UpdateMatrix(); - float scale; + double scale_; }; struct PixmapTexture : SimpleTexture -- cgit v1.2.3 From 308720c9287a7230a8acf73122e3b0e594bde5e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 24 Sep 2014 03:27:33 +0200 Subject: CompizUtils: include a CompRegion in TextureQuad, to avoid regeneration at each draw (bzr r3806.12.13) --- unity-shared/CompizUtils.h | 1 + 1 file changed, 1 insertion(+) (limited to 'unity-shared') diff --git a/unity-shared/CompizUtils.h b/unity-shared/CompizUtils.h index 5dafd7b82..c3437ec57 100644 --- a/unity-shared/CompizUtils.h +++ b/unity-shared/CompizUtils.h @@ -37,6 +37,7 @@ struct TextureQuad {} CompRect box; + CompRegion region; GLTexture::MatrixList matrices; GLTexture::Matrix& matrix; }; -- cgit v1.2.3 From 83762aeb0cf12e02087c0209cd68c50255147dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 25 Sep 2014 18:56:05 +0200 Subject: CompizUtils: add missing comments (bzr r3806.12.21) --- unity-shared/CompizUtils.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'unity-shared') diff --git a/unity-shared/CompizUtils.cpp b/unity-shared/CompizUtils.cpp index 3139f3725..fb7b1a587 100644 --- a/unity-shared/CompizUtils.cpp +++ b/unity-shared/CompizUtils.cpp @@ -169,6 +169,8 @@ int CairoContext::height() const return cairo_xlib_surface_get_height(surface_); } +// + bool IsWindowShadowDecorable(CompWindow* win) { if (!win) @@ -185,7 +187,7 @@ bool IsWindowShadowDecorable(CompWindow* win) if (win->region().numRects() != 1) // Non rectangular windows return false; - else if (win->region().boundingRect() != win->geometry()) + else if (win->region().boundingRect() != win->geometry()) // Shaped windows return false; if (win->alpha()) -- cgit v1.2.3 From 044a82559e2488f63e1291f0a9826a0920336eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 1 Oct 2014 04:30:09 +0200 Subject: XWindowManager: properly log error (bzr r3806.12.22) --- unity-shared/XWindowManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'unity-shared') diff --git a/unity-shared/XWindowManager.cpp b/unity-shared/XWindowManager.cpp index aa3d9c54f..5058c2952 100644 --- a/unity-shared/XWindowManager.cpp +++ b/unity-shared/XWindowManager.cpp @@ -83,7 +83,7 @@ std::string XWindowManager::GetStringProperty(Window window_id, Atom atom) const { LOG_ERROR(logger) << "Impossible to get the property " << gdk_x11_get_xatom_name(atom) << " for window " << window_id << ": invalid string type: " - << gdk_x11_get_xatom_name(Atoms::utf8String); + << gdk_x11_get_xatom_name(type); return std::string(); } -- cgit v1.2.3 From 2deaf42880f8090d0e8d4c631345b223fd224dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 1 Oct 2014 04:33:47 +0200 Subject: CompizUtils: add WindowDecorationElements that returns a bitset describing the elements available This function will allow to check which decoration elements are supported by a window by using just a single call, that will check which elements should be added when decorating the window. By returning a single unsigned that is a bitwise composition of values, we can just use a single call to verify which elements are supported. (bzr r3806.12.23) --- unity-shared/CompizUtils.cpp | 79 +++++++++++++++++++++++--------------------- unity-shared/CompizUtils.h | 13 +++++++- 2 files changed, 53 insertions(+), 39 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/CompizUtils.cpp b/unity-shared/CompizUtils.cpp index fb7b1a587..29d85bbcd 100644 --- a/unity-shared/CompizUtils.cpp +++ b/unity-shared/CompizUtils.cpp @@ -1,6 +1,6 @@ // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- /* -* Copyright (C) 2013 Canonical Ltd +* Copyright (C) 2013-2014 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as @@ -30,6 +30,11 @@ namespace { const unsigned PIXMAP_DEPTH = 32; const float DEFAULT_SCALE = 1.0f; + const unsigned DECORABLE_WINDOW_TYPES = CompWindowTypeDialogMask | + CompWindowTypeModalDialogMask | + CompWindowTypeUtilMask | + CompWindowTypeMenuMask | + CompWindowTypeNormalMask; } SimpleTexture::SimpleTexture(GLTexture::List const& tex) @@ -168,65 +173,63 @@ int CairoContext::height() const { return cairo_xlib_surface_get_height(surface_); } - +// // -bool IsWindowShadowDecorable(CompWindow* win) +unsigned WindowDecorationElements(CompWindow* win) { + unsigned elements = DecorationElement::NONE; + if (!win) - return false; + return elements; if (!win->isViewable()) - return false; + return elements; if (win->wmType() & (CompWindowTypeDockMask | CompWindowTypeDesktopMask)) - return false; + return elements; if (win->inShowDesktopMode()) - return false; + return elements; if (win->region().numRects() != 1) // Non rectangular windows - return false; - else if (win->region().boundingRect() != win->geometry()) // Shaped windows - return false; + return elements; - if (win->alpha()) - return WindowHasMotifDecorations(win); + if (win->region().boundingRect() != win->geometry()) // Shaped windows + return elements; - return true; -} + elements |= DecorationElement::SHADOW; -bool IsWindowFullyDecorable(CompWindow* win) -{ - if (!win) - return false; + if (!win->overrideRedirect() && + (win->type() & DECORABLE_WINDOW_TYPES) && + (win->frame() || win->hasUnmapReference())) + { + if (win->actions() & CompWindowActionResizeMask) + elements |= DecorationElement::EDGE; - if (!IsWindowShadowDecorable(win)) - return false; + if (win->mwmDecor() & (MwmDecorAll | MwmDecorTitle)) + elements |= DecorationElement::BORDER; + } - return WindowHasMotifDecorations(win); + if (!(elements & DecorationElement::BORDER) && win->alpha()) + elements &= ~DecorationElement::SHADOW; + + return elements; } -bool WindowHasMotifDecorations(CompWindow* win) +bool IsWindowEdgeDecorable(CompWindow* win) { - if (!win) - return false; - - if (win->overrideRedirect()) - return false; + return WindowDecorationElements(win) & DecorationElement::EDGE; +} - switch (win->type()) - { - case CompWindowTypeDialogMask: - case CompWindowTypeModalDialogMask: - case CompWindowTypeUtilMask: - case CompWindowTypeMenuMask: - case CompWindowTypeNormalMask: - if (win->mwmDecor() & (MwmDecorAll | MwmDecorTitle)) - return true; - } +bool IsWindowShadowDecorable(CompWindow* win) +{ + return WindowDecorationElements(win) & DecorationElement::SHADOW; +} - return false; +bool IsWindowFullyDecorable(CompWindow* win) +{ + return WindowDecorationElements(win) & DecorationElement::BORDER; } } // compiz_utils namespace diff --git a/unity-shared/CompizUtils.h b/unity-shared/CompizUtils.h index c3437ec57..f1885a5cc 100644 --- a/unity-shared/CompizUtils.h +++ b/unity-shared/CompizUtils.h @@ -119,9 +119,20 @@ private: cairo_t *cr_; }; +enum DecorationElement +{ + NONE = 0, + EDGE = (1 << 0), + SHADOW = (1 << 1), + BORDER = (1 << 2), + FULL = EDGE|SHADOW|BORDER +}; + +unsigned WindowDecorationElements(CompWindow*); + +bool IsWindowEdgeDecorable(CompWindow*); bool IsWindowShadowDecorable(CompWindow*); bool IsWindowFullyDecorable(CompWindow*); -bool WindowHasMotifDecorations(CompWindow*); } // compiz_utils namespace } // unity namespace -- cgit v1.2.3 From fc6a502f9a9eea8f329abddfbcede192101822de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 1 Oct 2014 17:08:56 +0200 Subject: CompizUtils: make possible for non-rectangular windows to have edges But only if they're resizable... Such as Chrome/Chromium when using its client side decorations. (bzr r3806.12.28) --- unity-shared/CompizUtils.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/CompizUtils.cpp b/unity-shared/CompizUtils.cpp index 29d85bbcd..1ee54baa0 100644 --- a/unity-shared/CompizUtils.cpp +++ b/unity-shared/CompizUtils.cpp @@ -173,7 +173,8 @@ int CairoContext::height() const { return cairo_xlib_surface_get_height(surface_); } -// + +// // unsigned WindowDecorationElements(CompWindow* win) @@ -192,13 +193,18 @@ unsigned WindowDecorationElements(CompWindow* win) if (win->inShowDesktopMode()) return elements; - if (win->region().numRects() != 1) // Non rectangular windows + auto const& region = win->region(); + bool rectangular = (region.numRects() == 1); + bool alpha = win->alpha(); + + if (!rectangular && alpha) // Non-rectangular windows with alpha channel return elements; - if (win->region().boundingRect() != win->geometry()) // Shaped windows + if (region.boundingRect() != win->geometry()) // Shaped windows return elements; - elements |= DecorationElement::SHADOW; + if (rectangular) + elements |= DecorationElement::SHADOW; if (!win->overrideRedirect() && (win->type() & DECORABLE_WINDOW_TYPES) && @@ -207,11 +213,11 @@ unsigned WindowDecorationElements(CompWindow* win) if (win->actions() & CompWindowActionResizeMask) elements |= DecorationElement::EDGE; - if (win->mwmDecor() & (MwmDecorAll | MwmDecorTitle)) + if (rectangular && (win->mwmDecor() & (MwmDecorAll | MwmDecorTitle))) elements |= DecorationElement::BORDER; } - if (!(elements & DecorationElement::BORDER) && win->alpha()) + if (alpha && !(elements & DecorationElement::BORDER)) elements &= ~DecorationElement::SHADOW; return elements; -- cgit v1.2.3 From 8714ad79533a71047a4c4a7b972ced3e21bd5007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 1 Oct 2014 17:18:40 +0200 Subject: CompizUtils: don't remove shadows to windows that have Motif borders set Such as gtk windows with HeaderBar when using Gtk <= 3.10 (bzr r3806.12.29) --- unity-shared/CompizUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'unity-shared') diff --git a/unity-shared/CompizUtils.cpp b/unity-shared/CompizUtils.cpp index 1ee54baa0..94322a68f 100644 --- a/unity-shared/CompizUtils.cpp +++ b/unity-shared/CompizUtils.cpp @@ -217,7 +217,7 @@ unsigned WindowDecorationElements(CompWindow* win) elements |= DecorationElement::BORDER; } - if (alpha && !(elements & DecorationElement::BORDER)) + if (alpha && !(elements & DecorationElement::BORDER) && !(win->mwmDecor() & MwmDecorBorder)) elements &= ~DecorationElement::SHADOW; return elements; -- cgit v1.2.3