summaryrefslogtreecommitdiff
path: root/unity-shared
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2014-10-01 04:33:47 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2014-10-01 04:33:47 +0200
commit2deaf42880f8090d0e8d4c631345b223fd224dab (patch)
tree731f45908ce7be3e95a12a32f8c9e614e598afb2 /unity-shared
parent044a82559e2488f63e1291f0a9826a0920336eb9 (diff)
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)
Diffstat (limited to 'unity-shared')
-rw-r--r--unity-shared/CompizUtils.cpp79
-rw-r--r--unity-shared/CompizUtils.h13
2 files changed, 53 insertions, 39 deletions
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