diff --git a/CMakeLists.txt b/CMakeLists.txt index d120c7f49..735eeaeb8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,755 +1,747 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR) project(KWIN) set(PROJECT_VERSION "5.16.80") set(PROJECT_VERSION_MAJOR 5) set(QT_MIN_VERSION "5.12.0") set(KF5_MIN_VERSION "5.58.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 -DQT_NO_URL_CAST_FROM_STRING) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) -# This is a workaround/compromise for a Kwin specific policy of not applying the relevant override fix. -# See thread in D18167. -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-inconsistent-missing-override") -else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-suggest-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(KF5Kirigami2 ${KF5_MIN_VERSION} CONFIG) set_package_properties(KF5Kirigami2 PROPERTIES DESCRIPTION "A QtQuick based components set" PURPOSE "Required at runtime for Virtual desktop KCM and the virtual keyboard" TYPE RUNTIME ) find_package(KDecoration2 5.13.0 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 "https://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.9) set_package_properties(Libinput PROPERTIES TYPE REQUIRED 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 REQUIRED PURPOSE "Required for input handling on Wayland." ) 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) set(HAVE_DRM TRUE) endif() find_package(gbm) set_package_properties(gbm PROPERTIES TYPE OPTIONAL PURPOSE "Required for egl output of drm backend.") set(HAVE_GBM FALSE) if(HAVE_DRM AND gbm_FOUND) set(HAVE_GBM TRUE) endif() option(KWIN_BUILD_EGL_STREAM_BACKEND "Enable building of EGLStream based DRM backend" ON) if(HAVE_DRM AND KWIN_BUILD_EGL_STREAM_BACKEND) set(HAVE_EGL_STREAMS 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 "https://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 "https://www.freetype.org" TYPE REQUIRED PURPOSE "Needed for KWin's QPA plugin." ) find_package(Fontconfig REQUIRED) set_package_properties(Fontconfig PROPERTIES TYPE REQUIRED PURPOSE "Needed for KWin's QPA plugin." ) find_package(Xwayland) set_package_properties(Xwayland PROPERTIES URL "https://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) 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") configure_file(config-kwin.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kwin.h ) ########### 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 virtualdesktopsdbustypes.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 outputscreens.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 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 abstract_output.cpp abstract_wayland_output.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 libinput/context.cpp libinput/connection.cpp libinput/device.cpp libinput/events.cpp libinput/libinput_logging.cpp udev.cpp touch_hide_cursor_spy.cpp internal_client.cpp xwl/xwayland_interface.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) include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) 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 (HAVE_LINUX_VT_H) set(kwin_KDEINIT_SRCS ${kwin_KDEINIT_SRCS} virtual_terminal.cpp ) 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_adaptor( kwin_KDEINIT_SRCS org.kde.KWin.VirtualDesktopManager.xml dbusinterface.h KWin::VirtualDesktopManagerDBusInterface ) qt5_add_dbus_interface( kwin_KDEINIT_SRCS ${KSCREENLOCKER_DBUS_INTERFACES_DIR}/kf5_org.freedesktop.ScreenSaver.xml screenlocker_interface ) qt5_add_dbus_interface( kwin_KDEINIT_SRCS ${KSCREENLOCKER_DBUS_INTERFACES_DIR}/org.kde.screensaver.xml kscreenlocker_interface ) qt5_add_dbus_interface( kwin_KDEINIT_SRCS org.kde.kappmenu.xml appmenu_interface ) 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} ${UDEV_LIBS} Libinput::Libinput ) 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} ) set(kwin_XWAYLAND_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/xwl/xwayland.cpp ${CMAKE_CURRENT_SOURCE_DIR}/xwl/databridge.cpp ${CMAKE_CURRENT_SOURCE_DIR}/xwl/selection.cpp ${CMAKE_CURRENT_SOURCE_DIR}/xwl/selection_source.cpp ${CMAKE_CURRENT_SOURCE_DIR}/xwl/transfer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/xwl/clipboard.cpp ${CMAKE_CURRENT_SOURCE_DIR}/xwl/dnd.cpp ${CMAKE_CURRENT_SOURCE_DIR}/xwl/drag.cpp ${CMAKE_CURRENT_SOURCE_DIR}/xwl/drag_wl.cpp ${CMAKE_CURRENT_SOURCE_DIR}/xwl/drag_x.cpp ) include(ECMQtDeclareLoggingCategory) ecm_qt_declare_logging_category(kwin_XWAYLAND_SRCS HEADER xwayland_logging.h IDENTIFIER KWIN_XWL CATEGORY_NAME kwin_xwl DEFAULT_SEVERITY Critical ) set(kwin_WAYLAND_SRCS tabletmodemanager.cpp main_wayland.cpp ) add_executable(kwin_wayland ${kwin_WAYLAND_SRCS} ${kwin_XWAYLAND_SRCS}) target_link_libraries(kwin_wayland kwin KF5::Crash) 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 org.kde.KWin.VirtualDesktopManager.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} ) add_subdirectory(qml) if (BUILD_TESTING) add_subdirectory(autotests) add_subdirectory(tests) endif() if (KF5DocTools_FOUND) add_subdirectory(doc) endif() add_subdirectory(kconf_update) 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/abstract_client.h b/abstract_client.h index 8afdc3d48..220afeeeb 100644 --- a/abstract_client.h +++ b/abstract_client.h @@ -1,1385 +1,1385 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_ABSTRACT_CLIENT_H #define KWIN_ABSTRACT_CLIENT_H #include "toplevel.h" #include "options.h" #include "rules.h" #include "tabgroup.h" #include "cursor.h" #include #include #include namespace KWayland { namespace Server { class PlasmaWindowInterface; } } namespace KDecoration2 { class Decoration; } namespace KWin { namespace TabBox { class TabBoxClientImpl; } namespace Decoration { class DecoratedClientImpl; class DecorationPalette; } class KWIN_EXPORT AbstractClient : public Toplevel { Q_OBJECT /** * Whether this Client is fullScreen. A Client might either be fullScreen due to the _NET_WM property * or through a legacy support hack. The fullScreen state can only be changed if the Client does not * use the legacy hack. To be sure whether the state changed, connect to the notify signal. **/ Q_PROPERTY(bool fullScreen READ isFullScreen WRITE setFullScreen NOTIFY fullScreenChanged) /** * Whether the Client can be set to fullScreen. The property is evaluated each time it is invoked. * Because of that there is no notify signal. **/ Q_PROPERTY(bool fullScreenable READ isFullScreenable) /** * Whether this Client is the currently visible Client in its Client Group (Window Tabs). * For change connect to the visibleChanged signal on the Client's Group. **/ Q_PROPERTY(bool isCurrentTab READ isCurrentTab) /** * Whether this Client is active or not. Use Workspace::activateClient() to activate a Client. * @see Workspace::activateClient **/ Q_PROPERTY(bool active READ isActive NOTIFY activeChanged) /** * The desktop this Client is on. If the Client is on all desktops the property has value -1. * This is a legacy property, use x11DesktopIds instead **/ Q_PROPERTY(int desktop READ desktop WRITE setDesktop NOTIFY desktopChanged) /** * Whether the Client is on all desktops. That is desktop is -1. **/ Q_PROPERTY(bool onAllDesktops READ isOnAllDesktops WRITE setOnAllDesktops NOTIFY desktopChanged) /** * The x11 ids for all desktops this client is in. On X11 this list will always have a length of 1 **/ Q_PROPERTY(QVector x11DesktopIds READ x11DesktopIds NOTIFY x11DesktopIdsChanged) /** * Indicates that the window should not be included on a taskbar. **/ Q_PROPERTY(bool skipTaskbar READ skipTaskbar WRITE setSkipTaskbar NOTIFY skipTaskbarChanged) /** * Indicates that the window should not be included on a Pager. **/ Q_PROPERTY(bool skipPager READ skipPager WRITE setSkipPager NOTIFY skipPagerChanged) /** * Whether the Client should be excluded from window switching effects. **/ Q_PROPERTY(bool skipSwitcher READ skipSwitcher WRITE setSkipSwitcher NOTIFY skipSwitcherChanged) /** * Whether the window can be closed by the user. The value is evaluated each time the getter is called. * Because of that no changed signal is provided. **/ Q_PROPERTY(bool closeable READ isCloseable) Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged) /** * Whether the Client is set to be kept above other windows. **/ Q_PROPERTY(bool keepAbove READ keepAbove WRITE setKeepAbove NOTIFY keepAboveChanged) /** * Whether the Client is set to be kept below other windows. **/ Q_PROPERTY(bool keepBelow READ keepBelow WRITE setKeepBelow NOTIFY keepBelowChanged) /** * Whether the Client can be shaded. The property is evaluated each time it is invoked. * Because of that there is no notify signal. **/ Q_PROPERTY(bool shadeable READ isShadeable) /** * Whether the Client is shaded. **/ Q_PROPERTY(bool shade READ isShade WRITE setShade NOTIFY shadeChanged) /** * Whether the Client can be minimized. The property is evaluated each time it is invoked. * Because of that there is no notify signal. **/ Q_PROPERTY(bool minimizable READ isMinimizable) /** * Whether the Client is minimized. **/ Q_PROPERTY(bool minimized READ isMinimized WRITE setMinimized NOTIFY minimizedChanged) /** * The optional geometry representing the minimized Client in e.g a taskbar. * See _NET_WM_ICON_GEOMETRY at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . * The value is evaluated each time the getter is called. * Because of that no changed signal is provided. **/ Q_PROPERTY(QRect iconGeometry READ iconGeometry) /** * Returns whether the window is any of special windows types (desktop, dock, splash, ...), * i.e. window types that usually don't have a window frame and the user does not use window * management (moving, raising,...) on them. * The value is evaluated each time the getter is called. * Because of that no changed signal is provided. **/ Q_PROPERTY(bool specialWindow READ isSpecialWindow) /** * Whether window state _NET_WM_STATE_DEMANDS_ATTENTION is set. This state indicates that some * action in or with the window happened. For example, it may be set by the Window Manager if * the window requested activation but the Window Manager refused it, or the application may set * it if it finished some work. This state may be set by both the Client and the Window Manager. * It should be unset by the Window Manager when it decides the window got the required attention * (usually, that it got activated). **/ Q_PROPERTY(bool demandsAttention READ isDemandingAttention WRITE demandAttention NOTIFY demandsAttentionChanged) /** * The Caption of the Client. Read from WM_NAME property together with a suffix for hostname and shortcut. * To read only the caption as provided by WM_NAME, use the getter with an additional @c false value. **/ Q_PROPERTY(QString caption READ caption NOTIFY captionChanged) /** * Minimum size as specified in WM_NORMAL_HINTS **/ Q_PROPERTY(QSize minSize READ minSize) /** * Maximum size as specified in WM_NORMAL_HINTS **/ Q_PROPERTY(QSize maxSize READ maxSize) /** * Whether the Client can accept keyboard focus. * The value is evaluated each time the getter is called. * Because of that no changed signal is provided. **/ Q_PROPERTY(bool wantsInput READ wantsInput) /** * Whether the Client is a transient Window to another Window. * @see transientFor **/ Q_PROPERTY(bool transient READ isTransient NOTIFY transientChanged) /** * The Client to which this Client is a transient if any. **/ Q_PROPERTY(KWin::AbstractClient *transientFor READ transientFor NOTIFY transientChanged) /** * Whether the Client represents a modal window. **/ Q_PROPERTY(bool modal READ isModal NOTIFY modalChanged) /** * The geometry of this Client. Be aware that depending on resize mode the geometryChanged signal * might be emitted at each resize step or only at the end of the resize operation. **/ Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry) /** * Whether the Client is currently being moved by the user. * Notify signal is emitted when the Client starts or ends move/resize mode. **/ Q_PROPERTY(bool move READ isMove NOTIFY moveResizedChanged) /** * Whether the Client is currently being resized by the user. * Notify signal is emitted when the Client starts or ends move/resize mode. **/ Q_PROPERTY(bool resize READ isResize NOTIFY moveResizedChanged) /** * Whether the decoration is currently using an alpha channel. **/ Q_PROPERTY(bool decorationHasAlpha READ decorationHasAlpha) /** * Whether the window has a decoration or not. * This property is not allowed to be set by applications themselves. * The decision whether a window has a border or not belongs to the window manager. * If this property gets abused by application developers, it will be removed again. **/ Q_PROPERTY(bool noBorder READ noBorder WRITE setNoBorder) /** * Whether the Client provides context help. Mostly needed by decorations to decide whether to * show the help button or not. **/ Q_PROPERTY(bool providesContextHelp READ providesContextHelp CONSTANT) /** * Whether the Client can be maximized both horizontally and vertically. * The property is evaluated each time it is invoked. * Because of that there is no notify signal. **/ Q_PROPERTY(bool maximizable READ isMaximizable) /** * Whether the Client is moveable. Even if it is not moveable, it might be possible to move * it to another screen. The property is evaluated each time it is invoked. * Because of that there is no notify signal. * @see moveableAcrossScreens **/ Q_PROPERTY(bool moveable READ isMovable) /** * Whether the Client can be moved to another screen. The property is evaluated each time it is invoked. * Because of that there is no notify signal. * @see moveable **/ Q_PROPERTY(bool moveableAcrossScreens READ isMovableAcrossScreens) /** * Whether the Client can be resized. The property is evaluated each time it is invoked. * Because of that there is no notify signal. **/ Q_PROPERTY(bool resizeable READ isResizable) /** * The desktop file name of the application this AbstractClient belongs to. * * This is either the base name without full path and without file extension of the * desktop file for the window's application (e.g. "org.kde.foo"). * * The application's desktop file name can also be the full path to the desktop file * (e.g. "/opt/kde/share/org.kde.foo.desktop") in case it's not in a standard location. **/ Q_PROPERTY(QByteArray desktopFileName READ desktopFileName NOTIFY desktopFileNameChanged) /** * Whether an application menu is available for this Client **/ Q_PROPERTY(bool hasApplicationMenu READ hasApplicationMenu NOTIFY hasApplicationMenuChanged) /** * Whether the application menu for this Client is currently opened **/ Q_PROPERTY(bool applicationMenuActive READ applicationMenuActive NOTIFY applicationMenuActiveChanged) /** * Whether this client is unresponsive. * * When an application failed to react on a ping request in time, it is * considered unresponsive. This usually indicates that the application froze or crashed. **/ Q_PROPERTY(bool unresponsive READ unresponsive NOTIFY unresponsiveChanged) /** * The "Window Tabs" Group this Client belongs to. **/ Q_PROPERTY(KWin::TabGroup* tabGroup READ tabGroup NOTIFY tabGroupChanged SCRIPTABLE false) /** * The color scheme set on this client * Absolute file path, or name of palette in the user's config directory following KColorSchemes format. * An empty string indicates the default palette from kdeglobals is used. * @note this indicates the colour scheme requested, which might differ from the theme applied if the colorScheme cannot be found **/ Q_PROPERTY(QString colorScheme READ colorScheme NOTIFY colorSchemeChanged) public: - virtual ~AbstractClient(); + ~AbstractClient() override; QWeakPointer tabBoxClient() const { return m_tabBoxClient.toWeakRef(); } bool isFirstInTabBox() const { return m_firstInTabBox; } bool skipSwitcher() const { return m_skipSwitcher; } void setSkipSwitcher(bool set); bool skipTaskbar() const { return m_skipTaskbar; } void setSkipTaskbar(bool set); void setOriginalSkipTaskbar(bool set); bool originalSkipTaskbar() const { return m_originalSkipTaskbar; } bool skipPager() const { return m_skipPager; } void setSkipPager(bool set); const QIcon &icon() const { return m_icon; } bool isActive() const { return m_active; } /** * Sets the client's active state to \a act. * * This function does only change the visual appearance of the client, * it does not change the focus setting. Use * Workspace::activateClient() or Workspace::requestFocus() instead. * * If a client receives or looses the focus, it calls setActive() on * its own. **/ void setActive(bool); bool keepAbove() const { return m_keepAbove; } void setKeepAbove(bool); bool keepBelow() const { return m_keepBelow; } void setKeepBelow(bool); void demandAttention(bool set = true); bool isDemandingAttention() const { return m_demandsAttention; } void cancelAutoRaise(); bool wantsTabFocus() const; QPoint clientPos() const override { return QPoint(borderLeft(), borderTop()); } virtual void updateMouseGrab(); /** * @returns The caption consisting of captionNormal and captionSuffix * @see captionNormal * @see captionSuffix **/ QString caption() const; /** * @returns The caption as set by the AbstractClient without any suffix. * @see caption * @see captionSuffix **/ virtual QString captionNormal() const = 0; /** * @returns The suffix added to the caption (e.g. shortcut, machine name, etc.) * @see caption * @see captionNormal **/ virtual QString captionSuffix() const = 0; virtual bool isCloseable() const = 0; // TODO: remove boolean trap virtual bool isShown(bool shaded_is_shown) const = 0; virtual bool isHiddenInternal() const = 0; // TODO: remove boolean trap virtual void hideClient(bool hide) = 0; virtual bool isFullScreenable() const = 0; virtual bool isFullScreen() const = 0; // TODO: remove boolean trap virtual AbstractClient *findModal(bool allow_itself = false) = 0; virtual bool isTransient() const; /** * @returns Whether there is a hint available to place the AbstractClient on it's parent, default @c false. * @see transientPlacementHint **/ virtual bool hasTransientPlacementHint() const; /** * Only valid id hasTransientPlacementHint is true * @returns The position the transient wishes to position itself **/ virtual QRect transientPlacement(const QRect &bounds) const; const AbstractClient* transientFor() const; AbstractClient* transientFor(); /** * @returns @c true if c is the transient_for window for this client, * or recursively the transient_for window * @todo: remove boolean trap **/ virtual bool hasTransient(const AbstractClient* c, bool indirect) const; const QList& transients() const; // Is not indirect virtual void removeTransient(AbstractClient* cl); virtual QList mainClients() const; // Call once before loop , is not indirect QList allMainClients() const; // Call once before loop , is indirect /** * Returns true for "special" windows and false for windows which are "normal" * (normal=window which has a border, can be moved by the user, can be closed, etc.) * true for Desktop, Dock, Splash, Override and TopMenu (and Toolbar??? - for now) * false for Normal, Dialog, Utility and Menu (and Toolbar??? - not yet) TODO **/ bool isSpecialWindow() const; void sendToScreen(int screen); const QKeySequence &shortcut() const { return _shortcut; } void setShortcut(const QString &cut); virtual bool performMouseCommand(Options::MouseCommand, const QPoint &globalPos); void setOnAllDesktops(bool set); void setDesktop(int); void enterDesktop(VirtualDesktop *desktop); void leaveDesktop(VirtualDesktop *desktop); /** * Set the window as being on the attached list of desktops * On X11 it will be set to the last entry **/ void setDesktops(QVector desktops); int desktop() const override { return m_desktops.isEmpty() ? (int)NET::OnAllDesktops : m_desktops.last()->x11DesktopNumber(); } - virtual QVector desktops() const { + QVector desktops() const override { return m_desktops; } QVector x11DesktopIds() const; void setMinimized(bool set); /** * Minimizes this client plus its transients **/ void minimize(bool avoid_animation = false); void unminimize(bool avoid_animation = false); bool isMinimized() const { return m_minimized; } virtual void setFullScreen(bool set, bool user = true) = 0; // Tabbing functions Q_INVOKABLE inline bool tabBefore(AbstractClient *other, bool activate) { return tabTo(other, false, activate); } Q_INVOKABLE inline bool tabBehind(AbstractClient *other, bool activate) { return tabTo(other, true, activate); } /** * Syncs the *dynamic* @p property @p fromThisClient or the currentTab() to * all members of the tabGroup() (if there is one) * * eg. if you call: * @code * client->setProperty("kwin_tiling_floats", true); * client->syncTabGroupFor("kwin_tiling_floats", true) * @endcode * all clients in this tabGroup will have property("kwin_tiling_floats").toBool() == true * * WARNING: non dynamic properties are ignored - you're not supposed to alter/update such explicitly **/ Q_INVOKABLE void syncTabGroupFor(QString property, bool fromThisClient = false); TabGroup *tabGroup() const; /** * Set tab group - this is to be invoked by TabGroup::add/remove(client) and NO ONE ELSE **/ void setTabGroup(TabGroup* group); virtual void setClientShown(bool shown); Q_INVOKABLE bool untab(const QRect &toGeometry = QRect(), bool clientRemoved = false); /** * When a click is done in the decoration and it calls the group * to change the visible client it starts to move-resize the new * client, this function stops it. **/ bool isCurrentTab() const; virtual QRect geometryRestore() const = 0; /** * The currently applied maximize mode **/ virtual MaximizeMode maximizeMode() const = 0; /** * The maximise mode requested by the server. * For X this always matches maximizeMode, for wayland clients it * is asyncronous **/ virtual MaximizeMode requestedMaximizeMode() const; void maximize(MaximizeMode); /** * Sets the maximization according to @p vertically and @p horizontally. **/ Q_INVOKABLE void setMaximize(bool vertically, bool horizontally); virtual bool noBorder() const = 0; virtual void setNoBorder(bool set) = 0; virtual void blockActivityUpdates(bool b = true) = 0; QPalette palette() const; const Decoration::DecorationPalette *decorationPalette() const; /** * Returns whether the window is resizable or has a fixed size. **/ virtual bool isResizable() const = 0; /** * Returns whether the window is moveable or has a fixed position. **/ virtual bool isMovable() const = 0; /** * Returns whether the window can be moved to another screen. **/ virtual bool isMovableAcrossScreens() const = 0; /** * @c true only for @c ShadeNormal **/ bool isShade() const { return shadeMode() == ShadeNormal; } /** * Default implementation returns @c ShadeNone **/ virtual ShadeMode shadeMode() const; // Prefer isShade() void setShade(bool set); /** * Default implementation does nothing **/ virtual void setShade(ShadeMode mode); /** * Whether the Client can be shaded. Default implementation returns @c false. **/ virtual bool isShadeable() const; /** * Returns whether the window is maximizable or not. **/ virtual bool isMaximizable() const = 0; virtual bool isMinimizable() const = 0; virtual QRect iconGeometry() const; virtual bool userCanSetFullScreen() const = 0; virtual bool userCanSetNoBorder() const = 0; virtual void checkNoBorder(); virtual void setOnActivities(QStringList newActivitiesList); virtual void setOnAllActivities(bool set) = 0; const WindowRules* rules() const { return &m_rules; } void removeRule(Rules* r); void setupWindowRules(bool ignore_temporary); void evaluateWindowRules(); void applyWindowRules(); virtual void takeFocus() = 0; virtual bool wantsInput() const = 0; /** * Whether a dock window wants input. * * By default KWin doesn't pass focus to a dock window unless a force activate * request is provided. * * This method allows to have dock windows take focus also through flags set on * the window. * * The default implementation returns @c false. **/ virtual bool dockWantsInput() const; void checkWorkspacePosition(QRect oldGeometry = QRect(), int oldDesktop = -2, QRect oldClientGeometry = QRect()); virtual xcb_timestamp_t userTime() const; virtual void updateWindowRules(Rules::Types selection); void growHorizontal(); void shrinkHorizontal(); void growVertical(); void shrinkVertical(); void updateMoveResize(const QPointF ¤tGlobalCursor); /** * Ends move resize when all pointer buttons are up again. **/ void endMoveResize(); void keyPressEvent(uint key_code); void enterEvent(const QPoint &globalPos); void leaveEvent(); /** * These values represent positions inside an area **/ enum Position { // without prefix, they'd conflict with Qt::TopLeftCorner etc. :( PositionCenter = 0x00, PositionLeft = 0x01, PositionRight = 0x02, PositionTop = 0x04, PositionBottom = 0x08, PositionTopLeft = PositionLeft | PositionTop, PositionTopRight = PositionRight | PositionTop, PositionBottomLeft = PositionLeft | PositionBottom, PositionBottomRight = PositionRight | PositionBottom }; Position titlebarPosition() const; bool titlebarPositionUnderMouse() const; // a helper for the workspace window packing. tests for screen validity and updates since in maximization case as with normal moving void packTo(int left, int top); /** * Sets the quick tile mode ("snap") of this window. * This will also handle preserving and restoring of window geometry as necessary. * @param mode The tile mode (left/right) to give this window. * @param keyboard Defines whether to take keyboard cursor into account. **/ void setQuickTileMode(QuickTileMode mode, bool keyboard = false); QuickTileMode quickTileMode() const { return QuickTileMode(m_quickTileMode); } Layer layer() const override; void updateLayer(); enum ForceGeometry_t { NormalGeometrySet, ForceGeometrySet }; void move(int x, int y, ForceGeometry_t force = NormalGeometrySet); void move(const QPoint &p, ForceGeometry_t force = NormalGeometrySet); virtual void resizeWithChecks(int w, int h, ForceGeometry_t force = NormalGeometrySet) = 0; void resizeWithChecks(const QSize& s, ForceGeometry_t force = NormalGeometrySet); void keepInArea(QRect area, bool partial = false); virtual QSize minSize() const; virtual QSize maxSize() const; virtual void setGeometry(int x, int y, int w, int h, ForceGeometry_t force = NormalGeometrySet) = 0; void setGeometry(const QRect& r, ForceGeometry_t force = NormalGeometrySet); /// How to resize the window in order to obey constains (mainly aspect ratios) enum Sizemode { SizemodeAny, SizemodeFixedW, ///< Try not to affect width SizemodeFixedH, ///< Try not to affect height SizemodeMax ///< Try not to make it larger in either direction }; /** * Calculates the appropriate frame size for the given client size @p wsize. * * @p wsize is adapted according to the window's size hints (minimum, maximum and incremental size changes). * * Default implementation returns the passed in @p wsize. **/ virtual QSize sizeForClientSize(const QSize &wsize, Sizemode mode = SizemodeAny, bool noframe = false) const; /** * Adjust the frame size @p frame according to the window's size hints. **/ QSize adjustedSize(const QSize&, Sizemode mode = SizemodeAny) const; QSize adjustedSize() const; bool isMove() const { return isMoveResize() && moveResizePointerMode() == PositionCenter; } bool isResize() const { return isMoveResize() && moveResizePointerMode() != PositionCenter; } /** * Cursor shape for move/resize mode. **/ CursorShape cursor() const { return m_moveResize.cursor; } virtual bool hasStrut() const; void setModal(bool modal); bool isModal() const; /** * Determines the mouse command for the given @p button in the current state. * * The @p handled argument specifies whether the button was handled or not. * This value should be used to determine whether the mouse button should be * passed to the AbstractClient or being filtered out. **/ Options::MouseCommand getMouseCommand(Qt::MouseButton button, bool *handled) const; Options::MouseCommand getWheelCommand(Qt::Orientation orientation, bool *handled) const; // decoration related KDecoration2::Decoration *decoration() { return m_decoration.decoration; } const KDecoration2::Decoration *decoration() const { return m_decoration.decoration; } bool isDecorated() const { return m_decoration.decoration != nullptr; } QPointer decoratedClient() const; void setDecoratedClient(QPointer client); bool decorationHasAlpha() const; void triggerDecorationRepaint(); virtual void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom) const; void processDecorationMove(const QPoint &localPos, const QPoint &globalPos); bool processDecorationButtonPress(QMouseEvent *event, bool ignoreMenu = false); void processDecorationButtonRelease(QMouseEvent *event); /** * TODO: fix boolean traps **/ virtual void updateDecoration(bool check_workspace_pos, bool force = false) = 0; /** * Returns whether the window provides context help or not. If it does, * you should show a help menu item or a help button like '?' and call * contextHelp() if this is invoked. * * Default implementation returns @c false. * @see showContextHelp; **/ virtual bool providesContextHelp() const; /** * Invokes context help on the window. Only works if the window * actually provides context help. * * Default implementation does nothing. * * @see providesContextHelp() **/ virtual void showContextHelp(); QRect inputGeometry() const override; /** * @returns the geometry of the virtual keyboard * This geometry is in global coordinates */ QRect virtualKeyboardGeometry() const; /** * Sets the geometry of the virtual keyboard, The window may resize itself in order to make space for the keybaord * This geometry is in global coordinates */ void setVirtualKeyboardGeometry(const QRect &geo); /** * Restores the AbstractClient after it had been hidden due to show on screen edge functionality. * The AbstractClient also gets raised (e.g. Panel mode windows can cover) and the AbstractClient * gets informed in a window specific way that it is shown and raised again. **/ virtual void showOnScreenEdge() = 0; QByteArray desktopFileName() const { return m_desktopFileName; } /** * Tries to terminate the process of this AbstractClient. * * Implementing subclasses can perform a windowing system solution for terminating. **/ virtual void killWindow() = 0; enum class SameApplicationCheck { RelaxedForActive = 1 << 0, AllowCrossProcesses = 1 << 1 }; Q_DECLARE_FLAGS(SameApplicationChecks, SameApplicationCheck) static bool belongToSameApplication(const AbstractClient* c1, const AbstractClient* c2, SameApplicationChecks checks = SameApplicationChecks()); bool hasApplicationMenu() const; bool applicationMenuActive() const { return m_applicationMenuActive; } void setApplicationMenuActive(bool applicationMenuActive); QString applicationMenuServiceName() const { return m_applicationMenuServiceName; } QString applicationMenuObjectPath() const { return m_applicationMenuObjectPath; } QString colorScheme() const { return m_colorScheme; } /** * Request showing the application menu bar * @param actionId The DBus menu ID of the action that should be highlighted, 0 for the root menu **/ void showApplicationMenu(int actionId); bool unresponsive() const; virtual bool isInitialPositionSet() const { return false; } /** * Default implementation returns @c null. * Mostly intended for X11 clients, from EWMH: * @verbatim * If the WM_TRANSIENT_FOR property is set to None or Root window, the window should be * treated as a transient for all other windows in the same group. It has been noted that this * is a slight ICCCM violation, but as this behavior is pretty standard for many toolkits and * window managers, and is extremely unlikely to break anything, it seems reasonable to document * it as standard. * @endverbatim **/ virtual bool groupTransient() const; /** * Default implementation returns @c null. * * Mostly for X11 clients, holds the client group **/ virtual const Group *group() const; /** * Default implementation returns @c null. * * Mostly for X11 clients, holds the client group **/ virtual Group *group(); /** * Returns whether this is an internal client. * * Internal clients are created by KWin and used for special purpose windows, * like the task switcher, etc. * * Default implementation returns @c false. **/ virtual bool isInternal() const; /** * Returns whether window rules can be applied to this client. * * Default implementation returns @c true. **/ virtual bool supportsWindowRules() const; public Q_SLOTS: virtual void closeWindow() = 0; Q_SIGNALS: void fullScreenChanged(); void skipTaskbarChanged(); void skipPagerChanged(); void skipSwitcherChanged(); void iconChanged(); void activeChanged(); void keepAboveChanged(bool); void keepBelowChanged(bool); /** * Emitted whenever the demands attention state changes. **/ void demandsAttentionChanged(); void desktopPresenceChanged(KWin::AbstractClient*, int); // to be forwarded by Workspace void desktopChanged(); void x11DesktopIdsChanged(); void shadeChanged(); void minimizedChanged(); void clientMinimized(KWin::AbstractClient* client, bool animate); void clientUnminimized(KWin::AbstractClient* client, bool animate); void paletteChanged(const QPalette &p); void colorSchemeChanged(); void captionChanged(); void clientMaximizedStateChanged(KWin::AbstractClient*, MaximizeMode); void clientMaximizedStateChanged(KWin::AbstractClient* c, bool h, bool v); void transientChanged(); void modalChanged(); void quickTileModeChanged(); void moveResizedChanged(); void moveResizeCursorChanged(CursorShape); void clientStartUserMovedResized(KWin::AbstractClient*); void clientStepUserMovedResized(KWin::AbstractClient *, const QRect&); void clientFinishUserMovedResized(KWin::AbstractClient*); void closeableChanged(bool); void minimizeableChanged(bool); void shadeableChanged(bool); void maximizeableChanged(bool); void desktopFileNameChanged(); void hasApplicationMenuChanged(bool); void applicationMenuActiveChanged(bool); void unresponsiveChanged(bool); /** * Emitted whenever the Client's TabGroup changed. That is whenever the Client is moved to * another group, but not when a Client gets added or removed to the Client's ClientGroup. **/ void tabGroupChanged(); protected: AbstractClient(); void setFirstInTabBox(bool enable) { m_firstInTabBox = enable; } void setIcon(const QIcon &icon); void startAutoRaise(); void autoRaise(); /** * Whether the window accepts focus. * The difference to wantsInput is that the implementation should not check rules and return * what the window effectively supports. **/ virtual bool acceptsFocus() const = 0; /** * Called from setActive once the active value got updated, but before the changed signal * is emitted. * * Default implementation does nothing. **/ virtual void doSetActive(); /** * Called from setKeepAbove once the keepBelow value got updated, but before the changed signal * is emitted. * * Default implementation does nothing. **/ virtual void doSetKeepAbove(); /** * Called from setKeepBelow once the keepBelow value got updated, but before the changed signal * is emitted. * * Default implementation does nothing. **/ virtual void doSetKeepBelow(); /** * Called from setDeskop once the desktop value got updated, but before the changed signal * is emitted. * * Default implementation does nothing. * @param desktop The new desktop the Client is on * @param was_desk The desktop the Client was on before **/ virtual void doSetDesktop(int desktop, int was_desk); /** * Called from @ref minimize and @ref unminimize once the minimized value got updated, but before the * changed signal is emitted. * * Default implementation does nothig. **/ virtual void doMinimize(); virtual bool belongsToSameApplication(const AbstractClient *other, SameApplicationChecks checks) const = 0; virtual void doSetSkipTaskbar(); virtual void doSetSkipPager(); virtual void doSetSkipSwitcher(); void setupWindowManagementInterface(); void destroyWindowManagementInterface(); void updateColorScheme(QString path); virtual void updateColorScheme() = 0; void setTransientFor(AbstractClient *transientFor); virtual void addTransient(AbstractClient* cl); /** * Just removes the @p cl from the transients without any further checks. **/ void removeTransientFromList(AbstractClient* cl); Layer belongsToLayer() const; virtual bool belongsToDesktop() const; void invalidateLayer(); bool isActiveFullScreen() const; virtual Layer layerForDock() const; // electric border / quick tiling void setElectricBorderMode(QuickTileMode mode); QuickTileMode electricBorderMode() const { return m_electricMode; } void setElectricBorderMaximizing(bool maximizing); bool isElectricBorderMaximizing() const { return m_electricMaximizing; } QRect electricBorderMaximizeGeometry(QPoint pos, int desktop); void updateQuickTileMode(QuickTileMode newMode) { m_quickTileMode = newMode; } KWayland::Server::PlasmaWindowInterface *windowManagementInterface() const { return m_windowManagementInterface; } // geometry handling void checkOffscreenPosition(QRect *geom, const QRect &screenArea); int borderLeft() const; int borderRight() const; int borderTop() const; int borderBottom() const; virtual void changeMaximize(bool horizontal, bool vertical, bool adjust) = 0; virtual void setGeometryRestore(const QRect &geo) = 0; /** * Called from move after updating the geometry. Can be reimplemented to perform specific tasks. * The base implementation does nothing. **/ virtual void doMove(int x, int y); void blockGeometryUpdates(bool block); void blockGeometryUpdates(); void unblockGeometryUpdates(); bool areGeometryUpdatesBlocked() const; enum PendingGeometry_t { PendingGeometryNone, PendingGeometryNormal, PendingGeometryForced }; PendingGeometry_t pendingGeometryUpdate() const; void setPendingGeometryUpdate(PendingGeometry_t update); QRect geometryBeforeUpdateBlocking() const { return m_geometryBeforeUpdateBlocking; } void updateGeometryBeforeUpdateBlocking(); /** * Schedules a repaint for the visibleRect before and after a * geometry update. The current visibleRect is stored for the * next time this method is called as the before geometry. **/ void addRepaintDuringGeometryUpdates(); /** * Convenient method to update the TabGroup states if there is one present. * Marked as virtual as TabGroup does not yet handle AbstractClient, but only * subclasses of AbstractClient. Given that the default implementation does nothing. **/ virtual void updateTabGroupStates(TabGroup::States states); /** * @returns whether the Client is currently in move resize mode **/ bool isMoveResize() const { return m_moveResize.enabled; } /** * Sets whether the Client is in move resize mode to @p enabled. **/ void setMoveResize(bool enabled) { m_moveResize.enabled = enabled; } /** * @returns whether the move resize mode is unrestricted. **/ bool isUnrestrictedMoveResize() const { return m_moveResize.unrestricted; } /** * Sets whether move resize mode is unrestricted to @p set. **/ void setUnrestrictedMoveResize(bool set) { m_moveResize.unrestricted = set; } QPoint moveOffset() const { return m_moveResize.offset; } void setMoveOffset(const QPoint &offset) { m_moveResize.offset = offset; } QPoint invertedMoveOffset() const { return m_moveResize.invertedOffset; } void setInvertedMoveOffset(const QPoint &offset) { m_moveResize.invertedOffset = offset; } QRect initialMoveResizeGeometry() const { return m_moveResize.initialGeometry; } /** * Sets the initial move resize geometry to the current geometry. **/ void updateInitialMoveResizeGeometry(); QRect moveResizeGeometry() const { return m_moveResize.geometry; } void setMoveResizeGeometry(const QRect &geo) { m_moveResize.geometry = geo; } Position moveResizePointerMode() const { return m_moveResize.pointer; } void setMoveResizePointerMode(Position mode) { m_moveResize.pointer = mode; } bool isMoveResizePointerButtonDown() const { return m_moveResize.buttonDown; } void setMoveResizePointerButtonDown(bool down) { m_moveResize.buttonDown = down; } int moveResizeStartScreen() const { return m_moveResize.startScreen; } void checkUnrestrictedMoveResize(); /** * Sets an appropriate cursor shape for the logical mouse position. **/ void updateCursor(); void startDelayedMoveResize(); void stopDelayedMoveResize(); bool startMoveResize(); /** * Called from startMoveResize. * * Implementing classes should return @c false if starting move resize should * get aborted. In that case startMoveResize will also return @c false. * * Base implementation returns @c true. **/ virtual bool doStartMoveResize(); void finishMoveResize(bool cancel); /** * Leaves the move resize mode. * * Inheriting classes must invoke the base implementation which * ensures that the internal mode is properly ended. **/ virtual void leaveMoveResize(); virtual void positionGeometryTip(); void performMoveResize(); /** * Called from performMoveResize() after actually performing the change of geometry. * Implementing subclasses can perform windowing system specific handling here. * * Default implementation does nothing. **/ virtual void doPerformMoveResize(); /* * Checks if the mouse cursor is near the edge of the screen and if so * activates quick tiling or maximization **/ void checkQuickTilingMaximizationZones(int xroot, int yroot); /** * Whether a sync request is still pending. * Default implementation returns @c false. **/ virtual bool isWaitingForMoveResizeSync() const; /** * Called during handling a resize. Implementing subclasses can use this * method to perform windowing system specific syncing. * * Default implementation does nothing. **/ virtual void doResizeSync(); void handleMoveResize(int x, int y, int x_root, int y_root); void handleMoveResize(const QPoint &local, const QPoint &global); void dontMoveResize(); virtual QSize resizeIncrements() const; /** * Returns the position depending on the Decoration's section under mouse. * If no decoration it returns PositionCenter. **/ Position mousePosition() const; static bool haveResizeEffect() { return s_haveResizeEffect; } static void updateHaveResizeEffect(); static void resetHaveResizeEffect() { s_haveResizeEffect = false; } void setDecoration(KDecoration2::Decoration *decoration) { m_decoration.decoration = decoration; } virtual void destroyDecoration(); void startDecorationDoubleClickTimer(); void invalidateDecorationDoubleClickTimer(); void setDesktopFileName(QByteArray name); QString iconFromDesktopFile() const; void updateApplicationMenuServiceName(const QString &serviceName); void updateApplicationMenuObjectPath(const QString &objectPath); void setUnresponsive(bool unresponsive); virtual void setShortcutInternal(); QString shortcutCaptionSuffix() const; virtual void updateCaption() = 0; /** * Looks for another AbstractClient with same captionNormal and captionSuffix. * If no such AbstractClient exists @c nullptr is returned. **/ AbstractClient *findClientWithSameCaption() const; void finishWindowRules(); void discardTemporaryRules(); bool tabTo(AbstractClient *other, bool behind, bool activate); private: void handlePaletteChange(); QSharedPointer m_tabBoxClient; bool m_firstInTabBox = false; bool m_skipTaskbar = false; /** * Unaffected by KWin **/ bool m_originalSkipTaskbar = false; bool m_skipPager = false; bool m_skipSwitcher = false; QIcon m_icon; bool m_active = false; bool m_keepAbove = false; bool m_keepBelow = false; bool m_demandsAttention = false; bool m_minimized = false; QTimer *m_autoRaiseTimer = nullptr; QVector m_desktops; QString m_colorScheme; std::shared_ptr m_palette; static QHash> s_palettes; static std::shared_ptr s_defaultPalette; KWayland::Server::PlasmaWindowInterface *m_windowManagementInterface = nullptr; AbstractClient *m_transientFor = nullptr; QList m_transients; bool m_modal = false; Layer m_layer = UnknownLayer; // electric border/quick tiling QuickTileMode m_electricMode = QuickTileFlag::None; bool m_electricMaximizing = false; // The quick tile mode of this window. int m_quickTileMode = int(QuickTileFlag::None); QTimer *m_electricMaximizingDelay = nullptr; // geometry int m_blockGeometryUpdates = 0; // > 0 = New geometry is remembered, but not actually set PendingGeometry_t m_pendingGeometryUpdate = PendingGeometryNone; friend class GeometryUpdatesBlocker; QRect m_visibleRectBeforeGeometryUpdate; QRect m_geometryBeforeUpdateBlocking; QRect m_virtualKeyboardGeometry; QRect m_keyboardGeometryRestore; struct { bool enabled = false; bool unrestricted = false; QPoint offset; QPoint invertedOffset; QRect initialGeometry; QRect geometry; Position pointer = PositionCenter; bool buttonDown = false; CursorShape cursor = Qt::ArrowCursor; int startScreen = 0; QTimer *delayedTimer = nullptr; } m_moveResize; struct { KDecoration2::Decoration *decoration = nullptr; QPointer client; QElapsedTimer doubleClickTimer; } m_decoration; QByteArray m_desktopFileName; bool m_applicationMenuActive = false; QString m_applicationMenuServiceName; QString m_applicationMenuObjectPath; bool m_unresponsive = false; QKeySequence _shortcut; WindowRules m_rules; TabGroup* tab_group = nullptr; static bool s_haveResizeEffect; }; /** * Helper for AbstractClient::blockGeometryUpdates() being called in pairs (true/false) **/ class GeometryUpdatesBlocker { public: explicit GeometryUpdatesBlocker(AbstractClient* c) : cl(c) { cl->blockGeometryUpdates(true); } ~GeometryUpdatesBlocker() { cl->blockGeometryUpdates(false); } private: AbstractClient* cl; }; inline void AbstractClient::move(const QPoint& p, ForceGeometry_t force) { move(p.x(), p.y(), force); } inline void AbstractClient::resizeWithChecks(const QSize& s, AbstractClient::ForceGeometry_t force) { resizeWithChecks(s.width(), s.height(), force); } inline void AbstractClient::setGeometry(const QRect& r, ForceGeometry_t force) { setGeometry(r.x(), r.y(), r.width(), r.height(), force); } inline const QList& AbstractClient::transients() const { return m_transients; } inline bool AbstractClient::areGeometryUpdatesBlocked() const { return m_blockGeometryUpdates != 0; } inline void AbstractClient::blockGeometryUpdates() { m_blockGeometryUpdates++; } inline void AbstractClient::unblockGeometryUpdates() { m_blockGeometryUpdates--; } inline AbstractClient::PendingGeometry_t AbstractClient::pendingGeometryUpdate() const { return m_pendingGeometryUpdate; } inline void AbstractClient::setPendingGeometryUpdate(PendingGeometry_t update) { m_pendingGeometryUpdate = update; } inline TabGroup* AbstractClient::tabGroup() const { return tab_group; } } Q_DECLARE_METATYPE(KWin::AbstractClient*) Q_DECLARE_METATYPE(QList) Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::AbstractClient::SameApplicationChecks) #endif diff --git a/abstract_wayland_output.h b/abstract_wayland_output.h index c11c3e7dc..50fd9a5ab 100644 --- a/abstract_wayland_output.h +++ b/abstract_wayland_output.h @@ -1,182 +1,182 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright 2019 Roman Gilg 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_ABSTRACT_WAYLAND_OUTPUT_H #define KWIN_ABSTRACT_WAYLAND_OUTPUT_H #include "abstract_output.h" #include #include #include #include #include #include #include #include #include #include namespace KWayland { namespace Server { class OutputInterface; class OutputDeviceInterface; class OutputChangeSet; class OutputManagementInterface; class XdgOutputInterface; } } namespace KWin { /** * Generic output representation in a Wayland session **/ class KWIN_EXPORT AbstractWaylandOutput : public AbstractOutput { Q_OBJECT public: explicit AbstractWaylandOutput(QObject *parent = nullptr); - virtual ~AbstractWaylandOutput(); + ~AbstractWaylandOutput() override; QString name() const override; bool isEnabled() const { return !m_waylandOutput.isNull(); } virtual QSize pixelSize() const = 0; qreal scale() const override { return m_scale; } /** * The geometry of this output in global compositor co-ordinates (i.e scaled) **/ QRect geometry() const override; QSize physicalSize() const override; Qt::ScreenOrientation orientation() const override { return m_orientation; } /** * Current refresh rate in 1/ms. **/ int refreshRate() const override; bool isInternal() const override { return m_internal; } void setGlobalPos(const QPoint &pos); void setScale(qreal scale); /** * This sets the changes and tests them against the specific output. **/ void setChanges(KWayland::Server::OutputChangeSet *changeset); QPointer waylandOutput() const { return m_waylandOutput; } /** * Enable or disable the output. * * This differs from updateDpms as it also removes the wl_output. * The default is on. **/ void setEnabled(bool enable); Q_SIGNALS: void modeChanged(); protected: void initWaylandOutput(); void initWaylandOutputDevice(const QString &model, const QString &manufacturer, const QByteArray &uuid, const QVector &modes); QPointer xdgOutput() const { return m_xdgOutput; } void createXdgOutput(); QPointer waylandOutputDevice() const { return m_waylandOutputDevice; } QPoint globalPos() const { return m_globalPos; } QSize rawPhysicalSize() const { return m_physicalSize; } void setRawPhysicalSize(const QSize &set) { m_physicalSize = set; } void setOrientation(Qt::ScreenOrientation set) { m_orientation = set; } bool internal() const { return m_internal; } void setInternal(bool set) { m_internal = set; } void setDpmsSupported(bool set) { m_supportsDpms = set; } virtual void updateDpms(KWayland::Server::OutputInterface::DpmsMode mode) { Q_UNUSED(mode); } virtual void updateMode(int modeIndex) { Q_UNUSED(modeIndex); } virtual void transform(KWayland::Server::OutputDeviceInterface::Transform transform) { Q_UNUSED(transform); } void setWaylandMode(const QSize &size, int refreshRate); QSize orientateSize(const QSize &size) const; private: QPointer m_waylandOutput; QPointer m_xdgOutput; QPointer m_waylandOutputDevice; KWayland::Server::OutputInterface::DpmsMode m_dpms = KWayland::Server::OutputInterface::DpmsMode::On; QPoint m_globalPos; qreal m_scale = 1; QSize m_physicalSize; Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation; bool m_internal = false; bool m_supportsDpms = false; }; } #endif // KWIN_OUTPUT_H diff --git a/activities.h b/activities.h index 9db83d8f9..5be842c28 100644 --- a/activities.h +++ b/activities.h @@ -1,129 +1,129 @@ /******************************************************************** 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_ACTIVITIES_H #define KWIN_ACTIVITIES_H #include #include #include #include namespace KActivities { class Controller; } namespace KWin { class Client; class KWIN_EXPORT Activities : public QObject { Q_OBJECT public: - ~Activities(); + ~Activities() override; bool stop(const QString &id); bool start(const QString &id); void setCurrent(const QString &activity); /** * Adds/removes client \a c to/from \a activity. * * Takes care of transients as well. **/ void toggleClientOnActivity(Client* c, const QString &activity, bool dont_activate); QStringList running() const; QStringList all() const; const QString ¤t() const; const QString &previous() const; static QString nullUuid(); KActivities::Controller::ServiceStatus serviceStatus() const; Q_SIGNALS: /** * This signal is emitted when the global * activity is changed * @param id id of the new current activity **/ void currentChanged(const QString &id); /** * This signal is emitted when a new activity is added * @param id id of the new activity **/ void added(const QString &id); /** * This signal is emitted when the activity * is removed * @param id id of the removed activity **/ void removed(const QString &id); private Q_SLOTS: void slotRemoved(const QString &activity); void slotCurrentChanged(const QString &newActivity); void reallyStop(const QString &id); //dbus deadlocks suck private: QString m_previous; QString m_current; KActivities::Controller *m_controller; KWIN_SINGLETON(Activities) }; inline QStringList Activities::all() const { return m_controller->activities(); } inline const QString &Activities::current() const { return m_current; } inline const QString &Activities::previous() const { return m_previous; } inline QStringList Activities::running() const { return m_controller->activities(KActivities::Info::Running); } inline QString Activities::nullUuid() { // cloned from kactivities/src/lib/core/consumer.cpp return QStringLiteral("00000000-0000-0000-0000-000000000000"); } } #endif // KWIN_ACTIVITIES_H diff --git a/autotests/fakeeffectplugin.cpp b/autotests/fakeeffectplugin.cpp index 73cc7e4bc..ddb5d41dd 100644 --- a/autotests/fakeeffectplugin.cpp +++ b/autotests/fakeeffectplugin.cpp @@ -1,49 +1,49 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 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 namespace KWin { class FakeEffect : public Effect { Q_OBJECT public: FakeEffect() {} - virtual ~FakeEffect() {} + ~FakeEffect() override {} static bool supported() { return effects->isOpenGLCompositing(); } static bool enabledByDefault() { return effects->property("testEnabledByDefault").toBool(); } }; } // namespace KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED( FakeEffectPluginFactory, KWin::FakeEffect, "fakeeffectplugin.json", return KWin::FakeEffect::supported();, return KWin::FakeEffect::enabledByDefault();) #include "fakeeffectplugin.moc" diff --git a/autotests/fakeeffectplugin_version.cpp b/autotests/fakeeffectplugin_version.cpp index 07066d0d0..e897ac067 100644 --- a/autotests/fakeeffectplugin_version.cpp +++ b/autotests/fakeeffectplugin_version.cpp @@ -1,50 +1,50 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 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 namespace KWin { class FakeVersionEffect : public Effect { Q_OBJECT public: FakeVersionEffect() {} - virtual ~FakeVersionEffect() {} + ~FakeVersionEffect() override {} }; } // namespace class FakeEffectPluginFactory : public KWin::EffectPluginFactory { Q_OBJECT Q_PLUGIN_METADATA(IID KPluginFactory_iid FILE "fakeeffectplugin_version.json") Q_INTERFACES(KPluginFactory) public: FakeEffectPluginFactory() {} - ~FakeEffectPluginFactory() {} + ~FakeEffectPluginFactory() override {} KWin::Effect *createEffect() const override { return new KWin::FakeVersionEffect(); } }; K_EXPORT_PLUGIN_VERSION(quint32(KWIN_EFFECT_API_VERSION) - 1) #include "fakeeffectplugin_version.moc" diff --git a/autotests/integration/debug_console_test.cpp b/autotests/integration/debug_console_test.cpp index 6dedca697..800433b63 100644 --- a/autotests/integration/debug_console_test.cpp +++ b/autotests/integration/debug_console_test.cpp @@ -1,531 +1,531 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2016 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 "kwin_wayland_test.h" #include "platform.h" #include "debug_console.h" #include "screens.h" #include "shell_client.h" #include "wayland_server.h" #include "xcbutils.h" #include #include #include #include #include #include #include namespace KWin { static const QString s_socketName = QStringLiteral("wayland_test_kwin_debug_console-0"); class DebugConsoleTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase(); void cleanup(); void topLevelTest_data(); void topLevelTest(); void testX11Client(); void testX11Unmanaged(); void testWaylandClient_data(); void testWaylandClient(); void testInternalWindow(); void testClosingDebugConsole(); }; void DebugConsoleTest::initTestCase() { qRegisterMetaType(); qRegisterMetaType(); QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); QVERIFY(workspaceCreatedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); kwinApp()->start(); QVERIFY(workspaceCreatedSpy.wait()); QCOMPARE(screens()->count(), 2); QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); setenv("QT_QPA_PLATFORM", "wayland", true); waylandServer()->initWorkspace(); } void DebugConsoleTest::cleanup() { Test::destroyWaylandConnection(); } void DebugConsoleTest::topLevelTest_data() { QTest::addColumn("row"); QTest::addColumn("column"); QTest::addColumn("expectedValid"); // this tests various combinations of row/column on the top level whether they are valid // valid are rows 0-4 with column 0, everything else is invalid QTest::newRow("0/0") << 0 << 0 << true; QTest::newRow("0/1") << 0 << 1 << false; QTest::newRow("0/3") << 0 << 3 << false; QTest::newRow("1/0") << 1 << 0 << true; QTest::newRow("1/1") << 1 << 1 << false; QTest::newRow("1/3") << 1 << 3 << false; QTest::newRow("2/0") << 2 << 0 << true; QTest::newRow("3/0") << 3 << 0 << true; QTest::newRow("4/0") << 4 << 0 << false; QTest::newRow("100/0") << 4 << 0 << false; } void DebugConsoleTest::topLevelTest() { DebugConsoleModel model; QCOMPARE(model.rowCount(QModelIndex()), 4); QCOMPARE(model.columnCount(QModelIndex()), 2); QFETCH(int, row); QFETCH(int, column); const QModelIndex index = model.index(row, column, QModelIndex()); QTEST(index.isValid(), "expectedValid"); if (index.isValid()) { QVERIFY(!model.parent(index).isValid()); QVERIFY(model.data(index, Qt::DisplayRole).isValid()); QCOMPARE(model.data(index, Qt::DisplayRole).userType(), int(QMetaType::QString)); for (int i = Qt::DecorationRole; i <= Qt::UserRole; i++) { QVERIFY(!model.data(index, i).isValid()); } } } void DebugConsoleTest::testX11Client() { DebugConsoleModel model; QModelIndex x11TopLevelIndex = model.index(0, 0, QModelIndex()); QVERIFY(x11TopLevelIndex.isValid()); // we don't have any windows yet QCOMPARE(model.rowCount(x11TopLevelIndex), 0); QVERIFY(!model.hasChildren(x11TopLevelIndex)); // child index must be invalid QVERIFY(!model.index(0, 0, x11TopLevelIndex).isValid()); QVERIFY(!model.index(0, 1, x11TopLevelIndex).isValid()); QVERIFY(!model.index(0, 2, x11TopLevelIndex).isValid()); QVERIFY(!model.index(1, 0, x11TopLevelIndex).isValid()); // start glxgears, to get a window, which should be added to the model QSignalSpy rowsInsertedSpy(&model, &QAbstractItemModel::rowsInserted); QVERIFY(rowsInsertedSpy.isValid()); QProcess glxgears; glxgears.start(QStringLiteral("glxgears")); QVERIFY(glxgears.waitForStarted()); QVERIFY(rowsInsertedSpy.wait()); QCOMPARE(rowsInsertedSpy.count(), 1); QVERIFY(model.hasChildren(x11TopLevelIndex)); QCOMPARE(model.rowCount(x11TopLevelIndex), 1); QCOMPARE(rowsInsertedSpy.first().at(0).value(), x11TopLevelIndex); QCOMPARE(rowsInsertedSpy.first().at(1).value(), 0); QCOMPARE(rowsInsertedSpy.first().at(2).value(), 0); QModelIndex clientIndex = model.index(0, 0, x11TopLevelIndex); QVERIFY(clientIndex.isValid()); QCOMPARE(model.parent(clientIndex), x11TopLevelIndex); QVERIFY(model.hasChildren(clientIndex)); QVERIFY(model.rowCount(clientIndex) != 0); QCOMPARE(model.columnCount(clientIndex), 2); // other indexes are still invalid QVERIFY(!model.index(0, 1, x11TopLevelIndex).isValid()); QVERIFY(!model.index(0, 2, x11TopLevelIndex).isValid()); QVERIFY(!model.index(1, 0, x11TopLevelIndex).isValid()); // the clientIndex has children and those are properties for (int i = 0; i < model.rowCount(clientIndex); i++) { const QModelIndex propNameIndex = model.index(i, 0, clientIndex); QVERIFY(propNameIndex.isValid()); QCOMPARE(model.parent(propNameIndex), clientIndex); QVERIFY(!model.hasChildren(propNameIndex)); QVERIFY(!model.index(0, 0, propNameIndex).isValid()); QVERIFY(model.data(propNameIndex, Qt::DisplayRole).isValid()); QCOMPARE(model.data(propNameIndex, Qt::DisplayRole).userType(), int(QMetaType::QString)); // and the value const QModelIndex propValueIndex = model.index(i, 1, clientIndex); QVERIFY(propValueIndex.isValid()); QCOMPARE(model.parent(propValueIndex), clientIndex); QVERIFY(!model.index(0, 0, propValueIndex).isValid()); QVERIFY(!model.hasChildren(propValueIndex)); // TODO: how to test whether the values actually work? // and on third column we should not get an index any more QVERIFY(!model.index(i, 2, clientIndex).isValid()); } // row after count should be invalid QVERIFY(!model.index(model.rowCount(clientIndex), 0, clientIndex).isValid()); // creating a second model should be initialized directly with the X11 child DebugConsoleModel model2; QVERIFY(model2.hasChildren(model2.index(0, 0, QModelIndex()))); // now close the window again, it should be removed from the model QSignalSpy rowsRemovedSpy(&model, &QAbstractItemModel::rowsRemoved); QVERIFY(rowsRemovedSpy.isValid()); glxgears.terminate(); QVERIFY(glxgears.waitForFinished()); QVERIFY(rowsRemovedSpy.wait()); QCOMPARE(rowsRemovedSpy.count(), 1); QCOMPARE(rowsRemovedSpy.first().first().value(), x11TopLevelIndex); QCOMPARE(rowsRemovedSpy.first().at(1).value(), 0); QCOMPARE(rowsRemovedSpy.first().at(2).value(), 0); // the child should be gone again QVERIFY(!model.hasChildren(x11TopLevelIndex)); QVERIFY(!model2.hasChildren(model2.index(0, 0, QModelIndex()))); } void DebugConsoleTest::testX11Unmanaged() { DebugConsoleModel model; QModelIndex unmanagedTopLevelIndex = model.index(1, 0, QModelIndex()); QVERIFY(unmanagedTopLevelIndex.isValid()); // we don't have any windows yet QCOMPARE(model.rowCount(unmanagedTopLevelIndex), 0); QVERIFY(!model.hasChildren(unmanagedTopLevelIndex)); // child index must be invalid QVERIFY(!model.index(0, 0, unmanagedTopLevelIndex).isValid()); QVERIFY(!model.index(0, 1, unmanagedTopLevelIndex).isValid()); QVERIFY(!model.index(0, 2, unmanagedTopLevelIndex).isValid()); QVERIFY(!model.index(1, 0, unmanagedTopLevelIndex).isValid()); // we need to create an unmanaged window QSignalSpy rowsInsertedSpy(&model, &QAbstractItemModel::rowsInserted); QVERIFY(rowsInsertedSpy.isValid()); // let's create an override redirect window const uint32_t values[] = {true}; Xcb::Window window(QRect(0, 0, 10, 10), XCB_CW_OVERRIDE_REDIRECT, values); window.map(); QVERIFY(rowsInsertedSpy.wait()); QCOMPARE(rowsInsertedSpy.count(), 1); QVERIFY(model.hasChildren(unmanagedTopLevelIndex)); QCOMPARE(model.rowCount(unmanagedTopLevelIndex), 1); QCOMPARE(rowsInsertedSpy.first().at(0).value(), unmanagedTopLevelIndex); QCOMPARE(rowsInsertedSpy.first().at(1).value(), 0); QCOMPARE(rowsInsertedSpy.first().at(2).value(), 0); QModelIndex clientIndex = model.index(0, 0, unmanagedTopLevelIndex); QVERIFY(clientIndex.isValid()); QCOMPARE(model.parent(clientIndex), unmanagedTopLevelIndex); QVERIFY(model.hasChildren(clientIndex)); QVERIFY(model.rowCount(clientIndex) != 0); QCOMPARE(model.columnCount(clientIndex), 2); // other indexes are still invalid QVERIFY(!model.index(0, 1, unmanagedTopLevelIndex).isValid()); QVERIFY(!model.index(0, 2, unmanagedTopLevelIndex).isValid()); QVERIFY(!model.index(1, 0, unmanagedTopLevelIndex).isValid()); QCOMPARE(model.data(clientIndex, Qt::DisplayRole).toString(), QString::number(window)); // the clientIndex has children and those are properties for (int i = 0; i < model.rowCount(clientIndex); i++) { const QModelIndex propNameIndex = model.index(i, 0, clientIndex); QVERIFY(propNameIndex.isValid()); QCOMPARE(model.parent(propNameIndex), clientIndex); QVERIFY(!model.hasChildren(propNameIndex)); QVERIFY(!model.index(0, 0, propNameIndex).isValid()); QVERIFY(model.data(propNameIndex, Qt::DisplayRole).isValid()); QCOMPARE(model.data(propNameIndex, Qt::DisplayRole).userType(), int(QMetaType::QString)); // and the value const QModelIndex propValueIndex = model.index(i, 1, clientIndex); QVERIFY(propValueIndex.isValid()); QCOMPARE(model.parent(propValueIndex), clientIndex); QVERIFY(!model.index(0, 0, propValueIndex).isValid()); QVERIFY(!model.hasChildren(propValueIndex)); // TODO: how to test whether the values actually work? // and on third column we should not get an index any more QVERIFY(!model.index(i, 2, clientIndex).isValid()); } // row after count should be invalid QVERIFY(!model.index(model.rowCount(clientIndex), 0, clientIndex).isValid()); // creating a second model should be initialized directly with the X11 child DebugConsoleModel model2; QVERIFY(model2.hasChildren(model2.index(1, 0, QModelIndex()))); // now close the window again, it should be removed from the model QSignalSpy rowsRemovedSpy(&model, &QAbstractItemModel::rowsRemoved); QVERIFY(rowsRemovedSpy.isValid()); window.unmap(); QVERIFY(rowsRemovedSpy.wait()); QCOMPARE(rowsRemovedSpy.count(), 1); QCOMPARE(rowsRemovedSpy.first().first().value(), unmanagedTopLevelIndex); QCOMPARE(rowsRemovedSpy.first().at(1).value(), 0); QCOMPARE(rowsRemovedSpy.first().at(2).value(), 0); // the child should be gone again QVERIFY(!model.hasChildren(unmanagedTopLevelIndex)); QVERIFY(!model2.hasChildren(model2.index(1, 0, QModelIndex()))); } void DebugConsoleTest::testWaylandClient_data() { QTest::addColumn("type"); QTest::newRow("wlShell") << Test::ShellSurfaceType::WlShell; QTest::newRow("xdgShellV5") << Test::ShellSurfaceType::XdgShellV5; } void DebugConsoleTest::testWaylandClient() { DebugConsoleModel model; QModelIndex waylandTopLevelIndex = model.index(2, 0, QModelIndex()); QVERIFY(waylandTopLevelIndex.isValid()); // we don't have any windows yet QCOMPARE(model.rowCount(waylandTopLevelIndex), 0); QVERIFY(!model.hasChildren(waylandTopLevelIndex)); // child index must be invalid QVERIFY(!model.index(0, 0, waylandTopLevelIndex).isValid()); QVERIFY(!model.index(0, 1, waylandTopLevelIndex).isValid()); QVERIFY(!model.index(0, 2, waylandTopLevelIndex).isValid()); QVERIFY(!model.index(1, 0, waylandTopLevelIndex).isValid()); // we need to create a wayland window QSignalSpy rowsInsertedSpy(&model, &QAbstractItemModel::rowsInserted); QVERIFY(rowsInsertedSpy.isValid()); // create our connection QVERIFY(Test::setupWaylandConnection()); // create the Surface and ShellSurface using namespace KWayland::Client; QScopedPointer surface(Test::createSurface()); QVERIFY(surface->isValid()); QFETCH(Test::ShellSurfaceType, type); QScopedPointer shellSurface(Test::createShellSurface(type, surface.data())); QVERIFY(!shellSurface.isNull()); Test::render(surface.data(), QSize(10, 10), Qt::red); // now we have the window, it should be added to our model QVERIFY(rowsInsertedSpy.wait()); QCOMPARE(rowsInsertedSpy.count(), 1); QVERIFY(model.hasChildren(waylandTopLevelIndex)); QCOMPARE(model.rowCount(waylandTopLevelIndex), 1); QCOMPARE(rowsInsertedSpy.first().at(0).value(), waylandTopLevelIndex); QCOMPARE(rowsInsertedSpy.first().at(1).value(), 0); QCOMPARE(rowsInsertedSpy.first().at(2).value(), 0); QModelIndex clientIndex = model.index(0, 0, waylandTopLevelIndex); QVERIFY(clientIndex.isValid()); QCOMPARE(model.parent(clientIndex), waylandTopLevelIndex); QVERIFY(model.hasChildren(clientIndex)); QVERIFY(model.rowCount(clientIndex) != 0); QCOMPARE(model.columnCount(clientIndex), 2); // other indexes are still invalid QVERIFY(!model.index(0, 1, waylandTopLevelIndex).isValid()); QVERIFY(!model.index(0, 2, waylandTopLevelIndex).isValid()); QVERIFY(!model.index(1, 0, waylandTopLevelIndex).isValid()); // the clientIndex has children and those are properties for (int i = 0; i < model.rowCount(clientIndex); i++) { const QModelIndex propNameIndex = model.index(i, 0, clientIndex); QVERIFY(propNameIndex.isValid()); QCOMPARE(model.parent(propNameIndex), clientIndex); QVERIFY(!model.hasChildren(propNameIndex)); QVERIFY(!model.index(0, 0, propNameIndex).isValid()); QVERIFY(model.data(propNameIndex, Qt::DisplayRole).isValid()); QCOMPARE(model.data(propNameIndex, Qt::DisplayRole).userType(), int(QMetaType::QString)); // and the value const QModelIndex propValueIndex = model.index(i, 1, clientIndex); QVERIFY(propValueIndex.isValid()); QCOMPARE(model.parent(propValueIndex), clientIndex); QVERIFY(!model.index(0, 0, propValueIndex).isValid()); QVERIFY(!model.hasChildren(propValueIndex)); // TODO: how to test whether the values actually work? // and on third column we should not get an index any more QVERIFY(!model.index(i, 2, clientIndex).isValid()); } // row after count should be invalid QVERIFY(!model.index(model.rowCount(clientIndex), 0, clientIndex).isValid()); // creating a second model should be initialized directly with the X11 child DebugConsoleModel model2; QVERIFY(model2.hasChildren(model2.index(2, 0, QModelIndex()))); // now close the window again, it should be removed from the model QSignalSpy rowsRemovedSpy(&model, &QAbstractItemModel::rowsRemoved); QVERIFY(rowsRemovedSpy.isValid()); surface->attachBuffer(Buffer::Ptr()); surface->commit(Surface::CommitFlag::None); shellSurface.reset(); Test::flushWaylandConnection(); qDebug() << rowsRemovedSpy.count(); QEXPECT_FAIL("wlShell", "Deleting a ShellSurface does not result in the server removing the ShellClient", Continue); QVERIFY(rowsRemovedSpy.wait(500)); surface.reset(); if (rowsRemovedSpy.isEmpty()) { QVERIFY(rowsRemovedSpy.wait()); } QCOMPARE(rowsRemovedSpy.count(), 1); QCOMPARE(rowsRemovedSpy.first().first().value(), waylandTopLevelIndex); QCOMPARE(rowsRemovedSpy.first().at(1).value(), 0); QCOMPARE(rowsRemovedSpy.first().at(2).value(), 0); // the child should be gone again QVERIFY(!model.hasChildren(waylandTopLevelIndex)); QVERIFY(!model2.hasChildren(model2.index(2, 0, QModelIndex()))); } class HelperWindow : public QRasterWindow { Q_OBJECT public: HelperWindow() : QRasterWindow(nullptr) {} - ~HelperWindow() = default; + ~HelperWindow() override = default; Q_SIGNALS: void entered(); void left(); void mouseMoved(const QPoint &global); void mousePressed(); void mouseReleased(); void wheel(); void keyPressed(); void keyReleased(); protected: void paintEvent(QPaintEvent *event) override { Q_UNUSED(event) QPainter p(this); p.fillRect(0, 0, width(), height(), Qt::red); } }; void DebugConsoleTest::testInternalWindow() { DebugConsoleModel model; QModelIndex internalTopLevelIndex = model.index(3, 0, QModelIndex()); QVERIFY(internalTopLevelIndex.isValid()); // there might already be some internal windows, so we cannot reliable test whether there are children // given that we just test whether adding a window works. QSignalSpy rowsInsertedSpy(&model, &QAbstractItemModel::rowsInserted); QVERIFY(rowsInsertedSpy.isValid()); QScopedPointer w(new HelperWindow); w->setGeometry(0, 0, 100, 100); w->show(); QTRY_COMPARE(rowsInsertedSpy.count(), 1); QCOMPARE(rowsInsertedSpy.first().first().value(), internalTopLevelIndex); QModelIndex clientIndex = model.index(rowsInsertedSpy.first().last().toInt(), 0, internalTopLevelIndex); QVERIFY(clientIndex.isValid()); QCOMPARE(model.parent(clientIndex), internalTopLevelIndex); QVERIFY(model.hasChildren(clientIndex)); QVERIFY(model.rowCount(clientIndex) != 0); QCOMPARE(model.columnCount(clientIndex), 2); // other indexes are still invalid QVERIFY(!model.index(rowsInsertedSpy.first().last().toInt(), 1, internalTopLevelIndex).isValid()); QVERIFY(!model.index(rowsInsertedSpy.first().last().toInt(), 2, internalTopLevelIndex).isValid()); QVERIFY(!model.index(rowsInsertedSpy.first().last().toInt() + 1, 0, internalTopLevelIndex).isValid()); // the wayland shell client top level should not have gained this window QVERIFY(!model.hasChildren(model.index(2, 0, QModelIndex()))); // the clientIndex has children and those are properties for (int i = 0; i < model.rowCount(clientIndex); i++) { const QModelIndex propNameIndex = model.index(i, 0, clientIndex); QVERIFY(propNameIndex.isValid()); QCOMPARE(model.parent(propNameIndex), clientIndex); QVERIFY(!model.hasChildren(propNameIndex)); QVERIFY(!model.index(0, 0, propNameIndex).isValid()); QVERIFY(model.data(propNameIndex, Qt::DisplayRole).isValid()); QCOMPARE(model.data(propNameIndex, Qt::DisplayRole).userType(), int(QMetaType::QString)); // and the value const QModelIndex propValueIndex = model.index(i, 1, clientIndex); QVERIFY(propValueIndex.isValid()); QCOMPARE(model.parent(propValueIndex), clientIndex); QVERIFY(!model.index(0, 0, propValueIndex).isValid()); QVERIFY(!model.hasChildren(propValueIndex)); // TODO: how to test whether the values actually work? // and on third column we should not get an index any more QVERIFY(!model.index(i, 2, clientIndex).isValid()); } // row after count should be invalid QVERIFY(!model.index(model.rowCount(clientIndex), 0, clientIndex).isValid()); // now close the window again, it should be removed from the model QSignalSpy rowsRemovedSpy(&model, &QAbstractItemModel::rowsRemoved); QVERIFY(rowsRemovedSpy.isValid()); w->hide(); w.reset(); QVERIFY(rowsRemovedSpy.wait()); QCOMPARE(rowsRemovedSpy.count(), 1); QCOMPARE(rowsRemovedSpy.first().first().value(), internalTopLevelIndex); } void DebugConsoleTest::testClosingDebugConsole() { // this test verifies that the DebugConsole gets destroyed when closing the window // BUG: 369858 DebugConsole *console = new DebugConsole; QSignalSpy destroyedSpy(console, &QObject::destroyed); QVERIFY(destroyedSpy.isValid()); QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); console->show(); QCOMPARE(console->windowHandle()->isVisible(), true); QTRY_COMPARE(clientAddedSpy.count(), 1); ShellClient *c = clientAddedSpy.first().first().value(); QVERIFY(c->isInternal()); QCOMPARE(c->internalWindow(), console->windowHandle()); QVERIFY(c->isDecorated()); QCOMPARE(c->isMinimizable(), false); c->closeWindow(); QVERIFY(destroyedSpy.wait()); } } WAYLANDTEST_MAIN(KWin::DebugConsoleTest) #include "debug_console_test.moc" diff --git a/autotests/integration/helper/copy.cpp b/autotests/integration/helper/copy.cpp index c27ec3c88..855a96338 100644 --- a/autotests/integration/helper/copy.cpp +++ b/autotests/integration/helper/copy.cpp @@ -1,71 +1,71 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2016 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 #include #include #include #include class Window : public QRasterWindow { Q_OBJECT public: explicit Window(); - virtual ~Window(); + ~Window() override; protected: void paintEvent(QPaintEvent *event) override; void focusInEvent(QFocusEvent *event) override; }; Window::Window() : QRasterWindow() { } Window::~Window() = default; void Window::paintEvent(QPaintEvent *event) { Q_UNUSED(event) QPainter p(this); p.fillRect(0, 0, width(), height(), Qt::red); } void Window::focusInEvent(QFocusEvent *event) { QRasterWindow::focusInEvent(event); // TODO: make it work without singleshot QTimer::singleShot(100,[] { qApp->clipboard()->setText(QStringLiteral("test")); }); } int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QScopedPointer w(new Window); w->setGeometry(QRect(0, 0, 100, 200)); w->show(); return app.exec(); } #include "copy.moc" diff --git a/autotests/integration/helper/paste.cpp b/autotests/integration/helper/paste.cpp index 0f1428c1a..8eea910df 100644 --- a/autotests/integration/helper/paste.cpp +++ b/autotests/integration/helper/paste.cpp @@ -1,68 +1,68 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2016 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 #include #include #include #include class Window : public QRasterWindow { Q_OBJECT public: explicit Window(); - virtual ~Window(); + ~Window() override; protected: void paintEvent(QPaintEvent *event) override; }; Window::Window() : QRasterWindow() { } Window::~Window() = default; void Window::paintEvent(QPaintEvent *event) { Q_UNUSED(event) QPainter p(this); p.fillRect(0, 0, width(), height(), Qt::blue); } int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QObject::connect(app.clipboard(), &QClipboard::changed, &app, [] { if (qApp->clipboard()->text() == QLatin1String("test")) { QTimer::singleShot(100, qApp, &QCoreApplication::quit); } } ); QScopedPointer w(new Window); w->setGeometry(QRect(0, 0, 100, 200)); w->show(); return app.exec(); } #include "paste.moc" diff --git a/autotests/integration/internal_window.cpp b/autotests/integration/internal_window.cpp index 92ce883a5..8d8719454 100644 --- a/autotests/integration/internal_window.cpp +++ b/autotests/integration/internal_window.cpp @@ -1,808 +1,808 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2016 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 "kwin_wayland_test.h" #include "platform.h" #include "cursor.h" #include "effects.h" #include "internal_client.h" #include "shell_client.h" #include "screens.h" #include "wayland_server.h" #include "workspace.h" #include #include #include #include #include #include #include #include #include using namespace KWayland::Client; Q_DECLARE_METATYPE(NET::WindowType); namespace KWin { static const QString s_socketName = QStringLiteral("wayland_test_kwin_internal_window-0"); class InternalWindowTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase(); void init(); void cleanup(); void testEnterLeave(); void testPointerPressRelease(); void testPointerAxis(); void testKeyboard_data(); void testKeyboard(); void testKeyboardShowWithoutActivating(); void testKeyboardTriggersLeave(); void testTouch(); void testOpacity(); void testMove(); void testSkipCloseAnimation_data(); void testSkipCloseAnimation(); void testModifierClickUnrestrictedMove(); void testModifierScroll(); void testPopup(); void testScale(); void testWindowType_data(); void testWindowType(); void testChangeWindowType_data(); void testChangeWindowType(); void testEffectWindow(); }; class HelperWindow : public QRasterWindow { Q_OBJECT public: HelperWindow(); - ~HelperWindow(); + ~HelperWindow() override; QPoint latestGlobalMousePos() const { return m_latestGlobalMousePos; } Qt::MouseButtons pressedButtons() const { return m_pressedButtons; } Q_SIGNALS: void entered(); void left(); void mouseMoved(const QPoint &global); void mousePressed(); void mouseReleased(); void wheel(); void keyPressed(); void keyReleased(); protected: void paintEvent(QPaintEvent *event) override; bool event(QEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; void wheelEvent(QWheelEvent *event) override; void keyPressEvent(QKeyEvent *event) override; void keyReleaseEvent(QKeyEvent *event) override; private: QPoint m_latestGlobalMousePos; Qt::MouseButtons m_pressedButtons = Qt::MouseButtons(); }; HelperWindow::HelperWindow() : QRasterWindow(nullptr) { setFlags(Qt::FramelessWindowHint); } HelperWindow::~HelperWindow() = default; void HelperWindow::paintEvent(QPaintEvent *event) { Q_UNUSED(event) QPainter p(this); p.fillRect(0, 0, width(), height(), Qt::red); } bool HelperWindow::event(QEvent *event) { if (event->type() == QEvent::Enter) { emit entered(); } if (event->type() == QEvent::Leave) { emit left(); } return QRasterWindow::event(event); } void HelperWindow::mouseMoveEvent(QMouseEvent *event) { m_latestGlobalMousePos = event->globalPos(); emit mouseMoved(event->globalPos()); } void HelperWindow::mousePressEvent(QMouseEvent *event) { m_latestGlobalMousePos = event->globalPos(); m_pressedButtons = event->buttons(); emit mousePressed(); } void HelperWindow::mouseReleaseEvent(QMouseEvent *event) { m_latestGlobalMousePos = event->globalPos(); m_pressedButtons = event->buttons(); emit mouseReleased(); } void HelperWindow::wheelEvent(QWheelEvent *event) { Q_UNUSED(event) emit wheel(); } void HelperWindow::keyPressEvent(QKeyEvent *event) { Q_UNUSED(event) emit keyPressed(); } void HelperWindow::keyReleaseEvent(QKeyEvent *event) { Q_UNUSED(event) emit keyReleased(); } void InternalWindowTest::initTestCase() { qRegisterMetaType(); qRegisterMetaType(); QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); QVERIFY(workspaceCreatedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig)); kwinApp()->start(); QVERIFY(workspaceCreatedSpy.wait()); QCOMPARE(screens()->count(), 2); QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); waylandServer()->initWorkspace(); } void InternalWindowTest::init() { Cursor::setPos(QPoint(1280, 512)); QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat)); QVERIFY(Test::waitForWaylandKeyboard()); } void InternalWindowTest::cleanup() { Test::destroyWaylandConnection(); } void InternalWindowTest::testEnterLeave() { QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); HelperWindow win; QVERIFY(!workspace()->findToplevel(nullptr)); QVERIFY(!workspace()->findToplevel(&win)); win.setGeometry(0, 0, 100, 100); win.show(); QTRY_COMPARE(clientAddedSpy.count(), 1); QVERIFY(!workspace()->activeClient()); ShellClient *c = clientAddedSpy.first().first().value(); QVERIFY(c->isInternal()); QVERIFY(qobject_cast(c)); QCOMPARE(c->icon().name(), QStringLiteral("wayland")); QVERIFY(!c->isDecorated()); QCOMPARE(workspace()->findToplevel(&win), c); QCOMPARE(c->geometry(), QRect(0, 0, 100, 100)); QVERIFY(c->isShown(false)); QVERIFY(workspace()->xStackingOrder().contains(c)); QSignalSpy enterSpy(&win, &HelperWindow::entered); QVERIFY(enterSpy.isValid()); QSignalSpy leaveSpy(&win, &HelperWindow::left); QVERIFY(leaveSpy.isValid()); QSignalSpy moveSpy(&win, &HelperWindow::mouseMoved); QVERIFY(moveSpy.isValid()); quint32 timestamp = 1; kwinApp()->platform()->pointerMotion(QPoint(50, 50), timestamp++); QTRY_COMPARE(moveSpy.count(), 1); kwinApp()->platform()->pointerMotion(QPoint(60, 50), timestamp++); QTRY_COMPARE(moveSpy.count(), 2); QCOMPARE(moveSpy[1].first().toPoint(), QPoint(60, 50)); kwinApp()->platform()->pointerMotion(QPoint(101, 50), timestamp++); QTRY_COMPARE(leaveSpy.count(), 1); // set a mask on the window win.setMask(QRegion(10, 20, 30, 40)); // outside the mask we should not get an enter kwinApp()->platform()->pointerMotion(QPoint(5, 5), timestamp++); QVERIFY(!enterSpy.wait(100)); QCOMPARE(enterSpy.count(), 1); // inside the mask we should still get an enter kwinApp()->platform()->pointerMotion(QPoint(25, 27), timestamp++); QTRY_COMPARE(enterSpy.count(), 2); // hide the window, which should be removed from the stacking order win.hide(); QTRY_VERIFY(!c->isShown(false)); QVERIFY(!workspace()->xStackingOrder().contains(c)); // show again win.show(); QTRY_VERIFY(c->isShown(false)); QVERIFY(workspace()->xStackingOrder().contains(c)); } void InternalWindowTest::testPointerPressRelease() { QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); HelperWindow win; win.setGeometry(0, 0, 100, 100); win.show(); QSignalSpy pressSpy(&win, &HelperWindow::mousePressed); QVERIFY(pressSpy.isValid()); QSignalSpy releaseSpy(&win, &HelperWindow::mouseReleased); QVERIFY(releaseSpy.isValid()); QTRY_COMPARE(clientAddedSpy.count(), 1); quint32 timestamp = 1; kwinApp()->platform()->pointerMotion(QPoint(50, 50), timestamp++); kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); QTRY_COMPARE(pressSpy.count(), 1); kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); QTRY_COMPARE(releaseSpy.count(), 1); } void InternalWindowTest::testPointerAxis() { QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); HelperWindow win; win.setGeometry(0, 0, 100, 100); win.show(); QSignalSpy wheelSpy(&win, &HelperWindow::wheel); QVERIFY(wheelSpy.isValid()); QTRY_COMPARE(clientAddedSpy.count(), 1); quint32 timestamp = 1; kwinApp()->platform()->pointerMotion(QPoint(50, 50), timestamp++); kwinApp()->platform()->pointerAxisVertical(5.0, timestamp++); QTRY_COMPARE(wheelSpy.count(), 1); kwinApp()->platform()->pointerAxisHorizontal(5.0, timestamp++); QTRY_COMPARE(wheelSpy.count(), 2); } void InternalWindowTest::testKeyboard_data() { QTest::addColumn("cursorPos"); QTest::newRow("on Window") << QPoint(50, 50); QTest::newRow("outside Window") << QPoint(250, 250); } void InternalWindowTest::testKeyboard() { QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); HelperWindow win; win.setGeometry(0, 0, 100, 100); win.show(); QSignalSpy pressSpy(&win, &HelperWindow::keyPressed); QVERIFY(pressSpy.isValid()); QSignalSpy releaseSpy(&win, &HelperWindow::keyReleased); QVERIFY(releaseSpy.isValid()); QTRY_COMPARE(clientAddedSpy.count(), 1); auto internalClient = clientAddedSpy.first().first().value(); QVERIFY(internalClient); QVERIFY(internalClient->isInternal()); QVERIFY(internalClient->readyForPainting()); quint32 timestamp = 1; QFETCH(QPoint, cursorPos); kwinApp()->platform()->pointerMotion(cursorPos, timestamp++); kwinApp()->platform()->keyboardKeyPressed(KEY_A, timestamp++); QTRY_COMPARE(pressSpy.count(), 1); QCOMPARE(releaseSpy.count(), 0); kwinApp()->platform()->keyboardKeyReleased(KEY_A, timestamp++); QTRY_COMPARE(releaseSpy.count(), 1); QCOMPARE(pressSpy.count(), 1); } void InternalWindowTest::testKeyboardShowWithoutActivating() { QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); HelperWindow win; win.setProperty("_q_showWithoutActivating", true); win.setGeometry(0, 0, 100, 100); win.show(); QSignalSpy pressSpy(&win, &HelperWindow::keyPressed); QVERIFY(pressSpy.isValid()); QSignalSpy releaseSpy(&win, &HelperWindow::keyReleased); QVERIFY(releaseSpy.isValid()); QTRY_COMPARE(clientAddedSpy.count(), 1); auto internalClient = clientAddedSpy.first().first().value(); QVERIFY(internalClient); QVERIFY(internalClient->isInternal()); QVERIFY(internalClient->readyForPainting()); quint32 timestamp = 1; const QPoint cursorPos = QPoint(50, 50); kwinApp()->platform()->pointerMotion(cursorPos, timestamp++); kwinApp()->platform()->keyboardKeyPressed(KEY_A, timestamp++); QCOMPARE(pressSpy.count(), 0); QVERIFY(!pressSpy.wait(100)); QCOMPARE(releaseSpy.count(), 0); kwinApp()->platform()->keyboardKeyReleased(KEY_A, timestamp++); QCOMPARE(releaseSpy.count(), 0); QVERIFY(!releaseSpy.wait(100)); QCOMPARE(pressSpy.count(), 0); } void InternalWindowTest::testKeyboardTriggersLeave() { // this test verifies that a leave event is sent to a client when an internal window // gets a key event QScopedPointer keyboard(Test::waylandSeat()->createKeyboard()); QVERIFY(!keyboard.isNull()); QVERIFY(keyboard->isValid()); QSignalSpy enteredSpy(keyboard.data(), &Keyboard::entered); QVERIFY(enteredSpy.isValid()); QSignalSpy leftSpy(keyboard.data(), &Keyboard::left); QVERIFY(leftSpy.isValid()); QScopedPointer surface(Test::createSurface()); QScopedPointer shellSurface(Test::createShellSurface(Test::ShellSurfaceType::WlShell, surface.data())); // now let's render auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); QVERIFY(c); QVERIFY(c->isActive()); QVERIFY(!c->isInternal()); if (enteredSpy.isEmpty()) { QVERIFY(enteredSpy.wait()); } QCOMPARE(enteredSpy.count(), 1); // create internal window QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); HelperWindow win; win.setGeometry(0, 0, 100, 100); win.show(); QSignalSpy pressSpy(&win, &HelperWindow::keyPressed); QVERIFY(pressSpy.isValid()); QSignalSpy releaseSpy(&win, &HelperWindow::keyReleased); QVERIFY(releaseSpy.isValid()); QTRY_COMPARE(clientAddedSpy.count(), 1); auto internalClient = clientAddedSpy.first().first().value(); QVERIFY(internalClient); QVERIFY(internalClient->isInternal()); QVERIFY(internalClient->readyForPainting()); QVERIFY(leftSpy.isEmpty()); QVERIFY(!leftSpy.wait(100)); // now let's trigger a key, which should result in a leave quint32 timestamp = 1; kwinApp()->platform()->keyboardKeyPressed(KEY_A, timestamp++); QVERIFY(leftSpy.wait()); QCOMPARE(pressSpy.count(), 1); kwinApp()->platform()->keyboardKeyReleased(KEY_A, timestamp++); QTRY_COMPARE(releaseSpy.count(), 1); // after hiding the internal window, next key press should trigger an enter win.hide(); kwinApp()->platform()->keyboardKeyPressed(KEY_A, timestamp++); QVERIFY(enteredSpy.wait()); kwinApp()->platform()->keyboardKeyReleased(KEY_A, timestamp++); } void InternalWindowTest::testTouch() { // touch events for internal windows are emulated through mouse events QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); HelperWindow win; win.setGeometry(0, 0, 100, 100); win.show(); QTRY_COMPARE(clientAddedSpy.count(), 1); QSignalSpy pressSpy(&win, &HelperWindow::mousePressed); QVERIFY(pressSpy.isValid()); QSignalSpy releaseSpy(&win, &HelperWindow::mouseReleased); QVERIFY(releaseSpy.isValid()); QSignalSpy moveSpy(&win, &HelperWindow::mouseMoved); QVERIFY(moveSpy.isValid()); quint32 timestamp = 1; QCOMPARE(win.pressedButtons(), Qt::MouseButtons()); kwinApp()->platform()->touchDown(0, QPointF(50, 50), timestamp++); QCOMPARE(pressSpy.count(), 1); QCOMPARE(win.latestGlobalMousePos(), QPoint(50, 50)); QCOMPARE(win.pressedButtons(), Qt::MouseButtons(Qt::LeftButton)); // further touch down should not trigger kwinApp()->platform()->touchDown(1, QPointF(75, 75), timestamp++); QCOMPARE(pressSpy.count(), 1); kwinApp()->platform()->touchUp(1, timestamp++); QCOMPARE(releaseSpy.count(), 0); QCOMPARE(win.latestGlobalMousePos(), QPoint(50, 50)); QCOMPARE(win.pressedButtons(), Qt::MouseButtons(Qt::LeftButton)); // another press kwinApp()->platform()->touchDown(1, QPointF(10, 10), timestamp++); QCOMPARE(pressSpy.count(), 1); QCOMPARE(win.latestGlobalMousePos(), QPoint(50, 50)); QCOMPARE(win.pressedButtons(), Qt::MouseButtons(Qt::LeftButton)); // simulate the move QCOMPARE(moveSpy.count(), 0); kwinApp()->platform()->touchMotion(0, QPointF(80, 90), timestamp++); QCOMPARE(moveSpy.count(), 1); QCOMPARE(win.latestGlobalMousePos(), QPoint(80, 90)); QCOMPARE(win.pressedButtons(), Qt::MouseButtons(Qt::LeftButton)); // move on other ID should not do anything kwinApp()->platform()->touchMotion(1, QPointF(20, 30), timestamp++); QCOMPARE(moveSpy.count(), 1); QCOMPARE(win.latestGlobalMousePos(), QPoint(80, 90)); QCOMPARE(win.pressedButtons(), Qt::MouseButtons(Qt::LeftButton)); // now up our main point kwinApp()->platform()->touchUp(0, timestamp++); QCOMPARE(releaseSpy.count(), 1); QCOMPARE(win.latestGlobalMousePos(), QPoint(80, 90)); QCOMPARE(win.pressedButtons(), Qt::MouseButtons()); // and up the additional point kwinApp()->platform()->touchUp(1, timestamp++); QCOMPARE(releaseSpy.count(), 1); QCOMPARE(moveSpy.count(), 1); QCOMPARE(win.latestGlobalMousePos(), QPoint(80, 90)); QCOMPARE(win.pressedButtons(), Qt::MouseButtons()); } void InternalWindowTest::testOpacity() { // this test verifies that opacity is properly synced from QWindow to ShellClient QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); HelperWindow win; win.setOpacity(0.5); win.setGeometry(0, 0, 100, 100); win.show(); QTRY_COMPARE(clientAddedSpy.count(), 1); auto internalClient = clientAddedSpy.first().first().value(); QVERIFY(internalClient); QVERIFY(internalClient->isInternal()); QCOMPARE(internalClient->opacity(), 0.5); QSignalSpy opacityChangedSpy(internalClient, &ShellClient::opacityChanged); QVERIFY(opacityChangedSpy.isValid()); win.setOpacity(0.75); QCOMPARE(opacityChangedSpy.count(), 1); QCOMPARE(internalClient->opacity(), 0.75); } void InternalWindowTest::testMove() { QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); HelperWindow win; win.setOpacity(0.5); win.setGeometry(0, 0, 100, 100); win.show(); QTRY_COMPARE(clientAddedSpy.count(), 1); auto internalClient = clientAddedSpy.first().first().value(); QVERIFY(internalClient); QCOMPARE(internalClient->geometry(), QRect(0, 0, 100, 100)); // normal move should be synced internalClient->move(5, 10); QCOMPARE(internalClient->geometry(), QRect(5, 10, 100, 100)); QTRY_COMPARE(win.geometry(), QRect(5, 10, 100, 100)); // another move should also be synced internalClient->move(10, 20); QCOMPARE(internalClient->geometry(), QRect(10, 20, 100, 100)); QTRY_COMPARE(win.geometry(), QRect(10, 20, 100, 100)); // now move with a Geometry update blocker { GeometryUpdatesBlocker blocker(internalClient); internalClient->move(5, 10); // not synced! QCOMPARE(win.geometry(), QRect(10, 20, 100, 100)); } // after destroying the blocker it should be synced QTRY_COMPARE(win.geometry(), QRect(5, 10, 100, 100)); } void InternalWindowTest::testSkipCloseAnimation_data() { QTest::addColumn("initial"); QTest::newRow("set") << true; QTest::newRow("not set") << false; } void InternalWindowTest::testSkipCloseAnimation() { QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); HelperWindow win; win.setOpacity(0.5); win.setGeometry(0, 0, 100, 100); QFETCH(bool, initial); win.setProperty("KWIN_SKIP_CLOSE_ANIMATION", initial); win.show(); QTRY_COMPARE(clientAddedSpy.count(), 1); auto internalClient = clientAddedSpy.first().first().value(); QVERIFY(internalClient); QCOMPARE(internalClient->skipsCloseAnimation(), initial); QSignalSpy skipCloseChangedSpy(internalClient, &Toplevel::skipCloseAnimationChanged); QVERIFY(skipCloseChangedSpy.isValid()); win.setProperty("KWIN_SKIP_CLOSE_ANIMATION", !initial); QCOMPARE(skipCloseChangedSpy.count(), 1); QCOMPARE(internalClient->skipsCloseAnimation(), !initial); win.setProperty("KWIN_SKIP_CLOSE_ANIMATION", initial); QCOMPARE(skipCloseChangedSpy.count(), 2); QCOMPARE(internalClient->skipsCloseAnimation(), initial); } void InternalWindowTest::testModifierClickUnrestrictedMove() { QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); HelperWindow win; win.setGeometry(0, 0, 100, 100); win.setFlags(win.flags() & ~Qt::FramelessWindowHint); win.show(); QTRY_COMPARE(clientAddedSpy.count(), 1); auto internalClient = clientAddedSpy.first().first().value(); QVERIFY(internalClient); QVERIFY(internalClient->isDecorated()); KConfigGroup group = kwinApp()->config()->group("MouseBindings"); group.writeEntry("CommandAllKey", "Alt"); group.writeEntry("CommandAll1", "Move"); group.writeEntry("CommandAll2", "Move"); group.writeEntry("CommandAll3", "Move"); group.sync(); workspace()->slotReconfigure(); QCOMPARE(options->commandAllModifier(), Qt::AltModifier); QCOMPARE(options->commandAll1(), Options::MouseUnrestrictedMove); QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove); QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove); // move cursor on window Cursor::setPos(internalClient->geometry().center()); // simulate modifier+click quint32 timestamp = 1; kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTALT, timestamp++); QVERIFY(!internalClient->isMove()); kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); QVERIFY(internalClient->isMove()); // release modifier should not change it kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++); QVERIFY(internalClient->isMove()); // but releasing the key should end move/resize kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); QVERIFY(!internalClient->isMove()); } void InternalWindowTest::testModifierScroll() { QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); HelperWindow win; win.setGeometry(0, 0, 100, 100); win.setFlags(win.flags() & ~Qt::FramelessWindowHint); win.show(); QTRY_COMPARE(clientAddedSpy.count(), 1); auto internalClient = clientAddedSpy.first().first().value(); QVERIFY(internalClient); QVERIFY(internalClient->isDecorated()); KConfigGroup group = kwinApp()->config()->group("MouseBindings"); group.writeEntry("CommandAllKey", "Alt"); group.writeEntry("CommandAllWheel", "change opacity"); group.sync(); workspace()->slotReconfigure(); // move cursor on window Cursor::setPos(internalClient->geometry().center()); // set the opacity to 0.5 internalClient->setOpacity(0.5); QCOMPARE(internalClient->opacity(), 0.5); quint32 timestamp = 1; kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTALT, timestamp++); kwinApp()->platform()->pointerAxisVertical(-5, timestamp++); QCOMPARE(internalClient->opacity(), 0.6); kwinApp()->platform()->pointerAxisVertical(5, timestamp++); QCOMPARE(internalClient->opacity(), 0.5); kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++); } void InternalWindowTest::testPopup() { QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); HelperWindow win; win.setGeometry(0, 0, 100, 100); win.setFlags(win.flags() | Qt::Popup); win.show(); QTRY_COMPARE(clientAddedSpy.count(), 1); auto internalClient = clientAddedSpy.first().first().value(); QVERIFY(internalClient); QCOMPARE(internalClient->isPopupWindow(), true); } void InternalWindowTest::testScale() { QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2), Q_ARG(QVector, QVector({QRect(0,0,1280, 1024), QRect(1280/2, 0, 1280, 1024)})), Q_ARG(QVector, QVector({2,2}))); QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); HelperWindow win; win.setGeometry(0, 0, 100, 100); win.setFlags(win.flags() | Qt::Popup); win.show(); QCOMPARE(win.devicePixelRatio(), 2.0); QTRY_COMPARE(clientAddedSpy.count(), 1); auto internalClient = clientAddedSpy.first().first().value(); QCOMPARE(internalClient->surface()->scale(), 2); QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); } void InternalWindowTest::testWindowType_data() { QTest::addColumn("windowType"); QTest::newRow("normal") << NET::Normal; QTest::newRow("desktop") << NET::Desktop; QTest::newRow("Dock") << NET::Dock; QTest::newRow("Toolbar") << NET::Toolbar; QTest::newRow("Menu") << NET::Menu; QTest::newRow("Dialog") << NET::Dialog; QTest::newRow("Utility") << NET::Utility; QTest::newRow("Splash") << NET::Splash; QTest::newRow("DropdownMenu") << NET::DropdownMenu; QTest::newRow("PopupMenu") << NET::PopupMenu; QTest::newRow("Tooltip") << NET::Tooltip; QTest::newRow("Notification") << NET::Notification; QTest::newRow("ComboBox") << NET::ComboBox; QTest::newRow("OnScreenDisplay") << NET::OnScreenDisplay; QTest::newRow("CriticalNotification") << NET::CriticalNotification; } void InternalWindowTest::testWindowType() { QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); HelperWindow win; win.setGeometry(0, 0, 100, 100); QFETCH(NET::WindowType, windowType); KWindowSystem::setType(win.winId(), windowType); win.show(); QTRY_COMPARE(clientAddedSpy.count(), 1); auto internalClient = clientAddedSpy.first().first().value(); QVERIFY(internalClient); QCOMPARE(internalClient->windowType(), windowType); } void InternalWindowTest::testChangeWindowType_data() { QTest::addColumn("windowType"); QTest::newRow("desktop") << NET::Desktop; QTest::newRow("Dock") << NET::Dock; QTest::newRow("Toolbar") << NET::Toolbar; QTest::newRow("Menu") << NET::Menu; QTest::newRow("Dialog") << NET::Dialog; QTest::newRow("Utility") << NET::Utility; QTest::newRow("Splash") << NET::Splash; QTest::newRow("DropdownMenu") << NET::DropdownMenu; QTest::newRow("PopupMenu") << NET::PopupMenu; QTest::newRow("Tooltip") << NET::Tooltip; QTest::newRow("Notification") << NET::Notification; QTest::newRow("ComboBox") << NET::ComboBox; QTest::newRow("OnScreenDisplay") << NET::OnScreenDisplay; QTest::newRow("CriticalNotification") << NET::CriticalNotification; } void InternalWindowTest::testChangeWindowType() { QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); HelperWindow win; win.setGeometry(0, 0, 100, 100); win.show(); QTRY_COMPARE(clientAddedSpy.count(), 1); auto internalClient = clientAddedSpy.first().first().value(); QVERIFY(internalClient); QCOMPARE(internalClient->windowType(), NET::Normal); QFETCH(NET::WindowType, windowType); KWindowSystem::setType(win.winId(), windowType); QTRY_COMPARE(internalClient->windowType(), windowType); KWindowSystem::setType(win.winId(), NET::Normal); QTRY_COMPARE(internalClient->windowType(), NET::Normal); } void InternalWindowTest::testEffectWindow() { QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); HelperWindow win; win.setGeometry(0, 0, 100, 100); win.show(); QTRY_COMPARE(clientAddedSpy.count(), 1); auto internalClient = clientAddedSpy.first().first().value(); QVERIFY(internalClient); QVERIFY(internalClient->effectWindow()); QCOMPARE(internalClient->effectWindow()->internalWindow(), &win); QCOMPARE(effects->findWindow(&win), internalClient->effectWindow()); QCOMPARE(effects->findWindow(&win)->internalWindow(), &win); } } WAYLANDTEST_MAIN(KWin::InternalWindowTest) #include "internal_window.moc" diff --git a/autotests/integration/kwin_wayland_test.h b/autotests/integration/kwin_wayland_test.h index 5db3d2edf..5ecdc3be2 100644 --- a/autotests/integration/kwin_wayland_test.h +++ b/autotests/integration/kwin_wayland_test.h @@ -1,256 +1,256 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_WAYLAND_TEST_H #define KWIN_WAYLAND_TEST_H #include "../../main.h" // Qt #include // KWayland #include namespace KWayland { namespace Client { class AppMenuManager; class ConnectionThread; class Compositor; class IdleInhibitManager; class PlasmaShell; class PlasmaWindowManagement; class PointerConstraints; class Seat; class ServerSideDecorationManager; class ShadowManager; class Shell; class ShellSurface; class ShmPool; class SubCompositor; class SubSurface; class Surface; class XdgDecorationManager; } } namespace KWin { namespace Xwl { class Xwayland; } class AbstractClient; class ShellClient; class WaylandTestApplication : public ApplicationWaylandAbstract { Q_OBJECT public: WaylandTestApplication(OperationMode mode, int &argc, char **argv); - virtual ~WaylandTestApplication(); + ~WaylandTestApplication() override; protected: void performStartup() override; private: void createBackend(); void continueStartupWithScreens(); void continueStartupWithScene(); void finalizeStartup(); Xwl::Xwayland *m_xwayland = nullptr; }; namespace Test { enum class AdditionalWaylandInterface { Seat = 1 << 0, Decoration = 1 << 1, PlasmaShell = 1 << 2, WindowManagement = 1 << 3, PointerConstraints = 1 << 4, IdleInhibition = 1 << 5, AppMenu = 1 << 6, ShadowManager = 1 << 7, XdgDecoration = 1 << 8, }; Q_DECLARE_FLAGS(AdditionalWaylandInterfaces, AdditionalWaylandInterface) /** * Creates a Wayland Connection in a dedicated thread and creates various * client side objects which can be used to create windows. * @returns @c true if created successfully, @c false if there was an error * @see destroyWaylandConnection **/ bool setupWaylandConnection(AdditionalWaylandInterfaces flags = AdditionalWaylandInterfaces()); /** * Destroys the Wayland Connection created with @link{setupWaylandConnection}. * This can be called from cleanup in order to ensure that no Wayland Connection * leaks into the next test method. * @see setupWaylandConnection */ void destroyWaylandConnection(); KWayland::Client::ConnectionThread *waylandConnection(); KWayland::Client::Compositor *waylandCompositor(); KWayland::Client::SubCompositor *waylandSubCompositor(); KWayland::Client::ShadowManager *waylandShadowManager(); KWayland::Client::Shell *waylandShell(); KWayland::Client::ShmPool *waylandShmPool(); KWayland::Client::Seat *waylandSeat(); KWayland::Client::ServerSideDecorationManager *waylandServerSideDecoration(); KWayland::Client::PlasmaShell *waylandPlasmaShell(); KWayland::Client::PlasmaWindowManagement *waylandWindowManagement(); KWayland::Client::PointerConstraints *waylandPointerConstraints(); KWayland::Client::IdleInhibitManager *waylandIdleInhibitManager(); KWayland::Client::AppMenuManager *waylandAppMenuManager(); KWayland::Client::XdgDecorationManager *xdgDecorationManager(); bool waitForWaylandPointer(); bool waitForWaylandTouch(); bool waitForWaylandKeyboard(); void flushWaylandConnection(); KWayland::Client::Surface *createSurface(QObject *parent = nullptr); KWayland::Client::SubSurface *createSubSurface(KWayland::Client::Surface *surface, KWayland::Client::Surface *parentSurface, QObject *parent = nullptr); enum class ShellSurfaceType { WlShell, XdgShellV5, XdgShellV6, XdgShellStable }; enum class CreationSetup { CreateOnly, CreateAndConfigure, /// commit and wait for the configure event, making this surface ready to commit buffers }; /** * Creates either a ShellSurface * or XdgShellSurface * as defined by @arg type * For XDG top levels this method will block for a configure event, make this surface ready to commit buffers */ QObject *createShellSurface(ShellSurfaceType type, KWayland::Client::Surface *surface, QObject *parent = nullptr); KWayland::Client::XdgShellSurface *createXdgShellSurface(ShellSurfaceType type, KWayland::Client::Surface *surface, QObject *parent = nullptr, CreationSetup creationSetup = CreationSetup::CreateAndConfigure); KWayland::Client::ShellSurface *createShellSurface(KWayland::Client::Surface *surface, QObject *parent = nullptr); KWayland::Client::XdgShellSurface *createXdgShellV5Surface(KWayland::Client::Surface *surface, QObject *parent = nullptr, CreationSetup = CreationSetup::CreateAndConfigure); KWayland::Client::XdgShellSurface *createXdgShellV6Surface(KWayland::Client::Surface *surface, QObject *parent = nullptr, CreationSetup = CreationSetup::CreateAndConfigure); KWayland::Client::XdgShellSurface *createXdgShellStableSurface(KWayland::Client::Surface *surface, QObject *parent = nullptr, CreationSetup = CreationSetup::CreateAndConfigure); KWayland::Client::XdgShellPopup *createXdgShellStablePopup(KWayland::Client::Surface *surface, KWayland::Client::XdgShellSurface *parentSurface, const KWayland::Client::XdgPositioner &positioner, QObject *parent = nullptr, CreationSetup = CreationSetup::CreateAndConfigure); /** * Commits the XdgShellSurface to the given surface, and waits for the configure event from the compositor */ void initXdgShellSurface(KWayland::Client::Surface *surface, KWayland::Client::XdgShellSurface *shellSurface); void initXdgShellPopup(KWayland::Client::Surface *surface, KWayland::Client::XdgShellPopup *popup); /** * Creates a shared memory buffer of @p size in @p color and attaches it to the @p surface. * The @p surface gets damaged and committed, thus it's rendered. **/ void render(KWayland::Client::Surface *surface, const QSize &size, const QColor &color, const QImage::Format &format = QImage::Format_ARGB32_Premultiplied); /** * Creates a shared memory buffer using the supplied image @p img and attaches it to the @p surface */ void render(KWayland::Client::Surface *surface, const QImage &img); /** * Waits till a new ShellClient is shown and returns the created ShellClient. * If no ShellClient gets shown during @p timeout @c null is returned. **/ ShellClient *waitForWaylandWindowShown(int timeout = 5000); /** * Combination of @link{render} and @link{waitForWaylandWindowShown}. **/ ShellClient *renderAndWaitForShown(KWayland::Client::Surface *surface, const QSize &size, const QColor &color, const QImage::Format &format = QImage::Format_ARGB32, int timeout = 5000); /** * Waits for the @p client to be destroyed. **/ bool waitForWindowDestroyed(AbstractClient *client); /** * Locks the screen and waits till the screen is locked. * @returns @c true if the screen could be locked, @c false otherwise **/ bool lockScreen(); /** * Unlocks the screen and waits till the screen is unlocked. * @returns @c true if the screen could be unlocked, @c false otherwise **/ bool unlockScreen(); } } Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::Test::AdditionalWaylandInterfaces) Q_DECLARE_METATYPE(KWin::Test::ShellSurfaceType) #define WAYLANDTEST_MAIN_HELPER(TestObject, DPI, OperationMode) \ int main(int argc, char *argv[]) \ { \ setenv("QT_QPA_PLATFORM", "wayland-org.kde.kwin.qpa", true); \ setenv("QT_QPA_PLATFORM_PLUGIN_PATH", QFileInfo(QString::fromLocal8Bit(argv[0])).absolutePath().toLocal8Bit().constData(), true); \ setenv("KWIN_FORCE_OWN_QPA", "1", true); \ qunsetenv("KDE_FULL_SESSION"); \ qunsetenv("KDE_SESSION_VERSION"); \ qunsetenv("XDG_SESSION_DESKTOP"); \ qunsetenv("XDG_CURRENT_DESKTOP"); \ DPI; \ KWin::WaylandTestApplication app(OperationMode, argc, argv); \ app.setAttribute(Qt::AA_Use96Dpi, true); \ TestObject tc; \ return QTest::qExec(&tc, argc, argv); \ } #ifdef NO_XWAYLAND #define WAYLANDTEST_MAIN(TestObject) WAYLANDTEST_MAIN_HELPER(TestObject, QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps), KWin::Application::OperationModeWaylandOnly) #else #define WAYLANDTEST_MAIN(TestObject) WAYLANDTEST_MAIN_HELPER(TestObject, QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps), KWin::Application::OperationModeXwayland) #endif #endif diff --git a/autotests/integration/lockscreen.cpp b/autotests/integration/lockscreen.cpp index 1e51e6b9d..3344655f2 100644 --- a/autotests/integration/lockscreen.cpp +++ b/autotests/integration/lockscreen.cpp @@ -1,770 +1,770 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2016 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 "kwin_wayland_test.h" #include "platform.h" #include "abstract_client.h" #include "composite.h" #include "cursor.h" #include "scene.h" #include "screenedge.h" #include "screens.h" #include "wayland_server.h" #include "workspace.h" #include "shell_client.h" #include #include #include #include #include #include #include #include #include #include #include #include //screenlocker #include #include #include Q_DECLARE_METATYPE(Qt::Orientation) namespace KWin { static const QString s_socketName = QStringLiteral("wayland_test_kwin_lock_screen-0"); class LockScreenTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase(); void init(); void cleanup(); void testPointer(); void testPointerButton(); void testPointerAxis(); void testKeyboard(); void testScreenEdge(); void testEffects(); void testEffectsKeyboard(); void testEffectsKeyboardAutorepeat(); void testMoveWindow(); void testPointerShortcut(); void testAxisShortcut_data(); void testAxisShortcut(); void testKeyboardShortcut(); void testTouch(); private: void unlock(); AbstractClient *showWindow(); KWayland::Client::ConnectionThread *m_connection = nullptr; KWayland::Client::Compositor *m_compositor = nullptr; KWayland::Client::Seat *m_seat = nullptr; KWayland::Client::ShmPool *m_shm = nullptr; KWayland::Client::Shell *m_shell = nullptr; }; class HelperEffect : public Effect { Q_OBJECT public: HelperEffect() {} - ~HelperEffect() {} + ~HelperEffect() override {} void windowInputMouseEvent(QEvent*) override { emit inputEvent(); } void grabbedKeyboardEvent(QKeyEvent *e) override { emit keyEvent(e->text()); } Q_SIGNALS: void inputEvent(); void keyEvent(const QString&); }; #define LOCK \ QVERIFY(!waylandServer()->isScreenLocked()); \ QSignalSpy lockStateChangedSpy(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged); \ QVERIFY(lockStateChangedSpy.isValid()); \ ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate); \ QCOMPARE(lockStateChangedSpy.count(), 1); \ QVERIFY(waylandServer()->isScreenLocked()); #define UNLOCK \ int expectedLockCount = 1; \ if (ScreenLocker::KSldApp::self()->lockState() == ScreenLocker::KSldApp::Locked) { \ expectedLockCount = 2; \ } \ QCOMPARE(lockStateChangedSpy.count(), expectedLockCount); \ unlock(); \ if (lockStateChangedSpy.count() < expectedLockCount + 1) { \ QVERIFY(lockStateChangedSpy.wait()); \ } \ QCOMPARE(lockStateChangedSpy.count(), expectedLockCount + 1); \ QVERIFY(!waylandServer()->isScreenLocked()); #define MOTION(target) \ kwinApp()->platform()->pointerMotion(target, timestamp++) #define PRESS \ kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++) #define RELEASE \ kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++) #define KEYPRESS( key ) \ kwinApp()->platform()->keyboardKeyPressed(key, timestamp++) #define KEYRELEASE( key ) \ kwinApp()->platform()->keyboardKeyReleased(key, timestamp++) void LockScreenTest::unlock() { using namespace ScreenLocker; const auto children = KSldApp::self()->children(); for (auto it = children.begin(); it != children.end(); ++it) { if (qstrcmp((*it)->metaObject()->className(), "LogindIntegration") != 0) { continue; } QMetaObject::invokeMethod(*it, "requestUnlock"); break; } } AbstractClient *LockScreenTest::showWindow() { using namespace KWayland::Client; #define VERIFY(statement) \ if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__))\ return nullptr; #define COMPARE(actual, expected) \ if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__))\ return nullptr; Surface *surface = Test::createSurface(m_compositor); VERIFY(surface); ShellSurface *shellSurface = Test::createShellSurface(surface, surface); VERIFY(shellSurface); // let's render auto c = Test::renderAndWaitForShown(surface, QSize(100, 50), Qt::blue); VERIFY(c); COMPARE(workspace()->activeClient(), c); #undef VERIFY #undef COMPARE return c; } void LockScreenTest::initTestCase() { qRegisterMetaType(); qRegisterMetaType(); QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); QVERIFY(workspaceCreatedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); qputenv("KWIN_COMPOSE", QByteArrayLiteral("O2")); kwinApp()->start(); QVERIFY(workspaceCreatedSpy.wait()); QCOMPARE(screens()->count(), 2); QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); setenv("QT_QPA_PLATFORM", "wayland", true); waylandServer()->initWorkspace(); auto scene = KWin::Compositor::self()->scene(); QVERIFY(scene); QCOMPARE(scene->compositingType(), KWin::OpenGL2Compositing); } void LockScreenTest::init() { QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat)); QVERIFY(Test::waitForWaylandPointer()); m_connection = Test::waylandConnection(); m_compositor = Test::waylandCompositor(); m_shell = Test::waylandShell(); m_shm = Test::waylandShmPool(); m_seat = Test::waylandSeat(); screens()->setCurrent(0); Cursor::setPos(QPoint(640, 512)); } void LockScreenTest::cleanup() { Test::destroyWaylandConnection(); } void LockScreenTest::testPointer() { using namespace KWayland::Client; QScopedPointer pointer(m_seat->createPointer()); QVERIFY(!pointer.isNull()); QSignalSpy enteredSpy(pointer.data(), &Pointer::entered); QVERIFY(enteredSpy.isValid()); QSignalSpy leftSpy(pointer.data(), &Pointer::left); QVERIFY(leftSpy.isValid()); AbstractClient *c = showWindow(); QVERIFY(c); // first move cursor into the center of the window quint32 timestamp = 1; MOTION(c->geometry().center()); QVERIFY(enteredSpy.wait()); LOCK QVERIFY(leftSpy.wait()); QCOMPARE(leftSpy.count(), 1); // simulate moving out in and out again MOTION(c->geometry().center()); MOTION(c->geometry().bottomRight() + QPoint(100, 100)); MOTION(c->geometry().bottomRight() + QPoint(100, 100)); QVERIFY(!leftSpy.wait()); QCOMPARE(leftSpy.count(), 1); QCOMPARE(enteredSpy.count(), 1); // go back on the window MOTION(c->geometry().center()); // and unlock UNLOCK QVERIFY(enteredSpy.wait()); QCOMPARE(enteredSpy.count(), 2); // move on the window MOTION(c->geometry().center() + QPoint(100, 100)); QVERIFY(leftSpy.wait()); MOTION(c->geometry().center()); QVERIFY(enteredSpy.wait()); QCOMPARE(enteredSpy.count(), 3); } void LockScreenTest::testPointerButton() { using namespace KWayland::Client; QScopedPointer pointer(m_seat->createPointer()); QVERIFY(!pointer.isNull()); QSignalSpy enteredSpy(pointer.data(), &Pointer::entered); QVERIFY(enteredSpy.isValid()); QSignalSpy buttonChangedSpy(pointer.data(), &Pointer::buttonStateChanged); QVERIFY(buttonChangedSpy.isValid()); AbstractClient *c = showWindow(); QVERIFY(c); // first move cursor into the center of the window quint32 timestamp = 1; MOTION(c->geometry().center()); QVERIFY(enteredSpy.wait()); // and simulate a click PRESS; QVERIFY(buttonChangedSpy.wait()); RELEASE; QVERIFY(buttonChangedSpy.wait()); LOCK // and simulate a click PRESS; QVERIFY(!buttonChangedSpy.wait()); RELEASE; QVERIFY(!buttonChangedSpy.wait()); UNLOCK QVERIFY(enteredSpy.wait()); QCOMPARE(enteredSpy.count(), 2); // and click again PRESS; QVERIFY(buttonChangedSpy.wait()); RELEASE; QVERIFY(buttonChangedSpy.wait()); } void LockScreenTest::testPointerAxis() { using namespace KWayland::Client; QScopedPointer pointer(m_seat->createPointer()); QVERIFY(!pointer.isNull()); QSignalSpy axisChangedSpy(pointer.data(), &Pointer::axisChanged); QVERIFY(axisChangedSpy.isValid()); QSignalSpy enteredSpy(pointer.data(), &Pointer::entered); QVERIFY(enteredSpy.isValid()); AbstractClient *c = showWindow(); QVERIFY(c); // first move cursor into the center of the window quint32 timestamp = 1; MOTION(c->geometry().center()); QVERIFY(enteredSpy.wait()); // and simulate axis kwinApp()->platform()->pointerAxisHorizontal(5.0, timestamp++); QVERIFY(axisChangedSpy.wait()); LOCK // and simulate axis kwinApp()->platform()->pointerAxisHorizontal(5.0, timestamp++); QVERIFY(!axisChangedSpy.wait(100)); kwinApp()->platform()->pointerAxisVertical(5.0, timestamp++); QVERIFY(!axisChangedSpy.wait(100)); // and unlock UNLOCK QVERIFY(enteredSpy.wait()); QCOMPARE(enteredSpy.count(), 2); // and move axis again kwinApp()->platform()->pointerAxisHorizontal(5.0, timestamp++); QVERIFY(axisChangedSpy.wait()); kwinApp()->platform()->pointerAxisVertical(5.0, timestamp++); QVERIFY(axisChangedSpy.wait()); } void LockScreenTest::testKeyboard() { using namespace KWayland::Client; QScopedPointer keyboard(m_seat->createKeyboard()); QVERIFY(!keyboard.isNull()); QSignalSpy enteredSpy(keyboard.data(), &Keyboard::entered); QVERIFY(enteredSpy.isValid()); QSignalSpy leftSpy(keyboard.data(), &Keyboard::left); QVERIFY(leftSpy.isValid()); QSignalSpy keyChangedSpy(keyboard.data(), &Keyboard::keyChanged); QVERIFY(keyChangedSpy.isValid()); AbstractClient *c = showWindow(); QVERIFY(c); QVERIFY(enteredSpy.wait()); QTRY_COMPARE(enteredSpy.count(), 1); quint32 timestamp = 1; KEYPRESS(KEY_A); QVERIFY(keyChangedSpy.wait()); QCOMPARE(keyChangedSpy.count(), 1); QCOMPARE(keyChangedSpy.at(0).at(0).value(), quint32(KEY_A)); QCOMPARE(keyChangedSpy.at(0).at(1).value(), Keyboard::KeyState::Pressed); QCOMPARE(keyChangedSpy.at(0).at(2).value(), quint32(1)); KEYRELEASE(KEY_A); QVERIFY(keyChangedSpy.wait()); QCOMPARE(keyChangedSpy.count(), 2); QCOMPARE(keyChangedSpy.at(1).at(0).value(), quint32(KEY_A)); QCOMPARE(keyChangedSpy.at(1).at(1).value(), Keyboard::KeyState::Released); QCOMPARE(keyChangedSpy.at(1).at(2).value(), quint32(2)); LOCK QVERIFY(leftSpy.wait()); KEYPRESS(KEY_B); KEYRELEASE(KEY_B); QCOMPARE(leftSpy.count(), 1); QCOMPARE(keyChangedSpy.count(), 2); UNLOCK QVERIFY(enteredSpy.wait()); QCOMPARE(enteredSpy.count(), 2); KEYPRESS(KEY_C); QVERIFY(keyChangedSpy.wait()); QCOMPARE(keyChangedSpy.count(), 3); KEYRELEASE(KEY_C); QVERIFY(keyChangedSpy.wait()); QCOMPARE(keyChangedSpy.count(), 4); QCOMPARE(enteredSpy.count(), 2); QCOMPARE(keyChangedSpy.at(2).at(0).value(), quint32(KEY_C)); QCOMPARE(keyChangedSpy.at(3).at(0).value(), quint32(KEY_C)); QCOMPARE(keyChangedSpy.at(2).at(2).value(), quint32(5)); QCOMPARE(keyChangedSpy.at(3).at(2).value(), quint32(6)); QCOMPARE(keyChangedSpy.at(2).at(1).value(), Keyboard::KeyState::Pressed); QCOMPARE(keyChangedSpy.at(3).at(1).value(), Keyboard::KeyState::Released); } void LockScreenTest::testScreenEdge() { QSignalSpy screenEdgeSpy(ScreenEdges::self(), &ScreenEdges::approaching); QVERIFY(screenEdgeSpy.isValid()); QCOMPARE(screenEdgeSpy.count(), 0); quint32 timestamp = 1; MOTION(QPoint(5, 5)); QCOMPARE(screenEdgeSpy.count(), 1); LOCK MOTION(QPoint(4, 4)); QCOMPARE(screenEdgeSpy.count(), 1); // and unlock UNLOCK MOTION(QPoint(5, 5)); QCOMPARE(screenEdgeSpy.count(), 2); } void LockScreenTest::testEffects() { QScopedPointer effect(new HelperEffect); QSignalSpy inputSpy(effect.data(), &HelperEffect::inputEvent); QVERIFY(inputSpy.isValid()); effects->startMouseInterception(effect.data(), Qt::ArrowCursor); quint32 timestamp = 1; QCOMPARE(inputSpy.count(), 0); MOTION(QPoint(5, 5)); QCOMPARE(inputSpy.count(), 1); // simlate click PRESS; QCOMPARE(inputSpy.count(), 2); RELEASE; QCOMPARE(inputSpy.count(), 3); LOCK MOTION(QPoint(6, 6)); QCOMPARE(inputSpy.count(), 3); // simlate click PRESS; QCOMPARE(inputSpy.count(), 3); RELEASE; QCOMPARE(inputSpy.count(), 3); UNLOCK MOTION(QPoint(5, 5)); QCOMPARE(inputSpy.count(), 4); // simlate click PRESS; QCOMPARE(inputSpy.count(), 5); RELEASE; QCOMPARE(inputSpy.count(), 6); effects->stopMouseInterception(effect.data()); } void LockScreenTest::testEffectsKeyboard() { QScopedPointer effect(new HelperEffect); QSignalSpy inputSpy(effect.data(), &HelperEffect::keyEvent); QVERIFY(inputSpy.isValid()); effects->grabKeyboard(effect.data()); quint32 timestamp = 1; KEYPRESS(KEY_A); QCOMPARE(inputSpy.count(), 1); QCOMPARE(inputSpy.first().first().toString(), QStringLiteral("a")); KEYRELEASE(KEY_A); QCOMPARE(inputSpy.count(), 2); QCOMPARE(inputSpy.first().first().toString(), QStringLiteral("a")); QCOMPARE(inputSpy.at(1).first().toString(), QStringLiteral("a")); LOCK KEYPRESS(KEY_B); QCOMPARE(inputSpy.count(), 2); KEYRELEASE(KEY_B); QCOMPARE(inputSpy.count(), 2); UNLOCK KEYPRESS(KEY_C); QCOMPARE(inputSpy.count(), 3); QCOMPARE(inputSpy.first().first().toString(), QStringLiteral("a")); QCOMPARE(inputSpy.at(1).first().toString(), QStringLiteral("a")); QCOMPARE(inputSpy.at(2).first().toString(), QStringLiteral("c")); KEYRELEASE(KEY_C); QCOMPARE(inputSpy.count(), 4); QCOMPARE(inputSpy.first().first().toString(), QStringLiteral("a")); QCOMPARE(inputSpy.at(1).first().toString(), QStringLiteral("a")); QCOMPARE(inputSpy.at(2).first().toString(), QStringLiteral("c")); QCOMPARE(inputSpy.at(3).first().toString(), QStringLiteral("c")); effects->ungrabKeyboard(); } void LockScreenTest::testEffectsKeyboardAutorepeat() { // this test is just like testEffectsKeyboard, but tests auto repeat key events // while the key is pressed the Effect should get auto repeated events // but the lock screen should filter them out QScopedPointer effect(new HelperEffect); QSignalSpy inputSpy(effect.data(), &HelperEffect::keyEvent); QVERIFY(inputSpy.isValid()); effects->grabKeyboard(effect.data()); // we need to configure the key repeat first. It is only enabled on libinput waylandServer()->seat()->setKeyRepeatInfo(25, 300); quint32 timestamp = 1; KEYPRESS(KEY_A); QCOMPARE(inputSpy.count(), 1); QCOMPARE(inputSpy.first().first().toString(), QStringLiteral("a")); QVERIFY(inputSpy.wait()); QVERIFY(inputSpy.count() > 1); // and still more events QVERIFY(inputSpy.wait()); QCOMPARE(inputSpy.at(1).first().toString(), QStringLiteral("a")); // now release inputSpy.clear(); KEYRELEASE(KEY_A); QCOMPARE(inputSpy.count(), 1); // while locked key repeat should not pass any events to the Effect LOCK KEYPRESS(KEY_B); QVERIFY(!inputSpy.wait(200)); KEYRELEASE(KEY_B); QVERIFY(!inputSpy.wait(200)); UNLOCK // don't test again, that's covered by testEffectsKeyboard effects->ungrabKeyboard(); } void LockScreenTest::testMoveWindow() { using namespace KWayland::Client; AbstractClient *c = showWindow(); QVERIFY(c); QSignalSpy clientStepUserMovedResizedSpy(c, &AbstractClient::clientStepUserMovedResized); QVERIFY(clientStepUserMovedResizedSpy.isValid()); quint32 timestamp = 1; workspace()->slotWindowMove(); QCOMPARE(workspace()->moveResizeClient(), c); QVERIFY(c->isMove()); kwinApp()->platform()->keyboardKeyPressed(KEY_RIGHT, timestamp++); kwinApp()->platform()->keyboardKeyReleased(KEY_RIGHT, timestamp++); QEXPECT_FAIL("", "First event is ignored", Continue); QCOMPARE(clientStepUserMovedResizedSpy.count(), 1); // TODO adjust once the expected fail is fixed kwinApp()->platform()->keyboardKeyPressed(KEY_RIGHT, timestamp++); kwinApp()->platform()->keyboardKeyReleased(KEY_RIGHT, timestamp++); QCOMPARE(clientStepUserMovedResizedSpy.count(), 1); // while locking our window should continue to be in move resize LOCK QCOMPARE(workspace()->moveResizeClient(), c); QVERIFY(c->isMove()); kwinApp()->platform()->keyboardKeyPressed(KEY_RIGHT, timestamp++); kwinApp()->platform()->keyboardKeyReleased(KEY_RIGHT, timestamp++); QCOMPARE(clientStepUserMovedResizedSpy.count(), 1); UNLOCK QCOMPARE(workspace()->moveResizeClient(), c); QVERIFY(c->isMove()); kwinApp()->platform()->keyboardKeyPressed(KEY_RIGHT, timestamp++); kwinApp()->platform()->keyboardKeyReleased(KEY_RIGHT, timestamp++); QCOMPARE(clientStepUserMovedResizedSpy.count(), 2); kwinApp()->platform()->keyboardKeyPressed(KEY_ESC, timestamp++); kwinApp()->platform()->keyboardKeyReleased(KEY_ESC, timestamp++); QVERIFY(!c->isMove()); } void LockScreenTest::testPointerShortcut() { using namespace KWayland::Client; QScopedPointer action(new QAction(nullptr)); QSignalSpy actionSpy(action.data(), &QAction::triggered); QVERIFY(actionSpy.isValid()); input()->registerPointerShortcut(Qt::MetaModifier, Qt::LeftButton, action.data()); // try to trigger the shortcut quint32 timestamp = 1; #define PERFORM(expectedCount) \ kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTMETA, timestamp++); \ PRESS; \ QCoreApplication::instance()->processEvents(); \ QCOMPARE(actionSpy.count(), expectedCount); \ RELEASE; \ kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTMETA, timestamp++); \ QCoreApplication::instance()->processEvents(); \ QCOMPARE(actionSpy.count(), expectedCount); PERFORM(1) // now the same thing with a locked screen LOCK PERFORM(1) // and as unlocked UNLOCK PERFORM(2) #undef PERFORM } void LockScreenTest::testAxisShortcut_data() { QTest::addColumn("direction"); QTest::addColumn("sign"); QTest::newRow("up") << Qt::Vertical << 1; QTest::newRow("down") << Qt::Vertical << -1; QTest::newRow("left") << Qt::Horizontal << 1; QTest::newRow("right") << Qt::Horizontal << -1; } void LockScreenTest::testAxisShortcut() { using namespace KWayland::Client; QScopedPointer action(new QAction(nullptr)); QSignalSpy actionSpy(action.data(), &QAction::triggered); QVERIFY(actionSpy.isValid()); QFETCH(Qt::Orientation, direction); QFETCH(int, sign); PointerAxisDirection axisDirection = PointerAxisUp; if (direction == Qt::Vertical) { axisDirection = sign > 0 ? PointerAxisUp : PointerAxisDown; } else { axisDirection = sign > 0 ? PointerAxisLeft : PointerAxisRight; } input()->registerAxisShortcut(Qt::MetaModifier, axisDirection, action.data()); // try to trigger the shortcut quint32 timestamp = 1; #define PERFORM(expectedCount) \ kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTMETA, timestamp++); \ if (direction == Qt::Vertical) \ kwinApp()->platform()->pointerAxisVertical(sign * 5.0, timestamp++); \ else \ kwinApp()->platform()->pointerAxisHorizontal(sign * 5.0, timestamp++); \ QCoreApplication::instance()->processEvents(); \ QCOMPARE(actionSpy.count(), expectedCount); \ kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTMETA, timestamp++); \ QCoreApplication::instance()->processEvents(); \ QCOMPARE(actionSpy.count(), expectedCount); PERFORM(1) // now the same thing with a locked screen LOCK PERFORM(1) // and as unlocked UNLOCK PERFORM(2) #undef PERFORM } void LockScreenTest::testKeyboardShortcut() { using namespace KWayland::Client; QScopedPointer action(new QAction(nullptr)); QSignalSpy actionSpy(action.data(), &QAction::triggered); QVERIFY(actionSpy.isValid()); action->setProperty("componentName", QStringLiteral(KWIN_NAME)); action->setObjectName("LockScreenTest::testKeyboardShortcut"); KGlobalAccel::self()->setDefaultShortcut(action.data(), QList{Qt::CTRL + Qt::META + Qt::ALT + Qt::Key_Space}); KGlobalAccel::self()->setShortcut(action.data(), QList{Qt::CTRL + Qt::META + Qt::ALT + Qt::Key_Space}, KGlobalAccel::NoAutoloading); // try to trigger the shortcut quint32 timestamp = 1; KEYPRESS(KEY_LEFTCTRL); KEYPRESS(KEY_LEFTMETA); KEYPRESS(KEY_LEFTALT); KEYPRESS(KEY_SPACE); QVERIFY(actionSpy.wait()); QCOMPARE(actionSpy.count(), 1); KEYRELEASE(KEY_SPACE); QVERIFY(!actionSpy.wait()); QCOMPARE(actionSpy.count(), 1); LOCK KEYPRESS(KEY_SPACE); QVERIFY(!actionSpy.wait()); QCOMPARE(actionSpy.count(), 1); KEYRELEASE(KEY_SPACE); QVERIFY(!actionSpy.wait()); QCOMPARE(actionSpy.count(), 1); UNLOCK KEYPRESS(KEY_SPACE); QVERIFY(actionSpy.wait()); QCOMPARE(actionSpy.count(), 2); KEYRELEASE(KEY_SPACE); QVERIFY(!actionSpy.wait()); QCOMPARE(actionSpy.count(), 2); KEYRELEASE(KEY_LEFTCTRL); KEYRELEASE(KEY_LEFTMETA); KEYRELEASE(KEY_LEFTALT); } void LockScreenTest::testTouch() { using namespace KWayland::Client; auto touch = m_seat->createTouch(m_seat); QVERIFY(touch); QVERIFY(touch->isValid()); AbstractClient *c = showWindow(); QVERIFY(c); QSignalSpy sequenceStartedSpy(touch, &Touch::sequenceStarted); QVERIFY(sequenceStartedSpy.isValid()); QSignalSpy cancelSpy(touch, &Touch::sequenceCanceled); QVERIFY(cancelSpy.isValid()); QSignalSpy pointRemovedSpy(touch, &Touch::pointRemoved); QVERIFY(pointRemovedSpy.isValid()); quint32 timestamp = 1; kwinApp()->platform()->touchDown(1, QPointF(25, 25), timestamp++); QVERIFY(sequenceStartedSpy.wait()); QCOMPARE(sequenceStartedSpy.count(), 1); LOCK QVERIFY(cancelSpy.wait()); kwinApp()->platform()->touchUp(1, timestamp++); QVERIFY(!pointRemovedSpy.wait(100)); kwinApp()->platform()->touchDown(1, QPointF(25, 25), timestamp++); kwinApp()->platform()->touchMotion(1, QPointF(26, 26), timestamp++); kwinApp()->platform()->touchUp(1, timestamp++); UNLOCK kwinApp()->platform()->touchDown(1, QPointF(25, 25), timestamp++); QVERIFY(sequenceStartedSpy.wait()); QCOMPARE(sequenceStartedSpy.count(), 2); kwinApp()->platform()->touchUp(1, timestamp++); QVERIFY(pointRemovedSpy.wait()); QCOMPARE(pointRemovedSpy.count(), 1); } } WAYLANDTEST_MAIN(KWin::LockScreenTest) #include "lockscreen.moc" diff --git a/autotests/integration/modifier_only_shortcut_test.cpp b/autotests/integration/modifier_only_shortcut_test.cpp index 00dc2d7d1..e88cbb0a5 100644 --- a/autotests/integration/modifier_only_shortcut_test.cpp +++ b/autotests/integration/modifier_only_shortcut_test.cpp @@ -1,386 +1,386 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2016 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 "kwin_wayland_test.h" #include "cursor.h" #include "input.h" #include "keyboard_input.h" #include "platform.h" #include "screens.h" #include "wayland_server.h" #include "workspace.h" #include #include #include using namespace KWin; using namespace KWayland::Client; static const QString s_socketName = QStringLiteral("wayland_test_kwin_modifier_only_shortcut-0"); static const QString s_serviceName = QStringLiteral("org.kde.KWin.Test.ModifierOnlyShortcut"); static const QString s_path = QStringLiteral("/Test"); class ModifierOnlyShortcutTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase(); void init(); void cleanup(); void testTrigger_data(); void testTrigger(); void testCapsLock(); void testGlobalShortcutsDisabled_data(); void testGlobalShortcutsDisabled(); }; class Target : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.KWin.Test.ModifierOnlyShortcut") public: Target(); - virtual ~Target(); + ~Target() override; public Q_SLOTS: Q_SCRIPTABLE void shortcut(); Q_SIGNALS: void shortcutTriggered(); }; Target::Target() : QObject() { QDBusConnection::sessionBus().registerService(s_serviceName); QDBusConnection::sessionBus().registerObject(s_path, s_serviceName, this, QDBusConnection::ExportScriptableSlots); } Target::~Target() { QDBusConnection::sessionBus().unregisterObject(s_path); QDBusConnection::sessionBus().unregisterService(s_serviceName); } void Target::shortcut() { emit shortcutTriggered(); } void ModifierOnlyShortcutTest::initTestCase() { QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); QVERIFY(workspaceCreatedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig)); qputenv("KWIN_XKB_DEFAULT_KEYMAP", "1"); qputenv("XKB_DEFAULT_RULES", "evdev"); kwinApp()->start(); QVERIFY(workspaceCreatedSpy.wait()); waylandServer()->initWorkspace(); } void ModifierOnlyShortcutTest::init() { screens()->setCurrent(0); KWin::Cursor::setPos(QPoint(640, 512)); } void ModifierOnlyShortcutTest::cleanup() { } void ModifierOnlyShortcutTest::testTrigger_data() { QTest::addColumn("metaConfig"); QTest::addColumn("altConfig"); QTest::addColumn("controlConfig"); QTest::addColumn("shiftConfig"); QTest::addColumn("modifier"); QTest::addColumn>("nonTriggeringMods"); const QStringList trigger = QStringList{s_serviceName, s_path, s_serviceName, QStringLiteral("shortcut")}; const QStringList e = QStringList(); QTest::newRow("leftMeta") << trigger << e << e << e << KEY_LEFTMETA << QList{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTSHIFT, KEY_RIGHTSHIFT}; QTest::newRow("rightMeta") << trigger << e << e << e << KEY_RIGHTMETA << QList{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTSHIFT, KEY_RIGHTSHIFT}; QTest::newRow("leftAlt") << e << trigger << e << e << KEY_LEFTALT << QList{KEY_LEFTMETA, KEY_RIGHTMETA, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTSHIFT, KEY_RIGHTSHIFT}; QTest::newRow("rightAlt") << e << trigger << e << e << KEY_RIGHTALT << QList{KEY_LEFTMETA, KEY_RIGHTMETA, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTSHIFT, KEY_RIGHTSHIFT}; QTest::newRow("leftControl") << e << e << trigger << e << KEY_LEFTCTRL << QList{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_LEFTSHIFT, KEY_RIGHTSHIFT}; QTest::newRow("rightControl") << e << e << trigger << e << KEY_RIGHTCTRL << QList{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_LEFTSHIFT, KEY_RIGHTSHIFT}; QTest::newRow("leftShift") << e << e << e << trigger << KEY_LEFTSHIFT << QList{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTMETA, KEY_RIGHTMETA}; QTest::newRow("rightShift") << e << e << e << trigger <{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTMETA, KEY_RIGHTMETA}; } void ModifierOnlyShortcutTest::testTrigger() { // this test verifies that modifier only shortcut triggers correctly Target target; QSignalSpy triggeredSpy(&target, &Target::shortcutTriggered); QVERIFY(triggeredSpy.isValid()); KConfigGroup group = kwinApp()->config()->group("ModifierOnlyShortcuts"); QFETCH(QStringList, metaConfig); QFETCH(QStringList, altConfig); QFETCH(QStringList, shiftConfig); QFETCH(QStringList, controlConfig); group.writeEntry("Meta", metaConfig); group.writeEntry("Alt", altConfig); group.writeEntry("Shift", shiftConfig); group.writeEntry("Control", controlConfig); group.sync(); workspace()->slotReconfigure(); // configured shortcut should trigger quint32 timestamp = 1; QFETCH(int, modifier); kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++); kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++); QCOMPARE(triggeredSpy.count(), 1); // the other shortcuts should not trigger QFETCH(QList, nonTriggeringMods); for (auto it = nonTriggeringMods.constBegin(), end = nonTriggeringMods.constEnd(); it != end; it++) { kwinApp()->platform()->keyboardKeyPressed(*it, timestamp++); kwinApp()->platform()->keyboardKeyReleased(*it, timestamp++); QCOMPARE(triggeredSpy.count(), 1); } // try configured again kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++); kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++); QCOMPARE(triggeredSpy.count(), 2); // click another key while modifier is held kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++); kwinApp()->platform()->keyboardKeyPressed(KEY_A, timestamp++); kwinApp()->platform()->keyboardKeyReleased(KEY_A, timestamp++); kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++); QCOMPARE(triggeredSpy.count(), 2); // release other key after modifier release kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++); kwinApp()->platform()->keyboardKeyPressed(KEY_A, timestamp++); kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++); kwinApp()->platform()->keyboardKeyReleased(KEY_A, timestamp++); QCOMPARE(triggeredSpy.count(), 2); // press key before pressing modifier kwinApp()->platform()->keyboardKeyPressed(KEY_A, timestamp++); kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++); kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++); kwinApp()->platform()->keyboardKeyReleased(KEY_A, timestamp++); QCOMPARE(triggeredSpy.count(), 2); // mouse button pressed before clicking modifier kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); QCOMPARE(input()->qtButtonStates(), Qt::LeftButton); kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++); kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++); kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); QCOMPARE(input()->qtButtonStates(), Qt::NoButton); QCOMPARE(triggeredSpy.count(), 2); // mouse button press before mod press, release before mod release kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); QCOMPARE(input()->qtButtonStates(), Qt::LeftButton); kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++); kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++); QCOMPARE(input()->qtButtonStates(), Qt::NoButton); QCOMPARE(triggeredSpy.count(), 2); // mouse button click while mod is pressed kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++); kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); QCOMPARE(input()->qtButtonStates(), Qt::LeftButton); kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++); QCOMPARE(input()->qtButtonStates(), Qt::NoButton); QCOMPARE(triggeredSpy.count(), 2); // scroll while mod is pressed kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++); kwinApp()->platform()->pointerAxisVertical(5.0, timestamp++); kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++); QCOMPARE(triggeredSpy.count(), 2); // same for horizontal kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++); kwinApp()->platform()->pointerAxisHorizontal(5.0, timestamp++); kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++); QCOMPARE(triggeredSpy.count(), 2); // now try to lock the screen while modifier key is pressed kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++); QVERIFY(Test::lockScreen()); kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++); QCOMPARE(triggeredSpy.count(), 2); // now trigger while screen is locked, should also not work kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++); kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++); QCOMPARE(triggeredSpy.count(), 2); QVERIFY(Test::unlockScreen()); } void ModifierOnlyShortcutTest::testCapsLock() { // this test verifies that Capslock does not trigger the shift shortcut // but other shortcuts still trigger even when Capslock is on Target target; QSignalSpy triggeredSpy(&target, &Target::shortcutTriggered); QVERIFY(triggeredSpy.isValid()); KConfigGroup group = kwinApp()->config()->group("ModifierOnlyShortcuts"); group.writeEntry("Meta", QStringList()); group.writeEntry("Alt", QStringList()); group.writeEntry("Shift", QStringList{s_serviceName, s_path, s_serviceName, QStringLiteral("shortcut")}); group.writeEntry("Control", QStringList()); group.sync(); workspace()->slotReconfigure(); // first test that the normal shortcut triggers quint32 timestamp = 1; const int modifier = KEY_LEFTSHIFT; kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++); kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++); QCOMPARE(triggeredSpy.count(), 1); // now capslock kwinApp()->platform()->keyboardKeyPressed(KEY_CAPSLOCK, timestamp++); kwinApp()->platform()->keyboardKeyReleased(KEY_CAPSLOCK, timestamp++); QCOMPARE(input()->keyboardModifiers(), Qt::ShiftModifier); QCOMPARE(triggeredSpy.count(), 1); // currently caps lock is on // shift still triggers kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++); kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++); QCOMPARE(input()->keyboardModifiers(), Qt::ShiftModifier); QCOMPARE(triggeredSpy.count(), 2); // meta should also trigger group.writeEntry("Meta", QStringList{s_serviceName, s_path, s_serviceName, QStringLiteral("shortcut")}); group.writeEntry("Alt", QStringList()); group.writeEntry("Shift", QStringList{}); group.writeEntry("Control", QStringList()); group.sync(); workspace()->slotReconfigure(); kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTMETA, timestamp++); QCOMPARE(input()->keyboardModifiers(), Qt::ShiftModifier | Qt::MetaModifier); QCOMPARE(input()->keyboard()->xkb()->modifiersRelevantForGlobalShortcuts(), Qt::MetaModifier); kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTMETA, timestamp++); QCOMPARE(triggeredSpy.count(), 3); // set back to shift to ensure we don't trigger with capslock group.writeEntry("Meta", QStringList()); group.writeEntry("Alt", QStringList()); group.writeEntry("Shift", QStringList{s_serviceName, s_path, s_serviceName, QStringLiteral("shortcut")}); group.writeEntry("Control", QStringList()); group.sync(); workspace()->slotReconfigure(); // release caps lock kwinApp()->platform()->keyboardKeyPressed(KEY_CAPSLOCK, timestamp++); kwinApp()->platform()->keyboardKeyReleased(KEY_CAPSLOCK, timestamp++); QCOMPARE(input()->keyboardModifiers(), Qt::NoModifier); QCOMPARE(triggeredSpy.count(), 3); } void ModifierOnlyShortcutTest::testGlobalShortcutsDisabled_data() { QTest::addColumn("metaConfig"); QTest::addColumn("altConfig"); QTest::addColumn("controlConfig"); QTest::addColumn("shiftConfig"); QTest::addColumn("modifier"); const QStringList trigger = QStringList{s_serviceName, s_path, s_serviceName, QStringLiteral("shortcut")}; const QStringList e = QStringList(); QTest::newRow("leftMeta") << trigger << e << e << e << KEY_LEFTMETA; QTest::newRow("rightMeta") << trigger << e << e << e << KEY_RIGHTMETA; QTest::newRow("leftAlt") << e << trigger << e << e << KEY_LEFTALT; QTest::newRow("rightAlt") << e << trigger << e << e << KEY_RIGHTALT; QTest::newRow("leftControl") << e << e << trigger << e << KEY_LEFTCTRL; QTest::newRow("rightControl") << e << e << trigger << e << KEY_RIGHTCTRL; QTest::newRow("leftShift") << e << e << e << trigger << KEY_LEFTSHIFT; QTest::newRow("rightShift") << e << e << e << trigger <config()->group("ModifierOnlyShortcuts"); QFETCH(QStringList, metaConfig); QFETCH(QStringList, altConfig); QFETCH(QStringList, shiftConfig); QFETCH(QStringList, controlConfig); group.writeEntry("Meta", metaConfig); group.writeEntry("Alt", altConfig); group.writeEntry("Shift", shiftConfig); group.writeEntry("Control", controlConfig); group.sync(); workspace()->slotReconfigure(); // trigger once to verify the shortcut works quint32 timestamp = 1; QFETCH(int, modifier); QVERIFY(!workspace()->globalShortcutsDisabled()); kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++); kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++); QCOMPARE(triggeredSpy.count(), 1); triggeredSpy.clear(); // now disable global shortcuts workspace()->disableGlobalShortcutsForClient(true); QVERIFY(workspace()->globalShortcutsDisabled()); // Should not get triggered kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++); kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++); QCOMPARE(triggeredSpy.count(), 0); triggeredSpy.clear(); // enable again workspace()->disableGlobalShortcutsForClient(false); QVERIFY(!workspace()->globalShortcutsDisabled()); // should get triggered again kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++); kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++); QCOMPARE(triggeredSpy.count(), 1); } WAYLANDTEST_MAIN(ModifierOnlyShortcutTest) #include "modifier_only_shortcut_test.moc" diff --git a/autotests/integration/no_global_shortcuts_test.cpp b/autotests/integration/no_global_shortcuts_test.cpp index 10d0a4f6e..bcf588660 100644 --- a/autotests/integration/no_global_shortcuts_test.cpp +++ b/autotests/integration/no_global_shortcuts_test.cpp @@ -1,285 +1,285 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2018 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 "kwin_wayland_test.h" #include "cursor.h" #include "input.h" #include "keyboard_input.h" #include "platform.h" #include "screenedge.h" #include "screens.h" #include "wayland_server.h" #include "workspace.h" #include #include #include #include using namespace KWin; using namespace KWayland::Client; static const QString s_socketName = QStringLiteral("wayland_test_kwin_no_global_shortcuts-0"); static const QString s_serviceName = QStringLiteral("org.kde.KWin.Test.ModifierOnlyShortcut"); static const QString s_path = QStringLiteral("/Test"); Q_DECLARE_METATYPE(KWin::ElectricBorder) /** * This test verifies the NoGlobalShortcuts initialization flag **/ class NoGlobalShortcutsTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase(); void init(); void cleanup(); void testTrigger_data(); void testTrigger(); void testKGlobalAccel(); void testPointerShortcut(); void testAxisShortcut_data(); void testAxisShortcut(); void testScreenEdge(); }; class Target : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.KWin.Test.ModifierOnlyShortcut") public: Target(); - virtual ~Target(); + ~Target() override; public Q_SLOTS: Q_SCRIPTABLE void shortcut(); Q_SIGNALS: void shortcutTriggered(); }; Target::Target() : QObject() { QDBusConnection::sessionBus().registerService(s_serviceName); QDBusConnection::sessionBus().registerObject(s_path, s_serviceName, this, QDBusConnection::ExportScriptableSlots); } Target::~Target() { QDBusConnection::sessionBus().unregisterObject(s_path); QDBusConnection::sessionBus().unregisterService(s_serviceName); } void Target::shortcut() { emit shortcutTriggered(); } void NoGlobalShortcutsTest::initTestCase() { qRegisterMetaType("ElectricBorder"); QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); QVERIFY(workspaceCreatedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit(), KWin::WaylandServer::InitalizationFlag::NoGlobalShortcuts)); kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig)); qputenv("KWIN_XKB_DEFAULT_KEYMAP", "1"); qputenv("XKB_DEFAULT_RULES", "evdev"); kwinApp()->start(); QVERIFY(workspaceCreatedSpy.wait()); waylandServer()->initWorkspace(); } void NoGlobalShortcutsTest::init() { screens()->setCurrent(0); KWin::Cursor::setPos(QPoint(640, 512)); } void NoGlobalShortcutsTest::cleanup() { } void NoGlobalShortcutsTest::testTrigger_data() { QTest::addColumn("metaConfig"); QTest::addColumn("altConfig"); QTest::addColumn("controlConfig"); QTest::addColumn("shiftConfig"); QTest::addColumn("modifier"); QTest::addColumn>("nonTriggeringMods"); const QStringList trigger = QStringList{s_serviceName, s_path, s_serviceName, QStringLiteral("shortcut")}; const QStringList e = QStringList(); QTest::newRow("leftMeta") << trigger << e << e << e << KEY_LEFTMETA << QList{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTSHIFT, KEY_RIGHTSHIFT}; QTest::newRow("rightMeta") << trigger << e << e << e << KEY_RIGHTMETA << QList{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTSHIFT, KEY_RIGHTSHIFT}; QTest::newRow("leftAlt") << e << trigger << e << e << KEY_LEFTALT << QList{KEY_LEFTMETA, KEY_RIGHTMETA, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTSHIFT, KEY_RIGHTSHIFT}; QTest::newRow("rightAlt") << e << trigger << e << e << KEY_RIGHTALT << QList{KEY_LEFTMETA, KEY_RIGHTMETA, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTSHIFT, KEY_RIGHTSHIFT}; QTest::newRow("leftControl") << e << e << trigger << e << KEY_LEFTCTRL << QList{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_LEFTSHIFT, KEY_RIGHTSHIFT}; QTest::newRow("rightControl") << e << e << trigger << e << KEY_RIGHTCTRL << QList{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTMETA, KEY_RIGHTMETA, KEY_LEFTSHIFT, KEY_RIGHTSHIFT}; QTest::newRow("leftShift") << e << e << e << trigger << KEY_LEFTSHIFT << QList{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTMETA, KEY_RIGHTMETA}; QTest::newRow("rightShift") << e << e << e << trigger <{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTMETA, KEY_RIGHTMETA}; } void NoGlobalShortcutsTest::testTrigger() { // test based on ModifierOnlyShortcutTest::testTrigger Target target; QSignalSpy triggeredSpy(&target, &Target::shortcutTriggered); QVERIFY(triggeredSpy.isValid()); KConfigGroup group = kwinApp()->config()->group("ModifierOnlyShortcuts"); QFETCH(QStringList, metaConfig); QFETCH(QStringList, altConfig); QFETCH(QStringList, shiftConfig); QFETCH(QStringList, controlConfig); group.writeEntry("Meta", metaConfig); group.writeEntry("Alt", altConfig); group.writeEntry("Shift", shiftConfig); group.writeEntry("Control", controlConfig); group.sync(); workspace()->slotReconfigure(); // configured shortcut should trigger quint32 timestamp = 1; QFETCH(int, modifier); kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++); kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++); QCOMPARE(triggeredSpy.count(), 0); // the other shortcuts should not trigger QFETCH(QList, nonTriggeringMods); for (auto it = nonTriggeringMods.constBegin(), end = nonTriggeringMods.constEnd(); it != end; it++) { kwinApp()->platform()->keyboardKeyPressed(*it, timestamp++); kwinApp()->platform()->keyboardKeyReleased(*it, timestamp++); QCOMPARE(triggeredSpy.count(), 0); } } void NoGlobalShortcutsTest::testKGlobalAccel() { QScopedPointer action(new QAction(nullptr)); action->setProperty("componentName", QStringLiteral(KWIN_NAME)); action->setObjectName(QStringLiteral("globalshortcuts-test-meta-shift-w")); QSignalSpy triggeredSpy(action.data(), &QAction::triggered); QVERIFY(triggeredSpy.isValid()); KGlobalAccel::self()->setShortcut(action.data(), QList{Qt::META + Qt::SHIFT + Qt::Key_W}, KGlobalAccel::NoAutoloading); input()->registerShortcut(Qt::META + Qt::SHIFT + Qt::Key_W, action.data()); // press meta+shift+w quint32 timestamp = 0; kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTMETA, timestamp++); QCOMPARE(input()->keyboardModifiers(), Qt::MetaModifier); kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTSHIFT, timestamp++); QCOMPARE(input()->keyboardModifiers(), Qt::ShiftModifier | Qt::MetaModifier); kwinApp()->platform()->keyboardKeyPressed(KEY_W, timestamp++); kwinApp()->platform()->keyboardKeyReleased(KEY_W, timestamp++); // release meta+shift kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTSHIFT, timestamp++); kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTMETA, timestamp++); QVERIFY(!triggeredSpy.wait()); QCOMPARE(triggeredSpy.count(), 0); } void NoGlobalShortcutsTest::testPointerShortcut() { // based on LockScreenTest::testPointerShortcut QScopedPointer action(new QAction(nullptr)); QSignalSpy actionSpy(action.data(), &QAction::triggered); QVERIFY(actionSpy.isValid()); input()->registerPointerShortcut(Qt::MetaModifier, Qt::LeftButton, action.data()); // try to trigger the shortcut quint32 timestamp = 1; kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTMETA, timestamp++); kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); QCoreApplication::instance()->processEvents(); QCOMPARE(actionSpy.count(), 0); kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTMETA, timestamp++); QCoreApplication::instance()->processEvents(); QCOMPARE(actionSpy.count(), 0); } void NoGlobalShortcutsTest::testAxisShortcut_data() { QTest::addColumn("direction"); QTest::addColumn("sign"); QTest::newRow("up") << Qt::Vertical << 1; QTest::newRow("down") << Qt::Vertical << -1; QTest::newRow("left") << Qt::Horizontal << 1; QTest::newRow("right") << Qt::Horizontal << -1; } void NoGlobalShortcutsTest::testAxisShortcut() { // based on LockScreenTest::testAxisShortcut QScopedPointer action(new QAction(nullptr)); QSignalSpy actionSpy(action.data(), &QAction::triggered); QVERIFY(actionSpy.isValid()); QFETCH(Qt::Orientation, direction); QFETCH(int, sign); PointerAxisDirection axisDirection = PointerAxisUp; if (direction == Qt::Vertical) { axisDirection = sign > 0 ? PointerAxisUp : PointerAxisDown; } else { axisDirection = sign > 0 ? PointerAxisLeft : PointerAxisRight; } input()->registerAxisShortcut(Qt::MetaModifier, axisDirection, action.data()); // try to trigger the shortcut quint32 timestamp = 1; kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTMETA, timestamp++); if (direction == Qt::Vertical) kwinApp()->platform()->pointerAxisVertical(sign * 5.0, timestamp++); else kwinApp()->platform()->pointerAxisHorizontal(sign * 5.0, timestamp++); QCoreApplication::instance()->processEvents(); QCOMPARE(actionSpy.count(), 0); kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTMETA, timestamp++); QCoreApplication::instance()->processEvents(); QCOMPARE(actionSpy.count(), 0); } void NoGlobalShortcutsTest::testScreenEdge() { // based on LockScreenTest::testScreenEdge QSignalSpy screenEdgeSpy(ScreenEdges::self(), &ScreenEdges::approaching); QVERIFY(screenEdgeSpy.isValid()); QCOMPARE(screenEdgeSpy.count(), 0); quint32 timestamp = 1; kwinApp()->platform()->pointerMotion({5, 5}, timestamp++); QCOMPARE(screenEdgeSpy.count(), 0); } WAYLANDTEST_MAIN(NoGlobalShortcutsTest) #include "no_global_shortcuts_test.moc" diff --git a/autotests/integration/plasmawindow_test.cpp b/autotests/integration/plasmawindow_test.cpp index 74e529c2e..60129d825 100644 --- a/autotests/integration/plasmawindow_test.cpp +++ b/autotests/integration/plasmawindow_test.cpp @@ -1,364 +1,364 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2016 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 "kwin_wayland_test.h" #include "platform.h" #include "client.h" #include "cursor.h" #include "screenedge.h" #include "screens.h" #include "wayland_server.h" #include "workspace.h" #include "shell_client.h" #include #include #include #include #include #include //screenlocker #include #include #include #include #include using namespace KWayland::Client; namespace KWin { static const QString s_socketName = QStringLiteral("wayland_test_kwin_plasma-window-0"); class PlasmaWindowTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase(); void init(); void cleanup(); void testCreateDestroyX11PlasmaWindow(); void testInternalWindowNoPlasmaWindow(); void testPopupWindowNoPlasmaWindow(); void testLockScreenNoPlasmaWindow(); void testDestroyedButNotUnmapped(); private: PlasmaWindowManagement *m_windowManagement = nullptr; KWayland::Client::Compositor *m_compositor = nullptr; Shell *m_shell = nullptr; }; void PlasmaWindowTest::initTestCase() { qRegisterMetaType(); qRegisterMetaType(); QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); QVERIFY(workspaceCreatedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); kwinApp()->start(); QVERIFY(workspaceCreatedSpy.wait()); QCOMPARE(screens()->count(), 2); QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); setenv("QT_QPA_PLATFORM", "wayland", true); setenv("QMLSCENE_DEVICE", "softwarecontext", true); waylandServer()->initWorkspace(); } void PlasmaWindowTest::init() { QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::WindowManagement)); m_windowManagement = Test::waylandWindowManagement(); m_compositor = Test::waylandCompositor(); m_shell = Test::waylandShell(); screens()->setCurrent(0); Cursor::setPos(QPoint(640, 512)); } void PlasmaWindowTest::cleanup() { Test::destroyWaylandConnection(); } void PlasmaWindowTest::testCreateDestroyX11PlasmaWindow() { // this test verifies that a PlasmaWindow gets unmapped on Client side when an X11 client is destroyed QSignalSpy plasmaWindowCreatedSpy(m_windowManagement, &PlasmaWindowManagement::windowCreated); QVERIFY(plasmaWindowCreatedSpy.isValid()); // create an xcb window struct XcbConnectionDeleter { static inline void cleanup(xcb_connection_t *pointer) { xcb_disconnect(pointer); } }; QScopedPointer c(xcb_connect(nullptr, nullptr)); QVERIFY(!xcb_connection_has_error(c.data())); const QRect windowGeometry(0, 0, 100, 200); xcb_window_t w = xcb_generate_id(c.data()); xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, w, rootWindow(), windowGeometry.x(), windowGeometry.y(), windowGeometry.width(), windowGeometry.height(), 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr); xcb_size_hints_t hints; memset(&hints, 0, sizeof(hints)); xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y()); xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height()); xcb_icccm_set_wm_normal_hints(c.data(), w, &hints); xcb_map_window(c.data(), w); xcb_flush(c.data()); // we should get a client for it QSignalSpy windowCreatedSpy(workspace(), &Workspace::clientAdded); QVERIFY(windowCreatedSpy.isValid()); QVERIFY(windowCreatedSpy.wait()); Client *client = windowCreatedSpy.first().first().value(); QVERIFY(client); QCOMPARE(client->window(), w); QVERIFY(client->isDecorated()); QVERIFY(client->isActive()); // verify that it gets the keyboard focus if (!client->surface()) { // we don't have a surface yet, so focused keyboard surface if set is not ours QVERIFY(!waylandServer()->seat()->focusedKeyboardSurface()); QSignalSpy surfaceChangedSpy(client, &Toplevel::surfaceChanged); QVERIFY(surfaceChangedSpy.isValid()); QVERIFY(surfaceChangedSpy.wait()); } QVERIFY(client->surface()); QCOMPARE(waylandServer()->seat()->focusedKeyboardSurface(), client->surface()); // now that should also give it to us on client side QVERIFY(plasmaWindowCreatedSpy.wait()); QCOMPARE(plasmaWindowCreatedSpy.count(), 1); QCOMPARE(m_windowManagement->windows().count(), 1); auto pw = m_windowManagement->windows().first(); QCOMPARE(pw->geometry(), client->geometry()); QSignalSpy geometryChangedSpy(pw, &PlasmaWindow::geometryChanged); QVERIFY(geometryChangedSpy.isValid()); QSignalSpy unmappedSpy(m_windowManagement->windows().first(), &PlasmaWindow::unmapped); QVERIFY(unmappedSpy.isValid()); QSignalSpy destroyedSpy(m_windowManagement->windows().first(), &QObject::destroyed); QVERIFY(destroyedSpy.isValid()); // now shade the window const QRect geoBeforeShade = client->geometry(); QVERIFY(geoBeforeShade.isValid()); QVERIFY(!geoBeforeShade.isEmpty()); workspace()->slotWindowShade(); QVERIFY(client->isShade()); QVERIFY(client->geometry() != geoBeforeShade); QVERIFY(geometryChangedSpy.wait()); QCOMPARE(pw->geometry(), client->geometry()); // and unshade again workspace()->slotWindowShade(); QVERIFY(!client->isShade()); QCOMPARE(client->geometry(), geoBeforeShade); QVERIFY(geometryChangedSpy.wait()); QCOMPARE(pw->geometry(), geoBeforeShade); // and destroy the window again xcb_unmap_window(c.data(), w); xcb_flush(c.data()); QSignalSpy windowClosedSpy(client, &Client::windowClosed); QVERIFY(windowClosedSpy.isValid()); QVERIFY(windowClosedSpy.wait()); xcb_destroy_window(c.data(), w); c.reset(); QVERIFY(unmappedSpy.wait()); QCOMPARE(unmappedSpy.count(), 1); QVERIFY(destroyedSpy.wait()); } class HelperWindow : public QRasterWindow { Q_OBJECT public: HelperWindow(); - ~HelperWindow(); + ~HelperWindow() override; protected: void paintEvent(QPaintEvent *event) override; }; HelperWindow::HelperWindow() : QRasterWindow(nullptr) { } HelperWindow::~HelperWindow() = default; void HelperWindow::paintEvent(QPaintEvent *event) { Q_UNUSED(event) QPainter p(this); p.fillRect(0, 0, width(), height(), Qt::red); } void PlasmaWindowTest::testInternalWindowNoPlasmaWindow() { // this test verifies that an internal window is not added as a PlasmaWindow to the client QSignalSpy plasmaWindowCreatedSpy(m_windowManagement, &PlasmaWindowManagement::windowCreated); QVERIFY(plasmaWindowCreatedSpy.isValid()); HelperWindow win; win.setGeometry(0, 0, 100, 100); win.show(); QVERIFY(!plasmaWindowCreatedSpy.wait()); } void PlasmaWindowTest::testPopupWindowNoPlasmaWindow() { // this test verifies that for a popup window no PlasmaWindow is sent to the client QSignalSpy plasmaWindowCreatedSpy(m_windowManagement, &PlasmaWindowManagement::windowCreated); QVERIFY(plasmaWindowCreatedSpy.isValid()); // first create the parent window QScopedPointer parentSurface(Test::createSurface()); QScopedPointer parentShellSurface(Test::createShellSurface(parentSurface.data())); // map that window Test::render(parentSurface.data(), QSize(100, 50), Qt::blue); // this should create a plasma window QVERIFY(plasmaWindowCreatedSpy.wait()); // now let's create a popup window for it QScopedPointer popupSurface(Test::createSurface()); QScopedPointer popupShellSurface(Test::createShellSurface(popupSurface.data())); popupShellSurface->setTransient(parentSurface.data(), QPoint(0, 0), ShellSurface::TransientFlag::NoFocus); // let's map it Test::render(popupSurface.data(), QSize(100, 50), Qt::blue); // this should not create a plasma window QVERIFY(!plasmaWindowCreatedSpy.wait()); // now the same with an already mapped surface when we create the shell surface QScopedPointer popup2Surface(Test::createSurface()); Test::render(popup2Surface.data(), QSize(100, 50), Qt::blue); QScopedPointer popup2ShellSurface(Test::createShellSurface(popup2Surface.data())); popup2ShellSurface->setTransient(popupSurface.data(), QPoint(0, 0), ShellSurface::TransientFlag::NoFocus); // this should not create a plasma window QEXPECT_FAIL("", "The call to setTransient comes to late the window is already mapped then", Continue); QVERIFY(!plasmaWindowCreatedSpy.wait()); // let's destroy the windows QCOMPARE(waylandServer()->clients().count(), 3); QSignalSpy destroyed1Spy(waylandServer()->clients().last(), &QObject::destroyed); QVERIFY(destroyed1Spy.isValid()); popup2Surface->attachBuffer(Buffer::Ptr()); popup2Surface->commit(Surface::CommitFlag::None); popup2ShellSurface.reset(); popup2Surface.reset(); QVERIFY(destroyed1Spy.wait()); QCOMPARE(waylandServer()->clients().count(), 2); QSignalSpy destroyed2Spy(waylandServer()->clients().last(), &QObject::destroyed); QVERIFY(destroyed2Spy.isValid()); popupSurface->attachBuffer(Buffer::Ptr()); popupSurface->commit(Surface::CommitFlag::None); popupShellSurface.reset(); popupSurface.reset(); QVERIFY(destroyed2Spy.wait()); QCOMPARE(waylandServer()->clients().count(), 1); QSignalSpy destroyed3Spy(waylandServer()->clients().last(), &QObject::destroyed); QVERIFY(destroyed3Spy.isValid()); parentSurface->attachBuffer(Buffer::Ptr()); parentSurface->commit(Surface::CommitFlag::None); parentShellSurface.reset(); parentSurface.reset(); QVERIFY(destroyed3Spy.wait()); } void PlasmaWindowTest::testLockScreenNoPlasmaWindow() { // this test verifies that lock screen windows are not exposed to PlasmaWindow QSignalSpy plasmaWindowCreatedSpy(m_windowManagement, &PlasmaWindowManagement::windowCreated); QVERIFY(plasmaWindowCreatedSpy.isValid()); // this time we use a QSignalSpy on ShellClient as it'a a little bit more complex setup QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); // lock ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate); QVERIFY(clientAddedSpy.wait()); QVERIFY(clientAddedSpy.first().first().value()->isLockScreen()); // should not be sent to the client QVERIFY(plasmaWindowCreatedSpy.isEmpty()); QVERIFY(!plasmaWindowCreatedSpy.wait()); // fake unlock QSignalSpy lockStateChangedSpy(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged); QVERIFY(lockStateChangedSpy.isValid()); const auto children = ScreenLocker::KSldApp::self()->children(); for (auto it = children.begin(); it != children.end(); ++it) { if (qstrcmp((*it)->metaObject()->className(), "LogindIntegration") != 0) { continue; } QMetaObject::invokeMethod(*it, "requestUnlock"); break; } QVERIFY(lockStateChangedSpy.wait()); QVERIFY(!waylandServer()->isScreenLocked()); } void PlasmaWindowTest::testDestroyedButNotUnmapped() { // this test verifies that also when a ShellSurface gets destroyed without a prior unmap // the PlasmaWindow gets destroyed on Client side QSignalSpy plasmaWindowCreatedSpy(m_windowManagement, &PlasmaWindowManagement::windowCreated); QVERIFY(plasmaWindowCreatedSpy.isValid()); // first create the parent window QScopedPointer parentSurface(Test::createSurface()); QScopedPointer parentShellSurface(Test::createShellSurface(parentSurface.data())); // map that window Test::render(parentSurface.data(), QSize(100, 50), Qt::blue); // this should create a plasma window QVERIFY(plasmaWindowCreatedSpy.wait()); QCOMPARE(plasmaWindowCreatedSpy.count(), 1); auto window = plasmaWindowCreatedSpy.first().first().value(); QVERIFY(window); QSignalSpy destroyedSpy(window, &QObject::destroyed); QVERIFY(destroyedSpy.isValid()); // now destroy without an unmap parentShellSurface.reset(); parentSurface.reset(); QVERIFY(destroyedSpy.wait()); } } WAYLANDTEST_MAIN(KWin::PlasmaWindowTest) #include "plasmawindow_test.moc" diff --git a/autotests/integration/pointer_input.cpp b/autotests/integration/pointer_input.cpp index 1e7a45ac4..6023afdb7 100644 --- a/autotests/integration/pointer_input.cpp +++ b/autotests/integration/pointer_input.cpp @@ -1,1604 +1,1604 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2016 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 "kwin_wayland_test.h" #include "platform.h" #include "abstract_client.h" #include "cursor.h" #include "deleted.h" #include "effects.h" #include "pointer_input.h" #include "options.h" #include "screenedge.h" #include "screens.h" #include "wayland_cursor_theme.h" #include "wayland_server.h" #include "workspace.h" #include "shell_client.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace KWin { template PlatformCursorImage loadReferenceThemeCursor(const T &shape) { if (!waylandServer()->internalShmPool()) { return PlatformCursorImage(); } QScopedPointer cursorTheme; cursorTheme.reset(new WaylandCursorTheme(waylandServer()->internalShmPool())); wl_cursor_image *cursor = cursorTheme->get(shape); if (!cursor) { return PlatformCursorImage(); } wl_buffer *b = wl_cursor_image_get_buffer(cursor); if (!b) { return PlatformCursorImage(); } waylandServer()->internalClientConection()->flush(); waylandServer()->dispatch(); auto buffer = KWayland::Server::BufferInterface::get( waylandServer()->internalConnection()->getResource( KWayland::Client::Buffer::getId(b))); if (!buffer) { return PlatformCursorImage{}; } const qreal scale = screens()->maxScale(); QImage image = buffer->data().copy(); image.setDevicePixelRatio(scale); const QPoint hotSpot( qRound(cursor->hotspot_x / scale), qRound(cursor->hotspot_y / scale) ); return PlatformCursorImage(image, hotSpot); } static const QString s_socketName = QStringLiteral("wayland_test_kwin_pointer_input-0"); class PointerInputTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase(); void init(); void cleanup(); void testWarpingUpdatesFocus(); void testWarpingGeneratesPointerMotion(); void testWarpingDuringFilter(); void testUpdateFocusAfterScreenChange(); void testModifierClickUnrestrictedMove_data(); void testModifierClickUnrestrictedMove(); void testModifierClickUnrestrictedMoveGlobalShortcutsDisabled(); void testModifierScrollOpacity_data(); void testModifierScrollOpacity(); void testModifierScrollOpacityGlobalShortcutsDisabled(); void testScrollAction(); void testFocusFollowsMouse(); void testMouseActionInactiveWindow_data(); void testMouseActionInactiveWindow(); void testMouseActionActiveWindow_data(); void testMouseActionActiveWindow(); void testCursorImage(); void testEffectOverrideCursorImage(); void testPopup(); void testDecoCancelsPopup(); void testWindowUnderCursorWhileButtonPressed(); void testConfineToScreenGeometry_data(); void testConfineToScreenGeometry(); void testResizeCursor_data(); void testResizeCursor(); void testMoveCursor(); private: void render(KWayland::Client::Surface *surface, const QSize &size = QSize(100, 50)); KWayland::Client::Compositor *m_compositor = nullptr; KWayland::Client::Seat *m_seat = nullptr; KWayland::Client::Shell *m_shell = nullptr; }; void PointerInputTest::initTestCase() { qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); QVERIFY(workspaceCreatedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig)); if (!QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("icons/DMZ-White/index.theme")).isEmpty()) { qputenv("XCURSOR_THEME", QByteArrayLiteral("DMZ-White")); } else { // might be vanilla-dmz (e.g. Arch, FreeBSD) qputenv("XCURSOR_THEME", QByteArrayLiteral("Vanilla-DMZ")); } qputenv("XCURSOR_SIZE", QByteArrayLiteral("24")); qputenv("XKB_DEFAULT_RULES", "evdev"); kwinApp()->start(); QVERIFY(workspaceCreatedSpy.wait()); QCOMPARE(screens()->count(), 2); QCOMPARE(screens()->geometry(0), QRect(0, 0, 1280, 1024)); QCOMPARE(screens()->geometry(1), QRect(1280, 0, 1280, 1024)); setenv("QT_QPA_PLATFORM", "wayland", true); waylandServer()->initWorkspace(); } void PointerInputTest::init() { QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat | Test::AdditionalWaylandInterface::Decoration)); QVERIFY(Test::waitForWaylandPointer()); m_compositor = Test::waylandCompositor(); m_shell = Test::waylandShell(); m_seat = Test::waylandSeat(); screens()->setCurrent(0); Cursor::setPos(QPoint(640, 512)); } void PointerInputTest::cleanup() { Test::destroyWaylandConnection(); } void PointerInputTest::render(KWayland::Client::Surface *surface, const QSize &size) { Test::render(surface, size, Qt::blue); Test::flushWaylandConnection(); } void PointerInputTest::testWarpingUpdatesFocus() { // this test verifies that warping the pointer creates pointer enter and leave events using namespace KWayland::Client; // create pointer and signal spy for enter and leave signals auto pointer = m_seat->createPointer(m_seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); QSignalSpy enteredSpy(pointer, &Pointer::entered); QVERIFY(enteredSpy.isValid()); QSignalSpy leftSpy(pointer, &Pointer::left); QVERIFY(leftSpy.isValid()); // create a window QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); Surface *surface = Test::createSurface(m_compositor); QVERIFY(surface); ShellSurface *shellSurface = Test::createShellSurface(surface, surface); QVERIFY(shellSurface); render(surface); QVERIFY(clientAddedSpy.wait()); AbstractClient *window = workspace()->activeClient(); QVERIFY(window); // currently there should not be a focused pointer surface QVERIFY(!waylandServer()->seat()->focusedPointerSurface()); QVERIFY(!pointer->enteredSurface()); // enter Cursor::setPos(QPoint(25, 25)); QVERIFY(enteredSpy.wait()); QCOMPARE(enteredSpy.count(), 1); QCOMPARE(enteredSpy.first().at(1).toPointF(), QPointF(25, 25)); // window should have focus QCOMPARE(pointer->enteredSurface(), surface); // also on the server QCOMPARE(waylandServer()->seat()->focusedPointerSurface(), window->surface()); // and out again Cursor::setPos(QPoint(250, 250));; QVERIFY(leftSpy.wait()); QCOMPARE(leftSpy.count(), 1); // there should not be a focused pointer surface anymore QVERIFY(!waylandServer()->seat()->focusedPointerSurface()); QVERIFY(!pointer->enteredSurface()); } void PointerInputTest::testWarpingGeneratesPointerMotion() { // this test verifies that warping the pointer creates pointer motion events using namespace KWayland::Client; // create pointer and signal spy for enter and motion auto pointer = m_seat->createPointer(m_seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); QSignalSpy enteredSpy(pointer, &Pointer::entered); QVERIFY(enteredSpy.isValid()); QSignalSpy movedSpy(pointer, &Pointer::motion); QVERIFY(movedSpy.isValid()); // create a window QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); Surface *surface = Test::createSurface(m_compositor); QVERIFY(surface); ShellSurface *shellSurface = Test::createShellSurface(surface, surface); QVERIFY(shellSurface); render(surface); QVERIFY(clientAddedSpy.wait()); AbstractClient *window = workspace()->activeClient(); QVERIFY(window); // enter kwinApp()->platform()->pointerMotion(QPointF(25, 25), 1); QVERIFY(enteredSpy.wait()); QCOMPARE(enteredSpy.first().at(1).toPointF(), QPointF(25, 25)); // now warp Cursor::setPos(QPoint(26, 26)); QVERIFY(movedSpy.wait()); QCOMPARE(movedSpy.count(), 1); QCOMPARE(movedSpy.last().first().toPointF(), QPointF(26, 26)); } void PointerInputTest::testWarpingDuringFilter() { // this test verifies that pointer motion is handled correctly if // the pointer gets warped during processing of input events using namespace KWayland::Client; // create pointer auto pointer = m_seat->createPointer(m_seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); QSignalSpy movedSpy(pointer, &Pointer::motion); QVERIFY(movedSpy.isValid()); // warp cursor into expected geometry Cursor::setPos(10, 10); // create a window QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); Surface *surface = Test::createSurface(m_compositor); QVERIFY(surface); ShellSurface *shellSurface = Test::createShellSurface(surface, surface); QVERIFY(shellSurface); render(surface); QVERIFY(clientAddedSpy.wait()); AbstractClient *window = workspace()->activeClient(); QVERIFY(window); QCOMPARE(window->pos(), QPoint(0, 0)); QVERIFY(window->geometry().contains(Cursor::pos())); // is PresentWindows effect for top left screen edge loaded QVERIFY(static_cast(effects)->isEffectLoaded("presentwindows")); QVERIFY(movedSpy.isEmpty()); quint32 timestamp = 0; kwinApp()->platform()->pointerMotion(QPoint(0, 0), timestamp++); // screen edges push back QCOMPARE(Cursor::pos(), QPoint(1, 1)); QVERIFY(movedSpy.wait()); QCOMPARE(movedSpy.count(), 2); QCOMPARE(movedSpy.at(0).first().toPoint(), QPoint(0, 0)); QCOMPARE(movedSpy.at(1).first().toPoint(), QPoint(1, 1)); } void PointerInputTest::testUpdateFocusAfterScreenChange() { // this test verifies that a pointer enter event is generated when the cursor changes to another // screen due to removal of screen using namespace KWayland::Client; // ensure cursor is on second screen Cursor::setPos(1500, 300); // create pointer and signal spy for enter and motion auto pointer = m_seat->createPointer(m_seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); QSignalSpy enteredSpy(pointer, &Pointer::entered); QVERIFY(enteredSpy.isValid()); // create a window QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); Surface *surface = Test::createSurface(m_compositor); QVERIFY(surface); ShellSurface *shellSurface = Test::createShellSurface(surface, surface); QVERIFY(shellSurface); render(surface, QSize(1280, 1024)); QVERIFY(clientAddedSpy.wait()); AbstractClient *window = workspace()->activeClient(); QVERIFY(window); QVERIFY(!window->geometry().contains(Cursor::pos())); QSignalSpy screensChangedSpy(screens(), &Screens::changed); QVERIFY(screensChangedSpy.isValid()); // now let's remove the screen containing the cursor QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 1), Q_ARG(QVector, QVector{QRect(0, 0, 1280, 1024)})); QVERIFY(screensChangedSpy.wait()); QCOMPARE(screens()->count(), 1); // this should have warped the cursor QCOMPARE(Cursor::pos(), QPoint(639, 511)); QVERIFY(window->geometry().contains(Cursor::pos())); // and we should get an enter event QVERIFY(enteredSpy.wait()); QCOMPARE(enteredSpy.count(), 1); } void PointerInputTest::testModifierClickUnrestrictedMove_data() { QTest::addColumn("modifierKey"); QTest::addColumn("mouseButton"); QTest::addColumn("modKey"); QTest::addColumn("capsLock"); const QString alt = QStringLiteral("Alt"); const QString meta = QStringLiteral("Meta"); QTest::newRow("Left Alt + Left Click") << KEY_LEFTALT << BTN_LEFT << alt << false; QTest::newRow("Left Alt + Right Click") << KEY_LEFTALT << BTN_RIGHT << alt << false; QTest::newRow("Left Alt + Middle Click") << KEY_LEFTALT << BTN_MIDDLE << alt << false; QTest::newRow("Right Alt + Left Click") << KEY_RIGHTALT << BTN_LEFT << alt << false; QTest::newRow("Right Alt + Right Click") << KEY_RIGHTALT << BTN_RIGHT << alt << false; QTest::newRow("Right Alt + Middle Click") << KEY_RIGHTALT << BTN_MIDDLE << alt << false; // now everything with meta QTest::newRow("Left Meta + Left Click") << KEY_LEFTMETA << BTN_LEFT << meta << false; QTest::newRow("Left Meta + Right Click") << KEY_LEFTMETA << BTN_RIGHT << meta << false; QTest::newRow("Left Meta + Middle Click") << KEY_LEFTMETA << BTN_MIDDLE << meta << false; QTest::newRow("Right Meta + Left Click") << KEY_RIGHTMETA << BTN_LEFT << meta << false; QTest::newRow("Right Meta + Right Click") << KEY_RIGHTMETA << BTN_RIGHT << meta << false; QTest::newRow("Right Meta + Middle Click") << KEY_RIGHTMETA << BTN_MIDDLE << meta << false; // and with capslock QTest::newRow("Left Alt + Left Click/CapsLock") << KEY_LEFTALT << BTN_LEFT << alt << true; QTest::newRow("Left Alt + Right Click/CapsLock") << KEY_LEFTALT << BTN_RIGHT << alt << true; QTest::newRow("Left Alt + Middle Click/CapsLock") << KEY_LEFTALT << BTN_MIDDLE << alt << true; QTest::newRow("Right Alt + Left Click/CapsLock") << KEY_RIGHTALT << BTN_LEFT << alt << true; QTest::newRow("Right Alt + Right Click/CapsLock") << KEY_RIGHTALT << BTN_RIGHT << alt << true; QTest::newRow("Right Alt + Middle Click/CapsLock") << KEY_RIGHTALT << BTN_MIDDLE << alt << true; // now everything with meta QTest::newRow("Left Meta + Left Click/CapsLock") << KEY_LEFTMETA << BTN_LEFT << meta << true; QTest::newRow("Left Meta + Right Click/CapsLock") << KEY_LEFTMETA << BTN_RIGHT << meta << true; QTest::newRow("Left Meta + Middle Click/CapsLock") << KEY_LEFTMETA << BTN_MIDDLE << meta << true; QTest::newRow("Right Meta + Left Click/CapsLock") << KEY_RIGHTMETA << BTN_LEFT << meta << true; QTest::newRow("Right Meta + Right Click/CapsLock") << KEY_RIGHTMETA << BTN_RIGHT << meta << true; QTest::newRow("Right Meta + Middle Click/CapsLock") << KEY_RIGHTMETA << BTN_MIDDLE << meta << true; } void PointerInputTest::testModifierClickUnrestrictedMove() { // this test ensures that Alt+mouse button press triggers unrestricted move using namespace KWayland::Client; // create pointer and signal spy for button events auto pointer = m_seat->createPointer(m_seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); QSignalSpy buttonSpy(pointer, &Pointer::buttonStateChanged); QVERIFY(buttonSpy.isValid()); // first modify the config for this run QFETCH(QString, modKey); KConfigGroup group = kwinApp()->config()->group("MouseBindings"); group.writeEntry("CommandAllKey", modKey); group.writeEntry("CommandAll1", "Move"); group.writeEntry("CommandAll2", "Move"); group.writeEntry("CommandAll3", "Move"); group.sync(); workspace()->slotReconfigure(); QCOMPARE(options->commandAllModifier(), modKey == QStringLiteral("Alt") ? Qt::AltModifier : Qt::MetaModifier); QCOMPARE(options->commandAll1(), Options::MouseUnrestrictedMove); QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove); QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove); // create a window QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); Surface *surface = Test::createSurface(m_compositor); QVERIFY(surface); ShellSurface *shellSurface = Test::createShellSurface(surface, surface); QVERIFY(shellSurface); render(surface); QVERIFY(clientAddedSpy.wait()); AbstractClient *window = workspace()->activeClient(); QVERIFY(window); // move cursor on window Cursor::setPos(window->geometry().center()); // simulate modifier+click quint32 timestamp = 1; QFETCH(bool, capsLock); if (capsLock) { kwinApp()->platform()->keyboardKeyPressed(KEY_CAPSLOCK, timestamp++); } QFETCH(int, modifierKey); QFETCH(int, mouseButton); kwinApp()->platform()->keyboardKeyPressed(modifierKey, timestamp++); QVERIFY(!window->isMove()); kwinApp()->platform()->pointerButtonPressed(mouseButton, timestamp++); QVERIFY(window->isMove()); // release modifier should not change it kwinApp()->platform()->keyboardKeyReleased(modifierKey, timestamp++); QVERIFY(window->isMove()); // but releasing the key should end move/resize kwinApp()->platform()->pointerButtonReleased(mouseButton, timestamp++); QVERIFY(!window->isMove()); if (capsLock) { kwinApp()->platform()->keyboardKeyReleased(KEY_CAPSLOCK, timestamp++); } // all of that should not have triggered button events on the surface QCOMPARE(buttonSpy.count(), 0); // also waiting shouldn't give us the event QVERIFY(!buttonSpy.wait(100)); } void PointerInputTest::testModifierClickUnrestrictedMoveGlobalShortcutsDisabled() { // this test ensures that Alt+mouse button press triggers unrestricted move using namespace KWayland::Client; // create pointer and signal spy for button events auto pointer = m_seat->createPointer(m_seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); QSignalSpy buttonSpy(pointer, &Pointer::buttonStateChanged); QVERIFY(buttonSpy.isValid()); // first modify the config for this run KConfigGroup group = kwinApp()->config()->group("MouseBindings"); group.writeEntry("CommandAllKey", "Alt"); group.writeEntry("CommandAll1", "Move"); group.writeEntry("CommandAll2", "Move"); group.writeEntry("CommandAll3", "Move"); group.sync(); workspace()->slotReconfigure(); QCOMPARE(options->commandAllModifier(), Qt::AltModifier); QCOMPARE(options->commandAll1(), Options::MouseUnrestrictedMove); QCOMPARE(options->commandAll2(), Options::MouseUnrestrictedMove); QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedMove); // create a window QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); Surface *surface = Test::createSurface(m_compositor); QVERIFY(surface); ShellSurface *shellSurface = Test::createShellSurface(surface, surface); QVERIFY(shellSurface); render(surface); QVERIFY(clientAddedSpy.wait()); AbstractClient *window = workspace()->activeClient(); QVERIFY(window); // disable global shortcuts QVERIFY(!workspace()->globalShortcutsDisabled()); workspace()->disableGlobalShortcutsForClient(true); QVERIFY(workspace()->globalShortcutsDisabled()); // move cursor on window Cursor::setPos(window->geometry().center()); // simulate modifier+click quint32 timestamp = 1; kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTALT, timestamp++); QVERIFY(!window->isMove()); kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); QVERIFY(!window->isMove()); // release modifier should not change it kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++); QVERIFY(!window->isMove()); kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); workspace()->disableGlobalShortcutsForClient(false); } void PointerInputTest::testModifierScrollOpacity_data() { QTest::addColumn("modifierKey"); QTest::addColumn("modKey"); QTest::addColumn("capsLock"); const QString alt = QStringLiteral("Alt"); const QString meta = QStringLiteral("Meta"); QTest::newRow("Left Alt") << KEY_LEFTALT << alt << false; QTest::newRow("Right Alt") << KEY_RIGHTALT << alt << false; QTest::newRow("Left Meta") << KEY_LEFTMETA << meta << false; QTest::newRow("Right Meta") << KEY_RIGHTMETA << meta << false; QTest::newRow("Left Alt/CapsLock") << KEY_LEFTALT << alt << true; QTest::newRow("Right Alt/CapsLock") << KEY_RIGHTALT << alt << true; QTest::newRow("Left Meta/CapsLock") << KEY_LEFTMETA << meta << true; QTest::newRow("Right Meta/CapsLock") << KEY_RIGHTMETA << meta << true; } void PointerInputTest::testModifierScrollOpacity() { // this test verifies that mod+wheel performs a window operation and does not // pass the wheel to the window using namespace KWayland::Client; // create pointer and signal spy for button events auto pointer = m_seat->createPointer(m_seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); QSignalSpy axisSpy(pointer, &Pointer::axisChanged); QVERIFY(axisSpy.isValid()); // first modify the config for this run QFETCH(QString, modKey); KConfigGroup group = kwinApp()->config()->group("MouseBindings"); group.writeEntry("CommandAllKey", modKey); group.writeEntry("CommandAllWheel", "change opacity"); group.sync(); workspace()->slotReconfigure(); // create a window QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); Surface *surface = Test::createSurface(m_compositor); QVERIFY(surface); ShellSurface *shellSurface = Test::createShellSurface(surface, surface); QVERIFY(shellSurface); render(surface); QVERIFY(clientAddedSpy.wait()); AbstractClient *window = workspace()->activeClient(); QVERIFY(window); // set the opacity to 0.5 window->setOpacity(0.5); QCOMPARE(window->opacity(), 0.5); // move cursor on window Cursor::setPos(window->geometry().center()); // simulate modifier+wheel quint32 timestamp = 1; QFETCH(bool, capsLock); if (capsLock) { kwinApp()->platform()->keyboardKeyPressed(KEY_CAPSLOCK, timestamp++); } QFETCH(int, modifierKey); kwinApp()->platform()->keyboardKeyPressed(modifierKey, timestamp++); kwinApp()->platform()->pointerAxisVertical(-5, timestamp++); QCOMPARE(window->opacity(), 0.6); kwinApp()->platform()->pointerAxisVertical(5, timestamp++); QCOMPARE(window->opacity(), 0.5); kwinApp()->platform()->keyboardKeyReleased(modifierKey, timestamp++); if (capsLock) { kwinApp()->platform()->keyboardKeyReleased(KEY_CAPSLOCK, timestamp++); } // axis should have been filtered out QCOMPARE(axisSpy.count(), 0); QVERIFY(!axisSpy.wait(100)); } void PointerInputTest::testModifierScrollOpacityGlobalShortcutsDisabled() { // this test verifies that mod+wheel performs a window operation and does not // pass the wheel to the window using namespace KWayland::Client; // create pointer and signal spy for button events auto pointer = m_seat->createPointer(m_seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); QSignalSpy axisSpy(pointer, &Pointer::axisChanged); QVERIFY(axisSpy.isValid()); // first modify the config for this run KConfigGroup group = kwinApp()->config()->group("MouseBindings"); group.writeEntry("CommandAllKey", "Alt"); group.writeEntry("CommandAllWheel", "change opacity"); group.sync(); workspace()->slotReconfigure(); // create a window QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); Surface *surface = Test::createSurface(m_compositor); QVERIFY(surface); ShellSurface *shellSurface = Test::createShellSurface(surface, surface); QVERIFY(shellSurface); render(surface); QVERIFY(clientAddedSpy.wait()); AbstractClient *window = workspace()->activeClient(); QVERIFY(window); // set the opacity to 0.5 window->setOpacity(0.5); QCOMPARE(window->opacity(), 0.5); // move cursor on window Cursor::setPos(window->geometry().center()); // disable global shortcuts QVERIFY(!workspace()->globalShortcutsDisabled()); workspace()->disableGlobalShortcutsForClient(true); QVERIFY(workspace()->globalShortcutsDisabled()); // simulate modifier+wheel quint32 timestamp = 1; kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTALT, timestamp++); kwinApp()->platform()->pointerAxisVertical(-5, timestamp++); QCOMPARE(window->opacity(), 0.5); kwinApp()->platform()->pointerAxisVertical(5, timestamp++); QCOMPARE(window->opacity(), 0.5); kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++); workspace()->disableGlobalShortcutsForClient(false); } void PointerInputTest::testScrollAction() { // this test verifies that scroll on inactive window performs a mouse action using namespace KWayland::Client; auto pointer = m_seat->createPointer(m_seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); QSignalSpy axisSpy(pointer, &Pointer::axisChanged); QVERIFY(axisSpy.isValid()); // first modify the config for this run KConfigGroup group = kwinApp()->config()->group("MouseBindings"); group.writeEntry("CommandWindowWheel", "activate and scroll"); group.sync(); workspace()->slotReconfigure(); // create two windows QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); Surface *surface1 = Test::createSurface(m_compositor); QVERIFY(surface1); ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1); QVERIFY(shellSurface1); render(surface1); QVERIFY(clientAddedSpy.wait()); AbstractClient *window1 = workspace()->activeClient(); QVERIFY(window1); Surface *surface2 = Test::createSurface(m_compositor); QVERIFY(surface2); ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2); QVERIFY(shellSurface2); render(surface2); QVERIFY(clientAddedSpy.wait()); AbstractClient *window2 = workspace()->activeClient(); QVERIFY(window2); QVERIFY(window1 != window2); // move cursor to the inactive window Cursor::setPos(window1->geometry().center()); quint32 timestamp = 1; QVERIFY(!window1->isActive()); kwinApp()->platform()->pointerAxisVertical(5, timestamp++); QVERIFY(window1->isActive()); // but also the wheel event should be passed to the window QVERIFY(axisSpy.wait()); // we need to wait a little bit, otherwise the test crashes in effectshandler, needs fixing QTest::qWait(100); } void PointerInputTest::testFocusFollowsMouse() { using namespace KWayland::Client; // need to create a pointer, otherwise it doesn't accept focus auto pointer = m_seat->createPointer(m_seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); // move cursor out of the way of first window to be created Cursor::setPos(900, 900); // first modify the config for this run KConfigGroup group = kwinApp()->config()->group("Windows"); group.writeEntry("AutoRaise", true); group.writeEntry("AutoRaiseInterval", 20); group.writeEntry("DelayFocusInterval", 200); group.writeEntry("FocusPolicy", "FocusFollowsMouse"); group.sync(); workspace()->slotReconfigure(); // verify the settings QCOMPARE(options->focusPolicy(), Options::FocusFollowsMouse); QVERIFY(options->isAutoRaise()); QCOMPARE(options->autoRaiseInterval(), 20); QCOMPARE(options->delayFocusInterval(), 200); // create two windows QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); Surface *surface1 = Test::createSurface(m_compositor); QVERIFY(surface1); ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1); QVERIFY(shellSurface1); render(surface1, QSize(800, 800)); QVERIFY(clientAddedSpy.wait()); AbstractClient *window1 = workspace()->activeClient(); QVERIFY(window1); Surface *surface2 = Test::createSurface(m_compositor); QVERIFY(surface2); ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2); QVERIFY(shellSurface2); render(surface2, QSize(800, 800)); QVERIFY(clientAddedSpy.wait()); AbstractClient *window2 = workspace()->activeClient(); QVERIFY(window2); QVERIFY(window1 != window2); QCOMPARE(workspace()->topClientOnDesktop(1, -1), window2); // geometry of the two windows should be overlapping QVERIFY(window1->geometry().intersects(window2->geometry())); // signal spies for active window changed and stacking order changed QSignalSpy activeWindowChangedSpy(workspace(), &Workspace::clientActivated); QVERIFY(activeWindowChangedSpy.isValid()); QSignalSpy stackingOrderChangedSpy(workspace(), &Workspace::stackingOrderChanged); QVERIFY(stackingOrderChangedSpy.isValid()); QVERIFY(!window1->isActive()); QVERIFY(window2->isActive()); // move on top of first window QVERIFY(window1->geometry().contains(10, 10)); QVERIFY(!window2->geometry().contains(10, 10)); Cursor::setPos(10, 10); QVERIFY(stackingOrderChangedSpy.wait()); QCOMPARE(stackingOrderChangedSpy.count(), 1); QCOMPARE(workspace()->topClientOnDesktop(1, -1), window1); QTRY_VERIFY(window1->isActive()); // move on second window, but move away before active window change delay hits Cursor::setPos(810, 810); QVERIFY(stackingOrderChangedSpy.wait()); QCOMPARE(stackingOrderChangedSpy.count(), 2); QCOMPARE(workspace()->topClientOnDesktop(1, -1), window2); Cursor::setPos(10, 10); QVERIFY(!activeWindowChangedSpy.wait(250)); QVERIFY(window1->isActive()); QCOMPARE(workspace()->topClientOnDesktop(1, -1), window1); // as we moved back on window 1 that should been raised in the mean time QCOMPARE(stackingOrderChangedSpy.count(), 3); // quickly move on window 2 and back on window 1 should not raise window 2 Cursor::setPos(810, 810); Cursor::setPos(10, 10); QVERIFY(!stackingOrderChangedSpy.wait(250)); } void PointerInputTest::testMouseActionInactiveWindow_data() { QTest::addColumn("button"); QTest::newRow("Left") << quint32(BTN_LEFT); QTest::newRow("Middle") << quint32(BTN_MIDDLE); QTest::newRow("Right") << quint32(BTN_RIGHT); } void PointerInputTest::testMouseActionInactiveWindow() { // this test performs the mouse button window action on an inactive window // it should activate the window and raise it using namespace KWayland::Client; // first modify the config for this run - disable FocusFollowsMouse KConfigGroup group = kwinApp()->config()->group("Windows"); group.writeEntry("FocusPolicy", "ClickToFocus"); group.sync(); group = kwinApp()->config()->group("MouseBindings"); group.writeEntry("CommandWindow1", "Activate, raise and pass click"); group.writeEntry("CommandWindow2", "Activate, raise and pass click"); group.writeEntry("CommandWindow3", "Activate, raise and pass click"); group.sync(); workspace()->slotReconfigure(); // create two windows QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); Surface *surface1 = Test::createSurface(m_compositor); QVERIFY(surface1); ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1); QVERIFY(shellSurface1); render(surface1, QSize(800, 800)); QVERIFY(clientAddedSpy.wait()); AbstractClient *window1 = workspace()->activeClient(); QVERIFY(window1); Surface *surface2 = Test::createSurface(m_compositor); QVERIFY(surface2); ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2); QVERIFY(shellSurface2); render(surface2, QSize(800, 800)); QVERIFY(clientAddedSpy.wait()); AbstractClient *window2 = workspace()->activeClient(); QVERIFY(window2); QVERIFY(window1 != window2); QCOMPARE(workspace()->topClientOnDesktop(1, -1), window2); // geometry of the two windows should be overlapping QVERIFY(window1->geometry().intersects(window2->geometry())); // signal spies for active window changed and stacking order changed QSignalSpy activeWindowChangedSpy(workspace(), &Workspace::clientActivated); QVERIFY(activeWindowChangedSpy.isValid()); QSignalSpy stackingOrderChangedSpy(workspace(), &Workspace::stackingOrderChanged); QVERIFY(stackingOrderChangedSpy.isValid()); QVERIFY(!window1->isActive()); QVERIFY(window2->isActive()); // move on top of first window QVERIFY(window1->geometry().contains(10, 10)); QVERIFY(!window2->geometry().contains(10, 10)); Cursor::setPos(10, 10); // no focus follows mouse QVERIFY(!stackingOrderChangedSpy.wait(200)); QVERIFY(stackingOrderChangedSpy.isEmpty()); QVERIFY(activeWindowChangedSpy.isEmpty()); QVERIFY(window2->isActive()); // and click quint32 timestamp = 1; QFETCH(quint32, button); kwinApp()->platform()->pointerButtonPressed(button, timestamp++); // should raise window1 and activate it QCOMPARE(stackingOrderChangedSpy.count(), 1); QVERIFY(!activeWindowChangedSpy.isEmpty()); QCOMPARE(workspace()->topClientOnDesktop(1, -1), window1); QVERIFY(window1->isActive()); QVERIFY(!window2->isActive()); // release again kwinApp()->platform()->pointerButtonReleased(button, timestamp++); } void PointerInputTest::testMouseActionActiveWindow_data() { QTest::addColumn("clickRaise"); QTest::addColumn("button"); for (quint32 i=BTN_LEFT; i < BTN_JOYSTICK; i++) { QByteArray number = QByteArray::number(i, 16); QTest::newRow(QByteArrayLiteral("click raise/").append(number).constData()) << true << i; QTest::newRow(QByteArrayLiteral("no click raise/").append(number).constData()) << false << i; } } void PointerInputTest::testMouseActionActiveWindow() { // this test verifies the mouse action performed on an active window // for all buttons it should trigger a window raise depending on the // click raise option using namespace KWayland::Client; // create a button spy - all clicks should be passed through auto pointer = m_seat->createPointer(m_seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); QSignalSpy buttonSpy(pointer, &Pointer::buttonStateChanged); QVERIFY(buttonSpy.isValid()); // adjust config for this run QFETCH(bool, clickRaise); KConfigGroup group = kwinApp()->config()->group("Windows"); group.writeEntry("ClickRaise", clickRaise); group.sync(); workspace()->slotReconfigure(); QCOMPARE(options->isClickRaise(), clickRaise); // create two windows QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); Surface *surface1 = Test::createSurface(m_compositor); QVERIFY(surface1); ShellSurface *shellSurface1 = Test::createShellSurface(surface1, surface1); QVERIFY(shellSurface1); render(surface1, QSize(800, 800)); QVERIFY(clientAddedSpy.wait()); AbstractClient *window1 = workspace()->activeClient(); QVERIFY(window1); QSignalSpy window1DestroyedSpy(window1, &QObject::destroyed); QVERIFY(window1DestroyedSpy.isValid()); Surface *surface2 = Test::createSurface(m_compositor); QVERIFY(surface2); ShellSurface *shellSurface2 = Test::createShellSurface(surface2, surface2); QVERIFY(shellSurface2); render(surface2, QSize(800, 800)); QVERIFY(clientAddedSpy.wait()); AbstractClient *window2 = workspace()->activeClient(); QVERIFY(window2); QVERIFY(window1 != window2); QSignalSpy window2DestroyedSpy(window2, &QObject::destroyed); QVERIFY(window2DestroyedSpy.isValid()); QCOMPARE(workspace()->topClientOnDesktop(1, -1), window2); // geometry of the two windows should be overlapping QVERIFY(window1->geometry().intersects(window2->geometry())); // lower the currently active window workspace()->lowerClient(window2); QCOMPARE(workspace()->topClientOnDesktop(1, -1), window1); // signal spy for stacking order spy QSignalSpy stackingOrderChangedSpy(workspace(), &Workspace::stackingOrderChanged); QVERIFY(stackingOrderChangedSpy.isValid()); // move on top of second window QVERIFY(!window1->geometry().contains(900, 900)); QVERIFY(window2->geometry().contains(900, 900)); Cursor::setPos(900, 900); // and click quint32 timestamp = 1; QFETCH(quint32, button); kwinApp()->platform()->pointerButtonPressed(button, timestamp++); QVERIFY(buttonSpy.wait()); if (clickRaise) { QCOMPARE(stackingOrderChangedSpy.count(), 1); QTRY_COMPARE_WITH_TIMEOUT(workspace()->topClientOnDesktop(1, -1), window2, 200); } else { QCOMPARE(stackingOrderChangedSpy.count(), 0); QVERIFY(!stackingOrderChangedSpy.wait(100)); QCOMPARE(workspace()->topClientOnDesktop(1, -1), window1); } // release again kwinApp()->platform()->pointerButtonReleased(button, timestamp++); delete surface1; QVERIFY(window1DestroyedSpy.wait()); delete surface2; QVERIFY(window2DestroyedSpy.wait()); } void PointerInputTest::testCursorImage() { // this test verifies that the pointer image gets updated correctly from the client provided data using namespace KWayland::Client; // we need a pointer to get the enter event auto pointer = m_seat->createPointer(m_seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); QSignalSpy enteredSpy(pointer, &Pointer::entered); QVERIFY(enteredSpy.isValid()); // move cursor somewhere the new window won't open Cursor::setPos(800, 800); auto p = input()->pointer(); // at the moment it should be the fallback cursor const QImage fallbackCursor = p->cursorImage(); QVERIFY(!fallbackCursor.isNull()); // create a window QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); Surface *surface = Test::createSurface(m_compositor); QVERIFY(surface); ShellSurface *shellSurface = Test::createShellSurface(surface, surface); QVERIFY(shellSurface); render(surface); QVERIFY(clientAddedSpy.wait()); AbstractClient *window = workspace()->activeClient(); QVERIFY(window); // move cursor to center of window, this should first set a null pointer, so we still show old cursor Cursor::setPos(window->geometry().center()); QCOMPARE(p->focus().data(), window); QCOMPARE(p->cursorImage(), fallbackCursor); QVERIFY(enteredSpy.wait()); // create a cursor on the pointer Surface *cursorSurface = Test::createSurface(m_compositor); QVERIFY(cursorSurface); QSignalSpy cursorRenderedSpy(cursorSurface, &Surface::frameRendered); QVERIFY(cursorRenderedSpy.isValid()); QImage red = QImage(QSize(10, 10), QImage::Format_ARGB32_Premultiplied); red.fill(Qt::red); cursorSurface->attachBuffer(Test::waylandShmPool()->createBuffer(red)); cursorSurface->damage(QRect(0, 0, 10, 10)); cursorSurface->commit(); pointer->setCursor(cursorSurface, QPoint(5, 5)); QVERIFY(cursorRenderedSpy.wait()); QCOMPARE(p->cursorImage(), red); QCOMPARE(p->cursorHotSpot(), QPoint(5, 5)); // change hotspot pointer->setCursor(cursorSurface, QPoint(6, 6)); Test::flushWaylandConnection(); QTRY_COMPARE(p->cursorHotSpot(), QPoint(6, 6)); QCOMPARE(p->cursorImage(), red); // change the buffer QImage blue = QImage(QSize(10, 10), QImage::Format_ARGB32_Premultiplied); blue.fill(Qt::blue); auto b = Test::waylandShmPool()->createBuffer(blue); cursorSurface->attachBuffer(b); cursorSurface->damage(QRect(0, 0, 10, 10)); cursorSurface->commit(); QVERIFY(cursorRenderedSpy.wait()); QTRY_COMPARE(p->cursorImage(), blue); QCOMPARE(p->cursorHotSpot(), QPoint(6, 6)); // scaled cursor QImage blueScaled = QImage(QSize(20, 20), QImage::Format_ARGB32_Premultiplied); blueScaled.fill(Qt::blue); auto bs = Test::waylandShmPool()->createBuffer(blueScaled); cursorSurface->attachBuffer(bs); cursorSurface->setScale(2); cursorSurface->damage(QRect(0, 0, 20, 20)); cursorSurface->commit(); QVERIFY(cursorRenderedSpy.wait()); QTRY_COMPARE(p->cursorImage(), blueScaled); QCOMPARE(p->cursorImage().devicePixelRatio(), 2.0); QCOMPARE(p->cursorHotSpot(), QPoint(6, 6)); //surface-local (so not changed) // hide the cursor pointer->setCursor(nullptr); Test::flushWaylandConnection(); QTRY_VERIFY(p->cursorImage().isNull()); // move cursor somewhere else, should reset to fallback cursor Cursor::setPos(window->geometry().bottomLeft() + QPoint(20, 20)); QVERIFY(p->focus().isNull()); QVERIFY(!p->cursorImage().isNull()); QCOMPARE(p->cursorImage(), fallbackCursor); } class HelperEffect : public Effect { Q_OBJECT public: HelperEffect() {} - ~HelperEffect() {} + ~HelperEffect() override {} }; void PointerInputTest::testEffectOverrideCursorImage() { // this test verifies the effect cursor override handling using namespace KWayland::Client; // we need a pointer to get the enter event and set a cursor auto pointer = m_seat->createPointer(m_seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); QSignalSpy enteredSpy(pointer, &Pointer::entered); QVERIFY(enteredSpy.isValid()); QSignalSpy leftSpy(pointer, &Pointer::left); QVERIFY(leftSpy.isValid()); // move cursor somewhere the new window won't open Cursor::setPos(800, 800); auto p = input()->pointer(); // here we should have the fallback cursor const QImage fallback = p->cursorImage(); QVERIFY(!fallback.isNull()); // now let's create a window QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); Surface *surface = Test::createSurface(m_compositor); QVERIFY(surface); ShellSurface *shellSurface = Test::createShellSurface(surface, surface); QVERIFY(shellSurface); render(surface); QVERIFY(clientAddedSpy.wait()); AbstractClient *window = workspace()->activeClient(); QVERIFY(window); // and move cursor to the window QVERIFY(!window->geometry().contains(QPoint(800, 800))); Cursor::setPos(window->geometry().center()); QVERIFY(enteredSpy.wait()); // cursor image should still be fallback QCOMPARE(p->cursorImage(), fallback); // now create an effect and set an override cursor QScopedPointer effect(new HelperEffect); effects->startMouseInterception(effect.data(), Qt::SizeAllCursor); const QImage sizeAll = p->cursorImage(); QVERIFY(!sizeAll.isNull()); QVERIFY(sizeAll != fallback); QVERIFY(leftSpy.wait()); // let's change to arrow cursor, this should be our fallback effects->defineCursor(Qt::ArrowCursor); QCOMPARE(p->cursorImage(), fallback); // back to size all effects->defineCursor(Qt::SizeAllCursor); QCOMPARE(p->cursorImage(), sizeAll); // move cursor outside the window area Cursor::setPos(800, 800); // and end the override, which should switch to fallback effects->stopMouseInterception(effect.data()); QCOMPARE(p->cursorImage(), fallback); // start mouse interception again effects->startMouseInterception(effect.data(), Qt::SizeAllCursor); QCOMPARE(p->cursorImage(), sizeAll); // move cursor to area of window Cursor::setPos(window->geometry().center()); // this should not result in an enter event QVERIFY(!enteredSpy.wait(100)); // after ending the interception we should get an enter event effects->stopMouseInterception(effect.data()); QVERIFY(enteredSpy.wait()); QVERIFY(p->cursorImage().isNull()); } void PointerInputTest::testPopup() { // this test validates the basic popup behavior // a button press outside the window should dismiss the popup // first create a parent surface using namespace KWayland::Client; auto pointer = m_seat->createPointer(m_seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); QSignalSpy enteredSpy(pointer, &Pointer::entered); QVERIFY(enteredSpy.isValid()); QSignalSpy leftSpy(pointer, &Pointer::left); QVERIFY(leftSpy.isValid()); QSignalSpy buttonStateChangedSpy(pointer, &Pointer::buttonStateChanged); QVERIFY(buttonStateChangedSpy.isValid()); QSignalSpy motionSpy(pointer, &Pointer::motion); QVERIFY(motionSpy.isValid()); Cursor::setPos(800, 800); QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); Surface *surface = Test::createSurface(m_compositor); QVERIFY(surface); ShellSurface *shellSurface = Test::createShellSurface(surface, surface); QVERIFY(shellSurface); render(surface); QVERIFY(clientAddedSpy.wait()); AbstractClient *window = workspace()->activeClient(); QVERIFY(window); QCOMPARE(window->hasPopupGrab(), false); // move pointer into window QVERIFY(!window->geometry().contains(QPoint(800, 800))); Cursor::setPos(window->geometry().center()); QVERIFY(enteredSpy.wait()); // click inside window to create serial quint32 timestamp = 0; kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); QVERIFY(buttonStateChangedSpy.wait()); // now create the popup surface Surface *popupSurface = Test::createSurface(m_compositor); QVERIFY(popupSurface); ShellSurface *popupShellSurface = Test::createShellSurface(popupSurface, popupSurface); QVERIFY(popupShellSurface); QSignalSpy popupDoneSpy(popupShellSurface, &ShellSurface::popupDone); QVERIFY(popupDoneSpy.isValid()); // TODO: proper serial popupShellSurface->setTransientPopup(surface, m_seat, 0, QPoint(80, 20)); render(popupSurface); QVERIFY(clientAddedSpy.wait()); auto popupClient = clientAddedSpy.last().first().value(); QVERIFY(popupClient); QVERIFY(popupClient != window); QCOMPARE(window, workspace()->activeClient()); QCOMPARE(popupClient->transientFor(), window); QCOMPARE(popupClient->pos(), window->pos() + QPoint(80, 20)); QCOMPARE(popupClient->hasPopupGrab(), true); // let's move the pointer into the center of the window Cursor::setPos(popupClient->geometry().center()); QVERIFY(enteredSpy.wait()); QCOMPARE(enteredSpy.count(), 2); QCOMPARE(leftSpy.count(), 1); QCOMPARE(pointer->enteredSurface(), popupSurface); // let's move the pointer outside of the popup window // this should not really change anything, it gets a leave event Cursor::setPos(popupClient->geometry().bottomRight() + QPoint(2, 2)); QVERIFY(leftSpy.wait()); QCOMPARE(leftSpy.count(), 2); QVERIFY(popupDoneSpy.isEmpty()); // now click, should trigger popupDone kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); QVERIFY(popupDoneSpy.wait()); kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); } void PointerInputTest::testDecoCancelsPopup() { // this test verifies that clicking the window decoration of parent window // cancels the popup // first create a parent surface using namespace KWayland::Client; auto pointer = m_seat->createPointer(m_seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); QSignalSpy enteredSpy(pointer, &Pointer::entered); QVERIFY(enteredSpy.isValid()); QSignalSpy leftSpy(pointer, &Pointer::left); QVERIFY(leftSpy.isValid()); QSignalSpy buttonStateChangedSpy(pointer, &Pointer::buttonStateChanged); QVERIFY(buttonStateChangedSpy.isValid()); QSignalSpy motionSpy(pointer, &Pointer::motion); QVERIFY(motionSpy.isValid()); Cursor::setPos(800, 800); QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); Surface *surface = Test::createSurface(m_compositor); QVERIFY(surface); ShellSurface *shellSurface = Test::createShellSurface(surface, surface); QVERIFY(shellSurface); auto deco = Test::waylandServerSideDecoration()->create(surface, surface); QSignalSpy decoSpy(deco, &ServerSideDecoration::modeChanged); QVERIFY(decoSpy.isValid()); QVERIFY(decoSpy.wait()); deco->requestMode(ServerSideDecoration::Mode::Server); QVERIFY(decoSpy.wait()); QCOMPARE(deco->mode(), ServerSideDecoration::Mode::Server); render(surface); QVERIFY(clientAddedSpy.wait()); AbstractClient *window = workspace()->activeClient(); QVERIFY(window); QCOMPARE(window->hasPopupGrab(), false); QVERIFY(window->isDecorated()); // move pointer into window QVERIFY(!window->geometry().contains(QPoint(800, 800))); Cursor::setPos(window->geometry().center()); QVERIFY(enteredSpy.wait()); // click inside window to create serial quint32 timestamp = 0; kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); QVERIFY(buttonStateChangedSpy.wait()); // now create the popup surface Surface *popupSurface = Test::createSurface(m_compositor); QVERIFY(popupSurface); ShellSurface *popupShellSurface = Test::createShellSurface(popupSurface, popupSurface); QVERIFY(popupShellSurface); QSignalSpy popupDoneSpy(popupShellSurface, &ShellSurface::popupDone); QVERIFY(popupDoneSpy.isValid()); // TODO: proper serial popupShellSurface->setTransientPopup(surface, m_seat, 0, QPoint(80, 20)); render(popupSurface); QVERIFY(clientAddedSpy.wait()); auto popupClient = clientAddedSpy.last().first().value(); QVERIFY(popupClient); QVERIFY(popupClient != window); QCOMPARE(window, workspace()->activeClient()); QCOMPARE(popupClient->transientFor(), window); QCOMPARE(popupClient->pos(), window->pos() + window->clientPos() + QPoint(80, 20)); QCOMPARE(popupClient->hasPopupGrab(), true); // let's move the pointer into the center of the deco Cursor::setPos(window->geometry().center().x(), window->y() + (window->height() - window->clientSize().height()) / 2); kwinApp()->platform()->pointerButtonPressed(BTN_RIGHT, timestamp++); QVERIFY(popupDoneSpy.wait()); kwinApp()->platform()->pointerButtonReleased(BTN_RIGHT, timestamp++); } void PointerInputTest::testWindowUnderCursorWhileButtonPressed() { // this test verifies that opening a window underneath the mouse cursor does not // trigger a leave event if a button is pressed // see BUG: 372876 // first create a parent surface using namespace KWayland::Client; auto pointer = m_seat->createPointer(m_seat); QVERIFY(pointer); QVERIFY(pointer->isValid()); QSignalSpy enteredSpy(pointer, &Pointer::entered); QVERIFY(enteredSpy.isValid()); QSignalSpy leftSpy(pointer, &Pointer::left); QVERIFY(leftSpy.isValid()); Cursor::setPos(800, 800); QSignalSpy clientAddedSpy(waylandServer(), &WaylandServer::shellClientAdded); QVERIFY(clientAddedSpy.isValid()); Surface *surface = Test::createSurface(m_compositor); QVERIFY(surface); ShellSurface *shellSurface = Test::createShellSurface(surface, surface); QVERIFY(shellSurface); render(surface); QVERIFY(clientAddedSpy.wait()); AbstractClient *window = workspace()->activeClient(); QVERIFY(window); // move cursor over window QVERIFY(!window->geometry().contains(QPoint(800, 800))); Cursor::setPos(window->geometry().center()); QVERIFY(enteredSpy.wait()); // click inside window quint32 timestamp = 0; kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); // now create a second window as transient Surface *popupSurface = Test::createSurface(m_compositor); QVERIFY(popupSurface); ShellSurface *popupShellSurface = Test::createShellSurface(popupSurface, popupSurface); QVERIFY(popupShellSurface); popupShellSurface->setTransient(surface, QPoint(0, 0)); render(popupSurface); QVERIFY(clientAddedSpy.wait()); auto popupClient = clientAddedSpy.last().first().value(); QVERIFY(popupClient); QVERIFY(popupClient != window); QCOMPARE(window->geometry(), popupClient->geometry()); QVERIFY(!leftSpy.wait()); kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); // now that the button is no longer pressed we should get the leave event QVERIFY(leftSpy.wait()); QCOMPARE(leftSpy.count(), 1); QCOMPARE(enteredSpy.count(), 2); } void PointerInputTest::testConfineToScreenGeometry_data() { QTest::addColumn("startPos"); QTest::addColumn("targetPos"); QTest::addColumn("expectedPos"); // screen layout: // // +----------+----------+---------+ // | left | top | right | // +----------+----------+---------+ // | bottom | // +----------+ // QTest::newRow("move top-left - left screen") << QPoint(640, 512) << QPoint(-100, -100) << QPoint(0, 0); QTest::newRow("move top - left screen") << QPoint(640, 512) << QPoint(640, -100) << QPoint(640, 0); QTest::newRow("move top-right - left screen") << QPoint(640, 512) << QPoint(1380, -100) << QPoint(1380, 0); QTest::newRow("move right - left screen") << QPoint(640, 512) << QPoint(1380, 512) << QPoint(1380, 512); QTest::newRow("move bottom-right - left screen") << QPoint(640, 512) << QPoint(1380, 1124) << QPoint(1380, 1124); QTest::newRow("move bottom - left screen") << QPoint(640, 512) << QPoint(640, 1124) << QPoint(640, 1023); QTest::newRow("move bottom-left - left screen") << QPoint(640, 512) << QPoint(-100, 1124) << QPoint(0, 1023); QTest::newRow("move left - left screen") << QPoint(640, 512) << QPoint(-100, 512) << QPoint(0, 512); QTest::newRow("move top-left - top screen") << QPoint(1920, 512) << QPoint(1180, -100) << QPoint(1180, 0); QTest::newRow("move top - top screen") << QPoint(1920, 512) << QPoint(1920, -100) << QPoint(1920, 0); QTest::newRow("move top-right - top screen") << QPoint(1920, 512) << QPoint(2660, -100) << QPoint(2660, 0); QTest::newRow("move right - top screen") << QPoint(1920, 512) << QPoint(2660, 512) << QPoint(2660, 512); QTest::newRow("move bottom-right - top screen") << QPoint(1920, 512) << QPoint(2660, 1124) << QPoint(2559, 1023); QTest::newRow("move bottom - top screen") << QPoint(1920, 512) << QPoint(1920, 1124) << QPoint(1920, 1124); QTest::newRow("move bottom-left - top screen") << QPoint(1920, 512) << QPoint(1180, 1124) << QPoint(1280, 1023); QTest::newRow("move left - top screen") << QPoint(1920, 512) << QPoint(1180, 512) << QPoint(1180, 512); QTest::newRow("move top-left - right screen") << QPoint(3200, 512) << QPoint(2460, -100) << QPoint(2460, 0); QTest::newRow("move top - right screen") << QPoint(3200, 512) << QPoint(3200, -100) << QPoint(3200, 0); QTest::newRow("move top-right - right screen") << QPoint(3200, 512) << QPoint(3940, -100) << QPoint(3839, 0); QTest::newRow("move right - right screen") << QPoint(3200, 512) << QPoint(3940, 512) << QPoint(3839, 512); QTest::newRow("move bottom-right - right screen") << QPoint(3200, 512) << QPoint(3940, 1124) << QPoint(3839, 1023); QTest::newRow("move bottom - right screen") << QPoint(3200, 512) << QPoint(3200, 1124) << QPoint(3200, 1023); QTest::newRow("move bottom-left - right screen") << QPoint(3200, 512) << QPoint(2460, 1124) << QPoint(2460, 1124); QTest::newRow("move left - right screen") << QPoint(3200, 512) << QPoint(2460, 512) << QPoint(2460, 512); QTest::newRow("move top-left - bottom screen") << QPoint(1920, 1536) << QPoint(1180, 924) << QPoint(1180, 924); QTest::newRow("move top - bottom screen") << QPoint(1920, 1536) << QPoint(1920, 924) << QPoint(1920, 924); QTest::newRow("move top-right - bottom screen") << QPoint(1920, 1536) << QPoint(2660, 924) << QPoint(2660, 924); QTest::newRow("move right - bottom screen") << QPoint(1920, 1536) << QPoint(2660, 1536) << QPoint(2559, 1536); QTest::newRow("move bottom-right - bottom screen") << QPoint(1920, 1536) << QPoint(2660, 2148) << QPoint(2559, 2047); QTest::newRow("move bottom - bottom screen") << QPoint(1920, 1536) << QPoint(1920, 2148) << QPoint(1920, 2047); QTest::newRow("move bottom-left - bottom screen") << QPoint(1920, 1536) << QPoint(1180, 2148) << QPoint(1280, 2047); QTest::newRow("move left - bottom screen") << QPoint(1920, 1536) << QPoint(1180, 1536) << QPoint(1280, 1536); } void PointerInputTest::testConfineToScreenGeometry() { // this test verifies that pointer belongs to at least one screen // after moving it to off-screen area // unload the Present Windows effect because it pushes back // pointer if it's at (0, 0) static_cast(effects)->unloadEffect(QStringLiteral("presentwindows")); // setup screen layout const QVector geometries { QRect(0, 0, 1280, 1024), QRect(1280, 0, 1280, 1024), QRect(2560, 0, 1280, 1024), QRect(1280, 1024, 1280, 1024) }; QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, geometries.count()), Q_ARG(QVector, geometries)); QCOMPARE(screens()->count(), geometries.count()); QCOMPARE(screens()->geometry(0), geometries.at(0)); QCOMPARE(screens()->geometry(1), geometries.at(1)); QCOMPARE(screens()->geometry(2), geometries.at(2)); QCOMPARE(screens()->geometry(3), geometries.at(3)); // move pointer to initial position QFETCH(QPoint, startPos); Cursor::setPos(startPos); QCOMPARE(Cursor::pos(), startPos); // perform movement QFETCH(QPoint, targetPos); kwinApp()->platform()->pointerMotion(targetPos, 1); QFETCH(QPoint, expectedPos); QCOMPARE(Cursor::pos(), expectedPos); } void PointerInputTest::testResizeCursor_data() { QTest::addColumn("edges"); QTest::addColumn("cursorShape"); QTest::newRow("top-left") << Qt::Edges(Qt::TopEdge | Qt::LeftEdge) << CursorShape(ExtendedCursor::SizeNorthWest); QTest::newRow("top") << Qt::Edges(Qt::TopEdge) << CursorShape(ExtendedCursor::SizeNorth); QTest::newRow("top-right") << Qt::Edges(Qt::TopEdge | Qt::RightEdge) << CursorShape(ExtendedCursor::SizeNorthEast); QTest::newRow("right") << Qt::Edges(Qt::RightEdge) << CursorShape(ExtendedCursor::SizeEast); QTest::newRow("bottom-right") << Qt::Edges(Qt::BottomEdge | Qt::RightEdge) << CursorShape(ExtendedCursor::SizeSouthEast); QTest::newRow("bottom") << Qt::Edges(Qt::BottomEdge) << CursorShape(ExtendedCursor::SizeSouth); QTest::newRow("bottom-left") << Qt::Edges(Qt::BottomEdge | Qt::LeftEdge) << CursorShape(ExtendedCursor::SizeSouthWest); QTest::newRow("left") << Qt::Edges(Qt::LeftEdge) << CursorShape(ExtendedCursor::SizeWest); } void PointerInputTest::testResizeCursor() { // this test verifies that the cursor has correct shape during resize operation // first modify the config for this run KConfigGroup group = kwinApp()->config()->group("MouseBindings"); group.writeEntry("CommandAllKey", "Alt"); group.writeEntry("CommandAll3", "Resize"); group.sync(); workspace()->slotReconfigure(); QCOMPARE(options->commandAllModifier(), Qt::AltModifier); QCOMPARE(options->commandAll3(), Options::MouseUnrestrictedResize); // create a test client using namespace KWayland::Client; QScopedPointer surface(Test::createSurface()); QVERIFY(!surface.isNull()); QScopedPointer shellSurface(Test::createXdgShellStableSurface(surface.data())); QVERIFY(!shellSurface.isNull()); ShellClient *c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); QVERIFY(c); // move the cursor to the test position QPoint cursorPos; QFETCH(Qt::Edges, edges); if (edges & Qt::LeftEdge) { cursorPos.setX(c->geometry().left()); } else if (edges & Qt::RightEdge) { cursorPos.setX(c->geometry().right()); } else { cursorPos.setX(c->geometry().center().x()); } if (edges & Qt::TopEdge) { cursorPos.setY(c->geometry().top()); } else if (edges & Qt::BottomEdge) { cursorPos.setY(c->geometry().bottom()); } else { cursorPos.setY(c->geometry().center().y()); } Cursor::setPos(cursorPos); const PlatformCursorImage arrowCursor = loadReferenceThemeCursor(Qt::ArrowCursor); QVERIFY(!arrowCursor.image().isNull()); QCOMPARE(kwinApp()->platform()->cursorImage().image(), arrowCursor.image()); QCOMPARE(kwinApp()->platform()->cursorImage().hotSpot(), arrowCursor.hotSpot()); // start resizing the client int timestamp = 1; kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTALT, timestamp++); kwinApp()->platform()->pointerButtonPressed(BTN_RIGHT, timestamp++); QVERIFY(c->isResize()); QFETCH(KWin::CursorShape, cursorShape); const PlatformCursorImage resizeCursor = loadReferenceThemeCursor(cursorShape); QVERIFY(!resizeCursor.image().isNull()); QCOMPARE(kwinApp()->platform()->cursorImage().image(), resizeCursor.image()); QCOMPARE(kwinApp()->platform()->cursorImage().hotSpot(), resizeCursor.hotSpot()); // finish resizing the client kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++); kwinApp()->platform()->pointerButtonReleased(BTN_RIGHT, timestamp++); QVERIFY(!c->isResize()); QCOMPARE(kwinApp()->platform()->cursorImage().image(), arrowCursor.image()); QCOMPARE(kwinApp()->platform()->cursorImage().hotSpot(), arrowCursor.hotSpot()); } void PointerInputTest::testMoveCursor() { // this test verifies that the cursor has correct shape during move operation // first modify the config for this run KConfigGroup group = kwinApp()->config()->group("MouseBindings"); group.writeEntry("CommandAllKey", "Alt"); group.writeEntry("CommandAll1", "Move"); group.sync(); workspace()->slotReconfigure(); QCOMPARE(options->commandAllModifier(), Qt::AltModifier); QCOMPARE(options->commandAll1(), Options::MouseUnrestrictedMove); // create a test client using namespace KWayland::Client; QScopedPointer surface(Test::createSurface()); QVERIFY(!surface.isNull()); QScopedPointer shellSurface(Test::createXdgShellStableSurface(surface.data())); QVERIFY(!shellSurface.isNull()); ShellClient *c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); QVERIFY(c); // move cursor to the test position Cursor::setPos(c->geometry().center()); const PlatformCursorImage arrowCursor = loadReferenceThemeCursor(Qt::ArrowCursor); QVERIFY(!arrowCursor.image().isNull()); QCOMPARE(kwinApp()->platform()->cursorImage().image(), arrowCursor.image()); QCOMPARE(kwinApp()->platform()->cursorImage().hotSpot(), arrowCursor.hotSpot()); // start moving the client int timestamp = 1; kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTALT, timestamp++); kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, timestamp++); QVERIFY(c->isMove()); const PlatformCursorImage sizeAllCursor = loadReferenceThemeCursor(Qt::SizeAllCursor); QVERIFY(!sizeAllCursor.image().isNull()); QCOMPARE(kwinApp()->platform()->cursorImage().image(), sizeAllCursor.image()); QCOMPARE(kwinApp()->platform()->cursorImage().hotSpot(), sizeAllCursor.hotSpot()); // finish moving the client kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTALT, timestamp++); kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, timestamp++); QVERIFY(!c->isMove()); QCOMPARE(kwinApp()->platform()->cursorImage().image(), arrowCursor.image()); QCOMPARE(kwinApp()->platform()->cursorImage().hotSpot(), arrowCursor.hotSpot()); } } WAYLANDTEST_MAIN(KWin::PointerInputTest) #include "pointer_input.moc" diff --git a/autotests/mock_abstract_client.h b/autotests/mock_abstract_client.h index 8d7e825d7..54c13e44d 100644 --- a/autotests/mock_abstract_client.h +++ b/autotests/mock_abstract_client.h @@ -1,70 +1,70 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 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_MOCK_ABSTRACT_CLIENT_H #define KWIN_MOCK_ABSTRACT_CLIENT_H #include #include namespace KWin { class AbstractClient : public QObject { Q_OBJECT public: explicit AbstractClient(QObject *parent); - virtual ~AbstractClient(); + ~AbstractClient() override; int screen() const; bool isOnScreen(int screen) const; bool isActive() const; bool isFullScreen() const; bool isHiddenInternal() const; QRect geometry() const; bool keepBelow() const; void setActive(bool active); void setScreen(int screen); void setFullScreen(bool set); void setHiddenInternal(bool set); void setGeometry(const QRect &rect); void setKeepBelow(bool); bool isResize() const; void setResize(bool set); virtual void showOnScreenEdge() = 0; Q_SIGNALS: void geometryChanged(); void keepBelowChanged(); private: bool m_active; int m_screen; bool m_fullscreen; bool m_hiddenInternal; bool m_keepBelow; QRect m_geometry; bool m_resize; }; } #endif diff --git a/autotests/mock_client.h b/autotests/mock_client.h index 17db3c8c7..7900f80dc 100644 --- a/autotests/mock_client.h +++ b/autotests/mock_client.h @@ -1,43 +1,43 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 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_MOCK_CLIENT_H #define KWIN_MOCK_CLIENT_H #include #include #include namespace KWin { class Client : public AbstractClient { Q_OBJECT public: explicit Client(QObject *parent); - virtual ~Client(); + ~Client() override; void showOnScreenEdge() override; }; } #endif diff --git a/autotests/mock_effectshandler.h b/autotests/mock_effectshandler.h index 55ff4ae4f..9eeeafc11 100644 --- a/autotests/mock_effectshandler.h +++ b/autotests/mock_effectshandler.h @@ -1,285 +1,285 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 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 MOCK_EFFECTS_HANDLER_H #define MOCK_EFFECTS_HANDLER_H #include #include class MockEffectsHandler : public KWin::EffectsHandler { Q_OBJECT public: explicit MockEffectsHandler(KWin::CompositingType type); void activateWindow(KWin::EffectWindow *) override {} - KWin::Effect *activeFullScreenEffect() const { + KWin::Effect *activeFullScreenEffect() const override { return nullptr; } bool hasActiveFullScreenEffect() const override { return false; } int activeScreen() const override { return 0; } KWin::EffectWindow *activeWindow() const override { return nullptr; } void addRepaint(const QRect &) override {} void addRepaint(const QRegion &) override {} void addRepaint(int, int, int, int) override {} void addRepaintFull() override {} double animationTimeFactor() const override { return 0; } xcb_atom_t announceSupportProperty(const QByteArray &, KWin::Effect *) override { return XCB_ATOM_NONE; } void buildQuads(KWin::EffectWindow *, KWin::WindowQuadList &) override {} QRect clientArea(KWin::clientAreaOption, const QPoint &, int) const override { return QRect(); } QRect clientArea(KWin::clientAreaOption, const KWin::EffectWindow *) const override { return QRect(); } QRect clientArea(KWin::clientAreaOption, int, int) const override { return QRect(); } void closeTabBox() override {} QString currentActivity() const override { return QString(); } int currentDesktop() const override { return 0; } int currentTabBoxDesktop() const override { return 0; } QList< int > currentTabBoxDesktopList() const override { return QList(); } KWin::EffectWindow *currentTabBoxWindow() const override { return nullptr; } KWin::EffectWindowList currentTabBoxWindowList() const override { return KWin::EffectWindowList(); } QPoint cursorPos() const override { return QPoint(); } bool decorationsHaveAlpha() const override { return false; } bool decorationSupportsBlurBehind() const override { return false; } void defineCursor(Qt::CursorShape) override {} int desktopAbove(int, bool) const override { return 0; } int desktopAtCoords(QPoint) const override { return 0; } int desktopBelow(int, bool) const override { return 0; } QPoint desktopCoords(int) const override { return QPoint(); } QPoint desktopGridCoords(int) const override { return QPoint(); } int desktopGridHeight() const override { return 0; } QSize desktopGridSize() const override { return QSize(); } int desktopGridWidth() const override { return 0; } QString desktopName(int) const override { return QString(); } int desktopToLeft(int, bool) const override { return 0; } int desktopToRight(int, bool) const override { return 0; } void doneOpenGLContextCurrent() override {} void drawWindow(KWin::EffectWindow *, int, QRegion, KWin::WindowPaintData &) override {} KWin::EffectFrame *effectFrame(KWin::EffectFrameStyle, bool, const QPoint &, Qt::Alignment) const override { return nullptr; } KWin::EffectWindow *findWindow(WId) const override { return nullptr; } KWin::EffectWindow *findWindow(KWayland::Server::SurfaceInterface *) const override { return nullptr; } KWin::EffectWindow *findWindow(QWindow *w) const override { Q_UNUSED(w) return nullptr; } KWin::EffectWindow *findWindow(const QUuid &id) const override { Q_UNUSED(id) return nullptr; } void *getProxy(QString) override { return nullptr; } bool grabKeyboard(KWin::Effect *) override { return false; } bool hasDecorationShadows() const override { return false; } bool isScreenLocked() const override { return false; } QVariant kwinOption(KWin::KWinOption) override { return QVariant(); } bool makeOpenGLContextCurrent() override { return false; } void moveWindow(KWin::EffectWindow *, const QPoint &, bool, double) override {} KWin::WindowQuadType newWindowQuadType() override { return KWin::WindowQuadError; } int numberOfDesktops() const override { return 0; } int numScreens() const override { return 0; } bool optionRollOverDesktops() const override { return false; } void paintEffectFrame(KWin::EffectFrame *, QRegion, double, double) override {} void paintScreen(int, QRegion, KWin::ScreenPaintData &) override {} void paintWindow(KWin::EffectWindow *, int, QRegion, KWin::WindowPaintData &) override {} void postPaintScreen() override {} void postPaintWindow(KWin::EffectWindow *) override {} void prePaintScreen(KWin::ScreenPrePaintData &, int) override {} void prePaintWindow(KWin::EffectWindow *, KWin::WindowPrePaintData &, int) override {} QByteArray readRootProperty(long int, long int, int) const override { return QByteArray(); } void reconfigure() override {} void refTabBox() override {} void registerAxisShortcut(Qt::KeyboardModifiers, KWin::PointerAxisDirection, QAction *) override {} void registerGlobalShortcut(const QKeySequence &, QAction *) override {} void registerPointerShortcut(Qt::KeyboardModifiers, Qt::MouseButton, QAction *) override {} void registerTouchpadSwipeShortcut(KWin::SwipeDirection, QAction *) override {} void reloadEffect(KWin::Effect *) override {} void removeSupportProperty(const QByteArray &, KWin::Effect *) override {} void reserveElectricBorder(KWin::ElectricBorder, KWin::Effect *) override {} void registerTouchBorder(KWin::ElectricBorder, QAction *) override {} void unregisterTouchBorder(KWin::ElectricBorder, QAction *) override {} QPainter *scenePainter() override { return nullptr; } int screenNumber(const QPoint &) const override { return 0; } void setActiveFullScreenEffect(KWin::Effect *) override {} void setCurrentDesktop(int) override {} void setElevatedWindow(KWin::EffectWindow *, bool) override {} void setNumberOfDesktops(int) override {} void setShowingDesktop(bool) override {} void setTabBoxDesktop(int) override {} void setTabBoxWindow(KWin::EffectWindow*) override {} KWin::EffectWindowList stackingOrder() const override { return KWin::EffectWindowList(); } void startMouseInterception(KWin::Effect *, Qt::CursorShape) override {} void startMousePolling() override {} void stopMouseInterception(KWin::Effect *) override {} void stopMousePolling() override {} void ungrabKeyboard() override {} void unrefTabBox() override {} void unreserveElectricBorder(KWin::ElectricBorder, KWin::Effect *) override {} QRect virtualScreenGeometry() const override { return QRect(); } QSize virtualScreenSize() const override { return QSize(); } void windowToDesktop(KWin::EffectWindow *, int) override {} void windowToScreen(KWin::EffectWindow *, int) override {} int workspaceHeight() const override { return 0; } int workspaceWidth() const override { return 0; } long unsigned int xrenderBufferPicture() override { return 0; } xcb_connection_t *xcbConnection() const override { return QX11Info::connection(); } xcb_window_t x11RootWindow() const override { return QX11Info::appRootWindow(); } KWayland::Server::Display *waylandDisplay() const override { return nullptr; } bool animationsSupported() const override { return m_animationsSuported; } void setAnimationsSupported(bool set) { m_animationsSuported = set; } KWin::PlatformCursorImage cursorImage() const override { return KWin::PlatformCursorImage(); } void hideCursor() override {} void showCursor() override {} void startInteractiveWindowSelection(std::function callback) override { callback(nullptr); } void startInteractivePositionSelection(std::function callback) override { callback(QPoint(-1, -1)); } void showOnScreenMessage(const QString &message, const QString &iconName = QString()) override { Q_UNUSED(message) Q_UNUSED(iconName) } void hideOnScreenMessage(OnScreenMessageHideFlags flags = OnScreenMessageHideFlags()) override { Q_UNUSED(flags)} - void windowToDesktops(KWin::EffectWindow *w, const QVector &desktops) { + void windowToDesktops(KWin::EffectWindow *w, const QVector &desktops) override { Q_UNUSED(w) Q_UNUSED(desktops) } KSharedConfigPtr config() const override; KSharedConfigPtr inputConfig() const override; private: bool m_animationsSuported = true; }; #endif diff --git a/autotests/mock_screens.h b/autotests/mock_screens.h index 5c6b8c2d1..1150e034f 100644 --- a/autotests/mock_screens.h +++ b/autotests/mock_screens.h @@ -1,53 +1,53 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 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_MOCK_SCREENS_H #define KWIN_MOCK_SCREENS_H #include "../screens.h" namespace KWin { class MockScreens : public Screens { Q_OBJECT public: explicit MockScreens(QObject *parent = nullptr); - virtual ~MockScreens(); + ~MockScreens() override; QRect geometry(int screen) const override; int number(const QPoint &pos) const override; QString name(int screen) const override; float refreshRate(int screen) const override; QSize size(int screen) const override; void init() override; void setGeometries(const QList &geometries); protected Q_SLOTS: void updateCount() override; private: QList m_scheduledGeometries; QList m_geometries; }; } #endif diff --git a/autotests/mock_workspace.h b/autotests/mock_workspace.h index 1a87ddcbf..f55a51c0c 100644 --- a/autotests/mock_workspace.h +++ b/autotests/mock_workspace.h @@ -1,83 +1,83 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 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_MOCK_WORKSPACE_H #define KWIN_MOCK_WORKSPACE_H #include #include namespace KWin { class AbstractClient; class Client; class X11EventFilter; class MockWorkspace; typedef MockWorkspace Workspace; class MockWorkspace : public QObject { Q_OBJECT public: explicit MockWorkspace(QObject *parent = nullptr); - virtual ~MockWorkspace(); + ~MockWorkspace() override; AbstractClient *activeClient() const; AbstractClient *moveResizeClient() const; void setShowingDesktop(bool showing); bool showingDesktop() const; QRect clientArea(clientAreaOption, int screen, int desktop) const; void setActiveClient(AbstractClient *c); void setMoveResizeClient(AbstractClient *c); void registerEventFilter(X11EventFilter *filter); void unregisterEventFilter(X11EventFilter *filter); bool compositing() const { return false; } static Workspace *self(); Q_SIGNALS: void clientRemoved(KWin::Client*); private: AbstractClient *m_activeClient; AbstractClient *m_moveResizeClient; bool m_showingDesktop; static Workspace *s_self; }; inline Workspace *MockWorkspace::self() { return s_self; } inline Workspace *workspace() { return Workspace::self(); } } #endif diff --git a/autotests/tabbox/mock_tabboxclient.h b/autotests/tabbox/mock_tabboxclient.h index f8ce00cd4..6d45eb74b 100644 --- a/autotests/tabbox/mock_tabboxclient.h +++ b/autotests/tabbox/mock_tabboxclient.h @@ -1,78 +1,78 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2012 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_MOCK_TABBOX_CLIENT_H #define KWIN_MOCK_TABBOX_CLIENT_H #include "../../tabbox/tabboxhandler.h" #include #include namespace KWin { class MockTabBoxClient : public TabBox::TabBoxClient { public: explicit MockTabBoxClient(QString caption, WId id); - virtual bool isMinimized() const { + bool isMinimized() const override { return false; } - virtual QString caption() const { + QString caption() const override { return m_caption; } - virtual void close(); - virtual int height() const { + void close() override; + int height() const override { return 100; } virtual QPixmap icon(const QSize &size = QSize(32, 32)) const { return QPixmap(size); } - virtual bool isCloseable() const { + bool isCloseable() const override { return true; } - virtual bool isFirstInTabBox() const { + bool isFirstInTabBox() const override { return false; } - virtual int width() const { + int width() const override { return 100; } - virtual WId window() const { + WId window() const override { return m_wId; } - virtual int x() const { + int x() const override { return 0; } - virtual int y() const { + int y() const override { return 0; } - virtual QIcon icon() const { + QIcon icon() const override { return QIcon(); } QUuid internalId() const override { return QUuid{}; } private: QString m_caption; WId m_wId; }; } // namespace KWin #endif diff --git a/autotests/tabbox/mock_tabboxhandler.h b/autotests/tabbox/mock_tabboxhandler.h index 4820a3d6a..841f189d4 100644 --- a/autotests/tabbox/mock_tabboxhandler.h +++ b/autotests/tabbox/mock_tabboxhandler.h @@ -1,113 +1,113 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2012 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_MOCK_TABBOX_HANDLER_H #define KWIN_MOCK_TABBOX_HANDLER_H #include "../../tabbox/tabboxhandler.h" namespace KWin { class MockTabBoxHandler : public TabBox::TabBoxHandler { Q_OBJECT public: MockTabBoxHandler(QObject *parent = nullptr); - virtual ~MockTabBoxHandler(); - virtual void activateAndClose() { + ~MockTabBoxHandler() override; + void activateAndClose() override { } - virtual QWeakPointer< TabBox::TabBoxClient > activeClient() const; + QWeakPointer< TabBox::TabBoxClient > activeClient() const override; void setActiveClient(const QWeakPointer &client); - virtual int activeScreen() const { + int activeScreen() const override { return 0; } - virtual QWeakPointer< TabBox::TabBoxClient > clientToAddToList(TabBox::TabBoxClient *client, int desktop) const; - virtual int currentDesktop() const { + QWeakPointer< TabBox::TabBoxClient > clientToAddToList(TabBox::TabBoxClient *client, int desktop) const override; + int currentDesktop() const override { return 1; } - virtual QWeakPointer< TabBox::TabBoxClient > desktopClient() const { + QWeakPointer< TabBox::TabBoxClient > desktopClient() const override { return QWeakPointer(); } - virtual QString desktopName(int desktop) const { + QString desktopName(int desktop) const override { Q_UNUSED(desktop) return "desktop 1"; } - virtual QString desktopName(TabBox::TabBoxClient *client) const { + QString desktopName(TabBox::TabBoxClient *client) const override { Q_UNUSED(client) return "desktop"; } - virtual void elevateClient(TabBox::TabBoxClient *c, QWindow *tabbox, bool elevate) const { + void elevateClient(TabBox::TabBoxClient *c, QWindow *tabbox, bool elevate) const override { Q_UNUSED(c) Q_UNUSED(tabbox) Q_UNUSED(elevate) } - virtual void shadeClient(TabBox::TabBoxClient *c, bool b) const { + void shadeClient(TabBox::TabBoxClient *c, bool b) const override { Q_UNUSED(c) Q_UNUSED(b) } virtual void hideOutline() { } - virtual QWeakPointer< TabBox::TabBoxClient > nextClientFocusChain(TabBox::TabBoxClient *client) const; - virtual QWeakPointer firstClientFocusChain() const; - virtual bool isInFocusChain (TabBox::TabBoxClient* client) const; - virtual int nextDesktopFocusChain(int desktop) const { + QWeakPointer< TabBox::TabBoxClient > nextClientFocusChain(TabBox::TabBoxClient *client) const override; + QWeakPointer firstClientFocusChain() const override; + bool isInFocusChain (TabBox::TabBoxClient* client) const override; + int nextDesktopFocusChain(int desktop) const override { Q_UNUSED(desktop) return 1; } - virtual int numberOfDesktops() const { + int numberOfDesktops() const override { return 1; } virtual QVector< xcb_window_t > outlineWindowIds() const { return QVector(); } - virtual bool isKWinCompositing() const { + bool isKWinCompositing() const override { return false; } - virtual void raiseClient(TabBox::TabBoxClient *c) const { + void raiseClient(TabBox::TabBoxClient *c) const override { Q_UNUSED(c) } - virtual void restack(TabBox::TabBoxClient *c, TabBox::TabBoxClient *under) { + void restack(TabBox::TabBoxClient *c, TabBox::TabBoxClient *under) override { Q_UNUSED(c) Q_UNUSED(under) } virtual void showOutline(const QRect &outline) { Q_UNUSED(outline) } - virtual TabBox::TabBoxClientList stackingOrder() const { + TabBox::TabBoxClientList stackingOrder() const override { return TabBox::TabBoxClientList(); } - virtual void grabbedKeyEvent(QKeyEvent *event) const; + void grabbedKeyEvent(QKeyEvent *event) const override; void highlightWindows(TabBox::TabBoxClient *window = nullptr, QWindow *controller = nullptr) override { Q_UNUSED(window) Q_UNUSED(controller) } bool noModifierGrab() const override { return false; } // mock methods QWeakPointer createMockWindow(const QString &caption, WId id); void closeWindow(TabBox::TabBoxClient *client); private: QList< QSharedPointer > m_windows; QWeakPointer m_activeClient; }; } // namespace KWin #endif diff --git a/autotests/test_virtualkeyboard_dbus.cpp b/autotests/test_virtualkeyboard_dbus.cpp index ba83c8726..57123562f 100644 --- a/autotests/test_virtualkeyboard_dbus.cpp +++ b/autotests/test_virtualkeyboard_dbus.cpp @@ -1,142 +1,142 @@ /******************************************************************** 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 #include #include #include #include #include "../virtualkeyboard_dbus.h" using KWin::VirtualKeyboardDBus; class VirtualKeyboardDBusTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase(); void testEnabled(); void testRequestEnabled_data(); void testRequestEnabled(); }; class DbusPropertyHelper : public QObject { Q_OBJECT public: DbusPropertyHelper() : QObject(nullptr) { QDBusConnection::sessionBus().connect( QStringLiteral("org.kde.kwin.testvirtualkeyboard"), QStringLiteral("/VirtualKeyboard"), QStringLiteral("org.kde.kwin.VirtualKeyboard"), QStringLiteral("enabledChanged"), this, SLOT(slotEnabledChanged())); } - ~DbusPropertyHelper() = default; + ~DbusPropertyHelper() override = default; Q_SIGNALS: void enabledChanged(); private Q_SLOTS: void slotEnabledChanged() { emit enabledChanged(); } }; void VirtualKeyboardDBusTest::initTestCase() { QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.kwin.testvirtualkeyboard")); } void VirtualKeyboardDBusTest::testEnabled() { VirtualKeyboardDBus dbus; DbusPropertyHelper helper; QSignalSpy helperChangedSpy(&helper, &DbusPropertyHelper::enabledChanged); QVERIFY(helperChangedSpy.isValid()); QCOMPARE(dbus.isEnabled(), false); QCOMPARE(dbus.property("enabled").toBool(), false); QSignalSpy enabledChangedSpy(&dbus, &VirtualKeyboardDBus::enabledChanged); QVERIFY(enabledChangedSpy.isValid()); auto readProperty = [] (bool enabled) { const QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kwin.testvirtualkeyboard"), QStringLiteral("/VirtualKeyboard"), QStringLiteral("org.kde.kwin.VirtualKeyboard"), QStringLiteral("isEnabled")); const auto reply = QDBusConnection::sessionBus().call(message); QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); QCOMPARE(reply.arguments().count(), 1); QCOMPARE(reply.arguments().first().toBool(), enabled); }; readProperty(false); dbus.setEnabled(true); QCOMPARE(enabledChangedSpy.count(), 1); QVERIFY(helperChangedSpy.wait()); QCOMPARE(helperChangedSpy.count(), 1); QCOMPARE(dbus.isEnabled(), true); QCOMPARE(dbus.property("enabled").toBool(), true); readProperty(true); // setting again to enabled should not change anything dbus.setEnabled(true); QCOMPARE(enabledChangedSpy.count(), 1); // back to false dbus.setEnabled(false); QCOMPARE(enabledChangedSpy.count(), 2); QVERIFY(helperChangedSpy.wait()); QCOMPARE(helperChangedSpy.count(), 2); QCOMPARE(dbus.isEnabled(), false); QCOMPARE(dbus.property("enabled").toBool(), false); readProperty(false); } void VirtualKeyboardDBusTest::testRequestEnabled_data() { QTest::addColumn("method"); QTest::addColumn("expectedResult"); QTest::newRow("enable") << QStringLiteral("enable") << true; QTest::newRow("disable") << QStringLiteral("disable") << false; } void VirtualKeyboardDBusTest::testRequestEnabled() { VirtualKeyboardDBus dbus; QSignalSpy activateRequestedSpy(&dbus, &VirtualKeyboardDBus::activateRequested); QVERIFY(activateRequestedSpy.isValid()); QFETCH(QString, method); const QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kwin.testvirtualkeyboard"), QStringLiteral("/VirtualKeyboard"), QStringLiteral("org.kde.kwin.VirtualKeyboard"), method); QDBusConnection::sessionBus().asyncCall(message); QTRY_COMPARE(activateRequestedSpy.count(), 1); QTEST(activateRequestedSpy.first().first().toBool(), "expectedResult"); } QTEST_GUILESS_MAIN(VirtualKeyboardDBusTest) #include "test_virtualkeyboard_dbus.moc" diff --git a/autotests/test_x11_timestamp_update.cpp b/autotests/test_x11_timestamp_update.cpp index c6169e1ab..5e7f40cfa 100644 --- a/autotests/test_x11_timestamp_update.cpp +++ b/autotests/test_x11_timestamp_update.cpp @@ -1,140 +1,140 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2017 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 #include #include #include #include "main.h" #include "utils.h" namespace KWin { class X11TestApplication : public Application { Q_OBJECT public: X11TestApplication(int &argc, char **argv); - virtual ~X11TestApplication(); + ~X11TestApplication() override; protected: void performStartup() override; }; X11TestApplication::X11TestApplication(int &argc, char **argv) : Application(OperationModeX11, argc, argv) { setX11Connection(QX11Info::connection()); setX11RootWindow(QX11Info::appRootWindow()); // move directory containing executable to front, so that KPluginLoader prefers the plugins in // the build dir over system installed ones const auto ownPath = libraryPaths().last(); removeLibraryPath(ownPath); addLibraryPath(ownPath); const auto plugins = KPluginLoader::findPluginsById(QStringLiteral("org.kde.kwin.platforms"), QStringLiteral("KWinX11Platform")); if (plugins.empty()) { quit(); return; } initPlatform(plugins.first()); } X11TestApplication::~X11TestApplication() { } void X11TestApplication::performStartup() { } } class X11TimestampUpdateTest : public QObject { Q_OBJECT private Q_SLOTS: void testGrabAfterServerTime(); void testBeforeLastGrabTime(); }; void X11TimestampUpdateTest::testGrabAfterServerTime() { // this test tries to grab the X keyboard with a timestamp in future // that should fail, but after updating the X11 timestamp, it should // work again KWin::updateXTime(); QCOMPARE(KWin::grabXKeyboard(), true); KWin::ungrabXKeyboard(); // now let's change the timestamp KWin::kwinApp()->setX11Time(KWin::xTime() + 5 * 60 * 1000); // now grab keyboard should fail QCOMPARE(KWin::grabXKeyboard(), false); // let's update timestamp, now it should work again KWin::updateXTime(); QCOMPARE(KWin::grabXKeyboard(), true); KWin::ungrabXKeyboard(); } void X11TimestampUpdateTest::testBeforeLastGrabTime() { // this test tries to grab the X keyboard with a timestamp before the // last grab time on the server. That should fail, but after updating the X11 // timestamp it should work again // first set the grab timestamp KWin::updateXTime(); QCOMPARE(KWin::grabXKeyboard(), true); KWin::ungrabXKeyboard(); // now go to past const auto timestamp = KWin::xTime(); KWin::kwinApp()->setX11Time(KWin::xTime() - 5 * 60 * 1000, KWin::Application::TimestampUpdate::Always); QCOMPARE(KWin::xTime(), timestamp - 5 * 60 * 1000); // now grab keyboard should fail QCOMPARE(KWin::grabXKeyboard(), false); // let's update timestamp, now it should work again KWin::updateXTime(); QVERIFY(KWin::xTime() >= timestamp); QCOMPARE(KWin::grabXKeyboard(), true); KWin::ungrabXKeyboard(); } int main(int argc, char *argv[]) { setenv("QT_QPA_PLATFORM", "xcb", true); KWin::X11TestApplication app(argc, argv); app.setAttribute(Qt::AA_Use96Dpi, true); X11TimestampUpdateTest tc; return QTest::qExec(&tc, argc, argv); } #include "test_x11_timestamp_update.moc" diff --git a/client.h b/client.h index 85047266f..7813ace08 100644 --- a/client.h +++ b/client.h @@ -1,699 +1,699 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 1999, 2000 Matthias Ettrich Copyright (C) 2003 Lubos Lunak 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_CLIENT_H #define KWIN_CLIENT_H // kwin #include "options.h" #include "rules.h" #include "tabgroup.h" #include "abstract_client.h" #include "xcbutils.h" // Qt #include #include #include #include #include // X #include // TODO: Cleanup the order of things in this .h file class QTimer; class KStartupInfoData; class KStartupInfoId; namespace KWin { /** * @brief Defines Predicates on how to search for a Client. * * Used by Workspace::findClient. **/ enum class Predicate { WindowMatch, WrapperIdMatch, FrameIdMatch, InputIdMatch }; class KWIN_EXPORT Client : public AbstractClient { Q_OBJECT /** * By how much the window wishes to grow/shrink at least. Usually QSize(1,1). * MAY BE DISOBEYED BY THE WM! It's only for information, do NOT rely on it at all. * The value is evaluated each time the getter is called. * Because of that no changed signal is provided. **/ Q_PROPERTY(QSize basicUnit READ basicUnit) /** * A client can block compositing. That is while the Client is alive and the state is set, * Compositing is suspended and is resumed when there are no Clients blocking compositing any * more. * * This is actually set by a window property, unfortunately not used by the target application * group. For convenience it's exported as a property to the scripts. * * Use with care! **/ Q_PROPERTY(bool blocksCompositing READ isBlockingCompositing WRITE setBlockingCompositing NOTIFY blockingCompositingChanged) /** * Whether the Client uses client side window decorations. * Only GTK+ are detected. **/ Q_PROPERTY(bool clientSideDecorated READ isClientSideDecorated NOTIFY clientSideDecoratedChanged) public: explicit Client(); xcb_window_t wrapperId() const; xcb_window_t inputId() const { return m_decoInputExtent; } - virtual xcb_window_t frameId() const override; + xcb_window_t frameId() const override; bool isTransient() const override; bool groupTransient() const override; bool wasOriginallyGroupTransient() const; QList mainClients() const override; // Call once before loop , is not indirect bool hasTransient(const AbstractClient* c, bool indirect) const override; void checkTransient(xcb_window_t w); AbstractClient* findModal(bool allow_itself = false) override; const Group* group() const override; Group* group() override; void checkGroup(Group* gr = NULL, bool force = false); void changeClientLeaderGroup(Group* gr); void updateWindowRules(Rules::Types selection) override; void updateFullscreenMonitors(NETFullscreenMonitors topology); bool hasNETSupport() const; QSize minSize() const override; QSize maxSize() const override; QSize basicUnit() const; - virtual QSize clientSize() const; + QSize clientSize() const override; QPoint inputPos() const { return input_offset; } // Inside of geometry() bool windowEvent(xcb_generic_event_t *e); - NET::WindowType windowType(bool direct = false, int supported_types = 0) const; + NET::WindowType windowType(bool direct = false, int supported_types = 0) const override; bool manage(xcb_window_t w, bool isMapped); void releaseWindow(bool on_shutdown = false); void destroyClient(); - virtual QStringList activities() const; + QStringList activities() const override; void setOnActivity(const QString &activity, bool enable); void setOnAllActivities(bool set) override; void setOnActivities(QStringList newActivitiesList) override; void updateActivities(bool includeTransients); void blockActivityUpdates(bool b = true) override; /// Is not minimized and not hidden. I.e. normally visible on some virtual desktop. bool isShown(bool shaded_is_shown) const override; bool isHiddenInternal() const override; // For compositing ShadeMode shadeMode() const override; // Prefer isShade() void setShade(ShadeMode mode) override; bool isShadeable() const override; bool isMaximizable() const override; QRect geometryRestore() const override; MaximizeMode maximizeMode() const override; bool isMinimizable() const override; QRect iconGeometry() const override; bool isFullScreenable() const override; void setFullScreen(bool set, bool user = true) override; bool isFullScreen() const override; bool userCanSetFullScreen() const override; QRect geometryFSRestore() const { return geom_fs_restore; // only for session saving } int fullScreenMode() const { return m_fullscreenMode; // only for session saving } bool userNoBorder() const; bool noBorder() const override; void setNoBorder(bool set) override; bool userCanSetNoBorder() const override; void checkNoBorder() override; int sessionStackingOrder() const; // Auxiliary functions, depend on the windowType bool wantsInput() const override; bool isResizable() const override; bool isMovable() const override; bool isMovableAcrossScreens() const override; bool isCloseable() const override; ///< May be closed by the user (May have a close button) void takeFocus() override; void updateDecoration(bool check_workspace_pos, bool force = false) override; void updateShape(); using AbstractClient::setGeometry; void setGeometry(int x, int y, int w, int h, ForceGeometry_t force = NormalGeometrySet) override; /// plainResize() simply resizes void plainResize(int w, int h, ForceGeometry_t force = NormalGeometrySet); void plainResize(const QSize& s, ForceGeometry_t force = NormalGeometrySet); /// resizeWithChecks() resizes according to gravity, and checks workarea position using AbstractClient::resizeWithChecks; void resizeWithChecks(int w, int h, ForceGeometry_t force = NormalGeometrySet) override; void resizeWithChecks(int w, int h, xcb_gravity_t gravity, ForceGeometry_t force = NormalGeometrySet); void resizeWithChecks(const QSize& s, xcb_gravity_t gravity, ForceGeometry_t force = NormalGeometrySet); QSize sizeForClientSize(const QSize&, Sizemode mode = SizemodeAny, bool noframe = false) const override; bool providesContextHelp() const override; Options::WindowOperation mouseButtonToWindowOperation(Qt::MouseButtons button); bool performMouseCommand(Options::MouseCommand, const QPoint& globalPos) override; QRect adjustedClientArea(const QRect& desktop, const QRect& area) const; xcb_colormap_t colormap() const; /// Updates visibility depending on being shaded, virtual desktop, etc. void updateVisibility(); /// Hides a client - Basically like minimize, but without effects, it's simply hidden void hideClient(bool hide) override; bool hiddenPreview() const; ///< Window is mapped in order to get a window pixmap - virtual bool setupCompositing(); + bool setupCompositing() override; void finishCompositing(ReleaseReason releaseReason = ReleaseReason::Release) override; void setBlockingCompositing(bool block); inline bool isBlockingCompositing() { return blocks_compositing; } QString captionNormal() const override { return cap_normal; } QString captionSuffix() const override { return cap_suffix; } using AbstractClient::keyPressEvent; void keyPressEvent(uint key_code, xcb_timestamp_t time); // FRAME ?? void updateMouseGrab() override; xcb_window_t moveResizeGrabWindow() const; const QPoint calculateGravitation(bool invert, int gravity = 0) const; // FRAME public? void NETMoveResize(int x_root, int y_root, NET::Direction direction); void NETMoveResizeWindow(int flags, int x, int y, int width, int height); void restackWindow(xcb_window_t above, int detail, NET::RequestSource source, xcb_timestamp_t timestamp, bool send_event = false); void gotPing(xcb_timestamp_t timestamp); void updateUserTime(xcb_timestamp_t time = XCB_TIME_CURRENT_TIME); xcb_timestamp_t userTime() const override; bool hasUserTimeSupport() const; /// Does 'delete c;' static void deleteClient(Client* c); static bool belongToSameApplication(const Client* c1, const Client* c2, SameApplicationChecks checks = SameApplicationChecks()); static bool sameAppWindowRoleMatch(const Client* c1, const Client* c2, bool active_hack); void killWindow() override; void toggleShade(); void showContextHelp() override; void cancelShadeHoverTimer(); void checkActiveModal(); StrutRect strutRect(StrutArea area) const; StrutRects strutRects() const; bool hasStrut() const override; /** * If shown is true the client is mapped and raised, if false * the client is unmapped and hidden, this function is called * when the tabbing group of the client switches its visible * client. **/ void setClientShown(bool shown) override; /** * Whether or not the window has a strut that expands through the invisible area of * an xinerama setup where the monitors are not the same resolution. **/ bool hasOffscreenXineramaStrut() const; // Decorations <-> Effects - QRect decorationRect() const; + QRect decorationRect() const override; - QRect transparentRect() const; + QRect transparentRect() const override; bool isClientSideDecorated() const; bool wantsShadowToBeRendered() const override; void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom) const override; Xcb::Property fetchFirstInTabBox() const; void readFirstInTabBox(Xcb::Property &property); void updateFirstInTabBox(); Xcb::StringProperty fetchColorScheme() const; void readColorScheme(Xcb::StringProperty &property); void updateColorScheme() override; //sets whether the client should be faked as being on all activities (and be shown during session save) void setSessionActivityOverride(bool needed); - virtual bool isClient() const; + bool isClient() const override; template void print(T &stream) const; void cancelFocusOutTimer(); /** * Restores the Client after it had been hidden due to show on screen edge functionality. * In addition the property gets deleted so that the Client knows that it is visible again. **/ void showOnScreenEdge() override; Xcb::StringProperty fetchApplicationMenuServiceName() const; void readApplicationMenuServiceName(Xcb::StringProperty &property); void checkApplicationMenuServiceName(); Xcb::StringProperty fetchApplicationMenuObjectPath() const; void readApplicationMenuObjectPath(Xcb::StringProperty &property); void checkApplicationMenuObjectPath(); struct SyncRequest { xcb_sync_counter_t counter; xcb_sync_int64_t value; xcb_sync_alarm_t alarm; xcb_timestamp_t lastTimestamp; QTimer *timeout, *failsafeTimeout; bool isPending; }; const SyncRequest &getSyncRequest() const { return syncRequest; } void handleSync(); static void cleanupX11(); public Q_SLOTS: void closeWindow() override; void updateCaption() override; private Q_SLOTS: void shadeHover(); void shadeUnhover(); private: // Use Workspace::createClient() - virtual ~Client(); ///< Use destroyClient() or releaseWindow() + ~Client() override; ///< Use destroyClient() or releaseWindow() // Handlers for X11 events bool mapRequestEvent(xcb_map_request_event_t *e); void unmapNotifyEvent(xcb_unmap_notify_event_t *e); void destroyNotifyEvent(xcb_destroy_notify_event_t *e); void configureRequestEvent(xcb_configure_request_event_t *e); - virtual void propertyNotifyEvent(xcb_property_notify_event_t *e) override; + void propertyNotifyEvent(xcb_property_notify_event_t *e) override; void clientMessageEvent(xcb_client_message_event_t *e) override; void enterNotifyEvent(xcb_enter_notify_event_t *e); void leaveNotifyEvent(xcb_leave_notify_event_t *e); void focusInEvent(xcb_focus_in_event_t *e); void focusOutEvent(xcb_focus_out_event_t *e); - virtual void damageNotifyEvent(); + void damageNotifyEvent() override; bool buttonPressEvent(xcb_window_t w, int button, int state, int x, int y, int x_root, int y_root, xcb_timestamp_t time = XCB_CURRENT_TIME); bool buttonReleaseEvent(xcb_window_t w, int button, int state, int x, int y, int x_root, int y_root); bool motionNotifyEvent(xcb_window_t w, int state, int x, int y, int x_root, int y_root); Client* findAutogroupCandidate() const; protected: - virtual void debug(QDebug& stream) const; + void debug(QDebug& stream) const override; void addDamage(const QRegion &damage) override; bool belongsToSameApplication(const AbstractClient *other, SameApplicationChecks checks) const override; void doSetActive() override; void doSetKeepAbove() override; void doSetKeepBelow() override; void doSetDesktop(int desktop, int was_desk) override; void doMinimize() override; void doSetSkipPager() override; void doSetSkipTaskbar() override; void doSetSkipSwitcher() override; bool belongsToDesktop() const override; void setGeometryRestore(const QRect &geo) override; void updateTabGroupStates(TabGroup::States states) override; void doMove(int x, int y) override; bool doStartMoveResize() override; void doPerformMoveResize() override; bool isWaitingForMoveResizeSync() const override; void doResizeSync() override; QSize resizeIncrements() const override; bool acceptsFocus() const override; //Signals for the scripting interface //Signals make an excellent way for communication //in between objects as compared to simple function //calls Q_SIGNALS: void clientManaging(KWin::Client*); void clientFullScreenSet(KWin::Client*, bool, bool); /** * Emitted whenever the Client want to show it menu **/ void showRequest(); /** * Emitted whenever the Client's menu is closed **/ void menuHidden(); /** * Emitted whenever the Client's menu is available **/ void appMenuAvailable(); /** * Emitted whenever the Client's menu is unavailable **/ void appMenuUnavailable(); /** * Emitted whenever the Client's block compositing state changes. **/ void blockingCompositingChanged(KWin::Client *client); void clientSideDecoratedChanged(); private: void exportMappingState(int s); // ICCCM 4.1.3.1, 4.1.4, NETWM 2.5.1 bool isManaged() const; ///< Returns false if this client is not yet managed void updateAllowedActions(bool force = false); QRect fullscreenMonitorsArea(NETFullscreenMonitors topology) const; void changeMaximize(bool horizontal, bool vertical, bool adjust) override; void getWmNormalHints(); void getMotifHints(); void getIcons(); void fetchName(); void fetchIconicName(); QString readName() const; void setCaption(const QString& s, bool force = false); bool hasTransientInternal(const Client* c, bool indirect, ConstClientList& set) const; void setShortcutInternal() override; void configureRequest(int value_mask, int rx, int ry, int rw, int rh, int gravity, bool from_tool); NETExtendedStrut strut() const; int checkShadeGeometry(int w, int h); void getSyncCounter(); void sendSyncRequest(); void leaveMoveResize() override; void positionGeometryTip() override; void grabButton(int mod); void ungrabButton(int mod); void resizeDecoration(); void createDecoration(const QRect &oldgeom); void pingWindow(); void killProcess(bool ask, xcb_timestamp_t timestamp = XCB_TIME_CURRENT_TIME); void updateUrgency(); static void sendClientMessage(xcb_window_t w, xcb_atom_t a, xcb_atom_t protocol, uint32_t data1 = 0, uint32_t data2 = 0, uint32_t data3 = 0, xcb_timestamp_t timestamp = xTime()); void embedClient(xcb_window_t w, xcb_visualid_t visualid, xcb_colormap_t colormap, uint8_t depth); void detectNoBorder(); Xcb::Property fetchGtkFrameExtents() const; void readGtkFrameExtents(Xcb::Property &prop); void detectGtkFrameExtents(); void destroyDecoration() override; void updateFrameExtents(); void internalShow(); void internalHide(); void internalKeep(); void map(); void unmap(); void updateHiddenPreview(); void updateInputShape(); xcb_timestamp_t readUserTimeMapTimestamp(const KStartupInfoId* asn_id, const KStartupInfoData* asn_data, bool session) const; xcb_timestamp_t readUserCreationTime() const; void startupIdChanged(); void updateInputWindow(); Xcb::Property fetchShowOnScreenEdge() const; void readShowOnScreenEdge(Xcb::Property &property); /** * Reads the property and creates/destroys the screen edge if required * and shows/hides the client. **/ void updateShowOnScreenEdge(); Xcb::Window m_client; Xcb::Window m_wrapper; Xcb::Window m_frame; QStringList activityList; int m_activityUpdatesBlocked; bool m_blockedActivityUpdatesRequireTransients; Xcb::Window m_moveResizeGrabWindow; bool move_resize_has_keyboard_grab; bool m_managed; Xcb::GeometryHints m_geometryHints; void sendSyntheticConfigureNotify(); enum MappingState { Withdrawn, ///< Not handled, as per ICCCM WithdrawnState Mapped, ///< The frame is mapped Unmapped, ///< The frame is not mapped Kept ///< The frame should be unmapped, but is kept (For compositing) }; MappingState mapping_state; Xcb::TransientFor fetchTransient() const; void readTransientProperty(Xcb::TransientFor &transientFor); void readTransient(); xcb_window_t verifyTransientFor(xcb_window_t transient_for, bool set); void addTransient(AbstractClient* cl) override; void removeTransient(AbstractClient* cl) override; void removeFromMainClients(); void cleanGrouping(); void checkGroupTransients(); void setTransient(xcb_window_t new_transient_for_id); xcb_window_t m_transientForId; xcb_window_t m_originalTransientForId; ShadeMode shade_mode; Client *shade_below; uint deleting : 1; ///< True when doing cleanup and destroying the client Xcb::MotifHints m_motif; uint hidden : 1; ///< Forcibly hidden by calling hide() uint noborder : 1; uint app_noborder : 1; ///< App requested no border via window type, shape extension, etc. uint ignore_focus_stealing : 1; ///< Don't apply focus stealing prevention to this client bool blocks_compositing; enum FullScreenMode { FullScreenNone, FullScreenNormal } m_fullscreenMode; MaximizeMode max_mode; QRect geom_restore; QRect geom_fs_restore; QTimer* shadeHoverTimer; xcb_colormap_t m_colormap; QString cap_normal, cap_iconic, cap_suffix; Group* in_group; QTimer* ping_timer; qint64 m_killHelperPID; xcb_timestamp_t m_pingTimestamp; xcb_timestamp_t m_userTime; NET::Actions allowed_actions; QSize client_size; bool shade_geometry_change; SyncRequest syncRequest; static bool check_active_modal; ///< \see Client::checkActiveModal() int sm_stacking_order; friend struct ResetupRulesProcedure; friend bool performTransiencyCheck(); Xcb::StringProperty fetchActivities() const; void readActivities(Xcb::StringProperty &property); void checkActivities(); bool activitiesDefined; //whether the x property was actually set bool sessionActivityOverride; bool needsXWindowMove; Xcb::Window m_decoInputExtent; QPoint input_offset; QTimer *m_focusOutTimer; QList m_connections; bool m_clientSideDecorated; QMetaObject::Connection m_edgeRemoveConnection; QMetaObject::Connection m_edgeGeometryTrackingConnection; }; inline xcb_window_t Client::wrapperId() const { return m_wrapper; } inline bool Client::isClientSideDecorated() const { return m_clientSideDecorated; } inline bool Client::groupTransient() const { return m_transientForId == rootWindow(); } // Needed because verifyTransientFor() may set transient_for_id to root window, // if the original value has a problem (window doesn't exist, etc.) inline bool Client::wasOriginallyGroupTransient() const { return m_originalTransientForId == rootWindow(); } inline bool Client::isTransient() const { return m_transientForId != XCB_WINDOW_NONE; } inline const Group* Client::group() const { return in_group; } inline Group* Client::group() { return in_group; } inline bool Client::isShown(bool shaded_is_shown) const { return !isMinimized() && (!isShade() || shaded_is_shown) && !hidden && (!tabGroup() || tabGroup()->current() == this); } inline bool Client::isHiddenInternal() const { return hidden; } inline ShadeMode Client::shadeMode() const { return shade_mode; } inline QRect Client::geometryRestore() const { return geom_restore; } inline void Client::setGeometryRestore(const QRect &geo) { geom_restore = geo; } inline MaximizeMode Client::maximizeMode() const { return max_mode; } inline bool Client::isFullScreen() const { return m_fullscreenMode != FullScreenNone; } inline bool Client::hasNETSupport() const { return info->hasNETSupport(); } inline xcb_colormap_t Client::colormap() const { return m_colormap; } inline int Client::sessionStackingOrder() const { return sm_stacking_order; } inline bool Client::isManaged() const { return m_managed; } inline QSize Client::clientSize() const { return client_size; } inline void Client::plainResize(const QSize& s, ForceGeometry_t force) { plainResize(s.width(), s.height(), force); } inline void Client::resizeWithChecks(int w, int h, AbstractClient::ForceGeometry_t force) { resizeWithChecks(w, h, XCB_GRAVITY_BIT_FORGET, force); } inline void Client::resizeWithChecks(const QSize& s, xcb_gravity_t gravity, ForceGeometry_t force) { resizeWithChecks(s.width(), s.height(), gravity, force); } inline bool Client::hasUserTimeSupport() const { return info->userTime() != -1U; } inline xcb_window_t Client::moveResizeGrabWindow() const { return m_moveResizeGrabWindow; } inline bool Client::hiddenPreview() const { return mapping_state == Kept; } template inline void Client::print(T &stream) const { stream << "\'Client:" << window() << ";WMCLASS:" << resourceClass() << ":" << resourceName() << ";Caption:" << caption() << "\'"; } } // namespace Q_DECLARE_METATYPE(KWin::Client*) Q_DECLARE_METATYPE(QList) #endif diff --git a/client_machine.h b/client_machine.h index e56ffc70c..a3fc1f5a3 100644 --- a/client_machine.h +++ b/client_machine.h @@ -1,117 +1,117 @@ /******************************************************************** 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_CLIENT_MACHINE_H #define KWIN_CLIENT_MACHINE_H #include #include // forward declaration struct addrinfo; template class QFutureWatcher; namespace KWin { class GetAddrInfo : public QObject { Q_OBJECT public: explicit GetAddrInfo(const QByteArray &hostName, QObject *parent = NULL); - virtual ~GetAddrInfo(); + ~GetAddrInfo() override; void resolve(); Q_SIGNALS: void local(); private Q_SLOTS: void slotResolved(); void slotOwnAddressResolved(); private: void compare(); bool resolved(QFutureWatcher *watcher); bool m_resolving; bool m_resolved; bool m_ownResolved; QByteArray m_hostName; addrinfo *m_addressHints; addrinfo *m_address; addrinfo *m_ownAddress; QFutureWatcher *m_watcher; QFutureWatcher *m_ownAddressWatcher; }; class ClientMachine : public QObject { Q_OBJECT public: explicit ClientMachine(QObject *parent = NULL); - virtual ~ClientMachine(); + ~ClientMachine() override; void resolve(xcb_window_t window, xcb_window_t clientLeader); const QByteArray &hostName() const; bool isLocal() const; static QByteArray localhost(); bool isResolving() const; Q_SIGNALS: void localhostChanged(); private Q_SLOTS: void setLocal(); void resolveFinished(); private: void checkForLocalhost(); QByteArray m_hostName; bool m_localhost; bool m_resolved; bool m_resolving; }; inline bool ClientMachine::isLocal() const { return m_localhost; } inline const QByteArray &ClientMachine::hostName() const { return m_hostName; } inline QByteArray ClientMachine::localhost() { return "localhost"; } inline bool ClientMachine::isResolving() const { return m_resolving; } } // namespace #endif diff --git a/colorcorrection/colorcorrectdbusinterface.h b/colorcorrection/colorcorrectdbusinterface.h index 311436d32..30fabdb74 100644 --- a/colorcorrection/colorcorrectdbusinterface.h +++ b/colorcorrection/colorcorrectdbusinterface.h @@ -1,126 +1,126 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright 2017 Roman Gilg 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_NIGHTCOLOR_DBUS_INTERFACE_H #define KWIN_NIGHTCOLOR_DBUS_INTERFACE_H #include #include namespace KWin { namespace ColorCorrect { class Manager; class ColorCorrectDBusInterface : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.ColorCorrect") public: explicit ColorCorrectDBusInterface(Manager *parent); - virtual ~ColorCorrectDBusInterface() = default; + ~ColorCorrectDBusInterface() override = default; public Q_SLOTS: /** * @brief Gives information about the current state of Night Color. * * The returned variant hash has always the fields: * - ActiveEnabled * - Active * - Mode * - NightTemperatureEnabled * - NightTemperature * - Running * - CurrentColorTemperature * - LatitudeAuto * - LongitudeAuto * - LocationEnabled * - LatitudeFixed * - LongitudeFixed * - TimingsEnabled * - MorningBeginFixed * - EveningBeginFixed * - TransitionTime * * @return QHash * @see nightColorConfigChange * @see signalNightColorConfigChange * @since 5.12 **/ QHash nightColorInfo(); /** * @brief Allows changing the Night Color configuration. * * The provided variant hash can have the following fields: * - Active * - Mode * - NightTemperature * - LatitudeAuto * - LongitudeAuto * - LatitudeFixed * - LongitudeFixed * - MorningBeginFixed * - EveningBeginFixed * - TransitionTime * * It returns true if the configuration change was successful, otherwise false. * A change request for the location or timings needs to provide all relevant fields at the same time * to be successful. Otherwise the whole change request will get ignored. A change request will be ignored * as a whole as well, if one of the provided information has been sent in a wrong format. * * @return bool * @see nightColorInfo * @see signalNightColorConfigChange * @since 5.12 **/ bool setNightColorConfig(QHash data); /** * @brief For receiving auto location updates, primarily through the KDE Daemon * @return void * @since 5.12 **/ void nightColorAutoLocationUpdate(double latitude, double longitude); Q_SIGNALS: /** * @brief Emits that the Night Color configuration has been changed. * * The provided variant hash provides the same fields as nightColorInfo * * @return void * @see nightColorInfo * @see nightColorConfigChange * @since 5.12 **/ void nightColorConfigChanged(QHash data); private: Manager *m_manager; }; } } #endif // KWIN_NIGHTCOLOR_DBUS_INTERFACE_H diff --git a/cursor.h b/cursor.h index a8c609fe7..5874c0236 100644 --- a/cursor.h +++ b/cursor.h @@ -1,304 +1,304 @@ /******************************************************************** 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_CURSOR_H #define KWIN_CURSOR_H // kwin #include // Qt #include #include #include // xcb #include class QTimer; namespace KWin { namespace ExtendedCursor { /** * Extension of Qt::CursorShape with values not currently present there **/ enum Shape { SizeNorthWest = 0x100 + 0, SizeNorth = 0x100 + 1, SizeNorthEast = 0x100 + 2, SizeEast = 0x100 + 3, SizeWest = 0x100 + 4, SizeSouthEast = 0x100 + 5, SizeSouth = 0x100 + 6, SizeSouthWest = 0x100 + 7 }; } /** * @brief Wrapper round Qt::CursorShape with extensions enums into a single entity **/ class KWIN_EXPORT CursorShape { public: CursorShape() = default; CursorShape(Qt::CursorShape qtShape) { m_shape = qtShape; } CursorShape(KWin::ExtendedCursor::Shape kwinShape) { m_shape = kwinShape; } bool operator==(const CursorShape &o) const { return m_shape == o.m_shape; } operator int() const { return m_shape; } /** * @brief The name of a cursor shape in the theme. **/ QByteArray name() const; private: int m_shape = Qt::ArrowCursor; }; /** * @short Replacement for QCursor. * * This class provides a similar API to QCursor and should be preferred inside KWin. It allows to * get the position and warp the mouse cursor with static methods just like QCursor. It also provides * the possibility to get an X11 cursor for a Qt::CursorShape - a functionality lost in Qt 5's QCursor * implementation. * * In addition the class provides a mouse polling facility as required by e.g. Effects and ScreenEdges * and emits signals when the mouse position changes. In opposite to QCursor this class is a QObject * and cannot be constructed. Instead it provides a singleton getter, though the most important * methods are wrapped in a static method, just like QCursor. * * The actual implementation is split into two parts: a system independent interface and a windowing * system specific subclass. So far only an X11 backend is implemented which uses query pointer to * fetch the position and warp pointer to set the position. It uses a timer based mouse polling and * can provide X11 cursors through the XCursor library. **/ class KWIN_EXPORT Cursor : public QObject { Q_OBJECT public: - virtual ~Cursor(); + ~Cursor() override; void startMousePolling(); void stopMousePolling(); /** * @brief Enables tracking changes of cursor images. * * After enabling cursor change tracking the signal cursorChanged will be emitted * whenever a change to the cursor image is recognized. * * Use stopCursorTracking to no longer emit this signal. Note: the signal will be * emitted until each call of this method has been matched with a call to stopCursorTracking. * * This tracking is not about pointer position tracking. * @see stopCursorTracking * @see cursorChanged **/ void startCursorTracking(); /** * @brief Disables tracking changes of cursor images. * * Only call after using startCursorTracking. * * @see startCursorTracking **/ void stopCursorTracking(); /** * @brief The name of the currently used Cursor theme. * * @return const QString& **/ const QString &themeName() const; /** * @brief The size of the currently used Cursor theme. * * @return int **/ int themeSize() const; /** * @return list of alternative names for the cursor with @p name **/ QVector cursorAlternativeNames(const QByteArray &name) const; /** * Returns the current cursor position. This method does an update of the mouse position if * needed. It's save to call it multiple times. * * Implementing subclasses should prefer to use currentPos which is not performing a check * for update. **/ static QPoint pos(); /** * Warps the mouse cursor to new @p pos. **/ static void setPos(const QPoint &pos); static void setPos(int x, int y); static xcb_cursor_t x11Cursor(CursorShape shape); /** * Notice: if available always use the CursorShape variant to avoid cache duplicates for * ambiguous cursor names in the non existing cursor name specification **/ static xcb_cursor_t x11Cursor(const QByteArray &name); Q_SIGNALS: void posChanged(QPoint pos); void mouseChanged(const QPoint& pos, const QPoint& oldpos, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); /** * @brief Signal emitted when the cursor image changes. * * To enable these signals use startCursorTracking. * * @see startCursorTracking * @see stopCursorTracking **/ void cursorChanged(); void themeChanged(); protected: /** * Called from x11Cursor to actually retrieve the X11 cursor. Base implementation returns * a null cursor, an implementing subclass should implement this method if it can provide X11 * mouse cursors. **/ virtual xcb_cursor_t getX11Cursor(CursorShape shape); /** * Called from x11Cursor to actually retrieve the X11 cursor. Base implementation returns * a null cursor, an implementing subclass should implement this method if it can provide X11 * mouse cursors. **/ virtual xcb_cursor_t getX11Cursor(const QByteArray &name); /** * Performs the actual warping of the cursor. **/ virtual void doSetPos(); /** * Called from @ref pos() to allow syncing the internal position with the underlying * system's cursor position. **/ virtual void doGetPos(); /** * Called from startMousePolling when the mouse polling gets activated. Base implementation * does nothing, inheriting classes can overwrite to e.g. start a timer. **/ virtual void doStartMousePolling(); /** * Called from stopMousePolling when the mouse polling gets deactivated. Base implementation * does nothing, inheriting classes can overwrite to e.g. stop a timer. **/ virtual void doStopMousePolling(); /** * Called from startCursorTracking when cursor image tracking gets activated. Inheriting class needs * to overwrite to enable platform specific code for the tracking. **/ virtual void doStartCursorTracking(); /** * Called from stopCursorTracking when cursor image tracking gets deactivated. Inheriting class needs * to overwrite to disable platform specific code for the tracking. **/ virtual void doStopCursorTracking(); bool isCursorTracking() const; /** * Provides the actual internal cursor position to inheriting classes. If an inheriting class needs * access to the cursor position this method should be used instead of the static @ref pos, as * the static method syncs with the underlying system's cursor. **/ const QPoint ¤tPos() const; /** * Updates the internal position to @p pos without warping the pointer as * setPos does. **/ void updatePos(const QPoint &pos); void updatePos(int x, int y); private Q_SLOTS: void loadThemeSettings(); void slotKGlobalSettingsNotifyChange(int type, int arg); private: void updateTheme(const QString &name, int size); void loadThemeFromKConfig(); QPoint m_pos; int m_mousePollingCounter; int m_cursorTrackingCounter; QString m_themeName; int m_themeSize; KWIN_SINGLETON(Cursor) }; /** * @brief Implementation using the InputRedirection framework to get pointer positions. * * Does not support warping of cursor. **/ class InputRedirectionCursor : public Cursor { Q_OBJECT public: explicit InputRedirectionCursor(QObject *parent); - virtual ~InputRedirectionCursor(); + ~InputRedirectionCursor() override; protected: - virtual void doSetPos(); - virtual void doStartCursorTracking(); - virtual void doStopCursorTracking(); + void doSetPos() override; + void doStartCursorTracking() override; + void doStopCursorTracking() override; private Q_SLOTS: void slotPosChanged(const QPointF &pos); void slotPointerButtonChanged(); void slotModifiersChanged(Qt::KeyboardModifiers mods, Qt::KeyboardModifiers oldMods); private: Qt::MouseButtons m_currentButtons; friend class Cursor; }; inline const QPoint &Cursor::currentPos() const { return m_pos; } inline void Cursor::updatePos(int x, int y) { updatePos(QPoint(x, y)); } inline const QString& Cursor::themeName() const { return m_themeName; } inline int Cursor::themeSize() const { return m_themeSize; } inline bool Cursor::isCursorTracking() const { return m_cursorTrackingCounter > 0; } } Q_DECLARE_METATYPE(KWin::CursorShape) #endif // KWIN_CURSOR_H diff --git a/dbusinterface.h b/dbusinterface.h index b17945620..88d935355 100644 --- a/dbusinterface.h +++ b/dbusinterface.h @@ -1,254 +1,254 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2012 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_DBUS_INTERFACE_H #define KWIN_DBUS_INTERFACE_H #include #include #include "virtualdesktopsdbustypes.h" namespace KWin { class Compositor; class VirtualDesktopManager; /** * @brief This class is a wrapper for the org.kde.KWin D-Bus interface. * * The main purpose of this class is to be exported on the D-Bus as object /KWin. * It is a pure wrapper to provide the deprecated D-Bus methods which have been * removed from Workspace which used to implement the complete D-Bus interface. * * Nowadays the D-Bus interfaces are distributed, parts of it are exported on * /Compositor, parts on /Effects and parts on /KWin. The implementation in this * class just delegates the method calls to the actual implementation in one of the * three singletons. * * @author Martin Gräßlin **/ class DBusInterface: public QObject, protected QDBusContext { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.KWin") public: explicit DBusInterface(QObject *parent); - virtual ~DBusInterface(); + ~DBusInterface() override; public: // PROPERTIES public Q_SLOTS: // METHODS Q_NOREPLY void cascadeDesktop(); int currentDesktop(); Q_NOREPLY void killWindow(); void nextDesktop(); void previousDesktop(); Q_NOREPLY void reconfigure(); bool setCurrentDesktop(int desktop); bool startActivity(const QString &in0); bool stopActivity(const QString &in0); QString supportInformation(); Q_NOREPLY void unclutterDesktop(); Q_NOREPLY void showDebugConsole(); QVariantMap queryWindowInfo(); QVariantMap getWindowInfo(const QString &uuid); private Q_SLOTS: void becomeKWinService(const QString &service); private: void announceService(); QString m_serviceName; QDBusMessage m_replyQueryWindowInfo; }; class CompositorDBusInterface : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Compositing") /** * @brief Whether the Compositor is active. That is a Scene is present and the Compositor is * not shutting down itself. **/ Q_PROPERTY(bool active READ isActive) /** * @brief Whether compositing is possible. Mostly means whether the required X extensions * are available. **/ Q_PROPERTY(bool compositingPossible READ isCompositingPossible) /** * @brief The reason why compositing is not possible. Empty String if compositing is possible. **/ Q_PROPERTY(QString compositingNotPossibleReason READ compositingNotPossibleReason) /** * @brief Whether OpenGL has failed badly in the past (crash) and is considered as broken. **/ Q_PROPERTY(bool openGLIsBroken READ isOpenGLBroken) /** * The type of the currently used Scene: * @li @c none No Compositing * @li @c xrender XRender * @li @c gl1 OpenGL 1 * @li @c gl2 OpenGL 2 * @li @c gles OpenGL ES 2 **/ Q_PROPERTY(QString compositingType READ compositingType) /** * @brief All currently supported OpenGLPlatformInterfaces. * * Possible values: * @li glx * @li egl * * Values depend on operation mode and compile time options. **/ Q_PROPERTY(QStringList supportedOpenGLPlatformInterfaces READ supportedOpenGLPlatformInterfaces) Q_PROPERTY(bool platformRequiresCompositing READ platformRequiresCompositing) public: explicit CompositorDBusInterface(Compositor *parent); - virtual ~CompositorDBusInterface() = default; + ~CompositorDBusInterface() override = default; bool isActive() const; bool isCompositingPossible() const; QString compositingNotPossibleReason() const; bool isOpenGLBroken() const; QString compositingType() const; QStringList supportedOpenGLPlatformInterfaces() const; bool platformRequiresCompositing() const; public Q_SLOTS: /** * @brief Suspends the Compositor if it is currently active. * * Note: it is possible that the Compositor is not able to suspend. Use isActive to check * whether the Compositor has been suspended. * * @return void * @see resume * @see isActive **/ void suspend(); /** * @brief Resumes the Compositor if it is currently suspended. * * Note: it is possible that the Compositor cannot be resumed, that is there might be Clients * blocking the usage of Compositing or the Scene might be broken. Use isActive to check * whether the Compositor has been resumed. Also check isCompositingPossible and * isOpenGLBroken. * * Note: The starting of the Compositor can require some time and is partially done threaded. * After this method returns the setup may not have been completed. * * @return void * @see suspend * @see isActive * @see isCompositingPossible * @see isOpenGLBroken **/ void resume(); /** * @brief Used by Compositing KCM after settings change. * * On signal Compositor reloads settings and restarts. */ void reinitialize(); Q_SIGNALS: void compositingToggled(bool active); private: Compositor *m_compositor; }; //TODO: disable all of this in case of kiosk? class VirtualDesktopManagerDBusInterface : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.KWin.VirtualDesktopManager") /** * The number of virtual desktops currently available. * The ids of the virtual desktops are in the range [1, VirtualDesktopManager::maximum()]. **/ Q_PROPERTY(uint count READ count NOTIFY countChanged) /** * The number of rows the virtual desktops will be laid out in **/ Q_PROPERTY(uint rows READ rows WRITE setRows NOTIFY rowsChanged) /** * The id of the virtual desktop which is currently in use. **/ Q_PROPERTY(QString current READ current WRITE setCurrent NOTIFY currentChanged) /** * Whether navigation in the desktop layout wraps around at the borders. **/ Q_PROPERTY(bool navigationWrappingAround READ isNavigationWrappingAround WRITE setNavigationWrappingAround NOTIFY navigationWrappingAroundChanged) /** * list of key/value pairs which every one of them is representing a desktop **/ Q_PROPERTY(KWin::DBusDesktopDataVector desktops READ desktops NOTIFY desktopsChanged); public: VirtualDesktopManagerDBusInterface(VirtualDesktopManager *parent); - ~VirtualDesktopManagerDBusInterface() = default; + ~VirtualDesktopManagerDBusInterface() override = default; uint count() const; void setRows(uint rows); uint rows() const; void setCurrent(const QString &id); QString current() const; void setNavigationWrappingAround(bool wraps); bool isNavigationWrappingAround() const; KWin::DBusDesktopDataVector desktops() const; Q_SIGNALS: void countChanged(uint count); void rowsChanged(uint rows); void currentChanged(const QString &id); void navigationWrappingAroundChanged(bool wraps); void desktopsChanged(KWin::DBusDesktopDataVector); void desktopDataChanged(const QString &id, KWin::DBusDesktopDataStruct); void desktopCreated(const QString &id, KWin::DBusDesktopDataStruct); void desktopRemoved(const QString &id); public Q_SLOTS: /** * Create a desktop with a new name at a given position * note: the position starts from 1 **/ void createDesktop(uint position, const QString &name); void setDesktopName(const QString &id, const QString &name); void removeDesktop(const QString &id); private: VirtualDesktopManager *m_manager; }; } // namespace #endif // KWIN_DBUS_INTERFACE_H diff --git a/debug_console.h b/debug_console.h index 6cda3ff52..7fb826183 100644 --- a/debug_console.h +++ b/debug_console.h @@ -1,184 +1,184 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2016 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_DEBUG_CONSOLE_H #define KWIN_DEBUG_CONSOLE_H #include #include #include "input.h" #include "input_event_spy.h" #include #include #include class QTextEdit; namespace Ui { class DebugConsole; } namespace KWin { class Client; class ShellClient; class Unmanaged; class DebugConsoleFilter; class KWIN_EXPORT DebugConsoleModel : public QAbstractItemModel { Q_OBJECT public: explicit DebugConsoleModel(QObject *parent = nullptr); - virtual ~DebugConsoleModel(); + ~DebugConsoleModel() override; int columnCount(const QModelIndex &parent) const override; QVariant data(const QModelIndex &index, int role) const override; QModelIndex index(int row, int column, const QModelIndex & parent) const override; int rowCount(const QModelIndex &parent) const override; QModelIndex parent(const QModelIndex &child) const override; private: template QModelIndex indexForClient(int row, int column, const QVector &clients, int id) const; template QModelIndex indexForProperty(int row, int column, const QModelIndex &parent, T *(DebugConsoleModel::*filter)(const QModelIndex&) const) const; template int propertyCount(const QModelIndex &parent, T *(DebugConsoleModel::*filter)(const QModelIndex&) const) const; QVariant propertyData(QObject *object, const QModelIndex &index, int role) const; template QVariant clientData(const QModelIndex &index, int role, const QVector clients) const; template void add(int parentRow, QVector &clients, T *client); template void remove(int parentRow, QVector &clients, T *client); ShellClient *shellClient(const QModelIndex &index) const; ShellClient *internalClient(const QModelIndex &index) const; Client *x11Client(const QModelIndex &index) const; Unmanaged *unmanaged(const QModelIndex &index) const; int topLevelRowCount() const; QVector m_shellClients; QVector m_internalClients; QVector m_x11Clients; QVector m_unmanageds; }; class DebugConsoleDelegate : public QStyledItemDelegate { Q_OBJECT public: explicit DebugConsoleDelegate(QObject *parent = nullptr); - virtual ~DebugConsoleDelegate(); + ~DebugConsoleDelegate() override; QString displayText(const QVariant &value, const QLocale &locale) const override; }; class KWIN_EXPORT DebugConsole : public QWidget { Q_OBJECT public: DebugConsole(); - virtual ~DebugConsole(); + ~DebugConsole() override; protected: void showEvent(QShowEvent *event) override; private: void initGLTab(); void updateKeyboardTab(); QScopedPointer m_ui; QScopedPointer m_inputFilter; }; class SurfaceTreeModel : public QAbstractItemModel { Q_OBJECT public: explicit SurfaceTreeModel(QObject *parent = nullptr); - virtual ~SurfaceTreeModel(); + ~SurfaceTreeModel() override; int columnCount(const QModelIndex &parent) const override; QVariant data(const QModelIndex &index, int role) const override; QModelIndex index(int row, int column, const QModelIndex & parent) const override; int rowCount(const QModelIndex &parent) const override; QModelIndex parent(const QModelIndex &child) const override; }; class DebugConsoleFilter : public InputEventSpy { public: explicit DebugConsoleFilter(QTextEdit *textEdit); - virtual ~DebugConsoleFilter(); + ~DebugConsoleFilter() override; void pointerEvent(MouseEvent *event) override; void wheelEvent(WheelEvent *event) override; void keyEvent(KeyEvent *event) override; void touchDown(quint32 id, const QPointF &pos, quint32 time) override; void touchMotion(quint32 id, const QPointF &pos, quint32 time) override; void touchUp(quint32 id, quint32 time) override; void pinchGestureBegin(int fingerCount, quint32 time) override; void pinchGestureUpdate(qreal scale, qreal angleDelta, const QSizeF &delta, quint32 time) override; void pinchGestureEnd(quint32 time) override; void pinchGestureCancelled(quint32 time) override; void swipeGestureBegin(int fingerCount, quint32 time) override; void swipeGestureUpdate(const QSizeF &delta, quint32 time) override; void swipeGestureEnd(quint32 time) override; void swipeGestureCancelled(quint32 time) override; void switchEvent(SwitchEvent *event) override; private: QTextEdit *m_textEdit; }; namespace LibInput { class Device; } class InputDeviceModel : public QAbstractItemModel { Q_OBJECT public: explicit InputDeviceModel(QObject *parent = nullptr); - virtual ~InputDeviceModel(); + ~InputDeviceModel() override; int columnCount(const QModelIndex &parent) const override; QVariant data(const QModelIndex &index, int role) const override; QModelIndex index(int row, int column, const QModelIndex & parent) const override; int rowCount(const QModelIndex &parent) const override; QModelIndex parent(const QModelIndex &child) const override; private: void setupDeviceConnections(LibInput::Device *device); QVector m_devices; }; } #endif diff --git a/decorations/decoratedclient.h b/decorations/decoratedclient.h index e9c1b3b79..735748a6c 100644 --- a/decorations/decoratedclient.h +++ b/decorations/decoratedclient.h @@ -1,124 +1,124 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 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_DECORATED_CLIENT_H #define KWIN_DECORATED_CLIENT_H #include "options.h" #include #include #include #include namespace KWin { class AbstractClient; namespace Decoration { class Renderer; class DecoratedClientImpl : public QObject, public KDecoration2::ApplicationMenuEnabledDecoratedClientPrivate { Q_OBJECT public: explicit DecoratedClientImpl(AbstractClient *client, KDecoration2::DecoratedClient *decoratedClient, KDecoration2::Decoration *decoration); - virtual ~DecoratedClientImpl(); + ~DecoratedClientImpl() override; QString caption() const override; WId decorationId() const override; int desktop() const override; int height() const override; QIcon icon() const override; bool isActive() const override; bool isCloseable() const override; bool isKeepAbove() const override; bool isKeepBelow() const override; bool isMaximizeable() const override; bool isMaximized() const override; bool isMaximizedHorizontally() const override; bool isMaximizedVertically() const override; bool isMinimizeable() const override; bool isModal() const override; bool isMoveable() const override; bool isOnAllDesktops() const override; bool isResizeable() const override; bool isShadeable() const override; bool isShaded() const override; QPalette palette() const override; QColor color(KDecoration2::ColorGroup group, KDecoration2::ColorRole role) const override; bool providesContextHelp() const override; int width() const override; WId windowId() const override; Qt::Edges adjacentScreenEdges() const override; bool hasApplicationMenu() const override; bool isApplicationMenuActive() const override; void requestShowToolTip(const QString &text) override; void requestHideToolTip() override; void requestClose() override; void requestContextHelp() override; void requestToggleMaximization(Qt::MouseButtons buttons) override; void requestMinimize() override; void requestShowWindowMenu() override; void requestShowApplicationMenu(const QRect &rect, int actionId) override; void requestToggleKeepAbove() override; void requestToggleKeepBelow() override; void requestToggleOnAllDesktops() override; void requestToggleShade() override; - void showApplicationMenu(int actionId); + void showApplicationMenu(int actionId) override; AbstractClient *client() { return m_client; } Renderer *renderer() { return m_renderer; } KDecoration2::DecoratedClient *decoratedClient() { return KDecoration2::DecoratedClientPrivate::client(); } void signalShadeChange(); private Q_SLOTS: void delayedRequestToggleMaximization(Options::WindowOperation operation); private: void createRenderer(); void destroyRenderer(); AbstractClient *m_client; QSize m_clientSize; Renderer *m_renderer; QMetaObject::Connection m_compositorToggledConnection; QString m_toolTipText; QTimer m_toolTipWakeUp; QDeadlineTimer m_toolTipFallAsleep; bool m_toolTipShowing = false; }; } } #endif diff --git a/decorations/decorationbridge.h b/decorations/decorationbridge.h index f85ef8a4f..0ea8822d2 100644 --- a/decorations/decorationbridge.h +++ b/decorations/decorationbridge.h @@ -1,104 +1,104 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 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_DECORATION_BRIDGE_H #define KWIN_DECORATION_BRIDGE_H #include #include #include #include #include class KPluginFactory; namespace KDecoration2 { class DecorationSettings; } namespace KWin { class AbstractClient; namespace Decoration { class KWIN_EXPORT DecorationBridge : public KDecoration2::DecorationBridge { Q_OBJECT public: - virtual ~DecorationBridge(); + ~DecorationBridge() override; void init(); KDecoration2::Decoration *createDecoration(AbstractClient *client); std::unique_ptr createClient(KDecoration2::DecoratedClient *client, KDecoration2::Decoration *decoration) override; std::unique_ptr settings(KDecoration2::DecorationSettings *parent) override; void update(KDecoration2::Decoration *decoration, const QRect &geometry) override; bool needsBlur() const { return m_blur; } QString recommendedBorderSize() const { return m_recommendedBorderSize; } bool showToolTips() const { return m_showToolTips; } void reconfigure(); const QSharedPointer &settings() const { return m_settings; } QString supportInformation() const; Q_SIGNALS: void metaDataLoaded(); private: QString readPlugin(); void loadMetaData(const QJsonObject &object); void findTheme(const QVariantMap &map); void initPlugin(); QString readTheme() const; void readDecorationOptions(); KPluginFactory *m_factory; KSharedConfig::Ptr m_lnfConfig; bool m_blur; bool m_showToolTips; QString m_recommendedBorderSize; QString m_plugin; QString m_defaultTheme; QString m_theme; QSharedPointer m_settings; bool m_noPlugin; KWIN_SINGLETON(DecorationBridge) }; } // Decoration } // KWin #endif diff --git a/decorations/decorationrenderer.h b/decorations/decorationrenderer.h index 417bf849f..ca63fc391 100644 --- a/decorations/decorationrenderer.h +++ b/decorations/decorationrenderer.h @@ -1,86 +1,86 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 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_DECORATION_RENDERER_H #define KWIN_DECORATION_RENDERER_H #include #include #include namespace KWin { class Deleted; namespace Decoration { class DecoratedClientImpl; class KWIN_EXPORT Renderer : public QObject { Q_OBJECT public: - virtual ~Renderer(); + ~Renderer() override; void schedule(const QRect &rect); /** * Reparents this Renderer to the @p deleted. * After this call the Renderer is no longer able to render * anything, client() returns a nullptr. **/ virtual void reparent(Deleted *deleted); Q_SIGNALS: void renderScheduled(const QRect &geo); protected: explicit Renderer(DecoratedClientImpl *client); /** * @returns the scheduled paint region and resets **/ QRegion getScheduled(); virtual void render() = 0; DecoratedClientImpl *client() { return m_client; } bool areImageSizesDirty() const { return m_imageSizesDirty; } void resetImageSizesDirty() { m_imageSizesDirty = false; } QImage renderToImage(const QRect &geo); private: DecoratedClientImpl *m_client; QRegion m_scheduled; bool m_imageSizesDirty; }; } } #endif diff --git a/decorations/settings.h b/decorations/settings.h index f722328c3..f5b8e3b21 100644 --- a/decorations/settings.h +++ b/decorations/settings.h @@ -1,71 +1,71 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 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_DECORATION_SETTINGS_H #define KWIN_DECORATION_SETTINGS_H #include #include class KConfigGroup; namespace KWin { namespace Decoration { class SettingsImpl : public QObject, public KDecoration2::DecorationSettingsPrivate { Q_OBJECT public: explicit SettingsImpl(KDecoration2::DecorationSettings *parent); - virtual ~SettingsImpl(); + ~SettingsImpl() override; bool isAlphaChannelSupported() const override; bool isOnAllDesktopsAvailable() const override; bool isCloseOnDoubleClickOnMenu() const override; KDecoration2::BorderSize borderSize() const override { return m_borderSize; } QVector< KDecoration2::DecorationButtonType > decorationButtonsLeft() const override { return m_leftButtons; } QVector< KDecoration2::DecorationButtonType > decorationButtonsRight() const override { return m_rightButtons; } QFont font() const override { return m_font; } private: void readSettings(); QVector< KDecoration2::DecorationButtonType > readDecorationButtons(const KConfigGroup &config, const char *key, const QVector< KDecoration2::DecorationButtonType > &defaultValue) const; QVector< KDecoration2::DecorationButtonType > m_leftButtons; QVector< KDecoration2::DecorationButtonType > m_rightButtons; KDecoration2::BorderSize m_borderSize; bool m_autoBorderSize = true; bool m_closeDoubleClickMenu = false; QFont m_font; }; } // Decoration } // KWin #endif diff --git a/deleted.h b/deleted.h index e3021b0b6..d16d22257 100644 --- a/deleted.h +++ b/deleted.h @@ -1,251 +1,251 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2006 Lubos Lunak 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_DELETED_H #define KWIN_DELETED_H #include "toplevel.h" namespace KWin { class AbstractClient; namespace Decoration { class Renderer; } class KWIN_EXPORT Deleted : public Toplevel { Q_OBJECT public: static Deleted* create(Toplevel* c); // used by effects to keep the window around for e.g. fadeout effects when it's destroyed void refWindow(); void unrefWindow(); void discard(); - virtual int desktop() const; - virtual QStringList activities() const; - virtual QVector desktops() const; - virtual QPoint clientPos() const; - virtual QSize clientSize() const; + int desktop() const override; + QStringList activities() const override; + QVector desktops() const override; + QPoint clientPos() const override; + QSize clientSize() const override; QPoint clientContentPos() const override { return m_contentPos; } - virtual QRect transparentRect() const; - virtual bool isDeleted() const; - virtual xcb_window_t frameId() const override; + QRect transparentRect() const override; + bool isDeleted() const override; + xcb_window_t frameId() const override; bool noBorder() const { return no_border; } void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom) const; - QRect decorationRect() const; - virtual Layer layer() const { + QRect decorationRect() const override; + Layer layer() const override { return m_layer; } bool isMinimized() const { return m_minimized; } bool isModal() const { return m_modal; } QList mainClients() const { return m_mainClients; } - NET::WindowType windowType(bool direct = false, int supported_types = 0) const; + NET::WindowType windowType(bool direct = false, int supported_types = 0) const override; bool wasClient() const { return m_wasClient; } double opacity() const override; QByteArray windowRole() const override; const Decoration::Renderer *decorationRenderer() const { return m_decorationRenderer; } bool isFullScreen() const { return m_fullscreen; } bool isCurrentTab() const { return m_wasCurrentTab; } bool keepAbove() const { return m_keepAbove; } bool keepBelow() const { return m_keepBelow; } QString caption() const { return m_caption; } /** * Returns whether the client was active. * * @returns @c true if the client was active at the time when it was closed, * @c false otherwise **/ bool wasActive() const { return m_wasActive; } /** * Returns whether this was an X11 client. * * @returns @c true if it was an X11 client, @c false otherwise. **/ bool wasX11Client() const { return m_wasX11Client; } /** * Returns whether this was a Wayland client. * * @returns @c true if it was a Wayland client, @c false otherwise. **/ bool wasWaylandClient() const { return m_wasWaylandClient; } /** * Returns whether the client was a transient. * * @returns @c true if it was a transient, @c false otherwise. **/ bool wasTransient() const { return !m_transientFor.isEmpty(); } /** * Returns whether the client was a group transient. * * @returns @c true if it was a group transient, @c false otherwise. * @note This is relevant only for X11 clients. **/ bool wasGroupTransient() const { return m_wasGroupTransient; } /** * Checks whether this client was a transient for given toplevel. * * @param toplevel Toplevel against which we are testing. * @returns @c true if it was a transient for given toplevel, @c false otherwise. **/ bool wasTransientFor(const Toplevel *toplevel) const { return m_transientFor.contains(const_cast(toplevel)); } /** * Returns the list of transients. * * Because the window is Deleted, it can have only Deleted child transients. **/ DeletedList transients() const { return m_transients; } /** * Returns whether the client was a popup. * * @returns @c true if the client was a popup, @c false otherwise. **/ bool isPopupWindow() const override { return m_wasPopupWindow; } QVector x11DesktopIds() const; /** * Whether this Deleted represents the outline. **/ bool isOutline() const override { return m_wasOutline; } protected: - virtual void debug(QDebug& stream) const; + void debug(QDebug& stream) const override; private Q_SLOTS: void mainClientClosed(KWin::Toplevel *client); void transientForClosed(Toplevel *toplevel, Deleted *deleted); private: Deleted(); // use create() void copyToDeleted(Toplevel* c); - virtual ~Deleted(); // deleted only using unrefWindow() + ~Deleted() override; // deleted only using unrefWindow() void addTransient(Deleted *transient); void removeTransient(Deleted *transient); void addTransientFor(AbstractClient *parent); void removeTransientFor(Deleted *parent); int delete_refcount; int desk; QStringList activityList; QRect contentsRect; // for clientPos()/clientSize() QPoint m_contentPos; QRect transparent_rect; xcb_window_t m_frame; QVector m_desktops; bool no_border; QRect decoration_left; QRect decoration_right; QRect decoration_top; QRect decoration_bottom; Layer m_layer; bool m_minimized; bool m_modal; QList m_mainClients; bool m_wasClient; bool m_wasCurrentTab; Decoration::Renderer *m_decorationRenderer; double m_opacity; NET::WindowType m_type = NET::Unknown; QByteArray m_windowRole; bool m_fullscreen; bool m_keepAbove; bool m_keepBelow; QString m_caption; bool m_wasActive; bool m_wasX11Client; bool m_wasWaylandClient; bool m_wasGroupTransient; ToplevelList m_transientFor; DeletedList m_transients; bool m_wasPopupWindow; bool m_wasOutline; }; inline void Deleted::refWindow() { ++delete_refcount; } } // namespace Q_DECLARE_METATYPE(KWin::Deleted*) #endif diff --git a/effectloader.h b/effectloader.h index 0ad2e270d..bbab66b25 100644 --- a/effectloader.h +++ b/effectloader.h @@ -1,377 +1,377 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 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_EFFECT_LOADER_H #define KWIN_EFFECT_LOADER_H #include // KDE #include #include // Qt #include #include #include #include #include namespace KWin { class Effect; class EffectPluginFactory; enum class BuiltInEffect; /** * @brief Flags defining how a Loader should load an Effect. * * These Flags are only used internally when querying the configuration on whether * an Effect should be loaded. * * @see AbstractEffectLoader::readConfig() **/ enum class LoadEffectFlag { Load = 1 << 0, ///< Effect should be loaded CheckDefaultFunction = 1 << 2 ///< The Check Default Function needs to be invoked if the Effect provides it }; Q_DECLARE_FLAGS(LoadEffectFlags, LoadEffectFlag) /** * @brief Interface to describe how an effect loader has to function. * * The AbstractEffectLoader specifies the methods a concrete loader has to implement and how * those methods are expected to perform. Also it provides an interface to the outside world * (that is EffectsHandlerImpl). * * The abstraction is used because there are multiple types of Effects which need to be loaded: * @li Built-In Effects * @li Scripted Effects * @li Binary Plugin Effects * * Serving all of them with one Effect Loader is rather complex given that different stores need * to be queried at the same time. Thus the idea is to have one implementation per type and one * implementation which makes use of all of them and combines the loading. **/ class KWIN_EXPORT AbstractEffectLoader : public QObject { Q_OBJECT public: - virtual ~AbstractEffectLoader(); + ~AbstractEffectLoader() override; /** * @brief The KSharedConfig this EffectLoader should operate on. * * Important: a valid KSharedConfig must be provided before trying to load any effects! * * @param config * @internal **/ virtual void setConfig(KSharedConfig::Ptr config); /** * @brief Whether this Effect Loader can load the Effect with the given @p name. * * The Effect Loader determines whether it knows or can find an Effect called @p name, * and thus whether it can attempt to load the Effect. * * @param name The name of the Effect to look for. * @return bool @c true if the Effect Loader knows this effect, false otherwise **/ virtual bool hasEffect(const QString &name) const = 0; /** * @brief All the Effects this loader knows of. * * The implementation should re-query its store whenever this method is invoked. * It's possible that the store of effects changed (e.g. a new one got installed) * * @return QStringList The internal names of the known Effects **/ virtual QStringList listOfKnownEffects() const = 0; /** * @brief Synchronous loading of the Effect with the given @p name. * * Loads the Effect without checking any configuration value or any enabled by default * function provided by the Effect. * * The loader is expected to apply the following checks: * If the Effect is already loaded, the Effect should not get loaded again. Thus the loader * is expected to track which Effects it has loaded, and which of those have been destroyed. * The loader should check whether the Effect is supported. If the Effect indicates it is * not supported, it should not get loaded. * * If the Effect loaded successfully the signal effectLoaded(KWin::Effect*,const QString&) * must be emitted. Otherwise the user of the loader is not able to get the loaded Effect. * It's not returning the Effect as queryAndLoadAll() is working async and thus the users * of the loader are expected to be prepared for async loading. * * @param name The internal name of the Effect which should be loaded * @return bool @c true if the effect could be loaded, @c false in error case * @see queryAndLoadAll() * @see effectLoaded(KWin::Effect*,const QString&) **/ virtual bool loadEffect(const QString &name) = 0; /** * @brief The Effect Loader should query its store for all available effects and try to load them. * * The Effect Loader is supposed to perform this operation in a highly async way. If there is * IO which needs to be performed this should be done in a background thread and a queue should * be used to load the effects. The loader should make sure to not load more than one Effect * in one event cycle. Loading the Effect has to be performed in the Compositor thread and * thus blocks the Compositor. Therefore after loading one Effect all events should get * processed first, so that the Compositor can perform a painting pass if needed. To simplify * this operation one can use the EffectLoadQueue. This requires to add another loadEffect * method with the custom loader specific type to refer to an Effect and LoadEffectFlags. * * The LoadEffectFlags have to be determined by querying the configuration with readConfig(). * If the Load flag is set the loading can proceed and all the checks from * loadEffect(const QString &) have to be applied. * In addition if the CheckDefaultFunction flag is set and the Effect provides such a method, * it should be queried to determine whether the Effect is enabled by default. If such a method * returns @c false the Effect should not get loaded. If the Effect does not provide a way to * query whether it's enabled by default at runtime the flag can get ignored. * * If the Effect loaded successfully the signal effectLoaded(KWin::Effect*,const QString&) * must be emitted. * * @see loadEffect(const QString &) * @see effectLoaded(KWin::Effect*,const QString&) **/ virtual void queryAndLoadAll() = 0; /** * @brief Whether the Effect with the given @p name is supported by the compositing backend. * * @param name The name of the Effect to check. * @return bool @c true if it is supported, @c false otherwise **/ virtual bool isEffectSupported(const QString &name) const = 0; /** * @brief Clears the load queue, that is all scheduled Effects are discarded from loading. **/ virtual void clear() = 0; Q_SIGNALS: /** * @brief The loader emits this signal when it successfully loaded an effect. * * @param effect The created Effect * @param name The internal name of the loaded Effect * @return void **/ void effectLoaded(KWin::Effect *effect, const QString &name); protected: explicit AbstractEffectLoader(QObject *parent = nullptr); /** * @brief Checks the configuration for the Effect identified by @p effectName. * * For each Effect there could be a key called "Enabled". If there is such a key * the returned flags will contain Load in case it's @c true. If the key does not exist the * @p defaultValue determines whether the Effect should be loaded. A value of @c true means * that Load | CheckDefaultFunction is returned, in case of @c false no Load flags are returned. * * @param effectName The name of the Effect to look for in the configuration * @param defaultValue Whether the Effect is enabled by default or not. * @returns Flags indicating whether the Effect should be loaded and how it should be loaded **/ LoadEffectFlags readConfig(const QString &effectName, bool defaultValue) const; private: KSharedConfig::Ptr m_config; }; /** * @brief Helper class to queue the loading of Effects. * * Loading an Effect has to be done in the compositor thread and thus the Compositor is blocked * while the Effect loads. To not block the compositor for several frames the loading of all * Effects need to be queued. By invoking the slot dequeue() through a QueuedConnection the queue * can ensure that events are processed between the loading of two Effects and thus the compositor * doesn't block. * * As it needs to be a slot, the queue must subclass QObject, but it also needs to be templated as * the information to load an Effect is specific to the Effect Loader. Thus there is the * AbstractEffectLoadQueue providing the slots as pure virtual functions and the templated * EffectLoadQueue inheriting from AbstractEffectLoadQueue. * * The queue operates like a normal queue providing enqueue and a scheduleDequeue instead of dequeue. * **/ class AbstractEffectLoadQueue : public QObject { Q_OBJECT public: explicit AbstractEffectLoadQueue(QObject *parent = nullptr) : QObject(parent) { } protected Q_SLOTS: virtual void dequeue() = 0; }; template class EffectLoadQueue : public AbstractEffectLoadQueue { public: explicit EffectLoadQueue(Loader *parent) : AbstractEffectLoadQueue(parent) , m_effectLoader(parent) , m_dequeueScheduled(false) { } void enqueue(const QPair value) { m_queue.enqueue(value); scheduleDequeue(); } void clear() { m_queue.clear(); m_dequeueScheduled = false; } protected: void dequeue() override { if (m_queue.isEmpty()) { return; } m_dequeueScheduled = false; const auto pair = m_queue.dequeue(); m_effectLoader->loadEffect(pair.first, pair.second); scheduleDequeue(); } private: void scheduleDequeue() { if (m_queue.isEmpty() || m_dequeueScheduled) { return; } m_dequeueScheduled = true; QMetaObject::invokeMethod(this, "dequeue", Qt::QueuedConnection); } Loader *m_effectLoader; bool m_dequeueScheduled; QQueue> m_queue; }; /** * @brief Can load the Built-In-Effects **/ class BuiltInEffectLoader : public AbstractEffectLoader { Q_OBJECT public: explicit BuiltInEffectLoader(QObject *parent = nullptr); ~BuiltInEffectLoader() override; bool hasEffect(const QString &name) const override; bool isEffectSupported(const QString &name) const override; QStringList listOfKnownEffects() const override; void clear() override; void queryAndLoadAll() override; bool loadEffect(const QString& name) override; bool loadEffect(BuiltInEffect effect, LoadEffectFlags flags); private: bool loadEffect(const QString &name, BuiltInEffect effect, LoadEffectFlags flags); QString internalName(const QString &name) const; EffectLoadQueue *m_queue; QMap m_loadedEffects; }; /** * @brief Can load scripted Effects **/ class KWIN_EXPORT ScriptedEffectLoader : public AbstractEffectLoader { Q_OBJECT public: explicit ScriptedEffectLoader(QObject* parent = nullptr); ~ScriptedEffectLoader() override; bool hasEffect(const QString &name) const override; bool isEffectSupported(const QString &name) const override; QStringList listOfKnownEffects() const override; void clear() override; void queryAndLoadAll() override; bool loadEffect(const QString &name) override; bool loadEffect(const KPluginMetaData &effect, LoadEffectFlags flags); private: QList findAllEffects() const; KPluginMetaData findEffect(const QString &name) const; QStringList m_loadedEffects; EffectLoadQueue< ScriptedEffectLoader, KPluginMetaData > *m_queue; QMetaObject::Connection m_queryConnection; }; class PluginEffectLoader : public AbstractEffectLoader { Q_OBJECT public: explicit PluginEffectLoader(QObject *parent = nullptr); ~PluginEffectLoader() override; bool hasEffect(const QString &name) const override; bool isEffectSupported(const QString &name) const override; QStringList listOfKnownEffects() const override; void clear() override; void queryAndLoadAll() override; bool loadEffect(const QString &name) override; bool loadEffect(const KPluginMetaData &info, LoadEffectFlags flags); void setPluginSubDirectory(const QString &directory); private: QVector findAllEffects() const; KPluginMetaData findEffect(const QString &name) const; EffectPluginFactory *factory(const KPluginMetaData &info) const; QStringList m_loadedEffects; EffectLoadQueue< PluginEffectLoader, KPluginMetaData> *m_queue; QString m_pluginSubDirectory; QMetaObject::Connection m_queryConnection; }; class EffectLoader : public AbstractEffectLoader { Q_OBJECT public: explicit EffectLoader(QObject *parent = nullptr); ~EffectLoader() override; bool hasEffect(const QString &name) const override; bool isEffectSupported(const QString &name) const override; QStringList listOfKnownEffects() const override; bool loadEffect(const QString &name) override; void queryAndLoadAll() override; void setConfig(KSharedConfig::Ptr config) override; void clear() override; private: QList m_loaders; }; } Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::LoadEffectFlags) #endif diff --git a/effects.h b/effects.h index 4ccd1691d..a7736e570 100644 --- a/effects.h +++ b/effects.h @@ -1,669 +1,669 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2006 Lubos Lunak Copyright (C) 2010, 2011 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_EFFECTSIMPL_H #define KWIN_EFFECTSIMPL_H #include "kwineffects.h" #include "scene.h" #include #include #include namespace Plasma { class Theme; } namespace KWayland { namespace Server { class Display; } } class QDBusPendingCallWatcher; class QDBusServiceWatcher; namespace KWin { class AbstractThumbnailItem; class DesktopThumbnailItem; class WindowThumbnailItem; class AbstractClient; class Client; class Compositor; class Deleted; class EffectLoader; class Toplevel; class Unmanaged; class WindowPropertyNotifyX11Filter; class KWIN_EXPORT EffectsHandlerImpl : public EffectsHandler { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Effects") Q_PROPERTY(QStringList activeEffects READ activeEffects) Q_PROPERTY(QStringList loadedEffects READ loadedEffects) Q_PROPERTY(QStringList listOfEffects READ listOfEffects) public: EffectsHandlerImpl(Compositor *compositor, Scene *scene); - virtual ~EffectsHandlerImpl(); + ~EffectsHandlerImpl() override; void prePaintScreen(ScreenPrePaintData& data, int time) override; void paintScreen(int mask, QRegion region, ScreenPaintData& data) override; /** * Special hook to perform a paintScreen but just with the windows on @p desktop. **/ void paintDesktop(int desktop, int mask, QRegion region, ScreenPaintData& data); void postPaintScreen() override; void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) override; void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override; void postPaintWindow(EffectWindow* w) override; void paintEffectFrame(EffectFrame* frame, QRegion region, double opacity, double frameOpacity) override; Effect *provides(Effect::Feature ef); void drawWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override; void buildQuads(EffectWindow* w, WindowQuadList& quadList) override; void activateWindow(EffectWindow* c) override; EffectWindow* activeWindow() const override; void moveWindow(EffectWindow* w, const QPoint& pos, bool snap = false, double snapAdjust = 1.0) override; void windowToDesktop(EffectWindow* w, int desktop) override; void windowToScreen(EffectWindow* w, int screen) override; void setShowingDesktop(bool showing) override; QString currentActivity() const override; int currentDesktop() const override; int numberOfDesktops() const override; void setCurrentDesktop(int desktop) override; void setNumberOfDesktops(int desktops) override; QSize desktopGridSize() const override; int desktopGridWidth() const override; int desktopGridHeight() const override; int workspaceWidth() const override; int workspaceHeight() const override; int desktopAtCoords(QPoint coords) const override; QPoint desktopGridCoords(int id) const override; QPoint desktopCoords(int id) const override; int desktopAbove(int desktop = 0, bool wrap = true) const override; int desktopToRight(int desktop = 0, bool wrap = true) const override; int desktopBelow(int desktop = 0, bool wrap = true) const override; int desktopToLeft(int desktop = 0, bool wrap = true) const override; QString desktopName(int desktop) const override; bool optionRollOverDesktops() const override; QPoint cursorPos() const override; bool grabKeyboard(Effect* effect) override; void ungrabKeyboard() override; // not performing XGrabPointer void startMouseInterception(Effect *effect, Qt::CursorShape shape) override; void stopMouseInterception(Effect *effect) override; bool isMouseInterception() const; void registerGlobalShortcut(const QKeySequence &shortcut, QAction *action) override; void registerPointerShortcut(Qt::KeyboardModifiers modifiers, Qt::MouseButton pointerButtons, QAction *action) override; void registerAxisShortcut(Qt::KeyboardModifiers modifiers, PointerAxisDirection axis, QAction *action) override; void registerTouchpadSwipeShortcut(SwipeDirection direction, QAction *action) override; void* getProxy(QString name) override; void startMousePolling() override; void stopMousePolling() override; EffectWindow* findWindow(WId id) const override; EffectWindow* findWindow(KWayland::Server::SurfaceInterface *surf) const override; EffectWindow *findWindow(QWindow *w) const override; EffectWindow *findWindow(const QUuid &id) const override; EffectWindowList stackingOrder() const override; void setElevatedWindow(KWin::EffectWindow* w, bool set) override; void setTabBoxWindow(EffectWindow*) override; void setTabBoxDesktop(int) override; EffectWindowList currentTabBoxWindowList() const override; void refTabBox() override; void unrefTabBox() override; void closeTabBox() override; QList< int > currentTabBoxDesktopList() const override; int currentTabBoxDesktop() const override; EffectWindow* currentTabBoxWindow() const override; void setActiveFullScreenEffect(Effect* e) override; Effect* activeFullScreenEffect() const override; bool hasActiveFullScreenEffect() const override; void addRepaintFull() override; void addRepaint(const QRect& r) override; void addRepaint(const QRegion& r) override; void addRepaint(int x, int y, int w, int h) override; int activeScreen() const override; int numScreens() const override; int screenNumber(const QPoint& pos) const override; QRect clientArea(clientAreaOption, int screen, int desktop) const override; QRect clientArea(clientAreaOption, const EffectWindow* c) const override; QRect clientArea(clientAreaOption, const QPoint& p, int desktop) const override; QSize virtualScreenSize() const override; QRect virtualScreenGeometry() const override; double animationTimeFactor() const override; WindowQuadType newWindowQuadType() override; void defineCursor(Qt::CursorShape shape) override; bool checkInputWindowEvent(QMouseEvent *e); bool checkInputWindowEvent(QWheelEvent *e); void checkInputWindowStacking(); void reserveElectricBorder(ElectricBorder border, Effect *effect) override; void unreserveElectricBorder(ElectricBorder border, Effect *effect) override; void registerTouchBorder(ElectricBorder border, QAction *action) override; void unregisterTouchBorder(ElectricBorder border, QAction *action) override; unsigned long xrenderBufferPicture() override; QPainter* scenePainter() override; void reconfigure() override; QByteArray readRootProperty(long atom, long type, int format) const override; xcb_atom_t announceSupportProperty(const QByteArray& propertyName, Effect* effect) override; void removeSupportProperty(const QByteArray& propertyName, Effect* effect) override; bool hasDecorationShadows() const override; bool decorationsHaveAlpha() const override; bool decorationSupportsBlurBehind() const override; EffectFrame* effectFrame(EffectFrameStyle style, bool staticSize, const QPoint& position, Qt::Alignment alignment) const override; QVariant kwinOption(KWinOption kwopt) override; bool isScreenLocked() const override; bool makeOpenGLContextCurrent() override; void doneOpenGLContextCurrent() override; xcb_connection_t *xcbConnection() const override; xcb_window_t x11RootWindow() const override; // internal (used by kwin core or compositing code) void startPaint(); void grabbedKeyboardEvent(QKeyEvent* e); bool hasKeyboardGrab() const; void desktopResized(const QSize &size); void reloadEffect(Effect *effect) override; QStringList loadedEffects() const; QStringList listOfEffects() const; void unloadAllEffects(); QList elevatedWindows() const; QStringList activeEffects() const; /** * @returns Whether we are currently in a desktop rendering process triggered by paintDesktop hook **/ bool isDesktopRendering() const { return m_desktopRendering; } /** * @returns the desktop currently being rendered in the paintDesktop hook. **/ int currentRenderedDesktop() const { return m_currentRenderedDesktop; } KWayland::Server::Display *waylandDisplay() const override; bool animationsSupported() const override; PlatformCursorImage cursorImage() const override; void hideCursor() override; void showCursor() override; void startInteractiveWindowSelection(std::function callback) override; void startInteractivePositionSelection(std::function callback) override; void showOnScreenMessage(const QString &message, const QString &iconName = QString()) override; void hideOnScreenMessage(OnScreenMessageHideFlags flags = OnScreenMessageHideFlags()) override; KSharedConfigPtr config() const override; KSharedConfigPtr inputConfig() const override; Scene *scene() const { return m_scene; } bool touchDown(quint32 id, const QPointF &pos, quint32 time); bool touchMotion(quint32 id, const QPointF &pos, quint32 time); bool touchUp(quint32 id, quint32 time); void highlightWindows(const QVector &windows); bool isPropertyTypeRegistered(xcb_atom_t atom) const { return registered_atoms.contains(atom); } - void windowToDesktops(EffectWindow *w, const QVector &desktops); + void windowToDesktops(EffectWindow *w, const QVector &desktops) override; /** * Finds an effect with the given name. * * @param name The name of the effect. * @returns The effect with the given name @p name, or nullptr if there * is no such effect loaded. **/ Effect *findEffect(const QString &name) const; public Q_SLOTS: void slotCurrentTabAboutToChange(EffectWindow* from, EffectWindow* to); void slotTabAdded(EffectWindow* from, EffectWindow* to); void slotTabRemoved(EffectWindow* c, EffectWindow* newActiveWindow); // slots for D-Bus interface Q_SCRIPTABLE void reconfigureEffect(const QString& name); Q_SCRIPTABLE bool loadEffect(const QString& name); Q_SCRIPTABLE void toggleEffect(const QString& name); Q_SCRIPTABLE void unloadEffect(const QString& name); Q_SCRIPTABLE bool isEffectLoaded(const QString& name) const; Q_SCRIPTABLE bool isEffectSupported(const QString& name); Q_SCRIPTABLE QList areEffectsSupported(const QStringList &names); Q_SCRIPTABLE QString supportInformation(const QString& name) const; Q_SCRIPTABLE QString debug(const QString& name, const QString& parameter = QString()) const; protected Q_SLOTS: void slotClientShown(KWin::Toplevel*); void slotShellClientShown(KWin::Toplevel*); void slotUnmanagedShown(KWin::Toplevel*); void slotWindowClosed(KWin::Toplevel *c, KWin::Deleted *d); void slotClientMaximized(KWin::AbstractClient *c, MaximizeMode maxMode); void slotOpacityChanged(KWin::Toplevel *t, qreal oldOpacity); void slotClientModalityChanged(); void slotGeometryShapeChanged(KWin::Toplevel *t, const QRect &old); void slotPaddingChanged(KWin::Toplevel *t, const QRect &old); void slotWindowDamaged(KWin::Toplevel *t, const QRect& r); protected: void connectNotify(const QMetaMethod &signal) override; void disconnectNotify(const QMetaMethod &signal) override; void effectsChanged(); void setupAbstractClientConnections(KWin::AbstractClient *c); void setupClientConnections(KWin::Client *c); void setupUnmanagedConnections(KWin::Unmanaged *u); /** * Default implementation does nothing and returns @c true. **/ virtual bool doGrabKeyboard(); /** * Default implementation does nothing. **/ virtual void doUngrabKeyboard(); /** * Default implementation sets Effects override cursor on the PointerInputRedirection. **/ virtual void doStartMouseInterception(Qt::CursorShape shape); /** * Default implementation removes the Effects override cursor on the PointerInputRedirection. **/ virtual void doStopMouseInterception(); /** * Default implementation does nothing **/ virtual void doCheckInputWindowStacking(); Effect* keyboard_grab_effect; Effect* fullscreen_effect; QList elevated_windows; QMultiMap< int, EffectPair > effect_order; QHash< long, int > registered_atoms; int next_window_quad_type; private: void registerPropertyType(long atom, bool reg); void destroyEffect(Effect *effect); typedef QVector< Effect*> EffectsList; typedef EffectsList::const_iterator EffectsIterator; EffectsList m_activeEffects; EffectsIterator m_currentDrawWindowIterator; EffectsIterator m_currentPaintWindowIterator; EffectsIterator m_currentPaintEffectFrameIterator; EffectsIterator m_currentPaintScreenIterator; EffectsIterator m_currentBuildQuadsIterator; typedef QHash< QByteArray, QList< Effect*> > PropertyEffectMap; PropertyEffectMap m_propertiesForEffects; QHash m_managedProperties; Compositor *m_compositor; Scene *m_scene; bool m_desktopRendering; int m_currentRenderedDesktop; QList m_grabbedMouseEffects; EffectLoader *m_effectLoader; int m_trackingCursorChanges; std::unique_ptr m_x11WindowPropertyNotify; }; class EffectWindowImpl : public EffectWindow { Q_OBJECT public: explicit EffectWindowImpl(Toplevel *toplevel); ~EffectWindowImpl() override; void enablePainting(int reason) override; void disablePainting(int reason) override; bool isPaintingEnabled() override; void addRepaint(const QRect &r) override; void addRepaint(int x, int y, int w, int h) override; void addRepaintFull() override; void addLayerRepaint(const QRect &r) override; void addLayerRepaint(int x, int y, int w, int h) override; void refWindow() override; void unrefWindow() override; const EffectWindowGroup* group() const override; bool isDeleted() const override; bool isMinimized() const override; double opacity() const override; bool hasAlpha() const override; QStringList activities() const override; int desktop() const override; QVector desktops() const override; int x() const override; int y() const override; int width() const override; int height() const override; QSize basicUnit() const override; QRect geometry() const override; QString caption() const override; QRect expandedGeometry() const override; QRegion shape() const override; int screen() const override; bool hasOwnShape() const override; // only for shadow effect, for now QPoint pos() const override; QSize size() const override; QRect rect() const override; bool isMovable() const override; bool isMovableAcrossScreens() const override; bool isUserMove() const override; bool isUserResize() const override; QRect iconGeometry() const override; bool isDesktop() const override; bool isDock() const override; bool isToolbar() const override; bool isMenu() const override; bool isNormalWindow() const override; bool isSpecialWindow() const override; bool isDialog() const override; bool isSplash() const override; bool isUtility() const override; bool isDropdownMenu() const override; bool isPopupMenu() const override; bool isTooltip() const override; bool isNotification() const override; bool isCriticalNotification() const override; bool isOnScreenDisplay() const override; bool isComboBox() const override; bool isDNDIcon() const override; bool skipsCloseAnimation() const override; bool acceptsFocus() const override; bool keepAbove() const override; bool keepBelow() const override; bool isModal() const override; bool isPopupWindow() const override; bool isOutline() const override; KWayland::Server::SurfaceInterface *surface() const override; bool isFullScreen() const override; bool isUnresponsive() const override; QRect contentsRect() const override; bool decorationHasAlpha() const override; QIcon icon() const override; QString windowClass() const override; NET::WindowType windowType() const override; bool isSkipSwitcher() const override; bool isCurrentTab() const override; QString windowRole() const override; bool isManaged() const override; bool isWaylandClient() const override; bool isX11Client() const override; QRect decorationInnerRect() const override; QByteArray readProperty(long atom, long type, int format) const override; void deleteProperty(long atom) const override; EffectWindow* findModal() override; EffectWindowList mainWindows() const override; WindowQuadList buildQuads(bool force = false) const override; void minimize() override; void unminimize() override; void closeWindow() override; void referencePreviousWindowPixmap() override; void unreferencePreviousWindowPixmap() override; QWindow *internalWindow() const override; const Toplevel* window() const; Toplevel* window(); void setWindow(Toplevel* w); // internal void setSceneWindow(Scene::Window* w); // internal const Scene::Window* sceneWindow() const; // internal Scene::Window* sceneWindow(); // internal void elevate(bool elevate); - void setData(int role, const QVariant &data); - QVariant data(int role) const; + void setData(int role, const QVariant &data) override; + QVariant data(int role) const override; void registerThumbnail(AbstractThumbnailItem *item); QHash > const &thumbnails() const { return m_thumbnails; } QList const &desktopThumbnails() const { return m_desktopThumbnails; } private Q_SLOTS: void thumbnailDestroyed(QObject *object); void thumbnailTargetChanged(); void desktopThumbnailDestroyed(QObject *object); private: void insertThumbnail(WindowThumbnailItem *item); Toplevel* toplevel; Scene::Window* sw; // This one is used only during paint pass. QHash dataMap; QHash > m_thumbnails; QList m_desktopThumbnails; bool managed = false; bool waylandClient; bool x11Client; }; class EffectWindowGroupImpl : public EffectWindowGroup { public: explicit EffectWindowGroupImpl(Group* g); EffectWindowList members() const override; private: Group* group; }; class KWIN_EXPORT EffectFrameImpl : public QObject, public EffectFrame { Q_OBJECT public: explicit EffectFrameImpl(EffectFrameStyle style, bool staticSize = true, QPoint position = QPoint(-1, -1), Qt::Alignment alignment = Qt::AlignCenter); - virtual ~EffectFrameImpl(); + ~EffectFrameImpl() override; void free() override; void render(QRegion region = infiniteRegion(), double opacity = 1.0, double frameOpacity = 1.0) override; Qt::Alignment alignment() const override; void setAlignment(Qt::Alignment alignment) override; const QFont& font() const override; void setFont(const QFont& font) override; const QRect& geometry() const override; void setGeometry(const QRect& geometry, bool force = false) override; const QIcon& icon() const override; void setIcon(const QIcon& icon) override; const QSize& iconSize() const override; void setIconSize(const QSize& size) override; void setPosition(const QPoint& point) override; const QString& text() const override; void setText(const QString& text) override; EffectFrameStyle style() const override { return m_style; }; Plasma::FrameSvg& frame() { return m_frame; } bool isStatic() const { return m_static; }; void finalRender(QRegion region, double opacity, double frameOpacity) const; void setShader(GLShader* shader) override { m_shader = shader; } GLShader* shader() const override { return m_shader; } void setSelection(const QRect& selection) override; const QRect& selection() const { return m_selectionGeometry; } Plasma::FrameSvg& selectionFrame() { return m_selection; } /** * The foreground text color as specified by the default Plasma theme. **/ QColor styledTextColor(); private Q_SLOTS: void plasmaThemeChanged(); private: Q_DISABLE_COPY(EffectFrameImpl) // As we need to use Qt slots we cannot copy this class void align(QRect &geometry); // positions geometry around m_point respecting m_alignment void autoResize(); // Auto-resize if not a static size EffectFrameStyle m_style; Plasma::FrameSvg m_frame; // TODO: share between all EffectFrames Plasma::FrameSvg m_selection; // Position bool m_static; QPoint m_point; Qt::Alignment m_alignment; QRect m_geometry; // Contents QString m_text; QFont m_font; QIcon m_icon; QSize m_iconSize; QRect m_selectionGeometry; Scene::EffectFrame* m_sceneFrame; GLShader* m_shader; Plasma::Theme *m_theme; }; inline QList EffectsHandlerImpl::elevatedWindows() const { if (isScreenLocked()) return QList(); return elevated_windows; } inline xcb_window_t EffectsHandlerImpl::x11RootWindow() const { return rootWindow(); } inline xcb_connection_t *EffectsHandlerImpl::xcbConnection() const { return connection(); } inline EffectWindowGroupImpl::EffectWindowGroupImpl(Group* g) : group(g) { } EffectWindow* effectWindow(Toplevel* w); EffectWindow* effectWindow(Scene::Window* w); inline const Scene::Window* EffectWindowImpl::sceneWindow() const { return sw; } inline Scene::Window* EffectWindowImpl::sceneWindow() { return sw; } inline const Toplevel* EffectWindowImpl::window() const { return toplevel; } inline Toplevel* EffectWindowImpl::window() { return toplevel; } } // namespace #endif diff --git a/effects/blur/blur_config.h b/effects/blur/blur_config.h index bc33efc9d..a766eec68 100644 --- a/effects/blur/blur_config.h +++ b/effects/blur/blur_config.h @@ -1,46 +1,46 @@ /* * Copyright © 2010 Fredrik Höglund * * 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; see the file COPYING. if not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef BLUR_CONFIG_H #define BLUR_CONFIG_H #include #include "ui_blur_config.h" namespace KWin { class BlurEffectConfig : public KCModule { Q_OBJECT public: explicit BlurEffectConfig(QWidget *parent = 0, const QVariantList& args = QVariantList()); - ~BlurEffectConfig(); + ~BlurEffectConfig() override; - void save(); + void save() override; private: ::Ui::BlurEffectConfig ui; }; } // namespace KWin #endif diff --git a/effects/colorpicker/colorpicker.h b/effects/colorpicker/colorpicker.h index f3856cea8..79dade4c1 100644 --- a/effects/colorpicker/colorpicker.h +++ b/effects/colorpicker/colorpicker.h @@ -1,65 +1,65 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2016 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_COLORPICKER_H #define KWIN_COLORPICKER_H #include #include #include #include #include #include namespace KWin { class ColorPickerEffect : public Effect, protected QDBusContext { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.ColorPicker") public: ColorPickerEffect(); - virtual ~ColorPickerEffect(); + ~ColorPickerEffect() override; void paintScreen(int mask, QRegion region, ScreenPaintData &data) override; void postPaintScreen() override; bool isActive() const override; int requestedEffectChainPosition() const override { return 50; } static bool supported(); public Q_SLOTS: Q_SCRIPTABLE QColor pick(); private: void showInfoMessage(); void hideInfoMessage(); QDBusMessage m_replyMessage; QRect m_cachedOutputGeometry; QPoint m_scheduledPosition; bool m_picking = false; }; } // namespace #endif diff --git a/effects/coverswitch/coverswitch.h b/effects/coverswitch/coverswitch.h index 4c3b15b0d..994df1c1f 100644 --- a/effects/coverswitch/coverswitch.h +++ b/effects/coverswitch/coverswitch.h @@ -1,166 +1,166 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2008 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_COVERSWITCH_H #define KWIN_COVERSWITCH_H #include #include #include #include #include #include #include #include namespace KWin { class CoverSwitchEffect : public Effect { Q_OBJECT Q_PROPERTY(int animationDuration READ configuredAnimationDuration) Q_PROPERTY(bool animateSwitch READ isAnimateSwitch) Q_PROPERTY(bool animateStart READ isAnimateStart) Q_PROPERTY(bool animateStop READ isAnimateStop) Q_PROPERTY(bool reflection READ isReflection) Q_PROPERTY(bool windowTitle READ isWindowTitle) Q_PROPERTY(qreal zPosition READ windowZPosition) Q_PROPERTY(bool primaryTabBox READ isPrimaryTabBox) Q_PROPERTY(bool secondaryTabBox READ isSecondaryTabBox) // TODO: mirror colors public: CoverSwitchEffect(); ~CoverSwitchEffect() override; void reconfigure(ReconfigureFlags) override; void prePaintScreen(ScreenPrePaintData &data, int time) override; void paintScreen(int mask, QRegion region, ScreenPaintData &data) override; - void postPaintScreen(); + void postPaintScreen() override; void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override; void windowInputMouseEvent(QEvent *e) override; bool isActive() const override; static bool supported(); // for properties int configuredAnimationDuration() const { return animationDuration.count(); } bool isAnimateSwitch() const { return animateSwitch; } bool isAnimateStart() const { return animateStart; } bool isAnimateStop() const { return animateStop; } bool isReflection() const { return reflection; } bool isWindowTitle() const { return windowTitle; } qreal windowZPosition() const { return zPosition; } bool isPrimaryTabBox() const { return primaryTabBox; } bool isSecondaryTabBox() const { return secondaryTabBox; } int requestedEffectChainPosition() const override { return 50; } public Q_SLOTS: void slotWindowClosed(KWin::EffectWindow *c); void slotTabBoxAdded(int mode); void slotTabBoxClosed(); void slotTabBoxUpdated(); void slotTabBoxKeyEvent(QKeyEvent* event); private: void paintScene(EffectWindow* frontWindow, const EffectWindowList& leftWindows, const EffectWindowList& rightWindows, bool reflectedWindows = false); void paintWindowCover(EffectWindow* w, bool reflectedWindow, WindowPaintData& data); void paintFrontWindow(EffectWindow* frontWindow, int width, int leftWindows, int rightWindows, bool reflectedWindow); void paintWindows(const EffectWindowList& windows, bool left, bool reflectedWindows, EffectWindow* additionalWindow = NULL); void selectNextOrPreviousWindow(bool forward); inline void selectNextWindow() { selectNextOrPreviousWindow(true); } inline void selectPreviousWindow() { selectNextOrPreviousWindow(false); } void abort(); /** * Updates the caption of the caption frame. * Taking care of rewording the desktop client. * As well sets the icon for the caption frame. **/ void updateCaption(); bool mActivated; float angle; bool animateSwitch; bool animateStart; bool animateStop; bool animation; bool start; bool stop; bool reflection; float mirrorColor[2][4]; bool windowTitle; std::chrono::milliseconds animationDuration; bool stopRequested; bool startRequested; TimeLine timeLine; QRect area; float zPosition; float scaleFactor; enum Direction { Left, Right }; Direction direction; QQueue scheduled_directions; EffectWindow* selected_window; int activeScreen; QList< EffectWindow* > leftWindows; QList< EffectWindow* > rightWindows; EffectWindowList currentWindowList; EffectWindowList referrencedWindows; EffectFrame* captionFrame; QFont captionFont; bool primaryTabBox; bool secondaryTabBox; GLShader *m_reflectionShader; QMatrix4x4 m_projectionMatrix; QMatrix4x4 m_modelviewMatrix; }; } // namespace #endif diff --git a/effects/coverswitch/coverswitch_config.h b/effects/coverswitch/coverswitch_config.h index 7945de230..f6986a5db 100644 --- a/effects/coverswitch/coverswitch_config.h +++ b/effects/coverswitch/coverswitch_config.h @@ -1,54 +1,54 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2008 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_COVERSWITCH_CONFIG_H #define KWIN_COVERSWITCH_CONFIG_H #include #include "ui_coverswitch_config.h" namespace KWin { class CoverSwitchEffectConfigForm : public QWidget, public Ui::CoverSwitchEffectConfigForm { Q_OBJECT public: explicit CoverSwitchEffectConfigForm(QWidget* parent); }; class CoverSwitchEffectConfig : public KCModule { Q_OBJECT public: explicit CoverSwitchEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); public Q_SLOTS: - virtual void save(); + void save() override; private: CoverSwitchEffectConfigForm* m_ui; }; } // namespace #endif diff --git a/effects/cube/cube.h b/effects/cube/cube.h index 8da87a6a6..654df2115 100644 --- a/effects/cube/cube.h +++ b/effects/cube/cube.h @@ -1,263 +1,263 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2008 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_CUBE_H #define KWIN_CUBE_H #include #include #include #include #include #include #include "cube_inside.h" #include "cube_proxy.h" namespace KWin { class CubeEffect : public Effect { Q_OBJECT Q_PROPERTY(qreal cubeOpacity READ configuredCubeOpacity) Q_PROPERTY(bool opacityDesktopOnly READ isOpacityDesktopOnly) Q_PROPERTY(bool displayDesktopName READ isDisplayDesktopName) Q_PROPERTY(bool reflection READ isReflection) Q_PROPERTY(int rotationDuration READ configuredRotationDuration) Q_PROPERTY(QColor backgroundColor READ configuredBackgroundColor) Q_PROPERTY(QColor capColor READ configuredCapColor) Q_PROPERTY(bool paintCaps READ isPaintCaps) Q_PROPERTY(bool closeOnMouseRelease READ isCloseOnMouseRelease) Q_PROPERTY(qreal zPosition READ configuredZPosition) Q_PROPERTY(bool useForTabBox READ isUseForTabBox) Q_PROPERTY(bool invertKeys READ isInvertKeys) Q_PROPERTY(bool invertMouse READ isInvertMouse) Q_PROPERTY(qreal capDeformationFactor READ configuredCapDeformationFactor) Q_PROPERTY(bool useZOrdering READ isUseZOrdering) Q_PROPERTY(bool texturedCaps READ isTexturedCaps) // TODO: electric borders: not a registered type public: CubeEffect(); - ~CubeEffect(); - virtual void reconfigure(ReconfigureFlags); - virtual void prePaintScreen(ScreenPrePaintData& data, int time); - virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); - virtual void postPaintScreen(); - virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); - virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); - virtual bool borderActivated(ElectricBorder border); - virtual void grabbedKeyboardEvent(QKeyEvent* e); - virtual void windowInputMouseEvent(QEvent* e); - virtual bool isActive() const; + ~CubeEffect() override; + void reconfigure(ReconfigureFlags) override; + void prePaintScreen(ScreenPrePaintData& data, int time) override; + void paintScreen(int mask, QRegion region, ScreenPaintData& data) override; + void postPaintScreen() override; + void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) override; + void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override; + bool borderActivated(ElectricBorder border) override; + void grabbedKeyboardEvent(QKeyEvent* e) override; + void windowInputMouseEvent(QEvent* e) override; + bool isActive() const override; int requestedEffectChainPosition() const override { return 50; } // proxy functions - virtual void* proxy(); + void* proxy() override; void registerCubeInsideEffect(CubeInsideEffect* effect); void unregisterCubeInsideEffect(CubeInsideEffect* effect); static bool supported(); // for properties qreal configuredCubeOpacity() const { return cubeOpacity; } bool isOpacityDesktopOnly() const { return opacityDesktopOnly; } bool isDisplayDesktopName() const { return displayDesktopName; } bool isReflection() const { return reflection; } int configuredRotationDuration() const { return rotationDuration.count(); } QColor configuredBackgroundColor() const { return backgroundColor; } QColor configuredCapColor() const { return capColor; } bool isPaintCaps() const { return paintCaps; } bool isCloseOnMouseRelease() const { return closeOnMouseRelease; } qreal configuredZPosition() const { return zPosition; } bool isUseForTabBox() const { return useForTabBox; } bool isInvertKeys() const { return invertKeys; } bool isInvertMouse() const { return invertMouse; } qreal configuredCapDeformationFactor() const { return capDeformationFactor; } bool isUseZOrdering() const { return useZOrdering; } bool isTexturedCaps() const { return texturedCaps; } private Q_SLOTS: void toggleCube(); void toggleCylinder(); void toggleSphere(); // slots for global shortcut changed // needed to toggle the effect void globalShortcutChanged(QAction *action, const QKeySequence &seq); void slotTabBoxAdded(int mode); void slotTabBoxUpdated(); void slotTabBoxClosed(); void slotCubeCapLoaded(); void slotWallPaperLoaded(); private: enum class AnimationState { None, Start, Stop, Left, Right }; enum class VerticalAnimationState { None, Upwards, Downwards }; enum CubeMode { Cube, Cylinder, Sphere }; void toggle(CubeMode newMode = Cube); void paintCube(int mask, QRegion region, ScreenPaintData& data); void paintCap(bool frontFirst, float zOffset, const QMatrix4x4 &projection); void paintCubeCap(); void paintCylinderCap(); void paintSphereCap(); bool loadShader(); void rotateCube(); void rotateToDesktop(int desktop); void setActive(bool active); QImage loadCubeCap(const QString &capPath); QImage loadWallPaper(const QString &file); void startAnimation(AnimationState state); void startVerticalAnimation(VerticalAnimationState state); bool activated; bool cube_painting; bool keyboard_grab; bool schedule_close; QList borderActivate; QList borderActivateCylinder; QList borderActivateSphere; int painting_desktop; int frontDesktop; float cubeOpacity; bool opacityDesktopOnly; bool displayDesktopName; EffectFrame* desktopNameFrame; QFont desktopNameFont; bool reflection; bool rotating; bool verticalRotating; bool desktopChangedWhileRotating; bool paintCaps; QColor backgroundColor; QColor capColor; GLTexture* wallpaper; bool texturedCaps; GLTexture* capTexture; // animations // Horizontal/start/stop float startAngle; float currentAngle; int startFrontDesktop; AnimationState animationState; TimeLine timeLine; QQueue animations; // vertical float verticalStartAngle; float verticalCurrentAngle; VerticalAnimationState verticalAnimationState; TimeLine verticalTimeLine; QQueue verticalAnimations; bool reflectionPainting; std::chrono::milliseconds rotationDuration; int activeScreen; bool bottomCap; bool closeOnMouseRelease; float zoom; float zPosition; bool useForTabBox; bool invertKeys; bool invertMouse; bool tabBoxMode; bool shortcutsRegistered; CubeMode mode; bool useShaders; GLShader* cylinderShader; GLShader* sphereShader; GLShader* m_reflectionShader; GLShader* m_capShader; float capDeformationFactor; bool useZOrdering; float zOrderingFactor; bool useList; // needed for reflection float mAddedHeightCoeff1; float mAddedHeightCoeff2; QMatrix4x4 m_rotationMatrix; QMatrix4x4 m_reflectionMatrix; QMatrix4x4 m_textureMirrorMatrix; QMatrix4x4 m_currentFaceMatrix; GLVertexBuffer *m_cubeCapBuffer; // Shortcuts - needed to toggle the effect QList cubeShortcut; QList cylinderShortcut; QList sphereShortcut; // proxy CubeEffectProxy m_proxy; QList< CubeInsideEffect* > m_cubeInsideEffects; QAction *m_cubeAction; QAction *m_cylinderAction; QAction *m_sphereAction; }; } // namespace #endif diff --git a/effects/cube/cube_config.h b/effects/cube/cube_config.h index 378d7e13d..1cb151ab4 100644 --- a/effects/cube/cube_config.h +++ b/effects/cube/cube_config.h @@ -1,57 +1,57 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2008 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_CUBE_CONFIG_H #define KWIN_CUBE_CONFIG_H #include #include "ui_cube_config.h" namespace KWin { class CubeEffectConfigForm : public QWidget, public Ui::CubeEffectConfigForm { Q_OBJECT public: explicit CubeEffectConfigForm(QWidget* parent); }; class CubeEffectConfig : public KCModule { Q_OBJECT public: explicit CubeEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); public Q_SLOTS: - virtual void save(); + void save() override; private Q_SLOTS: void capsSelectionChanged(); private: CubeEffectConfigForm* m_ui; KActionCollection* m_actionCollection; }; } // namespace #endif diff --git a/effects/cube/cube_inside.h b/effects/cube/cube_inside.h index b8223d02f..4b347b144 100644 --- a/effects/cube/cube_inside.h +++ b/effects/cube/cube_inside.h @@ -1,40 +1,40 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2009 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_CUBE_INSIDE_H #define KWIN_CUBE_INSIDE_H #include namespace KWin { class CubeInsideEffect : public Effect { public: CubeInsideEffect() {} - virtual ~CubeInsideEffect() {} + ~CubeInsideEffect() override {} virtual void paint() = 0; virtual void setActive(bool active) = 0; }; } // namespace #endif // KWIN_CUBE_INSIDE_H diff --git a/effects/cubeslide/cubeslide.h b/effects/cubeslide/cubeslide.h index f05da0aaf..42c7e2ffc 100644 --- a/effects/cubeslide/cubeslide.h +++ b/effects/cubeslide/cubeslide.h @@ -1,116 +1,116 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2009 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_CUBESLIDE_H #define KWIN_CUBESLIDE_H #include #include #include #include #include namespace KWin { class CubeSlideEffect : public Effect { Q_OBJECT Q_PROPERTY(int rotationDuration READ configuredRotationDuration) Q_PROPERTY(bool dontSlidePanels READ isDontSlidePanels) Q_PROPERTY(bool dontSlideStickyWindows READ isDontSlideStickyWindows) Q_PROPERTY(bool usePagerLayout READ isUsePagerLayout) Q_PROPERTY(bool useWindowMoving READ isUseWindowMoving) public: CubeSlideEffect(); - ~CubeSlideEffect(); - virtual void reconfigure(ReconfigureFlags); - virtual void prePaintScreen(ScreenPrePaintData& data, int time); - virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); - virtual void postPaintScreen(); - virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); - virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); - virtual bool isActive() const; + ~CubeSlideEffect() override; + void reconfigure(ReconfigureFlags) override; + void prePaintScreen(ScreenPrePaintData& data, int time) override; + void paintScreen(int mask, QRegion region, ScreenPaintData& data) override; + void postPaintScreen() override; + void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) override; + void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override; + bool isActive() const override; int requestedEffectChainPosition() const override { return 50; } static bool supported(); // for properties int configuredRotationDuration() const { return rotationDuration; } bool isDontSlidePanels() const { return dontSlidePanels; } bool isDontSlideStickyWindows() const { return dontSlideStickyWindows; } bool isUsePagerLayout() const { return usePagerLayout; } bool isUseWindowMoving() const { return useWindowMoving; } private Q_SLOTS: void slotWindowAdded(EffectWindow* w); void slotWindowDeleted(EffectWindow* w); void slotDesktopChanged(int old, int current, EffectWindow* w); void slotWindowStepUserMovedResized(KWin::EffectWindow *w); void slotWindowFinishUserMovedResized(KWin::EffectWindow *w); void slotNumberDesktopsChanged(); private: enum RotationDirection { Left, Right, Upwards, Downwards }; void paintSlideCube(int mask, QRegion region, ScreenPaintData& data); void windowMovingChanged(float progress, RotationDirection direction); bool shouldAnimate(const EffectWindow* w) const; void startAnimation(); bool cube_painting; int front_desktop; int painting_desktop; int other_desktop; bool firstDesktop; bool stickyPainting; QSet staticWindows; QTimeLine timeLine; QQueue slideRotations; bool dontSlidePanels; bool dontSlideStickyWindows; bool usePagerLayout; int rotationDuration; bool useWindowMoving; bool windowMoving; bool desktopChangedWhileMoving; double progressRestriction; }; } #endif diff --git a/effects/cubeslide/cubeslide_config.h b/effects/cubeslide/cubeslide_config.h index fa7f18ddb..647a2621c 100644 --- a/effects/cubeslide/cubeslide_config.h +++ b/effects/cubeslide/cubeslide_config.h @@ -1,54 +1,54 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2009 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_CUBESLIDE_CONFIG_H #define KWIN_CUBESLIDE_CONFIG_H #include #include "ui_cubeslide_config.h" namespace KWin { class CubeSlideEffectConfigForm : public QWidget, public Ui::CubeSlideEffectConfigForm { Q_OBJECT public: explicit CubeSlideEffectConfigForm(QWidget* parent); }; class CubeSlideEffectConfig : public KCModule { Q_OBJECT public: explicit CubeSlideEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); public Q_SLOTS: - virtual void save(); + void save() override; private: CubeSlideEffectConfigForm* m_ui; }; } // namespace #endif diff --git a/effects/desktopgrid/desktopgrid.h b/effects/desktopgrid/desktopgrid.h index 62c4d7166..abcf98d50 100644 --- a/effects/desktopgrid/desktopgrid.h +++ b/effects/desktopgrid/desktopgrid.h @@ -1,193 +1,193 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2007 Lubos Lunak Copyright (C) 2008 Lucas Murray 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_DESKTOPGRID_H #define KWIN_DESKTOPGRID_H #include #include #include #include namespace KWin { class PresentWindowsEffectProxy; class DesktopButtonsView : public QQuickView { Q_OBJECT public: explicit DesktopButtonsView(QWindow *parent = 0); void windowInputMouseEvent(QMouseEvent* e); void setAddDesktopEnabled(bool enable); void setRemoveDesktopEnabled(bool enable); bool isVisible() const; void show(); void hide(); public: EffectWindow *effectWindow; Q_SIGNALS: void addDesktop(); void removeDesktop(); private: bool m_visible; QPoint m_pos; bool m_posIsValid; }; class DesktopGridEffect : public Effect { Q_OBJECT Q_PROPERTY(int zoomDuration READ configuredZoomDuration) Q_PROPERTY(int border READ configuredBorder) Q_PROPERTY(Qt::Alignment desktopNameAlignment READ configuredDesktopNameAlignment) Q_PROPERTY(int layoutMode READ configuredLayoutMode) Q_PROPERTY(int customLayoutRows READ configuredCustomLayoutRows) Q_PROPERTY(bool usePresentWindows READ isUsePresentWindows) // TODO: electric borders public: DesktopGridEffect(); - ~DesktopGridEffect(); - virtual void reconfigure(ReconfigureFlags); - virtual void prePaintScreen(ScreenPrePaintData& data, int time); - virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); - virtual void postPaintScreen(); - virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); - virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); - virtual void windowInputMouseEvent(QEvent* e); - virtual void grabbedKeyboardEvent(QKeyEvent* e); - virtual bool borderActivated(ElectricBorder border); - virtual bool isActive() const; + ~DesktopGridEffect() override; + void reconfigure(ReconfigureFlags) override; + void prePaintScreen(ScreenPrePaintData& data, int time) override; + void paintScreen(int mask, QRegion region, ScreenPaintData& data) override; + void postPaintScreen() override; + void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) override; + void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override; + void windowInputMouseEvent(QEvent* e) override; + void grabbedKeyboardEvent(QKeyEvent* e) override; + bool borderActivated(ElectricBorder border) override; + bool isActive() const override; int requestedEffectChainPosition() const override { return 50; } enum { LayoutPager, LayoutAutomatic, LayoutCustom }; // Layout modes // for properties int configuredZoomDuration() const { return zoomDuration; } int configuredBorder() const { return border; } Qt::Alignment configuredDesktopNameAlignment() const { return desktopNameAlignment; } int configuredLayoutMode() const { return layoutMode; } int configuredCustomLayoutRows() const { return customLayoutRows; } bool isUsePresentWindows() const { return m_usePresentWindows; } private Q_SLOTS: void toggle(); // slots for global shortcut changed // needed to toggle the effect void globalShortcutChanged(QAction *action, const QKeySequence& seq); void slotAddDesktop(); void slotRemoveDesktop(); void slotWindowAdded(KWin::EffectWindow* w); void slotWindowClosed(KWin::EffectWindow *w); void slotWindowDeleted(KWin::EffectWindow *w); void slotNumberDesktopsChanged(uint old); void slotWindowGeometryShapeChanged(KWin::EffectWindow *w, const QRect &old); private: QPointF scalePos(const QPoint& pos, int desktop, int screen = -1) const; QPoint unscalePos(const QPoint& pos, int* desktop = NULL) const; int posToDesktop(const QPoint& pos) const; EffectWindow* windowAt(QPoint pos) const; void setCurrentDesktop(int desktop); void setHighlightedDesktop(int desktop); int desktopToRight(int desktop, bool wrap = true) const; int desktopToLeft(int desktop, bool wrap = true) const; int desktopUp(int desktop, bool wrap = true) const; int desktopDown(int desktop, bool wrap = true) const; void setActive(bool active); void setup(); void setupGrid(); void finish(); bool isMotionManagerMovingWindows() const; bool isRelevantWithPresentWindows(EffectWindow *w) const; bool isUsingPresentWindows() const; QRectF moveGeometryToDesktop(int desktop) const; void desktopsAdded(int old); void desktopsRemoved(int old); QVector desktopList(const EffectWindow *w) const; QList borderActivate; int zoomDuration; int border; Qt::Alignment desktopNameAlignment; int layoutMode; int customLayoutRows; bool activated; QTimeLine timeline; int paintingDesktop; int highlightedDesktop; int sourceDesktop; int m_originalMovingDesktop; bool keyboardGrab; bool wasWindowMove, wasWindowCopy, wasDesktopMove, isValidMove; EffectWindow* windowMove; QPoint windowMoveDiff; QPoint dragStartPos; // Soft highlighting QList hoverTimeline; QList< EffectFrame* > desktopNames; QSize gridSize; Qt::Orientation orientation; QPoint activeCell; // Per screen variables QList scale; // Because the border isn't a ratio each screen is different QList unscaledBorder; QList scaledSize; QList scaledOffset; // Shortcut - needed to toggle the effect QList shortcut; PresentWindowsEffectProxy* m_proxy; QList m_managers; bool m_usePresentWindows; QRect m_windowMoveGeometry; QPoint m_windowMoveStartPoint; QVector m_desktopButtonsViews; QAction *m_activateAction; }; } // namespace #endif diff --git a/effects/desktopgrid/desktopgrid_config.h b/effects/desktopgrid/desktopgrid_config.h index 8bd87276b..1654d3623 100644 --- a/effects/desktopgrid/desktopgrid_config.h +++ b/effects/desktopgrid/desktopgrid_config.h @@ -1,62 +1,62 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2007 Rivo Laks Copyright (C) 2008 Lucas Murray 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_DESKTOPGRID_CONFIG_H #define KWIN_DESKTOPGRID_CONFIG_H #include #include "ui_desktopgrid_config.h" #include "desktopgrid.h" namespace KWin { class DesktopGridEffectConfigForm : public QWidget, public Ui::DesktopGridEffectConfigForm { Q_OBJECT public: explicit DesktopGridEffectConfigForm(QWidget* parent); }; class DesktopGridEffectConfig : public KCModule { Q_OBJECT public: explicit DesktopGridEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); - ~DesktopGridEffectConfig(); + ~DesktopGridEffectConfig() override; public Q_SLOTS: - virtual void save(); - virtual void load(); - virtual void defaults(); + void save() override; + void load() override; + void defaults() override; private Q_SLOTS: void layoutSelectionChanged(); private: DesktopGridEffectConfigForm* m_ui; KActionCollection* m_actionCollection; }; } // namespace #endif diff --git a/effects/fallapart/fallapart.h b/effects/fallapart/fallapart.h index b8d27a588..4d400d678 100644 --- a/effects/fallapart/fallapart.h +++ b/effects/fallapart/fallapart.h @@ -1,67 +1,67 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2007 Lubos Lunak 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_FALLAPART_H #define KWIN_FALLAPART_H #include namespace KWin { class FallApartEffect : public Effect { Q_OBJECT Q_PROPERTY(int blockSize READ configuredBlockSize) public: FallApartEffect(); - virtual void reconfigure(ReconfigureFlags); - virtual void prePaintScreen(ScreenPrePaintData& data, int time); - virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); - virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); - virtual void postPaintScreen(); - virtual bool isActive() const; + void reconfigure(ReconfigureFlags) override; + void prePaintScreen(ScreenPrePaintData& data, int time) override; + void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) override; + void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override; + void postPaintScreen() override; + bool isActive() const override; int requestedEffectChainPosition() const override { return 70; } // for properties int configuredBlockSize() const { return blockSize; } static bool supported(); public Q_SLOTS: void slotWindowClosed(KWin::EffectWindow *c); void slotWindowDeleted(KWin::EffectWindow *w); void slotWindowDataChanged(KWin::EffectWindow *w, int role); private: QHash< EffectWindow*, double > windows; bool isRealWindow(EffectWindow* w); int blockSize; }; } // namespace #endif diff --git a/effects/flipswitch/flipswitch.h b/effects/flipswitch/flipswitch.h index add05b4ff..6f86e6d93 100644 --- a/effects/flipswitch/flipswitch.h +++ b/effects/flipswitch/flipswitch.h @@ -1,165 +1,165 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2008, 2009 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_FLIPSWITCH_H #define KWIN_FLIPSWITCH_H #include #include #include #include #include namespace KWin { class FlipSwitchEffect : public Effect { Q_OBJECT Q_PROPERTY(bool tabBox READ isTabBox) Q_PROPERTY(bool tabBoxAlternative READ isTabBoxAlternative) Q_PROPERTY(int duration READ duration) Q_PROPERTY(int angle READ angle) Q_PROPERTY(qreal xPosition READ xPosition) Q_PROPERTY(qreal yPosition READ yPosition) Q_PROPERTY(bool windowTitle READ isWindowTitle) public: FlipSwitchEffect(); - ~FlipSwitchEffect(); - - virtual void reconfigure(ReconfigureFlags); - virtual void prePaintScreen(ScreenPrePaintData& data, int time); - virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); - virtual void postPaintScreen(); - virtual void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time); - virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); - virtual void grabbedKeyboardEvent(QKeyEvent* e); - virtual void windowInputMouseEvent(QEvent* e); - virtual bool isActive() const; + ~FlipSwitchEffect() override; + + void reconfigure(ReconfigureFlags) override; + void prePaintScreen(ScreenPrePaintData& data, int time) override; + void paintScreen(int mask, QRegion region, ScreenPaintData& data) override; + void postPaintScreen() override; + void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time) override; + void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override; + void grabbedKeyboardEvent(QKeyEvent* e) override; + void windowInputMouseEvent(QEvent* e) override; + bool isActive() const override; int requestedEffectChainPosition() const override { return 50; } static bool supported(); // for properties bool isTabBox() const { return m_tabbox; } bool isTabBoxAlternative() const { return m_tabboxAlternative; } int duration() const { return m_timeLine.duration(); } int angle() const { return m_angle; } qreal xPosition() const { return m_xPosition; } qreal yPosition() const { return m_yPosition; } bool isWindowTitle() const { return m_windowTitle; } private Q_SLOTS: void toggleActiveCurrent(); void toggleActiveAllDesktops(); void globalShortcutChanged(QAction *action, QKeySequence shortcut); void slotWindowAdded(KWin::EffectWindow* w); void slotWindowClosed(KWin::EffectWindow *w); void slotTabBoxAdded(int mode); void slotTabBoxClosed(); void slotTabBoxUpdated(); void slotTabBoxKeyEvent(QKeyEvent* event); private: class ItemInfo; enum SwitchingDirection { DirectionForward, DirectionBackward }; enum FlipSwitchMode { TabboxMode, CurrentDesktopMode, AllDesktopsMode }; void setActive(bool activate, FlipSwitchMode mode); bool isSelectableWindow(EffectWindow *w) const; void scheduleAnimation(const SwitchingDirection& direction, int distance = 1); void adjustWindowMultiScreen(const EffectWindow *w, WindowPaintData& data); void selectNextOrPreviousWindow(bool forward); inline void selectNextWindow() { selectNextOrPreviousWindow(true); } inline void selectPreviousWindow() { selectNextOrPreviousWindow(false); } /** * Updates the caption of the caption frame. * Taking care of rewording the desktop client. * As well sets the icon for the caption frame. **/ void updateCaption(); QQueue< SwitchingDirection> m_scheduledDirections; EffectWindow* m_selectedWindow; QTimeLine m_timeLine; QTimeLine m_startStopTimeLine; QTimeLine::CurveShape m_currentAnimationShape; QRect m_screenArea; int m_activeScreen; bool m_active; bool m_start; bool m_stop; bool m_animation; bool m_hasKeyboardGrab; FlipSwitchMode m_mode; EffectFrame* m_captionFrame; QFont m_captionFont; EffectWindowList m_flipOrderedWindows; QHash< const EffectWindow*, ItemInfo* > m_windows; QMatrix4x4 m_projectionMatrix; QMatrix4x4 m_modelviewMatrix; // options bool m_tabbox; bool m_tabboxAlternative; float m_angle; float m_xPosition; float m_yPosition; bool m_windowTitle; // Shortcuts QList m_shortcutCurrent; QList m_shortcutAll; }; class FlipSwitchEffect::ItemInfo { public: ItemInfo(); ~ItemInfo(); bool deleted; double opacity; double brightness; double saturation; }; } // namespace #endif diff --git a/effects/flipswitch/flipswitch_config.h b/effects/flipswitch/flipswitch_config.h index 2c1e0fa57..27252e474 100644 --- a/effects/flipswitch/flipswitch_config.h +++ b/effects/flipswitch/flipswitch_config.h @@ -1,57 +1,57 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2008, 2009 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_FLIPSWITCH_CONFIG_H #define KWIN_FLIPSWITCH_CONFIG_H #include #include "ui_flipswitch_config.h" class KActionCollection; namespace KWin { class FlipSwitchEffectConfigForm : public QWidget, public Ui::FlipSwitchEffectConfigForm { Q_OBJECT public: explicit FlipSwitchEffectConfigForm(QWidget* parent); }; class FlipSwitchEffectConfig : public KCModule { Q_OBJECT public: explicit FlipSwitchEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); - ~FlipSwitchEffectConfig(); + ~FlipSwitchEffectConfig() override; public Q_SLOTS: - virtual void save(); + void save() override; private: FlipSwitchEffectConfigForm* m_ui; KActionCollection* m_actionCollection; }; } // namespace #endif diff --git a/effects/highlightwindow/highlightwindow.h b/effects/highlightwindow/highlightwindow.h index 2de9b3d9c..58158813c 100644 --- a/effects/highlightwindow/highlightwindow.h +++ b/effects/highlightwindow/highlightwindow.h @@ -1,87 +1,87 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2009 Lucas Murray 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_HIGHLIGHTWINDOW_H #define KWIN_HIGHLIGHTWINDOW_H #include namespace KWin { class HighlightWindowEffect : public Effect { Q_OBJECT public: HighlightWindowEffect(); - virtual ~HighlightWindowEffect(); + ~HighlightWindowEffect() override; - virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); - virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); - virtual bool isActive() const; + void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) override; + void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override; + bool isActive() const override; int requestedEffectChainPosition() const override { return 70; } bool provides(Feature feature) override; bool perform(Feature feature, const QVariantList &arguments) override; public Q_SLOTS: void slotWindowAdded(KWin::EffectWindow* w); void slotWindowClosed(KWin::EffectWindow *w); void slotWindowDeleted(KWin::EffectWindow *w); void slotPropertyNotify(KWin::EffectWindow* w, long atom, EffectWindow *addedWindow = NULL); private: void prepareHighlighting(); void finishHighlighting(); void highlightWindows(const QVector &windows); bool m_finishing; float m_fadeDuration; QHash m_windowOpacity; long m_atom; QList m_highlightedWindows; EffectWindow* m_monitorWindow; QList m_highlightedIds; // Offscreen position cache /*QRect m_thumbArea; // Thumbnail area QPoint m_arrowTip; // Position of the arrow's tip QPoint m_arrowA; // Arrow vertex position at the base (First) QPoint m_arrowB; // Arrow vertex position at the base (Second) // Helper functions inline double aspectRatio( EffectWindow *w ) { return w->width() / double( w->height() ); } inline int widthForHeight( EffectWindow *w, int height ) { return int(( height / double( w->height() )) * w->width() ); } inline int heightForWidth( EffectWindow *w, int width ) { return int(( width / double( w->width() )) * w->height() ); }*/ }; } // namespace #endif diff --git a/effects/invert/invert.h b/effects/invert/invert.h index 65d2e8d1c..598faddc0 100644 --- a/effects/invert/invert.h +++ b/effects/invert/invert.h @@ -1,75 +1,75 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2007 Rivo Laks Copyright (C) 2008 Lucas Murray 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_INVERT_H #define KWIN_INVERT_H #include namespace KWin { class GLShader; /** * Inverts desktop's colors **/ class InvertEffect : public Effect { Q_OBJECT public: InvertEffect(); - ~InvertEffect(); + ~InvertEffect() override; - virtual void drawWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); - virtual void paintEffectFrame(KWin::EffectFrame* frame, QRegion region, double opacity, double frameOpacity); - virtual bool isActive() const; - virtual bool provides(Feature); + void drawWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override; + void paintEffectFrame(KWin::EffectFrame* frame, QRegion region, double opacity, double frameOpacity) override; + bool isActive() const override; + bool provides(Feature) override; int requestedEffectChainPosition() const override; static bool supported(); public Q_SLOTS: void toggleScreenInversion(); void toggleWindow(); void slotWindowClosed(KWin::EffectWindow *w); protected: bool loadData(); private: bool m_inited; bool m_valid; GLShader* m_shader; bool m_allWindows; QList m_windows; }; inline int InvertEffect::requestedEffectChainPosition() const { return 99; } } // namespace #endif diff --git a/effects/invert/invert_config.h b/effects/invert/invert_config.h index 1fab78ccd..b4269a19b 100644 --- a/effects/invert/invert_config.h +++ b/effects/invert/invert_config.h @@ -1,49 +1,49 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2007 Rivo Laks 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_INVERT_CONFIG_H #define KWIN_INVERT_CONFIG_H #include class KShortcutsEditor; namespace KWin { class InvertEffectConfig : public KCModule { Q_OBJECT public: explicit InvertEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); - ~InvertEffectConfig(); + ~InvertEffectConfig() override; public Q_SLOTS: - virtual void save(); - virtual void load(); - virtual void defaults(); + void save() override; + void load() override; + void defaults() override; private: KShortcutsEditor* mShortcutEditor; }; } // namespace #endif diff --git a/effects/kscreen/kscreen.h b/effects/kscreen/kscreen.h index 2f9dad1df..b0feae0b3 100644 --- a/effects/kscreen/kscreen.h +++ b/effects/kscreen/kscreen.h @@ -1,66 +1,66 @@ /******************************************************************** 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_KSCREEN_H #define KWIN_KSCREEN_H #include namespace KWin { class KscreenEffect : public Effect { Q_OBJECT public: KscreenEffect(); - virtual ~KscreenEffect(); + ~KscreenEffect() override; - virtual void prePaintScreen(ScreenPrePaintData &data, int time); - virtual void postPaintScreen(); - virtual void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time); - virtual void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data); + void prePaintScreen(ScreenPrePaintData &data, int time) override; + void postPaintScreen() override; + void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time) override; + void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override; - void reconfigure(ReconfigureFlags flags); - virtual bool isActive() const; + void reconfigure(ReconfigureFlags flags) override; + bool isActive() const override; int requestedEffectChainPosition() const override { return 99; } private Q_SLOTS: void propertyNotify(KWin::EffectWindow *window, long atom); private: void switchState(); enum FadeOutState { StateNormal, StateFadingOut, StateFadedOut, StateFadingIn }; TimeLine m_timeLine; FadeOutState m_state; xcb_atom_t m_atom; }; } // namespace KWin #endif // KWIN_KSCREEN_H diff --git a/effects/lookingglass/lookingglass.h b/effects/lookingglass/lookingglass.h index 2252a7007..84a0e63bc 100644 --- a/effects/lookingglass/lookingglass.h +++ b/effects/lookingglass/lookingglass.h @@ -1,83 +1,83 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2007 Rivo Laks Copyright (C) 2007 Christian Nitschkowski 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_LOOKINGGLASS_H #define KWIN_LOOKINGGLASS_H #include namespace KWin { class GLRenderTarget; class GLShader; class GLTexture; class GLVertexBuffer; /** * Enhanced magnifier **/ class LookingGlassEffect : public Effect { Q_OBJECT Q_PROPERTY(int initialRadius READ initialRadius) public: LookingGlassEffect(); - virtual ~LookingGlassEffect(); + ~LookingGlassEffect() override; - virtual void reconfigure(ReconfigureFlags); + void reconfigure(ReconfigureFlags) override; - virtual void prePaintScreen(ScreenPrePaintData& data, int time); + void prePaintScreen(ScreenPrePaintData& data, int time) override; void paintScreen(int mask, QRegion region, ScreenPaintData &data) override; - virtual bool isActive() const; + bool isActive() const override; static bool supported(); // for properties int initialRadius() const { return initialradius; } public Q_SLOTS: void toggle(); void zoomIn(); void zoomOut(); void slotMouseChanged(const QPoint& pos, const QPoint& old, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); private: bool loadData(); double zoom; double target_zoom; bool polling; // Mouse polling int radius; int initialradius; GLTexture *m_texture; GLRenderTarget *m_fbo; GLVertexBuffer *m_vbo; GLShader *m_shader; bool m_enabled; bool m_valid; }; } // namespace #endif diff --git a/effects/lookingglass/lookingglass_config.h b/effects/lookingglass/lookingglass_config.h index ef81612bf..22adf1b10 100644 --- a/effects/lookingglass/lookingglass_config.h +++ b/effects/lookingglass/lookingglass_config.h @@ -1,57 +1,57 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2007 Christian Nitschkowski 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_LOOKINGGLASS_CONFIG_H #define KWIN_LOOKINGGLASS_CONFIG_H #include #include "ui_lookingglass_config.h" class KActionCollection; namespace KWin { class LookingGlassEffectConfigForm : public QWidget, public Ui::LookingGlassEffectConfigForm { Q_OBJECT public: explicit LookingGlassEffectConfigForm(QWidget* parent); }; class LookingGlassEffectConfig : public KCModule { Q_OBJECT public: explicit LookingGlassEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); - virtual ~LookingGlassEffectConfig(); + ~LookingGlassEffectConfig() override; - virtual void save(); - virtual void defaults(); + void save() override; + void defaults() override; private: LookingGlassEffectConfigForm* m_ui; KActionCollection* m_actionCollection; }; } // namespace #endif diff --git a/effects/magiclamp/magiclamp.h b/effects/magiclamp/magiclamp.h index 0bd900b2c..6626241a9 100644 --- a/effects/magiclamp/magiclamp.h +++ b/effects/magiclamp/magiclamp.h @@ -1,69 +1,69 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2008 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_MAGICLAMP_H #define KWIN_MAGICLAMP_H #include namespace KWin { class MagicLampEffect : public Effect { Q_OBJECT public: MagicLampEffect(); - virtual void reconfigure(ReconfigureFlags); - virtual void prePaintScreen(ScreenPrePaintData& data, int time); - virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); - virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); - virtual void postPaintScreen(); - virtual bool isActive() const; + void reconfigure(ReconfigureFlags) override; + void prePaintScreen(ScreenPrePaintData& data, int time) override; + void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) override; + void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override; + void postPaintScreen() override; + bool isActive() const override; int requestedEffectChainPosition() const override { return 50; } static bool supported(); public Q_SLOTS: void slotWindowDeleted(KWin::EffectWindow *w); void slotWindowMinimized(KWin::EffectWindow *w); void slotWindowUnminimized(KWin::EffectWindow *w); private: std::chrono::milliseconds m_duration; QHash m_animations; enum IconPosition { Top, Bottom, Left, Right }; }; } // namespace #endif diff --git a/effects/magiclamp/magiclamp_config.h b/effects/magiclamp/magiclamp_config.h index 4f07dd881..2f074c07d 100644 --- a/effects/magiclamp/magiclamp_config.h +++ b/effects/magiclamp/magiclamp_config.h @@ -1,54 +1,54 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2009 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_MAGICLAMP_CONFIG_H #define KWIN_MAGICLAMP_CONFIG_H #include #include "ui_magiclamp_config.h" namespace KWin { class MagicLampEffectConfigForm : public QWidget, public Ui::MagicLampEffectConfigForm { Q_OBJECT public: explicit MagicLampEffectConfigForm(QWidget* parent); }; class MagicLampEffectConfig : public KCModule { Q_OBJECT public: explicit MagicLampEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); public Q_SLOTS: - virtual void save(); + void save() override; private: MagicLampEffectConfigForm* m_ui; }; } // namespace #endif diff --git a/effects/magnifier/magnifier.h b/effects/magnifier/magnifier.h index 14345bc45..de2a215ba 100644 --- a/effects/magnifier/magnifier.h +++ b/effects/magnifier/magnifier.h @@ -1,82 +1,82 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2007 Lubos Lunak Copyright (C) 2011 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_MAGNIFIER_H #define KWIN_MAGNIFIER_H #include namespace KWin { class GLRenderTarget; class GLTexture; class XRenderPicture; class MagnifierEffect : public Effect { Q_OBJECT Q_PROPERTY(QSize magnifierSize READ magnifierSize) Q_PROPERTY(qreal targetZoom READ targetZoom) public: MagnifierEffect(); - virtual ~MagnifierEffect(); - virtual void reconfigure(ReconfigureFlags); - virtual void prePaintScreen(ScreenPrePaintData& data, int time); - virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); - virtual void postPaintScreen(); - virtual bool isActive() const; + ~MagnifierEffect() override; + void reconfigure(ReconfigureFlags) override; + void prePaintScreen(ScreenPrePaintData& data, int time) override; + void paintScreen(int mask, QRegion region, ScreenPaintData& data) override; + void postPaintScreen() override; + bool isActive() const override; static bool supported(); // for properties QSize magnifierSize() const { return magnifier_size; } qreal targetZoom() const { return target_zoom; } private Q_SLOTS: void zoomIn(); void zoomOut(); void toggle(); void slotMouseChanged(const QPoint& pos, const QPoint& old, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); void destroyPixmap(); private: QRect magnifierArea(QPoint pos = cursorPos()) const; double zoom; double target_zoom; bool polling; // Mouse polling QSize magnifier_size; GLTexture *m_texture; GLRenderTarget *m_fbo; #ifdef KWIN_HAVE_XRENDER_COMPOSITING xcb_pixmap_t m_pixmap; QSize m_pixmapSize; QScopedPointer m_picture; #endif }; } // namespace #endif diff --git a/effects/magnifier/magnifier_config.h b/effects/magnifier/magnifier_config.h index f21652a1b..6dafd4f87 100644 --- a/effects/magnifier/magnifier_config.h +++ b/effects/magnifier/magnifier_config.h @@ -1,57 +1,57 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2007 Christian Nitschkowski 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_MAGNIFIER_CONFIG_H #define KWIN_MAGNIFIER_CONFIG_H #include #include "ui_magnifier_config.h" class KActionCollection; namespace KWin { class MagnifierEffectConfigForm : public QWidget, public Ui::MagnifierEffectConfigForm { Q_OBJECT public: explicit MagnifierEffectConfigForm(QWidget* parent); }; class MagnifierEffectConfig : public KCModule { Q_OBJECT public: explicit MagnifierEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); - virtual ~MagnifierEffectConfig(); + ~MagnifierEffectConfig() override; - virtual void save(); - virtual void defaults(); + void save() override; + void defaults() override; private: MagnifierEffectConfigForm* m_ui; KActionCollection* m_actionCollection; }; } // namespace #endif diff --git a/effects/mouseclick/mouseclick.h b/effects/mouseclick/mouseclick.h index afcd170bc..1c4eb1e49 100644 --- a/effects/mouseclick/mouseclick.h +++ b/effects/mouseclick/mouseclick.h @@ -1,185 +1,185 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2012 Filip Wieladek 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_MOUSECLICK_H #define KWIN_MOUSECLICK_H #include #include #include #include #include namespace KWin { #define BUTTON_COUNT 3 class MouseEvent { public: int m_button; QPoint m_pos; int m_time; EffectFrame* m_frame; bool m_press; public: MouseEvent(int button, QPoint point, int time, EffectFrame* frame, bool press) : m_button(button), m_pos(point), m_time(time), m_frame(frame), m_press(press) {}; ~MouseEvent() { delete m_frame; } }; class MouseButton { public: QString m_labelUp; QString m_labelDown; Qt::MouseButtons m_button; bool m_isPressed; int m_time; public: MouseButton(QString label, Qt::MouseButtons button) : m_labelUp(label), m_labelDown(label), m_button(button), m_isPressed(false), m_time(0) { m_labelDown.append(i18n("↓")); m_labelUp.append(i18n("↑")); }; inline void setPressed(bool pressed) { if (m_isPressed != pressed) { m_isPressed = pressed; if (pressed) m_time = 0; } } }; class MouseClickEffect : public Effect { Q_OBJECT Q_PROPERTY(QColor color1 READ color1) Q_PROPERTY(QColor color2 READ color2) Q_PROPERTY(QColor color3 READ color3) Q_PROPERTY(qreal lineWidth READ lineWidth) Q_PROPERTY(int ringLife READ ringLife) Q_PROPERTY(int ringSize READ ringSize) Q_PROPERTY(int ringCount READ ringCount) Q_PROPERTY(bool showText READ isShowText) Q_PROPERTY(QFont font READ font) Q_PROPERTY(bool enabled READ isEnabled) public: MouseClickEffect(); - ~MouseClickEffect(); - virtual void reconfigure(ReconfigureFlags); - virtual void prePaintScreen(ScreenPrePaintData& data, int time); - virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); - virtual void postPaintScreen(); - virtual bool isActive() const; + ~MouseClickEffect() override; + void reconfigure(ReconfigureFlags) override; + void prePaintScreen(ScreenPrePaintData& data, int time) override; + void paintScreen(int mask, QRegion region, ScreenPaintData& data) override; + void postPaintScreen() override; + bool isActive() const override; // for properties QColor color1() const { return m_colors[0]; } QColor color2() const { return m_colors[1]; } QColor color3() const { return m_colors[2]; } qreal lineWidth() const { return m_lineWidth; } int ringLife() const { return m_ringLife; } int ringSize() const { return m_ringMaxSize; } int ringCount() const { return m_ringCount; } bool isShowText() const { return m_showText; } QFont font() const { return m_font; } bool isEnabled() const { return m_enabled; } private Q_SLOTS: void toggleEnabled(); void slotMouseChanged(const QPoint& pos, const QPoint& old, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); private: EffectFrame* createEffectFrame(const QPoint& pos, const QString& text); inline void drawCircle(const QColor& color, float cx, float cy, float r); inline void paintScreenSetup(int mask, QRegion region, ScreenPaintData& data); inline void paintScreenFinish(int mask, QRegion region, ScreenPaintData& data); inline bool isReleased(Qt::MouseButtons button, Qt::MouseButtons buttons, Qt::MouseButtons oldButtons); inline bool isPressed(Qt::MouseButtons button, Qt::MouseButtons buttons, Qt::MouseButtons oldButtons); inline float computeRadius(const MouseEvent* click, int ring); inline float computeAlpha(const MouseEvent* click, int ring); void repaint(); void drawCircleGl(const QColor& color, float cx, float cy, float r); void drawCircleXr(const QColor& color, float cx, float cy, float r); void drawCircleQPainter(const QColor& color, float cx, float cy, float r); void paintScreenSetupGl(int mask, QRegion region, ScreenPaintData& data); void paintScreenFinishGl(int mask, QRegion region, ScreenPaintData& data); QColor m_colors[BUTTON_COUNT]; int m_ringCount; float m_lineWidth; float m_ringLife; float m_ringMaxSize; bool m_showText; QFont m_font; QList m_clicks; MouseButton* m_buttons[BUTTON_COUNT]; bool m_enabled; }; } // namespace #endif diff --git a/effects/mouseclick/mouseclick_config.h b/effects/mouseclick/mouseclick_config.h index 028662c6e..9e8ef375c 100644 --- a/effects/mouseclick/mouseclick_config.h +++ b/effects/mouseclick/mouseclick_config.h @@ -1,56 +1,56 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2012 Filip Wieladek 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_MOUSECLICK_CONFIG_H #define KWIN_MOUSECLICK_CONFIG_H #include #include "ui_mouseclick_config.h" class KActionCollection; namespace KWin { class MouseClickEffectConfigForm : public QWidget, public Ui::MouseClickEffectConfigForm { Q_OBJECT public: explicit MouseClickEffectConfigForm(QWidget* parent); }; class MouseClickEffectConfig : public KCModule { Q_OBJECT public: explicit MouseClickEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); - virtual ~MouseClickEffectConfig(); + ~MouseClickEffectConfig() override; - virtual void save(); + void save() override; private: MouseClickEffectConfigForm* m_ui; KActionCollection* m_actionCollection; }; } // namespace #endif diff --git a/effects/mousemark/mousemark.h b/effects/mousemark/mousemark.h index 2f24f7596..eab3c2705 100644 --- a/effects/mousemark/mousemark.h +++ b/effects/mousemark/mousemark.h @@ -1,76 +1,76 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2007 Lubos Lunak 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_MOUSEMARK_H #define KWIN_MOUSEMARK_H #include #include #include struct xcb_render_color_t; namespace KWin { class MouseMarkEffect : public Effect { Q_OBJECT Q_PROPERTY(int width READ configuredWidth) Q_PROPERTY(QColor color READ configuredColor) public: MouseMarkEffect(); - ~MouseMarkEffect(); - virtual void reconfigure(ReconfigureFlags); - virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); - virtual bool isActive() const; + ~MouseMarkEffect() override; + void reconfigure(ReconfigureFlags) override; + void paintScreen(int mask, QRegion region, ScreenPaintData& data) override; + bool isActive() const override; // for properties int configuredWidth() const { return width; } QColor configuredColor() const { return color; } private Q_SLOTS: void clear(); void clearLast(); void slotMouseChanged(const QPoint& pos, const QPoint& old, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); void screenLockingChanged(bool locked); private: typedef QVector< QPoint > Mark; void drawMark(QPainter *painter, const Mark &mark); static Mark createArrow(QPoint arrow_start, QPoint arrow_end); #ifdef KWIN_HAVE_XRENDER_COMPOSITING void addRect(const QPoint &p1, const QPoint &p2, xcb_rectangle_t *r, xcb_render_color_t *c); #endif QVector< Mark > marks; Mark drawing; QPoint arrow_start; int width; QColor color; }; } // namespace #endif diff --git a/effects/mousemark/mousemark_config.h b/effects/mousemark/mousemark_config.h index 290c9add7..aea63f0c0 100644 --- a/effects/mousemark/mousemark_config.h +++ b/effects/mousemark/mousemark_config.h @@ -1,56 +1,56 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2007 Christian Nitschkowski 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_MOUSEMARK_CONFIG_H #define KWIN_MOUSEMARK_CONFIG_H #include #include "ui_mousemark_config.h" class KActionCollection; namespace KWin { class MouseMarkEffectConfigForm : public QWidget, public Ui::MouseMarkEffectConfigForm { Q_OBJECT public: explicit MouseMarkEffectConfigForm(QWidget* parent); }; class MouseMarkEffectConfig : public KCModule { Q_OBJECT public: explicit MouseMarkEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); - virtual ~MouseMarkEffectConfig(); + ~MouseMarkEffectConfig() override; - virtual void save(); + void save() override; private: MouseMarkEffectConfigForm* m_ui; KActionCollection* m_actionCollection; }; } // namespace #endif diff --git a/effects/presentwindows/presentwindows.h b/effects/presentwindows/presentwindows.h index 9f2c21fa1..21881d261 100644 --- a/effects/presentwindows/presentwindows.h +++ b/effects/presentwindows/presentwindows.h @@ -1,352 +1,352 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2007 Rivo Laks Copyright (C) 2008 Lucas Murray 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_PRESENTWINDOWS_H #define KWIN_PRESENTWINDOWS_H #include "presentwindows_proxy.h" #include class QMouseEvent; class QElapsedTimer; class QQuickView; namespace KWin { class CloseWindowView : public QObject { Q_OBJECT public: explicit CloseWindowView(QObject *parent = 0); void windowInputMouseEvent(QMouseEvent* e); void disarm(); void show(); void hide(); bool isVisible() const; // delegate to QWindow int width() const; int height() const; QSize size() const; QRect geometry() const; WId winId() const; void setGeometry(const QRect &geometry); QPoint mapFromGlobal(const QPoint &pos) const; Q_SIGNALS: void requestClose(); private: QScopedPointer m_armTimer; QScopedPointer m_window; bool m_visible; QPoint m_pos; bool m_posIsValid; }; /** * Expose-like effect which shows all windows on current desktop side-by-side, * letting the user select active window. **/ class PresentWindowsEffect : public Effect { Q_OBJECT Q_PROPERTY(int layoutMode READ layoutMode) Q_PROPERTY(bool showCaptions READ isShowCaptions) Q_PROPERTY(bool showIcons READ isShowIcons) Q_PROPERTY(bool doNotCloseWindows READ isDoNotCloseWindows) Q_PROPERTY(bool ignoreMinimized READ isIgnoreMinimized) Q_PROPERTY(int accuracy READ accuracy) Q_PROPERTY(bool fillGaps READ isFillGaps) Q_PROPERTY(int fadeDuration READ fadeDuration) Q_PROPERTY(bool showPanel READ isShowPanel) Q_PROPERTY(int leftButtonWindow READ leftButtonWindow) Q_PROPERTY(int rightButtonWindow READ rightButtonWindow) Q_PROPERTY(int middleButtonWindow READ middleButtonWindow) Q_PROPERTY(int leftButtonDesktop READ leftButtonDesktop) Q_PROPERTY(int middleButtonDesktop READ middleButtonDesktop) Q_PROPERTY(int rightButtonDesktop READ rightButtonDesktop) // TODO: electric borders private: // Structures struct WindowData { bool visible; bool deleted; bool referenced; double opacity; double highlight; EffectFrame* textFrame; EffectFrame* iconFrame; }; typedef QHash DataHash; struct GridSize { int columns; int rows; }; public: PresentWindowsEffect(); - virtual ~PresentWindowsEffect(); + ~PresentWindowsEffect() override; - virtual void reconfigure(ReconfigureFlags); - virtual void* proxy(); + void reconfigure(ReconfigureFlags) override; + void* proxy() override; // Screen painting - virtual void prePaintScreen(ScreenPrePaintData &data, int time); - virtual void paintScreen(int mask, QRegion region, ScreenPaintData &data); - virtual void postPaintScreen(); + void prePaintScreen(ScreenPrePaintData &data, int time) override; + void paintScreen(int mask, QRegion region, ScreenPaintData &data) override; + void postPaintScreen() override; // Window painting - virtual void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time); - virtual void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data); + void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time) override; + void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override; // User interaction - virtual bool borderActivated(ElectricBorder border); - virtual void windowInputMouseEvent(QEvent *e); - virtual void grabbedKeyboardEvent(QKeyEvent *e); - virtual bool isActive() const; + bool borderActivated(ElectricBorder border) override; + void windowInputMouseEvent(QEvent *e) override; + void grabbedKeyboardEvent(QKeyEvent *e) override; + bool isActive() const override; bool touchDown(quint32 id, const QPointF &pos, quint32 time) override; bool touchMotion(quint32 id, const QPointF &pos, quint32 time) override; bool touchUp(quint32 id, quint32 time) override; int requestedEffectChainPosition() const override { return 70; } enum { LayoutNatural, LayoutRegularGrid, LayoutFlexibleGrid }; // Layout modes enum PresentWindowsMode { ModeAllDesktops, // Shows windows of all desktops ModeCurrentDesktop, // Shows windows on current desktop ModeSelectedDesktop, // Shows windows of selected desktop via property (m_desktop) ModeWindowGroup, // Shows windows selected via property ModeWindowClass // Shows all windows of same class as selected class }; enum WindowMouseAction { WindowNoAction = 0, // Nothing WindowActivateAction = 1, // Activates the window and deactivates the effect WindowExitAction = 2, // Deactivates the effect without activating new window WindowToCurrentDesktopAction = 3, // Brings window to current desktop WindowToAllDesktopsAction = 4, // Brings window to all desktops WindowMinimizeAction = 5, // Minimizes the window WindowCloseAction = 6 // Closes the window }; enum DesktopMouseAction { DesktopNoAction = 0, // nothing DesktopActivateAction = 1, // Activates the window and deactivates the effect DesktopExitAction = 2, // Deactivates the effect without activating new window DesktopShowDesktopAction = 3 // Minimizes all windows }; // for properties int layoutMode() const { return m_layoutMode; } bool isShowCaptions() const { return m_showCaptions; } bool isShowIcons() const { return m_showIcons; } bool isDoNotCloseWindows() const { return m_doNotCloseWindows; } bool isIgnoreMinimized() const { return m_ignoreMinimized; } int accuracy() const { return m_accuracy; } bool isFillGaps() const { return m_fillGaps; } int fadeDuration() const { return m_fadeDuration; } bool isShowPanel() const { return m_showPanel; } int leftButtonWindow() const { return m_leftButtonWindow; } int rightButtonWindow() const { return m_rightButtonWindow; } int middleButtonWindow() const { return m_middleButtonWindow; } int leftButtonDesktop() const { return m_leftButtonDesktop; } int middleButtonDesktop() const { return m_middleButtonDesktop; } int rightButtonDesktop() const { return m_rightButtonDesktop; } public Q_SLOTS: void setActive(bool active); void toggleActive() { m_mode = ModeCurrentDesktop; setActive(!m_activated); } void toggleActiveAllDesktops() { m_mode = ModeAllDesktops; setActive(!m_activated); } void toggleActiveClass(); // slots for global shortcut changed // needed to toggle the effect void globalShortcutChanged(QAction *action, const QKeySequence &seq); // EffectsHandler void slotWindowAdded(KWin::EffectWindow *w); void slotWindowClosed(KWin::EffectWindow *w); void slotWindowDeleted(KWin::EffectWindow *w); void slotWindowGeometryShapeChanged(KWin::EffectWindow *w, const QRect &old); // atoms void slotPropertyNotify(KWin::EffectWindow* w, long atom); private Q_SLOTS: void closeWindow(); void elevateCloseWindow(); protected: // Window rearranging void rearrangeWindows(); void reCreateGrids(); void calculateWindowTransformations(EffectWindowList windowlist, int screen, WindowMotionManager& motionManager, bool external = false); void calculateWindowTransformationsClosest(EffectWindowList windowlist, int screen, WindowMotionManager& motionManager); void calculateWindowTransformationsKompose(EffectWindowList windowlist, int screen, WindowMotionManager& motionManager); void calculateWindowTransformationsNatural(EffectWindowList windowlist, int screen, WindowMotionManager& motionManager); // Helper functions for window rearranging inline double aspectRatio(EffectWindow *w) { return w->width() / double(w->height()); } inline int widthForHeight(EffectWindow *w, int height) { return int((height / double(w->height())) * w->width()); } inline int heightForWidth(EffectWindow *w, int width) { return int((width / double(w->width())) * w->height()); } bool isOverlappingAny(EffectWindow *w, const QHash &targets, const QRegion &border); // Filter box void updateFilterFrame(); // Helper functions bool isSelectableWindow(EffectWindow *w); bool isVisibleWindow(EffectWindow *w); void setHighlightedWindow(EffectWindow *w); EffectWindow* relativeWindow(EffectWindow *w, int xdiff, int ydiff, bool wrap) const; EffectWindow* findFirstWindow() const; void updateCloseWindow(); // Helper functions for mouse actions void mouseActionWindow(WindowMouseAction& action); void mouseActionDesktop(DesktopMouseAction& action); void inputEventUpdate(const QPoint &pos, QEvent::Type type = QEvent::None, Qt::MouseButton button = Qt::NoButton); private: PresentWindowsEffectProxy m_proxy; friend class PresentWindowsEffectProxy; // User configuration settings QList m_borderActivate; QList m_borderActivateAll; QList m_borderActivateClass; int m_layoutMode; bool m_showCaptions; bool m_showIcons; bool m_doNotCloseWindows; int m_accuracy; bool m_fillGaps; double m_fadeDuration; bool m_showPanel; // Activation bool m_activated; bool m_ignoreMinimized; double m_decalOpacity; bool m_hasKeyboardGrab; PresentWindowsMode m_mode; int m_desktop; EffectWindowList m_selectedWindows; EffectWindow *m_managerWindow; QString m_class; bool m_needInitialSelection; // Window data WindowMotionManager m_motionManager; DataHash m_windowData; EffectWindow *m_highlightedWindow; // Grid layout info QList m_gridSizes; // Filter box EffectFrame* m_filterFrame; QString m_windowFilter; // Shortcut - needed to toggle the effect QList shortcut; QList shortcutAll; QList shortcutClass; // Atoms // Present windows for all windows of given desktop // -1 for all desktops long m_atomDesktop; // Present windows for group of window ids long m_atomWindows; // Mouse Actions WindowMouseAction m_leftButtonWindow; WindowMouseAction m_middleButtonWindow; WindowMouseAction m_rightButtonWindow; DesktopMouseAction m_leftButtonDesktop; DesktopMouseAction m_middleButtonDesktop; DesktopMouseAction m_rightButtonDesktop; CloseWindowView* m_closeView; EffectWindow* m_closeWindow; Qt::Corner m_closeButtonCorner; struct { quint32 id = 0; bool active = false; } m_touch; QAction *m_exposeAction; QAction *m_exposeAllAction; QAction *m_exposeClassAction; }; } // namespace #endif diff --git a/effects/presentwindows/presentwindows_config.h b/effects/presentwindows/presentwindows_config.h index 6eae72b01..4607be00b 100644 --- a/effects/presentwindows/presentwindows_config.h +++ b/effects/presentwindows/presentwindows_config.h @@ -1,57 +1,57 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2007 Rivo Laks Copyright (C) 2008 Lucas Murray 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_PRESENTWINDOWS_CONFIG_H #define KWIN_PRESENTWINDOWS_CONFIG_H #include #include "ui_presentwindows_config.h" namespace KWin { class PresentWindowsEffectConfigForm : public QWidget, public Ui::PresentWindowsEffectConfigForm { Q_OBJECT public: explicit PresentWindowsEffectConfigForm(QWidget* parent); }; class PresentWindowsEffectConfig : public KCModule { Q_OBJECT public: explicit PresentWindowsEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); - ~PresentWindowsEffectConfig(); + ~PresentWindowsEffectConfig() override; public Q_SLOTS: - virtual void save(); - virtual void defaults(); + void save() override; + void defaults() override; private: PresentWindowsEffectConfigForm* m_ui; KActionCollection* m_actionCollection; }; } // namespace #endif diff --git a/effects/resize/resize.h b/effects/resize/resize.h index 4b79bbc98..299ae1982 100644 --- a/effects/resize/resize.h +++ b/effects/resize/resize.h @@ -1,73 +1,73 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2009 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_RESIZE_H #define KWIN_RESIZE_H #include namespace KWin { class ResizeEffect : public AnimationEffect { Q_OBJECT Q_PROPERTY(bool textureScale READ isTextureScale) Q_PROPERTY(bool outline READ isOutline) public: ResizeEffect(); - ~ResizeEffect(); - virtual inline bool provides(Effect::Feature ef) { + ~ResizeEffect() override; + inline bool provides(Effect::Feature ef) override { return ef == Effect::Resize; } - inline bool isActive() const { return m_active || AnimationEffect::isActive(); } - virtual void prePaintScreen(ScreenPrePaintData& data, int time); - virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); - virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); - virtual void reconfigure(ReconfigureFlags); + inline bool isActive() const override { return m_active || AnimationEffect::isActive(); } + void prePaintScreen(ScreenPrePaintData& data, int time) override; + void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) override; + void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override; + void reconfigure(ReconfigureFlags) override; int requestedEffectChainPosition() const override { return 60; } bool isTextureScale() const { return m_features & TextureScale; } bool isOutline() const { return m_features & Outline; } public Q_SLOTS: void slotWindowStartUserMovedResized(KWin::EffectWindow *w); void slotWindowStepUserMovedResized(KWin::EffectWindow *w, const QRect &geometry); void slotWindowFinishUserMovedResized(KWin::EffectWindow *w); private: enum Feature { TextureScale = 1 << 0, Outline = 1 << 1 }; bool m_active; int m_features; EffectWindow* m_resizeWindow; QRect m_currentGeometry, m_originalGeometry; }; } #endif diff --git a/effects/resize/resize_config.h b/effects/resize/resize_config.h index f9742e0ff..e02e596e3 100644 --- a/effects/resize/resize_config.h +++ b/effects/resize/resize_config.h @@ -1,54 +1,54 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2010 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_RESIZE_CONFIG_H #define KWIN_RESIZE_CONFIG_H #include #include "ui_resize_config.h" namespace KWin { class ResizeEffectConfigForm : public QWidget, public Ui::ResizeEffectConfigForm { Q_OBJECT public: explicit ResizeEffectConfigForm(QWidget* parent = 0); }; class ResizeEffectConfig : public KCModule { Q_OBJECT public: explicit ResizeEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); public Q_SLOTS: - virtual void save(); + void save() override; private: ResizeEffectConfigForm* m_ui; }; } // namespace #endif diff --git a/effects/screenedge/screenedgeeffect.h b/effects/screenedge/screenedgeeffect.h index d940e6191..9ed7a524d 100644 --- a/effects/screenedge/screenedgeeffect.h +++ b/effects/screenedge/screenedgeeffect.h @@ -1,79 +1,79 @@ /******************************************************************** 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_SCREEN_EDGE_EFFECT_H #define KWIN_SCREEN_EDGE_EFFECT_H #include class QTimer; namespace Plasma { class Svg; } namespace KWin { class Glow; class GLTexture; class ScreenEdgeEffect : public Effect { Q_OBJECT public: ScreenEdgeEffect(); - virtual ~ScreenEdgeEffect(); - virtual void prePaintScreen(ScreenPrePaintData &data, int time); - virtual void paintScreen(int mask, QRegion region, ScreenPaintData &data); - virtual bool isActive() const; + ~ScreenEdgeEffect() override; + void prePaintScreen(ScreenPrePaintData &data, int time) override; + void paintScreen(int mask, QRegion region, ScreenPaintData &data) override; + bool isActive() const override; int requestedEffectChainPosition() const override { return 90; } private Q_SLOTS: void edgeApproaching(ElectricBorder border, qreal factor, const QRect &geometry); void cleanup(); private: void ensureGlowSvg(); Glow *createGlow(ElectricBorder border, qreal factor, const QRect &geometry); template T *createCornerGlow(ElectricBorder border); template T *createEdgeGlow(ElectricBorder border, const QSize &size); QSize cornerGlowSize(ElectricBorder border); Plasma::Svg *m_glow = nullptr; QHash m_borders; QTimer *m_cleanupTimer; }; class Glow { public: QScopedPointer texture; QScopedPointer image; #ifdef KWIN_HAVE_XRENDER_COMPOSITING QScopedPointer picture; #endif QSize pictureSize; qreal strength; QRect geometry; ElectricBorder border; }; } #endif diff --git a/effects/showfps/showfps.h b/effects/showfps/showfps.h index 40c6a86dd..3f5cb1583 100644 --- a/effects/showfps/showfps.h +++ b/effects/showfps/showfps.h @@ -1,109 +1,109 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2006 Lubos Lunak 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_SHOWFPS_H #define KWIN_SHOWFPS_H #include #include #include namespace KWin { class GLTexture; class ShowFpsEffect : public Effect { Q_OBJECT Q_PROPERTY(qreal alpha READ configuredAlpha) Q_PROPERTY(int x READ configuredX) Q_PROPERTY(int y READ configuredY) Q_PROPERTY(QRect fpsTextRect READ configuredFpsTextRect) Q_PROPERTY(int textAlign READ configuredTextAlign) Q_PROPERTY(QFont textFont READ configuredTextFont) Q_PROPERTY(QColor textColor READ configuredTextColor) public: ShowFpsEffect(); - virtual void reconfigure(ReconfigureFlags); - virtual void prePaintScreen(ScreenPrePaintData& data, int time); - virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); - virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); - virtual void postPaintScreen(); + void reconfigure(ReconfigureFlags) override; + void prePaintScreen(ScreenPrePaintData& data, int time) override; + void paintScreen(int mask, QRegion region, ScreenPaintData& data) override; + void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override; + void postPaintScreen() override; enum { INSIDE_GRAPH, NOWHERE, TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT }; // fps text position // for properties qreal configuredAlpha() const { return alpha; } int configuredX() const { return x; } int configuredY() const { return y; } QRect configuredFpsTextRect() const { return fpsTextRect; } int configuredTextAlign() const { return textAlign; } QFont configuredTextFont() const { return textFont; } QColor configuredTextColor() const { return textColor; } private: void paintGL(int fps, const QMatrix4x4 &projectionMatrix); #ifdef KWIN_HAVE_XRENDER_COMPOSITING void paintXrender(int fps); #endif void paintQPainter(int fps); void paintFPSGraph(int x, int y); void paintDrawSizeGraph(int x, int y); void paintGraph(int x, int y, QList values, QList lines, bool colorize); QImage fpsTextImage(int fps); QTime t; enum { NUM_PAINTS = 100 }; // remember time needed to paint this many paints int paints[ NUM_PAINTS ]; // time needed to paint int paint_size[ NUM_PAINTS ]; // number of pixels painted int paints_pos; // position in the queue enum { MAX_FPS = 200 }; int frames[ MAX_FPS ]; // (sec*1000+msec) of the time the frame was done int frames_pos; // position in the queue double alpha; int x; int y; QRect fps_rect; QScopedPointer fpsText; int textPosition; QFont textFont; QColor textColor; QRect fpsTextRect; int textAlign; QScopedPointer m_noBenchmark; }; } // namespace #endif diff --git a/effects/showfps/showfps_config.h b/effects/showfps/showfps_config.h index 9858d5f4c..7ac264d08 100644 --- a/effects/showfps/showfps_config.h +++ b/effects/showfps/showfps_config.h @@ -1,47 +1,47 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2007 Rivo Laks 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_SHOWFPS_CONFIG_H #define KWIN_SHOWFPS_CONFIG_H #include #include "ui_showfps_config.h" namespace KWin { class ShowFpsEffectConfig : public KCModule { Q_OBJECT public: explicit ShowFpsEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); - ~ShowFpsEffectConfig(); + ~ShowFpsEffectConfig() override; public Q_SLOTS: - virtual void save(); + void save() override; private: Ui::ShowFpsEffectConfigForm *m_ui; }; } // namespace #endif diff --git a/effects/slide/slide_config.h b/effects/slide/slide_config.h index f6286b1f6..d13acd607 100644 --- a/effects/slide/slide_config.h +++ b/effects/slide/slide_config.h @@ -1,47 +1,47 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2017, 2018 Vlad Zagorodniy 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 SLIDE_CONFIG_H #define SLIDE_CONFIG_H #include #include "ui_slide_config.h" namespace KWin { class SlideEffectConfig : public KCModule { Q_OBJECT public: explicit SlideEffectConfig(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); - ~SlideEffectConfig(); + ~SlideEffectConfig() override; - void save(); + void save() override; private: ::Ui::SlideEffectConfig m_ui; }; } // namespace KWin #endif diff --git a/effects/slideback/slideback.h b/effects/slideback/slideback.h index c71502e5e..6cdf5f005 100644 --- a/effects/slideback/slideback.h +++ b/effects/slideback/slideback.h @@ -1,80 +1,80 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2009 Michael Zanetti 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_SLIDEBACK_H #define KWIN_SLIDEBACK_H // Include with base class for effects. #include namespace KWin { class SlideBackEffect : public Effect { Q_OBJECT public: SlideBackEffect(); - virtual void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time); - virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); - virtual void postPaintWindow(EffectWindow* w); + void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, int time) override; + void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override; + void postPaintWindow(EffectWindow* w) override; - virtual void prePaintScreen(ScreenPrePaintData &data, int time); - virtual void postPaintScreen(); - virtual bool isActive() const; + void prePaintScreen(ScreenPrePaintData &data, int time) override; + void postPaintScreen() override; + bool isActive() const override; int requestedEffectChainPosition() const override { return 50; } public Q_SLOTS: void slotWindowAdded(KWin::EffectWindow *w); void slotWindowDeleted(KWin::EffectWindow *w); void slotWindowUnminimized(KWin::EffectWindow *w); void slotStackingOrderChanged(); void slotTabBoxAdded(); void slotTabBoxClosed(); private: WindowMotionManager motionManager; EffectWindowList usableOldStackingOrder; EffectWindowList oldStackingOrder; EffectWindowList coveringWindows; EffectWindowList elevatedList; EffectWindow *m_justMapped, *m_upmostWindow; QHash destinationList; int m_tabboxActive; QList clippedRegions; QRect getSlideDestination(const QRect &windowUnderGeometry, const QRect &windowOverGeometry); bool isWindowUsable(EffectWindow *w); bool intersects(EffectWindow *windowUnder, const QRect &windowOverGeometry); EffectWindowList usableWindows(const EffectWindowList &allWindows); QRect getModalGroupGeometry(EffectWindow *w); void windowRaised(EffectWindow *w); }; } // namespace #endif diff --git a/effects/startupfeedback/startupfeedback.h b/effects/startupfeedback/startupfeedback.h index 96ed0d857..204f79850 100644 --- a/effects/startupfeedback/startupfeedback.h +++ b/effects/startupfeedback/startupfeedback.h @@ -1,93 +1,93 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2010 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_STARTUPFEEDBACK_H #define KWIN_STARTUPFEEDBACK_H #include #include #include class KSelectionOwner; namespace KWin { class GLTexture; class StartupFeedbackEffect : public Effect { Q_OBJECT Q_PROPERTY(int type READ type) public: StartupFeedbackEffect(); - virtual ~StartupFeedbackEffect(); + ~StartupFeedbackEffect() override; - virtual void reconfigure(ReconfigureFlags flags); - virtual void prePaintScreen(ScreenPrePaintData& data, int time); - virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); - virtual void postPaintScreen(); - virtual bool isActive() const; + void reconfigure(ReconfigureFlags flags) override; + void prePaintScreen(ScreenPrePaintData& data, int time) override; + void paintScreen(int mask, QRegion region, ScreenPaintData& data) override; + void postPaintScreen() override; + bool isActive() const override; int requestedEffectChainPosition() const override { return 90; } int type() const { return int(m_type); } static bool supported(); private Q_SLOTS: void gotNewStartup(const KStartupInfoId& id, const KStartupInfoData& data); void gotRemoveStartup(const KStartupInfoId& id, const KStartupInfoData& data); void gotStartupChange(const KStartupInfoId& id, const KStartupInfoData& data); void slotMouseChanged(const QPoint& pos, const QPoint& oldpos, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); private: enum FeedbackType { NoFeedback, BouncingFeedback, BlinkingFeedback, PassiveFeedback }; void start(const QString& icon); void stop(); QImage scalePixmap(const QPixmap& pm, const QSize& size) const; void prepareTextures(const QPixmap& pix); QRect feedbackRect() const; qreal m_bounceSizesRatio; KStartupInfo* m_startupInfo; KSelectionOwner* m_selection; KStartupInfoId m_currentStartup; QMap< KStartupInfoId, QString > m_startups; // QString == pixmap bool m_active; int m_frame; int m_progress; GLTexture* m_bouncingTextures[5]; GLTexture* m_texture; // for passive and blinking FeedbackType m_type; QRect m_currentGeometry, m_dirtyRect; GLShader *m_blinkingShader; int m_cursorSize; }; } // namespace #endif diff --git a/effects/thumbnailaside/thumbnailaside.h b/effects/thumbnailaside/thumbnailaside.h index ac38ea5b2..ec98bb29f 100644 --- a/effects/thumbnailaside/thumbnailaside.h +++ b/effects/thumbnailaside/thumbnailaside.h @@ -1,91 +1,91 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2007 Lubos Lunak Copyright (C) 2007 Christian Nitschkowski 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 . *********************************************************************/ /* Testing of painting a window more than once. */ #ifndef KWIN_THUMBNAILASIDE_H #define KWIN_THUMBNAILASIDE_H #include #include namespace KWin { class ThumbnailAsideEffect : public Effect { Q_OBJECT Q_PROPERTY(int maxWidth READ configuredMaxWidth) Q_PROPERTY(int spacing READ configuredSpacing) Q_PROPERTY(qreal opacity READ configuredOpacity) Q_PROPERTY(int screen READ configuredScreen) public: ThumbnailAsideEffect(); - virtual void reconfigure(ReconfigureFlags); - virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); - virtual void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data); + void reconfigure(ReconfigureFlags) override; + void paintScreen(int mask, QRegion region, ScreenPaintData& data) override; + void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override; // for properties int configuredMaxWidth() const { return maxwidth; } int configuredSpacing() const { return spacing; } qreal configuredOpacity() const { return opacity; } int configuredScreen() const { return screen; } private Q_SLOTS: void toggleCurrentThumbnail(); void slotWindowClosed(KWin::EffectWindow *w); void slotWindowGeometryShapeChanged(KWin::EffectWindow *w, const QRect &old); void slotWindowDamaged(KWin::EffectWindow* w, const QRect& damage); - virtual bool isActive() const; + bool isActive() const override; void repaintAll(); private: void addThumbnail(EffectWindow* w); void removeThumbnail(EffectWindow* w); void arrange(); struct Data { EffectWindow* window; // the same like the key in the hash (makes code simpler) int index; QRect rect; }; QHash< EffectWindow*, Data > windows; int maxwidth; int spacing; double opacity; int screen; QRegion painted; }; } // namespace #endif diff --git a/effects/thumbnailaside/thumbnailaside_config.h b/effects/thumbnailaside/thumbnailaside_config.h index 675667228..88973b832 100644 --- a/effects/thumbnailaside/thumbnailaside_config.h +++ b/effects/thumbnailaside/thumbnailaside_config.h @@ -1,56 +1,56 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2007 Christian Nitschkowski 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_THUMBNAILASIDE_CONFIG_H #define KWIN_THUMBNAILASIDE_CONFIG_H #include #include "ui_thumbnailaside_config.h" class KActionCollection; namespace KWin { class ThumbnailAsideEffectConfigForm : public QWidget, public Ui::ThumbnailAsideEffectConfigForm { Q_OBJECT public: explicit ThumbnailAsideEffectConfigForm(QWidget* parent); }; class ThumbnailAsideEffectConfig : public KCModule { Q_OBJECT public: explicit ThumbnailAsideEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); - virtual ~ThumbnailAsideEffectConfig(); + ~ThumbnailAsideEffectConfig() override; - virtual void save(); + void save() override; private: ThumbnailAsideEffectConfigForm* m_ui; KActionCollection* m_actionCollection; }; } // namespace #endif diff --git a/effects/touchpoints/touchpoints.h b/effects/touchpoints/touchpoints.h index 15296514e..d5c168ed7 100644 --- a/effects/touchpoints/touchpoints.h +++ b/effects/touchpoints/touchpoints.h @@ -1,99 +1,99 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2012 Filip Wieladek Copyright (C) 2016 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_TOUCHPOINTS_H #define KWIN_TOUCHPOINTS_H #include namespace KWin { class TouchPointsEffect : public Effect { Q_OBJECT Q_PROPERTY(qreal lineWidth READ lineWidth) Q_PROPERTY(int ringLife READ ringLife) Q_PROPERTY(int ringSize READ ringSize) Q_PROPERTY(int ringCount READ ringCount) public: TouchPointsEffect(); - ~TouchPointsEffect(); + ~TouchPointsEffect() override; void prePaintScreen(ScreenPrePaintData& data, int time) override; void paintScreen(int mask, QRegion region, ScreenPaintData& data) override; void postPaintScreen() override; bool isActive() const override; bool touchDown(quint32 id, const QPointF &pos, quint32 time) override; bool touchMotion(quint32 id, const QPointF &pos, quint32 time) override; bool touchUp(quint32 id, quint32 time) override; // for properties qreal lineWidth() const { return m_lineWidth; } int ringLife() const { return m_ringLife; } int ringSize() const { return m_ringMaxSize; } int ringCount() const { return m_ringCount; } private: inline void drawCircle(const QColor& color, float cx, float cy, float r); inline void paintScreenSetup(int mask, QRegion region, ScreenPaintData& data); inline void paintScreenFinish(int mask, QRegion region, ScreenPaintData& data); void repaint(); float computeAlpha(int time, int ring); float computeRadius(int time, bool press, int ring); void drawCircleGl(const QColor& color, float cx, float cy, float r); void drawCircleXr(const QColor& color, float cx, float cy, float r); void drawCircleQPainter(const QColor& color, float cx, float cy, float r); void paintScreenSetupGl(int mask, QRegion region, ScreenPaintData& data); void paintScreenFinishGl(int mask, QRegion region, ScreenPaintData& data); Qt::GlobalColor colorForId(quint32 id); int m_ringCount = 2; float m_lineWidth = 1.0; int m_ringLife = 300; float m_ringMaxSize = 20.0; struct TouchPoint { QPointF pos; int time = 0; bool press; QColor color; }; QVector m_points; QHash m_latestPositions; QHash m_colors; }; } // namespace #endif diff --git a/effects/trackmouse/trackmouse.h b/effects/trackmouse/trackmouse.h index f2eb602ca..76f9ac9db 100644 --- a/effects/trackmouse/trackmouse.h +++ b/effects/trackmouse/trackmouse.h @@ -1,87 +1,87 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2006 Lubos Lunak Copyright (C) 2010 Jorge Mata Copyright (C) 2018 Vlad Zagorodniy 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_TRACKMOUSE_H #define KWIN_TRACKMOUSE_H #include class QAction; namespace KWin { class GLTexture; class TrackMouseEffect : public Effect { Q_OBJECT Q_PROPERTY(Qt::KeyboardModifiers modifiers READ modifiers) Q_PROPERTY(bool mousePolling READ isMousePolling) public: TrackMouseEffect(); - virtual ~TrackMouseEffect(); - virtual void prePaintScreen(ScreenPrePaintData& data, int time); - virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); - virtual void postPaintScreen(); - virtual void reconfigure(ReconfigureFlags); - virtual bool isActive() const; + ~TrackMouseEffect() override; + void prePaintScreen(ScreenPrePaintData& data, int time) override; + void paintScreen(int mask, QRegion region, ScreenPaintData& data) override; + void postPaintScreen() override; + void reconfigure(ReconfigureFlags) override; + bool isActive() const override; // for properties Qt::KeyboardModifiers modifiers() const { return m_modifiers; } bool isMousePolling() const { return m_mousePolling; } private Q_SLOTS: void toggle(); void slotMouseChanged(const QPoint& pos, const QPoint& old, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); private: bool init(); void loadTexture(); QRect m_lastRect[2]; bool m_mousePolling; float m_angle; float m_angleBase; GLTexture* m_texture[2]; #ifdef KWIN_HAVE_XRENDER_COMPOSITING QSize m_size[2]; XRenderPicture *m_picture[2]; #endif QAction* m_action; QImage m_image[2]; Qt::KeyboardModifiers m_modifiers; enum class State { ActivatedByModifiers, ActivatedByShortcut, Inactive }; State m_state = State::Inactive; }; } // namespace #endif diff --git a/effects/trackmouse/trackmouse_config.h b/effects/trackmouse/trackmouse_config.h index 56f9a60db..7a6a8d3f1 100644 --- a/effects/trackmouse/trackmouse_config.h +++ b/effects/trackmouse/trackmouse_config.h @@ -1,61 +1,61 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2007 Rivo Laks Copyright (C) 2010 Jorge Mata 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_TRACKMOUSE_CONFIG_H #define KWIN_TRACKMOUSE_CONFIG_H #include #include "ui_trackmouse_config.h" class KActionCollection; namespace KWin { class TrackMouseEffectConfigForm : public QWidget, public Ui::TrackMouseEffectConfigForm { Q_OBJECT public: explicit TrackMouseEffectConfigForm(QWidget* parent); }; class TrackMouseEffectConfig : public KCModule { Q_OBJECT public: explicit TrackMouseEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); - ~TrackMouseEffectConfig(); + ~TrackMouseEffectConfig() override; public Q_SLOTS: - virtual void save(); - virtual void load(); - virtual void defaults(); + void save() override; + void load() override; + void defaults() override; private Q_SLOTS: void shortcutChanged(const QKeySequence &seq); private: TrackMouseEffectConfigForm* m_ui; KActionCollection* m_actionCollection; }; } // namespace #endif diff --git a/effects/windowgeometry/windowgeometry.h b/effects/windowgeometry/windowgeometry.h index 6c05550bb..3c98cb3da 100644 --- a/effects/windowgeometry/windowgeometry.h +++ b/effects/windowgeometry/windowgeometry.h @@ -1,73 +1,73 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2010 Thomas Lübking 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 WINDOWGEOMETRY_H #define WINDOWGEOMETRY_H #include namespace KWin { class WindowGeometry : public Effect { Q_OBJECT Q_PROPERTY(bool handlesMoves READ isHandlesMoves) Q_PROPERTY(bool handlesResizes READ isHandlesResizes) public: WindowGeometry(); - ~WindowGeometry(); + ~WindowGeometry() override; - inline bool provides(Effect::Feature ef) { + inline bool provides(Effect::Feature ef) override { return ef == Effect::GeometryTip; } - void reconfigure(ReconfigureFlags); - void paintScreen(int mask, QRegion region, ScreenPaintData &data); - virtual bool isActive() const; + void reconfigure(ReconfigureFlags) override; + void paintScreen(int mask, QRegion region, ScreenPaintData &data) override; + bool isActive() const override; int requestedEffectChainPosition() const override { return 90; } // for properties bool isHandlesMoves() const { return iHandleMoves; } bool isHandlesResizes() const { return iHandleResizes; } private Q_SLOTS: void toggle(); void slotWindowStartUserMovedResized(KWin::EffectWindow *w); void slotWindowFinishUserMovedResized(KWin::EffectWindow *w); void slotWindowStepUserMovedResized(KWin::EffectWindow *w, const QRect &geometry); private: void createFrames(); EffectWindow *myResizeWindow; EffectFrame *myMeasure[3] = {nullptr, nullptr, nullptr}; QRect myOriginalGeometry, myCurrentGeometry; QRect myExtraDirtyArea; bool iAmActive, iAmActivated, iHandleMoves, iHandleResizes; QString myCoordString[2], myResizeString; }; } // namespace #endif diff --git a/effects/windowgeometry/windowgeometry_config.h b/effects/windowgeometry/windowgeometry_config.h index eaa49c43b..b45d30275 100644 --- a/effects/windowgeometry/windowgeometry_config.h +++ b/effects/windowgeometry/windowgeometry_config.h @@ -1,57 +1,57 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2010 Thomas Lübking 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 WINDOWGEOMETRY_CONFIG_H #define WINDOWGEOMETRY_CONFIG_H #include #include "ui_windowgeometry_config.h" namespace KWin { class WindowGeometryConfigForm : public QWidget, public Ui::WindowGeometryConfigForm { Q_OBJECT public: explicit WindowGeometryConfigForm(QWidget* parent); }; class WindowGeometryConfig : public KCModule { Q_OBJECT public: explicit WindowGeometryConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); - ~WindowGeometryConfig(); + ~WindowGeometryConfig() override; public Q_SLOTS: - void save(); - void defaults(); + void save() override; + void defaults() override; private: WindowGeometryConfigForm* myUi; KActionCollection* myActionCollection; }; } // namespace #endif diff --git a/effects/wobblywindows/wobblywindows.h b/effects/wobblywindows/wobblywindows.h index 643cc75b3..8169cd739 100644 --- a/effects/wobblywindows/wobblywindows.h +++ b/effects/wobblywindows/wobblywindows.h @@ -1,219 +1,219 @@ /***************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2008 Cédric Borgese You can Freely distribute this program under the GNU General Public License. See the file "COPYING" for the exact licensing terms. ******************************************************************/ #ifndef KWIN_WOBBLYWINDOWS_H #define KWIN_WOBBLYWINDOWS_H // Include with base class for effects. #include namespace KWin { struct ParameterSet; /** * Effect which wobble windows **/ class WobblyWindowsEffect : public Effect { Q_OBJECT Q_PROPERTY(qreal stiffness READ stiffness) Q_PROPERTY(qreal drag READ drag) Q_PROPERTY(qreal moveFactor READ moveFactor) Q_PROPERTY(qreal xTesselation READ xTesselation) Q_PROPERTY(qreal yTesselation READ yTesselation) Q_PROPERTY(qreal minVelocity READ minVelocity) Q_PROPERTY(qreal maxVelocity READ maxVelocity) Q_PROPERTY(qreal stopVelocity READ stopVelocity) Q_PROPERTY(qreal minAcceleration READ minAcceleration) Q_PROPERTY(qreal maxAcceleration READ maxAcceleration) Q_PROPERTY(qreal stopAcceleration READ stopAcceleration) Q_PROPERTY(bool moveEffectEnabled READ isMoveEffectEnabled) Q_PROPERTY(bool openEffectEnabled READ isOpenEffectEnabled) Q_PROPERTY(bool closeEffectEnabled READ isCloseEffectEnabled) Q_PROPERTY(bool moveWobble READ isMoveWobble) Q_PROPERTY(bool resizeWobble READ isResizeWobble) public: WobblyWindowsEffect(); - virtual ~WobblyWindowsEffect(); - - virtual void reconfigure(ReconfigureFlags); - virtual void prePaintScreen(ScreenPrePaintData& data, int time); - virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); - virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); - virtual void postPaintScreen(); - virtual bool isActive() const; + ~WobblyWindowsEffect() override; + + void reconfigure(ReconfigureFlags) override; + void prePaintScreen(ScreenPrePaintData& data, int time) override; + void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) override; + void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override; + void postPaintScreen() override; + bool isActive() const override; int requestedEffectChainPosition() const override { // Please notice that the Wobbly Windows effect has to be placed // after the Maximize effect in the effect chain, otherwise there // can be visual artifacts when dragging maximized windows. return 70; } // Wobbly model parameters void setStiffness(qreal stiffness); void setDrag(qreal drag); void setVelocityThreshold(qreal velocityThreshold); void setMoveFactor(qreal factor); struct Pair { qreal x; qreal y; }; enum WindowStatus { Free, Moving, Openning, Closing }; static bool supported(); // for properties qreal stiffness() const { return m_stiffness; } qreal drag() const { return m_drag; } qreal moveFactor() const { return m_move_factor; } qreal xTesselation() const { return m_xTesselation; } qreal yTesselation() const { return m_yTesselation; } qreal minVelocity() const { return m_minVelocity; } qreal maxVelocity() const { return m_maxVelocity; } qreal stopVelocity() const { return m_stopVelocity; } qreal minAcceleration() const { return m_minAcceleration; } qreal maxAcceleration() const { return m_maxAcceleration; } qreal stopAcceleration() const { return m_stopAcceleration; } bool isMoveEffectEnabled() const { return m_moveEffectEnabled; } bool isOpenEffectEnabled() const { return m_openEffectEnabled; } bool isCloseEffectEnabled() const { return m_closeEffectEnabled; } bool isMoveWobble() const { return m_moveWobble; } bool isResizeWobble() const { return m_resizeWobble; } public Q_SLOTS: void slotWindowAdded(KWin::EffectWindow *w); void slotWindowClosed(KWin::EffectWindow *w); void slotWindowStartUserMovedResized(KWin::EffectWindow *w); void slotWindowStepUserMovedResized(KWin::EffectWindow *w, const QRect &geometry); void slotWindowFinishUserMovedResized(KWin::EffectWindow *w); void slotWindowMaximizeStateChanged(KWin::EffectWindow *w, bool horizontal, bool vertical); private: void cancelWindowGrab(KWin::EffectWindow *w, int grabRole); void startMovedResized(EffectWindow* w); void stepMovedResized(EffectWindow* w); bool updateWindowWobblyDatas(EffectWindow* w, qreal time); struct WindowWobblyInfos { Pair* origin; Pair* position; Pair* velocity; Pair* acceleration; Pair* buffer; // if true, the physics system moves this point based only on it "normal" destination // given by the window position, ignoring neighbour points. bool* constraint; unsigned int width; unsigned int height; unsigned int count; Pair* bezierSurface; unsigned int bezierWidth; unsigned int bezierHeight; unsigned int bezierCount; WindowStatus status; // for closing QRectF closeRect; // for resizing. Only sides that have moved will wobble bool can_wobble_top, can_wobble_left, can_wobble_right, can_wobble_bottom; QRect resize_original_rect; }; QHash< const EffectWindow*, WindowWobblyInfos > windows; QRegion m_updateRegion; qreal m_stiffness; qreal m_drag; qreal m_move_factor; // the default tesselation for windows // use qreal instead of int as I really often need // these values as real to do divisions. qreal m_xTesselation; qreal m_yTesselation; qreal m_minVelocity; qreal m_maxVelocity; qreal m_stopVelocity; qreal m_minAcceleration; qreal m_maxAcceleration; qreal m_stopAcceleration; bool m_moveEffectEnabled; bool m_openEffectEnabled; bool m_closeEffectEnabled; bool m_moveWobble; // Expands m_moveEffectEnabled bool m_resizeWobble; void initWobblyInfo(WindowWobblyInfos& wwi, QRect geometry) const; void freeWobblyInfo(WindowWobblyInfos& wwi) const; void wobblyOpenInit(WindowWobblyInfos& wwi) const; void wobblyCloseInit(WindowWobblyInfos& wwi, EffectWindow* w) const; WobblyWindowsEffect::Pair computeBezierPoint(const WindowWobblyInfos& wwi, Pair point) const; static void heightRingLinearMean(Pair** data_pointer, WindowWobblyInfos& wwi); void setParameterSet(const ParameterSet& pset); }; } // namespace KWin #endif // WOBBLYWINDOWS_H diff --git a/effects/wobblywindows/wobblywindows_config.h b/effects/wobblywindows/wobblywindows_config.h index 196246a5a..3dadb60fb 100644 --- a/effects/wobblywindows/wobblywindows_config.h +++ b/effects/wobblywindows/wobblywindows_config.h @@ -1,52 +1,52 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2008 Cédric Borgese Copyright (C) 2008 Lucas Murray 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_WOBBLYWINDOWS_CONFIG_H #define KWIN_WOBBLYWINDOWS_CONFIG_H #include #include "ui_wobblywindows_config.h" namespace KWin { class WobblyWindowsEffectConfig : public KCModule { Q_OBJECT public: explicit WobblyWindowsEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); - ~WobblyWindowsEffectConfig(); + ~WobblyWindowsEffectConfig() override; public Q_SLOTS: - virtual void save(); + void save() override; private Q_SLOTS: void wobblinessChanged(); private: ::Ui::WobblyWindowsEffectConfigForm m_ui; }; } // namespace #endif diff --git a/effects/zoom/zoom.h b/effects/zoom/zoom.h index 09bb3da57..153434121 100644 --- a/effects/zoom/zoom.h +++ b/effects/zoom/zoom.h @@ -1,134 +1,134 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2006 Lubos Lunak Copyright (C) 2010 Sebastian Sauer 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_ZOOM_H #define KWIN_ZOOM_H #include #include #include namespace KWin { class GLTexture; class XRenderPicture; class ZoomEffect : public Effect { Q_OBJECT Q_PROPERTY(qreal zoomFactor READ configuredZoomFactor) Q_PROPERTY(int mousePointer READ configuredMousePointer) Q_PROPERTY(int mouseTracking READ configuredMouseTracking) Q_PROPERTY(bool enableFocusTracking READ isEnableFocusTracking) Q_PROPERTY(bool followFocus READ isFollowFocus) Q_PROPERTY(int focusDelay READ configuredFocusDelay) Q_PROPERTY(qreal moveFactor READ configuredMoveFactor) Q_PROPERTY(qreal targetZoom READ targetZoom) public: ZoomEffect(); - virtual ~ZoomEffect(); - virtual void reconfigure(ReconfigureFlags flags); - virtual void prePaintScreen(ScreenPrePaintData& data, int time); - virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); - virtual void postPaintScreen(); - virtual bool isActive() const; + ~ZoomEffect() override; + void reconfigure(ReconfigureFlags flags) override; + void prePaintScreen(ScreenPrePaintData& data, int time) override; + void paintScreen(int mask, QRegion region, ScreenPaintData& data) override; + void postPaintScreen() override; + bool isActive() const override; // for properties qreal configuredZoomFactor() const { return zoomFactor; } int configuredMousePointer() const { return mousePointer; } int configuredMouseTracking() const { return mouseTracking; } bool isEnableFocusTracking() const { return enableFocusTracking; } bool isFollowFocus() const { return followFocus; } int configuredFocusDelay() const { return focusDelay; } qreal configuredMoveFactor() const { return moveFactor; } qreal targetZoom() const { return target_zoom; } private Q_SLOTS: inline void zoomIn() { zoomIn(-1.0); }; void zoomIn(double to); void zoomOut(); void actualSize(); void moveZoomLeft(); void moveZoomRight(); void moveZoomUp(); void moveZoomDown(); void moveMouseToFocus(); void moveMouseToCenter(); void timelineFrameChanged(int frame); void focusChanged(int px, int py, int rx, int ry, int rwidth, int rheight); void slotMouseChanged(const QPoint& pos, const QPoint& old, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); void recreateTexture(); private: void showCursor(); void hideCursor(); void moveZoom(int x, int y); private: double zoom; double target_zoom; double source_zoom; bool polling; // Mouse polling double zoomFactor; enum MouseTrackingType { MouseTrackingProportional = 0, MouseTrackingCentred = 1, MouseTrackingPush = 2, MouseTrackingDisabled = 3 }; MouseTrackingType mouseTracking; bool enableFocusTracking; bool followFocus; enum MousePointerType { MousePointerScale = 0, MousePointerKeep = 1, MousePointerHide = 2 }; MousePointerType mousePointer; int focusDelay; QPoint cursorPoint; QPoint cursorHotSpot; QPoint focusPoint; QPoint prevPoint; QTime lastMouseEvent; QTime lastFocusEvent; QScopedPointer texture; #ifdef KWIN_HAVE_XRENDER_COMPOSITING QScopedPointer xrenderPicture; #endif int imageWidth; int imageHeight; bool isMouseHidden; QTimeLine timeline; int xMove, yMove; double moveFactor; }; } // namespace #endif diff --git a/effects/zoom/zoom_config.h b/effects/zoom/zoom_config.h index b59aa55f0..c40c8be97 100644 --- a/effects/zoom/zoom_config.h +++ b/effects/zoom/zoom_config.h @@ -1,57 +1,57 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2007 Rivo Laks Copyright (C) 2010 Sebastian Sauer 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_ZOOM_CONFIG_H #define KWIN_ZOOM_CONFIG_H #include #include "ui_zoom_config.h" namespace KWin { class ZoomEffectConfigForm : public QWidget, public Ui::ZoomEffectConfigForm { Q_OBJECT public: explicit ZoomEffectConfigForm(QWidget* parent = 0); }; class ZoomEffectConfig : public KCModule { Q_OBJECT public: explicit ZoomEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); - virtual ~ZoomEffectConfig(); + ~ZoomEffectConfig() override; public Q_SLOTS: - virtual void save(); + void save() override; private: ZoomEffectConfigForm* m_ui; enum MouseTracking { MouseCentred = 0, MouseProportional = 1, MouseDisabled = 2 }; }; } // namespace #endif diff --git a/focuschain.h b/focuschain.h index 662cffd07..91e834fa6 100644 --- a/focuschain.h +++ b/focuschain.h @@ -1,254 +1,254 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2012 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_FOCUS_CHAIN_H #define KWIN_FOCUS_CHAIN_H // KWin #include // Qt #include #include namespace KWin { // forward declarations class AbstractClient; /** * @brief Singleton class to handle the various focus chains. * * A focus chain is a list of Clients containing information on which Client should be activated. * * Internally this FocusChain holds multiple independent chains. There is one chain of most recently * used Clients which is primarily used by TabBox to build up the list of Clients for navigation. * The chains are organized as a normal QList of Clients with the most recently used Client being the * last item of the list, that is a LIFO like structure. * * In addition there is one chain for each virtual desktop which is used to determine which Client * should get activated when the user switches to another virtual desktop. * * Furthermore this class contains various helper methods for the two different kind of chains. **/ class FocusChain : public QObject { Q_OBJECT public: enum Change { MakeFirst, MakeLast, Update, MakeFirstMinimized = MakeFirst }; - virtual ~FocusChain(); + ~FocusChain() override; /** * @brief Updates the position of the @p client according to the requested @p change in the * focus chain. * * This method affects both the most recently used focus chain and the per virtual desktop focus * chain. * * In case the client does no longer want to get focus, it is removed from all chains. In case * the client is on all virtual desktops it is ensured that it is present in each of the virtual * desktops focus chain. In case it's on exactly one virtual desktop it is ensured that it is only * in the focus chain for that virtual desktop. * * Depending on @p change the Client is inserted at different positions in the focus chain. In case * of @c MakeFirst it is moved to the first position of the chain, in case of * @c MakeLast it is moved to the last position of the chain. In all other cases it * depends on whether the @p client is the currently active Client. If it is the active Client it * becomes the first Client in the chain, otherwise it is inserted at the second position that is * directly after the currently active Client. * * @param client The Client which should be moved inside the chains. * @param change Where to move the Client * @return void **/ void update(AbstractClient *client, Change change); /** * @brief Moves @p client behind the @p reference Client in all focus chains. * * @param client The Client to move in the chains * @param reference The Client behind which the @p client should be moved * @return void **/ void moveAfterClient(AbstractClient *client, AbstractClient *reference); /** * @brief Finds the best Client to become the new active Client in the focus chain for the given * virtual @p desktop. * * In case that separate screen focus is used only Clients on the current screen are considered. * If no Client for activation is found @c null is returned. * * @param desktop The virtual desktop to look for a Client for activation * @return :Client* The Client which could be activated or @c null if there is none. **/ AbstractClient *getForActivation(uint desktop) const; /** * @brief Finds the best Client to become the new active Client in the focus chain for the given * virtual @p desktop on the given @p screen. * * This method makes only sense to use if separate screen focus is used. If separate screen focus * is disabled the @p screen is ignored. * If no Client for activation is found @c null is returned. * * @param desktop The virtual desktop to look for a Client for activation * @param screen The screen to constrain the search on with separate screen focus * @return :Client* The Client which could be activated or @c null if there is none. **/ AbstractClient *getForActivation(uint desktop, int screen) const; /** * @brief Checks whether the most recently used focus chain contains the given @p client. * * Does not consider the per-desktop focus chains. * @param client The Client to look for. * @return bool @c true if the most recently used focus chain contains @p client, @c false otherwise. **/ bool contains(AbstractClient *client) const; /** * @brief Checks whether the focus chain for the given @p desktop contains the given @p client. * * Does not consider the most recently used focus chain. * * @param client The Client to look for. * @param desktop The virtual desktop whose focus chain should be used * @return bool @c true if the focus chain for @p desktop contains @p client, @c false otherwise. **/ bool contains(AbstractClient *client, uint desktop) const; /** * @brief Queries the most recently used focus chain for the next Client after the given * @p reference Client. * * The navigation wraps around the borders of the chain. That is if the @p reference Client is * the last item of the focus chain, the first Client will be returned. * * If the @p reference Client cannot be found in the focus chain, the first element of the focus * chain is returned. * * @param reference The start point in the focus chain to search * @return :Client* The relatively next Client in the most recently used chain. **/ AbstractClient *nextMostRecentlyUsed(AbstractClient *reference) const; /** * @brief Queries the focus chain for @p desktop for the next Client in relation to the given * @p reference Client. * * The method finds the first usable Client which is not the @p reference Client. If no Client * can be found @c null is returned * * @param reference The reference Client which should not be returned * @param desktop The virtual desktop whose focus chain should be used * @return :Client* The next usable Client or @c null if none can be found. **/ AbstractClient *nextForDesktop(AbstractClient *reference, uint desktop) const; /** * @brief Returns the first Client in the most recently used focus chain. First Client in this * case means really the first Client in the chain and not the most recently used Client. * * @return :Client* The first Client in the most recently used chain. **/ AbstractClient *firstMostRecentlyUsed() const; public Q_SLOTS: /** * @brief Resizes the per virtual desktop focus chains from @p previousSize to @p newSize. * This means that for each virtual desktop between previous and new size a new focus chain is * created and in case the number is reduced the focus chains are destroyed. * * @param previousSize The previous number of virtual desktops * @param newSize The new number of virtual desktops * @return void **/ void resize(uint previousSize, uint newSize); /** * @brief Removes @p client from all focus chains. * * @param client The Client to remove from all focus chains. * @return void **/ void remove(KWin::AbstractClient *client); void setSeparateScreenFocus(bool enabled); void setActiveClient(KWin::AbstractClient *client); void setCurrentDesktop(uint previous, uint newDesktop); bool isUsableFocusCandidate(AbstractClient *c, AbstractClient *prev) const; private: using Chain = QList; /** * @brief Makes @p client the first Client in the given focus @p chain. * * This means the existing position of @p client is dropped and @p client is appended to the * @p chain which makes it the first item. * * @param client The Client to become the first in @p chain * @param chain The focus chain to operate on * @return void **/ void makeFirstInChain(AbstractClient *client, Chain &chain); /** * @brief Makes @p client the last Client in the given focus @p chain. * * This means the existing position of @p client is dropped and @p client is prepended to the * @p chain which makes it the last item. * * @param client The Client to become the last in @p chain * @param chain The focus chain to operate on * @return void **/ void makeLastInChain(AbstractClient *client, Chain &chain); void moveAfterClientInChain(AbstractClient *client, AbstractClient *reference, Chain &chain); void updateClientInChain(AbstractClient *client, Change change, Chain &chain); void insertClientIntoChain(AbstractClient *client, Chain &chain); Chain m_mostRecentlyUsed; QHash m_desktopFocusChains; bool m_separateScreenFocus; AbstractClient *m_activeClient; uint m_currentDesktop; KWIN_SINGLETON_VARIABLE(FocusChain, s_manager) }; inline bool FocusChain::contains(AbstractClient *client) const { return m_mostRecentlyUsed.contains(client); } inline void FocusChain::setSeparateScreenFocus(bool enabled) { m_separateScreenFocus = enabled; } inline void FocusChain::setActiveClient(AbstractClient *client) { m_activeClient = client; } inline void FocusChain::setCurrentDesktop(uint previous, uint newDesktop) { Q_UNUSED(previous) m_currentDesktop = newDesktop; } } // namespace #endif // KWIN_FOCUS_CHAIN_H diff --git a/geometrytip.h b/geometrytip.h index 8a8d5e317..e856b529f 100644 --- a/geometrytip.h +++ b/geometrytip.h @@ -1,44 +1,44 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (c) 2003, Karol Szwed 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_GEOMETRY_TIP_H #define KWIN_GEOMETRY_TIP_H #include "xcbutils.h" #include namespace KWin { class GeometryTip: public QLabel { Q_OBJECT public: GeometryTip(const Xcb::GeometryHints* xSizeHints); - ~GeometryTip(); + ~GeometryTip() override; void setGeometry(const QRect& geom); private: const Xcb::GeometryHints* sizeHints; }; } // namespace #endif diff --git a/globalshortcuts.h b/globalshortcuts.h index 1f95a969b..5272f16e4 100644 --- a/globalshortcuts.h +++ b/globalshortcuts.h @@ -1,192 +1,192 @@ /******************************************************************** 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_GLOBALSHORTCUTS_H #define KWIN_GLOBALSHORTCUTS_H // KWin #include // Qt #include class QAction; class KGlobalAccelD; class KGlobalAccelInterface; namespace KWin { class GlobalShortcut; class SwipeGesture; class GestureRecognizer; /** * @brief Manager for the global shortcut system inside KWin. * * This class is responsible for holding all the global shortcuts and to process a key press event. * That is trigger a shortcut if there is a match. * * For internal shortcut handling (those which are delivered inside KWin) QActions are used and * triggered if the shortcut matches. For external shortcut handling a DBus interface is used. **/ class GlobalShortcutsManager : public QObject { Q_OBJECT public: explicit GlobalShortcutsManager(QObject *parent = nullptr); - virtual ~GlobalShortcutsManager(); + ~GlobalShortcutsManager() override; void init(); /** * @brief Registers an internal global pointer shortcut * * @param action The action to trigger if the shortcut is pressed * @param modifiers The modifiers which need to be hold to trigger the action * @param pointerButtons The pointer button which needs to be pressed **/ void registerPointerShortcut(QAction *action, Qt::KeyboardModifiers modifiers, Qt::MouseButtons pointerButtons); /** * @brief Registers an internal global axis shortcut * * @param action The action to trigger if the shortcut is triggered * @param modifiers The modifiers which need to be hold to trigger the action * @param axis The pointer axis **/ void registerAxisShortcut(QAction *action, Qt::KeyboardModifiers modifiers, PointerAxisDirection axis); void registerTouchpadSwipe(QAction *action, SwipeDirection direction); /** * @brief Processes a key event to decide whether a shortcut needs to be triggered. * * If a shortcut triggered this method returns @c true to indicate to the caller that the event * should not be further processed. If there is no shortcut which triggered for the key, then * @c false is returned. * * @param modifiers The current hold modifiers * @param keyQt The Qt::Key which got pressed * @return @c true if a shortcut triggered, @c false otherwise **/ bool processKey(Qt::KeyboardModifiers modifiers, int keyQt); bool processPointerPressed(Qt::KeyboardModifiers modifiers, Qt::MouseButtons pointerButtons); /** * @brief Processes a pointer axis event to decide whether a shortcut needs to be triggered. * * If a shortcut triggered this method returns @c true to indicate to the caller that the event * should not be further processed. If there is no shortcut which triggered for the key, then * @c false is returned. * * @param modifiers The current hold modifiers * @param axis The axis direction which has triggered this event * @return @c true if a shortcut triggered, @c false otherwise **/ bool processAxis(Qt::KeyboardModifiers modifiers, PointerAxisDirection axis); void processSwipeStart(uint fingerCount); void processSwipeUpdate(const QSizeF &delta); void processSwipeCancel(); void processSwipeEnd(); void setKGlobalAccelInterface(KGlobalAccelInterface *interface) { m_kglobalAccelInterface = interface; } private: void objectDeleted(QObject *object); QHash > m_pointerShortcuts; QHash > m_axisShortcuts; QHash > m_swipeShortcuts; KGlobalAccelD *m_kglobalAccel = nullptr; KGlobalAccelInterface *m_kglobalAccelInterface = nullptr; GestureRecognizer *m_gestureRecognizer; }; class GlobalShortcut { public: virtual ~GlobalShortcut(); const QKeySequence &shortcut() const; Qt::KeyboardModifiers pointerButtonModifiers() const; Qt::MouseButtons pointerButtons() const; SwipeDirection swipeDirection() const { return m_swipeDirection; } virtual void invoke() = 0; protected: GlobalShortcut(const QKeySequence &shortcut); GlobalShortcut(Qt::KeyboardModifiers pointerButtonModifiers, Qt::MouseButtons pointerButtons); GlobalShortcut(Qt::KeyboardModifiers axisModifiers); GlobalShortcut(SwipeDirection direction); private: QKeySequence m_shortcut; Qt::KeyboardModifiers m_pointerModifiers; Qt::MouseButtons m_pointerButtons; SwipeDirection m_swipeDirection = SwipeDirection::Invalid;; }; class InternalGlobalShortcut : public GlobalShortcut { public: InternalGlobalShortcut(Qt::KeyboardModifiers modifiers, const QKeySequence &shortcut, QAction *action); InternalGlobalShortcut(Qt::KeyboardModifiers pointerButtonModifiers, Qt::MouseButtons pointerButtons, QAction *action); InternalGlobalShortcut(Qt::KeyboardModifiers axisModifiers, PointerAxisDirection axis, QAction *action); InternalGlobalShortcut(Qt::KeyboardModifiers swipeModifier, SwipeDirection direction, QAction *action); - virtual ~InternalGlobalShortcut(); + ~InternalGlobalShortcut() override; void invoke() override; QAction *action() const; SwipeGesture *swipeGesture() const { return m_swipe.data(); } private: QAction *m_action; QScopedPointer m_swipe; }; inline QAction *InternalGlobalShortcut::action() const { return m_action; } inline const QKeySequence &GlobalShortcut::shortcut() const { return m_shortcut; } inline Qt::KeyboardModifiers GlobalShortcut::pointerButtonModifiers() const { return m_pointerModifiers; } inline Qt::MouseButtons GlobalShortcut::pointerButtons() const { return m_pointerButtons; } } // namespace #endif diff --git a/idle_inhibition.h b/idle_inhibition.h index a5f310e2b..1cdae7cd1 100644 --- a/idle_inhibition.h +++ b/idle_inhibition.h @@ -1,71 +1,71 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2017 Martin Flöser Copyright (C) 2018 Vlad Zagorodniy 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 namespace KWayland { namespace Server { class IdleInterface; } } using KWayland::Server::IdleInterface; namespace KWin { class AbstractClient; class ShellClient; class IdleInhibition : public QObject { Q_OBJECT public: explicit IdleInhibition(IdleInterface *idle); - ~IdleInhibition(); + ~IdleInhibition() override; void registerShellClient(ShellClient *client); bool isInhibited() const { return !m_idleInhibitors.isEmpty(); } bool isInhibited(AbstractClient *client) const { return m_idleInhibitors.contains(client); } private Q_SLOTS: void slotWorkspaceCreated(); void slotDesktopChanged(); private: void inhibit(AbstractClient *client); void uninhibit(AbstractClient *client); void update(AbstractClient *client); IdleInterface *m_idle; QVector m_idleInhibitors; QMap m_connections; }; } diff --git a/input.h b/input.h index fd1fbdfc2..41412f502 100644 --- a/input.h +++ b/input.h @@ -1,496 +1,496 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2013 Martin Gräßlin Copyright (C) 2018 Roman Gilg Copyright (C) 2019 Vlad Zagorodniy 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_INPUT_H #define KWIN_INPUT_H #include #include #include #include #include #include #include #include class KGlobalAccelInterface; class QKeySequence; class QMouseEvent; class QKeyEvent; class QWheelEvent; namespace KWin { class GlobalShortcutsManager; class Toplevel; class InputEventFilter; class InputEventSpy; class KeyboardInputRedirection; class PointerInputRedirection; class TouchInputRedirection; class WindowSelectorFilter; class SwitchEvent; namespace Decoration { class DecoratedClientImpl; } namespace LibInput { class Connection; } /** * @brief This class is responsible for redirecting incoming input to the surface which currently * has input or send enter/leave events. * * In addition input is intercepted before passed to the surfaces to have KWin internal areas * getting input first (e.g. screen edges) and filter the input event out if we currently have * a full input grab. **/ class KWIN_EXPORT InputRedirection : public QObject { Q_OBJECT public: enum PointerButtonState { PointerButtonReleased, PointerButtonPressed }; enum PointerAxis { PointerAxisVertical, PointerAxisHorizontal }; enum PointerAxisSource { PointerAxisSourceUnknown, PointerAxisSourceWheel, PointerAxisSourceFinger, PointerAxisSourceContinuous, PointerAxisSourceWheelTilt }; enum KeyboardKeyState { KeyboardKeyReleased, KeyboardKeyPressed, KeyboardKeyAutoRepeat }; - virtual ~InputRedirection(); + ~InputRedirection() override; void init(); /** * @return const QPointF& The current global pointer position **/ QPointF globalPointer() const; Qt::MouseButtons qtButtonStates() const; Qt::KeyboardModifiers keyboardModifiers() const; Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const; void registerShortcut(const QKeySequence &shortcut, QAction *action); /** * @overload * * Like registerShortcut, but also connects QAction::triggered to the @p slot on @p receiver. * It's recommended to use this method as it ensures that the X11 timestamp is updated prior * to the @p slot being invoked. If not using this overload it's required to ensure that * registerShortcut is called before connecting to QAction's triggered signal. **/ template void registerShortcut(const QKeySequence &shortcut, QAction *action, T *receiver, Slot slot); void registerPointerShortcut(Qt::KeyboardModifiers modifiers, Qt::MouseButton pointerButtons, QAction *action); void registerAxisShortcut(Qt::KeyboardModifiers modifiers, PointerAxisDirection axis, QAction *action); void registerTouchpadSwipeShortcut(SwipeDirection direction, QAction *action); void registerGlobalAccel(KGlobalAccelInterface *interface); /** * @internal **/ void processPointerMotion(const QPointF &pos, uint32_t time); /** * @internal **/ void processPointerButton(uint32_t button, PointerButtonState state, uint32_t time); /** * @internal **/ void processPointerAxis(PointerAxis axis, qreal delta, qint32 discreteDelta, PointerAxisSource source, uint32_t time); /** * @internal **/ void processKeyboardKey(uint32_t key, KeyboardKeyState state, uint32_t time); /** * @internal **/ void processKeyboardModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group); /** * @internal **/ void processKeymapChange(int fd, uint32_t size); void processTouchDown(qint32 id, const QPointF &pos, quint32 time); void processTouchUp(qint32 id, quint32 time); void processTouchMotion(qint32 id, const QPointF &pos, quint32 time); void cancelTouch(); void touchFrame(); bool supportsPointerWarping() const; void warpPointer(const QPointF &pos); /** * Adds the @p filter to the list of event filters and makes it the first * event filter in processing. * * Note: the event filter will get events before the lock screen can get them, thus * this is a security relevant method. **/ void prependInputEventFilter(InputEventFilter *filter); void uninstallInputEventFilter(InputEventFilter *filter); /** * Installs the @p spy for spying on events. **/ void installInputEventSpy(InputEventSpy *spy); /** * Uninstalls the @p spy. This happens automatically when deleting an InputEventSpy. **/ void uninstallInputEventSpy(InputEventSpy *spy); Toplevel *findToplevel(const QPoint &pos); Toplevel *findManagedToplevel(const QPoint &pos); GlobalShortcutsManager *shortcuts() const { return m_shortcuts; } /** * Sends an event through all InputFilters. * The method @p function is invoked on each input filter. Processing is stopped if * a filter returns @c true for @p function. * * The UnaryPredicate is defined like the UnaryPredicate of std::any_of. * The signature of the function should be equivalent to the following: * @code * bool function(const InputEventFilter *spy); * @endcode * * The intended usage is to std::bind the method to invoke on the filter with all arguments * bind. **/ template void processFilters(UnaryPredicate function) { std::any_of(m_filters.constBegin(), m_filters.constEnd(), function); } /** * Sends an event through all input event spies. * The @p function is invoked on each InputEventSpy. * * The UnaryFunction is defined like the UnaryFunction of std::for_each. * The signature of the function should be equivalent to the following: * @code * void function(const InputEventSpy *spy); * @endcode * * The intended usage is to std::bind the method to invoke on the spies with all arguments * bind. **/ template void processSpies(UnaryFunction function) { std::for_each(m_spies.constBegin(), m_spies.constEnd(), function); } KeyboardInputRedirection *keyboard() const { return m_keyboard; } PointerInputRedirection *pointer() const { return m_pointer; } TouchInputRedirection *touch() const { return m_touch; } bool hasAlphaNumericKeyboard(); bool hasTabletModeSwitch(); void startInteractiveWindowSelection(std::function callback, const QByteArray &cursorName); void startInteractivePositionSelection(std::function callback); bool isSelectingWindow() const; Q_SIGNALS: /** * @brief Emitted when the global pointer position changed * * @param pos The new global pointer position. **/ void globalPointerChanged(const QPointF &pos); /** * @brief Emitted when the state of a pointer button changed. * * @param button The button which changed * @param state The new button state **/ void pointerButtonStateChanged(uint32_t button, InputRedirection::PointerButtonState state); /** * @brief Emitted when a pointer axis changed * * @param axis The axis on which the even occurred * @param delta The delta of the event. **/ void pointerAxisChanged(InputRedirection::PointerAxis axis, qreal delta); /** * @brief Emitted when the modifiers changes. * * Only emitted for the mask which is provided by Qt::KeyboardModifiers, if other modifiers * change signal is not emitted * * @param newMods The new modifiers state * @param oldMods The previous modifiers state **/ void keyboardModifiersChanged(Qt::KeyboardModifiers newMods, Qt::KeyboardModifiers oldMods); /** * @brief Emitted when the state of a key changed. * * @param keyCode The keycode of the key which changed * @param state The new key state **/ void keyStateChanged(quint32 keyCode, InputRedirection::KeyboardKeyState state); void hasAlphaNumericKeyboardChanged(bool set); void hasTabletModeSwitchChanged(bool set); private: void setupLibInput(); void setupTouchpadShortcuts(); void setupLibInputWithScreens(); void setupWorkspace(); void reconfigure(); void setupInputFilters(); void installInputEventFilter(InputEventFilter *filter); KeyboardInputRedirection *m_keyboard; PointerInputRedirection *m_pointer; TouchInputRedirection *m_touch; GlobalShortcutsManager *m_shortcuts; LibInput::Connection *m_libInput = nullptr; WindowSelectorFilter *m_windowSelector = nullptr; QVector m_filters; QVector m_spies; KWIN_SINGLETON(InputRedirection) friend InputRedirection *input(); friend class DecorationEventFilter; friend class InternalWindowEventFilter; friend class ForwardInputFilter; }; /** * Base class for filtering input events inside InputRedirection. * * The idea behind the InputEventFilter is to have task oriented * filters. E.g. there is one filter taking care of a locked screen, * one to take care of interacting with window decorations, etc. * * A concrete subclass can reimplement the virtual methods and decide * whether an event should be filtered out or not by returning either * @c true or @c false. E.g. the lock screen filter can easily ensure * that all events are filtered out. * * As soon as a filter returns @c true the processing is stopped. If * a filter returns @c false the next one is invoked. This means a filter * installed early gets to see more events than a filter installed later on. * * Deleting an instance of InputEventFilter automatically uninstalls it from * InputRedirection. **/ class KWIN_EXPORT InputEventFilter { public: InputEventFilter(); virtual ~InputEventFilter(); /** * Event filter for pointer events which can be described by a QMouseEvent. * * Please note that the button translation in QMouseEvent cannot cover all * possible buttons. Because of that also the @p nativeButton code is passed * through the filter. For internal areas it's fine to use @p event, but for * passing to client windows the @p nativeButton should be used. * * @param event The event information about the move or button press/release * @param nativeButton The native key code of the button, for move events 0 * @return @c true to stop further event processing, @c false to pass to next filter **/ virtual bool pointerEvent(QMouseEvent *event, quint32 nativeButton); /** * Event filter for pointer axis events. * * @param event The event information about the axis event * @return @c true to stop further event processing, @c false to pass to next filter **/ virtual bool wheelEvent(QWheelEvent *event); /** * Event filter for keyboard events. * * @param event The event information about the key event * @return @c tru to stop further event processing, @c false to pass to next filter. **/ virtual bool keyEvent(QKeyEvent *event); virtual bool touchDown(quint32 id, const QPointF &pos, quint32 time); virtual bool touchMotion(quint32 id, const QPointF &pos, quint32 time); virtual bool touchUp(quint32 id, quint32 time); virtual bool pinchGestureBegin(int fingerCount, quint32 time); virtual bool pinchGestureUpdate(qreal scale, qreal angleDelta, const QSizeF &delta, quint32 time); virtual bool pinchGestureEnd(quint32 time); virtual bool pinchGestureCancelled(quint32 time); virtual bool swipeGestureBegin(int fingerCount, quint32 time); virtual bool swipeGestureUpdate(const QSizeF &delta, quint32 time); virtual bool swipeGestureEnd(quint32 time); virtual bool swipeGestureCancelled(quint32 time); virtual bool switchEvent(SwitchEvent *event); protected: void passToWaylandServer(QKeyEvent *event); }; class KWIN_EXPORT InputDeviceHandler : public QObject { Q_OBJECT public: - virtual ~InputDeviceHandler(); + ~InputDeviceHandler() override; virtual void init(); void update(); /** * @brief First Toplevel currently at the position of the input device * according to the stacking order. * @return Toplevel* at device position. **/ QPointer at() const { return m_at.at; } /** * @brief Toplevel currently having pointer input focus (this might * be different from the Toplevel at the position of the pointer). * @return Toplevel* with pointer focus. **/ QPointer focus() const { return m_focus.focus; } /** * @brief The Decoration currently receiving events. * @return decoration with pointer focus. **/ QPointer decoration() const { return m_focus.decoration; } /** * @brief The internal window currently receiving events. * @return QWindow with pointer focus. **/ QPointer internalWindow() const { return m_focus.internalWindow; } virtual QPointF position() const = 0; void setFocus(Toplevel *toplevel); void setDecoration(QPointer decoration); void setInternalWindow(QWindow *window); Q_SIGNALS: void atChanged(Toplevel *old, Toplevel *now); void decorationChanged(); protected: explicit InputDeviceHandler(InputRedirection *parent); virtual void cleanupInternalWindow(QWindow *old, QWindow *now) = 0; virtual void cleanupDecoration(Decoration::DecoratedClientImpl *old, Decoration::DecoratedClientImpl *now) = 0; virtual void focusUpdate(Toplevel *old, Toplevel *now) = 0; /** * Certain input devices can be in a state of having no valid * position. An example are touch screens when no finger/pen * is resting on the surface (no touch point). **/ virtual bool positionValid() const { return false; } virtual bool focusUpdatesBlocked() { return false; } inline bool inited() const { return m_inited; } inline void setInited(bool set) { m_inited = set; } private: bool setAt(Toplevel *toplevel); void updateFocus(); bool updateDecoration(); void updateInternalWindow(QWindow *window); QWindow* findInternalWindow(const QPoint &pos) const; struct { QPointer at; QMetaObject::Connection surfaceCreatedConnection; } m_at; struct { QPointer focus; QPointer decoration; QPointer internalWindow; } m_focus; bool m_inited = false; }; inline InputRedirection *input() { return InputRedirection::s_self; } template inline void InputRedirection::registerShortcut(const QKeySequence &shortcut, QAction *action, T *receiver, Slot slot) { registerShortcut(shortcut, action); connect(action, &QAction::triggered, receiver, slot); } } // namespace KWin Q_DECLARE_METATYPE(KWin::InputRedirection::KeyboardKeyState) Q_DECLARE_METATYPE(KWin::InputRedirection::PointerButtonState) Q_DECLARE_METATYPE(KWin::InputRedirection::PointerAxis) Q_DECLARE_METATYPE(KWin::InputRedirection::PointerAxisSource) #endif // KWIN_INPUT_H diff --git a/kcmkwin/kwincompositing/compositing.h b/kcmkwin/kwincompositing/compositing.h index 80c2815f7..0439e81b5 100644 --- a/kcmkwin/kwincompositing/compositing.h +++ b/kcmkwin/kwincompositing/compositing.h @@ -1,181 +1,181 @@ /************************************************************************** * KWin - the KDE window manager * * This file is part of the KDE project. * * * * Copyright (C) 2013 Antonis Tsiapaliokas * * * * 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 COMPOSITING_H #define COMPOSITING_H #include #include class OrgKdeKwinCompositingInterface; namespace KWin { namespace Compositing { class OpenGLPlatformInterfaceModel; class Compositing : public QObject { Q_OBJECT Q_PROPERTY(int animationSpeed READ animationSpeed WRITE setAnimationSpeed NOTIFY animationSpeedChanged) Q_PROPERTY(int windowThumbnail READ windowThumbnail WRITE setWindowThumbnail NOTIFY windowThumbnailChanged) Q_PROPERTY(int glScaleFilter READ glScaleFilter WRITE setGlScaleFilter NOTIFY glScaleFilterChanged) Q_PROPERTY(bool xrScaleFilter READ xrScaleFilter WRITE setXrScaleFilter NOTIFY xrScaleFilterChanged) Q_PROPERTY(int glSwapStrategy READ glSwapStrategy WRITE setGlSwapStrategy NOTIFY glSwapStrategyChanged) Q_PROPERTY(int compositingType READ compositingType WRITE setCompositingType NOTIFY compositingTypeChanged) Q_PROPERTY(bool compositingEnabled READ compositingEnabled WRITE setCompositingEnabled NOTIFY compositingEnabledChanged) Q_PROPERTY(KWin::Compositing::OpenGLPlatformInterfaceModel *openGLPlatformInterfaceModel READ openGLPlatformInterfaceModel CONSTANT) Q_PROPERTY(int openGLPlatformInterface READ openGLPlatformInterface WRITE setOpenGLPlatformInterface NOTIFY openGLPlatformInterfaceChanged) Q_PROPERTY(bool windowsBlockCompositing READ windowsBlockCompositing WRITE setWindowsBlockCompositing NOTIFY windowsBlockCompositingChanged) Q_PROPERTY(bool compositingRequired READ compositingRequired CONSTANT) public: explicit Compositing(QObject *parent = 0); Q_INVOKABLE bool OpenGLIsUnsafe() const; Q_INVOKABLE bool OpenGLIsBroken(); Q_INVOKABLE void reenableOpenGLDetection(); int animationSpeed() const; int windowThumbnail() const; int glScaleFilter() const; bool xrScaleFilter() const; int glSwapStrategy() const; int compositingType() const; bool compositingEnabled() const; int openGLPlatformInterface() const; bool windowsBlockCompositing() const; bool compositingRequired() const; OpenGLPlatformInterfaceModel *openGLPlatformInterfaceModel() const; void setAnimationSpeed(int speed); void setWindowThumbnail(int index); void setGlScaleFilter(int index); void setXrScaleFilter(bool filter); void setGlSwapStrategy(int strategy); void setCompositingType(int index); void setCompositingEnabled(bool enalbed); void setOpenGLPlatformInterface(int interface); void setWindowsBlockCompositing(bool set); void save(); public Q_SLOTS: void reset(); void defaults(); Q_SIGNALS: void changed(); void animationSpeedChanged(int); void windowThumbnailChanged(int); void glScaleFilterChanged(int); void xrScaleFilterChanged(int); void glSwapStrategyChanged(int); void compositingTypeChanged(int); void compositingEnabledChanged(bool); void openGLPlatformInterfaceChanged(int); void windowsBlockCompositingChanged(bool); private: int m_animationSpeed; int m_windowThumbnail; int m_glScaleFilter; bool m_xrScaleFilter; int m_glSwapStrategy; int m_compositingType; bool m_compositingEnabled; bool m_changed; OpenGLPlatformInterfaceModel *m_openGLPlatformInterfaceModel; int m_openGLPlatformInterface; bool m_windowsBlockCompositing; bool m_windowsBlockingCompositing; OrgKdeKwinCompositingInterface *m_compositingInterface; }; struct CompositingData; class CompositingType : public QAbstractItemModel { Q_OBJECT Q_ENUMS(CompositingTypeIndex) public: enum CompositingTypeIndex { OPENGL31_INDEX = 0, OPENGL20_INDEX, XRENDER_INDEX }; enum CompositingTypeRoles { NameRole = Qt::UserRole +1, TypeRole = Qt::UserRole +2 }; explicit CompositingType(QObject *parent = 0); QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; QModelIndex parent(const QModelIndex &child) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - virtual QHash< int, QByteArray > roleNames() const override; + QHash< int, QByteArray > roleNames() const override; Q_INVOKABLE int compositingTypeForIndex(int row) const; Q_INVOKABLE int indexForCompositingType(int type) const; private: void generateCompositing(); QList m_compositingList; }; struct CompositingData { QString name; CompositingType::CompositingTypeIndex type; }; class OpenGLPlatformInterfaceModel : public QAbstractListModel { Q_OBJECT public: explicit OpenGLPlatformInterfaceModel(QObject *parent = nullptr); - virtual ~OpenGLPlatformInterfaceModel(); + ~OpenGLPlatformInterfaceModel() override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; QModelIndex indexForKey(const QString &key) const; QHash< int, QByteArray > roleNames() const override; private: QStringList m_keys; QStringList m_names; }; }//end namespace Compositing }//end namespace KWin Q_DECLARE_METATYPE(KWin::Compositing::OpenGLPlatformInterfaceModel*) #endif diff --git a/kcmkwin/kwindecoration/declarative-plugin/buttonsmodel.h b/kcmkwin/kwindecoration/declarative-plugin/buttonsmodel.h index 0c09119c9..9c19faf5f 100644 --- a/kcmkwin/kwindecoration/declarative-plugin/buttonsmodel.h +++ b/kcmkwin/kwindecoration/declarative-plugin/buttonsmodel.h @@ -1,66 +1,66 @@ /* * Copyright 2014 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) 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 . */ #ifndef KDECOARTIONS_PREVIEW_BUTTONS_MODEL_H #define KDECOARTIONS_PREVIEW_BUTTONS_MODEL_H #include #include namespace KDecoration2 { namespace Preview { class PreviewBridge; class ButtonsModel : public QAbstractListModel { Q_OBJECT public: explicit ButtonsModel(const QVector< DecorationButtonType > &buttons, QObject *parent = 0); explicit ButtonsModel(QObject *parent = nullptr); - virtual ~ButtonsModel(); + ~ButtonsModel() override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override; QHash< int, QByteArray > roleNames() const override; QVector< DecorationButtonType > buttons() const { return m_buttons; } Q_INVOKABLE void clear(); Q_INVOKABLE void remove(int index); Q_INVOKABLE void up(int index); Q_INVOKABLE void down(int index); Q_INVOKABLE void move(int sourceIndex, int targetIndex); void replace(const QVector< DecorationButtonType > &buttons); void add(DecorationButtonType type); Q_INVOKABLE void add(int index, int type); private: QVector< DecorationButtonType > m_buttons; }; } } #endif diff --git a/kcmkwin/kwindecoration/declarative-plugin/previewbridge.h b/kcmkwin/kwindecoration/declarative-plugin/previewbridge.h index fe366eb42..7e1d8f3d4 100644 --- a/kcmkwin/kwindecoration/declarative-plugin/previewbridge.h +++ b/kcmkwin/kwindecoration/declarative-plugin/previewbridge.h @@ -1,139 +1,139 @@ /* * Copyright 2014 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) 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 . */ #ifndef KDECOARTIONS_PREVIEW_BRIDGE_H #define KDECOARTIONS_PREVIEW_BRIDGE_H #include #include #include #include class KPluginFactory; namespace KDecoration2 { namespace Preview { class PreviewClient; class PreviewItem; class PreviewSettings; class PreviewBridge : public DecorationBridge { Q_OBJECT Q_PROPERTY(QString plugin READ plugin WRITE setPlugin NOTIFY pluginChanged) Q_PROPERTY(QString theme READ theme WRITE setTheme NOTIFY themeChanged) Q_PROPERTY(bool valid READ isValid NOTIFY validChanged) public: explicit PreviewBridge(QObject *parent = nullptr); - virtual ~PreviewBridge(); + ~PreviewBridge() override; std::unique_ptr createClient(DecoratedClient *client, Decoration *decoration) override; void update(Decoration* decoration, const QRect& geometry) override; std::unique_ptr settings(DecorationSettings *parent) override; PreviewClient *lastCreatedClient() { return m_lastCreatedClient; } PreviewSettings *lastCreatedSettings() { return m_lastCreatedSettings; } void registerPreviewItem(PreviewItem *item); void unregisterPreviewItem(PreviewItem *item); void setPlugin(const QString &plugin); QString plugin() const; void setTheme(const QString &theme); QString theme() const; bool isValid() const; KDecoration2::Decoration *createDecoration(QObject *parent = nullptr); KDecoration2::DecorationButton *createButton(KDecoration2::Decoration *decoration, KDecoration2::DecorationButtonType type, QObject *parent = nullptr); public Q_SLOTS: void configure(); Q_SIGNALS: void pluginChanged(); void themeChanged(); void validChanged(); private: void createFactory(); void setValid(bool valid); PreviewClient *m_lastCreatedClient; PreviewSettings *m_lastCreatedSettings; QList m_previewItems; QString m_plugin; QString m_theme; QPointer m_factory; bool m_valid; }; class BridgeItem : public QObject { Q_OBJECT Q_PROPERTY(QString plugin READ plugin WRITE setPlugin NOTIFY pluginChanged) Q_PROPERTY(QString theme READ theme WRITE setTheme NOTIFY themeChanged) Q_PROPERTY(bool valid READ isValid NOTIFY validChanged) Q_PROPERTY(KDecoration2::Preview::PreviewBridge *bridge READ bridge CONSTANT) public: explicit BridgeItem(QObject *parent = nullptr); - virtual ~BridgeItem(); + ~BridgeItem() override; void setPlugin(const QString &plugin) { m_bridge->setPlugin(plugin); } QString plugin() const { return m_bridge->plugin(); } void setTheme(const QString &theme) { m_bridge->setTheme(theme); } QString theme() const { return m_bridge->theme(); } bool isValid() const { return m_bridge->isValid(); } PreviewBridge *bridge() const { return m_bridge; } Q_SIGNALS: void pluginChanged(); void themeChanged(); void validChanged(); private: PreviewBridge *m_bridge; }; } } Q_DECLARE_METATYPE(KDecoration2::Preview::PreviewBridge *) #endif diff --git a/kcmkwin/kwindecoration/declarative-plugin/previewbutton.h b/kcmkwin/kwindecoration/declarative-plugin/previewbutton.h index a2cee4c21..ed70e6db7 100644 --- a/kcmkwin/kwindecoration/declarative-plugin/previewbutton.h +++ b/kcmkwin/kwindecoration/declarative-plugin/previewbutton.h @@ -1,87 +1,87 @@ /* * Copyright 2014 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) 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 . */ #ifndef KDECOARTIONS_PREVIEW_BUTTON_ITEM_H #define KDECOARTIONS_PREVIEW_BUTTON_ITEM_H #include #include #include #include namespace KDecoration2 { class Decoration; namespace Preview { class PreviewBridge; class Settings; class PreviewButtonItem : public QQuickPaintedItem { Q_OBJECT Q_PROPERTY(KDecoration2::Preview::PreviewBridge *bridge READ bridge WRITE setBridge NOTIFY bridgeChanged) Q_PROPERTY(KDecoration2::Preview::Settings *settings READ settings WRITE setSettings NOTIFY settingsChanged) Q_PROPERTY(int type READ typeAsInt WRITE setType NOTIFY typeChanged) Q_PROPERTY(QColor color READ color WRITE setColor) public: explicit PreviewButtonItem(QQuickItem *parent = nullptr); - virtual ~PreviewButtonItem(); + ~PreviewButtonItem() override; void paint(QPainter *painter) override; PreviewBridge *bridge() const; void setBridge(PreviewBridge *bridge); Settings *settings() const; void setSettings(Settings *settings); KDecoration2::DecorationButtonType type() const; int typeAsInt() const; void setType(KDecoration2::DecorationButtonType type); void setType(int type); const QColor &color() const { return m_color; } void setColor(const QColor color); Q_SIGNALS: void bridgeChanged(); void typeChanged(); void settingsChanged(); protected: void componentComplete() override; private: void createButton(); void syncGeometry(); QColor m_color; QPointer m_bridge; QPointer m_settings; KDecoration2::Decoration *m_decoration = nullptr; KDecoration2::DecorationButton *m_button = nullptr; KDecoration2::DecorationButtonType m_type = KDecoration2::DecorationButtonType::Custom; }; } // Preview } // KDecoration2 #endif diff --git a/kcmkwin/kwindecoration/declarative-plugin/previewclient.h b/kcmkwin/kwindecoration/declarative-plugin/previewclient.h index df3608393..ced66cade 100644 --- a/kcmkwin/kwindecoration/declarative-plugin/previewclient.h +++ b/kcmkwin/kwindecoration/declarative-plugin/previewclient.h @@ -1,214 +1,214 @@ /* * Copyright 2014 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) 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 . */ #ifndef KDECOARTIONS_PREVIEW_CLIENT_H #define KDECOARTIONS_PREVIEW_CLIENT_H #include "../../../decorations/decorationpalette.h" #include #include #include class QAbstractItemModel; namespace KDecoration2 { namespace Preview { class PreviewClient : public QObject, public ApplicationMenuEnabledDecoratedClientPrivate { Q_OBJECT Q_PROPERTY(KDecoration2::Decoration *decoration READ decoration CONSTANT) Q_PROPERTY(QString caption READ caption WRITE setCaption NOTIFY captionChanged) Q_PROPERTY(QIcon icon READ icon WRITE setIcon NOTIFY iconChanged) Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged) Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged) Q_PROPERTY(bool closeable READ isCloseable WRITE setCloseable NOTIFY closeableChanged) Q_PROPERTY(bool keepAbove READ isKeepAbove WRITE setKeepAbove NOTIFY keepAboveChanged) Q_PROPERTY(bool keepBelow READ isKeepBelow WRITE setKeepBelow NOTIFY keepBelowChanged) Q_PROPERTY(bool maximizable READ isMaximizeable WRITE setMaximizable NOTIFY maximizableChanged) Q_PROPERTY(bool maximized READ isMaximized NOTIFY maximizedChanged) Q_PROPERTY(bool maximizedVertically READ isMaximizedVertically WRITE setMaximizedVertically NOTIFY maximizedVerticallyChanged) Q_PROPERTY(bool maximizedHorizontally READ isMaximizedHorizontally WRITE setMaximizedHorizontally NOTIFY maximizedHorizontallyChanged) Q_PROPERTY(bool minimizable READ isMinimizeable WRITE setMinimizable NOTIFY minimizableChanged) Q_PROPERTY(bool modal READ isModal WRITE setModal NOTIFY modalChanged) Q_PROPERTY(bool movable READ isMoveable WRITE setMovable NOTIFY movableChanged) Q_PROPERTY(int desktop READ desktop WRITE setDesktop NOTIFY desktopChanged) Q_PROPERTY(bool onAllDesktops READ isOnAllDesktops NOTIFY onAllDesktopsChanged) Q_PROPERTY(bool resizable READ isResizeable WRITE setResizable NOTIFY resizableChanged) Q_PROPERTY(bool shadeable READ isShadeable WRITE setShadeable NOTIFY shadeableChanged) Q_PROPERTY(bool shaded READ isShaded WRITE setShaded NOTIFY shadedChanged) Q_PROPERTY(bool providesContextHelp READ providesContextHelp WRITE setProvidesContextHelp NOTIFY providesContextHelpChanged) Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged) Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged) Q_PROPERTY(bool bordersTopEdge READ bordersTopEdge WRITE setBordersTopEdge NOTIFY bordersTopEdgeChanged) Q_PROPERTY(bool bordersLeftEdge READ bordersLeftEdge WRITE setBordersLeftEdge NOTIFY bordersLeftEdgeChanged) Q_PROPERTY(bool bordersRightEdge READ bordersRightEdge WRITE setBordersRightEdge NOTIFY bordersRightEdgeChanged) Q_PROPERTY(bool bordersBottomEdge READ bordersBottomEdge WRITE setBordersBottomEdge NOTIFY bordersBottomEdgeChanged) public: explicit PreviewClient(DecoratedClient *client, Decoration *decoration); - virtual ~PreviewClient(); + ~PreviewClient() override; QString caption() const override; WId decorationId() const override; WId windowId() const override; int desktop() const override; QIcon icon() const override; bool isActive() const override; bool isCloseable() const override; bool isKeepAbove() const override; bool isKeepBelow() const override; bool isMaximizeable() const override; bool isMaximized() const override; bool isMaximizedVertically() const override; bool isMaximizedHorizontally() const override; bool isMinimizeable() const override; bool isModal() const override; bool isMoveable() const override; bool isOnAllDesktops() const override; bool isResizeable() const override; bool isShadeable() const override; bool isShaded() const override; bool providesContextHelp() const override; int width() const override; int height() const override; QPalette palette() const override; QColor color(ColorGroup group, ColorRole role) const override; Qt::Edges adjacentScreenEdges() const override; bool hasApplicationMenu() const override; bool isApplicationMenuActive() const override; void requestShowToolTip(const QString &text) override; void requestHideToolTip() override; void requestClose() override; void requestContextHelp() override; void requestToggleMaximization(Qt::MouseButtons buttons) override; void requestMinimize() override; void requestToggleKeepAbove() override; void requestToggleKeepBelow() override; void requestToggleShade() override; void requestShowWindowMenu() override; void requestShowApplicationMenu(const QRect &rect, int actionId) override; void requestToggleOnAllDesktops() override; - void showApplicationMenu(int actionId); + void showApplicationMenu(int actionId) override; void setCaption(const QString &caption); void setActive(bool active); void setCloseable(bool closeable); void setMaximizable(bool maximizable); void setKeepBelow(bool keepBelow); void setKeepAbove(bool keepAbove); void setMaximizedHorizontally(bool maximized); void setMaximizedVertically(bool maximized); void setMinimizable(bool minimizable); void setModal(bool modal); void setMovable(bool movable); void setResizable(bool resizable); void setShadeable(bool shadeable); void setShaded(bool shaded); void setProvidesContextHelp(bool contextHelp); void setDesktop(int desktop); void setWidth(int width); void setHeight(int height); QString iconName() const; void setIconName(const QString &icon); void setIcon(const QIcon &icon); bool bordersTopEdge() const; bool bordersLeftEdge() const; bool bordersRightEdge() const; bool bordersBottomEdge() const; void setBordersTopEdge(bool enabled); void setBordersLeftEdge(bool enabled); void setBordersRightEdge(bool enabled); void setBordersBottomEdge(bool enabled); Q_SIGNALS: void captionChanged(const QString &); void iconChanged(const QIcon &); void iconNameChanged(const QString &); void activeChanged(bool); void closeableChanged(bool); void keepAboveChanged(bool); void keepBelowChanged(bool); void maximizableChanged(bool); void maximizedChanged(bool); void maximizedVerticallyChanged(bool); void maximizedHorizontallyChanged(bool); void minimizableChanged(bool); void modalChanged(bool); void movableChanged(bool); void onAllDesktopsChanged(bool); void resizableChanged(bool); void shadeableChanged(bool); void shadedChanged(bool); void providesContextHelpChanged(bool); void desktopChanged(int); void widthChanged(int); void heightChanged(int); void paletteChanged(const QPalette&); void bordersTopEdgeChanged(bool); void bordersLeftEdgeChanged(bool); void bordersRightEdgeChanged(bool); void bordersBottomEdgeChanged(bool); void showWindowMenuRequested(); void showApplicationMenuRequested(); void minimizeRequested(); void closeRequested(); private: QString m_caption; QIcon m_icon; QString m_iconName; KWin::Decoration::DecorationPalette m_palette; bool m_active; bool m_closeable; bool m_keepBelow; bool m_keepAbove; bool m_maximizable; bool m_maximizedHorizontally; bool m_maximizedVertically; bool m_minimizable; bool m_modal; bool m_movable; bool m_resizable; bool m_shadeable; bool m_shaded; bool m_providesContextHelp; int m_desktop; int m_width; int m_height; bool m_bordersTopEdge; bool m_bordersLeftEdge; bool m_bordersRightEdge; bool m_bordersBottomEdge; }; } // namespace Preview } // namespace KDecoration2 #endif diff --git a/kcmkwin/kwindecoration/declarative-plugin/previewitem.h b/kcmkwin/kwindecoration/declarative-plugin/previewitem.h index e052751ef..cd9ed6dad 100644 --- a/kcmkwin/kwindecoration/declarative-plugin/previewitem.h +++ b/kcmkwin/kwindecoration/declarative-plugin/previewitem.h @@ -1,104 +1,104 @@ /* * Copyright 2014 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) 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 . */ #ifndef KDECOARTIONS_PREVIEW_ITEM_H #define KDECOARTIONS_PREVIEW_ITEM_H #include #include namespace KDecoration2 { class Decoration; class DecorationShadow; class DecorationSettings; namespace Preview { class PreviewBridge; class PreviewClient; class Settings; class PreviewItem : public QQuickPaintedItem { Q_OBJECT Q_PROPERTY(KDecoration2::Decoration *decoration READ decoration NOTIFY decorationChanged) Q_PROPERTY(KDecoration2::Preview::PreviewBridge *bridge READ bridge WRITE setBridge NOTIFY bridgeChanged) Q_PROPERTY(KDecoration2::Preview::Settings *settings READ settings WRITE setSettings NOTIFY settingsChanged) Q_PROPERTY(KDecoration2::Preview::PreviewClient *client READ client) Q_PROPERTY(KDecoration2::DecorationShadow *shadow READ shadow NOTIFY shadowChanged) Q_PROPERTY(QColor windowColor READ windowColor WRITE setWindowColor NOTIFY windowColorChanged) Q_PROPERTY(bool drawBackground READ isDrawingBackground WRITE setDrawingBackground NOTIFY drawingBackgroundChanged) public: PreviewItem(QQuickItem *parent = nullptr); - virtual ~PreviewItem(); - void paint(QPainter *painter); + ~PreviewItem() override; + void paint(QPainter *painter) override; KDecoration2::Decoration *decoration() const; void setDecoration(KDecoration2::Decoration *deco); QColor windowColor() const; void setWindowColor(const QColor &color); bool isDrawingBackground() const; void setDrawingBackground(bool set); PreviewBridge *bridge() const; void setBridge(PreviewBridge *bridge); Settings *settings() const; void setSettings(Settings *settings); PreviewClient *client(); DecorationShadow *shadow() const; Q_SIGNALS: void decorationChanged(KDecoration2::Decoration *deco); void windowColorChanged(const QColor &color); void drawingBackgroundChanged(bool); void bridgeChanged(); void settingsChanged(); void shadowChanged(); protected: void mouseDoubleClickEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; void hoverEnterEvent(QHoverEvent *event) override; void hoverLeaveEvent(QHoverEvent *event) override; void hoverMoveEvent(QHoverEvent *event) override; void componentComplete() override; private: void paintShadow(QPainter *painter, int &paddingLeft, int &paddingRight, int &paddingTop, int &paddingBottom); void syncSize(); void createDecoration(); Decoration *m_decoration; QColor m_windowColor; bool m_drawBackground = true; QPointer m_bridge; QPointer m_settings; QPointer m_client; }; } // Preview } // KDecoration2 #endif diff --git a/kcmkwin/kwindecoration/declarative-plugin/previewsettings.h b/kcmkwin/kwindecoration/declarative-plugin/previewsettings.h index dcebdabcc..f206e79ff 100644 --- a/kcmkwin/kwindecoration/declarative-plugin/previewsettings.h +++ b/kcmkwin/kwindecoration/declarative-plugin/previewsettings.h @@ -1,163 +1,163 @@ /* * Copyright 2014 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) 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 . */ #ifndef KDECOARTIONS_PREVIEW_SETTINGS_H #define KDECOARTIONS_PREVIEW_SETTINGS_H #include #include #include #include namespace KDecoration2 { namespace Preview { class ButtonsModel; class PreviewBridge; class BorderSizesModel : public QAbstractListModel { Q_OBJECT public: explicit BorderSizesModel(QObject *parent = 0); - virtual ~BorderSizesModel(); + ~BorderSizesModel() override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override; QHash< int, QByteArray > roleNames() const override; private: QList m_borders = QList({ BorderSize::None, BorderSize::NoSides, BorderSize::Tiny, BorderSize::Normal, BorderSize::Large, BorderSize::VeryLarge, BorderSize::Huge, BorderSize::VeryHuge, BorderSize::Oversized }); }; class PreviewSettings : public QObject, public DecorationSettingsPrivate { Q_OBJECT Q_PROPERTY(bool onAllDesktopsAvailable READ isOnAllDesktopsAvailable WRITE setOnAllDesktopsAvailable NOTIFY onAllDesktopsAvailableChanged) Q_PROPERTY(bool alphaChannelSupported READ isAlphaChannelSupported WRITE setAlphaChannelSupported NOTIFY alphaChannelSupportedChanged) Q_PROPERTY(bool closeOnDoubleClickOnMenu READ isCloseOnDoubleClickOnMenu WRITE setCloseOnDoubleClickOnMenu NOTIFY closeOnDoubleClickOnMenuChanged) Q_PROPERTY(QAbstractItemModel *leftButtonsModel READ leftButtonsModel CONSTANT) Q_PROPERTY(QAbstractItemModel *rightButtonsModel READ rightButtonsModel CONSTANT) Q_PROPERTY(QAbstractItemModel *availableButtonsModel READ availableButtonsModel CONSTANT) Q_PROPERTY(QAbstractItemModel *borderSizesModel READ borderSizesModel CONSTANT) Q_PROPERTY(int borderSizesIndex READ borderSizesIndex WRITE setBorderSizesIndex NOTIFY borderSizesIndexChanged) Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) public: explicit PreviewSettings(DecorationSettings *parent); - virtual ~PreviewSettings(); + ~PreviewSettings() override; bool isAlphaChannelSupported() const override; bool isOnAllDesktopsAvailable() const override; bool isCloseOnDoubleClickOnMenu() const override { return m_closeOnDoubleClick; } BorderSize borderSize() const override; void setOnAllDesktopsAvailable(bool available); void setAlphaChannelSupported(bool supported); void setCloseOnDoubleClickOnMenu(bool enabled); QAbstractItemModel *leftButtonsModel() const; QAbstractItemModel *rightButtonsModel() const; QAbstractItemModel *availableButtonsModel() const; QAbstractItemModel *borderSizesModel() const { return m_borderSizes; } QVector< DecorationButtonType > decorationButtonsLeft() const override; QVector< DecorationButtonType > decorationButtonsRight() const override; Q_INVOKABLE void addButtonToLeft(int row); Q_INVOKABLE void addButtonToRight(int row); int borderSizesIndex() const { return m_borderSize; } void setBorderSizesIndex(int index); - QFont font() const { + QFont font() const override { return m_font; } void setFont(const QFont &font); Q_SIGNALS: void onAllDesktopsAvailableChanged(bool); void alphaChannelSupportedChanged(bool); void closeOnDoubleClickOnMenuChanged(bool); void borderSizesIndexChanged(int); void fontChanged(const QFont &); private: bool m_alphaChannelSupported; bool m_onAllDesktopsAvailable; bool m_closeOnDoubleClick; ButtonsModel *m_leftButtons; ButtonsModel *m_rightButtons; ButtonsModel *m_availableButtons; BorderSizesModel *m_borderSizes; int m_borderSize; QFont m_font; }; class Settings : public QObject { Q_OBJECT Q_PROPERTY(KDecoration2::Preview::PreviewBridge *bridge READ bridge WRITE setBridge NOTIFY bridgeChanged) Q_PROPERTY(KDecoration2::DecorationSettings *settings READ settingsPointer NOTIFY settingsChanged) Q_PROPERTY(int borderSizesIndex READ borderSizesIndex WRITE setBorderSizesIndex NOTIFY borderSizesIndexChanged) public: explicit Settings(QObject *parent = nullptr); - virtual ~Settings(); + ~Settings() override; PreviewBridge *bridge() const; void setBridge(PreviewBridge *bridge); QSharedPointer settings() const; DecorationSettings *settingsPointer() const; int borderSizesIndex() const { return m_borderSize; } void setBorderSizesIndex(int index); Q_SIGNALS: void bridgeChanged(); void settingsChanged(); void borderSizesIndexChanged(int); private: void createSettings(); QPointer m_bridge; QSharedPointer m_settings; PreviewSettings *m_previewSettings = nullptr; int m_borderSize = 3; }; } } #endif diff --git a/kcmkwin/kwindecoration/decorationmodel.h b/kcmkwin/kwindecoration/decorationmodel.h index 54826a48b..9fde4bffe 100644 --- a/kcmkwin/kwindecoration/decorationmodel.h +++ b/kcmkwin/kwindecoration/decorationmodel.h @@ -1,76 +1,76 @@ /* * Copyright 2014 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) 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 . */ #ifndef KDECORATION_DECORATION_MODEL_H #define KDECORATION_DECORATION_MODEL_H #include "utils.h" #include namespace KDecoration2 { namespace Configuration { class DecorationsModel : public QAbstractListModel { Q_OBJECT public: enum DecorationRole { PluginNameRole = Qt::UserRole + 1, ThemeNameRole, ConfigurationRole, RecommendedBorderSizeRole, }; public: explicit DecorationsModel(QObject *parent = nullptr); - virtual ~DecorationsModel(); + ~DecorationsModel() override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; QHash< int, QByteArray > roleNames() const override; QModelIndex findDecoration(const QString &pluginName, const QString &themeName = QString()) const; QStringList knsProviders() const { return m_knsProviders; } public Q_SLOTS: void init(); private: struct Data { QString pluginName; QString themeName; QString visibleName; bool configuration = false; KDecoration2::BorderSize recommendedBorderSize = KDecoration2::BorderSize::Normal; }; std::vector m_plugins; QStringList m_knsProviders; }; } } #endif diff --git a/kcmkwin/kwinoptions/main.h b/kcmkwin/kwinoptions/main.h index 82cb0e5d1..903cd720c 100644 --- a/kcmkwin/kwinoptions/main.h +++ b/kcmkwin/kwinoptions/main.h @@ -1,99 +1,99 @@ /* * main.h * * Copyright (c) 2001 Waldo Bastian * * Requires the Qt widget libraries, available at no cost at * https://www.qt.io/ * * 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef __MAIN_H__ #define __MAIN_H__ #include #include class KConfig; class KFocusConfig; class KTitleBarActionsConfig; class KWindowActionsConfig; class KAdvancedConfig; class KMovingConfig; class KWinOptions : public KCModule { Q_OBJECT public: KWinOptions(QWidget *parent, const QVariantList &args); - virtual ~KWinOptions(); + ~KWinOptions() override; - void load(); - void save(); - void defaults(); - QString quickHelp() const; + void load() override; + void save() override; + void defaults() override; + QString quickHelp() const override; protected Q_SLOTS: void moduleChanged(bool state); private: QTabWidget *tab; KFocusConfig *mFocus; KTitleBarActionsConfig *mTitleBarActions; KWindowActionsConfig *mWindowActions; KMovingConfig *mMoving; KAdvancedConfig *mAdvanced; KConfig *mConfig; }; class KActionsOptions : public KCModule { Q_OBJECT public: KActionsOptions(QWidget *parent, const QVariantList &args); - virtual ~KActionsOptions(); + ~KActionsOptions() override; - void load(); - void save(); - void defaults(); + void load() override; + void save() override; + void defaults() override; protected Q_SLOTS: void moduleChanged(bool state); private: QTabWidget *tab; KTitleBarActionsConfig *mTitleBarActions; KWindowActionsConfig *mWindowActions; KConfig *mConfig; }; #endif diff --git a/kcmkwin/kwinoptions/mouse.h b/kcmkwin/kwinoptions/mouse.h index c7a1e3c11..1dee6eb34 100644 --- a/kcmkwin/kwinoptions/mouse.h +++ b/kcmkwin/kwinoptions/mouse.h @@ -1,132 +1,132 @@ /* * mouse.h * * Copyright (c) 1998 Matthias Ettrich * * * 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef __KKWMMOUSECONFIG_H__ #define __KKWMMOUSECONFIG_H__ class KConfig; #include #include #include #include "ui_actions.h" #include "ui_mouse.h" class KWinMouseConfigForm : public QWidget, public Ui::KWinMouseConfigForm { Q_OBJECT public: explicit KWinMouseConfigForm(QWidget* parent); }; class KWinActionsConfigForm : public QWidget, public Ui::KWinActionsConfigForm { Q_OBJECT public: explicit KWinActionsConfigForm(QWidget* parent); }; class KTitleBarActionsConfig : public KCModule { Q_OBJECT public: KTitleBarActionsConfig(bool _standAlone, KConfig *_config, QWidget *parent); - ~KTitleBarActionsConfig(); + ~KTitleBarActionsConfig() override; - void load(); - void save(); - void defaults(); + void load() override; + void save() override; + void defaults() override; protected: - void showEvent(QShowEvent *ev); - void changeEvent(QEvent *ev); + void showEvent(QShowEvent *ev) override; + void changeEvent(QEvent *ev) override; public Q_SLOTS: void changed() { emit KCModule::changed(true); } private: KConfig *config; bool standAlone; KWinMouseConfigForm *m_ui; const char* functionTiDbl(int); const char* functionTiAc(int); const char* functionTiWAc(int); const char* functionTiInAc(int); const char* functionMax(int); void setComboText(KComboBox* combo, const char* text); void createMaximizeButtonTooltips(KComboBox* combo); const char* fixup(const char* s); private Q_SLOTS: void paletteChanged(); }; class KWindowActionsConfig : public KCModule { Q_OBJECT public: KWindowActionsConfig(bool _standAlone, KConfig *_config, QWidget *parent); - ~KWindowActionsConfig(); + ~KWindowActionsConfig() override; - void load(); - void save(); - void defaults(); + void load() override; + void save() override; + void defaults() override; protected: - void showEvent(QShowEvent *ev); + void showEvent(QShowEvent *ev) override; public Q_SLOTS: void changed() { emit KCModule::changed(true); } private: KConfig *config; bool standAlone; KWinActionsConfigForm *m_ui; const char* functionWin(int); const char* functionWinWheel(int); const char* functionAllKey(int); const char* functionAll(int); const char* functionAllW(int); void setComboText(KComboBox* combo, const char* text); const char* fixup(const char* s); }; #endif diff --git a/kcmkwin/kwinoptions/windows.h b/kcmkwin/kwinoptions/windows.h index 959afacfb..0de3a215d 100644 --- a/kcmkwin/kwinoptions/windows.h +++ b/kcmkwin/kwinoptions/windows.h @@ -1,191 +1,191 @@ /* * windows.h * * Copyright (c) 1997 Patrick Dowler dowler@morgul.fsh.uvic.ca * Copyright (c) 2001 Waldo Bastian bastian@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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KKWMWINDOWS_H #define KKWMWINDOWS_H #include #include #include "ui_advanced.h" #include "ui_focus.h" #include "ui_moving.h" class QRadioButton; class QCheckBox; class QPushButton; class KComboBox; class QGroupBox; class QLabel; class QSlider; class QGroupBox; class QSpinBox; class KColorButton; class KWinFocusConfigForm : public QWidget, public Ui::KWinFocusConfigForm { Q_OBJECT public: explicit KWinFocusConfigForm(QWidget* parent); }; class KWinMovingConfigForm : public QWidget, public Ui::KWinMovingConfigForm { Q_OBJECT public: explicit KWinMovingConfigForm(QWidget* parent); }; class KWinAdvancedConfigForm : public QWidget, public Ui::KWinAdvancedConfigForm { Q_OBJECT public: explicit KWinAdvancedConfigForm(QWidget* parent); }; class KFocusConfig : public KCModule { Q_OBJECT public: KFocusConfig(bool _standAlone, KConfig *_config, QWidget *parent); - ~KFocusConfig(); + ~KFocusConfig() override; - void load(); - void save(); - void defaults(); + void load() override; + void save() override; + void defaults() override; protected: - void showEvent(QShowEvent *ev); + void showEvent(QShowEvent *ev) override; private Q_SLOTS: void setDelayFocusEnabled(); void focusPolicyChanged(); void autoRaiseOnTog(bool);//CT 23Oct1998 void delayFocusOnTog(bool); void updateActiveMouseScreen(); void updateMultiScreen(); void changed() { emit KCModule::changed(true); } private: int getFocus(void); int getAutoRaiseInterval(void); int getDelayFocusInterval(void); void setFocus(int); void setAutoRaiseInterval(int); void setAutoRaise(bool); void setDelayFocusInterval(int); void setClickRaise(bool); void setSeparateScreenFocus(bool); void setActiveMouseScreen(bool); void setFocusStealing(int); KConfig *config; bool standAlone; KWinFocusConfigForm *m_ui; }; class KMovingConfig : public KCModule { Q_OBJECT public: KMovingConfig(bool _standAlone, KConfig *config, QWidget *parent); - ~KMovingConfig(); + ~KMovingConfig() override; - void load(); - void save(); - void defaults(); + void load() override; + void save() override; + void defaults() override; protected: - void showEvent(QShowEvent *ev); + void showEvent(QShowEvent *ev) override; private Q_SLOTS: void changed() { emit KCModule::changed(true); } private: bool getGeometryTip(void); //KS void setGeometryTip(bool); //KS KConfig *config; bool standAlone; KWinMovingConfigForm *m_ui; int getBorderSnapZone(); void setBorderSnapZone(int); int getWindowSnapZone(); void setWindowSnapZone(int); int getCenterSnapZone(); void setCenterSnapZone(int); }; class KAdvancedConfig : public KCModule { Q_OBJECT public: KAdvancedConfig(bool _standAlone, KConfig *config, QWidget *parent); - ~KAdvancedConfig(); + ~KAdvancedConfig() override; - void load(); - void save(); - void defaults(); + void load() override; + void save() override; + void defaults() override; protected: - void showEvent(QShowEvent *ev); + void showEvent(QShowEvent *ev) override; private Q_SLOTS: void shadeHoverChanged(bool); void changed() { emit KCModule::changed(true); } private: int getShadeHoverInterval(void); void setShadeHover(bool); void setShadeHoverInterval(int); KConfig *config; bool standAlone; KWinAdvancedConfigForm *m_ui; void setHideUtilityWindowsForInactive(bool); void setInactiveTabsSkipTaskbar(bool); void setAutogroupSimilarWindows(bool); void setAutogroupInForeground(bool); }; #endif // KKWMWINDOWS_H diff --git a/kcmkwin/kwinrules/kcm.h b/kcmkwin/kwinrules/kcm.h index f804ee9d5..cb1f48dd8 100644 --- a/kcmkwin/kwinrules/kcm.h +++ b/kcmkwin/kwinrules/kcm.h @@ -1,52 +1,52 @@ /* * Copyright (c) 2004 Lubos Lunak * * 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef __KCM_H__ #define __KCM_H__ #include #include class KConfig; namespace KWin { class KCMRulesList; class KCMRules : public KCModule { Q_OBJECT public: KCMRules(QWidget *parent, const QVariantList &args); - virtual void load(); - virtual void save(); - virtual void defaults(); - virtual QString quickHelp() const; + void load() override; + void save() override; + void defaults() override; + QString quickHelp() const override; protected Q_SLOTS: void moduleChanged(bool state); private: KCMRulesList* widget; KConfig config; }; } // namespace #endif diff --git a/kcmkwin/kwinrules/ruleslist.h b/kcmkwin/kwinrules/ruleslist.h index eb9a1ad1a..c480d1081 100644 --- a/kcmkwin/kwinrules/ruleslist.h +++ b/kcmkwin/kwinrules/ruleslist.h @@ -1,57 +1,57 @@ /* * Copyright (c) 2004 Lubos Lunak * * 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef __RULESLIST_H__ #define __RULESLIST_H__ #include "../../rules.h" #include "ui_ruleslist.h" namespace KWin { class KCMRulesList : public QWidget, Ui_KCMRulesList { Q_OBJECT public: explicit KCMRulesList(QWidget* parent = nullptr); - virtual ~KCMRulesList(); + ~KCMRulesList() override; void load(); void save(); void defaults(); Q_SIGNALS: void changed(bool); private Q_SLOTS: void newClicked(); void modifyClicked(); void deleteClicked(); void moveupClicked(); void movedownClicked(); void exportClicked(); void importClicked(); void activeChanged(); private: QVector< Rules* > rules; }; } // namespace #endif diff --git a/kcmkwin/kwinrules/ruleswidget.h b/kcmkwin/kwinrules/ruleswidget.h index 6c1253d4c..feaf1a221 100644 --- a/kcmkwin/kwinrules/ruleswidget.h +++ b/kcmkwin/kwinrules/ruleswidget.h @@ -1,178 +1,178 @@ /* * Copyright (c) 2004 Lubos Lunak * * 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef __RULESWIDGET_H__ #define __RULESWIDGET_H__ #include #include #include #include "ui_ruleswidgetbase.h" #include "ui_editshortcut.h" #ifdef KWIN_BUILD_ACTIVITIES namespace KActivities { class Consumer; } // namespace KActivities #endif namespace KWin { class Rules; class DetectDialog; class RulesWidget : public QWidget, public Ui::RulesWidgetBase { Q_OBJECT public: explicit RulesWidget(QWidget* parent = nullptr); void setRules(Rules* r); Rules* rules() const; bool finalCheck(); void prepareWindowSpecific(const QVariantMap &info); Q_SIGNALS: void changed(bool state); protected Q_SLOTS: void detectClicked(); void wmclassMatchChanged(); void roleMatchChanged(); void titleMatchChanged(); void machineMatchChanged(); void shortcutEditClicked(); private Q_SLOTS: // geometry tab void updateEnableposition(); void updateEnablesize(); void updateEnabledesktop(); void updateEnablescreen(); #ifdef KWIN_BUILD_ACTIVITIES void updateEnableactivity(); #endif void updateEnablemaximizehoriz(); void updateEnablemaximizevert(); void updateEnableminimize(); void updateEnableshade(); void updateEnablefullscreen(); void updateEnableplacement(); // preferences tab void updateEnableabove(); void updateEnablebelow(); void updateEnablenoborder(); void updateEnabledecocolor(); void updateEnableskiptaskbar(); void updateEnableskippager(); void updateEnableskipswitcher(); void updateEnableacceptfocus(); void updateEnablecloseable(); void updateEnableautogroup(); void updateEnableautogroupfg(); void updateEnableautogroupid(); void updateEnableopacityactive(); void updateEnableopacityinactive(); // workarounds tab void updateEnablefsplevel(); void updateEnablefpplevel(); void updateEnabletype(); void updateEnableignoregeometry(); void updateEnableminsize(); void updateEnablemaxsize(); void updateEnablestrictgeometry(); void updateEnableshortcut(); void updateEnabledisableglobalshortcuts(); void updateEnableblockcompositing(); void updateEnabledesktopfile(); // internal void detected(bool); private: int desktopToCombo(int d) const; int comboToDesktop(int val) const; #ifdef KWIN_BUILD_ACTIVITIES int activityToCombo(QString d) const; QString comboToActivity(int val) const; void updateActivitiesList(); KActivities::Consumer *m_activities; QString m_selectedActivityId; // we need this for async activity loading #endif int comboToTiling(int val) const; int inc(int i) const { return i+1; } int dec(int i) const { return i-1; } void prefillUnusedValues(const QVariantMap& info); DetectDialog* detect_dlg; bool detect_dlg_ok; }; class RulesDialog : public QDialog { Q_OBJECT public: explicit RulesDialog(QWidget* parent = nullptr, const char* name = nullptr); Rules* edit(Rules* r, const QVariantMap& info, bool show_hints); protected: - virtual void accept(); + void accept() override; private Q_SLOTS: void displayHints(); private: RulesWidget* widget; Rules* rules; }; class EditShortcut : public QWidget, public Ui_EditShortcut { Q_OBJECT public: explicit EditShortcut(QWidget* parent = nullptr); protected Q_SLOTS: void editShortcut(); void clearShortcut(); }; class EditShortcutDialog : public QDialog { Q_OBJECT public: explicit EditShortcutDialog(QWidget* parent = nullptr, const char* name = nullptr); void setShortcut(const QString& cut); QString shortcut() const; private: EditShortcut* widget; }; // slightly duped from utils.cpp class ShortcutDialog : public QDialog { Q_OBJECT public: explicit ShortcutDialog(const QKeySequence& cut, QWidget* parent = nullptr); - virtual void accept(); + void accept() override; QKeySequence shortcut() const; private: KKeySequenceWidget* widget; }; } // namespace #endif diff --git a/kcmkwin/kwinscreenedges/main.h b/kcmkwin/kwinscreenedges/main.h index 4b7eb4fb5..00b1f01d6 100644 --- a/kcmkwin/kwinscreenedges/main.h +++ b/kcmkwin/kwinscreenedges/main.h @@ -1,98 +1,98 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2009 Lucas Murray 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 __MAIN_H__ #define __MAIN_H__ #include #include #include "kwinglobals.h" #include "ui_main.h" class QShowEvent; namespace KWin { enum class BuiltInEffect; class KWinScreenEdgesConfigForm : public QWidget, public Ui::KWinScreenEdgesConfigForm { Q_OBJECT public: explicit KWinScreenEdgesConfigForm(QWidget* parent); }; class KWinScreenEdgesConfig : public KCModule { Q_OBJECT public: explicit KWinScreenEdgesConfig(QWidget* parent, const QVariantList& args); - ~KWinScreenEdgesConfig(); + ~KWinScreenEdgesConfig() override; public Q_SLOTS: virtual void groupChanged(); - virtual void save(); - virtual void load(); - virtual void defaults(); + void save() override; + void load() override; + void defaults() override; protected: - virtual void showEvent(QShowEvent* e); + void showEvent(QShowEvent* e) override; private Q_SLOTS: void sanitizeCooldown(); private: KWinScreenEdgesConfigForm* m_ui; KSharedConfigPtr m_config; QStringList m_scripts; //list of script IDs ordered in the list they are presented in the menu enum EffectActions { PresentWindowsAll = ELECTRIC_ACTION_COUNT, // Start at the end of built in actions PresentWindowsCurrent, PresentWindowsClass, DesktopGrid, Cube, Cylinder, Sphere, TabBox, TabBoxAlternative, EffectCount }; bool effectEnabled(const BuiltInEffect& effect, const KConfigGroup& cfg) const; void monitorAddItem(const QString& item); void monitorItemSetEnabled(int index, bool enabled); void monitorInit(); void monitorLoadAction(ElectricBorder edge, const QString& configName); void monitorLoad(); void monitorSaveAction(int edge, const QString& configName); void monitorSave(); void monitorDefaults(); void monitorShowEvent(); void monitorChangeEdge(ElectricBorder border, int index); void monitorHideEdge(ElectricBorder border, bool hidden); QList monitorCheckEffectHasEdge(int index) const; }; } // namespace #endif diff --git a/kcmkwin/kwinscreenedges/monitor.h b/kcmkwin/kwinscreenedges/monitor.h index c40f10573..300305815 100644 --- a/kcmkwin/kwinscreenedges/monitor.h +++ b/kcmkwin/kwinscreenedges/monitor.h @@ -1,113 +1,113 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2008 Lubos Lunak Copyright (C) 2009 Lucas Murray 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 CCSM_MONITOR_H #define CCSM_MONITOR_H #include "screenpreviewwidget.h" #include #include #include class QAction; class QGraphicsView; class QGraphicsScene; class QMenu; namespace Plasma { class FrameSvg; } namespace KWin { class Monitor : public ScreenPreviewWidget { Q_OBJECT public: explicit Monitor(QWidget* parent); void setEdge(int edge, bool set); bool edge(int edge) const; void setEdgeHidden(int edge, bool set); bool edgeHidden(int edge) const; void clear(); void addEdgeItem(int edge, const QString& item); void setEdgeItemEnabled(int edge, int index, bool enabled); bool edgeItemEnabled(int edge, int index) const; void selectEdgeItem(int edge, int index); int selectedEdgeItem(int edge) const; enum Edges { Left, Right, Top, Bottom, TopLeft, TopRight, BottomLeft, BottomRight }; Q_SIGNALS: void changed(); void edgeSelectionChanged(int edge, int index); protected: - virtual void resizeEvent(QResizeEvent* e); + void resizeEvent(QResizeEvent* e) override; private: class Corner; void popup(Corner* c, QPoint pos); void flip(Corner* c, QPoint pos); void checkSize(); QGraphicsView* view; QGraphicsScene* scene; Corner* items[ 8 ]; bool hidden[ 8 ]; QMenu* popups[ 8 ]; QVector< QAction* > popup_actions[ 8 ]; QActionGroup* grp[ 8 ]; }; class Monitor::Corner : public QGraphicsRectItem { public: Corner(Monitor* m); - ~Corner(); + ~Corner() override; void setActive(bool active); bool active() const; protected: - virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent* e); - virtual void mousePressEvent(QGraphicsSceneMouseEvent* e); - virtual void hoverEnterEvent(QGraphicsSceneHoverEvent * e); - virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent * e); - virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0); + void contextMenuEvent(QGraphicsSceneContextMenuEvent* e) override; + void mousePressEvent(QGraphicsSceneMouseEvent* e) override; + void hoverEnterEvent(QGraphicsSceneHoverEvent * e) override; + void hoverLeaveEvent(QGraphicsSceneHoverEvent * e) override; + void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) override; private: Monitor* monitor; Plasma::FrameSvg *button; bool m_active; bool m_hover; }; } // namespace #endif diff --git a/kcmkwin/kwinscreenedges/screenpreviewwidget.h b/kcmkwin/kwinscreenedges/screenpreviewwidget.h index 470d31456..02c5984f9 100644 --- a/kcmkwin/kwinscreenedges/screenpreviewwidget.h +++ b/kcmkwin/kwinscreenedges/screenpreviewwidget.h @@ -1,58 +1,58 @@ /* This file is part of the KDE libraries Copyright (C) 2009 Marco Martin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef SCREENPREVIEWWIDGET_H #define SCREENPREVIEWWIDGET_H #include class ScreenPreviewWidgetPrivate; class ScreenPreviewWidget : public QWidget { Q_OBJECT public: ScreenPreviewWidget(QWidget *parent); - ~ScreenPreviewWidget(); + ~ScreenPreviewWidget() override; void setPreview(const QPixmap &preview); const QPixmap preview() const; void setRatio(const qreal ratio); qreal ratio() const; QRect previewRect() const; protected: - void resizeEvent(QResizeEvent *event); - void paintEvent(QPaintEvent *event); - virtual void dropEvent(QDropEvent *event); + void resizeEvent(QResizeEvent *event) override; + void paintEvent(QPaintEvent *event) override; + void dropEvent(QDropEvent *event) override; Q_SIGNALS: void imageDropped(const QString &); private: ScreenPreviewWidgetPrivate *const d; Q_PRIVATE_SLOT(d, void updateRect(const QRectF& rect)) }; #endif diff --git a/kcmkwin/kwinscreenedges/touch.h b/kcmkwin/kwinscreenedges/touch.h index 8fc61e33a..92c47d9bf 100644 --- a/kcmkwin/kwinscreenedges/touch.h +++ b/kcmkwin/kwinscreenedges/touch.h @@ -1,95 +1,95 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2009 Lucas Murray 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 __TOUCH_H__ #define __TOUCH_H__ #include #include #include "kwinglobals.h" #include "ui_touch.h" class QShowEvent; namespace KWin { enum class BuiltInEffect; class KWinScreenEdgesConfigForm : public QWidget, public Ui::KWinScreenEdgesConfigForm { Q_OBJECT public: explicit KWinScreenEdgesConfigForm(QWidget* parent); }; class KWinScreenEdgesConfig : public KCModule { Q_OBJECT public: explicit KWinScreenEdgesConfig(QWidget* parent, const QVariantList& args); - ~KWinScreenEdgesConfig(); + ~KWinScreenEdgesConfig() override; public Q_SLOTS: - virtual void save(); - virtual void load(); - virtual void defaults(); + void save() override; + void load() override; + void defaults() override; protected: - virtual void showEvent(QShowEvent* e); + void showEvent(QShowEvent* e) override; private: KWinScreenEdgesConfigForm* m_ui; KSharedConfigPtr m_config; QStringList m_scripts; //list of script IDs ordered in the list they are presented in the menu enum EffectActions { PresentWindowsAll = ELECTRIC_ACTION_COUNT, // Start at the end of built in actions PresentWindowsCurrent, PresentWindowsClass, DesktopGrid, Cube, Cylinder, Sphere, TabBox, TabBoxAlternative, EffectCount }; bool effectEnabled(const BuiltInEffect& effect, const KConfigGroup& cfg) const; void monitorAddItem(const QString& item); void monitorItemSetEnabled(int index, bool enabled); void monitorInit(); void monitorLoadAction(ElectricBorder edge, const QString& configName); void monitorLoad(); void monitorSaveAction(int edge, const QString& configName); void monitorSave(); void monitorDefaults(); void monitorShowEvent(); void monitorChangeEdge(ElectricBorder border, int index); void monitorHideEdge(ElectricBorder border, bool hidden); QList monitorCheckEffectHasEdge(int index) const; }; } // namespace #endif diff --git a/kcmkwin/kwinscripts/module.h b/kcmkwin/kwinscripts/module.h index 226e128f5..1a14d4ea4 100644 --- a/kcmkwin/kwinscripts/module.h +++ b/kcmkwin/kwinscripts/module.h @@ -1,73 +1,73 @@ /* * Copyright (c) 2011 Tamas Krutki * * 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MODULE_H #define MODULE_H #include #include namespace Ui { class Module; } class KJob; class Module : public KCModule { Q_OBJECT public: /** * Constructor. * * @param parent Parent widget of the module * @param args Arguments for the module **/ explicit Module(QWidget *parent, const QVariantList &args = QVariantList()); /** * Destructor. **/ - ~Module(); - virtual void load(); - virtual void save(); - virtual void defaults(); + ~Module() override; + void load() override; + void save() override; + void defaults() override; protected Q_SLOTS: /** * Called when the import script button is clicked. **/ void importScript(); void importScriptInstallFinished(KJob *job); private: /** * UI **/ Ui::Module *ui; /** * Updates the contents of the list view. **/ void updateListViewContents(); KSharedConfigPtr m_kwinConfig; }; #endif // MODULE_H diff --git a/kcmkwin/kwintabbox/layoutpreview.h b/kcmkwin/kwintabbox/layoutpreview.h index 8edc25045..5639682ad 100644 --- a/kcmkwin/kwintabbox/layoutpreview.h +++ b/kcmkwin/kwintabbox/layoutpreview.h @@ -1,145 +1,145 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2009, 2011 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_TABBOX_LAYOUTPREVIEW_H #define KWIN_TABBOX_LAYOUTPREVIEW_H #include #include #include #include namespace KWin { namespace TabBox { class SwitcherItem; class LayoutPreview : public QObject { Q_OBJECT public: explicit LayoutPreview(const QString &path, QObject *parent = nullptr); - virtual ~LayoutPreview(); + ~LayoutPreview() override; - virtual bool eventFilter(QObject *object, QEvent *event) override; + bool eventFilter(QObject *object, QEvent *event) override; private: SwitcherItem *m_item; }; class ExampleClientModel : public QAbstractListModel { Q_OBJECT public: explicit ExampleClientModel(QObject *parent = nullptr); - virtual ~ExampleClientModel(); + ~ExampleClientModel() override; - virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; - virtual QHash roleNames() const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + QHash roleNames() const override; Q_INVOKABLE QString longestCaption() const; private: void init(); QList m_services; KService::Ptr m_fileManager; KService::Ptr m_browser; KService::Ptr m_email; KService::Ptr m_systemSettings; }; class SwitcherItem : public QObject { Q_OBJECT Q_PROPERTY(QAbstractItemModel *model READ model NOTIFY modelChanged) Q_PROPERTY(QRect screenGeometry READ screenGeometry NOTIFY screenGeometryChanged) Q_PROPERTY(bool visible READ isVisible NOTIFY visibleChanged) Q_PROPERTY(bool allDesktops READ isAllDesktops NOTIFY allDesktopsChanged) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) /** * The main QML item that will be displayed in the Dialog **/ Q_PROPERTY(QObject *item READ item WRITE setItem NOTIFY itemChanged) Q_CLASSINFO("DefaultProperty", "item") public: SwitcherItem(QObject *parent = nullptr); - virtual ~SwitcherItem(); + ~SwitcherItem() override; QAbstractItemModel *model() const; QRect screenGeometry() const; bool isVisible() const; bool isAllDesktops() const; int currentIndex() const; void setCurrentIndex(int index); QObject *item() const; void setItem(QObject *item); void setVisible(bool visible); void incrementIndex(); void decrementIndex(); Q_SIGNALS: void visibleChanged(); void currentIndexChanged(int index); void modelChanged(); void allDesktopsChanged(); void screenGeometryChanged(); void itemChanged(); private: QAbstractItemModel *m_model; QObject *m_item; int m_currentIndex; bool m_visible; }; inline QAbstractItemModel *SwitcherItem::model() const { return m_model; } inline bool SwitcherItem::isVisible() const { return m_visible; } inline bool SwitcherItem::isAllDesktops() const { return true; } inline int SwitcherItem::currentIndex() const { return m_currentIndex; } inline QObject *SwitcherItem::item() const { return m_item; } } // namespace TabBox } // namespace KWin #endif // KWIN_TABBOX_LAYOUTPREVIEW_H diff --git a/kcmkwin/kwintabbox/main.h b/kcmkwin/kwintabbox/main.h index d454e26e3..e167e8345 100644 --- a/kcmkwin/kwintabbox/main.h +++ b/kcmkwin/kwintabbox/main.h @@ -1,96 +1,96 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2009 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 __MAIN_H__ #define __MAIN_H__ #include #include #include "tabboxconfig.h" #include "ui_main.h" class KShortcutsEditor; class KActionCollection; namespace KWin { enum class BuiltInEffect; namespace TabBox { } class KWinTabBoxConfigForm : public QWidget, public Ui::KWinTabBoxConfigForm { Q_OBJECT public: explicit KWinTabBoxConfigForm(QWidget* parent); }; class KWinTabBoxConfig : public KCModule { Q_OBJECT public: explicit KWinTabBoxConfig(QWidget* parent, const QVariantList& args); - ~KWinTabBoxConfig(); + ~KWinTabBoxConfig() override; public Q_SLOTS: - virtual void save(); - virtual void load(); - virtual void defaults(); + void save() override; + void load() override; + void defaults() override; private Q_SLOTS: void effectSelectionChanged(int index); void configureEffectClicked(); void tabBoxToggled(bool on); void shortcutChanged(const QKeySequence &seq); void slotGHNS(); private: void updateUiFromConfig(KWinTabBoxConfigForm* ui, const TabBox::TabBoxConfig& config); void updateConfigFromUi(const KWinTabBoxConfigForm* ui, TabBox::TabBoxConfig& config); void loadConfig(const KConfigGroup& config, KWin::TabBox::TabBoxConfig& tabBoxConfig); void saveConfig(KConfigGroup& config, const KWin::TabBox::TabBoxConfig& tabBoxConfig); void initLayoutLists(); private: enum Mode { CoverSwitch = 0, FlipSwitch = 1, Layout = 2 }; KWinTabBoxConfigForm* m_primaryTabBoxUi; KWinTabBoxConfigForm* m_alternativeTabBoxUi; KSharedConfigPtr m_config; KActionCollection* m_actionCollection; KShortcutsEditor* m_editor; TabBox::TabBoxConfig m_tabBoxConfig; TabBox::TabBoxConfig m_tabBoxAlternativeConfig; bool effectEnabled(const BuiltInEffect& effect, const KConfigGroup& cfg) const; }; } // namespace #endif diff --git a/kcmkwin/kwintabbox/thumbnailitem.h b/kcmkwin/kwintabbox/thumbnailitem.h index 070fe399b..a5acf11a0 100644 --- a/kcmkwin/kwintabbox/thumbnailitem.h +++ b/kcmkwin/kwintabbox/thumbnailitem.h @@ -1,108 +1,108 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2011, 2014 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_THUMBNAILITEM_H #define KWIN_THUMBNAILITEM_H #include #include #include namespace KWin { class BrightnessSaturationShader : public QSGMaterialShader { public: BrightnessSaturationShader(); - virtual const char* vertexShader() const override; - virtual const char* fragmentShader() const override; - virtual const char*const* attributeNames() const override; - virtual void updateState(const RenderState& state, QSGMaterial* newMaterial, QSGMaterial* oldMaterial) override; - virtual void initialize() override; + const char* vertexShader() const override; + const char* fragmentShader() const override; + const char*const* attributeNames() const override; + void updateState(const RenderState& state, QSGMaterial* newMaterial, QSGMaterial* oldMaterial) override; + void initialize() override; private: int m_id_matrix; int m_id_opacity; int m_id_saturation; int m_id_brightness; }; class BrightnessSaturationMaterial : public QSGTextureMaterial { public: - virtual QSGMaterialShader* createShader() const override { + QSGMaterialShader* createShader() const override { return new BrightnessSaturationShader; } QSGMaterialType *type() const override { static QSGMaterialType type; return &type; } qreal brightness; qreal saturation; }; class WindowThumbnailItem : public QQuickItem { Q_OBJECT Q_PROPERTY(qulonglong wId READ wId WRITE setWId NOTIFY wIdChanged SCRIPTABLE true) Q_PROPERTY(QQuickItem *clipTo READ clipTo WRITE setClipTo NOTIFY clipToChanged) Q_PROPERTY(qreal brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged) Q_PROPERTY(qreal saturation READ saturation WRITE setSaturation NOTIFY saturationChanged) public: explicit WindowThumbnailItem(QQuickItem *parent = nullptr); - virtual ~WindowThumbnailItem(); + ~WindowThumbnailItem() override; qulonglong wId() const { return m_wId; } QQuickItem *clipTo() const { return m_clipToItem; } qreal brightness() const; qreal saturation() const; void setWId(qulonglong wId); void setClipTo(QQuickItem *clip); void setBrightness(qreal brightness); void setSaturation(qreal saturation); - virtual QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override; + QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override; enum Thumbnail { Konqueror = 1, KMail, Systemsettings, Dolphin }; Q_SIGNALS: void wIdChanged(qulonglong wid); void clipToChanged(); void brightnessChanged(); void saturationChanged(); private: void findImage(); qulonglong m_wId; QImage m_image; QQuickItem *m_clipToItem; qreal m_brightness; qreal m_saturation; }; } // KWin #endif // KWIN_THUMBNAILITEM_H diff --git a/keyboard_input.h b/keyboard_input.h index 5d70bfbd2..a744e18c3 100644 --- a/keyboard_input.h +++ b/keyboard_input.h @@ -1,104 +1,104 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2013, 2016 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_KEYBOARD_INPUT_H #define KWIN_KEYBOARD_INPUT_H #include "input.h" #include "xkb.h" #include #include #include #include class QWindow; struct xkb_context; struct xkb_keymap; struct xkb_state; struct xkb_compose_table; struct xkb_compose_state; typedef uint32_t xkb_mod_index_t; typedef uint32_t xkb_led_index_t; typedef uint32_t xkb_keysym_t; typedef uint32_t xkb_layout_index_t; namespace KWin { class InputRedirection; class KeyboardLayout; class ModifiersChangedSpy; class Toplevel; namespace LibInput { class Device; } class KWIN_EXPORT KeyboardInputRedirection : public QObject { Q_OBJECT public: explicit KeyboardInputRedirection(InputRedirection *parent); - virtual ~KeyboardInputRedirection(); + ~KeyboardInputRedirection() override; void init(); void update(); /** * @internal **/ void processKey(uint32_t key, InputRedirection::KeyboardKeyState state, uint32_t time, LibInput::Device *device = nullptr); /** * @internal **/ void processModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group); /** * @internal **/ void processKeymapChange(int fd, uint32_t size); Xkb *xkb() const { return m_xkb.data(); } Qt::KeyboardModifiers modifiers() const { return m_xkb->modifiers(); } Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const { return m_xkb->modifiersRelevantForGlobalShortcuts(); } Q_SIGNALS: void ledsChanged(KWin::Xkb::LEDs); private: InputRedirection *m_input; bool m_inited = false; QScopedPointer m_xkb; QMetaObject::Connection m_activeClientSurfaceChangedConnection; ModifiersChangedSpy *m_modifiersChangedSpy = nullptr; KeyboardLayout *m_keyboardLayout = nullptr; }; } #endif diff --git a/keyboard_layout_switching.h b/keyboard_layout_switching.h index 4e21fee80..5b5882b52 100644 --- a/keyboard_layout_switching.h +++ b/keyboard_layout_switching.h @@ -1,138 +1,138 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2017 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_KEYBOARD_LAYOUT_SWITCHING_H #define KWIN_KEYBOARD_LAYOUT_SWITCHING_H #include #include namespace KWin { class AbstractClient; class KeyboardLayout; class Xkb; class VirtualDesktop; namespace KeyboardLayoutSwitching { class Policy : public QObject { Q_OBJECT public: - virtual ~Policy(); + ~Policy() override; virtual QString name() const = 0; static Policy *create(Xkb *xkb, KeyboardLayout *layout, const QString &policy); protected: explicit Policy(Xkb *xkb, KeyboardLayout *layout); virtual void clearCache() = 0; virtual void layoutChanged() = 0; void setLayout(quint32 layout); quint32 layout() const; private: Xkb *m_xkb; KeyboardLayout *m_layout; }; class GlobalPolicy : public Policy { Q_OBJECT public: explicit GlobalPolicy(Xkb *xkb, KeyboardLayout *layout); ~GlobalPolicy() override; QString name() const override { return QStringLiteral("Global"); } protected: void clearCache() override {} void layoutChanged() override {} }; class VirtualDesktopPolicy : public Policy { Q_OBJECT public: explicit VirtualDesktopPolicy(Xkb *xkb, KeyboardLayout *layout); ~VirtualDesktopPolicy() override; QString name() const override { return QStringLiteral("Desktop"); } protected: void clearCache() override; void layoutChanged() override; private: void desktopChanged(); QHash m_layouts; }; class WindowPolicy : public Policy { Q_OBJECT public: explicit WindowPolicy(Xkb *xkb, KeyboardLayout *layout); ~WindowPolicy() override; QString name() const override { return QStringLiteral("Window"); } protected: void clearCache() override; void layoutChanged() override; private: QHash m_layouts; }; class ApplicationPolicy : public Policy { Q_OBJECT public: explicit ApplicationPolicy(Xkb *xkb, KeyboardLayout *layout); ~ApplicationPolicy() override; QString name() const override { return QStringLiteral("WinClass"); } protected: void clearCache() override; void layoutChanged() override; private: void clientActivated(AbstractClient *c); QHash m_layouts; }; } } #endif diff --git a/libinput/connection.cpp b/libinput/connection.cpp index 104847aba..bb299d4ce 100644 --- a/libinput/connection.cpp +++ b/libinput/connection.cpp @@ -1,664 +1,664 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 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 "connection.h" #include "context.h" #include "device.h" #include "events.h" #ifndef KWIN_BUILD_TESTING #include "../screens.h" #endif #include "../logind.h" #include "../udev.h" #include "libinput_logging.h" #include #include #include #include #include #include #include #include namespace KWin { namespace LibInput { class ConnectionAdaptor : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.KWin.InputDeviceManager") Q_PROPERTY(QStringList devicesSysNames READ devicesSysNames CONSTANT) private: Connection *m_con; public: ConnectionAdaptor(Connection *con) : m_con(con) { connect(con, &Connection::deviceAddedSysName, this, &ConnectionAdaptor::deviceAdded, Qt::QueuedConnection); connect(con, &Connection::deviceRemovedSysName, this, &ConnectionAdaptor::deviceRemoved, Qt::QueuedConnection); QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/kde/KWin/InputDevice"), QStringLiteral("org.kde.KWin.InputDeviceManager"), this, QDBusConnection::ExportAllProperties | QDBusConnection::ExportAllSignals ); } - ~ConnectionAdaptor() { + ~ConnectionAdaptor() override { QDBusConnection::sessionBus().unregisterObject(QStringLiteral("/org/kde/KWin/InputDeviceManager")); } QStringList devicesSysNames() { // TODO: is this allowed? directly calling function of object in another thread!? // otherwise use signal-slot mechanism return m_con->devicesSysNames(); } Q_SIGNALS: void deviceAdded(QString sysName); void deviceRemoved(QString sysName); }; Connection *Connection::s_self = nullptr; QPointer Connection::s_thread; static ConnectionAdaptor *s_adaptor = nullptr; static Context *s_context = nullptr; static quint32 toLibinputLEDS(Xkb::LEDs leds) { quint32 libinputLeds = 0; if (leds.testFlag(Xkb::LED::NumLock)) { libinputLeds = libinputLeds | LIBINPUT_LED_NUM_LOCK; } if (leds.testFlag(Xkb::LED::CapsLock)) { libinputLeds = libinputLeds | LIBINPUT_LED_CAPS_LOCK; } if (leds.testFlag(Xkb::LED::ScrollLock)) { libinputLeds = libinputLeds | LIBINPUT_LED_SCROLL_LOCK; } return libinputLeds; } Connection::Connection(QObject *parent) : Connection(nullptr, parent) { // only here to fix build, using will crash, BUG 343529 } void Connection::createThread() { if (s_thread) { return; } s_thread = new QThread(); s_thread->setObjectName(QStringLiteral("libinput-connection")); s_thread->start(); } Connection *Connection::create(QObject *parent) { Q_ASSERT(!s_self); static Udev s_udev; if (!s_udev.isValid()) { qCWarning(KWIN_LIBINPUT) << "Failed to initialize udev"; return nullptr; } if (!s_context) { s_context = new Context(s_udev); if (!s_context->isValid()) { qCWarning(KWIN_LIBINPUT) << "Failed to create context from udev"; delete s_context; s_context = nullptr; return nullptr; } if (!s_context->assignSeat(LogindIntegration::self()->seat().toUtf8().constData())) { qCWarning(KWIN_LIBINPUT) << "Failed to assign seat" << LogindIntegration::self()->seat(); delete s_context; s_context = nullptr; return nullptr; } } Connection::createThread(); s_self = new Connection(s_context); s_self->moveToThread(s_thread); QObject::connect(s_thread, &QThread::finished, s_self, &QObject::deleteLater); QObject::connect(s_thread, &QThread::finished, s_thread, &QObject::deleteLater); QObject::connect(parent, &QObject::destroyed, s_thread, &QThread::quit); if (!s_adaptor) { s_adaptor = new ConnectionAdaptor(s_self); } return s_self; } Connection::Connection(Context *input, QObject *parent) : QObject(parent) , m_input(input) , m_notifier(nullptr) , m_mutex(QMutex::Recursive) , m_leds() { Q_ASSERT(m_input); // need to connect to KGlobalSettings as the mouse KCM does not emit a dedicated signal QDBusConnection::sessionBus().connect(QString(), QStringLiteral("/KGlobalSettings"), QStringLiteral("org.kde.KGlobalSettings"), QStringLiteral("notifyChange"), this, SLOT(slotKGlobalSettingsNotifyChange(int,int))); } Connection::~Connection() { delete s_adaptor; s_adaptor = nullptr; s_self = nullptr; delete s_context; s_context = nullptr; } void Connection::setup() { QMetaObject::invokeMethod(this, "doSetup", Qt::QueuedConnection); } void Connection::doSetup() { connect(s_self, &Connection::deviceAdded, s_self, [](Device* device) { emit s_self->deviceAddedSysName(device->sysName()); }); connect(s_self, &Connection::deviceRemoved, s_self, [](Device* device) { emit s_self->deviceRemovedSysName(device->sysName()); }); Q_ASSERT(!m_notifier); m_notifier = new QSocketNotifier(m_input->fileDescriptor(), QSocketNotifier::Read, this); connect(m_notifier, &QSocketNotifier::activated, this, &Connection::handleEvent); LogindIntegration *logind = LogindIntegration::self(); connect(logind, &LogindIntegration::sessionActiveChanged, this, [this](bool active) { if (active) { if (!m_input->isSuspended()) { return; } m_input->resume(); wasSuspended = true; } else { deactivate(); } } ); handleEvent(); } void Connection::deactivate() { if (m_input->isSuspended()) { return; } m_keyboardBeforeSuspend = hasKeyboard(); m_alphaNumericKeyboardBeforeSuspend = hasAlphaNumericKeyboard(); m_pointerBeforeSuspend = hasPointer(); m_touchBeforeSuspend = hasTouch(); m_tabletModeSwitchBeforeSuspend = hasTabletModeSwitch(); m_input->suspend(); handleEvent(); } void Connection::handleEvent() { QMutexLocker locker(&m_mutex); const bool wasEmpty = m_eventQueue.isEmpty(); do { m_input->dispatch(); Event *event = m_input->event(); if (!event) { break; } m_eventQueue << event; } while (true); if (wasEmpty && !m_eventQueue.isEmpty()) { emit eventsRead(); } } void Connection::processEvents() { QMutexLocker locker(&m_mutex); while (!m_eventQueue.isEmpty()) { QScopedPointer event(m_eventQueue.takeFirst()); switch (event->type()) { case LIBINPUT_EVENT_DEVICE_ADDED: { auto device = new Device(event->nativeDevice()); device->moveToThread(s_thread); m_devices << device; if (device->isKeyboard()) { m_keyboard++; if (device->isAlphaNumericKeyboard()) { m_alphaNumericKeyboard++; if (m_alphaNumericKeyboard == 1) { emit hasAlphaNumericKeyboardChanged(true); } } if (m_keyboard == 1) { emit hasKeyboardChanged(true); } } if (device->isPointer()) { m_pointer++; if (m_pointer == 1) { emit hasPointerChanged(true); } } if (device->isTouch()) { m_touch++; if (m_touch == 1) { emit hasTouchChanged(true); } } if (device->isTabletModeSwitch()) { m_tabletModeSwitch++; if (m_tabletModeSwitch == 1) { emit hasTabletModeSwitchChanged(true); } } applyDeviceConfig(device); applyScreenToDevice(device); // enable possible leds libinput_device_led_update(device->device(), static_cast(toLibinputLEDS(m_leds))); emit deviceAdded(device); break; } case LIBINPUT_EVENT_DEVICE_REMOVED: { auto it = std::find_if(m_devices.begin(), m_devices.end(), [&event] (Device *d) { return event->device() == d; } ); if (it == m_devices.end()) { // we don't know this device break; } auto device = *it; m_devices.erase(it); emit deviceRemoved(device); if (device->isKeyboard()) { m_keyboard--; if (device->isAlphaNumericKeyboard()) { m_alphaNumericKeyboard--; if (m_alphaNumericKeyboard == 0) { emit hasAlphaNumericKeyboardChanged(false); } } if (m_keyboard == 0) { emit hasKeyboardChanged(false); } } if (device->isPointer()) { m_pointer--; if (m_pointer == 0) { emit hasPointerChanged(false); } } if (device->isTouch()) { m_touch--; if (m_touch == 0) { emit hasTouchChanged(false); } } if (device->isTabletModeSwitch()) { m_tabletModeSwitch--; if (m_tabletModeSwitch == 0) { emit hasTabletModeSwitchChanged(false); } } device->deleteLater(); break; } case LIBINPUT_EVENT_KEYBOARD_KEY: { KeyEvent *ke = static_cast(event.data()); emit keyChanged(ke->key(), ke->state(), ke->time(), ke->device()); break; } case LIBINPUT_EVENT_POINTER_AXIS: { PointerEvent *pe = static_cast(event.data()); const auto axes = pe->axis(); for (const InputRedirection::PointerAxis &axis : axes) { emit pointerAxisChanged(axis, pe->axisValue(axis), pe->discreteAxisValue(axis), pe->axisSource(), pe->time(), pe->device()); } break; } case LIBINPUT_EVENT_POINTER_BUTTON: { PointerEvent *pe = static_cast(event.data()); emit pointerButtonChanged(pe->button(), pe->buttonState(), pe->time(), pe->device()); break; } case LIBINPUT_EVENT_POINTER_MOTION: { PointerEvent *pe = static_cast(event.data()); auto delta = pe->delta(); auto deltaNonAccel = pe->deltaUnaccelerated(); quint32 latestTime = pe->time(); quint64 latestTimeUsec = pe->timeMicroseconds(); auto it = m_eventQueue.begin(); while (it != m_eventQueue.end()) { if ((*it)->type() == LIBINPUT_EVENT_POINTER_MOTION) { QScopedPointer p(static_cast(*it)); delta += p->delta(); deltaNonAccel += p->deltaUnaccelerated(); latestTime = p->time(); latestTimeUsec = p->timeMicroseconds(); it = m_eventQueue.erase(it); } else { break; } } emit pointerMotion(delta, deltaNonAccel, latestTime, latestTimeUsec, pe->device()); break; } case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE: { PointerEvent *pe = static_cast(event.data()); emit pointerMotionAbsolute(pe->absolutePos(), pe->absolutePos(m_size), pe->time(), pe->device()); break; } case LIBINPUT_EVENT_TOUCH_DOWN: { #ifndef KWIN_BUILD_TESTING TouchEvent *te = static_cast(event.data()); const auto &geo = screens()->geometry(te->device()->screenId()); emit touchDown(te->id(), geo.topLeft() + te->absolutePos(geo.size()), te->time(), te->device()); break; #endif } case LIBINPUT_EVENT_TOUCH_UP: { TouchEvent *te = static_cast(event.data()); emit touchUp(te->id(), te->time(), te->device()); break; } case LIBINPUT_EVENT_TOUCH_MOTION: { #ifndef KWIN_BUILD_TESTING TouchEvent *te = static_cast(event.data()); const auto &geo = screens()->geometry(te->device()->screenId()); emit touchMotion(te->id(), geo.topLeft() + te->absolutePos(geo.size()), te->time(), te->device()); break; #endif } case LIBINPUT_EVENT_TOUCH_CANCEL: { emit touchCanceled(event->device()); break; } case LIBINPUT_EVENT_TOUCH_FRAME: { emit touchFrame(event->device()); break; } case LIBINPUT_EVENT_GESTURE_PINCH_BEGIN: { PinchGestureEvent *pe = static_cast(event.data()); emit pinchGestureBegin(pe->fingerCount(), pe->time(), pe->device()); break; } case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE: { PinchGestureEvent *pe = static_cast(event.data()); emit pinchGestureUpdate(pe->scale(), pe->angleDelta(), pe->delta(), pe->time(), pe->device()); break; } case LIBINPUT_EVENT_GESTURE_PINCH_END: { PinchGestureEvent *pe = static_cast(event.data()); if (pe->isCancelled()) { emit pinchGestureCancelled(pe->time(), pe->device()); } else { emit pinchGestureEnd(pe->time(), pe->device()); } break; } case LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN: { SwipeGestureEvent *se = static_cast(event.data()); emit swipeGestureBegin(se->fingerCount(), se->time(), se->device()); break; } case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE: { SwipeGestureEvent *se = static_cast(event.data()); emit swipeGestureUpdate(se->delta(), se->time(), se->device()); break; } case LIBINPUT_EVENT_GESTURE_SWIPE_END: { SwipeGestureEvent *se = static_cast(event.data()); if (se->isCancelled()) { emit swipeGestureCancelled(se->time(), se->device()); } else { emit swipeGestureEnd(se->time(), se->device()); } break; } case LIBINPUT_EVENT_SWITCH_TOGGLE: { SwitchEvent *se = static_cast(event.data()); switch (se->state()) { case SwitchEvent::State::Off: emit switchToggledOff(se->time(), se->timeMicroseconds(), se->device()); break; case SwitchEvent::State::On: emit switchToggledOn(se->time(), se->timeMicroseconds(), se->device()); break; default: Q_UNREACHABLE(); } break; } default: // nothing break; } } if (wasSuspended) { if (m_keyboardBeforeSuspend && !m_keyboard) { emit hasKeyboardChanged(false); } if (m_alphaNumericKeyboardBeforeSuspend && !m_alphaNumericKeyboard) { emit hasAlphaNumericKeyboardChanged(false); } if (m_pointerBeforeSuspend && !m_pointer) { emit hasPointerChanged(false); } if (m_touchBeforeSuspend && !m_touch) { emit hasTouchChanged(false); } if (m_tabletModeSwitchBeforeSuspend && !m_tabletModeSwitch) { emit hasTabletModeSwitchChanged(false); } wasSuspended = false; } } void Connection::setScreenSize(const QSize &size) { m_size = size; } void Connection::updateScreens() { QMutexLocker locker(&m_mutex); for (auto device: qAsConst(m_devices)) { applyScreenToDevice(device); } } void Connection::applyScreenToDevice(Device *device) { #ifndef KWIN_BUILD_TESTING QMutexLocker locker(&m_mutex); if (!device->isTouch()) { return; } int id = -1; // let's try to find a screen for it if (screens()->count() == 1) { id = 0; } if (id == -1 && !device->outputName().isEmpty()) { // we have an output name, try to find a screen with matching name for (int i = 0; i < screens()->count(); i++) { if (screens()->name(i) == device->outputName()) { id = i; break; } } } if (id == -1) { // do we have an internal screen? int internalId = -1; for (int i = 0; i < screens()->count(); i++) { if (screens()->isInternal(i)) { internalId = i; break; } } auto testScreenMatches = [device] (int id) { const auto &size = device->size(); const auto &screenSize = screens()->physicalSize(id); return std::round(size.width()) == std::round(screenSize.width()) && std::round(size.height()) == std::round(screenSize.height()); }; if (internalId != -1 && testScreenMatches(internalId)) { id = internalId; } // let's compare all screens for size for (int i = 0; i < screens()->count(); i++) { if (testScreenMatches(i)) { id = i; break; } } if (id == -1) { // still not found if (internalId != -1) { // we have an internal id, so let's use that id = internalId; } else { // just take first screen, we have no clue id = 0; } } } device->setScreenId(id); device->setOrientation(screens()->orientation(id)); #else Q_UNUSED(device) #endif } bool Connection::isSuspended() const { if (!s_context) { return false; } return s_context->isSuspended(); } void Connection::applyDeviceConfig(Device *device) { // pass configuration to Device device->setConfig(m_config->group("Libinput").group(QString::number(device->vendor())).group(QString::number(device->product())).group(device->name())); device->loadConfiguration(); } void Connection::slotKGlobalSettingsNotifyChange(int type, int arg) { if (type == 3 /**SettingsChanged**/ && arg == 0 /** SETTINGS_MOUSE **/) { m_config->reparseConfiguration(); for (auto it = m_devices.constBegin(), end = m_devices.constEnd(); it != end; ++it) { if ((*it)->isPointer()) { applyDeviceConfig(*it); } } } } void Connection::toggleTouchpads() { bool changed = false; m_touchpadsEnabled = !m_touchpadsEnabled; for (auto it = m_devices.constBegin(); it != m_devices.constEnd(); ++it) { auto device = *it; if (!device->isTouchpad()) { continue; } const bool old = device->isEnabled(); device->setEnabled(m_touchpadsEnabled); if (old != device->isEnabled()) { changed = true; } } if (changed) { // send OSD message QDBusMessage msg = QDBusMessage::createMethodCall( QStringLiteral("org.kde.plasmashell"), QStringLiteral("/org/kde/osdService"), QStringLiteral("org.kde.osdService"), QStringLiteral("touchpadEnabledChanged") ); msg.setArguments({m_touchpadsEnabled}); QDBusConnection::sessionBus().asyncCall(msg); } } void Connection::enableTouchpads() { if (m_touchpadsEnabled) { return; } toggleTouchpads(); } void Connection::disableTouchpads() { if (!m_touchpadsEnabled) { return; } toggleTouchpads(); } void Connection::updateLEDs(Xkb::LEDs leds) { if (m_leds == leds) { return; } m_leds = leds; // update on devices const libinput_led l = static_cast(toLibinputLEDS(leds)); for (auto it = m_devices.constBegin(), end = m_devices.constEnd(); it != end; ++it) { libinput_device_led_update((*it)->device(), l); } } QStringList Connection::devicesSysNames() const { QStringList sl; foreach (Device *d, m_devices) { sl.append(d->sysName()); } return sl; } } } #include "connection.moc" diff --git a/libinput/connection.h b/libinput/connection.h index 9c701141d..83c5cf0aa 100644 --- a/libinput/connection.h +++ b/libinput/connection.h @@ -1,173 +1,173 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 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_LIBINPUT_CONNECTION_H #define KWIN_LIBINPUT_CONNECTION_H #include "../input.h" #include "../keyboard_input.h" #include #include #include #include #include #include #include class QSocketNotifier; class QThread; namespace KWin { namespace LibInput { class Event; class Device; class Context; class KWIN_EXPORT Connection : public QObject { Q_OBJECT public: - ~Connection(); + ~Connection() override; void setInputConfig(const KSharedConfigPtr &config) { m_config = config; } void setup(); /** * Sets the screen @p size. This is needed for mapping absolute pointer events to * the screen data. **/ void setScreenSize(const QSize &size); void updateScreens(); bool hasKeyboard() const { return m_keyboard > 0; } bool hasAlphaNumericKeyboard() const { return m_alphaNumericKeyboard > 0; } bool hasTouch() const { return m_touch > 0; } bool hasPointer() const { return m_pointer > 0; } bool hasTabletModeSwitch() const { return m_tabletModeSwitch > 0; } bool isSuspended() const; void deactivate(); void processEvents(); void toggleTouchpads(); void enableTouchpads(); void disableTouchpads(); QVector devices() const { return m_devices; } QStringList devicesSysNames() const; void updateLEDs(KWin::Xkb::LEDs leds); static void createThread(); Q_SIGNALS: void keyChanged(quint32 key, KWin::InputRedirection::KeyboardKeyState, quint32 time, KWin::LibInput::Device *device); void pointerButtonChanged(quint32 button, KWin::InputRedirection::PointerButtonState state, quint32 time, KWin::LibInput::Device *device); void pointerMotionAbsolute(QPointF orig, QPointF screen, quint32 time, KWin::LibInput::Device *device); void pointerMotion(const QSizeF &delta, const QSizeF &deltaNonAccelerated, quint32 time, quint64 timeMicroseconds, KWin::LibInput::Device *device); void pointerAxisChanged(KWin::InputRedirection::PointerAxis axis, qreal delta, qint32 discreteDelta, KWin::InputRedirection::PointerAxisSource source, quint32 time, KWin::LibInput::Device *device); void touchFrame(KWin::LibInput::Device *device); void touchCanceled(KWin::LibInput::Device *device); void touchDown(qint32 id, const QPointF &absolutePos, quint32 time, KWin::LibInput::Device *device); void touchUp(qint32 id, quint32 time, KWin::LibInput::Device *device); void touchMotion(qint32 id, const QPointF &absolutePos, quint32 time, KWin::LibInput::Device *device); void hasKeyboardChanged(bool); void hasAlphaNumericKeyboardChanged(bool); void hasPointerChanged(bool); void hasTouchChanged(bool); void hasTabletModeSwitchChanged(bool); void deviceAdded(KWin::LibInput::Device *); void deviceRemoved(KWin::LibInput::Device *); void deviceAddedSysName(QString); void deviceRemovedSysName(QString); void swipeGestureBegin(int fingerCount, quint32 time, KWin::LibInput::Device *device); void swipeGestureUpdate(const QSizeF &delta, quint32 time, KWin::LibInput::Device *device); void swipeGestureEnd(quint32 time, KWin::LibInput::Device *device); void swipeGestureCancelled(quint32 time, KWin::LibInput::Device *device); void pinchGestureBegin(int fingerCount, quint32 time, KWin::LibInput::Device *device); void pinchGestureUpdate(qreal scale, qreal angleDelta, const QSizeF &delta, quint32 time, KWin::LibInput::Device *device); void pinchGestureEnd(quint32 time, KWin::LibInput::Device *device); void pinchGestureCancelled(quint32 time, KWin::LibInput::Device *device); void switchToggledOn(quint32 time, quint64 timeMicroseconds, KWin::LibInput::Device *device); void switchToggledOff(quint32 time, quint64 timeMicroseconds, KWin::LibInput::Device *device); void eventsRead(); private Q_SLOTS: void doSetup(); void slotKGlobalSettingsNotifyChange(int type, int arg); private: Connection(Context *input, QObject *parent = nullptr); void handleEvent(); void applyDeviceConfig(Device *device); void applyScreenToDevice(Device *device); Context *m_input; QSocketNotifier *m_notifier; QSize m_size; int m_keyboard = 0; int m_alphaNumericKeyboard = 0; int m_pointer = 0; int m_touch = 0; int m_tabletModeSwitch = 0; bool m_keyboardBeforeSuspend = false; bool m_alphaNumericKeyboardBeforeSuspend = false; bool m_pointerBeforeSuspend = false; bool m_touchBeforeSuspend = false; bool m_tabletModeSwitchBeforeSuspend = false; QMutex m_mutex; QVector m_eventQueue; bool wasSuspended = false; QVector m_devices; KSharedConfigPtr m_config; bool m_touchpadsEnabled = true; Xkb::LEDs m_leds; KWIN_SINGLETON(Connection) static QPointer s_thread; }; } } #endif diff --git a/libinput/device.h b/libinput/device.h index 0c827ad2e..04c103e1c 100644 --- a/libinput/device.h +++ b/libinput/device.h @@ -1,582 +1,582 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2016 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_LIBINPUT_DEVICE_H #define KWIN_LIBINPUT_DEVICE_H #include #include #include #include #include #include #include "kwin_export.h" struct libinput_device; namespace KWin { namespace LibInput { enum class ConfigKey; class KWIN_EXPORT Device : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.KWin.InputDevice") // // general Q_PROPERTY(bool keyboard READ isKeyboard CONSTANT) Q_PROPERTY(bool alphaNumericKeyboard READ isAlphaNumericKeyboard CONSTANT) Q_PROPERTY(bool pointer READ isPointer CONSTANT) Q_PROPERTY(bool touchpad READ isTouchpad CONSTANT) Q_PROPERTY(bool touch READ isTouch CONSTANT) Q_PROPERTY(bool tabletTool READ isTabletTool CONSTANT) Q_PROPERTY(bool tabletPad READ isTabletPad CONSTANT) Q_PROPERTY(bool gestureSupport READ supportsGesture CONSTANT) Q_PROPERTY(QString name READ name CONSTANT) Q_PROPERTY(QString sysName READ sysName CONSTANT) Q_PROPERTY(QString outputName READ outputName CONSTANT) Q_PROPERTY(QSizeF size READ size CONSTANT) Q_PROPERTY(quint32 product READ product CONSTANT) Q_PROPERTY(quint32 vendor READ vendor CONSTANT) Q_PROPERTY(bool supportsDisableEvents READ supportsDisableEvents CONSTANT) Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) // // advanced Q_PROPERTY(int supportedButtons READ supportedButtons CONSTANT) Q_PROPERTY(bool supportsCalibrationMatrix READ supportsCalibrationMatrix CONSTANT) Q_PROPERTY(bool supportsLeftHanded READ supportsLeftHanded CONSTANT) Q_PROPERTY(bool leftHandedEnabledByDefault READ leftHandedEnabledByDefault CONSTANT) Q_PROPERTY(bool leftHanded READ isLeftHanded WRITE setLeftHanded NOTIFY leftHandedChanged) Q_PROPERTY(bool supportsDisableEventsOnExternalMouse READ supportsDisableEventsOnExternalMouse CONSTANT) Q_PROPERTY(bool supportsDisableWhileTyping READ supportsDisableWhileTyping CONSTANT) Q_PROPERTY(bool disableWhileTypingEnabledByDefault READ disableWhileTypingEnabledByDefault CONSTANT) Q_PROPERTY(bool disableWhileTyping READ isDisableWhileTyping WRITE setDisableWhileTyping NOTIFY disableWhileTypingChanged) // // acceleration speed and profile Q_PROPERTY(bool supportsPointerAcceleration READ supportsPointerAcceleration CONSTANT) Q_PROPERTY(qreal defaultPointerAcceleration READ defaultPointerAcceleration CONSTANT) Q_PROPERTY(qreal pointerAcceleration READ pointerAcceleration WRITE setPointerAcceleration NOTIFY pointerAccelerationChanged) Q_PROPERTY(bool supportsPointerAccelerationProfileFlat READ supportsPointerAccelerationProfileFlat CONSTANT) Q_PROPERTY(bool defaultPointerAccelerationProfileFlat READ defaultPointerAccelerationProfileFlat CONSTANT) Q_PROPERTY(bool pointerAccelerationProfileFlat READ pointerAccelerationProfileFlat WRITE setPointerAccelerationProfileFlat NOTIFY pointerAccelerationProfileChanged) Q_PROPERTY(bool supportsPointerAccelerationProfileAdaptive READ supportsPointerAccelerationProfileAdaptive CONSTANT) Q_PROPERTY(bool defaultPointerAccelerationProfileAdaptive READ defaultPointerAccelerationProfileAdaptive CONSTANT) Q_PROPERTY(bool pointerAccelerationProfileAdaptive READ pointerAccelerationProfileAdaptive WRITE setPointerAccelerationProfileAdaptive NOTIFY pointerAccelerationProfileChanged) // // tapping Q_PROPERTY(int tapFingerCount READ tapFingerCount CONSTANT) Q_PROPERTY(bool tapToClickEnabledByDefault READ tapToClickEnabledByDefault CONSTANT) Q_PROPERTY(bool tapToClick READ isTapToClick WRITE setTapToClick NOTIFY tapToClickChanged) Q_PROPERTY(bool supportsLmrTapButtonMap READ supportsLmrTapButtonMap CONSTANT) Q_PROPERTY(bool lmrTapButtonMapEnabledByDefault READ lmrTapButtonMapEnabledByDefault CONSTANT) Q_PROPERTY(bool lmrTapButtonMap READ lmrTapButtonMap WRITE setLmrTapButtonMap NOTIFY tapButtonMapChanged) Q_PROPERTY(bool tapAndDragEnabledByDefault READ tapAndDragEnabledByDefault CONSTANT) Q_PROPERTY(bool tapAndDrag READ isTapAndDrag WRITE setTapAndDrag NOTIFY tapAndDragChanged) Q_PROPERTY(bool tapDragLockEnabledByDefault READ tapDragLockEnabledByDefault CONSTANT) Q_PROPERTY(bool tapDragLock READ isTapDragLock WRITE setTapDragLock NOTIFY tapDragLockChanged) Q_PROPERTY(bool supportsMiddleEmulation READ supportsMiddleEmulation CONSTANT) Q_PROPERTY(bool middleEmulationEnabledByDefault READ middleEmulationEnabledByDefault CONSTANT) Q_PROPERTY(bool middleEmulation READ isMiddleEmulation WRITE setMiddleEmulation NOTIFY middleEmulationChanged) // // scrolling Q_PROPERTY(bool supportsNaturalScroll READ supportsNaturalScroll CONSTANT) Q_PROPERTY(bool naturalScrollEnabledByDefault READ naturalScrollEnabledByDefault CONSTANT) Q_PROPERTY(bool naturalScroll READ isNaturalScroll WRITE setNaturalScroll NOTIFY naturalScrollChanged) Q_PROPERTY(bool supportsScrollTwoFinger READ supportsScrollTwoFinger CONSTANT) Q_PROPERTY(bool scrollTwoFingerEnabledByDefault READ scrollTwoFingerEnabledByDefault CONSTANT) Q_PROPERTY(bool scrollTwoFinger READ isScrollTwoFinger WRITE setScrollTwoFinger NOTIFY scrollMethodChanged) Q_PROPERTY(bool supportsScrollEdge READ supportsScrollEdge CONSTANT) Q_PROPERTY(bool scrollEdgeEnabledByDefault READ scrollEdgeEnabledByDefault CONSTANT) Q_PROPERTY(bool scrollEdge READ isScrollEdge WRITE setScrollEdge NOTIFY scrollMethodChanged) Q_PROPERTY(bool supportsScrollOnButtonDown READ supportsScrollOnButtonDown CONSTANT) Q_PROPERTY(bool scrollOnButtonDownEnabledByDefault READ scrollOnButtonDownEnabledByDefault CONSTANT) Q_PROPERTY(quint32 defaultScrollButton READ defaultScrollButton CONSTANT) Q_PROPERTY(bool scrollOnButtonDown READ isScrollOnButtonDown WRITE setScrollOnButtonDown NOTIFY scrollMethodChanged) Q_PROPERTY(quint32 scrollButton READ scrollButton WRITE setScrollButton NOTIFY scrollButtonChanged) // switches Q_PROPERTY(bool switchDevice READ isSwitch CONSTANT) Q_PROPERTY(bool lidSwitch READ isLidSwitch CONSTANT) Q_PROPERTY(bool tabletModeSwitch READ isTabletModeSwitch CONSTANT) // Click Methods Q_PROPERTY(bool supportsClickMethodAreas READ supportsClickMethodAreas CONSTANT) Q_PROPERTY(bool defaultClickMethodAreas READ defaultClickMethodAreas CONSTANT) Q_PROPERTY(bool clickMethodAreas READ isClickMethodAreas WRITE setClickMethodAreas NOTIFY clickMethodChanged) Q_PROPERTY(bool supportsClickMethodClickfinger READ supportsClickMethodClickfinger CONSTANT) Q_PROPERTY(bool defaultClickMethodClickfinger READ defaultClickMethodClickfinger CONSTANT) Q_PROPERTY(bool clickMethodClickfinger READ isClickMethodClickfinger WRITE setClickMethodClickfinger NOTIFY clickMethodChanged) public: explicit Device(libinput_device *device, QObject *parent = nullptr); - virtual ~Device(); + ~Device() override; bool isKeyboard() const { return m_keyboard; } bool isAlphaNumericKeyboard() const { return m_alphaNumericKeyboard; } bool isPointer() const { return m_pointer; } bool isTouchpad() const{ return m_pointer && // ignore all combined devices. E.g. a touchpad on a keyboard we don't want to toggle // as that would result in the keyboard going off as well !(m_keyboard || m_touch || m_tabletPad || m_tabletTool) && // is this a touch pad? We don't really know, let's do some assumptions (m_tapFingerCount > 0 || m_supportsDisableWhileTyping || m_supportsDisableEventsOnExternalMouse); } bool isTouch() const { return m_touch; } bool isTabletTool() const { return m_tabletTool; } bool isTabletPad() const { return m_tabletPad; } bool supportsGesture() const { return m_supportsGesture; } QString name() const { return m_name; } QString sysName() const { return m_sysName; } QString outputName() const { return m_outputName; } QSizeF size() const { return m_size; } quint32 product() const { return m_product; } quint32 vendor() const { return m_vendor; } Qt::MouseButtons supportedButtons() const { return m_supportedButtons; } int tapFingerCount() const { return m_tapFingerCount; } bool tapToClickEnabledByDefault() const { return m_tapToClickEnabledByDefault; } bool isTapToClick() const { return m_tapToClick; } /** * Set the Device to tap to click if @p set is @c true. **/ void setTapToClick(bool set); bool tapAndDragEnabledByDefault() const { return m_tapAndDragEnabledByDefault; } bool isTapAndDrag() const { return m_tapAndDrag; } void setTapAndDrag(bool set); bool tapDragLockEnabledByDefault() const { return m_tapDragLockEnabledByDefault; } bool isTapDragLock() const { return m_tapDragLock; } void setTapDragLock(bool set); bool supportsDisableWhileTyping() const { return m_supportsDisableWhileTyping; } bool disableWhileTypingEnabledByDefault() const { return m_disableWhileTypingEnabledByDefault; } bool supportsPointerAcceleration() const { return m_supportsPointerAcceleration; } bool supportsLeftHanded() const { return m_supportsLeftHanded; } bool supportsCalibrationMatrix() const { return m_supportsCalibrationMatrix; } bool supportsDisableEvents() const { return m_supportsDisableEvents; } bool supportsDisableEventsOnExternalMouse() const { return m_supportsDisableEventsOnExternalMouse; } bool supportsMiddleEmulation() const { return m_supportsMiddleEmulation; } bool supportsNaturalScroll() const { return m_supportsNaturalScroll; } bool supportsScrollTwoFinger() const { return (m_supportedScrollMethods & LIBINPUT_CONFIG_SCROLL_2FG); } bool supportsScrollEdge() const { return (m_supportedScrollMethods & LIBINPUT_CONFIG_SCROLL_EDGE); } bool supportsScrollOnButtonDown() const { return (m_supportedScrollMethods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN); } bool leftHandedEnabledByDefault() const { return m_leftHandedEnabledByDefault; } bool middleEmulationEnabledByDefault() const { return m_middleEmulationEnabledByDefault; } bool naturalScrollEnabledByDefault() const { return m_naturalScrollEnabledByDefault; } enum libinput_config_scroll_method defaultScrollMethod() const { return m_defaultScrollMethod; } quint32 defaultScrollMethodToInt() const { return (quint32) m_defaultScrollMethod; } bool scrollTwoFingerEnabledByDefault() const { return m_defaultScrollMethod == LIBINPUT_CONFIG_SCROLL_2FG; } bool scrollEdgeEnabledByDefault() const { return m_defaultScrollMethod == LIBINPUT_CONFIG_SCROLL_EDGE; } bool scrollOnButtonDownEnabledByDefault() const { return m_defaultScrollMethod == LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; } bool supportsLmrTapButtonMap() const { return m_tapFingerCount > 1; } bool lmrTapButtonMapEnabledByDefault() const { return m_defaultTapButtonMap == LIBINPUT_CONFIG_TAP_MAP_LMR; } void setLmrTapButtonMap(bool set); bool lmrTapButtonMap() const { return m_tapButtonMap & LIBINPUT_CONFIG_TAP_MAP_LMR; } quint32 defaultScrollButton() const { return m_defaultScrollButton; } bool isMiddleEmulation() const { return m_middleEmulation; } void setMiddleEmulation(bool set); bool isNaturalScroll() const { return m_naturalScroll; } void setNaturalScroll(bool set); void setScrollMethod(bool set, enum libinput_config_scroll_method method); bool isScrollTwoFinger() const { return m_scrollMethod & LIBINPUT_CONFIG_SCROLL_2FG; } void setScrollTwoFinger(bool set) { setScrollMethod(set, LIBINPUT_CONFIG_SCROLL_2FG); } bool isScrollEdge() const { return m_scrollMethod & LIBINPUT_CONFIG_SCROLL_EDGE; } void setScrollEdge(bool set) { setScrollMethod(set, LIBINPUT_CONFIG_SCROLL_EDGE); } bool isScrollOnButtonDown() const { return m_scrollMethod & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; } void setScrollOnButtonDown(bool set) { setScrollMethod(set, LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN); } void activateScrollMethodFromInt(quint32 method) { setScrollMethod(true, (libinput_config_scroll_method) method); } quint32 scrollButton() const { return m_scrollButton; } void setScrollButton(quint32 button); void setDisableWhileTyping(bool set); bool isDisableWhileTyping() const { return m_disableWhileTyping; } bool isLeftHanded() const { return m_leftHanded; } /** * Sets the Device to left handed mode if @p set is @c true. * If @p set is @c false the device is set to right handed mode **/ void setLeftHanded(bool set); qreal defaultPointerAcceleration() const { return m_defaultPointerAcceleration; } qreal pointerAcceleration() const { return m_pointerAcceleration; } /** * @param acceleration mapped to range [-1,1] with -1 being the slowest, 1 being the fastest supported acceleration. **/ void setPointerAcceleration(qreal acceleration); void setPointerAccelerationFromString(QString acceleration) { setPointerAcceleration(acceleration.toDouble()); } QString defaultPointerAccelerationToString() const { return QString::number(m_pointerAcceleration, 'f', 3); } bool supportsPointerAccelerationProfileFlat() const { return (m_supportedPointerAccelerationProfiles & LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT); } bool supportsPointerAccelerationProfileAdaptive() const { return (m_supportedPointerAccelerationProfiles & LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); } bool defaultPointerAccelerationProfileFlat() const { return (m_defaultPointerAccelerationProfile & LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT); } bool defaultPointerAccelerationProfileAdaptive() const { return (m_defaultPointerAccelerationProfile & LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); } bool pointerAccelerationProfileFlat() const { return (m_pointerAccelerationProfile & LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT); } bool pointerAccelerationProfileAdaptive() const { return (m_pointerAccelerationProfile & LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); } void setPointerAccelerationProfile(bool set, enum libinput_config_accel_profile profile); void setPointerAccelerationProfileFlat(bool set) { setPointerAccelerationProfile(set, LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT); } void setPointerAccelerationProfileAdaptive(bool set) { setPointerAccelerationProfile(set, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); } void setPointerAccelerationProfileFromInt(quint32 profile) { setPointerAccelerationProfile(true, (libinput_config_accel_profile) profile); } quint32 defaultPointerAccelerationProfileToInt() const { return (quint32) m_defaultPointerAccelerationProfile; } bool supportsClickMethodAreas() const { return (m_supportedClickMethods & LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS); } bool defaultClickMethodAreas() const { return (m_defaultClickMethod == LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS); } bool isClickMethodAreas() const { return (m_clickMethod == LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS); } bool supportsClickMethodClickfinger() const { return (m_supportedClickMethods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER); } bool defaultClickMethodClickfinger() const { return (m_defaultClickMethod == LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER); } bool isClickMethodClickfinger() const { return (m_clickMethod == LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER); } void setClickMethod(bool set, enum libinput_config_click_method method); void setClickMethodAreas(bool set) { setClickMethod(set, LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS); } void setClickMethodClickfinger(bool set) { setClickMethod(set, LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER); } void setClickMethodFromInt(quint32 method) { setClickMethod(true, (libinput_config_click_method) method); } quint32 defaultClickMethodToInt() const { return (quint32) m_defaultClickMethod; } bool isEnabled() const { return m_enabled; } void setEnabled(bool enabled); libinput_device *device() const { return m_device; } /** * Sets the @p config to load the Device configuration from and to store each * successful Device configuration. **/ void setConfig(const KConfigGroup &config) { m_config = config; } /** * The id of the screen in KWin identifiers. Set from KWin through setScreenId. **/ int screenId() const { return m_screenId; } /** * Sets the KWin screen id for the device **/ void setScreenId(int screenId) { m_screenId = screenId; } void setOrientation(Qt::ScreenOrientation orientation); /** * Loads the configuration and applies it to the Device **/ void loadConfiguration(); bool isSwitch() const { return m_switch; } bool isLidSwitch() const { return m_lidSwitch; } bool isTabletModeSwitch() const { return m_tabletSwitch; } /** * All created Devices **/ static QVector devices() { return s_devices; } /** * Gets the Device for @p native. @c null if there is no Device for @p native. **/ static Device *getDevice(libinput_device *native); Q_SIGNALS: void tapButtonMapChanged(); void leftHandedChanged(); void disableWhileTypingChanged(); void pointerAccelerationChanged(); void pointerAccelerationProfileChanged(); void enabledChanged(); void tapToClickChanged(); void tapAndDragChanged(); void tapDragLockChanged(); void middleEmulationChanged(); void naturalScrollChanged(); void scrollMethodChanged(); void scrollButtonChanged(); void clickMethodChanged(); private: template void writeEntry(const ConfigKey &key, const T &value); template void readEntry(const QByteArray &key, const Setter &s, const T &defaultValue = T()); libinput_device *m_device; bool m_keyboard; bool m_alphaNumericKeyboard = false; bool m_pointer; bool m_touch; bool m_tabletTool; bool m_tabletPad; bool m_supportsGesture; bool m_switch = false; bool m_lidSwitch = false; bool m_tabletSwitch = false; QString m_name; QString m_sysName; QString m_outputName; QSizeF m_size; quint32 m_product; quint32 m_vendor; Qt::MouseButtons m_supportedButtons = Qt::NoButton; int m_tapFingerCount; enum libinput_config_tap_button_map m_defaultTapButtonMap; enum libinput_config_tap_button_map m_tapButtonMap; bool m_tapToClickEnabledByDefault; bool m_tapToClick; bool m_tapAndDragEnabledByDefault; bool m_tapAndDrag; bool m_tapDragLockEnabledByDefault; bool m_tapDragLock; bool m_supportsDisableWhileTyping; bool m_supportsPointerAcceleration; bool m_supportsLeftHanded; bool m_supportsCalibrationMatrix; bool m_supportsDisableEvents; bool m_supportsDisableEventsOnExternalMouse; bool m_supportsMiddleEmulation; bool m_supportsNaturalScroll; quint32 m_supportedScrollMethods; bool m_supportsScrollEdge; bool m_supportsScrollOnButtonDown; bool m_leftHandedEnabledByDefault; bool m_middleEmulationEnabledByDefault; bool m_naturalScrollEnabledByDefault; enum libinput_config_scroll_method m_defaultScrollMethod; quint32 m_defaultScrollButton; bool m_disableWhileTypingEnabledByDefault; bool m_disableWhileTyping; bool m_middleEmulation; bool m_leftHanded; bool m_naturalScroll; enum libinput_config_scroll_method m_scrollMethod; quint32 m_scrollButton; qreal m_defaultPointerAcceleration; qreal m_pointerAcceleration; quint32 m_supportedPointerAccelerationProfiles; enum libinput_config_accel_profile m_defaultPointerAccelerationProfile; enum libinput_config_accel_profile m_pointerAccelerationProfile; bool m_enabled; KConfigGroup m_config; bool m_loading = false; int m_screenId = 0; Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation; QMatrix4x4 m_defaultCalibrationMatrix; quint32 m_supportedClickMethods; enum libinput_config_click_method m_defaultClickMethod; enum libinput_config_click_method m_clickMethod; static QVector s_devices; }; } } Q_DECLARE_METATYPE(KWin::LibInput::Device*) #endif diff --git a/libinput/events.h b/libinput/events.h index 6f8ab7094..0308656c6 100644 --- a/libinput/events.h +++ b/libinput/events.h @@ -1,203 +1,203 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 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_LIBINPUT_EVENTS_H #define KWIN_LIBINPUT_EVENTS_H #include "../input.h" #include namespace KWin { namespace LibInput { class Device; class Event { public: virtual ~Event(); libinput_event_type type() const; Device *device() const; libinput_device *nativeDevice() const; operator libinput_event*() { return m_event; } operator libinput_event*() const { return m_event; } static Event *create(libinput_event *event); protected: Event(libinput_event *event, libinput_event_type type); private: libinput_event *m_event; libinput_event_type m_type; mutable Device *m_device; }; class KeyEvent : public Event { public: KeyEvent(libinput_event *event); - virtual ~KeyEvent(); + ~KeyEvent() override; uint32_t key() const; InputRedirection::KeyboardKeyState state() const; uint32_t time() const; operator libinput_event_keyboard*() { return m_keyboardEvent; } operator libinput_event_keyboard*() const { return m_keyboardEvent; } private: libinput_event_keyboard *m_keyboardEvent; }; class PointerEvent : public Event { public: PointerEvent(libinput_event* event, libinput_event_type type); - virtual ~PointerEvent(); + ~PointerEvent() override; QPointF absolutePos() const; QPointF absolutePos(const QSize &size) const; QSizeF delta() const; QSizeF deltaUnaccelerated() const; uint32_t button() const; InputRedirection::PointerButtonState buttonState() const; uint32_t time() const; quint64 timeMicroseconds() const; QVector axis() const; qreal axisValue(InputRedirection::PointerAxis a) const; qint32 discreteAxisValue(InputRedirection::PointerAxis axis) const; InputRedirection::PointerAxisSource axisSource() const; operator libinput_event_pointer*() { return m_pointerEvent; } operator libinput_event_pointer*() const { return m_pointerEvent; } private: libinput_event_pointer *m_pointerEvent; }; class TouchEvent : public Event { public: TouchEvent(libinput_event *event, libinput_event_type type); - virtual ~TouchEvent(); + ~TouchEvent() override; quint32 time() const; QPointF absolutePos() const; QPointF absolutePos(const QSize &size) const; qint32 id() const; operator libinput_event_touch*() { return m_touchEvent; } operator libinput_event_touch*() const { return m_touchEvent; } private: libinput_event_touch *m_touchEvent; }; class GestureEvent : public Event { public: - virtual ~GestureEvent(); + ~GestureEvent() override; quint32 time() const; int fingerCount() const; QSizeF delta() const; bool isCancelled() const; operator libinput_event_gesture*() { return m_gestureEvent; } operator libinput_event_gesture*() const { return m_gestureEvent; } protected: GestureEvent(libinput_event *event, libinput_event_type type); libinput_event_gesture *m_gestureEvent; }; class PinchGestureEvent : public GestureEvent { public: PinchGestureEvent(libinput_event *event, libinput_event_type type); - virtual ~PinchGestureEvent(); + ~PinchGestureEvent() override; qreal scale() const; qreal angleDelta() const; }; class SwipeGestureEvent : public GestureEvent { public: SwipeGestureEvent(libinput_event *event, libinput_event_type type); - virtual ~SwipeGestureEvent(); + ~SwipeGestureEvent() override; }; class SwitchEvent : public Event { public: SwitchEvent(libinput_event *event, libinput_event_type type); ~SwitchEvent() override; enum class State { Off, On }; State state() const; quint32 time() const; quint64 timeMicroseconds() const; private: libinput_event_switch *m_switchEvent; }; inline libinput_event_type Event::type() const { return m_type; } } } #endif diff --git a/libkwineffects/kwinanimationeffect.h b/libkwineffects/kwinanimationeffect.h index 93f100023..8211b9dc9 100644 --- a/libkwineffects/kwinanimationeffect.h +++ b/libkwineffects/kwinanimationeffect.h @@ -1,419 +1,419 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2011 Thomas Lübking Copyright (C) 2018 Vlad Zagorodniy 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 ANIMATION_EFFECT_H #define ANIMATION_EFFECT_H #include #include #include #include #include namespace KWin { class KWINEFFECTS_EXPORT FPx2 { public: FPx2() { f[0] = f[1] = 0.0; valid = false; } explicit FPx2(float v) { f[0] = f[1] = v; valid = true; } FPx2(float v1, float v2) { f[0] = v1; f[1] = v2; valid = true; } FPx2(const FPx2 &other) { f[0] = other.f[0]; f[1] = other.f[1]; valid = other.valid; } explicit FPx2(const QPoint &other) { f[0] = other.x(); f[1] = other.y(); valid = true; } explicit FPx2(const QPointF &other) { f[0] = other.x(); f[1] = other.y(); valid = true; } explicit FPx2(const QSize &other) { f[0] = other.width(); f[1] = other.height(); valid = true; } explicit FPx2(const QSizeF &other) { f[0] = other.width(); f[1] = other.height(); valid = true; } inline void invalidate() { valid = false; } inline bool isValid() const { return valid; } inline float operator[](int n) const { return f[n]; } inline QString toString() const { QString ret; if (valid) ret = QString::number(f[0]) + QLatin1Char(',') + QString::number(f[1]); else ret = QString(); return ret; } inline FPx2 &operator=(const FPx2 &other) { f[0] = other.f[0]; f[1] = other.f[1]; valid = other.valid; return *this; } inline FPx2 &operator+=(const FPx2 &other) { f[0] += other[0]; f[1] += other[1]; return *this; } inline FPx2 &operator-=(const FPx2 &other) { f[0] -= other[0]; f[1] -= other[1]; return *this; } inline FPx2 &operator*=(float fl) { f[0] *= fl; f[1] *= fl; return *this; } inline FPx2 &operator/=(float fl) { f[0] /= fl; f[1] /= fl; return *this; } friend inline bool operator==(const FPx2 &f1, const FPx2 &f2) { return f1[0] == f2[0] && f1[1] == f2[1]; } friend inline bool operator!=(const FPx2 &f1, const FPx2 &f2) { return f1[0] != f2[0] || f1[1] != f2[1]; } friend inline const FPx2 operator+(const FPx2 &f1, const FPx2 &f2) { return FPx2( f1[0] + f2[0], f1[1] + f2[1] ); } friend inline const FPx2 operator-(const FPx2 &f1, const FPx2 &f2) { return FPx2( f1[0] - f2[0], f1[1] - f2[1] ); } friend inline const FPx2 operator*(const FPx2 &f, float fl) { return FPx2( f[0] * fl, f[1] * fl ); } friend inline const FPx2 operator*(float fl, const FPx2 &f) { return FPx2( f[0] * fl, f[1] *fl ); } friend inline const FPx2 operator-(const FPx2 &f) { return FPx2( -f[0], -f[1] ); } friend inline const FPx2 operator/(const FPx2 &f, float fl) { return FPx2( f[0] / fl, f[1] / fl ); } inline void set(float v) { f[0] = v; valid = true; } inline void set(float v1, float v2) { f[0] = v1; f[1] = v2; valid = true; } private: float f[2]; bool valid; }; class AniData; class AnimationEffectPrivate; /** * Base class for animation effects. * * AnimationEffect serves as a base class for animation effects. It makes easier * implementing animated transitions, without having to worry about low-level * specific stuff, e.g. referencing and unreferencing deleted windows, scheduling * repaints for the next frame, etc. * * Each animation animates one specific attribute, e.g. size, position, scale, etc. * You can provide your own implementation of the Generic attribute if none of the * standard attributes(e.g. size, position, etc) satisfy your requirements. * * @since 4.8 **/ class KWINEFFECTS_EXPORT AnimationEffect : public Effect { Q_OBJECT public: enum Anchor { Left = 1<<0, Top = 1<<1, Right = 1<<2, Bottom = 1<<3, Horizontal = Left|Right, Vertical = Top|Bottom, Mouse = 1<<4 }; Q_ENUM(Anchor) enum Attribute { Opacity = 0, Brightness, Saturation, Scale, Rotation, Position, Size, Translation, Clip, Generic, CrossFadePrevious, NonFloatBase = Position }; Q_ENUM(Attribute) enum MetaType { SourceAnchor, TargetAnchor, RelativeSourceX, RelativeSourceY, RelativeTargetX, RelativeTargetY, Axis }; Q_ENUM(MetaType) /** * This enum type is used to specify the direction of the animation. * * @since 5.15 **/ enum Direction { Forward, ///< The animation goes from source to target. Backward ///< The animation goes from target to source. }; Q_ENUM(Direction) /** * This enum type is used to specify when the animation should be terminated. * * @since 5.15 **/ enum TerminationFlag { /** * Don't terminate the animation when it reaches source or target position. **/ DontTerminate = 0x00, /** * Terminate the animation when it reaches the source position. An animation * can reach the source position if its direction was changed to go backward * (from target to source). **/ TerminateAtSource = 0x01, /** * Terminate the animation when it reaches the target position. If this flag * is not set, then the animation will be persistent. **/ TerminateAtTarget = 0x02 }; Q_FLAGS(TerminationFlag) Q_DECLARE_FLAGS(TerminationFlags, TerminationFlag) /** * Constructs AnimationEffect. * * Whenever you intend to connect to the EffectsHandler::windowClosed() signal, * do so when reimplementing the constructor. Do not add private slots named * _windowClosed or _windowDeleted! The AnimationEffect connects them right after * the construction. * * If you shadow the _windowDeleted slot (it doesn't matter that it's a private * slot), this will lead to segfaults. * * If you shadow _windowClosed or connect your slot to EffectsHandler::windowClosed() * after _windowClosed was connected, animations for closing windows will fail. **/ AnimationEffect(); - ~AnimationEffect(); + ~AnimationEffect() override; - bool isActive() const; + bool isActive() const override; /** * Gets stored metadata. * * Metadata can be used to store some extra information, for example rotation axis, * etc. The first 24 bits are reserved for the AnimationEffect class, you can use * the last 8 bits for custom hints. In case when you transform a Generic attribute, * all 32 bits are yours and you can use them as you want and read them in your * genericAnimation() implementation. * * @param type The type of the metadata. * @param meta Where the metadata is stored. * @returns Stored metadata. * @since 4.8 **/ static int metaData(MetaType type, uint meta ); /** * Sets metadata. * * @param type The type of the metadata. * @param value The data to be stored. * @param meta Where the metadata will be stored. * @since 4.8 **/ static void setMetaData(MetaType type, uint value, uint &meta ); // Reimplemented from KWin::Effect. - QString debug(const QString ¶meter) const; - virtual void prePaintScreen( ScreenPrePaintData& data, int time ); - virtual void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ); - virtual void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ); - virtual void postPaintScreen(); + QString debug(const QString ¶meter) const override; + void prePaintScreen( ScreenPrePaintData& data, int time ) override; + void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ) override; + void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) override; + void postPaintScreen() override; /** * Gaussian (bumper) animation curve for QEasingCurve. * * @since 4.8 **/ static qreal qecGaussian(qreal progress) { progress = 2*progress - 1; progress *= -5*progress; return qExp(progress); } /** * @since 4.8 **/ static inline qint64 clock() { return s_clock.elapsed(); } protected: /** * Starts an animated transition of any supported attribute. * * @param w The animated window. * @param a The animated attribute. * @param meta Basically a wildcard to carry various extra information, e.g. * the anchor, relativity or rotation axis. You will probably use it when * performing Generic animations. * @param ms How long the transition will last. * @param to The target value. FPx2 is an agnostic two component float type * (like QPointF or QSizeF, but without requiring to be either and supporting * an invalid state). * @param curve How the animation progresses, e.g. Linear progresses constantly * while Exponential start slow and becomes very fast in the end. * @param delay When the animation will start compared to "now" (the window will * remain at the "from" position until then). * @param from The starting value, the default is invalid, ie. the attribute for * the window is not transformed in the beginning. * @param fullScreen Sets this effect as the active full screen effect for the * duration of the animation. * @param keepAlive Whether closed windows should be kept alive during animation. * @returns An ID that you can use to cancel a running animation. * @since 4.8 **/ quint64 animate( EffectWindow *w, Attribute a, uint meta, int ms, FPx2 to, QEasingCurve curve = QEasingCurve(), int delay = 0, FPx2 from = FPx2(), bool fullScreen = false, bool keepAlive = true) { return p_animate(w, a, meta, ms, to, curve, delay, from, false, fullScreen, keepAlive); } /** * Starts a persistent animated transition of any supported attribute. * * This method is equal to animate() with one important difference: * the target value for the attribute is kept until you call cancel(). * * @param w The animated window. * @param a The animated attribute. * @param meta Basically a wildcard to carry various extra information, e.g. * the anchor, relativity or rotation axis. You will probably use it when * performing Generic animations. * @param ms How long the transition will last. * @param to The target value. FPx2 is an agnostic two component float type * (like QPointF or QSizeF, but without requiring to be either and supporting * an invalid state). * @param curve How the animation progresses, e.g. Linear progresses constantly * while Exponential start slow and becomes very fast in the end. * @param delay When the animation will start compared to "now" (the window will * remain at the "from" position until then). * @param from The starting value, the default is invalid, ie. the attribute for * the window is not transformed in the beginning. * @param fullScreen Sets this effect as the active full screen effect for the * duration of the animation. * @param keepAlive Whether closed windows should be kept alive during animation. * @returns An ID that you need to use to cancel this manipulation. * @since 4.11 **/ quint64 set( EffectWindow *w, Attribute a, uint meta, int ms, FPx2 to, QEasingCurve curve = QEasingCurve(), int delay = 0, FPx2 from = FPx2(), bool fullScreen = false, bool keepAlive = true) { return p_animate(w, a, meta, ms, to, curve, delay, from, true, fullScreen, keepAlive); } /** * Changes the target (but not type or curve) of a running animation. * * Please use cancel() to cancel an animation rather than altering it. * * @param animationId The id of the animation to be retargetted. * @param newTarget The new target. * @param newRemainingTime The new duration of the transition. By default (-1), * the remaining time remains unchanged. * @returns @c true if the animation was retargetted successfully, @c false otherwise. * @note You can NOT retarget an animation that just has just ended! * @since 5.6 **/ bool retarget(quint64 animationId, FPx2 newTarget, int newRemainingTime = -1); /** * Changes the direction of the animation. * * @param animationId The id of the animation. * @param direction The new direction of the animation. * @param terminationFlags Whether the animation should be terminated when it * reaches the source position after its direction was changed to go backward. * Currently, TerminationFlag::TerminateAtTarget has no effect. * @returns @c true if the direction of the animation was changed successfully, * otherwise @c false. * @since 5.15 **/ bool redirect(quint64 animationId, Direction direction, TerminationFlags terminationFlags = TerminateAtSource); /** * Fast-forwards the animation to the target position. * * @param animationId The id of the animation. * @returns @c true if the animation was fast-forwarded successfully, otherwise * @c false. * @since 5.15 **/ bool complete(quint64 animationId); /** * Called whenever an animation ends. * * You can reimplement this method to keep a constant transformation for the window * (i.e. keep it at some opacity or position) or to start another animation. * * @param w The animated window. * @param a The animated attribute. * @param meta Originally supplied metadata to animate() or set(). * @since 4.8 **/ virtual void animationEnded(EffectWindow *w, Attribute a, uint meta) {Q_UNUSED(w); Q_UNUSED(a); Q_UNUSED(meta);} /** * Cancels a running animation. * * @param animationId The id of the animation. * @returns @c true if the animation was found (and canceled), @c false otherwise. * @note There is NO animated reset of the original value. You'll have to provide * that with a second animation. * @note This will eventually release a Deleted window as well. * @note If you intend to run another animation on the (Deleted) window, you have * to do that before cancelling the old animation (to keep the window around). * @since 4.11 **/ bool cancel(quint64 animationId); /** * Called whenever animation that transforms Generic attribute needs to be painted. * * You should reimplement this method if you transform Generic attribute. @p meta * can be used to support more than one additional animations. * * @param w The animated window. * @param data The paint data. * @param progress Current progress value. * @param meta The metadata. * @since 4.8 **/ virtual void genericAnimation( EffectWindow *w, WindowPaintData &data, float progress, uint meta ) {Q_UNUSED(w); Q_UNUSED(data); Q_UNUSED(progress); Q_UNUSED(meta);} /** * @internal **/ typedef QMap, QRect> > AniMap; /** * @internal **/ AniMap state() const; private: quint64 p_animate(EffectWindow *w, Attribute a, uint meta, int ms, FPx2 to, QEasingCurve curve, int delay, FPx2 from, bool keepAtTarget, bool fullScreenEffect, bool keepAlive); QRect clipRect(const QRect &windowRect, const AniData&) const; void clipWindow(const EffectWindow *, const AniData &, WindowQuadList &) const; float interpolated( const AniData&, int i = 0 ) const; float progress( const AniData& ) const; void disconnectGeometryChanges(); void updateLayerRepaints(); void validate(Attribute a, uint &meta, FPx2 *from, FPx2 *to, const EffectWindow *w) const; private Q_SLOTS: void init(); void triggerRepaint(); void _windowClosed( KWin::EffectWindow* w ); void _windowDeleted( KWin::EffectWindow* w ); void _expandedGeometryChanged(KWin::EffectWindow *w, const QRect &old); private: static QElapsedTimer s_clock; AnimationEffectPrivate * const d_ptr; Q_DECLARE_PRIVATE(AnimationEffect) Q_DISABLE_COPY(AnimationEffect) }; } // namespace QDebug operator<<(QDebug dbg, const KWin::FPx2 &fpx2); Q_DECLARE_METATYPE(KWin::FPx2) Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::AnimationEffect::TerminationFlags) #endif // ANIMATION_EFFECT_H diff --git a/libkwineffects/kwineffects.h b/libkwineffects/kwineffects.h index 6e8b86854..d53a8763a 100644 --- a/libkwineffects/kwineffects.h +++ b/libkwineffects/kwineffects.h @@ -1,3953 +1,3953 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2006 Lubos Lunak Copyright (C) 2009 Lucas Murray Copyright (C) 2010, 2011 Martin Gräßlin Copyright (C) 2018 Vlad Zagorodniy 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 KWINEFFECTS_H #define KWINEFFECTS_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include class KConfigGroup; class QFont; class QGraphicsScale; class QKeyEvent; class QMatrix4x4; class QAction; /** * Logging category to be used inside the KWin effects. * Do not use in this library. **/ Q_DECLARE_LOGGING_CATEGORY(KWINEFFECTS) namespace KWayland { namespace Server { class SurfaceInterface; class Display; } } namespace KWin { class PaintDataPrivate; class WindowPaintDataPrivate; class EffectWindow; class EffectWindowGroup; class EffectFrame; class EffectFramePrivate; class Effect; class WindowQuad; class GLShader; class XRenderPicture; class WindowQuadList; class WindowPrePaintData; class WindowPaintData; class ScreenPrePaintData; class ScreenPaintData; typedef QPair< QString, Effect* > EffectPair; typedef QList< KWin::EffectWindow* > EffectWindowList; /** @defgroup kwineffects KWin effects library * KWin effects library contains necessary classes for creating new KWin * compositing effects. * * @section creating Creating new effects * This example will demonstrate the basics of creating an effect. We'll use * CoolEffect as the class name, cooleffect as internal name and * "Cool Effect" as user-visible name of the effect. * * This example doesn't demonstrate how to write the effect's code. For that, * see the documentation of the Effect class. * * @subsection creating-class CoolEffect class * First you need to create CoolEffect class which has to be a subclass of * @ref KWin::Effect. In that class you can reimplement various virtual * methods to control how and where the windows are drawn. * * @subsection creating-macro KWIN_EFFECT_FACTORY macro * This library provides a specialized KPluginFactory subclass and macros to * create a sub class. This subclass of KPluginFactory has to be used, otherwise * KWin won't load the plugin. Use the @ref KWIN_EFFECT_FACTORY macro to create the * plugin factory. * * @subsection creating-buildsystem Buildsystem * To build the effect, you can use the KWIN_ADD_EFFECT() cmake macro which * can be found in effects/CMakeLists.txt file in KWin's source. First * argument of the macro is the name of the library that will contain * your effect. Although not strictly required, it is usually a good idea to * use the same name as your effect's internal name there. Following arguments * to the macro are the files containing your effect's source. If our effect's * source is in cooleffect.cpp, we'd use following: * @code * KWIN_ADD_EFFECT(cooleffect cooleffect.cpp) * @endcode * * This macro takes care of compiling your effect. You'll also need to install * your effect's .desktop file, so the example CMakeLists.txt file would be * as follows: * @code * KWIN_ADD_EFFECT(cooleffect cooleffect.cpp) * install( FILES cooleffect.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kwin ) * @endcode * * @subsection creating-desktop Effect's .desktop file * You will also need to create .desktop file to set name, description, icon * and other properties of your effect. Important fields of the .desktop file * are: * @li Name User-visible name of your effect * @li Icon Name of the icon of the effect * @li Comment Short description of the effect * @li Type must be "Service" * @li X-KDE-ServiceTypes must be "KWin/Effect" * @li X-KDE-PluginInfo-Name effect's internal name as passed to the KWIN_EFFECT macro plus "kwin4_effect_" prefix * @li X-KDE-PluginInfo-Category effect's category. Should be one of Appearance, Accessibility, Window Management, Demos, Tests, Misc * @li X-KDE-PluginInfo-EnabledByDefault whether the effect should be enabled by default (use sparingly). Default is false * @li X-KDE-Library name of the library containing the effect. This is the first argument passed to the KWIN_ADD_EFFECT macro in cmake file plus "kwin4_effect_" prefix. * * Example cooleffect.desktop file follows: * @code [Desktop Entry] Name=Cool Effect Comment=The coolest effect you've ever seen Icon=preferences-system-windows-effect-cooleffect Type=Service X-KDE-ServiceTypes=KWin/Effect X-KDE-PluginInfo-Author=My Name X-KDE-PluginInfo-Email=my@email.here X-KDE-PluginInfo-Name=kwin4_effect_cooleffect X-KDE-PluginInfo-Category=Misc X-KDE-Library=kwin4_effect_cooleffect * @endcode * * * @section accessing Accessing windows and workspace * Effects can gain access to the properties of windows and workspace via * EffectWindow and EffectsHandler classes. * * There is one global EffectsHandler object which you can access using the * @ref effects pointer. * For each window, there is an EffectWindow object which can be used to read * window properties such as position and also to change them. * * For more information about this, see the documentation of the corresponding * classes. * * @{ **/ #define KWIN_EFFECT_API_MAKE_VERSION( major, minor ) (( major ) << 8 | ( minor )) #define KWIN_EFFECT_API_VERSION_MAJOR 0 #define KWIN_EFFECT_API_VERSION_MINOR 228 #define KWIN_EFFECT_API_VERSION KWIN_EFFECT_API_MAKE_VERSION( \ KWIN_EFFECT_API_VERSION_MAJOR, KWIN_EFFECT_API_VERSION_MINOR ) enum WindowQuadType { WindowQuadError, // for the stupid default ctor WindowQuadContents, WindowQuadDecoration, // Shadow Quad types WindowQuadShadow, // OpenGL only. The other shadow types are only used by Xrender WindowQuadShadowTop, WindowQuadShadowTopRight, WindowQuadShadowRight, WindowQuadShadowBottomRight, WindowQuadShadowBottom, WindowQuadShadowBottomLeft, WindowQuadShadowLeft, WindowQuadShadowTopLeft, EFFECT_QUAD_TYPE_START = 100 ///< @internal }; /** * EffectWindow::setData() and EffectWindow::data() global roles. * All values between 0 and 999 are reserved for global roles. **/ enum DataRole { // Grab roles are used to force all other animations to ignore the window. // The value of the data is set to the Effect's `this` value. WindowAddedGrabRole = 1, WindowClosedGrabRole, WindowMinimizedGrabRole, WindowUnminimizedGrabRole, WindowForceBlurRole, ///< For fullscreen effects to enforce blurring of windows, WindowBlurBehindRole, ///< For single windows to blur behind WindowForceBackgroundContrastRole, ///< For fullscreen effects to enforce the background contrast, WindowBackgroundContrastRole, ///< For single windows to enable Background contrast LanczosCacheRole }; /** * Style types used by @ref EffectFrame. * @since 4.6 **/ enum EffectFrameStyle { EffectFrameNone, ///< Displays no frame around the contents. EffectFrameUnstyled, ///< Displays a basic box around the contents. EffectFrameStyled ///< Displays a Plasma-styled frame around the contents. }; /** * Infinite region (i.e. a special region type saying that everything needs to be painted). **/ KWINEFFECTS_EXPORT inline QRect infiniteRegion() { // INT_MIN / 2 because width/height is used (INT_MIN+INT_MAX==-1) return QRect(INT_MIN / 2, INT_MIN / 2, INT_MAX, INT_MAX); } /** * @short Base class for all KWin effects * * This is the base class for all effects. By reimplementing virtual methods * of this class, you can customize how the windows are painted. * * The virtual methods are used for painting and need to be implemented for * custom painting. * * In order to react to state changes (e.g. a window gets closed) the effect * should provide slots for the signals emitted by the EffectsHandler. * * @section Chaining * Most methods of this class are called in chain style. This means that when * effects A and B area active then first e.g. A::paintWindow() is called and * then from within that method B::paintWindow() is called (although * indirectly). To achieve this, you need to make sure to call corresponding * method in EffectsHandler class from each such method (using @ref effects * pointer): * @code * void MyEffect::postPaintScreen() * { * // Do your own processing here * ... * // Call corresponding EffectsHandler method * effects->postPaintScreen(); * } * @endcode * * @section Effectsptr Effects pointer * @ref effects pointer points to the global EffectsHandler object that you can * use to interact with the windows. * * @section painting Painting stages * Painting of windows is done in three stages: * @li First, the prepaint pass.
* Here you can specify how the windows will be painted, e.g. that they will * be translucent and transformed. * @li Second, the paint pass.
* Here the actual painting takes place. You can change attributes such as * opacity of windows as well as apply transformations to them. You can also * paint something onto the screen yourself. * @li Finally, the postpaint pass.
* Here you can mark windows, part of windows or even the entire screen for * repainting to create animations. * * For each stage there are *Screen() and *Window() methods. The window method * is called for every window which the screen method is usually called just * once. * * @section OpenGL * Effects can use OpenGL if EffectsHandler::isOpenGLCompositing() returns @c true. * The OpenGL context may not always be current when code inside the effect is * executed. The framework ensures that the OpenGL context is current when the Effect * gets created, destroyed or reconfigured and during the painting stages. All virtual * methods which have the OpenGL context current are documented. * * If OpenGL code is going to be executed outside the painting stages, e.g. in reaction * to a global shortcut, it is the task of the Effect to make the OpenGL context current: * @code * effects->makeOpenGLContextCurrent(); * @endcode * * There is in general no need to call the matching doneCurrent method. **/ class KWINEFFECTS_EXPORT Effect : public QObject { Q_OBJECT public: /** Flags controlling how painting is done. */ // TODO: is that ok here? enum { /** * Window (or at least part of it) will be painted opaque. **/ PAINT_WINDOW_OPAQUE = 1 << 0, /** * Window (or at least part of it) will be painted translucent. **/ PAINT_WINDOW_TRANSLUCENT = 1 << 1, /** * Window will be painted with transformed geometry. **/ PAINT_WINDOW_TRANSFORMED = 1 << 2, /** * Paint only a region of the screen (can be optimized, cannot * be used together with TRANSFORMED flags). **/ PAINT_SCREEN_REGION = 1 << 3, /** * The whole screen will be painted with transformed geometry. * Forces the entire screen to be painted. **/ PAINT_SCREEN_TRANSFORMED = 1 << 4, /** * At least one window will be painted with transformed geometry. * Forces the entire screen to be painted. **/ PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS = 1 << 5, /** * Clear whole background as the very first step, without optimizing it **/ PAINT_SCREEN_BACKGROUND_FIRST = 1 << 6, // PAINT_DECORATION_ONLY = 1 << 7 has been deprecated /** * Window will be painted with a lanczos filter. **/ PAINT_WINDOW_LANCZOS = 1 << 8 // PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_WITHOUT_FULL_REPAINTS = 1 << 9 has been removed }; enum Feature { Nothing = 0, Resize, GeometryTip, Outline, /**< @deprecated */ ScreenInversion, Blur, Contrast, HighlightWindows }; /** * Constructs new Effect object. * * In OpenGL based compositing, the frameworks ensures that the context is current * when the Effect is constructed. **/ Effect(); /** * Destructs the Effect object. * * In OpenGL based compositing, the frameworks ensures that the context is current * when the Effect is destroyed. **/ - virtual ~Effect(); + ~Effect() override; /** * Flags describing which parts of configuration have changed. **/ enum ReconfigureFlag { ReconfigureAll = 1 << 0 /// Everything needs to be reconfigured. }; Q_DECLARE_FLAGS(ReconfigureFlags, ReconfigureFlag) /** * Called when configuration changes (either the effect's or KWin's global). * * In OpenGL based compositing, the frameworks ensures that the context is current * when the Effect is reconfigured. If this method is called from within the Effect it is * required to ensure that the context is current if the implementation does OpenGL calls. **/ virtual void reconfigure(ReconfigureFlags flags); /** * Called when another effect requests the proxy for this effect. **/ virtual void* proxy(); /** * Called before starting to paint the screen. * In this method you can: * @li set whether the windows or the entire screen will be transformed * @li change the region of the screen that will be painted * @li do various housekeeping tasks such as initing your effect's variables for the upcoming paint pass or updating animation's progress * * In OpenGL based compositing, the frameworks ensures that the context is current * when this method is invoked. **/ virtual void prePaintScreen(ScreenPrePaintData& data, int time); /** * In this method you can: * @li paint something on top of the windows (by painting after calling * effects->paintScreen()) * @li paint multiple desktops and/or multiple copies of the same desktop * by calling effects->paintScreen() multiple times * * In OpenGL based compositing, the frameworks ensures that the context is current * when this method is invoked. **/ virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data); /** * Called after all the painting has been finished. * In this method you can: * @li schedule next repaint in case of animations * You shouldn't paint anything here. * * In OpenGL based compositing, the frameworks ensures that the context is current * when this method is invoked. **/ virtual void postPaintScreen(); /** * Called for every window before the actual paint pass * In this method you can: * @li enable or disable painting of the window (e.g. enable paiting of minimized window) * @li set window to be painted with translucency * @li set window to be transformed * @li request the window to be divided into multiple parts * * In OpenGL based compositing, the frameworks ensures that the context is current * when this method is invoked. **/ virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time); /** * This is the main method for painting windows. * In this method you can: * @li do various transformations * @li change opacity of the window * @li change brightness and/or saturation, if it's supported * * In OpenGL based compositing, the frameworks ensures that the context is current * when this method is invoked. **/ virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); /** * Called for every window after all painting has been finished. * In this method you can: * @li schedule next repaint for individual window(s) in case of animations * You shouldn't paint anything here. * * In OpenGL based compositing, the frameworks ensures that the context is current * when this method is invoked. **/ virtual void postPaintWindow(EffectWindow* w); /** * This method is called directly before painting an @ref EffectFrame. * You can implement this method if you need to bind a shader or perform * other operations before the frame is rendered. * @param frame The EffectFrame which will be rendered * @param region Region to restrict painting to * @param opacity Opacity of text/icon * @param frameOpacity Opacity of background * @since 4.6 * * In OpenGL based compositing, the frameworks ensures that the context is current * when this method is invoked. **/ virtual void paintEffectFrame(EffectFrame* frame, QRegion region, double opacity, double frameOpacity); /** * Called on Transparent resizes. * return true if your effect substitutes questioned feature **/ virtual bool provides(Feature); /** * Performs the @p feature with the @p arguments. * * This allows to have specific protocols between KWin core and an Effect. * * The method is supposed to return @c true if it performed the features, * @c false otherwise. * * The default implementation returns @c false. * @since 5.8 **/ virtual bool perform(Feature feature, const QVariantList &arguments); /** * Can be called to draw multiple copies (e.g. thumbnails) of a window. * You can change window's opacity/brightness/etc here, but you can't * do any transformations. * * In OpenGL based compositing, the frameworks ensures that the context is current * when this method is invoked. **/ virtual void drawWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data); /** * Define new window quads so that they can be transformed by other effects. * It's up to the effect to keep track of them. **/ virtual void buildQuads(EffectWindow* w, WindowQuadList& quadList); virtual void windowInputMouseEvent(QEvent* e); virtual void grabbedKeyboardEvent(QKeyEvent* e); /** * Overwrite this method to indicate whether your effect will be doing something in * the next frame to be rendered. If the method returns @c false the effect will be * excluded from the chained methods in the next rendered frame. * * This method is called always directly before the paint loop begins. So it is totally * fine to e.g. react on a window event, issue a repaint to trigger an animation and * change a flag to indicate that this method returns @c true. * * As the method is called each frame, you should not perform complex calculations. * Best use just a boolean flag. * * The default implementation of this method returns @c true. * @since 4.8 **/ virtual bool isActive() const; /** * Reimplement this method to provide online debugging. * This could be as trivial as printing specific detail information about the effect state * but could also be used to move the effect in and out of a special debug modes, clear bogus * data, etc. * Notice that the functions is const by intent! Whenever you alter the state of the object * due to random user input, you should do so with greatest care, hence const_cast<> your * object - signalling "let me alone, i know what i'm doing" * @param parameter A freeform string user input for your effect to interpret. * @since 4.11 **/ virtual QString debug(const QString ¶meter) const; /** * Reimplement this method to indicate where in the Effect chain the Effect should be placed. * * A low number indicates early chain position, thus before other Effects got called, a high * number indicates a late position. The returned number should be in the interval [0, 100]. * The default value is 0. * * In KWin4 this information was provided in the Effect's desktop file as property * X-KDE-Ordering. In the case of Scripted Effects this property is still used. * * @since 5.0 **/ virtual int requestedEffectChainPosition() const; /** * A touch point was pressed. * * If the effect wants to exclusively use the touch event it should return @c true. * If @c false is returned the touch event is passed to further effects. * * In general an Effect should only return @c true if it is the exclusive effect getting * input events. E.g. has grabbed mouse events. * * Default implementation returns @c false. * * @param id The unique id of the touch point * @param pos The position of the touch point in global coordinates * @param time Timestamp * * @see touchMotion * @see touchUp * @since 5.8 **/ virtual bool touchDown(quint32 id, const QPointF &pos, quint32 time); /** * A touch point moved. * * If the effect wants to exclusively use the touch event it should return @c true. * If @c false is returned the touch event is passed to further effects. * * In general an Effect should only return @c true if it is the exclusive effect getting * input events. E.g. has grabbed mouse events. * * Default implementation returns @c false. * * @param id The unique id of the touch point * @param pos The position of the touch point in global coordinates * @param time Timestamp * * @see touchDown * @see touchUp * @since 5.8 **/ virtual bool touchMotion(quint32 id, const QPointF &pos, quint32 time); /** * A touch point was released. * * If the effect wants to exclusively use the touch event it should return @c true. * If @c false is returned the touch event is passed to further effects. * * In general an Effect should only return @c true if it is the exclusive effect getting * input events. E.g. has grabbed mouse events. * * Default implementation returns @c false. * * @param id The unique id of the touch point * @param time Timestamp * * @see touchDown * @see touchMotion * @since 5.8 **/ virtual bool touchUp(quint32 id, quint32 time); static QPoint cursorPos(); /** * Read animation time from the configuration and possibly adjust using animationTimeFactor(). * The configuration value in the effect should also have special value 'default' (set using * QSpinBox::setSpecialValueText()) with the value 0. This special value is adjusted * using the global animation speed, otherwise the exact time configured is returned. * @param cfg configuration group to read value from * @param key configuration key to read value from * @param defaultTime default animation time in milliseconds **/ // return type is intentionally double so that one can divide using it without losing data static double animationTime(const KConfigGroup& cfg, const QString& key, int defaultTime); /** * @overload Use this variant if the animation time is hardcoded and not configurable * in the effect itself. **/ static double animationTime(int defaultTime); /** * @overload Use this variant if animation time is provided through a KConfigXT generated class * having a property called "duration". **/ template int animationTime(int defaultDuration); /** * Linearly interpolates between @p x and @p y. * * Returns @p x when @p a = 0; returns @p y when @p a = 1. **/ static double interpolate(double x, double y, double a) { return x * (1 - a) + y * a; } /** Helper to set WindowPaintData and QRegion to necessary transformations so that * a following drawWindow() would put the window at the requested geometry (useful for thumbnails) **/ static void setPositionTransformations(WindowPaintData& data, QRect& region, EffectWindow* w, const QRect& r, Qt::AspectRatioMode aspect); public Q_SLOTS: virtual bool borderActivated(ElectricBorder border); protected: xcb_connection_t *xcbConnection() const; xcb_window_t x11RootWindow() const; /** * An implementing class can call this with it's kconfig compiled singleton class. * This method will perform the instance on the class. * @since 5.9 **/ template void initConfig(); }; /** * Prefer the KWIN_EFFECT_FACTORY macros. **/ class KWINEFFECTS_EXPORT EffectPluginFactory : public KPluginFactory { Q_OBJECT public: EffectPluginFactory(); - virtual ~EffectPluginFactory(); + ~EffectPluginFactory() override; /** * Returns whether the Effect is supported. * * An Effect can implement this method to determine at runtime whether the Effect is supported. * * If the current compositing backend is not supported it should return @c false. * * This method is optional, by default @c true is returned. **/ virtual bool isSupported() const; /** * Returns whether the Effect should get enabled by default. * * This function provides a way for an effect to override the default at runtime, * e.g. based on the capabilities of the hardware. * * This method is optional; the effect doesn't have to provide it. * * Note that this function is only called if the supported() function returns true, * and if X-KDE-PluginInfo-EnabledByDefault is set to true in the .desktop file. * * This method is optional, by default @c true is returned. **/ virtual bool enabledByDefault() const; /** * This method returns the created Effect. **/ virtual KWin::Effect *createEffect() const = 0; }; /** * Defines an EffectPluginFactory sub class with customized isSupported and enabledByDefault methods. * * If the Effect to be created does not need the isSupported or enabledByDefault methods prefer * the simplified KWIN_EFFECT_FACTORY, KWIN_EFFECT_FACTORY_SUPPORTED or KWIN_EFFECT_FACTORY_ENABLED * macros which create an EffectPluginFactory with a useable default value. * * The macro also adds a useable K_EXPORT_PLUGIN_VERSION to the definition. KWin will not load * any Effect with a non-matching plugin version. This API is not providing binary compatibility * and thus the effect plugin must be compiled against the same kwineffects library version as * KWin. * * @param factoryName The name to be used for the EffectPluginFactory * @param className The class name of the Effect sub class which is to be created by the factory * @param jsonFile Name of the json file to be compiled into the plugin as metadata * @param supported Source code to go into the isSupported() method, must return a boolean * @param enabled Source code to go into the enabledByDefault() method, must return a boolean **/ #define KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED( factoryName, className, jsonFile, supported, enabled ) \ class factoryName : public KWin::EffectPluginFactory \ { \ Q_OBJECT \ Q_PLUGIN_METADATA(IID KPluginFactory_iid FILE jsonFile) \ Q_INTERFACES(KPluginFactory) \ public: \ explicit factoryName() {} \ ~factoryName() {} \ bool isSupported() const override { \ supported \ } \ bool enabledByDefault() const override { \ enabled \ } \ KWin::Effect *createEffect() const override { \ return new className(); \ } \ }; \ K_EXPORT_PLUGIN_VERSION(quint32(KWIN_EFFECT_API_VERSION)) #define KWIN_EFFECT_FACTORY_ENABLED( factoryName, className, jsonFile, enabled ) \ KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED( factoryName, className, jsonFile, return true;, enabled ) #define KWIN_EFFECT_FACTORY_SUPPORTED( factoryName, classname, jsonFile, supported ) \ KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED( factoryName, className, jsonFile, supported, return true; ) #define KWIN_EFFECT_FACTORY( factoryName, classname, jsonFile ) \ KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED( factoryName, className, jsonFile, return true;, return true; ) /** * @short Manager class that handles all the effects. * * This class creates Effect objects and calls it's appropriate methods. * * Effect objects can call methods of this class to interact with the * workspace, e.g. to activate or move a specific window, change current * desktop or create a special input window to receive mouse and keyboard * events. **/ class KWINEFFECTS_EXPORT EffectsHandler : public QObject { Q_OBJECT Q_PROPERTY(int currentDesktop READ currentDesktop WRITE setCurrentDesktop NOTIFY desktopChanged) Q_PROPERTY(QString currentActivity READ currentActivity NOTIFY currentActivityChanged) Q_PROPERTY(KWin::EffectWindow *activeWindow READ activeWindow WRITE activateWindow NOTIFY windowActivated) Q_PROPERTY(QSize desktopGridSize READ desktopGridSize) Q_PROPERTY(int desktopGridWidth READ desktopGridWidth) Q_PROPERTY(int desktopGridHeight READ desktopGridHeight) Q_PROPERTY(int workspaceWidth READ workspaceWidth) Q_PROPERTY(int workspaceHeight READ workspaceHeight) /** * The number of desktops currently used. Minimum number of desktops is 1, maximum 20. **/ Q_PROPERTY(int desktops READ numberOfDesktops WRITE setNumberOfDesktops NOTIFY numberDesktopsChanged) Q_PROPERTY(bool optionRollOverDesktops READ optionRollOverDesktops) Q_PROPERTY(int activeScreen READ activeScreen) Q_PROPERTY(int numScreens READ numScreens NOTIFY numberScreensChanged) /** * Factor by which animation speed in the effect should be modified (multiplied). * If configurable in the effect itself, the option should have also 'default' * animation speed. The actual value should be determined using animationTime(). * Note: The factor can be also 0, so make sure your code can cope with 0ms time * if used manually. **/ Q_PROPERTY(qreal animationTimeFactor READ animationTimeFactor) Q_PROPERTY(QList< KWin::EffectWindow* > stackingOrder READ stackingOrder) /** * Whether window decorations use the alpha channel. **/ Q_PROPERTY(bool decorationsHaveAlpha READ decorationsHaveAlpha) /** * Whether the window decorations support blurring behind the decoration. **/ Q_PROPERTY(bool decorationSupportsBlurBehind READ decorationSupportsBlurBehind) Q_PROPERTY(CompositingType compositingType READ compositingType CONSTANT) Q_PROPERTY(QPoint cursorPos READ cursorPos) Q_PROPERTY(QSize virtualScreenSize READ virtualScreenSize NOTIFY virtualScreenSizeChanged) Q_PROPERTY(QRect virtualScreenGeometry READ virtualScreenGeometry NOTIFY virtualScreenGeometryChanged) Q_PROPERTY(bool hasActiveFullScreenEffect READ hasActiveFullScreenEffect NOTIFY hasActiveFullScreenEffectChanged) friend class Effect; public: explicit EffectsHandler(CompositingType type); - virtual ~EffectsHandler(); + ~EffectsHandler() override; // for use by effects virtual void prePaintScreen(ScreenPrePaintData& data, int time) = 0; virtual void paintScreen(int mask, QRegion region, ScreenPaintData& data) = 0; virtual void postPaintScreen() = 0; virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time) = 0; virtual void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) = 0; virtual void postPaintWindow(EffectWindow* w) = 0; virtual void paintEffectFrame(EffectFrame* frame, QRegion region, double opacity, double frameOpacity) = 0; virtual void drawWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) = 0; virtual void buildQuads(EffectWindow* w, WindowQuadList& quadList) = 0; virtual QVariant kwinOption(KWinOption kwopt) = 0; /** * Sets the cursor while the mouse is intercepted. * @see startMouseInterception * @since 4.11 **/ virtual void defineCursor(Qt::CursorShape shape) = 0; virtual QPoint cursorPos() const = 0; virtual bool grabKeyboard(Effect* effect) = 0; virtual void ungrabKeyboard() = 0; /** * Ensures that all mouse events are sent to the @p effect. * No window will get the mouse events. Only fullscreen effects providing a custom user interface should * be using this method. The input events are delivered to Effect::windowInputMouseEvent. * * @note This method does not perform an X11 mouse grab. On X11 a fullscreen input window is raised above * all other windows, but no grab is performed. * * @param effect The effect * @param shape Sets the cursor to be used while the mouse is intercepted * @see stopMouseInterception * @see Effect::windowInputMouseEvent * @since 4.11 **/ virtual void startMouseInterception(Effect *effect, Qt::CursorShape shape) = 0; /** * Releases the hold mouse interception for @p effect * @see startMouseInterception * @since 4.11 **/ virtual void stopMouseInterception(Effect *effect) = 0; /** * @brief Registers a global shortcut with the provided @p action. * * @param shortcut The global shortcut which should trigger the action * @param action The action which gets triggered when the shortcut matches **/ virtual void registerGlobalShortcut(const QKeySequence &shortcut, QAction *action) = 0; /** * @brief Registers a global pointer shortcut with the provided @p action. * * @param modifiers The keyboard modifiers which need to be holded * @param pointerButtons The pointer buttons which need to be pressed * @param action The action which gets triggered when the shortcut matches **/ virtual void registerPointerShortcut(Qt::KeyboardModifiers modifiers, Qt::MouseButton pointerButtons, QAction *action) = 0; /** * @brief Registers a global axis shortcut with the provided @p action. * * @param modifiers The keyboard modifiers which need to be holded * @param axis The direction in which the axis needs to be moved * @param action The action which gets triggered when the shortcut matches **/ virtual void registerAxisShortcut(Qt::KeyboardModifiers modifiers, PointerAxisDirection axis, QAction *action) = 0; /** * @brief Registers a global touchpad swipe gesture shortcut with the provided @p action. * * @param direction The direction for the swipe * @param action The action which gets triggered when the gesture triggers * @since 5.10 **/ virtual void registerTouchpadSwipeShortcut(SwipeDirection direction, QAction *action) = 0; /** * Retrieve the proxy class for an effect if it has one. Will return NULL if * the effect isn't loaded or doesn't have a proxy class. **/ virtual void* getProxy(QString name) = 0; // Mouse polling virtual void startMousePolling() = 0; virtual void stopMousePolling() = 0; virtual void reserveElectricBorder(ElectricBorder border, Effect *effect) = 0; virtual void unreserveElectricBorder(ElectricBorder border, Effect *effect) = 0; /** * Registers the given @p action for the given @p border to be activated through * a touch swipe gesture. * * If the @p border gets triggered through a touch swipe gesture the QAction::triggered * signal gets invoked. * * To unregister the touch screen action either delete the @p action or * invoke unregisterTouchBorder. * * @see unregisterTouchBorder * @since 5.10 **/ virtual void registerTouchBorder(ElectricBorder border, QAction *action) = 0; /** * Unregisters the given @p action for the given touch @p border. * * @see registerTouchBorder * @since 5.10 **/ virtual void unregisterTouchBorder(ElectricBorder border, QAction *action) = 0; // functions that allow controlling windows/desktop virtual void activateWindow(KWin::EffectWindow* c) = 0; virtual KWin::EffectWindow* activeWindow() const = 0 ; Q_SCRIPTABLE virtual void moveWindow(KWin::EffectWindow* w, const QPoint& pos, bool snap = false, double snapAdjust = 1.0) = 0; /** * Moves the window to the specific desktop * Setting desktop to NET::OnAllDesktops will set the window on all desktops **/ Q_SCRIPTABLE virtual void windowToDesktop(KWin::EffectWindow* w, int desktop) = 0; /** * Moves a window to the given desktops * On X11, the window will end up on the last window in the list * Setting this to an empty list will set the window on all desktops * * @arg desktopIds a list of desktops the window should be placed on. NET::OnAllDesktops is not a valid desktop X11Id **/ Q_SCRIPTABLE virtual void windowToDesktops(KWin::EffectWindow* w, const QVector &desktopIds) = 0; Q_SCRIPTABLE virtual void windowToScreen(KWin::EffectWindow* w, int screen) = 0; virtual void setShowingDesktop(bool showing) = 0; // Activities /** * @returns The ID of the current activity. **/ virtual QString currentActivity() const = 0; // Desktops /** * @returns The ID of the current desktop. **/ virtual int currentDesktop() const = 0; /** * @returns Total number of desktops currently in existence. **/ virtual int numberOfDesktops() const = 0; /** * Set the current desktop to @a desktop. **/ virtual void setCurrentDesktop(int desktop) = 0; /** * Sets the total number of desktops to @a desktops. **/ virtual void setNumberOfDesktops(int desktops) = 0; /** * @returns The size of desktop layout in grid units. **/ virtual QSize desktopGridSize() const = 0; /** * @returns The width of desktop layout in grid units. **/ virtual int desktopGridWidth() const = 0; /** * @returns The height of desktop layout in grid units. **/ virtual int desktopGridHeight() const = 0; /** * @returns The width of desktop layout in pixels. **/ virtual int workspaceWidth() const = 0; /** * @returns The height of desktop layout in pixels. **/ virtual int workspaceHeight() const = 0; /** * @returns The ID of the desktop at the point @a coords or 0 if no desktop exists at that * point. @a coords is to be in grid units. **/ virtual int desktopAtCoords(QPoint coords) const = 0; /** * @returns The coords of desktop @a id in grid units. **/ virtual QPoint desktopGridCoords(int id) const = 0; /** * @returns The coords of the top-left corner of desktop @a id in pixels. **/ virtual QPoint desktopCoords(int id) const = 0; /** * @returns The ID of the desktop above desktop @a id. Wraps around to the bottom of * the layout if @a wrap is set. If @a id is not set use the current one. **/ Q_SCRIPTABLE virtual int desktopAbove(int desktop = 0, bool wrap = true) const = 0; /** * @returns The ID of the desktop to the right of desktop @a id. Wraps around to the * left of the layout if @a wrap is set. If @a id is not set use the current one. **/ Q_SCRIPTABLE virtual int desktopToRight(int desktop = 0, bool wrap = true) const = 0; /** * @returns The ID of the desktop below desktop @a id. Wraps around to the top of the * layout if @a wrap is set. If @a id is not set use the current one. **/ Q_SCRIPTABLE virtual int desktopBelow(int desktop = 0, bool wrap = true) const = 0; /** * @returns The ID of the desktop to the left of desktop @a id. Wraps around to the * right of the layout if @a wrap is set. If @a id is not set use the current one. **/ Q_SCRIPTABLE virtual int desktopToLeft(int desktop = 0, bool wrap = true) const = 0; Q_SCRIPTABLE virtual QString desktopName(int desktop) const = 0; virtual bool optionRollOverDesktops() const = 0; virtual int activeScreen() const = 0; // Xinerama virtual int numScreens() const = 0; // Xinerama Q_SCRIPTABLE virtual int screenNumber(const QPoint& pos) const = 0; // Xinerama virtual QRect clientArea(clientAreaOption, int screen, int desktop) const = 0; virtual QRect clientArea(clientAreaOption, const EffectWindow* c) const = 0; virtual QRect clientArea(clientAreaOption, const QPoint& p, int desktop) const = 0; /** * The bounding size of all screens combined. Overlapping areas * are not counted multiple times. * * @see virtualScreenGeometry() * @see virtualScreenSizeChanged() * @since 5.0 **/ virtual QSize virtualScreenSize() const = 0; /** * The bounding geometry of all outputs combined. Always starts at (0,0) and has * virtualScreenSize as it's size. * * @see virtualScreenSize() * @see virtualScreenGeometryChanged() * @since 5.0 **/ virtual QRect virtualScreenGeometry() const = 0; /** * Factor by which animation speed in the effect should be modified (multiplied). * If configurable in the effect itself, the option should have also 'default' * animation speed. The actual value should be determined using animationTime(). * Note: The factor can be also 0, so make sure your code can cope with 0ms time * if used manually. **/ virtual double animationTimeFactor() const = 0; virtual WindowQuadType newWindowQuadType() = 0; Q_SCRIPTABLE virtual KWin::EffectWindow* findWindow(WId id) const = 0; Q_SCRIPTABLE virtual KWin::EffectWindow* findWindow(KWayland::Server::SurfaceInterface *surf) const = 0; /** * Finds the EffectWindow for the internal window @p w. * If there is no such window @c null is returned. * * On Wayland this returns the internal window. On X11 it returns an Unamanged with the * window id matching that of the provided window @p w. * * @since 5.16 **/ Q_SCRIPTABLE virtual KWin::EffectWindow *findWindow(QWindow *w) const = 0; /** * Finds the EffectWindow for the Toplevel with KWin internal @p id. * If there is no such window @c null is returned. * * @since 5.16 **/ Q_SCRIPTABLE virtual KWin::EffectWindow *findWindow(const QUuid &id) const = 0; virtual EffectWindowList stackingOrder() const = 0; // window will be temporarily painted as if being at the top of the stack Q_SCRIPTABLE virtual void setElevatedWindow(KWin::EffectWindow* w, bool set) = 0; virtual void setTabBoxWindow(EffectWindow*) = 0; virtual void setTabBoxDesktop(int) = 0; virtual EffectWindowList currentTabBoxWindowList() const = 0; virtual void refTabBox() = 0; virtual void unrefTabBox() = 0; virtual void closeTabBox() = 0; virtual QList< int > currentTabBoxDesktopList() const = 0; virtual int currentTabBoxDesktop() const = 0; virtual EffectWindow* currentTabBoxWindow() const = 0; virtual void setActiveFullScreenEffect(Effect* e) = 0; virtual Effect* activeFullScreenEffect() const = 0; /** * Schedules the entire workspace to be repainted next time. * If you call it during painting (including prepaint) then it does not * affect the current painting. **/ Q_SCRIPTABLE virtual void addRepaintFull() = 0; Q_SCRIPTABLE virtual void addRepaint(const QRect& r) = 0; Q_SCRIPTABLE virtual void addRepaint(const QRegion& r) = 0; Q_SCRIPTABLE virtual void addRepaint(int x, int y, int w, int h) = 0; CompositingType compositingType() const; /** * @brief Whether the Compositor is OpenGL based (either GL 1 or 2). * * @return bool @c true in case of OpenGL based Compositor, @c false otherwise **/ bool isOpenGLCompositing() const; virtual unsigned long xrenderBufferPicture() = 0; /** * @brief Provides access to the QPainter which is rendering to the back buffer. * * Only relevant for CompositingType QPainterCompositing. For all other compositing types * @c null is returned. * * @return QPainter* The Scene's QPainter or @c null. **/ virtual QPainter *scenePainter() = 0; virtual void reconfigure() = 0; virtual QByteArray readRootProperty(long atom, long type, int format) const = 0; /** * @brief Announces support for the feature with the given name. If no other Effect * has announced support for this feature yet, an X11 property will be installed on * the root window. * * The Effect will be notified for events through the signal propertyNotify(). * * To remove the support again use removeSupportProperty. When an Effect is * destroyed it is automatically taken care of removing the support. It is not * required to call removeSupportProperty in the Effect's cleanup handling. * * @param propertyName The name of the property to announce support for * @param effect The effect which announces support * @return xcb_atom_t The created X11 atom * @see removeSupportProperty * @since 4.11 **/ virtual xcb_atom_t announceSupportProperty(const QByteArray &propertyName, Effect *effect) = 0; /** * @brief Removes support for the feature with the given name. If there is no other Effect left * which has announced support for the given property, the property will be removed from the * root window. * * In case the Effect had not registered support, calling this function does not change anything. * * @param propertyName The name of the property to remove support for * @param effect The effect which had registered the property. * @see announceSupportProperty * @since 4.11 **/ virtual void removeSupportProperty(const QByteArray &propertyName, Effect *effect) = 0; /** * Returns @a true if the active window decoration has shadow API hooks. **/ virtual bool hasDecorationShadows() const = 0; /** * Returns @a true if the window decorations use the alpha channel, and @a false otherwise. * @since 4.5 **/ virtual bool decorationsHaveAlpha() const = 0; /** * Returns @a true if the window decorations support blurring behind the decoration, and @a false otherwise * @since 4.6 **/ virtual bool decorationSupportsBlurBehind() const = 0; /** * Creates a new frame object. If the frame does not have a static size * then it will be located at @a position with @a alignment. A * non-static frame will automatically adjust its size to fit the contents. * @returns A new @ref EffectFrame. It is the responsibility of the caller to delete the * EffectFrame. * @since 4.6 **/ virtual EffectFrame* effectFrame(EffectFrameStyle style, bool staticSize = true, const QPoint& position = QPoint(-1, -1), Qt::Alignment alignment = Qt::AlignCenter) const = 0; /** * Allows an effect to trigger a reload of itself. * This can be used by an effect which needs to be reloaded when screen geometry changes. * It is possible that the effect cannot be loaded again as it's supported method does no longer * hold. * @param effect The effect to reload * @since 4.8 **/ virtual void reloadEffect(Effect *effect) = 0; /** * Whether the screen is currently considered as locked. * Note for technical reasons this is not always possible to detect. The screen will only * be considered as locked if the screen locking process implements the * org.freedesktop.ScreenSaver interface. * * @returns @c true if the screen is currently locked, @c false otherwise * @see screenLockingChanged * @since 4.11 **/ virtual bool isScreenLocked() const = 0; /** * @brief Makes the OpenGL compositing context current. * * If the compositing backend is not using OpenGL, this method returns @c false. * * @return bool @c true if the context became current, @c false otherwise. **/ virtual bool makeOpenGLContextCurrent() = 0; /** * @brief Makes a null OpenGL context current resulting in no context * being current. * * If the compositing backend is not OpenGL based, this method is a noop. * * There is normally no reason for an Effect to call this method. **/ virtual void doneOpenGLContextCurrent() = 0; virtual xcb_connection_t *xcbConnection() const = 0; virtual xcb_window_t x11RootWindow() const = 0; /** * Interface to the Wayland display: this is relevant only * on Wayland, on X11 it will be nullptr * @since 5.5 **/ virtual KWayland::Server::Display *waylandDisplay() const = 0; /** * Whether animations are supported by the Scene. * If this method returns @c false Effects are supposed to not * animate transitions. * * @returns Whether the Scene can drive animations * @since 5.8 **/ virtual bool animationsSupported() const = 0; /** * The current cursor image of the Platform. * @see cursorPos * @since 5.9 **/ virtual PlatformCursorImage cursorImage() const = 0; /** * The cursor image should be hidden. * @see showCursor * @since 5.9 **/ virtual void hideCursor() = 0; /** * The cursor image should be shown again after having been hidden. * @see hideCursor * @since 5.9 **/ virtual void showCursor() = 0; /** * Starts an interactive window selection process. * * Once the user selected a window the @p callback is invoked with the selected EffectWindow as * argument. In case the user cancels the interactive window selection or selecting a window is currently * not possible (e.g. screen locked) the @p callback is invoked with a @c nullptr argument. * * During the interactive window selection the cursor is turned into a crosshair cursor. * * @param callback The function to invoke once the interactive window selection ends * @since 5.9 **/ virtual void startInteractiveWindowSelection(std::function callback) = 0; /** * Starts an interactive position selection process. * * Once the user selected a position on the screen the @p callback is invoked with * the selected point as argument. In case the user cancels the interactive position selection * or selecting a position is currently not possible (e.g. screen locked) the @p callback * is invoked with a point at @c -1 as x and y argument. * * During the interactive window selection the cursor is turned into a crosshair cursor. * * @param callback The function to invoke once the interactive position selection ends * @since 5.9 **/ virtual void startInteractivePositionSelection(std::function callback) = 0; /** * Shows an on-screen-message. To hide it again use hideOnScreenMessage. * * @param message The message to show * @param iconName The optional themed icon name * @see hideOnScreenMessage * @since 5.9 **/ virtual void showOnScreenMessage(const QString &message, const QString &iconName = QString()) = 0; /** * Flags for how to hide a shown on-screen-message * @see hideOnScreenMessage * @since 5.9 **/ enum class OnScreenMessageHideFlag { /** * The on-screen-message should skip the close window animation. * @see EffectWindow::skipsCloseAnimation **/ SkipsCloseAnimation = 1 }; Q_DECLARE_FLAGS(OnScreenMessageHideFlags, OnScreenMessageHideFlag) /** * Hides a previously shown on-screen-message again. * @param flags The flags for how to hide the message * @see showOnScreenMessage * @since 5.9 **/ virtual void hideOnScreenMessage(OnScreenMessageHideFlags flags = OnScreenMessageHideFlags()) = 0; /* * @returns The configuration used by the EffectsHandler. * @since 5.10 **/ virtual KSharedConfigPtr config() const = 0; /** * @returns The global input configuration (kcminputrc) * @since 5.10 **/ virtual KSharedConfigPtr inputConfig() const = 0; /** * Returns if activeFullScreenEffect is set **/ virtual bool hasActiveFullScreenEffect() const = 0; Q_SIGNALS: /** * Signal emitted when the current desktop changed. * @param oldDesktop The previously current desktop * @param newDesktop The new current desktop * @param with The window which is taken over to the new desktop, can be NULL * @since 4.9 **/ void desktopChanged(int oldDesktop, int newDesktop, KWin::EffectWindow *with); /** * @since 4.7 * @deprecated **/ void desktopChanged(int oldDesktop, int newDesktop); /** * Signal emitted when a window moved to another desktop * NOTICE that this does NOT imply that the desktop has changed * The @param window which is moved to the new desktop * @param oldDesktop The previous desktop of the window * @param newDesktop The new desktop of the window * @since 4.11.4 **/ void desktopPresenceChanged(KWin::EffectWindow *window, int oldDesktop, int newDesktop); /** * Signal emitted when the number of currently existing desktops is changed. * @param old The previous number of desktops in used. * @see EffectsHandler::numberOfDesktops. * @since 4.7 **/ void numberDesktopsChanged(uint old); /** * Signal emitted when the number of screens changed. * @since 5.0 **/ void numberScreensChanged(); /** * Signal emitted when the desktop showing ("dashboard") state changed * The desktop is risen to the keepAbove layer, you may want to elevate * windows or such. * @since 5.3 **/ void showingDesktopChanged(bool); /** * Signal emitted when a new window has been added to the Workspace. * @param w The added window * @since 4.7 **/ void windowAdded(KWin::EffectWindow *w); /** * Signal emitted when a window is being removed from the Workspace. * An effect which wants to animate the window closing should connect * to this signal and reference the window by using * refWindow * @param w The window which is being closed * @since 4.7 **/ void windowClosed(KWin::EffectWindow *w); /** * Signal emitted when a window get's activated. * @param w The new active window, or @c NULL if there is no active window. * @since 4.7 **/ void windowActivated(KWin::EffectWindow *w); /** * Signal emitted when a window is deleted. * This means that a closed window is not referenced any more. * An effect bookkeeping the closed windows should connect to this * signal to clean up the internal references. * @param w The window which is going to be deleted. * @see EffectWindow::refWindow * @see EffectWindow::unrefWindow * @see windowClosed * @since 4.7 **/ void windowDeleted(KWin::EffectWindow *w); /** * Signal emitted when a user begins a window move or resize operation. * To figure out whether the user resizes or moves the window use * isUserMove or isUserResize. * Whenever the geometry is updated the signal @ref windowStepUserMovedResized * is emitted with the current geometry. * The move/resize operation ends with the signal @ref windowFinishUserMovedResized. * Only one window can be moved/resized by the user at the same time! * @param w The window which is being moved/resized * @see windowStepUserMovedResized * @see windowFinishUserMovedResized * @see EffectWindow::isUserMove * @see EffectWindow::isUserResize * @since 4.7 **/ void windowStartUserMovedResized(KWin::EffectWindow *w); /** * Signal emitted during a move/resize operation when the user changed the geometry. * Please note: KWin supports two operation modes. In one mode all changes are applied * instantly. This means the window's geometry matches the passed in @p geometry. In the * other mode the geometry is changed after the user ended the move/resize mode. * The @p geometry differs from the window's geometry. Also the window's pixmap still has * the same size as before. Depending what the effect wants to do it would be recommended * to scale/translate the window. * @param w The window which is being moved/resized * @param geometry The geometry of the window in the current move/resize step. * @see windowStartUserMovedResized * @see windowFinishUserMovedResized * @see EffectWindow::isUserMove * @see EffectWindow::isUserResize * @since 4.7 **/ void windowStepUserMovedResized(KWin::EffectWindow *w, const QRect &geometry); /** * Signal emitted when the user finishes move/resize of window @p w. * @param w The window which has been moved/resized * @see windowStartUserMovedResized * @see windowFinishUserMovedResized * @since 4.7 **/ void windowFinishUserMovedResized(KWin::EffectWindow *w); /** * Signal emitted when the maximized state of the window @p w changed. * A window can be in one of four states: * @li restored: both @p horizontal and @p vertical are @c false * @li horizontally maximized: @p horizontal is @c true and @p vertical is @c false * @li vertically maximized: @p horizontal is @c false and @p vertical is @c true * @li completely maximized: both @p horizontal and @p vertical are @c true * @param w The window whose maximized state changed * @param horizontal If @c true maximized horizontally * @param vertical If @c true maximized vertically * @since 4.7 **/ void windowMaximizedStateChanged(KWin::EffectWindow *w, bool horizontal, bool vertical); /** * Signal emitted when the geometry or shape of a window changed. * This is caused if the window changes geometry without user interaction. * E.g. the decoration is changed. This is in opposite to windowUserMovedResized * which is caused by direct user interaction. * @param w The window whose geometry changed * @param old The previous geometry * @see windowUserMovedResized * @since 4.7 **/ void windowGeometryShapeChanged(KWin::EffectWindow *w, const QRect &old); /** * Signal emitted when the padding of a window changed. (eg. shadow size) * @param w The window whose geometry changed * @param old The previous expandedGeometry() * @since 4.9 **/ void windowPaddingChanged(KWin::EffectWindow *w, const QRect &old); /** * Signal emitted when the windows opacity is changed. * @param w The window whose opacity level is changed. * @param oldOpacity The previous opacity level * @param newOpacity The new opacity level * @since 4.7 **/ void windowOpacityChanged(KWin::EffectWindow *w, qreal oldOpacity, qreal newOpacity); /** * Signal emitted when a window got minimized. * @param w The window which was minimized * @since 4.7 **/ void windowMinimized(KWin::EffectWindow *w); /** * Signal emitted when a window got unminimized. * @param w The window which was unminimized * @since 4.7 **/ void windowUnminimized(KWin::EffectWindow *w); /** * Signal emitted when a window either becomes modal (ie. blocking for its main client) or looses that state. * @param w The window which was unminimized * @since 4.11 **/ void windowModalityChanged(KWin::EffectWindow *w); /** * Signal emitted when a window either became unresponsive (eg. app froze or crashed) * or respoonsive * @param w The window that became (un)responsive * @param unresponsive Whether the window is responsive or unresponsive * @since 5.10 **/ void windowUnresponsiveChanged(KWin::EffectWindow *w, bool unresponsive); /** * Signal emitted when an area of a window is scheduled for repainting. * Use this signal in an effect if another area needs to be synced as well. * @param w The window which is scheduled for repainting * @param r Always empty. * @since 4.7 **/ void windowDamaged(KWin::EffectWindow *w, const QRect &r); /** * Signal emitted when a tabbox is added. * An effect who wants to replace the tabbox with itself should use refTabBox. * @param mode The TabBoxMode. * @see refTabBox * @see tabBoxClosed * @see tabBoxUpdated * @see tabBoxKeyEvent * @since 4.7 **/ void tabBoxAdded(int mode); /** * Signal emitted when the TabBox was closed by KWin core. * An effect which referenced the TabBox should use unrefTabBox to unref again. * @see unrefTabBox * @see tabBoxAdded * @since 4.7 **/ void tabBoxClosed(); /** * Signal emitted when the selected TabBox window changed or the TabBox List changed. * An effect should only response to this signal if it referenced the TabBox with refTabBox. * @see refTabBox * @see currentTabBoxWindowList * @see currentTabBoxDesktopList * @see currentTabBoxWindow * @see currentTabBoxDesktop * @since 4.7 **/ void tabBoxUpdated(); /** * Signal emitted when a key event, which is not handled by TabBox directly is, happens while * TabBox is active. An effect might use the key event to e.g. change the selected window. * An effect should only response to this signal if it referenced the TabBox with refTabBox. * @param event The key event not handled by TabBox directly * @see refTabBox * @since 4.7 **/ void tabBoxKeyEvent(QKeyEvent* event); void currentTabAboutToChange(KWin::EffectWindow* from, KWin::EffectWindow* to); void tabAdded(KWin::EffectWindow* from, KWin::EffectWindow* to); // from merged with to void tabRemoved(KWin::EffectWindow* c, KWin::EffectWindow* group); // c removed from group /** * Signal emitted when mouse changed. * If an effect needs to get updated mouse positions, it needs to first call startMousePolling. * For a fullscreen effect it is better to use an input window and react on windowInputMouseEvent. * @param pos The new mouse position * @param oldpos The previously mouse position * @param buttons The pressed mouse buttons * @param oldbuttons The previously pressed mouse buttons * @param modifiers Pressed keyboard modifiers * @param oldmodifiers Previously pressed keyboard modifiers. * @see startMousePolling * @since 4.7 **/ void mouseChanged(const QPoint& pos, const QPoint& oldpos, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); /** * Signal emitted when the cursor shape changed. * You'll likely want to query the current cursor as reaction: xcb_xfixes_get_cursor_image_unchecked * Connection to this signal is tracked, so if you don't need it anymore, disconnect from it to stop cursor event filtering **/ void cursorShapeChanged(); /** * Receives events registered for using registerPropertyType. * Use readProperty() to get the property data. * Note that the property may be already set on the window, so doing the same * processing from windowAdded() (e.g. simply calling propertyNotify() from it) * is usually needed. * @param w The window whose property changed, is @c null if it is a root window property * @param atom The property * @since 4.7 **/ void propertyNotify(KWin::EffectWindow* w, long atom); /** * Signal emitted after the screen geometry changed (e.g. add of a monitor). * Effects using displayWidth()/displayHeight() to cache information should * react on this signal and update the caches. * @param size The new screen size * @since 4.8 **/ void screenGeometryChanged(const QSize &size); /** * This signal is emitted when the global * activity is changed * @param id id of the new current activity * @since 4.9 **/ void currentActivityChanged(const QString &id); /** * This signal is emitted when a new activity is added * @param id id of the new activity * @since 4.9 **/ void activityAdded(const QString &id); /** * This signal is emitted when the activity * is removed * @param id id of the removed activity * @since 4.9 **/ void activityRemoved(const QString &id); /** * This signal is emitted when the screen got locked or unlocked. * @param locked @c true if the screen is now locked, @c false if it is now unlocked * @since 4.11 **/ void screenLockingChanged(bool locked); /** * This signal is emitted just before the screen locker tries to grab keys and lock the screen * Effects should release any grabs immediately * @since 5.17 **/ void screenAboutToLock(); /** * This signels is emitted when ever the stacking order is change, ie. a window is risen * or lowered * @since 4.10 **/ void stackingOrderChanged(); /** * This signal is emitted when the user starts to approach the @p border with the mouse. * The @p factor describes how far away the mouse is in a relative mean. The values are in * [0.0, 1.0] with 0.0 being emitted when first entered and on leaving. The value 1.0 means that * the @p border is reached with the mouse. So the values are well suited for animations. * The signal is always emitted when the mouse cursor position changes. * @param border The screen edge which is being approached * @param factor Value in range [0.0,1.0] to describe how close the mouse is to the border * @param geometry The geometry of the edge which is being approached * @since 4.11 **/ void screenEdgeApproaching(ElectricBorder border, qreal factor, const QRect &geometry); /** * Emitted whenever the virtualScreenSize changes. * @see virtualScreenSize() * @since 5.0 **/ void virtualScreenSizeChanged(); /** * Emitted whenever the virtualScreenGeometry changes. * @see virtualScreenGeometry() * @since 5.0 **/ void virtualScreenGeometryChanged(); /** * The window @p w gets shown again. The window was previously * initially shown with windowAdded and hidden with windowHidden. * * @see windowHidden * @see windowAdded * @since 5.8 **/ void windowShown(KWin::EffectWindow *w); /** * The window @p w got hidden but not yet closed. * This can happen when a window is still being used and is supposed to be shown again * with windowShown. On X11 an example is autohiding panels. On Wayland every * window first goes through the window hidden state and might get shown again, or might * get closed the normal way. * * @see windowShown * @see windowClosed * @since 5.8 **/ void windowHidden(KWin::EffectWindow *w); /** * This signal gets emitted when the data on EffectWindow @p w for @p role changed. * * An Effect can connect to this signal to read the new value and react on it. * E.g. an Effect which does not operate on windows grabbed by another Effect wants * to cancel the already scheduled animation if another Effect adds a grab. * * @param w The EffectWindow for which the data changed * @param role The data role which changed * @see EffectWindow::setData * @see EffectWindow::data * @since 5.8.4 **/ void windowDataChanged(KWin::EffectWindow *w, int role); /** * The xcb connection changed, either a new xcbConnection got created or the existing one * got destroyed. * Effects can use this to refetch the properties they want to set. * * When the xcbConnection changes also the x11RootWindow becomes invalid. * @see xcbConnection * @see x11RootWindow * @since 5.11 **/ void xcbConnectionChanged(); /** * This signal is emitted when active fullscreen effect changed. * * @see activeFullScreenEffect * @see setActiveFullScreenEffect * @since 5.14 **/ void activeFullScreenEffectChanged(); /** * This signal is emitted when active fullscreen effect changed to being * set or unset * * @see activeFullScreenEffect * @see setActiveFullScreenEffect * @since 5.15 **/ void hasActiveFullScreenEffectChanged(); /** * This signal is emitted when the keep above state of @p w was changed. * * @param w The window whose the keep above state was changed. * @since 5.15 **/ void windowKeepAboveChanged(KWin::EffectWindow *w); /** * This signal is emitted when the keep below state of @p was changed. * * @param w The window whose the keep below state was changed. * @since 5.15 **/ void windowKeepBelowChanged(KWin::EffectWindow *w); /** * This signal is emitted when the full screen state of @p w was changed. * * @param w The window whose the full screen state was changed. * @since 5.15 **/ void windowFullScreenChanged(KWin::EffectWindow *w); protected: QVector< EffectPair > loaded_effects; //QHash< QString, EffectFactory* > effect_factories; CompositingType compositing_type; }; /** * @short Representation of a window used by/for Effect classes. * * The purpose is to hide internal data and also to serve as a single * representation for the case when Client/Unmanaged becomes Deleted. **/ class KWINEFFECTS_EXPORT EffectWindow : public QObject { Q_OBJECT Q_PROPERTY(bool alpha READ hasAlpha CONSTANT) Q_PROPERTY(QRect geometry READ geometry) Q_PROPERTY(QRect expandedGeometry READ expandedGeometry) Q_PROPERTY(int height READ height) Q_PROPERTY(qreal opacity READ opacity) Q_PROPERTY(QPoint pos READ pos) Q_PROPERTY(int screen READ screen) Q_PROPERTY(QSize size READ size) Q_PROPERTY(int width READ width) Q_PROPERTY(int x READ x) Q_PROPERTY(int y READ y) Q_PROPERTY(int desktop READ desktop) Q_PROPERTY(bool onAllDesktops READ isOnAllDesktops) Q_PROPERTY(bool onCurrentDesktop READ isOnCurrentDesktop) Q_PROPERTY(QRect rect READ rect) Q_PROPERTY(QString windowClass READ windowClass) Q_PROPERTY(QString windowRole READ windowRole) /** * Returns whether the window is a desktop background window (the one with wallpaper). * See _NET_WM_WINDOW_TYPE_DESKTOP at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool desktopWindow READ isDesktop) /** * Returns whether the window is a dock (i.e. a panel). * See _NET_WM_WINDOW_TYPE_DOCK at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool dock READ isDock) /** * Returns whether the window is a standalone (detached) toolbar window. * See _NET_WM_WINDOW_TYPE_TOOLBAR at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool toolbar READ isToolbar) /** * Returns whether the window is a torn-off menu. * See _NET_WM_WINDOW_TYPE_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool menu READ isMenu) /** * Returns whether the window is a "normal" window, i.e. an application or any other window * for which none of the specialized window types fit. * See _NET_WM_WINDOW_TYPE_NORMAL at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool normalWindow READ isNormalWindow) /** * Returns whether the window is a dialog window. * See _NET_WM_WINDOW_TYPE_DIALOG at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool dialog READ isDialog) /** * Returns whether the window is a splashscreen. Note that many (especially older) applications * do not support marking their splash windows with this type. * See _NET_WM_WINDOW_TYPE_SPLASH at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool splash READ isSplash) /** * Returns whether the window is a utility window, such as a tool window. * See _NET_WM_WINDOW_TYPE_UTILITY at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool utility READ isUtility) /** * Returns whether the window is a dropdown menu (i.e. a popup directly or indirectly open * from the applications menubar). * See _NET_WM_WINDOW_TYPE_DROPDOWN_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool dropdownMenu READ isDropdownMenu) /** * Returns whether the window is a popup menu (that is not a torn-off or dropdown menu). * See _NET_WM_WINDOW_TYPE_POPUP_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool popupMenu READ isPopupMenu) /** * Returns whether the window is a tooltip. * See _NET_WM_WINDOW_TYPE_TOOLTIP at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool tooltip READ isTooltip) /** * Returns whether the window is a window with a notification. * See _NET_WM_WINDOW_TYPE_NOTIFICATION at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool notification READ isNotification) /** * Returns whether the window is a window with a critical notification. * using the non-standard _KDE_NET_WM_WINDOW_TYPE_CRITICAL_NOTIFICATION **/ Q_PROPERTY(bool criticalNotification READ isCriticalNotification) /** * Returns whether the window is an on screen display window * using the non-standard _KDE_NET_WM_WINDOW_TYPE_ON_SCREEN_DISPLAY **/ Q_PROPERTY(bool onScreenDisplay READ isOnScreenDisplay) /** * Returns whether the window is a combobox popup. * See _NET_WM_WINDOW_TYPE_COMBO at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool comboBox READ isComboBox) /** * Returns whether the window is a Drag&Drop icon. * See _NET_WM_WINDOW_TYPE_DND at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool dndIcon READ isDNDIcon) /** * Returns the NETWM window type * See https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(int windowType READ windowType) /** * Whether this EffectWindow is managed by KWin (it has control over its placement and other * aspects, as opposed to override-redirect windows that are entirely handled by the application). **/ Q_PROPERTY(bool managed READ isManaged) /** * Whether this EffectWindow represents an already deleted window and only kept for the compositor for animations. **/ Q_PROPERTY(bool deleted READ isDeleted) /** * Whether the window has an own shape **/ Q_PROPERTY(bool shaped READ hasOwnShape) /** * The Window's shape **/ Q_PROPERTY(QRegion shape READ shape) /** * The Caption of the window. Read from WM_NAME property together with a suffix for hostname and shortcut. **/ Q_PROPERTY(QString caption READ caption) /** * Whether the window is set to be kept above other windows. **/ Q_PROPERTY(bool keepAbove READ keepAbove) /** * Whether the window is set to be kept below other windows. **/ Q_PROPERTY(bool keepBelow READ keepBelow) /** * Whether the window is minimized. **/ Q_PROPERTY(bool minimized READ isMinimized WRITE setMinimized) /** * Whether the window represents a modal window. **/ Q_PROPERTY(bool modal READ isModal) /** * Whether the window is moveable. Even if it is not moveable, it might be possible to move * it to another screen. * @see moveableAcrossScreens **/ Q_PROPERTY(bool moveable READ isMovable) /** * Whether the window can be moved to another screen. * @see moveable **/ Q_PROPERTY(bool moveableAcrossScreens READ isMovableAcrossScreens) /** * By how much the window wishes to grow/shrink at least. Usually QSize(1,1). * MAY BE DISOBEYED BY THE WM! It's only for information, do NOT rely on it at all. **/ Q_PROPERTY(QSize basicUnit READ basicUnit) /** * Whether the window is currently being moved by the user. **/ Q_PROPERTY(bool move READ isUserMove) /** * Whether the window is currently being resized by the user. **/ Q_PROPERTY(bool resize READ isUserResize) /** * The optional geometry representing the minimized Client in e.g a taskbar. * See _NET_WM_ICON_GEOMETRY at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(QRect iconGeometry READ iconGeometry) /** * Returns whether the window is any of special windows types (desktop, dock, splash, ...), * i.e. window types that usually don't have a window frame and the user does not use window * management (moving, raising,...) on them. **/ Q_PROPERTY(bool specialWindow READ isSpecialWindow) Q_PROPERTY(QIcon icon READ icon) /** * Whether the window should be excluded from window switching effects. **/ Q_PROPERTY(bool skipSwitcher READ isSkipSwitcher) /** * Geometry of the actual window contents inside the whole (including decorations) window. **/ Q_PROPERTY(QRect contentsRect READ contentsRect) /** * Geometry of the transparent rect in the decoration. * May be different from contentsRect if the decoration is extended into the client area. **/ Q_PROPERTY(QRect decorationInnerRect READ decorationInnerRect) Q_PROPERTY(bool hasDecoration READ hasDecoration) Q_PROPERTY(QStringList activities READ activities) Q_PROPERTY(bool onCurrentActivity READ isOnCurrentActivity) Q_PROPERTY(bool onAllActivities READ isOnAllActivities) /** * Whether the decoration currently uses an alpha channel. * @since 4.10 **/ Q_PROPERTY(bool decorationHasAlpha READ decorationHasAlpha) /** * Whether the window is currently visible to the user, that is: *
    *
  • Not minimized
  • *
  • On current desktop
  • *
  • On current activity
  • *
* @since 4.11 **/ Q_PROPERTY(bool visible READ isVisible) /** * Whether the window does not want to be animated on window close. * In case this property is @c true it is not useful to start an animation on window close. * The window will not be visible, but the animation hooks are executed. * @since 5.0 **/ Q_PROPERTY(bool skipsCloseAnimation READ skipsCloseAnimation) /** * Interface to the corresponding wayland surface. * relevant only in Wayland, on X11 it will be nullptr **/ Q_PROPERTY(KWayland::Server::SurfaceInterface *surface READ surface) /** * Whether the window is fullscreen. * @since 5.6 **/ Q_PROPERTY(bool fullScreen READ isFullScreen) /** * Whether this client is unresponsive. * * When an application failed to react on a ping request in time, it is * considered unresponsive. This usually indicates that the application froze or crashed. * * @since 5.10 **/ Q_PROPERTY(bool unresponsive READ isUnresponsive) /** * Whether this is a Wayland client. * @since 5.15 **/ Q_PROPERTY(bool waylandClient READ isWaylandClient CONSTANT) /** * Whether this is an X11 client. * @since 5.15 **/ Q_PROPERTY(bool x11Client READ isX11Client CONSTANT) /** * Whether the window is a popup. * * A popup is a window that can be used to implement tooltips, combo box popups, * popup menus and other similar user interface concepts. * * @since 5.15 **/ Q_PROPERTY(bool popupWindow READ isPopupWindow CONSTANT) /** * KWin internal window. Specific to Wayland platform. * * If the EffectWindow does not reference an internal window, this property is @c null. * @since 5.16 **/ Q_PROPERTY(QWindow *internalWindow READ internalWindow CONSTANT) /** * Whether this EffectWindow represents the outline. * * When compositing is turned on, the outline is an actual window. * * @since 5.16 **/ Q_PROPERTY(bool outline READ isOutline CONSTANT) public: /** Flags explaining why painting should be disabled */ enum { /** Window will not be painted */ PAINT_DISABLED = 1 << 0, /** Window will not be painted because it is deleted */ PAINT_DISABLED_BY_DELETE = 1 << 1, /** Window will not be painted because of which desktop it's on */ PAINT_DISABLED_BY_DESKTOP = 1 << 2, /** Window will not be painted because it is minimized */ PAINT_DISABLED_BY_MINIMIZE = 1 << 3, /** Window will not be painted because it is not the active window in a client group */ PAINT_DISABLED_BY_TAB_GROUP = 1 << 4, /** Window will not be painted because it's not on the current activity */ PAINT_DISABLED_BY_ACTIVITY = 1 << 5 }; explicit EffectWindow(QObject *parent = nullptr); - virtual ~EffectWindow(); + ~EffectWindow() override; virtual void enablePainting(int reason) = 0; virtual void disablePainting(int reason) = 0; virtual bool isPaintingEnabled() = 0; Q_SCRIPTABLE virtual void addRepaint(const QRect &r) = 0; Q_SCRIPTABLE virtual void addRepaint(int x, int y, int w, int h) = 0; Q_SCRIPTABLE virtual void addRepaintFull() = 0; Q_SCRIPTABLE virtual void addLayerRepaint(const QRect &r) = 0; Q_SCRIPTABLE virtual void addLayerRepaint(int x, int y, int w, int h) = 0; virtual void refWindow() = 0; virtual void unrefWindow() = 0; virtual bool isDeleted() const = 0; virtual bool isMinimized() const = 0; virtual double opacity() const = 0; virtual bool hasAlpha() const = 0; bool isOnCurrentActivity() const; Q_SCRIPTABLE bool isOnActivity(QString id) const; bool isOnAllActivities() const; virtual QStringList activities() const = 0; Q_SCRIPTABLE bool isOnDesktop(int d) const; bool isOnCurrentDesktop() const; bool isOnAllDesktops() const; /** * The desktop this window is in. This mkaes sense only on X11 * where desktops are mutually exclusive, on Wayland it's the last * desktop the window has been added to. * use desktops() instead. * @see desktops() * @deprecated **/ #ifndef KWIN_NO_DEPRECATED virtual int KWIN_DEPRECATED desktop() const = 0; // prefer isOnXXX() #endif /** * All the desktops by number that the window is in. On X11 this list will always have * a length of 1, on Wayland can be any subset. * If the list is empty it means the window is on all desktops **/ virtual QVector desktops() const = 0; virtual int x() const = 0; virtual int y() const = 0; virtual int width() const = 0; virtual int height() const = 0; /** * By how much the window wishes to grow/shrink at least. Usually QSize(1,1). * MAY BE DISOBEYED BY THE WM! It's only for information, do NOT rely on it at all. **/ virtual QSize basicUnit() const = 0; virtual QRect geometry() const = 0; /** * Geometry of the window including decoration and potentially shadows. * May be different from geometry() if the window has a shadow. * @since 4.9 **/ virtual QRect expandedGeometry() const = 0; virtual QRegion shape() const = 0; virtual int screen() const = 0; /** @internal Do not use */ virtual bool hasOwnShape() const = 0; // only for shadow effect, for now virtual QPoint pos() const = 0; virtual QSize size() const = 0; virtual QRect rect() const = 0; virtual bool isMovable() const = 0; virtual bool isMovableAcrossScreens() const = 0; virtual bool isUserMove() const = 0; virtual bool isUserResize() const = 0; virtual QRect iconGeometry() const = 0; /** * Geometry of the actual window contents inside the whole (including decorations) window. **/ virtual QRect contentsRect() const = 0; /** * Geometry of the transparent rect in the decoration. * May be different from contentsRect() if the decoration is extended into the client area. * @since 4.5 **/ virtual QRect decorationInnerRect() const = 0; bool hasDecoration() const; virtual bool decorationHasAlpha() const = 0; virtual QByteArray readProperty(long atom, long type, int format) const = 0; virtual void deleteProperty(long atom) const = 0; virtual QString caption() const = 0; virtual QIcon icon() const = 0; virtual QString windowClass() const = 0; virtual QString windowRole() const = 0; virtual const EffectWindowGroup* group() const = 0; /** * Returns whether the window is a desktop background window (the one with wallpaper). * See _NET_WM_WINDOW_TYPE_DESKTOP at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ virtual bool isDesktop() const = 0; /** * Returns whether the window is a dock (i.e. a panel). * See _NET_WM_WINDOW_TYPE_DOCK at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ virtual bool isDock() const = 0; /** * Returns whether the window is a standalone (detached) toolbar window. * See _NET_WM_WINDOW_TYPE_TOOLBAR at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ virtual bool isToolbar() const = 0; /** * Returns whether the window is a torn-off menu. * See _NET_WM_WINDOW_TYPE_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ virtual bool isMenu() const = 0; /** * Returns whether the window is a "normal" window, i.e. an application or any other window * for which none of the specialized window types fit. * See _NET_WM_WINDOW_TYPE_NORMAL at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ virtual bool isNormalWindow() const = 0; // normal as in 'NET::Normal or NET::Unknown non-transient' /** * Returns whether the window is any of special windows types (desktop, dock, splash, ...), * i.e. window types that usually don't have a window frame and the user does not use window * management (moving, raising,...) on them. **/ virtual bool isSpecialWindow() const = 0; /** * Returns whether the window is a dialog window. * See _NET_WM_WINDOW_TYPE_DIALOG at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ virtual bool isDialog() const = 0; /** * Returns whether the window is a splashscreen. Note that many (especially older) applications * do not support marking their splash windows with this type. * See _NET_WM_WINDOW_TYPE_SPLASH at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ virtual bool isSplash() const = 0; /** * Returns whether the window is a utility window, such as a tool window. * See _NET_WM_WINDOW_TYPE_UTILITY at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ virtual bool isUtility() const = 0; /** * Returns whether the window is a dropdown menu (i.e. a popup directly or indirectly open * from the applications menubar). * See _NET_WM_WINDOW_TYPE_DROPDOWN_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ virtual bool isDropdownMenu() const = 0; /** * Returns whether the window is a popup menu (that is not a torn-off or dropdown menu). * See _NET_WM_WINDOW_TYPE_POPUP_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ virtual bool isPopupMenu() const = 0; // a context popup, not dropdown, not torn-off /** * Returns whether the window is a tooltip. * See _NET_WM_WINDOW_TYPE_TOOLTIP at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ virtual bool isTooltip() const = 0; /** * Returns whether the window is a window with a notification. * See _NET_WM_WINDOW_TYPE_NOTIFICATION at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ virtual bool isNotification() const = 0; /** * Returns whether the window is a window with a critical notification. * using the non-standard _KDE_NET_WM_WINDOW_TYPE_CRITICAL_NOTIFICATION **/ virtual bool isCriticalNotification() const = 0; /** * Returns whether the window is an on screen display window * using the non-standard _KDE_NET_WM_WINDOW_TYPE_ON_SCREEN_DISPLAY **/ virtual bool isOnScreenDisplay() const = 0; /** * Returns whether the window is a combobox popup. * See _NET_WM_WINDOW_TYPE_COMBO at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ virtual bool isComboBox() const = 0; /** * Returns whether the window is a Drag&Drop icon. * See _NET_WM_WINDOW_TYPE_DND at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ virtual bool isDNDIcon() const = 0; /** * Returns the NETWM window type * See https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ virtual NET::WindowType windowType() const = 0; /** * Returns whether the window is managed by KWin (it has control over its placement and other * aspects, as opposed to override-redirect windows that are entirely handled by the application). **/ virtual bool isManaged() const = 0; // whether it's managed or override-redirect /** * Returns whether or not the window can accept keyboard focus. **/ virtual bool acceptsFocus() const = 0; /** * Returns whether or not the window is kept above all other windows. **/ virtual bool keepAbove() const = 0; /** * Returns whether the window is kept below all other windows. **/ virtual bool keepBelow() const = 0; virtual bool isModal() const = 0; Q_SCRIPTABLE virtual KWin::EffectWindow* findModal() = 0; Q_SCRIPTABLE virtual QList mainWindows() const = 0; /** * Returns whether the window should be excluded from window switching effects. * @since 4.5 **/ virtual bool isSkipSwitcher() const = 0; /** * Returns the unmodified window quad list. Can also be used to force rebuilding. **/ virtual WindowQuadList buildQuads(bool force = false) const = 0; void setMinimized(bool minimize); virtual void minimize() = 0; virtual void unminimize() = 0; Q_SCRIPTABLE virtual void closeWindow() = 0; virtual bool isCurrentTab() const = 0; /** * @since 4.11 **/ bool isVisible() const; /** * @since 5.0 **/ virtual bool skipsCloseAnimation() const = 0; /** * @since 5.5 **/ virtual KWayland::Server::SurfaceInterface *surface() const = 0; /** * @since 5.6 **/ virtual bool isFullScreen() const = 0; /** * @since 5.10 **/ virtual bool isUnresponsive() const = 0; /** * @since 5.15 **/ virtual bool isWaylandClient() const = 0; /** * @since 5.15 **/ virtual bool isX11Client() const = 0; /** * @since 5.15 **/ virtual bool isPopupWindow() const = 0; /** * @since 5.16 **/ virtual QWindow *internalWindow() const = 0; /** * @since 5.16 **/ virtual bool isOutline() const = 0; /** * Can be used to by effects to store arbitrary data in the EffectWindow. * * Invoking this method will emit the signal EffectsHandler::windowDataChanged. * @see EffectsHandler::windowDataChanged **/ Q_SCRIPTABLE virtual void setData(int role, const QVariant &data) = 0; Q_SCRIPTABLE virtual QVariant data(int role) const = 0; /** * @brief References the previous window pixmap to prevent discarding. * * This method allows to reference the previous window pixmap in case that a window changed * its size, which requires a new window pixmap. By referencing the previous (and then outdated) * window pixmap an effect can for example cross fade the current window pixmap with the previous * one. This allows for smoother transitions for window geometry changes. * * If an effect calls this method on a window it also needs to call unreferencePreviousWindowPixmap * once it does no longer need the previous window pixmap. * * Note: the window pixmap is not kept forever even when referenced. If the geometry changes again, so that * a new window pixmap is created, the previous window pixmap will be exchanged with the current one. This * means it's still possible to have rendering glitches. An effect is supposed to track for itself the changes * to the window's geometry and decide how the transition should continue in such a situation. * * @see unreferencePreviousWindowPixmap * @since 4.11 **/ virtual void referencePreviousWindowPixmap() = 0; /** * @brief Unreferences the previous window pixmap. Only relevant after referencePreviousWindowPixmap had * been called. * * @see referencePreviousWindowPixmap * @since 4.11 **/ virtual void unreferencePreviousWindowPixmap() = 0; private: class Private; QScopedPointer d; }; class KWINEFFECTS_EXPORT EffectWindowGroup { public: virtual ~EffectWindowGroup(); virtual EffectWindowList members() const = 0; }; struct GLVertex2D { QVector2D position; QVector2D texcoord; }; struct GLVertex3D { QVector3D position; QVector2D texcoord; }; /** * @short Vertex class * * A vertex is one position in a window. WindowQuad consists of four WindowVertex objects * and represents one part of a window. **/ class KWINEFFECTS_EXPORT WindowVertex { public: WindowVertex(); WindowVertex(const QPointF &position, const QPointF &textureCoordinate); WindowVertex(double x, double y, double tx, double ty); double x() const { return px; } double y() const { return py; } double u() const { return tx; } double v() const { return ty; } double originalX() const { return ox; } double originalY() const { return oy; } double textureX() const { return tx; } double textureY() const { return ty; } void move(double x, double y); void setX(double x); void setY(double y); private: friend class WindowQuad; friend class WindowQuadList; double px, py; // position double ox, oy; // origional position double tx, ty; // texture coords }; /** * @short Class representing one area of a window. * * WindowQuads consists of four WindowVertex objects and represents one part of a window. **/ // NOTE: This class expects the (original) vertices to be in the clockwise order starting from topleft. class KWINEFFECTS_EXPORT WindowQuad { public: explicit WindowQuad(WindowQuadType type, int id = -1); WindowQuad makeSubQuad(double x1, double y1, double x2, double y2) const; WindowVertex& operator[](int index); const WindowVertex& operator[](int index) const; WindowQuadType type() const; void setUVAxisSwapped(bool value) { uvSwapped = value; } bool uvAxisSwapped() const { return uvSwapped; } int id() const; bool decoration() const; bool effect() const; double left() const; double right() const; double top() const; double bottom() const; double originalLeft() const; double originalRight() const; double originalTop() const; double originalBottom() const; bool smoothNeeded() const; bool isTransformed() const; private: friend class WindowQuadList; WindowVertex verts[ 4 ]; WindowQuadType quadType; // 0 - contents, 1 - decoration bool uvSwapped; int quadID; }; class KWINEFFECTS_EXPORT WindowQuadList : public QList< WindowQuad > { public: WindowQuadList splitAtX(double x) const; WindowQuadList splitAtY(double y) const; WindowQuadList makeGrid(int maxquadsize) const; WindowQuadList makeRegularGrid(int xSubdivisions, int ySubdivisions) const; WindowQuadList select(WindowQuadType type) const; WindowQuadList filterOut(WindowQuadType type) const; bool smoothNeeded() const; void makeInterleavedArrays(unsigned int type, GLVertex2D *vertices, const QMatrix4x4 &matrix) const; void makeArrays(float** vertices, float** texcoords, const QSizeF &size, bool yInverted) const; bool isTransformed() const; }; class KWINEFFECTS_EXPORT WindowPrePaintData { public: int mask; /** * Region that will be painted, in screen coordinates. **/ QRegion paint; /** * The clip region will be subtracted from paint region of following windows. * I.e. window will definitely cover it's clip region **/ QRegion clip; WindowQuadList quads; /** * Simple helper that sets data to say the window will be painted as non-opaque. * Takes also care of changing the regions. **/ void setTranslucent(); /** * Helper to mark that this window will be transformed **/ void setTransformed(); }; class KWINEFFECTS_EXPORT PaintData { public: virtual ~PaintData(); /** * @returns scale factor in X direction. * @since 4.10 **/ qreal xScale() const; /** * @returns scale factor in Y direction. * @since 4.10 **/ qreal yScale() const; /** * @returns scale factor in Z direction. * @since 4.10 **/ qreal zScale() const; /** * Sets the scale factor in X direction to @p scale * @param scale The scale factor in X direction * @since 4.10 **/ void setXScale(qreal scale); /** * Sets the scale factor in Y direction to @p scale * @param scale The scale factor in Y direction * @since 4.10 **/ void setYScale(qreal scale); /** * Sets the scale factor in Z direction to @p scale * @param scale The scale factor in Z direction * @since 4.10 **/ void setZScale(qreal scale); /** * Sets the scale factor in X and Y direction. * @param scale The scale factor for X and Y direction * @since 4.10 **/ void setScale(const QVector2D &scale); /** * Sets the scale factor in X, Y and Z direction * @param scale The scale factor for X, Y and Z direction * @since 4.10 **/ void setScale(const QVector3D &scale); const QGraphicsScale &scale() const; const QVector3D &translation() const; /** * @returns the translation in X direction. * @since 4.10 **/ qreal xTranslation() const; /** * @returns the translation in Y direction. * @since 4.10 **/ qreal yTranslation() const; /** * @returns the translation in Z direction. * @since 4.10 **/ qreal zTranslation() const; /** * Sets the translation in X direction to @p translate. * @since 4.10 **/ void setXTranslation(qreal translate); /** * Sets the translation in Y direction to @p translate. * @since 4.10 **/ void setYTranslation(qreal translate); /** * Sets the translation in Z direction to @p translate. * @since 4.10 **/ void setZTranslation(qreal translate); /** * Performs a translation by adding the values component wise. * @param x Translation in X direction * @param y Translation in Y direction * @param z Translation in Z direction * @since 4.10 **/ void translate(qreal x, qreal y = 0.0, qreal z = 0.0); /** * Performs a translation by adding the values component wise. * Overloaded method for convenience. * @param translate The translation * @since 4.10 **/ void translate(const QVector3D &translate); /** * Sets the rotation angle. * @param angle The new rotation angle. * @since 4.10 * @see rotationAngle() **/ void setRotationAngle(qreal angle); /** * Returns the rotation angle. * Initially 0.0. * @returns The current rotation angle. * @since 4.10 * @see setRotationAngle **/ qreal rotationAngle() const; /** * Sets the rotation origin. * @param origin The new rotation origin. * @since 4.10 * @see rotationOrigin() **/ void setRotationOrigin(const QVector3D &origin); /** * Returns the rotation origin. That is the point in space which is fixed during the rotation. * Initially this is 0/0/0. * @returns The rotation's origin * @since 4.10 * @see setRotationOrigin() **/ QVector3D rotationOrigin() const; /** * Sets the rotation axis. * Set a component to 1.0 to rotate around this axis and to 0.0 to disable rotation around the * axis. * @param axis A vector holding information on which axis to rotate * @since 4.10 * @see rotationAxis() **/ void setRotationAxis(const QVector3D &axis); /** * Sets the rotation axis. * Overloaded method for convenience. * @param axis The axis around which should be rotated. * @since 4.10 * @see rotationAxis() **/ void setRotationAxis(Qt::Axis axis); /** * The current rotation axis. * By default the rotation is (0/0/1) which means a rotation around the z axis. * @returns The current rotation axis. * @since 4.10 * @see setRotationAxis **/ QVector3D rotationAxis() const; protected: PaintData(); PaintData(const PaintData &other); private: PaintDataPrivate * const d; }; class KWINEFFECTS_EXPORT WindowPaintData : public PaintData { public: explicit WindowPaintData(EffectWindow* w); explicit WindowPaintData(EffectWindow* w, const QMatrix4x4 &screenProjectionMatrix); WindowPaintData(const WindowPaintData &other); - virtual ~WindowPaintData(); + ~WindowPaintData() override; /** * Scales the window by @p scale factor. * Multiplies all three components by the given factor. * @since 4.10 **/ WindowPaintData& operator*=(qreal scale); /** * Scales the window by @p scale factor. * Performs a component wise multiplication on x and y components. * @since 4.10 **/ WindowPaintData& operator*=(const QVector2D &scale); /** * Scales the window by @p scale factor. * Performs a component wise multiplication. * @since 4.10 **/ WindowPaintData& operator*=(const QVector3D &scale); /** * Translates the window by the given @p translation and returns a reference to the ScreenPaintData. * @since 4.10 **/ WindowPaintData& operator+=(const QPointF &translation); /** * Translates the window by the given @p translation and returns a reference to the ScreenPaintData. * Overloaded method for convenience. * @since 4.10 **/ WindowPaintData& operator+=(const QPoint &translation); /** * Translates the window by the given @p translation and returns a reference to the ScreenPaintData. * Overloaded method for convenience. * @since 4.10 **/ WindowPaintData& operator+=(const QVector2D &translation); /** * Translates the window by the given @p translation and returns a reference to the ScreenPaintData. * Overloaded method for convenience. * @since 4.10 **/ WindowPaintData& operator+=(const QVector3D &translation); /** * Window opacity, in range 0 = transparent to 1 = fully opaque * @see setOpacity * @since 4.10 **/ qreal opacity() const; /** * Sets the window opacity to the new @p opacity. * If you want to modify the existing opacity level consider using multiplyOpacity. * @param opacity The new opacity level * @since 4.10 **/ void setOpacity(qreal opacity); /** * Multiplies the current opacity with the @p factor. * @param factor Factor with which the opacity should be multiplied * @return New opacity level * @since 4.10 **/ qreal multiplyOpacity(qreal factor); /** * Saturation of the window, in range [0; 1] * 1 means that the window is unchanged, 0 means that it's completely * unsaturated (greyscale). 0.5 would make the colors less intense, * but not completely grey * Use EffectsHandler::saturationSupported() to find out whether saturation * is supported by the system, otherwise this value has no effect. * @return The current saturation * @see setSaturation() * @since 4.10 **/ qreal saturation() const; /** * Sets the window saturation level to @p saturation. * If you want to modify the existing saturation level consider using multiplySaturation. * @param saturation The new saturation level * @since 4.10 **/ void setSaturation(qreal saturation) const; /** * Multiplies the current saturation with @p factor. * @param factor with which the saturation should be multiplied * @return New saturation level * @since 4.10 **/ qreal multiplySaturation(qreal factor); /** * Brightness of the window, in range [0; 1] * 1 means that the window is unchanged, 0 means that it's completely * black. 0.5 would make it 50% darker than usual **/ qreal brightness() const; /** * Sets the window brightness level to @p brightness. * If you want to modify the existing brightness level consider using multiplyBrightness. * @param brightness The new brightness level **/ void setBrightness(qreal brightness); /** * Multiplies the current brightness level with @p factor. * @param factor with which the brightness should be multiplied. * @return New brightness level * @since 4.10 **/ qreal multiplyBrightness(qreal factor); /** * The screen number for which the painting should be done. * This affects color correction (different screens may need different * color correction lookup tables because they have different ICC profiles). * @return screen for which painting should be done **/ int screen() const; /** * @param screen New screen number * A value less than 0 will indicate that a default profile should be done. **/ void setScreen(int screen) const; /** * @brief Sets the cross fading @p factor to fade over with previously sized window. * If @c 1.0 only the current window is used, if @c 0.0 only the previous window is used. * * By default only the current window is used. This factor can only make any visual difference * if the previous window get referenced. * * @param factor The cross fade factor between @c 0.0 (previous window) and @c 1.0 (current window) * @see crossFadeProgress **/ void setCrossFadeProgress(qreal factor); /** * @see setCrossFadeProgress **/ qreal crossFadeProgress() const; /** * Sets the projection matrix that will be used when painting the window. * * The default projection matrix can be overridden by setting this matrix * to a non-identity matrix. **/ void setProjectionMatrix(const QMatrix4x4 &matrix); /** * Returns the current projection matrix. * * The default value for this matrix is the identity matrix. **/ QMatrix4x4 projectionMatrix() const; /** * Returns a reference to the projection matrix. **/ QMatrix4x4 &rprojectionMatrix(); /** * Sets the model-view matrix that will be used when painting the window. * * The default model-view matrix can be overridden by setting this matrix * to a non-identity matrix. **/ void setModelViewMatrix(const QMatrix4x4 &matrix); /** * Returns the current model-view matrix. * * The default value for this matrix is the identity matrix. **/ QMatrix4x4 modelViewMatrix() const; /** * Returns a reference to the model-view matrix. **/ QMatrix4x4 &rmodelViewMatrix(); /** * Returns The projection matrix as used by the current screen painting pass * including screen transformations. * * @since 5.6 **/ QMatrix4x4 screenProjectionMatrix() const; WindowQuadList quads; /** * Shader to be used for rendering, if any. **/ GLShader* shader; private: WindowPaintDataPrivate * const d; }; class KWINEFFECTS_EXPORT ScreenPaintData : public PaintData { public: ScreenPaintData(); ScreenPaintData(const QMatrix4x4 &projectionMatrix, const QRect &outputGeometry = QRect()); ScreenPaintData(const ScreenPaintData &other); - virtual ~ScreenPaintData(); + ~ScreenPaintData() override; /** * Scales the screen by @p scale factor. * Multiplies all three components by the given factor. * @since 4.10 **/ ScreenPaintData& operator*=(qreal scale); /** * Scales the screen by @p scale factor. * Performs a component wise multiplication on x and y components. * @since 4.10 **/ ScreenPaintData& operator*=(const QVector2D &scale); /** * Scales the screen by @p scale factor. * Performs a component wise multiplication. * @since 4.10 **/ ScreenPaintData& operator*=(const QVector3D &scale); /** * Translates the screen by the given @p translation and returns a reference to the ScreenPaintData. * @since 4.10 **/ ScreenPaintData& operator+=(const QPointF &translation); /** * Translates the screen by the given @p translation and returns a reference to the ScreenPaintData. * Overloaded method for convenience. * @since 4.10 **/ ScreenPaintData& operator+=(const QPoint &translation); /** * Translates the screen by the given @p translation and returns a reference to the ScreenPaintData. * Overloaded method for convenience. * @since 4.10 **/ ScreenPaintData& operator+=(const QVector2D &translation); /** * Translates the screen by the given @p translation and returns a reference to the ScreenPaintData. * Overloaded method for convenience. * @since 4.10 **/ ScreenPaintData& operator+=(const QVector3D &translation); ScreenPaintData& operator=(const ScreenPaintData &rhs); /** * The projection matrix used by the scene for the current rendering pass. * On non-OpenGL compositors it's set to Identity matrix. * @since 5.6 **/ QMatrix4x4 projectionMatrix() const; /** * The geometry of the currently rendered output. * Only set for per-output rendering (e.g. Wayland). * * This geometry can be used as a hint about the native window the OpenGL context * is bound. OpenGL calls need to be translated to this geometry. * @since 5.9 **/ QRect outputGeometry() const; private: class Private; QScopedPointer d; }; class KWINEFFECTS_EXPORT ScreenPrePaintData { public: int mask; QRegion paint; }; /** * @short Helper class for restricting painting area only to allowed area. * * This helper class helps specifying areas that should be painted, clipping * out the rest. The simplest usage is creating an object on the stack * and giving it the area that is allowed to be painted to. When the object * is destroyed, the restriction will be removed. * Note that all painting code must use paintArea() to actually perform the clipping. **/ class KWINEFFECTS_EXPORT PaintClipper { public: /** * Calls push(). **/ explicit PaintClipper(const QRegion& allowed_area); /** * Calls pop(). **/ ~PaintClipper(); /** * Allows painting only in the given area. When areas have been already * specified, painting is allowed only in the intersection of all areas. **/ static void push(const QRegion& allowed_area); /** * Removes the given area. It must match the top item in the stack. **/ static void pop(const QRegion& allowed_area); /** * Returns true if any clipping should be performed. **/ static bool clip(); /** * If clip() returns true, this function gives the resulting area in which * painting is allowed. It is usually simpler to use the helper Iterator class. **/ static QRegion paintArea(); /** * Helper class to perform the clipped painting. The usage is: * @code * for ( PaintClipper::Iterator iterator; * !iterator.isDone(); * iterator.next()) * { // do the painting, possibly use iterator.boundingRect() * } * @endcode **/ class KWINEFFECTS_EXPORT Iterator { public: Iterator(); ~Iterator(); bool isDone(); void next(); QRect boundingRect() const; private: struct Data; Data* data; }; private: QRegion area; static QStack< QRegion >* areas; }; /** * @internal **/ template class KWINEFFECTS_EXPORT Motion { public: /** * Creates a new motion object. "Strength" is the amount of * acceleration that is applied to the object when the target * changes and "smoothness" relates to how fast the object * can change its direction and speed. **/ explicit Motion(T initial, double strength, double smoothness); /** * Creates an exact copy of another motion object, including * position, target and velocity. **/ Motion(const Motion &other); ~Motion(); inline T value() const { return m_value; } inline void setValue(const T value) { m_value = value; } inline T target() const { return m_target; } inline void setTarget(const T target) { m_start = m_value; m_target = target; } inline T velocity() const { return m_velocity; } inline void setVelocity(const T velocity) { m_velocity = velocity; } inline double strength() const { return m_strength; } inline void setStrength(const double strength) { m_strength = strength; } inline double smoothness() const { return m_smoothness; } inline void setSmoothness(const double smoothness) { m_smoothness = smoothness; } inline T startValue() { return m_start; } /** * The distance between the current position and the target. **/ inline T distance() const { return m_target - m_value; } /** * Calculates the new position if not at the target. Called * once per frame only. **/ void calculate(const int msec); /** * Place the object on top of the target immediately, * bypassing all movement calculation. **/ void finish(); private: T m_value; T m_start; T m_target; T m_velocity; double m_strength; double m_smoothness; }; /** * @short A single 1D motion dynamics object. * * This class represents a single object that can be moved around a * 1D space. Although it can be used directly by itself it is * recommended to use a motion manager instead. **/ class KWINEFFECTS_EXPORT Motion1D : public Motion { public: explicit Motion1D(double initial = 0.0, double strength = 0.08, double smoothness = 4.0); Motion1D(const Motion1D &other); ~Motion1D(); }; /** * @short A single 2D motion dynamics object. * * This class represents a single object that can be moved around a * 2D space. Although it can be used directly by itself it is * recommended to use a motion manager instead. **/ class KWINEFFECTS_EXPORT Motion2D : public Motion { public: explicit Motion2D(QPointF initial = QPointF(), double strength = 0.08, double smoothness = 4.0); Motion2D(const Motion2D &other); ~Motion2D(); }; /** * @short Helper class for motion dynamics in KWin effects. * * This motion manager class is intended to help KWin effect authors * move windows across the screen smoothly and naturally. Once * windows are registered by the manager the effect can issue move * commands with the moveWindow() methods. The position of any * managed window can be determined in realtime by the * transformedGeometry() method. As the manager knows if any windows * are moving at any given time it can also be used as a notifier as * to see whether the effect is active or not. **/ class KWINEFFECTS_EXPORT WindowMotionManager { public: /** * Creates a new window manager object. **/ explicit WindowMotionManager(bool useGlobalAnimationModifier = true); ~WindowMotionManager(); /** * Register a window for managing. **/ void manage(EffectWindow *w); /** * Register a list of windows for managing. **/ inline void manage(EffectWindowList list) { for (int i = 0; i < list.size(); i++) manage(list.at(i)); } /** * Deregister a window. All transformations applied to the * window will be permanently removed and cannot be recovered. **/ void unmanage(EffectWindow *w); /** * Deregister all windows, returning the manager to its * originally initiated state. **/ void unmanageAll(); /** * Determine the new positions for windows that have not * reached their target. Called once per frame, usually in * prePaintScreen(). Remember to set the * Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS flag. **/ void calculate(int time); /** * Modify a registered window's paint data to make it appear * at its real location on the screen. Usually called in * paintWindow(). Remember to flag the window as having been * transformed in prePaintWindow() by calling * WindowPrePaintData::setTransformed() **/ void apply(EffectWindow *w, WindowPaintData &data); /** * Set all motion targets and values back to where the * windows were before transformations. The same as * unmanaging then remanaging all windows. **/ void reset(); /** * Resets the motion target and current value of a single * window. **/ void reset(EffectWindow *w); /** * Ask the manager to move the window to the target position * with the specified scale. If `yScale` is not provided or * set to 0.0, `scale` will be used as the scale in the * vertical direction as well as in the horizontal direction. **/ void moveWindow(EffectWindow *w, QPoint target, double scale = 1.0, double yScale = 0.0); /** * This is an overloaded method, provided for convenience. * * Ask the manager to move the window to the target rectangle. * Automatically determines scale. **/ inline void moveWindow(EffectWindow *w, QRect target) { // TODO: Scale might be slightly different in the comparison due to rounding moveWindow(w, target.topLeft(), target.width() / double(w->width()), target.height() / double(w->height())); } /** * Retrieve the current tranformed geometry of a registered * window. **/ QRectF transformedGeometry(EffectWindow *w) const; /** * Sets the current transformed geometry of a registered window to the given geometry. * @see transformedGeometry * @since 4.5 **/ void setTransformedGeometry(EffectWindow *w, const QRectF &geometry); /** * Retrieve the current target geometry of a registered * window. **/ QRectF targetGeometry(EffectWindow *w) const; /** * Return the window that has its transformed geometry under * the specified point. It is recommended to use the stacking * order as it's what the user sees, but it is slightly * slower to process. **/ EffectWindow* windowAtPoint(QPoint point, bool useStackingOrder = true) const; /** * Return a list of all currently registered windows. **/ inline EffectWindowList managedWindows() const { return m_managedWindows.keys(); } /** * Returns whether or not a specified window is being managed * by this manager object. **/ inline bool isManaging(EffectWindow *w) const { return m_managedWindows.contains(w); } /** * Returns whether or not this manager object is actually * managing any windows or not. **/ inline bool managingWindows() const { return !m_managedWindows.empty(); } /** * Returns whether all windows have reached their targets yet * or not. Can be used to see if an effect should be * processed and displayed or not. **/ inline bool areWindowsMoving() const { return !m_movingWindowsSet.isEmpty(); } /** * Returns whether a window has reached its targets yet * or not. **/ inline bool isWindowMoving(EffectWindow *w) const { return m_movingWindowsSet.contains(w); } private: bool m_useGlobalAnimationModifier; struct WindowMotion { // TODO: Rotation, etc? Motion2D translation; // Absolute position Motion2D scale; // xScale and yScale }; QHash m_managedWindows; QSet m_movingWindowsSet; }; /** * @short Helper class for displaying text and icons in frames. * * Paints text and/or and icon with an optional frame around them. The * available frames includes one that follows the default Plasma theme and * another that doesn't. * It is recommended to use this class whenever displaying text. **/ class KWINEFFECTS_EXPORT EffectFrame { public: EffectFrame(); virtual ~EffectFrame(); /** * Delete any existing textures to free up graphics memory. They will * be automatically recreated the next time they are required. **/ virtual void free() = 0; /** * Render the frame. **/ virtual void render(QRegion region = infiniteRegion(), double opacity = 1.0, double frameOpacity = 1.0) = 0; virtual void setPosition(const QPoint& point) = 0; /** * Set the text alignment for static frames and the position alignment * for non-static. **/ virtual void setAlignment(Qt::Alignment alignment) = 0; virtual Qt::Alignment alignment() const = 0; virtual void setGeometry(const QRect& geometry, bool force = false) = 0; virtual const QRect& geometry() const = 0; virtual void setText(const QString& text) = 0; virtual const QString& text() const = 0; virtual void setFont(const QFont& font) = 0; virtual const QFont& font() const = 0; /** * Set the icon that will appear on the left-hand size of the frame. **/ virtual void setIcon(const QIcon& icon) = 0; virtual const QIcon& icon() const = 0; virtual void setIconSize(const QSize& size) = 0; virtual const QSize& iconSize() const = 0; /** * Sets the geometry of a selection. * To remove the selection set a null rect. * @param selection The geometry of the selection in screen coordinates. **/ virtual void setSelection(const QRect& selection) = 0; /** * @param shader The GLShader for rendering. **/ virtual void setShader(GLShader* shader) = 0; /** * @returns The GLShader used for rendering or null if none. **/ virtual GLShader* shader() const = 0; /** * @returns The style of this EffectFrame. **/ virtual EffectFrameStyle style() const = 0; /** * If @p enable is @c true cross fading between icons and text is enabled * By default disabled. Use setCrossFadeProgress to cross fade. * Cross Fading is currently only available if OpenGL is used. * @param enable @c true enables cross fading, @c false disables it again * @see isCrossFade * @see setCrossFadeProgress * @since 4.6 **/ void enableCrossFade(bool enable); /** * @returns @c true if cross fading is enabled, @c false otherwise * @see enableCrossFade * @since 4.6 **/ bool isCrossFade() const; /** * Sets the current progress for cross fading the last used icon/text * with current icon/text to @p progress. * A value of 0.0 means completely old icon/text, a value of 1.0 means * completely current icon/text. * Default value is 1.0. You have to enable cross fade before using it. * Cross Fading is currently only available if OpenGL is used. * @see enableCrossFade * @see isCrossFade * @see crossFadeProgress * @since 4.6 **/ void setCrossFadeProgress(qreal progress); /** * @returns The current progress for cross fading * @see setCrossFadeProgress * @see enableCrossFade * @see isCrossFade * @since 4.6 **/ qreal crossFadeProgress() const; /** * Returns The projection matrix as used by the current screen painting pass * including screen transformations. * * This matrix is only valid during a rendering pass started by render. * * @since 5.6 * @see render * @see EffectsHandler::paintEffectFrame * @see Effect::paintEffectFrame **/ QMatrix4x4 screenProjectionMatrix() const; protected: void setScreenProjectionMatrix(const QMatrix4x4 &projection); private: EffectFramePrivate* const d; }; /** * The TimeLine class is a helper for controlling animations. **/ class KWINEFFECTS_EXPORT TimeLine { public: /** * Direction of the timeline. * * When the direction of the timeline is Forward, the progress * value will go from 0.0 to 1.0. * * When the direction of the timeline is Backward, the progress * value will go from 1.0 to 0.0. **/ enum Direction { Forward, Backward }; /** * Constructs a new instance of TimeLine. * * @param duration Duration of the timeline, in milliseconds * @param direction Direction of the timeline * @since 5.14 **/ explicit TimeLine(std::chrono::milliseconds duration = std::chrono::milliseconds(1000), Direction direction = Forward); TimeLine(const TimeLine &other); ~TimeLine(); /** * Returns the current value of the timeline. * * @since 5.14 **/ qreal value() const; /** * Updates the progress of the timeline. * * @note The delta value should be a non-negative number, i.e. it * should be greater or equal to 0. * * @param delta The number milliseconds passed since last frame * @since 5.14 **/ void update(std::chrono::milliseconds delta); /** * Returns the number of elapsed milliseconds. * * @see setElapsed * @since 5.14 **/ std::chrono::milliseconds elapsed() const; /** * Sets the number of elapsed milliseconds. * * This method overwrites previous value of elapsed milliseconds. * If the new value of elapsed milliseconds is greater or equal * to duration of the timeline, the timeline will be finished, i.e. * proceeding TimeLine::done method calls will return @c true. * Please don't use it. Instead, use TimeLine::update. * * @note The new number of elapsed milliseconds should be a non-negative * number, i.e. it should be greater or equal to 0. * * @param elapsed The new number of elapsed milliseconds * @see elapsed * @since 5.14 **/ void setElapsed(std::chrono::milliseconds elapsed); /** * Returns the duration of the timeline. * * @returns Duration of the timeline, in milliseconds * @see setDuration * @since 5.14 **/ std::chrono::milliseconds duration() const; /** * Sets the duration of the timeline. * * In addition to setting new value of duration, the timeline will * try to retarget the number of elapsed milliseconds to match * as close as possible old progress value. If the new duration * is much smaller than old duration, there is a big chance that * the timeline will be finished after setting new duration. * * @note The new duration should be a positive number, i.e. it * should be greater or equal to 1. * * @param duration The new duration of the timeline, in milliseconds * @see duration * @since 5.14 **/ void setDuration(std::chrono::milliseconds duration); /** * Returns the direction of the timeline. * * @returns Direction of the timeline(TimeLine::Forward or TimeLine::Backward) * @see setDirection * @see toggleDirection * @since 5.14 **/ Direction direction() const; /** * Sets the direction of the timeline. * * @param direction The new direction of the timeline * @see direction * @see toggleDirection * @since 5.14 **/ void setDirection(Direction direction); /** * Toggles the direction of the timeline. * * If the direction of the timeline was TimeLine::Forward, it becomes * TimeLine::Backward, and vice verca. * * @see direction * @see setDirection * @since 5.14 **/ void toggleDirection(); /** * Returns the easing curve of the timeline. * * @see setEasingCurve * @since 5.14 **/ QEasingCurve easingCurve() const; /** * Sets new easing curve. * * @param easingCurve An easing curve to be set * @see easingCurve * @since 5.14 **/ void setEasingCurve(const QEasingCurve &easingCurve); /** * Sets new easing curve by providing its type. * * @param type Type of the easing curve(e.g. QEasingCurve::InQuad, etc) * @see easingCurve * @since 5.14 **/ void setEasingCurve(QEasingCurve::Type type); /** * Returns whether the timeline is currently in progress. * * @see done * @since 5.14 **/ bool running() const; /** * Returns whether the timeline is finished. * * @see reset * @since 5.14 **/ bool done() const; /** * Resets the timeline to initial state. * * @since 5.14 **/ void reset(); enum class RedirectMode { Strict, Relaxed }; /** * Returns the redirect mode for the source position. * * The redirect mode controls behavior of the timeline when its direction is * changed at the source position, e.g. what should we do when the timeline * initially goes forward and we change its direction to go backward. * * In the strict mode, the timeline will stop. * * In the relaxed mode, the timeline will go in the new direction. For example, * if the timeline goes forward(from 0 to 1), then with the new direction it * will go backward(from 1 to 0). * * The default is RedirectMode::Relaxed. * * @see targetRedirectMode * @since 5.15 **/ RedirectMode sourceRedirectMode() const; /** * Sets the redirect mode for the source position. * * @param mode The new mode. * @since 5.15 **/ void setSourceRedirectMode(RedirectMode mode); /** * Returns the redirect mode for the target position. * * The redirect mode controls behavior of the timeline when its direction is * changed at the target position. * * In the strict mode, subsequent update calls won't have any effect on the * current value of the timeline. * * In the relaxed mode, the timeline will go in the new direction. * * The default is RedirectMode::Strict. * * @see sourceRedirectMode * @since 5.15 **/ RedirectMode targetRedirectMode() const; /** * Sets the redirect mode for the target position. * * @param mode The new mode. * @since 5.15 **/ void setTargetRedirectMode(RedirectMode mode); TimeLine &operator=(const TimeLine &other); private: qreal progress() const; private: class Data; QSharedDataPointer d; }; /** * Pointer to the global EffectsHandler object. **/ extern KWINEFFECTS_EXPORT EffectsHandler* effects; /*************************************************************** WindowVertex ***************************************************************/ inline WindowVertex::WindowVertex() : px(0), py(0), ox(0), oy(0), tx(0), ty(0) { } inline WindowVertex::WindowVertex(double _x, double _y, double _tx, double _ty) : px(_x), py(_y), ox(_x), oy(_y), tx(_tx), ty(_ty) { } inline WindowVertex::WindowVertex(const QPointF &position, const QPointF &texturePosition) : px(position.x()), py(position.y()), ox(position.x()), oy(position.y()), tx(texturePosition.x()), ty(texturePosition.y()) { } inline void WindowVertex::move(double x, double y) { px = x; py = y; } inline void WindowVertex::setX(double x) { px = x; } inline void WindowVertex::setY(double y) { py = y; } /*************************************************************** WindowQuad ***************************************************************/ inline WindowQuad::WindowQuad(WindowQuadType t, int id) : quadType(t) , uvSwapped(false) , quadID(id) { } inline WindowVertex& WindowQuad::operator[](int index) { assert(index >= 0 && index < 4); return verts[ index ]; } inline const WindowVertex& WindowQuad::operator[](int index) const { assert(index >= 0 && index < 4); return verts[ index ]; } inline WindowQuadType WindowQuad::type() const { assert(quadType != WindowQuadError); return quadType; } inline int WindowQuad::id() const { return quadID; } inline bool WindowQuad::decoration() const { assert(quadType != WindowQuadError); return quadType == WindowQuadDecoration; } inline bool WindowQuad::effect() const { assert(quadType != WindowQuadError); return quadType >= EFFECT_QUAD_TYPE_START; } inline bool WindowQuad::isTransformed() const { return !(verts[ 0 ].px == verts[ 0 ].ox && verts[ 0 ].py == verts[ 0 ].oy && verts[ 1 ].px == verts[ 1 ].ox && verts[ 1 ].py == verts[ 1 ].oy && verts[ 2 ].px == verts[ 2 ].ox && verts[ 2 ].py == verts[ 2 ].oy && verts[ 3 ].px == verts[ 3 ].ox && verts[ 3 ].py == verts[ 3 ].oy); } inline double WindowQuad::left() const { return qMin(verts[ 0 ].px, qMin(verts[ 1 ].px, qMin(verts[ 2 ].px, verts[ 3 ].px))); } inline double WindowQuad::right() const { return qMax(verts[ 0 ].px, qMax(verts[ 1 ].px, qMax(verts[ 2 ].px, verts[ 3 ].px))); } inline double WindowQuad::top() const { return qMin(verts[ 0 ].py, qMin(verts[ 1 ].py, qMin(verts[ 2 ].py, verts[ 3 ].py))); } inline double WindowQuad::bottom() const { return qMax(verts[ 0 ].py, qMax(verts[ 1 ].py, qMax(verts[ 2 ].py, verts[ 3 ].py))); } inline double WindowQuad::originalLeft() const { return verts[ 0 ].ox; } inline double WindowQuad::originalRight() const { return verts[ 2 ].ox; } inline double WindowQuad::originalTop() const { return verts[ 0 ].oy; } inline double WindowQuad::originalBottom() const { return verts[ 2 ].oy; } /*************************************************************** Motion ***************************************************************/ template Motion::Motion(T initial, double strength, double smoothness) : m_value(initial) , m_start(initial) , m_target(initial) , m_velocity() , m_strength(strength) , m_smoothness(smoothness) { } template Motion::Motion(const Motion &other) : m_value(other.value()) , m_start(other.target()) , m_target(other.target()) , m_velocity(other.velocity()) , m_strength(other.strength()) , m_smoothness(other.smoothness()) { } template Motion::~Motion() { } template void Motion::calculate(const int msec) { if (m_value == m_target && m_velocity == T()) // At target and not moving return; // Poor man's time independent calculation int steps = qMax(1, msec / 5); for (int i = 0; i < steps; i++) { T diff = m_target - m_value; T strength = diff * m_strength; m_velocity = (m_smoothness * m_velocity + strength) / (m_smoothness + 1.0); m_value += m_velocity; } } template void Motion::finish() { m_value = m_target; m_velocity = T(); } /*************************************************************** Effect ***************************************************************/ template int Effect::animationTime(int defaultDuration) { return animationTime(T::duration() != 0 ? T::duration() : defaultDuration); } template void Effect::initConfig() { T::instance(effects->config()); } } // namespace Q_DECLARE_METATYPE(KWin::EffectWindow*) Q_DECLARE_METATYPE(QList) Q_DECLARE_METATYPE(KWin::TimeLine) Q_DECLARE_METATYPE(KWin::TimeLine::Direction) /** @} */ #endif // KWINEFFECTS_H diff --git a/logind.h b/logind.h index 40e3c4f70..c5ff17274 100644 --- a/logind.h +++ b/logind.h @@ -1,112 +1,112 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 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_LOGIND_H #define KWIN_LOGIND_H #include #include #include class QDBusServiceWatcher; namespace KWin { class KWIN_EXPORT LogindIntegration : public QObject { Q_OBJECT public: - ~LogindIntegration(); + ~LogindIntegration() override; bool isConnected() const { return m_connected; } bool hasSessionControl() const { return m_sessionControl; } bool isActiveSession() const { return m_sessionActive; } int vt() const { return m_vt; } void switchVirtualTerminal(quint32 vtNr); void takeControl(); void releaseControl(); int takeDevice(const char *path); void releaseDevice(int fd); const QString seat() const { return m_seatName; } Q_SIGNALS: void connectedChanged(); void hasSessionControlChanged(bool); void sessionActiveChanged(bool); void virtualTerminalChanged(int); private Q_SLOTS: void getSessionActive(); void getVirtualTerminal(); void pauseDevice(uint major, uint minor, const QString &type); private: friend class LogindTest; /** * The DBusConnection argument is needed for the unit test. Logind uses the system bus * on which the unit test's fake logind cannot register to. Thus the unit test need to * be able to do everything over the session bus. This ctor allows the LogindTest to * create a LogindIntegration which listens on the session bus. **/ explicit LogindIntegration(const QDBusConnection &connection, QObject *parent = nullptr); void logindServiceRegistered(); void connectSessionPropertiesChanged(); enum SessionController { SessionControllerLogind, SessionControllerConsoleKit, }; void setupSessionController(SessionController controller); void getSeat(); QDBusConnection m_bus; QDBusServiceWatcher *m_logindServiceWatcher; bool m_connected; QString m_sessionPath; bool m_sessionControl; bool m_sessionActive; int m_vt = -1; QString m_seatName = QStringLiteral("seat0"); QString m_seatPath; QString m_sessionControllerName; QString m_sessionControllerService; QString m_sessionControllerPath; QString m_sessionControllerManagerInterface; QString m_sessionControllerSeatInterface; QString m_sessionControllerSessionInterface; QString m_sessionControllerActiveProperty; KWIN_SINGLETON(LogindIntegration) }; } #endif diff --git a/main.h b/main.h index 0f899bd83..36a5acde9 100644 --- a/main.h +++ b/main.h @@ -1,292 +1,292 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 1999, 2000 Matthias Ettrich Copyright (C) 2003 Lubos Lunak 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 MAIN_H #define MAIN_H #include #include #include // Qt #include #include #include class KPluginMetaData; class QCommandLineParser; namespace KWin { class Platform; class XcbEventFilter : public QAbstractNativeEventFilter { public: - virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long int *result) override; + bool nativeEventFilter(const QByteArray &eventType, void *message, long int *result) override; }; class KWIN_EXPORT Application : public QApplication { Q_OBJECT Q_PROPERTY(quint32 x11Time READ x11Time WRITE setX11Time) Q_PROPERTY(quint32 x11RootWindow READ x11RootWindow CONSTANT) Q_PROPERTY(void *x11Connection READ x11Connection NOTIFY x11ConnectionChanged) Q_PROPERTY(int x11ScreenNumber READ x11ScreenNumber CONSTANT) Q_PROPERTY(KSharedConfigPtr config READ config WRITE setConfig) Q_PROPERTY(KSharedConfigPtr kxkbConfig READ kxkbConfig WRITE setKxkbConfig) Q_PROPERTY(KSharedConfigPtr inputConfig READ inputConfig WRITE setInputConfig) public: /** * @brief This enum provides the various operation modes of KWin depending on the available * Windowing Systems at startup. For example whether KWin only talks to X11 or also to a Wayland * Compositor. * **/ enum OperationMode { /** * @brief KWin uses only X11 for managing windows and compositing **/ OperationModeX11, /** * @brief KWin uses only Wayland **/ OperationModeWaylandOnly, /** * @brief KWin uses Wayland and controls a nested Xwayland server. **/ OperationModeXwayland }; - virtual ~Application(); + ~Application() override; void setConfigLock(bool lock); KSharedConfigPtr config() const { return m_config; } void setConfig(KSharedConfigPtr config) { m_config = config; } KSharedConfigPtr kxkbConfig() const { return m_kxkbConfig; } void setKxkbConfig(KSharedConfigPtr config) { m_kxkbConfig = config; } KSharedConfigPtr inputConfig() const { return m_inputConfig; } void setInputConfig(KSharedConfigPtr config) { m_inputConfig = config; } void start(); /** * @brief The operation mode used by KWin. * * @return OperationMode **/ OperationMode operationMode() const; void setOperationMode(OperationMode mode); bool shouldUseWaylandForCompositing() const; void setupTranslator(); void setupCommandLine(QCommandLineParser *parser); void processCommandLine(QCommandLineParser *parser); xcb_timestamp_t x11Time() const { return m_x11Time; } enum class TimestampUpdate { OnlyIfLarger, Always }; void setX11Time(xcb_timestamp_t timestamp, TimestampUpdate force = TimestampUpdate::OnlyIfLarger) { if ((timestamp > m_x11Time || force == TimestampUpdate::Always) && timestamp != 0) { m_x11Time = timestamp; } } void updateX11Time(xcb_generic_event_t *event); void createScreens(); static void setCrashCount(int count); static bool wasCrash(); /** * Creates the KAboutData object for the KWin instance and registers it as * KAboutData::setApplicationData. **/ static void createAboutData(); /** * @returns the X11 Screen number. If not applicable it's set to @c -1. **/ static int x11ScreenNumber(); /** * Sets the X11 screen number of this KWin instance to @p screenNumber. **/ static void setX11ScreenNumber(int screenNumber); /** * @returns whether this is a multi head setup on X11. **/ static bool isX11MultiHead(); /** * Sets whether this is a multi head setup on X11. **/ static void setX11MultiHead(bool multiHead); /** * @returns the X11 root window. **/ xcb_window_t x11RootWindow() const { return m_rootWindow; } /** * @returns the X11 xcb connection **/ xcb_connection_t *x11Connection() const { return m_connection; } #ifdef KWIN_BUILD_ACTIVITIES bool usesKActivities() const { return m_useKActivities; } void setUseKActivities(bool use) { m_useKActivities = use; } #endif virtual QProcessEnvironment processStartupEnvironment() const; void initPlatform(const KPluginMetaData &plugin); Platform *platform() const { return m_platform; } bool isTerminating() const { return m_terminating; } static void setupMalloc(); static void setupLocalizedString(); static bool usesLibinput(); static void setUseLibinput(bool use); Q_SIGNALS: void x11ConnectionChanged(); void x11ConnectionAboutToBeDestroyed(); void workspaceCreated(); void screensCreated(); void virtualTerminalCreated(); protected: Application(OperationMode mode, int &argc, char **argv); virtual void performStartup() = 0; void notifyKSplash(); void createInput(); void createWorkspace(); void createAtoms(); void createOptions(); void createCompositor(); void setupEventFilters(); void destroyWorkspace(); void destroyCompositor(); /** * Inheriting classes should use this method to set the X11 root window * before accessing any X11 specific code pathes. **/ void setX11RootWindow(xcb_window_t root) { m_rootWindow = root; } /** * Inheriting classes should use this method to set the xcb connection * before accessing any X11 specific code pathes. **/ void setX11Connection(xcb_connection_t *c) { m_connection = c; emit x11ConnectionChanged(); } void destroyAtoms(); void setTerminating() { m_terminating = true; } protected: QString m_originalSessionKey; static int crashes; private Q_SLOTS: void resetCrashesCount(); private: QScopedPointer m_eventFilter; bool m_configLock; KSharedConfigPtr m_config; KSharedConfigPtr m_kxkbConfig; KSharedConfigPtr m_inputConfig; OperationMode m_operationMode; xcb_timestamp_t m_x11Time = XCB_TIME_CURRENT_TIME; xcb_window_t m_rootWindow = XCB_WINDOW_NONE; xcb_connection_t *m_connection = nullptr; #ifdef KWIN_BUILD_ACTIVITIES bool m_useKActivities = true; #endif Platform *m_platform = nullptr; bool m_terminating = false; }; inline static Application *kwinApp() { return static_cast(QCoreApplication::instance()); } namespace Xwl { class Xwayland; } class KWIN_EXPORT ApplicationWaylandAbstract : public Application { Q_OBJECT public: - virtual ~ApplicationWaylandAbstract() = 0; + ~ApplicationWaylandAbstract() override = 0; protected: friend class Xwl::Xwayland; ApplicationWaylandAbstract(OperationMode mode, int &argc, char **argv); virtual void setProcessStartupEnvironment(const QProcessEnvironment &environment) { Q_UNUSED(environment); } virtual void startSession() {} }; } // namespace #endif diff --git a/main_wayland.h b/main_wayland.h index 23c2fdfb4..788288764 100644 --- a/main_wayland.h +++ b/main_wayland.h @@ -1,80 +1,80 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 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_MAIN_WAYLAND_H #define KWIN_MAIN_WAYLAND_H #include "main.h" #include namespace KWin { namespace Xwl { class Xwayland; } class ApplicationWayland : public ApplicationWaylandAbstract { Q_OBJECT public: ApplicationWayland(int &argc, char **argv); - virtual ~ApplicationWayland(); + ~ApplicationWayland() override; void setStartXwayland(bool start) { m_startXWayland = start; } void setApplicationsToStart(const QStringList &applications) { m_applicationsToStart = applications; } void setInputMethodServerToStart(const QString &inputMethodServer) { m_inputMethodServerToStart = inputMethodServer; } void setProcessStartupEnvironment(const QProcessEnvironment &environment) override { m_environment = environment; } void setSessionArgument(const QString &session) { m_sessionArgument = session; } QProcessEnvironment processStartupEnvironment() const override { return m_environment; } protected: void performStartup() override; private: void createBackend(); void continueStartupWithScreens(); void continueStartupWithScene(); void finalizeStartup(); void startSession() override; bool m_startXWayland = false; QStringList m_applicationsToStart; QString m_inputMethodServerToStart; QProcessEnvironment m_environment; QString m_sessionArgument; Xwl::Xwayland *m_xwayland = nullptr; }; } #endif diff --git a/main_x11.h b/main_x11.h index 5965a1ff5..09f1708df 100644 --- a/main_x11.h +++ b/main_x11.h @@ -1,57 +1,57 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 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_MAIN_X11_H #define KWIN_MAIN_X11_H #include "main.h" namespace KWin { class KWinSelectionOwner; class ApplicationX11 : public Application { Q_OBJECT public: ApplicationX11(int &argc, char **argv); - virtual ~ApplicationX11(); + ~ApplicationX11() override; void setReplace(bool replace); protected: void performStartup() override; bool notify(QObject *o, QEvent *e) override; private Q_SLOTS: void lostSelection(); private: void crashChecking(); void setupCrashHandler(); static void crashHandler(int signal); QScopedPointer owner; bool m_replace; }; } #endif diff --git a/netinfo.h b/netinfo.h index 9adf582a5..835b908cf 100644 --- a/netinfo.h +++ b/netinfo.h @@ -1,100 +1,100 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 1999, 2000 Matthias Ettrich Copyright (C) 2003 Lubos Lunak Copyright (C) 2009 Lucas Murray 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_NETINFO_H #define KWIN_NETINFO_H #include #include #include namespace KWin { class AbstractClient; class Client; class RootInfoFilter; /** * NET WM Protocol handler class **/ class RootInfo : public NETRootInfo { private: typedef KWin::Client Client; // Because of NET::Client public: static RootInfo *create(); static void destroy(); void setActiveClient(AbstractClient *client); protected: - virtual void changeNumberOfDesktops(int n) override; - virtual void changeCurrentDesktop(int d) override; - virtual void changeActiveWindow(xcb_window_t w, NET::RequestSource src, xcb_timestamp_t timestamp, xcb_window_t active_window) override; - virtual void closeWindow(xcb_window_t w) override; - virtual void moveResize(xcb_window_t w, int x_root, int y_root, unsigned long direction) override; - virtual void moveResizeWindow(xcb_window_t w, int flags, int x, int y, int width, int height) override; - virtual void gotPing(xcb_window_t w, xcb_timestamp_t timestamp) override; - virtual void restackWindow(xcb_window_t w, RequestSource source, xcb_window_t above, int detail, xcb_timestamp_t timestamp) override; - virtual void changeShowingDesktop(bool showing) override; + void changeNumberOfDesktops(int n) override; + void changeCurrentDesktop(int d) override; + void changeActiveWindow(xcb_window_t w, NET::RequestSource src, xcb_timestamp_t timestamp, xcb_window_t active_window) override; + void closeWindow(xcb_window_t w) override; + void moveResize(xcb_window_t w, int x_root, int y_root, unsigned long direction) override; + void moveResizeWindow(xcb_window_t w, int flags, int x, int y, int width, int height) override; + void gotPing(xcb_window_t w, xcb_timestamp_t timestamp) override; + void restackWindow(xcb_window_t w, RequestSource source, xcb_window_t above, int detail, xcb_timestamp_t timestamp) override; + void changeShowingDesktop(bool showing) override; private: RootInfo(xcb_window_t w, const char* name, NET::Properties properties, NET::WindowTypes types, NET::States states, NET::Properties2 properties2, NET::Actions actions, int scr = -1); static RootInfo *s_self; friend RootInfo *rootInfo(); xcb_window_t m_activeWindow; std::unique_ptr m_eventFilter; }; inline RootInfo *rootInfo() { return RootInfo::s_self; } /** * NET WM Protocol handler class **/ class WinInfo : public NETWinInfo { private: typedef KWin::Client Client; // Because of NET::Client public: WinInfo(Client* c, xcb_window_t window, xcb_window_t rwin, NET::Properties properties, NET::Properties2 properties2); - virtual void changeDesktop(int desktop) override; - virtual void changeFullscreenMonitors(NETFullscreenMonitors topology) override; - virtual void changeState(NET::States state, NET::States mask) override; + void changeDesktop(int desktop) override; + void changeFullscreenMonitors(NETFullscreenMonitors topology) override; + void changeState(NET::States state, NET::States mask) override; void disable(); private: Client * m_client; }; } // KWin #endif diff --git a/options.h b/options.h index 112ba9442..14b7d7ef6 100644 --- a/options.h +++ b/options.h @@ -1,935 +1,935 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 1999, 2000 Matthias Ettrich Copyright (C) 2003 Lubos Lunak Copyright (C) 2012 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_OPTIONS_H #define KWIN_OPTIONS_H #include "main.h" #include "placement.h" namespace KWin { // Whether to keep all windows mapped when compositing (i.e. whether to have // actively updated window pixmaps). enum HiddenPreviews { // The normal mode with regard to mapped windows. Hidden (minimized, etc.) // and windows on inactive virtual desktops are not mapped, their pixmaps // are only their icons. HiddenPreviewsNever, // Like normal mode, but shown windows (i.e. on inactive virtual desktops) // are kept mapped, only hidden windows are unmapped. HiddenPreviewsShown, // All windows are kept mapped regardless of their state. HiddenPreviewsAlways }; class Settings; class KWIN_EXPORT Options : public QObject { Q_OBJECT Q_ENUMS(FocusPolicy) Q_ENUMS(GlSwapStrategy) Q_ENUMS(MouseCommand) Q_ENUMS(MouseWheelCommand) Q_ENUMS(WindowOperation) Q_PROPERTY(FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy NOTIFY focusPolicyChanged) Q_PROPERTY(bool nextFocusPrefersMouse READ isNextFocusPrefersMouse WRITE setNextFocusPrefersMouse NOTIFY nextFocusPrefersMouseChanged) /** * Whether clicking on a window raises it in FocusFollowsMouse * mode or not. **/ Q_PROPERTY(bool clickRaise READ isClickRaise WRITE setClickRaise NOTIFY clickRaiseChanged) /** * Whether autoraise is enabled FocusFollowsMouse mode or not. **/ Q_PROPERTY(bool autoRaise READ isAutoRaise WRITE setAutoRaise NOTIFY autoRaiseChanged) /** * Autoraise interval. **/ Q_PROPERTY(int autoRaiseInterval READ autoRaiseInterval WRITE setAutoRaiseInterval NOTIFY autoRaiseIntervalChanged) /** * Delayed focus interval. **/ Q_PROPERTY(int delayFocusInterval READ delayFocusInterval WRITE setDelayFocusInterval NOTIFY delayFocusIntervalChanged) /** * Whether shade hover is enabled or not. **/ Q_PROPERTY(bool shadeHover READ isShadeHover WRITE setShadeHover NOTIFY shadeHoverChanged) /** * Shade hover interval. **/ Q_PROPERTY(int shadeHoverInterval READ shadeHoverInterval WRITE setShadeHoverInterval NOTIFY shadeHoverIntervalChanged) /** * Whether to see Xinerama screens separately for focus (in Alt+Tab, when activating next client) **/ Q_PROPERTY(bool separateScreenFocus READ isSeparateScreenFocus WRITE setSeparateScreenFocus NOTIFY separateScreenFocusChanged) Q_PROPERTY(int placement READ placement WRITE setPlacement NOTIFY placementChanged) Q_PROPERTY(bool focusPolicyIsReasonable READ focusPolicyIsReasonable NOTIFY focusPolicyIsResonableChanged) /** * The size of the zone that triggers snapping on desktop borders. **/ Q_PROPERTY(int borderSnapZone READ borderSnapZone WRITE setBorderSnapZone NOTIFY borderSnapZoneChanged) /** * The size of the zone that triggers snapping with other windows. **/ Q_PROPERTY(int windowSnapZone READ windowSnapZone WRITE setWindowSnapZone NOTIFY windowSnapZoneChanged) /** * The size of the zone that triggers snapping on the screen center. **/ Q_PROPERTY(int centerSnapZone READ centerSnapZone WRITE setCenterSnapZone NOTIFY centerSnapZoneChanged) /** * Snap only when windows will overlap. **/ Q_PROPERTY(bool snapOnlyWhenOverlapping READ isSnapOnlyWhenOverlapping WRITE setSnapOnlyWhenOverlapping NOTIFY snapOnlyWhenOverlappingChanged) /** * Whether or not we roll over to the other edge when switching desktops past the edge. **/ Q_PROPERTY(bool rollOverDesktops READ isRollOverDesktops WRITE setRollOverDesktops NOTIFY rollOverDesktopsChanged) /** * 0 - 4 , see Workspace::allowClientActivation() **/ Q_PROPERTY(int focusStealingPreventionLevel READ focusStealingPreventionLevel WRITE setFocusStealingPreventionLevel NOTIFY focusStealingPreventionLevelChanged) Q_PROPERTY(KWin::Options::WindowOperation operationTitlebarDblClick READ operationTitlebarDblClick WRITE setOperationTitlebarDblClick NOTIFY operationTitlebarDblClickChanged) Q_PROPERTY(KWin::Options::WindowOperation operationMaxButtonLeftClick READ operationMaxButtonLeftClick WRITE setOperationMaxButtonLeftClick NOTIFY operationMaxButtonLeftClickChanged) Q_PROPERTY(KWin::Options::WindowOperation operationMaxButtonMiddleClick READ operationMaxButtonMiddleClick WRITE setOperationMaxButtonMiddleClick NOTIFY operationMaxButtonMiddleClickChanged) Q_PROPERTY(KWin::Options::WindowOperation operationMaxButtonRightClick READ operationMaxButtonRightClick WRITE setOperationMaxButtonRightClick NOTIFY operationMaxButtonRightClickChanged) Q_PROPERTY(MouseCommand commandActiveTitlebar1 READ commandActiveTitlebar1 WRITE setCommandActiveTitlebar1 NOTIFY commandActiveTitlebar1Changed) Q_PROPERTY(MouseCommand commandActiveTitlebar2 READ commandActiveTitlebar2 WRITE setCommandActiveTitlebar2 NOTIFY commandActiveTitlebar2Changed) Q_PROPERTY(MouseCommand commandActiveTitlebar3 READ commandActiveTitlebar3 WRITE setCommandActiveTitlebar3 NOTIFY commandActiveTitlebar3Changed) Q_PROPERTY(MouseCommand commandInactiveTitlebar1 READ commandInactiveTitlebar1 WRITE setCommandInactiveTitlebar1 NOTIFY commandInactiveTitlebar1Changed) Q_PROPERTY(MouseCommand commandInactiveTitlebar2 READ commandInactiveTitlebar2 WRITE setCommandInactiveTitlebar2 NOTIFY commandInactiveTitlebar2Changed) Q_PROPERTY(MouseCommand commandInactiveTitlebar3 READ commandInactiveTitlebar3 WRITE setCommandInactiveTitlebar3 NOTIFY commandInactiveTitlebar3Changed) Q_PROPERTY(MouseCommand commandWindow1 READ commandWindow1 WRITE setCommandWindow1 NOTIFY commandWindow1Changed) Q_PROPERTY(MouseCommand commandWindow2 READ commandWindow2 WRITE setCommandWindow2 NOTIFY commandWindow2Changed) Q_PROPERTY(MouseCommand commandWindow3 READ commandWindow3 WRITE setCommandWindow3 NOTIFY commandWindow3Changed) Q_PROPERTY(MouseCommand commandWindowWheel READ commandWindowWheel WRITE setCommandWindowWheel NOTIFY commandWindowWheelChanged) Q_PROPERTY(MouseCommand commandAll1 READ commandAll1 WRITE setCommandAll1 NOTIFY commandAll1Changed) Q_PROPERTY(MouseCommand commandAll2 READ commandAll2 WRITE setCommandAll2 NOTIFY commandAll2Changed) Q_PROPERTY(MouseCommand commandAll3 READ commandAll3 WRITE setCommandAll3 NOTIFY commandAll3Changed) Q_PROPERTY(uint keyCmdAllModKey READ keyCmdAllModKey WRITE setKeyCmdAllModKey NOTIFY keyCmdAllModKeyChanged) /** * Whether the Geometry Tip should be shown during a window move/resize. **/ Q_PROPERTY(bool showGeometryTip READ showGeometryTip WRITE setShowGeometryTip NOTIFY showGeometryTipChanged) /** * Whether the visible name should be condensed. **/ Q_PROPERTY(bool condensedTitle READ condensedTitle WRITE setCondensedTitle NOTIFY condensedTitleChanged) /** * Whether a window gets maximized when it reaches top screen edge while being moved. **/ Q_PROPERTY(bool electricBorderMaximize READ electricBorderMaximize WRITE setElectricBorderMaximize NOTIFY electricBorderMaximizeChanged) /** * Whether a window is tiled to half screen when reaching left or right screen edge while been moved. **/ Q_PROPERTY(bool electricBorderTiling READ electricBorderTiling WRITE setElectricBorderTiling NOTIFY electricBorderTilingChanged) /** * Whether a window is tiled to half screen when reaching left or right screen edge while been moved. **/ Q_PROPERTY(float electricBorderCornerRatio READ electricBorderCornerRatio WRITE setElectricBorderCornerRatio NOTIFY electricBorderCornerRatioChanged) Q_PROPERTY(bool borderlessMaximizedWindows READ borderlessMaximizedWindows WRITE setBorderlessMaximizedWindows NOTIFY borderlessMaximizedWindowsChanged) /** * timeout before non-responding application will be killed after attempt to close. **/ Q_PROPERTY(int killPingTimeout READ killPingTimeout WRITE setKillPingTimeout NOTIFY killPingTimeoutChanged) /** * Whether to hide utility windows for inactive applications. **/ Q_PROPERTY(bool hideUtilityWindowsForInactive READ isHideUtilityWindowsForInactive WRITE setHideUtilityWindowsForInactive NOTIFY hideUtilityWindowsForInactiveChanged) Q_PROPERTY(bool inactiveTabsSkipTaskbar READ isInactiveTabsSkipTaskbar WRITE setInactiveTabsSkipTaskbar NOTIFY inactiveTabsSkipTaskbarChanged) Q_PROPERTY(bool autogroupSimilarWindows READ isAutogroupSimilarWindows WRITE setAutogroupSimilarWindows NOTIFY autogroupSimilarWindowsChanged) Q_PROPERTY(bool autogroupInForeground READ isAutogroupInForeground WRITE setAutogroupInForeground NOTIFY autogroupInForegroundChanged) Q_PROPERTY(int compositingMode READ compositingMode WRITE setCompositingMode NOTIFY compositingModeChanged) Q_PROPERTY(bool useCompositing READ isUseCompositing WRITE setUseCompositing NOTIFY useCompositingChanged) Q_PROPERTY(int hiddenPreviews READ hiddenPreviews WRITE setHiddenPreviews NOTIFY hiddenPreviewsChanged) /** * 0 = no, 1 = yes when transformed, * 2 = try trilinear when transformed; else 1, * -1 = auto **/ Q_PROPERTY(int glSmoothScale READ glSmoothScale WRITE setGlSmoothScale NOTIFY glSmoothScaleChanged) Q_PROPERTY(bool xrenderSmoothScale READ isXrenderSmoothScale WRITE setXrenderSmoothScale NOTIFY xrenderSmoothScaleChanged) Q_PROPERTY(qint64 maxFpsInterval READ maxFpsInterval WRITE setMaxFpsInterval NOTIFY maxFpsIntervalChanged) Q_PROPERTY(uint refreshRate READ refreshRate WRITE setRefreshRate NOTIFY refreshRateChanged) Q_PROPERTY(qint64 vBlankTime READ vBlankTime WRITE setVBlankTime NOTIFY vBlankTimeChanged) Q_PROPERTY(bool glStrictBinding READ isGlStrictBinding WRITE setGlStrictBinding NOTIFY glStrictBindingChanged) /** * Whether strict binding follows the driver or has been overwritten by a user defined config value. * If @c true glStrictBinding is set by the OpenGL Scene during initialization. * If @c false glStrictBinding is set from a config value and not updated during scene initialization. **/ Q_PROPERTY(bool glStrictBindingFollowsDriver READ isGlStrictBindingFollowsDriver WRITE setGlStrictBindingFollowsDriver NOTIFY glStrictBindingFollowsDriverChanged) Q_PROPERTY(bool glCoreProfile READ glCoreProfile WRITE setGLCoreProfile NOTIFY glCoreProfileChanged) Q_PROPERTY(GlSwapStrategy glPreferBufferSwap READ glPreferBufferSwap WRITE setGlPreferBufferSwap NOTIFY glPreferBufferSwapChanged) Q_PROPERTY(KWin::OpenGLPlatformInterface glPlatformInterface READ glPlatformInterface WRITE setGlPlatformInterface NOTIFY glPlatformInterfaceChanged) Q_PROPERTY(bool windowsBlockCompositing READ windowsBlockCompositing WRITE setWindowsBlockCompositing NOTIFY windowsBlockCompositingChanged) public: explicit Options(QObject *parent = NULL); - ~Options(); + ~Options() override; void updateSettings(); /** * This enum type is used to specify the focus policy. * * Note that FocusUnderMouse and FocusStrictlyUnderMouse are not * particulary useful. They are only provided for old-fashined * die-hard UNIX people ;-) **/ enum FocusPolicy { /** * Clicking into a window activates it. This is also the default. **/ ClickToFocus, /** * Moving the mouse pointer actively onto a normal window activates it. * For convenience, the desktop and windows on the dock are excluded. * They require clicking. **/ FocusFollowsMouse, /** * The window that happens to be under the mouse pointer becomes active. * The invariant is: no window can have focus that is not under the mouse. * This also means that Alt-Tab won't work properly and popup dialogs are * usually unsable with the keyboard. Note that the desktop and windows on * the dock are excluded for convenience. They get focus only when clicking * on it. **/ FocusUnderMouse, /** * This is even worse than FocusUnderMouse. Only the window under the mouse * pointer is active. If the mouse points nowhere, nothing has the focus. If * the mouse points onto the desktop, the desktop has focus. The same holds * for windows on the dock. **/ FocusStrictlyUnderMouse }; FocusPolicy focusPolicy() const { return m_focusPolicy; } bool isNextFocusPrefersMouse() const { return m_nextFocusPrefersMouse; } /** * Whether clicking on a window raises it in FocusFollowsMouse * mode or not. **/ bool isClickRaise() const { return m_clickRaise; } /** * Whether autoraise is enabled FocusFollowsMouse mode or not. **/ bool isAutoRaise() const { return m_autoRaise; } /** * Autoraise interval **/ int autoRaiseInterval() const { return m_autoRaiseInterval; } /** * Delayed focus interval. **/ int delayFocusInterval() const { return m_delayFocusInterval; } /** * Whether shade hover is enabled or not. **/ bool isShadeHover() const { return m_shadeHover; } /** * Shade hover interval. **/ int shadeHoverInterval() { return m_shadeHoverInterval; } /** * Whether to see Xinerama screens separately for focus (in Alt+Tab, when activating next client) **/ bool isSeparateScreenFocus() const { return m_separateScreenFocus; } Placement::Policy placement() const { return m_placement; } bool focusPolicyIsReasonable() { return m_focusPolicy == ClickToFocus || m_focusPolicy == FocusFollowsMouse; } /** * The size of the zone that triggers snapping on desktop borders. **/ int borderSnapZone() const { return m_borderSnapZone; } /** * The size of the zone that triggers snapping with other windows. **/ int windowSnapZone() const { return m_windowSnapZone; } /** * The size of the zone that triggers snapping on the screen center. **/ int centerSnapZone() const { return m_centerSnapZone; } /** * Snap only when windows will overlap. **/ bool isSnapOnlyWhenOverlapping() const { return m_snapOnlyWhenOverlapping; } /** * Whether or not we roll over to the other edge when switching desktops past the edge. **/ bool isRollOverDesktops() const { return m_rollOverDesktops; } /** * Returns the focus stealing prevention level. * * @see allowClientActivation **/ int focusStealingPreventionLevel() const { return m_focusStealingPreventionLevel; } enum WindowOperation { MaximizeOp = 5000, RestoreOp, MinimizeOp, MoveOp, UnrestrictedMoveOp, ResizeOp, UnrestrictedResizeOp, CloseOp, OnAllDesktopsOp, ShadeOp, KeepAboveOp, KeepBelowOp, OperationsOp, WindowRulesOp, ToggleStoreSettingsOp = WindowRulesOp, ///< @obsolete HMaximizeOp, VMaximizeOp, LowerOp, FullScreenOp, NoBorderOp, NoOp, SetupWindowShortcutOp, ApplicationRulesOp, RemoveTabFromGroupOp, // Remove from group CloseTabGroupOp, // Close the group ActivateNextTabOp, // Move left in the group ActivatePreviousTabOp, // Move right in the group TabDragOp, }; WindowOperation operationTitlebarDblClick() const { return OpTitlebarDblClick; } WindowOperation operationMaxButtonLeftClick() const { return opMaxButtonLeftClick; } WindowOperation operationMaxButtonRightClick() const { return opMaxButtonRightClick; } WindowOperation operationMaxButtonMiddleClick() const { return opMaxButtonMiddleClick; } WindowOperation operationMaxButtonClick(Qt::MouseButtons button) const; enum MouseCommand { MouseRaise, MouseLower, MouseOperationsMenu, MouseToggleRaiseAndLower, MouseActivateAndRaise, MouseActivateAndLower, MouseActivate, MouseActivateRaiseAndPassClick, MouseActivateAndPassClick, MouseMove, MouseUnrestrictedMove, MouseActivateRaiseAndMove, MouseActivateRaiseAndUnrestrictedMove, MouseResize, MouseUnrestrictedResize, MouseShade, MouseSetShade, MouseUnsetShade, MouseMaximize, MouseRestore, MouseMinimize, MouseNextDesktop, MousePreviousDesktop, MouseAbove, MouseBelow, MouseOpacityMore, MouseOpacityLess, MouseClose, MousePreviousTab, MouseNextTab, MouseDragTab, MouseNothing }; enum MouseWheelCommand { MouseWheelRaiseLower, MouseWheelShadeUnshade, MouseWheelMaximizeRestore, MouseWheelAboveBelow, MouseWheelPreviousNextDesktop, MouseWheelChangeOpacity, MouseWheelChangeCurrentTab, MouseWheelNothing }; MouseCommand operationTitlebarMouseWheel(int delta) const { return wheelToMouseCommand(CmdTitlebarWheel, delta); } MouseCommand operationWindowMouseWheel(int delta) const { return wheelToMouseCommand(CmdAllWheel, delta); } MouseCommand commandActiveTitlebar1() const { return CmdActiveTitlebar1; } MouseCommand commandActiveTitlebar2() const { return CmdActiveTitlebar2; } MouseCommand commandActiveTitlebar3() const { return CmdActiveTitlebar3; } MouseCommand commandInactiveTitlebar1() const { return CmdInactiveTitlebar1; } MouseCommand commandInactiveTitlebar2() const { return CmdInactiveTitlebar2; } MouseCommand commandInactiveTitlebar3() const { return CmdInactiveTitlebar3; } MouseCommand commandWindow1() const { return CmdWindow1; } MouseCommand commandWindow2() const { return CmdWindow2; } MouseCommand commandWindow3() const { return CmdWindow3; } MouseCommand commandWindowWheel() const { return CmdWindowWheel; } MouseCommand commandAll1() const { return CmdAll1; } MouseCommand commandAll2() const { return CmdAll2; } MouseCommand commandAll3() const { return CmdAll3; } uint keyCmdAllModKey() const { return CmdAllModKey; } Qt::KeyboardModifier commandAllModifier() const { switch (CmdAllModKey) { case Qt::Key_Alt: return Qt::AltModifier; case Qt::Key_Meta: return Qt::MetaModifier; default: Q_UNREACHABLE(); } } static WindowOperation windowOperation(const QString &name, bool restricted); static MouseCommand mouseCommand(const QString &name, bool restricted); static MouseWheelCommand mouseWheelCommand(const QString &name); /** * @returns true if the Geometry Tip should be shown during a window move/resize. **/ bool showGeometryTip() const; /** * Returns whether the user prefers his caption clean. **/ bool condensedTitle() const; /** * @returns true if a window gets maximized when it reaches top screen edge * while being moved. **/ bool electricBorderMaximize() const { return electric_border_maximize; } /** * @returns true if window is tiled to half screen when reaching left or * right screen edge while been moved. **/ bool electricBorderTiling() const { return electric_border_tiling; } /** * @returns the factor that determines the corner part of the edge (ie. 0.1 means tiny corner) **/ float electricBorderCornerRatio() const { return electric_border_corner_ratio; } bool borderlessMaximizedWindows() const { return borderless_maximized_windows; } /** * Timeout before non-responding application will be killed after attempt to close. **/ int killPingTimeout() const { return m_killPingTimeout; } /** * Whether to hide utility windows for inactive applications. **/ bool isHideUtilityWindowsForInactive() const { return m_hideUtilityWindowsForInactive; } bool isInactiveTabsSkipTaskbar() const { return m_inactiveTabsSkipTaskbar; } bool isAutogroupSimilarWindows() const { return m_autogroupSimilarWindows; } bool isAutogroupInForeground() const { return m_autogroupInForeground; } /** * Returns the animation time factor for desktop effects. **/ double animationTimeFactor() const; //---------------------- // Compositing settings void reloadCompositingSettings(bool force = false); CompositingType compositingMode() const { return m_compositingMode; } void setCompositingMode(CompositingType mode) { m_compositingMode = mode; } // Separate to mode so the user can toggle bool isUseCompositing() const; // General preferences HiddenPreviews hiddenPreviews() const { return m_hiddenPreviews; } // OpenGL // 0 = no, 1 = yes when transformed, // 2 = try trilinear when transformed; else 1, // -1 = auto int glSmoothScale() const { return m_glSmoothScale; } // XRender bool isXrenderSmoothScale() const { return m_xrenderSmoothScale; } qint64 maxFpsInterval() const { return m_maxFpsInterval; } // Settings that should be auto-detected uint refreshRate() const { return m_refreshRate; } qint64 vBlankTime() const { return m_vBlankTime; } bool isGlStrictBinding() const { return m_glStrictBinding; } bool isGlStrictBindingFollowsDriver() const { return m_glStrictBindingFollowsDriver; } bool glCoreProfile() const { return m_glCoreProfile; } OpenGLPlatformInterface glPlatformInterface() const { return m_glPlatformInterface; } enum GlSwapStrategy { NoSwapEncourage = 0, CopyFrontBuffer = 'c', PaintFullScreen = 'p', ExtendDamage = 'e', AutoSwapStrategy = 'a' }; GlSwapStrategy glPreferBufferSwap() const { return m_glPreferBufferSwap; } bool windowsBlockCompositing() const { return m_windowsBlockCompositing; } QStringList modifierOnlyDBusShortcut(Qt::KeyboardModifier mod) const; // setters void setFocusPolicy(FocusPolicy focusPolicy); void setNextFocusPrefersMouse(bool nextFocusPrefersMouse); void setClickRaise(bool clickRaise); void setAutoRaise(bool autoRaise); void setAutoRaiseInterval(int autoRaiseInterval); void setDelayFocusInterval(int delayFocusInterval); void setShadeHover(bool shadeHover); void setShadeHoverInterval(int shadeHoverInterval); void setSeparateScreenFocus(bool separateScreenFocus); void setPlacement(int placement); void setBorderSnapZone(int borderSnapZone); void setWindowSnapZone(int windowSnapZone); void setCenterSnapZone(int centerSnapZone); void setSnapOnlyWhenOverlapping(bool snapOnlyWhenOverlapping); void setRollOverDesktops(bool rollOverDesktops); void setFocusStealingPreventionLevel(int focusStealingPreventionLevel); void setOperationTitlebarDblClick(WindowOperation operationTitlebarDblClick); void setOperationMaxButtonLeftClick(WindowOperation op); void setOperationMaxButtonRightClick(WindowOperation op); void setOperationMaxButtonMiddleClick(WindowOperation op); void setCommandActiveTitlebar1(MouseCommand commandActiveTitlebar1); void setCommandActiveTitlebar2(MouseCommand commandActiveTitlebar2); void setCommandActiveTitlebar3(MouseCommand commandActiveTitlebar3); void setCommandInactiveTitlebar1(MouseCommand commandInactiveTitlebar1); void setCommandInactiveTitlebar2(MouseCommand commandInactiveTitlebar2); void setCommandInactiveTitlebar3(MouseCommand commandInactiveTitlebar3); void setCommandWindow1(MouseCommand commandWindow1); void setCommandWindow2(MouseCommand commandWindow2); void setCommandWindow3(MouseCommand commandWindow3); void setCommandWindowWheel(MouseCommand commandWindowWheel); void setCommandAll1(MouseCommand commandAll1); void setCommandAll2(MouseCommand commandAll2); void setCommandAll3(MouseCommand commandAll3); void setKeyCmdAllModKey(uint keyCmdAllModKey); void setShowGeometryTip(bool showGeometryTip); void setCondensedTitle(bool condensedTitle); void setElectricBorderMaximize(bool electricBorderMaximize); void setElectricBorderTiling(bool electricBorderTiling); void setElectricBorderCornerRatio(float electricBorderCornerRatio); void setBorderlessMaximizedWindows(bool borderlessMaximizedWindows); void setKillPingTimeout(int killPingTimeout); void setHideUtilityWindowsForInactive(bool hideUtilityWindowsForInactive); void setInactiveTabsSkipTaskbar(bool inactiveTabsSkipTaskbar); void setAutogroupSimilarWindows(bool autogroupSimilarWindows); void setAutogroupInForeground(bool autogroupInForeground); void setCompositingMode(int compositingMode); void setUseCompositing(bool useCompositing); void setHiddenPreviews(int hiddenPreviews); void setGlSmoothScale(int glSmoothScale); void setXrenderSmoothScale(bool xrenderSmoothScale); void setMaxFpsInterval(qint64 maxFpsInterval); void setRefreshRate(uint refreshRate); void setVBlankTime(qint64 vBlankTime); void setGlStrictBinding(bool glStrictBinding); void setGlStrictBindingFollowsDriver(bool glStrictBindingFollowsDriver); void setGLCoreProfile(bool glCoreProfile); void setGlPreferBufferSwap(char glPreferBufferSwap); void setGlPlatformInterface(OpenGLPlatformInterface interface); void setWindowsBlockCompositing(bool set); // default values static WindowOperation defaultOperationTitlebarDblClick() { return MaximizeOp; } static WindowOperation defaultOperationMaxButtonLeftClick() { return MaximizeOp; } static WindowOperation defaultOperationMaxButtonRightClick() { return HMaximizeOp; } static WindowOperation defaultOperationMaxButtonMiddleClick() { return VMaximizeOp; } static MouseCommand defaultCommandActiveTitlebar1() { return MouseRaise; } static MouseCommand defaultCommandActiveTitlebar2() { return MouseDragTab; } static MouseCommand defaultCommandActiveTitlebar3() { return MouseOperationsMenu; } static MouseCommand defaultCommandInactiveTitlebar1() { return MouseActivateAndRaise; } static MouseCommand defaultCommandInactiveTitlebar2() { return MouseDragTab; } static MouseCommand defaultCommandInactiveTitlebar3() { return MouseOperationsMenu; } static MouseCommand defaultCommandWindow1() { return MouseActivateRaiseAndPassClick; } static MouseCommand defaultCommandWindow2() { return MouseActivateAndPassClick; } static MouseCommand defaultCommandWindow3() { return MouseActivateAndPassClick; } static MouseCommand defaultCommandWindowWheel() { return MouseNothing; } static MouseCommand defaultCommandAll1() { return MouseUnrestrictedMove; } static MouseCommand defaultCommandAll2() { return MouseToggleRaiseAndLower; } static MouseCommand defaultCommandAll3() { return MouseUnrestrictedResize; } static MouseWheelCommand defaultCommandTitlebarWheel() { return MouseWheelChangeCurrentTab; } static MouseWheelCommand defaultCommandAllWheel() { return MouseWheelNothing; } static uint defaultKeyCmdAllModKey() { return Qt::Key_Alt; } static bool defaultAutogroupInForeground() { return true; } static CompositingType defaultCompositingMode() { return OpenGLCompositing; } static bool defaultUseCompositing() { return true; } static HiddenPreviews defaultHiddenPreviews() { return HiddenPreviewsShown; } static int defaultGlSmoothScale() { return 2; } static bool defaultXrenderSmoothScale() { return false; } static qint64 defaultMaxFpsInterval() { return (1 * 1000 * 1000 * 1000) /60.0; // nanoseconds / Hz } static int defaultMaxFps() { return 60; } static uint defaultRefreshRate() { return 0; } static uint defaultVBlankTime() { return 6000; // 6ms } static bool defaultGlStrictBinding() { return true; } static bool defaultGlStrictBindingFollowsDriver() { return true; } static bool defaultGLCoreProfile() { return false; } static GlSwapStrategy defaultGlPreferBufferSwap() { return AutoSwapStrategy; } static OpenGLPlatformInterface defaultGlPlatformInterface() { return kwinApp()->shouldUseWaylandForCompositing() ? EglPlatformInterface : GlxPlatformInterface; }; static int defaultAnimationSpeed() { return 3; } /** * Performs loading all settings except compositing related. **/ void loadConfig(); /** * Performs loading of compositing settings which do not depend on OpenGL. **/ bool loadCompositingConfig(bool force); void reparseConfiguration(); static int currentRefreshRate(); //---------------------- Q_SIGNALS: // for properties void focusPolicyChanged(); void focusPolicyIsResonableChanged(); void nextFocusPrefersMouseChanged(); void clickRaiseChanged(); void autoRaiseChanged(); void autoRaiseIntervalChanged(); void delayFocusIntervalChanged(); void shadeHoverChanged(); void shadeHoverIntervalChanged(); void separateScreenFocusChanged(bool); void placementChanged(); void borderSnapZoneChanged(); void windowSnapZoneChanged(); void centerSnapZoneChanged(); void snapOnlyWhenOverlappingChanged(); void rollOverDesktopsChanged(bool enabled); void focusStealingPreventionLevelChanged(); void operationTitlebarDblClickChanged(); void operationMaxButtonLeftClickChanged(); void operationMaxButtonRightClickChanged(); void operationMaxButtonMiddleClickChanged(); void commandActiveTitlebar1Changed(); void commandActiveTitlebar2Changed(); void commandActiveTitlebar3Changed(); void commandInactiveTitlebar1Changed(); void commandInactiveTitlebar2Changed(); void commandInactiveTitlebar3Changed(); void commandWindow1Changed(); void commandWindow2Changed(); void commandWindow3Changed(); void commandWindowWheelChanged(); void commandAll1Changed(); void commandAll2Changed(); void commandAll3Changed(); void keyCmdAllModKeyChanged(); void showGeometryTipChanged(); void condensedTitleChanged(); void electricBorderMaximizeChanged(); void electricBorderTilingChanged(); void electricBorderCornerRatioChanged(); void borderlessMaximizedWindowsChanged(); void killPingTimeoutChanged(); void hideUtilityWindowsForInactiveChanged(); void inactiveTabsSkipTaskbarChanged(); void autogroupSimilarWindowsChanged(); void autogroupInForegroundChanged(); void compositingModeChanged(); void useCompositingChanged(); void hiddenPreviewsChanged(); void glSmoothScaleChanged(); void xrenderSmoothScaleChanged(); void maxFpsIntervalChanged(); void refreshRateChanged(); void vBlankTimeChanged(); void glStrictBindingChanged(); void glStrictBindingFollowsDriverChanged(); void glCoreProfileChanged(); void glPreferBufferSwapChanged(); void glPlatformInterfaceChanged(); void windowsBlockCompositingChanged(); void configChanged(); private: void setElectricBorders(int borders); void syncFromKcfgc(); QScopedPointer m_settings; FocusPolicy m_focusPolicy; bool m_nextFocusPrefersMouse; bool m_clickRaise; bool m_autoRaise; int m_autoRaiseInterval; int m_delayFocusInterval; bool m_shadeHover; int m_shadeHoverInterval; bool m_separateScreenFocus; Placement::Policy m_placement; int m_borderSnapZone; int m_windowSnapZone; int m_centerSnapZone; bool m_snapOnlyWhenOverlapping; bool m_rollOverDesktops; int m_focusStealingPreventionLevel; int m_killPingTimeout; bool m_hideUtilityWindowsForInactive; bool m_inactiveTabsSkipTaskbar; bool m_autogroupSimilarWindows; bool m_autogroupInForeground; CompositingType m_compositingMode; bool m_useCompositing; HiddenPreviews m_hiddenPreviews; int m_glSmoothScale; bool m_xrenderSmoothScale; qint64 m_maxFpsInterval; // Settings that should be auto-detected uint m_refreshRate; qint64 m_vBlankTime; bool m_glStrictBinding; bool m_glStrictBindingFollowsDriver; bool m_glCoreProfile; GlSwapStrategy m_glPreferBufferSwap; OpenGLPlatformInterface m_glPlatformInterface; bool m_windowsBlockCompositing; WindowOperation OpTitlebarDblClick; WindowOperation opMaxButtonRightClick = defaultOperationMaxButtonRightClick(); WindowOperation opMaxButtonMiddleClick = defaultOperationMaxButtonMiddleClick(); WindowOperation opMaxButtonLeftClick = defaultOperationMaxButtonRightClick(); // mouse bindings MouseCommand CmdActiveTitlebar1; MouseCommand CmdActiveTitlebar2; MouseCommand CmdActiveTitlebar3; MouseCommand CmdInactiveTitlebar1; MouseCommand CmdInactiveTitlebar2; MouseCommand CmdInactiveTitlebar3; MouseWheelCommand CmdTitlebarWheel; MouseCommand CmdWindow1; MouseCommand CmdWindow2; MouseCommand CmdWindow3; MouseCommand CmdWindowWheel; MouseCommand CmdAll1; MouseCommand CmdAll2; MouseCommand CmdAll3; MouseWheelCommand CmdAllWheel; uint CmdAllModKey; bool electric_border_maximize; bool electric_border_tiling; float electric_border_corner_ratio; bool borderless_maximized_windows; bool show_geometry_tip; bool condensed_title; int animationSpeed; // 0 - instant, 5 - very slow QHash m_modifierOnlyShortcuts; MouseCommand wheelToMouseCommand(MouseWheelCommand com, int delta) const; }; extern KWIN_EXPORT Options* options; } // namespace Q_DECLARE_METATYPE(KWin::Options::WindowOperation) Q_DECLARE_METATYPE(KWin::OpenGLPlatformInterface) #endif diff --git a/orientation_sensor.h b/orientation_sensor.h index 250b038f8..7f287694a 100644 --- a/orientation_sensor.h +++ b/orientation_sensor.h @@ -1,95 +1,95 @@ /******************************************************************** 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(); + ~OrientationSensor() override; 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 }; Q_ENUM(Orientation) 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 startStopSensor(); void loadConfig(); void refresh(); void activate(); void updateState(); 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/outline.h b/outline.h index 53e985054..e4ba94f72 100644 --- a/outline.h +++ b/outline.h @@ -1,194 +1,194 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2011 Arthur Arlt 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_OUTLINE_H #define KWIN_OUTLINE_H #include #include #include #include class QQmlContext; class QQmlComponent; namespace KWin { class OutlineVisual; /** * @short This class is used to show the outline of a given geometry. * * The class renders an outline by using four windows. One for each border of * the geometry. It is possible to replace the outline with an effect. If an * effect is available the effect will be used, otherwise the outline will be * rendered by using the X implementation. * * @author Arthur Arlt * @since 4.7 **/ class Outline : public QObject { Q_OBJECT Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged) Q_PROPERTY(QRect visualParentGeometry READ visualParentGeometry NOTIFY visualParentGeometryChanged) Q_PROPERTY(QRect unifiedGeometry READ unifiedGeometry NOTIFY unifiedGeometryChanged) Q_PROPERTY(bool active READ isActive NOTIFY activeChanged) public: - ~Outline(); + ~Outline() override; /** * Set the outline geometry. * To show the outline use showOutline. * @param outlineGeometry The geometry of the outline to be shown * @see showOutline **/ void setGeometry(const QRect &outlineGeometry); /** * Set the visual parent geometry. * This is the geometry from which the will emerge. * @param visualParentGeometry The visual geometry of the visual parent * @see showOutline **/ void setVisualParentGeometry(const QRect &visualParentGeometry); /** * Shows the outline of a window using either an effect or the X implementation. * To stop the outline process use hideOutline. * @see hideOutline **/ void show(); /** * Shows the outline for the given @p outlineGeometry. * This is the same as setOutlineGeometry followed by showOutline directly. * To stop the outline process use hideOutline. * @param outlineGeometry The geometry of the outline to be shown * @see hideOutline **/ void show(const QRect &outlineGeometry); /** * Shows the outline for the given @p outlineGeometry animated from @p visualParentGeometry. * This is the same as setOutlineGeometry followed by setVisualParentGeometry * and then showOutline. * To stop the outline process use hideOutline. * @param outlineGeometry The geometry of the outline to be shown * @param visualParentGeometry The geometry from where the outline should emerge * @see hideOutline * @since 5.10 **/ void show(const QRect &outlineGeometry, const QRect &visualParentGeometry); /** * Hides shown outline. * @see showOutline **/ void hide(); const QRect &geometry() const; const QRect &visualParentGeometry() const; QRect unifiedGeometry() const; bool isActive() const; private Q_SLOTS: void compositingChanged(); Q_SIGNALS: void activeChanged(); void geometryChanged(); void unifiedGeometryChanged(); void visualParentGeometryChanged(); private: void createHelper(); QScopedPointer m_visual; QRect m_outlineGeometry; QRect m_visualParentGeometry; bool m_active; KWIN_SINGLETON(Outline) }; class KWIN_EXPORT OutlineVisual { public: OutlineVisual(Outline *outline); virtual ~OutlineVisual(); virtual void show() = 0; virtual void hide() = 0; protected: Outline *outline(); const Outline *outline() const; private: Outline *m_outline; }; class CompositedOutlineVisual : public OutlineVisual { public: CompositedOutlineVisual(Outline *outline); - virtual ~CompositedOutlineVisual(); - virtual void show(); - virtual void hide(); + ~CompositedOutlineVisual() override; + void show() override; + void hide() override; private: QScopedPointer m_qmlContext; QScopedPointer m_qmlComponent; QScopedPointer m_mainItem; }; inline bool Outline::isActive() const { return m_active; } inline const QRect &Outline::geometry() const { return m_outlineGeometry; } inline const QRect &Outline::visualParentGeometry() const { return m_visualParentGeometry; } inline Outline *OutlineVisual::outline() { return m_outline; } inline const Outline *OutlineVisual::outline() const { return m_outline; } inline Outline *outline() { return Outline::self(); } } #endif diff --git a/outputscreens.h b/outputscreens.h index 55bf2a975..90fd071ca 100644 --- a/outputscreens.h +++ b/outputscreens.h @@ -1,61 +1,61 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright 2018 Roman Gilg 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_OUTPUTSCREENS_H #define KWIN_OUTPUTSCREENS_H #include "screens.h" namespace KWin { class AbstractOutput; /** * @brief Implementation for backends with Outputs **/ class KWIN_EXPORT OutputScreens : public Screens { Q_OBJECT public: OutputScreens(Platform *platform, QObject *parent = nullptr); - virtual ~OutputScreens(); + ~OutputScreens() override; void init() override; QString name(int screen) const override; - bool isInternal(int screen) const; - QSizeF physicalSize(int screen) const; + bool isInternal(int screen) const override; + QSizeF physicalSize(int screen) const override; QRect geometry(int screen) const override; QSize size(int screen) const override; qreal scale(int screen) const override; float refreshRate(int screen) const override; Qt::ScreenOrientation orientation(int screen) const override; void updateCount() override; int number(const QPoint &pos) const override; protected: Platform *m_platform; private: AbstractOutput *findOutput(int screen) const; }; } #endif // KWIN_OUTPUTSCREENS_H diff --git a/platform.h b/platform.h index b509a636d..113d21793 100644 --- a/platform.h +++ b/platform.h @@ -1,563 +1,563 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_PLATFORM_H #define KWIN_PLATFORM_H #include #include #include #include #include "fixqopengl.h" #include "input.h" #include #include #include class QAction; namespace KWayland { namespace Server { class OutputConfigurationInterface; } } namespace KWin { namespace ColorCorrect { class Manager; } class AbstractOutput; class Edge; class Compositor; class OverlayWindow; class OpenGLBackend; class Outline; class OutlineVisual; class QPainterBackend; class Scene; class Screens; class ScreenEdges; class Toplevel; class WaylandCursorTheme; namespace Decoration { class Renderer; class DecoratedClientImpl; } class KWIN_EXPORT Outputs : public QVector { public: Outputs(){}; template Outputs(const QVector &other) { resize(other.size()); std::copy(other.constBegin(), other.constEnd(), begin()); } }; class KWIN_EXPORT Platform : public QObject { Q_OBJECT public: - virtual ~Platform(); + ~Platform() override; virtual void init() = 0; virtual Screens *createScreens(QObject *parent = nullptr); virtual OpenGLBackend *createOpenGLBackend(); virtual QPainterBackend *createQPainterBackend(); /** * Allows the platform to create a platform specific screen edge. * The default implementation creates a Edge. **/ virtual Edge *createScreenEdge(ScreenEdges *parent); /** * Allows the platform to create a platform specific Cursor. * The default implementation creates an InputRedirectionCursor. **/ virtual void createPlatformCursor(QObject *parent = nullptr); virtual void warpPointer(const QPointF &globalPos); /** * Whether our Compositing EGL display allows a surface less context * so that a sharing context could be created. **/ virtual bool supportsQpaContext() const; /** * The EGLDisplay used by the compositing scene. **/ EGLDisplay sceneEglDisplay() const; void setSceneEglDisplay(EGLDisplay display); /** * The EGLContext used by the compositing scene. **/ virtual EGLContext sceneEglContext() const { return m_context; } /** * Sets the @p context used by the compositing scene. **/ void setSceneEglContext(EGLContext context) { m_context = context; } /** * The first (in case of multiple) EGLSurface used by the compositing scene. **/ EGLSurface sceneEglSurface() const { return m_surface; } /** * Sets the first @p surface used by the compositing scene. * @see sceneEglSurface **/ void setSceneEglSurface(EGLSurface surface) { m_surface = surface; } /** * The EglConfig used by the compositing scene. **/ EGLConfig sceneEglConfig() const { return m_eglConfig; } /** * Sets the @p config used by the compositing scene. * @see sceneEglConfig **/ void setSceneEglConfig(EGLConfig config) { m_eglConfig = config; } /** * Implementing subclasses should provide a size in case the backend represents * a basic screen and uses the BasicScreens. * * Base implementation returns an invalid size. **/ virtual QSize screenSize() const; /** * Implementing subclasses should provide all geometries in case the backend represents * a basic screen and uses the BasicScreens. * * Base implementation returns one QRect positioned at 0/0 with screenSize() as size. **/ virtual QVector screenGeometries() const; /** * Implementing subclasses should provide all geometries in case the backend represents * a basic screen and uses the BasicScreens. * * Base implementation returns a screen with a scale of 1. **/ virtual QVector screenScales() const; /** * Implement this method to receive configuration change requests through KWayland's * OutputManagement interface. * * Base implementation warns that the current backend does not implement this * functionality. **/ virtual void configurationChangeRequested(KWayland::Server::OutputConfigurationInterface *config); /** * Whether the Platform requires compositing for rendering. * Default implementation returns @c true. If the implementing Platform allows to be used * without compositing (e.g. rendering is done by the windowing system), re-implement this method. **/ virtual bool requiresCompositing() const; /** * Whether Compositing is possible in the Platform. * Returning @c false in this method makes only sense if requiresCompositing returns @c false. * * The default implementation returns @c true. * @see requiresCompositing **/ virtual bool compositingPossible() const; /** * Returns a user facing text explaining why compositing is not possible in case * compositingPossible returns @c false. * * The default implementation returns an empty string. * @see compositingPossible **/ virtual QString compositingNotPossibleReason() const; /** * Whether OpenGL compositing is broken. * The Platform can implement this method if it is able to detect whether OpenGL compositing * broke (e.g. triggered a crash in a previous run). * * Default implementation returns @c false. * @see createOpenGLSafePoint **/ virtual bool openGLCompositingIsBroken() const; enum class OpenGLSafePoint { PreInit, PostInit, PreFrame, PostFrame, PostLastGuardedFrame }; /** * This method is invoked before and after creating the OpenGL rendering Scene. * An implementing Platform can use it to detect crashes triggered by the OpenGL implementation. * This can be used for openGLCompositingIsBroken. * * The default implementation does nothing. * @see openGLCompositingIsBroken. **/ virtual void createOpenGLSafePoint(OpenGLSafePoint safePoint); /** * Starts an interactive window selection process. * * Once the user selected a window the @p callback is invoked with the selected Toplevel as * argument. In case the user cancels the interactive window selection or selecting a window is currently * not possible (e.g. screen locked) the @p callback is invoked with a @c nullptr argument. * * During the interactive window selection the cursor is turned into a crosshair cursor unless * @p cursorName is provided. The argument @p cursorName is a QByteArray instead of Qt::CursorShape * to support the "pirate" cursor for kill window which is not wrapped by Qt::CursorShape. * * The default implementation forwards to InputRedirection. * * @param callback The function to invoke once the interactive window selection ends * @param cursorName The optional name of the cursor shape to use, default is crosshair **/ virtual void startInteractiveWindowSelection(std::function callback, const QByteArray &cursorName = QByteArray()); /** * Starts an interactive position selection process. * * Once the user selected a position on the screen the @p callback is invoked with * the selected point as argument. In case the user cancels the interactive position selection * or selecting a position is currently not possible (e.g. screen locked) the @p callback * is invoked with a point at @c -1 as x and y argument. * * During the interactive window selection the cursor is turned into a crosshair cursor. * * The default implementation forwards to InputRedirection. * * @param callback The function to invoke once the interactive position selection ends **/ virtual void startInteractivePositionSelection(std::function callback); /** * Platform specific preparation for an @p action which is used for KGlobalAccel. * * A platform might need to do preparation for an @p action before * it can be used with KGlobalAccel. * * Code using KGlobalAccel should invoke this method for the @p action * prior to setting up any shortcuts and connections. * * The default implementation does nothing. * * @param action The action which will be used with KGlobalAccel. * @since 5.10 **/ virtual void setupActionForGlobalAccel(QAction *action); bool usesSoftwareCursor() const { return m_softWareCursor; } QImage softwareCursor() const; QPoint softwareCursorHotspot() const; void markCursorAsRendered(); /** * Returns a PlatformCursorImage. By default this is created by softwareCursor and * softwareCursorHotspot. An implementing subclass can use this to provide a better * suited PlatformCursorImage. * * @see softwareCursor * @see softwareCursorHotspot * @since 5.9 **/ virtual PlatformCursorImage cursorImage() const; /** * The Platform cursor image should be hidden. * @see showCursor * @see doHideCursor * @see isCursorHidden * @since 5.9 **/ void hideCursor(); /** * The Platform cursor image should be shown again. * @see hideCursor * @see doShowCursor * @see isCursorHidden * @since 5.9 **/ void showCursor(); /** * Whether the cursor is currently hidden. * @see showCursor * @see hideCursor * @since 5.9 **/ bool isCursorHidden() const { return m_hideCursorCounter > 0; } bool handlesOutputs() const { return m_handlesOutputs; } bool isReady() const { return m_ready; } void setInitialWindowSize(const QSize &size) { m_initialWindowSize = size; } void setDeviceIdentifier(const QByteArray &identifier) { m_deviceIdentifier = identifier; } bool supportsPointerWarping() const { return m_pointerWarping; } bool areOutputsEnabled() const { return m_outputsEnabled; } void setOutputsEnabled(bool enabled) { m_outputsEnabled = enabled; } int initialOutputCount() const { return m_initialOutputCount; } void setInitialOutputCount(int count) { m_initialOutputCount = count; } qreal initialOutputScale() const { return m_initialOutputScale; } void setInitialOutputScale(qreal scale) { m_initialOutputScale = scale; } /** * Creates the OverlayWindow required for X11 based compositors. * Default implementation returns @c nullptr. **/ virtual OverlayWindow *createOverlayWindow(); /** * Allows a platform to update the X11 timestamp. * Mostly for the X11 standalone platform to interact with QX11Info. * * Default implementation does nothing. This means code relying on the X timestamp being up to date, * might not be working. E.g. synced X11 window resizing **/ virtual void updateXTime(); /** * Creates the OutlineVisual for the given @p outline. * Default implementation creates an OutlineVisual suited for composited usage. **/ virtual OutlineVisual *createOutline(Outline *outline); /** * Creates the Decoration::Renderer for the given @p client. * * The default implementation creates a Renderer suited for the Compositor, @c nullptr if there is no Compositor. **/ virtual Decoration::Renderer *createDecorationRenderer(Decoration::DecoratedClientImpl *client); /** * Platform specific way to invert the screen. * Default implementation invokes the invert effect **/ virtual void invertScreen(); /** * Default implementation creates an EffectsHandlerImp; **/ virtual void createEffectsHandler(Compositor *compositor, Scene *scene); /** * The CompositingTypes supported by the Platform. * The first item should be the most preferred one. * @since 5.11 **/ virtual QVector supportedCompositors() const = 0; /** * Whether gamma control is supported by the backend. * @since 5.12 **/ bool supportsGammaControl() const { return m_supportsGammaControl; } ColorCorrect::Manager *colorCorrectManager() { return m_colorCorrect; } // outputs with connections (org_kde_kwin_outputdevice) virtual Outputs outputs() const { return Outputs(); } // actively compositing outputs (wl_output) virtual Outputs enabledOutputs() const { return Outputs(); } /** * A string of information to include in kwin debug output * It should not be translated. * * The base implementation prints the name. * @since 5.12 **/ virtual QString supportInformation() const; /** * The compositor plugin which got selected from @link{supportedCompositors}. * Prior to selecting a compositor this returns @c NoCompositing. * * This method allows the platforms to limit the offerings in @link{supportedCompositors} * in case they do not support runtime compositor switching **/ CompositingType selectedCompositor() const { return m_selectedCompositor; } /** * Used by Compositor to set the used compositor. **/ void setSelectedCompositor(CompositingType type) { m_selectedCompositor = type; } public Q_SLOTS: void pointerMotion(const QPointF &position, quint32 time); void pointerButtonPressed(quint32 button, quint32 time); void pointerButtonReleased(quint32 button, quint32 time); void pointerAxisHorizontal(qreal delta, quint32 time, qint32 discreteDelta = 0, InputRedirection::PointerAxisSource source = InputRedirection::PointerAxisSourceUnknown); void pointerAxisVertical(qreal delta, quint32 time, qint32 discreteDelta = 0, InputRedirection::PointerAxisSource source = InputRedirection::PointerAxisSourceUnknown); void keyboardKeyPressed(quint32 key, quint32 time); void keyboardKeyReleased(quint32 key, quint32 time); void keyboardModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group); void keymapChange(int fd, uint32_t size); void touchDown(qint32 id, const QPointF &pos, quint32 time); void touchUp(qint32 id, quint32 time); void touchMotion(qint32 id, const QPointF &pos, quint32 time); void touchCancel(); void touchFrame(); void processSwipeGestureBegin(int fingerCount, quint32 time); void processSwipeGestureUpdate(const QSizeF &delta, quint32 time); void processSwipeGestureEnd(quint32 time); void processSwipeGestureCancelled(quint32 time); void processPinchGestureBegin(int fingerCount, quint32 time); void processPinchGestureUpdate(qreal scale, qreal angleDelta, const QSizeF &delta, quint32 time); void processPinchGestureEnd(quint32 time); void processPinchGestureCancelled(quint32 time); Q_SIGNALS: void screensQueried(); void initFailed(); void cursorChanged(); void readyChanged(bool); /** * Emitted by backends using a one screen (nested window) approach and when the size of that changes. **/ void screenSizeChanged(); protected: explicit Platform(QObject *parent = nullptr); void setSoftWareCursor(bool set); void handleOutputs() { m_handlesOutputs = true; } void repaint(const QRect &rect); void setReady(bool ready); QSize initialWindowSize() const { return m_initialWindowSize; } QByteArray deviceIdentifier() const { return m_deviceIdentifier; } void setSupportsPointerWarping(bool set) { m_pointerWarping = set; } void setSupportsGammaControl(bool set) { m_supportsGammaControl = set; } /** * Actual platform specific way to hide the cursor. * Sub-classes need to implement if they support hiding the cursor. * * This method is invoked by hideCursor if the cursor needs to be hidden. * The default implementation does nothing. * * @see doShowCursor * @see hideCursor * @see showCursor **/ virtual void doHideCursor(); /** * Actual platform specific way to show the cursor. * Sub-classes need to implement if they support showing the cursor. * * This method is invoked by showCursor if the cursor needs to be shown again. * * @see doShowCursor * @see hideCursor * @see showCursor **/ virtual void doShowCursor(); private: void triggerCursorRepaint(); bool m_softWareCursor = false; struct { QRect lastRenderedGeometry; } m_cursor; bool m_handlesOutputs = false; bool m_ready = false; QSize m_initialWindowSize; QByteArray m_deviceIdentifier; bool m_pointerWarping = false; bool m_outputsEnabled = true; int m_initialOutputCount = 1; qreal m_initialOutputScale = 1; EGLDisplay m_eglDisplay; EGLConfig m_eglConfig = nullptr; EGLContext m_context = EGL_NO_CONTEXT; EGLSurface m_surface = EGL_NO_SURFACE; int m_hideCursorCounter = 0; ColorCorrect::Manager *m_colorCorrect = nullptr; bool m_supportsGammaControl = false; CompositingType m_selectedCompositor = NoCompositing; }; } Q_DECLARE_INTERFACE(KWin::Platform, "org.kde.kwin.Platform") #endif diff --git a/platformsupport/scenes/opengl/abstract_egl_backend.h b/platformsupport/scenes/opengl/abstract_egl_backend.h index 50d1a8282..a8dd1119c 100644 --- a/platformsupport/scenes/opengl/abstract_egl_backend.h +++ b/platformsupport/scenes/opengl/abstract_egl_backend.h @@ -1,122 +1,122 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_ABSTRACT_EGL_BACKEND_H #define KWIN_ABSTRACT_EGL_BACKEND_H #include "backend.h" #include "texture.h" #include #include #include class QOpenGLFramebufferObject; namespace KWayland { namespace Server { class BufferInterface; } } namespace KWin { class KWIN_EXPORT AbstractEglBackend : public QObject, public OpenGLBackend { Q_OBJECT public: - virtual ~AbstractEglBackend(); + ~AbstractEglBackend() override; bool makeCurrent() override; void doneCurrent() override; EGLDisplay eglDisplay() const { return m_display; } EGLContext context() const { return m_context; } EGLSurface surface() const { return m_surface; } EGLConfig config() const { return m_config; } protected: AbstractEglBackend(); void setEglDisplay(const EGLDisplay &display); void setSurface(const EGLSurface &surface); void setConfig(const EGLConfig &config); void cleanup(); virtual void cleanupSurfaces(); bool initEglAPI(); void initKWinGL(); void initBufferAge(); void initClientExtensions(); void initWayland(); bool hasClientExtension(const QByteArray &ext) const; bool isOpenGLES() const; bool createContext(); private: void unbindWaylandDisplay(); EGLDisplay m_display = EGL_NO_DISPLAY; EGLSurface m_surface = EGL_NO_SURFACE; EGLContext m_context = EGL_NO_CONTEXT; EGLConfig m_config = nullptr; QList m_clientExtensions; }; class KWIN_EXPORT AbstractEglTexture : public SceneOpenGLTexturePrivate { public: - virtual ~AbstractEglTexture(); + ~AbstractEglTexture() override; bool loadTexture(WindowPixmap *pixmap) override; void updateTexture(WindowPixmap *pixmap) override; OpenGLBackend *backend() override; protected: AbstractEglTexture(SceneOpenGLTexture *texture, AbstractEglBackend *backend); EGLImageKHR image() const { return m_image; } void setImage(const EGLImageKHR &img) { m_image = img; } SceneOpenGLTexture *texture() const { return q; } private: bool loadShmTexture(const QPointer &buffer); bool loadEglTexture(const QPointer &buffer); EGLImageKHR attach(const QPointer &buffer); bool updateFromFBO(const QSharedPointer &fbo); SceneOpenGLTexture *q; AbstractEglBackend *m_backend; EGLImageKHR m_image; }; } #endif diff --git a/plugins/idletime/poller.h b/plugins/idletime/poller.h index c14ba29a3..62e6e88ae 100644 --- a/plugins/idletime/poller.h +++ b/plugins/idletime/poller.h @@ -1,67 +1,67 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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 POLLER_H #define POLLER_H #include #include namespace KWayland { namespace Client { class Seat; class Idle; class IdleTimeout; } } class Poller : public AbstractSystemPoller { Q_OBJECT Q_PLUGIN_METADATA(IID "org.kde.kidletime.AbstractSystemPoller" FILE "kwin.json") Q_INTERFACES(AbstractSystemPoller) public: Poller(QObject *parent = 0); - virtual ~Poller(); + ~Poller() override; bool isAvailable() override; bool setUpPoller() override; void unloadPoller() override; public Q_SLOTS: void addTimeout(int nextTimeout) override; void removeTimeout(int nextTimeout) override; QList timeouts() const override; int forcePollRequest() override; void catchIdleEvent() override; void stopCatchingIdleEvents() override; void simulateUserActivity() override; private: KWayland::Client::Seat *m_seat = nullptr; KWayland::Client::Idle *m_idle = nullptr; KWayland::Client::IdleTimeout *m_catchResumeTimeout = nullptr; QHash m_timeouts; }; #endif diff --git a/plugins/kdecorations/aurorae/src/aurorae.h b/plugins/kdecorations/aurorae/src/aurorae.h index 3b280990e..7a1c8a275 100644 --- a/plugins/kdecorations/aurorae/src/aurorae.h +++ b/plugins/kdecorations/aurorae/src/aurorae.h @@ -1,135 +1,135 @@ /******************************************************************** Copyright (C) 2009, 2010, 2012 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 AURORAE_H #define AURORAE_H #include #include #include #include class QOffscreenSurface; class QOpenGLContext; class QOpenGLFramebufferObject; class QQmlComponent; class QQmlEngine; class QQuickItem; class QQuickRenderControl; class QQuickWindow; class KConfigLoader; namespace KWin { class Borders; } namespace Aurorae { class Decoration : public KDecoration2::Decoration { Q_OBJECT Q_PROPERTY(KDecoration2::DecoratedClient* client READ clientPointer CONSTANT) public: explicit Decoration(QObject *parent = nullptr, const QVariantList &args = QVariantList()); - virtual ~Decoration(); + ~Decoration() override; void paint(QPainter *painter, const QRect &repaintRegion) override; Q_INVOKABLE QVariant readConfig(const QString &key, const QVariant &defaultValue = QVariant()); KDecoration2::DecoratedClient *clientPointer() const; public Q_SLOTS: void init() override; void installTitleItem(QQuickItem *item); void updateShadow(); Q_SIGNALS: void configChanged(); protected: void hoverEnterEvent(QHoverEvent *event) override; void hoverLeaveEvent(QHoverEvent *event) override; void hoverMoveEvent(QHoverEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; private: void setupBorders(QQuickItem *item); void updateBorders(); QMouseEvent translatedMouseEvent(QMouseEvent *orig); QScopedPointer m_fbo; QImage m_buffer; QRect m_contentRect; //the geometry of the part of the buffer that is not a shadow when buffer was created. QPointer m_view; QQuickItem *m_item; KWin::Borders *m_borders; KWin::Borders *m_maximizedBorders; KWin::Borders *m_extendedBorders; KWin::Borders *m_padding; QString m_themeName; QQuickRenderControl *m_renderControl = nullptr; QScopedPointer m_updateTimer; QScopedPointer m_context; QScopedPointer m_offscreenSurface; QElapsedTimer m_doubleClickTimer; }; class ThemeFinder : public QObject { Q_OBJECT Q_PROPERTY(QVariantMap themes READ themes) public: explicit ThemeFinder(QObject *parent = nullptr, const QVariantList &args = QVariantList()); QVariantMap themes() const { return m_themes; } public Q_SLOTS: bool hasConfiguration(const QString &theme) const; private: void init(); void findAllQmlThemes(); void findAllSvgThemes(); QVariantMap m_themes; }; class ConfigurationModule : public KCModule { Q_OBJECT public: ConfigurationModule(QWidget *parent, const QVariantList &args); private: void init(); void initSvg(); void initQml(); QString m_theme; KConfigLoader *m_skeleton = nullptr; int m_buttonSize; }; } #endif diff --git a/plugins/kdecorations/aurorae/src/colorhelper.h b/plugins/kdecorations/aurorae/src/colorhelper.h index 1bdb3406c..91f889d96 100644 --- a/plugins/kdecorations/aurorae/src/colorhelper.h +++ b/plugins/kdecorations/aurorae/src/colorhelper.h @@ -1,241 +1,241 @@ /******************************************************************** Copyright (C) 2012 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 COLOR_HELPER_H #define COLOR_HELPER_H #include #include /** * @short Helper to manipulate colors. * * Exports a few functions from KColorScheme. **/ class ColorHelper : public QObject { Q_OBJECT Q_ENUMS(ShadeRole) Q_ENUMS(ForegroundRole) Q_ENUMS(BackgroundRole) /** * Same as KGlobalSettings::contrastF. **/ Q_PROPERTY(qreal contrast READ contrast CONSTANT) public: explicit ColorHelper(QObject *parent = nullptr); - ~ColorHelper(); + ~ColorHelper() override; /** * This enumeration describes the color shade being selected from the given * set. * * Color shades are used to draw "3d" elements, such as frames and bevels. * They are neither foreground nor background colors. Text should not be * painted over a shade, and shades should not be used to draw text. **/ enum ShadeRole { /** * The light color is lighter than dark() or shadow() and contrasts * with the base color. **/ LightShade, /** * The midlight color is in between base() and light(). **/ MidlightShade, /** * The mid color is in between base() and dark(). **/ MidShade, /** * The dark color is in between mid() and shadow(). **/ DarkShade, /** * The shadow color is darker than light() or midlight() and contrasts * the base color. **/ ShadowShade }; /** * This enumeration describes the background color being selected from the * given set. * * Background colors are suitable for drawing under text, and should never * be used to draw text. In combination with one of the overloads of * KColorScheme::shade, they may be used to generate colors for drawing * frames, bevels, and similar decorations. **/ enum BackgroundRole { /** * Normal background. **/ NormalBackground = 0, /** * Alternate background; for example, for use in lists. * * This color may be the same as BackgroundNormal, especially in sets * other than View and Window. **/ AlternateBackground = 1, /** * Third color; for example, items which are new, active, requesting * attention, etc. * * Alerting the user that a certain field must be filled out would be a * good usage (although NegativeBackground could be used to the same * effect, depending on what you are trying to achieve). Unlike * ActiveText, this should not be used for mouseover effects. **/ ActiveBackground = 2, /** * Fourth color; corresponds to (unvisited) links. * * Exactly what this might be used for is somewhat harder to qualify; * it might be used for bookmarks, as a 'you can click here' indicator, * or to highlight recent content (i.e. in a most-recently-accessed * list). **/ LinkBackground = 3, /** * Fifth color; corresponds to visited links. * * This can also be used to indicate "not recent" content, especially * when a color is needed to denote content which is "old" or * "archival". **/ VisitedBackground = 4, /** * Sixth color; for example, errors, untrusted content, etc. **/ NegativeBackground = 5, /** * Seventh color; for example, warnings, secure/encrypted content. **/ NeutralBackground = 6, /** * Eigth color; for example, success messages, trusted content. **/ PositiveBackground = 7 }; /** * This enumeration describes the foreground color being selected from the * given set. * * Foreground colors are suitable for drawing text or glyphs (such as the * symbols on window decoration buttons, assuming a suitable background * brush is used), and should never be used to draw backgrounds. * * For window decorations, the following is suggested, but not set in * stone: * @li Maximize - PositiveText * @li Minimize - NeutralText * @li Close - NegativeText * @li WhatsThis - LinkText * @li Sticky - ActiveText **/ enum ForegroundRole { /** * Normal foreground. **/ NormalText = 0, /** * Second color; for example, comments, items which are old, inactive * or disabled. Generally used for things that are meant to be "less * important". InactiveText is not the same role as NormalText in the * inactive state. **/ InactiveText = 1, /** * Third color; for example items which are new, active, requesting * attention, etc. May be used as a hover color for clickable items. **/ ActiveText = 2, /** * Fourth color; use for (unvisited) links. May also be used for other * clickable items or content that indicates relationships, items that * indicate somewhere the user can visit, etc. **/ LinkText = 3, /** * Fifth color; used for (visited) links. As with LinkText, may be used * for items that have already been "visited" or accessed. May also be * used to indicate "historical" (i.e. "old") items or information, * especially if InactiveText is being used in the same context to * express something different. **/ VisitedText = 4, /** * Sixth color; for example, errors, untrusted content, deletions, * etc. **/ NegativeText = 5, /** * Seventh color; for example, warnings, secure/encrypted content. **/ NeutralText = 6, /** * Eigth color; for example, additions, success messages, trusted * content. **/ PositiveText = 7 }; /** * Retrieve the requested shade color, using the specified color as the * base color and the system contrast setting. * * @note Shades are chosen such that all shades would contrast with the * base color. This means that if base is very dark, the 'dark' shades will * be lighter than the base color, with midlight() == shadow(). * Conversely, if the base color is very light, the 'light' shades will be * darker than the base color, with light() == mid(). **/ Q_INVOKABLE QColor shade(const QColor& color, ShadeRole role); Q_INVOKABLE QColor shade(const QColor& color, ShadeRole role, qreal contrast); /** * Retrieve the requested shade color, using the specified color as the * base color and the specified contrast. * * @param contrast Amount roughly specifying the contrast by which to * adjust the base color, between -1.0 and 1.0 (values between 0.0 and 1.0 * correspond to the value from KGlobalSettings::contrastF) * * @note Shades are chosen such that all shades would contrast with the * base color. This means that if base is very dark, the 'dark' shades will * be lighter than the base color, with midlight() == shadow(). * Conversely, if the base color is very light, the 'light' shades will be * darker than the base color, with light() == mid(). * * @see KColorUtils::shade **/ Q_INVOKABLE QColor multiplyAlpha(const QColor& color, qreal alpha); /** * Retrieve the requested background brush's color for the @p active button. * @param active Whether the active or inactive palette should be used. **/ Q_INVOKABLE QColor background(bool active, BackgroundRole role = NormalBackground) const; /** * Retrieve the requested foreground brush's color for the @p active button. * @param active Whether the active or inactive palette should be used. **/ Q_INVOKABLE QColor foreground(bool active, ForegroundRole role = NormalText) const; qreal contrast() const; }; #endif diff --git a/plugins/kdecorations/aurorae/src/decorationoptions.h b/plugins/kdecorations/aurorae/src/decorationoptions.h index 8e0e311c5..d38e2ca72 100644 --- a/plugins/kdecorations/aurorae/src/decorationoptions.h +++ b/plugins/kdecorations/aurorae/src/decorationoptions.h @@ -1,318 +1,318 @@ /******************************************************************** Copyright (C) 2012 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_DECORATION_OPTIONS_H #define KWIN_DECORATION_OPTIONS_H #include #include #include #include #include namespace KWin { // TODO: move to deco API class ColorSettings { public: ColorSettings(const QPalette &pal); void update(const QPalette &pal); const QColor &titleBarColor(bool active) const { return active ? m_activeTitleBarColor : m_inactiveTitleBarColor; } const QColor &activeTitleBarColor() const { return m_activeTitleBarColor; } const QColor &inactiveTitleBarColor() const { return m_inactiveTitleBarColor; } const QColor &activeTitleBarBlendColor() const { return m_activeTitleBarBlendColor; } const QColor &inactiveTitleBarBlendColor() const { return m_inactiveTitleBarBlendColor; } const QColor &frame(bool active) const { return active ? m_activeFrameColor : m_inactiveFrameColor; } const QColor &activeFrame() const { return m_activeFrameColor; } const QColor &inactiveFrame() const { return m_inactiveFrameColor; } const QColor &font(bool active) const { return active ? m_activeFontColor : m_inactiveFontColor; } const QColor &activeFont() const { return m_activeFontColor; } const QColor &inactiveFont() const { return m_inactiveFontColor; } const QColor &activeButtonColor() const { return m_activeButtonColor; } const QColor &inactiveButtonColor() const { return m_inactiveButtonColor; } const QColor &activeHandle() const { return m_activeHandle; } const QColor &inactiveHandle() const { return m_inactiveHandle; } const QPalette &palette() const { return m_palette; } private: void init(const QPalette &pal); QColor m_activeTitleBarColor; QColor m_inactiveTitleBarColor; QColor m_activeTitleBarBlendColor; QColor m_inactiveTitleBarBlendColor; QColor m_activeFrameColor; QColor m_inactiveFrameColor; QColor m_activeFontColor; QColor m_inactiveFontColor; QColor m_activeButtonColor; QColor m_inactiveButtonColor; QColor m_activeHandle; QColor m_inactiveHandle; QPalette m_palette; }; /** * @short Common Window Decoration Options. * * This Class provides common window decoration options which can be used, but do not have to * be used by a window decoration. The class provides properties for global settings such as * color, font and decoration button position. * * If a window decoration wants to follow the global color scheme it should honor the values * provided by the properties. * * In any case it makes sense to respect the font settings for the decoration as this is also * an accessibility feature. * * In order to use the options in a QML based window decoration an instance of this object needs * to be created and the as a context property available "decoration" needs to be passed to the * DecorationOptions instance: * * @code * DecorationOptions { * id: options * deco: decoration * } * @endcode **/ class DecorationOptions : public QObject { Q_OBJECT Q_ENUMS(BorderSize) Q_ENUMS(DecorationButton) /** * The decoration Object for which this set of options should be used. The decoration is * required to get the correct colors and fonts depending on whether the decoration represents * an active or inactive window. * * Best pass the decoration object available as a context property to this property. **/ Q_PROPERTY(KDecoration2::Decoration *deco READ decoration WRITE setDecoration NOTIFY decorationChanged) /** * The color for the titlebar depending on the decoration's active state. **/ Q_PROPERTY(QColor titleBarColor READ titleBarColor NOTIFY colorsChanged) /** * The blend color for the titlebar depending on the decoration's active state. **/ Q_PROPERTY(QColor titleBarBlendColor READ titleBarBlendColor NOTIFY colorsChanged) /** * The titlebar text color depending on the decoration's active state. **/ Q_PROPERTY(QColor fontColor READ fontColor NOTIFY colorsChanged) /** * The color to use for titlebar buttons depending on the decoration's active state. **/ Q_PROPERTY(QColor buttonColor READ buttonColor NOTIFY colorsChanged) /** * The color for the window frame (border) depending on the decoration's active state. **/ Q_PROPERTY(QColor borderColor READ borderColor NOTIFY colorsChanged) /** * The color for the resize handle depending on the decoration's active state. **/ Q_PROPERTY(QColor resizeHandleColor READ resizeHandleColor NOTIFY colorsChanged) /** * The font to be used for the decoration caption depending on the decoration's active state. **/ Q_PROPERTY(QFont titleFont READ titleFont NOTIFY fontChanged) /** * The buttons to be positioned on the left side of the titlebar from left to right. **/ Q_PROPERTY(QList titleButtonsLeft READ titleButtonsLeft NOTIFY titleButtonsChanged) /** * The buttons to be positioned on the right side of the titlebar from left to right. **/ Q_PROPERTY(QList titleButtonsRight READ titleButtonsRight NOTIFY titleButtonsChanged) Q_PROPERTY(int mousePressAndHoldInterval READ mousePressAndHoldInterval CONSTANT) public: enum BorderSize { BorderNone, ///< No borders except title BorderNoSides, ///< No borders on sides BorderTiny, ///< Minimal borders BorderNormal, ///< Standard size borders, the default setting BorderLarge, ///< Larger borders BorderVeryLarge, ///< Very large borders BorderHuge, ///< Huge borders BorderVeryHuge, ///< Very huge borders BorderOversized ///< Oversized borders }; /** * Enum values to identify the decorations buttons which should be used * by the decoration. * **/ enum DecorationButton { /** * Invalid button value. A decoration should not create a button for * this type. **/ DecorationButtonNone, DecorationButtonMenu, DecorationButtonApplicationMenu, DecorationButtonOnAllDesktops, DecorationButtonQuickHelp, DecorationButtonMinimize, DecorationButtonMaximizeRestore, DecorationButtonClose, DecorationButtonKeepAbove, DecorationButtonKeepBelow, DecorationButtonShade, DecorationButtonResize, /** * The decoration should create an empty spacer instead of a button for * this type. **/ DecorationButtonExplicitSpacer }; explicit DecorationOptions(QObject *parent = nullptr); - virtual ~DecorationOptions(); + ~DecorationOptions() override; QColor titleBarColor() const; QColor titleBarBlendColor() const; QColor fontColor() const; QColor buttonColor() const; QColor borderColor() const; QColor resizeHandleColor() const; QFont titleFont() const; QList titleButtonsLeft() const; QList titleButtonsRight() const; KDecoration2::Decoration *decoration() const; void setDecoration(KDecoration2::Decoration *decoration); int mousePressAndHoldInterval() const; Q_SIGNALS: void colorsChanged(); void fontChanged(); void decorationChanged(); void titleButtonsChanged(); private Q_SLOTS: void slotActiveChanged(); private: bool m_active; KDecoration2::Decoration *m_decoration; ColorSettings m_colors; QMetaObject::Connection m_paletteConnection; }; class Borders : public QObject { Q_OBJECT Q_PROPERTY(int left READ left WRITE setLeft NOTIFY leftChanged) Q_PROPERTY(int right READ right WRITE setRight NOTIFY rightChanged) Q_PROPERTY(int top READ top WRITE setTop NOTIFY topChanged) Q_PROPERTY(int bottom READ bottom WRITE setBottom NOTIFY bottomChanged) public: Borders(QObject *parent = nullptr); - virtual ~Borders(); + ~Borders() override; int left() const; int right() const; int top() const; int bottom() const; void setLeft(int left); void setRight(int right); void setTop(int top); void setBottom(int bottom); operator QMargins() const; public Q_SLOTS: /** * Sets all four borders to @p value. **/ void setAllBorders(int value); /** * Sets all borders except the title border to @p value. **/ void setBorders(int value); /** * Sets the side borders (e.g. if title is on top, the left and right borders) * to @p value. **/ void setSideBorders(int value); /** * Sets the title border to @p value. **/ void setTitle(int value); Q_SIGNALS: void leftChanged(); void rightChanged(); void topChanged(); void bottomChanged(); private: int m_left; int m_right; int m_top; int m_bottom; }; #define GETTER( name ) \ inline int Borders::name() const \ { \ return m_##name;\ }\ GETTER(left) GETTER(right) GETTER(top) GETTER(bottom) #undef GETTER } // namespace #endif // KWIN_DECORATION_OPTIONS_H diff --git a/plugins/kdecorations/aurorae/src/decorationplugin.h b/plugins/kdecorations/aurorae/src/decorationplugin.h index ead164449..f161eae30 100644 --- a/plugins/kdecorations/aurorae/src/decorationplugin.h +++ b/plugins/kdecorations/aurorae/src/decorationplugin.h @@ -1,29 +1,29 @@ /******************************************************************** Copyright (C) 2012 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 DECORATION_PLUGIN_H #define DECORATION_PLUGIN_H #include class DecorationPlugin : public QQmlExtensionPlugin { Q_PLUGIN_METADATA(IID "org.kde.kwin.decoration") Q_OBJECT public: - void registerTypes(const char *uri); + void registerTypes(const char *uri) override; }; #endif diff --git a/plugins/kdecorations/aurorae/src/lib/auroraetheme.h b/plugins/kdecorations/aurorae/src/lib/auroraetheme.h index 445ed61a6..d45f1941c 100644 --- a/plugins/kdecorations/aurorae/src/lib/auroraetheme.h +++ b/plugins/kdecorations/aurorae/src/lib/auroraetheme.h @@ -1,229 +1,229 @@ /* Library for Aurorae window decoration themes. Copyright (C) 2009, 2010, 2012 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, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef AURORAETHEME_H #define AURORAETHEME_H // #include "libaurorae_export.h" #include #include #include Q_DECLARE_LOGGING_CATEGORY(AURORAE) class KConfig; namespace Aurorae { class AuroraeThemePrivate; class ThemeConfig; enum AuroraeButtonType { MinimizeButton = 0, MaximizeButton, RestoreButton, CloseButton, AllDesktopsButton, KeepAboveButton, KeepBelowButton, ShadeButton, HelpButton, MenuButton, AppMenuButton }; enum DecorationPosition { DecorationTop = 0, DecorationLeft, DecorationRight, DecorationBottom }; class /*LIBAURORAE_EXPORT*/ AuroraeTheme : public QObject { Q_OBJECT Q_PROPERTY(int borderLeft READ leftBorder NOTIFY borderSizesChanged) Q_PROPERTY(int borderRight READ rightBorder NOTIFY borderSizesChanged) Q_PROPERTY(int borderTop READ topBorder NOTIFY borderSizesChanged) Q_PROPERTY(int borderBottom READ bottomBorder NOTIFY borderSizesChanged) Q_PROPERTY(int borderLeftMaximized READ leftBorderMaximized NOTIFY borderSizesChanged) Q_PROPERTY(int borderRightMaximized READ rightBorderMaximized NOTIFY borderSizesChanged) Q_PROPERTY(int borderTopMaximized READ topBorderMaximized NOTIFY borderSizesChanged) Q_PROPERTY(int borderBottomMaximized READ bottomBorderMaximized NOTIFY borderSizesChanged) Q_PROPERTY(int paddingLeft READ paddingLeft NOTIFY themeChanged) Q_PROPERTY(int paddingRight READ paddingRight NOTIFY themeChanged) Q_PROPERTY(int paddingTop READ paddingTop NOTIFY themeChanged) Q_PROPERTY(int paddingBottom READ paddingBottom NOTIFY themeChanged) Q_PROPERTY(QString themeName READ themeName NOTIFY themeChanged) Q_PROPERTY(int buttonHeight READ buttonHeight NOTIFY themeChanged) Q_PROPERTY(int buttonWidth READ buttonWidth NOTIFY themeChanged) Q_PROPERTY(int buttonWidthMinimize READ buttonWidthMinimize NOTIFY themeChanged) Q_PROPERTY(int buttonWidthMaximizeRestore READ buttonWidthMaximizeRestore NOTIFY themeChanged) Q_PROPERTY(int buttonWidthClose READ buttonWidthClose NOTIFY themeChanged) Q_PROPERTY(int buttonWidthAllDesktops READ buttonWidthAllDesktops NOTIFY themeChanged) Q_PROPERTY(int buttonWidthKeepAbove READ buttonWidthKeepAbove NOTIFY themeChanged) Q_PROPERTY(int buttonWidthKeepBelow READ buttonWidthKeepBelow NOTIFY themeChanged) Q_PROPERTY(int buttonWidthShade READ buttonWidthShade NOTIFY themeChanged) Q_PROPERTY(int buttonWidthHelp READ buttonWidthHelp NOTIFY themeChanged) Q_PROPERTY(int buttonWidthMenu READ buttonWidthMenu NOTIFY themeChanged) Q_PROPERTY(int buttonWidthAppMenu READ buttonWidthAppMenu NOTIFY themeChanged) Q_PROPERTY(int buttonSpacing READ buttonSpacing NOTIFY themeChanged) Q_PROPERTY(int buttonMarginTop READ buttonMarginTop NOTIFY themeChanged) Q_PROPERTY(int explicitButtonSpacer READ explicitButtonSpacer NOTIFY themeChanged) Q_PROPERTY(qreal buttonSizeFactor READ buttonSizeFactor NOTIFY buttonSizesChanged) Q_PROPERTY(int animationTime READ animationTime NOTIFY themeChanged) Q_PROPERTY(int titleEdgeLeft READ titleEdgeLeft NOTIFY themeChanged) Q_PROPERTY(int titleEdgeRight READ titleEdgeRight NOTIFY themeChanged) Q_PROPERTY(int titleEdgeTop READ titleEdgeTop NOTIFY themeChanged) Q_PROPERTY(int titleEdgeLeftMaximized READ titleEdgeLeftMaximized NOTIFY themeChanged) Q_PROPERTY(int titleEdgeRightMaximized READ titleEdgeRightMaximized NOTIFY themeChanged) Q_PROPERTY(int titleEdgeTopMaximized READ titleEdgeTopMaximized NOTIFY themeChanged) Q_PROPERTY(int titleBorderRight READ titleBorderRight NOTIFY themeChanged) Q_PROPERTY(int titleBorderLeft READ titleBorderLeft NOTIFY themeChanged) Q_PROPERTY(int titleHeight READ titleHeight NOTIFY themeChanged) Q_PROPERTY(QString decorationPath READ decorationPath NOTIFY themeChanged) Q_PROPERTY(QString minimizeButtonPath READ minimizeButtonPath NOTIFY themeChanged) Q_PROPERTY(QString maximizeButtonPath READ maximizeButtonPath NOTIFY themeChanged) Q_PROPERTY(QString restoreButtonPath READ restoreButtonPath NOTIFY themeChanged) Q_PROPERTY(QString closeButtonPath READ closeButtonPath NOTIFY themeChanged) Q_PROPERTY(QString allDesktopsButtonPath READ allDesktopsButtonPath NOTIFY themeChanged) Q_PROPERTY(QString keepAboveButtonPath READ keepAboveButtonPath NOTIFY themeChanged) Q_PROPERTY(QString keepBelowButtonPath READ keepBelowButtonPath NOTIFY themeChanged) Q_PROPERTY(QString shadeButtonPath READ shadeButtonPath NOTIFY themeChanged) Q_PROPERTY(QString helpButtonPath READ helpButtonPath NOTIFY themeChanged) Q_PROPERTY(QColor activeTextColor READ activeTextColor NOTIFY themeChanged) Q_PROPERTY(QColor inactiveTextColor READ inactiveTextColor NOTIFY themeChanged) Q_PROPERTY(Qt::Alignment horizontalAlignment READ alignment NOTIFY themeChanged) Q_PROPERTY(Qt::Alignment verticalAlignment READ verticalAlignment NOTIFY themeChanged) public: explicit AuroraeTheme(QObject* parent = nullptr); - virtual ~AuroraeTheme(); + ~AuroraeTheme() override; // TODO: KSharedConfigPtr void loadTheme(const QString &name, const KConfig &config); bool isValid() const; const QString &themeName() const; int leftBorder() const; int rightBorder() const; int topBorder() const; int bottomBorder() const; int leftBorderMaximized() const; int rightBorderMaximized() const; int topBorderMaximized() const; int bottomBorderMaximized() const; int paddingLeft() const; int paddingRight() const; int paddingTop() const; int paddingBottom() const; int buttonWidth() const; int buttonWidthMinimize() const; int buttonWidthMaximizeRestore() const; int buttonWidthClose() const; int buttonWidthAllDesktops() const; int buttonWidthKeepAbove() const; int buttonWidthKeepBelow() const; int buttonWidthShade() const; int buttonWidthHelp() const; int buttonWidthMenu() const; int buttonWidthAppMenu() const; int buttonHeight() const; int buttonSpacing() const; int buttonMarginTop() const; int explicitButtonSpacer() const; int animationTime() const; int titleEdgeLeft() const; int titleEdgeRight() const; int titleEdgeTop() const; int titleEdgeLeftMaximized() const; int titleEdgeRightMaximized() const; int titleEdgeTopMaximized() const; int titleBorderLeft() const; int titleBorderRight() const; int titleHeight() const; QString decorationPath() const; QString minimizeButtonPath() const; QString maximizeButtonPath() const; QString restoreButtonPath() const; QString closeButtonPath() const; QString allDesktopsButtonPath() const; QString keepAboveButtonPath() const; QString keepBelowButtonPath() const; QString shadeButtonPath() const; QString helpButtonPath() const; QColor activeTextColor() const; QColor inactiveTextColor() const; Qt::Alignment alignment() const; Qt::Alignment verticalAlignment() const; /** * Sets the title edges according to maximized state. * Title edges are global to all windows. **/ void titleEdges(int &left, int &top, int &right, int &bottom, bool maximized) const; void setCompositingActive(bool active); bool isCompositingActive() const; /** * @returns true if the theme contains a FrameSvg for specified button. **/ bool hasButton(AuroraeButtonType button) const; void setBorderSize(KDecoration2::BorderSize size); /** * Sets the size of the buttons. * The available sizes are identical to border sizes, therefore BorderSize is used. * @param size The buttons size **/ void setButtonSize(KDecoration2::BorderSize size); qreal buttonSizeFactor() const; DecorationPosition decorationPosition() const; void setTabDragMimeType(const QString &mime); const QString &tabDragMimeType() const; // TODO: move to namespace static QLatin1String mapButtonToName(AuroraeButtonType type); public Q_SLOTS: void loadTheme(const QString &name); Q_SIGNALS: void themeChanged(); void buttonSizesChanged(); void borderSizesChanged(); private: /** * Sets the borders according to maximized state. * Borders are global to all windows. **/ void borders(int &left, int &top, int &right, int &bottom, bool maximized) const; /** * Sets the padding according. * Padding is global to all windows. **/ void padding(int &left, int &top, int &right, int &bottom) const; AuroraeThemePrivate* const d; }; } // namespace #endif // AURORAETHEME_H diff --git a/plugins/kdecorations/aurorae/themes/plastik/code/plastikbutton.h b/plugins/kdecorations/aurorae/themes/plastik/code/plastikbutton.h index c81c9e70a..7a3553c8f 100644 --- a/plugins/kdecorations/aurorae/themes/plastik/code/plastikbutton.h +++ b/plugins/kdecorations/aurorae/themes/plastik/code/plastikbutton.h @@ -1,84 +1,84 @@ /******************************************************************** Copyright (C) 2012 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_PLASTIK_BUTTON_H #define KWIN_PLASTIK_BUTTON_H #include namespace KWin { class PlastikButtonProvider : public QQuickImageProvider { public: explicit PlastikButtonProvider(); - virtual QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize); + QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) override; private: enum ButtonIcon { CloseIcon = 0, MaxIcon, MaxRestoreIcon, MinIcon, HelpIcon, OnAllDesktopsIcon, NotOnAllDesktopsIcon, KeepAboveIcon, NoKeepAboveIcon, KeepBelowIcon, NoKeepBelowIcon, ShadeIcon, UnShadeIcon, AppMenuIcon, NumButtonIcons }; enum Object { HorizontalLine, VerticalLine, DiagonalLine, CrossDiagonalLine }; enum DecorationButton { /** * Invalid button value. A decoration should not create a button for * this type. **/ DecorationButtonNone, DecorationButtonMenu, DecorationButtonApplicationMenu, DecorationButtonOnAllDesktops, DecorationButtonQuickHelp, DecorationButtonMinimize, DecorationButtonMaximizeRestore, DecorationButtonClose, DecorationButtonKeepAbove, DecorationButtonKeepBelow, DecorationButtonShade, DecorationButtonResize, /** * The decoration should create an empty spacer instead of a button for * this type. **/ DecorationButtonExplicitSpacer }; QPixmap icon(ButtonIcon icon, int size, bool active, bool shadow); void drawObject(QPainter &p, Object object, int x, int y, int length, int lineWidth); }; } // namespace #endif // KWIN_PLASTIK_BUTTON_H diff --git a/plugins/kdecorations/aurorae/themes/plastik/code/plastikplugin.h b/plugins/kdecorations/aurorae/themes/plastik/code/plastikplugin.h index 33361a081..0bc660f7a 100644 --- a/plugins/kdecorations/aurorae/themes/plastik/code/plastikplugin.h +++ b/plugins/kdecorations/aurorae/themes/plastik/code/plastikplugin.h @@ -1,31 +1,31 @@ /******************************************************************** Copyright (C) 2012 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 PLASTIK_PLUGIN_H #define PLASTIK_PLUGIN_H #include class PlastikPlugin : public QQmlExtensionPlugin { Q_PLUGIN_METADATA(IID "org.kde.kwin.decorations.plastik") Q_OBJECT public: - virtual void registerTypes(const char *uri) override; - virtual void initializeEngine(QQmlEngine *engine, const char *uri) override; + void registerTypes(const char *uri) override; + void initializeEngine(QQmlEngine *engine, const char *uri) override; }; #endif // PLASTIK_PLUGIN_H diff --git a/plugins/kglobalaccel/kglobalaccel_plugin.h b/plugins/kglobalaccel/kglobalaccel_plugin.h index 4985a9076..2b72b6d3e 100644 --- a/plugins/kglobalaccel/kglobalaccel_plugin.h +++ b/plugins/kglobalaccel/kglobalaccel_plugin.h @@ -1,48 +1,48 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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 KGLOBALACCEL_PLUGIN_H #define KGLOBALACCEL_PLUGIN_H #include #include class KGlobalAccelImpl : public KGlobalAccelInterface { Q_OBJECT Q_PLUGIN_METADATA(IID "org.kde.kglobalaccel5.KGlobalAccelInterface" FILE "kwin.json") Q_INTERFACES(KGlobalAccelInterface) public: KGlobalAccelImpl(QObject *parent = 0); - virtual ~KGlobalAccelImpl(); + ~KGlobalAccelImpl() override; bool grabKey(int key, bool grab) override; void setEnabled(bool) override; public Q_SLOTS: bool checkKeyPressed(int keyQt); private: bool m_shuttingDown = false; QMetaObject::Connection m_inputDestroyedConnection; }; #endif diff --git a/plugins/platforms/drm/drm_backend.h b/plugins/platforms/drm/drm_backend.h index 2bcb67457..8e029231b 100644 --- a/plugins/platforms/drm/drm_backend.h +++ b/plugins/platforms/drm/drm_backend.h @@ -1,212 +1,212 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_DRM_BACKEND_H #define KWIN_DRM_BACKEND_H #include "platform.h" #include "input.h" #include "drm_buffer.h" #if HAVE_GBM #include "drm_buffer_gbm.h" #endif #include "drm_inputeventfilter.h" #include "drm_pointer.h" #include #include #include #include #include #include #include struct gbm_bo; struct gbm_device; struct gbm_surface; namespace KWayland { namespace Server { class OutputInterface; class OutputDeviceInterface; class OutputChangeSet; class OutputManagementInterface; } } namespace KWin { class Udev; class UdevMonitor; class DrmOutput; class DrmPlane; class DrmCrtc; class DrmConnector; class GbmSurface; class KWIN_EXPORT DrmBackend : public Platform { Q_OBJECT Q_INTERFACES(KWin::Platform) Q_PLUGIN_METADATA(IID "org.kde.kwin.Platform" FILE "drm.json") public: explicit DrmBackend(QObject *parent = nullptr); - virtual ~DrmBackend(); + ~DrmBackend() override; void configurationChangeRequested(KWayland::Server::OutputConfigurationInterface *config) override; Screens *createScreens(QObject *parent = nullptr) override; QPainterBackend *createQPainterBackend() override; OpenGLBackend* createOpenGLBackend() override; void init() override; DrmDumbBuffer *createBuffer(const QSize &size); #if HAVE_GBM DrmSurfaceBuffer *createBuffer(const std::shared_ptr &surface); #endif bool present(DrmBuffer *buffer, DrmOutput *output); int fd() const { return m_fd; } Outputs outputs() const override; Outputs enabledOutputs() const override; QVector drmOutputs() const { return m_outputs; } QVector drmEnabledOutputs() const { return m_enabledOutputs; } QVector planes() const { return m_planes; } QVector overlayPlanes() const { return m_overlayPlanes; } void outputWentOff(); void checkOutputsAreOn(); // QPainter reuses buffers bool deleteBufferAfterPageFlip() const { return m_deleteBufferAfterPageFlip; } // returns use of AMS, default is not/legacy bool atomicModeSetting() const { return m_atomicModeSetting; } void setGbmDevice(gbm_device *device) { m_gbmDevice = device; } gbm_device *gbmDevice() const { return m_gbmDevice; } QByteArray devNode() const { return m_devNode; } #if HAVE_EGL_STREAMS bool useEglStreams() const { return m_useEglStreams; } #endif QVector supportedCompositors() const override; QString supportInformation() const override; public Q_SLOTS: void turnOutputsOn(); Q_SIGNALS: /** * Emitted whenever an output is removed/disabled **/ void outputRemoved(KWin::DrmOutput *output); /** * Emitted whenever an output is added/enabled **/ void outputAdded(KWin::DrmOutput *output); protected: void doHideCursor() override; void doShowCursor() override; private: static void pageFlipHandler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, void *data); void openDrm(); void activate(bool active); void reactivate(); void deactivate(); void updateOutputs(); void setCursor(); void updateCursor(); void moveCursor(); void initCursor(); void outputDpmsChanged(); void readOutputsConfiguration(); void writeOutputsConfiguration(); QByteArray generateOutputConfigurationUuid() const; DrmOutput *findOutput(quint32 connector); DrmOutput *findOutput(const QByteArray &uuid); QScopedPointer m_udev; QScopedPointer m_udevMonitor; int m_fd = -1; int m_drmId = 0; // all crtcs QVector m_crtcs; // all connectors QVector m_connectors; // active output pipelines (planes + crtc + encoder + connector) QVector m_outputs; // active and enabled pipelines (above + wl_output) QVector m_enabledOutputs; bool m_deleteBufferAfterPageFlip; bool m_atomicModeSetting = false; bool m_cursorEnabled = false; QSize m_cursorSize; int m_pageFlipsPending = 0; bool m_active = false; QByteArray m_devNode; #if HAVE_EGL_STREAMS bool m_useEglStreams = false; #endif // all available planes: primarys, cursors and overlays QVector m_planes; QVector m_overlayPlanes; QScopedPointer m_dpmsFilter; KWayland::Server::OutputManagementInterface *m_outputManagement = nullptr; gbm_device *m_gbmDevice = nullptr; }; } #endif diff --git a/plugins/platforms/drm/drm_buffer.h b/plugins/platforms/drm/drm_buffer.h index 7af2ef913..804d5d8e4 100644 --- a/plugins/platforms/drm/drm_buffer.h +++ b/plugins/platforms/drm/drm_buffer.h @@ -1,88 +1,88 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_DRM_BUFFER_H #define KWIN_DRM_BUFFER_H #include #include namespace KWin { class DrmBuffer { public: DrmBuffer(int fd); virtual ~DrmBuffer() = default; virtual bool needsModeChange(DrmBuffer *b) const {Q_UNUSED(b) return false;} quint32 bufferId() const { return m_bufferId; } const QSize &size() const { return m_size; } virtual void releaseGbm() {} int fd() const { return m_fd; } protected: quint32 m_bufferId = 0; QSize m_size; int m_fd; }; class DrmDumbBuffer : public DrmBuffer { public: DrmDumbBuffer(int fd, const QSize &size); - ~DrmDumbBuffer(); + ~DrmDumbBuffer() override; bool needsModeChange(DrmBuffer *b) const override; bool map(QImage::Format format = QImage::Format_RGB32); quint32 handle() const { return m_handle; } QImage *image() const { return m_image; } quint32 stride() const { return m_stride; } private: quint32 m_handle = 0; quint64 m_bufferSize = 0; void *m_memory = nullptr; QImage *m_image = nullptr; quint32 m_stride = 0; }; } #endif diff --git a/plugins/platforms/drm/drm_buffer_gbm.h b/plugins/platforms/drm/drm_buffer_gbm.h index b9b40e8e7..0205be7ec 100644 --- a/plugins/platforms/drm/drm_buffer_gbm.h +++ b/plugins/platforms/drm/drm_buffer_gbm.h @@ -1,67 +1,67 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright 2017 Roman Gilg Copyright 2015 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_DRM_BUFFER_GBM_H #define KWIN_DRM_BUFFER_GBM_H #include "drm_buffer.h" #include struct gbm_bo; namespace KWin { class GbmSurface; class DrmSurfaceBuffer : public DrmBuffer { public: DrmSurfaceBuffer(int fd, const std::shared_ptr &surface); - ~DrmSurfaceBuffer(); + ~DrmSurfaceBuffer() override; bool needsModeChange(DrmBuffer *b) const override { if (DrmSurfaceBuffer *sb = dynamic_cast(b)) { return hasBo() != sb->hasBo(); } else { return true; } } bool hasBo() const { return m_bo != nullptr; } gbm_bo* getBo() const { return m_bo; } void releaseGbm() override; private: std::shared_ptr m_surface; gbm_bo *m_bo = nullptr; }; } #endif diff --git a/plugins/platforms/drm/drm_inputeventfilter.h b/plugins/platforms/drm/drm_inputeventfilter.h index 056f7792b..78ab4226c 100644 --- a/plugins/platforms/drm/drm_inputeventfilter.h +++ b/plugins/platforms/drm/drm_inputeventfilter.h @@ -1,56 +1,56 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_DRM_INPUTEVENTFILTER_H #define KWIN_DRM_INPUTEVENTFILTER_H #include "input.h" #include namespace KWin { class DrmBackend; class DpmsInputEventFilter : public InputEventFilter { public: DpmsInputEventFilter(DrmBackend *backend); - ~DpmsInputEventFilter(); + ~DpmsInputEventFilter() override; bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override; bool wheelEvent(QWheelEvent *event) override; bool keyEvent(QKeyEvent *event) override; bool touchDown(quint32 id, const QPointF &pos, quint32 time) override; bool touchMotion(quint32 id, const QPointF &pos, quint32 time) override; bool touchUp(quint32 id, quint32 time) override; private: void notify(); DrmBackend *m_backend; QElapsedTimer m_doubleTapTimer; QVector m_touchPoints; bool m_secondTap = false; }; } #endif diff --git a/plugins/platforms/drm/drm_object_connector.h b/plugins/platforms/drm/drm_object_connector.h index 7cd240629..d52c5cb47 100644 --- a/plugins/platforms/drm/drm_object_connector.h +++ b/plugins/platforms/drm/drm_object_connector.h @@ -1,57 +1,57 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2016 Roman Gilg 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_DRM_OBJECT_CONNECTOR_H #define KWIN_DRM_OBJECT_CONNECTOR_H #include "drm_object.h" namespace KWin { class DrmConnector : public DrmObject { public: DrmConnector(uint32_t connector_id, int fd); - virtual ~DrmConnector(); + ~DrmConnector() override; - bool atomicInit(); + bool atomicInit() override; enum class PropertyIndex { CrtcId = 0, Count }; QVector encoders() { return m_encoders; } - bool initProps(); + bool initProps() override; bool isConnected(); private: QVector m_encoders; }; } #endif diff --git a/plugins/platforms/drm/drm_object_crtc.h b/plugins/platforms/drm/drm_object_crtc.h index 1f6fe1169..88bc90255 100644 --- a/plugins/platforms/drm/drm_object_crtc.h +++ b/plugins/platforms/drm/drm_object_crtc.h @@ -1,85 +1,85 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2016 Roman Gilg 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_DRM_OBJECT_CRTC_H #define KWIN_DRM_OBJECT_CRTC_H #include "drm_object.h" namespace KWin { class DrmBackend; class DrmBuffer; class DrmDumbBuffer; class GammaRamp; class DrmCrtc : public DrmObject { public: DrmCrtc(uint32_t crtc_id, DrmBackend *backend, int resIndex); - virtual ~DrmCrtc(); + ~DrmCrtc() override; - bool atomicInit(); + bool atomicInit() override; enum class PropertyIndex { ModeId = 0, Active, Count }; - bool initProps(); + bool initProps() override; int resIndex() const { return m_resIndex; } DrmBuffer *current() { return m_currentBuffer; } DrmBuffer *next() { return m_nextBuffer; } void setNext(DrmBuffer *buffer) { m_nextBuffer = buffer; } void flipBuffer(); bool blank(); int gammaRampSize() const { return m_gammaRampSize; } bool setGammaRamp(const GammaRamp &gamma); private: int m_resIndex; uint32_t m_gammaRampSize = 0; DrmBuffer *m_currentBuffer = nullptr; DrmBuffer *m_nextBuffer = nullptr; DrmDumbBuffer *m_blackBuffer = nullptr; DrmBackend *m_backend; }; } #endif diff --git a/plugins/platforms/drm/drm_object_plane.h b/plugins/platforms/drm/drm_object_plane.h index cd6f739c6..52b59b02d 100644 --- a/plugins/platforms/drm/drm_object_plane.h +++ b/plugins/platforms/drm/drm_object_plane.h @@ -1,122 +1,122 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2016 Roman Gilg 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_DRM_OBJECT_PLANE_H #define KWIN_DRM_OBJECT_PLANE_H #include "drm_object.h" // drm #include namespace KWin { class DrmBuffer; class DrmPlane : public DrmObject { public: DrmPlane(uint32_t plane_id, int fd); - ~DrmPlane(); + ~DrmPlane() override; enum class PropertyIndex { Type = 0, SrcX, SrcY, SrcW, SrcH, CrtcX, CrtcY, CrtcW, CrtcH, FbId, CrtcId, Rotation, Count }; enum class TypeIndex { Primary = 0, Cursor, Overlay, Count }; enum class Transformation { Rotate0 = 1 << 0, Rotate90 = 1 << 1, Rotate180 = 1 << 2, Rotate270 = 1 << 3, ReflectX = 1 << 4, ReflectY = 1 << 5 }; Q_DECLARE_FLAGS(Transformations, Transformation); - bool atomicInit(); - bool initProps(); + bool atomicInit() override; + bool initProps() override; TypeIndex type(); bool isCrtcSupported(int resIndex) const { return (m_possibleCrtcs & (1 << resIndex)); } QVector formats() const { return m_formats; } DrmBuffer *current() const { return m_current; } DrmBuffer *next() const { return m_next; } void setCurrent(DrmBuffer *b) { m_current = b; } void setNext(DrmBuffer *b); void setTransformation(Transformations t); Transformations transformation(); - bool atomicPopulate(drmModeAtomicReq *req); + bool atomicPopulate(drmModeAtomicReq *req) override; void flipBuffer(); void flipBufferWithDelete(); Transformations supportedTransformations() const { return m_supportedTransformations; } private: DrmBuffer *m_current = nullptr; DrmBuffer *m_next = nullptr; // TODO: See weston drm_output_check_plane_format for future use of these member variables QVector m_formats; // Possible formats, which can be presented on this plane // TODO: when using overlay planes in the future: restrict possible screens / crtcs of planes uint32_t m_possibleCrtcs; Transformations m_supportedTransformations = Transformation::Rotate0; }; } Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::DrmPlane::Transformations) #endif diff --git a/plugins/platforms/drm/egl_gbm_backend.h b/plugins/platforms/drm/egl_gbm_backend.h index 8d6d1a670..2b1af6a66 100644 --- a/plugins/platforms/drm/egl_gbm_backend.h +++ b/plugins/platforms/drm/egl_gbm_backend.h @@ -1,101 +1,101 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_EGL_GBM_BACKEND_H #define KWIN_EGL_GBM_BACKEND_H #include "abstract_egl_backend.h" #include "remoteaccess_manager.h" #include struct gbm_surface; namespace KWin { class DrmBackend; class DrmBuffer; class DrmOutput; class GbmSurface; /** * @brief OpenGL Backend using Egl on a GBM surface. **/ class EglGbmBackend : public AbstractEglBackend { Q_OBJECT public: EglGbmBackend(DrmBackend *b); - virtual ~EglGbmBackend(); + ~EglGbmBackend() override; void screenGeometryChanged(const QSize &size) override; SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override; QRegion prepareRenderingFrame() override; void endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override; void endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion) override; bool usesOverlayWindow() const override; bool perScreenRendering() const override; QRegion prepareRenderingForScreen(int screenId) override; void init() override; protected: void present() override; void cleanupSurfaces() override; private: bool initializeEgl(); bool initBufferConfigs(); bool initRenderingContext(); void initRemotePresent(); struct Output { DrmOutput *output = nullptr; DrmBuffer *buffer = nullptr; std::shared_ptr gbmSurface; EGLSurface eglSurface = EGL_NO_SURFACE; int bufferAge = 0; /** * @brief The damage history for the past 10 frames. **/ QList damageHistory; }; bool resetOutput(Output &output, DrmOutput *drmOutput); bool makeContextCurrent(const Output &output); void presentOnOutput(Output &output); void cleanupOutput(const Output &output); void createOutput(DrmOutput *output); DrmBackend *m_backend; QVector m_outputs; QScopedPointer m_remoteaccessManager; friend class EglGbmTexture; }; /** * @brief Texture using an EGLImageKHR. **/ class EglGbmTexture : public AbstractEglTexture { public: - virtual ~EglGbmTexture(); + ~EglGbmTexture() override; private: friend class EglGbmBackend; EglGbmTexture(SceneOpenGLTexture *texture, EglGbmBackend *backend); }; } // namespace #endif diff --git a/plugins/platforms/drm/egl_stream_backend.h b/plugins/platforms/drm/egl_stream_backend.h index 6bae8e76c..1c5a5b80d 100644 --- a/plugins/platforms/drm/egl_stream_backend.h +++ b/plugins/platforms/drm/egl_stream_backend.h @@ -1,116 +1,116 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2019 NVIDIA Inc. 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_EGL_STREAM_BACKEND_H #define KWIN_EGL_STREAM_BACKEND_H #include "abstract_egl_backend.h" #include #include #include namespace KWin { class DrmBackend; class DrmOutput; class DrmBuffer; class ShellClient; /** * @brief OpenGL Backend using Egl with an EGLDevice. **/ class EglStreamBackend : public AbstractEglBackend { Q_OBJECT public: EglStreamBackend(DrmBackend *b); - virtual ~EglStreamBackend(); + ~EglStreamBackend() override; void screenGeometryChanged(const QSize &size) override; SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override; QRegion prepareRenderingFrame() override; void endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override; void endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion) override; bool usesOverlayWindow() const override; bool perScreenRendering() const override; QRegion prepareRenderingForScreen(int screenId) override; void init() override; protected: void present() override; void cleanupSurfaces() override; private: bool initializeEgl(); bool initBufferConfigs(); bool initRenderingContext(); struct StreamTexture { EGLStreamKHR stream; GLuint texture; }; StreamTexture *lookupStreamTexture(KWayland::Server::SurfaceInterface *surface); void attachStreamConsumer(KWayland::Server::SurfaceInterface *surface, void *eglStream, wl_array *attribs); struct Output { DrmOutput *output = nullptr; DrmBuffer *buffer = nullptr; EGLSurface eglSurface = EGL_NO_SURFACE; EGLStreamKHR eglStream = EGL_NO_STREAM_KHR; }; bool resetOutput(Output &output, DrmOutput *drmOutput); bool makeContextCurrent(const Output &output); void presentOnOutput(Output &output); void cleanupOutput(const Output &output); void createOutput(DrmOutput *output); DrmBackend *m_backend; QVector m_outputs; KWayland::Server::EglStreamControllerInterface *m_eglStreamControllerInterface; QHash m_streamTextures; friend class EglStreamTexture; }; /** * @brief External texture bound to an EGLStreamKHR. **/ class EglStreamTexture : public AbstractEglTexture { public: - virtual ~EglStreamTexture(); + ~EglStreamTexture() override; bool loadTexture(WindowPixmap *pixmap) override; void updateTexture(WindowPixmap *pixmap) override; private: EglStreamTexture(SceneOpenGLTexture *texture, EglStreamBackend *backend); bool acquireStreamFrame(EGLStreamKHR stream); void createFbo(); void copyExternalTexture(GLuint tex); bool attachBuffer(KWayland::Server::BufferInterface *buffer); EglStreamBackend *m_backend; GLuint m_fbo, m_rbo; GLenum m_format; friend class EglStreamBackend; }; } // namespace #endif diff --git a/plugins/platforms/drm/remoteaccess_manager.h b/plugins/platforms/drm/remoteaccess_manager.h index 3a1bc698b..b521bb8b6 100644 --- a/plugins/platforms/drm/remoteaccess_manager.h +++ b/plugins/platforms/drm/remoteaccess_manager.h @@ -1,61 +1,61 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2016 Oleg Chernovskiy 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 REMOTEACCESSMANAGER_H #define REMOTEACCESSMANAGER_H // KWayland #include #include // Qt #include struct gbm_bo; struct gbm_surface; namespace KWin { class DrmOutput; class DrmBuffer; using KWayland::Server::RemoteAccessManagerInterface; using KWayland::Server::BufferHandle; class RemoteAccessManager : public QObject { Q_OBJECT public: explicit RemoteAccessManager(QObject *parent = nullptr); - virtual ~RemoteAccessManager(); + ~RemoteAccessManager() override; void passBuffer(DrmOutput *output, DrmBuffer *buffer); signals: void bufferNoLongerNeeded(qint32 gbm_handle); private: void releaseBuffer(const BufferHandle *buf); RemoteAccessManagerInterface *m_interface = nullptr; }; } // KWin namespace #endif // REMOTEACCESSMANAGER_H diff --git a/plugins/platforms/drm/scene_qpainter_drm_backend.h b/plugins/platforms/drm/scene_qpainter_drm_backend.h index cdb308bb0..e4235345d 100644 --- a/plugins/platforms/drm/scene_qpainter_drm_backend.h +++ b/plugins/platforms/drm/scene_qpainter_drm_backend.h @@ -1,60 +1,60 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_SCENE_QPAINTER_DRM_BACKEND_H #define KWIN_SCENE_QPAINTER_DRM_BACKEND_H #include #include #include namespace KWin { class DrmBackend; class DrmDumbBuffer; class DrmOutput; class DrmQPainterBackend : public QObject, public QPainterBackend { Q_OBJECT public: DrmQPainterBackend(DrmBackend *backend); - virtual ~DrmQPainterBackend(); + ~DrmQPainterBackend() override; QImage *buffer() override; QImage *bufferForScreen(int screenId) override; bool needsFullRepaint() const override; bool usesOverlayWindow() const override; void prepareRenderingFrame() override; void present(int mask, const QRegion &damage) override; bool perScreenRendering() const override; private: void initOutput(DrmOutput *output); struct Output { DrmDumbBuffer *buffer[2]; DrmOutput *output; int index = 0; }; QVector m_outputs; DrmBackend *m_backend; }; } #endif diff --git a/plugins/platforms/drm/screens_drm.h b/plugins/platforms/drm/screens_drm.h index daa8afdac..0f62ad607 100644 --- a/plugins/platforms/drm/screens_drm.h +++ b/plugins/platforms/drm/screens_drm.h @@ -1,42 +1,42 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_DRM_H #define KWIN_SCREENS_DRM_H #include "outputscreens.h" namespace KWin { class DrmBackend; class DrmScreens : public OutputScreens { Q_OBJECT public: DrmScreens(DrmBackend *backend, QObject *parent = nullptr); - virtual ~DrmScreens(); + ~DrmScreens() override; bool supportsTransformations(int screen) const override; DrmBackend *m_backend; }; } #endif diff --git a/plugins/platforms/fbdev/fb_backend.h b/plugins/platforms/fbdev/fb_backend.h index 666cf3f16..b044abb13 100644 --- a/plugins/platforms/fbdev/fb_backend.h +++ b/plugins/platforms/fbdev/fb_backend.h @@ -1,131 +1,131 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright 2015 Martin Gräßlin Copyright 2019 Roman Gilg 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_FB_BACKEND_H #define KWIN_FB_BACKEND_H #include "abstract_wayland_output.h" #include "platform.h" #include #include namespace KWin { class FramebufferOutput : public AbstractWaylandOutput { Q_OBJECT public: FramebufferOutput(QObject *parent = nullptr) : AbstractWaylandOutput(parent) {} - virtual ~FramebufferOutput() = default; + ~FramebufferOutput() override = default; QSize pixelSize() const override { return m_pixelSize; } void setPixelSize(const QSize &set) { m_pixelSize = set; } void setRawPhysicalSize(const QSize &set) { AbstractWaylandOutput::setRawPhysicalSize(set); } private: QSize m_pixelSize; }; class KWIN_EXPORT FramebufferBackend : public Platform { Q_OBJECT Q_INTERFACES(KWin::Platform) Q_PLUGIN_METADATA(IID "org.kde.kwin.Platform" FILE "fbdev.json") public: explicit FramebufferBackend(QObject *parent = nullptr); - virtual ~FramebufferBackend(); + ~FramebufferBackend() override; Screens *createScreens(QObject *parent = nullptr) override; QPainterBackend *createQPainterBackend() override; QSize screenSize() const override; void init() override; bool isValid() const { return m_fd >= 0; } void map(); void unmap(); void *mappedMemory() const { return m_memory; } int bytesPerLine() const { return m_bytesPerLine; } int bufferSize() const { return m_bufferLength; } quint32 bitsPerPixel() const { return m_bitsPerPixel; } QImage::Format imageFormat() const; /** * @returns whether the imageFormat is BGR instead of RGB. **/ bool isBGR() const { return m_bgr; } Outputs outputs() const override; Outputs enabledOutputs() const override; QVector supportedCompositors() const override { return QVector{QPainterCompositing}; } private: void openFrameBuffer(); bool handleScreenInfo(); void initImageFormat(); QVector m_outputs; QByteArray m_id; struct Color { quint32 offset; quint32 length; }; Color m_red; Color m_green; Color m_blue; Color m_alpha; quint32 m_bitsPerPixel = 0; int m_fd = -1; quint32 m_bufferLength = 0; int m_bytesPerLine = 0; void *m_memory = nullptr; QImage::Format m_imageFormat = QImage::Format_Invalid; bool m_bgr = false; }; } #endif diff --git a/plugins/platforms/fbdev/scene_qpainter_fb_backend.h b/plugins/platforms/fbdev/scene_qpainter_fb_backend.h index 1318fe51a..2a15b6a2f 100644 --- a/plugins/platforms/fbdev/scene_qpainter_fb_backend.h +++ b/plugins/platforms/fbdev/scene_qpainter_fb_backend.h @@ -1,62 +1,62 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_SCENE_QPAINTER_FB_BACKEND_H #define KWIN_SCENE_QPAINTER_FB_BACKEND_H #include #include #include namespace KWin { class FramebufferBackend; class FramebufferQPainterBackend : public QObject, public QPainterBackend { Q_OBJECT public: FramebufferQPainterBackend(FramebufferBackend *backend); - virtual ~FramebufferQPainterBackend(); + ~FramebufferQPainterBackend() override; QImage *buffer() override; QImage *bufferForScreen(int screenId) override; bool needsFullRepaint() const override; bool usesOverlayWindow() const override; void prepareRenderingFrame() override; void present(int mask, const QRegion &damage) override; bool perScreenRendering() const override; private: /** * @brief mapped memory buffer on fb device */ QImage m_renderBuffer; /** * @brief buffer to draw into */ QImage m_backBuffer; FramebufferBackend *m_backend; bool m_needsFullRepaint; }; } #endif diff --git a/plugins/platforms/virtual/egl_gbm_backend.h b/plugins/platforms/virtual/egl_gbm_backend.h index c8b7a7169..128244af7 100644 --- a/plugins/platforms/virtual/egl_gbm_backend.h +++ b/plugins/platforms/virtual/egl_gbm_backend.h @@ -1,74 +1,74 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_EGL_GBM_BACKEND_H #define KWIN_EGL_GBM_BACKEND_H #include "abstract_egl_backend.h" namespace KWin { class VirtualBackend; class GLTexture; class GLRenderTarget; /** * @brief OpenGL Backend using Egl on a GBM surface. **/ class EglGbmBackend : public AbstractEglBackend { public: EglGbmBackend(VirtualBackend *b); - virtual ~EglGbmBackend(); + ~EglGbmBackend() override; void screenGeometryChanged(const QSize &size) override; SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override; QRegion prepareRenderingFrame() override; void endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override; bool usesOverlayWindow() const override; void init() override; protected: void present() override; private: bool initializeEgl(); bool initBufferConfigs(); bool initRenderingContext(); VirtualBackend *m_backend; GLTexture *m_backBuffer = nullptr; GLRenderTarget *m_fbo = nullptr; int m_frameCounter = 0; friend class EglGbmTexture; }; /** * @brief Texture using an EGLImageKHR. **/ class EglGbmTexture : public AbstractEglTexture { public: - virtual ~EglGbmTexture(); + ~EglGbmTexture() override; private: friend class EglGbmBackend; EglGbmTexture(SceneOpenGLTexture *texture, EglGbmBackend *backend); }; } // namespace #endif diff --git a/plugins/platforms/virtual/scene_qpainter_virtual_backend.h b/plugins/platforms/virtual/scene_qpainter_virtual_backend.h index b72aa8c13..c95228a61 100644 --- a/plugins/platforms/virtual/scene_qpainter_virtual_backend.h +++ b/plugins/platforms/virtual/scene_qpainter_virtual_backend.h @@ -1,58 +1,58 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_SCENE_QPAINTER_VIRTUAL_BACKEND_H #define KWIN_SCENE_QPAINTER_VIRTUAL_BACKEND_H #include #include #include namespace KWin { class VirtualBackend; class VirtualQPainterBackend : public QObject, public QPainterBackend { Q_OBJECT public: VirtualQPainterBackend(VirtualBackend *backend); - virtual ~VirtualQPainterBackend(); + ~VirtualQPainterBackend() override; QImage *buffer() override; QImage *bufferForScreen(int screenId) override; bool needsFullRepaint() const override; bool usesOverlayWindow() const override; void prepareRenderingFrame() override; void present(int mask, const QRegion &damage) override; bool perScreenRendering() const override; private: void createOutputs(); QVector m_backBuffers; VirtualBackend *m_backend; int m_frameCounter = 0; }; } #endif diff --git a/plugins/platforms/virtual/screens_virtual.h b/plugins/platforms/virtual/screens_virtual.h index bdc4df3b1..ad20891cd 100644 --- a/plugins/platforms/virtual/screens_virtual.h +++ b/plugins/platforms/virtual/screens_virtual.h @@ -1,45 +1,45 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_VIRTUAL_H #define KWIN_SCREENS_VIRTUAL_H #include "outputscreens.h" #include namespace KWin { class VirtualBackend; class VirtualScreens : public OutputScreens { Q_OBJECT public: VirtualScreens(VirtualBackend *backend, QObject *parent = nullptr); - virtual ~VirtualScreens(); + ~VirtualScreens() override; void init() override; private: void createOutputs(); VirtualBackend *m_backend; }; } #endif diff --git a/plugins/platforms/virtual/virtual_backend.h b/plugins/platforms/virtual/virtual_backend.h index 458dee57d..09f6db032 100644 --- a/plugins/platforms/virtual/virtual_backend.h +++ b/plugins/platforms/virtual/virtual_backend.h @@ -1,79 +1,79 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_VIRTUAL_BACKEND_H #define KWIN_VIRTUAL_BACKEND_H #include "platform.h" #include #include #include class QTemporaryDir; namespace KWin { class VirtualOutput; class KWIN_EXPORT VirtualBackend : public Platform { Q_OBJECT Q_INTERFACES(KWin::Platform) Q_PLUGIN_METADATA(IID "org.kde.kwin.Platform" FILE "virtual.json") public: VirtualBackend(QObject *parent = nullptr); - virtual ~VirtualBackend(); + ~VirtualBackend() override; void init() override; bool saveFrames() const { return !m_screenshotDir.isNull(); } QString screenshotDirPath() const; Screens *createScreens(QObject *parent = nullptr) override; QPainterBackend* createQPainterBackend() override; OpenGLBackend *createOpenGLBackend() override; Q_INVOKABLE void setVirtualOutputs(int count, QVector geometries = QVector(), QVector scales = QVector()); Outputs outputs() const override; Outputs enabledOutputs() const override; QVector supportedCompositors() const override { if (selectedCompositor() != NoCompositing) { return {selectedCompositor()}; } return QVector{OpenGLCompositing, QPainterCompositing}; } Q_SIGNALS: void virtualOutputsSet(bool countChanged); private: QVector m_outputs; QVector m_enabledOutputs; QScopedPointer m_screenshotDir; }; } #endif diff --git a/plugins/platforms/virtual/virtual_output.h b/plugins/platforms/virtual/virtual_output.h index 5ddb9beaf..e8bf5b659 100644 --- a/plugins/platforms/virtual/virtual_output.h +++ b/plugins/platforms/virtual/virtual_output.h @@ -1,64 +1,64 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2018 Roman Gilg 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_VIRTUAL_OUTPUT_H #define KWIN_VIRTUAL_OUTPUT_H #include "abstract_wayland_output.h" #include #include namespace KWin { class VirtualBackend; class VirtualOutput : public AbstractWaylandOutput { Q_OBJECT public: VirtualOutput(QObject *parent = nullptr); - virtual ~VirtualOutput(); + ~VirtualOutput() override; QSize pixelSize() const override; void setGeometry(const QRect &geo); int gammaRampSize() const override { return m_gammaSize; } bool setGammaRamp(const GammaRamp &gamma) override { Q_UNUSED(gamma); return m_gammaResult; } private: Q_DISABLE_COPY(VirtualOutput); friend class VirtualBackend; QSize m_pixelSize; int m_gammaSize = 200; bool m_gammaResult = true; }; } #endif diff --git a/plugins/platforms/wayland/egl_wayland_backend.h b/plugins/platforms/wayland/egl_wayland_backend.h index 98a31b64c..b0957d0ec 100644 --- a/plugins/platforms/wayland/egl_wayland_backend.h +++ b/plugins/platforms/wayland/egl_wayland_backend.h @@ -1,132 +1,132 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright 2013 Martin Gräßlin Copyright 2019 Roman Gilg 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_EGL_WAYLAND_BACKEND_H #define KWIN_EGL_WAYLAND_BACKEND_H #include "abstract_egl_backend.h" // wayland #include class QTemporaryFile; struct wl_buffer; struct wl_shm; namespace KWin { namespace Wayland { class WaylandBackend; class WaylandOutput; class EglWaylandBackend; class EglWaylandOutput : public QObject { Q_OBJECT public: EglWaylandOutput(WaylandOutput *output, QObject *parent = nullptr); - ~EglWaylandOutput() = default; + ~EglWaylandOutput() override = default; bool init(EglWaylandBackend *backend); void updateSize(const QSize &size); private: WaylandOutput *m_waylandOutput; wl_egl_window *m_overlay = nullptr; EGLSurface m_eglSurface = EGL_NO_SURFACE; int m_bufferAge = 0; /** * @brief The damage history for the past 10 frames. */ QVector m_damageHistory; friend class EglWaylandBackend; }; /** * @brief OpenGL Backend using Egl on a Wayland surface. * * This Backend is the basis for a session compositor running on top of a Wayland system compositor. * It creates a Surface as large as the screen and maps it as a fullscreen shell surface on the * system compositor. The OpenGL context is created on the Wayland surface, so for rendering X11 is * not involved. * * Also in repainting the backend is currently still rather limited. Only supported mode is fullscreen * repaints, which is obviously not optimal. Best solution is probably to go for buffer_age extension * and make it the only available solution next to fullscreen repaints. **/ class EglWaylandBackend : public AbstractEglBackend { Q_OBJECT public: EglWaylandBackend(WaylandBackend *b); - virtual ~EglWaylandBackend(); + ~EglWaylandBackend() override; void screenGeometryChanged(const QSize &size) override; SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override; QRegion prepareRenderingFrame() override; QRegion prepareRenderingForScreen(int screenId) override; void endRenderingFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override; void endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion) override; - virtual bool usesOverlayWindow() const override; + bool usesOverlayWindow() const override; bool perScreenRendering() const override; void init() override; bool havePlatformBase() const { return m_havePlatformBase; } private: bool initializeEgl(); bool initBufferConfigs(); bool initRenderingContext(); bool createEglWaylandOutput(WaylandOutput *output); void cleanupSurfaces() override; void cleanupOutput(EglWaylandOutput *output); bool makeContextCurrent(EglWaylandOutput *output); void present() override; void presentOnSurface(EglWaylandOutput *output); WaylandBackend *m_backend; QVector m_outputs; bool m_havePlatformBase; bool m_swapping = false; friend class EglWaylandTexture; }; /** * @brief Texture using an EGLImageKHR. **/ class EglWaylandTexture : public AbstractEglTexture { public: - virtual ~EglWaylandTexture(); + ~EglWaylandTexture() override; private: friend class EglWaylandBackend; EglWaylandTexture(SceneOpenGLTexture *texture, EglWaylandBackend *backend); }; } } #endif diff --git a/plugins/platforms/wayland/scene_qpainter_wayland_backend.h b/plugins/platforms/wayland/scene_qpainter_wayland_backend.h index bbc0f2a0a..880c0e6fd 100644 --- a/plugins/platforms/wayland/scene_qpainter_wayland_backend.h +++ b/plugins/platforms/wayland/scene_qpainter_wayland_backend.h @@ -1,102 +1,102 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright 2019 Roman Gilg Copyright 2013, 2015 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_SCENE_QPAINTER_WAYLAND_BACKEND_H #define KWIN_SCENE_QPAINTER_WAYLAND_BACKEND_H #include #include #include #include namespace KWayland { namespace Client { class ShmPool; class Buffer; } } namespace KWin { namespace Wayland { class WaylandBackend; class WaylandOutput; class WaylandQPainterBackend; class WaylandQPainterOutput : public QObject { Q_OBJECT public: WaylandQPainterOutput(WaylandOutput *output, QObject *parent = nullptr); - ~WaylandQPainterOutput(); + ~WaylandQPainterOutput() override; bool init(KWayland::Client::ShmPool *pool); void updateSize(const QSize &size); void remapBuffer(); void prepareRenderingFrame(); void present(const QRegion &damage); private: WaylandOutput *m_waylandOutput; KWayland::Client::ShmPool *m_pool; QWeakPointer m_buffer; QImage m_backBuffer; friend class WaylandQPainterBackend; }; class WaylandQPainterBackend : public QObject, public QPainterBackend { Q_OBJECT public: explicit WaylandQPainterBackend(WaylandBackend *b); - virtual ~WaylandQPainterBackend(); + ~WaylandQPainterBackend() override; - virtual bool usesOverlayWindow() const override; + bool usesOverlayWindow() const override; - virtual QImage *buffer() override; + QImage *buffer() override; QImage *bufferForScreen(int screenId) override; - virtual void present(int mask, const QRegion& damage) override; - virtual void prepareRenderingFrame() override; + void present(int mask, const QRegion& damage) override; + void prepareRenderingFrame() override; - virtual bool needsFullRepaint() const override; + bool needsFullRepaint() const override; bool perScreenRendering() const override; private: void createOutput(WaylandOutput *waylandOutput); void frameRendered(); WaylandBackend *m_backend; bool m_needsFullRepaint; QVector m_outputs; }; } } #endif diff --git a/plugins/platforms/wayland/wayland_backend.h b/plugins/platforms/wayland/wayland_backend.h index c3c657b94..e6f2e2d3a 100644 --- a/plugins/platforms/wayland/wayland_backend.h +++ b/plugins/platforms/wayland/wayland_backend.h @@ -1,284 +1,284 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright 2019 Roman Gilg Copyright 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_WAYLAND_BACKEND_H #define KWIN_WAYLAND_BACKEND_H // KWin #include "platform.h" #include #include // Qt #include #include #include #include #include class QTemporaryFile; struct wl_buffer; struct wl_display; struct wl_event_queue; struct wl_seat; namespace KWayland { namespace Client { class Buffer; class ShmPool; class Compositor; class ConnectionThread; class EventQueue; class Keyboard; class Pointer; class PointerConstraints; class PointerGestures; class PointerSwipeGesture; class PointerPinchGesture; class Registry; class RelativePointer; class RelativePointerManager; class Seat; class Shell; class SubCompositor; class SubSurface; class Surface; class Touch; class XdgShell; } } namespace KWin { class WaylandCursorTheme; namespace Wayland { class WaylandBackend; class WaylandSeat; class WaylandOutput; class WaylandCursor : public QObject { Q_OBJECT public: explicit WaylandCursor(WaylandBackend *backend); - virtual ~WaylandCursor(); + ~WaylandCursor() override; virtual void init(); virtual void move(const QPointF &globalPosition) { Q_UNUSED(globalPosition) } void installImage(); protected: void resetSurface(); virtual void doInstallImage(wl_buffer *image, const QSize &size); void drawSurface(wl_buffer *image, const QSize &size); KWayland::Client::Surface *surface() const { return m_surface; } WaylandBackend *backend() const { return m_backend; } private: WaylandBackend *m_backend; KWayland::Client::Pointer *m_pointer; KWayland::Client::Surface *m_surface = nullptr; }; class WaylandSubSurfaceCursor : public WaylandCursor { Q_OBJECT public: explicit WaylandSubSurfaceCursor(WaylandBackend *backend); - virtual ~WaylandSubSurfaceCursor(); + ~WaylandSubSurfaceCursor() override; void init() override; void move(const QPointF &globalPosition) override; private: void changeOutput(WaylandOutput *output); void doInstallImage(wl_buffer *image, const QSize &size) override; void createSubSurface(); QPointF absoluteToRelativePosition(const QPointF &position); WaylandOutput *m_output = nullptr; KWayland::Client::SubSurface *m_subSurface = nullptr; }; class WaylandSeat : public QObject { Q_OBJECT public: WaylandSeat(wl_seat *seat, WaylandBackend *backend); - virtual ~WaylandSeat(); + ~WaylandSeat() override; KWayland::Client::Pointer *pointer() const { return m_pointer; } void installGesturesInterface(KWayland::Client::PointerGestures *gesturesInterface) { m_gesturesInterface = gesturesInterface; setupPointerGestures(); } private: void destroyPointer(); void destroyKeyboard(); void destroyTouch(); void setupPointerGestures(); KWayland::Client::Seat *m_seat; KWayland::Client::Pointer *m_pointer; KWayland::Client::Keyboard *m_keyboard; KWayland::Client::Touch *m_touch; KWayland::Client::PointerGestures *m_gesturesInterface = nullptr; KWayland::Client::PointerPinchGesture *m_pinchGesture = nullptr; KWayland::Client::PointerSwipeGesture *m_swipeGesture = nullptr; uint32_t m_enteredSerial; WaylandBackend *m_backend; }; /** * @brief Class encapsulating all Wayland data structures needed by the Egl backend. * * It creates the connection to the Wayland Compositor, sets up the registry and creates * the Wayland output surfaces and its shell mappings. */ class KWIN_EXPORT WaylandBackend : public Platform { Q_OBJECT Q_INTERFACES(KWin::Platform) Q_PLUGIN_METADATA(IID "org.kde.kwin.Platform" FILE "wayland.json") public: explicit WaylandBackend(QObject *parent = nullptr); - virtual ~WaylandBackend(); + ~WaylandBackend() override; void init() override; wl_display *display(); KWayland::Client::Compositor *compositor(); KWayland::Client::SubCompositor *subCompositor(); KWayland::Client::ShmPool *shmPool(); Screens *createScreens(QObject *parent = nullptr) override; OpenGLBackend *createOpenGLBackend() override; QPainterBackend *createQPainterBackend() override; void flush(); WaylandSeat *seat() const { return m_seat; } KWayland::Client::PointerConstraints *pointerConstraints() const { return m_pointerConstraints; } void pointerMotionRelativeToOutput(const QPointF &position, quint32 time); bool supportsPointerLock(); void togglePointerLock(); bool pointerIsLocked(); QVector supportedCompositors() const override; void checkBufferSwap(); WaylandOutput* getOutputAt(const QPointF globalPosition); Outputs outputs() const override; Outputs enabledOutputs() const override; QVector waylandOutputs() const { return m_outputs; } Q_SIGNALS: void outputAdded(WaylandOutput *output); void outputRemoved(WaylandOutput *output); void systemCompositorDied(); void connectionFailed(); void pointerLockSupportedChanged(); void pointerLockChanged(bool locked); private: void initConnection(); void createOutputs(); void updateScreenSize(WaylandOutput *output); void relativeMotionHandler(const QSizeF &delta, const QSizeF &deltaNonAccelerated, quint64 timestamp); wl_display *m_display; KWayland::Client::EventQueue *m_eventQueue; KWayland::Client::Registry *m_registry; KWayland::Client::Compositor *m_compositor; KWayland::Client::SubCompositor *m_subCompositor; KWayland::Client::Shell *m_shell; KWayland::Client::XdgShell *m_xdgShell = nullptr; KWayland::Client::ShmPool *m_shm; KWayland::Client::ConnectionThread *m_connectionThreadObject; WaylandSeat *m_seat = nullptr; KWayland::Client::RelativePointer *m_relativePointer = nullptr; KWayland::Client::RelativePointerManager *m_relativePointerManager = nullptr; KWayland::Client::PointerConstraints *m_pointerConstraints = nullptr; QThread *m_connectionThread; QVector m_outputs; WaylandCursor *m_waylandCursor = nullptr; bool m_pointerLockRequested = false; }; inline wl_display *WaylandBackend::display() { return m_display; } inline KWayland::Client::Compositor *WaylandBackend::compositor() { return m_compositor; } inline KWayland::Client::SubCompositor *WaylandBackend::subCompositor() { return m_subCompositor; } inline KWayland::Client::ShmPool* WaylandBackend::shmPool() { return m_shm; } } // namespace Wayland } // namespace KWin #endif // KWIN_WAYLAND_BACKEND_H diff --git a/plugins/platforms/wayland/wayland_output.h b/plugins/platforms/wayland/wayland_output.h index 09e749ecb..1e9dc76af 100644 --- a/plugins/platforms/wayland/wayland_output.h +++ b/plugins/platforms/wayland/wayland_output.h @@ -1,130 +1,130 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright 2019 Roman Gilg 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_WAYLAND_OUTPUT_H #define KWIN_WAYLAND_OUTPUT_H #include "abstract_wayland_output.h" #include #include namespace KWayland { namespace Client { class Surface; class Shell; class ShellSurface; class Pointer; class LockedPointer; } } namespace KWin { namespace Wayland { class WaylandBackend; class WaylandOutput : public AbstractWaylandOutput { Q_OBJECT public: explicit WaylandOutput(KWayland::Client::Surface *surface, QObject *parent = nullptr); - ~WaylandOutput(); + ~WaylandOutput() override; virtual void lockPointer(KWayland::Client::Pointer *pointer, bool lock) { Q_UNUSED(pointer) Q_UNUSED(lock) } virtual bool pointerIsLocked() { return false; } QSize pixelSize() const override; /** * @brief defines the geometry of the output * @param logicalPosition top left position of the output in compositor space * @param pixelSize output size as seen from the outside */ void setGeometry(const QPoint &logicalPosition, const QSize &pixelSize); KWayland::Client::Surface* surface() const { return m_surface; } bool rendered() const { return m_rendered; } void resetRendered() { m_rendered = false; } Q_SIGNALS: void sizeChanged(const QSize &size); void frameRendered(); private: KWayland::Client::Surface *m_surface; QSize m_pixelSize; bool m_rendered = false; }; class ShellOutput : public WaylandOutput { public: ShellOutput(KWayland::Client::Surface *surface, KWayland::Client::Shell *shell, WaylandBackend *backend); - ~ShellOutput(); + ~ShellOutput() override; private: KWayland::Client::ShellSurface *m_shellSurface = nullptr; }; class XdgShellOutput : public WaylandOutput { public: XdgShellOutput(KWayland::Client::Surface *surface, KWayland::Client::XdgShell *xdgShell, WaylandBackend *backend, int number); - ~XdgShellOutput(); + ~XdgShellOutput() override; void lockPointer(KWayland::Client::Pointer *pointer, bool lock) override; private: void handleConfigure(const QSize &size, KWayland::Client::XdgShellSurface::States states, quint32 serial); void updateWindowTitle(); KWayland::Client::XdgShellSurface *m_xdgShellSurface = nullptr; WaylandBackend *m_backend; int m_number; KWayland::Client::LockedPointer *m_pointerLock = nullptr; bool m_hasPointerLock = false; }; } } #endif diff --git a/plugins/platforms/x11/common/eglonxbackend.h b/plugins/platforms/x11/common/eglonxbackend.h index 0063971bf..ea253d91d 100644 --- a/plugins/platforms/x11/common/eglonxbackend.h +++ b/plugins/platforms/x11/common/eglonxbackend.h @@ -1,108 +1,108 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2012 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_EGL_ON_X_BACKEND_H #define KWIN_EGL_ON_X_BACKEND_H #include "abstract_egl_backend.h" #include "swap_profiler.h" #include namespace KWin { /** * @brief OpenGL Backend using Egl windowing system over an X overlay window. **/ class KWIN_EXPORT EglOnXBackend : public AbstractEglBackend { public: EglOnXBackend(Display *display); explicit EglOnXBackend(xcb_connection_t *connection, Display *display, xcb_window_t rootWindow, int screenNumber, xcb_window_t renderingWindow); - virtual ~EglOnXBackend(); - virtual void screenGeometryChanged(const QSize &size); - virtual SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override; - virtual QRegion prepareRenderingFrame(); - virtual void endRenderingFrame(const QRegion &damage, const QRegion &damagedRegion); - virtual OverlayWindow* overlayWindow() override; - virtual bool usesOverlayWindow() const override; + ~EglOnXBackend() override; + void screenGeometryChanged(const QSize &size) override; + SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override; + QRegion prepareRenderingFrame() override; + void endRenderingFrame(const QRegion &damage, const QRegion &damagedRegion) override; + OverlayWindow* overlayWindow() override; + bool usesOverlayWindow() const override; void init() override; bool isX11TextureFromPixmapSupported() const { return m_x11TextureFromPixmapSupported; } protected: - virtual void present(); + void present() override; void presentSurface(EGLSurface surface, const QRegion &damage, const QRect &screenGeometry); virtual bool createSurfaces(); EGLSurface createSurface(xcb_window_t window); void setHavePlatformBase(bool have) { m_havePlatformBase = have; } bool havePlatformBase() const { return m_havePlatformBase; } bool makeContextCurrent(const EGLSurface &surface); void setX11TextureFromPixmapSupported(bool set) { m_x11TextureFromPixmapSupported = set; } private: bool initBufferConfigs(); bool initRenderingContext(); /** * @brief The OverlayWindow used by this Backend. **/ OverlayWindow *m_overlayWindow; int surfaceHasSubPost; int m_bufferAge; bool m_usesOverlayWindow; xcb_connection_t *m_connection; Display *m_x11Display; xcb_window_t m_rootWindow; int m_x11ScreenNumber; xcb_window_t m_renderingWindow = XCB_WINDOW_NONE; bool m_havePlatformBase = false; bool m_x11TextureFromPixmapSupported = true; SwapProfiler m_swapProfiler; friend class EglTexture; }; /** * @brief Texture using an EGLImageKHR. **/ class EglTexture : public AbstractEglTexture { public: - virtual ~EglTexture(); - virtual void onDamage(); + ~EglTexture() override; + void onDamage() override; bool loadTexture(WindowPixmap *pixmap) override; private: bool loadTexture(xcb_pixmap_t pix, const QSize &size); friend class EglOnXBackend; EglTexture(SceneOpenGLTexture *texture, EglOnXBackend *backend); EglOnXBackend *m_backend; }; } // namespace #endif // KWIN_EGL_ON_X_BACKEND_H diff --git a/plugins/platforms/x11/standalone/edge.h b/plugins/platforms/x11/standalone/edge.h index 6934b7dcb..f913c2a64 100644 --- a/plugins/platforms/x11/standalone/edge.h +++ b/plugins/platforms/x11/standalone/edge.h @@ -1,79 +1,79 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2011 Arthur Arlt Copyright (C) 2013 Martin Gräßlin Since the functionality provided in this class has been moved from class Workspace, it is not clear who exactly has written the code. The list below contains the copyright holders of the class Workspace. Copyright (C) 1999, 2000 Matthias Ettrich Copyright (C) 2003 Lubos Lunak Copyright (C) 2009 Lucas Murray 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_EDGE_H #define KWIN_EDGE_H #include "screenedge.h" #include "xcbutils.h" namespace KWin { class WindowBasedEdge : public Edge { Q_OBJECT public: explicit WindowBasedEdge(ScreenEdges *parent); - virtual ~WindowBasedEdge(); + ~WindowBasedEdge() override; quint32 window() const override; /** * The approach window is a special window to notice when get close to the screen border but * not yet triggering the border. **/ quint32 approachWindow() const override; protected: - virtual void doGeometryUpdate(); - virtual void doActivate() override; - virtual void doDeactivate() override; - virtual void doStartApproaching(); - virtual void doStopApproaching(); - virtual void doUpdateBlocking(); + void doGeometryUpdate() override; + void doActivate() override; + void doDeactivate() override; + void doStartApproaching() override; + void doStopApproaching() override; + void doUpdateBlocking() override; private: void createWindow(); void createApproachWindow(); Xcb::Window m_window; Xcb::Window m_approachWindow; QMetaObject::Connection m_cursorPollingConnection; }; inline quint32 WindowBasedEdge::window() const { return m_window; } inline quint32 WindowBasedEdge::approachWindow() const { return m_approachWindow; } } #endif diff --git a/plugins/platforms/x11/standalone/glxbackend.h b/plugins/platforms/x11/standalone/glxbackend.h index ff3a0d8f2..97017d7d0 100644 --- a/plugins/platforms/x11/standalone/glxbackend.h +++ b/plugins/platforms/x11/standalone/glxbackend.h @@ -1,150 +1,150 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2012 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_GLX_BACKEND_H #define KWIN_GLX_BACKEND_H #include "backend.h" #include "texture.h" #include "swap_profiler.h" #include "x11eventfilter.h" #include #include #include #include namespace KWin { // GLX_MESA_swap_interval using glXSwapIntervalMESA_func = int (*)(unsigned int interval); extern glXSwapIntervalMESA_func glXSwapIntervalMESA; class FBConfigInfo { public: GLXFBConfig fbconfig; int bind_texture_format; int texture_targets; int y_inverted; int mipmap; }; // ------------------------------------------------------------------ class SwapEventFilter : public X11EventFilter { public: SwapEventFilter(xcb_drawable_t drawable, xcb_glx_drawable_t glxDrawable); bool event(xcb_generic_event_t *event) override; private: xcb_drawable_t m_drawable; xcb_glx_drawable_t m_glxDrawable; }; /** * @brief OpenGL Backend using GLX over an X overlay window. **/ class GlxBackend : public OpenGLBackend { public: GlxBackend(Display *display); - virtual ~GlxBackend(); - virtual void screenGeometryChanged(const QSize &size); - virtual SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override; - virtual QRegion prepareRenderingFrame(); - virtual void endRenderingFrame(const QRegion &damage, const QRegion &damagedRegion); - virtual bool makeCurrent() override; - virtual void doneCurrent() override; - virtual OverlayWindow* overlayWindow() override; - virtual bool usesOverlayWindow() const override; + ~GlxBackend() override; + void screenGeometryChanged(const QSize &size) override; + SceneOpenGLTexturePrivate *createBackendTexture(SceneOpenGLTexture *texture) override; + QRegion prepareRenderingFrame() override; + void endRenderingFrame(const QRegion &damage, const QRegion &damagedRegion) override; + bool makeCurrent() override; + void doneCurrent() override; + OverlayWindow* overlayWindow() override; + bool usesOverlayWindow() const override; void init() override; protected: - virtual void present(); + void present() override; private: bool initBuffer(); bool checkVersion(); void initExtensions(); void waitSync(); bool initRenderingContext(); bool initFbConfig(); void initVisualDepthHashTable(); void setSwapInterval(int interval); Display *display() const { return m_x11Display; } int visualDepth(xcb_visualid_t visual) const; FBConfigInfo *infoForVisual(xcb_visualid_t visual); /** * @brief The OverlayWindow used by this Backend. **/ OverlayWindow *m_overlayWindow; Window window; GLXFBConfig fbconfig; GLXWindow glxWindow; GLXContext ctx; QHash m_fbconfigHash; QHash m_visualDepthHash; std::unique_ptr m_swapEventFilter; int m_bufferAge; bool m_haveMESACopySubBuffer = false; bool m_haveMESASwapControl = false; bool m_haveEXTSwapControl = false; bool m_haveSGISwapControl = false; bool m_haveINTELSwapEvent = false; bool haveSwapInterval = false; bool haveWaitSync = false; Display *m_x11Display; SwapProfiler m_swapProfiler; friend class GlxTexture; }; /** * @brief Texture using an GLXPixmap. **/ class GlxTexture : public SceneOpenGLTexturePrivate { public: - virtual ~GlxTexture(); - virtual void onDamage(); - virtual bool loadTexture(WindowPixmap *pixmap) override; - virtual OpenGLBackend *backend(); + ~GlxTexture() override; + void onDamage() override; + bool loadTexture(WindowPixmap *pixmap) override; + OpenGLBackend *backend() override; private: friend class GlxBackend; GlxTexture(SceneOpenGLTexture *texture, GlxBackend *backend); bool loadTexture(xcb_pixmap_t pix, const QSize &size, xcb_visualid_t visual); Display *display() const { return m_backend->m_x11Display; } SceneOpenGLTexture *q; GlxBackend *m_backend; GLXPixmap m_glxpixmap; // the glx pixmap the texture is bound to }; } // namespace #endif // KWIN_GLX_BACKEND_H diff --git a/plugins/platforms/x11/standalone/non_composited_outline.h b/plugins/platforms/x11/standalone/non_composited_outline.h index 1744ff96a..a5286b483 100644 --- a/plugins/platforms/x11/standalone/non_composited_outline.h +++ b/plugins/platforms/x11/standalone/non_composited_outline.h @@ -1,59 +1,59 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2011 Arthur Arlt 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_NON_COMPOSITED_OUTLINE_H #define KWIN_NON_COMPOSITED_OUTLINE_H #include "outline.h" #include "xcbutils.h" namespace KWin { class NonCompositedOutlineVisual : public OutlineVisual { public: NonCompositedOutlineVisual(Outline *outline); - virtual ~NonCompositedOutlineVisual(); - virtual void show(); - virtual void hide(); + ~NonCompositedOutlineVisual() override; + void show() override; + void hide() override; private: // TODO: variadic template arguments for adding method arguments template void forEachWindow(T method); bool m_initialized; Xcb::Window m_topOutline; Xcb::Window m_rightOutline; Xcb::Window m_bottomOutline; Xcb::Window m_leftOutline; }; template inline void NonCompositedOutlineVisual::forEachWindow(T method) { (m_topOutline.*method)(); (m_rightOutline.*method)(); (m_bottomOutline.*method)(); (m_leftOutline.*method)(); } } #endif diff --git a/plugins/platforms/x11/standalone/overlaywindow_x11.h b/plugins/platforms/x11/standalone/overlaywindow_x11.h index 0ca5b143c..e93dd0a9c 100644 --- a/plugins/platforms/x11/standalone/overlaywindow_x11.h +++ b/plugins/platforms/x11/standalone/overlaywindow_x11.h @@ -1,57 +1,57 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2011 Arthur Arlt 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_OVERLAYWINDOW_X11_H #define KWIN_OVERLAYWINDOW_X11_H #include "../../../../overlaywindow.h" #include "../../../../x11eventfilter.h" namespace KWin { class KWIN_EXPORT OverlayWindowX11 : public OverlayWindow, public X11EventFilter { public: OverlayWindowX11(); - ~OverlayWindowX11(); + ~OverlayWindowX11() override; /// Creates XComposite overlay window, call initOverlay() afterwards bool create() override; /// Init overlay and the destination window in it void setup(xcb_window_t window) override; void show() override; void hide() override; // hides and resets overlay window void setShape(const QRegion& reg) override; void resize(const QSize &size) override; /// Destroys XComposite overlay window void destroy() override; xcb_window_t window() const override; bool isVisible() const override; void setVisibility(bool visible) override; bool event(xcb_generic_event_t *event) override; private: void setNoneBackgroundPixmap(xcb_window_t window); void setupInputShape(xcb_window_t window); bool m_visible; bool m_shown; // For showOverlay() QRegion m_shape; xcb_window_t m_window; }; } // namespace #endif //KWIN_OVERLAYWINDOW_H diff --git a/plugins/platforms/x11/standalone/screens_xrandr.h b/plugins/platforms/x11/standalone/screens_xrandr.h index e0f9b6a08..9a6d8f60d 100644 --- a/plugins/platforms/x11/standalone/screens_xrandr.h +++ b/plugins/platforms/x11/standalone/screens_xrandr.h @@ -1,51 +1,51 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 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_XRANDR_H #define KWIN_SCREENS_XRANDR_H // kwin #include "outputscreens.h" #include "x11eventfilter.h" namespace KWin { class X11StandalonePlatform; class XRandRScreens : public OutputScreens, public X11EventFilter { Q_OBJECT public: XRandRScreens(X11StandalonePlatform *backend, QObject *parent = nullptr); - virtual ~XRandRScreens(); + ~XRandRScreens() override; void init() override; QSize displaySize() const override; using QObject::event; bool event(xcb_generic_event_t *event) override; private: void updateCount() override; X11StandalonePlatform *m_backend; }; } // namespace #endif diff --git a/plugins/platforms/x11/standalone/windowselector.h b/plugins/platforms/x11/standalone/windowselector.h index 710acd8aa..e755a823d 100644 --- a/plugins/platforms/x11/standalone/windowselector.h +++ b/plugins/platforms/x11/standalone/windowselector.h @@ -1,70 +1,70 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 1999, 2000 Matthias Ettrich Copyright (C) 2003 Lubos Lunak Copyright (C) 2012 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_WINDOWSELECTOR_H #define KWIN_WINDOWSELECTOR_H #include "x11eventfilter.h" #include #include class QPoint; namespace KWin { class Toplevel; class WindowSelector : public X11EventFilter { public: WindowSelector(); - ~WindowSelector(); + ~WindowSelector() override; void start(std::function callback, const QByteArray &cursorName); void start(std::function callback); bool isActive() const { return m_active; } void processEvent(xcb_generic_event_t *event); bool event(xcb_generic_event_t *event) override; private: xcb_cursor_t createCursor(const QByteArray &cursorName); void release(); void selectWindowUnderPointer(); void handleKeyPress(xcb_keycode_t keycode, uint16_t state); void handleButtonRelease(xcb_button_t button, xcb_window_t window); void selectWindowId(xcb_window_t window_to_kill); bool activate(const QByteArray &cursorName = QByteArray()); void cancelCallback(); bool m_active; std::function m_callback; std::function m_pointSelectionFallback; }; } // namespace #endif diff --git a/plugins/platforms/x11/standalone/x11_decoration_renderer.h b/plugins/platforms/x11/standalone/x11_decoration_renderer.h index bbcda9728..77437b9da 100644 --- a/plugins/platforms/x11/standalone/x11_decoration_renderer.h +++ b/plugins/platforms/x11/standalone/x11_decoration_renderer.h @@ -1,55 +1,55 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2014 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_DECORATION_X11_RENDERER_H #define KWIN_DECORATION_X11_RENDERER_H #include "decorations/decorationrenderer.h" #include class QTimer; namespace KWin { namespace Decoration { class X11Renderer : public Renderer { Q_OBJECT public: explicit X11Renderer(DecoratedClientImpl *client); - virtual ~X11Renderer(); + ~X11Renderer() override; void reparent(Deleted *deleted) override; protected: void render() override; private: QTimer *m_scheduleTimer; xcb_gcontext_t m_gc; }; } } #endif diff --git a/plugins/platforms/x11/standalone/x11_output.h b/plugins/platforms/x11/standalone/x11_output.h index 944c123aa..71240041c 100644 --- a/plugins/platforms/x11/standalone/x11_output.h +++ b/plugins/platforms/x11/standalone/x11_output.h @@ -1,80 +1,80 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright 2019 Roman Gilg 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_X11_OUTPUT_H #define KWIN_X11_OUTPUT_H #include "abstract_output.h" #include #include #include #include namespace KWin { /** * X11 output representation **/ class KWIN_EXPORT X11Output : public AbstractOutput { Q_OBJECT public: explicit X11Output(QObject *parent = nullptr); - virtual ~X11Output() = default; + ~X11Output() override = default; QString name() const override; void setName(QString set); /** * The geometry of this output in global compositor co-ordinates (i.e scaled) **/ QRect geometry() const override; void setGeometry(QRect set); /** * Current refresh rate in 1/ms. **/ int refreshRate() const override; void setRefreshRate(int set); /** * The size of gamma lookup table. **/ int gammaRampSize() const override; bool setGammaRamp(const GammaRamp &gamma) override; private: void setCrtc(xcb_randr_crtc_t crtc); void setGammaRampSize(int size); xcb_randr_crtc_t m_crtc = XCB_NONE; QString m_name; QRect m_geometry; int m_gammaRampSize; int m_refreshRate; friend class X11StandalonePlatform; }; } #endif diff --git a/plugins/platforms/x11/standalone/x11_platform.h b/plugins/platforms/x11/standalone/x11_platform.h index 44e4e4ad0..56b4fcb58 100644 --- a/plugins/platforms/x11/standalone/x11_platform.h +++ b/plugins/platforms/x11/standalone/x11_platform.h @@ -1,113 +1,113 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2016 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_X11_PLATFORM_H #define KWIN_X11_PLATFORM_H #include "platform.h" #include #include #include namespace KWin { class SyncFilter; class XInputIntegration; class WindowSelector; class X11EventFilter; class X11Output; class KWIN_EXPORT X11StandalonePlatform : public Platform { Q_OBJECT Q_INTERFACES(KWin::Platform) Q_PLUGIN_METADATA(IID "org.kde.kwin.Platform" FILE "x11.json") public: X11StandalonePlatform(QObject *parent = nullptr); - virtual ~X11StandalonePlatform(); + ~X11StandalonePlatform() override; void init() override; Screens *createScreens(QObject *parent = nullptr) override; OpenGLBackend *createOpenGLBackend() override; Edge *createScreenEdge(ScreenEdges *parent) override; void createPlatformCursor(QObject *parent = nullptr) override; bool requiresCompositing() const override; bool compositingPossible() const override; QString compositingNotPossibleReason() const override; bool openGLCompositingIsBroken() const override; void createOpenGLSafePoint(OpenGLSafePoint safePoint) override; void startInteractiveWindowSelection(std::function callback, const QByteArray &cursorName = QByteArray()) override; void startInteractivePositionSelection(std::function callback) override; PlatformCursorImage cursorImage() const override; void setupActionForGlobalAccel(QAction *action) override; OverlayWindow *createOverlayWindow() override; void updateXTime() override; OutlineVisual *createOutline(Outline *outline) override; Decoration::Renderer *createDecorationRenderer(Decoration::DecoratedClientImpl *client) override; void invertScreen() override; void createEffectsHandler(Compositor *compositor, Scene *scene) override; QVector supportedCompositors() const override; void initOutputs(); void updateOutputs(); Outputs outputs() const override; Outputs enabledOutputs() const override; protected: void doHideCursor() override; void doShowCursor() override; private: /** * Tests whether GLX is supported and returns @c true * in case KWin is compiled with OpenGL support and GLX * is available. * * If KWin is compiled with OpenGL ES or without OpenGL at * all, @c false is returned. * @returns @c true if GLX is available, @c false otherwise and if not build with OpenGL support. **/ static bool hasGlx(); template void doUpdateOutputs(); XInputIntegration *m_xinputIntegration = nullptr; QThread *m_openGLFreezeProtectionThread = nullptr; QTimer *m_openGLFreezeProtection = nullptr; Display *m_x11Display; QScopedPointer m_windowSelector; QScopedPointer m_screenEdgesFilter; std::unique_ptr m_syncFilter; QVector m_outputs; }; } #endif diff --git a/plugins/platforms/x11/standalone/x11cursor.h b/plugins/platforms/x11/standalone/x11cursor.h index e4336c7cf..7aabc264a 100644 --- a/plugins/platforms/x11/standalone/x11cursor.h +++ b/plugins/platforms/x11/standalone/x11cursor.h @@ -1,85 +1,85 @@ /******************************************************************** 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_X11CURSOR_H #define KWIN_X11CURSOR_H #include "cursor.h" #include namespace KWin { class XFixesCursorEventFilter; class KWIN_EXPORT X11Cursor : public Cursor { Q_OBJECT public: X11Cursor(QObject *parent, bool xInputSupport = false); - virtual ~X11Cursor(); + ~X11Cursor() override; void schedulePoll() { m_needsPoll = true; } /** * @internal * * Called from X11 event handler. **/ void notifyCursorChanged(); protected: - virtual xcb_cursor_t getX11Cursor(CursorShape shape); + xcb_cursor_t getX11Cursor(CursorShape shape) override; xcb_cursor_t getX11Cursor(const QByteArray &name) override; - virtual void doSetPos(); - virtual void doGetPos(); - virtual void doStartMousePolling(); - virtual void doStopMousePolling(); - virtual void doStartCursorTracking(); - virtual void doStopCursorTracking(); + void doSetPos() override; + void doGetPos() override; + void doStartMousePolling() override; + void doStopMousePolling() override; + void doStartCursorTracking() override; + void doStopCursorTracking() override; private Q_SLOTS: /** * Because of QTimer's and the impossibility to get events for all mouse * movements (at least I haven't figured out how) the position needs * to be also refetched after each return to the event loop. **/ void resetTimeStamp(); void mousePolled(); void aboutToBlock(); private: xcb_cursor_t createCursor(const QByteArray &name); QHash m_cursors; xcb_timestamp_t m_timeStamp; uint16_t m_buttonMask; QTimer *m_resetTimeStampTimer; QTimer *m_mousePollingTimer; bool m_hasXInput; bool m_needsPoll; std::unique_ptr m_xfixesFilter; friend class Cursor; }; } #endif diff --git a/plugins/platforms/x11/standalone/xinputintegration.cpp b/plugins/platforms/x11/standalone/xinputintegration.cpp index 01b6e55b9..f7d472cf7 100644 --- a/plugins/platforms/x11/standalone/xinputintegration.cpp +++ b/plugins/platforms/x11/standalone/xinputintegration.cpp @@ -1,287 +1,287 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2016 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 "xinputintegration.h" #include "main.h" #include "logging.h" #include "gestures.h" #include "platform.h" #include "screenedge.h" #include "x11cursor.h" #include "ge_event_mem_mover.h" #include "input.h" #include "x11eventfilter.h" #include "modifier_only_shortcuts.h" #include #include #include #include namespace KWin { static inline qreal fixed1616ToReal(FP1616 val) { return (val) * 1.0 / (1 << 16); } class XInputEventFilter : public X11EventFilter { public: XInputEventFilter(int xi_opcode) : X11EventFilter(XCB_GE_GENERIC, xi_opcode, QVector{XI_RawMotion, XI_RawButtonPress, XI_RawButtonRelease, XI_RawKeyPress, XI_RawKeyRelease, XI_TouchBegin, XI_TouchUpdate, XI_TouchOwnership, XI_TouchEnd}) {} - virtual ~XInputEventFilter() = default; + ~XInputEventFilter() override = default; bool event(xcb_generic_event_t *event) override { GeEventMemMover ge(event); switch (ge->event_type) { case XI_RawKeyPress: { auto re = reinterpret_cast(event); kwinApp()->platform()->keyboardKeyPressed(re->detail - 8, re->time); break; } case XI_RawKeyRelease: { auto re = reinterpret_cast(event); kwinApp()->platform()->keyboardKeyReleased(re->detail - 8, re->time); break; } case XI_RawButtonPress: { auto e = reinterpret_cast(event); switch (e->detail) { // TODO: this currently ignores left handed settings, for current usage not needed // if we want to use also for global mouse shortcuts, this needs to reflect state correctly case XCB_BUTTON_INDEX_1: kwinApp()->platform()->pointerButtonPressed(BTN_LEFT, e->time); break; case XCB_BUTTON_INDEX_2: kwinApp()->platform()->pointerButtonPressed(BTN_MIDDLE, e->time); break; case XCB_BUTTON_INDEX_3: kwinApp()->platform()->pointerButtonPressed(BTN_RIGHT, e->time); break; case XCB_BUTTON_INDEX_4: case XCB_BUTTON_INDEX_5: // vertical axis, ignore on press break; // TODO: further buttons, horizontal scrolling? } } if (m_x11Cursor) { m_x11Cursor->schedulePoll(); } break; case XI_RawButtonRelease: { auto e = reinterpret_cast(event); switch (e->detail) { // TODO: this currently ignores left handed settings, for current usage not needed // if we want to use also for global mouse shortcuts, this needs to reflect state correctly case XCB_BUTTON_INDEX_1: kwinApp()->platform()->pointerButtonReleased(BTN_LEFT, e->time); break; case XCB_BUTTON_INDEX_2: kwinApp()->platform()->pointerButtonReleased(BTN_MIDDLE, e->time); break; case XCB_BUTTON_INDEX_3: kwinApp()->platform()->pointerButtonReleased(BTN_RIGHT, e->time); break; case XCB_BUTTON_INDEX_4: kwinApp()->platform()->pointerAxisVertical(120, e->time); break; case XCB_BUTTON_INDEX_5: kwinApp()->platform()->pointerAxisVertical(-120, e->time); break; // TODO: further buttons, horizontal scrolling? } } if (m_x11Cursor) { m_x11Cursor->schedulePoll(); } break; case XI_TouchBegin: { auto e = reinterpret_cast(event); m_lastTouchPositions.insert(e->detail, QPointF(fixed1616ToReal(e->event_x), fixed1616ToReal(e->event_y))); break; } case XI_TouchUpdate: { auto e = reinterpret_cast(event); const QPointF touchPosition = QPointF(fixed1616ToReal(e->event_x), fixed1616ToReal(e->event_y)); if (e->detail == m_trackingTouchId) { const auto last = m_lastTouchPositions.value(e->detail); ScreenEdges::self()->gestureRecognizer()->updateSwipeGesture(QSizeF(touchPosition.x() - last.x(), touchPosition.y() - last.y())); } m_lastTouchPositions.insert(e->detail, touchPosition); break; } case XI_TouchEnd: { auto e = reinterpret_cast(event); if (e->detail == m_trackingTouchId) { ScreenEdges::self()->gestureRecognizer()->endSwipeGesture(); } m_lastTouchPositions.remove(e->detail); m_trackingTouchId = 0; break; } case XI_TouchOwnership: { auto e = reinterpret_cast(event); auto it = m_lastTouchPositions.constFind(e->touchid); if (it == m_lastTouchPositions.constEnd()) { XIAllowTouchEvents(display(), e->deviceid, e->sourceid, e->touchid, XIRejectTouch); } else { if (ScreenEdges::self()->gestureRecognizer()->startSwipeGesture(it.value()) > 0) { m_trackingTouchId = e->touchid; } XIAllowTouchEvents(display(), e->deviceid, e->sourceid, e->touchid, m_trackingTouchId == e->touchid ? XIAcceptTouch : XIRejectTouch); } break; } default: if (m_x11Cursor) { m_x11Cursor->schedulePoll(); } break; } return false; } void setCursor(const QPointer &cursor) { m_x11Cursor = cursor; } void setDisplay(Display *display) { m_x11Display = display; } private: Display *display() const { return m_x11Display; } QPointer m_x11Cursor; Display *m_x11Display = nullptr; uint32_t m_trackingTouchId = 0; QHash m_lastTouchPositions; }; class XKeyPressReleaseEventFilter : public X11EventFilter { public: XKeyPressReleaseEventFilter(uint32_t type) : X11EventFilter(type) {} - ~XKeyPressReleaseEventFilter() = default; + ~XKeyPressReleaseEventFilter() override = default; bool event(xcb_generic_event_t *event) override { xcb_key_press_event_t *ke = reinterpret_cast(event); if (ke->event == ke->root) { const uint8_t eventType = event->response_type & ~0x80; if (eventType == XCB_KEY_PRESS) { kwinApp()->platform()->keyboardKeyPressed(ke->detail - 8, ke->time); } else { kwinApp()->platform()->keyboardKeyReleased(ke->detail - 8, ke->time); } } return false; } }; XInputIntegration::XInputIntegration(Display *display, QObject *parent) : QObject(parent) , m_x11Display(display) { } XInputIntegration::~XInputIntegration() = default; void XInputIntegration::init() { Display *dpy = display(); int xi_opcode, event, error; // init XInput extension if (!XQueryExtension(dpy, "XInputExtension", &xi_opcode, &event, &error)) { qCDebug(KWIN_X11STANDALONE) << "XInputExtension not present"; return; } // verify that the XInput extension is at at least version 2.0 int major = 2, minor = 2; int result = XIQueryVersion(dpy, &major, &minor); if (result != Success) { qCDebug(KWIN_X11STANDALONE) << "Failed to init XInput 2.2, trying 2.0"; minor = 0; if (XIQueryVersion(dpy, &major, &minor) != Success) { qCDebug(KWIN_X11STANDALONE) << "Failed to init XInput"; return; } } m_hasXInput = true; m_xiOpcode = xi_opcode; m_majorVersion = major; m_minorVersion = minor; qCDebug(KWIN_X11STANDALONE) << "Has XInput support" << m_majorVersion << "." << m_minorVersion; } void XInputIntegration::setCursor(X11Cursor *cursor) { m_x11Cursor = QPointer(cursor); } void XInputIntegration::startListening() { // this assumes KWin is the only one setting events on the root window // given Qt's source code this seems to be true. If it breaks, we need to change XIEventMask evmasks[1]; unsigned char mask1[XIMaskLen(XI_LASTEVENT)]; memset(mask1, 0, sizeof(mask1)); XISetMask(mask1, XI_RawMotion); XISetMask(mask1, XI_RawButtonPress); XISetMask(mask1, XI_RawButtonRelease); if (m_majorVersion >= 2 && m_minorVersion >= 1) { // we need to listen to all events, which is only available with XInput 2.1 XISetMask(mask1, XI_RawKeyPress); XISetMask(mask1, XI_RawKeyRelease); } if (m_majorVersion >=2 && m_minorVersion >= 2) { // touch events since 2.2 XISetMask(mask1, XI_TouchBegin); XISetMask(mask1, XI_TouchUpdate); XISetMask(mask1, XI_TouchOwnership); XISetMask(mask1, XI_TouchEnd); } evmasks[0].deviceid = XIAllMasterDevices; evmasks[0].mask_len = sizeof(mask1); evmasks[0].mask = mask1; XISelectEvents(display(), rootWindow(), evmasks, 1); m_xiEventFilter.reset(new XInputEventFilter(m_xiOpcode)); m_xiEventFilter->setCursor(m_x11Cursor); m_xiEventFilter->setDisplay(display()); m_keyPressFilter.reset(new XKeyPressReleaseEventFilter(XCB_KEY_PRESS)); m_keyReleaseFilter.reset(new XKeyPressReleaseEventFilter(XCB_KEY_RELEASE)); // install the input event spies also relevant for X11 platform input()->installInputEventSpy(new ModifierOnlyShortcuts); } } diff --git a/plugins/platforms/x11/standalone/xinputintegration.h b/plugins/platforms/x11/standalone/xinputintegration.h index f98e7f3a1..e976ac72b 100644 --- a/plugins/platforms/x11/standalone/xinputintegration.h +++ b/plugins/platforms/x11/standalone/xinputintegration.h @@ -1,69 +1,69 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2016 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_XINPUTINTEGRATION_H #define KWIN_XINPUTINTEGRATION_H #include #include #include typedef struct _XDisplay Display; namespace KWin { class XInputEventFilter; class XKeyPressReleaseEventFilter; class X11Cursor; class XInputIntegration : public QObject { Q_OBJECT public: explicit XInputIntegration(Display *display, QObject *parent); - virtual ~XInputIntegration(); + ~XInputIntegration() override; void init(); void startListening(); bool hasXinput() const { return m_hasXInput; } void setCursor(X11Cursor *cursor); private: Display *display() const { return m_x11Display; } bool m_hasXInput = false; int m_xiOpcode = 0; int m_majorVersion = 0; int m_minorVersion = 0; QPointer m_x11Cursor; Display *m_x11Display; QScopedPointer m_xiEventFilter; QScopedPointer m_keyPressFilter; QScopedPointer m_keyReleaseFilter; }; } #endif diff --git a/plugins/platforms/x11/windowed/egl_x11_backend.h b/plugins/platforms/x11/windowed/egl_x11_backend.h index 523480107..e9d18f39d 100644 --- a/plugins/platforms/x11/windowed/egl_x11_backend.h +++ b/plugins/platforms/x11/windowed/egl_x11_backend.h @@ -1,57 +1,57 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_EGL_X11_BACKEND_H #define KWIN_EGL_X11_BACKEND_H #include "eglonxbackend.h" namespace KWin { class X11WindowedBackend; /** * @brief OpenGL Backend using Egl windowing system over an X overlay window. **/ class EglX11Backend : public EglOnXBackend { public: explicit EglX11Backend(X11WindowedBackend *backend); - virtual ~EglX11Backend(); - virtual QRegion prepareRenderingFrame(); - virtual void endRenderingFrame(const QRegion &damage, const QRegion &damagedRegion); - virtual bool usesOverlayWindow() const override; + ~EglX11Backend() override; + QRegion prepareRenderingFrame() override; + void endRenderingFrame(const QRegion &damage, const QRegion &damagedRegion) override; + bool usesOverlayWindow() const override; bool perScreenRendering() const override; QRegion prepareRenderingForScreen(int screenId) override; void endRenderingFrameForScreen(int screenId, const QRegion &damage, const QRegion &damagedRegion) override; protected: - virtual void present(); + void present() override; void cleanupSurfaces() override; bool createSurfaces() override; private: void setupViewport(int screenId); QVector m_surfaces; X11WindowedBackend *m_backend; }; } // namespace #endif diff --git a/plugins/platforms/x11/windowed/scene_qpainter_x11_backend.h b/plugins/platforms/x11/windowed/scene_qpainter_x11_backend.h index 1e57a3dab..449e6c346 100644 --- a/plugins/platforms/x11/windowed/scene_qpainter_x11_backend.h +++ b/plugins/platforms/x11/windowed/scene_qpainter_x11_backend.h @@ -1,65 +1,65 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_SCENE_QPAINTER_X11_BACKEND_H #define KWIN_SCENE_QPAINTER_X11_BACKEND_H #include #include #include #include #include namespace KWin { class X11WindowedBackend; class X11WindowedQPainterBackend : public QObject, public QPainterBackend { Q_OBJECT public: X11WindowedQPainterBackend(X11WindowedBackend *backend); - virtual ~X11WindowedQPainterBackend(); + ~X11WindowedQPainterBackend() override; QImage *buffer() override; QImage *bufferForScreen(int screenId) override; bool needsFullRepaint() const override; bool usesOverlayWindow() const override; void prepareRenderingFrame() override; void present(int mask, const QRegion &damage) override; bool perScreenRendering() const override; private: void createOutputs(); bool m_needsFullRepaint = true; xcb_gcontext_t m_gc = XCB_NONE; X11WindowedBackend *m_backend; struct Output { xcb_window_t window; QImage buffer; }; QVector m_outputs; }; } #endif diff --git a/plugins/platforms/x11/windowed/x11windowed_backend.h b/plugins/platforms/x11/windowed/x11windowed_backend.h index 9694b9b72..1d4d65c36 100644 --- a/plugins/platforms/x11/windowed/x11windowed_backend.h +++ b/plugins/platforms/x11/windowed/x11windowed_backend.h @@ -1,124 +1,124 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_X11WINDOWED_BACKEND_H #define KWIN_X11WINDOWED_BACKEND_H #include "platform.h" #include #include #include #include struct _XDisplay; typedef struct _XDisplay Display; typedef struct _XCBKeySymbols xcb_key_symbols_t; class NETWinInfo; namespace KWin { class X11WindowedOutput; class KWIN_EXPORT X11WindowedBackend : public Platform { Q_OBJECT Q_INTERFACES(KWin::Platform) Q_PLUGIN_METADATA(IID "org.kde.kwin.Platform" FILE "x11.json") Q_PROPERTY(QSize size READ screenSize NOTIFY sizeChanged) public: X11WindowedBackend(QObject *parent = nullptr); - virtual ~X11WindowedBackend(); + ~X11WindowedBackend() override; void init() override; xcb_connection_t *connection() const { return m_connection; } xcb_screen_t *screen() const { return m_screen; } int screenNumer() const { return m_screenNumber; } xcb_window_t window() const { return windowForScreen(0); } xcb_window_t windowForScreen(int screen) const; Display *display() const { return m_display; } xcb_window_t rootWindow() const; bool hasXInput() const { return m_hasXInput; } Screens *createScreens(QObject *parent = nullptr) override; OpenGLBackend *createOpenGLBackend() override; QPainterBackend* createQPainterBackend() override; void warpPointer(const QPointF &globalPos) override; QVector supportedCompositors() const override { if (selectedCompositor() != NoCompositing) { return {selectedCompositor()}; } return QVector{OpenGLCompositing, QPainterCompositing}; } Outputs outputs() const override; Outputs enabledOutputs() const override; Q_SIGNALS: void sizeChanged(); private: void createOutputs(); void startEventReading(); void grabKeyboard(xcb_timestamp_t time); void updateWindowTitle(); void handleEvent(xcb_generic_event_t *event); void handleClientMessage(xcb_client_message_event_t *event); void handleButtonPress(xcb_button_press_event_t *event); void handleExpose(xcb_expose_event_t *event); void updateSize(xcb_configure_notify_event_t *event); void createCursor(const QImage &img, const QPoint &hotspot); void initXInput(); xcb_connection_t *m_connection = nullptr; xcb_screen_t *m_screen = nullptr; xcb_key_symbols_t *m_keySymbols = nullptr; int m_screenNumber = 0; xcb_atom_t m_protocols = XCB_ATOM_NONE; xcb_atom_t m_deleteWindowProtocol = XCB_ATOM_NONE; xcb_cursor_t m_cursor = XCB_CURSOR_NONE; Display *m_display = nullptr; bool m_keyboardGrabbed = false; bool m_hasXInput = false; int m_xiOpcode = 0; int m_majorVersion = 0; int m_minorVersion = 0; QVector m_outputs; }; } #endif diff --git a/plugins/qpa/abstractplatformcontext.h b/plugins/qpa/abstractplatformcontext.h index decd807dc..eda15ba4e 100644 --- a/plugins/qpa/abstractplatformcontext.h +++ b/plugins/qpa/abstractplatformcontext.h @@ -1,67 +1,67 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_QPA_ABSTRACTPLATFORMCONTEXT_H #define KWIN_QPA_ABSTRACTPLATFORMCONTEXT_H #include #include "fixqopengl.h" #include #include namespace KWin { namespace QPA { class AbstractPlatformContext : public QPlatformOpenGLContext { public: AbstractPlatformContext(QOpenGLContext *context, EGLDisplay display, EGLConfig config = nullptr); - virtual ~AbstractPlatformContext(); + ~AbstractPlatformContext() override; void doneCurrent() override; QSurfaceFormat format() const override; bool isValid() const override; QFunctionPointer getProcAddress(const char *procName) override; protected: EGLDisplay eglDisplay() const { return m_eglDisplay; } EGLConfig config() const { return m_config; } bool bindApi(); EGLContext eglContext() const { return m_context; } void createContext(EGLContext shareContext = EGL_NO_CONTEXT); private: EGLDisplay m_eglDisplay; EGLConfig m_config; EGLContext m_context = EGL_NO_CONTEXT; QSurfaceFormat m_format; }; } } #endif diff --git a/plugins/qpa/backingstore.h b/plugins/qpa/backingstore.h index 53c25a778..b27b0dc07 100644 --- a/plugins/qpa/backingstore.h +++ b/plugins/qpa/backingstore.h @@ -1,61 +1,61 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_QPA_BACKINGSTORE_H #define KWIN_QPA_BACKINGSTORE_H #include namespace KWayland { namespace Client { class Buffer; class ShmPool; } } namespace KWin { namespace QPA { class BackingStore : public QPlatformBackingStore { public: explicit BackingStore(QWindow *w, KWayland::Client::ShmPool *shm); - virtual ~BackingStore(); + ~BackingStore() override; QPaintDevice *paintDevice() override; void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) override; void resize(const QSize &size, const QRegion &staticContents) override; void beginPaint(const QRegion &) override; private: int scale() const; KWayland::Client::ShmPool *m_shm; QWeakPointer m_buffer; QImage m_backBuffer; QSize m_size; }; } } #endif diff --git a/plugins/qpa/integration.h b/plugins/qpa/integration.h index eb18dbd21..6e4cc1059 100644 --- a/plugins/qpa/integration.h +++ b/plugins/qpa/integration.h @@ -1,87 +1,87 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_QPA_INTEGRATION_H #define KWIN_QPA_INTEGRATION_H #include #include "fixqopengl.h" #include #include #include namespace KWayland { namespace Client { class Compositor; class Shell; } } namespace KWin { namespace QPA { class Screen; class Integration : public QObject, public QPlatformIntegration { Q_OBJECT public: explicit Integration(); - virtual ~Integration(); + ~Integration() override; bool hasCapability(Capability cap) const override; QPlatformWindow *createPlatformWindow(QWindow *window) const override; QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override; QAbstractEventDispatcher *createEventDispatcher() const override; QPlatformFontDatabase *fontDatabase() const override; QStringList themeNames() const override; QPlatformTheme *createPlatformTheme(const QString &name) const override; QPlatformNativeInterface *nativeInterface() const override; QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override; void initialize() override; QPlatformInputContext *inputContext() const override; KWayland::Client::Compositor *compositor() const; EGLDisplay eglDisplay() const; private: void initScreens(); KWayland::Client::Shell *shell() const; QPlatformFontDatabase *m_fontDb; QPlatformNativeInterface *m_nativeInterface; KWayland::Client::Compositor *m_compositor = nullptr; KWayland::Client::Shell *m_shell = nullptr; EGLDisplay m_eglDisplay = EGL_NO_DISPLAY; Screen *m_dummyScreen = nullptr; QScopedPointer m_inputContext; QVector m_screens; }; } } #endif diff --git a/plugins/qpa/platformcursor.h b/plugins/qpa/platformcursor.h index e694d4ebf..a100c6bce 100644 --- a/plugins/qpa/platformcursor.h +++ b/plugins/qpa/platformcursor.h @@ -1,43 +1,43 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2016 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_QPA_PLATFORMCURSOR_H #define KWIN_QPA_PLATFORMCURSOR_H #include namespace KWin { namespace QPA { class PlatformCursor : public QPlatformCursor { public: PlatformCursor(); - virtual ~PlatformCursor(); + ~PlatformCursor() override; QPoint pos() const override; void setPos(const QPoint &pos) override; void changeCursor(QCursor *windowCursor, QWindow *window) override; }; } } #endif diff --git a/plugins/qpa/screen.h b/plugins/qpa/screen.h index 2753a4e89..ed4649dcc 100644 --- a/plugins/qpa/screen.h +++ b/plugins/qpa/screen.h @@ -1,54 +1,54 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_QPA_SCREEN_H #define KWIN_QPA_SCREEN_H #include #include namespace KWin { namespace QPA { class PlatformCursor; class Screen : public QPlatformScreen { public: explicit Screen(int screen); - virtual ~Screen(); + ~Screen() override; QRect geometry() const override; int depth() const override; QImage::Format format() const override; QSizeF physicalSize() const override; QPlatformCursor *cursor() const override; QDpi logicalDpi() const override; qreal devicePixelRatio() const override; private: int m_screen; QScopedPointer m_cursor; }; } } #endif diff --git a/plugins/qpa/window.h b/plugins/qpa/window.h index f43019535..12f8fa0e5 100644 --- a/plugins/qpa/window.h +++ b/plugins/qpa/window.h @@ -1,92 +1,92 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_QPA_WINDOW_H #define KWIN_QPA_WINDOW_H #include #include "fixqopengl.h" #include #include class QOpenGLFramebufferObject; namespace KWayland { namespace Client { class Surface; class ShellSurface; } } namespace KWin { class ShellClient; namespace QPA { class Integration; class Window : public QPlatformWindow { public: explicit Window(QWindow *window, KWayland::Client::Surface *surface, KWayland::Client::ShellSurface *shellSurface, const Integration *integration); - virtual ~Window(); + ~Window() override; void setVisible(bool visible) override; void setGeometry(const QRect &rect) override; WId winId() const override; KWayland::Client::Surface *surface() const { return m_surface; } int scale() const; qreal devicePixelRatio() const override; void bindContentFBO(); const QSharedPointer &contentFBO() const { return m_contentFBO; } QSharedPointer swapFBO(); ShellClient *shellClient(); private: void unmap(); void createFBO(); KWayland::Client::Surface *m_surface; KWayland::Client::ShellSurface *m_shellSurface; QSharedPointer m_contentFBO; bool m_resized = false; ShellClient *m_shellClient = nullptr; quint32 m_windowId; const Integration *m_integration; int m_scale = 1; }; } } #endif diff --git a/plugins/scenes/opengl/lanczosfilter.h b/plugins/scenes/opengl/lanczosfilter.h index 66481a770..bb11a6e1f 100644 --- a/plugins/scenes/opengl/lanczosfilter.h +++ b/plugins/scenes/opengl/lanczosfilter.h @@ -1,73 +1,73 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2010 by Fredrik Höglund Copyright (C) 2010 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_LANCZOSFILTER_P_H #define KWIN_LANCZOSFILTER_P_H #include #include #include #include #include namespace KWin { class EffectWindow; class EffectWindowImpl; class WindowPaintData; class GLTexture; class GLRenderTarget; class GLShader; class LanczosFilter : public QObject { Q_OBJECT public: explicit LanczosFilter(QObject* parent = 0); - ~LanczosFilter(); + ~LanczosFilter() override; void performPaint(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data); protected: - virtual void timerEvent(QTimerEvent*); + void timerEvent(QTimerEvent*) override; private: void init(); void updateOffscreenSurfaces(); void setUniforms(); void discardCacheTexture(EffectWindow *w); void createKernel(float delta, int *kernelSize); void createOffsets(int count, float width, Qt::Orientation direction); GLTexture *m_offscreenTex; GLRenderTarget *m_offscreenTarget; QBasicTimer m_timer; bool m_inited; QScopedPointer m_shader; int m_uOffsets; int m_uKernel; QVector2D m_offsets[16]; QVector4D m_kernel[16]; }; } // namespace #endif // KWIN_LANCZOSFILTER_P_H diff --git a/plugins/scenes/opengl/scene_opengl.h b/plugins/scenes/opengl/scene_opengl.h index 6453d3b57..e2cc16709 100644 --- a/plugins/scenes/opengl/scene_opengl.h +++ b/plugins/scenes/opengl/scene_opengl.h @@ -1,357 +1,357 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2006 Lubos Lunak Copyright (C) 2009, 2010, 2011 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_SCENE_OPENGL_H #define KWIN_SCENE_OPENGL_H #include "scene.h" #include "shadow.h" #include "kwinglutils.h" #include "decorations/decorationrenderer.h" #include "platformsupport/scenes/opengl/backend.h" namespace KWin { class LanczosFilter; class OpenGLBackend; class SyncManager; class SyncObject; class KWIN_EXPORT SceneOpenGL : public Scene { Q_OBJECT public: class EffectFrame; class Window; - virtual ~SceneOpenGL(); - virtual bool initFailed() const; - virtual bool hasPendingFlush() const; - virtual qint64 paint(QRegion damage, ToplevelList windows); - virtual Scene::EffectFrame *createEffectFrame(EffectFrameImpl *frame); - virtual Shadow *createShadow(Toplevel *toplevel); - virtual void screenGeometryChanged(const QSize &size); - virtual OverlayWindow *overlayWindow(); - virtual bool usesOverlayWindow() const; - virtual bool blocksForRetrace() const; - virtual bool syncsToVBlank() const; - virtual bool makeOpenGLContextCurrent() override; - virtual void doneOpenGLContextCurrent() override; + ~SceneOpenGL() override; + bool initFailed() const override; + bool hasPendingFlush() const override; + qint64 paint(QRegion damage, ToplevelList windows) override; + Scene::EffectFrame *createEffectFrame(EffectFrameImpl *frame) override; + Shadow *createShadow(Toplevel *toplevel) override; + void screenGeometryChanged(const QSize &size) override; + OverlayWindow *overlayWindow() override; + bool usesOverlayWindow() const override; + bool blocksForRetrace() const override; + bool syncsToVBlank() const override; + bool makeOpenGLContextCurrent() override; + void doneOpenGLContextCurrent() override; Decoration::Renderer *createDecorationRenderer(Decoration::DecoratedClientImpl *impl) override; - virtual void triggerFence() override; + void triggerFence() override; virtual QMatrix4x4 projectionMatrix() const = 0; bool animationsSupported() const override; void insertWait(); - void idle(); + void idle() override; bool debug() const { return m_debug; } void initDebugOutput(); /** * @brief Factory method to create a backend specific texture. * * @return :SceneOpenGL::Texture* **/ SceneOpenGLTexture *createTexture(); OpenGLBackend *backend() const { return m_backend; } QVector openGLPlatformInterfaceExtensions() const override; static SceneOpenGL *createScene(QObject *parent); protected: SceneOpenGL(OpenGLBackend *backend, QObject *parent = nullptr); - virtual void paintBackground(QRegion region); - virtual void extendPaintRegion(QRegion ®ion, bool opaqueFullscreen); + void paintBackground(QRegion region) override; + void extendPaintRegion(QRegion ®ion, bool opaqueFullscreen) override; QMatrix4x4 transformation(int mask, const ScreenPaintData &data) const; - virtual void paintDesktop(int desktop, int mask, const QRegion ®ion, ScreenPaintData &data); + void paintDesktop(int desktop, int mask, const QRegion ®ion, ScreenPaintData &data) override; void handleGraphicsReset(GLenum status); virtual void doPaintBackground(const QVector &vertices) = 0; virtual void updateProjectionMatrix() = 0; protected: bool init_ok; private: bool viewportLimitsMatched(const QSize &size) const; private: bool m_debug; OpenGLBackend *m_backend; SyncManager *m_syncManager; SyncObject *m_currentFence; }; class SceneOpenGL2 : public SceneOpenGL { Q_OBJECT public: explicit SceneOpenGL2(OpenGLBackend *backend, QObject *parent = nullptr); - virtual ~SceneOpenGL2(); - virtual CompositingType compositingType() const { + ~SceneOpenGL2() override; + CompositingType compositingType() const override { return OpenGL2Compositing; } static bool supported(OpenGLBackend *backend); QMatrix4x4 projectionMatrix() const override { return m_projectionMatrix; } QMatrix4x4 screenProjectionMatrix() const override { return m_screenProjectionMatrix; } protected: - virtual void paintSimpleScreen(int mask, QRegion region); - virtual void paintGenericScreen(int mask, ScreenPaintData data); - virtual void doPaintBackground(const QVector< float >& vertices); - virtual Scene::Window *createWindow(Toplevel *t); - virtual void finalDrawWindow(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data); - virtual void updateProjectionMatrix() override; + void paintSimpleScreen(int mask, QRegion region) override; + void paintGenericScreen(int mask, ScreenPaintData data) override; + void doPaintBackground(const QVector< float >& vertices) override; + Scene::Window *createWindow(Toplevel *t) override; + void finalDrawWindow(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data) override; + void updateProjectionMatrix() override; void paintCursor() override; private: void performPaintWindow(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data); QMatrix4x4 createProjectionMatrix() const; private: LanczosFilter *m_lanczosFilter; QScopedPointer m_cursorTexture; QMatrix4x4 m_projectionMatrix; QMatrix4x4 m_screenProjectionMatrix; GLuint vao; }; class SceneOpenGL::Window : public Scene::Window { public: - virtual ~Window(); + ~Window() override; bool beginRenderWindow(int mask, const QRegion ®ion, WindowPaintData &data); - virtual void performPaint(int mask, QRegion region, WindowPaintData data) = 0; + void performPaint(int mask, QRegion region, WindowPaintData data) override = 0; void endRenderWindow(); bool bindTexture(); void setScene(SceneOpenGL *scene) { m_scene = scene; } protected: - virtual WindowPixmap* createWindowPixmap(); + WindowPixmap* createWindowPixmap() override; Window(Toplevel* c); enum TextureType { Content, Decoration, Shadow }; QMatrix4x4 transformation(int mask, const WindowPaintData &data) const; GLTexture *getDecorationTexture() const; protected: SceneOpenGL *m_scene; bool m_hardwareClipping; }; class OpenGLWindowPixmap; class SceneOpenGL2Window : public SceneOpenGL::Window { public: enum Leaf { ShadowLeaf = 0, DecorationLeaf, ContentLeaf, PreviousContentLeaf, LeafCount }; struct LeafNode { LeafNode() : texture(0), firstVertex(0), vertexCount(0), opacity(1.0), hasAlpha(false), coordinateType(UnnormalizedCoordinates) { } GLTexture *texture; int firstVertex; int vertexCount; float opacity; bool hasAlpha; TextureCoordinateType coordinateType; }; explicit SceneOpenGL2Window(Toplevel *c); - virtual ~SceneOpenGL2Window(); + ~SceneOpenGL2Window() override; protected: QMatrix4x4 modelViewProjectionMatrix(int mask, const WindowPaintData &data) const; QVector4D modulate(float opacity, float brightness) const; void setBlendEnabled(bool enabled); void setupLeafNodes(LeafNode *nodes, const WindowQuadList *quads, const WindowPaintData &data); - virtual void performPaint(int mask, QRegion region, WindowPaintData data); + void performPaint(int mask, QRegion region, WindowPaintData data) override; private: void renderSubSurface(GLShader *shader, const QMatrix4x4 &mvp, const QMatrix4x4 &windowMatrix, OpenGLWindowPixmap *pixmap, const QRegion ®ion, bool hardwareClipping); /** * Whether prepareStates enabled blending and restore states should disable again. **/ bool m_blendingEnabled; }; class OpenGLWindowPixmap : public WindowPixmap { public: explicit OpenGLWindowPixmap(Scene::Window *window, SceneOpenGL *scene); - virtual ~OpenGLWindowPixmap(); + ~OpenGLWindowPixmap() override; SceneOpenGLTexture *texture() const; bool bind(); bool isValid() const override; protected: WindowPixmap *createChild(const QPointer &subSurface) override; private: explicit OpenGLWindowPixmap(const QPointer &subSurface, WindowPixmap *parent, SceneOpenGL *scene); QScopedPointer m_texture; SceneOpenGL *m_scene; }; class SceneOpenGL::EffectFrame : public Scene::EffectFrame { public: EffectFrame(EffectFrameImpl* frame, SceneOpenGL *scene); - virtual ~EffectFrame(); + ~EffectFrame() override; - virtual void free(); - virtual void freeIconFrame(); - virtual void freeTextFrame(); - virtual void freeSelection(); + void free() override; + void freeIconFrame() override; + void freeTextFrame() override; + void freeSelection() override; - virtual void render(QRegion region, double opacity, double frameOpacity); + void render(QRegion region, double opacity, double frameOpacity) override; - virtual void crossFadeIcon(); - virtual void crossFadeText(); + void crossFadeIcon() override; + void crossFadeText() override; static void cleanup(); private: void updateTexture(); void updateTextTexture(); GLTexture *m_texture; GLTexture *m_textTexture; GLTexture *m_oldTextTexture; QPixmap *m_textPixmap; // need to keep the pixmap around to workaround some driver problems GLTexture *m_iconTexture; GLTexture *m_oldIconTexture; GLTexture *m_selectionTexture; GLVertexBuffer *m_unstyledVBO; SceneOpenGL *m_scene; static GLTexture* m_unstyledTexture; static QPixmap* m_unstyledPixmap; // need to keep the pixmap around to workaround some driver problems static void updateUnstyledTexture(); // Update OpenGL unstyled frame texture }; /** * @short OpenGL implementation of Shadow. * * This class extends Shadow by the Elements required for OpenGL rendering. * @author Martin Gräßlin **/ class SceneOpenGLShadow : public Shadow { public: explicit SceneOpenGLShadow(Toplevel *toplevel); - virtual ~SceneOpenGLShadow(); + ~SceneOpenGLShadow() override; GLTexture *shadowTexture() { return m_texture.data(); } protected: - virtual void buildQuads(); - virtual bool prepareBackend(); + void buildQuads() override; + bool prepareBackend() override; private: QSharedPointer m_texture; }; class SceneOpenGLDecorationRenderer : public Decoration::Renderer { Q_OBJECT public: enum class DecorationPart : int { Left, Top, Right, Bottom, Count }; explicit SceneOpenGLDecorationRenderer(Decoration::DecoratedClientImpl *client); - virtual ~SceneOpenGLDecorationRenderer(); + ~SceneOpenGLDecorationRenderer() override; void render() override; void reparent(Deleted *deleted) override; GLTexture *texture() { return m_texture.data(); } GLTexture *texture() const { return m_texture.data(); } private: void resizeTexture(); QScopedPointer m_texture; }; inline bool SceneOpenGL::hasPendingFlush() const { return m_backend->hasPendingFlush(); } inline bool SceneOpenGL::usesOverlayWindow() const { return m_backend->usesOverlayWindow(); } inline SceneOpenGLTexture* OpenGLWindowPixmap::texture() const { return m_texture.data(); } class KWIN_EXPORT OpenGLFactory : public SceneFactory { Q_OBJECT Q_INTERFACES(KWin::SceneFactory) Q_PLUGIN_METADATA(IID "org.kde.kwin.Scene" FILE "opengl.json") public: explicit OpenGLFactory(QObject *parent = nullptr); ~OpenGLFactory() override; Scene *create(QObject *parent = nullptr) const override; }; } // namespace #endif diff --git a/plugins/scenes/qpainter/scene_qpainter.h b/plugins/scenes/qpainter/scene_qpainter.h index e7c9f9a3a..2cb03211d 100644 --- a/plugins/scenes/qpainter/scene_qpainter.h +++ b/plugins/scenes/qpainter/scene_qpainter.h @@ -1,202 +1,202 @@ /******************************************************************** 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_SCENE_QPAINTER_H #define KWIN_SCENE_QPAINTER_H #include "scene.h" #include #include "shadow.h" #include "decorations/decorationrenderer.h" namespace KWin { class KWIN_EXPORT SceneQPainter : public Scene { Q_OBJECT public: - virtual ~SceneQPainter(); - virtual bool usesOverlayWindow() const override; - virtual OverlayWindow* overlayWindow() override; - virtual qint64 paint(QRegion damage, ToplevelList windows) override; - virtual void paintGenericScreen(int mask, ScreenPaintData data) override; - virtual CompositingType compositingType() const override; - virtual bool initFailed() const override; - virtual EffectFrame *createEffectFrame(EffectFrameImpl *frame) override; - virtual Shadow *createShadow(Toplevel *toplevel) override; + ~SceneQPainter() override; + bool usesOverlayWindow() const override; + OverlayWindow* overlayWindow() override; + qint64 paint(QRegion damage, ToplevelList windows) override; + void paintGenericScreen(int mask, ScreenPaintData data) override; + CompositingType compositingType() const override; + bool initFailed() const override; + EffectFrame *createEffectFrame(EffectFrameImpl *frame) override; + Shadow *createShadow(Toplevel *toplevel) override; Decoration::Renderer *createDecorationRenderer(Decoration::DecoratedClientImpl *impl) override; void screenGeometryChanged(const QSize &size) override; bool animationsSupported() const override { return false; } QPainter *scenePainter() const override; QImage *qpainterRenderBuffer() const override; QPainterBackend *backend() const { return m_backend.data(); } static SceneQPainter *createScene(QObject *parent); protected: - virtual void paintBackground(QRegion region) override; - virtual Scene::Window *createWindow(Toplevel *toplevel) override; + void paintBackground(QRegion region) override; + Scene::Window *createWindow(Toplevel *toplevel) override; void paintCursor() override; private: explicit SceneQPainter(QPainterBackend *backend, QObject *parent = nullptr); QScopedPointer m_backend; QScopedPointer m_painter; class Window; }; class SceneQPainter::Window : public Scene::Window { public: Window(SceneQPainter *scene, Toplevel *c); - virtual ~Window(); - virtual void performPaint(int mask, QRegion region, WindowPaintData data) override; + ~Window() override; + void performPaint(int mask, QRegion region, WindowPaintData data) override; protected: - virtual WindowPixmap *createWindowPixmap() override; + WindowPixmap *createWindowPixmap() override; private: void renderShadow(QPainter *painter); void renderWindowDecorations(QPainter *painter); SceneQPainter *m_scene; }; class QPainterWindowPixmap : public WindowPixmap { public: explicit QPainterWindowPixmap(Scene::Window *window); - virtual ~QPainterWindowPixmap(); - virtual void create() override; + ~QPainterWindowPixmap() override; + void create() override; bool isValid() const override; void updateBuffer() override; const QImage &image(); protected: WindowPixmap *createChild(const QPointer &subSurface) override; private: explicit QPainterWindowPixmap(const QPointer &subSurface, WindowPixmap *parent); QImage m_image; }; class QPainterEffectFrame : public Scene::EffectFrame { public: QPainterEffectFrame(EffectFrameImpl *frame, SceneQPainter *scene); - virtual ~QPainterEffectFrame(); - virtual void crossFadeIcon() override {} - virtual void crossFadeText() override {} - virtual void free() override {} - virtual void freeIconFrame() override {} - virtual void freeTextFrame() override {} - virtual void freeSelection() override {} - virtual void render(QRegion region, double opacity, double frameOpacity) override; + ~QPainterEffectFrame() override; + void crossFadeIcon() override {} + void crossFadeText() override {} + void free() override {} + void freeIconFrame() override {} + void freeTextFrame() override {} + void freeSelection() override {} + void render(QRegion region, double opacity, double frameOpacity) override; private: SceneQPainter *m_scene; }; class SceneQPainterShadow : public Shadow { public: SceneQPainterShadow(Toplevel* toplevel); - virtual ~SceneQPainterShadow(); + ~SceneQPainterShadow() override; QImage &shadowTexture() { return m_texture; } protected: - virtual void buildQuads() override; - virtual bool prepareBackend() override; + void buildQuads() override; + bool prepareBackend() override; private: QImage m_texture; }; class SceneQPainterDecorationRenderer : public Decoration::Renderer { Q_OBJECT public: enum class DecorationPart : int { Left, Top, Right, Bottom, Count }; explicit SceneQPainterDecorationRenderer(Decoration::DecoratedClientImpl *client); - virtual ~SceneQPainterDecorationRenderer(); + ~SceneQPainterDecorationRenderer() override; void render() override; void reparent(Deleted *deleted) override; QImage image(DecorationPart part) const; private: void resizeImages(); QImage m_images[int(DecorationPart::Count)]; }; class KWIN_EXPORT QPainterFactory : public SceneFactory { Q_OBJECT Q_INTERFACES(KWin::SceneFactory) Q_PLUGIN_METADATA(IID "org.kde.kwin.Scene" FILE "qpainter.json") public: explicit QPainterFactory(QObject *parent = nullptr); ~QPainterFactory() override; Scene *create(QObject *parent = nullptr) const override; }; inline bool SceneQPainter::usesOverlayWindow() const { return m_backend->usesOverlayWindow(); } inline OverlayWindow* SceneQPainter::overlayWindow() { return m_backend->overlayWindow(); } inline QPainter* SceneQPainter::scenePainter() const { return m_painter.data(); } inline const QImage &QPainterWindowPixmap::image() { return m_image; } } // KWin #endif // KWIN_SCENEQPAINTER_H diff --git a/plugins/scenes/xrender/scene_xrender.h b/plugins/scenes/xrender/scene_xrender.h index 2545f65cf..e727206d3 100644 --- a/plugins/scenes/xrender/scene_xrender.h +++ b/plugins/scenes/xrender/scene_xrender.h @@ -1,358 +1,358 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2006 Lubos Lunak 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_SCENE_XRENDER_H #define KWIN_SCENE_XRENDER_H #include "scene.h" #include "shadow.h" #include "decorations/decorationrenderer.h" #ifdef KWIN_HAVE_XRENDER_COMPOSITING namespace KWin { namespace Xcb { class Shm; } /** * @brief Backend for the SceneXRender to hold the compositing buffer and take care of buffer * swapping. * * This class is intended as a small abstraction to support multiple compositing backends in the * SceneXRender. **/ class XRenderBackend { public: virtual ~XRenderBackend(); virtual void present(int mask, const QRegion &damage) = 0; /** * @brief Returns the OverlayWindow used by the backend. * * A backend does not have to use an OverlayWindow, this is mostly for the X world. * In case the backend does not use an OverlayWindow it is allowed to return @c null. * It's the task of the caller to check whether it is @c null. * * @return :OverlayWindow* **/ virtual OverlayWindow *overlayWindow(); virtual bool usesOverlayWindow() const = 0; /** * @brief Shows the Overlay Window * * Default implementation does nothing. **/ virtual void showOverlay(); /** * @brief React on screen geometry changes. * * Default implementation does nothing. Override if specific functionality is required. * * @param size The new screen size **/ virtual void screenGeometryChanged(const QSize &size); /** * @brief The compositing buffer hold by this backend. * * The Scene composites the new frame into this buffer. * * @return xcb_render_picture_t **/ xcb_render_picture_t buffer() const { return m_buffer; } /** * @brief Whether the creation of the Backend failed. * * The SceneXRender should test whether the Backend got constructed correctly. If this method * returns @c true, the SceneXRender should not try to start the rendering. * * @return bool @c true if the creation of the Backend failed, @c false otherwise. **/ bool isFailed() const { return m_failed; } protected: XRenderBackend(); /** * @brief A subclass needs to call this method once it created the compositing back buffer. * * @param buffer The buffer to use for compositing * @return void **/ void setBuffer(xcb_render_picture_t buffer); /** * @brief Sets the backend initialization to failed. * * This method should be called by the concrete subclass in case the initialization failed. * The given @p reason is logged as a warning. * * @param reason The reason why the initialization failed. **/ void setFailed(const QString &reason); private: // Create the compositing buffer. The root window is not double-buffered, // so it is done manually using this buffer, xcb_render_picture_t m_buffer; bool m_failed; }; /** * @brief XRenderBackend using an X11 Overlay Window as compositing target. **/ class X11XRenderBackend : public XRenderBackend { public: X11XRenderBackend(); - ~X11XRenderBackend(); + ~X11XRenderBackend() override; - virtual void present(int mask, const QRegion &damage); - virtual OverlayWindow* overlayWindow(); - virtual void showOverlay(); - virtual void screenGeometryChanged(const QSize &size); - virtual bool usesOverlayWindow() const; + void present(int mask, const QRegion &damage) override; + OverlayWindow* overlayWindow() override; + void showOverlay() override; + void screenGeometryChanged(const QSize &size) override; + bool usesOverlayWindow() const override; private: void init(bool createOverlay); void createBuffer(); QScopedPointer m_overlayWindow; xcb_render_picture_t m_front; xcb_render_pictformat_t m_format; }; class SceneXrender : public Scene { Q_OBJECT public: class EffectFrame; - virtual ~SceneXrender(); - virtual bool initFailed() const; - virtual CompositingType compositingType() const { + ~SceneXrender() override; + bool initFailed() const override; + CompositingType compositingType() const override { return XRenderCompositing; } - virtual qint64 paint(QRegion damage, ToplevelList windows); - virtual Scene::EffectFrame *createEffectFrame(EffectFrameImpl *frame); - virtual Shadow *createShadow(Toplevel *toplevel); - virtual void screenGeometryChanged(const QSize &size); + qint64 paint(QRegion damage, ToplevelList windows) override; + Scene::EffectFrame *createEffectFrame(EffectFrameImpl *frame) override; + Shadow *createShadow(Toplevel *toplevel) override; + void screenGeometryChanged(const QSize &size) override; xcb_render_picture_t xrenderBufferPicture() const override; - virtual OverlayWindow *overlayWindow() { + OverlayWindow *overlayWindow() override { return m_backend->overlayWindow(); } - virtual bool usesOverlayWindow() const { + bool usesOverlayWindow() const override { return m_backend->usesOverlayWindow(); } - Decoration::Renderer *createDecorationRenderer(Decoration::DecoratedClientImpl *client); + Decoration::Renderer *createDecorationRenderer(Decoration::DecoratedClientImpl *client) override; bool animationsSupported() const override { return true; } static SceneXrender *createScene(QObject *parent); protected: - virtual Scene::Window *createWindow(Toplevel *toplevel); - virtual void paintBackground(QRegion region); - virtual void paintGenericScreen(int mask, ScreenPaintData data); - virtual void paintDesktop(int desktop, int mask, const QRegion ®ion, ScreenPaintData &data); + Scene::Window *createWindow(Toplevel *toplevel) override; + void paintBackground(QRegion region) override; + void paintGenericScreen(int mask, ScreenPaintData data) override; + void paintDesktop(int desktop, int mask, const QRegion ®ion, ScreenPaintData &data) override; void paintCursor() override; private: explicit SceneXrender(XRenderBackend *backend, QObject *parent = nullptr); static ScreenPaintData screen_paint; class Window; QScopedPointer m_backend; }; class SceneXrender::Window : public Scene::Window { public: Window(Toplevel* c, SceneXrender *scene); - virtual ~Window(); - virtual void performPaint(int mask, QRegion region, WindowPaintData data); + ~Window() override; + void performPaint(int mask, QRegion region, WindowPaintData data) override; QRegion transformedShape() const; void setTransformedShape(const QRegion& shape); static void cleanup(); protected: - virtual WindowPixmap* createWindowPixmap(); + WindowPixmap* createWindowPixmap() override; private: QRect mapToScreen(int mask, const WindowPaintData &data, const QRect &rect) const; QPoint mapToScreen(int mask, const WindowPaintData &data, const QPoint &point) const; void prepareTempPixmap(); void setPictureFilter(xcb_render_picture_t pic, ImageFilterType filter); SceneXrender *m_scene; xcb_render_pictformat_t format; QRegion transformed_shape; static QRect temp_visibleRect; static XRenderPicture *s_tempPicture; static XRenderPicture *s_fadeAlphaPicture; }; class XRenderWindowPixmap : public WindowPixmap { public: explicit XRenderWindowPixmap(Scene::Window *window, xcb_render_pictformat_t format); - virtual ~XRenderWindowPixmap(); + ~XRenderWindowPixmap() override; xcb_render_picture_t picture() const; - virtual void create(); + void create() override; private: xcb_render_picture_t m_picture; xcb_render_pictformat_t m_format; }; class SceneXrender::EffectFrame : public Scene::EffectFrame { public: EffectFrame(EffectFrameImpl* frame); - virtual ~EffectFrame(); - - virtual void free(); - virtual void freeIconFrame(); - virtual void freeTextFrame(); - virtual void freeSelection(); - virtual void crossFadeIcon(); - virtual void crossFadeText(); - virtual void render(QRegion region, double opacity, double frameOpacity); + ~EffectFrame() override; + + void free() override; + void freeIconFrame() override; + void freeTextFrame() override; + void freeSelection() override; + void crossFadeIcon() override; + void crossFadeText() override; + void render(QRegion region, double opacity, double frameOpacity) override; static void cleanup(); private: void updatePicture(); void updateTextPicture(); void renderUnstyled(xcb_render_picture_t pict, const QRect &rect, qreal opacity); XRenderPicture* m_picture; XRenderPicture* m_textPicture; XRenderPicture* m_iconPicture; XRenderPicture* m_selectionPicture; static XRenderPicture* s_effectFrameCircle; }; inline xcb_render_picture_t SceneXrender::xrenderBufferPicture() const { return m_backend->buffer(); } inline QRegion SceneXrender::Window::transformedShape() const { return transformed_shape; } inline void SceneXrender::Window::setTransformedShape(const QRegion& shape) { transformed_shape = shape; } inline xcb_render_picture_t XRenderWindowPixmap::picture() const { return m_picture; } /** * @short XRender implementation of Shadow. * * This class extends Shadow by the elements required for XRender rendering. * @author Jacopo De Simoi **/ class SceneXRenderShadow : public Shadow { public: explicit SceneXRenderShadow(Toplevel *toplevel); using Shadow::ShadowElements; using Shadow::ShadowElementTop; using Shadow::ShadowElementTopRight; using Shadow::ShadowElementRight; using Shadow::ShadowElementBottomRight; using Shadow::ShadowElementBottom; using Shadow::ShadowElementBottomLeft; using Shadow::ShadowElementLeft; using Shadow::ShadowElementTopLeft; using Shadow::ShadowElementsCount; using Shadow::shadowPixmap; - virtual ~SceneXRenderShadow(); + ~SceneXRenderShadow() override; void layoutShadowRects(QRect& top, QRect& topRight, QRect& right, QRect& bottomRight, QRect& bottom, QRect& bottomLeft, QRect& Left, QRect& topLeft); xcb_render_picture_t picture(ShadowElements element) const; protected: - virtual void buildQuads(); - virtual bool prepareBackend(); + void buildQuads() override; + bool prepareBackend() override; private: XRenderPicture* m_pictures[ShadowElementsCount]; }; class SceneXRenderDecorationRenderer : public Decoration::Renderer { Q_OBJECT public: enum class DecorationPart : int { Left, Top, Right, Bottom, Count }; explicit SceneXRenderDecorationRenderer(Decoration::DecoratedClientImpl *client); - virtual ~SceneXRenderDecorationRenderer(); + ~SceneXRenderDecorationRenderer() override; void render() override; void reparent(Deleted *deleted) override; xcb_render_picture_t picture(DecorationPart part) const; private: void resizePixmaps(); QSize m_sizes[int(DecorationPart::Count)]; xcb_pixmap_t m_pixmaps[int(DecorationPart::Count)]; xcb_gcontext_t m_gc; XRenderPicture* m_pictures[int(DecorationPart::Count)]; }; class KWIN_EXPORT XRenderFactory : public SceneFactory { Q_OBJECT Q_INTERFACES(KWin::SceneFactory) Q_PLUGIN_METADATA(IID "org.kde.kwin.Scene" FILE "xrender.json") public: explicit XRenderFactory(QObject *parent = nullptr); ~XRenderFactory() override; Scene *create(QObject *parent = nullptr) const override; }; } // namespace #endif #endif diff --git a/pointer_input.h b/pointer_input.h index e3322762e..2e41e16bd 100644 --- a/pointer_input.h +++ b/pointer_input.h @@ -1,259 +1,259 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2013, 2016 Martin Gräßlin Copyright (C) 2018 Roman Gilg Copyright (C) 2019 Vlad Zagorodniy 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_POINTER_INPUT_H #define KWIN_POINTER_INPUT_H #include "input.h" #include #include #include #include class QWindow; namespace KWayland { namespace Server { class SurfaceInterface; } } namespace KWin { class CursorImage; class InputRedirection; class Toplevel; class WaylandCursorTheme; class CursorShape; namespace Decoration { class DecoratedClientImpl; } namespace LibInput { class Device; } class KWIN_EXPORT PointerInputRedirection : public InputDeviceHandler { Q_OBJECT public: explicit PointerInputRedirection(InputRedirection *parent); - virtual ~PointerInputRedirection(); + ~PointerInputRedirection() override; - void init(); + void init() override; void updateAfterScreenChange(); bool supportsWarping() const; void warp(const QPointF &pos); QPointF pos() const { return m_pos; } Qt::MouseButtons buttons() const { return m_qtButtons; } bool areButtonsPressed() const; QImage cursorImage() const; QPoint cursorHotSpot() const; void markCursorAsRendered(); void setEffectsOverrideCursor(Qt::CursorShape shape); void removeEffectsOverrideCursor(); void setWindowSelectionCursor(const QByteArray &shape); void removeWindowSelectionCursor(); void updatePointerConstraints(); void setEnableConstraints(bool set); bool isConstrained() const { return m_confined || m_locked; } bool focusUpdatesBlocked() override; /** * @internal **/ void processMotion(const QPointF &pos, uint32_t time, LibInput::Device *device = nullptr); /** * @internal **/ void processMotion(const QPointF &pos, const QSizeF &delta, const QSizeF &deltaNonAccelerated, uint32_t time, quint64 timeUsec, LibInput::Device *device); /** * @internal **/ void processButton(uint32_t button, InputRedirection::PointerButtonState state, uint32_t time, LibInput::Device *device = nullptr); /** * @internal **/ void processAxis(InputRedirection::PointerAxis axis, qreal delta, qint32 discreteDelta, InputRedirection::PointerAxisSource source, uint32_t time, LibInput::Device *device = nullptr); /** * @internal **/ void processSwipeGestureBegin(int fingerCount, quint32 time, KWin::LibInput::Device *device = nullptr); /** * @internal **/ void processSwipeGestureUpdate(const QSizeF &delta, quint32 time, KWin::LibInput::Device *device = nullptr); /** * @internal **/ void processSwipeGestureEnd(quint32 time, KWin::LibInput::Device *device = nullptr); /** * @internal **/ void processSwipeGestureCancelled(quint32 time, KWin::LibInput::Device *device = nullptr); /** * @internal **/ void processPinchGestureBegin(int fingerCount, quint32 time, KWin::LibInput::Device *device = nullptr); /** * @internal **/ void processPinchGestureUpdate(qreal scale, qreal angleDelta, const QSizeF &delta, quint32 time, KWin::LibInput::Device *device = nullptr); /** * @internal **/ void processPinchGestureEnd(quint32 time, KWin::LibInput::Device *device = nullptr); /** * @internal **/ void processPinchGestureCancelled(quint32 time, KWin::LibInput::Device *device = nullptr); private: void cleanupInternalWindow(QWindow *old, QWindow *now) override; void cleanupDecoration(Decoration::DecoratedClientImpl *old, Decoration::DecoratedClientImpl *now) override; void focusUpdate(Toplevel *focusOld, Toplevel *focusNow) override; QPointF position() const override; void updateOnStartMoveResize(); void updateToReset(); void updatePosition(const QPointF &pos); void updateButton(uint32_t button, InputRedirection::PointerButtonState state); void warpXcbOnSurfaceLeft(KWayland::Server::SurfaceInterface *surface); QPointF applyPointerConfinement(const QPointF &pos) const; void disconnectConfinedPointerRegionConnection(); void disconnectLockedPointerAboutToBeUnboundConnection(); void disconnectPointerConstraintsConnection(); void breakPointerConstraints(KWayland::Server::SurfaceInterface *surface); CursorImage *m_cursor; bool m_supportsWarping; QPointF m_pos; QHash m_buttons; Qt::MouseButtons m_qtButtons; QMetaObject::Connection m_focusGeometryConnection; QMetaObject::Connection m_internalWindowConnection; QMetaObject::Connection m_constraintsConnection; QMetaObject::Connection m_constraintsActivatedConnection; QMetaObject::Connection m_confinedPointerRegionConnection; QMetaObject::Connection m_lockedPointerAboutToBeUnboundConnection; QMetaObject::Connection m_decorationGeometryConnection; bool m_confined = false; bool m_locked = false; bool m_enableConstraints = true; }; class CursorImage : public QObject { Q_OBJECT public: explicit CursorImage(PointerInputRedirection *parent = nullptr); - virtual ~CursorImage(); + ~CursorImage() override; void setEffectsOverrideCursor(Qt::CursorShape shape); void removeEffectsOverrideCursor(); void setWindowSelectionCursor(const QByteArray &shape); void removeWindowSelectionCursor(); QImage image() const; QPoint hotSpot() const; void markAsRendered(); Q_SIGNALS: void changed(); private: void reevaluteSource(); void update(); void updateServerCursor(); void updateDecoration(); void updateDecorationCursor(); void updateMoveResize(); void updateDrag(); void updateDragCursor(); void loadTheme(); struct Image { QImage image; QPoint hotSpot; }; void loadThemeCursor(CursorShape shape, Image *image); void loadThemeCursor(const QByteArray &shape, Image *image); template void loadThemeCursor(const T &shape, QHash &cursors, Image *image); enum class CursorSource { LockScreen, EffectsOverride, MoveResize, PointerSurface, Decoration, DragAndDrop, Fallback, WindowSelector }; void setSource(CursorSource source); PointerInputRedirection *m_pointer; CursorSource m_currentSource = CursorSource::Fallback; WaylandCursorTheme *m_cursorTheme = nullptr; struct { QMetaObject::Connection connection; QImage image; QPoint hotSpot; } m_serverCursor; Image m_effectsCursor; Image m_decorationCursor; QMetaObject::Connection m_decorationConnection; Image m_fallbackCursor; Image m_moveResizeCursor; Image m_windowSelectionCursor; QHash m_cursors; QHash m_cursorsByName; QElapsedTimer m_surfaceRenderedTimer; struct { Image cursor; QMetaObject::Connection connection; } m_drag; }; } #endif diff --git a/rules.h b/rules.h index 0496a4acd..7d2b4afdb 100644 --- a/rules.h +++ b/rules.h @@ -1,394 +1,394 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2004 Lubos Lunak 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_RULES_H #define KWIN_RULES_H #include #include #include #include #include "placement.h" #include "options.h" #include "utils.h" class QDebug; class KConfig; class KXMessages; namespace KWin { class AbstractClient; class Client; class Rules; #ifndef KCMRULES // only for kwin core class WindowRules { public: explicit WindowRules(const QVector< Rules* >& rules); WindowRules(); void update(AbstractClient*, int selection); void discardTemporary(); bool contains(const Rules* rule) const; void remove(Rules* rule); Placement::Policy checkPlacement(Placement::Policy placement) const; QRect checkGeometry(QRect rect, bool init = false) const; // use 'invalidPoint' with checkPosition, unlike QSize() and QRect(), QPoint() is a valid point QPoint checkPosition(QPoint pos, bool init = false) const; QSize checkSize(QSize s, bool init = false) const; QSize checkMinSize(QSize s) const; QSize checkMaxSize(QSize s) const; int checkOpacityActive(int s) const; int checkOpacityInactive(int s) const; bool checkIgnoreGeometry(bool ignore, bool init = false) const; int checkDesktop(int desktop, bool init = false) const; int checkScreen(int screen, bool init = false) const; QString checkActivity(QString activity, bool init = false) const; NET::WindowType checkType(NET::WindowType type) const; MaximizeMode checkMaximize(MaximizeMode mode, bool init = false) const; bool checkMinimize(bool minimized, bool init = false) const; ShadeMode checkShade(ShadeMode shade, bool init = false) const; bool checkSkipTaskbar(bool skip, bool init = false) const; bool checkSkipPager(bool skip, bool init = false) const; bool checkSkipSwitcher(bool skip, bool init = false) const; bool checkKeepAbove(bool above, bool init = false) const; bool checkKeepBelow(bool below, bool init = false) const; bool checkFullScreen(bool fs, bool init = false) const; bool checkNoBorder(bool noborder, bool init = false) const; QString checkDecoColor(QString schemeFile) const; bool checkBlockCompositing(bool block) const; int checkFSP(int fsp) const; int checkFPP(int fpp) const; bool checkAcceptFocus(bool focus) const; bool checkCloseable(bool closeable) const; bool checkAutogrouping(bool autogroup) const; bool checkAutogroupInForeground(bool fg) const; QString checkAutogroupById(QString id) const; bool checkStrictGeometry(bool strict) const; QString checkShortcut(QString s, bool init = false) const; bool checkDisableGlobalShortcuts(bool disable) const; QString checkDesktopFile(QString desktopFile, bool init = false) const; private: MaximizeMode checkMaximizeVert(MaximizeMode mode, bool init) const; MaximizeMode checkMaximizeHoriz(MaximizeMode mode, bool init) const; QVector< Rules* > rules; }; #endif class Rules { public: Rules(); explicit Rules(const KConfigGroup&); Rules(const QString&, bool temporary); enum Type { Position = 1<<0, Size = 1<<1, Desktop = 1<<2, MaximizeVert = 1<<3, MaximizeHoriz = 1<<4, Minimize = 1<<5, Shade = 1<<6, SkipTaskbar = 1<<7, SkipPager = 1<<8, SkipSwitcher = 1<<9, Above = 1<<10, Below = 1<<11, Fullscreen = 1<<12, NoBorder = 1<<13, OpacityActive = 1<<14, OpacityInactive = 1<<15, Activity = 1<<16, Screen = 1<<17, DesktopFile = 1 << 18, All = 0xffffffff }; Q_DECLARE_FLAGS(Types, Type) // All these values are saved to the cfg file, and are also used in kstart! enum { Unused = 0, DontAffect, // use the default value Force, // force the given value Apply, // apply only after initial mapping Remember, // like apply, and remember the value when the window is withdrawn ApplyNow, // apply immediatelly, then forget the setting ForceTemporarily // apply and force until the window is withdrawn }; enum StringMatch { FirstStringMatch, UnimportantMatch = FirstStringMatch, ExactMatch, SubstringMatch, RegExpMatch, LastStringMatch = RegExpMatch }; void write(KConfigGroup&) const; bool isEmpty() const; #ifndef KCMRULES bool discardUsed(bool withdrawn); bool match(const AbstractClient* c) const; bool update(AbstractClient*, int selection); bool isTemporary() const; bool discardTemporary(bool force); // removes if temporary and forced or too old bool applyPlacement(Placement::Policy& placement) const; bool applyGeometry(QRect& rect, bool init) const; // use 'invalidPoint' with applyPosition, unlike QSize() and QRect(), QPoint() is a valid point bool applyPosition(QPoint& pos, bool init) const; bool applySize(QSize& s, bool init) const; bool applyMinSize(QSize& s) const; bool applyMaxSize(QSize& s) const; bool applyOpacityActive(int& s) const; bool applyOpacityInactive(int& s) const; bool applyIgnoreGeometry(bool& ignore, bool init) const; bool applyDesktop(int& desktop, bool init) const; bool applyScreen(int& desktop, bool init) const; bool applyActivity(QString& activity, bool init) const; bool applyType(NET::WindowType& type) const; bool applyMaximizeVert(MaximizeMode& mode, bool init) const; bool applyMaximizeHoriz(MaximizeMode& mode, bool init) const; bool applyMinimize(bool& minimized, bool init) const; bool applyShade(ShadeMode& shade, bool init) const; bool applySkipTaskbar(bool& skip, bool init) const; bool applySkipPager(bool& skip, bool init) const; bool applySkipSwitcher(bool& skip, bool init) const; bool applyKeepAbove(bool& above, bool init) const; bool applyKeepBelow(bool& below, bool init) const; bool applyFullScreen(bool& fs, bool init) const; bool applyNoBorder(bool& noborder, bool init) const; bool applyDecoColor(QString &schemeFile) const; bool applyBlockCompositing(bool& block) const; bool applyFSP(int& fsp) const; bool applyFPP(int& fpp) const; bool applyAcceptFocus(bool& focus) const; bool applyCloseable(bool& closeable) const; bool applyAutogrouping(bool& autogroup) const; bool applyAutogroupInForeground(bool& fg) const; bool applyAutogroupById(QString& id) const; bool applyStrictGeometry(bool& strict) const; bool applyShortcut(QString& shortcut, bool init) const; bool applyDisableGlobalShortcuts(bool& disable) const; bool applyDesktopFile(QString &desktopFile, bool init) const; private: #endif bool matchType(NET::WindowType match_type) const; bool matchWMClass(const QByteArray& match_class, const QByteArray& match_name) const; bool matchRole(const QByteArray& match_role) const; bool matchTitle(const QString& match_title) const; bool matchClientMachine(const QByteArray& match_machine, bool local) const; enum SetRule { UnusedSetRule = Unused, SetRuleDummy = 256 // so that it's at least short int }; enum ForceRule { UnusedForceRule = Unused, ForceRuleDummy = 256 // so that it's at least short int }; void readFromCfg(const KConfigGroup& cfg); static SetRule readSetRule(const KConfigGroup&, const QString& key); static ForceRule readForceRule(const KConfigGroup&, const QString& key); static NET::WindowType readType(const KConfigGroup&, const QString& key); static QString readDecoColor(const KConfigGroup &cfg); #ifndef KCMRULES static bool checkSetRule(SetRule rule, bool init); static bool checkForceRule(ForceRule rule); static bool checkSetStop(SetRule rule); static bool checkForceStop(ForceRule rule); #endif int temporary_state; // e.g. for kstart QString description; QByteArray wmclass; StringMatch wmclassmatch; bool wmclasscomplete; QByteArray windowrole; StringMatch windowrolematch; QString title; StringMatch titlematch; QByteArray clientmachine; StringMatch clientmachinematch; NET::WindowTypes types; // types for matching Placement::Policy placement; ForceRule placementrule; QPoint position; SetRule positionrule; QSize size; SetRule sizerule; QSize minsize; ForceRule minsizerule; QSize maxsize; ForceRule maxsizerule; int opacityactive; ForceRule opacityactiverule; int opacityinactive; ForceRule opacityinactiverule; bool ignoregeometry; SetRule ignoregeometryrule; int desktop; SetRule desktoprule; int screen; SetRule screenrule; QString activity; SetRule activityrule; NET::WindowType type; // type for setting ForceRule typerule; bool maximizevert; SetRule maximizevertrule; bool maximizehoriz; SetRule maximizehorizrule; bool minimize; SetRule minimizerule; bool shade; SetRule shaderule; bool skiptaskbar; SetRule skiptaskbarrule; bool skippager; SetRule skippagerrule; bool skipswitcher; SetRule skipswitcherrule; bool above; SetRule aboverule; bool below; SetRule belowrule; bool fullscreen; SetRule fullscreenrule; bool noborder; SetRule noborderrule; QString decocolor; ForceRule decocolorrule; bool blockcompositing; ForceRule blockcompositingrule; int fsplevel; int fpplevel; ForceRule fsplevelrule; ForceRule fpplevelrule; bool acceptfocus; ForceRule acceptfocusrule; bool closeable; ForceRule closeablerule; bool autogroup; ForceRule autogrouprule; bool autogroupfg; ForceRule autogroupfgrule; QString autogroupid; ForceRule autogroupidrule; bool strictgeometry; ForceRule strictgeometryrule; QString shortcut; SetRule shortcutrule; bool disableglobalshortcuts; ForceRule disableglobalshortcutsrule; QString desktopfile; SetRule desktopfilerule; friend QDebug& operator<<(QDebug& stream, const Rules*); }; #ifndef KCMRULES class KWIN_EXPORT RuleBook : public QObject { Q_OBJECT public: - virtual ~RuleBook(); + ~RuleBook() override; WindowRules find(const AbstractClient*, bool); void discardUsed(AbstractClient* c, bool withdraw); void setUpdatesDisabled(bool disable); bool areUpdatesDisabled() const; void load(); void edit(AbstractClient* c, bool whole_app); void requestDiskStorage(); void setConfig(const KSharedConfig::Ptr &config) { m_config = config; } private Q_SLOTS: void temporaryRulesMessage(const QString&); void cleanupTemporaryRules(); void save(); private: void deleteAll(); void initWithX11(); QTimer *m_updateTimer; bool m_updatesDisabled; QList m_rules; QScopedPointer m_temporaryRulesMessages; KSharedConfig::Ptr m_config; KWIN_SINGLETON(RuleBook) }; inline bool RuleBook::areUpdatesDisabled() const { return m_updatesDisabled; } inline bool Rules::checkSetRule(SetRule rule, bool init) { if (rule > (SetRule)DontAffect) { // Unused or DontAffect if (rule == (SetRule)Force || rule == (SetRule) ApplyNow || rule == (SetRule) ForceTemporarily || init) return true; } return false; } inline bool Rules::checkForceRule(ForceRule rule) { return rule == (ForceRule)Force || rule == (ForceRule) ForceTemporarily; } inline bool Rules::checkSetStop(SetRule rule) { return rule != UnusedSetRule; } inline bool Rules::checkForceStop(ForceRule rule) { return rule != UnusedForceRule; } inline WindowRules::WindowRules(const QVector< Rules* >& r) : rules(r) { } inline WindowRules::WindowRules() { } inline bool WindowRules::contains(const Rules* rule) const { return rules.contains(const_cast(rule)); } inline void WindowRules::remove(Rules* rule) { rules.removeOne(rule); } #endif QDebug& operator<<(QDebug& stream, const Rules*); } // namespace Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::Rules::Types) #endif diff --git a/scene.h b/scene.h index 47cfca173..b426f2c01 100644 --- a/scene.h +++ b/scene.h @@ -1,689 +1,689 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2006 Lubos Lunak 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_SCENE_H #define KWIN_SCENE_H #include "toplevel.h" #include "utils.h" #include "kwineffects.h" #include #include class QOpenGLFramebufferObject; namespace KWayland { namespace Server { class BufferInterface; class SubSurfaceInterface; } } namespace KWin { namespace Decoration { class DecoratedClientImpl; class Renderer; } class AbstractThumbnailItem; class Deleted; class EffectFrameImpl; class EffectWindowImpl; class OverlayWindow; class Shadow; class WindowPixmap; // The base class for compositing backends. class KWIN_EXPORT Scene : public QObject { Q_OBJECT public: explicit Scene(QObject *parent = nullptr); - virtual ~Scene() = 0; + ~Scene() override = 0; class EffectFrame; class Window; // Returns true if the ctor failed to properly initialize. virtual bool initFailed() const = 0; virtual CompositingType compositingType() const = 0; virtual bool hasPendingFlush() const { return false; } // Repaints the given screen areas, windows provides the stacking order. // The entry point for the main part of the painting pass. // returns the time since the last vblank signal - if there's one // ie. "what of this frame is lost to painting" virtual qint64 paint(QRegion damage, ToplevelList windows) = 0; /** * Adds the Toplevel to the Scene. * * If the toplevel gets deleted, then the scene will try automatically * to re-bind an underlying scene window to the corresponding Deleted. * * @param toplevel The window to be added. * @note You can add a toplevel to scene only once. **/ void addToplevel(Toplevel *toplevel); /** * Removes the Toplevel from the Scene. * * @param toplevel The window to be removed. * @note You can remove a toplevel from the scene only once. **/ void removeToplevel(Toplevel *toplevel); /** * @brief Creates the Scene backend of an EffectFrame. * * @param frame The EffectFrame this Scene::EffectFrame belongs to. **/ virtual Scene::EffectFrame *createEffectFrame(EffectFrameImpl *frame) = 0; /** * @brief Creates the Scene specific Shadow subclass. * * An implementing class has to create a proper instance. It is not allowed to * return @c null. * * @param toplevel The Toplevel for which the Shadow needs to be created. **/ virtual Shadow *createShadow(Toplevel *toplevel) = 0; /** * Method invoked when the screen geometry is changed. * Reimplementing classes should also invoke the parent method * as it takes care of resizing the overlay window. * @param size The new screen geometry size **/ virtual void screenGeometryChanged(const QSize &size); // Flags controlling how painting is done. enum { // Window (or at least part of it) will be painted opaque. PAINT_WINDOW_OPAQUE = 1 << 0, // Window (or at least part of it) will be painted translucent. PAINT_WINDOW_TRANSLUCENT = 1 << 1, // Window will be painted with transformed geometry. PAINT_WINDOW_TRANSFORMED = 1 << 2, // Paint only a region of the screen (can be optimized, cannot // be used together with TRANSFORMED flags). PAINT_SCREEN_REGION = 1 << 3, // Whole screen will be painted with transformed geometry. PAINT_SCREEN_TRANSFORMED = 1 << 4, // At least one window will be painted with transformed geometry. PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS = 1 << 5, // Clear whole background as the very first step, without optimizing it PAINT_SCREEN_BACKGROUND_FIRST = 1 << 6, // PAINT_DECORATION_ONLY = 1 << 7 has been removed // Window will be painted with a lanczos filter. PAINT_WINDOW_LANCZOS = 1 << 8 // PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS_WITHOUT_FULL_REPAINTS = 1 << 9 has been removed }; // types of filtering available enum ImageFilterType { ImageFilterFast, ImageFilterGood }; // there's nothing to paint (adjust time_diff later) virtual void idle(); virtual bool blocksForRetrace() const; virtual bool syncsToVBlank() const; virtual OverlayWindow* overlayWindow() = 0; virtual bool makeOpenGLContextCurrent(); virtual void doneOpenGLContextCurrent(); virtual QMatrix4x4 screenProjectionMatrix() const; /** * Whether the Scene uses an X11 overlay window to perform compositing. **/ virtual bool usesOverlayWindow() const = 0; virtual void triggerFence(); virtual Decoration::Renderer *createDecorationRenderer(Decoration::DecoratedClientImpl *) = 0; /** * Whether the Scene is able to drive animations. * This is used as a hint to the effects system which effects can be supported. * If the Scene performs software rendering it is supposed to return @c false, * if rendering is hardware accelerated it should return @c true. **/ virtual bool animationsSupported() const = 0; /** * The render buffer used by an XRender based compositor scene. * Default implementation returns XCB_RENDER_PICTURE_NONE **/ virtual xcb_render_picture_t xrenderBufferPicture() const; /** * The QPainter used by a QPainter based compositor scene. * Default implementation returns @c nullptr; **/ virtual QPainter *scenePainter() const; /** * The render buffer used by a QPainter based compositor. * Default implementation returns @c nullptr. **/ virtual QImage *qpainterRenderBuffer() const; /** * The backend specific extensions (e.g. EGL/GLX extensions). * * Not the OpenGL (ES) extension! * * Default implementation returns empty list **/ virtual QVector openGLPlatformInterfaceExtensions() const; Q_SIGNALS: void frameRendered(); void resetCompositing(); public Q_SLOTS: // shape/size of a window changed void windowGeometryShapeChanged(KWin::Toplevel* c); // a window has been closed void windowClosed(KWin::Toplevel* c, KWin::Deleted* deleted); protected: virtual Window *createWindow(Toplevel *toplevel) = 0; void createStackingOrder(ToplevelList toplevels); void clearStackingOrder(); // shared implementation, starts painting the screen void paintScreen(int *mask, const QRegion &damage, const QRegion &repaint, QRegion *updateRegion, QRegion *validRegion, const QMatrix4x4 &projection = QMatrix4x4(), const QRect &outputGeometry = QRect()); // Render cursor texture in case hardware cursor is disabled/non-applicable virtual void paintCursor() = 0; friend class EffectsHandlerImpl; // called after all effects had their paintScreen() called void finalPaintScreen(int mask, QRegion region, ScreenPaintData& data); // shared implementation of painting the screen in the generic // (unoptimized) way virtual void paintGenericScreen(int mask, ScreenPaintData data); // shared implementation of painting the screen in an optimized way virtual void paintSimpleScreen(int mask, QRegion region); // paint the background (not the desktop background - the whole background) virtual void paintBackground(QRegion region) = 0; // called after all effects had their paintWindow() called void finalPaintWindow(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data); // shared implementation, starts painting the window virtual void paintWindow(Window* w, int mask, QRegion region, WindowQuadList quads); // called after all effects had their drawWindow() called virtual void finalDrawWindow(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data); // let the scene decide whether it's better to paint more of the screen, eg. in order to allow a buffer swap // the default is NOOP virtual void extendPaintRegion(QRegion ®ion, bool opaqueFullscreen); virtual void paintDesktop(int desktop, int mask, const QRegion ®ion, ScreenPaintData &data); // compute time since the last repaint void updateTimeDiff(); // saved data for 2nd pass of optimized screen painting struct Phase2Data { Window *window = nullptr; QRegion region; QRegion clip; int mask = 0; WindowQuadList quads; }; // The region which actually has been painted by paintScreen() and should be // copied from the buffer to the screen. I.e. the region returned from Scene::paintScreen(). // Since prePaintWindow() can extend areas to paint, these changes would have to propagate // up all the way from paintSimpleScreen() up to paintScreen(), so save them here rather // than propagate them up in arguments. QRegion painted_region; // Additional damage that needs to be repaired to bring a reused back buffer up to date QRegion repaint_region; // The dirty region before it was unioned with repaint_region QRegion damaged_region; // time since last repaint int time_diff; QElapsedTimer last_time; private: void paintWindowThumbnails(Scene::Window *w, QRegion region, qreal opacity, qreal brightness, qreal saturation); void paintDesktopThumbnails(Scene::Window *w); QHash< Toplevel*, Window* > m_windows; // windows in their stacking order QVector< Window* > stacking_order; }; /** * Factory class to create a Scene. Needs to be implemented by the plugins. **/ class KWIN_EXPORT SceneFactory : public QObject { Q_OBJECT public: - virtual ~SceneFactory(); + ~SceneFactory() override; /** * @returns The created Scene, may be @c nullptr. **/ virtual Scene *create(QObject *parent = nullptr) const = 0; protected: explicit SceneFactory(QObject *parent); }; // The base class for windows representations in composite backends class Scene::Window { public: Window(Toplevel* c); virtual ~Window(); // perform the actual painting of the window virtual void performPaint(int mask, QRegion region, WindowPaintData data) = 0; // do any cleanup needed when the window's composite pixmap is discarded void pixmapDiscarded(); int x() const; int y() const; int width() const; int height() const; QRect geometry() const; QPoint pos() const; QSize size() const; QRect rect() const; // access to the internal window class // TODO eventually get rid of this Toplevel* window() const; // should the window be painted bool isPaintingEnabled() const; void resetPaintingEnabled(); // Flags explaining why painting should be disabled enum { // Window will not be painted PAINT_DISABLED = 1 << 0, // Window will not be painted because it is deleted PAINT_DISABLED_BY_DELETE = 1 << 1, // Window will not be painted because of which desktop it's on PAINT_DISABLED_BY_DESKTOP = 1 << 2, // Window will not be painted because it is minimized PAINT_DISABLED_BY_MINIMIZE = 1 << 3, // Window will not be painted because it is not the active window in a client group PAINT_DISABLED_BY_TAB_GROUP = 1 << 4, // Window will not be painted because it's not on the current activity PAINT_DISABLED_BY_ACTIVITY = 1 << 5 }; void enablePainting(int reason); void disablePainting(int reason); // is the window visible at all bool isVisible() const; // is the window fully opaque bool isOpaque() const; // shape of the window const QRegion &shape() const; QRegion clientShape() const; void discardShape(); void updateToplevel(Toplevel* c); // creates initial quad list for the window virtual WindowQuadList buildQuads(bool force = false) const; void updateShadow(Shadow* shadow); const Shadow* shadow() const; Shadow* shadow(); void referencePreviousPixmap(); void unreferencePreviousPixmap(); void invalidateQuadsCache(); protected: WindowQuadList makeQuads(WindowQuadType type, const QRegion& reg, const QPoint &textureOffset = QPoint(0, 0), qreal textureScale = 1.0) const; WindowQuadList makeDecorationQuads(const QRect *rects, const QRegion ®ion, qreal textureScale = 1.0) const; /** * @brief Returns the WindowPixmap for this Window. * * If the WindowPixmap does not yet exist, this method will invoke createWindowPixmap. * If the WindowPixmap is not valid it tries to create it, in case this succeeds the WindowPixmap is * returned. In case it fails, the previous (and still valid) WindowPixmap is returned. * * @note This method can return @c NULL as there might neither be a valid previous nor current WindowPixmap * around. * * The WindowPixmap gets casted to the type passed in as a template parameter. That way this class does not * need to know the actual WindowPixmap subclass used by the concrete Scene implementations. * * @return The WindowPixmap casted to T* or @c NULL if there is no valid window pixmap. **/ template T *windowPixmap(); template T *previousWindowPixmap(); /** * @brief Factory method to create a WindowPixmap. * * The inheriting classes need to implement this method to create a new instance of their WindowPixmap subclass. * @note Do not use WindowPixmap::create on the created instance. The Scene will take care of that. **/ virtual WindowPixmap *createWindowPixmap() = 0; Toplevel* toplevel; ImageFilterType filter; Shadow *m_shadow; private: QScopedPointer m_currentPixmap; QScopedPointer m_previousPixmap; int m_referencePixmapCounter; int disable_painting; mutable QRegion shape_region; mutable bool shape_valid; mutable QScopedPointer cached_quad_list; Q_DISABLE_COPY(Window) }; /** * @brief Wrapper for a pixmap of the Scene::Window. * * This class encapsulates the functionality to get the pixmap for a window. When initialized the pixmap is not yet * mapped to the window and isValid will return @c false. The pixmap mapping to the window can be established * through @ref create. If it succeeds isValid will return @c true, otherwise it will keep in the non valid * state and it can be tried to create the pixmap mapping again (e.g. in the next frame). * * This class is not intended to be updated when the pixmap is no longer valid due to e.g. resizing the window. * Instead a new instance of this class should be instantiated. The idea behind this is that a valid pixmap does not * get destroyed, but can continue to be used. To indicate that a newer pixmap should in generally be around, one can * use markAsDiscarded. * * This class is intended to be inherited for the needs of the compositor backends which need further mapping from * the native pixmap to the respective rendering format. **/ class KWIN_EXPORT WindowPixmap { public: virtual ~WindowPixmap(); /** * @brief Tries to create the mapping between the Window and the pixmap. * * In case this method succeeds in creating the pixmap for the window, isValid will return @c true otherwise * @c false. * * Inheriting classes should re-implement this method in case they need to add further functionality for mapping the * native pixmap to the rendering format. **/ virtual void create(); /** * @return @c true if the pixmap has been created and is valid, @c false otherwise **/ virtual bool isValid() const; /** * @return The native X11 pixmap handle **/ xcb_pixmap_t pixmap() const; /** * @return The Wayland BufferInterface for this WindowPixmap. **/ QPointer buffer() const; const QSharedPointer &fbo() const; /** * @brief Whether this WindowPixmap is considered as discarded. This means the window has changed in a way that a new * WindowPixmap should have been created already. * * @return @c true if this WindowPixmap is considered as discarded, @c false otherwise. * @see markAsDiscarded **/ bool isDiscarded() const; /** * @brief Marks this WindowPixmap as discarded. From now on isDiscarded will return @c true. This method should * only be used by the Window when it changes in a way that a new pixmap is required. * * @see isDiscarded **/ void markAsDiscarded(); /** * The size of the pixmap. **/ const QSize &size() const; /** * The geometry of the Client's content inside the pixmap. In case of a decorated Client the * pixmap also contains the decoration which is not rendered into this pixmap, though. This * contentsRect tells where inside the complete pixmap the real content is. **/ const QRect &contentsRect() const; /** * @brief Returns the Toplevel this WindowPixmap belongs to. * Note: the Toplevel can change over the lifetime of the WindowPixmap in case the Toplevel is copied to Deleted. **/ Toplevel *toplevel() const; /** * @returns the parent WindowPixmap in the sub-surface tree **/ WindowPixmap *parent() const { return m_parent; } /** * @returns the current sub-surface tree **/ QVector children() const { return m_children; } /** * @returns the subsurface this WindowPixmap is for if it is not for a root window **/ QPointer subSurface() const { return m_subSurface; } /** * @returns the surface this WindowPixmap references, might be @c null. **/ KWayland::Server::SurfaceInterface *surface() const; protected: explicit WindowPixmap(Scene::Window *window); explicit WindowPixmap(const QPointer &subSurface, WindowPixmap *parent); virtual WindowPixmap *createChild(const QPointer &subSurface); /** * @return The Window this WindowPixmap belongs to **/ Scene::Window *window(); /** * Should be called by the implementing subclasses when the Wayland Buffer changed and needs * updating. **/ virtual void updateBuffer(); /** * Sets the sub-surface tree to @p children. **/ void setChildren(const QVector &children) { m_children = children; } private: Scene::Window *m_window; xcb_pixmap_t m_pixmap; QSize m_pixmapSize; bool m_discarded; QRect m_contentsRect; QPointer m_buffer; QSharedPointer m_fbo; WindowPixmap *m_parent = nullptr; QVector m_children; QPointer m_subSurface; }; class Scene::EffectFrame { public: EffectFrame(EffectFrameImpl* frame); virtual ~EffectFrame(); virtual void render(QRegion region, double opacity, double frameOpacity) = 0; virtual void free() = 0; virtual void freeIconFrame() = 0; virtual void freeTextFrame() = 0; virtual void freeSelection() = 0; virtual void crossFadeIcon() = 0; virtual void crossFadeText() = 0; protected: EffectFrameImpl* m_effectFrame; }; inline int Scene::Window::x() const { return toplevel->x(); } inline int Scene::Window::y() const { return toplevel->y(); } inline int Scene::Window::width() const { return toplevel->width(); } inline int Scene::Window::height() const { return toplevel->height(); } inline QRect Scene::Window::geometry() const { return toplevel->geometry(); } inline QSize Scene::Window::size() const { return toplevel->size(); } inline QPoint Scene::Window::pos() const { return toplevel->pos(); } inline QRect Scene::Window::rect() const { return toplevel->rect(); } inline Toplevel* Scene::Window::window() const { return toplevel; } inline void Scene::Window::updateToplevel(Toplevel* c) { toplevel = c; } inline const Shadow* Scene::Window::shadow() const { return m_shadow; } inline Shadow* Scene::Window::shadow() { return m_shadow; } inline QPointer WindowPixmap::buffer() const { return m_buffer; } inline const QSharedPointer &WindowPixmap::fbo() const { return m_fbo; } template inline T* Scene::Window::windowPixmap() { if (m_currentPixmap.isNull()) { m_currentPixmap.reset(createWindowPixmap()); } if (m_currentPixmap->isValid()) { return static_cast(m_currentPixmap.data()); } m_currentPixmap->create(); if (m_currentPixmap->isValid()) { return static_cast(m_currentPixmap.data()); } else { return static_cast(m_previousPixmap.data()); } } template inline T* Scene::Window::previousWindowPixmap() { return static_cast(m_previousPixmap.data()); } inline Toplevel* WindowPixmap::toplevel() const { return m_window->window(); } inline xcb_pixmap_t WindowPixmap::pixmap() const { return m_pixmap; } inline bool WindowPixmap::isDiscarded() const { return m_discarded; } inline void WindowPixmap::markAsDiscarded() { m_discarded = true; m_window->referencePreviousPixmap(); } inline const QRect &WindowPixmap::contentsRect() const { return m_contentsRect; } inline const QSize &WindowPixmap::size() const { return m_pixmapSize; } } // namespace Q_DECLARE_INTERFACE(KWin::SceneFactory, "org.kde.kwin.Scene") #endif diff --git a/screenedge.h b/screenedge.h index 22b53a2a5..fd8f83368 100644 --- a/screenedge.h +++ b/screenedge.h @@ -1,591 +1,591 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2011 Arthur Arlt Copyright (C) 2013 Martin Gräßlin Since the functionality provided in this class has been moved from class Workspace, it is not clear who exactly has written the code. The list below contains the copyright holders of the class Workspace. Copyright (C) 1999, 2000 Matthias Ettrich Copyright (C) 2003 Lubos Lunak Copyright (C) 2009 Lucas Murray 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_SCREENEDGE_H #define KWIN_SCREENEDGE_H // KWin #include "kwinglobals.h" // KDE includes #include // Qt #include #include #include #include class QAction; class QMouseEvent; namespace KWin { class AbstractClient; class GestureRecognizer; class ScreenEdges; class SwipeGesture; class KWIN_EXPORT Edge : public QObject { Q_OBJECT public: explicit Edge(ScreenEdges *parent); - virtual ~Edge(); + ~Edge() override; bool isLeft() const; bool isTop() const; bool isRight() const; bool isBottom() const; bool isCorner() const; bool isScreenEdge() const; bool triggersFor(const QPoint &cursorPos) const; bool check(const QPoint &cursorPos, const QDateTime &triggerTime, bool forceNoPushBack = false); void markAsTriggered(const QPoint &cursorPos, const QDateTime &triggerTime); bool isReserved() const; const QRect &approachGeometry() const; ElectricBorder border() const; void reserve(QObject *object, const char *slot); const QHash &callBacks() const; void reserveTouchCallBack(QAction *action); void unreserveTouchCallBack(QAction *action); QVector touchCallBacks() const { return m_touchActions; } void startApproaching(); void stopApproaching(); bool isApproaching() const; void setClient(AbstractClient *client); AbstractClient *client() const; const QRect &geometry() const; void setTouchAction(ElectricBorderAction action); bool activatesForPointer() const; bool activatesForTouchGesture() const; /** * The window id of the native window representing the edge. * Default implementation returns @c 0, which means no window. **/ virtual quint32 window() const; /** * The approach window is a special window to notice when get close to the screen border but * not yet triggering the border. * * The default implementation returns @c 0, which means no window. **/ virtual quint32 approachWindow() const; public Q_SLOTS: void reserve(); void unreserve(); void unreserve(QObject *object); void setBorder(ElectricBorder border); void setAction(ElectricBorderAction action); void setGeometry(const QRect &geometry); void updateApproaching(const QPoint &point); void checkBlocking(); Q_SIGNALS: void approaching(ElectricBorder border, qreal factor, const QRect &geometry); void activatesForTouchGestureChanged(); protected: ScreenEdges *edges(); const ScreenEdges *edges() const; bool isBlocked() const; virtual void doGeometryUpdate(); virtual void doActivate(); virtual void doDeactivate(); virtual void doStartApproaching(); virtual void doStopApproaching(); virtual void doUpdateBlocking(); private: void activate(); void deactivate(); bool canActivate(const QPoint &cursorPos, const QDateTime &triggerTime); void handle(const QPoint &cursorPos); bool handleAction(ElectricBorderAction action); bool handlePointerAction() { return handleAction(m_action); } bool handleTouchAction() { return handleAction(m_touchAction); } bool handleByCallback(); void handleTouchCallback(); void switchDesktop(const QPoint &cursorPos); void pushCursorBack(const QPoint &cursorPos); ScreenEdges *m_edges; ElectricBorder m_border; ElectricBorderAction m_action; ElectricBorderAction m_touchAction = ElectricActionNone; int m_reserved; QRect m_geometry; QRect m_approachGeometry; QDateTime m_lastTrigger; QDateTime m_lastReset; QPoint m_triggeredPoint; QHash m_callBacks; bool m_approaching; int m_lastApproachingFactor; bool m_blocked; bool m_pushBackBlocked; AbstractClient *m_client; SwipeGesture *m_gesture; QVector m_touchActions; }; /** * @short Class for controlling screen edges. * * The screen edge functionality is split into three parts: * @li This manager class ScreenEdges * @li abstract class @ref Edge * @li specific implementation of @ref Edge, e.g. WindowBasedEdge * * The ScreenEdges creates an @ref Edge for each screen edge which is also an edge in the * combination of all screens. E.g. if there are two screens, no Edge is created between the screens, * but at all other edges even if the screens have a different dimension. * * In addition at each corner of the overall display geometry an one-pixel large @ref Edge is * created. No matter how many screens there are, there will only be exactly four of these corner * edges. This is motivated by Fitts's Law which show that it's easy to trigger such a corner, but * it would be very difficult to trigger a corner between two screens (one pixel target not visually * outlined). * * The ScreenEdges are used for one of the following functionality: * @li switch virtual desktop (see property @ref desktopSwitching) * @li switch virtual desktop when moving a window (see property @ref desktopSwitchingMovingClients) * @li trigger a pre-defined action (see properties @ref actionTop and similar) * @li trigger an externally configured action (e.g. Effect, Script, see @ref reserve, @ref unreserve) * * An @ref Edge is only active if there is at least one of the possible actions "reserved" for this * edge. The idea is to not block the screen edge if nothing could be triggered there, so that the * user e.g. can configure nothing on the top edge, which tends to interfere with full screen apps * having a hidden panel there. On X11 (currently only supported backend) the @ref Edge is * represented by a WindowBasedEdge which creates an input only window for the geometry and * reacts on enter notify events. If the edge gets reserved for the first time a window is created * and mapped, once the edge gets unreserved again, the window gets destroyed. * * When the mouse enters one of the screen edges the following values are used to determine whether * the action should be triggered or the cursor be pushed back * @li Time difference between two entering events is not larger than a certain threshold * @li Time difference between two entering events is larger than @ref timeThreshold * @li Time difference between two activations is larger than @ref reActivateThreshold * @li Distance between two enter events is not larger than a defined pixel distance * These checks are performed in @ref Edge * * @todo change way how Effects/Scripts can reserve an edge and are notified. **/ class KWIN_EXPORT ScreenEdges : public QObject { Q_OBJECT Q_PROPERTY(bool desktopSwitching READ isDesktopSwitching) Q_PROPERTY(bool desktopSwitchingMovingClients READ isDesktopSwitchingMovingClients) Q_PROPERTY(QSize cursorPushBackDistance READ cursorPushBackDistance) Q_PROPERTY(int timeThreshold READ timeThreshold) Q_PROPERTY(int reActivateThreshold READ reActivationThreshold) Q_PROPERTY(int actionTopLeft READ actionTopLeft) Q_PROPERTY(int actionTop READ actionTop) Q_PROPERTY(int actionTopRight READ actionTopRight) Q_PROPERTY(int actionRight READ actionRight) Q_PROPERTY(int actionBottomRight READ actionBottomRight) Q_PROPERTY(int actionBottom READ actionBottom) Q_PROPERTY(int actionBottomLeft READ actionBottomLeft) Q_PROPERTY(int actionLeft READ actionLeft) public: - virtual ~ScreenEdges(); + ~ScreenEdges() override; /** * @internal **/ void setConfig(KSharedConfig::Ptr config); /** * Initialize the screen edges. * @internal **/ void init(); /** * Check, if a screen edge is entered and trigger the appropriate action * if one is enabled for the current region and the timeout is satisfied * @param pos the position of the mouse pointer * @param now the time when the function is called * @param forceNoPushBack needs to be called to workaround some DnD clients, don't use unless you want to chek on a DnD event **/ void check(const QPoint& pos, const QDateTime &now, bool forceNoPushBack = false); /** * The (dpi dependent) length, reserved for the active corners of each edge - 1/3" **/ int cornerOffset() const; /** * Mark the specified screen edge as reserved. This method is provided for external activation * like effects and scripts. When the effect/script does no longer need the edge it is supposed * to call @ref unreserve. * @param border the screen edge to mark as reserved * @param object The object on which the @p callback needs to be invoked * @param callback The method name to be invoked - uses QMetaObject::invokeMethod * @see unreserve * @todo: add pointer to script/effect **/ void reserve(ElectricBorder border, QObject *object, const char *callback); /** * Mark the specified screen edge as unreserved. This method is provided for external activation * like effects and scripts. This method is only allowed to be called if @ref reserve had been * called before for the same @p border. An unbalanced calling of reserve/unreserve leads to the * edge never being active or never being able to deactivate again. * @param border the screen edge to mark as unreserved * @param object the object on which the callback had been invoked * @see reserve * @todo: add pointer to script/effect **/ void unreserve(ElectricBorder border, QObject *object); /** * Reserves an edge for the @p client. The idea behind this is to show the @p client if the * screen edge which the @p client borders gets triggered. * * When first called it is tried to create an Edge for the client. This is only done if the * client borders with a screen edge specified by @p border. If the client doesn't border the * screen edge, no Edge gets created and the client is shown again. Otherwise there would not * be a possibility to show the client again. * * On subsequent calls for the client no new Edge is created, but the existing one gets reused * and if the client is already hidden, the Edge gets reserved. * * Once the Edge for the client triggers, the client gets shown again and the Edge unreserved. * The idea is that the Edge can only get activated if the client is currently hidden. * * To make sure that the client can always be shown again the implementation also starts to * track geometry changes and shows the Client again. The same for screen geometry changes. * * The Edge gets automatically destroyed if the client gets released. * @param client The Client for which an Edge should be reserved * @param border The border which the client wants to use, only proper borders are supported (no corners) **/ void reserve(KWin::AbstractClient *client, ElectricBorder border); /** * Mark the specified screen edge as reserved for touch gestures. This method is provided for * external activation like effects and scripts. * When the effect/script does no longer need the edge it is supposed * to call @ref unreserveTouch. * @param border the screen edge to mark as reserved * @param action The action which gets triggered * @see unreserveTouch * @since 5.10 **/ void reserveTouch(ElectricBorder border, QAction *action); /** * Unreserves the specified @p border from activating the @p action for touch gestures. * @see reserveTouch * @since 5.10 **/ void unreserveTouch(ElectricBorder border, QAction *action); /** * Reserve desktop switching for screen edges, if @p isToReserve is @c true. Unreserve otherwise. * @param isToReserve indicated whether desktop switching should be reserved or unreseved * @param o Qt orientations **/ void reserveDesktopSwitching(bool isToReserve, Qt::Orientations o); /** * Raise electric border windows to the real top of the screen. We only need * to do this if an effect input window is active. **/ void ensureOnTop(); bool isEntered(QMouseEvent *event); /** * Returns a QVector of all existing screen edge windows * @return all existing screen edge windows in a QVector **/ QVector< xcb_window_t > windows() const; bool isDesktopSwitching() const; bool isDesktopSwitchingMovingClients() const; const QSize &cursorPushBackDistance() const; /** * Minimum time between the push back of the cursor and the activation by re-entering the edge. **/ int timeThreshold() const; /** * Minimum time between triggers **/ int reActivationThreshold() const; ElectricBorderAction actionTopLeft() const; ElectricBorderAction actionTop() const; ElectricBorderAction actionTopRight() const; ElectricBorderAction actionRight() const; ElectricBorderAction actionBottomRight() const; ElectricBorderAction actionBottom() const; ElectricBorderAction actionBottomLeft() const; ElectricBorderAction actionLeft() const; GestureRecognizer *gestureRecognizer() const { return m_gestureRecognizer; } bool handleDndNotify(xcb_window_t window, const QPoint &point); bool handleEnterNotifiy(xcb_window_t window, const QPoint &point, const QDateTime ×tamp); public Q_SLOTS: void reconfigure(); /** * Updates the layout of virtual desktops and adjust the reserved borders in case of * virtual desktop switching on edges. **/ void updateLayout(); /** * Recreates all edges e.g. after the screen size changes. **/ void recreateEdges(); Q_SIGNALS: /** * Signal emitted during approaching of mouse towards @p border. The @p factor indicates how * far away the mouse is from the approaching area. The values are clamped into [0.0,1.0] with * @c 0.0 meaning far away from the border, @c 1.0 in trigger distance. **/ void approaching(ElectricBorder border, qreal factor, const QRect &geometry); void checkBlocking(); private: enum { ElectricDisabled = 0, ElectricMoveOnly = 1, ElectricAlways = 2 }; void setDesktopSwitching(bool enable); void setDesktopSwitchingMovingClients(bool enable); void setCursorPushBackDistance(const QSize &distance); void setTimeThreshold(int threshold); void setReActivationThreshold(int threshold); void createHorizontalEdge(ElectricBorder border, const QRect &screen, const QRect &fullArea); void createVerticalEdge(ElectricBorder border, const QRect &screen, const QRect &fullArea); Edge *createEdge(ElectricBorder border, int x, int y, int width, int height, bool createAction = true); void setActionForBorder(ElectricBorder border, ElectricBorderAction *oldValue, ElectricBorderAction newValue); void setActionForTouchBorder(ElectricBorder border, ElectricBorderAction newValue); ElectricBorderAction actionForEdge(Edge *edge) const; ElectricBorderAction actionForTouchEdge(Edge *edge) const; void createEdgeForClient(AbstractClient *client, ElectricBorder border); void deleteEdgeForClient(AbstractClient *client); bool m_desktopSwitching; bool m_desktopSwitchingMovingClients; QSize m_cursorPushBackDistance; int m_timeThreshold; int m_reactivateThreshold; Qt::Orientations m_virtualDesktopLayout; QList m_edges; KSharedConfig::Ptr m_config; ElectricBorderAction m_actionTopLeft; ElectricBorderAction m_actionTop; ElectricBorderAction m_actionTopRight; ElectricBorderAction m_actionRight; ElectricBorderAction m_actionBottomRight; ElectricBorderAction m_actionBottom; ElectricBorderAction m_actionBottomLeft; ElectricBorderAction m_actionLeft; QMap m_touchActions; int m_cornerOffset; GestureRecognizer *m_gestureRecognizer; KWIN_SINGLETON(ScreenEdges) }; /********************************************************** * Inlines Edge *********************************************************/ inline bool Edge::isBottom() const { return m_border == ElectricBottom || m_border == ElectricBottomLeft || m_border == ElectricBottomRight; } inline bool Edge::isLeft() const { return m_border == ElectricLeft || m_border == ElectricTopLeft || m_border == ElectricBottomLeft; } inline bool Edge::isRight() const { return m_border == ElectricRight || m_border == ElectricTopRight || m_border == ElectricBottomRight; } inline bool Edge::isTop() const { return m_border == ElectricTop || m_border == ElectricTopLeft || m_border == ElectricTopRight; } inline bool Edge::isCorner() const { return m_border == ElectricTopLeft || m_border == ElectricTopRight || m_border == ElectricBottomRight || m_border == ElectricBottomLeft; } inline bool Edge::isScreenEdge() const { return m_border == ElectricLeft || m_border == ElectricRight || m_border == ElectricTop || m_border == ElectricBottom; } inline bool Edge::isReserved() const { return m_reserved != 0; } inline void Edge::setAction(ElectricBorderAction action) { m_action = action; } inline ScreenEdges *Edge::edges() { return m_edges; } inline const ScreenEdges *Edge::edges() const { return m_edges; } inline const QRect &Edge::geometry() const { return m_geometry; } inline const QRect &Edge::approachGeometry() const { return m_approachGeometry; } inline ElectricBorder Edge::border() const { return m_border; } inline const QHash< QObject *, QByteArray > &Edge::callBacks() const { return m_callBacks; } inline bool Edge::isBlocked() const { return m_blocked; } inline AbstractClient *Edge::client() const { return m_client; } inline bool Edge::isApproaching() const { return m_approaching; } /********************************************************** * Inlines ScreenEdges *********************************************************/ inline void ScreenEdges::setConfig(KSharedConfig::Ptr config) { m_config = config; } inline int ScreenEdges::cornerOffset() const { return m_cornerOffset; } inline const QSize &ScreenEdges::cursorPushBackDistance() const { return m_cursorPushBackDistance; } inline bool ScreenEdges::isDesktopSwitching() const { return m_desktopSwitching; } inline bool ScreenEdges::isDesktopSwitchingMovingClients() const { return m_desktopSwitchingMovingClients; } inline int ScreenEdges::reActivationThreshold() const { return m_reactivateThreshold; } inline int ScreenEdges::timeThreshold() const { return m_timeThreshold; } inline void ScreenEdges::setCursorPushBackDistance(const QSize &distance) { m_cursorPushBackDistance = distance; } inline void ScreenEdges::setDesktopSwitching(bool enable) { if (enable == m_desktopSwitching) { return; } m_desktopSwitching = enable; reserveDesktopSwitching(enable, m_virtualDesktopLayout); } inline void ScreenEdges::setDesktopSwitchingMovingClients(bool enable) { m_desktopSwitchingMovingClients = enable; } inline void ScreenEdges::setReActivationThreshold(int threshold) { Q_ASSERT(threshold >= m_timeThreshold); m_reactivateThreshold = threshold; } inline void ScreenEdges::setTimeThreshold(int threshold) { m_timeThreshold = threshold; } #define ACTION( name ) \ inline ElectricBorderAction ScreenEdges::name() const \ { \ return m_##name; \ } ACTION(actionTopLeft) ACTION(actionTop) ACTION(actionTopRight) ACTION(actionRight) ACTION(actionBottomRight) ACTION(actionBottom) ACTION(actionBottomLeft) ACTION(actionLeft) #undef ACTION } #endif // KWIN_SCREENEDGE_H diff --git a/screenlockerwatcher.h b/screenlockerwatcher.h index 02aa68ba2..59b7d3add 100644 --- a/screenlockerwatcher.h +++ b/screenlockerwatcher.h @@ -1,63 +1,63 @@ /******************************************************************** 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_SCREENLOCKERWATCHER_H #define KWIN_SCREENLOCKERWATCHER_H #include #include class OrgFreedesktopScreenSaverInterface; class OrgKdeScreensaverInterface; class QDBusServiceWatcher; class QDBusPendingCallWatcher; namespace KWin { class KWIN_EXPORT ScreenLockerWatcher : public QObject { Q_OBJECT public: - virtual ~ScreenLockerWatcher(); + ~ScreenLockerWatcher() override; bool isLocked() const { return m_locked; } Q_SIGNALS: void locked(bool locked); void aboutToLock(); private Q_SLOTS: void setLocked(bool activated); void activeQueried(QDBusPendingCallWatcher *watcher); void serviceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner); void serviceRegisteredQueried(); void serviceOwnerQueried(); private: void initialize(); OrgFreedesktopScreenSaverInterface *m_interface = nullptr; OrgKdeScreensaverInterface *m_kdeInterface = nullptr; QDBusServiceWatcher *m_serviceWatcher; bool m_locked; KWIN_SINGLETON(ScreenLockerWatcher) }; } #endif diff --git a/screens.h b/screens.h index 9b5532968..a92d96f4b 100644 --- a/screens.h +++ b/screens.h @@ -1,255 +1,255 @@ /******************************************************************** 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(); + ~Screens() override; /** * @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 highest scale() of all connected screens * for use when deciding what scale to load global assets at * Similar to QGuiApplication::scale * @see scale **/ qreal maxScale() const; /** * 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 @ref 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(); /** * Emitted when the maximum scale of all attached screens changes * @see maxScale **/ void maxScaleChanged(); 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; qreal m_maxScale; KWIN_SINGLETON(Screens) }; 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/scripting/dbuscall.h b/scripting/dbuscall.h index febee1ea8..9d3a4a0af 100644 --- a/scripting/dbuscall.h +++ b/scripting/dbuscall.h @@ -1,147 +1,147 @@ /******************************************************************** 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_DBUSCALL_H #define KWIN_DBUSCALL_H #include #include namespace KWin { /** * @brief Qml export for providing a wrapper for sending a message over the DBus * session bus. * * Allows to setup the connection arguments just like in QDBusMessage and supports * adding arguments to the call. To invoke the message use the slot @ref call. * * If the call succeeds the signal @ref finished is emitted, if the call fails * the signal @ref failed is emitted. * * Note: the DBusCall always uses the session bus and performs an async call. * * Example on how to use in Qml: * @code * DBusCall { * id: dbus * service: "org.kde.KWin" * path: "/KWin" * method: "nextDesktop" * Component.onCompleted: dbus.call() * } * @endcode * * Example with arguments: * @code * DBusCall { * id: dbus * service: "org.kde.KWin" * path: "/KWin" * method: "setCurrentDesktop" * arguments: [1] * Component.onCompleted: dbus.call() * } * @endcode * * Example with a callback: * @code * DBusCall { * id: dbus * service: "org.kde.KWin" * path: "/KWin" * method: "currentDesktop" * onFinished: console.log(returnValue[0]) * } * @endcode **/ class DBusCall : public QObject { Q_OBJECT Q_PROPERTY(QString service READ service WRITE setService NOTIFY serviceChanged) Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged) Q_PROPERTY(QString dbusInterface READ interface WRITE setInterface NOTIFY interfaceChanged) Q_PROPERTY(QString method READ method WRITE setMethod NOTIFY methodChanged) Q_PROPERTY(QVariantList arguments READ arguments WRITE setArguments NOTIFY argumentsChanged) public: explicit DBusCall(QObject* parent = 0); - virtual ~DBusCall(); + ~DBusCall() override; const QString &service() const; const QString &path() const; const QString &interface() const; const QString &method() const; const QVariantList &arguments() const; public Q_SLOTS: void call(); void setService(const QString &service); void setPath(const QString &path); void setInterface(const QString &interface); void setMethod(const QString &method); void setArguments(const QVariantList &arguments); Q_SIGNALS: void finished(QVariantList returnValue); void failed(); void serviceChanged(); void pathChanged(); void interfaceChanged(); void methodChanged(); void argumentsChanged(); private: QString m_service; QString m_path; QString m_interface; QString m_method; QVariantList m_arguments; }; #define GENERIC_WRAPPER(type, name, upperName) \ inline type DBusCall::name() const \ { \ return m_##name; \ }\ inline void DBusCall::set##upperName(type name) \ {\ if (m_##name == name) { \ return; \ } \ m_##name = name; \ emit name##Changed(); \ } #define WRAPPER(name, upperName) \ GENERIC_WRAPPER(const QString&, name, upperName) WRAPPER(interface, Interface) WRAPPER(method, Method) WRAPPER(path, Path) WRAPPER(service, Service) GENERIC_WRAPPER(const QVariantList &, arguments, Arguments) #undef WRAPPER #undef GENERIC_WRAPPER } // KWin #endif // KWIN_SCRIPTING_DBUSCALL_H diff --git a/scripting/genericscriptedconfig.h b/scripting/genericscriptedconfig.h index 0ba73476a..8d123c63c 100644 --- a/scripting/genericscriptedconfig.h +++ b/scripting/genericscriptedconfig.h @@ -1,99 +1,99 @@ /* * 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_GENERICSCRIPTEDCONFIG_H #define KWIN_GENERICSCRIPTEDCONFIG_H #include #include #include class KLocalizedTranslator; namespace KWin { class GenericScriptedConfigFactory : public KPluginFactory { Q_OBJECT Q_PLUGIN_METADATA(IID "org.kde.KPluginFactory" FILE "genericscriptedconfig.json" ) Q_INTERFACES(KPluginFactory) protected: QObject *create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &args, const QString &keyword) override; }; class GenericScriptedConfig : public KCModule { Q_OBJECT public: GenericScriptedConfig(const QString &componentName, const QString &keyword, QWidget *parent, const QVariantList &args); - virtual ~GenericScriptedConfig(); + ~GenericScriptedConfig() override; public Q_SLOTS: - virtual void save(); + void save() override; protected: const QString &packageName() const; void createUi(); virtual QString typeName() const = 0; virtual KConfigGroup configGroup() = 0; virtual void reload(); private: QString m_packageName; KLocalizedTranslator *m_translator; }; class ScriptedEffectConfig : public GenericScriptedConfig { Q_OBJECT public: ScriptedEffectConfig(const QString &componentName, const QString &keyword, QWidget *parent, const QVariantList &args); - virtual ~ScriptedEffectConfig(); + ~ScriptedEffectConfig() override; protected: - virtual QString typeName() const; - virtual KConfigGroup configGroup(); - virtual void reload(); + QString typeName() const override; + KConfigGroup configGroup() override; + void reload() override; }; class ScriptingConfig : public GenericScriptedConfig { Q_OBJECT public: ScriptingConfig(const QString &componentName, const QString &keyword, QWidget *parent, const QVariantList &args); - virtual ~ScriptingConfig(); + ~ScriptingConfig() override; protected: - virtual QString typeName() const; - virtual KConfigGroup configGroup(); - virtual void reload(); + QString typeName() const override; + KConfigGroup configGroup() override; + void reload() override; }; inline const QString &GenericScriptedConfig::packageName() const { return m_packageName; } } #endif // KWIN_GENERICSCRIPTEDCONFIG_H diff --git a/scripting/screenedgeitem.h b/scripting/screenedgeitem.h index 58e44aecb..324223af8 100644 --- a/scripting/screenedgeitem.h +++ b/scripting/screenedgeitem.h @@ -1,126 +1,126 @@ /******************************************************************** 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_SCREENEDGEITEM_H #define KWIN_SCREENEDGEITEM_H #include #include class QAction; namespace KWin { /** * @brief Qml export for reserving a Screen Edge. * * The edge is controlled by the @c enabled property and the @c edge * property. If the edge is enabled and gets triggered the @ref activated() * signal gets emitted. * * Example usage: * @code * ScreenEdgeItem { * edge: ScreenEdgeItem.LeftEdge * onActivated: doSomething() * } * @endcode **/ class ScreenEdgeItem : public QObject { Q_OBJECT Q_ENUMS(Edge) Q_ENUMS(Mode) /** * @brief Whether the edge is currently enabled, that is reserved. Default value is @c true. **/ Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) /** * @brief Which of the screen edges is to be reserved. Default value is @c NoEdge. **/ Q_PROPERTY(Edge edge READ edge WRITE setEdge NOTIFY edgeChanged) /** * @brief The operation mode for this edge. Default value is @c Mode::Pointer **/ Q_PROPERTY(Mode mode READ mode WRITE setMode NOTIFY modeChanged) public: enum Edge { TopEdge, TopRightEdge, RightEdge, BottomRightEdge, BottomEdge, BottomLeftEdge, LeftEdge, TopLeftEdge, EDGE_COUNT, NoEdge }; /** * Enum describing the operation modes of the edge. **/ enum class Mode { Pointer, Touch }; explicit ScreenEdgeItem(QObject *parent = 0); - virtual ~ScreenEdgeItem(); + ~ScreenEdgeItem() override; bool isEnabled() const; Edge edge() const; Mode mode() const { return m_mode; } public Q_SLOTS: void setEnabled(bool enabled); void setEdge(Edge edge); void setMode(Mode mode); Q_SIGNALS: void enabledChanged(); void edgeChanged(); void modeChanged(); void activated(); private Q_SLOTS: bool borderActivated(ElectricBorder edge); private: void enableEdge(); void disableEdge(); bool m_enabled; Edge m_edge; Mode m_mode = Mode::Pointer; QAction *m_action; }; inline bool ScreenEdgeItem::isEnabled() const { return m_enabled; } inline ScreenEdgeItem::Edge ScreenEdgeItem::edge() const { return m_edge; } } // namespace KWin #endif // KWIN_SCREENEDGEITEM_H diff --git a/scripting/scriptedeffect.h b/scripting/scriptedeffect.h index 9eb8027dd..a98050d4b 100644 --- a/scripting/scriptedeffect.h +++ b/scripting/scriptedeffect.h @@ -1,167 +1,167 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2012 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_SCRIPTEDEFFECT_H #define KWIN_SCRIPTEDEFFECT_H #include class KConfigLoader; class KPluginMetaData; class QScriptEngine; class QScriptValue; namespace KWin { class KWIN_EXPORT ScriptedEffect : public KWin::AnimationEffect { Q_OBJECT Q_ENUMS(DataRole) Q_ENUMS(Qt::Axis) Q_ENUMS(Anchor) Q_ENUMS(MetaType) Q_ENUMS(EasingCurve) /** * True if we are the active fullscreen effect **/ Q_PROPERTY(bool isActiveFullScreenEffect READ isActiveFullScreenEffect NOTIFY isActiveFullScreenEffectChanged) public: // copied from kwineffects.h enum DataRole { // Grab roles are used to force all other animations to ignore the window. // The value of the data is set to the Effect's `this` value. WindowAddedGrabRole = 1, WindowClosedGrabRole, WindowMinimizedGrabRole, WindowUnminimizedGrabRole, WindowForceBlurRole, ///< For fullscreen effects to enforce blurring of windows, WindowBlurBehindRole, ///< For single windows to blur behind WindowForceBackgroundContrastRole, ///< For fullscreen effects to enforce the background contrast, WindowBackgroundContrastRole, ///< For single windows to enable Background contrast LanczosCacheRole }; enum EasingCurve { GaussianCurve = 128 }; const QString &scriptFile() const { return m_scriptFile; } - virtual void reconfigure(ReconfigureFlags flags); + void reconfigure(ReconfigureFlags flags) override; int requestedEffectChainPosition() const override { return m_chainPosition; } QString activeConfig() const; void setActiveConfig(const QString &name); static ScriptedEffect *create(const QString &effectName, const QString &pathToScript, int chainPosition); static ScriptedEffect *create(const KPluginMetaData &effect); static bool supported(); - virtual ~ScriptedEffect(); + ~ScriptedEffect() override; /** * Whether another effect has grabbed the @p w with the given @p grabRole. * @param w The window to check * @param grabRole The grab role to check * @returns @c true if another window has grabbed the effect, @c false otherwise **/ Q_SCRIPTABLE bool isGrabbed(KWin::EffectWindow *w, DataRole grabRole); /** * Grabs the window with the specified role. * * @param w The window. * @param grabRole The grab role. * @param force By default, if the window is already grabbed by another effect, * then that window won't be grabbed by effect that called this method. If you * would like to grab a window even if it's grabbed by another effect, then * pass @c true. * @returns @c true if the window was grabbed successfully, otherwise @c false. **/ Q_SCRIPTABLE bool grab(KWin::EffectWindow *w, DataRole grabRole, bool force = false); /** * Ungrabs the window with the specified role. * * @param w The window. * @param grabRole The grab role. * @returns @c true if the window was ungrabbed successfully, otherwise @c false. **/ Q_SCRIPTABLE bool ungrab(KWin::EffectWindow *w, DataRole grabRole); /** * Reads the value from the configuration data for the given key. * @param key The key to search for * @param defaultValue The value to return if the key is not found * @returns The config value if present **/ Q_SCRIPTABLE QVariant readConfig(const QString &key, const QVariant defaultValue = QVariant()); void registerShortcut(QAction *a, QScriptValue callback); const QHash &shortcutCallbacks() const { return m_shortcutCallbacks; } QHash > &screenEdgeCallbacks() { return m_screenEdgeCallbacks; } bool isActiveFullScreenEffect() const; bool registerTouchScreenCallback(int edge, QScriptValue callback); bool unregisterTouchScreenCallback(int edge); public Q_SLOTS: //curve should be of type QEasingCurve::type or ScriptedEffect::EasingCurve quint64 animate(KWin::EffectWindow *w, Attribute a, int ms, KWin::FPx2 to, KWin::FPx2 from = KWin::FPx2(), uint metaData = 0, int curve = QEasingCurve::Linear, int delay = 0, bool fullScreen = false, bool keepAlive = true); quint64 set(KWin::EffectWindow *w, Attribute a, int ms, KWin::FPx2 to, KWin::FPx2 from = KWin::FPx2(), uint metaData = 0, int curve = QEasingCurve::Linear, int delay = 0, bool fullScreen = false, bool keepAlive = true); bool retarget(quint64 animationId, KWin::FPx2 newTarget, int newRemainingTime = -1); bool redirect(quint64 animationId, Direction direction, TerminationFlags terminationFlags = TerminateAtSource); bool complete(quint64 animationId); bool cancel(quint64 animationId) { return AnimationEffect::cancel(animationId); } - virtual bool borderActivated(ElectricBorder border); + bool borderActivated(ElectricBorder border) override; Q_SIGNALS: /** * Signal emitted whenever the effect's config changed. **/ void configChanged(); void animationEnded(KWin::EffectWindow *w, quint64 animationId); void isActiveFullScreenEffectChanged(); protected: ScriptedEffect(); QScriptEngine *engine() const; bool init(const QString &effectName, const QString &pathToScript); - void animationEnded(KWin::EffectWindow *w, Attribute a, uint meta); + void animationEnded(KWin::EffectWindow *w, Attribute a, uint meta) override; private Q_SLOTS: void signalHandlerException(const QScriptValue &value); void globalShortcutTriggered(); private: QScriptEngine *m_engine; QString m_effectName; QString m_scriptFile; QHash m_shortcutCallbacks; QHash > m_screenEdgeCallbacks; KConfigLoader *m_config; int m_chainPosition; QHash m_touchScreenEdgeCallbacks; Effect *m_activeFullScreenEffect = nullptr; }; } #endif // KWIN_SCRIPTEDEFFECT_H diff --git a/scripting/scripting.h b/scripting/scripting.h index 3900451ba..7f467af14 100644 --- a/scripting/scripting.h +++ b/scripting/scripting.h @@ -1,432 +1,432 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2010 Rohan Prabhu Copyright (C) 2011 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_SCRIPTING_H #define KWIN_SCRIPTING_H #include #include #include #include #include #include #include #include class QQmlComponent; class QQmlContext; class QQmlEngine; class QAction; class QDBusPendingCallWatcher; class QGraphicsScene; class QMenu; class QMutex; class QScriptEngine; class QScriptValue; class QQuickWindow; class KConfigGroup; /// @c true == javascript, @c false == qml typedef QList< QPair > > LoadScriptList; namespace KWin { class AbstractClient; class Client; class ScriptUnloaderAgent; class QtScriptWorkspaceWrapper; class KWIN_EXPORT AbstractScript : public QObject { Q_OBJECT public: AbstractScript(int id, QString scriptName, QString pluginName, QObject *parent = nullptr); - ~AbstractScript(); + ~AbstractScript() override; QString fileName() const { return m_fileName; } const QString &pluginName() { return m_pluginName; } void printMessage(const QString &message); void registerShortcut(QAction *a, QScriptValue callback); /** * @brief Registers the given @p callback to be invoked whenever the UserActionsMenu is about * to be showed. In the callback the script can create a further sub menu or menu entry to be * added to the UserActionsMenu. * * @param callback Script method to execute when the UserActionsMenu is about to be shown. * @return void * @see actionsForUserActionMenu **/ void registerUseractionsMenuCallback(QScriptValue callback); /** * @brief Creates actions for the UserActionsMenu by invoking the registered callbacks. * * This method invokes all the callbacks previously registered with registerUseractionsMenuCallback. * The Client @p c is passed in as an argument to the invoked method. * * The invoked method is supposed to return a JavaScript object containing either the menu or * menu entry to be added. In case the callback returns a null or undefined or any other invalid * value, it is not considered for adding to the menu. * * The JavaScript object structure for a menu entry looks like the following: * @code * { * title: "My Menu Entry", * checkable: true, * checked: false, * triggered: function (action) { * // callback when the menu entry is triggered with the QAction as argument * } * } * @endcode * * To construct a complete Menu the JavaScript object looks like the following: * @code * { * title: "My Menu Title", * items: [{...}, {...}, ...] // list of menu entries as described above * } * @endcode * * The returned JavaScript object is introspected and for a menu entry a QAction is created, * while for a menu a QMenu is created and QActions for the individual entries. Of course it * is allowed to have nested structures. * * All created objects are (grand) children to the passed in @p parent menu, so that they get * deleted whenever the menu is destroyed. * * @param c The Client for which the menu is invoked, passed to the callback * @param parent The Parent for the created Menus or Actions * @return QList< QAction* > List of QActions obtained from asking the registered callbacks * @see registerUseractionsMenuCallback **/ QList actionsForUserActionMenu(AbstractClient *c, QMenu *parent); KConfigGroup config() const; const QHash &shortcutCallbacks() const { return m_shortcutCallbacks; } QHash > &screenEdgeCallbacks() { return m_screenEdgeCallbacks; } int registerCallback(QScriptValue value); public Q_SLOTS: Q_SCRIPTABLE void stop(); Q_SCRIPTABLE virtual void run() = 0; void slotPendingDBusCall(QDBusPendingCallWatcher *watcher); private Q_SLOTS: void globalShortcutTriggered(); bool borderActivated(ElectricBorder edge); /** * @brief Slot invoked when a menu action is destroyed. Used to remove the action and callback * from the map of actions. * * @param object The destroyed action **/ void actionDestroyed(QObject *object); Q_SIGNALS: Q_SCRIPTABLE void print(const QString &text); void runningChanged(bool); protected: bool running() const { return m_running; } void setRunning(bool running) { if (m_running == running) { return; } m_running = running; emit runningChanged(m_running); } int scriptId() const { return m_scriptId; } private: /** * @brief Parses the @p value to either a QMenu or QAction. * * @param value The ScriptValue describing either a menu or action * @param parent The parent to use for the created menu or action * @return QAction* The parsed action or menu action, if parsing fails returns @c null. **/ QAction *scriptValueToAction(QScriptValue &value, QMenu *parent); /** * @brief Creates a new QAction from the provided data and registers it for invoking the * @p callback when the action is triggered. * * The created action is added to the map of actions and callbacks shared with the global * shortcuts. * * @param title The title of the action * @param checkable Whether the action is checkable * @param checked Whether the checkable action is checked * @param callback The callback to invoke when the action is triggered * @param parent The parent to be used for the new created action * @return QAction* The created action **/ QAction *createAction(const QString &title, bool checkable, bool checked, QScriptValue &callback, QMenu *parent); /** * @brief Parses the @p items and creates a QMenu from it. * * @param title The title of the Menu. * @param items JavaScript Array containing Menu items. * @param parent The parent to use for the new created menu * @return QAction* The menu action for the new Menu **/ QAction *createMenu(const QString &title, QScriptValue &items, QMenu *parent); int m_scriptId; QString m_fileName; QString m_pluginName; bool m_running; QHash m_shortcutCallbacks; QHash > m_screenEdgeCallbacks; QHash m_callbacks; /** * @brief List of registered functions to call when the UserActionsMenu is about to show * to add further entries. **/ QList m_userActionsMenuCallbacks; }; class Script : public AbstractScript, QDBusContext { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Scripting") public: Script(int id, QString scriptName, QString pluginName, QObject *parent = nullptr); - virtual ~Script(); + ~Script() override; QScriptEngine *engine() { return m_engine; } bool registerTouchScreenCallback(int edge, QScriptValue callback); bool unregisterTouchScreenCallback(int edge); public Q_SLOTS: - Q_SCRIPTABLE void run(); + Q_SCRIPTABLE void run() override; Q_SIGNALS: Q_SCRIPTABLE void printError(const QString &text); private Q_SLOTS: /** * A nice clean way to handle exceptions in scripting. * TODO: Log to file, show from notifier.. **/ void sigException(const QScriptValue &exception); /** * Callback for when loadScriptFromFile has finished. **/ void slotScriptLoadedFromFile(); private: void installScriptFunctions(QScriptEngine *engine); /** * Read the script from file into a byte array. * If file cannot be read an empty byte array is returned. **/ QByteArray loadScriptFromFile(const QString &fileName); QScriptEngine *m_engine; QDBusMessage m_invocationContext; bool m_starting; QScopedPointer m_agent; QHash m_touchScreenEdgeCallbacks; }; class ScriptUnloaderAgent : public QScriptEngineAgent { public: explicit ScriptUnloaderAgent(Script *script); - virtual void scriptUnload(qint64 id); + void scriptUnload(qint64 id) override; private: Script *m_script; }; class DeclarativeScript : public AbstractScript { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Scripting") public: explicit DeclarativeScript(int id, QString scriptName, QString pluginName, QObject *parent = nullptr); - virtual ~DeclarativeScript(); + ~DeclarativeScript() override; public Q_SLOTS: - Q_SCRIPTABLE void run(); + Q_SCRIPTABLE void run() override; private Q_SLOTS: void createComponent(); private: QQmlContext *m_context; QQmlComponent *m_component; }; class JSEngineGlobalMethodsWrapper : public QObject { Q_OBJECT Q_ENUMS(ClientAreaOption) public: //------------------------------------------------------------------ //enums copy&pasted from kwinglobals.h for exporting enum ClientAreaOption { ///< geometry where a window will be initially placed after being mapped PlacementArea, ///< window movement snapping area? ignore struts MovementArea, ///< geometry to which a window will be maximized MaximizeArea, ///< like MaximizeArea, but ignore struts - used e.g. for topmenu MaximizeFullArea, ///< area for fullscreen windows FullScreenArea, ///< whole workarea (all screens together) WorkArea, ///< whole area (all screens together), ignore struts FullArea, ///< one whole screen, ignore struts ScreenArea }; explicit JSEngineGlobalMethodsWrapper(DeclarativeScript *parent); - virtual ~JSEngineGlobalMethodsWrapper(); + ~JSEngineGlobalMethodsWrapper() override; public Q_SLOTS: QVariant readConfig(const QString &key, QVariant defaultValue = QVariant()); void registerWindow(QQuickWindow *window); bool registerShortcut(const QString &name, const QString &text, const QKeySequence& keys, QJSValue function); private: DeclarativeScript *m_script; }; /** * The heart of KWin::Scripting. Infinite power lies beyond **/ class KWIN_EXPORT Scripting : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.Scripting") private: explicit Scripting(QObject *parent); QStringList scriptList; QList scripts; /** * Lock to protect the scripts member variable. **/ QScopedPointer m_scriptsLock; // Preferably call ONLY at load time void runScripts(); public: - ~Scripting(); + ~Scripting() override; Q_SCRIPTABLE Q_INVOKABLE int loadScript(const QString &filePath, const QString &pluginName = QString()); Q_SCRIPTABLE Q_INVOKABLE int loadDeclarativeScript(const QString &filePath, const QString &pluginName = QString()); Q_SCRIPTABLE Q_INVOKABLE bool isScriptLoaded(const QString &pluginName) const; Q_SCRIPTABLE Q_INVOKABLE bool unloadScript(const QString &pluginName); /** * @brief Invokes all registered callbacks to add actions to the UserActionsMenu. * * @param c The Client for which the UserActionsMenu is about to be shown * @param parent The parent menu to which to add created child menus and items * @return QList< QAction* > List of all actions aggregated from all scripts. **/ QList actionsForUserActionMenu(AbstractClient *c, QMenu *parent); QQmlEngine *qmlEngine() const; QQmlEngine *qmlEngine(); QQmlContext *declarativeScriptSharedContext() const; QQmlContext *declarativeScriptSharedContext(); QtScriptWorkspaceWrapper *workspaceWrapper() const; AbstractScript *findScript(const QString &pluginName) const; static Scripting *self(); static Scripting *create(QObject *parent); public Q_SLOTS: void scriptDestroyed(QObject *object); Q_SCRIPTABLE void start(); private Q_SLOTS: void slotScriptsQueried(); private: void init(); LoadScriptList queryScriptsToLoad(); static Scripting *s_self; QQmlEngine *m_qmlEngine; QQmlContext *m_declarativeScriptSharedContext; QtScriptWorkspaceWrapper *m_workspaceWrapper; }; inline QQmlEngine *Scripting::qmlEngine() const { return m_qmlEngine; } inline QQmlEngine *Scripting::qmlEngine() { return m_qmlEngine; } inline QQmlContext *Scripting::declarativeScriptSharedContext() const { return m_declarativeScriptSharedContext; } inline QQmlContext *Scripting::declarativeScriptSharedContext() { return m_declarativeScriptSharedContext; } inline QtScriptWorkspaceWrapper *Scripting::workspaceWrapper() const { return m_workspaceWrapper; } inline Scripting *Scripting::self() { return s_self; } } #endif diff --git a/scripting/scripting_model.h b/scripting/scripting_model.h index 96ea90e9b..cbb0299fe 100644 --- a/scripting/scripting_model.h +++ b/scripting/scripting_model.h @@ -1,379 +1,379 @@ /******************************************************************** 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_SCRIPTING_MODEL_H #define KWIN_SCRIPTING_MODEL_H #include #include #include namespace KWin { class AbstractClient; class Client; namespace ScriptingClientModel { class AbstractLevel; class ClientModel : public QAbstractItemModel { Q_OBJECT Q_ENUMS(Exclude) Q_ENUMS(LevelRestriction) Q_PROPERTY(Exclusions exclusions READ exclusions WRITE setExclusions NOTIFY exclusionsChanged) public: enum Exclusion { NoExclusion = 0, // window types DesktopWindowsExclusion = 1 << 0, DockWindowsExclusion = 1 << 1, UtilityWindowsExclusion = 1 << 2, SpecialWindowsExclusion = 1 << 3, // windows with flags SkipTaskbarExclusion = 1 << 4, SkipPagerExclusion = 1 << 5, SwitchSwitcherExclusion = 1 << 6, // based on state OtherDesktopsExclusion = 1 << 7, OtherActivitiesExclusion = 1 << 8, MinimizedExclusion = 1 << 9, NonSelectedWindowTabExclusion = 1 << 10, NotAcceptingFocusExclusion = 1 << 11 }; Q_DECLARE_FLAGS(Exclusions, Exclusion) Q_FLAGS(Exclusions) enum LevelRestriction { NoRestriction = 0, VirtualDesktopRestriction = 1 << 0, ScreenRestriction = 1 << 1, ActivityRestriction = 1 << 2 }; Q_DECLARE_FLAGS(LevelRestrictions, LevelRestriction) Q_FLAGS(LevelRestrictions) explicit ClientModel(QObject *parent); - virtual ~ClientModel(); - virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; - virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; - virtual QModelIndex parent(const QModelIndex &child) const; - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; - virtual QHash roleNames() const; + ~ClientModel() override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex &child) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + QHash roleNames() const override; void setExclusions(ClientModel::Exclusions exclusions); Exclusions exclusions() const; Q_SIGNALS: void exclusionsChanged(); private Q_SLOTS: void levelBeginInsert(int rowStart, int rowEnd, quint32 parentId); void levelEndInsert(); void levelBeginRemove(int rowStart, int rowEnd, quint32 parentId); void levelEndRemove(); protected: enum ClientModelRoles { ClientRole = Qt::UserRole, ScreenRole, DesktopRole, ActivityRole }; void setLevels(QList restrictions); private: QModelIndex parentForId(quint32 childId) const; const AbstractLevel *getLevel(const QModelIndex &index) const; AbstractLevel *m_root; Exclusions m_exclusions; }; /** * @brief The data structure of the Model. * * The model is implemented as a Tree consisting of AbstractLevels as the levels of the tree. * A non leaf level is represented by the inheriting class ForkLevel, the last level above a * leaf is represented by the inheriting class ClientLevel, which contains the Clients - each * Client is one leaf. * * In case the tree would only consist of Clients - leafs - it has always one ClientLevel as the root * of the tree. * * The number of levels in the tree is controlled by the LevelRestrictions. For each existing * LevelRestriction a new Level is created, if there are no more restrictions a ClientLevel is created. * * To build up the tree the static factory method @ref create has to be used. It will recursively * build up the tree. After the tree has been build up use @ref init to initialize the tree which * will add the Clients to the ClientLevel. * * Each element of the tree has a unique id which can be used by the QAbstractItemModel as the * internal id for its QModelIndex. Note: the ids have no ordering, if trying to get a specific element * the tree performs a depth-first search. **/ class AbstractLevel : public QObject { Q_OBJECT public: - virtual ~AbstractLevel(); + ~AbstractLevel() override; virtual int count() const = 0; virtual void init() = 0; virtual quint32 idForRow(int row) const = 0; uint screen() const; uint virtualDesktop() const; const QString &activity() const; ClientModel::LevelRestrictions restrictions() const; void setRestrictions(ClientModel::LevelRestrictions restrictions); ClientModel::LevelRestriction restriction() const; void setRestriction(ClientModel::LevelRestriction restriction); quint32 id() const; AbstractLevel *parentLevel() const; virtual const AbstractLevel *levelForId(quint32 id) const = 0; virtual AbstractLevel *parentForId(quint32 child) const = 0; virtual int rowForId(quint32 child) const = 0; virtual AbstractClient *clientForId(quint32 child) const = 0; virtual void setScreen(uint screen); virtual void setVirtualDesktop(uint virtualDesktop); virtual void setActivity(const QString &activity); static AbstractLevel *create(const QList &restrictions, ClientModel::LevelRestrictions parentRestrictions, ClientModel *model, AbstractLevel *parent = nullptr); Q_SIGNALS: void beginInsert(int rowStart, int rowEnd, quint32 parentId); void endInsert(); void beginRemove(int rowStart, int rowEnd, quint32 parentId); void endRemove(); protected: AbstractLevel(ClientModel *model, AbstractLevel *parent); ClientModel *model() const; private: ClientModel *m_model; AbstractLevel *m_parent; uint m_screen; uint m_virtualDesktop; QString m_activity; ClientModel::LevelRestriction m_restriction; ClientModel::LevelRestrictions m_restrictions; quint32 m_id; }; class ForkLevel : public AbstractLevel { Q_OBJECT public: ForkLevel(const QList &childRestrictions, ClientModel *model, AbstractLevel *parent); - virtual ~ForkLevel(); - virtual int count() const; - virtual void init(); - virtual quint32 idForRow(int row) const; + ~ForkLevel() override; + int count() const override; + void init() override; + quint32 idForRow(int row) const override; void addChild(AbstractLevel *child); - virtual void setScreen(uint screen); - virtual void setVirtualDesktop(uint virtualDesktop); - virtual void setActivity(const QString &activity); - virtual const AbstractLevel *levelForId(quint32 id) const; - virtual AbstractLevel *parentForId(quint32 child) const; - virtual int rowForId(quint32 child) const; - virtual AbstractClient *clientForId(quint32 child) const override; + void setScreen(uint screen) override; + void setVirtualDesktop(uint virtualDesktop) override; + void setActivity(const QString &activity) override; + const AbstractLevel *levelForId(quint32 id) const override; + AbstractLevel *parentForId(quint32 child) const override; + int rowForId(quint32 child) const override; + AbstractClient *clientForId(quint32 child) const override; private Q_SLOTS: void desktopCountChanged(uint previousCount, uint newCount); void screenCountChanged(int previousCount, int newCount); void activityAdded(const QString &id); void activityRemoved(const QString &id); private: QList m_children; QList m_childRestrictions; }; /** * @brief The actual leafs of the model's tree containing the Client's in this branch of the tree. * * This class groups all the Clients of one branch of the tree and takes care of updating the tree * when a Client changes its state in a way that it should be excluded/included or gets added or * removed. * * The Clients in this group are not sorted in any particular way. It's a simple list which only * gets added to. If some sorting should be applied, use a QSortFilterProxyModel. **/ class ClientLevel : public AbstractLevel { Q_OBJECT public: explicit ClientLevel(ClientModel *model, AbstractLevel *parent); - virtual ~ClientLevel(); + ~ClientLevel() override; - void init(); + void init() override; - int count() const; - quint32 idForRow(int row) const; + int count() const override; + quint32 idForRow(int row) const override; bool containsId(quint32 id) const; - int rowForId(quint32 row) const; - AbstractClient *clientForId(quint32 child) const; - virtual const AbstractLevel *levelForId(quint32 id) const; - virtual AbstractLevel *parentForId(quint32 child) const override; + int rowForId(quint32 row) const override; + AbstractClient *clientForId(quint32 child) const override; + const AbstractLevel *levelForId(quint32 id) const override; + AbstractLevel *parentForId(quint32 child) const override; public Q_SLOTS: void clientAdded(KWin::AbstractClient *client); void clientRemoved(KWin::AbstractClient *client); private Q_SLOTS: // uses sender() void reInit(); private: void checkClient(KWin::AbstractClient *client); void setupClientConnections(AbstractClient *client); void addClient(AbstractClient *client); void removeClient(AbstractClient *client); bool shouldAdd(AbstractClient *client) const; bool exclude(AbstractClient *client) const; bool containsClient(AbstractClient *client) const; QMap m_clients; }; class SimpleClientModel : public ClientModel { Q_OBJECT public: SimpleClientModel(QObject *parent = nullptr); - virtual ~SimpleClientModel(); + ~SimpleClientModel() override; }; class ClientModelByScreen : public ClientModel { Q_OBJECT public: ClientModelByScreen(QObject *parent = nullptr); - virtual ~ClientModelByScreen(); + ~ClientModelByScreen() override; }; class ClientModelByScreenAndDesktop : public ClientModel { Q_OBJECT public: ClientModelByScreenAndDesktop(QObject *parent = nullptr); - virtual ~ClientModelByScreenAndDesktop(); + ~ClientModelByScreenAndDesktop() override; }; /** * @brief Custom QSortFilterProxyModel to filter on Client caption, role and class. **/ class ClientFilterModel : public QSortFilterProxyModel { Q_OBJECT Q_PROPERTY(KWin::ScriptingClientModel::ClientModel *clientModel READ clientModel WRITE setClientModel NOTIFY clientModelChanged) Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged) public: ClientFilterModel(QObject *parent = nullptr); - virtual ~ClientFilterModel(); + ~ClientFilterModel() override; ClientModel *clientModel() const; const QString &filter() const; public Q_SLOTS: void setClientModel(ClientModel *clientModel); void setFilter(const QString &filter); protected: - virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; + bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override; Q_SIGNALS: void clientModelChanged(); void filterChanged(); private: ClientModel *m_clientModel; QString m_filter; }; inline int ClientLevel::count() const { return m_clients.count(); } inline const QString &AbstractLevel::activity() const { return m_activity; } inline AbstractLevel *AbstractLevel::parentLevel() const { return m_parent; } inline ClientModel *AbstractLevel::model() const { return m_model; } inline uint AbstractLevel::screen() const { return m_screen; } inline uint AbstractLevel::virtualDesktop() const { return m_virtualDesktop; } inline ClientModel::LevelRestriction AbstractLevel::restriction() const { return m_restriction; } inline ClientModel::LevelRestrictions AbstractLevel::restrictions() const { return m_restrictions; } inline quint32 AbstractLevel::id() const { return m_id; } inline ClientModel::Exclusions ClientModel::exclusions() const { return m_exclusions; } inline ClientModel *ClientFilterModel::clientModel() const { return m_clientModel; } inline const QString &ClientFilterModel::filter() const { return m_filter; } } // namespace Scripting } // namespace KWin Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::ScriptingClientModel::ClientModel::Exclusions) Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::ScriptingClientModel::ClientModel::LevelRestrictions) #endif // KWIN_SCRIPTING_MODEL_H diff --git a/shadow.h b/shadow.h index df92c2883..fd1506c66 100644 --- a/shadow.h +++ b/shadow.h @@ -1,192 +1,192 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2011 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_SHADOW_H #define KWIN_SHADOW_H #include #include #include namespace KDecoration2 { class Decoration; class DecorationShadow; } namespace KWayland { namespace Server { class ShadowInterface; } } namespace KWin { class Toplevel; /** * @short Class representing a Window's Shadow to be rendered by the Compositor. * * This class holds all information about the Shadow to be rendered together with the * window during the Compositing stage. The Shadow consists of several pixmaps and offsets. * For a complete description please refer to https://community.kde.org/KWin/Shadow * * To create a Shadow instance use the static factory method createShadow which will * create an instance for the currently used Compositing Backend. It will read the X11 Property * and create the Shadow and all required data (such as WindowQuads). If there is no Shadow * defined for the Toplevel the factory method returns @c NULL. * * @author Martin Gräßlin * @todo React on Toplevel size changes. **/ class KWIN_EXPORT Shadow : public QObject { Q_OBJECT public: - virtual ~Shadow(); + ~Shadow() override; /** * @return Region of the shadow. **/ const QRegion &shadowRegion() const { return m_shadowRegion; }; /** * @return Cached Shadow Quads **/ const WindowQuadList &shadowQuads() const { return m_shadowQuads; }; WindowQuadList &shadowQuads() { return m_shadowQuads; }; /** * This method updates the Shadow when the property has been changed. * It is the responsibility of the owner of the Shadow to call this method * whenever the owner receives a PropertyNotify event. * This method will invoke a re-read of the Property. In case the Property has * been withdrawn the method returns @c false. In that case the owner should * delete the Shadow. * @returns @c true when the shadow has been updated, @c false if the property is not set anymore. **/ virtual bool updateShadow(); /** * Factory Method to create the shadow from the property. * This method takes care of creating an instance of the * Shadow class for the current Compositing Backend. * * If there is no shadow defined for @p toplevel this method * will return @c NULL. * @param toplevel The Toplevel for which the shadow should be created * @return Created Shadow or @c NULL in case there is no shadow defined. **/ static Shadow *createShadow(Toplevel *toplevel); /** * Reparents the shadow to @p toplevel. * Used when a window is deleted. * @param toplevel The new parent **/ void setToplevel(Toplevel *toplevel); bool hasDecorationShadow() const { return !m_decorationShadow.isNull(); } QImage decorationShadowImage() const; QWeakPointer decorationShadow() const { return m_decorationShadow.toWeakRef(); } public Q_SLOTS: void geometryChanged(); protected: Shadow(Toplevel *toplevel); enum ShadowElements { ShadowElementTop, ShadowElementTopRight, ShadowElementRight, ShadowElementBottomRight, ShadowElementBottom, ShadowElementBottomLeft, ShadowElementLeft, ShadowElementTopLeft, ShadowElementsCount }; inline const QPixmap &shadowPixmap(ShadowElements element) const { return m_shadowElements[element]; }; QSize elementSize(ShadowElements element) const; int topOffset() const { return m_topOffset; }; int rightOffset() const { return m_rightOffset; }; int bottomOffset() const { return m_bottomOffset; }; int leftOffset() const { return m_leftOffset; }; virtual void buildQuads(); void updateShadowRegion(); Toplevel *topLevel() { return m_topLevel; }; void setShadowRegion(const QRegion ®ion) { m_shadowRegion = region; }; virtual bool prepareBackend() = 0; WindowQuadList m_shadowQuads; void setShadowElement(const QPixmap &shadow, ShadowElements element); private: static Shadow *createShadowFromX11(Toplevel *toplevel); static Shadow *createShadowFromDecoration(Toplevel *toplevel); static Shadow *createShadowFromWayland(Toplevel *toplevel); static QVector readX11ShadowProperty(xcb_window_t id); bool init(const QVector &data); bool init(KDecoration2::Decoration *decoration); bool init(const QPointer &shadow); Toplevel *m_topLevel; // shadow pixmaps QPixmap m_shadowElements[ShadowElementsCount]; // shadow offsets int m_topOffset; int m_rightOffset; int m_bottomOffset; int m_leftOffset; // caches QRegion m_shadowRegion; QSize m_cachedSize; // Decoration based shadows QSharedPointer m_decorationShadow; }; } #endif // KWIN_SHADOW_H diff --git a/shell_client.h b/shell_client.h index 289551550..62e037c18 100644 --- a/shell_client.h +++ b/shell_client.h @@ -1,309 +1,309 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 Martin Gräßlin Copyright (C) 2018 David Edmundson 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_SHELL_CLIENT_H #define KWIN_SHELL_CLIENT_H #include "abstract_client.h" #include namespace KWayland { namespace Server { class ShellSurfaceInterface; class ServerSideDecorationInterface; class ServerSideDecorationPaletteInterface; class AppMenuInterface; class PlasmaShellSurfaceInterface; class XdgDecorationInterface; } } namespace KWin { /** * @brief The reason for which the server pinged a client surface **/ enum class PingReason { CloseWindow = 0, FocusWindow }; class KWIN_EXPORT ShellClient : public AbstractClient { Q_OBJECT public: ShellClient(KWayland::Server::ShellSurfaceInterface *surface); ShellClient(KWayland::Server::XdgShellSurfaceInterface *surface); ShellClient(KWayland::Server::XdgShellPopupInterface *surface); - virtual ~ShellClient(); + ~ShellClient() override; QStringList activities() const override; QPoint clientContentPos() const override; QSize clientSize() const override; QRect transparentRect() const override; NET::WindowType windowType(bool direct = false, int supported_types = 0) const override; void debug(QDebug &stream) const override; double opacity() const override; void setOpacity(double opacity) override; QByteArray windowRole() const override; void blockActivityUpdates(bool b = true) override; QString captionNormal() const override { return m_caption; } QString captionSuffix() const override { return m_captionSuffix; } void closeWindow() override; AbstractClient *findModal(bool allow_itself = false) override; bool isCloseable() const override; bool isFullScreenable() const override; bool isFullScreen() const override; bool isMaximizable() const override; bool isMinimizable() const override; bool isMovable() const override; bool isMovableAcrossScreens() const override; bool isResizable() const override; bool isShown(bool shaded_is_shown) const override; bool isHiddenInternal() const override { return m_unmapped || m_hidden; } void hideClient(bool hide) override; MaximizeMode maximizeMode() const override; MaximizeMode requestedMaximizeMode() const override; QRect geometryRestore() const override { return m_geomMaximizeRestore; } bool noBorder() const override; void setFullScreen(bool set, bool user = true) override; void setNoBorder(bool set) override; void updateDecoration(bool check_workspace_pos, bool force = false) override; void setOnAllActivities(bool set) override; void takeFocus() override; bool userCanSetFullScreen() const override; bool userCanSetNoBorder() const override; bool wantsInput() const override; bool dockWantsInput() const override; using AbstractClient::resizeWithChecks; void resizeWithChecks(int w, int h, ForceGeometry_t force = NormalGeometrySet) override; using AbstractClient::setGeometry; void setGeometry(int x, int y, int w, int h, ForceGeometry_t force = NormalGeometrySet) override; bool hasStrut() const override; quint32 windowId() const override { return m_windowId; } /** * The process for this client. * Note that processes started by kwin will share its process id. * @since 5.11 * @returns the process if for this client. **/ pid_t pid() const override; bool isLockScreen() const override; bool isInputMethod() const override; virtual QWindow *internalWindow() const; void installPlasmaShellSurface(KWayland::Server::PlasmaShellSurfaceInterface *surface); void installServerSideDecoration(KWayland::Server::ServerSideDecorationInterface *decoration); void installAppMenu(KWayland::Server::AppMenuInterface *appmenu); void installPalette(KWayland::Server::ServerSideDecorationPaletteInterface *palette); void installXdgDecoration(KWayland::Server::XdgDecorationInterface *decoration); bool isInitialPositionSet() const override; bool isTransient() const override; bool hasTransientPlacementHint() const override; QRect transientPlacement(const QRect &bounds) const override; QMatrix4x4 inputTransformation() const override; bool setupCompositing() override; void finishCompositing(ReleaseReason releaseReason = ReleaseReason::Release) override; void showOnScreenEdge() override; void killWindow() override; // TODO: const-ref void placeIn(QRect &area); bool hasPopupGrab() const override; void popupDone() override; void updateColorScheme() override; bool isPopupWindow() const override; bool isLocalhost() const override { return true; } bool supportsWindowRules() const override; protected: void addDamage(const QRegion &damage) override; bool belongsToSameApplication(const AbstractClient *other, SameApplicationChecks checks) const override; void doSetActive() override; bool belongsToDesktop() const override; Layer layerForDock() const override; void changeMaximize(bool horizontal, bool vertical, bool adjust) override; void setGeometryRestore(const QRect &geo) override { m_geomMaximizeRestore = geo; } void doResizeSync() override; bool isWaitingForMoveResizeSync() const override; bool acceptsFocus() const override; void doMinimize() override; void updateCaption() override; virtual bool requestGeometry(const QRect &rect); virtual void doSetGeometry(const QRect &rect); void unmap(); void markAsMapped(); void setClientSize(const QSize &size) { m_clientSize = size; } bool isUnmapped() const { return m_unmapped; } private Q_SLOTS: void clientFullScreenChanged(bool fullScreen); private: /** * Called when the shell is created. **/ void init(); /** * Called for the XDG case when the shell surface is committed to the surface. * At this point all initial properties should have been set by the client. **/ void finishInit(); template void initSurface(T *shellSurface); void createDecoration(const QRect &oldgeom); void destroyClient(); void createWindowId(); void updateIcon(); void setTransient(); bool shouldExposeToWindowManagement(); void updateClientOutputs(); void updateWindowMargins(); KWayland::Server::XdgShellSurfaceInterface::States xdgSurfaceStates() const; void updateShowOnScreenEdge(); void updateMaximizeMode(MaximizeMode maximizeMode); // called on surface commit and processes all m_pendingConfigureRequests up to m_lastAckedConfigureReqest void updatePendingGeometry(); QPoint popupOffset(const QRect &anchorRect, const Qt::Edges anchorEdge, const Qt::Edges gravity, const QSize popupSize) const; static void deleteClient(ShellClient *c); QSize toWindowGeometry(const QSize &geometry) const; KWayland::Server::ShellSurfaceInterface *m_shellSurface; KWayland::Server::XdgShellSurfaceInterface *m_xdgShellSurface; KWayland::Server::XdgShellPopupInterface *m_xdgShellPopup; // size of the last buffer QSize m_clientSize; // last size we requested or empty if we haven't sent an explicit request to the client // if empty the client should choose their own default size QSize m_requestedClientSize = QSize(0, 0); struct PendingConfigureRequest { //note for wl_shell we have no serial, so serialId and m_lastAckedConfigureRequest will always be 0 //meaning we treat a surface commit as having processed all requests quint32 serialId = 0; // position to apply after a resize operation has been completed QPoint positionAfterResize; MaximizeMode maximizeMode; }; QVector m_pendingConfigureRequests; quint32 m_lastAckedConfigureRequest = 0; //mode in use by the current buffer MaximizeMode m_maximizeMode = MaximizeRestore; //mode we currently want to be, could be pending on client updating, could be not sent yet MaximizeMode m_requestedMaximizeMode = MaximizeRestore; QRect m_geomFsRestore; //size and position of the window before it was set to fullscreen bool m_closing = false; quint32 m_windowId = 0; bool m_unmapped = true; QRect m_geomMaximizeRestore; // size and position of the window before it was set to maximize NET::WindowType m_windowType = NET::Normal; QPointer m_plasmaShellSurface; QPointer m_appMenuInterface; QPointer m_paletteInterface; KWayland::Server::ServerSideDecorationInterface *m_serverDecoration = nullptr; KWayland::Server::XdgDecorationInterface *m_xdgDecoration = nullptr; bool m_userNoBorder = false; bool m_fullScreen = false; bool m_transient = false; bool m_hidden = false; bool m_internal; bool m_hasPopupGrab = false; qreal m_opacity = 1.0; class RequestGeometryBlocker { //TODO rename ConfigureBlocker when this class is Xdg only public: RequestGeometryBlocker(ShellClient *client) : m_client(client) { m_client->m_requestGeometryBlockCounter++; } ~RequestGeometryBlocker() { m_client->m_requestGeometryBlockCounter--; if (m_client->m_requestGeometryBlockCounter == 0) { m_client->requestGeometry(m_client->m_blockedRequestGeometry); } } private: ShellClient *m_client; }; friend class RequestGeometryBlocker; int m_requestGeometryBlockCounter = 0; QRect m_blockedRequestGeometry; QString m_caption; QString m_captionSuffix; QHash m_pingSerials; QMargins m_windowMargins; bool m_compositingSetup = false; bool m_isInitialized = false; }; } Q_DECLARE_METATYPE(KWin::ShellClient*) #endif diff --git a/sm.h b/sm.h index 529187d84..b00cb3588 100644 --- a/sm.h +++ b/sm.h @@ -1,103 +1,103 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 1999, 2000 Matthias Ettrich Copyright (C) 2003 Lubos Lunak 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_SM_H #define KWIN_SM_H #include #include #include #include #include #include #include class QSocketNotifier; namespace KWin { class Client; struct SessionInfo { QByteArray sessionId; QByteArray windowRole; QByteArray wmCommand; QByteArray wmClientMachine; QByteArray resourceName; QByteArray resourceClass; QRect geometry; QRect restore; QRect fsrestore; int maximized; int fullscreen; int desktop; bool minimized; bool onAllDesktops; bool shaded; bool keepAbove; bool keepBelow; bool skipTaskbar; bool skipPager; bool skipSwitcher; bool noBorder; NET::WindowType windowType; QString shortcut; bool active; // means 'was active in the saved session' int stackingOrder; float opacity; int tabGroup; // Unique identifier for the client group that this window is in Client* tabGroupClient; // The first client created that has an identical identifier QStringList activities; }; enum SMSavePhase { SMSavePhase0, // saving global state in "phase 0" SMSavePhase2, // saving window state in phase 2 SMSavePhase2Full // complete saving in phase2, there was no phase 0 }; class KWIN_EXPORT SessionSaveDoneHelper : public QObject { Q_OBJECT public: SessionSaveDoneHelper(); - virtual ~SessionSaveDoneHelper(); + ~SessionSaveDoneHelper() override; SmcConn connection() const { return conn; } void saveDone(); void close(); private Q_SLOTS: void processData(); private: QSocketNotifier* notifier; SmcConn conn; }; } // namespace #endif diff --git a/tabbox/clientmodel.h b/tabbox/clientmodel.h index 28c25415b..e8bfdedb1 100644 --- a/tabbox/clientmodel.h +++ b/tabbox/clientmodel.h @@ -1,114 +1,114 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2009 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 CLIENTMODEL_H #define CLIENTMODEL_H #include "tabboxhandler.h" #include /** * @file * This file defines the class ClientModel, the model for TabBoxClients. * * @author Martin Gräßlin * @since 4.4 **/ namespace KWin { namespace TabBox { /** * The model for TabBoxClients used in TabBox. * * @author Martin Gräßlin * @since 4.4 **/ class ClientModel : public QAbstractItemModel { Q_OBJECT public: enum { ClientRole = Qt::UserRole, ///< The TabBoxClient CaptionRole = Qt::UserRole + 1, ///< The caption of TabBoxClient DesktopNameRole = Qt::UserRole + 2, ///< The name of the desktop the TabBoxClient is on IconRole = Qt::UserRole + 3, // TODO: to be removed WIdRole = Qt::UserRole + 5, ///< The window ID of TabBoxClient MinimizedRole = Qt::UserRole + 6, ///< TabBoxClient is minimized CloseableRole = Qt::UserRole + 7 ///< TabBoxClient can be closed }; explicit ClientModel(QObject* parent = nullptr); - ~ClientModel(); - virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; - virtual int columnCount(const QModelIndex& parent = QModelIndex()) const; - virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; - virtual QModelIndex parent(const QModelIndex& child) const; - virtual QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const; - virtual QHash roleNames() const; + ~ClientModel() override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex& child) const override; + QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; + QHash roleNames() const override; Q_INVOKABLE QString longestCaption() const; /** * @param client The TabBoxClient whose index should be returned * @return Returns the ModelIndex of given TabBoxClient or an invalid ModelIndex * if the model does not contain the given TabBoxClient. **/ QModelIndex index(QWeakPointer client) const; /** * Generates a new list of TabBoxClients based on the current config. * Calling this method will reset the model. If partialReset is true * the top of the list is kept as a starting point. If not the * current active client is used as the starting point to generate the * list. * @param desktop The desktop for which the list should be created * @param partialReset Keep the currently selected client or regenerate everything **/ void createClientList(int desktop, bool partialReset = false); /** * This method is provided as a overload for current desktop * @see createClientList **/ void createClientList(bool partialReset = false); /** * @return Returns the current list of TabBoxClients. **/ TabBoxClientList clientList() const { return m_clientList; } public Q_SLOTS: void close(int index); /** * Activates the client at @p index and closes the TabBox. * @param index The row index **/ void activate(int index); private: TabBoxClientList m_clientList; }; } // namespace Tabbox } // namespace KWin #endif // CLIENTMODEL_H diff --git a/tabbox/desktopchain.h b/tabbox/desktopchain.h index e2505c9c1..c74324711 100644 --- a/tabbox/desktopchain.h +++ b/tabbox/desktopchain.h @@ -1,148 +1,148 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2012 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_TABBOX_DESKTOP_CHAIN_H #define KWIN_TABBOX_DESKTOP_CHAIN_H // Qt #include #include #include namespace KWin { namespace TabBox { /** * @brief A chain for last recently used virtual desktops. **/ class DesktopChain { public: /** * Creates a last recently used virtual desktop chain with the given @p initialSize. **/ explicit DesktopChain(uint initialSize = 0); /** * Returns the next desktop in the chain starting from @p indexDesktop. * In case that the @p indexDesktop is the last desktop of the chain, the method wraps around * and returns the first desktop stored in the chain. * In case the chain is valid, but does not contain the @p indexDesktop, the first element of * the chain is returned. * In case the chain is not valid, the always valid virtual desktop with identifier @c 1 * is returned. * @param indexDesktop The id of the virtual desktop which should be used as a starting point * @return The next virtual desktop in the chain **/ uint next(uint indexDesktop) const; /** * Adds the @p desktop to the chain. The @p desktop becomes the first element of the * chain. All desktops in the chain from the previous index of @p desktop are moved * one position in the chain. * @param desktop The new desktop to be the top most element in the chain. **/ void add(uint desktop); /** * Resizes the chain from @p previousSize to @p newSize. * In case the chain grows new elements are added with a meaning full id in the range * [previousSize, newSize]. * In case the chain shrinks it is ensured that no element points to a virtual desktop * with an id larger than @p newSize. * @param previousSize The previous size of the desktop chain * @param newSize The size to be used for the desktop chain **/ void resize(uint previousSize, uint newSize); private: /** * Initializes the chain with default values. **/ void init(); QVector m_chain; }; /** * @brief A manager for multiple desktop chains. * * This manager keeps track of multiple desktop chains which have a given identifier. * A common usage for this is to have a different desktop chain for each Activity. **/ class DesktopChainManager : public QObject { Q_OBJECT public: explicit DesktopChainManager(QObject *parent = nullptr); - virtual ~DesktopChainManager(); + ~DesktopChainManager() override; /** * Returns the next virtual desktop starting from @p indexDesktop in the currently used chain. * @param indexDesktop The id of the virtual desktop which should be used as a starting point * @return The next virtual desktop in the currently used chain * @see DesktopChain::next **/ uint next(uint indexDesktop) const; public Q_SLOTS: /** * Adds the @p currentDesktop to the currently used desktop chain. * @param previousDesktop The previously used desktop, should be the top element of the chain * @param currentDesktop The desktop which should be the new top element of the chain **/ void addDesktop(uint previousDesktop, uint currentDesktop); /** * Resizes all managed desktop chains from @p previousSize to @p newSize. * @param previousSize The previously used size for the chains * @param newSize The size to be used for the chains * @see DesktopChain::resize **/ void resize(uint previousSize, uint newSize); /** * Switches to the desktop chain identified by the given @p identifier. * If there is no chain yet for the given @p identifier a new chain is created and used. * @param identifier The identifier of the desktop chain to be used **/ void useChain(const QString &identifier); private: typedef QHash< QString, DesktopChain > DesktopChains; /** * Creates a new desktop chain for the given @p identifier and adds it to the list * of identifiers. * @returns Position of the new chain in the managed list of chains **/ DesktopChains::Iterator addNewChain(const QString &identifier); /** * Creates the very first list to be used when an @p identifier comes in. * The dummy chain which is used by default gets copied and used for this chain. **/ void createFirstChain(const QString &identifier); DesktopChains::Iterator m_currentChain; DesktopChains m_chains; /** * The maximum size to be used for a new desktop chain **/ uint m_maxChainSize; }; } // TabBox } // namespace KWin #endif diff --git a/tabbox/desktopmodel.h b/tabbox/desktopmodel.h index df59a1505..10786d36d 100644 --- a/tabbox/desktopmodel.h +++ b/tabbox/desktopmodel.h @@ -1,90 +1,90 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2009 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 DESKTOPMODEL_H #define DESKTOPMODEL_H #include /** * @file * This file defines the class DesktopModel, the model for desktops. * * @author Martin Gräßlin * @since 4.4 **/ namespace KWin { namespace TabBox { class ClientModel; /** * The model for desktops used in TabBox. * * @author Martin Gräßlin * @since 4.4 **/ class DesktopModel : public QAbstractItemModel { public: enum { DesktopRole = Qt::UserRole, ///< Desktop number DesktopNameRole = Qt::UserRole + 1, ///< Desktop name ClientModelRole = Qt::UserRole + 2 ///< Clients on this desktop }; explicit DesktopModel(QObject* parent = nullptr); - ~DesktopModel(); + ~DesktopModel() override; - virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; - virtual int columnCount(const QModelIndex& parent = QModelIndex()) const; - virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; - virtual QModelIndex parent(const QModelIndex& child) const; - virtual QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const; - virtual QHash roleNames() const; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex& child) const override; + QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; + QHash roleNames() const override; Q_INVOKABLE QString longestCaption() const; /** * Generates a new list of desktops based on the current config. * Calling this method will reset the model. **/ void createDesktopList(); /** * @return The current list of desktops. **/ QList< int > desktopList() const { return m_desktopList; } /** * @param desktop The desktop whose ModelIndex should be retrieved * @return The ModelIndex of given desktop or an invalid ModelIndex if * the desktop is not in the model. **/ QModelIndex desktopIndex(int desktop) const; private: QList< int > m_desktopList; QMap< int, ClientModel* > m_clientModels; }; } // namespace Tabbox } // namespace KWin #endif // DESKTOPMODEL_H diff --git a/tabbox/switcheritem.h b/tabbox/switcheritem.h index ea6ed1326..77314854c 100644 --- a/tabbox/switcheritem.h +++ b/tabbox/switcheritem.h @@ -1,118 +1,118 @@ /******************************************************************** 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_TABBOX_SWITCHERITEM_H #define KWIN_TABBOX_SWITCHERITEM_H #include #include class QAbstractItemModel; namespace KWin { namespace TabBox { class SwitcherItem : public QObject { Q_OBJECT Q_PROPERTY(QAbstractItemModel *model READ model NOTIFY modelChanged) Q_PROPERTY(QRect screenGeometry READ screenGeometry NOTIFY screenGeometryChanged) Q_PROPERTY(bool visible READ isVisible NOTIFY visibleChanged) Q_PROPERTY(bool allDesktops READ isAllDesktops NOTIFY allDesktopsChanged) Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) Q_PROPERTY(bool noModifierGrab READ noModifierGrab NOTIFY noModifierGrabChanged) /** * The main QML item that will be displayed in the Dialog **/ Q_PROPERTY(QObject *item READ item WRITE setItem NOTIFY itemChanged) Q_CLASSINFO("DefaultProperty", "item") public: SwitcherItem(QObject *parent = nullptr); - virtual ~SwitcherItem(); + ~SwitcherItem() override; QAbstractItemModel *model() const; QRect screenGeometry() const; bool isVisible() const; bool isAllDesktops() const; int currentIndex() const; void setCurrentIndex(int index); QObject *item() const; void setItem(QObject *item); bool noModifierGrab() const { return m_noModifierGrab; } // for usage from outside void setModel(QAbstractItemModel *model); void setAllDesktops(bool all); void setVisible(bool visible); void setNoModifierGrab(bool set); Q_SIGNALS: void visibleChanged(); void currentIndexChanged(int index); void modelChanged(); void allDesktopsChanged(); void screenGeometryChanged(); void itemChanged(); void noModifierGrabChanged(); private: QAbstractItemModel *m_model; QObject *m_item; bool m_visible; bool m_allDesktops; int m_currentIndex; QMetaObject::Connection m_selectedIndexConnection; bool m_noModifierGrab = false; }; inline QAbstractItemModel *SwitcherItem::model() const { return m_model; } inline bool SwitcherItem::isVisible() const { return m_visible; } inline bool SwitcherItem::isAllDesktops() const { return m_allDesktops; } inline int SwitcherItem::currentIndex() const { return m_currentIndex; } inline QObject *SwitcherItem::item() const { return m_item; } } // TabBox } // KWin #endif // KWIN_TABBOX_SWITCHERITEM_H diff --git a/tabbox/tabbox.h b/tabbox/tabbox.h index be107440a..755fd890c 100644 --- a/tabbox/tabbox.h +++ b/tabbox/tabbox.h @@ -1,376 +1,376 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 1999, 2000 Matthias Ettrich Copyright (C) 2003 Lubos Lunak Copyright (C) 2009 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_TABBOX_H #define KWIN_TABBOX_H #include #include #include #include "utils.h" #include "tabbox/tabboxhandler.h" class KConfigGroup; class QAction; class QMouseEvent; class QKeyEvent; class QWheelEvent; namespace KWin { class Workspace; class AbstractClient; class Client; class X11EventFilter; namespace TabBox { class DesktopChainManager; class TabBoxConfig; class TabBox; class TabBoxHandlerImpl : public TabBoxHandler { public: explicit TabBoxHandlerImpl(TabBox* tabBox); - virtual ~TabBoxHandlerImpl(); - - virtual int activeScreen() const; - virtual QWeakPointer< TabBoxClient > activeClient() const; - virtual int currentDesktop() const; - virtual QString desktopName(TabBoxClient* client) const; - virtual QString desktopName(int desktop) const; - virtual bool isKWinCompositing() const; - virtual QWeakPointer< TabBoxClient > nextClientFocusChain(TabBoxClient* client) const; - virtual QWeakPointer< TabBoxClient > firstClientFocusChain() const; - virtual bool isInFocusChain (TabBoxClient* client) const; - virtual int nextDesktopFocusChain(int desktop) const; - virtual int numberOfDesktops() const; - virtual TabBoxClientList stackingOrder() const; - virtual void elevateClient(TabBoxClient* c, QWindow *tabbox, bool elevate) const; - virtual void raiseClient(TabBoxClient *client) const; - virtual void restack(TabBoxClient *c, TabBoxClient *under); - virtual void shadeClient(TabBoxClient *c, bool b) const; - virtual QWeakPointer< TabBoxClient > clientToAddToList(KWin::TabBox::TabBoxClient* client, int desktop) const; - virtual QWeakPointer< TabBoxClient > desktopClient() const; - virtual void activateAndClose(); + ~TabBoxHandlerImpl() override; + + int activeScreen() const override; + QWeakPointer< TabBoxClient > activeClient() const override; + int currentDesktop() const override; + QString desktopName(TabBoxClient* client) const override; + QString desktopName(int desktop) const override; + bool isKWinCompositing() const override; + QWeakPointer< TabBoxClient > nextClientFocusChain(TabBoxClient* client) const override; + QWeakPointer< TabBoxClient > firstClientFocusChain() const override; + bool isInFocusChain (TabBoxClient* client) const override; + int nextDesktopFocusChain(int desktop) const override; + int numberOfDesktops() const override; + TabBoxClientList stackingOrder() const override; + void elevateClient(TabBoxClient* c, QWindow *tabbox, bool elevate) const override; + void raiseClient(TabBoxClient *client) const override; + void restack(TabBoxClient *c, TabBoxClient *under) override; + void shadeClient(TabBoxClient *c, bool b) const override; + QWeakPointer< TabBoxClient > clientToAddToList(KWin::TabBox::TabBoxClient* client, int desktop) const override; + QWeakPointer< TabBoxClient > desktopClient() const override; + void activateAndClose() override; void highlightWindows(TabBoxClient *window = nullptr, QWindow *controller = nullptr) override; bool noModifierGrab() const override; private: bool checkDesktop(TabBoxClient* client, int desktop) const; bool checkActivity(TabBoxClient* client) const; bool checkApplications(TabBoxClient* client) const; bool checkMinimized(TabBoxClient* client) const; bool checkMultiScreen(TabBoxClient* client) const; TabBox* m_tabBox; DesktopChainManager* m_desktopFocusChain; }; class TabBoxClientImpl : public TabBoxClient { public: explicit TabBoxClientImpl(AbstractClient *client); - virtual ~TabBoxClientImpl(); - - virtual QString caption() const; - virtual QIcon icon() const override; - virtual WId window() const; - virtual bool isMinimized() const; - virtual int x() const; - virtual int y() const; - virtual int width() const; - virtual int height() const; - virtual bool isCloseable() const; - virtual void close(); - virtual bool isFirstInTabBox() const; + ~TabBoxClientImpl() override; + + QString caption() const override; + QIcon icon() const override; + WId window() const override; + bool isMinimized() const override; + int x() const override; + int y() const override; + int width() const override; + int height() const override; + bool isCloseable() const override; + void close() override; + bool isFirstInTabBox() const override; QUuid internalId() const override; AbstractClient* client() const { return m_client; } private: AbstractClient* m_client; }; class KWIN_EXPORT TabBox : public QObject { Q_OBJECT public: - ~TabBox(); + ~TabBox() override; /** * Returns the currently displayed client ( only works in TabBoxWindowsMode ). * Returns 0 if no client is displayed. **/ AbstractClient *currentClient(); /** * Returns the list of clients potentially displayed ( only works in * TabBoxWindowsMode ). * Returns an empty list if no clients are available. **/ QList currentClientList(); /** * Returns the currently displayed virtual desktop ( only works in * TabBoxDesktopListMode ) * Returns -1 if no desktop is displayed. **/ int currentDesktop(); /** * Returns the list of desktops potentially displayed ( only works in * TabBoxDesktopListMode ) * Returns an empty list if no are available. **/ QList< int > currentDesktopList(); /** * Change the currently selected client, and notify the effects. * * @see setCurrentDesktop **/ void setCurrentClient(AbstractClient *newClient); /** * Change the currently selected desktop, and notify the effects. * * @see setCurrentClient **/ void setCurrentDesktop(int newDesktop); /** * Sets the current mode to \a mode, either TabBoxDesktopListMode or TabBoxWindowsMode * * @see mode **/ void setMode(TabBoxMode mode); TabBoxMode mode() const { return m_tabBoxMode; } /** * Resets the tab box to display the active client in TabBoxWindowsMode, or the * current desktop in TabBoxDesktopListMode **/ void reset(bool partial_reset = false); /** * Shows the next or previous item, depending on \a next **/ void nextPrev(bool next = true); /** * Shows the tab box after some delay. * * If the 'ShowDelay' setting is false, show() is simply called. * * Otherwise, we start a timer for the delay given in the settings and only * do a show() when it times out. * * This means that you can alt-tab between windows and you don't see the * tab box immediately. Not only does this make alt-tabbing faster, it gives * less 'flicker' to the eyes. You don't need to see the tab box if you're * just quickly switching between 2 or 3 windows. It seems to work quite * nicely. **/ void delayedShow(); /** * Notify effects that the tab box is being hidden. **/ void hide(bool abort = false); /** * Increases the reference count, preventing the default tabbox from showing. * * @see unreference * @see isDisplayed **/ void reference() { ++m_displayRefcount; } /** * Decreases the reference count. Only when the reference count is 0 will * the default tab box be shown. **/ void unreference() { --m_displayRefcount; } /** * Returns whether the tab box is being displayed, either natively or by an * effect. * * @see reference * @see unreference **/ bool isDisplayed() const { return m_displayRefcount > 0; } /** * @returns @c true if TabBox is shown, @c false if replaced by Effect **/ bool isShown() const { return m_isShown; } bool handleMouseEvent(QMouseEvent *event); bool handleWheelEvent(QWheelEvent *event); void grabbedKeyEvent(QKeyEvent* event); bool isGrabbed() const { return m_tabGrab || m_desktopGrab; } void initShortcuts(); AbstractClient* nextClientStatic(AbstractClient*) const; AbstractClient* previousClientStatic(AbstractClient*) const; int nextDesktopStatic(int iDesktop) const; int previousDesktopStatic(int iDesktop) const; void keyPress(int key); void modifiersReleased(); bool forcedGlobalMouseGrab() const { return m_forcedGlobalMouseGrab; } bool noModifierGrab() const { return m_noModifierGrab; } void setCurrentIndex(QModelIndex index, bool notifyEffects = true); static TabBox *self(); static TabBox *create(QObject *parent); public Q_SLOTS: /** * Notify effects that the tab box is being shown, and only display the * default tab box QFrame if no effect has referenced the tab box. **/ void show(); void close(bool abort = false); void accept(bool closeTabBox = true); void slotWalkThroughDesktops(); void slotWalkBackThroughDesktops(); void slotWalkThroughDesktopList(); void slotWalkBackThroughDesktopList(); void slotWalkThroughWindows(); void slotWalkBackThroughWindows(); void slotWalkThroughWindowsAlternative(); void slotWalkBackThroughWindowsAlternative(); void slotWalkThroughCurrentAppWindows(); void slotWalkBackThroughCurrentAppWindows(); void slotWalkThroughCurrentAppWindowsAlternative(); void slotWalkBackThroughCurrentAppWindowsAlternative(); void handlerReady(); bool toggle(ElectricBorder eb); Q_SIGNALS: void tabBoxAdded(int); void tabBoxClosed(); void tabBoxUpdated(); void tabBoxKeyEvent(QKeyEvent*); private: explicit TabBox(QObject *parent); void loadConfig(const KConfigGroup& config, TabBoxConfig& tabBoxConfig); bool startKDEWalkThroughWindows(TabBoxMode mode); // TabBoxWindowsMode | TabBoxWindowsAlternativeMode bool startWalkThroughDesktops(TabBoxMode mode); // TabBoxDesktopMode | TabBoxDesktopListMode bool startWalkThroughDesktops(); bool startWalkThroughDesktopList(); void navigatingThroughWindows(bool forward, const QKeySequence &shortcut, TabBoxMode mode); // TabBoxWindowsMode | TabBoxWindowsAlternativeMode void KDEWalkThroughWindows(bool forward); void CDEWalkThroughWindows(bool forward); void walkThroughDesktops(bool forward); void KDEOneStepThroughWindows(bool forward, TabBoxMode mode); // TabBoxWindowsMode | TabBoxWindowsAlternativeMode void oneStepThroughDesktops(bool forward, TabBoxMode mode); // TabBoxDesktopMode | TabBoxDesktopListMode void oneStepThroughDesktops(bool forward); void oneStepThroughDesktopList(bool forward); bool establishTabBoxGrab(); void removeTabBoxGrab(); template void key(const char *actionName, Slot slot, const QKeySequence &shortcut = QKeySequence()); void shadeActivate(AbstractClient *c); bool toggleMode(TabBoxMode mode); private Q_SLOTS: void reconfigure(); void globalShortcutChanged(QAction *action, const QKeySequence &seq); private: TabBoxMode m_tabBoxMode; TabBoxHandlerImpl* m_tabBox; bool m_delayShow; int m_delayShowTime; QTimer m_delayedShowTimer; int m_displayRefcount; TabBoxConfig m_defaultConfig; TabBoxConfig m_alternativeConfig; TabBoxConfig m_defaultCurrentApplicationConfig; TabBoxConfig m_alternativeCurrentApplicationConfig; TabBoxConfig m_desktopConfig; TabBoxConfig m_desktopListConfig; // false if an effect has referenced the tabbox // true if tabbox is active (independent on showTabbox setting) bool m_isShown; bool m_desktopGrab; bool m_tabGrab; // true if tabbox is in modal mode which does not require holding a modifier bool m_noModifierGrab; QKeySequence m_cutWalkThroughDesktops, m_cutWalkThroughDesktopsReverse; QKeySequence m_cutWalkThroughDesktopList, m_cutWalkThroughDesktopListReverse; QKeySequence m_cutWalkThroughWindows, m_cutWalkThroughWindowsReverse; QKeySequence m_cutWalkThroughWindowsAlternative, m_cutWalkThroughWindowsAlternativeReverse; QKeySequence m_cutWalkThroughCurrentAppWindows, m_cutWalkThroughCurrentAppWindowsReverse; QKeySequence m_cutWalkThroughCurrentAppWindowsAlternative, m_cutWalkThroughCurrentAppWindowsAlternativeReverse; bool m_forcedGlobalMouseGrab; bool m_ready; // indicates whether the config is completely loaded QList m_borderActivate, m_borderAlternativeActivate; QHash m_touchActivate; QHash m_touchAlternativeActivate; QScopedPointer m_x11EventFilter; static TabBox *s_self; }; inline TabBox *TabBox::self() { return s_self; } } // namespace TabBox } // namespace #endif diff --git a/tabbox/tabboxhandler.h b/tabbox/tabboxhandler.h index edf2bf182..e586e06c4 100644 --- a/tabbox/tabboxhandler.h +++ b/tabbox/tabboxhandler.h @@ -1,409 +1,409 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2009 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 TABBOXHANDLER_H #define TABBOXHANDLER_H #include "tabboxconfig.h" #include #include #include #include #include #include /** * @file * This file contains the classes which hide KWin core from tabbox. * It defines the pure virtual classes TabBoxHandler and TabBoxClient. * The classes have to be implemented in KWin Core. * * @author Martin Gräßlin * @since 4.4 **/ class QKeyEvent; namespace KWin { /** * The TabBox is a model based view for displaying a list while switching windows or desktops. * This functionality is mostly referred to as Alt+Tab. TabBox itself does not provide support for * switching windows or desktops. This has to be done outside of TabBox inside an independent controller. * * The main entrance point to TabBox is the class TabBoxHandler, which has to be subclassed and implemented. * The class TabBoxClient, which represents a window client inside TabBox, has to be implemented as well. * * The behavior of the TabBox is defined by the TabBoxConfig and has to be set in the TabBoxHandler. * If the TabBox should be used to switch desktops as well as clients it is sufficient to just provide * different TabBoxConfig objects instead of creating an own handler for each mode. * * In order to use the TabBox the TabBoxConfig has to be set. This defines if the model for desktops or for * clients will be used. The model has to be initialized by calling TabBoxHandler::createModel(), as the * model is undefined when the TabBox is not active. The TabBox is activated by TabBoxHandler::show(). * Depending on the current set TabBoxConfig it is possible that the * highlight windows effect activated and that the view is not displayed at all. As already mentioned * the TabBox does not handle any updating of the selected item. This has to be done by invoking * TabBoxHandler::setCurrentIndex(). Nevertheless the TabBoxHandler provides methods to query for the * model index or the next or previous item, for a cursor position or for a given item (that is * TabBoxClient or desktop). By invoking TabBoxHandler::hide() the view, the * optional highlight windows effect are removed. The model is invalidated immediately. So if it is * necessary to retrieve the last selected item this has to be done before calling the hide method. * * The layout of the TabBox View and the items is completely customizable. Therefore TabBox provides * a widget LayoutConfig which includes a live preview (in kcmkwin/kwintabbox). The layout of items * can be defined by an xml document. That way the user is able to define own custom layouts. The view * itself is made up of two widgets: one to show the complete list and one to show only the selected * item. This way it is possible to have a view which shows for example a list containing only small * icons and nevertheless show the title of the currently selected client. **/ namespace TabBox { class DesktopModel; class ClientModel; class TabBoxConfig; class TabBoxClient; class TabBoxHandlerPrivate; typedef QList< QWeakPointer< TabBoxClient > > TabBoxClientList; /** * This class is a wrapper around KWin Workspace. It is used for accessing the * required core methods from inside TabBox and has to be implemented in KWin core. * * @author Martin Gräßlin * @since 4.4 **/ class TabBoxHandler : public QObject { Q_OBJECT public: TabBoxHandler(QObject *parent); - virtual ~TabBoxHandler(); + ~TabBoxHandler() override; /** * @return The id of the active screen **/ virtual int activeScreen() const = 0; /** * @return The current active TabBoxClient or NULL * if there is no active client. **/ virtual QWeakPointer activeClient() const = 0; /** * @param client The client which is starting point to find the next client * @return The next TabBoxClient in focus chain **/ virtual QWeakPointer nextClientFocusChain(TabBoxClient* client) const = 0; /** * This method is used by the ClientModel to find an entrance into the focus chain in case * there is no active Client. * * @return The first Client of the focus chain * @since 4.9.1 **/ virtual QWeakPointer firstClientFocusChain() const = 0; /** * Checks whether the given @p client is part of the focus chain at all. * This is useful to figure out whether the currently active Client can be used * as a starting point to construct the recently used list. * * In case the @p client is not in the focus chain it is recommended to use the * Client returned by firstClientFocusChain. * * The method accepts a @c null Client and in that case @c false is returned. * @param client The Client to check whether it is in the Focus Chain * @return @c true in case the Client is part of the focus chain, @c false otherwise. * @since 4.9.2 **/ virtual bool isInFocusChain(TabBoxClient* client) const = 0; /** * @param client The client whose desktop name should be retrieved * @return The desktop name of the given TabBoxClient. If the client is * on all desktops the name of current desktop will be returned. **/ virtual QString desktopName(TabBoxClient* client) const = 0; /** * @param desktop The desktop whose name should be retrieved * @return The desktop name of given desktop **/ virtual QString desktopName(int desktop) const = 0; /** * @return The number of current desktop **/ virtual int currentDesktop() const = 0; /** * @return The number of virtual desktops **/ virtual int numberOfDesktops() const = 0; /** * @param desktop The desktop which is the starting point to find the next desktop * @return The next desktop in the current focus chain. **/ virtual int nextDesktopFocusChain(int desktop) const = 0; /** * whether KWin is currently compositing and it's related features (elevating) can be used **/ virtual bool isKWinCompositing() const = 0; /** * De-/Elevate a client using the compositor (if enabled) **/ virtual void elevateClient(TabBoxClient* c, QWindow *tabbox, bool elevate) const = 0; /** * Raise a client (w/o activating it) **/ virtual void raiseClient(TabBoxClient* c) const = 0; /** * @param c The client to be restacked * @param under The client the other one will be placed below **/ virtual void restack(TabBoxClient *c, TabBoxClient *under) = 0; /** * Toggle between ShadeHover and ShadeNormal - not shaded windows are unaffected * @param c The client to be shaded * @param b Whether to un- or shade **/ virtual void shadeClient(TabBoxClient *c, bool b) const = 0; virtual void highlightWindows(TabBoxClient *window = nullptr, QWindow *controller = nullptr) = 0; /** * @return The current stacking order of TabBoxClients **/ virtual TabBoxClientList stackingOrder() const = 0; /** * Determines if given client will be added to the list: *
    *
  • Depends on desktop
  • *
  • if the client wants to have tab focus.
  • *
  • The client won't be added if it has modal dialogs
  • *
  • In that case the modal dialog will be returned if it isn't already * included
  • *
  • Won't be added if it isn't on active screen when using separate * screen focus
  • *
* @param client The client to be checked for inclusion * @param desktop The desktop the client should be on. This is irrelevant if allDesktops is set * @param allDesktops Add clients from all desktops or only from current * @return The client to be included in the list or NULL if it isn't to be included **/ virtual QWeakPointer clientToAddToList(TabBoxClient* client, int desktop) const = 0; /** * @return The first desktop window in the stacking order. **/ virtual QWeakPointer desktopClient() const = 0; /** * Activates the currently selected client and closes the TabBox. **/ virtual void activateAndClose() = 0; /** * @return The currently used TabBoxConfig **/ const TabBoxConfig& config() const; /** * Call this method when you want to change the currently used TabBoxConfig. * It fires the signal configChanged. * @param config Updates the currently used TabBoxConfig to config **/ void setConfig(const TabBoxConfig& config); /** * Call this method to show the TabBoxView. Depending on current * configuration this method might not do anything. * If highlight windows effect is to be used it will be activated. * Highlight windows and outline are not shown if * TabBoxConfig::TabBoxMode is TabBoxConfig::DesktopTabBox. * @see TabBoxConfig::isShowTabBox * @see TabBoxConfig::isHighlightWindows **/ void show(); /** * Hides the TabBoxView if shown. * Deactivates highlight windows effect if active. * @see show **/ void hide(bool abort = false); /** * Sets the current model index in the view and updates * highlight windows if active. * @param index The current Model index **/ void setCurrentIndex(const QModelIndex& index); /** * @returns the current index **/ const QModelIndex ¤tIndex() const; /** * Retrieves the next or previous item of the current item. * @param forward next or previous item * @return The next or previous item. If there is no matching item * the current item will be returned. **/ QModelIndex nextPrev(bool forward) const; /** * Initializes the model based on the current config. * This method has to be invoked before showing the TabBox. * It can also be invoked when clients are added or removed. * In that case partialReset has to be true. * * @param partialReset Keep the currently selected item or regenerate everything **/ void createModel(bool partialReset = false); /** * @param desktop The desktop whose index should be retrieved * @return The model index of given desktop. If TabBoxMode is not * TabBoxConfig::DesktopTabBox an invalid model index will be returned. **/ QModelIndex desktopIndex(int desktop) const; /** * @return The current list of desktops. * If TabBoxMode is not TabBoxConfig::DesktopTabBox an empty list will * be returned. * @see DesktopModel::desktopList **/ QList< int > desktopList() const; /** * @return The desktop for given model index. If the index is not valid * or TabBoxMode is not TabBoxConfig::DesktopTabBox -1 will be returned. * @see DesktopModel::desktopIndex **/ int desktop(const QModelIndex& index) const; /** * Handles additional grabbed key events by the TabBox controller. * @param event The key event which has been grabbed **/ virtual void grabbedKeyEvent(QKeyEvent* event) const; /** * @param pos The position to be tested in global coordinates * @return True if the view contains the point, otherwise false. **/ bool containsPos(const QPoint& pos) const; /** * @param client The TabBoxClient whose index should be returned * @return Returns the ModelIndex of given TabBoxClient or an invalid ModelIndex * if the model does not contain the given TabBoxClient. * @see ClientModel::index **/ QModelIndex index(QWeakPointer client) const; /** * @return Returns the current list of TabBoxClients. * If TabBoxMode is not TabBoxConfig::ClientTabBox an empty list will * be returned. * @see ClientModel::clientList **/ TabBoxClientList clientList() const; /** * @param index The index of the client to be returned * @return Returns the TabBoxClient at given model index. If * the index is invalid, does not point to a Client or the list * is empty, NULL will be returned. **/ TabBoxClient* client(const QModelIndex& index) const; /** * @return The first model index. That is the model index at position 0, 0. * It is valid, as desktop has at least one desktop and if there are no * clients an empty item is created. **/ QModelIndex first() const; bool eventFilter(QObject *watcher, QEvent *event) override; /** * @returns whether the TabBox operates in a no modifier grab mode. * In this mode a click on an item should directly accept and close the tabbox. **/ virtual bool noModifierGrab() const = 0; Q_SIGNALS: /** * This signal is fired when the TabBoxConfig changes * @see setConfig **/ void configChanged(); void selectedIndexChanged(); private Q_SLOTS: void initHighlightWindows(); private: friend class TabBoxHandlerPrivate; TabBoxHandlerPrivate* d; }; /** * This class is a wrapper around a KWin Client. It is used for accessing the * required client methods from inside TabBox and has to be implemented in KWin core. * * @author Martin Gräßlin * @since 4.4 **/ class TabBoxClient { public: TabBoxClient(); virtual ~TabBoxClient(); /** * @return The caption of the client **/ virtual QString caption() const = 0; /** * @param size Requested size of the icon * @return The icon of the client **/ virtual QIcon icon() const = 0; /** * @return The window Id of the client **/ virtual WId window() const = 0; /** * @return Minimized state of the client **/ virtual bool isMinimized() const = 0; virtual int x() const = 0; virtual int y() const = 0; virtual int width() const = 0; virtual int height() const = 0; virtual bool isCloseable() const = 0; virtual void close() = 0; virtual bool isFirstInTabBox() const = 0; virtual QUuid internalId() const = 0; }; /** * Pointer to the global TabBoxHandler object. **/ extern TabBoxHandler* tabBox; } // namespace TabBox } // namespace KWin #endif // TABBOXHANDLER_H diff --git a/tabletmodemanager.h b/tabletmodemanager.h index add1076cb..6b0aa51d5 100644 --- a/tabletmodemanager.h +++ b/tabletmodemanager.h @@ -1,61 +1,61 @@ /* * Copyright 2018 Marco Martin * * 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 . * */ #ifndef KWIN_TABLETMODEMANAGER_H #define KWIN_TABLETMODEMANAGER_H #include #include namespace KWin { class TabletModeManager : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.KWin.TabletModeManager") //assuming such a switch is not pluggable for now Q_PROPERTY(bool tabletModeAvailable READ isTabletModeAvailable NOTIFY tabletModeAvailableChanged) Q_PROPERTY(bool tabletMode READ isTablet NOTIFY tabletModeChanged) public: - ~TabletModeManager() = default; + ~TabletModeManager() override = default; void setTabletModeAvailable(bool detecting); bool isTabletModeAvailable() const; bool isTablet() const; void setIsTablet(bool tablet); Q_SIGNALS: void tabletModeAvailableChanged(bool available); void tabletModeChanged(bool tabletMode); private: void hasTabletModeInputChanged(bool set); bool m_tabletModeAvailable = false; bool m_isTabletMode = false; bool m_detecting = false; KWIN_SINGLETON_VARIABLE(TabletModeManager, s_manager) }; } #endif // KWIN_TABLETMODEMANAGER_H diff --git a/tests/cursorhotspottest.cpp b/tests/cursorhotspottest.cpp index efc3916e3..ad72be8b8 100644 --- a/tests/cursorhotspottest.cpp +++ b/tests/cursorhotspottest.cpp @@ -1,157 +1,157 @@ /* * Copyright 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) 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 . */ #include #include #include #include #include class MouseCursorWidget : public QWidget { Q_OBJECT public: explicit MouseCursorWidget(); - ~MouseCursorWidget(); + ~MouseCursorWidget() override; protected: void paintEvent(QPaintEvent * event) override; void mouseMoveEvent(QMouseEvent * event) override; void keyPressEvent(QKeyEvent * event) override; private: QPoint m_cursorPos; QCursor m_cursors[5]; int m_cursorIndex = 0; }; namespace { QCursor createCenterHotspotCursor() { QPixmap cursor(64, 64); cursor.fill(Qt::transparent); QPainter p(&cursor); p.setPen(Qt::black); const QPoint center = cursor.rect().center(); p.drawLine(0, center.y(), center.x()-1, center.y()); p.drawLine(center.x() + 1, center.y(), cursor.width(), center.y()); p.drawLine(center.x(), 0, center.x(), center.y() -1); p.drawLine(center.x(), center.y() + 1, center.x(), cursor.height()); return QCursor(cursor, 31, 31); } QCursor createTopLeftHotspotCursor() { QPixmap cursor(64, 64); cursor.fill(Qt::transparent); QPainter p(&cursor); p.setPen(Qt::black); p.drawLine(0, 1, 0, cursor.height()); p.drawLine(1, 0, cursor.width(), 0); return QCursor(cursor, 0, 0); } QCursor createTopRightHotspotCursor() { QPixmap cursor(64, 64); cursor.fill(Qt::transparent); QPainter p(&cursor); p.setPen(Qt::black); p.drawLine(cursor.width() -1, 1, cursor.width() -1, cursor.height()); p.drawLine(0, 0, cursor.width() -2, 0); return QCursor(cursor, 63, 0); } QCursor createButtomRightHotspotCursor() { QPixmap cursor(64, 64); cursor.fill(Qt::transparent); QPainter p(&cursor); p.setPen(Qt::black); p.drawLine(cursor.width() -1, 0, cursor.width() -1, cursor.height() - 2); p.drawLine(0, cursor.height()-1, cursor.width() -2, cursor.height()-1); return QCursor(cursor, 63, 63); } QCursor createButtomLeftHotspotCursor() { QPixmap cursor(64, 64); cursor.fill(Qt::transparent); QPainter p(&cursor); p.setPen(Qt::black); p.drawLine(0, 0, 0, cursor.height() - 2); p.drawLine(1, cursor.height()-1, cursor.width(), cursor.height()-1); return QCursor(cursor, 0, 63); } } MouseCursorWidget::MouseCursorWidget() : QWidget() { setMouseTracking(true); // create cursors m_cursors[0] = createCenterHotspotCursor(); m_cursors[1] = createTopLeftHotspotCursor(); m_cursors[2] = createTopRightHotspotCursor(); m_cursors[3] = createButtomRightHotspotCursor(); m_cursors[4] = createButtomLeftHotspotCursor(); setCursor(m_cursors[m_cursorIndex]); } MouseCursorWidget::~MouseCursorWidget() = default; void MouseCursorWidget::paintEvent(QPaintEvent *event) { Q_UNUSED(event) QPainter p(this); p.fillRect(0, 0, width(), height(), Qt::white); if (geometry().contains(m_cursorPos)) { p.setPen(Qt::red); p.drawPoint(m_cursorPos); } } void MouseCursorWidget::mouseMoveEvent(QMouseEvent *event) { m_cursorPos = event->pos(); update(); } void MouseCursorWidget::keyPressEvent(QKeyEvent* event) { if (event->key() == Qt::Key_Space) { m_cursorIndex = (m_cursorIndex + 1) % 5; setCursor(m_cursors[m_cursorIndex]); } } int main(int argc, char *argv[]) { QApplication app(argc, argv); MouseCursorWidget widget; widget.show(); return app.exec(); } #include "cursorhotspottest.moc" diff --git a/tests/pointergesturestest.cpp b/tests/pointergesturestest.cpp index f096de729..7f433981c 100644 --- a/tests/pointergesturestest.cpp +++ b/tests/pointergesturestest.cpp @@ -1,168 +1,168 @@ /* * Copyright 2016 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) 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 . */ #include #include #include #include #include #include #include #include using namespace KWayland::Client; class PinchGesture : public QQuickItem { Q_OBJECT Q_PROPERTY(qreal scale READ scale NOTIFY scaleChanged) Q_PROPERTY(qreal progressScale READ progressScale NOTIFY progressScaleChanged) public: explicit PinchGesture(QQuickItem *parent = nullptr); - virtual ~PinchGesture(); + ~PinchGesture() override; qreal scale() const { return m_scale; } qreal progressScale() const { return m_progressScale; } protected: void componentComplete() override; Q_SIGNALS: void scaleChanged(); void progressScaleChanged(); private: void initWayland(); void setupGesture(); Pointer *m_pointer = nullptr; PointerGestures *m_pointerGestures = nullptr; PointerPinchGesture *m_gesture = nullptr; qreal m_scale = 1.0; qreal m_progressScale = 1.0; }; PinchGesture::PinchGesture(QQuickItem* parent) : QQuickItem(parent) { } PinchGesture::~PinchGesture() = default; void PinchGesture::componentComplete() { QQuickItem::componentComplete(); initWayland(); } void PinchGesture::initWayland() { auto c = ConnectionThread::fromApplication(this); Registry *r = new Registry(c); r->create(c); connect(r, &Registry::interfacesAnnounced, this, [this, r] { const auto gi = r->interface(Registry::Interface::PointerGesturesUnstableV1); if (gi.name == 0) { return; } m_pointerGestures = r->createPointerGestures(gi.name, gi.version, this); // now create seat const auto si = r->interface(Registry::Interface::Seat); if (si.name == 0) { return; } auto seat = r->createSeat(si.name, si.version, this); connect(seat, &Seat::hasKeyboardChanged, this, [this, seat] (bool hasPointer) { if (hasPointer) { m_pointer = seat->createPointer(this); setupGesture(); } else { delete m_pointer; delete m_gesture; m_pointer = nullptr; m_gesture = nullptr; } } ); } ); r->setup(); c->roundtrip(); } void PinchGesture::setupGesture() { if (m_gesture || !m_pointerGestures || !m_pointer) { return; } m_gesture = m_pointerGestures->createPinchGesture(m_pointer, this); connect(m_gesture, &PointerPinchGesture::updated, this, [this] (const QSizeF &delta, qreal scale) { Q_UNUSED(delta) m_progressScale = scale; emit progressScaleChanged(); } ); connect(m_gesture, &PointerPinchGesture::ended, this, [this] { m_scale = m_scale * m_progressScale; m_progressScale = 1.0; emit scaleChanged(); emit progressScaleChanged(); } ); connect(m_gesture, &PointerPinchGesture::cancelled, this, [this] { m_progressScale = 1.0; emit progressScaleChanged(); } ); } int main(int argc, char *argv[]) { qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("wayland")); QGuiApplication app(argc, argv); qmlRegisterType("org.kde.kwin.tests", 1, 0, "PinchGesture"); QQuickView view; view.setSource(QUrl::fromLocalFile(QStringLiteral(DIR) +QStringLiteral("/pointergesturestest.qml"))); view.show(); return app.exec(); } #include "pointergesturestest.moc" diff --git a/tests/screenedgeshowtest.cpp b/tests/screenedgeshowtest.cpp index 804fd366d..9fbaf1927 100644 --- a/tests/screenedgeshowtest.cpp +++ b/tests/screenedgeshowtest.cpp @@ -1,361 +1,361 @@ /* * Copyright 2014 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) 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 . */ #include #include #include #include #include #include #include #include #include #include #include #include #include "../xcbutils.h" #include #include #include #include #include class ScreenEdgeHelper : public QObject { Q_OBJECT protected: ScreenEdgeHelper(QWidget *widget, QObject *parent = nullptr); QWindow *window() const { return m_widget->windowHandle(); } virtual void restore() = 0; public: - virtual ~ScreenEdgeHelper(); + ~ScreenEdgeHelper() override; virtual void hide() = 0; virtual void raiseOrShow(bool raise) = 0; virtual void init() {}; virtual void moveToTop(); virtual void moveToRight(); virtual void moveToBottom(); virtual void moveToLeft(); virtual void moveToFloating(); void hideAndRestore() { hide(); m_timer->start(10000); } private: QWidget *m_widget; QTimer *m_timer; }; class ScreenEdgeHelperX11 : public ScreenEdgeHelper { Q_OBJECT public: ScreenEdgeHelperX11(QWidget *widget, QObject *parent = nullptr); - virtual ~ScreenEdgeHelperX11() = default; + ~ScreenEdgeHelperX11() override = default; void hide() override; void raiseOrShow(bool raise) override; void moveToTop() override; void moveToRight() override; void moveToBottom() override; void moveToLeft() override; void moveToFloating() override; protected: void restore() override; private: uint32_t m_locationValue = 2; uint32_t m_actionValue = 0; KWin::Xcb::Atom m_atom; }; class ScreenEdgeHelperWayland : public ScreenEdgeHelper { Q_OBJECT public: ScreenEdgeHelperWayland(QWidget *widget, QObject *parent = nullptr); - virtual ~ScreenEdgeHelperWayland() = default; + ~ScreenEdgeHelperWayland() override = default; void hide() override; void raiseOrShow(bool raise) override; void init() override; bool eventFilter(QObject * watched, QEvent * event) override; protected: void restore() override; private: void setupSurface(); KWayland::Client::PlasmaShell *m_shell = nullptr; KWayland::Client::PlasmaShellSurface *m_shellSurface = nullptr; bool m_autoHide = true; }; ScreenEdgeHelper::ScreenEdgeHelper(QWidget *widget, QObject *parent) : QObject(parent) , m_widget(widget) , m_timer(new QTimer(this)) { m_timer->setSingleShot(true); connect(m_timer, &QTimer::timeout, this, &ScreenEdgeHelper::restore); } ScreenEdgeHelper::~ScreenEdgeHelper() = default; void ScreenEdgeHelper::moveToTop() { const QRect geo = QGuiApplication::primaryScreen()->geometry(); m_widget->setGeometry(geo.x(), geo.y(), geo.width(), 100); } void ScreenEdgeHelper::moveToRight() { const QRect geo = QGuiApplication::primaryScreen()->geometry(); m_widget->setGeometry(geo.x(), geo.y(), geo.width(), 100); } void ScreenEdgeHelper::moveToBottom() { const QRect geo = QGuiApplication::primaryScreen()->geometry(); m_widget->setGeometry(geo.x(), geo.y() + geo.height() - 100, geo.width(), 100); } void ScreenEdgeHelper::moveToLeft() { const QRect geo = QGuiApplication::primaryScreen()->geometry(); m_widget->setGeometry(geo.x(), geo.y(), 100, geo.height()); } void ScreenEdgeHelper::moveToFloating() { const QRect geo = QGuiApplication::primaryScreen()->geometry(); m_widget->setGeometry(QRect(geo.center(), QSize(100, 100))); } ScreenEdgeHelperX11::ScreenEdgeHelperX11(QWidget *widget, QObject *parent) : ScreenEdgeHelper(widget, parent) , m_atom(QByteArrayLiteral("_KDE_NET_WM_SCREEN_EDGE_SHOW")) { } void ScreenEdgeHelperX11::hide() { uint32_t value = m_locationValue | (m_actionValue << 8); xcb_change_property(QX11Info::connection(), XCB_PROP_MODE_REPLACE, window()->winId(), m_atom, XCB_ATOM_CARDINAL, 32, 1, &value); } void ScreenEdgeHelperX11::restore() { xcb_delete_property(QX11Info::connection(), window()->winId(), m_atom); } void ScreenEdgeHelperX11::raiseOrShow(bool raise) { m_actionValue = raise ? 1: 0; } void ScreenEdgeHelperX11::moveToBottom() { ScreenEdgeHelper::moveToBottom(); m_locationValue = 2; } void ScreenEdgeHelperX11::moveToFloating() { ScreenEdgeHelper::moveToFloating(); m_locationValue = 4; } void ScreenEdgeHelperX11::moveToLeft() { ScreenEdgeHelper::moveToLeft(); m_locationValue = 3; } void ScreenEdgeHelperX11::moveToRight() { ScreenEdgeHelper::moveToRight(); m_locationValue = 1; } void ScreenEdgeHelperX11::moveToTop() { ScreenEdgeHelper::moveToTop(); m_locationValue = 0; } using namespace KWayland::Client; ScreenEdgeHelperWayland::ScreenEdgeHelperWayland(QWidget *widget, QObject *parent) : ScreenEdgeHelper(widget, parent) { ConnectionThread *connection = ConnectionThread::fromApplication(this); Registry *registry = new Registry(connection); registry->create(connection); connect(registry, &Registry::interfacesAnnounced, this, [registry, this] { const auto interface = registry->interface(Registry::Interface::PlasmaShell); if (interface.name == 0) { return; } m_shell = registry->createPlasmaShell(interface.name, interface.version); } ); registry->setup(); connection->roundtrip(); } void ScreenEdgeHelperWayland::init() { window()->installEventFilter(this); setupSurface(); } void ScreenEdgeHelperWayland::setupSurface() { if (!m_shell) { return; } if (auto s = Surface::fromWindow(window())) { m_shellSurface = m_shell->createSurface(s, window()); m_shellSurface->setRole(PlasmaShellSurface::Role::Panel); m_shellSurface->setPanelBehavior(PlasmaShellSurface::PanelBehavior::AutoHide); m_shellSurface->setPosition(window()->position()); } } void ScreenEdgeHelperWayland::hide() { if (m_shellSurface && m_autoHide) { m_shellSurface->requestHideAutoHidingPanel(); } } void ScreenEdgeHelperWayland::restore() { if (m_shellSurface && m_autoHide) { m_shellSurface->requestShowAutoHidingPanel(); } } void ScreenEdgeHelperWayland::raiseOrShow(bool raise) { m_autoHide = !raise; if (m_shellSurface) { if (raise) { m_shellSurface->setPanelBehavior(PlasmaShellSurface::PanelBehavior::WindowsCanCover); } else { m_shellSurface->setPanelBehavior(PlasmaShellSurface::PanelBehavior::AutoHide); } } } bool ScreenEdgeHelperWayland::eventFilter(QObject *watched, QEvent *event) { if (watched != window() || !m_shell) { return false; } if (event->type() == QEvent::PlatformSurface) { QPlatformSurfaceEvent *pe = static_cast(event); if (pe->surfaceEventType() == QPlatformSurfaceEvent::SurfaceCreated) { setupSurface(); } else { delete m_shellSurface; m_shellSurface = nullptr; } } if (event->type() == QEvent::Move) { if (m_shellSurface) { m_shellSurface->setPosition(window()->position()); } } return false; } int main(int argc, char **argv) { QApplication app(argc, argv); QApplication::setApplicationDisplayName(QStringLiteral("Screen Edge Show Test App")); ScreenEdgeHelper *helper = nullptr; QScopedPointer widget(new QWidget(nullptr, Qt::FramelessWindowHint)); if (KWindowSystem::isPlatformX11()) { app.setProperty("x11Connection", QVariant::fromValue(QX11Info::connection())); helper = new ScreenEdgeHelperX11(widget.data(), &app); } else if (KWindowSystem::isPlatformWayland()) { helper = new ScreenEdgeHelperWayland(widget.data(), &app); } if (!helper) { return 2; } QPushButton *hideWindowButton = new QPushButton(QStringLiteral("Hide"), widget.data()); QObject::connect(hideWindowButton, &QPushButton::clicked, helper, &ScreenEdgeHelper::hide); QPushButton *hideAndRestoreButton = new QPushButton(QStringLiteral("Hide and Restore after 10 sec"), widget.data()); QObject::connect(hideAndRestoreButton, &QPushButton::clicked, helper, &ScreenEdgeHelper::hideAndRestore); QToolButton *edgeButton = new QToolButton(widget.data()); QCheckBox *raiseCheckBox = new QCheckBox("Raise:", widget.data()); QObject::connect(raiseCheckBox, &QCheckBox::toggled, helper, &ScreenEdgeHelper::raiseOrShow); edgeButton->setText(QStringLiteral("Edge")); edgeButton->setPopupMode(QToolButton::MenuButtonPopup); QMenu *edgeButtonMenu = new QMenu(edgeButton); QObject::connect(edgeButtonMenu->addAction("Top"), &QAction::triggered, helper, &ScreenEdgeHelper::moveToTop); QObject::connect(edgeButtonMenu->addAction("Right"), &QAction::triggered, helper, &ScreenEdgeHelper::moveToRight); QObject::connect(edgeButtonMenu->addAction("Bottom"), &QAction::triggered, helper, &ScreenEdgeHelper::moveToBottom); QObject::connect(edgeButtonMenu->addAction("Left"), &QAction::triggered, helper, &ScreenEdgeHelper::moveToLeft); edgeButtonMenu->addSeparator(); QObject::connect(edgeButtonMenu->addAction("Floating"), &QAction::triggered, helper, &ScreenEdgeHelper::moveToFloating); edgeButton->setMenu(edgeButtonMenu); QHBoxLayout *layout = new QHBoxLayout(widget.data()); layout->addWidget(hideWindowButton); layout->addWidget(hideAndRestoreButton); layout->addWidget(edgeButton); widget->setLayout(layout); const QRect geo = QGuiApplication::primaryScreen()->geometry(); widget->setGeometry(geo.x(), geo.y() + geo.height() - 100, geo.width(), 100); widget->show(); helper->init(); return app.exec(); } #include "screenedgeshowtest.moc" diff --git a/tests/waylandclienttest.h b/tests/waylandclienttest.h index 7d8b54a88..652556339 100644 --- a/tests/waylandclienttest.h +++ b/tests/waylandclienttest.h @@ -1,74 +1,74 @@ /* * Copyright 2014 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) 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 . */ #ifndef WAYLANDCLIENTTEST_H #define WAYLANDCLIENTTEST_H #include #include namespace KWayland { namespace Client { class Compositor; class ConnectionThread; class EventQueue; class Output; class Registry; class ShellSurface; class ShmPool; class Surface; } } class QThread; class QTimer; class WaylandClientTest : public QObject { Q_OBJECT public: explicit WaylandClientTest(QObject *parent = nullptr); - virtual ~WaylandClientTest(); + ~WaylandClientTest() override; private: void init(); void render(const QSize &size); void render(); void setupRegistry(KWayland::Client::Registry *registry); void toggleTimer(); QThread *m_connectionThread; KWayland::Client::ConnectionThread *m_connectionThreadObject; KWayland::Client::EventQueue *m_eventQueue; KWayland::Client::Compositor *m_compositor; KWayland::Client::Output *m_output; KWayland::Client::Surface *m_surface; KWayland::Client::ShmPool *m_shm; KWayland::Client::ShellSurface *m_shellSurface; QSize m_currentSize; QTimer *m_timer; struct { KWayland::Client::Surface *surface = nullptr; KWayland::Client::ShellSurface *shellSurface = nullptr; bool visible = false; } m_transient; }; #endif diff --git a/thumbnailitem.h b/thumbnailitem.h index b40ad94ca..8cbee2cb8 100644 --- a/thumbnailitem.h +++ b/thumbnailitem.h @@ -1,150 +1,150 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2011 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_THUMBNAILITEM_H #define KWIN_THUMBNAILITEM_H #include #include #include #include namespace KWin { class AbstractClient; class EffectWindow; class EffectWindowImpl; class AbstractThumbnailItem : public QQuickPaintedItem { Q_OBJECT Q_PROPERTY(qreal brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged) Q_PROPERTY(qreal saturation READ saturation WRITE setSaturation NOTIFY saturationChanged) Q_PROPERTY(QQuickItem *clipTo READ clipTo WRITE setClipTo NOTIFY clipToChanged) public: - virtual ~AbstractThumbnailItem(); + ~AbstractThumbnailItem() override; qreal brightness() const; qreal saturation() const; QQuickItem *clipTo() const; public Q_SLOTS: void setBrightness(qreal brightness); void setSaturation(qreal saturation); void setClipTo(QQuickItem *clip); Q_SIGNALS: void brightnessChanged(); void saturationChanged(); void clipToChanged(); protected: explicit AbstractThumbnailItem(QQuickItem *parent = 0); protected Q_SLOTS: virtual void repaint(KWin::EffectWindow* w) = 0; private Q_SLOTS: void init(); void effectWindowAdded(); void compositingToggled(); private: void findParentEffectWindow(); QWeakPointer m_parent; qreal m_brightness; qreal m_saturation; QPointer m_clipToItem; }; class WindowThumbnailItem : public AbstractThumbnailItem { Q_OBJECT Q_PROPERTY(QUuid wId READ wId WRITE setWId NOTIFY wIdChanged SCRIPTABLE true) Q_PROPERTY(KWin::AbstractClient *client READ client WRITE setClient NOTIFY clientChanged) public: explicit WindowThumbnailItem(QQuickItem *parent = 0); - virtual ~WindowThumbnailItem(); + ~WindowThumbnailItem() override; QUuid wId() const { return m_wId; } void setWId(const QUuid &wId); AbstractClient *client() const; void setClient(AbstractClient *client); - virtual void paint(QPainter *painter); + void paint(QPainter *painter) override; Q_SIGNALS: void wIdChanged(const QUuid &wid); void clientChanged(); protected Q_SLOTS: - virtual void repaint(KWin::EffectWindow* w); + void repaint(KWin::EffectWindow* w) override; private: QUuid m_wId; AbstractClient *m_client; }; class DesktopThumbnailItem : public AbstractThumbnailItem { Q_OBJECT Q_PROPERTY(int desktop READ desktop WRITE setDesktop NOTIFY desktopChanged) public: DesktopThumbnailItem(QQuickItem *parent = 0); - virtual ~DesktopThumbnailItem(); + ~DesktopThumbnailItem() override; int desktop() const { return m_desktop; } void setDesktop(int desktop); - virtual void paint(QPainter *painter); + void paint(QPainter *painter) override; Q_SIGNALS: void desktopChanged(int desktop); protected Q_SLOTS: - virtual void repaint(KWin::EffectWindow* w); + void repaint(KWin::EffectWindow* w) override; private: int m_desktop; }; inline qreal AbstractThumbnailItem::brightness() const { return m_brightness; } inline qreal AbstractThumbnailItem::saturation() const { return m_saturation; } inline QQuickItem* AbstractThumbnailItem::clipTo() const { return m_clipToItem.data(); } inline AbstractClient *WindowThumbnailItem::client() const { return m_client; } } // KWin #endif // KWIN_THUMBNAILITEM_H diff --git a/toplevel.h b/toplevel.h index fe32ae056..7b3dd452c 100644 --- a/toplevel.h +++ b/toplevel.h @@ -1,958 +1,958 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2006 Lubos Lunak 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_TOPLEVEL_H #define KWIN_TOPLEVEL_H // kwin #include "input.h" #include "utils.h" #include "virtualdesktops.h" #include "xcbutils.h" // KDE #include // Qt #include #include #include // xcb #include #include // XLib #include #include // c++ #include #include class QOpenGLFramebufferObject; namespace KWayland { namespace Server { class SurfaceInterface; } } namespace KWin { class ClientMachine; class EffectWindowImpl; class Shadow; /** * Enum to describe the reason why a Toplevel has to be released. **/ enum class ReleaseReason { Release, ///< Normal Release after e.g. an Unmap notify event (window still valid) Destroyed, ///< Release after an Destroy notify event (window no longer valid) KWinShutsDown ///< Release on KWin Shutdown (window still valid) }; class KWIN_EXPORT Toplevel : public QObject { Q_OBJECT Q_PROPERTY(bool alpha READ hasAlpha NOTIFY hasAlphaChanged) Q_PROPERTY(qulonglong frameId READ frameId) Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged) Q_PROPERTY(QRect visibleRect READ visibleRect) Q_PROPERTY(int height READ height) Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) Q_PROPERTY(QPoint pos READ pos) Q_PROPERTY(int screen READ screen NOTIFY screenChanged) Q_PROPERTY(QSize size READ size) Q_PROPERTY(int width READ width) Q_PROPERTY(qulonglong windowId READ windowId CONSTANT) Q_PROPERTY(int x READ x) Q_PROPERTY(int y READ y) Q_PROPERTY(int desktop READ desktop) /** * Whether the window is on all desktops. That is desktop is -1. **/ Q_PROPERTY(bool onAllDesktops READ isOnAllDesktops) Q_PROPERTY(QRect rect READ rect) Q_PROPERTY(QPoint clientPos READ clientPos) Q_PROPERTY(QSize clientSize READ clientSize) Q_PROPERTY(QByteArray resourceName READ resourceName NOTIFY windowClassChanged) Q_PROPERTY(QByteArray resourceClass READ resourceClass NOTIFY windowClassChanged) Q_PROPERTY(QByteArray windowRole READ windowRole NOTIFY windowRoleChanged) /** * Returns whether the window is a desktop background window (the one with wallpaper). * See _NET_WM_WINDOW_TYPE_DESKTOP at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool desktopWindow READ isDesktop) /** * Returns whether the window is a dock (i.e. a panel). * See _NET_WM_WINDOW_TYPE_DOCK at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool dock READ isDock) /** * Returns whether the window is a standalone (detached) toolbar window. * See _NET_WM_WINDOW_TYPE_TOOLBAR at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool toolbar READ isToolbar) /** * Returns whether the window is a torn-off menu. * See _NET_WM_WINDOW_TYPE_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool menu READ isMenu) /** * Returns whether the window is a "normal" window, i.e. an application or any other window * for which none of the specialized window types fit. * See _NET_WM_WINDOW_TYPE_NORMAL at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool normalWindow READ isNormalWindow) /** * Returns whether the window is a dialog window. * See _NET_WM_WINDOW_TYPE_DIALOG at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool dialog READ isDialog) /** * Returns whether the window is a splashscreen. Note that many (especially older) applications * do not support marking their splash windows with this type. * See _NET_WM_WINDOW_TYPE_SPLASH at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool splash READ isSplash) /** * Returns whether the window is a utility window, such as a tool window. * See _NET_WM_WINDOW_TYPE_UTILITY at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool utility READ isUtility) /** * Returns whether the window is a dropdown menu (i.e. a popup directly or indirectly open * from the applications menubar). * See _NET_WM_WINDOW_TYPE_DROPDOWN_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool dropdownMenu READ isDropdownMenu) /** * Returns whether the window is a popup menu (that is not a torn-off or dropdown menu). * See _NET_WM_WINDOW_TYPE_POPUP_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool popupMenu READ isPopupMenu) /** * Returns whether the window is a tooltip. * See _NET_WM_WINDOW_TYPE_TOOLTIP at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool tooltip READ isTooltip) /** * Returns whether the window is a window with a notification. * See _NET_WM_WINDOW_TYPE_NOTIFICATION at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool notification READ isNotification) /** * Returns whether the window is a window with a critical notification. **/ Q_PROPERTY(bool criticalNotification READ isCriticalNotification) /** * Returns whether the window is an On Screen Display. **/ Q_PROPERTY(bool onScreenDisplay READ isOnScreenDisplay) /** * Returns whether the window is a combobox popup. * See _NET_WM_WINDOW_TYPE_COMBO at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool comboBox READ isComboBox) /** * Returns whether the window is a Drag&Drop icon. * See _NET_WM_WINDOW_TYPE_DND at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(bool dndIcon READ isDNDIcon) /** * Returns the NETWM window type * See https://standards.freedesktop.org/wm-spec/wm-spec-latest.html . **/ Q_PROPERTY(int windowType READ windowType) Q_PROPERTY(QStringList activities READ activities NOTIFY activitiesChanged) /** * Whether this Toplevel is managed by KWin (it has control over its placement and other * aspects, as opposed to override-redirect windows that are entirely handled by the application). **/ Q_PROPERTY(bool managed READ isClient CONSTANT) /** * Whether this Toplevel represents an already deleted window and only kept for the compositor for animations. **/ Q_PROPERTY(bool deleted READ isDeleted CONSTANT) /** * Whether the window has an own shape **/ Q_PROPERTY(bool shaped READ shape NOTIFY shapedChanged) /** * Whether the window does not want to be animated on window close. * There are legit reasons for this like a screenshot application which does not want it's * window being captured. **/ Q_PROPERTY(bool skipsCloseAnimation READ skipsCloseAnimation WRITE setSkipCloseAnimation NOTIFY skipCloseAnimationChanged) /** * The Id of the Wayland Surface associated with this Toplevel. * On X11 only setups the value is @c 0. **/ Q_PROPERTY(quint32 surfaceId READ surfaceId NOTIFY surfaceIdChanged) /** * Interface to the Wayland Surface. * Relevant only in Wayland, in X11 it will be nullptr **/ Q_PROPERTY(KWayland::Server::SurfaceInterface *surface READ surface) /** * Whether the window is a popup. **/ Q_PROPERTY(bool popupWindow READ isPopupWindow) /** * Whether this Toplevel represents the outline. * * @note It's always @c false if compositing is turned off. **/ Q_PROPERTY(bool outline READ isOutline) public: explicit Toplevel(); virtual xcb_window_t frameId() const; xcb_window_t window() const; /** * @return a unique identifier for the Toplevel. On X11 same as @ref window **/ virtual quint32 windowId() const; QRect geometry() const; /** * The geometry of the Toplevel which accepts input events. This might be larger * than the actual geometry, e.g. to support resizing outside the window. * * Default implementation returns same as geometry. **/ virtual QRect inputGeometry() const; QSize size() const; QPoint pos() const; QRect rect() const; int x() const; int y() const; int width() const; int height() const; bool isOnScreen(int screen) const; // true if it's at least partially there bool isOnActiveScreen() const; int screen() const; // the screen where the center is /** * The scale of the screen this window is currently on * @note The buffer scale can be different. * @since 5.12 **/ qreal screenScale() const; // virtual QPoint clientPos() const = 0; // inside of geometry() /** * Describes how the client's content maps to the window geometry including the frame. * The default implementation is a 1:1 mapping meaning the frame is part of the content. **/ virtual QPoint clientContentPos() const; virtual QSize clientSize() const = 0; virtual QRect visibleRect() const; // the area the window occupies on the screen virtual QRect decorationRect() const; // rect including the decoration shadows virtual QRect transparentRect() const = 0; virtual bool isClient() const; virtual bool isDeleted() const; // prefer isXXX() instead // 0 for supported types means default for managed/unmanaged types virtual NET::WindowType windowType(bool direct = false, int supported_types = 0) const = 0; bool hasNETSupport() const; bool isDesktop() const; bool isDock() const; bool isToolbar() const; bool isMenu() const; bool isNormalWindow() const; // normal as in 'NET::Normal or NET::Unknown non-transient' bool isDialog() const; bool isSplash() const; bool isUtility() const; bool isDropdownMenu() const; bool isPopupMenu() const; // a context popup, not dropdown, not torn-off bool isTooltip() const; bool isNotification() const; bool isCriticalNotification() const; bool isOnScreenDisplay() const; bool isComboBox() const; bool isDNDIcon() const; virtual bool isLockScreen() const; virtual bool isInputMethod() const; virtual bool isOutline() const; /** * Returns the virtual desktop within the workspace() the client window * is located in, 0 if it isn't located on any special desktop (not mapped yet), * or NET::OnAllDesktops. Do not use desktop() directly, use * isOnDesktop() instead. **/ virtual int desktop() const = 0; virtual QVector desktops() const = 0; virtual QStringList activities() const = 0; bool isOnDesktop(int d) const; bool isOnActivity(const QString &activity) const; bool isOnCurrentDesktop() const; bool isOnCurrentActivity() const; bool isOnAllDesktops() const; bool isOnAllActivities() const; virtual QByteArray windowRole() const; QByteArray sessionId() const; QByteArray resourceName() const; QByteArray resourceClass() const; QByteArray wmCommand(); QByteArray wmClientMachine(bool use_localhost) const; const ClientMachine *clientMachine() const; virtual bool isLocalhost() const; Window wmClientLeader() const; virtual pid_t pid() const; static bool resourceMatch(const Toplevel* c1, const Toplevel* c2); bool readyForPainting() const; // true if the window has been already painted its contents xcb_visualid_t visual() const; bool shape() const; QRegion inputShape() const; virtual void setOpacity(double opacity); virtual double opacity() const; int depth() const; bool hasAlpha() const; virtual bool setupCompositing(); virtual void finishCompositing(ReleaseReason releaseReason = ReleaseReason::Release); Q_INVOKABLE void addRepaint(const QRect& r); Q_INVOKABLE void addRepaint(const QRegion& r); Q_INVOKABLE void addRepaint(int x, int y, int w, int h); Q_INVOKABLE void addLayerRepaint(const QRect& r); Q_INVOKABLE void addLayerRepaint(const QRegion& r); Q_INVOKABLE void addLayerRepaint(int x, int y, int w, int h); Q_INVOKABLE virtual void addRepaintFull(); // these call workspace->addRepaint(), but first transform the damage if needed void addWorkspaceRepaint(const QRect& r); void addWorkspaceRepaint(int x, int y, int w, int h); QRegion repaints() const; void resetRepaints(); QRegion damage() const; void resetDamage(); EffectWindowImpl* effectWindow(); const EffectWindowImpl* effectWindow() const; /** * Window will be temporarily painted as if being at the top of the stack. * Only available if Compositor is active, if not active, this method is a no-op. **/ void elevate(bool elevate); /** * @returns Whether the Toplevel has a Shadow or not * @see shadow **/ bool hasShadow() const; /** * Returns the pointer to the Toplevel's Shadow. A Shadow * is only available if Compositing is enabled and the corresponding X window * has the Shadow property set. * If a shadow is available hasShadow returns @c true. * @returns The Shadow belonging to this Toplevel, may be @c NULL. * @see hasShadow **/ const Shadow *shadow() const; Shadow *shadow(); /** * Updates the Shadow associated with this Toplevel from X11 Property. * Call this method when the Property changes or Compositing is started. **/ void getShadow(); /** * Whether the Toplevel currently wants the shadow to be rendered. Default * implementation always returns @c true. **/ virtual bool wantsShadowToBeRendered() const; /** * This method returns the area that the Toplevel window reports to be opaque. * It is supposed to only provide valuable information if hasAlpha is @c true . * @see hasAlpha **/ const QRegion& opaqueRegion() const; virtual Layer layer() const = 0; /** * Resets the damage state and sends a request for the damage region. * A call to this function must be followed by a call to getDamageRegionReply(), * or the reply will be leaked. * * Returns true if the window was damaged, and false otherwise. **/ bool resetAndFetchDamage(); /** * Gets the reply from a previous call to resetAndFetchDamage(). * Calling this function is a no-op if there is no pending reply. * Call damage() to return the fetched region. **/ void getDamageRegionReply(); bool skipsCloseAnimation() const; void setSkipCloseAnimation(bool set); quint32 surfaceId() const; KWayland::Server::SurfaceInterface *surface() const; void setSurface(KWayland::Server::SurfaceInterface *surface); virtual void setInternalFramebufferObject(const QSharedPointer &fbo); const QSharedPointer &internalFramebufferObject() const; /** * @returns Transformation to map from global to window coordinates. * * Default implementation returns a translation on negative pos(). * @see pos **/ virtual QMatrix4x4 inputTransformation() const; /** * The window has a popup grab. This means that when it got mapped the * parent window had an implicit (pointer) grab. * * Normally this is only relevant for transient windows. * * Once the popup grab ends (e.g. pointer press outside of any Toplevel of * the client), the method popupDone should be invoked. * * The default implementation returns @c false. * @see popupDone * @since 5.10 **/ virtual bool hasPopupGrab() const { return false; } /** * This method should be invoked for Toplevels with a popup grab when * the grab ends. * * The default implementation does nothing. * @see hasPopupGrab * @since 5.10 **/ virtual void popupDone() {}; /** * @brief Finds the Toplevel matching the condition expressed in @p func in @p list. * * The method is templated to operate on either a list of Toplevels or on a list of * a subclass type of Toplevel. * @param list The list to search in * @param func The condition function (compare std::find_if) * @return T* The found Toplevel or @c null if there is no matching Toplevel **/ template static T *findInList(const QList &list, std::function func); /** * Whether the window is a popup. * * Popups can be used to implement popup menus, tooltips, combo boxes, etc. * * @since 5.15 **/ virtual bool isPopupWindow() const; /** * A UUID to uniquely identify this Toplevel independent of windowing system. **/ QUuid internalId() const { return m_internalId; } Q_SIGNALS: void opacityChanged(KWin::Toplevel* toplevel, qreal oldOpacity); void damaged(KWin::Toplevel* toplevel, const QRect& damage); void geometryChanged(); void geometryShapeChanged(KWin::Toplevel* toplevel, const QRect& old); void paddingChanged(KWin::Toplevel* toplevel, const QRect& old); void windowClosed(KWin::Toplevel* toplevel, KWin::Deleted* deleted); void windowShown(KWin::Toplevel* toplevel); void windowHidden(KWin::Toplevel* toplevel); /** * Signal emitted when the window's shape state changed. That is if it did not have a shape * and received one or if the shape was withdrawn. Think of Chromium enabling/disabling KWin's * decoration. **/ void shapedChanged(); /** * Emitted whenever the state changes in a way, that the Compositor should * schedule a repaint of the scene. **/ void needsRepaint(); void activitiesChanged(KWin::Toplevel* toplevel); /** * Emitted whenever the Toplevel's screen changes. This can happen either in consequence to * a screen being removed/added or if the Toplevel's geometry changes. * @since 4.11 **/ void screenChanged(); void skipCloseAnimationChanged(); /** * Emitted whenever the window role of the window changes. * @since 5.0 **/ void windowRoleChanged(); /** * Emitted whenever the window class name or resource name of the window changes. * @since 5.0 **/ void windowClassChanged(); /** * Emitted when a Wayland Surface gets associated with this Toplevel. * @since 5.3 **/ void surfaceIdChanged(quint32); /** * @since 5.4 **/ void hasAlphaChanged(); /** * Emitted whenever the Surface for this Toplevel changes. **/ void surfaceChanged(); /* * Emitted when the client's screen changes onto a screen of a different scale * or the screen we're on changes * @since 5.12 **/ void screenScaleChanged(); /** * Emitted whenever the client's shadow changes. * @since 5.15 **/ void shadowChanged(); protected Q_SLOTS: /** * Checks whether the screen number for this Toplevel changed and updates if needed. * Any method changing the geometry of the Toplevel should call this method. **/ void checkScreen(); void setupCheckScreenConnection(); void removeCheckScreenConnection(); void setReadyForPainting(); protected: - virtual ~Toplevel(); + ~Toplevel() override; void setWindowHandles(xcb_window_t client); void detectShape(Window id); virtual void propertyNotifyEvent(xcb_property_notify_event_t *e); virtual void damageNotifyEvent(); virtual void clientMessageEvent(xcb_client_message_event_t *e); void discardWindowPixmap(); void addDamageFull(); virtual void addDamage(const QRegion &damage); Xcb::Property fetchWmClientLeader() const; void readWmClientLeader(Xcb::Property &p); void getWmClientLeader(); void getWmClientMachine(); /** * @returns Whether there is a compositor and it is active. **/ bool compositing() const; /** * This function fetches the opaque region from this Toplevel. * Will only be called on corresponding property changes and for initialization. **/ void getWmOpaqueRegion(); void getResourceClass(); void setResourceClass(const QByteArray &name, const QByteArray &className = QByteArray()); Xcb::Property fetchSkipCloseAnimation() const; void readSkipCloseAnimation(Xcb::Property &prop); void getSkipCloseAnimation(); virtual void debug(QDebug& stream) const = 0; void copyToDeleted(Toplevel* c); void disownDataPassedToDeleted(); friend QDebug& operator<<(QDebug& stream, const Toplevel*); void deleteEffectWindow(); void setDepth(int depth); QRect geom; xcb_visualid_t m_visual; int bit_depth; NETWinInfo* info; bool ready_for_painting; QRegion repaints_region; // updating, repaint just requires repaint of that area QRegion layer_repaints_region; protected: bool m_isDamaged; private: // when adding new data members, check also copyToDeleted() QUuid m_internalId; Xcb::Window m_client; xcb_damage_damage_t damage_handle; QRegion damage_region; // damage is really damaged window (XDamage) and texture needs bool is_shape; EffectWindowImpl* effect_window; QByteArray resource_name; QByteArray resource_class; ClientMachine *m_clientMachine; WId wmClientLeaderWin; bool m_damageReplyPending; QRegion opaque_region; xcb_xfixes_fetch_region_cookie_t m_regionCookie; int m_screen; bool m_skipCloseAnimation; quint32 m_surfaceId = 0; KWayland::Server::SurfaceInterface *m_surface = nullptr; /** * An FBO object KWin internal windows might render to. **/ QSharedPointer m_internalFBO; // when adding new data members, check also copyToDeleted() qreal m_screenScale = 1.0; }; inline xcb_window_t Toplevel::window() const { return m_client; } inline void Toplevel::setWindowHandles(xcb_window_t w) { assert(!m_client.isValid() && w != XCB_WINDOW_NONE); m_client.reset(w, false); } inline QRect Toplevel::geometry() const { return geom; } inline QSize Toplevel::size() const { return geom.size(); } inline QPoint Toplevel::pos() const { return geom.topLeft(); } inline int Toplevel::x() const { return geom.x(); } inline int Toplevel::y() const { return geom.y(); } inline int Toplevel::width() const { return geom.width(); } inline int Toplevel::height() const { return geom.height(); } inline QRect Toplevel::rect() const { return QRect(0, 0, width(), height()); } inline bool Toplevel::readyForPainting() const { return ready_for_painting; } inline xcb_visualid_t Toplevel::visual() const { return m_visual; } inline bool Toplevel::isDesktop() const { return windowType() == NET::Desktop; } inline bool Toplevel::isDock() const { return windowType() == NET::Dock; } inline bool Toplevel::isMenu() const { return windowType() == NET::Menu; } inline bool Toplevel::isToolbar() const { return windowType() == NET::Toolbar; } inline bool Toplevel::isSplash() const { return windowType() == NET::Splash; } inline bool Toplevel::isUtility() const { return windowType() == NET::Utility; } inline bool Toplevel::isDialog() const { return windowType() == NET::Dialog; } inline bool Toplevel::isNormalWindow() const { return windowType() == NET::Normal; } inline bool Toplevel::isDropdownMenu() const { return windowType() == NET::DropdownMenu; } inline bool Toplevel::isPopupMenu() const { return windowType() == NET::PopupMenu; } inline bool Toplevel::isTooltip() const { return windowType() == NET::Tooltip; } inline bool Toplevel::isNotification() const { return windowType() == NET::Notification; } inline bool Toplevel::isCriticalNotification() const { return windowType() == NET::CriticalNotification; } inline bool Toplevel::isOnScreenDisplay() const { return windowType() == NET::OnScreenDisplay; } inline bool Toplevel::isComboBox() const { return windowType() == NET::ComboBox; } inline bool Toplevel::isDNDIcon() const { return windowType() == NET::DNDIcon; } inline bool Toplevel::isLockScreen() const { return false; } inline bool Toplevel::isInputMethod() const { return false; } inline bool Toplevel::isOutline() const { return false; } inline QRegion Toplevel::damage() const { return damage_region; } inline QRegion Toplevel::repaints() const { return repaints_region.translated(pos()) | layer_repaints_region; } inline bool Toplevel::shape() const { return is_shape; } inline int Toplevel::depth() const { return bit_depth; } inline bool Toplevel::hasAlpha() const { return depth() == 32; } inline const QRegion& Toplevel::opaqueRegion() const { return opaque_region; } inline EffectWindowImpl* Toplevel::effectWindow() { return effect_window; } inline const EffectWindowImpl* Toplevel::effectWindow() const { return effect_window; } inline bool Toplevel::isOnAllDesktops() const { return kwinApp()->operationMode() == Application::OperationModeWaylandOnly || kwinApp()->operationMode() == Application::OperationModeXwayland //Wayland ? desktops().isEmpty() //X11 : desktop() == NET::OnAllDesktops; } inline bool Toplevel::isOnAllActivities() const { return activities().isEmpty(); } inline bool Toplevel::isOnDesktop(int d) const { return (kwinApp()->operationMode() == Application::OperationModeWaylandOnly || kwinApp()->operationMode() == Application::OperationModeXwayland ? desktops().contains(VirtualDesktopManager::self()->desktopForX11Id(d)) : desktop() == d ) || isOnAllDesktops(); } inline bool Toplevel::isOnActivity(const QString &activity) const { return activities().isEmpty() || activities().contains(activity); } inline bool Toplevel::isOnCurrentDesktop() const { return isOnDesktop(VirtualDesktopManager::self()->current()); } inline QByteArray Toplevel::resourceName() const { return resource_name; // it is always lowercase } inline QByteArray Toplevel::resourceClass() const { return resource_class; // it is always lowercase } inline const ClientMachine *Toplevel::clientMachine() const { return m_clientMachine; } inline quint32 Toplevel::surfaceId() const { return m_surfaceId; } inline KWayland::Server::SurfaceInterface *Toplevel::surface() const { return m_surface; } inline const QSharedPointer &Toplevel::internalFramebufferObject() const { return m_internalFBO; } inline QPoint Toplevel::clientContentPos() const { return QPoint(0, 0); } template inline T *Toplevel::findInList(const QList &list, std::function func) { static_assert(std::is_base_of::value, "U must be derived from T"); const auto it = std::find_if(list.begin(), list.end(), func); if (it == list.end()) { return nullptr; } return *it; } inline bool Toplevel::isPopupWindow() const { switch (windowType()) { case NET::ComboBox: case NET::DropdownMenu: case NET::PopupMenu: case NET::Tooltip: return true; default: return false; } } QDebug& operator<<(QDebug& stream, const Toplevel*); QDebug& operator<<(QDebug& stream, const ToplevelList&); } // namespace Q_DECLARE_METATYPE(KWin::Toplevel*) #endif diff --git a/touch_input.h b/touch_input.h index 529f85e22..526d125e6 100644 --- a/touch_input.h +++ b/touch_input.h @@ -1,106 +1,106 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2013, 2016 Martin Gräßlin Copyright (C) 2018 Roman Gilg 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_TOUCH_INPUT_H #define KWIN_TOUCH_INPUT_H #include "input.h" #include #include #include #include namespace KWin { class InputRedirection; class Toplevel; namespace Decoration { class DecoratedClientImpl; } namespace LibInput { class Device; } class TouchInputRedirection : public InputDeviceHandler { Q_OBJECT public: explicit TouchInputRedirection(InputRedirection *parent); - virtual ~TouchInputRedirection(); + ~TouchInputRedirection() override; bool positionValid() const override; bool focusUpdatesBlocked() override; - void init(); + void init() override; void processDown(qint32 id, const QPointF &pos, quint32 time, LibInput::Device *device = nullptr); void processUp(qint32 id, quint32 time, LibInput::Device *device = nullptr); void processMotion(qint32 id, const QPointF &pos, quint32 time, LibInput::Device *device = nullptr); void cancel(); void frame(); void insertId(quint32 internalId, qint32 kwaylandId); void removeId(quint32 internalId); qint32 mappedId(quint32 internalId); void setDecorationPressId(qint32 id) { m_decorationId = id; } qint32 decorationPressId() const { return m_decorationId; } void setInternalPressId(qint32 id) { m_internalId = id; } qint32 internalPressId() const { return m_internalId; } QPointF position() const override { return m_lastPosition; } private: void cleanupInternalWindow(QWindow *old, QWindow *now) override; void cleanupDecoration(Decoration::DecoratedClientImpl *old, Decoration::DecoratedClientImpl *now) override; void focusUpdate(Toplevel *focusOld, Toplevel *focusNow) override; bool m_inited = false; qint32 m_decorationId = -1; qint32 m_internalId = -1; /** * external/kwayland **/ QHash m_idMapper; QMetaObject::Connection m_focusGeometryConnection; bool m_windowUpdatedInCycle = false; QPointF m_lastPosition; int m_touches = 0; }; } #endif diff --git a/unmanaged.h b/unmanaged.h index d7aa3a546..fd22218f8 100644 --- a/unmanaged.h +++ b/unmanaged.h @@ -1,69 +1,69 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2006 Lubos Lunak 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_UNMANAGED_H #define KWIN_UNMANAGED_H #include #include "toplevel.h" namespace KWin { class Unmanaged : public Toplevel { Q_OBJECT public: explicit Unmanaged(); bool windowEvent(xcb_generic_event_t *e); bool track(Window w); static void deleteUnmanaged(Unmanaged* c); - virtual int desktop() const; - virtual QStringList activities() const; - virtual QVector desktops() const override; - virtual QPoint clientPos() const; - virtual QSize clientSize() const; - virtual QRect transparentRect() const; - virtual Layer layer() const { + int desktop() const override; + QStringList activities() const override; + QVector desktops() const override; + QPoint clientPos() const override; + QSize clientSize() const override; + QRect transparentRect() const override; + Layer layer() const override { return UnmanagedLayer; } - NET::WindowType windowType(bool direct = false, int supported_types = 0) const; + NET::WindowType windowType(bool direct = false, int supported_types = 0) const override; bool isOutline() const override; bool setupCompositing() override; public Q_SLOTS: void release(ReleaseReason releaseReason = ReleaseReason::Release); protected: - virtual void debug(QDebug& stream) const; + void debug(QDebug& stream) const override; void addDamage(const QRegion &damage) override; private: - virtual ~Unmanaged(); // use release() + ~Unmanaged() override; // use release() // handlers for X11 events void configureNotifyEvent(xcb_configure_notify_event_t *e); QWindow *findInternalWindow() const; bool m_outline = false; }; } // namespace #endif diff --git a/useractions.h b/useractions.h index e032fbf26..df14142fe 100644 --- a/useractions.h +++ b/useractions.h @@ -1,303 +1,303 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2012 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_USERACTIONS_H #define KWIN_USERACTIONS_H #include "ui_shortcutdialog.h" #include // Qt #include #include class QAction; class QRect; namespace KWin { class AbstractClient; class Client; /** * @brief Menu shown for a Client. * * The UserActionsMenu implements the Menu which is shown on: * @li context-menu event on Window decoration * @li window menu button * @li Keyboard Shortcut (by default Alt+F3) * * The menu contains various window management related actions for the Client the menu is opened * for, this is normally the active Client. * * The menu which is shown is tried to be as close as possible to the menu implemented in * libtaskmanager, though there are differences as there are some actions only the window manager * can provide and on the other hand the libtaskmanager cares also about things like e.g. grouping. * * Whenever the menu is changed it should be tried to also adjust the menu in libtaskmanager. * * @author Martin Gräßlin **/ class KWIN_EXPORT UserActionsMenu : public QObject { Q_OBJECT public: explicit UserActionsMenu(QObject *parent = 0); - virtual ~UserActionsMenu(); + ~UserActionsMenu() override; /** * Discards the constructed menu, so that it gets recreates * on next show event. * @see show **/ void discard(); /** * @returns Whether the menu is currently visible **/ bool isShown() const; /** * grabs keyboard and mouse, workaround(?) for bug #351112 **/ void grabInput(); /** * @returns Whether the menu has a Client set to operate on. **/ bool hasClient() const; /** * Checks whether the given Client @p c is the Client * for which the Menu is shown. * @param c The Client to compare * @returns Whether the Client is the one related to this Menu **/ bool isMenuClient(const AbstractClient *c) const; /** * Closes the Menu and prepares it for next usage. **/ void close(); /** * @brief Shows the menu at the given @p pos for the given @p client. * * @param pos The position where the menu should be shown. * @param client The Client for which the Menu has to be shown. **/ void show(const QRect &pos, const QWeakPointer &client); public Q_SLOTS: /** * Delayed initialization of the activity menu. * * The call to retrieve the current list of activities is performed in a thread and this * slot is invoked once the list has been fetched. Only task of this method is to decide * whether to show the activity menu and to invoke the initialization of it. * * @see initActivityPopup **/ void showHideActivityMenu(); private Q_SLOTS: /** * The menu will become visible soon. * * Adjust the items according to the respective Client. **/ void menuAboutToShow(); /** * Adjusts the add to tab group menu to the current value of the Client. **/ void rebuildTabGroupPopup(); /** * Adjusts the switch to tab menu to the current values of the Client. **/ void rebuildTabListPopup(); /** * Adds the Client as tab to the Client identified by the @p action. * * @param action The invoked action containing the Client to which the active Client should be tabbed. **/ void entabPopupClient(QAction *action); /** * Activates the selected tabbed Client. * * @param action The invoked action containing the tabbed Client which should be activated. **/ void selectPopupClientTab(QAction *action); /** * Adjusts the desktop popup to the current values and the location of * the Client. **/ void desktopPopupAboutToShow(); /** * Adjusts the multipleDesktopsMenu popup to the current values and the location of * the Client, Wayland only. **/ void multipleDesktopsPopupAboutToShow(); /** * Adjusts the screen popup to the current values and the location of * the Client. **/ void screenPopupAboutToShow(); /** * Adjusts the activity popup to the current values and the location of * the Client. **/ void activityPopupAboutToShow(); /** * Sends the client to desktop \a desk * * @param action Invoked Action containing the Desktop as data element **/ void slotSendToDesktop(QAction *action); /** * Toggle whether the Client is on a desktop (Wayland only) * * @param action Invoked Action containing the Desktop as data element **/ void slotToggleOnVirtualDesktop(QAction *action); /** * Sends the Client to screen \a screen * * @param action Invoked Action containing the Screen as data element **/ void slotSendToScreen(QAction *action); /** * Toggles whether the Client is on the \a activity * * @param action Invoked Action containing the Id of the Activity to toggle the Client on **/ void slotToggleOnActivity(QAction *action); /** * Performs a window operation. * * @param action Invoked Action containing the Window Operation to perform for the Client **/ void slotWindowOperation(QAction *action); private: /** * Creates the menu if not already created. **/ void init(); /** * Creates the Move To Desktop sub-menu. **/ void initDesktopPopup(); /** * Creates the Move To Screen sub-menu. **/ void initScreenPopup(); /** * Creates activity popup. * I'm going with checkable ones instead of "copy to" and "move to" menus; I *think* it's an easier way. * Oh, and an 'all' option too of course **/ void initActivityPopup(); /** * Creates the Window Tabbing related menus. **/ void initTabbingPopups(); /** * Shows a helper Dialog to inform the user how to get back in case he triggered * an action which hides the window decoration (e.g. NoBorder or Fullscreen). * @param message The message type to be shown * @param c The Client for which the dialog should be shown. **/ void helperDialog(const QString &message, const QWeakPointer &c); /** * The actual main context menu which is show when the UserActionsMenu is invoked. **/ QMenu* m_menu; /** * The move to desktop sub menu. **/ QMenu* m_desktopMenu; /** * The move to desktop sub menu, with the Wayland protocol. **/ QMenu* m_multipleDesktopsMenu; /** * The move to screen sub menu. **/ QMenu* m_screenMenu; /** * The activities sub menu. **/ QMenu* m_activityMenu; /** * Menu to add the group to other group. **/ QMenu* m_addTabsMenu; /** * Menu to change tab. **/ QMenu* m_switchToTabMenu; /** * Menu for further entries added by scripts. **/ QMenu* m_scriptsMenu; QAction* m_resizeOperation; QAction* m_moveOperation; QAction* m_maximizeOperation; QAction* m_shadeOperation; QAction* m_keepAboveOperation; QAction* m_keepBelowOperation; QAction* m_fullScreenOperation; QAction* m_noBorderOperation; QAction* m_minimizeOperation; QAction* m_closeOperation; QAction* m_shortcutOperation; /** * Remove client from group. **/ QAction* m_removeFromTabGroup; /** * Close all clients in the group. **/ QAction* m_closeTabGroup; /** * The Client for which the menu is shown. **/ QWeakPointer m_client; QAction *m_rulesOperation = nullptr; QAction *m_applicationRulesOperation = nullptr; }; class ShortcutDialog : public QDialog { Q_OBJECT public: explicit ShortcutDialog(const QKeySequence& cut); - virtual void accept(); + void accept() override; QKeySequence shortcut() const; public Q_SLOTS: void keySequenceChanged(); Q_SIGNALS: void dialogDone(bool ok); protected: - virtual void done(int r); + void done(int r) override; private: Ui::ShortcutDialog m_ui; QKeySequence _shortcut; }; } // namespace #endif // KWIN_USERACTIONS_H diff --git a/utils.h b/utils.h index 459cae8df..a12473e6e 100644 --- a/utils.h +++ b/utils.h @@ -1,247 +1,247 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 1999, 2000 Matthias Ettrich Copyright (C) 2003 Lubos Lunak 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_UTILS_H #define KWIN_UTILS_H // cmake stuff #include #include // kwin #include // KDE #include // Qt #include #include #include #include #include #include // system #include Q_DECLARE_LOGGING_CATEGORY(KWIN_CORE) Q_DECLARE_LOGGING_CATEGORY(KWIN_VIRTUALKEYBOARD) namespace KWin { // window types that are supported as normal windows (i.e. KWin actually manages them) const NET::WindowTypes SUPPORTED_MANAGED_WINDOW_TYPES_MASK = NET::NormalMask | NET::DesktopMask | NET::DockMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask /*| NET::OverrideMask*/ | NET::TopMenuMask | NET::UtilityMask | NET::SplashMask | NET::NotificationMask | NET::OnScreenDisplayMask | NET::CriticalNotificationMask; // window types that are supported as unmanaged (mainly for compositing) const NET::WindowTypes SUPPORTED_UNMANAGED_WINDOW_TYPES_MASK = NET::NormalMask | NET::DesktopMask | NET::DockMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask /*| NET::OverrideMask*/ | NET::TopMenuMask | NET::UtilityMask | NET::SplashMask | NET::DropdownMenuMask | NET::PopupMenuMask | NET::TooltipMask | NET::NotificationMask | NET::ComboBoxMask | NET::DNDIconMask | NET::OnScreenDisplayMask | NET::CriticalNotificationMask; const QPoint invalidPoint(INT_MIN, INT_MIN); class Toplevel; class Client; class Unmanaged; class Deleted; class Group; class Options; typedef QList< Toplevel* > ToplevelList; typedef QList< Client* > ClientList; typedef QList< const Client* > ConstClientList; typedef QList< Unmanaged* > UnmanagedList; typedef QList< Deleted* > DeletedList; typedef QList< Group* > GroupList; extern Options* options; enum Layer { UnknownLayer = -1, FirstLayer = 0, DesktopLayer = FirstLayer, BelowLayer, NormalLayer, DockLayer, AboveLayer, NotificationLayer, // layer for windows of type notification ActiveLayer, // active fullscreen, or active dialog CriticalNotificationLayer, // layer for notifications that should be shown even on top of fullscreen OnScreenDisplayLayer, // layer for On Screen Display windows such as volume feedback UnmanagedLayer, // layer for override redirect windows. NumLayers // number of layers, must be last }; // yes, I know this is not 100% like standard operator++ inline void operator++(Layer& lay) { lay = static_cast< Layer >(lay + 1); } enum StrutArea { StrutAreaInvalid = 0, // Null StrutAreaTop = 1 << 0, StrutAreaRight = 1 << 1, StrutAreaBottom = 1 << 2, StrutAreaLeft = 1 << 3, StrutAreaAll = StrutAreaTop | StrutAreaRight | StrutAreaBottom | StrutAreaLeft }; Q_DECLARE_FLAGS(StrutAreas, StrutArea) class StrutRect : public QRect { public: explicit StrutRect(QRect rect = QRect(), StrutArea area = StrutAreaInvalid); StrutRect(const StrutRect& other); inline StrutArea area() const { return m_area; }; private: StrutArea m_area; }; typedef QVector StrutRects; enum ShadeMode { ShadeNone, // not shaded ShadeNormal, // normally shaded - isShade() is true only here ShadeHover, // "shaded", but visible due to hover unshade ShadeActivated // "shaded", but visible due to alt+tab to the window }; /** * Maximize mode. These values specify how a window is maximized. * * @note these values are written to session files, don't change the order **/ enum MaximizeMode { MaximizeRestore = 0, ///< The window is not maximized in any direction. MaximizeVertical = 1, ///< The window is maximized vertically. MaximizeHorizontal = 2, ///< The window is maximized horizontally. /// Equal to @p MaximizeVertical | @p MaximizeHorizontal MaximizeFull = MaximizeVertical | MaximizeHorizontal }; inline MaximizeMode operator^(MaximizeMode m1, MaximizeMode m2) { return MaximizeMode(int(m1) ^ int(m2)); } enum class QuickTileFlag { None = 0, Left = 1 << 0, Right = 1 << 1, Top = 1 << 2, Bottom = 1 << 3, Horizontal = Left | Right, Vertical = Top | Bottom, Maximize = Left | Right | Top | Bottom, }; Q_DECLARE_FLAGS(QuickTileMode, QuickTileFlag) template using ScopedCPointer = QScopedPointer; void KWIN_EXPORT updateXTime(); void KWIN_EXPORT grabXServer(); void KWIN_EXPORT ungrabXServer(); bool KWIN_EXPORT grabXKeyboard(xcb_window_t w = XCB_WINDOW_NONE); void KWIN_EXPORT ungrabXKeyboard(); /** * Small helper class which performs grabXServer in the ctor and * ungrabXServer in the dtor. Use this class to ensure that grab and * ungrab are matched. * * To simplify usage consider using the macro GRAB_SERVER_DURING_CONTEXT **/ class XServerGrabber { public: XServerGrabber() { grabXServer(); } ~XServerGrabber() { ungrabXServer(); } }; #define GRAB_SERVER_DURING_CONTEXT XServerGrabber xserverGrabber; // the docs say it's UrgencyHint, but it's often #defined as XUrgencyHint #ifndef UrgencyHint #define UrgencyHint XUrgencyHint #endif // converting between X11 mouse/keyboard state mask and Qt button/keyboard states Qt::MouseButton x11ToQtMouseButton(int button); Qt::MouseButton KWIN_EXPORT x11ToQtMouseButton(int button); Qt::MouseButtons KWIN_EXPORT x11ToQtMouseButtons(int state); Qt::KeyboardModifiers KWIN_EXPORT x11ToQtKeyboardModifiers(int state); /** * Separate the concept of an unet QPoint and 0,0 **/ class ClearablePoint { public: inline bool isValid() const { return m_valid; } inline void clear(){ m_valid = false; } inline void setPoint(const QPoint &point) { m_point = point; m_valid = true; } inline QPoint point() const { return m_point; } private: QPoint m_point; bool m_valid = false; }; /** * QProcess subclass which unblocks SIGUSR in the child process. **/ class KWIN_EXPORT Process : public QProcess { Q_OBJECT public: explicit Process(QObject *parent = nullptr); - virtual ~Process(); + ~Process() override; protected: void setupChildProcess() override; }; } // namespace // Must be outside namespace Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::StrutAreas) Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::QuickTileMode) #endif diff --git a/virtual_terminal.h b/virtual_terminal.h index efeeb91f9..d3321a1a2 100644 --- a/virtual_terminal.h +++ b/virtual_terminal.h @@ -1,61 +1,61 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_VIRTUAL_TERMINAL_H #define KWIN_VIRTUAL_TERMINAL_H #include #include class QSocketNotifier; namespace KWin { class KWIN_EXPORT VirtualTerminal : public QObject { Q_OBJECT public: - virtual ~VirtualTerminal(); + ~VirtualTerminal() override; void init(); void activate(int vt); bool isActive() const { return m_active; } Q_SIGNALS: void activeChanged(bool); private: void setup(int vtNr); void closeFd(); bool createSignalHandler(); void setActive(bool active); int m_vt = -1; QSocketNotifier *m_notifier = nullptr; bool m_active = false; int m_vtNumber = 0; KWIN_SINGLETON(VirtualTerminal) }; } #endif diff --git a/virtualdesktops.h b/virtualdesktops.h index 8282ee8c7..801ea1d7f 100644 --- a/virtualdesktops.h +++ b/virtualdesktops.h @@ -1,730 +1,730 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2012 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_VIRTUAL_DESKTOPS_H #define KWIN_VIRTUAL_DESKTOPS_H // KWin #include #include // Qt includes #include #include #include #include // KDE includes #include #include class KLocalizedString; class NETRootInfo; class QAction; namespace KWayland { namespace Server { class PlasmaVirtualDesktopManagementInterface; } } namespace KWin { class KWIN_EXPORT VirtualDesktop : public QObject { Q_OBJECT Q_PROPERTY(QByteArray id READ id CONSTANT) Q_PROPERTY(uint x11DesktopNumber READ x11DesktopNumber NOTIFY x11DesktopNumberChanged) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) public: explicit VirtualDesktop(QObject *parent = nullptr); - virtual ~VirtualDesktop(); + ~VirtualDesktop() override; void setId(const QByteArray &id); QByteArray id() const { return m_id; } void setName(const QString &name); QString name() const { return m_name; } void setX11DesktopNumber(uint number); uint x11DesktopNumber() const { return m_x11DesktopNumber; } Q_SIGNALS: void nameChanged(); void x11DesktopNumberChanged(); /** * Emitted just before the desktop gets destroyed. **/ void aboutToBeDestroyed(); private: QByteArray m_id; QString m_name; int m_x11DesktopNumber = 0; }; /** * @brief Two dimensional grid containing the ID of the virtual desktop at a specific position * in the grid. * * The VirtualDesktopGrid represents a visual layout of the Virtual Desktops as they are in e.g. * a Pager. This grid is used for getting a desktop next to a given desktop in any direction by * making use of the layout information. This allows navigation like move to desktop on left. **/ class VirtualDesktopGrid { public: VirtualDesktopGrid(); ~VirtualDesktopGrid(); void update(const QSize &size, Qt::Orientation orientation, const QVector &desktops); /** * @returns The coords of desktop @a id in grid units. **/ QPoint gridCoords(uint id) const; /** * @returns The coords of desktop @a vd in grid units. **/ QPoint gridCoords(VirtualDesktop *vd) const; /** * @returns The desktop at the point @a coords or 0 if no desktop exists at that * point. @a coords is to be in grid units. **/ VirtualDesktop *at(const QPoint &coords) const; int width() const; int height() const; const QSize &size() const; private: QSize m_size; QVector> m_grid; }; /** * @brief Manages the number of available virtual desktops, the layout of those and which virtual * desktop is the current one. * * This manager is responsible for Virtual Desktop handling inside KWin. It has a property for the * count of available virtual desktops and a property for the currently active virtual desktop. All * changes to the number of virtual desktops and the current virtual desktop need to go through this * manager. * * On all changes a signal is emitted and interested parties should connect to the signal. The manager * itself does not interact with other parts of the system. E.g. it does not hide/show windows of * desktop changes. This is outside the scope of this manager. * * Internally the manager organizes the virtual desktops in a grid allowing to navigate over the * virtual desktops. For this a set of convenient methods are available which allow to get the id * of an adjacent desktop or to switch to an adjacent desktop. Interested parties should make use of * these methods and not replicate the logic to switch to the next desktop. **/ class KWIN_EXPORT VirtualDesktopManager : public QObject { Q_OBJECT /** * The number of virtual desktops currently available. * The ids of the virtual desktops are in the range [1, VirtualDesktopManager::maximum()]. **/ Q_PROPERTY(uint count READ count WRITE setCount NOTIFY countChanged) /** * The id of the virtual desktop which is currently in use. **/ Q_PROPERTY(uint current READ current WRITE setCurrent NOTIFY currentChanged) /** * Whether navigation in the desktop layout wraps around at the borders. **/ Q_PROPERTY(bool navigationWrappingAround READ isNavigationWrappingAround WRITE setNavigationWrappingAround NOTIFY navigationWrappingAroundChanged) public: - virtual ~VirtualDesktopManager(); + ~VirtualDesktopManager() override; /** * @internal, for X11 case **/ void setRootInfo(NETRootInfo *info); /** * @internal, for Wayland case **/ void setVirtualDesktopManagement(KWayland::Server::PlasmaVirtualDesktopManagementInterface *management); /** * @internal **/ void setConfig(KSharedConfig::Ptr config); /** * @returns Total number of desktops currently in existence. * @see setCount * @see countChanged **/ uint count() const; /** * @returns the number of rows the layout has. * @see setRows * @see rowsChanged **/ uint rows() const; /** * @returns The ID of the current desktop. * @see setCurrent * @see currentChanged **/ uint current() const; /** * @returns The current desktop * @see setCurrent * @see currentChanged **/ VirtualDesktop *currentDesktop() const; /** * Moves to the desktop through the algorithm described by Direction. * @param wrap If @c true wraps around to the other side of the layout * @see setCurrent **/ template void moveTo(bool wrap = false); /** * @returns The name of the @p desktop **/ QString name(uint desktop) const; /** * @returns @c true if navigation at borders of layout wraps around, @c false otherwise * @see setNavigationWrappingAround * @see navigationWrappingAroundChanged **/ bool isNavigationWrappingAround() const; /** * @returns The layout aware virtual desktop grid used by this manager. **/ const VirtualDesktopGrid &grid() const; /** * @returns The ID of the desktop above desktop @a id. Wraps around to the bottom of * the layout if @a wrap is set. If @a id is not set use the current one. **/ uint above(uint id = 0, bool wrap = true) const; /** * @returns The desktop above desktop @a desktop. Wraps around to the bottom of * the layout if @a wrap is set. If @a desktop is @c null use the current one. **/ VirtualDesktop *above(VirtualDesktop *desktop, bool wrap = true) const; /** * @returns The ID of the desktop to the right of desktop @a id. Wraps around to the * left of the layout if @a wrap is set. If @a id is not set use the current one. **/ uint toRight(uint id = 0, bool wrap = true) const; /** * @returns The desktop to the right of desktop @a desktop. Wraps around to the * left of the layout if @a wrap is set. If @a desktop is @c null use the current one. **/ VirtualDesktop *toRight(VirtualDesktop *desktop, bool wrap = true) const; /** * @returns The ID of the desktop below desktop @a id. Wraps around to the top of the * layout if @a wrap is set. If @a id is not set use the current one. **/ uint below(uint id = 0, bool wrap = true) const; /** * @returns The desktop below desktop @a desktop. Wraps around to the top of the * layout if @a wrap is set. If @a desktop is @c null use the current one. **/ VirtualDesktop *below(VirtualDesktop *desktop, bool wrap = true) const; /** * @returns The ID of the desktop to the left of desktop @a id. Wraps around to the * right of the layout if @a wrap is set. If @a id is not set use the current one. **/ uint toLeft(uint id = 0, bool wrap = true) const; /** * @returns The desktop to the left of desktop @a desktop. Wraps around to the * right of the layout if @a wrap is set. If @a desktop is @c null use the current one. **/ VirtualDesktop *toLeft(VirtualDesktop *desktop, bool wrap = true) const; /** * @returns The desktop after the desktop @a desktop. Wraps around to the first * desktop if @a wrap is set. If @a desktop is @c null use the current desktop. **/ VirtualDesktop *next(VirtualDesktop *desktop = nullptr, bool wrap = true) const; /** * @returns The desktop in front of the desktop @a desktop. Wraps around to the * last desktop if @a wrap is set. If @a desktop is @c null use the current desktop. **/ VirtualDesktop *previous(VirtualDesktop *desktop = nullptr, bool wrap = true) const; void initShortcuts(); /** * @returns all currently managed VirtualDesktops **/ QVector desktops() const { return m_desktops; } /** * @returns The VirtualDesktop for the x11 @p id, if no such VirtualDesktop @c null is returned **/ VirtualDesktop *desktopForX11Id(uint id) const; /** * @returns The VirtualDesktop for the internal desktop string @p id, if no such VirtualDesktop @c null is returned **/ VirtualDesktop *desktopForId(const QByteArray &id) const; /** * Create a new virtual desktop at the requested position. * The difference with setCount is that setCount always adds new desktops at the end of the chain. The Id is automatically generated. * @param position The position of the desktop. It should be in range [0, count]. * @param name The name for the new desktop, if empty the default name will be used. * @returns the new VirtualDesktop, nullptr if we reached the maximum number of desktops **/ VirtualDesktop *createVirtualDesktop(uint position, const QString &name = QString()); /** * Remove the virtual desktop identified by id, if it exists * difference with setCount is that is possible to remove an arbitrary desktop, * not only the last one. * @param id the string id of the desktop to remove **/ void removeVirtualDesktop(const QByteArray &id); /** * Updates the net root info for new number of desktops **/ void updateRootInfo(); /** * @returns The maximum number of desktops that KWin supports. **/ static uint maximum(); public Q_SLOTS: /** * Set the number of available desktops to @a count. This function overrides any previous * grid layout. * There needs to be at least one virtual desktop and the new value is capped at the maximum * number of desktops. A caller of this function cannot expect that the change has been applied. * It is the callers responsibility to either check the numberOfDesktops or connect to the * countChanged signal. * * In case the @ref current desktop is on a desktop higher than the new count, the current desktop * is changed to be the new desktop with highest id. In that situation the signal desktopRemoved * is emitted. * @param count The new number of desktops to use * @see count * @see maximum * @see countChanged * @see desktopCreated * @see desktopRemoved **/ void setCount(uint count); /** * Set the current desktop to @a current. * @returns True on success, false otherwise. * @see current * @see currentChanged * @see moveTo **/ bool setCurrent(uint current); /** * Set the current desktop to @a current. * @returns True on success, false otherwise. * @see current * @see currentChanged * @see moveTo **/ bool setCurrent(VirtualDesktop *current); /** * Updates the layout to a new number of rows. The number of columns will be calculated accordingly **/ void setRows(uint rows); /** * Called from within setCount() to ensure the desktop layout is still valid. **/ void updateLayout(); /** * @param enabled wrapping around borders for navigation in desktop layout * @see isNavigationWrappingAround * @see navigationWrappingAroundChanged **/ void setNavigationWrappingAround(bool enabled); /** * Loads number of desktops and names from configuration file **/ void load(); /** * Saves number of desktops and names to configuration file **/ void save(); Q_SIGNALS: /** * Signal emitted whenever the number of virtual desktops changes. * @param previousCount The number of desktops prior to the change * @param newCount The new current number of desktops **/ void countChanged(uint previousCount, uint newCount); /** * Signal when the number of rows in the layout changes * @param rows number of rows **/ void rowsChanged(uint rows); /** * A new desktop has been created * @param desktop the new just crated desktop **/ void desktopCreated(KWin::VirtualDesktop *desktop); /** * A desktop has been removed and is about to be deleted * @param desktop the desktop that has been removed. * It's guaranteed to stil la valid pointer when the signal arrives, * but it's about to be deleted. **/ void desktopRemoved(KWin::VirtualDesktop *desktop); /** * Signal emitted whenever the current desktop changes. * @param previousDesktop The virtual desktop changed from * @param newDesktop The virtual desktop changed to **/ void currentChanged(uint previousDesktop, uint newDesktop); /** * Signal emitted whenever the desktop layout changes. * @param columns The new number of columns in the layout * @param rows The new number of rows in the layout **/ void layoutChanged(int columns, int rows); /** * Signal emitted whenever the navigationWrappingAround property changes. **/ void navigationWrappingAroundChanged(); private Q_SLOTS: /** * Common slot for all "Switch to Desktop n" shortcuts. * This method uses the sender() method to access some data. * DO NOT CALL DIRECTLY! ONLY TO BE USED FROM AN ACTION! **/ void slotSwitchTo(); /** * Slot for switch to next desktop action. **/ void slotNext(); /** * Slot for switch to previous desktop action. **/ void slotPrevious(); /** * Slot for switch to right desktop action. **/ void slotRight(); /** * Slot for switch to left desktop action. **/ void slotLeft(); /** * Slot for switch to desktop above action. **/ void slotUp(); /** * Slot for switch to desktop below action. **/ void slotDown(); private: /** * Generate a desktop layout from EWMH _NET_DESKTOP_LAYOUT property parameters. **/ void setNETDesktopLayout(Qt::Orientation orientation, uint width, uint height, int startingCorner); /** * @returns A default name for the given @p desktop **/ QString defaultName(int desktop) const; /** * Creates all the global keyboard shortcuts for "Switch To Desktop n" actions. **/ void initSwitchToShortcuts(); /** * Creates an action and connects it to the @p slot in this Manager. This method is * meant to be used for the case that an additional information needs to be stored in * the action and the label. * @param name The name of the action to be created * @param label The localized name for the action to be created * @param value An additional value added to the label and to the created action * @param key The global shortcut for the action * @param slot The slot to invoke when the action is triggered **/ QAction *addAction(const QString &name, const KLocalizedString &label, uint value, const QKeySequence &key, void (VirtualDesktopManager::*slot)()); /** * Creates an action and connects it to the @p slot in this Manager. * Overloaded method for the case that no additional value needs to be passed to the action and * no global shortcut is defined by default. * @param name The name of the action to be created * @param label The localized name for the action to be created * @param slot The slot to invoke when the action is triggered **/ QAction *addAction(const QString &name, const QString &label, void (VirtualDesktopManager::*slot)()); QVector m_desktops; QPointer m_current; quint32 m_rows = 2; bool m_navigationWrapsAround; VirtualDesktopGrid m_grid; // TODO: QPointer NETRootInfo *m_rootInfo; KWayland::Server::PlasmaVirtualDesktopManagementInterface *m_virtualDesktopManagement = nullptr; KSharedConfig::Ptr m_config; KWIN_SINGLETON_VARIABLE(VirtualDesktopManager, s_manager) }; /** * Function object to select the desktop above in the layout. * Note: does not switch to the desktop! **/ class DesktopAbove { public: DesktopAbove() {} /** * @param desktop The desktop from which the desktop above should be selected. If @c 0 the current desktop is used * @param wrap Whether to wrap around if already topmost desktop * @returns Id of the desktop above @p desktop **/ uint operator() (uint desktop, bool wrap) { return (*this)(VirtualDesktopManager::self()->desktopForX11Id(desktop), wrap)->x11DesktopNumber(); } /** * @param desktop The desktop from which the desktop above should be selected. If @c 0 the current desktop is used * @param wrap Whether to wrap around if already topmost desktop * @returns the desktop above @p desktop **/ VirtualDesktop *operator() (VirtualDesktop *desktop, bool wrap) { return VirtualDesktopManager::self()->above(desktop, wrap); } }; /** * Function object to select the desktop below in the layout. * Note: does not switch to the desktop! **/ class DesktopBelow { public: DesktopBelow() {} /** * @param desktop The desktop from which the desktop below should be selected. If @c 0 the current desktop is used * @param wrap Whether to wrap around if already lowest desktop * @returns Id of the desktop below @p desktop **/ uint operator() (uint desktop, bool wrap) { return (*this)(VirtualDesktopManager::self()->desktopForX11Id(desktop), wrap)->x11DesktopNumber(); } /** * @param desktop The desktop from which the desktop below should be selected. If @c 0 the current desktop is used * @param wrap Whether to wrap around if already lowest desktop * @returns the desktop below @p desktop **/ VirtualDesktop *operator() (VirtualDesktop *desktop, bool wrap) { return VirtualDesktopManager::self()->below(desktop, wrap); } }; /** * Function object to select the desktop to the left in the layout. * Note: does not switch to the desktop! **/ class DesktopLeft { public: DesktopLeft() {} /** * @param desktop The desktop from which the desktop on the left should be selected. If @c 0 the current desktop is used * @param wrap Whether to wrap around if already leftmost desktop * @returns Id of the desktop left of @p desktop **/ uint operator() (uint desktop, bool wrap) { return (*this)(VirtualDesktopManager::self()->desktopForX11Id(desktop), wrap)->x11DesktopNumber(); } /** * @param desktop The desktop from which the desktop on the left should be selected. If @c 0 the current desktop is used * @param wrap Whether to wrap around if already leftmost desktop * @returns the desktop left of @p desktop **/ VirtualDesktop *operator() (VirtualDesktop *desktop, bool wrap) { return VirtualDesktopManager::self()->toLeft(desktop, wrap); } }; /** * Function object to select the desktop to the right in the layout. * Note: does not switch to the desktop! **/ class DesktopRight { public: DesktopRight() {} /** * @param desktop The desktop from which the desktop on the right should be selected. If @c 0 the current desktop is used * @param wrap Whether to wrap around if already rightmost desktop * @returns Id of the desktop right of @p desktop **/ uint operator() (uint desktop, bool wrap) { return (*this)(VirtualDesktopManager::self()->desktopForX11Id(desktop), wrap)->x11DesktopNumber(); } /** * @param desktop The desktop from which the desktop on the right should be selected. If @c 0 the current desktop is used * @param wrap Whether to wrap around if already rightmost desktop * @returns the desktop right of @p desktop **/ VirtualDesktop *operator() (VirtualDesktop *desktop, bool wrap) { return VirtualDesktopManager::self()->toRight(desktop, wrap); } }; /** * Function object to select the next desktop in the layout. * Note: does not switch to the desktop! **/ class DesktopNext { public: DesktopNext() {} /** * @param desktop The desktop from which the next desktop should be selected. If @c 0 the current desktop is used * @param wrap Whether to wrap around if already last desktop * @returns Id of the next desktop **/ uint operator() (uint desktop, bool wrap) { return (*this)(VirtualDesktopManager::self()->desktopForX11Id(desktop), wrap)->x11DesktopNumber(); } /** * @param desktop The desktop from which the next desktop should be selected. If @c 0 the current desktop is used * @param wrap Whether to wrap around if already last desktop * @returns the next desktop **/ VirtualDesktop *operator() (VirtualDesktop *desktop, bool wrap) { return VirtualDesktopManager::self()->next(desktop, wrap); } }; /** * Function object to select the previous desktop in the layout. * Note: does not switch to the desktop! **/ class DesktopPrevious { public: DesktopPrevious() {} /** * @param desktop The desktop from which the previous desktop should be selected. If @c 0 the current desktop is used * @param wrap Whether to wrap around if already first desktop * @returns Id of the previous desktop **/ uint operator() (uint desktop, bool wrap) { return (*this)(VirtualDesktopManager::self()->desktopForX11Id(desktop), wrap)->x11DesktopNumber(); } /** * @param desktop The desktop from which the previous desktop should be selected. If @c 0 the current desktop is used * @param wrap Whether to wrap around if already first desktop * @returns the previous desktop **/ VirtualDesktop *operator() (VirtualDesktop *desktop, bool wrap) { return VirtualDesktopManager::self()->previous(desktop, wrap); } }; /** * Helper function to get the ID of a virtual desktop in the direction from * the given @p desktop. If @c 0 the current desktop is used as a starting point. * @param desktop The desktop from which the desktop in given Direction should be selected. * @param wrap Whether desktop navigation wraps around at the borders of the layout * @returns The next desktop in specified direction **/ template uint getDesktop(int desktop = 0, bool wrap = true); template uint getDesktop(int d, bool wrap) { Direction direction; return direction(d, wrap); } inline int VirtualDesktopGrid::width() const { return m_size.width(); } inline int VirtualDesktopGrid::height() const { return m_size.height(); } inline const QSize &VirtualDesktopGrid::size() const { return m_size; } inline uint VirtualDesktopManager::maximum() { return 20; } inline uint VirtualDesktopManager::count() const { return m_desktops.count(); } inline bool VirtualDesktopManager::isNavigationWrappingAround() const { return m_navigationWrapsAround; } inline void VirtualDesktopManager::setConfig(KSharedConfig::Ptr config) { m_config = config; } inline const VirtualDesktopGrid &VirtualDesktopManager::grid() const { return m_grid; } template void VirtualDesktopManager::moveTo(bool wrap) { Direction functor; setCurrent(functor(nullptr, wrap)); } } // namespace KWin #endif diff --git a/virtualkeyboard.h b/virtualkeyboard.h index b72a0d3ec..21d2bad33 100644 --- a/virtualkeyboard.h +++ b/virtualkeyboard.h @@ -1,79 +1,79 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2016 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_VIRTUAL_KEYBOARD_H #define KWIN_VIRTUAL_KEYBOARD_H #include #include #include #include class QQuickView; class QTimer; class QWindow; class KStatusNotifierItem; namespace KWin { class KWIN_EXPORT VirtualKeyboard : public QObject { Q_OBJECT public: - virtual ~VirtualKeyboard(); + ~VirtualKeyboard() override; void init(); bool event(QEvent *e) override; bool eventFilter(QObject *o, QEvent *event) override; QWindow *inputPanel() const; Q_SIGNALS: void enabledChanged(bool enabled); private: void show(); void hide(); void setEnabled(bool enable); void updateSni(); void updateInputPanelState(); bool m_enabled = false; KStatusNotifierItem *m_sni = nullptr; QScopedPointer m_inputWindow; QPointer m_trackedClient; // If a surface loses focus immediately after being resized by the keyboard, don't react to it to avoid resize loops QTimer *m_floodTimer; QMetaObject::Connection m_waylandShowConnection; QMetaObject::Connection m_waylandHideConnection; QMetaObject::Connection m_waylandHintsConnection; QMetaObject::Connection m_waylandSurroundingTextConnection; QMetaObject::Connection m_waylandResetConnection; QMetaObject::Connection m_waylandEnabledConnection; KWIN_SINGLETON(VirtualKeyboard) }; } #endif diff --git a/virtualkeyboard_dbus.h b/virtualkeyboard_dbus.h index 64c2a63ef..9efe501f5 100644 --- a/virtualkeyboard_dbus.h +++ b/virtualkeyboard_dbus.h @@ -1,62 +1,62 @@ /******************************************************************** 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 namespace KWin { class VirtualKeyboardDBus : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.VirtualKeyboard") Q_PROPERTY(bool enabled READ isEnabled NOTIFY enabledChanged) public: explicit VirtualKeyboardDBus(QObject *parent = nullptr); - ~VirtualKeyboardDBus(); + ~VirtualKeyboardDBus() override; Q_INVOKABLE bool isEnabled() const { return m_enabled; } void setEnabled(bool enabled) { if (m_enabled == enabled) { return; } m_enabled = enabled; emit enabledChanged(); } public Q_SLOTS: void enable() { emit activateRequested(true); } void disable() { emit activateRequested(false); } Q_SIGNALS: Q_SCRIPTABLE void enabledChanged(); void activateRequested(bool requested); private: bool m_enabled = false; }; } diff --git a/wayland_cursor_theme.h b/wayland_cursor_theme.h index be79089a8..5f3a90b6e 100644 --- a/wayland_cursor_theme.h +++ b/wayland_cursor_theme.h @@ -1,64 +1,64 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_WAYLAND_CURSOR_THEME_H #define KWIN_WAYLAND_CURSOR_THEME_H #include #include #include "cursor.h" struct wl_cursor_image; struct wl_cursor_theme; namespace KWayland { namespace Client { class ShmPool; } } namespace KWin { class KWIN_EXPORT WaylandCursorTheme : public QObject { Q_OBJECT public: explicit WaylandCursorTheme(KWayland::Client::ShmPool *shm, QObject *parent = nullptr); - virtual ~WaylandCursorTheme(); + ~WaylandCursorTheme() override; wl_cursor_image *get(CursorShape shape); wl_cursor_image *get(const QByteArray &name); Q_SIGNALS: void themeChanged(); private: void loadTheme(); void destroyTheme(); wl_cursor_theme *m_theme; KWayland::Client::ShmPool *m_shm = nullptr; }; } #endif diff --git a/wayland_server.h b/wayland_server.h index 09dd3657f..1f68e5b50 100644 --- a/wayland_server.h +++ b/wayland_server.h @@ -1,298 +1,298 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2015 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_WAYLAND_SERVER_H #define KWIN_WAYLAND_SERVER_H #include #include "keyboard_input.h" #include class QThread; class QProcess; class QWindow; namespace KWayland { namespace Client { class ConnectionThread; class Registry; class Compositor; class Seat; class DataDeviceManager; class ShmPool; class Surface; } namespace Server { class AppMenuManagerInterface; class ClientConnection; class CompositorInterface; class Display; class DataDeviceInterface; class IdleInterface; class ShellInterface; class SeatInterface; class DataDeviceManagerInterface; class ServerSideDecorationManagerInterface; class ServerSideDecorationPaletteManagerInterface; class SurfaceInterface; class OutputInterface; class PlasmaShellInterface; class PlasmaShellSurfaceInterface; class PlasmaVirtualDesktopManagementInterface; class PlasmaWindowManagementInterface; class QtSurfaceExtensionInterface; class OutputManagementInterface; class OutputConfigurationInterface; class XdgDecorationManagerInterface; class XdgShellInterface; class XdgForeignInterface; class XdgOutputManagerInterface; class KeyStateInterface; } } namespace KWin { class ShellClient; class AbstractClient; class Toplevel; class KWIN_EXPORT WaylandServer : public QObject { Q_OBJECT public: enum class InitalizationFlag { NoOptions = 0x0, LockScreen = 0x1, NoLockScreenIntegration = 0x2, NoGlobalShortcuts = 0x4 }; Q_DECLARE_FLAGS(InitalizationFlags, InitalizationFlag) - virtual ~WaylandServer(); + ~WaylandServer() override; bool init(const QByteArray &socketName = QByteArray(), InitalizationFlags flags = InitalizationFlag::NoOptions); void terminateClientConnections(); KWayland::Server::Display *display() { return m_display; } KWayland::Server::CompositorInterface *compositor() { return m_compositor; } KWayland::Server::SeatInterface *seat() { return m_seat; } KWayland::Server::DataDeviceManagerInterface *dataDeviceManager() { return m_dataDeviceManager; } KWayland::Server::ShellInterface *shell() { return m_shell; } KWayland::Server::PlasmaVirtualDesktopManagementInterface *virtualDesktopManagement() { return m_virtualDesktopManagement; } KWayland::Server::PlasmaWindowManagementInterface *windowManagement() { return m_windowManagement; } KWayland::Server::ServerSideDecorationManagerInterface *decorationManager() const { return m_decorationManager; } KWayland::Server::XdgOutputManagerInterface *xdgOutputManager() const { return m_xdgOutputManager; } QList clients() const { return m_clients; } QList internalClients() const { return m_internalClients; } void removeClient(ShellClient *c); ShellClient *findClient(quint32 id) const; ShellClient *findClient(KWayland::Server::SurfaceInterface *surface) const; AbstractClient *findAbstractClient(KWayland::Server::SurfaceInterface *surface) const; ShellClient *findClient(QWindow *w) const; /** * @returns a transient parent of a surface imported with the foreign protocol, if any **/ KWayland::Server::SurfaceInterface *findForeignTransientForSurface(KWayland::Server::SurfaceInterface *surface); /** * @returns file descriptor for Xwayland to connect to. **/ int createXWaylandConnection(); void destroyXWaylandConnection(); /** * @returns file descriptor to the input method server's socket. **/ int createInputMethodConnection(); void destroyInputMethodConnection(); /** * @returns true if screen is locked. **/ bool isScreenLocked() const; /** * @returns whether integration with KScreenLocker is available. **/ bool hasScreenLockerIntegration() const; /** * @returns whether any kind of global shortcuts are supported. **/ bool hasGlobalShortcutSupport() const; void createInternalConnection(); void initWorkspace(); KWayland::Server::ClientConnection *xWaylandConnection() const { return m_xwayland.client; } KWayland::Server::ClientConnection *inputMethodConnection() const { return m_inputMethodServerConnection; } KWayland::Server::ClientConnection *internalConnection() const { return m_internalConnection.server; } KWayland::Server::ClientConnection *screenLockerClientConnection() const { return m_screenLockerClientConnection; } KWayland::Client::Compositor *internalCompositor() { return m_internalConnection.compositor; } KWayland::Client::Seat *internalSeat() { return m_internalConnection.seat; } KWayland::Client::DataDeviceManager *internalDataDeviceManager() { return m_internalConnection.ddm; } KWayland::Client::ShmPool *internalShmPool() { return m_internalConnection.shm; } KWayland::Client::ConnectionThread *internalClientConection() { return m_internalConnection.client; } KWayland::Client::Registry *internalClientRegistry() { return m_internalConnection.registry; } void dispatch(); quint32 createWindowId(KWayland::Server::SurfaceInterface *surface); /** * Struct containing information for a created Wayland connection through a * socketpair. **/ struct SocketPairConnection { /** * ServerSide Connection **/ KWayland::Server::ClientConnection *connection = nullptr; /** * client-side file descriptor for the socket **/ int fd = -1; }; /** * Creates a Wayland connection using a socket pair. **/ SocketPairConnection createConnection(); void simulateUserActivity(); void updateKeyState(KWin::Xkb::LEDs leds); Q_SIGNALS: void shellClientAdded(KWin::ShellClient*); void shellClientRemoved(KWin::ShellClient*); void terminatingInternalClientConnection(); void initialized(); void foreignTransientChanged(KWayland::Server::SurfaceInterface *child); private: void shellClientShown(Toplevel *t); void initOutputs(); void syncOutputsToWayland(); quint16 createClientId(KWayland::Server::ClientConnection *c); void destroyInternalConnection(); void configurationChangeRequested(KWayland::Server::OutputConfigurationInterface *config); template void createSurface(T *surface); void initScreenLocker(); KWayland::Server::Display *m_display = nullptr; KWayland::Server::CompositorInterface *m_compositor = nullptr; KWayland::Server::SeatInterface *m_seat = nullptr; KWayland::Server::DataDeviceManagerInterface *m_dataDeviceManager = nullptr; KWayland::Server::ShellInterface *m_shell = nullptr; KWayland::Server::XdgShellInterface *m_xdgShell5 = nullptr; KWayland::Server::XdgShellInterface *m_xdgShell6 = nullptr; KWayland::Server::XdgShellInterface *m_xdgShell = nullptr; KWayland::Server::PlasmaShellInterface *m_plasmaShell = nullptr; KWayland::Server::PlasmaWindowManagementInterface *m_windowManagement = nullptr; KWayland::Server::PlasmaVirtualDesktopManagementInterface *m_virtualDesktopManagement = nullptr; KWayland::Server::ServerSideDecorationManagerInterface *m_decorationManager = nullptr; KWayland::Server::OutputManagementInterface *m_outputManagement = nullptr; KWayland::Server::AppMenuManagerInterface *m_appMenuManager = nullptr; KWayland::Server::ServerSideDecorationPaletteManagerInterface *m_paletteManager = nullptr; KWayland::Server::IdleInterface *m_idle = nullptr; KWayland::Server::XdgOutputManagerInterface *m_xdgOutputManager = nullptr; KWayland::Server::XdgDecorationManagerInterface *m_xdgDecorationManager = nullptr; struct { KWayland::Server::ClientConnection *client = nullptr; QMetaObject::Connection destroyConnection; } m_xwayland; KWayland::Server::ClientConnection *m_inputMethodServerConnection = nullptr; KWayland::Server::ClientConnection *m_screenLockerClientConnection = nullptr; struct { KWayland::Server::ClientConnection *server = nullptr; KWayland::Client::ConnectionThread *client = nullptr; QThread *clientThread = nullptr; KWayland::Client::Registry *registry = nullptr; KWayland::Client::Compositor *compositor = nullptr; KWayland::Client::Seat *seat = nullptr; KWayland::Client::DataDeviceManager *ddm = nullptr; KWayland::Client::ShmPool *shm = nullptr; bool interfacesAnnounced = false; } m_internalConnection; KWayland::Server::XdgForeignInterface *m_XdgForeign = nullptr; KWayland::Server::KeyStateInterface *m_keyState = nullptr; QList m_clients; QList m_internalClients; QHash m_clientIds; InitalizationFlags m_initFlags; QVector m_plasmaShellSurfaces; KWIN_SINGLETON(WaylandServer) }; inline WaylandServer *waylandServer() { return WaylandServer::self(); } } // namespace KWin #endif diff --git a/workspace.h b/workspace.h index 304b55a5c..fdcf03afc 100644 --- a/workspace.h +++ b/workspace.h @@ -1,779 +1,779 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 1999, 2000 Matthias Ettrich Copyright (C) 2003 Lubos Lunak Copyright (C) 2009 Lucas Murray 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_WORKSPACE_H #define KWIN_WORKSPACE_H // kwin #include "sm.h" #include "options.h" #include "utils.h" // Qt #include #include // std #include #include // TODO: Cleanup the order of things in this .h file class QStringList; class KConfig; class KConfigGroup; class KStartupInfo; class KStartupInfoId; class KStartupInfoData; namespace KWin { namespace Xcb { class Tree; class Window; } class AbstractClient; class Client; class KillWindow; class ShortcutDialog; class UserActionsMenu; class Compositor; class X11EventFilter; enum class Predicate; class KWIN_EXPORT Workspace : public QObject { Q_OBJECT public: explicit Workspace(const QString &sessionKey = QString()); - virtual ~Workspace(); + ~Workspace() override; static Workspace* self() { return _self; } bool workspaceEvent(xcb_generic_event_t*); bool workspaceEvent(QEvent*); bool hasClient(const Client*); bool hasClient(const AbstractClient*); /** * @brief Finds the first Client matching the condition expressed by passed in @p func. * * Internally findClient uses the std::find_if algorithm and that determines how the function * needs to be implemented. An example usage for finding a Client with a matching windowId * @code * xcb_window_t w; // our test window * Client *client = findClient([w](const Client *c) -> bool { * return c->window() == w; * }); * @endcode * * For the standard cases of matching the window id with one of the Client's windows use * the simplified overload method findClient(Predicate, xcb_window_t). Above example * can be simplified to: * @code * xcb_window_t w; // our test window * Client *client = findClient(Predicate::WindowMatch, w); * @endcode * * @param func Unary function that accepts a Client* as argument and * returns a value convertible to bool. The value returned indicates whether the * Client* is considered a match in the context of this function. * The function shall not modify its argument. * This can either be a function pointer or a function object. * @return KWin::Client* The found Client or @c null * @see findClient(Predicate, xcb_window_t) **/ Client *findClient(std::function func) const; AbstractClient *findAbstractClient(std::function func) const; /** * @brief Finds the Client matching the given match @p predicate for the given window. * * @param predicate Which window should be compared * @param w The window id to test against * @return KWin::Client* The found Client or @c null * @see findClient(std::function) **/ Client *findClient(Predicate predicate, xcb_window_t w) const; void forEachClient(std::function func); void forEachAbstractClient(std::function func); Unmanaged *findUnmanaged(std::function func) const; /** * @brief Finds the Unmanaged with the given window id. * * @param w The window id to search for * @return KWin::Unmanaged* Found Unmanaged or @c null if there is no Unmanaged with given Id. **/ Unmanaged *findUnmanaged(xcb_window_t w) const; void forEachUnmanaged(std::function func); Toplevel *findToplevel(std::function func) const; /** * Finds the Toplevel for the KWin internal window @p w. * On Wayland this is normally a ShellClient. For X11 an Unmanaged. **/ Toplevel *findToplevel(QWindow *w) const; /** * @brief Finds a Toplevel for the internal window @p w. * * Internal window means a window created by KWin itself. On X11 this is an Unmanaged * and mapped by the window id, on Wayland a ShellClient mapped on the internal window id. * * @returns Toplevel **/ Toplevel *findInternal(QWindow *w) const; QRect clientArea(clientAreaOption, const QPoint& p, int desktop) const; QRect clientArea(clientAreaOption, const AbstractClient* c) const; QRect clientArea(clientAreaOption, int screen, int desktop) const; QRegion restrictedMoveArea(int desktop, StrutAreas areas = StrutAreaAll) const; bool initializing() const; /** * Returns the active client, i.e. the client that has the focus (or None * if no client has the focus) **/ AbstractClient* activeClient() const; /** * Client that was activated, but it's not yet really activeClient(), because * we didn't process yet the matching FocusIn event. Used mostly in focus * stealing prevention code. **/ AbstractClient* mostRecentlyActivatedClient() const; AbstractClient* clientUnderMouse(int screen) const; void activateClient(AbstractClient*, bool force = false); void requestFocus(AbstractClient* c, bool force = false); enum ActivityFlag { ActivityFocus = 1 << 0, // focus the window ActivityFocusForce = 1 << 1 | ActivityFocus, // focus even if Dock etc. ActivityRaise = 1 << 2 // raise the window }; Q_DECLARE_FLAGS(ActivityFlags, ActivityFlag) void takeActivity(AbstractClient* c, ActivityFlags flags); bool allowClientActivation(const AbstractClient* c, xcb_timestamp_t time = -1U, bool focus_in = false, bool ignore_desktop = false); void restoreFocus(); void gotFocusIn(const AbstractClient*); void setShouldGetFocus(AbstractClient*); bool activateNextClient(AbstractClient* c); bool focusChangeEnabled() { return block_focus == 0; } /** * Indicates that the client c is being moved or resized by the user. **/ void setMoveResizeClient(AbstractClient* c); QPoint adjustClientPosition(AbstractClient* c, QPoint pos, bool unrestricted, double snapAdjust = 1.0); QRect adjustClientSize(AbstractClient* c, QRect moveResizeGeom, int mode); void raiseClient(AbstractClient* c, bool nogroup = false); void lowerClient(AbstractClient* c, bool nogroup = false); void raiseClientRequest(AbstractClient* c, NET::RequestSource src = NET::FromApplication, xcb_timestamp_t timestamp = 0); void lowerClientRequest(Client* c, NET::RequestSource src, xcb_timestamp_t timestamp); void lowerClientRequest(AbstractClient* c); void restackClientUnderActive(AbstractClient*); void restack(AbstractClient *c, AbstractClient *under, bool force = false); void updateClientLayer(AbstractClient* c); void raiseOrLowerClient(AbstractClient*); void resetUpdateToolWindowsTimer(); void restoreSessionStackingOrder(Client* c); void updateStackingOrder(bool propagate_new_clients = false); void forceRestacking(); void clientHidden(AbstractClient*); void clientAttentionChanged(AbstractClient* c, bool set); /** * @return List of clients currently managed by Workspace **/ const ClientList &clientList() const { return clients; } /** * @return List of unmanaged "clients" currently registered in Workspace **/ const UnmanagedList &unmanagedList() const { return unmanaged; } /** * @return List of desktop "clients" currently managed by Workspace **/ const ClientList &desktopList() const { return desktops; } /** * @return List of deleted "clients" currently managed by Workspace **/ const DeletedList &deletedList() const { return deleted; } /** * @returns List of all clients (either X11 or Wayland) currently managed by Workspace **/ const QList allClientList() const { return m_allClients; } void stackScreenEdgesUnderOverrideRedirect(); public: QPoint cascadeOffset(const AbstractClient *c) const; private: Compositor *m_compositor; //------------------------------------------------- // Unsorted public: bool isOnCurrentHead(); // True when performing Workspace::updateClientArea(). // The calls below are valid only in that case. bool inUpdateClientArea() const; QRegion previousRestrictedMoveArea(int desktop, StrutAreas areas = StrutAreaAll) const; QVector< QRect > previousScreenSizes() const; int oldDisplayWidth() const; int oldDisplayHeight() const; /** * Returns the list of clients sorted in stacking order, with topmost client * at the last position **/ const ToplevelList& stackingOrder() const; ToplevelList xStackingOrder() const; ClientList ensureStackingOrder(const ClientList& clients) const; QList ensureStackingOrder(const QList &clients) const; AbstractClient* topClientOnDesktop(int desktop, int screen, bool unconstrained = false, bool only_normal = true) const; AbstractClient* findDesktop(bool topmost, int desktop) const; void sendClientToDesktop(AbstractClient* c, int desktop, bool dont_activate); void windowToPreviousDesktop(AbstractClient* c); void windowToNextDesktop(AbstractClient* c); void sendClientToScreen(AbstractClient* c, int screen); void addManualOverlay(xcb_window_t id) { manual_overlays << id; } void removeManualOverlay(xcb_window_t id) { manual_overlays.removeOne(id); } /** * Shows the menu operations menu for the client and makes it active if * it's not already. **/ void showWindowMenu(const QRect& pos, AbstractClient* cl); const UserActionsMenu *userActionsMenu() const { return m_userActionsMenu; } void showApplicationMenu(const QRect &pos, AbstractClient *c, int actionId); void updateMinimizedOfTransients(AbstractClient*); void updateOnAllDesktopsOfTransients(AbstractClient*); void checkTransients(xcb_window_t w); void storeSession(KConfig* config, SMSavePhase phase); void storeClient(KConfigGroup &cg, int num, Client *c); void storeSubSession(const QString &name, QSet sessionIds); void loadSubSessionInfo(const QString &name); SessionInfo* takeSessionInfo(Client*); // D-Bus interface QString supportInformation() const; void setCurrentScreen(int new_screen); void setShowingDesktop(bool showing); bool showingDesktop() const; void sendPingToWindow(xcb_window_t w, xcb_timestamp_t timestamp); // Called from Client::pingWindow() void removeClient(Client*); // Only called from Client::destroyClient() or Client::releaseWindow() void setActiveClient(AbstractClient*); Group* findGroup(xcb_window_t leader) const; void addGroup(Group* group); void removeGroup(Group* group); Group* findClientLeaderGroup(const Client* c) const; void removeUnmanaged(Unmanaged*); // Only called from Unmanaged::release() void removeDeleted(Deleted*); void addDeleted(Deleted*, Toplevel*); bool checkStartupNotification(xcb_window_t w, KStartupInfoId& id, KStartupInfoData& data); void focusToNull(); // SELI TODO: Public? void clientShortcutUpdated(AbstractClient* c); bool shortcutAvailable(const QKeySequence &cut, AbstractClient* ignore = NULL) const; bool globalShortcutsDisabled() const; void disableGlobalShortcutsForClient(bool disable); void sessionSaveStarted(); void sessionSaveDone(); void setWasUserInteraction(); bool wasUserInteraction() const; bool sessionSaving() const; int packPositionLeft(const AbstractClient* cl, int oldx, bool left_edge) const; int packPositionRight(const AbstractClient* cl, int oldx, bool right_edge) const; int packPositionUp(const AbstractClient* cl, int oldy, bool top_edge) const; int packPositionDown(const AbstractClient* cl, int oldy, bool bottom_edge) const; void cancelDelayFocus(); void requestDelayFocus(AbstractClient*); /** * updates the mouse position to track whether a focus follow mouse focus change was caused by * an actual mouse move * is esp. called on enter/motion events of inactive windows * since an active window doesn't receive mouse events, it must also be invoked if a (potentially) * active window might be moved/resize away from the cursor (causing a leave event) **/ void updateFocusMousePosition(const QPoint& pos); QPoint focusMousePosition() const; /** * Returns a client that is currently being moved or resized by the user. * * If none of clients is being moved or resized, @c null will be returned. **/ AbstractClient* moveResizeClient() { return movingClient; } /** * @returns Whether we have a Compositor and it is active (Scene created) **/ bool compositing() const; void registerEventFilter(X11EventFilter *filter); void unregisterEventFilter(X11EventFilter *filter); void markXStackingOrderAsDirty(); void quickTileWindow(QuickTileMode mode); enum Direction { DirectionNorth, DirectionEast, DirectionSouth, DirectionWest }; void switchWindow(Direction direction); ShortcutDialog *shortcutDialog() const { return client_keys_dialog; } public Q_SLOTS: void performWindowOperation(KWin::AbstractClient* c, Options::WindowOperation op); // Keybindings //void slotSwitchToWindow( int ); void slotWindowToDesktop(uint i); //void slotWindowToListPosition( int ); void slotSwitchToScreen(); void slotWindowToScreen(); void slotSwitchToNextScreen(); void slotWindowToNextScreen(); void slotSwitchToPrevScreen(); void slotWindowToPrevScreen(); void slotToggleShowDesktop(); void slotWindowMaximize(); void slotWindowMaximizeVertical(); void slotWindowMaximizeHorizontal(); void slotWindowMinimize(); void slotWindowShade(); void slotWindowRaise(); void slotWindowLower(); void slotWindowRaiseOrLower(); void slotActivateAttentionWindow(); void slotWindowPackLeft(); void slotWindowPackRight(); void slotWindowPackUp(); void slotWindowPackDown(); void slotWindowGrowHorizontal(); void slotWindowGrowVertical(); void slotWindowShrinkHorizontal(); void slotWindowShrinkVertical(); void slotIncreaseWindowOpacity(); void slotLowerWindowOpacity(); void slotWindowOperations(); void slotWindowClose(); void slotWindowMove(); void slotWindowResize(); void slotWindowAbove(); void slotWindowBelow(); void slotWindowOnAllDesktops(); void slotWindowFullScreen(); void slotWindowNoBorder(); void slotWindowToNextDesktop(); void slotWindowToPreviousDesktop(); void slotWindowToDesktopRight(); void slotWindowToDesktopLeft(); void slotWindowToDesktopUp(); void slotWindowToDesktopDown(); void reconfigure(); void slotReconfigure(); void slotKillWindow(); void slotSetupWindowShortcut(); void setupWindowShortcutDone(bool); void updateClientArea(); void slotActivateNextTab(); // Slot to move left the active Client. void slotActivatePrevTab(); // Slot to move right the active Client. void slotUntab(); // Slot to remove the active client from its group. private Q_SLOTS: void desktopResized(); void selectWmInputEventMask(); void slotUpdateToolWindows(); void delayFocus(); void slotReloadConfig(); void updateCurrentActivity(const QString &new_activity); // virtual desktop handling void slotDesktopCountChanged(uint previousCount, uint newCount); void slotCurrentDesktopChanged(uint oldDesktop, uint newDesktop); // session management void saveState(QSessionManager &sm); void commitData(QSessionManager &sm); Q_SIGNALS: /** * Emitted after the Workspace has setup the complete initialization process. * This can be used to connect to for performing post-workspace initialization. **/ void workspaceInitialized(); //Signals required for the scripting interface void desktopPresenceChanged(KWin::AbstractClient*, int); void currentDesktopChanged(int, KWin::AbstractClient*); void clientAdded(KWin::Client*); void clientRemoved(KWin::AbstractClient*); void clientActivated(KWin::AbstractClient*); void clientDemandsAttentionChanged(KWin::AbstractClient*, bool); void clientMinimizedChanged(KWin::AbstractClient*); void groupAdded(KWin::Group*); void unmanagedAdded(KWin::Unmanaged*); void unmanagedRemoved(KWin::Unmanaged*); void deletedRemoved(KWin::Deleted*); void configChanged(); void showingDesktopChanged(bool showing); /** * This signels is emitted when ever the stacking order is change, ie. a window is risen * or lowered **/ void stackingOrderChanged(); private: void init(); void initWithX11(); void initShortcuts(); template void initShortcut(const QString &actionName, const QString &description, const QKeySequence &shortcut, Slot slot, const QVariant &data = QVariant()); template void initShortcut(const QString &actionName, const QString &description, const QKeySequence &shortcut, T *receiver, Slot slot, const QVariant &data = QVariant()); void setupWindowShortcut(AbstractClient* c); bool switchWindow(AbstractClient *c, Direction direction, QPoint curPos, int desktop); void propagateClients(bool propagate_new_clients); // Called only from updateStackingOrder ToplevelList constrainedStackingOrder(); void raiseClientWithinApplication(AbstractClient* c); void lowerClientWithinApplication(AbstractClient* c); bool allowFullClientRaising(const AbstractClient* c, xcb_timestamp_t timestamp); bool keepTransientAbove(const AbstractClient* mainwindow, const AbstractClient* transient); bool keepDeletedTransientAbove(const Toplevel *mainWindow, const Deleted *transient) const; void blockStackingUpdates(bool block); void updateToolWindows(bool also_hide); void fixPositionAfterCrash(xcb_window_t w, const xcb_get_geometry_reply_t *geom); void saveOldScreenSizes(); /// This is the right way to create a new client Client* createClient(xcb_window_t w, bool is_mapped); void setupClientConnections(AbstractClient *client); void addClient(Client* c); Unmanaged* createUnmanaged(xcb_window_t w); void addUnmanaged(Unmanaged* c); //--------------------------------------------------------------------- void closeActivePopup(); void updateClientArea(bool force); void resetClientAreas(uint desktopCount); void updateClientVisibilityOnDesktopChange(uint newDesktop); void activateClientOnNewDesktop(uint desktop); AbstractClient *findClientToActivateOnDesktop(uint desktop); QWidget* active_popup; AbstractClient* active_popup_client; int m_initialDesktop; void loadSessionInfo(const QString &key); void addSessionInfo(KConfigGroup &cg); QList session; void updateXStackingOrder(); AbstractClient* active_client; AbstractClient* last_active_client; AbstractClient* most_recently_raised; // Used ONLY by raiseOrLowerClient() AbstractClient* movingClient; // Delay(ed) window focus timer and client QTimer* delayFocusTimer; AbstractClient* delayfocus_client; QPoint focusMousePos; ClientList clients; QList m_allClients; ClientList desktops; UnmanagedList unmanaged; DeletedList deleted; ToplevelList unconstrained_stacking_order; // Topmost last ToplevelList stacking_order; // Topmost last QVector manual_overlays; //Topmost last bool force_restacking; ToplevelList x_stacking; // From XQueryTree() std::unique_ptr m_xStackingQueryTree; bool m_xStackingDirty = false; QList should_get_focus; // Last is most recent QList attention_chain; bool showing_desktop; GroupList groups; bool was_user_interaction; QScopedPointer m_wasUserInteractionFilter; bool session_saving; int session_active_client; int session_desktop; int block_focus; /** * Holds the menu containing the user actions which is shown * on e.g. right click the window decoration. **/ UserActionsMenu *m_userActionsMenu; void modalActionsSwitch(bool enabled); ShortcutDialog* client_keys_dialog; AbstractClient* client_keys_client; bool global_shortcuts_disabled_for_client; // Timer to collect requests for 'reconfigure' QTimer reconfigureTimer; QTimer updateToolWindowsTimer; static Workspace* _self; bool workspaceInit; KStartupInfo* startup; QVector workarea; // Array of workareas for virtual desktops // Array of restricted areas that window cannot be moved into QVector restrictedmovearea; // Array of the previous restricted areas that window cannot be moved into QVector oldrestrictedmovearea; QVector< QVector > screenarea; // Array of workareas per xinerama screen for all virtual desktops QVector< QRect > oldscreensizes; // array of previous sizes of xinerama screens QSize olddisplaysize; // previous sizes od displayWidth()/displayHeight() int set_active_client_recursion; int block_stacking_updates; // When > 0, stacking updates are temporarily disabled bool blocked_propagating_new_clients; // Propagate also new clients after enabling stacking updates? QScopedPointer m_nullFocus; friend class StackingUpdatesBlocker; QScopedPointer m_windowKiller; QList m_eventFilters; QList m_genericEventFilters; QScopedPointer m_movingClientFilter; private: friend bool performTransiencyCheck(); friend Workspace *workspace(); }; /** * Helper for Workspace::blockStackingUpdates() being called in pairs (True/false) **/ class StackingUpdatesBlocker { public: explicit StackingUpdatesBlocker(Workspace* w) : ws(w) { ws->blockStackingUpdates(true); } ~StackingUpdatesBlocker() { ws->blockStackingUpdates(false); } private: Workspace* ws; }; class ColorMapper : public QObject { Q_OBJECT public: ColorMapper(QObject *parent); - virtual ~ColorMapper(); + ~ColorMapper() override; public Q_SLOTS: void update(); private: xcb_colormap_t m_default; xcb_colormap_t m_installed; }; //--------------------------------------------------------- // Unsorted inline bool Workspace::initializing() const { return workspaceInit; } inline AbstractClient *Workspace::activeClient() const { return active_client; } inline AbstractClient *Workspace::mostRecentlyActivatedClient() const { return should_get_focus.count() > 0 ? should_get_focus.last() : active_client; } inline void Workspace::addGroup(Group* group) { emit groupAdded(group); groups.append(group); } inline void Workspace::removeGroup(Group* group) { groups.removeAll(group); } inline const ToplevelList& Workspace::stackingOrder() const { // TODO: Q_ASSERT( block_stacking_updates == 0 ); return stacking_order; } inline bool Workspace::wasUserInteraction() const { return was_user_interaction; } inline void Workspace::sessionSaveStarted() { session_saving = true; } inline bool Workspace::sessionSaving() const { return session_saving; } inline bool Workspace::showingDesktop() const { return showing_desktop; } inline bool Workspace::globalShortcutsDisabled() const { return global_shortcuts_disabled_for_client; } inline void Workspace::forceRestacking() { force_restacking = true; StackingUpdatesBlocker blocker(this); // Do restacking if not blocked } inline void Workspace::updateFocusMousePosition(const QPoint& pos) { focusMousePos = pos; } inline QPoint Workspace::focusMousePosition() const { return focusMousePos; } inline void Workspace::forEachClient(std::function< void (Client*) > func) { std::for_each(clients.constBegin(), clients.constEnd(), func); std::for_each(desktops.constBegin(), desktops.constEnd(), func); } inline void Workspace::forEachUnmanaged(std::function< void (Unmanaged*) > func) { std::for_each(unmanaged.constBegin(), unmanaged.constEnd(), func); } inline bool Workspace::hasClient(const Client* c) { return findClient([c](const Client *test) { return test == c; }); } inline Workspace *workspace() { return Workspace::_self; } } // namespace Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::Workspace::ActivityFlags) #endif diff --git a/xkb.h b/xkb.h index 671f67b22..02d3f9b10 100644 --- a/xkb.h +++ b/xkb.h @@ -1,179 +1,179 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright (C) 2013, 2016, 2017 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_XKB_H #define KWIN_XKB_H #include "input.h" #include #include #include Q_DECLARE_LOGGING_CATEGORY(KWIN_XKB) struct xkb_context; struct xkb_keymap; struct xkb_state; struct xkb_compose_table; struct xkb_compose_state; typedef uint32_t xkb_mod_index_t; typedef uint32_t xkb_led_index_t; typedef uint32_t xkb_keysym_t; typedef uint32_t xkb_layout_index_t; namespace KWayland { namespace Server { class SeatInterface; } } namespace KWin { class KWIN_EXPORT Xkb : public QObject { Q_OBJECT public: Xkb(QObject *parent = nullptr); - ~Xkb(); + ~Xkb() override; void setConfig(KSharedConfigPtr config) { m_config = config; } void setNumLockConfig(KSharedConfigPtr config) { m_numLockConfig = config; } void reconfigure(); void installKeymap(int fd, uint32_t size); void updateModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group); void updateKey(uint32_t key, InputRedirection::KeyboardKeyState state); xkb_keysym_t toKeysym(uint32_t key); xkb_keysym_t currentKeysym() const { return m_keysym; } QString toString(xkb_keysym_t keysym); Qt::Key toQtKey(xkb_keysym_t keysym) const; xkb_keysym_t fromQtKey(Qt::Key key, Qt::KeyboardModifiers mods) const; xkb_keysym_t fromKeyEvent(QKeyEvent *event) const; Qt::KeyboardModifiers modifiers() const; Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const; bool shouldKeyRepeat(quint32 key) const; void switchToNextLayout(); void switchToPreviousLayout(); void switchToLayout(xkb_layout_index_t layout); enum class LED { NumLock = 1 << 0, CapsLock = 1 << 1, ScrollLock = 1 << 2 }; Q_DECLARE_FLAGS(LEDs, LED) LEDs leds() const { return m_leds; } xkb_keymap *keymap() const { return m_keymap; } xkb_state *state() const { return m_state; } quint32 currentLayout() const { return m_currentLayout; } QString layoutName() const; QMap layoutNames() const; quint32 numberOfLayouts() const; /** * Forwards the current modifier state to the Wayland seat **/ void forwardModifiers(); void setSeat(KWayland::Server::SeatInterface *seat); Q_SIGNALS: void ledsChanged(const LEDs &leds); private: xkb_keymap *loadKeymapFromConfig(); xkb_keymap *loadDefaultKeymap(); void updateKeymap(xkb_keymap *keymap); void createKeymapFile(); void updateModifiers(); void updateConsumedModifiers(uint32_t key); QString layoutName(xkb_layout_index_t layout) const; xkb_context *m_context; xkb_keymap *m_keymap; xkb_state *m_state; xkb_mod_index_t m_shiftModifier; xkb_mod_index_t m_capsModifier; xkb_mod_index_t m_controlModifier; xkb_mod_index_t m_altModifier; xkb_mod_index_t m_metaModifier; xkb_mod_index_t m_numModifier; xkb_led_index_t m_numLock; xkb_led_index_t m_capsLock; xkb_led_index_t m_scrollLock; Qt::KeyboardModifiers m_modifiers; Qt::KeyboardModifiers m_consumedModifiers; xkb_keysym_t m_keysym; quint32 m_currentLayout = 0; struct { xkb_compose_table *table = nullptr; xkb_compose_state *state = nullptr; } m_compose; LEDs m_leds; KSharedConfigPtr m_config; KSharedConfigPtr m_numLockConfig; struct { xkb_mod_index_t depressed = 0; xkb_mod_index_t latched = 0; xkb_mod_index_t locked = 0; } m_modifierState; enum class Ownership { Server, Client }; Ownership m_ownership = Ownership::Server; QPointer m_seat; }; inline Qt::KeyboardModifiers Xkb::modifiers() const { return m_modifiers; } } Q_DECLARE_METATYPE(KWin::Xkb::LED) Q_DECLARE_METATYPE(KWin::Xkb::LEDs) #endif diff --git a/xwl/databridge.h b/xwl/databridge.h index b1b4296fb..cf368a409 100644 --- a/xwl/databridge.h +++ b/xwl/databridge.h @@ -1,104 +1,104 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright 2018 Roman Gilg 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_XWL_DATABRIDGE #define KWIN_XWL_DATABRIDGE #include #include #include class xcb_xfixes_selection_notify_event_t; namespace KWayland { namespace Client { class DataDevice; } namespace Server { class DataDeviceInterface; class SurfaceInterface; } } namespace KWin { class Toplevel; namespace Xwl { class Xwayland; class Clipboard; class Dnd; enum class DragEventReply; /** * Interface class for all data sharing in the context of X selections * and Wayland's internal mechanism. * * Exists only once per Xwayland session. **/ class DataBridge : public QObject { Q_OBJECT public: static DataBridge *self(); explicit DataBridge(QObject *parent = nullptr); - ~DataBridge(); + ~DataBridge() override; bool filterEvent(xcb_generic_event_t *event); DragEventReply dragMoveFilter(Toplevel *target, const QPoint &pos); KWayland::Client::DataDevice *dataDevice() const { return m_dataDevice; } KWayland::Server::DataDeviceInterface *dataDeviceIface() const { return m_dataDeviceInterface; } Dnd *dnd() const { return m_dnd; } private: void init(); bool handleXfixesNotify(xcb_xfixes_selection_notify_event_t *event); Clipboard *m_clipboard = nullptr; Dnd *m_dnd = nullptr; /* Internal data device interface */ KWayland::Client::DataDevice *m_dataDevice = nullptr; KWayland::Server::DataDeviceInterface *m_dataDeviceInterface = nullptr; Q_DISABLE_COPY(DataBridge) }; } // namespace Xwl } // namespace KWin #endif diff --git a/xwl/drag_x.h b/xwl/drag_x.h index 283208ef9..1bbf40b0b 100644 --- a/xwl/drag_x.h +++ b/xwl/drag_x.h @@ -1,169 +1,169 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright 2019 Roman Gilg 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_XWL_DRAG_X #define KWIN_XWL_DRAG_X #include "drag.h" #include #include #include #include #include #include namespace KWayland { namespace Client { class DataSource; } } namespace KWin { class Toplevel; class AbstractClient; namespace Xwl { class X11Source; enum class DragEventReply; class WlVisit; using Mimes = QVector >; class XToWlDrag : public Drag { Q_OBJECT public: explicit XToWlDrag(X11Source *source); ~XToWlDrag() override; DragEventReply moveFilter(Toplevel *target, const QPoint &pos) override; bool handleClientMessage(xcb_client_message_event_t *event) override; void setDragAndDropAction(DnDAction action); DnDAction selectedDragAndDropAction(); bool end() override { return false; } X11Source *x11Source() const { return m_source; } private: void setOffers(const Mimes &offers); void offerCallback(const QString &mime); void setDragTarget(); bool checkForFinished(); KWayland::Client::DataSource *m_dataSource; Mimes m_offers; Mimes m_offersPending; X11Source *m_source; QVector > m_dataRequests; WlVisit *m_visit = nullptr; QVector m_oldVisits; bool m_performed = false; DnDAction m_lastSelectedDragAndDropAction = DnDAction::None; Q_DISABLE_COPY(XToWlDrag) }; class WlVisit : public QObject { Q_OBJECT public: WlVisit(AbstractClient *target, XToWlDrag *drag); - ~WlVisit(); + ~WlVisit() override; bool handleClientMessage(xcb_client_message_event_t *event); bool leave(); AbstractClient *target() const { return m_target; } xcb_window_t window() const { return m_window; } bool entered() const { return m_entered; } bool dropHandled() const { return m_dropHandled; } bool finished() const { return m_finished; } void sendFinished(); Q_SIGNALS: void offersReceived(const Mimes &offers); void finish(WlVisit *self); private: bool handleEnter(xcb_client_message_event_t *event); bool handlePosition(xcb_client_message_event_t *event); bool handleDrop(xcb_client_message_event_t *event); bool handleLeave(xcb_client_message_event_t *event); void sendStatus(); void getMimesFromWinProperty(Mimes &offers); bool targetAcceptsAction() const; void doFinish(); void unmapProxyWindow(); AbstractClient *m_target; xcb_window_t m_window; xcb_window_t m_srcWindow = XCB_WINDOW_NONE; XToWlDrag *m_drag; uint32_t m_version = 0; xcb_atom_t m_actionAtom; DnDAction m_action = DnDAction::None; bool m_mapped = false; bool m_entered = false; bool m_dropHandled = false; bool m_finished = false; Q_DISABLE_COPY(WlVisit) }; } // namespace Xwl } // namespace KWin #endif diff --git a/xwl/transfer.h b/xwl/transfer.h index 43b6403f0..d57a58fea 100644 --- a/xwl/transfer.h +++ b/xwl/transfer.h @@ -1,230 +1,230 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright 2018 Roman Gilg 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_XWL_TRANSFER #define KWIN_XWL_TRANSFER #include #include #include #include namespace KWayland { namespace Client { class DataDevice; class DataSource; } namespace Server { class DataDeviceInterface; } } namespace KWin { namespace Xwl { /** * Represents for an arbitrary selection a data transfer between * sender and receiver. * * Lives for the duration of the transfer and must be cleaned up * externally afterwards. For that the owner should connect to the * @c finished() signal. **/ class Transfer : public QObject { Q_OBJECT public: Transfer(xcb_atom_t selection, qint32 fd, xcb_timestamp_t timestamp, QObject *parent = nullptr); virtual bool handlePropertyNotify(xcb_property_notify_event_t *event) = 0; void timeout(); xcb_timestamp_t timestamp() const { return m_timestamp; } Q_SIGNALS: void finished(); protected: void endTransfer(); xcb_atom_t atom() const { return m_atom; } qint32 fd() const { return m_fd; } void setIncr(bool set) { m_incr = set; } bool incr() const { return m_incr; } void resetTimeout() { m_timeout = false; } void createSocketNotifier(QSocketNotifier::Type type); void clearSocketNotifier(); QSocketNotifier *socketNotifier() const { return m_notifier; } private: void closeFd(); xcb_atom_t m_atom; qint32 m_fd; xcb_timestamp_t m_timestamp = XCB_CURRENT_TIME; QSocketNotifier *m_notifier = nullptr; bool m_incr = false; bool m_timeout = false; Q_DISABLE_COPY(Transfer) }; /** * Represents a transfer from a Wayland native source to an X window. **/ class TransferWltoX : public Transfer { Q_OBJECT public: TransferWltoX(xcb_atom_t selection, xcb_selection_request_event_t *request, qint32 fd, QObject *parent = nullptr); - ~TransferWltoX(); + ~TransferWltoX() override; void startTransferFromSource(); bool handlePropertyNotify(xcb_property_notify_event_t *event) override; Q_SIGNALS: void selectionNotify(xcb_selection_request_event_t *event, bool success); private: void startIncr(); void readWlSource(); int flushSourceData(); void handlePropertyDelete(); xcb_selection_request_event_t *m_request = nullptr; /* contains all received data portioned in chunks * TODO: explain second QPair component */ QVector > m_chunks; bool m_propertyIsSet = false; bool m_flushPropertyOnDelete = false; Q_DISABLE_COPY(TransferWltoX) }; /** * Helper class for X to Wl transfers. **/ class DataReceiver { public: virtual ~DataReceiver(); void transferFromProperty(xcb_get_property_reply_t *reply); virtual void setData(const char *value, int length); QByteArray data() const; void partRead(int length); protected: void setDataInternal(QByteArray data) { m_data = data; } private: xcb_get_property_reply_t *m_propertyReply = nullptr; int m_propertyStart = 0; QByteArray m_data; }; /** * Compatibility receiver for clients only * supporting the NETSCAPE_URL scheme (Firefox) **/ class NetscapeUrlReceiver : public DataReceiver { public: void setData(const char *value, int length) override; }; /** * Compatibility receiver for clients only * supporting the text/x-moz-url scheme (Chromium on own drags) **/ class MozUrlReceiver : public DataReceiver { public: void setData(const char *value, int length) override; }; /** * Represents a transfer from an X window to a Wayland native client. **/ class TransferXtoWl : public Transfer { Q_OBJECT public: TransferXtoWl(xcb_atom_t selection, xcb_atom_t target, qint32 fd, xcb_timestamp_t timestamp, xcb_window_t parentWindow, QObject *parent = nullptr); - ~TransferXtoWl(); + ~TransferXtoWl() override; bool handleSelectionNotify(xcb_selection_notify_event_t *event); bool handlePropertyNotify(xcb_property_notify_event_t *event) override; private: void dataSourceWrite(); void startTransfer(); void getIncrChunk(); xcb_window_t m_window; DataReceiver *m_receiver = nullptr; Q_DISABLE_COPY(TransferXtoWl) }; } // namespace Xwl } // namespace KWin #endif diff --git a/xwl/xwayland_interface.h b/xwl/xwayland_interface.h index 2783f8968..a7ef7cb98 100644 --- a/xwl/xwayland_interface.h +++ b/xwl/xwayland_interface.h @@ -1,68 +1,68 @@ /******************************************************************** KWin - the KDE window manager This file is part of the KDE project. Copyright 2019 Roman Gilg 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_XWL_XWAYLAND_INTERFACE #define KWIN_XWL_XWAYLAND_INTERFACE #include #include #include namespace KWin { class Toplevel; namespace Xwl { enum class DragEventReply { // event should be ignored by the filter Ignore, // event is filtered out Take, // event should be handled as a Wayland native one Wayland, }; } // namespace Xwl class KWIN_EXPORT XwaylandInterface : public QObject { Q_OBJECT public: static XwaylandInterface *self(); virtual Xwl::DragEventReply dragMoveFilter(Toplevel *target, const QPoint &pos) = 0; protected: explicit XwaylandInterface(QObject *parent = nullptr); - virtual ~XwaylandInterface(); + ~XwaylandInterface() override; private: Q_DISABLE_COPY(XwaylandInterface) }; inline XwaylandInterface *xwayland() { return XwaylandInterface::self(); } } // namespace KWin #endif