Bugfix/resolution change event Fixes part of #620 (#867)

* Detect resolution changes

* include Qt5Widgets

* find Qt5Widgets

Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
This commit is contained in:
Murat Seker 2020-07-12 09:23:13 +02:00 committed by GitHub
parent 22ace55447
commit c32a4df587
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 55 additions and 10 deletions

View File

@ -40,7 +40,7 @@ wget -qN https://raw.github.com/hyperion-project/hyperion.ng/master/bin/scripts/
```
sudo apt-get update
sudo apt-get install git cmake build-essential qtbase5-dev libqt5serialport5-dev libusb-1.0-0-dev python3-dev libxrender-dev libavahi-core-dev libavahi-compat-libdnssd-dev libjpeg-dev libturbojpeg0-dev libqt5sql5-sqlite libssl-dev zlib1g-dev
sudo apt-get install git cmake build-essential qtbase5-dev libqt5serialport5-dev libusb-1.0-0-dev python3-dev libxcb-util0-dev libxcb-randr0-dev libxrandr-dev libxrender-dev libavahi-core-dev libavahi-compat-libdnssd-dev libjpeg-dev libturbojpeg0-dev libqt5sql5-sqlite libssl-dev zlib1g-dev
```
**on RPI you need the videocore IV headers**

View File

@ -4,14 +4,14 @@ Use a clean Raspbian Stretch Lite (on target) and Ubuntu 18/19 (on host) to exec
## On the Target system (here Raspberry Pi)
Install required additional packages.
```
sudo apt-get install qtbase5-dev libqt5serialport5-dev libusb-1.0-0-dev python3-dev libxrender-dev libavahi-core-dev libavahi-compat-libdnssd-dev libjpeg-dev libturbojpeg0-dev libqt5sql5-sqlite aptitude qt5-default rsync libssl-dev zlib1g-dev
sudo apt-get install qtbase5-dev libqt5serialport5-dev libusb-1.0-0-dev python3-dev libxcb-util0-dev libxcb-randr0-dev libxrandr-dev libxrender-dev libavahi-core-dev libavahi-compat-libdnssd-dev libjpeg-dev libturbojpeg0-dev libqt5sql5-sqlite aptitude qt5-default rsync libssl-dev zlib1g-dev
```
## On the Host system (here Ubuntu)
Update the Ubuntu environment to the latest stage and install required additional packages.
```
sudo apt-get update
sudo apt-get upgrade
sudo apt-get -qq -y install git rsync cmake build-essential qtbase5-dev libqt5serialport5-dev libusb-1.0-0-dev python3-dev libxrender-dev libavahi-core-dev libavahi-compat-libdnssd-dev libjpeg-dev libturbojpeg0-dev libqt5sql5-sqlite libssl-dev zlib1g-dev
sudo apt-get -qq -y install git rsync cmake build-essential qtbase5-dev libqt5serialport5-dev libusb-1.0-0-dev python3-dev libxcb-util0-dev libxcb-randr0-dev libxrandr-dev libxrender-dev libavahi-core-dev libavahi-compat-libdnssd-dev libjpeg-dev libturbojpeg0-dev libqt5sql5-sqlite libssl-dev zlib1g-dev
```
Refine the target IP or hostname, plus userID as required and set-up cross-compilation environment:

View File

@ -5,7 +5,7 @@ CFG="${2:-Release}"
INST="$( [ "${3:-}" = "install" ] && echo true || echo false )"
sudo apt-get update
sudo apt-get install git cmake build-essential qtbase5-dev libqt5serialport5-dev libusb-1.0-0-dev libturbojpeg0-dev python3-dev libxrender-dev libavahi-core-dev libavahi-compat-libdnssd-dev libssl-dev libjpeg-dev libqt5sql5-sqlite zlib1g-dev || exit 1
sudo apt-get install git cmake build-essential qtbase5-dev libqt5serialport5-dev libusb-1.0-0-dev libturbojpeg0-dev python3-dev libxcb-util0-dev libxcb-randr0-dev libxrandr-dev libxrender-dev libavahi-core-dev libavahi-compat-libdnssd-dev libssl-dev libjpeg-dev libqt5sql5-sqlite zlib1g-dev || exit 1
if [ -e /dev/vc-cma -a -e /dev/vc-mem ]
then

View File

@ -18,8 +18,11 @@ tar --create --verbose --gzip --absolute-names --show-transformed-names --derefe
"$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libX11.so.6" \
"$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libXau.so.6" \
"$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libxcb.so.1" \
"$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libxcb-util.so" \
"$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libxcb-randr.so" \
"$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libXdmcp.so.6" \
"$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libXext.so.6" \
"$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libXrandr.so.2" \
"$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libXrender.so.1" \
"$IMX6_ROOTFS/usr/lib/arm-linux-gnueabihf/libXt.so.6" \
"./openelec/hyperiond.sh" \

View File

