Skip to content

Commit

Permalink
Fixes: NB#289336 - time is not in sync on status bar with lock screen
Browse files Browse the repository at this point in the history
Bug: NB#289336 - time is not in sync on status bar with lock screen
RevBy: Artem Egorkine
Details: Qt didn't forward the PropertyNotify in some cases since it didn't find any widget with a matching window ID. This patch creates such a widget.
  • Loading branch information
Vesa Halttunen committed Nov 21, 2011
1 parent ffa8bd8 commit 0992023
Show file tree
Hide file tree
Showing 13 changed files with 342 additions and 3 deletions.
1 change: 1 addition & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
system-ui (1.2.19~1) unstable; urgency=low

* [UNRELEASED]
* Fixes: NB#289336 - time is not in sync on status bar with lock screen

-- Vesa Halttunen <[email protected]> Fri, 18 Nov 2011 15:16:16 +0200

Expand Down
15 changes: 13 additions & 2 deletions src/systemui/statusarea/statusarearenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
**
****************************************************************************/

#include <QDebug>
#include "statusarearenderer.h"
#include "xeventlistenerwidget.h"
#include <MStyle>
#include "statusareastyle.h"
#include <QMeeGoLivePixmap>
Expand All @@ -39,6 +39,7 @@ StatusAreaRenderer::StatusAreaRenderer(QObject *parent) :
statusAreaLivePixmap(NULL),
statusAreaPropertyWindow(0),
windowManagerWindow(0),
windowManagerWindowWidget(NULL),
statusBarVisible(false),
#ifdef HAVE_QMSYSTEM
displayState(new MeeGo::QmDisplayState()),
Expand Down Expand Up @@ -74,7 +75,7 @@ StatusAreaRenderer::StatusAreaRenderer(QObject *parent) :

setSizeFromStyle();
if(!createSharedPixmapHandle() || !createBackPixmap()) {
qWarning() << "Shared Pixmap was not created. Status area will not render";
qWarning("Shared Pixmap was not created. Status area will not render");
} else {
createStatusAreaPropertyWindow();
setSharedPixmapHandleToWindowProperty();
Expand Down Expand Up @@ -228,6 +229,8 @@ StatusAreaRenderer::~StatusAreaRenderer()
}
}

delete windowManagerWindowWidget;

#ifdef HAVE_QMSYSTEM
delete displayState;
#endif
Expand Down Expand Up @@ -291,6 +294,8 @@ bool StatusAreaRenderer::setupStatusBarVisibleListener()
uchar *data = 0;

windowManagerWindow = 0;
delete windowManagerWindowWidget;
windowManagerWindowWidget = NULL;
if (X11Wrapper::XGetWindowProperty(QX11Info::display(), QX11Info::appRootWindow(), windowManagerWindowAtom,
0, 1024, False, XA_WINDOW, &type, &format, &length, &after, &data) == Success) {
if (type == XA_WINDOW && format == 32) {
Expand All @@ -315,6 +320,10 @@ bool StatusAreaRenderer::setupStatusBarVisibleListener()
}
}

if (windowManagerWindow != 0) {
windowManagerWindowWidget = new XEventListenerWidget(NULL, windowManagerWindow);
}

return (windowManagerWindow != 0);
}

