diff --git a/backends/xcbwrapper.h b/backends/xcbwrapper.h index d9f4960..f394048 100644 --- a/backends/xcbwrapper.h +++ b/backends/xcbwrapper.h @@ -1,211 +1,211 @@ /******************************************************************** K Win - the KDE window manager This file is part of the KDE project. Copyright (C) 2012, 2013 Martin Gräßlin Copyright (C) 2015 Daniel Vrátil 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 . *********************************************************************/ #ifndef XCB_WRAPPER_H #define XCB_WRAPPER_H #include #include #include #include #include #include namespace XCB { template using ScopedPointer = QScopedPointer; xcb_connection_t *connection(); void closeConnection(); xcb_screen_t *screenOfDisplay(xcb_connection_t *c, int screen); struct GrabServer { GrabServer(); ~GrabServer(); }; template class Wrapper { public: Wrapper() : m_retrieved(false) , m_window(XCB_WINDOW_NONE) , m_reply(nullptr) { m_cookie.sequence = 0; } explicit Wrapper(const RequestFuncArgs& ... args) : m_retrieved(false) , m_cookie(requestFunc(connection(), args ...)) , m_window(requestWindow(args ...)) , m_reply(nullptr) { } explicit Wrapper(const Wrapper &other) : m_retrieved(other.m_retrieved) , m_cookie(other.m_cookie) , m_window(other.m_window) , m_reply(nullptr) { takeFromOther(const_cast(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(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 == nullptr; } 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 = 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, nullptr); 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 constexpr xcb_window_t requestWindow(const Args & ... args) { return std::is_same>::type, xcb_window_t>::value ? std::get<0>(std::tuple(args ...)) : static_cast(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 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 *); XCB_DECLARE_TYPE(OutputInfo, xcb_randr_get_output_info, xcb_randr_output_t, xcb_timestamp_t); XCB_DECLARE_TYPE(CRTCInfo, xcb_randr_get_crtc_info, xcb_randr_crtc_t, xcb_timestamp_t); XCB_DECLARE_TYPE(AtomName, xcb_get_atom_name, xcb_atom_t); } -#endif \ No newline at end of file +#endif diff --git a/src/backendlauncher/CMakeLists.txt b/src/backendlauncher/CMakeLists.txt index f26ad0e..e031a89 100644 --- a/src/backendlauncher/CMakeLists.txt +++ b/src/backendlauncher/CMakeLists.txt @@ -1,42 +1,42 @@ include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. ) set(backendlauncher_SRCS main.cpp backendloader.cpp backenddbuswrapper.cpp ) ecm_qt_declare_logging_category(backendlauncher_SRCS HEADER debug_p.h IDENTIFIER KSCREEN_BACKEND_LAUNCHER CATEGORY_NAME kscreen.backendLauncher ) qt5_add_dbus_adaptor(backendlauncher_SRCS ${CMAKE_SOURCE_DIR}/interfaces/org.kde.KScreen.Backend.xml backenddbuswrapper.h BackendDBusWrapper backendadaptor BackendAdaptor) qt5_add_dbus_adaptor(backendlauncher_SRCS ${CMAKE_SOURCE_DIR}/interfaces/org.kde.KScreen.xml backendloader.h BackendLoader backendloaderadaptor BackendLoaderAdaptor) add_executable(kscreen_backend_launcher ${backendlauncher_SRCS}) target_link_libraries(kscreen_backend_launcher KF5Screen Qt5::Core Qt5::Gui Qt5::X11Extras Qt5::DBus ) install(TARGETS kscreen_backend_launcher DESTINATION ${CMAKE_INSTALL_FULL_LIBEXECDIR_KF5} ) configure_file(org.kde.kscreen.service.cmake ${CMAKE_CURRENT_BINARY_DIR}/org.kde.kscreen.service @ONLY ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.kscreen.service DESTINATION ${KDE_INSTALL_DBUSSERVICEDIR} -) \ No newline at end of file +) diff --git a/src/backendlauncher/org.kde.kscreen.service.cmake b/src/backendlauncher/org.kde.kscreen.service.cmake index 794b33f..d2c8010 100644 --- a/src/backendlauncher/org.kde.kscreen.service.cmake +++ b/src/backendlauncher/org.kde.kscreen.service.cmake @@ -1,3 +1,3 @@ [D-BUS Service] Name=org.kde.KScreen -Exec=@CMAKE_INSTALL_FULL_LIBEXECDIR_KF5@/kscreen_backend_launcher \ No newline at end of file +Exec=@CMAKE_INSTALL_FULL_LIBEXECDIR_KF5@/kscreen_backend_launcher diff --git a/src/debug_p.h b/src/debug_p.h index a55c9ba..ec00f0a 100644 --- a/src/debug_p.h +++ b/src/debug_p.h @@ -1,27 +1,27 @@ /************************************************************************************* * Copyright (C) 2014 by Alejandro Fiestas Olivares * * * * 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 SCREEN_DEBUG_P_H #define SCREEN_DEBUG_P_H #include Q_DECLARE_LOGGING_CATEGORY(KSCREEN) Q_DECLARE_LOGGING_CATEGORY(KSCREEN_EDID) -#endif //SCREEN_DEBUG_P_H \ No newline at end of file +#endif //SCREEN_DEBUG_P_H