diff --git a/CMakeLists.txt b/CMakeLists.txt
index 27928fc1a..75313d3d0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,734 +1,735 @@
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(KWIN)
set(PROJECT_VERSION "5.11.90")
set(PROJECT_VERSION_MAJOR 5)
set(QT_MIN_VERSION "5.9.0")
set(KF5_MIN_VERSION "5.41.0")
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH} )
find_package(ECM 5.38 REQUIRED NO_MODULE)
include(FeatureSummary)
include(WriteBasicConfigVersionFile)
include(GenerateExportHeader)
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Concurrent
Core
DBus
Quick
QuickWidgets
Sensors
Script
UiTools
Widgets
X11Extras
)
find_package(Qt5Test ${QT_MIN_VERSION} CONFIG QUIET)
set_package_properties(Qt5Test PROPERTIES
PURPOSE "Required for tests"
TYPE OPTIONAL
)
add_feature_info("Qt5Test" Qt5Test_FOUND "Required for building tests")
if (NOT Qt5Test_FOUND)
set(BUILD_TESTING OFF CACHE BOOL "Build the testing tree.")
endif()
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(ECMInstallIcons)
include(ECMOptionalAddSubdirectory)
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0 -DQT_USE_QSTRINGBUILDER)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-inconsistent-missing-override")
endif()
find_package(Qt5Multimedia QUIET)
set_package_properties(Qt5Multimedia PROPERTIES
PURPOSE "Runtime-only dependency for effect video playback"
TYPE RUNTIME
)
# required frameworks by Core
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
Config
ConfigWidgets
CoreAddons
Crash
GlobalAccel
I18n
Init
Notifications
Package
Plasma
WidgetsAddons
WindowSystem
IconThemes
IdleTime
Wayland
)
# required frameworks by config modules
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
Completion
Declarative
KCMUtils
KIO
TextWidgets
NewStuff
Service
XmlGui
)
find_package(Threads)
set_package_properties(Threads PROPERTIES
PURPOSE "Needed for VirtualTerminal support in KWin Wayland"
TYPE REQUIRED
)
# optional frameworks
find_package(KF5Activities ${KF5_MIN_VERSION} CONFIG)
set_package_properties(KF5Activities PROPERTIES
PURPOSE "Enable building of KWin with kactivities support"
TYPE OPTIONAL
)
add_feature_info("KF5Activities" KF5Activities_FOUND "Enable building of KWin with kactivities support")
find_package(KF5DocTools ${KF5_MIN_VERSION} CONFIG)
set_package_properties(KF5DocTools PROPERTIES
PURPOSE "Enable building documentation"
TYPE OPTIONAL
)
add_feature_info("KF5DocTools" KF5DocTools_FOUND "Enable building documentation")
find_package(KDecoration2 CONFIG REQUIRED)
find_package(KScreenLocker CONFIG REQUIRED)
set_package_properties(KScreenLocker PROPERTIES
TYPE REQUIRED
PURPOSE "For screenlocker integration in kwin_wayland")
find_package(Breeze 5.9.0 CONFIG)
set_package_properties(Breeze PROPERTIES
TYPE OPTIONAL
PURPOSE "For setting the default window decoration plugin")
if(${Breeze_FOUND})
if(${BREEZE_WITH_KDECORATION})
set(HAVE_BREEZE_DECO true)
else()
set(HAVE_BREEZE_DECO FALSE)
endif()
else()
set(HAVE_BREEZE_DECO FALSE)
endif()
add_feature_info("Breeze-Decoration" HAVE_BREEZE_DECO "Default decoration plugin Breeze")
find_package(EGL)
set_package_properties(EGL PROPERTIES
TYPE RUNTIME
PURPOSE "Required to build KWin with EGL support"
)
find_package(epoxy)
set_package_properties(epoxy PROPERTIES DESCRIPTION "libepoxy"
URL "http://github.com/anholt/libepoxy"
TYPE REQUIRED
PURPOSE "OpenGL dispatch library"
)
set(HAVE_DL_LIBRARY FALSE)
if(epoxy_HAS_GLX)
find_library(DL_LIBRARY dl)
if(DL_LIBRARY)
set(HAVE_DL_LIBRARY TRUE)
endif()
endif()
find_package(Wayland 1.2 REQUIRED COMPONENTS Cursor OPTIONAL_COMPONENTS Egl)
set_package_properties(Wayland PROPERTIES
TYPE REQUIRED
PURPOSE "Required for building KWin with Wayland support"
)
add_feature_info("Wayland::EGL" Wayland_Egl_FOUND "Enable building of Wayland backend and QPA with EGL support.")
set(HAVE_WAYLAND_EGL FALSE)
if(Wayland_Egl_FOUND)
set(HAVE_WAYLAND_EGL TRUE)
endif()
find_package(XKB 0.7.0)
set_package_properties(XKB PROPERTIES
TYPE REQUIRED
PURPOSE "Required for building KWin with Wayland support"
)
find_package(Libinput 1.5)
set_package_properties(Libinput PROPERTIES TYPE OPTIONAL PURPOSE "Required for input handling on Wayland.")
find_package(UDev)
set_package_properties(UDev PROPERTIES URL "http://www.freedesktop.org/software/systemd/libudev/"
DESCRIPTION "Linux device library."
TYPE OPTIONAL
PURPOSE "Required for input handling on Wayland."
)
set(HAVE_INPUT FALSE)
if (Libinput_FOUND AND UDEV_FOUND)
set(HAVE_INPUT TRUE)
endif()
set(HAVE_UDEV FALSE)
if (UDEV_FOUND)
set(HAVE_UDEV TRUE)
endif()
find_package(Libdrm 2.4.62)
set_package_properties(Libdrm PROPERTIES TYPE OPTIONAL PURPOSE "Required for drm output on Wayland.")
set(HAVE_DRM FALSE)
if(Libdrm_FOUND AND UDEV_FOUND)
set(HAVE_DRM TRUE)
endif()
find_package(gbm)
set_package_properties(gbm PROPERTIES TYPE OPTIONAL PURPOSE "Required for egl ouput of drm backend.")
set(HAVE_GBM FALSE)
if(HAVE_DRM AND gbm_FOUND)
set(HAVE_GBM TRUE)
endif()
find_package(libhybris)
set_package_properties(libhybris PROPERTIES TYPE OPTIONAL PURPOSE "Required for libhybris backend")
set(HAVE_LIBHYBRIS ${libhybris_FOUND})
find_package(X11)
set_package_properties(X11 PROPERTIES DESCRIPTION "X11 libraries"
URL "http://www.x.org"
TYPE REQUIRED
)
add_feature_info("XInput" X11_Xinput_FOUND "Required for poll-free mouse cursor updates")
set(HAVE_X11_XINPUT ${X11_Xinput_FOUND})
# All the required XCB components
find_package(XCB 1.10
REQUIRED COMPONENTS
XCB
XFIXES
DAMAGE
COMPOSITE
SHAPE
SYNC
RENDER
RANDR
KEYSYMS
IMAGE
SHM
GLX
CURSOR
ICCCM
)
set_package_properties(XCB PROPERTIES TYPE REQUIRED)
# and the optional XCB dependencies
if (XCB_ICCCM_VERSION VERSION_LESS "0.4")
set(XCB_ICCCM_FOUND FALSE)
endif()
add_feature_info("XCB-ICCCM" XCB_ICCCM_FOUND "Required for building test applications for KWin")
find_package(X11_XCB)
set_package_properties(X11_XCB PROPERTIES
PURPOSE "Required for building X11 windowed backend of kwin_wayland"
TYPE OPTIONAL)
# dependencies for QPA plugin
find_package(Qt5FontDatabaseSupport REQUIRED)
find_package(Qt5ThemeSupport REQUIRED)
find_package(Qt5EventDispatcherSupport REQUIRED)
find_package(Freetype REQUIRED)
set_package_properties(Freetype PROPERTIES DESCRIPTION "A font rendering engine"
URL "http://www.freetype.org"
TYPE REQUIRED
PURPOSE "Needed for KWin's QPA plugin."
)
find_package(Fontconfig REQUIRED)
set_package_properties(Fontconfig PROPERTIES DESCRIPTION "Font access configuration library"
URL "http://www.freedesktop.org/wiki/Software/fontconfig"
TYPE REQUIRED
PURPOSE "Needed for KWin's QPA plugin."
)
find_package(Xwayland)
set_package_properties(Xwayland PROPERTIES
URL "http://x.org"
DESCRIPTION "Xwayland X server"
TYPE RUNTIME
PURPOSE "Needed for running kwin_wayland"
)
find_package(Libcap)
set_package_properties(Libcap PROPERTIES
TYPE OPTIONAL
PURPOSE "Needed for running kwin_wayland with real-time scheduling policy"
)
set(HAVE_LIBCAP ${Libcap_FOUND})
include(ECMQMLModules)
ecm_find_qmlmodule(QtQuick 2.3)
ecm_find_qmlmodule(QtQuick.Controls 1.2)
ecm_find_qmlmodule(QtQuick.Layouts 1.3)
ecm_find_qmlmodule(QtQuick.VirtualKeyboard 2.1)
ecm_find_qmlmodule(QtQuick.Window 2.1)
ecm_find_qmlmodule(QtMultimedia 5.0)
ecm_find_qmlmodule(org.kde.kquickcontrolsaddons 2.0)
ecm_find_qmlmodule(org.kde.plasma.core 2.0)
ecm_find_qmlmodule(org.kde.plasma.components 2.0)
########### configure tests ###############
include(CMakeDependentOption)
option(KWIN_BUILD_DECORATIONS "Enable building of KWin decorations." ON)
option(KWIN_BUILD_KCMS "Enable building of KWin configuration modules." ON)
option(KWIN_BUILD_TABBOX "Enable building of KWin Tabbox functionality" ON)
option(KWIN_BUILD_XRENDER_COMPOSITING "Enable building of KWin with XRender Compositing support" ON)
cmake_dependent_option(KWIN_BUILD_ACTIVITIES "Enable building of KWin with kactivities support" ON "KF5Activities_FOUND" OFF)
# Binary name of KWin
set(KWIN_NAME "kwin")
set(KWIN_INTERNAL_NAME_X11 "kwin_x11")
set(KWIN_INTERNAL_NAME_WAYLAND "kwin_wayland")
set(KWIN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
# KWIN_HAVE_XRENDER_COMPOSITING - whether XRender-based compositing support is available: may be disabled
if( KWIN_BUILD_XRENDER_COMPOSITING )
set( KWIN_HAVE_XRENDER_COMPOSITING 1 )
endif()
include_directories(${XKB_INCLUDE_DIR})
include_directories(${epoxy_INCLUDE_DIR})
set(HAVE_EPOXY_GLX ${epoxy_HAS_GLX})
# for things that are also used by kwin libraries
configure_file(libkwineffects/kwinconfig.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/libkwineffects/kwinconfig.h )
# for kwin internal things
set(HAVE_X11_XCB ${X11_XCB_FOUND})
include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckSymbolExists)
check_include_files(unistd.h HAVE_UNISTD_H)
check_include_files(malloc.h HAVE_MALLOC_H)
check_include_file("sys/prctl.h" HAVE_SYS_PRCTL_H)
check_symbol_exists(PR_SET_DUMPABLE "sys/prctl.h" HAVE_PR_SET_DUMPABLE)
check_symbol_exists(PR_SET_PDEATHSIG "sys/prctl.h" HAVE_PR_SET_PDEATHSIG)
check_include_file("sys/procctl.h" HAVE_SYS_PROCCTL_H)
check_symbol_exists(PROC_TRACE_CTL "sys/procctl.h" HAVE_PROC_TRACE_CTL)
if (HAVE_PR_SET_DUMPABLE OR HAVE_PROC_TRACE_CTL)
set(CAN_DISABLE_PTRACE TRUE)
endif()
add_feature_info("prctl/procctl tracing control"
CAN_DISABLE_PTRACE
"Required for disallowing ptrace on kwin_wayland process")
check_include_file("sys/sysmacros.h" HAVE_SYS_SYSMACROS_H)
configure_file(config-kwin.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kwin.h )
check_include_file("linux/vt.h" HAVE_LINUX_VT_H)
add_feature_info("linux/vt.h"
HAVE_LINUX_VT_H
"Required for virtual terminal support under wayland")
check_include_file("linux/fb.h" HAVE_LINUX_FB_H)
add_feature_info("linux/fb.h"
HAVE_LINUX_FB_H
"Required for the fbdev backend")
check_symbol_exists(SCHED_RESET_ON_FORK "sched.h" HAVE_SCHED_RESET_ON_FORK)
add_feature_info("SCHED_RESET_ON_FORK"
HAVE_SCHED_RESET_ON_FORK
"Required for running kwin_wayland with real-time scheduling")
########### global ###############
set(kwin_effects_dbus_xml ${CMAKE_CURRENT_SOURCE_DIR}/org.kde.kwin.Effects.xml)
include_directories(BEFORE
${CMAKE_CURRENT_BINARY_DIR}/libkwineffects
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/libkwineffects
${CMAKE_CURRENT_SOURCE_DIR}/effects
${CMAKE_CURRENT_SOURCE_DIR}/tabbox
${CMAKE_CURRENT_SOURCE_DIR}/platformsupport
)
add_subdirectory( libkwineffects )
if(KWIN_BUILD_KCMS)
add_subdirectory( kcmkwin )
endif()
add_subdirectory( data )
add_subdirectory( effects )
add_subdirectory( scripts )
add_subdirectory( tabbox )
add_subdirectory(scripting)
add_subdirectory(helpers)
########### next target ###############
set(kwin_KDEINIT_SRCS
workspace.cpp
dbusinterface.cpp
abstract_client.cpp
client.cpp
client_machine.cpp
cursor.cpp
debug_console.cpp
tabgroup.cpp
focuschain.cpp
globalshortcuts.cpp
input.cpp
input_event.cpp
input_event_spy.cpp
keyboard_input.cpp
keyboard_layout.cpp
keyboard_layout_switching.cpp
keyboard_repeat.cpp
pointer_input.cpp
touch_input.cpp
netinfo.cpp
placement.cpp
atoms.cpp
utils.cpp
layers.cpp
main.cpp
options.cpp
outline.cpp
events.cpp
killwindow.cpp
geometrytip.cpp
screens.cpp
shadow.cpp
sm.cpp
group.cpp
manage.cpp
overlaywindow.cpp
activation.cpp
useractions.cpp
geometry.cpp
rules.cpp
composite.cpp
toplevel.cpp
unmanaged.cpp
scene.cpp
screenlockerwatcher.cpp
thumbnailitem.cpp
lanczosfilter.cpp
deleted.cpp
effects.cpp
effectloader.cpp
virtualdesktops.cpp
xcbutils.cpp
x11eventfilter.cpp
logind.cpp
onscreennotification.cpp
osd.cpp
screenedge.cpp
scripting/scripting.cpp
scripting/workspace_wrapper.cpp
scripting/meta.cpp
scripting/scriptedeffect.cpp
scripting/scriptingutils.cpp
scripting/timer.cpp
scripting/scripting_model.cpp
scripting/dbuscall.cpp
scripting/screenedgeitem.cpp
scripting/scripting_logging.cpp
decorations/decoratedclient.cpp
decorations/decorationbridge.cpp
decorations/decorationpalette.cpp
decorations/settings.cpp
decorations/decorationrenderer.cpp
decorations/decorations_logging.cpp
platform.cpp
shell_client.cpp
wayland_server.cpp
wayland_cursor_theme.cpp
virtualkeyboard.cpp
virtualkeyboard_dbus.cpp
appmenu.cpp
modifier_only_shortcuts.cpp
xkb.cpp
gestures.cpp
popup_input_filter.cpp
colorcorrection/manager.cpp
colorcorrection/colorcorrectdbusinterface.cpp
colorcorrection/suncalc.cpp
abstract_opengl_context_attribute_builder.cpp
egl_context_attribute_builder.cpp
was_user_interaction_x11_filter.cpp
moving_client_x11_filter.cpp
window_property_notify_x11_filter.cpp
rootinfo_filter.cpp
orientation_sensor.cpp
idle_inhibition.cpp
)
include(ECMQtDeclareLoggingCategory)
ecm_qt_declare_logging_category(kwin_KDEINIT_SRCS
HEADER
colorcorrect_logging.h
IDENTIFIER
KWIN_COLORCORRECTION
CATEGORY_NAME
kwin_colorcorrection
DEFAULT_SEVERITY
Critical
)
if(KWIN_BUILD_TABBOX)
set(
kwin_KDEINIT_SRCS ${kwin_KDEINIT_SRCS}
tabbox/tabbox.cpp
tabbox/clientmodel.cpp
tabbox/desktopchain.cpp
tabbox/desktopmodel.cpp
tabbox/switcheritem.cpp
tabbox/tabboxconfig.cpp
tabbox/tabboxhandler.cpp
tabbox/tabbox_logging.cpp
tabbox/x11_filter.cpp
)
endif()
if(KWIN_BUILD_ACTIVITIES)
set(
kwin_KDEINIT_SRCS ${kwin_KDEINIT_SRCS}
activities.cpp
)
endif()
if(UDEV_FOUND)
set(kwin_KDEINIT_SRCS
${kwin_KDEINIT_SRCS}
udev.cpp
)
endif()
if(HAVE_INPUT)
set(kwin_KDEINIT_SRCS
${kwin_KDEINIT_SRCS}
libinput/context.cpp
libinput/connection.cpp
libinput/device.cpp
libinput/events.cpp
libinput/libinput_logging.cpp
)
if (HAVE_LINUX_VT_H)
set(kwin_KDEINIT_SRCS
${kwin_KDEINIT_SRCS}
virtual_terminal.cpp
)
endif()
endif()
kconfig_add_kcfg_files(kwin_KDEINIT_SRCS settings.kcfgc)
kconfig_add_kcfg_files(kwin_KDEINIT_SRCS colorcorrection/colorcorrect_settings.kcfgc)
qt5_add_dbus_adaptor( kwin_KDEINIT_SRCS org.kde.KWin.xml dbusinterface.h KWin::DBusInterface )
qt5_add_dbus_adaptor( kwin_KDEINIT_SRCS org.kde.kwin.Compositing.xml dbusinterface.h KWin::CompositorDBusInterface )
qt5_add_dbus_adaptor( kwin_KDEINIT_SRCS org.kde.kwin.ColorCorrect.xml colorcorrection/colorcorrectdbusinterface.h KWin::ColorCorrect::ColorCorrectDBusInterface )
qt5_add_dbus_adaptor( kwin_KDEINIT_SRCS ${kwin_effects_dbus_xml} effects.h KWin::EffectsHandlerImpl )
+qt5_add_dbus_adaptor( kwin_KDEINIT_SRCS org.kde.kwin.OrientationSensor.xml orientation_sensor.h KWin::OrientationSensor)
qt5_add_dbus_interface( kwin_KDEINIT_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/org.freedesktop.ScreenSaver.xml screenlocker_interface)
qt5_add_dbus_interface( kwin_KDEINIT_SRCS org.kde.kappmenu.xml appmenu_interface )
qt5_add_resources( kwin_KDEINIT_SRCS resources.qrc )
ki18n_wrap_ui(kwin_KDEINIT_SRCS
debug_console.ui
shortcutdialog.ui
)
########### target link libraries ###############
set(kwin_OWN_LIBS
kwineffects
kwin4_effect_builtins
)
set(kwin_QT_LIBS
Qt5::Concurrent
Qt5::DBus
Qt5::Quick
Qt5::Sensors
Qt5::Script
)
set(kwin_KDE_LIBS
KF5::ConfigCore
KF5::CoreAddons
KF5::ConfigWidgets
KF5::GlobalAccel
KF5::GlobalAccelPrivate
KF5::I18n
KF5::Notifications
KF5::Package
KF5::Plasma
KF5::WindowSystem
KF5::QuickAddons
KDecoration2::KDecoration
KDecoration2::KDecoration2Private
PW::KScreenLocker
)
set(kwin_XLIB_LIBS
${X11_X11_LIB}
${X11_ICE_LIB}
${X11_SM_LIB}
)
set(kwin_XCB_LIBS
XCB::XCB
XCB::XFIXES
XCB::DAMAGE
XCB::COMPOSITE
XCB::SHAPE
XCB::SYNC
XCB::RENDER
XCB::RANDR
XCB::KEYSYMS
XCB::SHM
XCB::GLX
XCB::ICCCM
)
set(kwin_WAYLAND_LIBS
XKB::XKB
KF5::WaylandClient
KF5::WaylandServer
Wayland::Cursor
${CMAKE_THREAD_LIBS_INIT}
)
if(KWIN_BUILD_ACTIVITIES)
set(kwin_KDE_LIBS ${kwin_KDE_LIBS} KF5::Activities)
endif()
set(kwinLibs
${kwin_OWN_LIBS}
${kwin_QT_LIBS}
${kwin_KDE_LIBS}
${kwin_XLIB_LIBS}
${kwin_XCB_LIBS}
${kwin_WAYLAND_LIBS}
)
if(UDEV_FOUND)
set(kwinLibs ${kwinLibs} ${UDEV_LIBS})
endif()
if(HAVE_INPUT)
set(kwinLibs ${kwinLibs} Libinput::Libinput)
endif()
add_library(kwin SHARED ${kwin_KDEINIT_SRCS})
set_target_properties(kwin PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
)
target_link_libraries(kwin ${kwinLibs})
generate_export_header(kwin EXPORT_FILE_NAME kwin_export.h)
target_link_libraries(kwin kwinglutils ${epoxy_LIBRARY})
kf5_add_kdeinit_executable(kwin_x11 main_x11.cpp)
target_link_libraries(kdeinit_kwin_x11 kwin KF5::Crash Qt5::X11Extras)
install(TARGETS kwin ${INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP )
install(TARGETS kdeinit_kwin_x11 ${INSTALL_TARGETS_DEFAULT_ARGS} )
install(TARGETS kwin_x11 ${INSTALL_TARGETS_DEFAULT_ARGS} )
add_executable(kwin_wayland main_wayland.cpp)
target_link_libraries(kwin_wayland kwin)
if (HAVE_LIBCAP)
target_link_libraries(kwin_wayland ${Libcap_LIBRARIES})
endif()
install(TARGETS kwin_wayland ${INSTALL_TARGETS_DEFAULT_ARGS} )
if (HAVE_LIBCAP)
install(
CODE "execute_process(
COMMAND
${SETCAP_EXECUTABLE}
CAP_SYS_NICE=+ep
\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_BINDIR}/kwin_wayland)"
)
endif()
add_subdirectory(platformsupport)
add_subdirectory(plugins)
########### install files ###############
install( FILES kwin.kcfg DESTINATION ${KCFG_INSTALL_DIR} RENAME ${KWIN_NAME}.kcfg )
install( FILES colorcorrection/colorcorrect_settings.kcfg DESTINATION ${KCFG_INSTALL_DIR} RENAME ${KWIN_NAME}_colorcorrect.kcfg )
install( FILES kwin.notifyrc DESTINATION ${KNOTIFYRC_INSTALL_DIR} RENAME ${KWIN_NAME}.notifyrc)
install(
FILES
org.kde.KWin.xml
org.kde.kwin.Compositing.xml
org.kde.kwin.ColorCorrect.xml
org.kde.kwin.Effects.xml
DESTINATION
${KDE_INSTALL_DBUSINTERFACEDIR}
)
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/kwin_export.h DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)
# Install the KWin/Script service type
install( FILES scripting/kwinscript.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} )
ecm_install_icons(
ICONS
16-apps-kwin.png
32-apps-kwin.png
48-apps-kwin.png
sc-apps-kwin.svgz
DESTINATION
${ICON_INSTALL_DIR}
THEME
hicolor
)
add_subdirectory(qml)
add_subdirectory(autotests)
add_subdirectory(tests)
add_subdirectory(packageplugins)
if (KF5DocTools_FOUND)
add_subdirectory(doc)
endif()
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
include(CMakePackageConfigHelpers)
set(CMAKECONFIG_INSTALL_DIR "${CMAKECONFIG_INSTALL_PREFIX}/KWinDBusInterface")
configure_package_config_file(KWinDBusInterfaceConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/KWinDBusInterfaceConfig.cmake"
PATH_VARS KDE_INSTALL_DBUSINTERFACEDIR
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/KWinDBusInterfaceConfig.cmake
DESTINATION ${CMAKECONFIG_INSTALL_DIR})
diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt
index d2992fb80..b5cfbc826 100644
--- a/autotests/CMakeLists.txt
+++ b/autotests/CMakeLists.txt
@@ -1,440 +1,447 @@
add_definitions(-DKWIN_UNIT_TEST)
remove_definitions(-DQT_USE_QSTRINGBUILDER)
add_subdirectory(libkwineffects)
add_subdirectory(libxrenderutils)
add_subdirectory(integration)
if (HAVE_INPUT)
add_subdirectory(libinput)
endif()
if (HAVE_DRM)
add_subdirectory(drm)
endif()
add_subdirectory(tabbox)
########################################################
# Test ScreenPaintData
########################################################
set( testScreenPaintData_SRCS test_screen_paint_data.cpp )
add_executable(testScreenPaintData ${testScreenPaintData_SRCS})
target_link_libraries( testScreenPaintData kwineffects Qt5::Test Qt5::Widgets KF5::WindowSystem)
add_test(NAME kwin-testScreenPaintData COMMAND testScreenPaintData)
ecm_mark_as_test(testScreenPaintData)
########################################################
# Test WindowPaintData
########################################################
set( testWindowPaintData_SRCS test_window_paint_data.cpp )
add_executable(testWindowPaintData ${testWindowPaintData_SRCS})
target_link_libraries( testWindowPaintData kwineffects Qt5::Widgets Qt5::Test )
add_test(NAME kwin-testWindowPaintData COMMAND testWindowPaintData)
ecm_mark_as_test(testWindowPaintData)
########################################################
# Test VirtualDesktopManager
########################################################
set( testVirtualDesktops_SRCS
test_virtual_desktops.cpp
../virtualdesktops.cpp
)
add_executable(testVirtualDesktops ${testVirtualDesktops_SRCS})
target_link_libraries( testVirtualDesktops
Qt5::Test
Qt5::Widgets
KF5::I18n
KF5::GlobalAccel
KF5::ConfigCore
KF5::WindowSystem
)
add_test(NAME kwin-testVirtualDesktops COMMAND testVirtualDesktops)
ecm_mark_as_test(testVirtualDesktops)
########################################################
# Test ClientMachine
########################################################
set( testClientMachine_SRCS
test_client_machine.cpp
../client_machine.cpp
)
add_executable( testClientMachine ${testClientMachine_SRCS} )
set_target_properties(testClientMachine PROPERTIES COMPILE_DEFINITIONS "NO_NONE_WINDOW")
target_link_libraries( testClientMachine
Qt5::Concurrent
Qt5::Test
Qt5::X11Extras
Qt5::Widgets
KF5::ConfigCore
KF5::WindowSystem
XCB::XCB
XCB::XFIXES
${X11_X11_LIB} # to make jenkins happy
)
add_test(NAME kwin-testClientMachine COMMAND testClientMachine)
ecm_mark_as_test(testClientMachine)
########################################################
# Test XcbWrapper
########################################################
set( testXcbWrapper_SRCS
test_xcb_wrapper.cpp
)
add_executable( testXcbWrapper ${testXcbWrapper_SRCS} )
target_link_libraries( testXcbWrapper
Qt5::Test
Qt5::X11Extras
Qt5::Widgets
KF5::ConfigCore
KF5::WindowSystem
XCB::XCB
)
add_test(NAME kwin-testXcbWrapper COMMAND testXcbWrapper)
ecm_mark_as_test(testXcbWrapper)
if (XCB_ICCCM_FOUND)
add_executable( testXcbSizeHints test_xcb_size_hints.cpp )
set_target_properties(testXcbSizeHints PROPERTIES COMPILE_DEFINITIONS "NO_NONE_WINDOW")
target_link_libraries( testXcbSizeHints
Qt5::Test
Qt5::X11Extras
Qt5::Widgets
KF5::ConfigCore
KF5::WindowSystem
XCB::XCB
XCB::ICCCM
)
add_test(NAME kwin-testXcbSizeHints COMMAND testXcbSizeHints)
ecm_mark_as_test(testXcbSizeHints)
endif()
########################################################
# Test XcbWindow
########################################################
set( testXcbWindow_SRCS
test_xcb_window.cpp
)
add_executable( testXcbWindow ${testXcbWindow_SRCS} )
target_link_libraries( testXcbWindow
Qt5::Test
Qt5::X11Extras
Qt5::Widgets
KF5::ConfigCore
KF5::WindowSystem
XCB::XCB
)
add_test(NAME kwin-testXcbWindow COMMAND testXcbWindow)
ecm_mark_as_test(testXcbWindow)
########################################################
# Test BuiltInEffectLoader
########################################################
set( testBuiltInEffectLoader_SRCS
test_builtin_effectloader.cpp
mock_effectshandler.cpp
../effectloader.cpp
)
add_executable( testBuiltInEffectLoader ${testBuiltInEffectLoader_SRCS})
set_target_properties(testBuiltInEffectLoader PROPERTIES COMPILE_DEFINITIONS "NO_NONE_WINDOW")
target_link_libraries(testBuiltInEffectLoader
Qt5::Concurrent
Qt5::Test
Qt5::X11Extras
KF5::Package
kwineffects
kwin4_effect_builtins
)
add_test(NAME kwin-testBuiltInEffectLoader COMMAND testBuiltInEffectLoader)
ecm_mark_as_test(testBuiltInEffectLoader)
########################################################
# Test ScriptedEffectLoader
########################################################
include_directories(${KWIN_SOURCE_DIR})
set( testScriptedEffectLoader_SRCS
test_scripted_effectloader.cpp
mock_abstract_client.cpp
mock_effectshandler.cpp
mock_screens.cpp
mock_workspace.cpp
../effectloader.cpp
../scripting/scriptedeffect.cpp
../scripting/scriptingutils.cpp
../scripting/scripting_logging.cpp
../screens.cpp
../orientation_sensor.cpp
)
kconfig_add_kcfg_files(testScriptedEffectLoader_SRCS ../settings.kcfgc)
+qt5_add_dbus_adaptor( testScriptedEffectLoader_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/../org.kde.kwin.OrientationSensor.xml ${CMAKE_CURRENT_SOURCE_DIR}/../orientation_sensor.h KWin::OrientationSensor)
add_executable( testScriptedEffectLoader ${testScriptedEffectLoader_SRCS})
target_link_libraries(testScriptedEffectLoader
Qt5::Concurrent
Qt5::Qml
Qt5::Script
Qt5::Sensors
Qt5::Test
Qt5::X11Extras
KF5::ConfigGui
KF5::GlobalAccel
KF5::I18n
KF5::Notifications
KF5::Package
kwineffects
kwin4_effect_builtins
)
add_test(NAME kwin-testScriptedEffectLoader COMMAND testScriptedEffectLoader)
ecm_mark_as_test(testScriptedEffectLoader)
########################################################
# Test PluginEffectLoader
########################################################
set( testPluginEffectLoader_SRCS
test_plugin_effectloader.cpp
mock_effectshandler.cpp
../effectloader.cpp
)
add_executable( testPluginEffectLoader ${testPluginEffectLoader_SRCS})
target_link_libraries(testPluginEffectLoader
Qt5::Concurrent
Qt5::Test
Qt5::X11Extras
KF5::Package
kwineffects
kwin4_effect_builtins
)
add_test(NAME kwin-testPluginEffectLoader COMMAND testPluginEffectLoader)
ecm_mark_as_test(testPluginEffectLoader)
########################################################
# FakeEffectPlugin
########################################################
add_library(fakeeffectplugin MODULE fakeeffectplugin.cpp)
set_target_properties(fakeeffectplugin PROPERTIES PREFIX "")
target_link_libraries(fakeeffectplugin kwineffects)
########################################################
# FakeEffectPlugin-Version
########################################################
add_library(effectversionplugin MODULE fakeeffectplugin_version.cpp)
set_target_properties(effectversionplugin PROPERTIES PREFIX "")
target_link_libraries(effectversionplugin kwineffects)
########################################################
# Test Screens
########################################################
set( testScreens_SRCS
test_screens.cpp
mock_abstract_client.cpp
mock_client.cpp
mock_screens.cpp
mock_workspace.cpp
../screens.cpp
../x11eventfilter.cpp
../orientation_sensor.cpp
)
kconfig_add_kcfg_files(testScreens_SRCS ../settings.kcfgc)
+qt5_add_dbus_adaptor( testScreens_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/../org.kde.kwin.OrientationSensor.xml ${CMAKE_CURRENT_SOURCE_DIR}/../orientation_sensor.h KWin::OrientationSensor)
add_executable( testScreens ${testScreens_SRCS})
target_include_directories(testScreens BEFORE PRIVATE ./)
target_link_libraries(testScreens
+ Qt5::DBus
Qt5::Sensors
Qt5::Test
Qt5::X11Extras
Qt5::Widgets
KF5::ConfigCore
KF5::ConfigGui
KF5::I18n
KF5::Notifications
KF5::WindowSystem
)
add_test(NAME kwin_testScreens COMMAND testScreens)
ecm_mark_as_test(testScreens)
########################################################
# Test XrandRScreens
########################################################
set( testXRandRScreens_SRCS
test_xrandr_screens.cpp
mock_abstract_client.cpp
mock_client.cpp
mock_screens.cpp
mock_workspace.cpp
../screens.cpp
../plugins/platforms/x11/standalone/screens_xrandr.cpp
../xcbutils.cpp # init of extensions
../x11eventfilter.cpp
../orientation_sensor.cpp
)
kconfig_add_kcfg_files(testXRandRScreens_SRCS ../settings.kcfgc)
+qt5_add_dbus_adaptor( testXRandRScreens_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/../org.kde.kwin.OrientationSensor.xml ${CMAKE_CURRENT_SOURCE_DIR}/../orientation_sensor.h KWin::OrientationSensor)
add_executable( testXRandRScreens ${testXRandRScreens_SRCS} )
target_link_libraries( testXRandRScreens
Qt5::Test
+ Qt5::DBus
+ Qt5::Gui
Qt5::Sensors
Qt5::Widgets
KF5::ConfigCore
KF5::ConfigGui
KF5::I18n
KF5::Notifications
KF5::WindowSystem
XCB::XCB
XCB::RANDR
XCB::XFIXES
XCB::SYNC
XCB::COMPOSITE
XCB::DAMAGE
XCB::GLX
XCB::SHM
)
add_test(NAME kwin-testXRandRScreens COMMAND testXRandRScreens)
ecm_mark_as_test(testXRandRScreens)
########################################################
# Test ScreenEdges
########################################################
set( testScreenEdges_SRCS
test_screen_edges.cpp
mock_abstract_client.cpp
mock_client.cpp
mock_screens.cpp
mock_workspace.cpp
../atoms.cpp
../gestures.cpp
../screens.cpp
../screenedge.cpp
../virtualdesktops.cpp
../xcbutils.cpp # init of extensions
../plugins/platforms/x11/standalone/edge.cpp
../orientation_sensor.cpp
)
kconfig_add_kcfg_files(testScreenEdges_SRCS ../settings.kcfgc)
qt5_add_dbus_interface( testScreenEdges_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/../org.freedesktop.ScreenSaver.xml screenlocker_interface)
+qt5_add_dbus_adaptor( testScreenEdges_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/../org.kde.kwin.OrientationSensor.xml ${CMAKE_CURRENT_SOURCE_DIR}/../orientation_sensor.h KWin::OrientationSensor)
add_executable( testScreenEdges ${testScreenEdges_SRCS})
set_target_properties(testScreenEdges PROPERTIES COMPILE_DEFINITIONS "NO_NONE_WINDOW")
target_include_directories(testScreenEdges BEFORE PRIVATE ./)
target_link_libraries(testScreenEdges
Qt5::DBus
Qt5::Sensors
Qt5::Test
Qt5::X11Extras
KF5::ConfigCore
KF5::ConfigGui
KF5::I18n
KF5::GlobalAccel
KF5::Notifications
KF5::WindowSystem
XCB::XCB
XCB::RANDR
XCB::XFIXES
XCB::SYNC
XCB::COMPOSITE
XCB::DAMAGE
XCB::GLX
XCB::SHM
)
add_test(NAME kwin_testScreenEdges COMMAND testScreenEdges)
ecm_mark_as_test(testScreenEdges)
########################################################
# Test OnScreenNotification
########################################################
set( testOnScreenNotification_SRCS
onscreennotificationtest.cpp
../onscreennotification.cpp
../input_event_spy.cpp
)
add_executable( testOnScreenNotification ${testOnScreenNotification_SRCS})
target_link_libraries(testOnScreenNotification
Qt5::Test
Qt5::Widgets # QAction include
Qt5::Quick
KF5::ConfigCore
)
add_test(NAME kwin-testOnScreenNotification COMMAND testOnScreenNotification)
ecm_mark_as_test(testOnScreenNotification)
########################################################
# Test Gestures
########################################################
set( testGestures_SRCS
test_gestures.cpp
../gestures.cpp
)
add_executable( testGestures ${testGestures_SRCS})
target_link_libraries(testGestures
Qt5::Test
)
add_test(NAME kwin-testGestures COMMAND testGestures)
ecm_mark_as_test(testGestures)
########################################################
# Test X11 TimestampUpdate
########################################################
add_executable(testX11TimestampUpdate test_x11_timestamp_update.cpp)
target_link_libraries(testX11TimestampUpdate
Qt5::Test
KF5::CoreAddons
kwin
)
add_test(NAME kwin-testX11TimestampUpdate COMMAND testX11TimestampUpdate)
ecm_mark_as_test(testX11TimestampUpdate)
set(testOpenGLContextAttributeBuilder_SRCS
opengl_context_attribute_builder_test.cpp
../abstract_opengl_context_attribute_builder.cpp
../egl_context_attribute_builder.cpp
)
if(HAVE_EPOXY_GLX)
set(testOpenGLContextAttributeBuilder_SRCS ${testOpenGLContextAttributeBuilder_SRCS} ../plugins/platforms/x11/standalone/glx_context_attribute_builder.cpp)
endif()
add_executable(testOpenGLContextAttributeBuilder ${testOpenGLContextAttributeBuilder_SRCS})
target_link_libraries(testOpenGLContextAttributeBuilder Qt5::Test)
add_test(NAME kwin-testOpenGLContextAttributeBuilder COMMAND testOpenGLContextAttributeBuilder)
ecm_mark_as_test(testOpenGLContextAttributeBuilder)
set(testXkb_SRCS
test_xkb.cpp
../xkb.cpp
)
add_executable(testXkb ${testXkb_SRCS})
target_link_libraries(testXkb
Qt5::Test
Qt5::Gui
Qt5::Widgets
KF5::ConfigCore
KF5::WindowSystem
KF5::WaylandServer
XKB::XKB
)
add_test(NAME kwin-testXkb COMMAND testXkb)
ecm_mark_as_test(testXkb)
if(HAVE_GBM)
add_executable(testGbmSurface test_gbm_surface.cpp ../plugins/platforms/drm/gbm_surface.cpp)
target_link_libraries(testGbmSurface Qt5::Test)
add_test(NAME kwin-testGbmSurface COMMAND testGbmSurface)
ecm_mark_as_test(testGbmSurface)
endif()
add_executable(testVirtualKeyboardDBus test_virtualkeyboard_dbus.cpp ../virtualkeyboard_dbus.cpp)
target_link_libraries(testVirtualKeyboardDBus
Qt5::Test
Qt5::DBus
)
add_test(NAME kwin-testVirtualKeyboardDBus COMMAND testVirtualKeyboardDBus)
ecm_mark_as_test(testVirtualKeyboardDBus)
diff --git a/org.kde.kwin.OrientationSensor.xml b/org.kde.kwin.OrientationSensor.xml
new file mode 100644
index 000000000..12f245c62
--- /dev/null
+++ b/org.kde.kwin.OrientationSensor.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/orientation_sensor.cpp b/orientation_sensor.cpp
index 7d9dcd5c8..c78a3794f 100644
--- a/orientation_sensor.cpp
+++ b/orientation_sensor.cpp
@@ -1,126 +1,153 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2017 Martin Flöser
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 .
*********************************************************************/
#include "orientation_sensor.h"
+#include
#include
#include
+#include
#include
#include
namespace KWin
{
OrientationSensor::OrientationSensor(QObject *parent)
: QObject(parent)
, m_sensor(new QOrientationSensor(this))
{
connect(m_sensor, &QOrientationSensor::readingChanged, this,
[this] {
auto toOrientation = [] (auto reading) {
switch (reading->orientation()) {
case QOrientationReading::Undefined:
return OrientationSensor::Orientation::Undefined;
case QOrientationReading::TopUp:
return OrientationSensor::Orientation::TopUp;
case QOrientationReading::TopDown:
return OrientationSensor::Orientation::TopDown;
case QOrientationReading::LeftUp:
return OrientationSensor::Orientation::LeftUp;
case QOrientationReading::RightUp:
return OrientationSensor::Orientation::RightUp;
case QOrientationReading::FaceUp:
return OrientationSensor::Orientation::FaceUp;
case QOrientationReading::FaceDown:
return OrientationSensor::Orientation::FaceDown;
default:
Q_UNREACHABLE();
}
};
const auto orientation = toOrientation(m_sensor->reading());
if (m_orientation != orientation) {
m_orientation = orientation;
emit orientationChanged();
}
}
);
connect(m_sensor, &QOrientationSensor::activeChanged, this,
[this] {
if (!m_sni) {
return;
}
if (m_sensor->isActive()) {
m_sni->setToolTipTitle(i18n("Automatic screen rotation is enabled"));
} else {
m_sni->setToolTipTitle(i18n("Automatic screen rotation is disabled"));
}
}
);
}
OrientationSensor::~OrientationSensor() = default;
void OrientationSensor::setEnabled(bool enabled)
{
if (m_enabled == enabled) {
return;
}
m_enabled = enabled;
if (m_enabled) {
+ loadConfig();
setupStatusNotifier();
+ m_adaptor = new OrientationSensorAdaptor(this);
} else {
delete m_sni;
m_sni = nullptr;
+ delete m_adaptor;
+ m_adaptor = nullptr;
}
startStopSensor();
}
+void OrientationSensor::loadConfig()
+{
+ if (!m_config) {
+ return;
+ }
+ m_userEnabled = m_config->group("OrientationSensor").readEntry("Enabled", true);
+}
+
void OrientationSensor::setupStatusNotifier()
{
if (m_sni) {
return;
}
m_sni = new KStatusNotifierItem(QStringLiteral("kwin-automatic-rotation"), this);
m_sni->setStandardActionsEnabled(false);
m_sni->setCategory(KStatusNotifierItem::Hardware);
m_sni->setStatus(KStatusNotifierItem::Passive);
m_sni->setTitle(i18n("Automatic Screen Rotation"));
// TODO: proper icon with state
m_sni->setIconByName(QStringLiteral("preferences-desktop-display"));
// we start disabled, it gets updated when the sensor becomes active
m_sni->setToolTipTitle(i18n("Automatic screen rotation is disabled"));
connect(m_sni, &KStatusNotifierItem::activateRequested, this,
[this] {
m_userEnabled = !m_userEnabled;
startStopSensor();
+ emit userEnabledChanged(m_userEnabled);
}
);
}
void OrientationSensor::startStopSensor()
{
if (m_enabled && m_userEnabled) {
m_sensor->start();
} else {
m_sensor->stop();
}
}
+void OrientationSensor::setUserEnabled(bool enabled)
+{
+ if (m_userEnabled == enabled) {
+ return;
+ }
+ m_userEnabled = enabled;
+ if (m_config) {
+ m_config->group("OrientationSensor").writeEntry("Enabled", m_userEnabled);
+ }
+ emit userEnabledChanged(m_userEnabled);
+}
+
}
diff --git a/orientation_sensor.h b/orientation_sensor.h
index 5234360c2..29b2ef703 100644
--- a/orientation_sensor.h
+++ b/orientation_sensor.h
@@ -1,73 +1,91 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2017 Martin Flöser
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 .
*********************************************************************/
#pragma once
#include
+#include
+
#include
class QOrientationSensor;
+class OrientationSensorAdaptor;
class KStatusNotifierItem;
namespace KWin
{
class KWIN_EXPORT OrientationSensor : public QObject
{
Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.OrientationSensor")
+ Q_PROPERTY(bool userEnabled READ isUserEnabled WRITE setUserEnabled NOTIFY userEnabledChanged)
public:
explicit OrientationSensor(QObject *parent = nullptr);
~OrientationSensor();
void setEnabled(bool enabled);
/**
* Just like QOrientationReading::Orientation,
* copied to not leak the QSensors API into internal API.
**/
enum class Orientation {
Undefined,
TopUp,
TopDown,
LeftUp,
RightUp,
FaceUp,
FaceDown
};
Orientation orientation() const {
return m_orientation;
}
+ void setConfig(KSharedConfig::Ptr config) {
+ m_config = config;
+ }
+
+ bool isUserEnabled() const {
+ return m_userEnabled;
+ }
+ void setUserEnabled(bool enabled);
+
Q_SIGNALS:
void orientationChanged();
+ void userEnabledChanged(bool);
private:
void setupStatusNotifier();
void startStopSensor();
+ void loadConfig();
QOrientationSensor *m_sensor;
bool m_enabled = false;
bool m_userEnabled = true;
Orientation m_orientation = Orientation::Undefined;
KStatusNotifierItem *m_sni = nullptr;
+ KSharedConfig::Ptr m_config;
+ OrientationSensorAdaptor *m_adaptor = nullptr;
};
}
diff --git a/screens.cpp b/screens.cpp
index d6df56f9b..d28f75ce1 100644
--- a/screens.cpp
+++ b/screens.cpp
@@ -1,300 +1,308 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2013 Martin Gräßlin
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 .
*********************************************************************/
#include "screens.h"
#include
#include
#include "cursor.h"
#include "orientation_sensor.h"
#include "utils.h"
#include "settings.h"
#include
#include
#include "platform.h"
#include "wayland_server.h"
#ifdef KWIN_UNIT_TEST
#include
#endif
namespace KWin
{
Screens *Screens::s_self = nullptr;
Screens *Screens::create(QObject *parent)
{
Q_ASSERT(!s_self);
#ifdef KWIN_UNIT_TEST
s_self = new MockScreens(parent);
#else
s_self = kwinApp()->platform()->createScreens(parent);
#endif
Q_ASSERT(s_self);
s_self->init();
return s_self;
}
Screens::Screens(QObject *parent)
: QObject(parent)
, m_count(0)
, m_current(0)
, m_currentFollowsMouse(false)
, m_changedTimer(new QTimer(this))
, m_orientationSensor(new OrientationSensor(this))
{
connect(this, &Screens::changed, this,
[this] {
int internalIndex = -1;
for (int i = 0; i < m_count; i++) {
if (isInternal(i)) {
internalIndex = i;
break;
}
}
m_orientationSensor->setEnabled(internalIndex != -1 && supportsTransformations(internalIndex));
}
);
}
Screens::~Screens()
{
s_self = NULL;
}
void Screens::init()
{
m_changedTimer->setSingleShot(true);
m_changedTimer->setInterval(100);
connect(m_changedTimer, SIGNAL(timeout()), SLOT(updateCount()));
connect(m_changedTimer, SIGNAL(timeout()), SIGNAL(changed()));
connect(this, &Screens::countChanged, this, &Screens::changed, Qt::QueuedConnection);
connect(this, &Screens::changed, this, &Screens::updateSize);
connect(this, &Screens::sizeChanged, this, &Screens::geometryChanged);
Settings settings;
settings.setDefaults();
m_currentFollowsMouse = settings.activeMouseScreen();
}
QString Screens::name(int screen) const
{
Q_UNUSED(screen)
qCWarning(KWIN_CORE, "%s::name(int screen) is a stub, please reimplement it!", metaObject()->className());
return QLatin1String("DUMMY");
}
float Screens::refreshRate(int screen) const
{
Q_UNUSED(screen)
qCWarning(KWIN_CORE, "%s::refreshRate(int screen) is a stub, please reimplement it!", metaObject()->className());
return 60.0f;
}
qreal Screens::scale(int screen) const
{
Q_UNUSED(screen)
return 1;
}
void Screens::reconfigure()
{
if (!m_config) {
return;
}
Settings settings(m_config);
settings.read();
setCurrentFollowsMouse(settings.activeMouseScreen());
}
void Screens::updateSize()
{
QRect bounding;
for (int i = 0; i < count(); ++i) {
bounding = bounding.united(geometry(i));
}
if (m_boundingSize != bounding.size()) {
m_boundingSize = bounding.size();
emit sizeChanged();
}
}
void Screens::setCount(int count)
{
if (m_count == count) {
return;
}
const int previous = m_count;
m_count = count;
emit countChanged(previous, count);
}
void Screens::setCurrent(int current)
{
if (m_current == current) {
return;
}
m_current = current;
emit currentChanged();
}
void Screens::setCurrent(const QPoint &pos)
{
setCurrent(number(pos));
}
void Screens::setCurrent(const AbstractClient *c)
{
if (!c->isActive()) {
return;
}
if (!c->isOnScreen(m_current)) {
setCurrent(c->screen());
}
}
void Screens::setCurrentFollowsMouse(bool follows)
{
if (m_currentFollowsMouse == follows) {
return;
}
m_currentFollowsMouse = follows;
}
int Screens::current() const
{
if (m_currentFollowsMouse) {
return number(Cursor::pos());
}
AbstractClient *client = Workspace::self()->activeClient();
if (client && !client->isOnScreen(m_current)) {
return client->screen();
}
return m_current;
}
int Screens::intersecting(const QRect &r) const
{
int cnt = 0;
for (int i = 0; i < count(); ++i) {
if (geometry(i).intersects(r)) {
++cnt;
}
}
return cnt;
}
QSize Screens::displaySize() const
{
return size();
}
QSizeF Screens::physicalSize(int screen) const
{
return QSizeF(size(screen)) / 3.8;
}
bool Screens::isInternal(int screen) const
{
Q_UNUSED(screen)
return false;
}
bool Screens::supportsTransformations(int screen) const
{
Q_UNUSED(screen)
return false;
}
Qt::ScreenOrientation Screens::orientation(int screen) const
{
Q_UNUSED(screen)
return Qt::PrimaryOrientation;
}
+void Screens::setConfig(KSharedConfig::Ptr config)
+{
+ m_config = config;
+ if (m_orientationSensor) {
+ m_orientationSensor->setConfig(config);
+ }
+}
+
BasicScreens::BasicScreens(Platform *backend, QObject *parent)
: Screens(parent)
, m_backend(backend)
{
}
BasicScreens::~BasicScreens() = default;
void BasicScreens::init()
{
updateCount();
KWin::Screens::init();
#ifndef KWIN_UNIT_TEST
connect(m_backend, &Platform::screenSizeChanged,
this, &BasicScreens::startChangedTimer);
#endif
emit changed();
}
QRect BasicScreens::geometry(int screen) const
{
if (screen < m_geometries.count()) {
return m_geometries.at(screen);
}
return QRect();
}
QSize BasicScreens::size(int screen) const
{
if (screen < m_geometries.count()) {
return m_geometries.at(screen).size();
}
return QSize();
}
qreal BasicScreens::scale(int screen) const
{
if (screen < m_scales.count()) {
return m_scales.at(screen);
}
return 1;
}
void BasicScreens::updateCount()
{
m_geometries = m_backend->screenGeometries();
m_scales = m_backend->screenScales();
setCount(m_geometries.count());
}
int BasicScreens::number(const QPoint &pos) const
{
int bestScreen = 0;
int minDistance = INT_MAX;
for (int i = 0; i < m_geometries.count(); ++i) {
const QRect &geo = m_geometries.at(i);
if (geo.contains(pos)) {
return i;
}
int distance = QPoint(geo.topLeft() - pos).manhattanLength();
distance = qMin(distance, QPoint(geo.topRight() - pos).manhattanLength());
distance = qMin(distance, QPoint(geo.bottomRight() - pos).manhattanLength());
distance = qMin(distance, QPoint(geo.bottomLeft() - pos).manhattanLength());
if (distance < minDistance) {
minDistance = distance;
bestScreen = i;
}
}
return bestScreen;
}
} // namespace
diff --git a/screens.h b/screens.h
index 76add1381..4fda86fb9 100644
--- a/screens.h
+++ b/screens.h
@@ -1,270 +1,264 @@
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2013 Martin Gräßlin
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 KWIN_SCREENS_H
#define KWIN_SCREENS_H
// KWin includes
#include
// KDE includes
#include
#include
// Qt includes
#include
#include
#include
#include
namespace KWin
{
class AbstractClient;
class Platform;
class OrientationSensor;
class KWIN_EXPORT Screens : public QObject
{
Q_OBJECT
Q_PROPERTY(int count READ count WRITE setCount NOTIFY countChanged)
Q_PROPERTY(int current READ current WRITE setCurrent NOTIFY currentChanged)
Q_PROPERTY(bool currentFollowsMouse READ isCurrentFollowsMouse WRITE setCurrentFollowsMouse)
public:
virtual ~Screens();
/**
* @internal
**/
void setConfig(KSharedConfig::Ptr config);
int count() const;
int current() const;
void setCurrent(int current);
/**
* Called e.g. when a user clicks on a window, set current screen to be the screen
* where the click occurred
*/
void setCurrent(const QPoint &pos);
/**
* Check whether a client moved completely out of what's considered the current screen,
* if yes, set a new active screen.
*/
void setCurrent(const AbstractClient *c);
bool isCurrentFollowsMouse() const;
void setCurrentFollowsMouse(bool follows);
virtual QRect geometry(int screen) const = 0;
/**
* The bounding geometry of all screens combined. Overlapping areas
* are not counted multiple times.
* @see geometryChanged()
**/
QRect geometry() const;
/**
* The output name of the screen (usually eg. LVDS-1, VGA-0 or DVI-I-1 etc.)
*/
virtual QString name(int screen) const;
/**
* @returns current refreshrate of the @p screen.
**/
virtual float refreshRate(int screen) const;
/**
* @returns size of the @p screen.
*
* To get the size of all screens combined use size().
* @see size()
**/
virtual QSize size(int screen) const = 0;
/*
* The output scale for this display, for use by high DPI displays
*/
virtual qreal scale(int screen) const;
/**
* The bounding size of all screens combined. Overlapping areas
* are not counted multiple times.
*
* @see geometry()
* @see sizeChanged()
**/
QSize size() const;
virtual int number(const QPoint &pos) const = 0;
inline bool isChanging() { return m_changedTimer->isActive(); }
int intersecting(const QRect &r) const;
/**
* The virtual bounding size of all screens combined.
* The default implementation returns the same as @link{size} and that is the
* method which should be preferred.
*
* This method is only for cases where the platform specific implementation needs
* to support different virtual sizes like on X11 with XRandR panning.
*
* @see size
**/
virtual QSize displaySize() const;
/**
* The physical size of @p screen in mm.
* Default implementation returns a size derived from 96 DPI.
**/
virtual QSizeF physicalSize(int screen) const;
/**
* @returns @c true if the @p screen is connected through an internal display (e.g. LVDS).
* Default implementation returns @c false.
**/
virtual bool isInternal(int screen) const;
/**
* @returns @c true if the @p screen can be rotated.
* Default implementation returns @c false
**/
virtual bool supportsTransformations(int screen) const;
virtual Qt::ScreenOrientation orientation(int screen) const;
/**
* Provides access to the OrientationSensor. The OrientationSensor is controlled by the
* base implementation. The implementing subclass can use this to get notifications about
* changes of the orientation and current orientation. There is no need to enable/disable it,
* that is done by the base implementation
**/
OrientationSensor *orientationSensor() const {
return m_orientationSensor;
}
public Q_SLOTS:
void reconfigure();
Q_SIGNALS:
void countChanged(int previousCount, int newCount);
/**
* Emitted whenever the screens are changed either count or geometry.
**/
void changed();
void currentChanged();
/**
* Emitted when the geometry of all screens combined changes.
* Not emitted when the geometry of an individual screen changes.
* @see geometry()
**/
void geometryChanged();
/**
* Emitted when the size of all screens combined changes.
* Not emitted when the size of an individual screen changes.
* @see size()
**/
void sizeChanged();
protected Q_SLOTS:
void setCount(int count);
void startChangedTimer();
virtual void updateCount() = 0;
protected:
/**
* Called once the singleton instance has been created.
* Any initialization code should go into this method. Overriding classes have to call
* the base implementation first.
**/
virtual void init();
private Q_SLOTS:
void updateSize();
private:
int m_count;
int m_current;
bool m_currentFollowsMouse;
QTimer *m_changedTimer;
KSharedConfig::Ptr m_config;
QSize m_boundingSize;
OrientationSensor *m_orientationSensor;
KWIN_SINGLETON(Screens)
};
/**
* @brief A base implementation for backends with just a (nested) window
**/
class KWIN_EXPORT BasicScreens : public Screens
{
Q_OBJECT
public:
BasicScreens(Platform *backend, QObject *parent = nullptr);
virtual ~BasicScreens();
void init() override;
QRect geometry(int screen) const override;
int number(const QPoint &pos) const override;
QSize size(int screen) const override;
qreal scale(int screen) const override;
void updateCount() override;
private:
Platform *m_backend;
QVector m_geometries;
QVector m_scales;
};
-inline
-void Screens::setConfig(KSharedConfig::Ptr config)
-{
- m_config = config;
-}
-
inline
int Screens::count() const
{
return m_count;
}
inline
bool Screens::isCurrentFollowsMouse() const
{
return m_currentFollowsMouse;
}
inline
void Screens::startChangedTimer()
{
m_changedTimer->start();
}
inline
QSize Screens::size() const
{
return m_boundingSize;
}
inline
QRect Screens::geometry() const
{
return QRect(QPoint(0,0), size());
}
inline
Screens *screens()
{
return Screens::self();
}
}
#endif // KWIN_SCREENS_H
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 35eae423a..48f307c77 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,48 +1,54 @@
if (XCB_ICCCM_FOUND)
set(normalhintsbasesizetest_SRCS normalhintsbasesizetest.cpp)
add_executable(normalhintsbasesizetest ${normalhintsbasesizetest_SRCS})
target_link_libraries(normalhintsbasesizetest XCB::XCB XCB::ICCCM KF5::WindowSystem)
endif()
# next target
set(screenedgeshowtest_SRCS screenedgeshowtest.cpp)
add_executable(screenedgeshowtest ${screenedgeshowtest_SRCS})
target_link_libraries(screenedgeshowtest Qt5::Widgets Qt5::X11Extras KF5::ConfigCore KF5::WindowSystem KF5::WaylandClient ${XCB_XCB_LIBRARY})
if (KF5Wayland_FOUND)
add_definitions(-DSOURCE_DIR="${KWIN_SOURCE_DIR}")
set(waylandclienttest_SRCS
waylandclienttest.cpp
)
add_executable(waylandclienttest ${waylandclienttest_SRCS})
target_link_libraries(waylandclienttest Qt5::Core Qt5::Gui KF5::WaylandClient)
endif()
if (HAVE_INPUT)
set(libinputtest_SRCS
libinputtest.cpp
${KWIN_SOURCE_DIR}/libinput/context.cpp
${KWIN_SOURCE_DIR}/libinput/connection.cpp
${KWIN_SOURCE_DIR}/libinput/device.cpp
${KWIN_SOURCE_DIR}/libinput/events.cpp
${KWIN_SOURCE_DIR}/libinput/libinput_logging.cpp
${KWIN_SOURCE_DIR}/logind.cpp
${KWIN_SOURCE_DIR}/udev.cpp
)
add_executable(libinputtest ${libinputtest_SRCS})
add_definitions(-DKWIN_BUILD_TESTING)
target_link_libraries(libinputtest Qt5::Core Qt5::DBus Libinput::Libinput ${UDEV_LIBS} KF5::ConfigCore KF5::GlobalAccel KF5::WindowSystem)
endif()
add_executable(x11shadowreader x11shadowreader.cpp)
target_link_libraries(x11shadowreader XCB::XCB Qt5::Widgets Qt5::X11Extras KF5::ConfigCore KF5::WindowSystem)
add_executable(pointergestures pointergesturestest.cpp)
add_definitions(-DDIR="${CMAKE_CURRENT_SOURCE_DIR}")
target_link_libraries(pointergestures Qt5::Gui Qt5::Quick KF5::WaylandClient)
add_executable(cursorhotspottest cursorhotspottest.cpp)
target_link_libraries(cursorhotspottest Qt5::Widgets)
-add_executable(orientationtest orientationtest.cpp ../orientation_sensor.cpp)
-target_link_libraries(orientationtest Qt5::Widgets Qt5::Sensors KF5::Notifications KF5::I18n)
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+set( orientationtest_SRCS
+ orientationtest.cpp
+ ../orientation_sensor.cpp
+)
+qt5_add_dbus_adaptor( orientationtest_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/../org.kde.kwin.OrientationSensor.xml ${CMAKE_CURRENT_SOURCE_DIR}/../orientation_sensor.h KWin::OrientationSensor)
+add_executable(orientationtest ${orientationtest_SRCS})
+target_link_libraries(orientationtest Qt5::DBus Qt5::Widgets Qt5::Sensors KF5::ConfigCore KF5::Notifications KF5::I18n)