Expand Down Expand Up @@ -400,6 +409,8 @@ void StatusAreaRenderer::stopTrackingRootWindowProperties()
void StatusAreaRenderer::wmWindowUnavailable()
{
windowManagerWindow = 0;
delete windowManagerWindowWidget;
windowManagerWindowWidget = NULL;

// Assume status bar is visible when WM window is not available
statusBarVisible = true;
Expand Down
2 changes: 2 additions & 0 deletions src/systemui/statusarea/statusarearenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ private slots:
Window statusAreaPropertyWindow;
//! Window id of the window manager window
Window windowManagerWindow;
//! Widget representing the window manager window
QWidget *windowManagerWindowWidget;

//! Status Area dimensions.
uint statusAreaHeight;
Expand Down
2 changes: 2 additions & 0 deletions src/systemui/systemui.pro
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ HEADERS += \
applicationcontext.h \
x11wrapper.h \
xeventlistener.h \
xeventlistenerwidget.h \
diskspacenotifier.h

SOURCES += \
Expand All @@ -57,6 +58,7 @@ SOURCES += \
contextframeworkcontext.cpp \
x11wrapper.cpp \
xeventlistener.cpp \
xeventlistenerwidget.cpp \
diskspacenotifier.cpp

include(statusindicatormenu/statusindicatormenu.pri)
Expand Down
37 changes: 37 additions & 0 deletions src/systemui/xeventlistenerwidget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation ([email protected])
**
** This file is part of systemui.
**
** If you have questions regarding the use of this file, please contact
** Nokia at [email protected].
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/

#include "xeventlistenerwidget.h"
#include "xeventlistener.h"

XEventListenerWidget::XEventListenerWidget(QWidget *parent, Window id) :
QWidget(parent)
{
create(id, false, false);
}

XEventListenerWidget::~XEventListenerWidget()
{
destroy(false, false);
}

bool XEventListenerWidget::x11Event(XEvent *event)
{
return XEventListener::xEventFilter(event);
}
57 changes: 57 additions & 0 deletions src/systemui/xeventlistenerwidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation ([email protected])
**
** This file is part of systemui.
**
** If you have questions regarding the use of this file, please contact
** Nokia at [email protected].
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/

#ifndef XEVENTLISTENERWIDGET_H_
#define XEVENTLISTENERWIDGET_H_

#include <QWidget>
#include <X11/Xlib.h>

/*!
* A QWidget which listens to the X events of the given window and relays them
* to the XEventListener.
*/
class XEventListenerWidget : public QWidget {
Q_OBJECT

public:
/*!
* Creates an XEventListenerWidget.
*
* \param parent the parent widget for the widget
* \param id the ID of the X window for the window to be represented by this widget
*/
XEventListenerWidget(QWidget *parent, Window id);

/*!
* Destroys the XEventListenerWidget.
*/
~XEventListenerWidget();

protected:
//! \reimp
virtual bool x11Event(XEvent *event);
//! \reimp_end

#ifdef UNIT_TEST
friend class Ut_XEventListenerWidget;
#endif
};

#endif /* XEVENTLISTENERWIDGET_H_ */
72 changes: 72 additions & 0 deletions tests/stubs/xeventlistenerwidget_stub.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation ([email protected])
**
** This file is part of mhome.
**
** If you have questions regarding the use of this file, please contact
** Nokia at [email protected].
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/
#ifndef XEVENTLISTENERWIDGET_STUB
#define XEVENTLISTENERWIDGET_STUB

#include "xeventlistenerwidget.h"
#include <stubbase.h>


// 1. DECLARE STUB
// FIXME - stubgen is not yet finished
class XEventListenerWidgetStub : public StubBase {
public:
virtual void XEventListenerWidgetConstructor(QWidget *parent, Window id);
virtual void XEventListenerWidgetDestructor();
virtual bool x11Event(XEvent *event);
};

// 2. IMPLEMENT STUB
void XEventListenerWidgetStub::XEventListenerWidgetConstructor(QWidget *parent, Window id) {
Q_UNUSED(parent);
Q_UNUSED(id);

}
void XEventListenerWidgetStub::XEventListenerWidgetDestructor() {

}
bool XEventListenerWidgetStub::x11Event(XEvent *event) {
QList<ParameterBase*> params;
params.append( new Parameter<XEvent * >(event));
stubMethodEntered("x11Event",params);
return stubReturnValue<bool>("x11Event");
}



// 3. CREATE A STUB INSTANCE
XEventListenerWidgetStub gDefaultXEventListenerWidgetStub;
XEventListenerWidgetStub* gXEventListenerWidgetStub = &gDefaultXEventListenerWidgetStub;


// 4. CREATE A PROXY WHICH CALLS THE STUB
XEventListenerWidget::XEventListenerWidget(QWidget *parent, Window id) {
gXEventListenerWidgetStub->XEventListenerWidgetConstructor(parent, id);
}

XEventListenerWidget::~XEventListenerWidget() {
gXEventListenerWidgetStub->XEventListenerWidgetDestructor();
}

bool XEventListenerWidget::x11Event(XEvent *event) {
return gXEventListenerWidgetStub->x11Event(event);
}


#endif
1 change: 1 addition & 0 deletions tests/ut_statusarearenderer/ut_statusarearenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "x11wrapper_modified_stub.h"
#include <QX11Info>
#include "xeventlistener_stub.h"
#include "xeventlistenerwidget_stub.h"

#define ROOT_WINDOW_ID (QX11Info::appRootWindow())
const static Window MEEGOTOUCH_STATUSBAR_WINDOW_ID = 1;
Expand Down
3 changes: 2 additions & 1 deletion tests/ut_statusarearenderer/ut_statusarearenderer.pro
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ HEADERS += \
$$SRCDIR/statusarea/statusarearenderer.h \
$$SRCDIR/statusarea/statusarea.h \
$$SRCDIR/x11wrapper.h \
$$SRCDIR/xeventlistener.h
$$SRCDIR/xeventlistener.h \
$$SRCDIR/xeventlistenerwidget.h

include(../common_bot.pri)
1 change: 1 addition & 0 deletions tests/ut_xeventlistenerwidget/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ut_xeventlistenerwidget
99 changes: 99 additions & 0 deletions tests/ut_xeventlistenerwidget/ut_xeventlistenerwidget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation ([email protected])
**
** This file is part of systemui.
**
** If you have questions regarding the use of this file, please contact
** Nokia at [email protected].
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/

#include <QtTest/QtTest>
#include <QX11Info>
#include "xeventlistenerwidget.h"
#include "xeventlistener_stub.h"
#include "ut_xeventlistenerwidget.h"

WId qWidgetCreateWindow = 0;
bool qWidgetCreateInitializeWindow = true;
bool qWidgetCreateDestroyOldWindow = true;
void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow)
{
qWidgetCreateWindow = window;
qWidgetCreateInitializeWindow = initializeWindow;
qWidgetCreateDestroyOldWindow = destroyOldWindow;
}