@ -1,5 +1,7 @@
#pragma once
#include <QAbstractEventDispatcher>
#include <QAbstractNativeEventFilter>
#include <QCoreApplication>
#include <QObject>
// Hyperion-utils includes
@ -8,12 +10,13 @@
// X11 includes
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
#include <X11/extensions/Xrender.h>
#include <X11/extensions/XShm.h>
#include <sys/ipc.h>
#include <sys/shm.h>
class X11Grabber : public Grabber
class X11Grabber : public Grabber , public QAbstractNativeEventFilter
{
public:
@ -58,8 +61,11 @@ public:
///
virtual void setCropping(unsigned cropLeft, unsigned cropRight, unsigned cropTop, unsigned cropBottom);
protected:
bool nativeEventFilter(const QByteArray & eventType, void * message, long int * result) override;
private:
bool _XShmAvailable, _XShmPixmapAvailable, _XRenderAvailable;
bool _XShmAvailable, _XShmPixmapAvailable, _XRenderAvailable, _XRandRAvailable;
XImage* _xImage;
XShmSegmentInfo _shminfo;
@ -76,6 +82,8 @@ private:
Picture _srcPicture;
Picture _dstPicture;
int _XRandREventBase;
XTransform _transform;
int _pixelDecimation;

View File

@ -4,6 +4,7 @@ SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/x11)
# Find X11
find_package(X11 REQUIRED)
find_package(Qt5Widgets REQUIRED)
include_directories( ${X11_INCLUDES} )
@ -18,5 +19,7 @@ add_library(x11-grabber ${X11_SOURCES} )
target_link_libraries(x11-grabber
hyperion
${X11_LIBRARIES}
${X11_Xrandr_LIB}
${X11_Xrender_LIB}
Qt5::Widgets
)

View File

@ -1,6 +1,9 @@
#include <utils/Logger.h>
#include <grabber/X11Grabber.h>
#include <xcb/randr.h>
#include <xcb/xcb_event.h>
X11Grabber::X11Grabber(int cropLeft, int cropRight, int cropTop, int cropBottom, int pixelDecimation)
: Grabber("X11GRABBER", 0, 0, cropLeft, cropRight, cropTop, cropBottom)
, _x11Display(nullptr)
@ -35,6 +38,10 @@ void X11Grabber::freeResources()
{
// Cleanup allocated resources of the X11 grab
XDestroyImage(_xImage);
if (_XRandRAvailable)
{
qApp->removeNativeEventFilter(this);
}
if(_XShmAvailable)
{
XShmDetach(_x11Display, &_shminfo);
@ -51,6 +58,11 @@ void X11Grabber::freeResources()
void X11Grabber::setupResources()
{
if (_XRandRAvailable)
{
qApp->installNativeEventFilter(this);
}
if(_XShmAvailable)
{
_xImage = XShmCreateImage(_x11Display, _windowAttr.visual, _windowAttr.depth, ZPixmap, NULL, &_shminfo, _width, _height);
@ -99,6 +111,7 @@ bool X11Grabber::Setup()
int dummy, pixmaps_supported;
_XRandRAvailable = XRRQueryExtension(_x11Display, &_XRandREventBase, &dummy);
_XRenderAvailable = XRenderQueryExtension(_x11Display, &dummy, &dummy);
_XShmAvailable = XShmQueryExtension(_x11Display);
XShmQueryVersion(_x11Display, &dummy, &dummy, &pixmaps_supported);
@ -293,3 +306,20 @@ void X11Grabber::setCropping(unsigned cropLeft, unsigned cropRight, unsigned cro
Grabber::setCropping(cropLeft, cropRight, cropTop, cropBottom);
if(_x11Display != nullptr) updateScreenDimensions(true); // segfault on init
}
bool X11Grabber::nativeEventFilter(const QByteArray & eventType, void * message, long int * /*result*/)
{
if (!_XRandRAvailable || eventType != "xcb_generic_event_t") {
return false;
}
xcb_generic_event_t *e = static_cast<xcb_generic_event_t*>(message);
const uint8_t xEventType = XCB_EVENT_RESPONSE_TYPE(e);
if (xEventType == _XRandREventBase + XCB_RANDR_SCREEN_CHANGE_NOTIFY)
{
updateScreenDimensions(true);
}
return false;
}

View File

@ -36,10 +36,12 @@ target_link_libraries(${PROJECT_NAME}
x11-grabber
ssdp
${X11_LIBRARIES}
${X11_Xrandr_LIB}
${X11_Xrender_LIB}
Qt5::Core
Qt5::Gui
Qt5::Network
Qt5::Widgets
)
install ( TARGETS ${PROJECT_NAME} DESTINATION "share/hyperion/bin" COMPONENT "hyperion_x11" )

View File

@ -1,6 +1,6 @@
// QT includes
#include <QCoreApplication>
#include <QApplication>
#include <QImage>
#include <commandline/Parser.h>
@ -28,8 +28,7 @@ int main(int argc, char ** argv)
<< "\tVersion : " << HYPERION_VERSION << " (" << HYPERION_BUILD_ID << ")" << std::endl
<< "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl;
QCoreApplication app(argc, argv);
QApplication app(argc, argv);
try
{
// create the option parser and initialize all parameters