[-]
[+]
|
Changed |
libkscreen.spec
|
|
[-]
[+]
|
Deleted |
libkscreen-5.2.0.tar.xz/backends/xrandr/xlibandxrandr.h
^
|
@@ -1,36 +0,0 @@
-/*************************************************************************************
- * Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> *
- * *
- * This library is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * This library is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this library; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
- *************************************************************************************/
-
-#ifndef XLIBANDXRANDR_H
-#define XLIBANDXRANDR_H
-
-extern "C"
-{
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#define INT8 _X11INT8
-#define INT32 _X11INT32
-#include <X11/Xproto.h>
-#undef INT8
-#undef INT32
-#include <X11/extensions/Xrandr.h>
-}
-
-#include "../xrandr1.1/fixx11h.h"
-
-#endif // XLIBANDXRANDR
|
[-]
[+]
|
Deleted |
libkscreen-5.2.0.tar.xz/backends/xrandr/xrandrxcbhelper.cpp
^
|
@@ -1,272 +0,0 @@
-/*************************************************************************************
- * Copyright 2012, 2013 Daniel Vrátil <dvratil@redhat.com> *
- * *
- * This library is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * This library is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this library; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
- *************************************************************************************/
-
-#include "xrandrxcbhelper.h"
-#include "xrandr.h"
-#include "xlibandxrandr.h"
-
-#include <xcb/randr.h>
-
-#include <QX11Info>
-#include <QGuiApplication>
-
-Q_LOGGING_CATEGORY(KSCREEN_XCB_HELPER, "kscreen.xcb.helper")
-XRandRXCBHelper::XRandRXCBHelper():
- QObject(),
- m_isRandrPresent(false),
- m_event11(false),
- m_randrBase(0),
- m_randrErrorBase(0),
- m_majorOpcode(0),
- m_eventType(0),
- m_versionMajor(0),
- m_versionMinor(0),
- m_window(0)
-{
- QLoggingCategory::setFilterRules(QStringLiteral("kscreen.xcb.helper = true"));
-
- xcb_connection_t* c = QX11Info::connection();
- xcb_prefetch_extension_data(c, &xcb_randr_id);
- xcb_randr_query_version_cookie_t cookie = xcb_randr_query_version(c,
- XCB_RANDR_MAJOR_VERSION,
- XCB_RANDR_MINOR_VERSION
- );
- const xcb_query_extension_reply_t *queryExtension = xcb_get_extension_data(c, &xcb_randr_id);
- if (!queryExtension) {
- qCDebug(KSCREEN_XCB_HELPER) << "Fail to query for xrandr extension";
- return;
- }
- if (!queryExtension->present) {
- qCDebug(KSCREEN_XCB_HELPER) << "XRandR extension is not present at all";
- return;
- }
-
- m_isRandrPresent = queryExtension->present;
- m_randrBase = queryExtension->first_event;
- m_randrErrorBase = queryExtension->first_error;
- m_majorOpcode = queryExtension->major_opcode;
-
- xcb_generic_error_t *error = NULL;
- xcb_randr_query_version_reply_t* versionReply = xcb_randr_query_version_reply(c, cookie, &error);
- Q_ASSERT_X(versionReply, "xrandrxcbhelper", "Query to fetch xrandr version failed");
- if (error) {
- qFatal("Error while querying for xrandr version: %d", error->error_code);
- }
- m_versionMajor = versionReply->major_version;
- m_versionMinor = versionReply->minor_version;
- free(versionReply);
-
- if (m_versionMajor == 1 && m_versionMinor <= 1) {
- m_event11 = true;
- }
- qCDebug(KSCREEN_XCB_HELPER).nospace() << "Detected XRandR " << m_versionMajor << "." << m_versionMinor;
- qCDebug(KSCREEN_XCB_HELPER) << "Event Base: " << m_randrBase;
- qCDebug(KSCREEN_XCB_HELPER) << "Event Error: "<< m_randrErrorBase;
-
- uint32_t rWindow = QX11Info::appRootWindow();
- m_window = xcb_generate_id(c);
- xcb_create_window(c, XCB_COPY_FROM_PARENT, m_window,
- rWindow,
- 0, 0, 1, 1, 0, XCB_COPY_FROM_PARENT,
- XCB_COPY_FROM_PARENT, 0, NULL);
-
- xcb_randr_select_input(c, m_window,
- XCB_RANDR_NOTIFY_MASK_SCREEN_CHANGE |
- XCB_RANDR_NOTIFY_MASK_OUTPUT_CHANGE |
- XCB_RANDR_NOTIFY_MASK_CRTC_CHANGE |
- XCB_RANDR_NOTIFY_MASK_OUTPUT_PROPERTY
- );
-
- qApp->installNativeEventFilter(this);
-}
-
-XRandRXCBHelper::~XRandRXCBHelper()
-{
- if (m_window && QX11Info::connection()) {
- xcb_destroy_window(QX11Info::connection(), m_window);
- }
-}
-
-QString XRandRXCBHelper::rotationToString(Rotation rotation)
-{
- switch (rotation) {
- case RR_Rotate_0:
- return "RR_Rotate_0";
- case RR_Rotate_90:
- return "RR_Rotate_90";
- case RR_Rotate_180:
- return "RR_Rotate_180";
- case RR_Rotate_270:
- return "RR_Rotate_270";
- }
-
- return QString("invalid value (%1)").arg(rotation);
-}
-
-QString XRandRXCBHelper::connectionToString(Connection connection)
-{
- switch (connection) {
- case RR_Connected:
- return "RR_Connected";
- case RR_Disconnected:
- return "RR_Disconnected";
- case RR_UnknownConnection:
- return "RR_UnknownConnection";
- }
-
- return QString("invalid value (%1)").arg(connection);
-}
-
-bool XRandRXCBHelper::nativeEventFilter(const QByteArray& eventType, void* message, long int* result)
-{
- Q_UNUSED(result);
-
- if (eventType != "xcb_generic_event_t") {
- return false;
- }
-
- xcb_generic_event_t* e = static_cast<xcb_generic_event_t *>(message);
- const uint8_t xEventType = e->response_type & ~0x80;
-
- //If this event is not xcb_randr_notify, we don't want it
- if (xEventType == m_randrBase + XCB_RANDR_SCREEN_CHANGE_NOTIFY && m_event11) {
- handleScreenChange(e);
- }
- if (xEventType == m_randrBase + XCB_RANDR_NOTIFY) {
- handleXRandRNotify(e);
- }
-
- return false;
-}
-
-void XRandRXCBHelper::handleScreenChange(xcb_generic_event_t* e)
-{
- xcb_randr_screen_change_notify_event_t *e2 =
- (xcb_randr_screen_change_notify_event_t *) e;
- qCDebug(KSCREEN_XCB_HELPER) << "Timestamp: " << e2->timestamp;
- qCDebug(KSCREEN_XCB_HELPER) << "Window: " << e2->request_window;
- qCDebug(KSCREEN_XCB_HELPER) << "Root: "<< e2->root;
- qCDebug(KSCREEN_XCB_HELPER) << "Subpixel Order:" << e2->subpixel_order;
- qCDebug(KSCREEN_XCB_HELPER) << "Rotation: " << rotationToString(e2->rotation);
- qCDebug(KSCREEN_XCB_HELPER) << "Size: " << e2->width << e2->height;
- qCDebug(KSCREEN_XCB_HELPER) << "SizeMM: " << e2->mwidth << e2->mheight;
-
- Q_EMIT outputsChanged();
-}
-
-void XRandRXCBHelper::handleXRandRNotify(xcb_generic_event_t* e)
-{
- xcb_randr_notify_event_t*
- randrEvent = reinterpret_cast<xcb_randr_notify_event_t*>(e);
-
- if (randrEvent->subCode == XCB_RANDR_NOTIFY_CRTC_CHANGE) {
- xcb_randr_crtc_change_t crtc = randrEvent->u.cc;
- qCDebug(KSCREEN_XCB_HELPER) << "CRTC CHANGE";
- qCDebug(KSCREEN_XCB_HELPER) << "CRTC: " << crtc.crtc;
- qCDebug(KSCREEN_XCB_HELPER) << "Mode: " << crtc.mode;
- qCDebug(KSCREEN_XCB_HELPER) << "Rotation: " << rotationToString(crtc.rotation);
- qCDebug(KSCREEN_XCB_HELPER) << "Geometry: " << crtc.x << crtc.y << crtc.width << crtc.height;
-
- Q_EMIT crtcChanged(crtc.crtc);
- } else if(randrEvent->subCode == XCB_RANDR_NOTIFY_OUTPUT_CHANGE) {
- xcb_randr_output_change_t output = randrEvent->u.oc;
- qCDebug(KSCREEN_XCB_HELPER) << "OUTPUT CHANGE";
- qCDebug(KSCREEN_XCB_HELPER) << "Output: " << output.output;
- qCDebug(KSCREEN_XCB_HELPER) << "CRTC: " << output.crtc;
- qCDebug(KSCREEN_XCB_HELPER) << "Mode: " << output.mode;
- qCDebug(KSCREEN_XCB_HELPER) << "Rotation: " << rotationToString(output.rotation);
- qCDebug(KSCREEN_XCB_HELPER) << "Connection: " << connectionToString(output.connection);
- qCDebug(KSCREEN_XCB_HELPER) << "Subpixel Order: " << output.subpixel_order;
-
- Q_EMIT outputChanged(output.output);
- } else if(randrEvent->subCode == XCB_RANDR_NOTIFY_OUTPUT_PROPERTY) {
- xcb_randr_output_property_t property = randrEvent->u.op;
-
|
[-]
[+]
|
Deleted |
libkscreen-5.2.0.tar.xz/backends/xrandr/xrandrxcbhelper.h
^
|
@@ -1,81 +0,0 @@
-/*************************************************************************************
- * Copyright 2012, 2013 Daniel Vrátil <dvratil@redhat.com> *
- * *
- * This library is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * This library is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this library; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
- *************************************************************************************/
-
-#ifndef XRANDRX11HELPER_H
-#define XRANDRX11HELPER_H
-
-#include <xcb/xcb.h>
-#include <QObject>
-#include <QLoggingCategory>
-#include <QAbstractNativeEventFilter>
-
-#include "xlibandxrandr.h"
-
-class XRandRXCBHelper : public QObject, public QAbstractNativeEventFilter
-{
- Q_OBJECT
-
- public:
- XRandRXCBHelper();
- virtual ~XRandRXCBHelper();
-
- virtual bool nativeEventFilter(const QByteArray& eventType, void* message, long int* result) Q_DECL_OVERRIDE;
- Q_SIGNALS:
- /* Emitted when only XRandR 1.1 or older is available */
- void outputsChanged();
-
- /* Emitted only when XRandR 1.2 or newer is available */
- void crtcChanged(RRCrtc crtc);
- void outputChanged(RROutput output);
- void outputPropertyChanged(RROutput output);
-
- private:
- QString rotationToString(Rotation rotation);
- QString connectionToString(Connection connection);
- void handleScreenChange(xcb_generic_event_t *e);
- void handleXRandRNotify(xcb_generic_event_t *e);
- inline xcb_window_t rootWindow(xcb_connection_t *c, int screen)
- {
- xcb_screen_iterator_t iter = xcb_setup_roots_iterator(xcb_get_setup(c));
- for (xcb_screen_iterator_t it = xcb_setup_roots_iterator(xcb_get_setup(c));
- it.rem;
- --screen, xcb_screen_next(&it)) {
- if (screen == 0) {
- return iter.data->root;
- }
- }
- return XCB_WINDOW_NONE;
- }
-
- protected:
- virtual bool x11Event(XEvent *);
-
- bool m_isRandrPresent;
- bool m_event11;
- int m_randrBase;
- int m_randrErrorBase;
- int m_majorOpcode;
- int m_eventType;
- int m_versionMajor;
- int m_versionMinor;
-
- uint32_t m_window;
-};
-
-Q_DECLARE_LOGGING_CATEGORY(KSCREEN_XCB_HELPER)
-#endif // XRANDRX11HELPER_H
|
[-]
[+]
|
Deleted |
libkscreen-5.2.0.tar.xz/backends/xrandr1.1/fixx11h.h
^
|
@@ -1,301 +0,0 @@
-/****************************************************************************
-
- Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-the rights to use, copy, modify, merge, publish, distribute, sublicense,
-and/or sell copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
-
-****************************************************************************/
-
-//#ifdef don't do this, this file is supposed to be included
-//#define multiple times
-
-#include <QtCore/QtGlobal>
-
-/* Usage:
-
- If you get compile errors caused by X11 includes (the line
- where first error appears contains word like None, Unsorted,
- Below, etc.), put #include <fixx11h.h> in the .cpp file
- (not .h file!) between the place where X11 headers are
- included and the place where the file with compile
- error is included (or the place where the compile error
- in the .cpp file occurs).
-
- This file remaps X11 #defines to const variables or
- inline functions. The side effect may be that these
- symbols may now refer to different variables
- (e.g. if X11 #defined NoButton, after this file
- is included NoButton would no longer be X11's
- NoButton, but Qt::NoButton instead). At this time,
- there's no conflict known that could cause problems.
-
- The original X11 symbols are still accessible
- (e.g. for None) as X::None, XNone, and also still
- None, unless name lookup finds different None
- first (in the current class, etc.)
-
- Use 'Unsorted', 'Bool' and 'index' as templates.
-
-*/
-
-namespace X
-{
-
-// template --->
-// Affects: Should be without side effects.
-#ifdef Unsorted
-#ifndef FIXX11H_Unsorted
-#define FIXX11H_Unsorted
-const int XUnsorted = Unsorted;
-#undef Unsorted
-const int Unsorted = XUnsorted;
-#endif
-#undef Unsorted
-#endif
-// template <---
-
-// Affects: Should be without side effects.
-#ifdef None
-#ifndef FIXX11H_None
-#define FIXX11H_None
-const XID XNone = None;
-#undef None
-const XID None = XNone;
-#endif
-#undef None
-#endif
-
-// template --->
-// Affects: Should be without side effects.
-#ifdef Bool
-#ifndef FIXX11H_Bool
-#define FIXX11H_Bool
-#ifdef _XTYPEDEF_BOOL /* Xdefs.h has typedef'ed Bool already */
-#undef Bool
-#else
-typedef Bool XBool;
-#undef Bool
-typedef XBool Bool;
-#endif
-#endif
-#undef Bool
-#define _XTYPEDEF_BOOL
-#endif
-// template <---
-
-// Affects: Should be without side effects.
-#ifdef KeyPress
-#ifndef FIXX11H_KeyPress
-#define FIXX11H_KeyPress
-const int XKeyPress = KeyPress;
-#undef KeyPress
-const int KeyPress = XKeyPress;
-#endif
-#undef KeyPress
-#endif
-
-// Affects: Should be without side effects.
-#ifdef KeyRelease
-#ifndef FIXX11H_KeyRelease
-#define FIXX11H_KeyRelease
-const int XKeyRelease = KeyRelease;
-#undef KeyRelease
-const int KeyRelease = XKeyRelease;
-#endif
-#undef KeyRelease
-#endif
-
-// Affects: Should be without side effects.
-#ifdef Above
-#ifndef FIXX11H_Above
-#define FIXX11H_Above
-const int XAbove = Above;
-#undef Above
-const int Above = XAbove;
-#endif
-#undef Above
-#endif
-
-// Affects: Should be without side effects.
-#ifdef Below
-#ifndef FIXX11H_Below
-#define FIXX11H_Below
-const int XBelow = Below;
-#undef Below
-const int Below = XBelow;
-#endif
-#undef Below
-#endif
-
-// Affects: Should be without side effects.
-#ifdef FocusIn
-#ifndef FIXX11H_FocusIn
-#define FIXX11H_FocusIn
-const int XFocusIn = FocusIn;
-#undef FocusIn
-const int FocusIn = XFocusIn;
-#endif
-#undef FocusIn
-#endif
-
-// Affects: Should be without side effects.
-#ifdef FocusOut
-#ifndef FIXX11H_FocusOut
-#define FIXX11H_FocusOut
-const int XFocusOut = FocusOut;
-#undef FocusOut
-const int FocusOut = XFocusOut;
-#endif
-#undef FocusOut
-#endif
-
-// Affects: Should be without side effects.
-#ifdef Always
-#ifndef FIXX11H_Always
-#define FIXX11H_Always
-const int XAlways = Always;
-#undef Always
-const int Always = XAlways;
-#endif
-#undef Always
-#endif
-
-// Affects: Should be without side effects.
-#ifdef Expose
-#ifndef FIXX11H_Expose
-#define FIXX11H_Expose
-const int XExpose = Expose;
-#undef Expose
-const int Expose = XExpose;
-#endif
-#undef Expose
-#endif
-
-// Affects: Should be without side effects.
-#ifdef Success
-#ifndef FIXX11H_Success
-#define FIXX11H_Success
-const int XSuccess = Success;
-#undef Success
-const int Success = XSuccess;
-#endif
-#undef Success
-#endif
|
[-]
[+]
|
Deleted |
libkscreen-5.2.0.tar.xz/backends/xrandr1.1/wrapper.h
^
|
@@ -1,174 +0,0 @@
-/********************************************************************
- K Win - the KDE window manager
- This file is part of the KDE project.
-
-Copyright (C) 2012, 2013 Martin Gräßlin <mgraesslin@kde.org>
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-*********************************************************************/
-
-#include "xlibandxcb.h"
-
-#include <xcb/randr.h>
-#include <QX11Info>
-
-static xcb_connection_t *XRandR11XCBConnection = 0;
-
-xcb_connection_t *connection()
-{
- // Use our own connection to make sure that we won't mess up Qt's connection
- // if something goes wrong on our side.
- if (XRandR11XCBConnection == 0) {
- XRandR11XCBConnection = xcb_connect(0, 0);
- }
- return XRandR11XCBConnection;
-}
-
-void closeConnection()
-{
- xcb_disconnect(XRandR11XCBConnection);
- XRandR11XCBConnection = 0;
-}
-
-xcb_screen_t *screen_of_display (xcb_connection_t *c, int screen)
-{
- xcb_screen_iterator_t iter;
-
- iter = xcb_setup_roots_iterator (xcb_get_setup (c));
- for (; iter.rem; --screen, xcb_screen_next (&iter))
- if (screen == 0)
- return iter.data;
-
- return NULL;
-}
-
-typedef xcb_window_t WindowId;
-
-template <typename Reply,
-typename Cookie,
-Reply *(*replyFunc)(xcb_connection_t*, Cookie, xcb_generic_error_t**),
-Cookie (*requestFunc)(xcb_connection_t*, xcb_window_t)>
-class Wrapper
-{
-public:
- Wrapper()
- : m_retrieved(false)
- , m_window(XCB_WINDOW_NONE)
- , m_reply(NULL)
- {
- m_cookie.sequence = 0;
- }
- explicit Wrapper(WindowId window)
- : m_retrieved(false)
- , m_cookie(requestFunc(connection(), window))
- , m_window(window)
- , m_reply(NULL)
- {
- }
- explicit Wrapper(const Wrapper &other)
- : m_retrieved(other.m_retrieved)
- , m_cookie(other.m_cookie)
- , m_window(other.m_window)
- , m_reply(NULL)
- {
- takeFromOther(const_cast<Wrapper&>(other));
- }
- virtual ~Wrapper() {
- cleanup();
- }
- inline Wrapper &operator=(const Wrapper &other) {
- if (this != &other) {
- // if we had managed a reply, free it
- cleanup();
- // copy members
- m_retrieved = other.m_retrieved;
- m_cookie = other.m_cookie;
- m_window = other.m_window;
- m_reply = other.m_reply;
- // take over the responsibility for the reply pointer
- takeFromOther(const_cast<Wrapper&>(other));
- }
- return *this;
- }
-
- inline const Reply *operator->() const {
- getReply();
- return m_reply;
- }
- inline bool isNull() const {
- getReply();
- return m_reply == NULL;
- }
- inline operator bool() const {
- return !isNull();
- }
- inline const Reply *data() const {
- getReply();
- return m_reply;
- }
- inline WindowId window() const {
- return m_window;
- }
- inline bool isRetrieved() const {
- return m_retrieved;
- }
- /**
- * Returns the value of the reply pointer referenced by this object. The reply pointer of
- * this object will be reset to null. Calling any method which requires the reply to be valid
- * will crash.
- *
- * Callers of this function take ownership of the pointer.
- **/
- inline Reply *take() {
- getReply();
- Reply *ret = m_reply;
- m_reply = NULL;
- m_window = XCB_WINDOW_NONE;
- return ret;
- }
-
-protected:
- void getReply() const {
- if (m_retrieved || !m_cookie.sequence) {
- return;
- }
- m_reply = replyFunc(connection(), m_cookie, NULL);
- m_retrieved = true;
- }
-
-private:
- inline void cleanup() {
- if (!m_retrieved && m_cookie.sequence) {
- xcb_discard_reply(connection(), m_cookie.sequence);
- } else if (m_reply) {
- free(m_reply);
- }
- }
- inline void takeFromOther(Wrapper &other) {
- if (m_retrieved) {
- m_reply = other.take();
- } else {
- //ensure that other object doesn't try to get the reply or discards it in the dtor
- other.m_retrieved = true;
- other.m_window = XCB_WINDOW_NONE;
- }
- }
- mutable bool m_retrieved;
- Cookie m_cookie;
- WindowId m_window;
- mutable Reply *m_reply;
-};
-
-typedef Wrapper<xcb_randr_get_screen_size_range_reply_t, xcb_randr_get_screen_size_range_cookie_t, &xcb_randr_get_screen_size_range_reply, &xcb_randr_get_screen_size_range> ScreenSize;
-typedef Wrapper<xcb_randr_get_screen_info_reply_t, xcb_randr_get_screen_info_cookie_t, &xcb_randr_get_screen_info_reply, &xcb_randr_get_screen_info> ScreenInfo;
|
[-]
[+]
|
Deleted |
libkscreen-5.2.0.tar.xz/backends/xrandr1.1/xlibandxcb.h
^
|
@@ -1,38 +0,0 @@
-/*************************************************************************************
- * Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> *
- * *
- * This library is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * This library is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this library; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
- *************************************************************************************/
-
-#ifndef XLIBANDXCB_H
-#define XLIBANDXCB_H
-
-extern "C"
-{
- #include <X11/Xlib.h>
- #include <X11/Xatom.h>
- #include <X11/Xlib-xcb.h>
- #define INT8 _X11INT8
- #define INT32 _X11INT32
- #include <X11/Xproto.h>
- #undef INT8
- #undef INT32
-
- #include <xcb/xcb.h>
-}
-
-#include "fixx11h.h"
-
-#endif // XLIBANDXCB_H
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/CMakeLists.txt
^
|
@@ -1,9 +1,9 @@
project(libkscreen)
-set(PROJECT_VERSION "5.2.0")
+set(PROJECT_VERSION "5.3.0")
cmake_minimum_required(VERSION 2.8.12)
-find_package(ECM 0.0.11 REQUIRED NO_MODULE)
+find_package(ECM 1.3.0 REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
include(KDEInstallDirs)
include(KDECompilerSettings)
@@ -20,15 +20,8 @@
find_package(XCB COMPONENTS XCB RANDR)
set_package_properties(XCB PROPERTIES
- TYPE OPTIONAL
- PURPOSE "Required for building XRandR 1.1 backend"
-)
-
-find_package(X11)
-set_package_properties(X11 PROPERTIES DESCRIPTION "X11 libraries"
- URL "http://www.x.org"
- TYPE OPTIONAL
- PURPOSE "Required for building XRandR 1.2 backend"
+ TYPE REQUIRED
+ PURPOSE "Required for building XRandR backends"
)
set(KF5_VERSION ${PROJECT_VERSION}) #When we are happy with the api, we can sync with frameworks
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/backends/CMakeLists.txt
^
|
@@ -1,6 +1,4 @@
add_subdirectory(fake)
add_subdirectory(qscreen)
add_subdirectory(xrandr)
-# if (XCB_FOUND AND X11_XCB_FOUND)
- add_subdirectory(xrandr1.1)
-# endif(XCB_FOUND AND X11_XCB_FOUND)
+add_subdirectory(xrandr1.1)
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/backends/fake/fake.cpp
^
|
@@ -173,3 +173,18 @@
output->setRotation(rot);
Q_EMIT configChanged(mConfig);
}
+
+void Fake::addOutput(int outputId, const QString &name)
+{
+ KScreen::OutputPtr output(new KScreen::Output);
+ output->setId(outputId);
+ output->setName(name);
+ mConfig->addOutput(output);
+ Q_EMIT configChanged(mConfig);
+}
+
+void Fake::removeOutput(int outputId)
+{
+ mConfig->removeOutput(outputId);
+ Q_EMIT configChanged(mConfig);
+}
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/backends/fake/fake.h
^
|
@@ -45,6 +45,8 @@
void setPrimary(int outputId, bool primary);
void setCurrentModeId(int outputId, const QString &modeId);
void setRotation(int outputId, int rotation);
+ void addOutput(int outputId, const QString &name);
+ void removeOutput(int outputId);
private Q_SLOTS:
void delayedInit();
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/backends/fake/parser.cpp
^
|
@@ -23,6 +23,8 @@
#include "output.h"
#include <QtCore/QFile>
+#include <QMetaObject>
+#include <QMetaProperty>
#include <QLoggingCategory>
#include <QJsonDocument>
#include <QJsonArray>
@@ -78,21 +80,30 @@
return screen;
}
-void Parser::qvariant2qobject(const QVariantMap& variant, QObject* object)
+void Parser::qvariant2qobject(const QVariantMap &variant, QObject *object)
{
- for ( QVariantMap::const_iterator iter = variant.begin(); iter != variant.end(); ++iter )
- {
- const QVariant property = object->property( iter.key().toLatin1() );
- Q_ASSERT( property.isValid() );
- if ( property.isValid() )
- {
+ const QMetaObject *metaObject = object->metaObject();
+ for (QVariantMap::const_iterator iter = variant.begin(); iter != variant.end(); ++iter) {
+ const int propertyIndex = metaObject->indexOfProperty(qPrintable(iter.key()));
+ if (propertyIndex == -1) {
+ qWarning() << "Skipping non-existent property" << iter.key();
+ continue;
+ }
+ const QMetaProperty metaProperty = metaObject->property(propertyIndex);
+ if (!metaProperty.isWritable()) {
+ qWarning() << "Skipping read-only property" << iter.key();
+ continue;
+ }
+
+ const QVariant property = object->property(iter.key().toLatin1());
+ Q_ASSERT(property.isValid());
+ if (property.isValid()) {
QVariant value = iter.value();
- if ( value.canConvert( property.type() ) )
- {
- value.convert( property.type() );
- object->setProperty( iter.key().toLatin1(), value );
- } else if ( QString( QLatin1String("QVariant") ).compare( QLatin1String( property.typeName() ) ) == 0) {
- object->setProperty( iter.key().toLatin1(), value );
+ if (value.canConvert(property.type())) {
+ value.convert(property.type());
+ object->setProperty(iter.key().toLatin1(), value);
+ } else if (QString(QLatin1String("QVariant")).compare(QLatin1String(property.typeName())) == 0) {
+ object->setProperty(iter.key().toLatin1(), value);
}
}
}
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/backends/qscreen/qscreenscreen.cpp
^
|
@@ -46,14 +46,20 @@
void QScreenScreen::updateKScreenScreen(ScreenPtr &screen) const
{
+ if (!screen) {
+ return;
+ }
+
auto primary = QGuiApplication::primaryScreen();
-// QSize _s = primary->availableVirtualGeometry().size();
- QSize _s = QSize(1080, 1920);
- screen->setCurrentSize(_s);
- screen->setId(1);
- screen->setMaxSize(_s);
- screen->setMinSize(_s);
- screen->setCurrentSize(_s);
- screen->setMaxActiveOutputsCount(QGuiApplication::screens().count());
+ if (primary) {
+ QSize _s = primary->availableVirtualGeometry().size();
+
+ screen->setCurrentSize(_s);
+ screen->setId(1);
+ screen->setMaxSize(_s);
+ screen->setMinSize(_s);
+ screen->setCurrentSize(_s);
+ screen->setMaxActiveOutputsCount(QGuiApplication::screens().count());
+ }
}
|
[-]
[+]
|
Added |
libkscreen-5.3.0.tar.xz/backends/xcbeventlistener.cpp
^
|
@@ -0,0 +1,213 @@
+/*************************************************************************************
+ * Copyright 2012, 2013 Daniel Vrátil <dvratil@redhat.com> *
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * This library is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this library; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ *************************************************************************************/
+
+#include "xcbeventlistener.h"
+
+#include <QX11Info>
+#include <QGuiApplication>
+
+#include <QRect>
+
+Q_LOGGING_CATEGORY(KSCREEN_XCB_HELPER, "kscreen.xcb.helper")
+
+XCBEventListener::XCBEventListener():
+ QObject(),
+ m_isRandrPresent(false),
+ m_randrBase(0),
+ m_randrErrorBase(0),
+ m_majorOpcode(0),
+ m_eventType(0),
+ m_versionMajor(0),
+ m_versionMinor(0),
+ m_window(0)
+{
+ QLoggingCategory::setFilterRules(QStringLiteral("kscreen.xcb.helper = true"));
+
+ xcb_connection_t* c = QX11Info::connection();
+ xcb_prefetch_extension_data(c, &xcb_randr_id);
+ auto cookie = xcb_randr_query_version(c, XCB_RANDR_MAJOR_VERSION, XCB_RANDR_MINOR_VERSION);
+ const auto *queryExtension = xcb_get_extension_data(c, &xcb_randr_id);
+ if (!queryExtension) {
+ qCDebug(KSCREEN_XCB_HELPER) << "Fail to query for xrandr extension";
+ return;
+ }
+ if (!queryExtension->present) {
+ qCDebug(KSCREEN_XCB_HELPER) << "XRandR extension is not present at all";
+ return;
+ }
+
+ m_isRandrPresent = queryExtension->present;
+ m_randrBase = queryExtension->first_event;
+ m_randrErrorBase = queryExtension->first_error;
+ m_majorOpcode = queryExtension->major_opcode;
+
+ xcb_generic_error_t *error = NULL;
+ auto* versionReply = xcb_randr_query_version_reply(c, cookie, &error);
+ Q_ASSERT_X(versionReply, "xrandrxcbhelper", "Query to fetch xrandr version failed");
+ if (error) {
+ qFatal("Error while querying for xrandr version: %d", error->error_code);
+ }
+ m_versionMajor = versionReply->major_version;
+ m_versionMinor = versionReply->minor_version;
+ free(versionReply);
+
+ qCDebug(KSCREEN_XCB_HELPER).nospace() << "Detected XRandR " << m_versionMajor << "." << m_versionMinor;
+ qCDebug(KSCREEN_XCB_HELPER) << "Event Base: " << m_randrBase;
+ qCDebug(KSCREEN_XCB_HELPER) << "Event Error: "<< m_randrErrorBase;
+
+ uint32_t rWindow = QX11Info::appRootWindow();
+ m_window = xcb_generate_id(c);
+ xcb_create_window(c, XCB_COPY_FROM_PARENT, m_window,
+ rWindow,
+ 0, 0, 1, 1, 0, XCB_COPY_FROM_PARENT,
+ XCB_COPY_FROM_PARENT, 0, NULL);
+
+ xcb_randr_select_input(c, m_window,
+ XCB_RANDR_NOTIFY_MASK_SCREEN_CHANGE |
+ XCB_RANDR_NOTIFY_MASK_OUTPUT_CHANGE |
+ XCB_RANDR_NOTIFY_MASK_CRTC_CHANGE |
+ XCB_RANDR_NOTIFY_MASK_OUTPUT_PROPERTY
+ );
+
+ qApp->installNativeEventFilter(this);
+}
+
+XCBEventListener::~XCBEventListener()
+{
+ if (m_window && QX11Info::connection()) {
+ xcb_destroy_window(QX11Info::connection(), m_window);
+ }
+}
+
+QString XCBEventListener::rotationToString(xcb_randr_rotation_t rotation)
+{
+ switch (rotation) {
+ case XCB_RANDR_ROTATION_ROTATE_0:
+ return "Rotate_0";
+ case XCB_RANDR_ROTATION_ROTATE_90:
+ return "Rotate_90";
+ case XCB_RANDR_ROTATION_ROTATE_180:
+ return "Rotate_180";
+ case XCB_RANDR_ROTATION_ROTATE_270:
+ return "Rotate_270";
+ case XCB_RANDR_ROTATION_REFLECT_X:
+ return "Reflect_X";
+ case XCB_RANDR_ROTATION_REFLECT_Y:
+ return "REflect_Y";
+ }
+
+ return QString("invalid value (%1)").arg(rotation);
+}
+
+QString XCBEventListener::connectionToString(xcb_randr_connection_t connection)
+{
+ switch (connection) {
+ case XCB_RANDR_CONNECTION_CONNECTED:
+ return "Connected";
+ case XCB_RANDR_CONNECTION_DISCONNECTED:
+ return "Disconnected";
+ case XCB_RANDR_CONNECTION_UNKNOWN:
+ return "UnknownConnection";
+ }
+
+ return QString("invalid value (%1)").arg(connection);
+}
+
+bool XCBEventListener::nativeEventFilter(const QByteArray& eventType, void* message, long int* result)
+{
+ Q_UNUSED(result);
+
+ if (eventType != "xcb_generic_event_t") {
+ return false;
+ }
+
+ xcb_generic_event_t* e = static_cast<xcb_generic_event_t *>(message);
+ const uint8_t xEventType = e->response_type & ~0x80;
+
+ //If this event is not xcb_randr_notify, we don't want it
+ if (xEventType == m_randrBase + XCB_RANDR_SCREEN_CHANGE_NOTIFY) {
+ handleScreenChange(e);
+ }
+ if (xEventType == m_randrBase + XCB_RANDR_NOTIFY) {
+ handleXRandRNotify(e);
+ }
+
+ return false;
+}
+
+void XCBEventListener::handleScreenChange(xcb_generic_event_t* e)
+{
+ xcb_randr_screen_change_notify_event_t *e2 =
+ (xcb_randr_screen_change_notify_event_t *) e;
+
+ // Only accept notifications for our window
+ if (e2->request_window != m_window) {
+ return;
+ }
+
+ qCDebug(KSCREEN_XCB_HELPER) << "RRScreenChangeNotify";
+ qCDebug(KSCREEN_XCB_HELPER) << "\tWindow:" << e2->request_window;
+ qCDebug(KSCREEN_XCB_HELPER) << "\tRoot:" << e2->root;
+ qCDebug(KSCREEN_XCB_HELPER) << "\tRotation: " << rotationToString((xcb_randr_rotation_t) e2->rotation);
+ qCDebug(KSCREEN_XCB_HELPER) << "\tSize ID:" << e2->sizeID;
+ qCDebug(KSCREEN_XCB_HELPER) << "\tSize: " << e2->width << e2->height;
+ qCDebug(KSCREEN_XCB_HELPER) << "\tSizeMM: " << e2->mwidth << e2->mheight;
+
+ Q_EMIT screenChanged((xcb_randr_rotation_t) e2->rotation, QSize(e2->width, e2->height), QSize(e2->mwidth, e2->mheight));
+ Q_EMIT outputsChanged();
+}
+
+void XCBEventListener::handleXRandRNotify(xcb_generic_event_t* e)
+{
+ xcb_randr_notify_event_t*
+ randrEvent = reinterpret_cast<xcb_randr_notify_event_t*>(e);
+
+ if (randrEvent->subCode == XCB_RANDR_NOTIFY_CRTC_CHANGE) {
+ xcb_randr_crtc_change_t crtc = randrEvent->u.cc;
+ qCDebug(KSCREEN_XCB_HELPER) << "RRNotify_CrtcChange";
+ qCDebug(KSCREEN_XCB_HELPER) << "\tCRTC: " << crtc.crtc;
+ qCDebug(KSCREEN_XCB_HELPER) << "\tMode: " << crtc.mode;
+ qCDebug(KSCREEN_XCB_HELPER) << "\tRotation: " << rotationToString((xcb_randr_rotation_t) crtc.rotation);
+ qCDebug(KSCREEN_XCB_HELPER) << "\tGeometry: " << crtc.x << crtc.y << crtc.width << crtc.height;
+ Q_EMIT crtcChanged(crtc.crtc, crtc.mode, (xcb_randr_rotation_t) crtc.rotation,
+ QRect(crtc.x, crtc.y, crtc.width, crtc.height));
+
+ } else if(randrEvent->subCode == XCB_RANDR_NOTIFY_OUTPUT_CHANGE) {
+ xcb_randr_output_change_t output = randrEvent->u.oc;
+ qCDebug(KSCREEN_XCB_HELPER) << "RRotify_OutputChange";
+ qCDebug(KSCREEN_XCB_HELPER) << "\tOutput: " << output.output;
+ qCDebug(KSCREEN_XCB_HELPER) << "\tCRTC: " << output.crtc;
+ qCDebug(KSCREEN_XCB_HELPER) << "\tMode: " << output.mode;
+ qCDebug(KSCREEN_XCB_HELPER) << "\tRotation: " << rotationToString((xcb_randr_rotation_t) output.rotation);
+ qCDebug(KSCREEN_XCB_HELPER) << "\tConnection: " << connectionToString((xcb_randr_connection_t) output.connection);
+ qCDebug(KSCREEN_XCB_HELPER) << "\tSubpixel Order: " << output.subpixel_order;
+ Q_EMIT outputChanged(output.output, output.crtc, output.mode,
|
[-]
[+]
|
Added |
libkscreen-5.3.0.tar.xz/backends/xcbeventlistener.h
^
|
@@ -0,0 +1,78 @@
+/*************************************************************************************
+ * Copyright 2012, 2013 Daniel Vrátil <dvratil@redhat.com> *
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * This library is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this library; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ *************************************************************************************/
+
+#ifndef XRANDRX11HELPER_H
+#define XRANDRX11HELPER_H
+
+#include <QObject>
+#include <QLoggingCategory>
+#include <QAbstractNativeEventFilter>
+#include <QRect>
+
+#include "xcbwrapper.h"
+
+class XCBEventListener : public QObject,
+ public QAbstractNativeEventFilter
+{
+ Q_OBJECT
+
+ public:
+ XCBEventListener();
+ ~XCBEventListener();
+
+ bool nativeEventFilter(const QByteArray& eventType, void* message, long int* result) Q_DECL_OVERRIDE;
+
+ Q_SIGNALS:
+ /* Emitted when only XRandR 1.1 or older is available */
+ void screenChanged(xcb_randr_rotation_t rotation,
+ const QSize &sizePx,
+ const QSize &sizeMm);
+ void outputsChanged();
+
+ /* Emitted only when XRandR 1.2 or newer is available */
+ void crtcChanged(xcb_randr_crtc_t crtc,
+ xcb_randr_mode_t mode,
+ xcb_randr_rotation_t rotation,
+ const QRect &geom);
+ void outputChanged(xcb_randr_output_t output,
+ xcb_randr_crtc_t crtc,
+ xcb_randr_mode_t mode,
+ xcb_randr_connection_t connection);
+ void outputPropertyChanged(xcb_randr_output_t output);
+
+ private:
+ QString rotationToString(xcb_randr_rotation_t rotation);
+ QString connectionToString(xcb_randr_connection_t connection);
+ void handleScreenChange(xcb_generic_event_t *e);
+ void handleXRandRNotify(xcb_generic_event_t *e);
+
+ protected:
+ bool m_isRandrPresent;
+ bool m_event11;
+ int m_randrBase;
+ int m_randrErrorBase;
+ int m_majorOpcode;
+ int m_eventType;
+ int m_versionMajor;
+ int m_versionMinor;
+
+ uint32_t m_window;
+};
+
+Q_DECLARE_LOGGING_CATEGORY(KSCREEN_XCB_HELPER)
+#endif // XRANDRX11HELPER_H
|
[-]
[+]
|
Added |
libkscreen-5.3.0.tar.xz/backends/xcbwrapper.cpp
^
|
@@ -0,0 +1,67 @@
+/********************************************************************
+ K Win - the KDE window manager
+ This file is part of the KDE project.
+
+Copyright (C) 2012, 2013 Martin Gräßlin <mgraesslin@kde.org>
+Copyright (C) 2015 Daniel Vrátil <dvratil@redhat.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*********************************************************************/
+
+#include "xcbwrapper.h"
+
+static xcb_connection_t *sXRandR11XCBConnection = 0;
+
+xcb_connection_t* XCB::connection()
+{
+ // Use our own connection to make sure that we won't mess up Qt's connection
+ // if something goes wrong on our side.
+ if (sXRandR11XCBConnection == 0) {
+ sXRandR11XCBConnection = xcb_connect(0, 0);
+ }
+ return sXRandR11XCBConnection;
+}
+
+void XCB::closeConnection()
+{
+ if (sXRandR11XCBConnection) {
+ xcb_disconnect(sXRandR11XCBConnection);
+ sXRandR11XCBConnection = 0;
+ }
+}
+
+xcb_screen_t* XCB::screenOfDisplay(xcb_connection_t* c, int screen)
+{
+ for (auto iter = xcb_setup_roots_iterator(xcb_get_setup(c));
+ iter.rem; --screen, xcb_screen_next(&iter))
+ {
+ if (screen == 0) {
+ return iter.data;
+ }
+ }
+
+ return Q_NULLPTR;
+}
+
+
+XCB::GrabServer::GrabServer()
+{
+ xcb_grab_server(connection());
+}
+
+XCB::GrabServer::~GrabServer()
+{
+ xcb_ungrab_server(connection());
+ xcb_flush(connection());
+}
|
[-]
[+]
|
Added |
libkscreen-5.3.0.tar.xz/backends/xcbwrapper.h
^
|
@@ -0,0 +1,211 @@
+/********************************************************************
+ K Win - the KDE window manager
+ This file is part of the KDE project.
+
+Copyright (C) 2012, 2013 Martin Gräßlin <mgraesslin@kde.org>
+Copyright (C) 2015 Daniel Vrátil <dvratil@redhat.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*********************************************************************/
+
+#ifndef XCB_WRAPPER_H
+#define XCB_WRAPPER_H
+
+#include <functional>
+#include <type_traits>
+
+#include <QX11Info>
+#include <QScopedPointer>
+
+#include <xcb/xcb.h>
+#include <xcb/randr.h>
+
+namespace XCB
+{
+
+template<typename T>
+using ScopedPointer = QScopedPointer<T, QScopedPointerPodDeleter>;
+
+xcb_connection_t *connection();
+void closeConnection();
+xcb_screen_t *screenOfDisplay(xcb_connection_t *c, int screen);
+
+struct GrabServer
+{
+ GrabServer();
+ ~GrabServer();
+};
+
+template <typename Reply,
+ typename Cookie,
+ typename ReplyFunc,
+ ReplyFunc replyFunc,
+ typename RequestFunc,
+ RequestFunc requestFunc,
+ typename ... RequestFuncArgs>
+class Wrapper
+{
+public:
+ Wrapper()
+ : m_retrieved(false)
+ , m_window(XCB_WINDOW_NONE)
+ , m_reply(Q_NULLPTR)
+ {
+ m_cookie.sequence = 0;
+ }
+ explicit Wrapper(const RequestFuncArgs& ... args)
+ : m_retrieved(false)
+ , m_cookie(requestFunc(connection(), args ...))
+ , m_window(requestWindow<RequestFuncArgs ...>(args ...))
+ , m_reply(Q_NULLPTR)
+ {
+ }
+ explicit Wrapper(const Wrapper &other)
+ : m_retrieved(other.m_retrieved)
+ , m_cookie(other.m_cookie)
+ , m_window(other.m_window)
+ , m_reply(Q_NULLPTR)
+ {
+ takeFromOther(const_cast<Wrapper&>(other));
+ }
+ virtual ~Wrapper() {
+ cleanup();
+ }
+ inline Wrapper &operator=(const Wrapper &other) {
+ if (this != &other) {
+ // if we had managed a reply, free it
+ cleanup();
+ // copy members
+ m_retrieved = other.m_retrieved;
+ m_cookie = other.m_cookie;
+ m_window = other.m_window;
+ m_reply = other.m_reply;
+ // take over the responsibility for the reply pointer
+ takeFromOther(const_cast<Wrapper&>(other));
+ }
+ return *this;
+ }
+
+ inline operator const Reply*() const {
+ getReply();
+ return m_reply;
+ }
+ inline const Reply* operator->() const {
+ getReply();
+ return m_reply;
+ }
+ inline bool isNull() const {
+ getReply();
+ return m_reply == NULL;
+ }
+ inline operator bool() const {
+ return !isNull();
+ }
+ inline const Reply* data() const {
+ getReply();
+ return m_reply;
+ }
+ inline xcb_window_t window() const {
+ return m_window;
+ }
+ inline bool isRetrieved() const {
+ return m_retrieved;
+ }
+ /**
+ * Returns the value of the reply pointer referenced by this object. The reply pointer of
+ * this object will be reset to null. Calling any method which requires the reply to be valid
+ * will crash.
+ *
+ * Callers of this function take ownership of the pointer.
+ **/
+ inline Reply *take() {
+ getReply();
+ Reply *ret = m_reply;
+ m_reply = Q_NULLPTR;
+ m_window = XCB_WINDOW_NONE;
+ return ret;
+ }
+
+protected:
+ void getReply() const {
+ if (m_retrieved || !m_cookie.sequence) {
+ return;
+ }
+ m_reply = replyFunc(connection(), m_cookie, NULL);
+ m_retrieved = true;
+ }
+
+private:
+ inline void cleanup() {
+ if (!m_retrieved && m_cookie.sequence) {
+ xcb_discard_reply(connection(), m_cookie.sequence);
+ } else if (m_reply) {
+ free(m_reply);
+ }
+ }
+ inline void takeFromOther(Wrapper &other) {
+ if (m_retrieved) {
+ m_reply = other.take();
+ } else {
+ //ensure that other object doesn't try to get the reply or discards it in the dtor
+ other.m_retrieved = true;
+ other.m_window = XCB_WINDOW_NONE;
+ }
+ }
+ template<typename ... Args>
+ constexpr xcb_window_t requestWindow(const Args & ... args) {
+ return std::is_same<typename std::tuple_element<0, std::tuple<Args ...>>::type, xcb_window_t>::value
+ ? std::get<0>(std::tuple<Args ...>(args ...))
+ : static_cast<xcb_window_t>(XCB_WINDOW_NONE);
+ }
+
+ mutable bool m_retrieved;
+ Cookie m_cookie;
+ xcb_window_t m_window;
+ mutable Reply *m_reply;
+};
+
+#define XCB_DECLARE_TYPE(name, xcb_request, ...) \
+ typedef Wrapper<xcb_request##_reply_t, \
+ xcb_request##_cookie_t, \
+ decltype(&xcb_request##_reply), \
+ xcb_request##_reply, \
+ decltype(&xcb_request), \
+ xcb_request, \
+ ##__VA_ARGS__> name
+
+XCB_DECLARE_TYPE(ScreenInfo, xcb_randr_get_screen_info,
+ xcb_window_t);
+
+XCB_DECLARE_TYPE(ScreenSize, xcb_randr_get_screen_size_range,
+ xcb_window_t);
+
+XCB_DECLARE_TYPE(PrimaryOutput, xcb_randr_get_output_primary,
+ xcb_window_t);
+
+XCB_DECLARE_TYPE(InternAtom, xcb_intern_atom,
+ uint8_t, uint16_t, const char *);
+
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/backends/xrandr/CMakeLists.txt
^
|
@@ -1,15 +1,16 @@
include_directories(${CMAKE_SOURCE_DIR}/src
${CMAKE_BUILD_DIR}
- ${X11_Xrandr_INCLUDE_PATH}
)
set(xrandr_SRCS
xrandr.cpp
- xrandrxcbhelper.cpp
xrandrconfig.cpp
+ xrandrcrtc.cpp
xrandroutput.cpp
xrandrmode.cpp
xrandrscreen.cpp
+ ../xcbwrapper.cpp
+ ../xcbeventlistener.cpp
)
add_library(KSC_XRandR MODULE ${xrandr_SRCS})
@@ -18,9 +19,7 @@
target_link_libraries(KSC_XRandR Qt5::Core
Qt5::Gui
Qt5::X11Extras
- ${X11_Xrandr_LIB}
- ${X11_LIBRARIES}
- ${XCB_LIBRARIES} #for xrandrxcbhelper
+ ${XCB_LIBRARIES}
KF5::Screen
)
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/backends/xrandr/xrandr.cpp
^
|
@@ -19,7 +19,9 @@
#include "xrandr.h"
#include "xrandrconfig.h"
-#include "xrandrxcbhelper.h"
+#include "xrandrscreen.h"
+#include "../xcbwrapper.h"
+#include "../xcbeventlistener.h"
#include "config.h"
#include "output.h"
@@ -29,15 +31,14 @@
#include <QtCore/qplugin.h>
#include <QtCore/QRect>
#include <QAbstractEventDispatcher>
+#include <QTimer>
+#include <QTime>
#include <QX11Info>
#include <QGuiApplication>
-#include <xcb/randr.h>
-
-Display* XRandR::s_display = 0;
-int XRandR::s_screen = 0;
-Window XRandR::s_rootWindow = 0;
+xcb_screen_t* XRandR::s_screen = 0;
+xcb_window_t XRandR::s_rootWindow = 0;
XRandRConfig* XRandR::s_internalConfig = 0;
int XRandR::s_randrBase = 0;
int XRandR::s_randrError = 0;
@@ -53,18 +54,25 @@
: KScreen::AbstractBackend()
, m_x11Helper(0)
, m_isValid(false)
+ , m_configChangeCompressor(0)
{
QLoggingCategory::setFilterRules(QLatin1Literal("kscreen.xrandr.debug = true"));
+ qRegisterMetaType<xcb_randr_output_t>("xcb_randr_output_t");
+ qRegisterMetaType<xcb_randr_crtc_t>("xcb_randr_crtc_t");
+ qRegisterMetaType<xcb_randr_mode_t>("xcb_randr_mode_t");
+ qRegisterMetaType<xcb_randr_connection_t>("xcb_randr_connection_t");
+ qRegisterMetaType<xcb_randr_rotation_t>("xcb_randr_rotation_t");
+
// Use our own connection to make sure that we won't mess up Qt's connection
// if something goes wrong on our side.
xcb_generic_error_t *error = 0;
xcb_randr_query_version_reply_t* version;
- xcb_connection_t *connection = xcb_connect(0, 0);
- version = xcb_randr_query_version_reply(connection, xcb_randr_query_version(connection, XCB_RANDR_MAJOR_VERSION, XCB_RANDR_MINOR_VERSION), &error);
- xcb_disconnect(connection);
+ XCB::connection();
+ version = xcb_randr_query_version_reply(XCB::connection(), xcb_randr_query_version(XCB::connection(), XCB_RANDR_MAJOR_VERSION, XCB_RANDR_MINOR_VERSION), &error);
if (!version || error) {
+ XCB::closeConnection();
free(error);
return;
}
@@ -72,16 +80,19 @@
if ((version->major_version > 1) || ((version->major_version == 1) && (version->minor_version >= 2))) {
m_isValid = true;
} else {
+ XCB::closeConnection();
qCWarning(KSCREEN_XRANDR) << "XRandR extension not available or unsupported version";
return;
}
- if (s_display == 0) {
- s_display = QX11Info::display();
- s_screen = DefaultScreen(s_display);
- s_rootWindow = XRootWindow(s_display, s_screen);
-
- XRRQueryExtension(s_display, &s_randrBase, &s_randrError);
+ if (s_screen == 0) {
+ s_screen = XCB::screenOfDisplay(XCB::connection(), QX11Info::appScreen());
+ s_rootWindow = s_screen->root;
+
+ xcb_prefetch_extension_data(XCB::connection(), &xcb_randr_id);
+ auto reply = xcb_get_extension_data(XCB::connection(), &xcb_randr_id);
+ s_randrBase = reply->first_event;
+ s_randrError = reply->first_error;
}
XRandR::s_has_1_3 = (version->major_version > 1 || (version->major_version == 1 && version->minor_version >= 3));
@@ -91,14 +102,25 @@
}
if (!s_monitorInitialized) {
- m_x11Helper = new XRandRXCBHelper();
- /* In case of XRandR 1.0 or 1.1 */
- connect(m_x11Helper, SIGNAL(outputsChanged()), SLOT(updateConfig()));
-
- /* XRandR >= 1.2 */
- connect(m_x11Helper, SIGNAL(outputChanged(RROutput)), SLOT(updateOutput(RROutput)));
- connect(m_x11Helper, SIGNAL(crtcChanged(RRCrtc)), SLOT(updateCrtc(RRCrtc)));
- connect(s_internalConfig, SIGNAL(outputRemoved(int)), SLOT(outputRemovedSlot()));
+ m_x11Helper = new XCBEventListener();
+ connect(m_x11Helper, &XCBEventListener::outputChanged,
+ this, &XRandR::outputChanged,
+ Qt::QueuedConnection);
+ connect(m_x11Helper, &XCBEventListener::crtcChanged,
+ this, &XRandR::crtcChanged,
+ Qt::QueuedConnection);
+ connect(m_x11Helper, &XCBEventListener::screenChanged,
+ this, &XRandR::screenChanged,
+ Qt::QueuedConnection);
+
+ m_configChangeCompressor = new QTimer(this);
+ m_configChangeCompressor->setSingleShot(true);
+ m_configChangeCompressor->setInterval(500);
+ connect(m_configChangeCompressor, &QTimer::timeout,
+ [&]() {
+ qCDebug(KSCREEN_XRANDR) << "Emitting configChanged()";
+ Q_EMIT configChanged(config());
+ });
s_monitorInitialized = true;
}
@@ -120,45 +142,62 @@
}
-void XRandR::updateConfig()
-{
- s_internalConfig->update();
- Q_EMIT configChanged(config());
-}
-
-void XRandR::outputRemovedSlot()
+void XRandR::outputChanged(xcb_randr_output_t output, xcb_randr_crtc_t crtc,
+ xcb_randr_mode_t mode, xcb_randr_connection_t connection)
{
- Q_EMIT configChanged(config());
-}
-
-void XRandR::updateOutput(RROutput output)
-{
- XRandROutput *xOutput = s_internalConfig->outputs().value(output);
+ XRandROutput *xOutput = s_internalConfig->output(output);
+ XCB::PrimaryOutput primary(XRandR::rootWindow());
if (!xOutput) {
s_internalConfig->addNewOutput(output);
} else {
- RROutput primary = XRRGetOutputPrimary(XRandR::display(), XRandR::rootWindow());
- xOutput->update((output == primary) ? XRandROutput::SetPrimary : XRandROutput::UnsetPrimary);
- if (output == primary) {
- s_internalConfig->m_primaryOutput = output;
+ switch (crtc == XCB_NONE && mode == XCB_NONE && connection == XCB_RANDR_CONNECTION_DISCONNECTED) {
+ case true: {
+ XCB::OutputInfo info(output, XCB_TIME_CURRENT_TIME);
+ if (info.isNull()) {
+ s_internalConfig->removeOutput(output);
+ qCDebug(KSCREEN_XRANDR) << "Output" << output << " removed";
+ break;
+ }
+ // info is valid: fall-through
}
+ case false: {
+ xOutput->update(crtc, mode, connection, (primary->output == output));
+ qCDebug(KSCREEN_XRANDR) << "Output" << xOutput->id() << ": connected =" << xOutput->isConnected() << ", enabled =" << xOutput->isEnabled();
+ break;
+ }
+ } // switch
}
- Q_EMIT configChanged(config());
+ m_configChangeCompressor->start();
}
-void XRandR::updateCrtc(RRCrtc crtc)
+void XRandR::crtcChanged(xcb_randr_crtc_t crtc, xcb_randr_mode_t mode,
+ xcb_randr_rotation_t rotation, const QRect& geom)
{
- XRRCrtcInfo* crtcInfo = XRRCrtc(crtc);
- for (int i = 0; i < crtcInfo->noutput; ++i) {
- XRandROutput *xOutput = s_internalConfig->outputs().value(crtcInfo->outputs[i]);
- xOutput->update();
+ XRandRCrtc *xCrtc = s_internalConfig->crtc(crtc);
+ if (!xCrtc) {
+ s_internalConfig->addNewCrtc(crtc);
+ } else {
+ xCrtc->update(mode, rotation, geom);
}
- XRRFreeCrtcInfo(crtcInfo);
- Q_EMIT configChanged(config());
+ m_configChangeCompressor->start();
}
+void XRandR::screenChanged(xcb_randr_rotation_t rotation,
+ const QSize &sizePx, const QSize &sizeMm)
+{
+ Q_UNUSED(rotation);
+ Q_UNUSED(sizeMm);
+
+ XRandRScreen *xScreen = s_internalConfig->screen();
+ Q_ASSERT(xScreen);
+ xScreen->update(sizePx);
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/backends/xrandr/xrandr.h
^
|
@@ -20,13 +20,17 @@
#ifndef XRANDR_BACKEND_H
#define XRANDR_BACKEND_H
-#include "xlibandxrandr.h"
#include "abstractbackend.h"
#include <QtCore/QSize>
#include <QLoggingCategory>
-class XRandRXCBHelper;
+#include "../xcbwrapper.h"
+
+class QRect;
+class QTimer;
+
+class XCBEventListener;
class XRandRConfig;
namespace KScreen {
class Output;
@@ -48,29 +52,31 @@
virtual bool isValid() const;
virtual QByteArray edid(int outputId) const;
- static RRCrtc outputCrtc(int outputId);
- static quint8 *outputEdid(int outputId, size_t &len);
- static RRCrtc freeCrtc(int outputId);
- static XRRScreenResources* screenResources();
- static XRROutputInfo* XRROutput(int outputId);
- static XRRCrtcInfo* XRRCrtc(int crtcId);
- static Display* display();
- static int screen();
- static Window rootWindow();
+ static quint8 *outputEdid(xcb_randr_output_t outputId, size_t &len);
+ static xcb_randr_get_screen_resources_reply_t* screenResources();
+ static xcb_screen_t* screen();
+ static xcb_window_t rootWindow();
private Q_SLOTS:
- void updateConfig();
- void outputRemovedSlot();
-
- void updateOutput(RROutput output);
- void updateCrtc(RRCrtc crtc);
+ void outputChanged(xcb_randr_output_t output,
+ xcb_randr_crtc_t crtc,
+ xcb_randr_mode_t mode,
+ xcb_randr_connection_t connection);
+ void crtcChanged(xcb_randr_crtc_t crtc,
+ xcb_randr_mode_t mode,
+ xcb_randr_rotation_t rotation,
+ const QRect &geom);
+ void screenChanged(xcb_randr_rotation_t rotation,
+ const QSize &sizePx,
+ const QSize &sizeMm);
private:
- static quint8* getXProperty(Display *dpy, RROutput output, Atom atom, size_t &len);
+ static quint8* getXProperty(xcb_randr_output_t output,
+ xcb_atom_t atom,
+ size_t &len);
- static Display* s_display;
- static int s_screen;
- static Window s_rootWindow;
+ static xcb_screen_t *s_screen;
+ static xcb_window_t s_rootWindow;
static XRandRConfig *s_internalConfig;
static int s_randrBase;
static int s_randrError;
@@ -78,8 +84,10 @@
static bool s_has_1_3;
static bool s_xorgCacheInitialized;
- XRandRXCBHelper *m_x11Helper;
+ XCBEventListener *m_x11Helper;
bool m_isValid;
+
+ QTimer *m_configChangeCompressor;
};
Q_DECLARE_LOGGING_CATEGORY(KSCREEN_XRANDR)
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/backends/xrandr/xrandrconfig.cpp
^
|
@@ -1,6 +1,6 @@
/*************************************************************************************
* Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> *
- * Copyright (C) 2012, 2013 by Daniel Vrátil <dvratil@redhat.com> *
+ * Copyright (C) 2012 - 2015 by Daniel Vrátil <dvratil@redhat.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
@@ -22,86 +22,84 @@
#include "xrandr.h"
#include "xrandrmode.h"
#include "xrandroutput.h"
+#include "xrandrcrtc.h"
#include "config.h"
#include "output.h"
#include "edid.h"
+#include "../xcbwrapper.h"
+
#include <QX11Info>
#include <QRect>
+#include <QScopedPointer>
using namespace KScreen;
XRandRConfig::XRandRConfig()
: QObject()
- , m_primaryOutput(-1)
- , m_screen(new XRandRScreen(this))
+ , m_screen(Q_NULLPTR)
{
- XRRScreenResources* resources = XRandR::screenResources();
-
- const RROutput primary = XRRGetOutputPrimary(XRandR::display(), XRandR::rootWindow());
-
- RROutput id;
- for (int i = 0; i < resources->noutput; ++i)
- {
- id = resources->outputs[i];
+ m_screen = new XRandRScreen(this);
- XRandROutput *output = createNewOutput(id, (id == primary));
- m_outputs.insert(id, output);
- if (id == primary) {
- m_primaryOutput = output->id();
- }
+ XCB::ScopedPointer<xcb_randr_get_screen_resources_reply_t> resources(XRandR::screenResources());
+ xcb_randr_crtc_t *crtcs = xcb_randr_get_screen_resources_crtcs(resources.data());
+ for (int i = 0, c = xcb_randr_get_screen_resources_crtcs_length(resources.data()); i < c; ++i) {
+ addNewCrtc(crtcs[i]);
}
- XRRFreeScreenResources(resources);
+ xcb_randr_output_t *outputs = xcb_randr_get_screen_resources_outputs(resources.data());
+ for (int i = 0, c = xcb_randr_get_screen_resources_outputs_length(resources.data()); i < c; ++i) {
+ addNewOutput(outputs[i]);
+ }
}
XRandRConfig::~XRandRConfig()
{
+ qDeleteAll(m_outputs);
+ qDeleteAll(m_crtcs);
+ delete m_screen;
}
-void XRandRConfig::update()
+XRandROutput::Map XRandRConfig::outputs() const
{
- m_screen->update();
+ return m_outputs;
+}
- const RROutput primary = XRRGetOutputPrimary(XRandR::display(), XRandR::rootWindow());
+XRandROutput* XRandRConfig::output(xcb_randr_output_t output) const
+{
+ return m_outputs[output];
+}
- m_primaryOutput = -1;
- for (auto iter = m_outputs.begin(); iter != m_outputs.end(); ++iter) {
- XRandROutput *output = iter.value();
- output->update((iter.key() == (int) primary) ? XRandROutput::SetPrimary : XRandROutput::UnsetPrimary);
- if (iter.key() == (int) primary) {
- m_primaryOutput = output->id();
- }
- }
+XRandRCrtc::Map XRandRConfig::crtcs() const
+{
+ return m_crtcs;
}
-XRandROutput::Map XRandRConfig::outputs() const
+XRandRCrtc* XRandRConfig::crtc(xcb_randr_crtc_t crtc) const
{
- return m_outputs;
+ return m_crtcs[crtc];
}
-void XRandRConfig::addNewOutput(const RROutput id)
+XRandRScreen* XRandRConfig::screen() const
{
- const RROutput primary = XRRGetOutputPrimary(XRandR::display(), XRandR::rootWindow());
- XRandROutput *output = createNewOutput(id, (id == primary));
- m_outputs.insert(id, output);
- if (id == primary) {
- m_primaryOutput = id;
- }
+ return m_screen;
}
-XRandROutput* XRandRConfig::createNewOutput(RROutput id, bool primary)
+
+void XRandRConfig::addNewOutput(xcb_randr_output_t id)
{
- XRandROutput *xOutput = new XRandROutput(id, primary, this);
- connect(xOutput, SIGNAL(outputRemoved(int)), SLOT(outputRemovedSlot(int)));
+ XRandROutput *xOutput = new XRandROutput(id, this);
+ m_outputs.insert(id, xOutput);
+}
- return xOutput;
+void XRandRConfig::addNewCrtc(xcb_randr_crtc_t crtc)
+{
+ m_crtcs.insert(crtc, new XRandRCrtc(crtc, this));
}
-void XRandRConfig::outputRemovedSlot(int id)
+void XRandRConfig::removeOutput(xcb_randr_output_t id)
{
- m_outputs.remove(id);
- Q_EMIT outputRemoved(id);
+ delete m_outputs.take(id);
}
KScreen::ConfigPtr XRandRConfig::toKScreenConfig() const
@@ -110,120 +108,73 @@
KScreen::OutputList kscreenOutputs;
for (auto iter = m_outputs.constBegin(); iter != m_outputs.constEnd(); ++iter) {
- XRandROutput *output = iter.value();
- //FIXME XRandR backend should keep updated itself
- output->update(XRandROutput::NoChange);
- KScreen::OutputPtr kscreenOutput = output->toKScreenOutput();
+ KScreen::OutputPtr kscreenOutput = (*iter)->toKScreenOutput();
kscreenOutputs.insert(kscreenOutput->id(), kscreenOutput);
}
-
config->setOutputs(kscreenOutputs);
config->setScreen(m_screen->toKScreenScreen());
- if (m_primaryOutput != -1 && (!config->primaryOutput() || config->primaryOutput()->id() != m_primaryOutput)) {
- config->setPrimaryOutput(kscreenOutputs.value(m_primaryOutput));
- }
return config;
}
-void XRandRConfig::updateKScreenConfig(ConfigPtr &config) const
-{
- KScreen::ScreenPtr kscreenScreen = config->screen();
- m_screen->updateKScreenScreen(kscreenScreen);
- config->setScreen(kscreenScreen);
-
- //Removing removed outputs
- KScreen::OutputList outputs = config->outputs();
- Q_FOREACH(const KScreen::OutputPtr &output, outputs) {
- if (!m_outputs.contains(output->id())) {
- config->removeOutput(output->id());
- }
- }
-
- XRandROutput::Map::ConstIterator iter;
- KScreen::OutputList kscreenOutputs = config->outputs();
- for (iter = m_outputs.constBegin(); iter != m_outputs.constEnd(); ++iter) {
- XRandROutput *output = iter.value();
- KScreen::OutputPtr kscreenOutput = kscreenOutputs[output->id()];
-
- if (!kscreenOutput) {
- kscreenOutput = output->toKScreenOutput();
- kscreenOutputs.insert(kscreenOutput->id(), kscreenOutput);
- continue;
- }
- output->updateKScreenOutput(kscreenOutput);
- }
- config->setOutputs(kscreenOutputs);
-
- if (!config->primaryOutput() || config->primaryOutput()->id() != m_primaryOutput) {
- config->setPrimaryOutput(config->output(m_primaryOutput));
- }
-}
-
void XRandRConfig::applyKScreenConfig(const KScreen::ConfigPtr &config)
{
- KScreen::OutputList outputs = config->outputs();
- QSize newSize = screenSize(config);
+ const KScreen::OutputList kscreenOutputs = config->outputs();
+ const QSize newScreenSize = screenSize(config);
const QSize currentScreenSize = m_screen->currentSize();
-
- int neededCrtc = 0;
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/backends/xrandr/xrandrconfig.h
^
|
@@ -22,6 +22,7 @@
#include <QObject>
#include "xrandr.h"
+#include "xrandrcrtc.h"
#include "xrandroutput.h"
class XRandRScreen;
@@ -37,16 +38,21 @@
explicit XRandRConfig();
virtual ~XRandRConfig();
- void update();
-
XRandROutput::Map outputs() const;
- void addNewOutput(const RROutput id);
+ XRandROutput *output(xcb_randr_output_t output) const;
+
+ XRandRCrtc::Map crtcs() const;
+ XRandRCrtc *crtc(xcb_randr_crtc_t crtc) const;
+
+ XRandRScreen *screen() const;
+
+ void addNewOutput(xcb_randr_output_t id);
+ void addNewCrtc(xcb_randr_crtc_t crtc);
+ void removeOutput(xcb_randr_output_t id);
KScreen::ConfigPtr toKScreenConfig() const;
- void updateKScreenConfig(KScreen::ConfigPtr &config) const;
void applyKScreenConfig(const KScreen::ConfigPtr &config);
- int m_primaryOutput;
private:
/**
* We need to print stuff to discover the damn bug
@@ -55,20 +61,15 @@
void printConfig(const KScreen::ConfigPtr &config) const;
void printInternalCond() const;
QSize screenSize(const KScreen::ConfigPtr &config) const;
- bool setScreenSize(const QSize& size) const;
- void setPrimaryOutput(int outputId) const;
+ bool setScreenSize(const QSize &size) const;
+ void setPrimaryOutput(xcb_randr_output_t outputId) const;
bool disableOutput(const KScreen::OutputPtr &output) const;
bool enableOutput(const KScreen::OutputPtr &output) const;
- bool changeOutput(const KScreen::OutputPtr &output, int crtcId) const;
- XRandROutput* createNewOutput(RROutput id, bool primary);
+ bool changeOutput(const KScreen::OutputPtr &output) const;
+
XRandROutput::Map m_outputs;
+ XRandRCrtc::Map m_crtcs;
XRandRScreen *m_screen;
-
-Q_SIGNALS:
- void outputRemoved(int id);
-
-private Q_SLOTS:
- void outputRemovedSlot(int id);
};
#endif // XRANDRCONFIG_H
|
[-]
[+]
|
Added |
libkscreen-5.3.0.tar.xz/backends/xrandr/xrandrcrtc.cpp
^
|
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2015 Daniel Vrátil <dvratil@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License or (at your option) version 3 or any later version
+ * accepted by the membership of KDE e.V. (or its successor approved
+ * by the membership of KDE e.V.), which shall act as a proxy
+ * defined in Section 14 of version 3 of the license.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "xrandrcrtc.h"
+#include "xrandrconfig.h"
+#include "xrandr.h"
+
+#include "../xcbwrapper.h"
+
+XRandRCrtc::XRandRCrtc(xcb_randr_crtc_t crtc, XRandRConfig *config)
+ : QObject(config)
+ , m_crtc(crtc)
+ , m_mode(0)
+ , m_rotation(XCB_RANDR_ROTATION_ROTATE_0)
+{
+ update();
+}
+
+xcb_randr_crtc_t XRandRCrtc::crtc() const
+{
+ return m_crtc;
+}
+
+xcb_randr_mode_t XRandRCrtc::mode() const
+{
+ return m_mode;
+}
+
+QRect XRandRCrtc::geometry() const
+{
+ return m_geometry;
+}
+
+xcb_randr_rotation_t XRandRCrtc::rotation() const
+{
+ return m_rotation;
+}
+
+QVector<xcb_randr_output_t> XRandRCrtc::possibleOutputs()
+{
+ return m_possibleOutputs;
+}
+
+QVector<xcb_randr_output_t> XRandRCrtc::outputs() const
+{
+ return m_outputs;
+}
+
+bool XRandRCrtc::connectOutput(xcb_randr_output_t output)
+{
+ qCDebug(KSCREEN_XRANDR) << "Connected output" << output << "to CRTC" << m_crtc;
+ if (!m_possibleOutputs.contains(output)) {
+ qCDebug(KSCREEN_XRANDR) << "Output" << output << "is not an allowed output for CRTC" << m_crtc;
+ return false;
+ }
+
+ if (!m_outputs.contains(output)) {
+ m_outputs.append(output);
+ }
+ return true;
+}
+
+void XRandRCrtc::disconectOutput(xcb_randr_output_t output)
+{
+ qCDebug(KSCREEN_XRANDR) << "Disconnected output" << output << "from CRTC" << m_crtc;
+ const int index = m_outputs.indexOf(output);
+ if (index > -1) {
+ m_outputs.remove(index);
+ }
+}
+
+bool XRandRCrtc::isFree() const
+{
+ return m_outputs.isEmpty();
+}
+
+void XRandRCrtc::update()
+{
+ XCB::CRTCInfo crtcInfo(m_crtc, XCB_TIME_CURRENT_TIME);
+ m_mode = crtcInfo->mode;
+ m_rotation = (xcb_randr_rotation_t) crtcInfo->rotation;
+ m_geometry = QRect(crtcInfo->x, crtcInfo->y, crtcInfo->width, crtcInfo->height);
+ m_possibleOutputs.clear();
+ m_possibleOutputs.reserve(crtcInfo->num_possible_outputs);
+ xcb_randr_output_t *possible = xcb_randr_get_crtc_info_possible(crtcInfo);
+ for (int i = 0; i < crtcInfo->num_possible_outputs; ++i) {
+ m_possibleOutputs.append(possible[i]);
+ }
+ xcb_randr_output_t *outputs = xcb_randr_get_crtc_info_outputs(crtcInfo);
+ for (int i = 0; i < crtcInfo->num_outputs; ++i) {
+ m_outputs.append(outputs[i]);
+ }
+}
+
+void XRandRCrtc::update(xcb_randr_mode_t mode, xcb_randr_rotation_t rotation, const QRect &geom)
+{
+ m_mode = mode;
+ m_rotation = rotation;
+ m_geometry = geom;
+}
+
|
[-]
[+]
|
Added |
libkscreen-5.3.0.tar.xz/backends/xrandr/xrandrcrtc.h
^
|
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2015 Daniel Vrátil <dvratil@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License or (at your option) version 3 or any later version
+ * accepted by the membership of KDE e.V. (or its successor approved
+ * by the membership of KDE e.V.), which shall act as a proxy
+ * defined in Section 14 of version 3 of the license.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef XRANDRCRTC_H
+#define XRANDRCRTC_H
+
+#include <QObject>
+#include <QRect>
+#include <QVector>
+#include <QMap>
+
+#include <xcb/randr.h>
+
+class XRandRConfig;
+
+class XRandRCrtc : public QObject
+{
+ Q_OBJECT
+
+public:
+ typedef QMap<xcb_randr_crtc_t, XRandRCrtc*> Map;
+
+
+ XRandRCrtc(xcb_randr_crtc_t crtc, XRandRConfig *config);
+
+ xcb_randr_crtc_t crtc() const;
+ xcb_randr_mode_t mode() const;
+ xcb_randr_rotation_t rotation() const;
+ QRect geometry() const;
+ QVector<xcb_randr_output_t> possibleOutputs();
+ QVector<xcb_randr_output_t> outputs() const;
+
+ bool connectOutput(xcb_randr_output_t output);
+ void disconectOutput(xcb_randr_output_t output);
+
+ bool isFree() const;
+
+ void update();
+ void update(xcb_randr_crtc_t mode, xcb_randr_rotation_t rotation, const QRect &geom);
+
+private:
+ xcb_randr_crtc_t m_crtc;
+ xcb_randr_mode_t m_mode;
+ xcb_randr_rotation_t m_rotation;
+ QRect m_geometry;
+ QVector<xcb_randr_output_t> m_possibleOutputs;
+ QVector<xcb_randr_output_t> m_outputs;
+};
+
+#endif // XRANDRCRTC_H
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/backends/xrandr/xrandrmode.cpp
^
|
@@ -21,13 +21,14 @@
#include "mode.h"
#include "output.h"
-XRandRMode::XRandRMode(XRRModeInfo *modeInfo, XRandROutput *output)
+XRandRMode::XRandRMode(const xcb_randr_mode_info_t &modeInfo, XRandROutput *output)
: QObject(output)
{
- m_id = modeInfo->id;
- m_name = QString::fromUtf8(modeInfo->name);
- m_size = QSize(modeInfo->width, modeInfo->height);
- m_refreshRate = ((float) modeInfo->dotClock / ((float) modeInfo->hTotal * (float) modeInfo->vTotal));
+ m_id = modeInfo.id;
+ // FIXME XCB
+ //m_name = QString::fromUtf8(modeInfo->name);
+ m_size = QSize(modeInfo.width, modeInfo.height);
+ m_refreshRate = ((float) modeInfo.dot_clock / ((float) modeInfo.htotal * (float) modeInfo.vtotal));
}
@@ -47,7 +48,7 @@
return kscreenMode;
}
-int XRandRMode::id() const
+xcb_randr_mode_t XRandRMode::id() const
{
return m_id;
}
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/backends/xrandr/xrandrmode.h
^
|
@@ -25,7 +25,7 @@
#include <QSize>
#include "types.h"
-#include "xlibandxrandr.h"
+#include "../xcbwrapper.h"
class XRandROutput;
namespace KScreen
@@ -39,20 +39,20 @@
Q_OBJECT
public:
- typedef QMap<int, XRandRMode*> Map;
+ typedef QMap<xcb_randr_mode_t, XRandRMode*> Map;
- explicit XRandRMode(XRRModeInfo* modeInfo, XRandROutput *output);
+ explicit XRandRMode(const xcb_randr_mode_info_t &modeInfo, XRandROutput *output);
virtual ~XRandRMode();
KScreen::ModePtr toKScreenMode();
- int id() const;
+ xcb_randr_mode_t id() const;
QSize size() const;
float refreshRate() const;
QString name() const;
private:
- int m_id;
+ xcb_randr_mode_t m_id;
QString m_name;
QSize m_size;
float m_refreshRate;
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/backends/xrandr/xrandroutput.cpp
^
|
@@ -28,45 +28,34 @@
Q_DECLARE_METATYPE(QList<int>)
-XRandROutput::XRandROutput(int id, bool primary, XRandRConfig *config)
+XRandROutput::XRandROutput(xcb_randr_output_t id, XRandRConfig *config)
: QObject(config)
+ , m_config(config)
, m_id(id)
, m_type(KScreen::Output::Unknown)
- , m_rotation(KScreen::Output::None)
- , m_connected(0)
- , m_enabled(0)
, m_primary(0)
- , m_changedProperties(0)
+ , m_crtc(0)
{
- XRROutputInfo *outputInfo = XRandR::XRROutput(m_id);
- updateOutput(outputInfo);
- updateModes(outputInfo);
- fetchType();
- m_primary = primary;
- m_widthMm = outputInfo->mm_width;
- m_heightMm = outputInfo->mm_height;
-
- XRRFreeOutputInfo(outputInfo);
+ init();
}
-
XRandROutput::~XRandROutput()
{
}
-int XRandROutput::id() const
+xcb_randr_output_t XRandROutput::id() const
{
return m_id;
}
bool XRandROutput::isConnected() const
{
- return m_connected;
+ return m_connected == XCB_RANDR_CONNECTION_CONNECTED;
}
bool XRandROutput::isEnabled() const
{
- return m_enabled;
+ return m_crtc != Q_NULLPTR && m_crtc->mode() != XCB_NONE;
}
bool XRandROutput::isPrimary() const
@@ -76,7 +65,7 @@
QPoint XRandROutput::position() const
{
- return m_position;
+ return m_crtc ? m_crtc->geometry().topLeft() : QPoint();
}
XRandRMode::Map XRandROutput::modes() const
@@ -86,12 +75,15 @@
QString XRandROutput::currentModeId() const
{
- return m_currentMode;
+ return m_crtc ? QString::number(m_crtc->mode()) : QString();
}
XRandRMode* XRandROutput::currentMode() const
{
- int modeId = m_currentMode.toInt();
+ if (!m_crtc) {
+ return Q_NULLPTR;
+ }
+ int modeId = m_crtc->mode();
if (!m_modes.contains(modeId)) {
return 0;
}
@@ -101,7 +93,7 @@
KScreen::Output::Rotation XRandROutput::rotation() const
{
- return m_rotation;
+ return static_cast<KScreen::Output::Rotation>(m_crtc ? m_crtc->rotation() : XCB_RANDR_ROTATION_ROTATE_0);
}
QByteArray XRandROutput::edid() const
@@ -120,181 +112,186 @@
return m_edid;
}
-void XRandROutput::update(PrimaryChange primary)
+XRandRCrtc* XRandROutput::crtc() const
{
- XRROutputInfo *outputInfo = XRandR::XRROutput(m_id);
- if (!outputInfo) {
- Q_EMIT outputRemoved(m_id);
- deleteLater();
- return;
- }
+ return m_crtc;
+}
- m_changedProperties = 0;
- updateOutput(outputInfo);
+void XRandROutput::update()
+{
+ init();
+}
+
+void XRandROutput::update(xcb_randr_crtc_t crtc, xcb_randr_mode_t mode, xcb_randr_connection_t conn, bool primary)
+{
+ qCDebug(KSCREEN_XRANDR) << "XRandROutput" << m_id << "update";
+ qCDebug(KSCREEN_XRANDR) << "\tm_connected:" << m_connected;
+ qCDebug(KSCREEN_XRANDR) << "\tm_crtc" << m_crtc;
+ qCDebug(KSCREEN_XRANDR) << "\tCRTC:" << crtc;
+ qCDebug(KSCREEN_XRANDR) << "\tMODE:" << mode;
+ qCDebug(KSCREEN_XRANDR) << "\tConnection:" << conn;
+ qCDebug(KSCREEN_XRANDR) << "\tPrimary:" << primary;
- if (primary != NoChange) {
- const bool setPrimary = (primary == SetPrimary);
- if (m_primary != setPrimary) {
- m_primary = setPrimary;
- m_changedProperties |= PropertyPrimary;
+ // Connected or disconnected
+ if (isConnected() != (conn == XCB_RANDR_CONNECTION_CONNECTED)) {
+ if (conn == XCB_RANDR_CONNECTION_CONNECTED) {
+ // New monitor has been connected, refresh everything
+ init();
+ } else {
+ // Disconnected
+ m_connected = conn;
+ m_clones.clear();
+ m_heightMm = 0;
+ m_widthMm = 0;
+ m_type = KScreen::Output::Unknown;
+ qDeleteAll(m_modes);
+ m_modes.clear();
+ m_preferredModes.clear();
}
}
- if (m_changedProperties == 0) {
- m_changedProperties = PropertyNone;
+ // A monitor has been enabled or disabled
+ // We don't use isEnabled(), because it checks for crtc && crtc->mode(), however
+ // crtc->mode may already be unset due to xcb_randr_crtc_tChangeNotify coming before
+ // xcb_randr_output_tChangeNotify and reseting the CRTC mode
+
+ if ((m_crtc == Q_NULLPTR) != (crtc == XCB_NONE)) {
+ if (crtc == XCB_NONE && mode == XCB_NONE) {
+ // Monitor has been disabled
+ m_crtc->disconectOutput(m_id);
+ m_crtc = 0;
+ } else {
+ m_crtc = m_config->crtc(crtc);
+ m_crtc->connectOutput(m_id);
+ }
}
- XRRFreeOutputInfo(outputInfo);
+ // Primary has changed
+ m_primary = primary;
}
-void XRandROutput::updateOutput(const XRROutputInfo *outputInfo)
+void XRandROutput::setIsPrimary(bool primary)
{
- const bool isConnected = (outputInfo->connection == RR_Connected);
-
- if (m_name != outputInfo->name) {
- m_name = outputInfo->name;
- m_changedProperties |= PropertyName;
- }
+ m_primary = primary;
+}
- if (m_enabled != (outputInfo->crtc != None)) {
- m_enabled = outputInfo->crtc != None;
- m_changedProperties |= PropertyEnabled;
- }
- QList<int> clones;
- for (int i = 0; i < outputInfo->nclone; i++) {
- clones << outputInfo->clones[i];
- }
- if (isConnected && (m_clones != clones)) {
- m_clones = clones;
- m_changedProperties |= PropertyClones;
+void XRandROutput::init()
+{
+ XCB::OutputInfo outputInfo(m_id, XCB_TIME_CURRENT_TIME);
+ Q_ASSERT(outputInfo);
+ if (!outputInfo) {
+ return;
}
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/backends/xrandr/xrandroutput.h
^
|
@@ -24,11 +24,12 @@
#include <QVariant>
#include <QPointer>
-#include "xlibandxrandr.h"
#include "xrandrmode.h"
#include "output.h"
+#include "../xcbwrapper.h"
class XRandRConfig;
+class XRandRCrtc;
namespace KScreen
{
class Config;
@@ -38,42 +39,22 @@
class XRandROutput : public QObject
{
Q_OBJECT
- Q_FLAGS(Property Properties)
public:
- typedef QMap<int, XRandROutput*> Map;
+ typedef QMap<xcb_randr_output_t, XRandROutput*> Map;
- enum Property {
- PropertyNone = 1 << 0,
- PropertyId = 1 << 1,
- PropertyName = 1 << 2,
- PropertyIcon = 1 << 3,
- PropertyModes = 1 << 4,
- PropertyPos = 1 << 5,
- PropertyRotation = 1 << 6,
- PropertyCurrentMode = 1 << 7,
- PropertyConnected = 1 << 8,
- PropertyEnabled = 1 << 9,
- PropertyPrimary = 1 << 10,
- PropertyClones = 1 << 11,
- PropertyEdid = 1 << 12,
- PropertyPreferredMode = 1 << 13
- };
-
- enum PrimaryChange {
- NoChange = 0,
- SetPrimary = 1,
- UnsetPrimary = 2,
- };
+ explicit XRandROutput(xcb_randr_output_t id, XRandRConfig *config);
+ virtual ~XRandROutput();
- Q_DECLARE_FLAGS(Properties, Property)
+ void disabled();
+ void disconnected();
- explicit XRandROutput(int id, bool primary, XRandRConfig *config = 0);
- virtual ~XRandROutput();
+ void update();
+ void update(xcb_randr_crtc_t crtc, xcb_randr_mode_t mode, xcb_randr_connection_t conn, bool primary);
- void update(PrimaryChange primary = NoChange);
+ void setIsPrimary(bool primary);
- int id() const;
+ xcb_randr_output_t id() const;
bool isEnabled() const;
bool isConnected() const;
bool isPrimary() const;
@@ -82,42 +63,34 @@
XRandRMode::Map modes() const;
XRandRMode* currentMode() const;
KScreen::Output::Rotation rotation() const;
- inline bool isHorizontal() const { return ((m_rotation == KScreen::Output::None) || (m_rotation == KScreen::Output::Inverted)); }
+ bool isHorizontal() const;
QByteArray edid() const;
+ XRandRCrtc* crtc() const;
KScreen::OutputPtr toKScreenOutput() const;
- void updateKScreenOutput(KScreen::OutputPtr &output) const;
-
- void updateModes(const XRROutputInfo *outputInfo);
- void addNewOutput(const RROutput output);
-
-Q_SIGNALS:
- void outputRemoved(int id);
private:
- void updateOutput(const XRROutputInfo *outputInfo);
- void fetchType();
- KScreen::Output::Type typeFromName();
- QByteArray typeFromProperty() const;
+ void init();
+ void updateModes(const XCB::OutputInfo &outputInfo);
+
+ static KScreen::Output::Type fetchOutputType(xcb_randr_output_t outputId, const QString &name);
+ static KScreen::Output::Type typeFromName(const QString &name);
+ static QByteArray typeFromProperty(xcb_randr_output_t outputId);
- int m_id;
+ XRandRConfig *m_config;
+ xcb_randr_output_t m_id;
QString m_name;
+ xcb_randr_connection_t m_connected;
KScreen::Output::Type m_type;
QString m_icon;
XRandRMode::Map m_modes;
- QPoint m_position;
- KScreen::Output::Rotation m_rotation;
- QString m_currentMode;
QStringList m_preferredModes;
- bool m_connected;
- bool m_enabled;
bool m_primary;
- QList<int> m_clones;
+ QList<xcb_randr_output_t> m_clones;
mutable QByteArray m_edid;
unsigned int m_widthMm;
unsigned int m_heightMm;
-
- mutable int m_changedProperties;
+ XRandRCrtc *m_crtc;
};
Q_DECLARE_METATYPE(XRandROutput::Map)
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/backends/xrandr/xrandrscreen.cpp
^
|
@@ -19,15 +19,19 @@
#include "xrandrscreen.h"
#include "xrandrconfig.h"
-#include "xlibandxrandr.h"
-
#include "screen.h"
#include "config.h"
+
#include <QX11Info>
+#include "../xcbwrapper.h"
+
XRandRScreen::XRandRScreen(XRandRConfig *config)
: QObject(config)
{
+ XCB::ScreenSize size(XRandR::rootWindow());
+ m_maxSize = QSize(size->max_width, size->max_height);
+ m_minSize = QSize(size->min_width, size->min_height);
update();
}
@@ -37,19 +41,17 @@
void XRandRScreen::update()
{
- Display *display = QX11Info::display();
- const int screen = DefaultScreen(display);
- const Window rootWindow = XRootWindow(display, screen);
-
- XRRGetScreenSizeRange (display, rootWindow,
- &m_minSize.rwidth(), &m_minSize.rheight(),
- &m_maxSize.rwidth(), &m_maxSize.rheight());
- m_currentSize = QSize(DisplayWidth(display, screen),DisplayHeight(display, screen));
+ xcb_screen_t *screen = XCB::screenOfDisplay(XCB::connection(), QX11Info::appScreen());
+ m_currentSize = QSize(screen->width_in_pixels, screen->height_in_pixels);
+}
+
+void XRandRScreen::update(const QSize &size)
+{
+ m_currentSize = size;
}
QSize XRandRScreen::currentSize()
{
- update();
return m_currentSize;
}
@@ -60,7 +62,7 @@
kscreenScreen->setMaxSize(m_maxSize);
kscreenScreen->setMinSize(m_minSize);
kscreenScreen->setCurrentSize(m_currentSize);
- kscreenScreen->setMaxActiveOutputsCount(XRandR::screenResources()->ncrtc);
+ kscreenScreen->setMaxActiveOutputsCount(XRandR::screenResources()->num_crtcs);
return kscreenScreen;
}
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/backends/xrandr/xrandrscreen.h
^
|
@@ -43,6 +43,7 @@
void updateKScreenScreen(KScreen::ScreenPtr &screen) const;
void update();
+ void update(const QSize &size);
QSize currentSize();
private:
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/backends/xrandr1.1/CMakeLists.txt
^
|
@@ -4,12 +4,12 @@
${KDE4_INCLUDES}
${CMAKE_BUILD_DIR}
${QT_INCLUDES}
- ${X11_Xrandr_INCLUDE_PATH}
)
set(xrandr11_SRCS
xrandr11.cpp
- ../xrandr/xrandrxcbhelper.cpp
+ ../xcbeventlistener.cpp
+ ../xcbwrapper.cpp
)
add_library(KSC_XRandR11 MODULE ${xrandr11_SRCS})
@@ -18,8 +18,6 @@
target_link_libraries(KSC_XRandR11 Qt5::Core
Qt5::Gui
Qt5::X11Extras
- ${X11_LIBRARIES}
- ${X11_Xrandr_LIB}
${XCB_LIBRARIES}
KF5::Screen
)
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/backends/xrandr1.1/xrandr11.cpp
^
|
@@ -17,8 +17,7 @@
*************************************************************************************/
#include "xrandr11.h"
-#include "wrapper.h"
-#include "../xrandr/xrandrxcbhelper.h"
+#include "../xcbeventlistener.h"
#include "config.h"
#include "edid.h"
@@ -44,28 +43,32 @@
xcb_generic_error_t *error = 0;
xcb_randr_query_version_reply_t* version;
- version = xcb_randr_query_version_reply(connection(), xcb_randr_query_version(connection(), XCB_RANDR_MAJOR_VERSION, XCB_RANDR_MINOR_VERSION), &error);
+ version = xcb_randr_query_version_reply(XCB::connection(),
+ xcb_randr_query_version(XCB::connection(), XCB_RANDR_MAJOR_VERSION, XCB_RANDR_MINOR_VERSION), &error);
if (!version || error) {
free(error);
+ XCB::closeConnection();
qCDebug(KSCREEN_XRANDR11) << "Can't get XRandR version";
return;
}
if (version->major_version != 1 || version->minor_version != 1) {
+ XCB::closeConnection();
qCDebug(KSCREEN_XRANDR11) << "This backend is only for XRandR 1.1, your version is: " << version->major_version << "." << version->minor_version;
return;
}
- m_x11Helper = new XRandRXCBHelper();
+ m_x11Helper = new XCBEventListener();
- connect(m_x11Helper, SIGNAL(outputsChanged()), SLOT(updateConfig()));
+ connect(m_x11Helper, &XCBEventListener::outputsChanged,
+ this, &XRandR11::updateConfig);
m_valid = true;
}
XRandR11::~XRandR11()
{
- closeConnection();
+ XCB::closeConnection();
delete m_x11Helper;
}
@@ -90,9 +93,9 @@
KScreen::ConfigPtr config(new KScreen::Config);
const int screenId = QX11Info::appScreen();
- xcb_screen_t* xcbScreen = screen_of_display(connection(), screenId);
- const ScreenInfo info(xcbScreen->root);
- const ScreenSize size(xcbScreen->root);
+ xcb_screen_t* xcbScreen = XCB::screenOfDisplay(XCB::connection(), screenId);
+ const XCB::ScreenInfo info(xcbScreen->root);
+ const XCB::ScreenSize size(xcbScreen->root);
if (info->config_timestamp == m_currentTimestamp) {
return m_currentConfig;
@@ -101,8 +104,13 @@
KScreen::ScreenPtr screen(new KScreen::Screen);
screen->setId(screenId);
screen->setCurrentSize(QSize(xcbScreen->width_in_pixels, xcbScreen->height_in_pixels));
- screen->setMaxSize(QSize(size->max_width, size->max_height));
- screen->setMinSize(QSize(size->min_width, size->min_height));
+ if (size) { // RRGetScreenSize may file on VNC/RDP connections
+ screen->setMaxSize(QSize(size->max_width, size->max_height));
+ screen->setMinSize(QSize(size->min_width, size->min_height));
+ } else {
+ screen->setMaxSize(screen->currentSize());
+ screen->setMinSize(screen->currentSize());
+ }
screen->setMaxActiveOutputsCount(1);
config->setScreen(screen);
@@ -125,26 +133,28 @@
KScreen::ModePtr mode;
KScreen::ModeList modes;
- xcb_randr_refresh_rates_iterator_t ite = xcb_randr_get_screen_info_rates_iterator(info.data());
- xcb_randr_screen_size_t* sizes = xcb_randr_get_screen_info_sizes(info.data());
+ auto iter = xcb_randr_get_screen_info_rates_iterator(info);
+ xcb_randr_screen_size_t* sizes = xcb_randr_get_screen_info_sizes(info);
for (int x = 0; x < info->nSizes; x++) {
- const uint16_t* rates = xcb_randr_refresh_rates_rates(ite.data);
- const int nrates = xcb_randr_refresh_rates_rates_length(ite.data);
+ const xcb_randr_screen_size_t size = sizes[x];
+ const uint16_t* rates = xcb_randr_refresh_rates_rates(iter.data);
+ const int nrates = xcb_randr_refresh_rates_rates_length(iter.data);
for (int j = 0; j < nrates; j++) {
+ float rate = rates[j];
mode = KScreen::ModePtr(new KScreen::Mode);
- mode->setId(QString::number(x) + "-" + QString::number(j));
- mode->setSize(QSize(sizes[x].width, sizes[x].height));
- mode->setRefreshRate((float) rates[j]);
- mode->setName(QString(QString::number(sizes[x].width) + "x" + QString::number(sizes[x].height)));
+ mode->setId(QString::fromLatin1("%1-%2").arg(x).arg(j));
+ mode->setSize(QSize(size.width, size.height));
+ mode->setRefreshRate(rate);
+ mode->setName(QString::fromLatin1("%1x%2").arg(size.width).arg(size.height));
- if (x == info->sizeID && rates[j] == info->rate) {
+ if (x == info->sizeID && rate == info->rate) {
output->setCurrentModeId(mode->id());
}
modes.insert(mode->id(), mode);
}
- xcb_randr_refresh_rates_next(&ite);
+ xcb_randr_refresh_rates_next(&iter);
}
output->setModes(modes);
@@ -157,18 +167,19 @@
const KScreen::ModePtr mode = output->currentMode();
const int screenId = QX11Info::appScreen();
- xcb_screen_t* xcbScreen = screen_of_display(connection(), screenId);
+ xcb_screen_t* xcbScreen = XCB::screenOfDisplay(XCB::connection(), screenId);
- const ScreenInfo info(xcbScreen->root);
+ const XCB::ScreenInfo info(xcbScreen->root);
xcb_generic_error_t *err;
- xcb_randr_set_screen_config_cookie_t cookie;
- xcb_randr_set_screen_config_reply_t *result;
const int sizeId = mode->id().split("-").first().toInt();
- cookie = xcb_randr_set_screen_config(connection(), xcbScreen->root, CurrentTime, info->config_timestamp, sizeId,
+ auto cookie = xcb_randr_set_screen_config(XCB::connection(), xcbScreen->root,
+ XCB_CURRENT_TIME, info->config_timestamp, sizeId,
(short) output->rotation(), mode->refreshRate());
- result = xcb_randr_set_screen_config_reply(connection(), cookie, &err);
-
- delete result;
+ XCB::ScopedPointer<xcb_randr_set_screen_config_reply_t> reply(
+ xcb_randr_set_screen_config_reply(XCB::connection(), cookie, &err));
+ if (err) {
+ free(err);
+ }
}
void XRandR11::updateConfig()
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/backends/xrandr1.1/xrandr11.h
^
|
@@ -19,12 +19,13 @@
#ifndef XRANDR11_BACKEND_H
#define XRANDR11_BACKEND_H
-#include "xlibandxcb.h"
#include "abstractbackend.h"
+#include "../xcbwrapper.h"
+
#include <QtCore/QObject>
#include <QLoggingCategory>
-class XRandRXCBHelper;
+class XCBEventListener;
class XRandR11 : public KScreen::AbstractBackend
{
@@ -46,10 +47,11 @@
private:
bool m_valid;
- XRandRXCBHelper* m_x11Helper;
+ XCBEventListener* m_x11Helper;
KScreen::ConfigPtr m_currentConfig;
xcb_timestamp_t m_currentTimestamp;
};
Q_DECLARE_LOGGING_CATEGORY(KSCREEN_XRANDR11)
+
#endif //FAKE_BACKEND_H
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/interfaces/org.kde.KScreen.FakeBackend.xml
^
|
@@ -21,5 +21,12 @@
<arg type="i" name="outputId" direction="in" />
<arg type="i" name="rotation" direction="in" />
</method>
+ <method name="addOutput">
+ <arg type="i" name="outputId" direction="in" />
+ <arg type="s" name="name" direction="in" />
+ </method>
+ <method name="removeOutput">
+ <arg type="i" name="outputId" direction="in" />
+ </method>
</interface>
</node>
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/src/backendlauncher/backendloader.cpp
^
|
@@ -33,11 +33,13 @@
BackendLoader::BackendLoader()
: QObject()
+ , mBackend(0)
{
}
BackendLoader::~BackendLoader()
{
+ delete mBackend;
}
bool BackendLoader::loadBackend(const QString& backend)
@@ -47,7 +49,7 @@
const QStringList paths = QCoreApplication::libraryPaths();
qCDebug(KSCREEN_BACKEND_LAUNCHER) << "Lookup paths: " << paths;
Q_FOREACH (const QString &path, paths) {
- const QDir dir(path + QDir::separator() + QLatin1String("/kf5/kscreen/"),
+ const QDir dir(path + QLatin1String("/kf5/kscreen/"),
backendFilter,
QDir::SortFlags(QDir::QDir::NoSort),
QDir::NoDotAndDotDot | QDir::Files);
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/src/backendlauncher/main.cpp
^
|
@@ -28,9 +28,10 @@
int main(int argc, char **argv)
{
+ QGuiApplication::setDesktopSettingsAware(false);
QGuiApplication app(argc, argv);
- BackendLoader launcher;
+ BackendLoader *loader = new BackendLoader;
QCommandLineOption backendOption(QLatin1String("backend"),
QLatin1String("Backend to load. When not specified, BackendLauncher will "
@@ -44,9 +45,9 @@
bool success = false;
if (parser.isSet(backendOption)) {
- success = launcher.loadBackend(parser.value(backendOption));
+ success = loader->loadBackend(parser.value(backendOption));
} else {
- success = launcher.loadBackend();
+ success = loader->loadBackend();
}
// We failed to load any backend: abort immediatelly
@@ -56,15 +57,15 @@
// Create BackendDBusWrapper that takes implements the DBus interface and translates
// DBus calls to backend implementations. It will also take care of terminating this
- // launcher when no other KScreen-enabled processes are running
- BackendDBusWrapper backendWrapper(launcher.backend());
+ // loader when no other KScreen-enabled processes are running
+ BackendDBusWrapper backendWrapper(loader->backend());
if (!backendWrapper.init()) {
// Loading failed, maybe it failed because another process is already running; if so we still want to print the path before we exit
// Check if another Backend Launcher with this particular backend is already running
- const bool alreadyRunning = launcher.checkIsAlreadyRunning();
+ const bool alreadyRunning = loader->checkIsAlreadyRunning();
if (alreadyRunning) {
// If it is, let caller now it's DBus service name and terminate
- printf("%s", qPrintable(launcher.backend()->serviceName()));
+ printf("%s", qPrintable(loader->backend()->serviceName()));
fflush(stdout);
return BackendLoader::BackendAlreadyExists;
}
@@ -72,9 +73,14 @@
}
// Now let caller now what's our DBus service name, so it can connect to us
- printf("%s", qPrintable(launcher.backend()->serviceName()));
+ printf("%s", qPrintable(loader->backend()->serviceName()));
fflush(stdout);
// And go!
- return app.exec();
+ const int ret = app.exec();
+
+ // Make sure the backend is destroyed and unloaded before we return
+ delete loader;
+
+ return ret;
}
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/src/config.cpp
^
|
@@ -28,31 +28,76 @@
using namespace KScreen;
-class Config::Private
+class Config::Private : public QObject
{
- public:
- Private():
- valid(true)
+ Q_OBJECT
+public:
+ Private(Config *parent)
+ : QObject(parent)
+ , valid(true)
+ , q(parent)
{ }
- Private(const Private &other):
- valid(other.valid),
- primaryOutput(other.primaryOutput)
+ KScreen::OutputPtr findPrimaryOutput() const
{
- screen = other.screen->clone();
- Q_FOREACH (const OutputPtr &otherOutput, other.outputs) {
- outputs.insert(otherOutput->id(), otherOutput->clone());
- }
+ auto iter = std::find_if(outputs.constBegin(), outputs.constEnd(),
+ [](const KScreen::OutputPtr &output) -> bool {
+ return output->isPrimary();
+ });
+ return iter == outputs.constEnd() ? KScreen::OutputPtr() : iter.value();
+ }
+
+ void onPrimaryOutputChanged()
+ {
+ const KScreen::OutputPtr output(qobject_cast<KScreen::Output*>(sender()), [](void *) {});
+ Q_ASSERT(output);
+ if (output->isPrimary()) {
+ q->setPrimaryOutput(output);
+ } else {
+ q->setPrimaryOutput(findPrimaryOutput());
+ }
+ }
+
+ OutputList::Iterator removeOutput(OutputList::Iterator iter)
+ {
+ if (iter == outputs.end()) {
+ return iter;
+ }
+
+ OutputPtr output = iter.value();
+ if (!output) {
+ return outputs.erase(iter);
+ }
+
+ const int outputId = iter.key();
+ iter = outputs.erase(iter);
+
+ if (primaryOutput == output) {
+ q->setPrimaryOutput(OutputPtr());
+ }
+ output->disconnect(q);
+
+ Q_EMIT q->outputRemoved(outputId);
+
+ return iter;
}
bool valid;
ScreenPtr screen;
OutputPtr primaryOutput;
OutputList outputs;
+
+private:
+ Config *q;
};
bool Config::canBeApplied(const ConfigPtr &config)
{
+ return canBeApplied(config, ValidityFlag::None);
+}
+
+bool Config::canBeApplied(const ConfigPtr &config, ValidityFlags flags)
+{
ConfigPtr currentConfig = BackendManager::instance()->config();
if (!currentConfig) {
qCDebug(KSCREEN) << "canBeApplied: Current config not available, returning false";
@@ -93,7 +138,6 @@
return false;
}
-
const ModePtr currentMode = output->currentMode();
const QSize outputSize = currentMode->size();
@@ -124,6 +168,11 @@
}
}
+ if (flags & ValidityFlag::RequireAtLeastOneEnabledScreen && enabledOutputsCount == 0) {
+ qCDebug(KSCREEN) << "canBeAppled: There are no enabled screens, at least one required";
+ return false;
+ }
+
const int maxEnabledOutputsCount = config->screen()->maxActiveOutputsCount();
if (enabledOutputsCount > maxEnabledOutputsCount) {
qCDebug(KSCREEN) << "canBeApplied: Too many active screens. Requested: " << enabledOutputsCount << ", Max: " << maxEnabledOutputsCount;
@@ -144,13 +193,7 @@
Config::Config()
: QObject(0)
- , d(new Private())
-{
-}
-
-Config::Config(Config::Private *dd)
- : QObject()
- , d(dd)
+ , d(new Private(this))
{
}
@@ -162,7 +205,14 @@
ConfigPtr Config::clone() const
{
- return ConfigPtr(new Config(new Private(*d)));
+ ConfigPtr newConfig(new Config());
+ newConfig->d->screen = d->screen->clone();
+ for (const OutputPtr &ourOutput : d->outputs) {
+ newConfig->addOutput(ourOutput->clone());
+ }
+ newConfig->d->primaryOutput = newConfig->d->findPrimaryOutput();
+
+ return newConfig;
}
@@ -178,11 +228,7 @@
OutputPtr Config::output(int outputId) const
{
- if (!d->outputs.contains(outputId)) {
- return OutputPtr();
- }
-
- return d->outputs[outputId];
+ return d->outputs.value(outputId);
}
OutputList Config::outputs() const
@@ -209,52 +255,62 @@
return d->primaryOutput;
}
- Q_FOREACH(const OutputPtr &output, d->outputs) {
- if (output->isPrimary()) {
- d->primaryOutput = output;
- return d->primaryOutput;
- }
- }
-
- return OutputPtr();
+ d->primaryOutput = d->findPrimaryOutput();
+ return d->primaryOutput;
}
-void Config::setPrimaryOutput(const OutputPtr &output)
+void Config::setPrimaryOutput(const OutputPtr &newPrimary)
{
- if (primaryOutput() == output) {
+ // Don't call primaryOutput(): at this point d->primaryOutput is either
+ // initialized, or we need to look for the primary anyway
+ if (d->primaryOutput == newPrimary) {
return;
}
- qDebug(KSCREEN) << "Primary output changed from" << d->primaryOutput
- << "(" << (d->primaryOutput.isNull() ? "none" : d->primaryOutput->name()) << ") to"
- << output << "(" << (output.isNull() ? "none" : output->name()) << ")";
- d->primaryOutput = output;
+ qDebug(KSCREEN) << "Primary output changed from" << primaryOutput()
+ << "(" << (primaryOutput().isNull() ? "none" : primaryOutput()->name()) << ") to"
+ << newPrimary << "(" << (newPrimary.isNull() ? "none" : newPrimary->name()) << ")";
+
+ for (OutputPtr &output : d->outputs) {
+ disconnect(output.data(), &KScreen::Output::isPrimaryChanged,
+ d, &KScreen::Config::Private::onPrimaryOutputChanged);
+ output->setPrimary(output == newPrimary);
+ connect(output.data(), &KScreen::Output::isPrimaryChanged,
+ d, &KScreen::Config::Private::onPrimaryOutputChanged);
+ }
- Q_EMIT primaryOutputChanged(output);
+ d->primaryOutput = newPrimary;
+ Q_EMIT primaryOutputChanged(newPrimary);
}
void Config::addOutput(const OutputPtr &output)
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/src/config.h
^
|
@@ -50,6 +50,26 @@
Q_PROPERTY(OutputList outputs READ outputs)
public:
+ enum class ValidityFlag {
+ None = 0x0,
+ RequireAtLeastOneEnabledScreen = 0x1
+ };
+ Q_DECLARE_FLAGS(ValidityFlags, ValidityFlag)
+
+ /**
+ * Validates that a config can be applied in the current system
+ *
+ * Each system has different constrains, this method will test
+ * the given config with those constrains to see if it
+ * can be applied.
+ *
+ * @arg config to be checked
+ * @flags enable additional optional checks
+ * @return true if the configuration can be applied, false if not.
+ * @since 5.3.0
+ */
+ static bool canBeApplied(const ConfigPtr &config, ValidityFlags flags);
+
/**
* Validates that a config can be applied in the current system
*
@@ -109,8 +129,6 @@
class Private;
Private * const d;
-
- Config(Private *dd);
};
} //KScreen namespace
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/src/configmonitor.cpp
^
|
@@ -50,16 +50,15 @@
QPointer<org::kde::kscreen::Backend> mBackend;
bool mFirstBackend;
- QSet<int> mPendingEDIDRequests;
- KScreen::ConfigPtr mPendingConfigUpdate;
+ QMap<KScreen::ConfigPtr, QList<int>> mPendingEDIDRequests;
private:
ConfigMonitor *q;
};
ConfigMonitor::Private::Private(ConfigMonitor *q)
: QObject(q)
- , q(q)
, mFirstBackend(true)
+ , q(q)
{
}
@@ -117,17 +116,17 @@
Q_FOREACH (OutputPtr output, newConfig->connectedOutputs()) {
if (!output->edid() && output->isConnected()) {
QDBusPendingReply<QByteArray> reply = mBackend->getEdid(output->id());
- mPendingEDIDRequests.insert(output->id());
+ mPendingEDIDRequests[newConfig].append(output->id());
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply);
watcher->setProperty("outputId", output->id());
+ watcher->setProperty("config", QVariant::fromValue(newConfig));
connect(watcher, &QDBusPendingCallWatcher::finished,
this, &ConfigMonitor::Private::edidReady);
}
}
- if (!mPendingEDIDRequests.isEmpty()) {
- qCDebug(KSCREEN) << "Requesting missing EDID for outputs" << mPendingEDIDRequests;
- mPendingConfigUpdate = newConfig;
+ if (mPendingEDIDRequests.contains(newConfig)) {
+ qCDebug(KSCREEN) << "Requesting missing EDID for outputs" << mPendingEDIDRequests[newConfig];
} else {
updateConfigs(newConfig);
}
@@ -136,31 +135,27 @@
void ConfigMonitor::Private::edidReady(QDBusPendingCallWatcher* watcher)
{
const int outputId = watcher->property("outputId").toInt();
- Q_ASSERT(!mPendingConfigUpdate.isNull());
- Q_ASSERT(mPendingEDIDRequests.contains(outputId));
+ const ConfigPtr config = watcher->property("config").value<KScreen::ConfigPtr>();
+ Q_ASSERT(mPendingEDIDRequests.contains(config));
+ Q_ASSERT(mPendingEDIDRequests[config].contains(outputId));
watcher->deleteLater();
- mPendingEDIDRequests.remove(watcher->property("outputId").toInt());
+ mPendingEDIDRequests[config].removeOne(outputId);
const QDBusPendingReply<QByteArray> reply = *watcher;
if (reply.isError()) {
qCWarning(KSCREEN) << "Error when retrieving EDID: " << reply.error().message();
- if (mPendingEDIDRequests.isEmpty()) {
- updateConfigs(mPendingConfigUpdate);
+ } else {
+ const QByteArray edid = reply.argumentAt<0>();
+ if (!edid.isEmpty()) {
+ OutputPtr output = config->output(outputId);
+ output->setEdid(edid);
}
- return;
- }
-
- const QByteArray edid = reply.argumentAt<0>();
- if (!edid.isEmpty()) {
- OutputPtr output = mPendingConfigUpdate->output(outputId);
- output->setEdid(edid);
}
- if (mPendingEDIDRequests.isEmpty()) {
- const KScreen::ConfigPtr config = mPendingConfigUpdate;
- mPendingConfigUpdate.clear();
+ if (mPendingEDIDRequests[config].isEmpty()) {
+ mPendingEDIDRequests.remove(config);
updateConfigs(config);
}
}
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/src/configoperation.cpp
^
|
@@ -104,7 +104,7 @@
Q_UNUSED(op);
loop.quit();
});
- loop.exec();
+ loop.exec(QEventLoop::ExcludeUserInputEvents);
return !hasError();
}
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/src/configserializer.cpp
^
|
@@ -159,6 +159,7 @@
}
arg.endMapEntry();
}
+ arg.endMap();
return QSize(w, h);
}
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/src/getconfigoperation.cpp
^
|
@@ -103,6 +103,10 @@
pendingEDIDs = 0;
org::kde::kscreen::Backend *backend = watcher->property("backend").value<org::kde::kscreen::Backend*>();
Q_FOREACH (const OutputPtr &output, config->outputs()) {
+ if (!output->isConnected()) {
+ continue;
+ }
+
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(backend->getEdid(output->id()), this);
watcher->setProperty("outputId", output->id());
connect(watcher, &QDBusPendingCallWatcher::finished,
@@ -126,10 +130,7 @@
const QByteArray edidData = reply.value();
const int outputId = watcher->property("outputId").toInt();
- OutputList outputs = config->outputs();
- outputs[outputId]->setEdid(edidData);
- config->setOutputs(outputs);
-
+ config->output(outputId)->setEdid(edidData);
if (--pendingEDIDs == 0) {
q->emitResult();
}
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/src/output.cpp
^
|
@@ -421,7 +421,11 @@
return QRect();
}
- return QRect(pos(), currentMode()->size());
+ if (isHorizontal()) {
+ return QRect(pos(), currentMode()->size());
+ } else {
+ return QRect(pos(), QSize(currentMode()->size().height(), currentMode()->size().width()));
+ }
}
void Output::apply(const OutputPtr& other)
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/src/output.h
^
|
@@ -151,7 +151,10 @@
void setSizeMm(const QSize &size);
/**
- * @returns a rectangle containing the current output position and size.
+ * Returns a rectangle containing the current output position and size.
+ *
+ * The geometry takes rotation into account, so if an 1920x1200 output
+ * is rotated by 90 deg, the geometry will be (0, 0, 1200, 1920)!
*/
QRect geometry() const;
@@ -173,7 +176,6 @@
Private * const d;
Output(Private *dd);
-
};
} //KScreen namespace
|
[-]
[+]
|
Changed |
libkscreen-5.3.0.tar.xz/src/types.h
^
|
@@ -26,16 +26,16 @@
{
class Config;
-typedef QSharedPointer<Config> ConfigPtr;
+typedef QSharedPointer<KScreen::Config> ConfigPtr;
class Screen;
-typedef QSharedPointer<Screen> ScreenPtr;
+typedef QSharedPointer<KScreen::Screen> ScreenPtr;
class Output;
-typedef QSharedPointer<Output> OutputPtr;
-typedef QMap<int, OutputPtr> OutputList;
+typedef QSharedPointer<KScreen::Output> OutputPtr;
+typedef QMap<int, KScreen::OutputPtr> OutputList;
class Mode;
-typedef QSharedPointer<Mode> ModePtr;
-typedef QMap<QString, ModePtr> ModeList;
+typedef QSharedPointer<KScreen::Mode> ModePtr;
+typedef QMap<QString, KScreen::ModePtr> ModeList;
}
|
[-]
[+]
|
Changed |
libkscreen.yaml
^
|
@@ -1,5 +1,5 @@
Name : libkscreen
-Version : 5.2.0
+Version : 5.3.0
Release : 8
Group : System/Base
License : LGPLv2.1+
|