summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAbdiel Janulgue <abdiel.janulgue@nokia.com>2010-07-29 21:07:12 +0300
committerAbdiel Janulgue <abdiel.janulgue@nokia.com>2010-07-29 21:07:12 +0300
commit83f9300c82d1ea0da2c041accb16e8f7a40942c5 (patch)
treeff446896c5375dd2b8f307905b1e41cac5117eb5 /src
parentaa8457c27ee681ff3bedc0c7922e69d6c76cc056 (diff)
Fixes: NB#171592 - setGlobalAlpha does not work
RevBy: TrustMe
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp3
-rw-r--r--src/mcompatoms_p.h1
-rw-r--r--src/mcompositemanager.cpp55
-rw-r--r--src/mwindowpropertycache.cpp50
-rw-r--r--src/mwindowpropertycache.h4
5 files changed, 74 insertions, 39 deletions
diff --git a/src/main.cpp b/src/main.cpp
index f0bea6c..87dfaf5 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -24,6 +24,9 @@
int main(int argc, char *argv[])
{
+ // We don't need meego graphics system
+ setenv("QT_GRAPHICSSYSTEM", "raster", 1);
+
// Don't load any Qt plugins
QCoreApplication::setLibraryPaths(QStringList());
MCompositeManager app(argc, argv);
diff --git a/src/mcompatoms_p.h b/src/mcompatoms_p.h
index 1f679e8..bad2a4b 100644
--- a/src/mcompatoms_p.h
+++ b/src/mcompatoms_p.h
@@ -90,6 +90,7 @@ public:
_MEEGOTOUCH_DECORATOR_WINDOW,
_DUI_STATUSBAR_OVERLAY,
_MEEGOTOUCH_GLOBAL_ALPHA,
+ _MEEGOTOUCH_VIDEO_ALPHA,
_MEEGO_STACKING_LAYER,
_MEEGOTOUCH_DECORATOR_BUTTONS,
diff --git a/src/mcompositemanager.cpp b/src/mcompositemanager.cpp
index ac52c4c..671034b 100644
--- a/src/mcompositemanager.cpp
+++ b/src/mcompositemanager.cpp
@@ -140,6 +140,7 @@ MCompAtoms::MCompAtoms()
// TODO: remove this when statusbar in-scene approach is done
"_DUI_STATUSBAR_OVERLAY",
"_MEEGOTOUCH_GLOBAL_ALPHA",
+ "_MEEGOTOUCH_VIDEO_ALPHA",
"_MEEGO_STACKING_LAYER",
"_MEEGOTOUCH_DECORATOR_BUTTONS",
@@ -509,6 +510,16 @@ static void set_global_alpha(unsigned int plane, unsigned int level)
fclose(out);
}
}
+
+static void set_alpha_onplane(int plane, int value)
+{
+ if (value == 255)
+ toggle_global_alpha_blend(0, plane);
+ else if (value < 255)
+ toggle_global_alpha_blend(1, plane);
+
+ set_global_alpha(plane, value);
+}
#endif
static Bool map_predicate(Display *display, XEvent *xevent, XPointer arg)
@@ -943,20 +954,6 @@ void MCompositeManagerPrivate::unmapEvent(XUnmapEvent *e)
return;
}
-#ifdef GLES2_VERSION
- Window topmost_win = 0;
- for (int i = stacking_list.size() - 1; i >= 0; --i) {
- Window w = stacking_list.at(i);
- MCompositeWindow *cw = COMPOSITE_WINDOW(w);
- if (cw && cw->isMapped() && !cw->propertyCache()->isDecorator() &&
- cw->propertyCache()->windowTypeAtom()
- != ATOM(_NET_WM_WINDOW_TYPE_DOCK)) {
- topmost_win = w;
- break;
- }
- }
-#endif
-
MCompositeWindow *item = COMPOSITE_WINDOW(e->window);
if (item) {
item->setIsMapped(false);
@@ -1009,13 +1006,20 @@ void MCompositeManagerPrivate::unmapEvent(XUnmapEvent *e)
for (int i = 0; i < TOTAL_LAYERS; ++i)
if (stack[i] == e->window) stack[i] = 0;
-#ifdef GLES2_VERSION
- if (topmost_win == e->window) {
- toggle_global_alpha_blend(0);
- set_global_alpha(0, 255);
- }
-#endif
dirtyStacking(false);
+
+#ifdef GLES2_VERSION
+ // Set the global alpha if the window beneath this window has one
+ Window newtop = getTopmostApp(0, e->window);
+ MCompositeWindow *c_newtop = MCompositeWindow::compositeWindow(newtop);
+ if(c_newtop) {
+ set_alpha_onplane(0, c_newtop->propertyCache()->globalAlpha());
+ set_alpha_onplane(1, c_newtop->propertyCache()->videoGlobalAlpha());
+ } else {
+ set_alpha_onplane(0, 255);
+ set_alpha_onplane(1, 255);
+ }
+#endif
}
void MCompositeManagerPrivate::configureEvent(XConfigureEvent *e)
@@ -1803,15 +1807,10 @@ void MCompositeManagerPrivate::mapEvent(XMapEvent *e)
}
#ifdef GLES2_VERSION
- // TODO: this should probably be done on the focus level. Rewrite this
- // once new stacking code from Kimmo is done
- // FIXME: this works only if this window is on top
int g_alpha = wpc->globalAlpha();
- if (g_alpha == 255)
- toggle_global_alpha_blend(0);
- else if (g_alpha < 255)
- toggle_global_alpha_blend(1);
- set_global_alpha(0, g_alpha);
+ int v_alpha = wpc->videoGlobalAlpha();
+ set_alpha_onplane(0, g_alpha);
+ set_alpha_onplane(1, v_alpha);
#endif
MWindowPropertyCache *pc = 0;
diff --git a/src/mwindowpropertycache.cpp b/src/mwindowpropertycache.cpp
index eaac9a3..af053e6 100644
--- a/src/mwindowpropertycache.cpp
+++ b/src/mwindowpropertycache.cpp
@@ -44,6 +44,7 @@ MWindowPropertyCache::MWindowPropertyCache(Window w,
wm_state_query(true),
has_alpha(-1),
global_alpha(-1),
+ video_global_alpha(-1),
is_decorator(-1),
wmhints(0),
attrs(0),
@@ -114,6 +115,9 @@ MWindowPropertyCache::MWindowPropertyCache(Window w,
xcb_global_alpha_cookie = xcb_get_property(xcb_conn, 0, window,
ATOM(_MEEGOTOUCH_GLOBAL_ALPHA),
XCB_ATOM_CARDINAL, 0, 1);
+ xcb_video_global_alpha_cookie = xcb_get_property(xcb_conn, 0, window,
+ ATOM(_MEEGOTOUCH_VIDEO_ALPHA),
+ XCB_ATOM_CARDINAL, 0, 1);
xcb_shape_rects_cookie = xcb_shape_get_rectangles(xcb_conn, window,
ShapeBounding);
xcb_net_wm_state_cookie = xcb_get_property(xcb_conn, 0, window,
@@ -180,6 +184,8 @@ MWindowPropertyCache::~MWindowPropertyCache()
iconGeometry();
if (global_alpha < 0)
globalAlpha();
+ if (video_global_alpha < 0)
+ videoGlobalAlpha();
if (!shape_rects_valid)
shapeRegion();
if (!net_wm_state_valid)
@@ -400,6 +406,14 @@ bool MWindowPropertyCache::propertyEvent(XPropertyEvent *e)
xcb_global_alpha_cookie = xcb_get_property(xcb_conn, 0, window,
ATOM(_MEEGOTOUCH_GLOBAL_ALPHA),
XCB_ATOM_CARDINAL, 0, 1);
+ } else if (e->atom == ATOM(_MEEGOTOUCH_VIDEO_ALPHA)) {
+ if (video_global_alpha < 0)
+ // collect the old reply
+ videoGlobalAlpha();
+ video_global_alpha = -1;
+ xcb_video_global_alpha_cookie = xcb_get_property(xcb_conn, 0, window,
+ ATOM(_MEEGOTOUCH_VIDEO_ALPHA),
+ XCB_ATOM_CARDINAL, 0, 1);
} else if (e->atom == ATOM(_MEEGOTOUCH_DECORATOR_BUTTONS)) {
if (!decor_buttons_valid)
// collect the old reply
@@ -577,28 +591,42 @@ empty_geom:
}
#define OPAQUE 0xffffffff
-int MWindowPropertyCache::globalAlpha()
+int MWindowPropertyCache::alphaValue(xcb_get_property_cookie_t c)
{
- if (!is_valid || global_alpha != -1)
- return global_alpha;
xcb_get_property_reply_t *r;
- r = xcb_get_property_reply(xcb_conn, xcb_global_alpha_cookie, 0);
- if (!r) {
- global_alpha = 255;
- return global_alpha;
- }
+ r = xcb_get_property_reply(xcb_conn, c, 0);
+ if (!r)
+ return 255;
+
int len = xcb_get_property_value_length(r);
if ((unsigned)len < sizeof(CARD32)) {
free(r);
- global_alpha = 255;
- return global_alpha;
+ return 255;
}
CARD32 i = *((CARD32*)xcb_get_property_value(r));
double opacity = i * 1.0 / OPAQUE;
- global_alpha = opacity * 255;
+ return opacity * 255;
+}
+
+int MWindowPropertyCache::globalAlpha()
+{
+ if (!is_valid || global_alpha != -1)
+ return global_alpha;
+
+ global_alpha = alphaValue(xcb_global_alpha_cookie);
+
return global_alpha;
}
+int MWindowPropertyCache::videoGlobalAlpha()
+{
+ if (!is_valid || video_global_alpha != -1)
+ return video_global_alpha;
+
+ video_global_alpha = alphaValue(xcb_video_global_alpha_cookie);
+ return video_global_alpha;
+}
+
MCompAtoms::Type MWindowPropertyCache::windowType()
{
if (!is_valid || window_type != MCompAtoms::INVALID)
diff --git a/src/mwindowpropertycache.h b/src/mwindowpropertycache.h
index ff0d271..38df81a 100644
--- a/src/mwindowpropertycache.h
+++ b/src/mwindowpropertycache.h
@@ -198,6 +198,7 @@ public:
bool hasAlpha();
bool isDecorator();
int globalAlpha();
+ int videoGlobalAlpha();
bool is_valid;
static void set_xcb_connection(xcb_connection_t *c) {
@@ -205,6 +206,7 @@ public:
}
private:
+ int alphaValue(xcb_get_property_cookie_t c);
void buttonGeometryHelper();
Atom window_type_atom;
@@ -220,6 +222,7 @@ private:
QRectF icon_geometry;
int has_alpha;
int global_alpha;
+ int video_global_alpha;
int is_decorator;
QList<Atom> net_wm_state;
QRect req_geom, real_geom;
@@ -244,6 +247,7 @@ private:
xcb_get_property_cookie_t xcb_wm_hints_cookie;
xcb_get_property_cookie_t xcb_icon_geom_cookie;
xcb_get_property_cookie_t xcb_global_alpha_cookie;
+ xcb_get_property_cookie_t xcb_video_global_alpha_cookie;
xcb_get_property_cookie_t xcb_net_wm_state_cookie;
xcb_render_query_pict_formats_cookie_t xcb_pict_formats_cookie;
xcb_shape_get_rectangles_cookie_t xcb_shape_rects_cookie;