bool qWidgetDestroyDestroyWindow = true;
bool qWidgetDestroyDestroySubWindows = true;
void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
{
qWidgetDestroyDestroyWindow = destroyWindow;
qWidgetDestroyDestroySubWindows = destroySubWindows;
}

void Ut_XEventListenerWidget::init()
{
}

void Ut_XEventListenerWidget::cleanup()
{
gXEventListenerStub->stubReset();
qWidgetCreateWindow = 0;
qWidgetCreateInitializeWindow = true;
qWidgetCreateDestroyOldWindow = true;
qWidgetDestroyDestroyWindow = true;
qWidgetDestroyDestroySubWindows = true;
}

void Ut_XEventListenerWidget::initTestCase()
{
}

void Ut_XEventListenerWidget::cleanupTestCase()
{
}

void Ut_XEventListenerWidget::testConstructionAndDestruction()
{
Qt::HANDLE window = QX11Info::appRootWindow(QX11Info::appScreen());
XEventListenerWidget *widget = new XEventListenerWidget(NULL, window);
QCOMPARE(qWidgetCreateWindow, (WId)window);
QCOMPARE(qWidgetCreateInitializeWindow, false);
QCOMPARE(qWidgetCreateDestroyOldWindow, false);

delete widget;
QCOMPARE(qWidgetDestroyDestroyWindow, false);
QCOMPARE(qWidgetDestroyDestroySubWindows, false);
}

void Ut_XEventListenerWidget::testX11Event_data()
{
QTest::addColumn<bool>("returnValue");

QTest::newRow("Return true") << true;
QTest::newRow("Return false") << false;
}

void Ut_XEventListenerWidget::testX11Event()
{
QFETCH(bool, returnValue);

gXEventListenerStub->stubSetReturnValue("xEventFilter", returnValue);
XEventListenerWidget widget(NULL, 0);
XEvent event;
QCOMPARE(widget.x11Event(&event), returnValue);
QCOMPARE(gXEventListenerStub->stubCallCount("xEventFilter"), 1);
QCOMPARE(gXEventListenerStub->stubLastCallTo("xEventFilter").parameter<void *>(0), &event);
}

QTEST_MAIN(Ut_XEventListenerWidget)
Loading

0 comments on commit 0992023

Please sign in to comment.