Skip to content

Commit

Permalink
feat(DRegion): add compatibility macro
Browse files Browse the repository at this point in the history
Change-Id: I3bb30235c0c9adfafba331feb451ab38694cd8b2
  • Loading branch information
justforlxz authored and deepin-gerrit committed Dec 27, 2017
1 parent 367d843 commit 49db18a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
11 changes: 11 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,22 @@ DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk
export QT_SELECT = qt5
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

version=$(shell dpkg-query --showformat='$${Version}' --show libdframeworkdbus-dev)
COMPARE_VERSION=$(shell dpkg --compare-versions 0.4.2-1 ge-nl $(version); echo $$?)

%:
dh $@ --parallel

ifeq ($(COMPARE_VERSION), 1)
override_dh_auto_configure:
dh_auto_configure -- LIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH)
endif

ifeq ($(COMPARE_VERSION), 0)
override_dh_auto_configure:
dh_auto_configure -- LIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH) DBUS_VERSION_0_4_2=YES
endif

override_dh_makeshlibs:
dh_makeshlibs -V
4 changes: 4 additions & 0 deletions src/lib.pri
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ isEmpty(INCLUDE_INSTALL_DIR) {
DTK_INCLUDEPATH = $$INCLUDE_INSTALL_DIR/libdtk-$$VERSION
}

isEqual(DBUS_VERSION_0_4_2, YES) {
DEFINES += DBUS_VERSION_0_4_2
}

INSTALLS += includes target

win32* {
Expand Down
9 changes: 6 additions & 3 deletions src/util/dregionmonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ void DRegionMonitor::setWatchedRegion(const QRegion &region)
}

DRegionMonitorPrivate::DRegionMonitorPrivate(DRegionMonitor *q)
: DObjectPrivate(q),

eventInter(new XEventMonitor("com.deepin.api.XEventMonitor", "/com/deepin/api/XEventMonitor", QDBusConnection::sessionBus()))
: DObjectPrivate(q)
#ifndef DBUS_VERSION_0_4_2
, eventInter(new XEventMonitor("com.deepin.api.XEventMonitor", "/com/deepin/api/XEventMonitor", QDBusConnection::sessionBus()))
#else
, eventInter(new XMousAreaInter("com.deepin.api.XMouseArea", "/com/deepin/api/XMouseArea", QDBusConnection::sessionBus()))
#endif
{
}

Expand Down
14 changes: 13 additions & 1 deletion src/util/private/dregionmonitor_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@
#include <QRegion>
#include <QScreen>

#ifndef DBUS_VERSION_0_4_2
#include <com_deepin_api_xeventmonitor.h>
#else
#include <com_deepin_api_xmousearea.h>
#endif

DCORE_USE_NAMESPACE
DWIDGET_BEGIN_NAMESPACE

using XEventMonitor = com::deepin::api::XEventMonitor;
#ifndef DBUS_VERSION_0_4_2
using XEventMonitor = ::com::deepin::api::XEventMonitor;
#else
using XMousAreaInter = ::com::deepin::api::XMouseArea;
#endif

class DRegionMonitorPrivate : public DObjectPrivate
{
Expand Down Expand Up @@ -43,7 +51,11 @@ class DRegionMonitorPrivate : public DObjectPrivate

const QPoint deviceScaledCoordinate(const QPoint &p, const double ratio) const;

#ifndef DBUS_VERSION_0_4_2
XEventMonitor *eventInter;
#else
XMousAreaInter *eventInter;
#endif
QRegion watchedRegion;
QString registerKey;
};
Expand Down

0 comments on commit 49db18a

Please sign in to comment.