From 7096e3ead89e18135178e3346f08167ff69b5f98 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 23 Mar 2022 12:13:38 +0200 Subject: [PATCH] Run clang-format The .clang-format file is based on the one in ECM except the following style options: - AlwaysBreakBeforeMultilineStrings - BinPackArguments - BinPackParameters - ColumnLimit - BreakBeforeBraces - KeepEmptyLinesAtTheStartOfBlocks --- .clang-format | 83 ++ .gitignore | 1 - autotests/integration/activation_test.cpp | 30 +- autotests/integration/activities_test.cpp | 23 +- .../integration/buffer_size_change_test.cpp | 5 +- autotests/integration/dbus_interface_test.cpp | 115 +-- autotests/integration/debug_console_test.cpp | 13 +- .../integration/decoration_input_test.cpp | 100 +- .../integration/desktop_window_x11_test.cpp | 23 +- .../dont_crash_aurorae_destroy_deco.cpp | 12 +- .../dont_crash_cancel_animation.cpp | 19 +- .../dont_crash_cursor_physical_size_empty.cpp | 9 +- .../integration/dont_crash_empty_deco.cpp | 7 +- autotests/integration/dont_crash_glxgears.cpp | 7 +- .../integration/dont_crash_no_border.cpp | 7 +- .../dont_crash_reinitialize_compositor.cpp | 6 +- .../dont_crash_useractions_menu.cpp | 3 +- .../desktop_switching_animation_test.cpp | 4 +- .../effects/minimize_animation_test.cpp | 6 +- .../effects/scripted_effects_test.cpp | 73 +- .../effects/slidingpopups_test.cpp | 35 +- .../toplevel_open_close_animation_test.cpp | 12 +- .../integration/effects/translucency_test.cpp | 21 +- .../integration/effects/wobbly_shade_test.cpp | 16 +- .../fakedecoration_with_shadows.cpp | 18 +- .../integration/generic_scene_opengl_test.cpp | 4 +- .../integration/generic_scene_opengl_test.h | 3 +- .../integration/globalshortcuts_test.cpp | 52 +- autotests/integration/helper/copy.cpp | 2 +- autotests/integration/helper/kill.cpp | 2 +- autotests/integration/helper/paste.cpp | 11 +- .../integration/idle_inhibition_test.cpp | 8 +- .../integration/input_stacking_order.cpp | 13 +- autotests/integration/inputmethod_test.cpp | 32 +- autotests/integration/internal_window.cpp | 19 +- .../integration/keyboard_layout_test.cpp | 66 +- .../keymap_creation_failure_test.cpp | 3 +- autotests/integration/kwin_wayland_test.cpp | 8 +- autotests/integration/kwin_wayland_test.h | 52 +- autotests/integration/kwinbindings_test.cpp | 10 +- .../integration/layershellv1client_test.cpp | 122 ++- autotests/integration/lockscreen.cpp | 195 ++-- autotests/integration/maximize_test.cpp | 8 +- .../modifier_only_shortcut_test.cpp | 6 +- .../integration/move_resize_window_test.cpp | 65 +- autotests/integration/nightcolor_test.cpp | 7 +- .../integration/no_global_shortcuts_test.cpp | 3 +- autotests/integration/outputchanges_test.cpp | 2 +- autotests/integration/placement_test.cpp | 11 +- autotests/integration/plasma_surface_test.cpp | 6 +- autotests/integration/plasmawindow_test.cpp | 11 +- autotests/integration/platformcursor.cpp | 1 + .../integration/pointer_constraints_test.cpp | 20 +- autotests/integration/pointer_input.cpp | 174 ++-- autotests/integration/quick_tiling_test.cpp | 62 +- .../integration/scene_opengl_es_test.cpp | 5 +- autotests/integration/scene_opengl_test.cpp | 5 +- autotests/integration/scene_qpainter_test.cpp | 22 +- autotests/integration/screen_changes_test.cpp | 5 +- .../screenedge_client_show_test.cpp | 16 +- autotests/integration/screenedges_test.cpp | 2 +- autotests/integration/screens_test.cpp | 1 + .../scripting/minimizeall_test.cpp | 3 +- .../integration/scripting/screenedge_test.cpp | 42 +- autotests/integration/shade_test.cpp | 7 +- .../integration/showing_desktop_test.cpp | 3 +- autotests/integration/stacking_order_test.cpp | 107 +- autotests/integration/struts_test.cpp | 307 +++--- autotests/integration/tabbox_test.cpp | 5 +- autotests/integration/test_helpers.cpp | 32 +- .../integration/test_virtualkeyboard_dbus.cpp | 7 +- autotests/integration/touch_input_test.cpp | 16 +- autotests/integration/transient_placement.cpp | 105 +- .../integration/virtual_desktop_test.cpp | 39 +- autotests/integration/window_rules_test.cpp | 17 +- .../integration/window_selection_test.cpp | 19 +- autotests/integration/x11_client_test.cpp | 19 +- .../integration/xdgshellclient_rules_test.cpp | 5 +- autotests/integration/xdgshellclient_test.cpp | 89 +- autotests/integration/xwayland_input_test.cpp | 35 +- .../integration/xwayland_selections_test.cpp | 22 +- .../integration/xwaylandserver_crash_test.cpp | 3 +- .../xwaylandserver_restart_test.cpp | 1 + autotests/libinput/device_test.cpp | 102 +- autotests/libinput/gesture_event_test.cpp | 18 +- autotests/libinput/input_event_test.cpp | 3 +- autotests/libinput/key_event_test.cpp | 8 +- autotests/libinput/mock_libinput.cpp | 76 +- autotests/libinput/mock_libinput.h | 31 +- autotests/libinput/pointer_event_test.cpp | 38 +- autotests/libinput/switch_event_test.cpp | 2 +- autotests/libinput/touch_event_test.cpp | 10 +- autotests/libkwineffects/mock_gl.cpp | 12 +- autotests/libkwineffects/mock_gl.h | 6 +- autotests/libkwineffects/timelinetest.cpp | 28 +- .../libkwineffects/windowquadlisttest.cpp | 78 +- .../libxrenderutils/blendpicture_test.cpp | 2 +- autotests/onscreennotificationtest.cpp | 4 +- .../opengl_context_attribute_builder_test.cpp | 396 ++++---- autotests/tabbox/mock_tabboxclient.cpp | 2 +- autotests/tabbox/mock_tabboxclient.h | 33 +- autotests/tabbox/mock_tabboxhandler.cpp | 36 +- autotests/tabbox/mock_tabboxhandler.h | 65 +- autotests/tabbox/test_tabbox_clientmodel.cpp | 8 +- autotests/tabbox/test_tabbox_handler.cpp | 6 +- autotests/test_client_machine.cpp | 32 +- autotests/test_gestures.cpp | 33 +- autotests/test_virtual_desktops.cpp | 145 +-- autotests/test_window_paint_data.cpp | 227 +++-- autotests/test_x11_timestamp_update.cpp | 3 +- autotests/test_xcb_size_hints.cpp | 56 +- autotests/test_xcb_window.cpp | 2 +- autotests/test_xcb_wrapper.cpp | 80 +- autotests/test_xkb.cpp | 852 ++++++++-------- autotests/testutils.h | 15 +- data/update_default_rules.cpp | 57 +- src/abstract_client.cpp | 526 +++++----- src/abstract_client.h | 212 ++-- src/abstract_output.cpp | 4 +- src/abstract_output.h | 5 +- src/abstract_wayland_output.cpp | 6 +- src/abstract_wayland_output.h | 19 +- src/activation.cpp | 127 +-- src/activities.cpp | 53 +- src/activities.h | 20 +- src/appmenu.cpp | 30 +- src/atoms.h | 3 +- src/backends/drm/drm_abstract_output.cpp | 2 +- src/backends/drm/drm_backend.cpp | 213 ++-- src/backends/drm/drm_backend.h | 16 +- src/backends/drm/drm_buffer.cpp | 11 +- src/backends/drm/drm_buffer.h | 7 +- src/backends/drm/drm_buffer_gbm.cpp | 27 +- src/backends/drm/drm_buffer_gbm.h | 3 +- src/backends/drm/drm_gpu.cpp | 85 +- src/backends/drm/drm_gpu.h | 39 +- src/backends/drm/drm_layer.h | 4 +- src/backends/drm/drm_lease_egl_gbm_layer.cpp | 4 +- src/backends/drm/drm_lease_output.cpp | 5 +- src/backends/drm/drm_lease_output.h | 2 +- src/backends/drm/drm_object.cpp | 4 +- src/backends/drm/drm_object.h | 17 +- src/backends/drm/drm_object_connector.cpp | 78 +- src/backends/drm/drm_object_connector.h | 10 +- src/backends/drm/drm_object_crtc.cpp | 12 +- src/backends/drm/drm_object_crtc.h | 3 +- src/backends/drm/drm_object_plane.cpp | 50 +- src/backends/drm/drm_object_plane.h | 17 +- src/backends/drm/drm_output.cpp | 19 +- src/backends/drm/drm_output.h | 8 +- src/backends/drm/drm_pipeline.cpp | 37 +- src/backends/drm/drm_pipeline.h | 22 +- src/backends/drm/drm_pipeline_legacy.cpp | 17 +- src/backends/drm/drm_pointer.h | 33 +- src/backends/drm/drm_property.cpp | 8 +- src/backends/drm/drm_property.h | 21 +- src/backends/drm/drm_qpainter_layer.cpp | 12 +- src/backends/drm/drm_render_backend.h | 1 - src/backends/drm/drm_virtual_output.cpp | 8 +- src/backends/drm/dumb_swapchain.cpp | 7 +- src/backends/drm/dumb_swapchain.h | 6 +- src/backends/drm/edid.cpp | 7 +- src/backends/drm/egl_gbm_backend.cpp | 70 +- src/backends/drm/egl_gbm_backend.h | 3 +- src/backends/drm/egl_gbm_layer.cpp | 20 +- src/backends/drm/egl_gbm_layer.h | 9 +- src/backends/drm/gbm_dmabuf.cpp | 7 +- src/backends/drm/gbm_dmabuf.h | 2 +- src/backends/drm/gbm_surface.cpp | 12 +- src/backends/drm/gbm_surface.h | 4 +- .../drm/scene_qpainter_drm_backend.cpp | 18 +- src/backends/drm/scene_qpainter_drm_backend.h | 4 +- src/backends/drm/shadowbuffer.cpp | 33 +- src/backends/drm/shadowbuffer.h | 2 +- src/backends/drm/virtual_egl_gbm_layer.cpp | 22 +- src/backends/drm/virtual_egl_gbm_layer.h | 6 +- src/backends/fakeinput/fakeinputbackend.cpp | 16 +- src/backends/fakeinput/fakeinputdevice.cpp | 154 ++- src/backends/libinput/connection.cpp | 484 ++++----- src/backends/libinput/connection.h | 11 +- src/backends/libinput/context.cpp | 10 +- src/backends/libinput/context.h | 12 +- src/backends/libinput/device.cpp | 172 ++-- src/backends/libinput/device.h | 312 +++--- src/backends/libinput/events.cpp | 7 +- src/backends/libinput/events.h | 138 ++- src/backends/libinput/libinputbackend.cpp | 8 +- src/backends/virtual/egl_gbm_backend.cpp | 30 +- .../virtual/scene_qpainter_virtual_backend.h | 2 +- src/backends/virtual/virtual_backend.cpp | 10 +- src/backends/virtual/virtual_backend.h | 12 +- src/backends/virtual/virtual_output.cpp | 2 +- src/backends/virtual/virtual_output.h | 6 +- src/backends/wayland/egl_wayland_backend.cpp | 55 +- src/backends/wayland/egl_wayland_backend.h | 5 +- .../scene_qpainter_wayland_backend.cpp | 26 +- .../wayland/scene_qpainter_wayland_backend.h | 4 +- src/backends/wayland/wayland_backend.cpp | 145 ++- src/backends/wayland/wayland_backend.h | 77 +- src/backends/wayland/wayland_output.cpp | 30 +- src/backends/wayland/wayland_output.h | 20 +- src/backends/x11/common/eglonxbackend.cpp | 34 +- src/backends/x11/common/eglonxbackend.h | 11 +- src/backends/x11/common/ge_event_mem_mover.h | 7 +- src/backends/x11/standalone/edge.cpp | 8 +- .../effects_mouse_interception_x11_filter.cpp | 4 +- src/backends/x11/standalone/effects_x11.cpp | 5 +- src/backends/x11/standalone/eglbackend.cpp | 5 +- src/backends/x11/standalone/glxbackend.cpp | 212 ++-- src/backends/x11/standalone/glxbackend.h | 14 +- .../x11/standalone/glxconvenience.cpp | 3 +- .../x11/standalone/non_composited_outline.cpp | 25 +- .../x11/standalone/non_composited_outline.h | 7 +- .../standalone/omlsynccontrolvsyncmonitor.cpp | 3 +- .../standalone/omlsynccontrolvsyncmonitor.h | 3 +- .../x11/standalone/overlaywindow_x11.cpp | 23 +- .../x11/standalone/overlaywindow_x11.h | 11 +- .../x11/standalone/screenedges_filter.cpp | 6 +- .../standalone/sgivideosyncvsyncmonitor.cpp | 3 +- .../x11/standalone/sgivideosyncvsyncmonitor.h | 3 +- .../x11/standalone/windowselector.cpp | 54 +- src/backends/x11/standalone/windowselector.h | 10 +- src/backends/x11/standalone/x11_output.cpp | 2 +- src/backends/x11/standalone/x11_platform.cpp | 44 +- src/backends/x11/standalone/x11_platform.h | 6 +- src/backends/x11/standalone/x11cursor.cpp | 17 +- src/backends/x11/standalone/x11cursor.h | 5 +- .../standalone/xfixes_cursor_event_filter.cpp | 2 +- .../x11/standalone/xinputintegration.cpp | 125 +-- .../x11/standalone/xinputintegration.h | 6 +- .../x11/windowed/scene_qpainter_x11_backend.h | 9 +- .../x11/windowed/x11windowed_backend.cpp | 143 ++- .../x11/windowed/x11windowed_backend.h | 22 +- .../x11/windowed/x11windowed_output.cpp | 32 +- .../x11/windowed/x11windowed_output.h | 6 +- src/client_machine.cpp | 18 +- src/client_machine.h | 17 +- src/colordevice.cpp | 26 +- src/composite.cpp | 64 +- src/composite.h | 21 +- src/cursor.cpp | 412 +++++--- src/cursor.h | 78 +- src/dbusinterface.cpp | 224 ++--- src/dbusinterface.h | 22 +- src/debug_console.cpp | 384 ++++---- src/debug_console.h | 40 +- src/decorationitem.cpp | 2 +- src/decorationitem.h | 6 +- src/decorations/decoratedclient.cpp | 112 +-- src/decorations/decoratedclient.h | 6 +- src/decorations/decorationbridge.cpp | 19 +- src/decorations/decorationbridge.h | 9 +- src/decorations/decorationpalette.cpp | 130 +-- src/decorations/decorationpalette.h | 15 +- src/decorations/settings.cpp | 92 +- src/decorations/settings.h | 20 +- src/deleted.cpp | 28 +- src/deleted.h | 51 +- src/dmabuftexture.h | 4 +- src/dpmsinputeventfilter.cpp | 4 +- src/dpmsinputeventfilter.h | 2 - src/effectloader.cpp | 60 +- src/effectloader.h | 22 +- src/effects.cpp | 655 ++++++------- src/effects.h | 248 ++--- src/effects/backgroundcontrast/contrast.cpp | 78 +- src/effects/backgroundcontrast/contrast.h | 14 +- .../backgroundcontrast/contrastshader.cpp | 17 +- .../backgroundcontrast/contrastshader.h | 8 +- src/effects/backgroundcontrast/main.cpp | 3 +- src/effects/blur/blur.cpp | 93 +- src/effects/blur/blur.h | 30 +- src/effects/blur/blur_config.cpp | 9 +- src/effects/blur/blur_config.h | 5 +- src/effects/blur/blurshader.cpp | 24 +- src/effects/blur/blurshader.h | 2 +- src/effects/blur/main.cpp | 3 +- src/effects/colorpicker/colorpicker.cpp | 13 +- src/effects/colorpicker/colorpicker.h | 7 +- src/effects/desktopgrid/desktopgrid.cpp | 288 +++--- src/effects/desktopgrid/desktopgrid.h | 58 +- .../desktopgrid/desktopgrid_config.cpp | 19 +- src/effects/desktopgrid/desktopgrid_config.h | 10 +- src/effects/diminactive/diminactive.cpp | 3 +- src/effects/diminactive/diminactive.h | 7 +- .../diminactive/diminactive_config.cpp | 4 +- src/effects/fallapart/fallapart.cpp | 46 +- src/effects/fallapart/fallapart.h | 14 +- src/effects/glide/glide.cpp | 14 +- src/effects/glide/glide.h | 12 +- src/effects/glide/glide_config.cpp | 9 +- src/effects/glide/glide_config.h | 3 +- .../highlightwindow/highlightwindow.cpp | 49 +- src/effects/highlightwindow/highlightwindow.h | 7 +- src/effects/invert/invert.cpp | 27 +- src/effects/invert/invert.h | 8 +- src/effects/invert/invert_config.cpp | 17 +- src/effects/invert/invert_config.h | 4 +- src/effects/kscreen/kscreen.cpp | 44 +- src/effects/kscreen/kscreen.h | 7 +- src/effects/lookingglass/lookingglass.cpp | 17 +- src/effects/lookingglass/lookingglass.h | 11 +- .../lookingglass/lookingglass_config.cpp | 28 +- .../lookingglass/lookingglass_config.h | 8 +- src/effects/magiclamp/magiclamp.cpp | 91 +- src/effects/magiclamp/magiclamp.h | 7 +- src/effects/magiclamp/magiclamp_config.cpp | 15 +- src/effects/magiclamp/magiclamp_config.h | 7 +- src/effects/magnifier/magnifier.cpp | 21 +- src/effects/magnifier/magnifier.h | 17 +- src/effects/magnifier/magnifier_config.cpp | 26 +- src/effects/magnifier/magnifier_config.h | 8 +- src/effects/mouseclick/mouseclick.cpp | 120 +-- src/effects/mouseclick/mouseclick.h | 95 +- src/effects/mouseclick/mouseclick_config.cpp | 18 +- src/effects/mouseclick/mouseclick_config.h | 8 +- src/effects/mousemark/mousemark.cpp | 32 +- src/effects/mousemark/mousemark.h | 19 +- src/effects/mousemark/mousemark_config.cpp | 21 +- src/effects/mousemark/mousemark_config.h | 8 +- src/effects/overview/expolayout.cpp | 18 +- .../overview/kcm/overvieweffectkcm.cpp | 5 +- src/effects/overview/overvieweffect.cpp | 10 +- src/effects/presentwindows/presentwindows.cpp | 315 +++--- src/effects/presentwindows/presentwindows.h | 105 +- .../presentwindows/presentwindows_config.cpp | 24 +- .../presentwindows/presentwindows_config.h | 8 +- .../presentwindows/presentwindows_proxy.cpp | 4 +- .../presentwindows/presentwindows_proxy.h | 6 +- src/effects/screenedge/screenedgeeffect.cpp | 71 +- src/effects/screenedge/screenedgeeffect.h | 18 +- src/effects/screenshot/screenshot.cpp | 5 +- .../screenshot/screenshotdbusinterface1.cpp | 17 +- .../screenshot/screenshotdbusinterface1.h | 5 +- .../screenshot/screenshotdbusinterface2.cpp | 3 +- .../screentransform/screentransform.cpp | 3 +- src/effects/screentransform/screentransform.h | 3 +- src/effects/sheet/sheet.cpp | 20 +- src/effects/sheet/sheet.h | 5 +- src/effects/showfps/showfps.cpp | 65 +- src/effects/showfps/showfps.h | 37 +- src/effects/showfps/showfps_config.cpp | 8 +- src/effects/showfps/showfps_config.h | 2 +- src/effects/showpaint/showpaint.cpp | 5 +- src/effects/slide/slide.cpp | 16 +- src/effects/slide/slide.h | 9 +- src/effects/slide/slide_config.cpp | 5 +- src/effects/slide/slide_config.h | 3 +- src/effects/slideback/slideback.cpp | 40 +- src/effects/slideback/slideback.h | 11 +- src/effects/slidingpopups/slidingpopups.cpp | 30 +- src/effects/slidingpopups/slidingpopups.h | 11 +- src/effects/snaphelper/snaphelper.cpp | 13 +- src/effects/snaphelper/snaphelper.h | 3 +- .../startupfeedback/startupfeedback.cpp | 63 +- src/effects/startupfeedback/startupfeedback.h | 27 +- src/effects/thumbnailaside/thumbnailaside.cpp | 59 +- src/effects/thumbnailaside/thumbnailaside.h | 28 +- .../thumbnailaside/thumbnailaside_config.cpp | 22 +- .../thumbnailaside/thumbnailaside_config.h | 8 +- src/effects/touchpoints/touchpoints.cpp | 30 +- src/effects/touchpoints/touchpoints.h | 34 +- src/effects/trackmouse/trackmouse.cpp | 37 +- src/effects/trackmouse/trackmouse.h | 21 +- src/effects/trackmouse/trackmouse_config.cpp | 35 +- src/effects/trackmouse/trackmouse_config.h | 9 +- src/effects/wobblywindows/wobblywindows.cpp | 390 ++++---- src/effects/wobblywindows/wobblywindows.h | 85 +- .../wobblywindows/wobblywindows_config.cpp | 31 +- .../wobblywindows/wobblywindows_config.h | 3 +- src/effects/zoom/zoom.cpp | 81 +- src/effects/zoom/zoom.h | 37 +- src/effects/zoom/zoom_config.cpp | 18 +- src/effects/zoom/zoom_config.h | 7 +- src/events.cpp | 273 +++--- src/focuschain.cpp | 31 +- src/focuschain.h | 16 +- src/ftrace.h | 12 +- src/gestures.cpp | 13 +- src/gestures.h | 11 +- src/globalshortcuts.cpp | 11 +- src/group.cpp | 28 +- src/group.h | 10 +- src/helpers/killer/killer.cpp | 16 +- src/helpers/wayland_wrapper/kwin_wrapper.cpp | 9 +- src/helpers/wayland_wrapper/wl-socket.h | 1 - src/hide_cursor_spy.cpp | 4 +- src/idle_inhibition.cpp | 20 +- src/idle_inhibition.h | 8 +- src/input.cpp | 490 ++++++---- src/input.h | 65 +- src/input_event.cpp | 36 +- src/input_event.h | 66 +- src/input_event_spy.h | 1 - src/inputbackend.h | 4 +- src/inputdevice.h | 2 +- src/inputmethod.cpp | 37 +- src/inputmethod.h | 19 +- src/inputpanelv1client.cpp | 112 +-- src/inputpanelv1client.h | 53 +- src/internal_client.cpp | 13 +- src/item.h | 2 +- src/kcmkwin/common/effectsmodel.cpp | 137 ++- src/kcmkwin/common/effectsmodel.h | 3 +- src/kcmkwin/kwincompositing/main.cpp | 73 +- .../declarative-plugin/buttonsmodel.cpp | 89 +- .../declarative-plugin/buttonsmodel.h | 16 +- .../declarative-plugin/plugin.cpp | 4 +- .../declarative-plugin/previewbridge.cpp | 19 +- .../declarative-plugin/previewbridge.h | 29 +- .../declarative-plugin/previewbutton.cpp | 4 +- .../declarative-plugin/previewbutton.h | 10 +- .../declarative-plugin/previewclient.cpp | 102 +- .../declarative-plugin/previewclient.h | 8 +- .../declarative-plugin/previewitem.cpp | 42 +- .../declarative-plugin/previewitem.h | 2 +- .../declarative-plugin/previewsettings.cpp | 61 +- .../declarative-plugin/previewsettings.h | 50 +- .../kwindecoration/decorationmodel.cpp | 14 +- src/kcmkwin/kwindecoration/decorationmodel.h | 5 +- src/kcmkwin/kwindecoration/kcm.cpp | 19 +- src/kcmkwin/kwindecoration/kcm.h | 1 - .../kwin-applywindowdecoration.cpp | 21 +- src/kcmkwin/kwindecoration/utils.cpp | 66 +- src/kcmkwin/kwindecoration/utils.h | 1 - src/kcmkwin/kwindesktop/animationsmodel.cpp | 35 +- src/kcmkwin/kwindesktop/desktopsmodel.cpp | 79 +- src/kcmkwin/kwindesktop/desktopsmodel.h | 5 +- src/kcmkwin/kwindesktop/virtualdesktops.cpp | 38 +- src/kcmkwin/kwindesktop/virtualdesktops.h | 2 +- .../kwindesktop/virtualdesktopsdata.cpp | 2 +- .../kwineffects/effectsfilterproxymodel.cpp | 4 +- src/kcmkwin/kwineffects/kcm.cpp | 5 +- src/kcmkwin/kwinoptions/main.cpp | 20 +- src/kcmkwin/kwinoptions/main.h | 9 +- src/kcmkwin/kwinoptions/mouse.cpp | 6 +- src/kcmkwin/kwinoptions/mouse.h | 9 +- src/kcmkwin/kwinoptions/windows.cpp | 42 +- src/kcmkwin/kwinoptions/windows.h | 13 +- src/kcmkwin/kwinrules/kcmrules.cpp | 15 +- src/kcmkwin/kwinrules/kcmrules.h | 3 +- src/kcmkwin/kwinrules/kwinsrc.cpp | 2 +- src/kcmkwin/kwinrules/main.cpp | 2 +- src/kcmkwin/kwinrules/optionsmodel.cpp | 105 +- src/kcmkwin/kwinrules/optionsmodel.h | 30 +- src/kcmkwin/kwinrules/rulebookmodel.cpp | 3 +- src/kcmkwin/kwinrules/rulebookmodel.h | 1 - src/kcmkwin/kwinrules/ruleitem.cpp | 60 +- src/kcmkwin/kwinrules/ruleitem.h | 28 +- src/kcmkwin/kwinrules/rulesmodel.cpp | 255 +++-- src/kcmkwin/kwinrules/rulesmodel.h | 5 +- .../kwinscreenedges/kwinscreenedge.cpp | 10 +- src/kcmkwin/kwinscreenedges/main.cpp | 12 +- src/kcmkwin/kwinscreenedges/main.h | 4 +- src/kcmkwin/kwinscreenedges/monitor.cpp | 139 ++- src/kcmkwin/kwinscreenedges/monitor.h | 42 +- .../kwinscreenedges/screenpreviewwidget.cpp | 31 +- .../kwinscreenedges/screenpreviewwidget.h | 3 +- src/kcmkwin/kwinscreenedges/touch.cpp | 20 +- src/kcmkwin/kwinscreenedges/touch.h | 4 +- src/kcmkwin/kwinscripts/kwinscriptsdata.cpp | 2 +- src/kcmkwin/kwinscripts/main.cpp | 5 +- src/kcmkwin/kwinscripts/module.cpp | 27 +- .../kwintabbox/kwintabboxconfigform.cpp | 1 - src/kcmkwin/kwintabbox/kwintabboxconfigform.h | 9 +- src/kcmkwin/kwintabbox/kwintabboxdata.cpp | 4 +- src/kcmkwin/kwintabbox/layoutpreview.cpp | 70 +- src/kcmkwin/kwintabbox/layoutpreview.h | 8 +- src/kcmkwin/kwintabbox/main.cpp | 49 +- src/kcmkwin/kwintabbox/main.h | 5 +- src/kcmkwin/kwintabbox/thumbnailitem.cpp | 64 +- src/kcmkwin/kwintabbox/thumbnailitem.h | 22 +- .../kwinvirtualkeyboard/kcmvirtualkeyboard.h | 4 +- src/keyboard_input.cpp | 34 +- src/keyboard_input.h | 11 +- src/keyboard_layout.cpp | 14 +- src/keyboard_layout.h | 16 +- src/keyboard_layout_switching.cpp | 191 ++-- src/keyboard_layout_switching.h | 29 +- src/keyboard_repeat.cpp | 2 +- src/keyboard_repeat.h | 1 - src/killwindow.cpp | 12 +- src/killwindow.h | 1 - src/kwineglutils_p.h | 49 +- src/layers.cpp | 141 ++- src/layershellv1client.cpp | 22 +- src/libkwineffects/anidata.cpp | 76 +- src/libkwineffects/anidata_p.h | 12 +- src/libkwineffects/kwinanimationeffect.cpp | 457 +++++---- src/libkwineffects/kwinanimationeffect.h | 242 +++-- src/libkwineffects/kwindeformeffect.cpp | 10 +- src/libkwineffects/kwindeformeffect.h | 2 +- src/libkwineffects/kwineffects.cpp | 193 ++-- src/libkwineffects/kwineffects.h | 521 +++++----- src/libkwineffects/kwineglimagetexture.h | 3 +- src/libkwineffects/kwinglobals.h | 116 +-- src/libkwineffects/kwinglplatform.cpp | 413 ++++---- src/libkwineffects/kwinglplatform.h | 26 +- src/libkwineffects/kwingltexture.cpp | 146 ++- src/libkwineffects/kwingltexture.h | 22 +- src/libkwineffects/kwingltexture_p.h | 7 +- src/libkwineffects/kwinglutils.cpp | 654 +++++++------ src/libkwineffects/kwinglutils.h | 116 ++- src/libkwineffects/kwinglutils_funcs.cpp | 27 +- src/libkwineffects/kwinglutils_funcs.h | 6 +- src/libkwineffects/kwinoffscreenquickview.cpp | 125 ++- src/libkwineffects/kwinoffscreenquickview.h | 2 +- src/libkwineffects/kwinquickeffect.cpp | 11 +- src/libkwineffects/kwinquickeffect.h | 2 +- src/libkwineffects/kwinxrenderutils.cpp | 22 +- src/libkwineffects/kwinxrenderutils.h | 20 +- src/libkwineffects/logging_p.h | 2 +- src/main.cpp | 119 ++- src/main.h | 74 +- src/main_wayland.cpp | 91 +- src/main_wayland.h | 29 +- src/main_x11.cpp | 73 +- src/modifier_only_shortcuts.cpp | 11 +- src/modifier_only_shortcuts.h | 3 +- src/moving_client_x11_filter.cpp | 10 +- src/moving_client_x11_filter.h | 1 - src/netinfo.cpp | 161 +-- src/netinfo.h | 4 +- src/onscreennotification.cpp | 39 +- src/onscreennotification.h | 3 +- src/options.cpp | 114 ++- src/options.h | 317 ++++-- src/osd.cpp | 4 +- src/outline.cpp | 11 +- src/outline.h | 31 +- src/overlaywindow.cpp | 3 +- src/overlaywindow.h | 11 +- src/placement.cpp | 221 +++-- src/placement.h | 27 +- src/platform.cpp | 48 +- src/platform.h | 76 +- .../scenes/opengl/abstract_egl_backend.cpp | 13 +- .../scenes/opengl/abstract_egl_backend.h | 23 +- .../opengl/basiceglsurfacetexture_wayland.cpp | 3 +- .../scenes/opengl/egl_dmabuf.cpp | 203 ++-- .../scenes/opengl/egl_dmabuf.h | 10 +- .../scenes/opengl/kwineglext.h | 78 +- .../scenes/opengl/openglbackend.cpp | 2 +- .../scenes/opengl/openglbackend.h | 24 +- .../scenes/qpainter/qpainterbackend.h | 3 +- .../vsyncconvenience/softwarevsyncmonitor.cpp | 2 +- .../colord-integration/colorddevice.cpp | 2 +- .../colord-integration/colordintegration.cpp | 5 +- src/plugins/colord-integration/main.cpp | 2 +- src/plugins/idletime/poller.cpp | 9 +- .../kdecorations/aurorae/src/aurorae.cpp | 86 +- .../kdecorations/aurorae/src/aurorae.h | 4 +- .../kdecorations/aurorae/src/colorhelper.cpp | 1 - .../kdecorations/aurorae/src/colorhelper.h | 8 +- .../aurorae/src/decorationoptions.cpp | 42 +- .../aurorae/src/decorationoptions.h | 77 +- .../aurorae/src/decorationplugin.cpp | 1 - .../aurorae/src/lib/auroraetheme.cpp | 92 +- .../aurorae/src/lib/auroraetheme.h | 7 +- .../aurorae/src/lib/themeconfig.cpp | 14 +- .../aurorae/src/lib/themeconfig.h | 298 ++++-- .../themes/plastik/code/plastikbutton.cpp | 539 +++++----- .../kglobalaccel/kglobalaccel_plugin.cpp | 4 +- src/plugins/kpackage/aurorae/aurorae.cpp | 23 +- src/plugins/kpackage/aurorae/aurorae.h | 4 +- .../kpackage/decoration/decoration.cpp | 1 - src/plugins/kpackage/decoration/decoration.h | 4 +- src/plugins/kpackage/scripts/scripts.cpp | 1 - src/plugins/kpackage/scripts/scripts.h | 4 +- .../windowswitcher/windowswitcher.cpp | 1 - .../kpackage/windowswitcher/windowswitcher.h | 4 +- src/plugins/krunner-integration/dbusutils_p.h | 25 +- src/plugins/krunner-integration/main.cpp | 2 +- .../windowsrunnerinterface.cpp | 46 +- .../windowsrunnerinterface.h | 10 +- .../clockskewnotifierengine_linux.cpp | 2 +- src/plugins/nightcolor/constants.h | 2 +- .../nightcolor/nightcolordbusinterface.cpp | 29 +- src/plugins/nightcolor/nightcolormanager.cpp | 35 +- src/plugins/nightcolor/nightcolormanager.h | 10 +- src/plugins/nightcolor/suncalc.cpp | 31 +- src/plugins/nightcolor/suncalc.h | 2 +- src/plugins/qpa/eglhelpers.cpp | 10 +- src/plugins/qpa/integration.h | 4 +- src/plugins/qpa/offscreensurface.cpp | 3 +- src/plugins/screencast/eglnativefence.cpp | 4 +- src/plugins/screencast/main.cpp | 2 +- src/plugins/screencast/pipewirecore.cpp | 15 +- .../screencast/regionscreencastsource.cpp | 2 +- .../screencast/regionscreencastsource.h | 3 +- src/plugins/screencast/screencastmanager.cpp | 22 +- src/plugins/screencast/screencastmanager.h | 6 +- src/plugins/screencast/screencaststream.cpp | 122 ++- src/plugins/screencast/screencaststream.h | 11 +- src/plugins/screencast/screencastutils.h | 2 +- src/plugins/windowsystem/windoweffects.cpp | 13 +- src/plugins/windowsystem/windoweffects.h | 2 +- src/plugins/windowsystem/windowsystem.cpp | 10 +- src/pointer_input.cpp | 243 +++-- src/pointer_input.h | 24 +- src/popup_input_filter.cpp | 8 +- src/popup_input_filter.h | 3 +- src/renderloop.cpp | 8 +- src/renderloop_p.h | 2 +- src/rules.cpp | 464 +++++---- src/rules.h | 195 ++-- src/scene.cpp | 62 +- src/scene.h | 83 +- src/scenes/opengl/lanczosfilter.cpp | 57 +- src/scenes/opengl/lanczosfilter.h | 9 +- src/scenes/opengl/scene_opengl.cpp | 69 +- src/scenes/opengl/scene_opengl.h | 31 +- src/scenes/qpainter/scene_qpainter.cpp | 17 +- src/scenes/qpainter/scene_qpainter.h | 40 +- src/screenedge.cpp | 203 ++-- src/screenedge.h | 44 +- src/screenlockerwatcher.cpp | 2 +- src/screenlockerwatcher.h | 4 +- src/screens.cpp | 12 +- src/screens.h | 14 +- src/scripting/dbuscall.cpp | 3 +- src/scripting/dbuscall.h | 30 +- src/scripting/genericscriptedconfig.cpp | 28 +- src/scripting/genericscriptedconfig.h | 8 +- src/scripting/screenedgeitem.cpp | 4 +- src/scripting/screenedgeitem.h | 4 +- src/scripting/scriptedeffect.cpp | 50 +- src/scripting/scriptedeffect.h | 11 +- src/scripting/scripting.cpp | 65 +- src/scripting/scripting.h | 47 +- src/scripting/scriptingutils.cpp | 9 +- src/scripting/thumbnailitem.cpp | 6 +- src/scripting/thumbnailitem.h | 15 +- src/scripting/v2/clientmodel.cpp | 88 +- src/scripting/v2/clientmodel.h | 74 +- src/scripting/v3/clientmodel.cpp | 10 +- src/scripting/workspace_wrapper.cpp | 82 +- src/scripting/workspace_wrapper.h | 42 +- src/session.cpp | 9 +- src/session_consolekit.cpp | 22 +- src/session_logind.cpp | 24 +- src/shadow.cpp | 28 +- src/shadow.h | 18 +- src/shadowitem.cpp | 56 +- src/sm.cpp | 72 +- src/sm.h | 14 +- src/surfaceitem_x11.cpp | 2 +- src/syncalarmx11filter.cpp | 2 +- src/tabbox/clientmodel.cpp | 38 +- src/tabbox/clientmodel.h | 16 +- src/tabbox/desktopchain.cpp | 6 +- src/tabbox/desktopchain.h | 2 +- src/tabbox/desktopmodel.cpp | 36 +- src/tabbox/desktopmodel.h | 19 +- src/tabbox/switcheritem.cpp | 2 +- src/tabbox/switcheritem.h | 3 +- src/tabbox/tabbox.cpp | 288 +++--- src/tabbox/tabbox.h | 100 +- src/tabbox/tabboxconfig.cpp | 12 +- src/tabbox/tabboxconfig.h | 47 +- src/tabbox/tabboxhandler.cpp | 116 ++- src/tabbox/tabboxhandler.h | 34 +- src/tabbox/x11_filter.cpp | 25 +- src/tabbox/x11_filter.h | 2 - src/tablet_input.cpp | 56 +- src/tabletmodemanager.cpp | 12 +- src/tabletmodemanager.h | 5 +- src/toplevel.cpp | 6 +- src/toplevel.h | 68 +- src/touch_input.cpp | 52 +- src/touch_input.h | 20 +- src/udev.cpp | 9 +- src/udev.h | 23 +- src/unmanaged.cpp | 43 +- src/unmanaged.h | 5 +- src/useractions.cpp | 376 ++++--- src/useractions.h | 38 +- ...bstract_opengl_context_attribute_builder.h | 51 +- src/utils/common.cpp | 2 +- src/utils/common.h | 52 +- src/utils/serviceutils.h | 9 +- src/utils/subsurfacemonitor.cpp | 4 +- src/utils/xcbutils.cpp | 62 +- src/utils/xcbutils.h | 626 +++++++----- src/virtualdesktops.cpp | 159 ++- src/virtualdesktops.h | 119 ++- src/virtualdesktopsdbustypes.cpp | 1 - src/virtualdesktopsdbustypes.h | 3 +- src/virtualkeyboard_dbus.cpp | 5 +- src/virtualkeyboard_dbus.h | 2 +- src/wayland_server.cpp | 325 +++---- src/wayland_server.h | 38 +- src/waylandclient.cpp | 18 +- src/waylandoutput.h | 2 +- src/waylandoutputconfig.h | 2 +- src/window_property_notify_x11_filter.cpp | 4 +- src/workspace.cpp | 545 +++++------ src/workspace.h | 246 ++--- src/x11client.cpp | 920 ++++++++---------- src/x11client.h | 89 +- src/x11eventfilter.cpp | 7 +- src/x11eventfilter.h | 15 +- src/x11syncmanager.cpp | 2 +- src/x11syncmanager.h | 19 +- src/xdgactivationv1.cpp | 4 +- src/xdgactivationv1.h | 3 +- src/xdgshellclient.cpp | 43 +- src/xdgshellclient.h | 4 +- src/xdgshellintegration.cpp | 8 +- src/xkb.cpp | 44 +- src/xkb.h | 26 +- src/xwaylandclient.cpp | 2 +- src/xwl/clipboard.cpp | 7 +- src/xwl/databridge.cpp | 2 +- src/xwl/datasource.h | 12 +- src/xwl/dnd.cpp | 15 +- src/xwl/dnd.h | 2 +- src/xwl/drag.cpp | 12 +- src/xwl/drag.h | 2 +- src/xwl/drag_wl.cpp | 24 +- src/xwl/drag_wl.h | 15 +- src/xwl/drag_x.cpp | 41 +- src/xwl/drag_x.h | 24 +- src/xwl/lib/xauthority.cpp | 4 +- src/xwl/primary.cpp | 7 +- src/xwl/primary.h | 2 +- src/xwl/selection.cpp | 21 +- src/xwl/selection.h | 18 +- src/xwl/selection_source.cpp | 22 +- src/xwl/selection_source.h | 23 +- src/xwl/transfer.cpp | 49 +- src/xwl/transfer.h | 28 +- src/xwl/xwayland.cpp | 16 +- src/xwl/xwaylandlauncher.cpp | 20 +- src/xwl/xwaylandlauncher.h | 4 +- src/xwl/xwldrophandler.cpp | 10 +- src/xwl/xwldrophandler.h | 9 +- tests/cursorhotspottest.cpp | 25 +- tests/normalhintsbasesizetest.cpp | 7 +- tests/pointerconstraintstest.cpp | 103 +- tests/pointerconstraintstest.h | 54 +- tests/pointergesturestest.cpp | 96 +- tests/screenedgeshowtest.cpp | 37 +- tests/x11shadowreader.cpp | 12 +- 744 files changed, 17960 insertions(+), 16741 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000..18d3a686e3 --- /dev/null +++ b/.clang-format @@ -0,0 +1,83 @@ +--- +--- +# SPDX-FileCopyrightText: 2019 Christoph Cullmann +# SPDX-FileCopyrightText: 2019 Gernot Gebhard +# +# SPDX-License-Identifier: MIT + +--- +Language: JavaScript +DisableFormat: true +--- + +# Style for C++ +Language: Cpp +Standard: c++17 + +# base is WebKit coding style: https://webkit.org/code-style-guidelines/ +# below are only things set that diverge from this style! +BasedOnStyle: WebKit + +# 4 spaces indent +TabWidth: 4 + +# No line limit +ColumnLimit: 0 + +# sort includes inside line separated groups +SortIncludes: true + +# Braces are usually attached, but not after functions or class declarations. +BreakBeforeBraces: Custom +BraceWrapping: + AfterClass: true + AfterControlStatement: false + AfterEnum: false + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: false + AfterStruct: true + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + +# CrlInstruction *a; +PointerAlignment: Right + +# horizontally aligns arguments after an open bracket. +AlignAfterOpenBracket: Align + +# don't move all parameters to new line +AllowAllParametersOfDeclarationOnNextLine: false + +# no single line functions +AllowShortFunctionsOnASingleLine: None + +# In case we have an if statement with multiple lines the operator should be at the beginning of the line +# but we do not want to break assignments +BreakBeforeBinaryOperators: NonAssignment + +# format C++11 braced lists like function calls +Cpp11BracedListStyle: true + +# do not put a space before C++11 braced lists +SpaceBeforeCpp11BracedList: false + +# no namespace indentation to keep indent level low +NamespaceIndentation: None + +# we use template< without space. +SpaceAfterTemplateKeyword: false + +# Always break after template declaration +AlwaysBreakTemplateDeclarations: true + +# macros for which the opening brace stays attached. +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE , wl_resource_for_each, wl_resource_for_each_safe ] + +# keep lambda formatting multi-line if not empty +AllowShortLambdasOnASingleLine: Empty + +# We do not want clang-format to put all arguments on a new line +AllowAllArgumentsOnNextLine: false diff --git a/.gitignore b/.gitignore index 3b683fa07a..513215a9c8 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,6 @@ random_seed /build*/ CMakeLists.txt.user* *.unc-backup* -.clang-format /compile_commands.json .clangd .idea diff --git a/autotests/integration/activation_test.cpp b/autotests/integration/activation_test.cpp index 1424af536c..4ef1e3b0e7 100644 --- a/autotests/integration/activation_test.cpp +++ b/autotests/integration/activation_test.cpp @@ -529,23 +529,22 @@ void ActivationTest::stackScreensHorizontally() // Process pending wl_output bind requests before destroying all outputs. QTest::qWait(1); - const QVector screenGeometries { + const QVector screenGeometries{ QRect(0, 0, 1280, 1024), QRect(1280, 0, 1280, 1024), }; - const QVector screenScales { + const QVector screenScales{ 1, 1, }; QMetaObject::invokeMethod(kwinApp()->platform(), - "setVirtualOutputs", - Qt::DirectConnection, - Q_ARG(int, screenGeometries.count()), - Q_ARG(QVector, screenGeometries), - Q_ARG(QVector, screenScales) - ); + "setVirtualOutputs", + Qt::DirectConnection, + Q_ARG(int, screenGeometries.count()), + Q_ARG(QVector, screenGeometries), + Q_ARG(QVector, screenScales)); } void ActivationTest::stackScreensVertically() @@ -553,23 +552,22 @@ void ActivationTest::stackScreensVertically() // Process pending wl_output bind requests before destroying all outputs. QTest::qWait(1); - const QVector screenGeometries { + const QVector screenGeometries{ QRect(0, 0, 1280, 1024), QRect(0, 1024, 1280, 1024), }; - const QVector screenScales { + const QVector screenScales{ 1, 1, }; QMetaObject::invokeMethod(kwinApp()->platform(), - "setVirtualOutputs", - Qt::DirectConnection, - Q_ARG(int, screenGeometries.count()), - Q_ARG(QVector, screenGeometries), - Q_ARG(QVector, screenScales) - ); + "setVirtualOutputs", + Qt::DirectConnection, + Q_ARG(int, screenGeometries.count()), + Q_ARG(QVector, screenGeometries), + Q_ARG(QVector, screenScales)); } } diff --git a/autotests/integration/activities_test.cpp b/autotests/integration/activities_test.cpp index 2d4bb04658..c09a73e40b 100644 --- a/autotests/integration/activities_test.cpp +++ b/autotests/integration/activities_test.cpp @@ -7,15 +7,16 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_output.h" -#include "platform.h" #include "activities.h" -#include "x11client.h" #include "cursor.h" #include "deleted.h" +#include "platform.h" +#include "utils/xcbutils.h" #include "wayland_server.h" #include "workspace.h" -#include "utils/xcbutils.h" +#include "x11client.h" #include #include @@ -45,8 +46,8 @@ private: void ActivitiesTest::initTestCase() { - qRegisterMetaType(); - qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -103,11 +104,11 @@ void ActivitiesTest::testSetOnActivitiesValidates() const QRect windowGeometry(0, 0, 100, 200); auto cookie = xcb_create_window_checked(c.data(), 0, w, rootWindow(), - windowGeometry.x(), - windowGeometry.y(), - windowGeometry.width(), - windowGeometry.height(), - 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, 0, 0, nullptr); + windowGeometry.x(), + windowGeometry.y(), + windowGeometry.width(), + windowGeometry.height(), + 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, 0, 0, nullptr); QVERIFY(!xcb_request_check(c.data(), cookie)); xcb_size_hints_t hints; memset(&hints, 0, sizeof(hints)); @@ -126,7 +127,7 @@ void ActivitiesTest::testSetOnActivitiesValidates() QCOMPARE(client->window(), w); QVERIFY(client->isDecorated()); - //verify the test machine doesn't have the following activities used + // verify the test machine doesn't have the following activities used QVERIFY(!Activities::self()->all().contains(QStringLiteral("foo"))); QVERIFY(!Activities::self()->all().contains(QStringLiteral("bar"))); diff --git a/autotests/integration/buffer_size_change_test.cpp b/autotests/integration/buffer_size_change_test.cpp index a3af5934f9..678621a840 100644 --- a/autotests/integration/buffer_size_change_test.cpp +++ b/autotests/integration/buffer_size_change_test.cpp @@ -25,7 +25,10 @@ class BufferSizeChangeTest : public GenericSceneOpenGLTest { Q_OBJECT public: - BufferSizeChangeTest() : GenericSceneOpenGLTest(QByteArrayLiteral("O2")) {} + BufferSizeChangeTest() + : GenericSceneOpenGLTest(QByteArrayLiteral("O2")) + { + } private Q_SLOTS: void init(); void testShmBufferSizeChange(); diff --git a/autotests/integration/dbus_interface_test.cpp b/autotests/integration/dbus_interface_test.cpp index e44201a4d1..c4aa8b2bc2 100644 --- a/autotests/integration/dbus_interface_test.cpp +++ b/autotests/integration/dbus_interface_test.cpp @@ -9,15 +9,16 @@ #include "config-kwin.h" #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "atoms.h" -#include "x11client.h" #include "deleted.h" #include "platform.h" #include "rules.h" #include "virtualdesktops.h" #include "wayland_server.h" #include "workspace.h" +#include "x11client.h" #include @@ -54,8 +55,8 @@ private Q_SLOTS: void TestDbusInterface::initTestCase() { - qRegisterMetaType(); - qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); @@ -78,7 +79,8 @@ void TestDbusInterface::cleanup() Test::destroyWaylandConnection(); } -namespace { +namespace +{ QDBusPendingCall getWindowInfo(const QUuid &uuid) { auto msg = QDBusMessage::createMethodCall(s_destination, s_path, s_interface, QStringLiteral("getWindowInfo")); @@ -114,33 +116,33 @@ void TestDbusInterface::testGetWindowInfoXdgShellClient() auto client = clientAddedSpy.first().first().value(); QVERIFY(client); - const QVariantMap expectedData { - { QStringLiteral("type"), int(NET::Normal) }, - { QStringLiteral("x"), client->x() }, - { QStringLiteral("y"), client->y() }, - { QStringLiteral("width"), client->width() }, - { QStringLiteral("height"), client->height() }, - { QStringLiteral("desktops"), client->desktopIds() }, - { QStringLiteral("minimized"), false }, - { QStringLiteral("shaded"), false }, - { QStringLiteral("fullscreen"), false }, - { QStringLiteral("keepAbove"), false }, - { QStringLiteral("keepBelow"), false }, - { QStringLiteral("skipTaskbar"), false }, - { QStringLiteral("skipPager"), false }, - { QStringLiteral("skipSwitcher"), false }, - { QStringLiteral("maximizeHorizontal"), false }, - { QStringLiteral("maximizeVertical"), false }, - { QStringLiteral("noBorder"), false }, - { QStringLiteral("clientMachine"), QString() }, - { QStringLiteral("localhost"), true }, - { QStringLiteral("role"), QString() }, - { QStringLiteral("resourceName"), QStringLiteral("testDbusInterface") }, - { QStringLiteral("resourceClass"), QStringLiteral("org.kde.foo") }, - { QStringLiteral("desktopFile"), QStringLiteral("org.kde.foo") }, - { QStringLiteral("caption"), QStringLiteral("Test window") }, + const QVariantMap expectedData = { + {QStringLiteral("type"), int(NET::Normal)}, + {QStringLiteral("x"), client->x()}, + {QStringLiteral("y"), client->y()}, + {QStringLiteral("width"), client->width()}, + {QStringLiteral("height"), client->height()}, + {QStringLiteral("desktops"), client->desktopIds()}, + {QStringLiteral("minimized"), false}, + {QStringLiteral("shaded"), false}, + {QStringLiteral("fullscreen"), false}, + {QStringLiteral("keepAbove"), false}, + {QStringLiteral("keepBelow"), false}, + {QStringLiteral("skipTaskbar"), false}, + {QStringLiteral("skipPager"), false}, + {QStringLiteral("skipSwitcher"), false}, + {QStringLiteral("maximizeHorizontal"), false}, + {QStringLiteral("maximizeVertical"), false}, + {QStringLiteral("noBorder"), false}, + {QStringLiteral("clientMachine"), QString()}, + {QStringLiteral("localhost"), true}, + {QStringLiteral("role"), QString()}, + {QStringLiteral("resourceName"), QStringLiteral("testDbusInterface")}, + {QStringLiteral("resourceClass"), QStringLiteral("org.kde.foo")}, + {QStringLiteral("desktopFile"), QStringLiteral("org.kde.foo")}, + {QStringLiteral("caption"), QStringLiteral("Test window")}, #if KWIN_BUILD_ACTIVITIES - { QStringLiteral("activities"), QStringList() }, + {QStringLiteral("activities"), QStringList()}, #endif }; @@ -152,7 +154,7 @@ void TestDbusInterface::testGetWindowInfoXdgShellClient() auto windowData = reply.value(); QCOMPARE(windowData, expectedData); - auto verifyProperty = [client] (const QString &name) { + auto verifyProperty = [client](const QString &name) { QDBusPendingReply reply{getWindowInfo(client->internalId())}; reply.waitForFinished(); return reply.value().value(name).toBool(); @@ -219,7 +221,6 @@ void TestDbusInterface::testGetWindowInfoXdgShellClient() QVERIFY(reply.value().empty()); } - struct XcbConnectionDeleter { static inline void cleanup(xcb_connection_t *pointer) @@ -261,31 +262,31 @@ void TestDbusInterface::testGetWindowInfoX11Client() QCOMPARE(client->window(), w); QCOMPARE(client->clientSize(), windowGeometry.size()); - const QVariantMap expectedData { - { QStringLiteral("type"), NET::Normal }, - { QStringLiteral("x"), client->x() }, - { QStringLiteral("y"), client->y() }, - { QStringLiteral("width"), client->width() }, - { QStringLiteral("height"), client->height() }, - { QStringLiteral("desktops"), client->desktopIds() }, - { QStringLiteral("minimized"), false }, - { QStringLiteral("shaded"), false }, - { QStringLiteral("fullscreen"), false }, - { QStringLiteral("keepAbove"), false }, - { QStringLiteral("keepBelow"), false }, - { QStringLiteral("skipTaskbar"), false }, - { QStringLiteral("skipPager"), false }, - { QStringLiteral("skipSwitcher"), false }, - { QStringLiteral("maximizeHorizontal"), false }, - { QStringLiteral("maximizeVertical"), false }, - { QStringLiteral("noBorder"), false }, - { QStringLiteral("role"), QString() }, - { QStringLiteral("resourceName"), QStringLiteral("foo") }, - { QStringLiteral("resourceClass"), QStringLiteral("bar") }, - { QStringLiteral("desktopFile"), QStringLiteral("org.kde.foo") }, - { QStringLiteral("caption"), QStringLiteral("Some caption") }, + const QVariantMap expectedData = { + {QStringLiteral("type"), NET::Normal}, + {QStringLiteral("x"), client->x()}, + {QStringLiteral("y"), client->y()}, + {QStringLiteral("width"), client->width()}, + {QStringLiteral("height"), client->height()}, + {QStringLiteral("desktops"), client->desktopIds()}, + {QStringLiteral("minimized"), false}, + {QStringLiteral("shaded"), false}, + {QStringLiteral("fullscreen"), false}, + {QStringLiteral("keepAbove"), false}, + {QStringLiteral("keepBelow"), false}, + {QStringLiteral("skipTaskbar"), false}, + {QStringLiteral("skipPager"), false}, + {QStringLiteral("skipSwitcher"), false}, + {QStringLiteral("maximizeHorizontal"), false}, + {QStringLiteral("maximizeVertical"), false}, + {QStringLiteral("noBorder"), false}, + {QStringLiteral("role"), QString()}, + {QStringLiteral("resourceName"), QStringLiteral("foo")}, + {QStringLiteral("resourceClass"), QStringLiteral("bar")}, + {QStringLiteral("desktopFile"), QStringLiteral("org.kde.foo")}, + {QStringLiteral("caption"), QStringLiteral("Some caption")}, #if KWIN_BUILD_ACTIVITIES - { QStringLiteral("activities"), QStringList() }, + {QStringLiteral("activities"), QStringList()}, #endif }; @@ -300,7 +301,7 @@ void TestDbusInterface::testGetWindowInfoX11Client() windowData.remove(QStringLiteral("localhost")); QCOMPARE(windowData, expectedData); - auto verifyProperty = [client] (const QString &name) { + auto verifyProperty = [client](const QString &name) { QDBusPendingReply reply{getWindowInfo(client->internalId())}; reply.waitForFinished(); return reply.value().value(name).toBool(); diff --git a/autotests/integration/debug_console_test.cpp b/autotests/integration/debug_console_test.cpp index fbf917c07a..20153893c0 100644 --- a/autotests/integration/debug_console_test.cpp +++ b/autotests/integration/debug_console_test.cpp @@ -7,17 +7,18 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "abstract_output.h" #include "debug_console.h" #include "internal_client.h" #include "platform.h" +#include "utils/xcbutils.h" #include "wayland_server.h" #include "workspace.h" -#include "utils/xcbutils.h" -#include #include +#include #include #include @@ -386,7 +387,10 @@ class HelperWindow : public QRasterWindow { Q_OBJECT public: - HelperWindow() : QRasterWindow(nullptr) {} + HelperWindow() + : QRasterWindow(nullptr) + { + } ~HelperWindow() override = default; Q_SIGNALS: @@ -400,7 +404,8 @@ Q_SIGNALS: void keyReleased(); protected: - void paintEvent(QPaintEvent *event) override { + void paintEvent(QPaintEvent *event) override + { Q_UNUSED(event) QPainter p(this); p.fillRect(0, 0, width(), height(), Qt::red); diff --git a/autotests/integration/decoration_input_test.cpp b/autotests/integration/decoration_input_test.cpp index 8ff1a269f0..f51108d0ef 100644 --- a/autotests/integration/decoration_input_test.cpp +++ b/autotests/integration/decoration_input_test.cpp @@ -7,14 +7,15 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "abstract_output.h" #include "cursor.h" #include "internal_client.h" #include "platform.h" #include "pointer_input.h" -#include "touch_input.h" #include "screens.h" +#include "touch_input.h" #include "wayland_server.h" #include "workspace.h" #include @@ -23,8 +24,8 @@ #include "decorations/decorationbridge.h" #include "decorations/settings.h" -#include #include +#include #include #include #include @@ -83,11 +84,11 @@ private: AbstractClient *DecorationInputTest::showWindow() { using namespace KWayland::Client; -#define VERIFY(statement) \ - if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__))\ +#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__))\ +#define COMPARE(actual, expected) \ + if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__)) \ return nullptr; KWayland::Client::Surface *surface = Test::createSurface(Test::waylandCompositor()); @@ -365,10 +366,10 @@ void DecorationInputTest::testPressToMove_data() QTest::addColumn("offset2"); QTest::addColumn("offset3"); - QTest::newRow("To right") << QPoint(10, 0) << QPoint(20, 0) << QPoint(30, 0); - QTest::newRow("To left") << QPoint(-10, 0) << QPoint(-20, 0) << QPoint(-30, 0); - QTest::newRow("To bottom") << QPoint(0, 10) << QPoint(0, 20) << QPoint(0, 30); - QTest::newRow("To top") << QPoint(0, -10) << QPoint(0, -20) << QPoint(0, -30); + QTest::newRow("To right") << QPoint(10, 0) << QPoint(20, 0) << QPoint(30, 0); + QTest::newRow("To left") << QPoint(-10, 0) << QPoint(-20, 0) << QPoint(-30, 0); + QTest::newRow("To bottom") << QPoint(0, 10) << QPoint(0, 20) << QPoint(0, 30); + QTest::newRow("To top") << QPoint(0, -10) << QPoint(0, -20) << QPoint(0, -30); } void DecorationInputTest::testPressToMove() @@ -377,7 +378,7 @@ void DecorationInputTest::testPressToMove() QVERIFY(c); QVERIFY(c->isDecorated()); QVERIFY(!c->noBorder()); - c->move(screens()->geometry(0).center() - QPoint(c->width()/2, c->height()/2)); + c->move(screens()->geometry(0).center() - QPoint(c->width() / 2, c->height() / 2)); QSignalSpy startMoveResizedSpy(c, &AbstractClient::clientStartUserMovedResized); QVERIFY(startMoveResizedSpy.isValid()); QSignalSpy clientFinishUserMovedResizedSpy(c, &AbstractClient::clientFinishUserMovedResized); @@ -424,10 +425,10 @@ void DecorationInputTest::testTapToMove_data() QTest::addColumn("offset2"); QTest::addColumn("offset3"); - QTest::newRow("To right") << QPoint(10, 0) << QPoint(20, 0) << QPoint(30, 0); - QTest::newRow("To left") << QPoint(-10, 0) << QPoint(-20, 0) << QPoint(-30, 0); - QTest::newRow("To bottom") << QPoint(0, 10) << QPoint(0, 20) << QPoint(0, 30); - QTest::newRow("To top") << QPoint(0, -10) << QPoint(0, -20) << QPoint(0, -30); + QTest::newRow("To right") << QPoint(10, 0) << QPoint(20, 0) << QPoint(30, 0); + QTest::newRow("To left") << QPoint(-10, 0) << QPoint(-20, 0) << QPoint(-30, 0); + QTest::newRow("To bottom") << QPoint(0, 10) << QPoint(0, 20) << QPoint(0, 30); + QTest::newRow("To top") << QPoint(0, -10) << QPoint(0, -20) << QPoint(0, -30); } void DecorationInputTest::testTapToMove() @@ -436,7 +437,7 @@ void DecorationInputTest::testTapToMove() QVERIFY(c); QVERIFY(c->isDecorated()); QVERIFY(!c->noBorder()); - c->move(screens()->geometry(0).center() - QPoint(c->width()/2, c->height()/2)); + c->move(screens()->geometry(0).center() - QPoint(c->width() / 2, c->height() / 2)); QSignalSpy startMoveResizedSpy(c, &AbstractClient::clientStartUserMovedResized); QVERIFY(startMoveResizedSpy.isValid()); QSignalSpy clientFinishUserMovedResizedSpy(c, &AbstractClient::clientFinishUserMovedResized); @@ -502,7 +503,7 @@ void DecorationInputTest::testResizeOutsideWindow() QVERIFY(c); QVERIFY(c->isDecorated()); QVERIFY(!c->noBorder()); - c->move(screens()->geometry(0).center() - QPoint(c->width()/2, c->height()/2)); + c->move(screens()->geometry(0).center() - QPoint(c->width() / 2, c->height() / 2)); QVERIFY(c->frameGeometry() != c->inputGeometry()); QVERIFY(c->inputGeometry().contains(c->frameGeometry())); QSignalSpy startMoveResizedSpy(c, &AbstractClient::clientStartUserMovedResized); @@ -513,10 +514,10 @@ void DecorationInputTest::testResizeOutsideWindow() QFETCH(Qt::Edge, edge); switch (edge) { case Qt::LeftEdge: - MOTION(QPoint(c->frameGeometry().x() -1, c->frameGeometry().center().y())); + MOTION(QPoint(c->frameGeometry().x() - 1, c->frameGeometry().center().y())); break; case Qt::RightEdge: - MOTION(QPoint(c->frameGeometry().x() + c->frameGeometry().width() +1, c->frameGeometry().center().y())); + MOTION(QPoint(c->frameGeometry().x() + c->frameGeometry().width() + 1, c->frameGeometry().center().y())); break; case Qt::BottomEdge: MOTION(QPoint(c->frameGeometry().center().x(), c->frameGeometry().y() + c->frameGeometry().height() + 1)); @@ -546,33 +547,33 @@ void DecorationInputTest::testModifierClickUnrestrictedMove_data() 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("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("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("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("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; } @@ -599,7 +600,7 @@ void DecorationInputTest::testModifierClickUnrestrictedMove() QVERIFY(c); QVERIFY(c->isDecorated()); QVERIFY(!c->noBorder()); - c->move(screens()->geometry(0).center() - QPoint(c->width()/2, c->height()/2)); + c->move(screens()->geometry(0).center() - QPoint(c->width() / 2, c->height() / 2)); // move cursor on window Cursors::self()->mouse()->setPos(QPoint(c->frameGeometry().center().x(), c->y() + c->clientPos().y() / 2)); @@ -635,13 +636,13 @@ void DecorationInputTest::testModifierScrollOpacity_data() 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("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("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; } @@ -661,7 +662,7 @@ void DecorationInputTest::testModifierScrollOpacity() QVERIFY(c); QVERIFY(c->isDecorated()); QVERIFY(!c->noBorder()); - c->move(screens()->geometry(0).center() - QPoint(c->width()/2, c->height()/2)); + c->move(screens()->geometry(0).center() - QPoint(c->width() / 2, c->height() / 2)); // move cursor on window Cursors::self()->mouse()->setPos(QPoint(c->frameGeometry().center().x(), c->y() + c->clientPos().y() / 2)); // set the opacity to 0.5 @@ -690,7 +691,10 @@ class EventHelper : public QObject { Q_OBJECT public: - EventHelper() : QObject() {} + EventHelper() + : QObject() + { + } ~EventHelper() override = default; bool eventFilter(QObject *watched, QEvent *event) override diff --git a/autotests/integration/desktop_window_x11_test.cpp b/autotests/integration/desktop_window_x11_test.cpp index ee403cde3a..fb683d7593 100644 --- a/autotests/integration/desktop_window_x11_test.cpp +++ b/autotests/integration/desktop_window_x11_test.cpp @@ -7,15 +7,16 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "abstract_output.h" -#include "platform.h" -#include "x11client.h" #include "cursor.h" #include "deleted.h" +#include "platform.h" +#include "utils/xcbutils.h" #include "wayland_server.h" #include "workspace.h" -#include "utils/xcbutils.h" +#include "x11client.h" #include #include @@ -40,8 +41,8 @@ private: void X11DesktopWindowTest::initTestCase() { - qRegisterMetaType(); - qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -89,7 +90,7 @@ void X11DesktopWindowTest::testDesktopWindow() const QRect windowGeometry(0, 0, 1280, 1024); // helper to find the visual - auto findDepth = [&c] () -> xcb_visualid_t { + auto findDepth = [&c]() -> xcb_visualid_t { // find a visual with 32 depth const xcb_setup_t *setup = xcb_get_setup(c.data()); @@ -115,11 +116,11 @@ void X11DesktopWindowTest::testDesktopWindow() const uint32_t values[] = {XCB_PIXMAP_NONE, kwinApp()->x11DefaultScreen()->black_pixel, colormapId}; auto cookie = xcb_create_window_checked(c.data(), 32, w, rootWindow(), - windowGeometry.x(), - windowGeometry.y(), - windowGeometry.width(), - windowGeometry.height(), - 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, visualId, XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_COLORMAP, values); + windowGeometry.x(), + windowGeometry.y(), + windowGeometry.width(), + windowGeometry.height(), + 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, visualId, XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_COLORMAP, values); QVERIFY(!xcb_request_check(c.data(), cookie)); xcb_size_hints_t hints; memset(&hints, 0, sizeof(hints)); diff --git a/autotests/integration/dont_crash_aurorae_destroy_deco.cpp b/autotests/integration/dont_crash_aurorae_destroy_deco.cpp index e45d951cd3..efe50ff882 100644 --- a/autotests/integration/dont_crash_aurorae_destroy_deco.cpp +++ b/autotests/integration/dont_crash_aurorae_destroy_deco.cpp @@ -7,14 +7,15 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_output.h" -#include "platform.h" -#include "x11client.h" #include "composite.h" #include "cursor.h" +#include "platform.h" #include "renderbackend.h" #include "wayland_server.h" #include "workspace.h" +#include "x11client.h" #include #include @@ -35,13 +36,12 @@ private Q_SLOTS: void initTestCase(); void init(); void testBorderlessMaximizedWindows(); - }; void DontCrashAuroraeDestroyDecoTest::initTestCase() { qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8()); - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -108,7 +108,7 @@ void DontCrashAuroraeDestroyDecoTest::testBorderlessMaximizedWindows() // verify that the deco is Aurorae QCOMPARE(qstrcmp(client->decoration()->metaObject()->className(), "Aurorae::Decoration"), 0); // find the maximize button - QQuickItem *item = client->decoration()->findChild("maximizeButton"); + QQuickItem *item = client->decoration()->findChild("maximizeButton"); QVERIFY(item); const QPointF scenePoint = item->mapToScene(QPoint(0, 0)); @@ -117,7 +117,7 @@ void DontCrashAuroraeDestroyDecoTest::testBorderlessMaximizedWindows() QVERIFY(client->readyForPainting()); // simulate click on maximize button - QSignalSpy maximizedStateChangedSpy(client, static_cast(&AbstractClient::clientMaximizedStateChanged)); + QSignalSpy maximizedStateChangedSpy(client, static_cast(&AbstractClient::clientMaximizedStateChanged)); QVERIFY(maximizedStateChangedSpy.isValid()); quint32 timestamp = 1; Test::pointerMotion(client->frameGeometry().topLeft() + scenePoint.toPoint(), timestamp++); diff --git a/autotests/integration/dont_crash_cancel_animation.cpp b/autotests/integration/dont_crash_cancel_animation.cpp index b5d1064558..9720256a61 100644 --- a/autotests/integration/dont_crash_cancel_animation.cpp +++ b/autotests/integration/dont_crash_cancel_animation.cpp @@ -7,21 +7,22 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" -#include "platform.h" + #include "abstract_client.h" -#include "x11client.h" #include "composite.h" #include "deleted.h" -#include "effects.h" #include "effectloader.h" +#include "effects.h" +#include "platform.h" +#include "scripting/scriptedeffect.h" #include "wayland_server.h" #include "workspace.h" -#include "scripting/scriptedeffect.h" +#include "x11client.h" #include -#include #include +#include #include #include @@ -42,8 +43,8 @@ private Q_SLOTS: void DontCrashCancelAnimationFromAnimationEndedTest::initTestCase() { - qRegisterMetaType(); - qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); QVERIFY(waylandServer()->init(s_socketName)); kwinApp()->start(); @@ -75,10 +76,10 @@ void DontCrashCancelAnimationFromAnimationEndedTest::testScript() if (qstrcmp((*it)->metaObject()->className(), "KWin::EffectLoader") != 0) { continue; } - QVERIFY(QMetaObject::invokeMethod(*it, "effectLoaded", Q_ARG(KWin::Effect*, effect), Q_ARG(QString, QStringLiteral("crashy")))); + QVERIFY(QMetaObject::invokeMethod(*it, "effectLoaded", Q_ARG(KWin::Effect *, effect), Q_ARG(QString, QStringLiteral("crashy")))); break; } - QVERIFY(static_cast(effects)->isEffectLoaded(QStringLiteral("crashy"))); + QVERIFY(static_cast(effects)->isEffectLoaded(QStringLiteral("crashy"))); using namespace KWayland::Client; // create a window diff --git a/autotests/integration/dont_crash_cursor_physical_size_empty.cpp b/autotests/integration/dont_crash_cursor_physical_size_empty.cpp index 88724ac202..7f9d3f9103 100644 --- a/autotests/integration/dont_crash_cursor_physical_size_empty.cpp +++ b/autotests/integration/dont_crash_cursor_physical_size_empty.cpp @@ -7,14 +7,15 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "composite.h" -#include "effectloader.h" -#include "x11client.h" #include "cursor.h" +#include "effectloader.h" #include "effects.h" #include "platform.h" #include "wayland_server.h" #include "workspace.h" +#include "x11client.h" #include @@ -30,7 +31,7 @@ static const QString s_socketName = QStringLiteral("wayland_test_kwin_crash_curs class DontCrashCursorPhysicalSizeEmpty : public QObject { -Q_OBJECT + Q_OBJECT private Q_SLOTS: void init(); void initTestCase(); @@ -53,7 +54,7 @@ void DontCrashCursorPhysicalSizeEmpty::cleanup() void DontCrashCursorPhysicalSizeEmpty::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); diff --git a/autotests/integration/dont_crash_empty_deco.cpp b/autotests/integration/dont_crash_empty_deco.cpp index e9d342b9d5..981b0c6dd3 100644 --- a/autotests/integration/dont_crash_empty_deco.cpp +++ b/autotests/integration/dont_crash_empty_deco.cpp @@ -7,14 +7,15 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_output.h" -#include "platform.h" -#include "x11client.h" #include "composite.h" #include "cursor.h" +#include "platform.h" #include "renderbackend.h" #include "wayland_server.h" #include "workspace.h" +#include "x11client.h" #include #include @@ -37,7 +38,7 @@ private Q_SLOTS: void DontCrashEmptyDecorationTest::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); diff --git a/autotests/integration/dont_crash_glxgears.cpp b/autotests/integration/dont_crash_glxgears.cpp index 6eba7614d1..b22e8a836e 100644 --- a/autotests/integration/dont_crash_glxgears.cpp +++ b/autotests/integration/dont_crash_glxgears.cpp @@ -7,12 +7,13 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" -#include "platform.h" + #include "abstract_client.h" -#include "x11client.h" #include "deleted.h" +#include "platform.h" #include "wayland_server.h" #include "workspace.h" +#include "x11client.h" #include @@ -31,7 +32,7 @@ private Q_SLOTS: void DontCrashGlxgearsTest::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); diff --git a/autotests/integration/dont_crash_no_border.cpp b/autotests/integration/dont_crash_no_border.cpp index 78ed8e2c89..20ffecacb5 100644 --- a/autotests/integration/dont_crash_no_border.cpp +++ b/autotests/integration/dont_crash_no_border.cpp @@ -8,14 +8,15 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_output.h" -#include "platform.h" -#include "x11client.h" #include "composite.h" #include "cursor.h" +#include "platform.h" #include "renderbackend.h" #include "wayland_server.h" #include "workspace.h" +#include "x11client.h" #include #include @@ -41,7 +42,7 @@ private Q_SLOTS: void DontCrashNoBorder::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); diff --git a/autotests/integration/dont_crash_reinitialize_compositor.cpp b/autotests/integration/dont_crash_reinitialize_compositor.cpp index e95279712e..bb7d94d1c8 100644 --- a/autotests/integration/dont_crash_reinitialize_compositor.cpp +++ b/autotests/integration/dont_crash_reinitialize_compositor.cpp @@ -95,9 +95,9 @@ void DontCrashReinitializeCompositorTest::testReinitializeCompositor_data() { QTest::addColumn("effectName"); - QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade"); - QTest::newRow("Glide") << QStringLiteral("glide"); - QTest::newRow("Scale") << QStringLiteral("kwin4_effect_scale"); + QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade"); + QTest::newRow("Glide") << QStringLiteral("glide"); + QTest::newRow("Scale") << QStringLiteral("kwin4_effect_scale"); } void DontCrashReinitializeCompositorTest::testReinitializeCompositor() diff --git a/autotests/integration/dont_crash_useractions_menu.cpp b/autotests/integration/dont_crash_useractions_menu.cpp index 5c3f5c061e..f1014084be 100644 --- a/autotests/integration/dont_crash_useractions_menu.cpp +++ b/autotests/integration/dont_crash_useractions_menu.cpp @@ -7,6 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "abstract_output.h" #include "cursor.h" @@ -45,7 +46,7 @@ private Q_SLOTS: void TestDontCrashUseractionsMenu::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); diff --git a/autotests/integration/effects/desktop_switching_animation_test.cpp b/autotests/integration/effects/desktop_switching_animation_test.cpp index 3e35057801..7e48f32c36 100644 --- a/autotests/integration/effects/desktop_switching_animation_test.cpp +++ b/autotests/integration/effects/desktop_switching_animation_test.cpp @@ -88,8 +88,8 @@ void DesktopSwitchingAnimationTest::testSwitchDesktops_data() { QTest::addColumn("effectName"); - QTest::newRow("Fade Desktop") << QStringLiteral("kwin4_effect_fadedesktop"); - QTest::newRow("Slide") << QStringLiteral("slide"); + QTest::newRow("Fade Desktop") << QStringLiteral("kwin4_effect_fadedesktop"); + QTest::newRow("Slide") << QStringLiteral("slide"); } void DesktopSwitchingAnimationTest::testSwitchDesktops() diff --git a/autotests/integration/effects/minimize_animation_test.cpp b/autotests/integration/effects/minimize_animation_test.cpp index 143af989f0..2909843d64 100644 --- a/autotests/integration/effects/minimize_animation_test.cpp +++ b/autotests/integration/effects/minimize_animation_test.cpp @@ -71,9 +71,7 @@ void MinimizeAnimationTest::initTestCase() void MinimizeAnimationTest::init() { QVERIFY(Test::setupWaylandConnection( - Test::AdditionalWaylandInterface::PlasmaShell | - Test::AdditionalWaylandInterface::WindowManagement - )); + Test::AdditionalWaylandInterface::PlasmaShell | Test::AdditionalWaylandInterface::WindowManagement)); } void MinimizeAnimationTest::cleanup() @@ -91,7 +89,7 @@ void MinimizeAnimationTest::testMinimizeUnminimize_data() QTest::addColumn("effectName"); QTest::newRow("Magic Lamp") << QStringLiteral("magiclamp"); - QTest::newRow("Squash") << QStringLiteral("kwin4_effect_squash"); + QTest::newRow("Squash") << QStringLiteral("kwin4_effect_squash"); } void MinimizeAnimationTest::testMinimizeUnminimize() diff --git a/autotests/integration/effects/scripted_effects_test.cpp b/autotests/integration/effects/scripted_effects_test.cpp index 52f7ec6e8e..d9c1eb6dd8 100644 --- a/autotests/integration/effects/scripted_effects_test.cpp +++ b/autotests/integration/effects/scripted_effects_test.cpp @@ -7,8 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include "scripting/scriptedeffect.h" -#include "libkwineffects/anidata_p.h" +#include "kwin_wayland_test.h" #include "abstract_client.h" #include "composite.h" @@ -16,25 +15,25 @@ #include "deleted.h" #include "effectloader.h" #include "effects.h" -#include "kwin_wayland_test.h" +#include "libkwineffects/anidata_p.h" #include "platform.h" #include "renderbackend.h" +#include "scripting/scriptedeffect.h" #include "virtualdesktops.h" #include "wayland_server.h" #include "workspace.h" -#include -#include - #include #include - #include #include #include #include #include +#include +#include + using namespace KWin; using namespace std::chrono_literals; @@ -79,8 +78,8 @@ public: bool load(const QString &name); using AnimationEffect::AniMap; using AnimationEffect::state; - Q_INVOKABLE void sendTestResponse(const QString &out); //proxies triggers out from the tests - QList actions(); //returns any QActions owned by the ScriptEngine + Q_INVOKABLE void sendTestResponse(const QString &out); // proxies triggers out from the tests + QList actions(); // returns any QActions owned by the ScriptEngine Q_SIGNALS: void testOutput(const QString &data); }; @@ -106,7 +105,7 @@ bool ScriptedEffectWithDebugSpy::load(const QString &name) QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); const QString path = QFINDTESTDATA("./scripts/" + name + ".js"); engine()->globalObject().setProperty("sendTestResponse", selfContext.property("sendTestResponse")); - if (!init(name, path)) { + if (!init(name, path)) { return false; } @@ -118,18 +117,18 @@ bool ScriptedEffectWithDebugSpy::load(const QString &name) if (qstrcmp((*it)->metaObject()->className(), "KWin::EffectLoader") != 0) { continue; } - QMetaObject::invokeMethod(*it, "effectLoaded", Q_ARG(KWin::Effect*, this), Q_ARG(QString, name)); + QMetaObject::invokeMethod(*it, "effectLoaded", Q_ARG(KWin::Effect *, this), Q_ARG(QString, name)); break; } - return (static_cast(effects)->isEffectLoaded(name)); + return (static_cast(effects)->isEffectLoaded(name)); } void ScriptedEffectsTest::initTestCase() { - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -250,7 +249,7 @@ void ScriptedEffectsTest::testAnimations_data() QTest::addColumn("animationCount"); QTest::newRow("single") << "animationTest" << 1; - QTest::newRow("multi") << "animationTestMulti" << 2; + QTest::newRow("multi") << "animationTestMulti" << 2; } void ScriptedEffectsTest::testAnimations() @@ -353,7 +352,7 @@ void ScriptedEffectsTest::testFullScreenEffect_data() QTest::addColumn("file"); QTest::newRow("single") << "fullScreenEffectTest"; - QTest::newRow("multi") << "fullScreenEffectTestMulti"; + QTest::newRow("multi") << "fullScreenEffectTestMulti"; QTest::newRow("global") << "fullScreenEffectTestGlobal"; } @@ -368,8 +367,8 @@ void ScriptedEffectsTest::testFullScreenEffect() QVERIFY(effectMain->load(file)); - //load any random effect from another test to confirm fullscreen effect state is correctly - //shown as being someone else + // load any random effect from another test to confirm fullscreen effect state is correctly + // shown as being someone else auto effectOther = new ScriptedEffectWithDebugSpy(); QVERIFY(effectOther->load("screenEdgeTouchTest")); QSignalSpy isActiveFullScreenEffectSpyOther(effectOther, &ScriptedEffect::isActiveFullScreenEffectChanged); @@ -387,7 +386,7 @@ void ScriptedEffectsTest::testFullScreenEffect() QCOMPARE(effects->hasActiveFullScreenEffect(), false); QCOMPARE(effectMain->isActiveFullScreenEffect(), false); - //trigger animation + // trigger animation KWin::VirtualDesktopManager::self()->setCurrent(2); QCOMPARE(effects->activeFullScreenEffect(), effectMain); @@ -400,18 +399,18 @@ void ScriptedEffectsTest::testFullScreenEffect() QCOMPARE(effectOther->isActiveFullScreenEffect(), false); QCOMPARE(isActiveFullScreenEffectSpyOther.count(), 0); - //after 500ms trigger another full screen animation + // after 500ms trigger another full screen animation QTest::qWait(500); KWin::VirtualDesktopManager::self()->setCurrent(1); QCOMPARE(effects->activeFullScreenEffect(), effectMain); - //after 1000ms (+a safety margin for time based tests) we should still be the active full screen effect - //despite first animation expiring - QTest::qWait(500+100); + // after 1000ms (+a safety margin for time based tests) we should still be the active full screen effect + // despite first animation expiring + QTest::qWait(500 + 100); QCOMPARE(effects->activeFullScreenEffect(), effectMain); - //after 1500ms (+a safetey margin) we should have no full screen effect - QTest::qWait(500+100); + // after 1500ms (+a safetey margin) we should have no full screen effect + QTest::qWait(500 + 100); QCOMPARE(effects->activeFullScreenEffect(), nullptr); } @@ -420,8 +419,8 @@ void ScriptedEffectsTest::testKeepAlive_data() QTest::addColumn("file"); QTest::addColumn("keepAlive"); - QTest::newRow("keep") << "keepAliveTest" << true; - QTest::newRow("don't keep") << "keepAliveTestDontKeep" << false; + QTest::newRow("keep") << "keepAliveTest" << true; + QTest::newRow("don't keep") << "keepAliveTestDontKeep" << false; } void ScriptedEffectsTest::testKeepAlive() @@ -613,9 +612,9 @@ void ScriptedEffectsTest::testRedirect_data() QTest::addColumn("file"); QTest::addColumn("shouldTerminate"); QTest::newRow("animate/DontTerminateAtSource") << "redirectAnimateDontTerminateTest" << false; - QTest::newRow("animate/TerminateAtSource") << "redirectAnimateTerminateTest" << true; - QTest::newRow("set/DontTerminate") << "redirectSetDontTerminateTest" << false; - QTest::newRow("set/Terminate") << "redirectSetTerminateTest" << true; + QTest::newRow("animate/TerminateAtSource") << "redirectAnimateTerminateTest" << true; + QTest::newRow("set/DontTerminate") << "redirectSetDontTerminateTest" << false; + QTest::newRow("set/Terminate") << "redirectSetTerminateTest" << true; } void ScriptedEffectsTest::testRedirect() @@ -637,9 +636,9 @@ void ScriptedEffectsTest::testRedirect() QVERIFY(c); QCOMPARE(workspace()->activeClient(), c); - auto around = [] (std::chrono::milliseconds elapsed, - std::chrono::milliseconds pivot, - std::chrono::milliseconds margin) { + auto around = [](std::chrono::milliseconds elapsed, + std::chrono::milliseconds pivot, + std::chrono::milliseconds margin) { return qAbs(elapsed.count() - pivot.count()) < margin.count(); }; @@ -715,9 +714,9 @@ void ScriptedEffectsTest::testComplete() QVERIFY(c); QCOMPARE(workspace()->activeClient(), c); - auto around = [] (std::chrono::milliseconds elapsed, - std::chrono::milliseconds pivot, - std::chrono::milliseconds margin) { + auto around = [](std::chrono::milliseconds elapsed, + std::chrono::milliseconds pivot, + std::chrono::milliseconds margin) { return qAbs(elapsed.count() - pivot.count()) < margin.count(); }; diff --git a/autotests/integration/effects/slidingpopups_test.cpp b/autotests/integration/effects/slidingpopups_test.cpp index c2550a307a..cdef5b8289 100644 --- a/autotests/integration/effects/slidingpopups_test.cpp +++ b/autotests/integration/effects/slidingpopups_test.cpp @@ -6,24 +6,24 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include "kwin_wayland_test.h" -#include "x11client.h" #include "composite.h" -#include "deleted.h" -#include "effects.h" -#include "effectloader.h" #include "cursor.h" +#include "deleted.h" +#include "effectloader.h" +#include "effects.h" +#include "kwin_wayland_test.h" #include "platform.h" #include "renderbackend.h" #include "wayland_server.h" #include "workspace.h" +#include "x11client.h" #include #include #include -#include #include +#include #include #include @@ -33,7 +33,7 @@ static const QString s_socketName = QStringLiteral("wayland_test_effects_sliding class SlidingPopupsTest : public QObject { -Q_OBJECT + Q_OBJECT private Q_SLOTS: void initTestCase(); void init(); @@ -48,9 +48,9 @@ private Q_SLOTS: void SlidingPopupsTest::initTestCase() { qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8()); - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -88,7 +88,7 @@ void SlidingPopupsTest::init() void SlidingPopupsTest::cleanup() { Test::destroyWaylandConnection(); - EffectsHandlerImpl *e = static_cast(effects); + EffectsHandlerImpl *e = static_cast(effects); while (!e->loadedEffects().isEmpty()) { const QString effect = e->loadedEffects().first(); e->unloadEffect(effect); @@ -104,7 +104,6 @@ struct XcbConnectionDeleter } }; - void SlidingPopupsTest::testWithOtherEffect_data() { QTest::addColumn("effectsToLoad"); @@ -129,9 +128,9 @@ void SlidingPopupsTest::testWithOtherEffect() // this test verifies that slidingpopups effect grabs the window added role // independently of the sequence how the effects are loaded. // see BUG 336866 - EffectsHandlerImpl *e = static_cast(effects); + EffectsHandlerImpl *e = static_cast(effects); // find the effectsloader - auto effectloader = e->findChild(); + auto effectloader = e->findChild(); QVERIFY(effectloader); QSignalSpy effectLoadedSpy(effectloader, &AbstractEffectLoader::effectLoaded); QVERIFY(effectLoadedSpy.isValid()); @@ -145,7 +144,7 @@ void SlidingPopupsTest::testWithOtherEffect() QVERIFY(e->isEffectLoaded(effectName)); QCOMPARE(effectLoadedSpy.count(), 1); - Effect *effect = effectLoadedSpy.first().first().value(); + Effect *effect = effectLoadedSpy.first().first().value(); if (effectName == QStringLiteral("slidingpopups")) { slidingPoupus = effect; } else { @@ -267,9 +266,9 @@ void SlidingPopupsTest::testWithOtherEffectWayland() // independently of the sequence how the effects are loaded. // see BUG 336866 // the test is like testWithOtherEffect, but simulates using a Wayland window - EffectsHandlerImpl *e = static_cast(effects); + EffectsHandlerImpl *e = static_cast(effects); // find the effectsloader - auto effectloader = e->findChild(); + auto effectloader = e->findChild(); QVERIFY(effectloader); QSignalSpy effectLoadedSpy(effectloader, &AbstractEffectLoader::effectLoaded); QVERIFY(effectLoadedSpy.isValid()); @@ -283,7 +282,7 @@ void SlidingPopupsTest::testWithOtherEffectWayland() QVERIFY(e->isEffectLoaded(effectName)); QCOMPARE(effectLoadedSpy.count(), 1); - Effect *effect = effectLoadedSpy.first().first().value(); + Effect *effect = effectLoadedSpy.first().first().value(); if (effectName == QStringLiteral("slidingpopups")) { slidingPoupus = effect; } else { diff --git a/autotests/integration/effects/toplevel_open_close_animation_test.cpp b/autotests/integration/effects/toplevel_open_close_animation_test.cpp index f6c26a8c56..18f2b93216 100644 --- a/autotests/integration/effects/toplevel_open_close_animation_test.cpp +++ b/autotests/integration/effects/toplevel_open_close_animation_test.cpp @@ -89,9 +89,9 @@ void ToplevelOpenCloseAnimationTest::testAnimateToplevels_data() { QTest::addColumn("effectName"); - QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade"); - QTest::newRow("Glide") << QStringLiteral("glide"); - QTest::newRow("Scale") << QStringLiteral("kwin4_effect_scale"); + QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade"); + QTest::newRow("Glide") << QStringLiteral("glide"); + QTest::newRow("Scale") << QStringLiteral("kwin4_effect_scale"); } void ToplevelOpenCloseAnimationTest::testAnimateToplevels() @@ -142,9 +142,9 @@ void ToplevelOpenCloseAnimationTest::testDontAnimatePopups_data() { QTest::addColumn("effectName"); - QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade"); - QTest::newRow("Glide") << QStringLiteral("glide"); - QTest::newRow("Scale") << QStringLiteral("kwin4_effect_scale"); + QTest::newRow("Fade") << QStringLiteral("kwin4_effect_fade"); + QTest::newRow("Glide") << QStringLiteral("glide"); + QTest::newRow("Scale") << QStringLiteral("kwin4_effect_scale"); } void ToplevelOpenCloseAnimationTest::testDontAnimatePopups() diff --git a/autotests/integration/effects/translucency_test.cpp b/autotests/integration/effects/translucency_test.cpp index 27b822e08a..bf73ecbc32 100644 --- a/autotests/integration/effects/translucency_test.cpp +++ b/autotests/integration/effects/translucency_test.cpp @@ -7,14 +7,15 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" -#include "x11client.h" + #include "composite.h" -#include "effects.h" -#include "effectloader.h" #include "cursor.h" +#include "effectloader.h" +#include "effects.h" #include "platform.h" #include "wayland_server.h" #include "workspace.h" +#include "x11client.h" #include @@ -26,7 +27,7 @@ static const QString s_socketName = QStringLiteral("wayland_test_effects_translu class TranslucencyTest : public QObject { -Q_OBJECT + Q_OBJECT private Q_SLOTS: void initTestCase(); void init(); @@ -42,8 +43,8 @@ private: void TranslucencyTest::initTestCase() { qputenv("XDG_DATA_DIRS", QCoreApplication::applicationDirPath().toUtf8()); - qRegisterMetaType(); - qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -71,9 +72,9 @@ void TranslucencyTest::initTestCase() void TranslucencyTest::init() { // load the translucency effect - EffectsHandlerImpl *e = static_cast(effects); + EffectsHandlerImpl *e = static_cast(effects); // find the effectsloader - auto effectloader = e->findChild(); + auto effectloader = e->findChild(); QVERIFY(effectloader); QSignalSpy effectLoadedSpy(effectloader, &AbstractEffectLoader::effectLoaded); QVERIFY(effectLoadedSpy.isValid()); @@ -83,13 +84,13 @@ void TranslucencyTest::init() QVERIFY(e->isEffectLoaded(QStringLiteral("kwin4_effect_translucency"))); QCOMPARE(effectLoadedSpy.count(), 1); - m_translucencyEffect = effectLoadedSpy.first().first().value(); + m_translucencyEffect = effectLoadedSpy.first().first().value(); QVERIFY(m_translucencyEffect); } void TranslucencyTest::cleanup() { - EffectsHandlerImpl *e = static_cast(effects); + EffectsHandlerImpl *e = static_cast(effects); if (e->isEffectLoaded(QStringLiteral("kwin4_effect_translucency"))) { e->unloadEffect(QStringLiteral("kwin4_effect_translucency")); } diff --git a/autotests/integration/effects/wobbly_shade_test.cpp b/autotests/integration/effects/wobbly_shade_test.cpp index f28de2adef..c35a1c951e 100644 --- a/autotests/integration/effects/wobbly_shade_test.cpp +++ b/autotests/integration/effects/wobbly_shade_test.cpp @@ -7,22 +7,23 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" -#include "x11client.h" + #include "composite.h" #include "cursor.h" -#include "effects.h" #include "effectloader.h" +#include "effects.h" #include "platform.h" #include "renderbackend.h" #include "wayland_server.h" #include "workspace.h" +#include "x11client.h" #include #include #include -#include #include +#include #include #include @@ -32,7 +33,7 @@ static const QString s_socketName = QStringLiteral("wayland_test_effects_wobbly_ class WobblyWindowsShadeTest : public QObject { -Q_OBJECT + Q_OBJECT private Q_SLOTS: void initTestCase(); void init(); @@ -43,8 +44,8 @@ private Q_SLOTS: void WobblyWindowsShadeTest::initTestCase() { - qRegisterMetaType(); - qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -95,11 +96,10 @@ struct XcbConnectionDeleter void WobblyWindowsShadeTest::testShadeMove() { // this test simulates the condition from BUG 390953 - EffectsHandlerImpl *e = static_cast(effects); + EffectsHandlerImpl *e = static_cast(effects); QVERIFY(e->loadEffect(QStringLiteral("wobblywindows"))); QVERIFY(e->isEffectLoaded(QStringLiteral("wobblywindows"))); - QScopedPointer c(xcb_connect(nullptr, nullptr)); QVERIFY(!xcb_connection_has_error(c.data())); const QRect windowGeometry(0, 0, 100, 200); diff --git a/autotests/integration/fakes/org.kde.kdecoration2/fakedecoration_with_shadows.cpp b/autotests/integration/fakes/org.kde.kdecoration2/fakedecoration_with_shadows.cpp index 1451d15cca..3aba0d0fe0 100644 --- a/autotests/integration/fakes/org.kde.kdecoration2/fakedecoration_with_shadows.cpp +++ b/autotests/integration/fakes/org.kde.kdecoration2/fakedecoration_with_shadows.cpp @@ -12,23 +12,28 @@ #include #include - class FakeDecoWithShadows : public KDecoration2::Decoration { Q_OBJECT public: explicit FakeDecoWithShadows(QObject *parent = nullptr, const QVariantList &args = QVariantList()) - : Decoration(parent, args) {} - ~FakeDecoWithShadows() override {} + : Decoration(parent, args) + { + } + ~FakeDecoWithShadows() override + { + } - void paint(QPainter *painter, const QRect &repaintRegion) override { + void paint(QPainter *painter, const QRect &repaintRegion) override + { Q_UNUSED(painter) Q_UNUSED(repaintRegion) } public Q_SLOTS: - void init() override { + void init() override + { const int shadowSize = 128; const int offsetTop = 64; const int offsetLeft = 48; @@ -55,7 +60,6 @@ public Q_SLOTS: K_PLUGIN_FACTORY_WITH_JSON( FakeDecoWithShadowsFactory, "fakedecoration_with_shadows.json", - registerPlugin(); -) + registerPlugin();) #include "fakedecoration_with_shadows.moc" diff --git a/autotests/integration/generic_scene_opengl_test.cpp b/autotests/integration/generic_scene_opengl_test.cpp index bed92668c5..97a3ad3272 100644 --- a/autotests/integration/generic_scene_opengl_test.cpp +++ b/autotests/integration/generic_scene_opengl_test.cpp @@ -9,8 +9,8 @@ #include "generic_scene_opengl_test.h" #include "abstract_client.h" #include "composite.h" -#include "effectloader.h" #include "cursor.h" +#include "effectloader.h" #include "platform.h" #include "renderbackend.h" #include "scene.h" @@ -38,7 +38,7 @@ void GenericSceneOpenGLTest::cleanup() void GenericSceneOpenGLTest::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); diff --git a/autotests/integration/generic_scene_opengl_test.h b/autotests/integration/generic_scene_opengl_test.h index 8c1cf54205..85cb7e76e6 100644 --- a/autotests/integration/generic_scene_opengl_test.h +++ b/autotests/integration/generic_scene_opengl_test.h @@ -13,9 +13,10 @@ class GenericSceneOpenGLTest : public QObject { -Q_OBJECT + Q_OBJECT public: ~GenericSceneOpenGLTest() override; + protected: GenericSceneOpenGLTest(const QByteArray &envVariable); private Q_SLOTS: diff --git a/autotests/integration/globalshortcuts_test.cpp b/autotests/integration/globalshortcuts_test.cpp index 50c7da10ce..680f88d542 100644 --- a/autotests/integration/globalshortcuts_test.cpp +++ b/autotests/integration/globalshortcuts_test.cpp @@ -7,7 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" -#include "x11client.h" + #include "cursor.h" #include "input.h" #include "internal_client.h" @@ -16,6 +16,7 @@ #include "useractions.h" #include "wayland_server.h" #include "workspace.h" +#include "x11client.h" #include #include @@ -96,34 +97,31 @@ void GlobalShortcutsTest::testNonLatinLayout_data() QTest::addColumn("qtKey"); for (const auto &modifier : - QVector> { - {KEY_LEFTCTRL, Qt::CTRL}, - {KEY_LEFTALT, Qt::ALT}, - {KEY_LEFTSHIFT, Qt::SHIFT}, - {KEY_LEFTMETA, Qt::META}, - } ) - { + QVector>{ + {KEY_LEFTCTRL, Qt::CTRL}, + {KEY_LEFTALT, Qt::ALT}, + {KEY_LEFTSHIFT, Qt::SHIFT}, + {KEY_LEFTMETA, Qt::META}, + }) { for (const auto &key : QVector> { - // Tab is example of a key usually the same on different layouts, check it first - {KEY_TAB, Qt::Key_Tab}, + {KEY_TAB, Qt::Key_Tab}, - // Then check a key with a Latin letter. - // The symbol will probably be differ on non-Latin layout. - // On Russian layout, "w" key has a cyrillic letter "ц" - {KEY_W, Qt::Key_W}, + // Then check a key with a Latin letter. + // The symbol will probably be differ on non-Latin layout. + // On Russian layout, "w" key has a cyrillic letter "ц" + {KEY_W, Qt::Key_W}, - #if QT_VERSION_MAJOR > 5 // since Qt 5 LTS is frozen - // More common case with any Latin1 symbol keys, including punctuation, should work also. - // "`" key has a "Ñ‘" letter on Russian layout - // FIXME: QTBUG-90611 - {KEY_GRAVE, Qt::Key_QuoteLeft}, - #endif - } ) - { +#if QT_VERSION_MAJOR > 5 // since Qt 5 LTS is frozen + // More common case with any Latin1 symbol keys, including punctuation, should work also. + // "`" key has a "Ñ‘" letter on Russian layout + // FIXME: QTBUG-90611 + {KEY_GRAVE, Qt::Key_QuoteLeft}, +#endif + }) { QTest::newRow(QKeySequence(modifier.second + key.second).toString().toLatin1().constData()) - << modifier.first << modifier.second << key.first << key.second; + << modifier.first << modifier.second << key.first << key.second; } } } @@ -315,9 +313,7 @@ void GlobalShortcutsTest::testX11ClientShortcut() xcb_window_t w = xcb_generate_id(c.data()); const QRect windowGeometry = QRect(0, 0, 10, 20); const uint32_t values[] = { - XCB_EVENT_MASK_ENTER_WINDOW | - XCB_EVENT_MASK_LEAVE_WINDOW - }; + XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW}; xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, w, rootWindow(), windowGeometry.x(), windowGeometry.y(), @@ -409,7 +405,7 @@ void GlobalShortcutsTest::testWaylandClientShortcut() shellSurface.reset(); surface.reset(); QVERIFY(Test::waitForWindowDestroyed(client)); - QTRY_VERIFY_WITH_TIMEOUT(workspace()->shortcutAvailable(seq), 500); //we need the try since KGlobalAccelPrivate::unregister is async + QTRY_VERIFY_WITH_TIMEOUT(workspace()->shortcutAvailable(seq), 500); // we need the try since KGlobalAccelPrivate::unregister is async } void GlobalShortcutsTest::testSetupWindowShortcut() @@ -431,7 +427,7 @@ void GlobalShortcutsTest::testSetupWindowShortcut() auto dialog = shortcutDialogAddedSpy.first().first().value(); QVERIFY(dialog); QVERIFY(dialog->isInternal()); - auto sequenceEdit = workspace()->shortcutDialog()->findChild(); + auto sequenceEdit = workspace()->shortcutDialog()->findChild(); QVERIFY(sequenceEdit); // the QKeySequenceEdit field does not get focus, we need to pass it focus manually diff --git a/autotests/integration/helper/copy.cpp b/autotests/integration/helper/copy.cpp index 92029f0141..d0536f677e 100644 --- a/autotests/integration/helper/copy.cpp +++ b/autotests/integration/helper/copy.cpp @@ -42,7 +42,7 @@ void Window::focusInEvent(QFocusEvent *event) { QRasterWindow::focusInEvent(event); // TODO: make it work without singleshot - QTimer::singleShot(100,[] { + QTimer::singleShot(100, [] { qApp->clipboard()->setText(QStringLiteral("test")); }); } diff --git a/autotests/integration/helper/kill.cpp b/autotests/integration/helper/kill.cpp index 793012384e..2f24cc6d1b 100644 --- a/autotests/integration/helper/kill.cpp +++ b/autotests/integration/helper/kill.cpp @@ -24,7 +24,7 @@ int main(int argc, char *argv[]) w.show(); auto freezeHandler = [](int) { - while(true) { + while (true) { sleep(10000); } }; diff --git a/autotests/integration/helper/paste.cpp b/autotests/integration/helper/paste.cpp index ea4c8b1dc8..3075e98575 100644 --- a/autotests/integration/helper/paste.cpp +++ b/autotests/integration/helper/paste.cpp @@ -41,12 +41,11 @@ 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); - } - } - ); + [] { + 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(); diff --git a/autotests/integration/idle_inhibition_test.cpp b/autotests/integration/idle_inhibition_test.cpp index a5751a4d23..b8f840bcee 100644 --- a/autotests/integration/idle_inhibition_test.cpp +++ b/autotests/integration/idle_inhibition_test.cpp @@ -7,6 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "platform.h" #include "virtualdesktops.h" @@ -41,7 +42,7 @@ private Q_SLOTS: void TestIdleInhibition::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); @@ -57,7 +58,6 @@ void TestIdleInhibition::initTestCase() void TestIdleInhibition::init() { QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::IdleInhibitV1)); - } void TestIdleInhibition::cleanup() @@ -70,7 +70,7 @@ void TestIdleInhibition::cleanup() void TestIdleInhibition::testInhibit() { - auto idle = waylandServer()->display()->findChild(); + auto idle = waylandServer()->display()->findChild(); QVERIFY(idle); QVERIFY(!idle->isInhibited()); QSignalSpy inhibitedSpy(idle, &IdleInterface::inhibitedChanged); @@ -172,7 +172,7 @@ void TestIdleInhibition::testDontInhibitWhenMinimized() // This test verifies that the idle inhibitor object is not honored when the // associated surface is minimized. - // Get reference to the idle interface. + // Get reference to the idle interface. auto idle = waylandServer()->display()->findChild(); QVERIFY(idle); QVERIFY(!idle->isInhibited()); diff --git a/autotests/integration/input_stacking_order.cpp b/autotests/integration/input_stacking_order.cpp index 5e88f30bd3..15721f6108 100644 --- a/autotests/integration/input_stacking_order.cpp +++ b/autotests/integration/input_stacking_order.cpp @@ -7,20 +7,21 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" -#include "abstract_output.h" -#include "platform.h" + #include "abstract_client.h" +#include "abstract_output.h" #include "cursor.h" #include "deleted.h" +#include "platform.h" #include "wayland_server.h" #include "workspace.h" #include -#include #include +#include #include -#include #include +#include #include #include #include @@ -47,8 +48,8 @@ private: void InputStackingOrderTest::initTestCase() { - qRegisterMetaType(); - qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); diff --git a/autotests/integration/inputmethod_test.cpp b/autotests/integration/inputmethod_test.cpp index 32c2567509..db50a416ca 100644 --- a/autotests/integration/inputmethod_test.cpp +++ b/autotests/integration/inputmethod_test.cpp @@ -7,28 +7,29 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "abstract_output.h" #include "cursor.h" -#include "effects.h" #include "deleted.h" -#include "platform.h" -#include "wayland_server.h" -#include "workspace.h" +#include "effects.h" #include "inputmethod.h" -#include "virtualkeyboard_dbus.h" +#include "platform.h" #include "qwayland-input-method-unstable-v1.h" #include "qwayland-text-input-unstable-v3.h" +#include "virtualkeyboard_dbus.h" +#include "wayland_server.h" +#include "workspace.h" -#include -#include -#include -#include -#include #include #include #include #include +#include +#include +#include +#include +#include #include #include @@ -63,14 +64,14 @@ private Q_SLOTS: void testModifierForwarding(); private: - void touchNow() { + void touchNow() + { static int time = 0; Test::touchDown(0, {100, 100}, ++time); Test::touchUp(0, ++time); } }; - void InputMethodTest::initTestCase() { QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.kwin.testvirtualkeyboard")); @@ -93,16 +94,12 @@ void InputMethodTest::initTestCase() QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024)); QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024)); Test::initWaylandWorkspace(); - } void InputMethodTest::init() { touchNow(); - QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat | - Test::AdditionalWaylandInterface::TextInputManagerV2 | - Test::AdditionalWaylandInterface::InputMethodV1 | - Test::AdditionalWaylandInterface::TextInputManagerV3)); + QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat | Test::AdditionalWaylandInterface::TextInputManagerV2 | Test::AdditionalWaylandInterface::InputMethodV1 | Test::AdditionalWaylandInterface::TextInputManagerV3)); workspace()->setActiveOutput(QPoint(640, 512)); KWin::Cursors::self()->mouse()->setPos(QPoint(640, 512)); @@ -291,7 +288,6 @@ void InputMethodTest::testHidePanel() // Destroy the test client. shellSurface.reset(); QVERIFY(Test::waitForWindowDestroyed(client)); - } void InputMethodTest::testSwitchFocusedSurfaces() diff --git a/autotests/integration/internal_window.cpp b/autotests/integration/internal_window.cpp index dd40f91b78..cf90bf1792 100644 --- a/autotests/integration/internal_window.cpp +++ b/autotests/integration/internal_window.cpp @@ -7,12 +7,13 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_output.h" -#include "platform.h" #include "cursor.h" #include "deleted.h" #include "effects.h" #include "internal_client.h" +#include "platform.h" #include "wayland_server.h" #include "workspace.h" @@ -20,8 +21,8 @@ #include #include -#include #include +#include #include #include @@ -76,10 +77,12 @@ public: HelperWindow(); ~HelperWindow() override; - QPoint latestGlobalMousePos() const { + QPoint latestGlobalMousePos() const + { return m_latestGlobalMousePos; } - Qt::MouseButtons pressedButtons() const { + Qt::MouseButtons pressedButtons() const + { return m_pressedButtons; } @@ -676,9 +679,9 @@ void InternalWindowTest::testPopup() 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}))); + 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(workspace(), &Workspace::internalClientAdded); QVERIFY(clientAddedSpy.isValid()); @@ -838,7 +841,7 @@ void InternalWindowTest::testDismissPopup() auto serverPopup = clientAddedSpy.last().first().value(); QVERIFY(serverPopup); - //Create the other window to click + // Create the other window to click HelperWindow otherClientToplevel; otherClientToplevel.setGeometry(100, 100, 100, 100); otherClientToplevel.show(); diff --git a/autotests/integration/keyboard_layout_test.cpp b/autotests/integration/keyboard_layout_test.cpp index 136a8a61bf..d021b742aa 100644 --- a/autotests/integration/keyboard_layout_test.cpp +++ b/autotests/integration/keyboard_layout_test.cpp @@ -7,6 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "keyboard_input.h" #include "keyboard_layout.h" @@ -109,25 +110,29 @@ void KeyboardLayoutTest::resetLayouts() callSession(QStringLiteral("loadSession")); } -auto KeyboardLayoutTest::changeLayout(uint index) { - QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.keyboard"), QStringLiteral("/Layouts"), QStringLiteral("org.kde.KeyboardLayouts"), QStringLiteral("setLayout")); +auto KeyboardLayoutTest::changeLayout(uint index) +{ + QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.keyboard"), + QStringLiteral("/Layouts"), + QStringLiteral("org.kde.KeyboardLayouts"), + QStringLiteral("setLayout")); msg << index; return QDBusConnection::sessionBus().asyncCall(msg); } -void KeyboardLayoutTest::callSession(const QString &method) { - QDBusMessage msg = QDBusMessage::createMethodCall( - QStringLiteral("org.kde.KWin"), - QStringLiteral("/Session"), - QStringLiteral("org.kde.KWin.Session"), - method); - msg << QLatin1String(); // session name +void KeyboardLayoutTest::callSession(const QString &method) +{ + QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.KWin"), + QStringLiteral("/Session"), + QStringLiteral("org.kde.KWin.Session"), + method); + msg << QLatin1String(); // session name QVERIFY(QDBusConnection::sessionBus().call(msg).type() != QDBusMessage::ErrorMessage); } void KeyboardLayoutTest::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -144,9 +149,9 @@ void KeyboardLayoutTest::initTestCase() Test::initWaylandWorkspace(); // don't get DBus signal on one-layout configuration -// QVERIFY(layoutsReconfiguredSpy.wait()); -// QCOMPARE(layoutsReconfiguredSpy.count(), 1); -// layoutsReconfiguredSpy.clear(); + // QVERIFY(layoutsReconfiguredSpy.wait()); + // QCOMPARE(layoutsReconfiguredSpy.count(), 1); + // layoutsReconfiguredSpy.clear(); } void KeyboardLayoutTest::init() @@ -189,7 +194,12 @@ void KeyboardLayoutTest::testChangeLayoutThroughDBus() { // this test verifies that the layout can be changed through DBus // first configure layouts - enum Layout {de, us, de_neo, bad}; + enum Layout { + de, + us, + de_neo, + bad, + }; layoutGroup.writeEntry("LayoutList", QStringLiteral("de,us,de(neo)")); layoutGroup.sync(); reconfigureLayouts(); @@ -257,12 +267,12 @@ void KeyboardLayoutTest::testPerLayoutShortcut() QAction *a = new QAction(this); a->setObjectName(QStringLiteral("Switch keyboard layout to English (US)")); a->setProperty("componentName", componentName); - KGlobalAccel::self()->setShortcut(a, QList{Qt::CTRL|Qt::ALT|Qt::Key_1}, KGlobalAccel::NoAutoloading); + KGlobalAccel::self()->setShortcut(a, QList{Qt::CTRL | Qt::ALT | Qt::Key_1}, KGlobalAccel::NoAutoloading); delete a; a = new QAction(this); a->setObjectName(QStringLiteral("Switch keyboard layout to German")); a->setProperty("componentName", componentName); - KGlobalAccel::self()->setShortcut(a, QList{Qt::CTRL|Qt::ALT|Qt::Key_2}, KGlobalAccel::NoAutoloading); + KGlobalAccel::self()->setShortcut(a, QList{Qt::CTRL | Qt::ALT | Qt::Key_2}, KGlobalAccel::NoAutoloading); delete a; // now we should have three layouts @@ -356,18 +366,18 @@ void KeyboardLayoutTest::testVirtualDesktopPolicy() resetLayouts(); // check layout set on desktop switching as intended - for(--desktop;;) { + for (--desktop;;) { QCOMPARE(desktops.at(desktop), VirtualDesktopManager::self()->currentDesktop()); layout = (desktop + 1) % xkb->numberOfLayouts(); QCOMPARE(xkb->currentLayout(), layout); - if (--desktop >= VirtualDesktopManager::self()->count()) // overflow + if (--desktop >= VirtualDesktopManager::self()->count()) // overflow break; VirtualDesktopManager::self()->setCurrent(desktops.at(desktop)); } // remove virtual desktops desktop = 0; - const KWin::VirtualDesktop* deletedDesktop = desktops.last(); + const KWin::VirtualDesktop *deletedDesktop = desktops.last(); VirtualDesktopManager::self()->setCount(1); QCOMPARE(xkb->currentLayout(), layout = (desktop + 1) % xkb->numberOfLayouts()); QCOMPARE(xkb->layoutName(), QStringLiteral("German")); @@ -386,12 +396,17 @@ void KeyboardLayoutTest::testVirtualDesktopPolicy() QVERIFY(deletedDesktopSpy.isValid()); QVERIFY(deletedDesktopSpy.wait()); resetLayouts(); - QCOMPARE(layoutGroup.keyList().filter( QStringLiteral("LayoutDefault") ).count(), 1); + QCOMPARE(layoutGroup.keyList().filter(QStringLiteral("LayoutDefault")).count(), 1); } void KeyboardLayoutTest::testWindowPolicy() { - enum Layout {us, de, de_neo, bad}; + enum Layout { + us, + de, + de_neo, + bad, + }; layoutGroup.writeEntry("LayoutList", QStringLiteral("us,de,de(neo)")); layoutGroup.writeEntry("SwitchMode", QStringLiteral("Window")); layoutGroup.sync(); @@ -433,7 +448,12 @@ void KeyboardLayoutTest::testWindowPolicy() void KeyboardLayoutTest::testApplicationPolicy() { - enum Layout {us, de, de_neo, bad}; + enum Layout { + us, + de, + de_neo, + bad, + }; layoutGroup.writeEntry("LayoutList", QStringLiteral("us,de,de(neo)")); layoutGroup.writeEntry("SwitchMode", QStringLiteral("WinClass")); layoutGroup.sync(); @@ -488,7 +508,7 @@ void KeyboardLayoutTest::testApplicationPolicy() QCOMPARE(xkb->layoutName(), QStringLiteral("German (Neo 2)")); resetLayouts(); - QCOMPARE(layoutGroup.keyList().filter( QStringLiteral("LayoutDefault") ).count(), 1); + QCOMPARE(layoutGroup.keyList().filter(QStringLiteral("LayoutDefault")).count(), 1); } void KeyboardLayoutTest::testNumLock() diff --git a/autotests/integration/keymap_creation_failure_test.cpp b/autotests/integration/keymap_creation_failure_test.cpp index 7abe02eada..188993173f 100644 --- a/autotests/integration/keymap_creation_failure_test.cpp +++ b/autotests/integration/keymap_creation_failure_test.cpp @@ -7,6 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "keyboard_input.h" #include "keyboard_layout.h" @@ -46,7 +47,7 @@ void KeymapCreationFailureTest::initTestCase() qputenv("XKB_DEFAULT_VARIANT", "no"); qputenv("XKB_DEFAULT_OPTIONS", "no"); - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); diff --git a/autotests/integration/kwin_wayland_test.cpp b/autotests/integration/kwin_wayland_test.cpp index 5d299fa153..c033986173 100644 --- a/autotests/integration/kwin_wayland_test.cpp +++ b/autotests/integration/kwin_wayland_test.cpp @@ -13,9 +13,9 @@ #include "inputmethod.h" #include "platform.h" #include "pluginmanager.h" +#include "utils/xcbutils.h" #include "wayland_server.h" #include "workspace.h" -#include "utils/xcbutils.h" #include "xwl/xwayland.h" #include @@ -27,9 +27,9 @@ #include // system -#include -#include #include +#include +#include Q_IMPORT_PLUGIN(KWinIntegrationPlugin) Q_IMPORT_PLUGIN(KGlobalAccelImpl) @@ -83,7 +83,7 @@ WaylandTestApplication::~WaylandTestApplication() // need to unload all effects prior to destroying X connection as they might do X calls // also before destroy Workspace, as effects might call into Workspace if (effects) { - static_cast(effects)->unloadAllEffects(); + static_cast(effects)->unloadAllEffects(); } delete m_xwayland; m_xwayland = nullptr; diff --git a/autotests/integration/kwin_wayland_test.h b/autotests/integration/kwin_wayland_test.h index 8f71e58fdc..30efa09766 100644 --- a/autotests/integration/kwin_wayland_test.h +++ b/autotests/integration/kwin_wayland_test.h @@ -76,7 +76,8 @@ public: WaylandTestApplication(OperationMode mode, int &argc, char **argv); ~WaylandTestApplication() override; - void setInputMethodServerToStart(const QString &inputMethodServer) { + void setInputMethodServerToStart(const QString &inputMethodServer) + { m_inputMethodServerToStart = inputMethodServer; } @@ -111,14 +112,20 @@ class MockInputMethod; class TextInputManagerV3 : public QtWayland::zwp_text_input_manager_v3 { public: - ~TextInputManagerV3() override { destroy(); } + ~TextInputManagerV3() override + { + destroy(); + } }; class TextInputV3 : public QObject, public QtWayland::zwp_text_input_v3 { Q_OBJECT public: - ~TextInputV3() override { destroy(); } + ~TextInputV3() override + { + destroy(); + } Q_SIGNALS: void preeditString(const QString &text, int cursor_begin, int cursor_end); @@ -198,10 +205,10 @@ class XdgToplevel : public QObject, public QtWayland::xdg_toplevel public: enum class State { - Maximized = 1 << 0, + Maximized = 1 << 0, Fullscreen = 1 << 1, - Resizing = 1 << 2, - Activated = 1 << 3 + Resizing = 1 << 2, + Activated = 1 << 3 }; Q_DECLARE_FLAGS(States, State) @@ -608,7 +615,6 @@ XdgPopup *createXdgPopupSurface(KWayland::Client::Surface *surface, XdgSurface * XdgToplevelDecorationV1 *createXdgToplevelDecorationV1(XdgToplevel *toplevel, QObject *parent = nullptr); IdleInhibitorV1 *createIdleInhibitorV1(KWayland::Client::Surface *surface); - /** * 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. @@ -662,22 +668,22 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::Test::AdditionalWaylandInterfaces) Q_DECLARE_METATYPE(KWin::Test::XdgToplevel::States) Q_DECLARE_METATYPE(QtWayland::zxdg_toplevel_decoration_v1::mode) -#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); \ -} +#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) diff --git a/autotests/integration/kwinbindings_test.cpp b/autotests/integration/kwinbindings_test.cpp index 2a33e00e7c..dfe276837c 100644 --- a/autotests/integration/kwinbindings_test.cpp +++ b/autotests/integration/kwinbindings_test.cpp @@ -7,6 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "cursor.h" #include "input.h" @@ -42,10 +43,9 @@ private Q_SLOTS: void testWindowToDesktop(); }; - void KWinBindingsTest::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -100,7 +100,7 @@ void KWinBindingsTest::testSwitchWindow() // now let's trigger the shortcuts // invoke global shortcut through dbus - auto invokeShortcut = [] (const QString &shortcut) { + auto invokeShortcut = [](const QString &shortcut) { auto msg = QDBusMessage::createMethodCall( QStringLiteral("org.kde.kglobalaccel"), QStringLiteral("/component/kwin"), @@ -157,7 +157,7 @@ void KWinBindingsTest::testSwitchWindowScript() c3->move(QPoint(200, 200)); c4->move(QPoint(0, 200)); - auto runScript = [] (const QString &slot) { + auto runScript = [](const QString &slot) { QTemporaryFile tmpFile; QVERIFY(tmpFile.open()); QTextStream out(&tmpFile); @@ -227,7 +227,7 @@ void KWinBindingsTest::testWindowToDesktop() VirtualDesktopManager::self()->setCount(desktop); // now trigger the shortcut - auto invokeShortcut = [] (int desktop) { + auto invokeShortcut = [](int desktop) { auto msg = QDBusMessage::createMethodCall( QStringLiteral("org.kde.kglobalaccel"), QStringLiteral("/component/kwin"), diff --git a/autotests/integration/layershellv1client_test.cpp b/autotests/integration/layershellv1client_test.cpp index b157f7ba03..08f6c84373 100644 --- a/autotests/integration/layershellv1client_test.cpp +++ b/autotests/integration/layershellv1client_test.cpp @@ -5,6 +5,7 @@ */ #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "abstract_output.h" #include "main.h" @@ -84,7 +85,7 @@ void LayerShellV1ClientTest::testOutput_data() { QTest::addColumn("screenId"); - QTest::addRow("first output") << 0; + QTest::addRow("first output") << 0; QTest::addRow("second output") << 1; } @@ -127,33 +128,29 @@ void LayerShellV1ClientTest::testAnchor_data() QTest::addColumn("anchor"); QTest::addColumn("expectedGeometry"); - QTest::addRow("left") << int(Test::LayerSurfaceV1::anchor_left) - << QRect(0, 450, 280, 124); + QTest::addRow("left") << int(Test::LayerSurfaceV1::anchor_left) + << QRect(0, 450, 280, 124); - QTest::addRow("top left") << (Test::LayerSurfaceV1::anchor_top | - Test::LayerSurfaceV1::anchor_left) - << QRect(0, 0, 280, 124); + QTest::addRow("top left") << (Test::LayerSurfaceV1::anchor_top | Test::LayerSurfaceV1::anchor_left) + << QRect(0, 0, 280, 124); - QTest::addRow("top") << int(Test::LayerSurfaceV1::anchor_top) - << QRect(500, 0, 280, 124); + QTest::addRow("top") << int(Test::LayerSurfaceV1::anchor_top) + << QRect(500, 0, 280, 124); - QTest::addRow("top right") << (Test::LayerSurfaceV1::anchor_top | - Test::LayerSurfaceV1::anchor_right) - << QRect(1000, 0, 280, 124); + QTest::addRow("top right") << (Test::LayerSurfaceV1::anchor_top | Test::LayerSurfaceV1::anchor_right) + << QRect(1000, 0, 280, 124); - QTest::addRow("right") << int(Test::LayerSurfaceV1::anchor_right) - << QRect(1000, 450, 280, 124); + QTest::addRow("right") << int(Test::LayerSurfaceV1::anchor_right) + << QRect(1000, 450, 280, 124); - QTest::addRow("bottom right") << (Test::LayerSurfaceV1::anchor_bottom | - Test::LayerSurfaceV1::anchor_right) + QTest::addRow("bottom right") << (Test::LayerSurfaceV1::anchor_bottom | Test::LayerSurfaceV1::anchor_right) << QRect(1000, 900, 280, 124); - QTest::addRow("bottom") << int(Test::LayerSurfaceV1::anchor_bottom) - << QRect(500, 900, 280, 124); + QTest::addRow("bottom") << int(Test::LayerSurfaceV1::anchor_bottom) + << QRect(500, 900, 280, 124); - QTest::addRow("bottom left") << (Test::LayerSurfaceV1::anchor_bottom | - Test::LayerSurfaceV1::anchor_left) - << QRect(0, 900, 280, 124); + QTest::addRow("bottom left") << (Test::LayerSurfaceV1::anchor_bottom | Test::LayerSurfaceV1::anchor_left) + << QRect(0, 900, 280, 124); } void LayerShellV1ClientTest::testAnchor() @@ -194,41 +191,37 @@ void LayerShellV1ClientTest::testMargins_data() QTest::addColumn("margins"); QTest::addColumn("expectedGeometry"); - QTest::addRow("left") << int(Test::LayerSurfaceV1::anchor_left) - << QMargins(100, 0, 0, 0) - << QRect(100, 450, 280, 124); + QTest::addRow("left") << int(Test::LayerSurfaceV1::anchor_left) + << QMargins(100, 0, 0, 0) + << QRect(100, 450, 280, 124); - QTest::addRow("top left") << (Test::LayerSurfaceV1::anchor_top | - Test::LayerSurfaceV1::anchor_left) - << QMargins(100, 200, 0, 0) - << QRect(100, 200, 280, 124); + QTest::addRow("top left") << (Test::LayerSurfaceV1::anchor_top | Test::LayerSurfaceV1::anchor_left) + << QMargins(100, 200, 0, 0) + << QRect(100, 200, 280, 124); - QTest::addRow("top") << int(Test::LayerSurfaceV1::anchor_top) - << QMargins(0, 200, 0, 0) - << QRect(500, 200, 280, 124); + QTest::addRow("top") << int(Test::LayerSurfaceV1::anchor_top) + << QMargins(0, 200, 0, 0) + << QRect(500, 200, 280, 124); - QTest::addRow("top right") << (Test::LayerSurfaceV1::anchor_top | - Test::LayerSurfaceV1::anchor_right) - << QMargins(0, 200, 300, 0) - << QRect(700, 200, 280, 124); + QTest::addRow("top right") << (Test::LayerSurfaceV1::anchor_top | Test::LayerSurfaceV1::anchor_right) + << QMargins(0, 200, 300, 0) + << QRect(700, 200, 280, 124); - QTest::addRow("right") << int(Test::LayerSurfaceV1::anchor_right) - << QMargins(0, 0, 300, 0) - << QRect(700, 450, 280, 124); + QTest::addRow("right") << int(Test::LayerSurfaceV1::anchor_right) + << QMargins(0, 0, 300, 0) + << QRect(700, 450, 280, 124); - QTest::addRow("bottom right") << (Test::LayerSurfaceV1::anchor_bottom | - Test::LayerSurfaceV1::anchor_right) + QTest::addRow("bottom right") << (Test::LayerSurfaceV1::anchor_bottom | Test::LayerSurfaceV1::anchor_right) << QMargins(0, 0, 300, 400) << QRect(700, 500, 280, 124); - QTest::addRow("bottom") << int(Test::LayerSurfaceV1::anchor_bottom) - << QMargins(0, 0, 0, 400) - << QRect(500, 500, 280, 124); + QTest::addRow("bottom") << int(Test::LayerSurfaceV1::anchor_bottom) + << QMargins(0, 0, 0, 400) + << QRect(500, 500, 280, 124); - QTest::addRow("bottom left") << (Test::LayerSurfaceV1::anchor_bottom | - Test::LayerSurfaceV1::anchor_left) - << QMargins(100, 0, 0, 400) - << QRect(100, 500, 280, 124); + QTest::addRow("bottom left") << (Test::LayerSurfaceV1::anchor_bottom | Test::LayerSurfaceV1::anchor_left) + << QMargins(100, 0, 0, 400) + << QRect(100, 500, 280, 124); } void LayerShellV1ClientTest::testMargins() @@ -269,9 +262,9 @@ void LayerShellV1ClientTest::testLayer_data() QTest::addColumn("protocolLayer"); QTest::addColumn("compositorLayer"); - QTest::addRow("overlay") << int(Test::LayerShellV1::layer_overlay) << UnmanagedLayer; - QTest::addRow("top") << int(Test::LayerShellV1::layer_top) << AboveLayer; - QTest::addRow("bottom") << int(Test::LayerShellV1::layer_bottom) << BelowLayer; + QTest::addRow("overlay") << int(Test::LayerShellV1::layer_overlay) << UnmanagedLayer; + QTest::addRow("top") << int(Test::LayerShellV1::layer_top) << AboveLayer; + QTest::addRow("bottom") << int(Test::LayerShellV1::layer_bottom) << BelowLayer; QTest::addRow("background") << int(Test::LayerShellV1::layer_background) << DesktopLayer; } @@ -312,9 +305,9 @@ void LayerShellV1ClientTest::testPlacementArea_data() QTest::addColumn("exclusiveZone"); QTest::addColumn("placementArea"); - QTest::addRow("left") << int(Test::LayerSurfaceV1::anchor_left) << 300 << QRect(300, 0, 980, 1024); - QTest::addRow("top") << int(Test::LayerSurfaceV1::anchor_top) << 300 << QRect(0, 300, 1280, 724); - QTest::addRow("right") << int(Test::LayerSurfaceV1::anchor_right) << 300 << QRect(0, 0, 980, 1024); + QTest::addRow("left") << int(Test::LayerSurfaceV1::anchor_left) << 300 << QRect(300, 0, 980, 1024); + QTest::addRow("top") << int(Test::LayerSurfaceV1::anchor_top) << 300 << QRect(0, 300, 1280, 724); + QTest::addRow("right") << int(Test::LayerSurfaceV1::anchor_right) << 300 << QRect(0, 0, 980, 1024); QTest::addRow("bottom") << int(Test::LayerSurfaceV1::anchor_bottom) << 300 << QRect(0, 0, 1280, 724); } @@ -357,22 +350,17 @@ void LayerShellV1ClientTest::testFill_data() QTest::addColumn("desiredSize"); QTest::addColumn("expectedGeometry"); - QTest::addRow("horizontal") << (Test::LayerSurfaceV1::anchor_left | - Test::LayerSurfaceV1::anchor_right) + QTest::addRow("horizontal") << (Test::LayerSurfaceV1::anchor_left | Test::LayerSurfaceV1::anchor_right) << QSize(0, 124) << QRect(0, 450, 1280, 124); - QTest::addRow("vertical") << (Test::LayerSurfaceV1::anchor_top | - Test::LayerSurfaceV1::anchor_bottom) - << QSize(280, 0) - << QRect(500, 0, 280, 1024); + QTest::addRow("vertical") << (Test::LayerSurfaceV1::anchor_top | Test::LayerSurfaceV1::anchor_bottom) + << QSize(280, 0) + << QRect(500, 0, 280, 1024); - QTest::addRow("all") << (Test::LayerSurfaceV1::anchor_left | - Test::LayerSurfaceV1::anchor_top | - Test::LayerSurfaceV1::anchor_right | - Test::LayerSurfaceV1::anchor_bottom) - << QSize(0, 0) - << QRect(0, 0, 1280, 1024); + QTest::addRow("all") << (Test::LayerSurfaceV1::anchor_left | Test::LayerSurfaceV1::anchor_top | Test::LayerSurfaceV1::anchor_right | Test::LayerSurfaceV1::anchor_bottom) + << QSize(0, 0) + << QRect(0, 0, 1280, 1024); } void LayerShellV1ClientTest::testFill() @@ -493,9 +481,9 @@ void LayerShellV1ClientTest::testActivate_data() QTest::addColumn("layer"); QTest::addColumn("active"); - QTest::addRow("overlay") << int(Test::LayerShellV1::layer_overlay) << true; - QTest::addRow("top") << int(Test::LayerShellV1::layer_top) << true; - QTest::addRow("bottom") << int(Test::LayerShellV1::layer_bottom) << false; + QTest::addRow("overlay") << int(Test::LayerShellV1::layer_overlay) << true; + QTest::addRow("top") << int(Test::LayerShellV1::layer_top) << true; + QTest::addRow("bottom") << int(Test::LayerShellV1::layer_bottom) << false; QTest::addRow("background") << int(Test::LayerShellV1::layer_background) << false; } diff --git a/autotests/integration/lockscreen.cpp b/autotests/integration/lockscreen.cpp index 4b2da369da..0d1f51d77a 100644 --- a/autotests/integration/lockscreen.cpp +++ b/autotests/integration/lockscreen.cpp @@ -7,22 +7,23 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" -#include "abstract_output.h" -#include "platform.h" + #include "abstract_client.h" +#include "abstract_output.h" #include "composite.h" #include "cursor.h" +#include "platform.h" #include "renderbackend.h" #include "screenedge.h" #include "wayland_server.h" #include "workspace.h" #include -#include #include +#include #include -#include #include +#include #include #include #include @@ -30,7 +31,7 @@ #include #include -//screenlocker +// screenlocker #include #include @@ -80,41 +81,48 @@ class HelperEffect : public Effect { Q_OBJECT public: - HelperEffect() {} - ~HelperEffect() override {} + HelperEffect() + { + } + ~HelperEffect() override + { + } - void windowInputMouseEvent(QEvent*) override { + void windowInputMouseEvent(QEvent *) override + { Q_EMIT inputEvent(); } - void grabbedKeyboardEvent(QKeyEvent *e) override { + void grabbedKeyboardEvent(QKeyEvent *e) override + { Q_EMIT keyEvent(e->text()); } Q_SIGNALS: void inputEvent(); - void keyEvent(const QString&); + 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 LOCK \ + do { \ + 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()); \ + } while (false) -#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 UNLOCK \ + do { \ + QSignalSpy lockStateChangedSpy(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged); \ + QVERIFY(lockStateChangedSpy.isValid()); \ + unlock(); \ + if (lockStateChangedSpy.count() != 1) { \ + QVERIFY(lockStateChangedSpy.wait()); \ + } \ + QCOMPARE(lockStateChangedSpy.count(), 1); \ + QVERIFY(!waylandServer()->isScreenLocked()); \ + } while (false) #define MOTION(target) Test::pointerMotion(target, timestamp++) @@ -142,11 +150,11 @@ void LockScreenTest::unlock() AbstractClient *LockScreenTest::showWindow() { using namespace KWayland::Client; -#define VERIFY(statement) \ - if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__))\ +#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__))\ +#define COMPARE(actual, expected) \ + if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__)) \ return nullptr; KWayland::Client::Surface *surface = Test::createSurface(m_compositor); @@ -167,7 +175,7 @@ AbstractClient *LockScreenTest::showWindow() void LockScreenTest::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -212,7 +220,7 @@ void LockScreenTest::testStackingOrder() QSignalSpy clientAddedSpy(workspace(), &Workspace::clientAdded); QVERIFY(clientAddedSpy.isValid()); - LOCK + LOCK; QVERIFY(clientAddedSpy.wait()); AbstractClient *client = clientAddedSpy.first().first().value(); @@ -220,7 +228,7 @@ void LockScreenTest::testStackingOrder() QVERIFY(client->isLockScreen()); QCOMPARE(client->layer(), UnmanagedLayer); - UNLOCK + UNLOCK; } void LockScreenTest::testPointer() @@ -242,7 +250,7 @@ void LockScreenTest::testPointer() MOTION(c->frameGeometry().center()); QVERIFY(enteredSpy.wait()); - LOCK + LOCK; QVERIFY(leftSpy.wait()); QCOMPARE(leftSpy.count(), 1); @@ -258,7 +266,7 @@ void LockScreenTest::testPointer() // go back on the window MOTION(c->frameGeometry().center()); // and unlock - UNLOCK + UNLOCK; QVERIFY(enteredSpy.wait()); QCOMPARE(enteredSpy.count(), 2); @@ -294,7 +302,7 @@ void LockScreenTest::testPointerButton() RELEASE; QVERIFY(buttonChangedSpy.wait()); - LOCK + LOCK; // and simulate a click PRESS; @@ -302,7 +310,7 @@ void LockScreenTest::testPointerButton() RELEASE; QVERIFY(!buttonChangedSpy.wait()); - UNLOCK + UNLOCK; QVERIFY(enteredSpy.wait()); QCOMPARE(enteredSpy.count(), 2); @@ -335,16 +343,16 @@ void LockScreenTest::testPointerAxis() Test::pointerAxisHorizontal(5.0, timestamp++); QVERIFY(axisChangedSpy.wait()); - LOCK + LOCK; - // and simulate axis - Test::pointerAxisHorizontal(5.0, timestamp++); + // and simulate axis + Test::pointerAxisHorizontal(5.0, timestamp++); QVERIFY(!axisChangedSpy.wait(100)); Test::pointerAxisVertical(5.0, timestamp++); QVERIFY(!axisChangedSpy.wait(100)); // and unlock - UNLOCK + UNLOCK; QVERIFY(enteredSpy.wait()); QCOMPARE(enteredSpy.count(), 2); @@ -387,14 +395,14 @@ void LockScreenTest::testKeyboard() QCOMPARE(keyChangedSpy.at(1).at(1).value(), Keyboard::KeyState::Released); QCOMPARE(keyChangedSpy.at(1).at(2).value(), quint32(2)); - LOCK + LOCK; QVERIFY(leftSpy.wait()); KEYPRESS(KEY_B); KEYRELEASE(KEY_B); QCOMPARE(leftSpy.count(), 1); QCOMPARE(keyChangedSpy.count(), 2); - UNLOCK + UNLOCK; QVERIFY(enteredSpy.wait()); QCOMPARE(enteredSpy.count(), 2); KEYPRESS(KEY_C); @@ -422,13 +430,13 @@ void LockScreenTest::testScreenEdge() MOTION(QPoint(5, 5)); QCOMPARE(screenEdgeSpy.count(), 1); - LOCK + LOCK; MOTION(QPoint(4, 4)); QCOMPARE(screenEdgeSpy.count(), 1); // and unlock - UNLOCK + UNLOCK; MOTION(QPoint(5, 5)); QCOMPARE(screenEdgeSpy.count(), 2); @@ -451,7 +459,7 @@ void LockScreenTest::testEffects() RELEASE; QCOMPARE(inputSpy.count(), 3); - LOCK + LOCK; MOTION(QPoint(6, 6)); QCOMPARE(inputSpy.count(), 3); @@ -461,7 +469,7 @@ void LockScreenTest::testEffects() RELEASE; QCOMPARE(inputSpy.count(), 3); - UNLOCK + UNLOCK; MOTION(QPoint(5, 5)); QCOMPARE(inputSpy.count(), 4); @@ -490,13 +498,13 @@ void LockScreenTest::testEffectsKeyboard() QCOMPARE(inputSpy.first().first().toString(), QStringLiteral("a")); QCOMPARE(inputSpy.at(1).first().toString(), QStringLiteral("a")); - LOCK + LOCK; KEYPRESS(KEY_B); QCOMPARE(inputSpy.count(), 2); KEYRELEASE(KEY_B); QCOMPARE(inputSpy.count(), 2); - UNLOCK + UNLOCK; KEYPRESS(KEY_C); QCOMPARE(inputSpy.count(), 3); QCOMPARE(inputSpy.first().first().toString(), QStringLiteral("a")); @@ -541,13 +549,13 @@ void LockScreenTest::testEffectsKeyboardAutorepeat() QCOMPARE(inputSpy.count(), 1); // while locked key repeat should not pass any events to the Effect - LOCK + LOCK; KEYPRESS(KEY_B); QVERIFY(!inputSpy.wait(200)); KEYRELEASE(KEY_B); QVERIFY(!inputSpy.wait(200)); - UNLOCK + UNLOCK; // don't test again, that's covered by testEffectsKeyboard effects->ungrabKeyboard(); @@ -576,14 +584,14 @@ void LockScreenTest::testMoveWindow() QCOMPARE(clientStepUserMovedResizedSpy.count(), 1); // while locking our window should continue to be in move resize - LOCK + LOCK; QCOMPARE(workspace()->moveResizeClient(), c); QVERIFY(c->isInteractiveMove()); Test::keyboardKeyPressed(KEY_RIGHT, timestamp++); Test::keyboardKeyReleased(KEY_RIGHT, timestamp++); QCOMPARE(clientStepUserMovedResizedSpy.count(), 1); - UNLOCK + UNLOCK; QCOMPARE(workspace()->moveResizeClient(), c); QVERIFY(c->isInteractiveMove()); Test::keyboardKeyPressed(KEY_RIGHT, timestamp++); @@ -604,29 +612,30 @@ void LockScreenTest::testPointerShortcut() // try to trigger the shortcut quint32 timestamp = 1; -#define PERFORM(expectedCount) \ - Test::keyboardKeyPressed(KEY_LEFTMETA, timestamp++); \ - PRESS; \ - QCoreApplication::instance()->processEvents(); \ - QCOMPARE(actionSpy.count(), expectedCount); \ - RELEASE; \ - Test::keyboardKeyReleased(KEY_LEFTMETA, timestamp++); \ - QCoreApplication::instance()->processEvents(); \ - QCOMPARE(actionSpy.count(), expectedCount); +#define PERFORM(expectedCount) \ + do { \ + Test::keyboardKeyPressed(KEY_LEFTMETA, timestamp++); \ + PRESS; \ + QCoreApplication::instance()->processEvents(); \ + QCOMPARE(actionSpy.count(), expectedCount); \ + RELEASE; \ + Test::keyboardKeyReleased(KEY_LEFTMETA, timestamp++); \ + QCoreApplication::instance()->processEvents(); \ + QCOMPARE(actionSpy.count(), expectedCount); \ + } while (false) - PERFORM(1) + PERFORM(1); // now the same thing with a locked screen - LOCK - PERFORM(1) + LOCK; + PERFORM(1); // and as unlocked - UNLOCK - PERFORM(2) + UNLOCK; + PERFORM(2); #undef PERFORM } - void LockScreenTest::testAxisShortcut_data() { QTest::addColumn("direction"); @@ -656,27 +665,29 @@ void LockScreenTest::testAxisShortcut() // try to trigger the shortcut quint32 timestamp = 1; -#define PERFORM(expectedCount) \ - Test::keyboardKeyPressed(KEY_LEFTMETA, timestamp++); \ - if (direction == Qt::Vertical) \ - Test::pointerAxisVertical(sign * 5.0, timestamp++); \ - else \ - Test::pointerAxisHorizontal(sign * 5.0, timestamp++); \ - QCoreApplication::instance()->processEvents(); \ - QCOMPARE(actionSpy.count(), expectedCount); \ - Test::keyboardKeyReleased(KEY_LEFTMETA, timestamp++); \ - QCoreApplication::instance()->processEvents(); \ - QCOMPARE(actionSpy.count(), expectedCount); +#define PERFORM(expectedCount) \ + do { \ + Test::keyboardKeyPressed(KEY_LEFTMETA, timestamp++); \ + if (direction == Qt::Vertical) \ + Test::pointerAxisVertical(sign * 5.0, timestamp++); \ + else \ + Test::pointerAxisHorizontal(sign * 5.0, timestamp++); \ + QCoreApplication::instance()->processEvents(); \ + QCOMPARE(actionSpy.count(), expectedCount); \ + Test::keyboardKeyReleased(KEY_LEFTMETA, timestamp++); \ + QCoreApplication::instance()->processEvents(); \ + QCOMPARE(actionSpy.count(), expectedCount); \ + } while (false) - PERFORM(1) + PERFORM(1); // now the same thing with a locked screen - LOCK - PERFORM(1) + LOCK; + PERFORM(1); // and as unlocked - UNLOCK - PERFORM(2) + UNLOCK; + PERFORM(2); #undef PERFORM } @@ -690,7 +701,7 @@ void LockScreenTest::testKeyboardShortcut() 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); + KGlobalAccel::NoAutoloading); // try to trigger the shortcut quint32 timestamp = 1; @@ -704,7 +715,7 @@ void LockScreenTest::testKeyboardShortcut() QVERIFY(!actionSpy.wait()); QCOMPARE(actionSpy.count(), 1); - LOCK + LOCK; KEYPRESS(KEY_SPACE); QVERIFY(!actionSpy.wait()); QCOMPARE(actionSpy.count(), 1); @@ -712,7 +723,7 @@ void LockScreenTest::testKeyboardShortcut() QVERIFY(!actionSpy.wait()); QCOMPARE(actionSpy.count(), 1); - UNLOCK + UNLOCK; KEYPRESS(KEY_SPACE); QVERIFY(actionSpy.wait()); QCOMPARE(actionSpy.count(), 2); @@ -744,7 +755,7 @@ void LockScreenTest::testTouch() QVERIFY(sequenceStartedSpy.wait()); QCOMPARE(sequenceStartedSpy.count(), 1); - LOCK + LOCK; QVERIFY(cancelSpy.wait()); Test::touchUp(1, timestamp++); @@ -753,7 +764,7 @@ void LockScreenTest::testTouch() Test::touchMotion(1, QPointF(26, 26), timestamp++); Test::touchUp(1, timestamp++); - UNLOCK + UNLOCK; Test::touchDown(1, QPointF(25, 25), timestamp++); QVERIFY(sequenceStartedSpy.wait()); QCOMPARE(sequenceStartedSpy.count(), 2); diff --git a/autotests/integration/maximize_test.cpp b/autotests/integration/maximize_test.cpp index 7e0adcce5f..964b15f991 100644 --- a/autotests/integration/maximize_test.cpp +++ b/autotests/integration/maximize_test.cpp @@ -7,6 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "abstract_output.h" #include "cursor.h" @@ -17,9 +18,9 @@ #include "workspace.h" #include +#include #include #include -#include #include #include @@ -46,7 +47,7 @@ private Q_SLOTS: void TestMaximized::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -66,8 +67,7 @@ void TestMaximized::initTestCase() void TestMaximized::init() { - QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::XdgDecorationV1 | - Test::AdditionalWaylandInterface::PlasmaShell)); + QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::XdgDecorationV1 | Test::AdditionalWaylandInterface::PlasmaShell)); workspace()->setActiveOutput(QPoint(640, 512)); KWin::Cursors::self()->mouse()->setPos(QPoint(640, 512)); diff --git a/autotests/integration/modifier_only_shortcut_test.cpp b/autotests/integration/modifier_only_shortcut_test.cpp index 82909bb689..761dcc2e08 100644 --- a/autotests/integration/modifier_only_shortcut_test.cpp +++ b/autotests/integration/modifier_only_shortcut_test.cpp @@ -7,7 +7,9 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include + #include "kwin_wayland_test.h" + #include "cursor.h" #include "input.h" #include "keyboard_input.h" @@ -122,7 +124,7 @@ void ModifierOnlyShortcutTest::testTrigger_data() 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}; + QTest::newRow("rightShift") << e << e << e << trigger << KEY_RIGHTSHIFT << QList{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTMETA, KEY_RIGHTMETA}; } void ModifierOnlyShortcutTest::testTrigger() @@ -322,7 +324,7 @@ void ModifierOnlyShortcutTest::testGlobalShortcutsDisabled_data() 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 < #include -#include +#include #include +#include #include #include @@ -320,10 +321,10 @@ void MoveResizeWindowTest::testPackTo_data() QTest::addColumn("methodCall"); QTest::addColumn("expectedGeometry"); - QTest::newRow("left") << QStringLiteral("slotWindowMoveLeft") << QRect(0, 487, 100, 50); - QTest::newRow("up") << QStringLiteral("slotWindowMoveUp") << QRect(590, 0, 100, 50); + QTest::newRow("left") << QStringLiteral("slotWindowMoveLeft") << QRect(0, 487, 100, 50); + QTest::newRow("up") << QStringLiteral("slotWindowMoveUp") << QRect(590, 0, 100, 50); QTest::newRow("right") << QStringLiteral("slotWindowMoveRight") << QRect(1180, 487, 100, 50); - QTest::newRow("down") << QStringLiteral("slotWindowMoveDown") << QRect(590, 974, 100, 50); + QTest::newRow("down") << QStringLiteral("slotWindowMoveDown") << QRect(590, 974, 100, 50); } void MoveResizeWindowTest::testPackTo() @@ -358,10 +359,10 @@ void MoveResizeWindowTest::testPackAgainstClient_data() QTest::addColumn("methodCall"); QTest::addColumn("expectedGeometry"); - QTest::newRow("left") << QStringLiteral("slotWindowMoveLeft") << QRect(10, 487, 100, 50); - QTest::newRow("up") << QStringLiteral("slotWindowMoveUp") << QRect(590, 10, 100, 50); + QTest::newRow("left") << QStringLiteral("slotWindowMoveLeft") << QRect(10, 487, 100, 50); + QTest::newRow("up") << QStringLiteral("slotWindowMoveUp") << QRect(590, 10, 100, 50); QTest::newRow("right") << QStringLiteral("slotWindowMoveRight") << QRect(1170, 487, 100, 50); - QTest::newRow("down") << QStringLiteral("slotWindowMoveDown") << QRect(590, 964, 100, 50); + QTest::newRow("down") << QStringLiteral("slotWindowMoveDown") << QRect(590, 964, 100, 50); } void MoveResizeWindowTest::testPackAgainstClient() @@ -385,7 +386,7 @@ void MoveResizeWindowTest::testPackAgainstClient() QVERIFY(!shellSurface3.isNull()); QScopedPointer shellSurface4(Test::createXdgToplevelSurface(surface4.data())); QVERIFY(!shellSurface4.isNull()); - auto renderWindow = [] (KWayland::Client::Surface *surface, const QString &methodCall, const QRect &expectedGeometry) { + auto renderWindow = [](KWayland::Client::Surface *surface, const QString &methodCall, const QRect &expectedGeometry) { // let's render auto c = Test::renderAndWaitForShown(surface, QSize(10, 10), Qt::blue); @@ -398,10 +399,10 @@ void MoveResizeWindowTest::testPackAgainstClient() QMetaObject::invokeMethod(workspace(), methodCall.toLocal8Bit().constData()); QCOMPARE(c->frameGeometry(), expectedGeometry); }; - renderWindow(surface1.data(), QStringLiteral("slotWindowMoveLeft"), QRect(0, 507, 10, 10)); - renderWindow(surface2.data(), QStringLiteral("slotWindowMoveUp"), QRect(635, 0, 10, 10)); + renderWindow(surface1.data(), QStringLiteral("slotWindowMoveLeft"), QRect(0, 507, 10, 10)); + renderWindow(surface2.data(), QStringLiteral("slotWindowMoveUp"), QRect(635, 0, 10, 10)); renderWindow(surface3.data(), QStringLiteral("slotWindowMoveRight"), QRect(1270, 507, 10, 10)); - renderWindow(surface4.data(), QStringLiteral("slotWindowMoveDown"), QRect(635, 1014, 10, 10)); + renderWindow(surface4.data(), QStringLiteral("slotWindowMoveDown"), QRect(635, 1014, 10, 10)); QScopedPointer surface(Test::createSurface()); QVERIFY(!surface.isNull()); @@ -425,9 +426,9 @@ void MoveResizeWindowTest::testGrowShrink_data() QTest::addColumn("methodCall"); QTest::addColumn("expectedGeometry"); - QTest::newRow("grow vertical") << QStringLiteral("slotWindowExpandVertical") << QRect(590, 487, 100, 537); - QTest::newRow("grow horizontal") << QStringLiteral("slotWindowExpandHorizontal") << QRect(590, 487, 690, 50); - QTest::newRow("shrink vertical") << QStringLiteral("slotWindowShrinkVertical") << QRect(590, 487, 100, 23); + QTest::newRow("grow vertical") << QStringLiteral("slotWindowExpandVertical") << QRect(590, 487, 100, 537); + QTest::newRow("grow horizontal") << QStringLiteral("slotWindowExpandHorizontal") << QRect(590, 487, 690, 50); + QTest::newRow("shrink vertical") << QStringLiteral("slotWindowShrinkVertical") << QRect(590, 487, 100, 23); QTest::newRow("shrink horizontal") << QStringLiteral("slotWindowShrinkHorizontal") << QRect(590, 487, 40, 50); } @@ -481,14 +482,14 @@ void MoveResizeWindowTest::testPointerMoveEnd_data() { QTest::addColumn("additionalButton"); - QTest::newRow("BTN_RIGHT") << BTN_RIGHT; - QTest::newRow("BTN_MIDDLE") << BTN_MIDDLE; - QTest::newRow("BTN_SIDE") << BTN_SIDE; - QTest::newRow("BTN_EXTRA") << BTN_EXTRA; + QTest::newRow("BTN_RIGHT") << BTN_RIGHT; + QTest::newRow("BTN_MIDDLE") << BTN_MIDDLE; + QTest::newRow("BTN_SIDE") << BTN_SIDE; + QTest::newRow("BTN_EXTRA") << BTN_EXTRA; QTest::newRow("BTN_FORWARD") << BTN_FORWARD; - QTest::newRow("BTN_BACK") << BTN_BACK; - QTest::newRow("BTN_TASK") << BTN_TASK; - for (int i=BTN_TASK + 1; i < BTN_JOYSTICK; i++) { + QTest::newRow("BTN_BACK") << BTN_BACK; + QTest::newRow("BTN_TASK") << BTN_TASK; + for (int i = BTN_TASK + 1; i < BTN_JOYSTICK; i++) { QTest::newRow(QByteArray::number(i, 16).constData()) << i; } } @@ -589,10 +590,10 @@ void MoveResizeWindowTest::testPlasmaShellSurfaceMovable_data() QTest::addColumn("movableAcrossScreens"); QTest::addColumn("resizable"); - QTest::newRow("normal") << KWayland::Client::PlasmaShellSurface::Role::Normal << true << true << true; - QTest::newRow("desktop") << KWayland::Client::PlasmaShellSurface::Role::Desktop << false << false << false; - QTest::newRow("panel") << KWayland::Client::PlasmaShellSurface::Role::Panel << false << false << false; - QTest::newRow("osd") << KWayland::Client::PlasmaShellSurface::Role::OnScreenDisplay << false << false << false; + QTest::newRow("normal") << KWayland::Client::PlasmaShellSurface::Role::Normal << true << true << true; + QTest::newRow("desktop") << KWayland::Client::PlasmaShellSurface::Role::Desktop << false << false << false; + QTest::newRow("panel") << KWayland::Client::PlasmaShellSurface::Role::Panel << false << false << false; + QTest::newRow("osd") << KWayland::Client::PlasmaShellSurface::Role::OnScreenDisplay << false << false << false; } void MoveResizeWindowTest::testPlasmaShellSurfaceMovable() @@ -710,7 +711,7 @@ void MoveResizeWindowTest::testAdjustClientGeometryOfAutohidingX11Panel_data() QTest::addColumn("hideLocation"); QTest::newRow("top") << QRect(0, 0, 100, 20) << QPoint(50, 25) << QPoint(50, 20) << 0u; - QTest::newRow("bottom") << QRect(0, 1024-20, 100, 20) << QPoint(50, 1024 - 25 - 50) << QPoint(50, 1024 - 20 - 50) << 2u; + QTest::newRow("bottom") << QRect(0, 1024 - 20, 100, 20) << QPoint(50, 1024 - 25 - 50) << QPoint(50, 1024 - 20 - 50) << 2u; QTest::newRow("left") << QRect(0, 0, 20, 100) << QPoint(25, 50) << QPoint(20, 50) << 3u; QTest::newRow("right") << QRect(1280 - 20, 0, 20, 100) << QPoint(1280 - 25 - 100, 50) << QPoint(1280 - 20 - 100, 50) << 1u; } @@ -802,7 +803,7 @@ void MoveResizeWindowTest::testAdjustClientGeometryOfAutohidingWaylandPanel_data QTest::addColumn("expectedAdjustedPoint"); QTest::newRow("top") << QRect(0, 0, 100, 20) << QPoint(50, 25) << QPoint(50, 20); - QTest::newRow("bottom") << QRect(0, 1024-20, 100, 20) << QPoint(50, 1024 - 25 - 50) << QPoint(50, 1024 - 20 - 50); + QTest::newRow("bottom") << QRect(0, 1024 - 20, 100, 20) << QPoint(50, 1024 - 25 - 50) << QPoint(50, 1024 - 20 - 50); QTest::newRow("left") << QRect(0, 0, 20, 100) << QPoint(25, 50) << QPoint(20, 50); QTest::newRow("right") << QRect(1280 - 20, 0, 20, 100) << QPoint(1280 - 25 - 100, 50) << QPoint(1280 - 20 - 100, 50); } diff --git a/autotests/integration/nightcolor_test.cpp b/autotests/integration/nightcolor_test.cpp index f5bccf13f9..20eb339710 100644 --- a/autotests/integration/nightcolor_test.cpp +++ b/autotests/integration/nightcolor_test.cpp @@ -7,11 +7,11 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" -#include "platform.h" -#include "wayland_server.h" -#include "plugins/nightcolor/nightcolormanager.h" +#include "platform.h" #include "plugins/nightcolor/constants.h" +#include "plugins/nightcolor/nightcolormanager.h" +#include "wayland_server.h" #include @@ -102,7 +102,6 @@ void NightColorTest::testConfigRead() } else { QCOMPARE(manager->mode(), mode); } - } WAYLANDTEST_MAIN(NightColorTest) diff --git a/autotests/integration/no_global_shortcuts_test.cpp b/autotests/integration/no_global_shortcuts_test.cpp index 4f037623bf..11ce7cbebc 100644 --- a/autotests/integration/no_global_shortcuts_test.cpp +++ b/autotests/integration/no_global_shortcuts_test.cpp @@ -7,6 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "cursor.h" #include "input.h" #include "keyboard_input.h" @@ -131,7 +132,7 @@ void NoGlobalShortcutsTest::testTrigger_data() 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}; + QTest::newRow("rightShift") << e << e << e << trigger << KEY_RIGHTSHIFT << QList{KEY_LEFTALT, KEY_RIGHTALT, KEY_LEFTCTRL, KEY_RIGHTCTRL, KEY_LEFTMETA, KEY_RIGHTMETA}; } void NoGlobalShortcutsTest::testTrigger() diff --git a/autotests/integration/outputchanges_test.cpp b/autotests/integration/outputchanges_test.cpp index 5d169c3ced..1a6c40b768 100644 --- a/autotests/integration/outputchanges_test.cpp +++ b/autotests/integration/outputchanges_test.cpp @@ -10,8 +10,8 @@ #include "abstract_output.h" #include "cursor.h" #include "platform.h" -#include "waylandoutputconfig.h" #include "wayland_server.h" +#include "waylandoutputconfig.h" #include "workspace.h" #include diff --git a/autotests/integration/placement_test.cpp b/autotests/integration/placement_test.cpp index 2524e620f8..aa66b09552 100644 --- a/autotests/integration/placement_test.cpp +++ b/autotests/integration/placement_test.cpp @@ -7,10 +7,11 @@ SPDX-License-Identifier: GPL-2.0-or-later */ +#include "kwin_wayland_test.h" + #include "abstract_client.h" #include "abstract_output.h" #include "cursor.h" -#include "kwin_wayland_test.h" #include "platform.h" #include "screens.h" #include "wayland_server.h" @@ -77,7 +78,7 @@ void TestPlacement::cleanup() void TestPlacement::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -136,7 +137,7 @@ void TestPlacement::testPlaceSmart() { setPlacementPolicy(Placement::Smart); - QScopedPointer testParent(new QObject); //dumb QObject just for scoping surfaces to the test + QScopedPointer testParent(new QObject); // dumb QObject just for scoping surfaces to the test QRegion usedArea; @@ -166,7 +167,7 @@ void TestPlacement::testPlaceZeroCornered() QCOMPARE(windowPlacement.initiallyConfiguredSize, QSize(0, 0)); // size should match our buffer QCOMPARE(windowPlacement.finalGeometry.size(), QSize(600, 500)); - //and it should be in the corner + // and it should be in the corner QCOMPARE(windowPlacement.finalGeometry.topLeft(), QPoint(0, 0)); } } @@ -225,7 +226,7 @@ void TestPlacement::testPlaceMaximizedLeavesFullscreen() auto c = Test::renderAndWaitForShown(surface, initiallyConfiguredSize, Qt::red); QVERIFY(initiallyConfiguredStates & Test::XdgToplevel::State::Fullscreen); - QCOMPARE(initiallyConfiguredSize, QSize(1280, 1024 )); + QCOMPARE(initiallyConfiguredSize, QSize(1280, 1024)); QCOMPARE(c->frameGeometry(), QRect(0, 0, 1280, 1024)); } } diff --git a/autotests/integration/plasma_surface_test.cpp b/autotests/integration/plasma_surface_test.cpp index 3ddbe97c4d..2886cd0e2f 100644 --- a/autotests/integration/plasma_surface_test.cpp +++ b/autotests/integration/plasma_surface_test.cpp @@ -7,16 +7,17 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "abstract_output.h" -#include "platform.h" #include "cursor.h" +#include "platform.h" #include "screens.h" #include "virtualdesktops.h" #include "wayland_server.h" #include "workspace.h" -#include #include +#include #include #include #include @@ -240,7 +241,6 @@ void PlasmaSurfaceTest::testOSDPlacementManualPosition() QCOMPARE(c->frameGeometry(), QRect(50, 70, 100, 50)); } - void PlasmaSurfaceTest::testPanelTypeHasStrut_data() { QTest::addColumn("panelBehavior"); diff --git a/autotests/integration/plasmawindow_test.cpp b/autotests/integration/plasmawindow_test.cpp index f5c2db9bad..45e2f267aa 100644 --- a/autotests/integration/plasmawindow_test.cpp +++ b/autotests/integration/plasmawindow_test.cpp @@ -7,19 +7,20 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_output.h" -#include "platform.h" -#include "x11client.h" #include "cursor.h" +#include "platform.h" #include "wayland_server.h" #include "workspace.h" +#include "x11client.h" #include #include #include #include #include -//screenlocker +// screenlocker #if KWIN_BUILD_SCREENLOCKER #include #endif @@ -57,7 +58,7 @@ private: void PlasmaWindowTest::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -307,7 +308,7 @@ void PlasmaWindowTest::testDestroyedButNotUnmapped() // this should create a plasma window QVERIFY(plasmaWindowCreatedSpy.wait()); QCOMPARE(plasmaWindowCreatedSpy.count(), 1); - auto window = plasmaWindowCreatedSpy.first().first().value(); + auto window = plasmaWindowCreatedSpy.first().first().value(); QVERIFY(window); QSignalSpy destroyedSpy(window, &QObject::destroyed); QVERIFY(destroyedSpy.isValid()); diff --git a/autotests/integration/platformcursor.cpp b/autotests/integration/platformcursor.cpp index c67ef55286..9499648424 100644 --- a/autotests/integration/platformcursor.cpp +++ b/autotests/integration/platformcursor.cpp @@ -7,6 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "cursor.h" #include "platform.h" #include "wayland_server.h" diff --git a/autotests/integration/pointer_constraints_test.cpp b/autotests/integration/pointer_constraints_test.cpp index 92af1ce2f6..26821bfab8 100644 --- a/autotests/integration/pointer_constraints_test.cpp +++ b/autotests/integration/pointer_constraints_test.cpp @@ -7,6 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "abstract_output.h" #include "cursor.h" @@ -34,7 +35,7 @@ using namespace KWin; using namespace KWayland::Client; -typedef std::function PointerFunc; +typedef std::function PointerFunc; Q_DECLARE_METATYPE(PointerFunc) static const QString s_socketName = QStringLiteral("wayland_test_kwin_pointer_constraints-0"); @@ -56,7 +57,7 @@ private Q_SLOTS: void TestPointerConstraints::initTestCase() { qRegisterMetaType(); - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -71,7 +72,6 @@ void TestPointerConstraints::initTestCase() kwinApp()->setConfig(config); - kwinApp()->start(); QVERIFY(applicationStartedSpy.wait()); const auto outputs = kwinApp()->platform()->enabledOutputs(); @@ -105,10 +105,10 @@ void TestPointerConstraints::testConfinedPointer_data() PointerFunc topRight = &QRect::topRight; PointerFunc topLeft = &QRect::topLeft; - QTest::newRow("XdgWmBase - bottomLeft") << bottomLeft << -1 << 1; - QTest::newRow("XdgWmBase - bottomRight") << bottomRight << 1 << 1; - QTest::newRow("XdgWmBase - topLeft") << topLeft << -1 << -1; - QTest::newRow("XdgWmBase - topRight") << topRight << 1 << -1; + QTest::newRow("XdgWmBase - bottomLeft") << bottomLeft << -1 << 1; + QTest::newRow("XdgWmBase - bottomRight") << bottomRight << 1 << 1; + QTest::newRow("XdgWmBase - topLeft") << topLeft << -1 << -1; + QTest::newRow("XdgWmBase - topRight") << topRight << 1 << -1; } void TestPointerConstraints::testConfinedPointer() @@ -208,7 +208,7 @@ void TestPointerConstraints::testConfinedPointer() QVERIFY(unconfinedSpy2.isValid()); // activate it again, this confines again - workspace()->activateClient(static_cast(input()->pointer()->focus())); + workspace()->activateClient(static_cast(input()->pointer()->focus())); QVERIFY(confinedSpy2.wait()); QCOMPARE(input()->pointer()->isConstrained(), true); @@ -217,7 +217,7 @@ void TestPointerConstraints::testConfinedPointer() QVERIFY(unconfinedSpy2.wait()); QCOMPARE(input()->pointer()->isConstrained(), false); // activate it again, this confines again - workspace()->activateClient(static_cast(input()->pointer()->focus())); + workspace()->activateClient(static_cast(input()->pointer()->focus())); QVERIFY(confinedSpy2.wait()); QCOMPARE(input()->pointer()->isConstrained(), true); @@ -314,7 +314,7 @@ void TestPointerConstraints::testLockedPointer() QVERIFY(lockedSpy2.isValid()); // activate the client again, this should lock again - workspace()->activateClient(static_cast(input()->pointer()->focus())); + workspace()->activateClient(static_cast(input()->pointer()->focus())); QVERIFY(lockedSpy2.wait()); QCOMPARE(input()->pointer()->isConstrained(), true); diff --git a/autotests/integration/pointer_input.cpp b/autotests/integration/pointer_input.cpp index fe2db628c0..425f3d15df 100644 --- a/autotests/integration/pointer_input.cpp +++ b/autotests/integration/pointer_input.cpp @@ -7,14 +7,15 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" -#include "abstract_output.h" -#include "platform.h" + #include "abstract_client.h" +#include "abstract_output.h" #include "cursor.h" #include "deleted.h" #include "effects.h" -#include "pointer_input.h" #include "options.h" +#include "platform.h" +#include "pointer_input.h" #include "screenedge.h" #include "screens.h" #include "virtualdesktops.h" @@ -24,8 +25,8 @@ #include #include -#include #include +#include #include #include #include @@ -131,8 +132,8 @@ private: void PointerInputTest::initTestCase() { - qRegisterMetaType(); - qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -162,9 +163,7 @@ void PointerInputTest::initTestCase() void PointerInputTest::init() { - QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat | - Test::AdditionalWaylandInterface::Decoration | - Test::AdditionalWaylandInterface::XdgDecorationV1)); + QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat | Test::AdditionalWaylandInterface::Decoration | Test::AdditionalWaylandInterface::XdgDecorationV1)); QVERIFY(Test::waitForWaylandPointer()); m_compositor = Test::waylandCompositor(); m_seat = Test::waylandSeat(); @@ -224,7 +223,7 @@ void PointerInputTest::testWarpingUpdatesFocus() QCOMPARE(waylandServer()->seat()->focusedPointerSurface(), window->surface()); // and out again - Cursors::self()->mouse()->setPos(QPoint(250, 250));; + Cursors::self()->mouse()->setPos(QPoint(250, 250)); QVERIFY(leftSpy.wait()); QCOMPARE(leftSpy.count(), 1); // there should not be a focused pointer surface anymore @@ -301,7 +300,7 @@ void PointerInputTest::testWarpingDuringFilter() QVERIFY(window->frameGeometry().contains(Cursors::self()->mouse()->pos())); // is PresentWindows effect for top left screen edge loaded - QVERIFY(static_cast(effects)->isEffectLoaded("presentwindows")); + QVERIFY(static_cast(effects)->isEffectLoaded("presentwindows")); QVERIFY(movedSpy.isEmpty()); quint32 timestamp = 0; Test::pointerMotion(QPoint(0, 0), timestamp++); @@ -511,33 +510,33 @@ void PointerInputTest::testModifierClickUnrestrictedMove_data() 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("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("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("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("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; } @@ -676,13 +675,13 @@ void PointerInputTest::testModifierScrollOpacity_data() 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("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("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; } @@ -800,7 +799,7 @@ void PointerInputTest::testModifierScrollOpacityGlobalShortcutsDisabled() workspace()->disableGlobalShortcutsForClient(false); } -void PointerInputTest::testScrollAction() +void PointerInputTest::testScrollAction() { // this test verifies that scroll on inactive window performs a mouse action using namespace KWayland::Client; @@ -939,9 +938,9 @@ void PointerInputTest::testMouseActionInactiveWindow_data() { QTest::addColumn("button"); - QTest::newRow("Left") << quint32(BTN_LEFT); + QTest::newRow("Left") << quint32(BTN_LEFT); QTest::newRow("Middle") << quint32(BTN_MIDDLE); - QTest::newRow("Right") << quint32(BTN_RIGHT); + QTest::newRow("Right") << quint32(BTN_RIGHT); } void PointerInputTest::testMouseActionInactiveWindow() @@ -1023,7 +1022,7 @@ void PointerInputTest::testMouseActionActiveWindow_data() QTest::addColumn("clickRaise"); QTest::addColumn("button"); - for (quint32 i=BTN_LEFT; i < BTN_JOYSTICK; i++) { + 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; @@ -1193,7 +1192,7 @@ void PointerInputTest::testCursorImage() cursorSurface->commit(); QVERIFY(cursorRenderedSpy.wait()); QTRY_COMPARE(cursor->image(), blueScaled); - QCOMPARE(cursor->hotspot(), QPoint(6, 6)); //surface-local (so not changed) + QCOMPARE(cursor->hotspot(), QPoint(6, 6)); // surface-local (so not changed) // hide the cursor pointer->setCursor(nullptr); @@ -1211,8 +1210,12 @@ class HelperEffect : public Effect { Q_OBJECT public: - HelperEffect() {} - ~HelperEffect() override {} + HelperEffect() + { + } + ~HelperEffect() override + { + } }; void PointerInputTest::testEffectOverrideCursorImage() @@ -1525,41 +1528,41 @@ void PointerInputTest::testConfineToScreenGeometry_data() // +----------+ // - 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 - 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 - 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 - 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 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); + 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() @@ -1569,15 +1572,14 @@ void PointerInputTest::testConfineToScreenGeometry() // unload the Present Windows effect because it pushes back // pointer if it's at (0, 0) - static_cast(effects)->unloadEffect(QStringLiteral("presentwindows")); + static_cast(effects)->unloadEffect(QStringLiteral("presentwindows")); // setup screen layout - const QVector geometries { + const QVector geometries{ QRect(0, 0, 1280, 1024), QRect(1280, 0, 1280, 1024), QRect(2560, 0, 1280, 1024), - QRect(1280, 1024, 1280, 1024) - }; + QRect(1280, 1024, 1280, 1024)}; QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, geometries.count()), @@ -1606,14 +1608,14 @@ 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("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); + 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() diff --git a/autotests/integration/quick_tiling_test.cpp b/autotests/integration/quick_tiling_test.cpp index 4ca435a3f6..b30da9840f 100644 --- a/autotests/integration/quick_tiling_test.cpp +++ b/autotests/integration/quick_tiling_test.cpp @@ -7,23 +7,24 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" -#include "abstract_output.h" -#include "platform.h" + #include "abstract_client.h" -#include "x11client.h" +#include "abstract_output.h" #include "cursor.h" #include "decorations/decorationbridge.h" #include "decorations/settings.h" +#include "platform.h" +#include "scripting/scripting.h" #include "wayland_server.h" #include "workspace.h" -#include "scripting/scripting.h" +#include "x11client.h" #include #include #include -#include #include +#include #include #include @@ -79,7 +80,7 @@ private: void QuickTilingTest::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); qRegisterMetaType("MaximizeMode"); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); @@ -130,14 +131,14 @@ void QuickTilingTest::testQuickTiling_data() #define FLAG(name) QuickTileMode(QuickTileFlag::name) - QTest::newRow("left") << FLAG(Left) << QRect(0, 0, 640, 1024) << QRect(1280, 0, 640, 1024) << FLAG(Right); - QTest::newRow("top") << FLAG(Top) << QRect(0, 0, 1280, 512) << QRect(1280, 0, 1280, 512) << FLAG(Top); - QTest::newRow("right") << FLAG(Right) << QRect(640, 0, 640, 1024) << QRect(1920, 0, 640, 1024) << QuickTileMode(); + QTest::newRow("left") << FLAG(Left) << QRect(0, 0, 640, 1024) << QRect(1280, 0, 640, 1024) << FLAG(Right); + QTest::newRow("top") << FLAG(Top) << QRect(0, 0, 1280, 512) << QRect(1280, 0, 1280, 512) << FLAG(Top); + QTest::newRow("right") << FLAG(Right) << QRect(640, 0, 640, 1024) << QRect(1920, 0, 640, 1024) << QuickTileMode(); QTest::newRow("bottom") << FLAG(Bottom) << QRect(0, 512, 1280, 512) << QRect(1280, 512, 1280, 512) << FLAG(Bottom); - QTest::newRow("top left") << (FLAG(Left) | FLAG(Top)) << QRect(0, 0, 640, 512) << QRect(1280, 0, 640, 512) << (FLAG(Right) | FLAG(Top)); - QTest::newRow("top right") << (FLAG(Right) | FLAG(Top)) << QRect(640, 0, 640, 512) << QRect(1920, 0, 640, 512) << QuickTileMode(); - QTest::newRow("bottom left") << (FLAG(Left) | FLAG(Bottom)) << QRect(0, 512, 640, 512) << QRect(1280, 512, 640, 512) << (FLAG(Right) | FLAG(Bottom)); + QTest::newRow("top left") << (FLAG(Left) | FLAG(Top)) << QRect(0, 0, 640, 512) << QRect(1280, 0, 640, 512) << (FLAG(Right) | FLAG(Top)); + QTest::newRow("top right") << (FLAG(Right) | FLAG(Top)) << QRect(640, 0, 640, 512) << QRect(1920, 0, 640, 512) << QuickTileMode(); + QTest::newRow("bottom left") << (FLAG(Left) | FLAG(Bottom)) << QRect(0, 512, 640, 512) << QRect(1280, 512, 640, 512) << (FLAG(Right) | FLAG(Bottom)); QTest::newRow("bottom right") << (FLAG(Right) | FLAG(Bottom)) << QRect(640, 512, 640, 512) << QRect(1920, 512, 640, 512) << QuickTileMode(); QTest::newRow("maximize") << FLAG(Maximize) << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 1024) << QuickTileMode(); @@ -279,10 +280,10 @@ void QuickTilingTest::testQuickMaximizing() // client is now set to maximised QCOMPARE(maximizeChangedSpy1.count(), 1); - QCOMPARE(maximizeChangedSpy1.first().first().value(), c); + QCOMPARE(maximizeChangedSpy1.first().first().value(), c); QCOMPARE(maximizeChangedSpy1.first().last().value(), MaximizeFull); QCOMPARE(maximizeChangedSpy2.count(), 1); - QCOMPARE(maximizeChangedSpy2.first().first().value(), c); + QCOMPARE(maximizeChangedSpy2.first().first().value(), c); QCOMPARE(maximizeChangedSpy2.first().at(1).toBool(), true); QCOMPARE(maximizeChangedSpy2.first().at(2).toBool(), true); QCOMPARE(c->maximizeMode(), MaximizeFull); @@ -309,10 +310,10 @@ void QuickTilingTest::testQuickMaximizing() QCOMPARE(c->frameGeometry(), QRect(0, 0, 100, 50)); QCOMPARE(c->geometryRestore(), QRect(0, 0, 100, 50)); QCOMPARE(maximizeChangedSpy1.count(), 2); - QCOMPARE(maximizeChangedSpy1.last().first().value(), c); + QCOMPARE(maximizeChangedSpy1.last().first().value(), c); QCOMPARE(maximizeChangedSpy1.last().last().value(), MaximizeRestore); QCOMPARE(maximizeChangedSpy2.count(), 2); - QCOMPARE(maximizeChangedSpy2.last().first().value(), c); + QCOMPARE(maximizeChangedSpy2.last().first().value(), c); QCOMPARE(maximizeChangedSpy2.last().at(1).toBool(), false); QCOMPARE(maximizeChangedSpy2.last().at(2).toBool(), false); } @@ -505,9 +506,7 @@ void QuickTilingTest::testQuickTilingTouchMove() QVERIFY(c->isDecorated()); const auto decoration = c->decoration(); QCOMPARE(workspace()->activeClient(), c); - QCOMPARE(c->frameGeometry(), QRect(-decoration->borderLeft(), 0, - 1000 + decoration->borderLeft() + decoration->borderRight(), - 50 + decoration->borderTop() + decoration->borderBottom())); + QCOMPARE(c->frameGeometry(), QRect(-decoration->borderLeft(), 0, 1000 + decoration->borderLeft() + decoration->borderRight(), 50 + decoration->borderTop() + decoration->borderBottom())); QCOMPARE(c->quickTileMode(), QuickTileMode(QuickTileFlag::None)); QCOMPARE(c->maximizeMode(), MaximizeRestore); @@ -530,7 +529,6 @@ void QuickTilingTest::testQuickTilingTouchMove() Test::touchUp(0, timestamp++); QVERIFY(!workspace()->moveResizeClient()); - // When there are no borders, there is no change to them when quick-tiling. // TODO: we should test both cases with fixed fake decoration for autotests. const bool hasBorders = Decoration::DecorationBridge::self()->settings()->borderSize() != KDecoration2::BorderSize::None; @@ -559,14 +557,14 @@ void QuickTilingTest::testX11QuickTiling_data() #define FLAG(name) QuickTileMode(QuickTileFlag::name) - QTest::newRow("left") << FLAG(Left) << QRect(0, 0, 640, 1024) << 0 << QuickTileMode(); - QTest::newRow("top") << FLAG(Top) << QRect(0, 0, 1280, 512) << 1 << FLAG(Top); - QTest::newRow("right") << FLAG(Right) << QRect(640, 0, 640, 1024) << 1 << FLAG(Left); + QTest::newRow("left") << FLAG(Left) << QRect(0, 0, 640, 1024) << 0 << QuickTileMode(); + QTest::newRow("top") << FLAG(Top) << QRect(0, 0, 1280, 512) << 1 << FLAG(Top); + QTest::newRow("right") << FLAG(Right) << QRect(640, 0, 640, 1024) << 1 << FLAG(Left); QTest::newRow("bottom") << FLAG(Bottom) << QRect(0, 512, 1280, 512) << 1 << FLAG(Bottom); - QTest::newRow("top left") << (FLAG(Left) | FLAG(Top)) << QRect(0, 0, 640, 512) << 0 << QuickTileMode(); - QTest::newRow("top right") << (FLAG(Right) | FLAG(Top)) << QRect(640, 0, 640, 512) << 1 << (FLAG(Left) | FLAG(Top)); - QTest::newRow("bottom left") << (FLAG(Left) | FLAG(Bottom)) << QRect(0, 512, 640, 512) << 0 << QuickTileMode(); + QTest::newRow("top left") << (FLAG(Left) | FLAG(Top)) << QRect(0, 0, 640, 512) << 0 << QuickTileMode(); + QTest::newRow("top right") << (FLAG(Right) | FLAG(Top)) << QRect(640, 0, 640, 512) << 1 << (FLAG(Left) | FLAG(Top)); + QTest::newRow("bottom left") << (FLAG(Left) | FLAG(Bottom)) << QRect(0, 512, 640, 512) << 0 << QuickTileMode(); QTest::newRow("bottom right") << (FLAG(Right) | FLAG(Bottom)) << QRect(640, 512, 640, 512) << 1 << (FLAG(Left) | FLAG(Bottom)); QTest::newRow("maximize") << FLAG(Maximize) << QRect(0, 0, 1280, 1024) << 0 << QuickTileMode(); @@ -640,14 +638,14 @@ void QuickTilingTest::testX11QuickTilingAfterVertMaximize_data() #define FLAG(name) QuickTileMode(QuickTileFlag::name) - QTest::newRow("left") << FLAG(Left) << QRect(0, 0, 640, 1024); - QTest::newRow("top") << FLAG(Top) << QRect(0, 0, 1280, 512); - QTest::newRow("right") << FLAG(Right) << QRect(640, 0, 640, 1024); + QTest::newRow("left") << FLAG(Left) << QRect(0, 0, 640, 1024); + QTest::newRow("top") << FLAG(Top) << QRect(0, 0, 1280, 512); + QTest::newRow("right") << FLAG(Right) << QRect(640, 0, 640, 1024); QTest::newRow("bottom") << FLAG(Bottom) << QRect(0, 512, 1280, 512); - QTest::newRow("top left") << (FLAG(Left) | FLAG(Top)) << QRect(0, 0, 640, 512); - QTest::newRow("top right") << (FLAG(Right) | FLAG(Top)) << QRect(640, 0, 640, 512); - QTest::newRow("bottom left") << (FLAG(Left) | FLAG(Bottom)) << QRect(0, 512, 640, 512); + QTest::newRow("top left") << (FLAG(Left) | FLAG(Top)) << QRect(0, 0, 640, 512); + QTest::newRow("top right") << (FLAG(Right) | FLAG(Top)) << QRect(640, 0, 640, 512); + QTest::newRow("bottom left") << (FLAG(Left) | FLAG(Bottom)) << QRect(0, 512, 640, 512); QTest::newRow("bottom right") << (FLAG(Right) | FLAG(Bottom)) << QRect(640, 512, 640, 512); QTest::newRow("maximize") << FLAG(Maximize) << QRect(0, 0, 1280, 1024); diff --git a/autotests/integration/scene_opengl_es_test.cpp b/autotests/integration/scene_opengl_es_test.cpp index d9aa9cabcf..90c115d643 100644 --- a/autotests/integration/scene_opengl_es_test.cpp +++ b/autotests/integration/scene_opengl_es_test.cpp @@ -12,7 +12,10 @@ class SceneOpenGLESTest : public GenericSceneOpenGLTest { Q_OBJECT public: - SceneOpenGLESTest() : GenericSceneOpenGLTest(QByteArrayLiteral("O2ES")) {} + SceneOpenGLESTest() + : GenericSceneOpenGLTest(QByteArrayLiteral("O2ES")) + { + } }; WAYLANDTEST_MAIN(SceneOpenGLESTest) diff --git a/autotests/integration/scene_opengl_test.cpp b/autotests/integration/scene_opengl_test.cpp index c9d4575359..bbc15d89cf 100644 --- a/autotests/integration/scene_opengl_test.cpp +++ b/autotests/integration/scene_opengl_test.cpp @@ -12,7 +12,10 @@ class SceneOpenGLTest : public GenericSceneOpenGLTest { Q_OBJECT public: - SceneOpenGLTest() : GenericSceneOpenGLTest(QByteArrayLiteral("O2")) {} + SceneOpenGLTest() + : GenericSceneOpenGLTest(QByteArrayLiteral("O2")) + { + } }; WAYLANDTEST_MAIN(SceneOpenGLTest) diff --git a/autotests/integration/scene_qpainter_test.cpp b/autotests/integration/scene_qpainter_test.cpp index d3a3c4bed8..82b26a47cf 100644 --- a/autotests/integration/scene_qpainter_test.cpp +++ b/autotests/integration/scene_qpainter_test.cpp @@ -7,20 +7,21 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "composite.h" -#include "effectloader.h" -#include "x11client.h" #include "cursor.h" +#include "effectloader.h" #include "effects.h" #include "platform.h" #include "wayland_server.h" #include "workspace.h" +#include "x11client.h" #include +#include #include #include -#include #include #include @@ -34,7 +35,7 @@ static const QString s_socketName = QStringLiteral("wayland_test_kwin_scene_qpai class SceneQPainterTest : public QObject { -Q_OBJECT + Q_OBJECT private Q_SLOTS: void initTestCase(); void cleanup(); @@ -53,7 +54,7 @@ void SceneQPainterTest::cleanup() void SceneQPainterTest::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -210,14 +211,14 @@ void SceneQPainterTest::testWindowScaled() // now let's map the window s->setScale(2); - //draw a blue square@400x600 with red rectangle@200x200 in the middle - const QSize size(400,600); + // draw a blue square@400x600 with red rectangle@200x200 in the middle + const QSize size(400, 600); QImage img(size, QImage::Format_ARGB32_Premultiplied); img.fill(Qt::blue); QPainter surfacePainter(&img); - surfacePainter.fillRect(200,300,200,200, Qt::red); + surfacePainter.fillRect(200, 300, 200, 200, Qt::red); - //add buffer + // add buffer Test::render(s.data(), img); QVERIFY(pointerEnteredSpy.wait()); p->setCursor(cs.data(), QPoint(5, 5)); @@ -229,7 +230,7 @@ void SceneQPainterTest::testWindowScaled() QPainter painter(&referenceImage); painter.fillRect(0, 0, 200, 300, Qt::blue); painter.fillRect(100, 150, 100, 100, Qt::red); - painter.fillRect(5, 5, 10, 10, Qt::red); //cursor + painter.fillRect(5, 5, 10, 10, Qt::red); // cursor const auto outputs = kwinApp()->platform()->enabledOutputs(); QCOMPARE(referenceImage, *scene->qpainterRenderBuffer(outputs.constFirst())); @@ -337,7 +338,6 @@ void SceneQPainterTest::testX11Window() 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()); diff --git a/autotests/integration/screen_changes_test.cpp b/autotests/integration/screen_changes_test.cpp index 8ac6463c71..9e4d510a01 100644 --- a/autotests/integration/screen_changes_test.cpp +++ b/autotests/integration/screen_changes_test.cpp @@ -7,6 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_output.h" #include "cursor.h" #include "platform.h" @@ -15,8 +16,8 @@ #include "workspace.h" #include -#include #include +#include using namespace KWin; using namespace KWayland::Client; @@ -133,7 +134,7 @@ void ScreenChangesTest::testScreenAddRemove() QVERIFY(o2ChangedSpy.wait()); QCOMPARE(o2->geometry(), geometries.at(1)); - //and check XDGOutput is synced + // and check XDGOutput is synced QScopedPointer xdgO1(xdgOutputManager->getXdgOutput(o1.data())); QSignalSpy xdgO1ChangedSpy(xdgO1.data(), &XdgOutput::changed); QVERIFY(xdgO1ChangedSpy.isValid()); diff --git a/autotests/integration/screenedge_client_show_test.cpp b/autotests/integration/screenedge_client_show_test.cpp index 9495d85c83..30cf5cd3e8 100644 --- a/autotests/integration/screenedge_client_show_test.cpp +++ b/autotests/integration/screenedge_client_show_test.cpp @@ -7,14 +7,15 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_output.h" -#include "platform.h" -#include "x11client.h" #include "cursor.h" #include "deleted.h" +#include "platform.h" #include "screenedge.h" #include "wayland_server.h" #include "workspace.h" +#include "x11client.h" #include #include @@ -39,8 +40,8 @@ private Q_SLOTS: void ScreenEdgeClientShowTest::initTestCase() { - qRegisterMetaType(); - qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -72,7 +73,6 @@ void ScreenEdgeClientShowTest::init() QVERIFY(waylandServer()->clients().isEmpty()); } - struct XcbConnectionDeleter { static inline void cleanup(xcb_connection_t *pointer) @@ -163,16 +163,16 @@ void ScreenEdgeClientShowTest::testScreenEdgeShowHideX11() // go into event loop to trigger xcb_flush QTest::qWait(1); - //hide window again + // hide window again Cursors::self()->mouse()->setPos(QPoint(640, 512)); xcb_change_property(c.data(), XCB_PROP_MODE_REPLACE, w, atom, XCB_ATOM_CARDINAL, 32, 1, &location); xcb_flush(c.data()); QVERIFY(clientHiddenSpy.wait()); QVERIFY(client->isHiddenInternal()); QFETCH(QRect, resizedWindowGeometry); - //resizewhile hidden + // resizewhile hidden client->moveResize(resizedWindowGeometry); - //triggerPos shouldn't be valid anymore + // triggerPos shouldn't be valid anymore Cursors::self()->mouse()->setPos(triggerPos); QVERIFY(client->isHiddenInternal()); diff --git a/autotests/integration/screenedges_test.cpp b/autotests/integration/screenedges_test.cpp index 906eb13f00..a8f27a4484 100644 --- a/autotests/integration/screenedges_test.cpp +++ b/autotests/integration/screenedges_test.cpp @@ -14,8 +14,8 @@ #include "cursor.h" #include "effectloader.h" #include "main.h" -#include "screenedge.h" #include "platform.h" +#include "screenedge.h" #include "wayland_server.h" #include "workspace.h" diff --git a/autotests/integration/screens_test.cpp b/autotests/integration/screens_test.cpp index 092f8bfbf8..eb2900573d 100644 --- a/autotests/integration/screens_test.cpp +++ b/autotests/integration/screens_test.cpp @@ -7,6 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "abstract_output.h" #include "cursor.h" diff --git a/autotests/integration/scripting/minimizeall_test.cpp b/autotests/integration/scripting/minimizeall_test.cpp index db9418234e..de5abc7305 100644 --- a/autotests/integration/scripting/minimizeall_test.cpp +++ b/autotests/integration/scripting/minimizeall_test.cpp @@ -67,8 +67,7 @@ static QString locateMainScript(const QString &pluginName) QStringLiteral("kwin/scripts"), [&](const KPluginMetaData &metaData) { return metaData.pluginId() == pluginName; - } - ); + }); if (offers.isEmpty()) { return QString(); } diff --git a/autotests/integration/scripting/screenedge_test.cpp b/autotests/integration/scripting/screenedge_test.cpp index a73b76ea4f..b1c120bac8 100644 --- a/autotests/integration/scripting/screenedge_test.cpp +++ b/autotests/integration/scripting/screenedge_test.cpp @@ -7,12 +7,13 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "cursor.h" #include "effectloader.h" #include "platform.h" +#include "scripting/scripting.h" #include "wayland_server.h" #include "workspace.h" -#include "scripting/scripting.h" #define private public #include "screenedge.h" @@ -90,7 +91,7 @@ void ScreenEdgeTest::cleanup() { // try to unload the script const QStringList scripts = {QFINDTESTDATA("./scripts/screenedge.js"), QFINDTESTDATA("./scripts/screenedgeunregister.js"), QFINDTESTDATA("./scripts/touchScreenedge.js")}; - for (const QString &script: scripts) { + for (const QString &script : scripts) { if (!script.isEmpty()) { if (Scripting::self()->isScriptLoaded(script)) { QVERIFY(Scripting::self()->unloadScript(script)); @@ -105,17 +106,17 @@ void ScreenEdgeTest::testEdge_data() QTest::addColumn("edge"); QTest::addColumn("triggerPos"); - QTest::newRow("Top") << KWin::ElectricTop << QPoint(512, 0); + QTest::newRow("Top") << KWin::ElectricTop << QPoint(512, 0); QTest::newRow("TopRight") << KWin::ElectricTopRight << QPoint(1279, 0); - QTest::newRow("Right") << KWin::ElectricRight << QPoint(1279, 512); + QTest::newRow("Right") << KWin::ElectricRight << QPoint(1279, 512); QTest::newRow("BottomRight") << KWin::ElectricBottomRight << QPoint(1279, 1023); QTest::newRow("Bottom") << KWin::ElectricBottom << QPoint(512, 1023); QTest::newRow("BottomLeft") << KWin::ElectricBottomLeft << QPoint(0, 1023); QTest::newRow("Left") << KWin::ElectricLeft << QPoint(0, 512); QTest::newRow("TopLeft") << KWin::ElectricTopLeft << QPoint(0, 0); - //repeat a row to show previously unloading and re-registering works - QTest::newRow("Top") << KWin::ElectricTop << QPoint(512, 0); + // repeat a row to show previously unloading and re-registering works + QTest::newRow("Top") << KWin::ElectricTop << QPoint(512, 0); } void ScreenEdgeTest::testEdge() @@ -158,13 +159,13 @@ void ScreenEdgeTest::testTouchEdge_data() QTest::addColumn("triggerPos"); QTest::addColumn("motionPos"); - QTest::newRow("Top") << KWin::ElectricTop << QPoint(50, 0) << QPoint(50, 500); - QTest::newRow("Right") << KWin::ElectricRight << QPoint(1279, 50) << QPoint(500, 50); + QTest::newRow("Top") << KWin::ElectricTop << QPoint(50, 0) << QPoint(50, 500); + QTest::newRow("Right") << KWin::ElectricRight << QPoint(1279, 50) << QPoint(500, 50); QTest::newRow("Bottom") << KWin::ElectricBottom << QPoint(512, 1023) << QPoint(512, 500); QTest::newRow("Left") << KWin::ElectricLeft << QPoint(0, 50) << QPoint(500, 50); - //repeat a row to show previously unloading and re-registering works - QTest::newRow("Top") << KWin::ElectricTop << QPoint(512, 0) << QPoint(512, 500); + // repeat a row to show previously unloading and re-registering works + QTest::newRow("Top") << KWin::ElectricTop << QPoint(512, 0) << QPoint(512, 500); } void ScreenEdgeTest::testTouchEdge() @@ -206,7 +207,8 @@ void ScreenEdgeTest::testTouchEdge() QVERIFY(workspace()->showingDesktop()); } -void ScreenEdgeTest::triggerConfigReload() { +void ScreenEdgeTest::triggerConfigReload() +{ workspace()->slotReconfigure(); } @@ -229,31 +231,31 @@ void ScreenEdgeTest::testEdgeUnregister() QSignalSpy showDesktopSpy(workspace(), &Workspace::showingDesktopChanged); QVERIFY(showDesktopSpy.isValid()); - //trigger the edge + // trigger the edge KWin::Cursors::self()->mouse()->setPos(triggerPos); QCOMPARE(showDesktopSpy.count(), 1); - //reset - KWin::Cursors::self()->mouse()->setPos(500,500); + // reset + KWin::Cursors::self()->mouse()->setPos(500, 500); workspace()->slotToggleShowDesktop(); showDesktopSpy.clear(); - //trigger again, to show that retriggering works + // trigger again, to show that retriggering works KWin::Cursors::self()->mouse()->setPos(triggerPos); QCOMPARE(showDesktopSpy.count(), 1); - //reset - KWin::Cursors::self()->mouse()->setPos(500,500); + // reset + KWin::Cursors::self()->mouse()->setPos(500, 500); workspace()->slotToggleShowDesktop(); showDesktopSpy.clear(); - //make the script unregister the edge + // make the script unregister the edge configGroup.writeEntry("mode", "unregister"); triggerConfigReload(); KWin::Cursors::self()->mouse()->setPos(triggerPos); - QCOMPARE(showDesktopSpy.count(), 0); //not triggered + QCOMPARE(showDesktopSpy.count(), 0); // not triggered - //force the script to unregister a non-registered edge to prove it doesn't explode + // force the script to unregister a non-registered edge to prove it doesn't explode triggerConfigReload(); } diff --git a/autotests/integration/shade_test.cpp b/autotests/integration/shade_test.cpp index 06a3a94323..02bb2905e4 100644 --- a/autotests/integration/shade_test.cpp +++ b/autotests/integration/shade_test.cpp @@ -7,12 +7,13 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_output.h" -#include "platform.h" -#include "x11client.h" #include "cursor.h" +#include "platform.h" #include "wayland_server.h" #include "workspace.h" +#include "x11client.h" #include #include @@ -36,7 +37,7 @@ private Q_SLOTS: void ShadeTest::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); diff --git a/autotests/integration/showing_desktop_test.cpp b/autotests/integration/showing_desktop_test.cpp index 8da49ff012..8ebba14e25 100644 --- a/autotests/integration/showing_desktop_test.cpp +++ b/autotests/integration/showing_desktop_test.cpp @@ -7,6 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "platform.h" #include "wayland_server.h" @@ -34,7 +35,7 @@ private Q_SLOTS: void ShowingDesktopTest::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); diff --git a/autotests/integration/stacking_order_test.cpp b/autotests/integration/stacking_order_test.cpp index 92e65b263b..5ec45df440 100644 --- a/autotests/integration/stacking_order_test.cpp +++ b/autotests/integration/stacking_order_test.cpp @@ -11,12 +11,12 @@ #include "abstract_client.h" #include "atoms.h" -#include "x11client.h" #include "deleted.h" #include "main.h" #include "platform.h" #include "wayland_server.h" #include "workspace.h" +#include "x11client.h" #include #include @@ -48,7 +48,6 @@ private Q_SLOTS: void testKeepAbove(); void testKeepBelow(); - }; void StackingOrderTest::initTestCase() @@ -197,7 +196,8 @@ void StackingOrderTest::testRaiseTransient() struct WindowUnrefDeleter { - static inline void cleanup(Deleted *d) { + static inline void cleanup(Deleted *d) + { if (d != nullptr) { d->unrefWindow(); } @@ -265,11 +265,10 @@ void StackingOrderTest::testDeletedTransient() // Close the top-most transient. connect(transient2, &AbstractClient::windowClosed, this, - [](Toplevel *toplevel, Deleted *deleted) { - Q_UNUSED(toplevel) - deleted->refWindow(); - } - ); + [](Toplevel *toplevel, Deleted *deleted) { + Q_UNUSED(toplevel) + deleted->refWindow(); + }); QSignalSpy windowClosedSpy(transient2, &AbstractClient::windowClosed); QVERIFY(windowClosedSpy.isValid()); @@ -293,19 +292,19 @@ static xcb_window_t createGroupWindow(xcb_connection_t *conn, { xcb_window_t wid = xcb_generate_id(conn); xcb_create_window( - conn, // c - XCB_COPY_FROM_PARENT, // depth - wid, // wid - rootWindow(), // parent - geometry.x(), // x - geometry.y(), // y - geometry.width(), // width - geometry.height(), // height - 0, // border_width + conn, // c + XCB_COPY_FROM_PARENT, // depth + wid, // wid + rootWindow(), // parent + geometry.x(), // x + geometry.y(), // y + geometry.width(), // width + geometry.height(), // height + 0, // border_width XCB_WINDOW_CLASS_INPUT_OUTPUT, // _class - XCB_COPY_FROM_PARENT, // visual - 0, // value_mask - nullptr // value_list + XCB_COPY_FROM_PARENT, // visual + 0, // value_mask + nullptr // value_list ); xcb_size_hints_t sizeHints = {}; @@ -318,14 +317,14 @@ static xcb_window_t createGroupWindow(xcb_connection_t *conn, } xcb_change_property( - conn, // c - XCB_PROP_MODE_REPLACE, // mode - wid, // window + conn, // c + XCB_PROP_MODE_REPLACE, // mode + wid, // window atoms->wm_client_leader, // property - XCB_ATOM_WINDOW, // type - 32, // format - 1, // data_len - &leaderWid // data + XCB_ATOM_WINDOW, // type + 32, // format + 1, // data_len + &leaderWid // data ); return wid; @@ -333,7 +332,8 @@ static xcb_window_t createGroupWindow(xcb_connection_t *conn, struct XcbConnectionDeleter { - static inline void cleanup(xcb_connection_t *c) { + static inline void cleanup(xcb_connection_t *c) + { xcb_disconnect(c); } }; @@ -412,13 +412,13 @@ void StackingOrderTest::testGroupTransientIsAboveWindowGroup() xcb_atom_t net_wm_window_type_normal = Xcb::Atom( QByteArrayLiteral("_NET_WM_WINDOW_TYPE_NORMAL"), false, conn.data()); xcb_change_property( - conn.data(), // c - XCB_PROP_MODE_REPLACE, // mode - transientWid, // window - net_wm_window_type, // property - XCB_ATOM_ATOM, // type - 32, // format - 1, // data_len + conn.data(), // c + XCB_PROP_MODE_REPLACE, // mode + transientWid, // window + net_wm_window_type, // property + XCB_ATOM_ATOM, // type + 32, // format + 1, // data_len &net_wm_window_type_normal // data ); @@ -526,13 +526,13 @@ void StackingOrderTest::testRaiseGroupTransient() xcb_atom_t net_wm_window_type_normal = Xcb::Atom( QByteArrayLiteral("_NET_WM_WINDOW_TYPE_NORMAL"), false, conn.data()); xcb_change_property( - conn.data(), // c - XCB_PROP_MODE_REPLACE, // mode - transientWid, // window - net_wm_window_type, // property - XCB_ATOM_ATOM, // type - 32, // format - 1, // data_len + conn.data(), // c + XCB_PROP_MODE_REPLACE, // mode + transientWid, // window + net_wm_window_type, // property + XCB_ATOM_ATOM, // type + 32, // format + 1, // data_len &net_wm_window_type_normal // data ); @@ -660,13 +660,13 @@ void StackingOrderTest::testDeletedGroupTransient() xcb_atom_t net_wm_window_type_normal = Xcb::Atom( QByteArrayLiteral("_NET_WM_WINDOW_TYPE_NORMAL"), false, conn.data()); xcb_change_property( - conn.data(), // c - XCB_PROP_MODE_REPLACE, // mode - transientWid, // window - net_wm_window_type, // property - XCB_ATOM_ATOM, // type - 32, // format - 1, // data_len + conn.data(), // c + XCB_PROP_MODE_REPLACE, // mode + transientWid, // window + net_wm_window_type, // property + XCB_ATOM_ATOM, // type + 32, // format + 1, // data_len &net_wm_window_type_normal // data ); @@ -687,11 +687,10 @@ void StackingOrderTest::testDeletedGroupTransient() // Unmap the transient. connect(transient, &X11Client::windowClosed, this, - [](Toplevel *toplevel, Deleted *deleted) { - Q_UNUSED(toplevel) - deleted->refWindow(); - } - ); + [](Toplevel *toplevel, Deleted *deleted) { + Q_UNUSED(toplevel) + deleted->refWindow(); + }); QSignalSpy windowClosedSpy(transient, &X11Client::windowClosed); QVERIFY(windowClosedSpy.isValid()); diff --git a/autotests/integration/struts_test.cpp b/autotests/integration/struts_test.cpp index c2f9b0d7df..2932e7b3f3 100644 --- a/autotests/integration/struts_test.cpp +++ b/autotests/integration/struts_test.cpp @@ -7,16 +7,17 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_output.h" -#include "platform.h" -#include "x11client.h" #include "cursor.h" #include "deleted.h" +#include "platform.h" #include "screenedge.h" #include "screens.h" #include "virtualdesktops.h" #include "wayland_server.h" #include "workspace.h" +#include "x11client.h" #include #include @@ -57,8 +58,8 @@ private: void StrutsTest::initTestCase() { - qRegisterMetaType(); - qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -107,24 +108,24 @@ void StrutsTest::testWaylandStruts_data() QTest::addColumn("workArea"); QTest::addColumn("restrictedMoveArea"); - QTest::newRow("bottom/0") << QVector{QRect(0, 992, 1280, 32)} << QRect(0, 0, 1280, 992) << QRect(1280, 0, 1280, 1024) << QRect(0, 0, 2560, 992) << QRegion(0, 992, 1280, 32); - QTest::newRow("bottom/1") << QVector{QRect(1280, 992, 1280, 32)} << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 992) << QRect(0, 0, 2560, 992) << QRegion(1280, 992, 1280, 32); - QTest::newRow("top/0") << QVector{QRect(0, 0, 1280, 32)} << QRect(0, 32, 1280, 992) << QRect(1280, 0, 1280, 1024) << QRect(0, 32, 2560, 992) << QRegion(0, 0, 1280, 32); - QTest::newRow("top/1") << QVector{QRect(1280, 0, 1280, 32)} << QRect(0, 0, 1280, 1024) << QRect(1280, 32, 1280, 992) << QRect(0, 32, 2560, 992) << QRegion(1280, 0, 1280, 32); - QTest::newRow("left/0") << QVector{QRect(0, 0, 32, 1024)} << QRect(32, 0, 1248, 1024) << QRect(1280, 0, 1280, 1024) << QRect(32, 0, 2528, 1024) << QRegion(0, 0, 32, 1024); - QTest::newRow("left/1") << QVector{QRect(1280, 0, 32, 1024)} << QRect(0, 0, 1280, 1024) << QRect(1312, 0, 1248, 1024) << QRect(0, 0, 2560, 1024) << QRegion(1280, 0, 32, 1024); - QTest::newRow("right/0") << QVector{QRect(1248, 0, 32, 1024)} << QRect(0, 0, 1248, 1024) << QRect(1280, 0, 1280, 1024) << QRect(0, 0, 2560, 1024) << QRegion(1248, 0, 32, 1024); - QTest::newRow("right/1") << QVector{QRect(2528, 0, 32, 1024)} << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1248, 1024) << QRect(0, 0, 2528, 1024) << QRegion(2528, 0, 32, 1024); + QTest::newRow("bottom/0") << QVector{QRect(0, 992, 1280, 32)} << QRect(0, 0, 1280, 992) << QRect(1280, 0, 1280, 1024) << QRect(0, 0, 2560, 992) << QRegion(0, 992, 1280, 32); + QTest::newRow("bottom/1") << QVector{QRect(1280, 992, 1280, 32)} << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 992) << QRect(0, 0, 2560, 992) << QRegion(1280, 992, 1280, 32); + QTest::newRow("top/0") << QVector{QRect(0, 0, 1280, 32)} << QRect(0, 32, 1280, 992) << QRect(1280, 0, 1280, 1024) << QRect(0, 32, 2560, 992) << QRegion(0, 0, 1280, 32); + QTest::newRow("top/1") << QVector{QRect(1280, 0, 1280, 32)} << QRect(0, 0, 1280, 1024) << QRect(1280, 32, 1280, 992) << QRect(0, 32, 2560, 992) << QRegion(1280, 0, 1280, 32); + QTest::newRow("left/0") << QVector{QRect(0, 0, 32, 1024)} << QRect(32, 0, 1248, 1024) << QRect(1280, 0, 1280, 1024) << QRect(32, 0, 2528, 1024) << QRegion(0, 0, 32, 1024); + QTest::newRow("left/1") << QVector{QRect(1280, 0, 32, 1024)} << QRect(0, 0, 1280, 1024) << QRect(1312, 0, 1248, 1024) << QRect(0, 0, 2560, 1024) << QRegion(1280, 0, 32, 1024); + QTest::newRow("right/0") << QVector{QRect(1248, 0, 32, 1024)} << QRect(0, 0, 1248, 1024) << QRect(1280, 0, 1280, 1024) << QRect(0, 0, 2560, 1024) << QRegion(1248, 0, 32, 1024); + QTest::newRow("right/1") << QVector{QRect(2528, 0, 32, 1024)} << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1248, 1024) << QRect(0, 0, 2528, 1024) << QRegion(2528, 0, 32, 1024); // same with partial panels not covering the whole area - QTest::newRow("part bottom/0") << QVector{QRect(100, 992, 1080, 32)} << QRect(0, 0, 1280, 992) << QRect(1280, 0, 1280, 1024) << QRect(0, 0, 2560, 992) << QRegion(100, 992, 1080, 32); - QTest::newRow("part bottom/1") << QVector{QRect(1380, 992, 1080, 32)} << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 992) << QRect(0, 0, 2560, 992) << QRegion(1380, 992, 1080, 32); - QTest::newRow("part top/0") << QVector{QRect(100, 0, 1080, 32)} << QRect(0, 32, 1280, 992) << QRect(1280, 0, 1280, 1024) << QRect(0, 32, 2560, 992) << QRegion(100, 0, 1080, 32); - QTest::newRow("part top/1") << QVector{QRect(1380, 0, 1080, 32)} << QRect(0, 0, 1280, 1024) << QRect(1280, 32, 1280, 992) << QRect(0, 32, 2560, 992) << QRegion(1380, 0, 1080, 32); - QTest::newRow("part left/0") << QVector{QRect(0, 100, 32, 824)} << QRect(32, 0, 1248, 1024) << QRect(1280, 0, 1280, 1024) << QRect(32, 0, 2528, 1024) << QRegion(0, 100, 32, 824); - QTest::newRow("part left/1") << QVector{QRect(1280, 100, 32, 824)} << QRect(0, 0, 1280, 1024) << QRect(1312, 0, 1248, 1024) << QRect(0, 0, 2560, 1024) << QRegion(1280, 100, 32, 824); - QTest::newRow("part right/0") << QVector{QRect(1248, 100, 32, 824)} << QRect(0, 0, 1248, 1024) << QRect(1280, 0, 1280, 1024) << QRect(0, 0, 2560, 1024) << QRegion(1248, 100, 32, 824); - QTest::newRow("part right/1") << QVector{QRect(2528, 100, 32, 824)} << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1248, 1024) << QRect(0, 0, 2528, 1024) << QRegion(2528, 100, 32, 824); + QTest::newRow("part bottom/0") << QVector{QRect(100, 992, 1080, 32)} << QRect(0, 0, 1280, 992) << QRect(1280, 0, 1280, 1024) << QRect(0, 0, 2560, 992) << QRegion(100, 992, 1080, 32); + QTest::newRow("part bottom/1") << QVector{QRect(1380, 992, 1080, 32)} << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1280, 992) << QRect(0, 0, 2560, 992) << QRegion(1380, 992, 1080, 32); + QTest::newRow("part top/0") << QVector{QRect(100, 0, 1080, 32)} << QRect(0, 32, 1280, 992) << QRect(1280, 0, 1280, 1024) << QRect(0, 32, 2560, 992) << QRegion(100, 0, 1080, 32); + QTest::newRow("part top/1") << QVector{QRect(1380, 0, 1080, 32)} << QRect(0, 0, 1280, 1024) << QRect(1280, 32, 1280, 992) << QRect(0, 32, 2560, 992) << QRegion(1380, 0, 1080, 32); + QTest::newRow("part left/0") << QVector{QRect(0, 100, 32, 824)} << QRect(32, 0, 1248, 1024) << QRect(1280, 0, 1280, 1024) << QRect(32, 0, 2528, 1024) << QRegion(0, 100, 32, 824); + QTest::newRow("part left/1") << QVector{QRect(1280, 100, 32, 824)} << QRect(0, 0, 1280, 1024) << QRect(1312, 0, 1248, 1024) << QRect(0, 0, 2560, 1024) << QRegion(1280, 100, 32, 824); + QTest::newRow("part right/0") << QVector{QRect(1248, 100, 32, 824)} << QRect(0, 0, 1248, 1024) << QRect(1280, 0, 1280, 1024) << QRect(0, 0, 2560, 1024) << QRegion(1248, 100, 32, 824); + QTest::newRow("part right/1") << QVector{QRect(2528, 100, 32, 824)} << QRect(0, 0, 1280, 1024) << QRect(1280, 0, 1248, 1024) << QRect(0, 0, 2528, 1024) << QRegion(2528, 100, 32, 824); // multiple panels QTest::newRow("two bottom panels") << QVector{QRect(100, 992, 1080, 32), QRect(1380, 984, 1080, 40)} << QRect(0, 0, 1280, 992) << QRect(1280, 0, 1280, 984) << QRect(0, 0, 2560, 984) << QRegion(100, 992, 1080, 32).united(QRegion(1380, 984, 1080, 40)); @@ -162,7 +163,7 @@ void StrutsTest::testWaylandStruts() QFETCH(QVector, windowGeometries); // create the panels - QHash clients; + QHash clients; for (auto it = windowGeometries.constBegin(), end = windowGeometries.constEnd(); it != end; it++) { const QRect windowGeometry = *it; KWayland::Client::Surface *surface = Test::createSurface(m_compositor); @@ -249,8 +250,8 @@ void StrutsTest::testMoveWaylandPanel() QVERIFY(c->hasStrut()); QCOMPARE(workspace()->clientArea(PlacementArea, outputs[0], desktop), QRect(0, 0, 1280, 1000)); QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[0], desktop), QRect(0, 0, 1280, 1000)); - QCOMPARE(workspace()->clientArea(PlacementArea,outputs[1], desktop), QRect(1280, 0, 1280, 1024)); - QCOMPARE(workspace()->clientArea(MaximizeArea,outputs[1], desktop), QRect(1280, 0, 1280, 1024)); + QCOMPARE(workspace()->clientArea(PlacementArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024)); + QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[1], desktop), QRect(1280, 0, 1280, 1024)); QCOMPARE(workspace()->clientArea(WorkArea, outputs[0], desktop), QRect(0, 0, 2560, 1000)); QSignalSpy frameGeometryChangedSpy(c, &AbstractClient::frameGeometryChanged); @@ -260,8 +261,8 @@ void StrutsTest::testMoveWaylandPanel() QCOMPARE(c->frameGeometry(), QRect(1280, 1000, 1280, 24)); QCOMPARE(workspace()->clientArea(PlacementArea, outputs[0], desktop), QRect(0, 0, 1280, 1024)); QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[0], desktop), QRect(0, 0, 1280, 1024)); - QCOMPARE(workspace()->clientArea(PlacementArea,outputs[1], desktop), QRect(1280, 0, 1280, 1000)); - QCOMPARE(workspace()->clientArea(MaximizeArea,outputs[1], desktop), QRect(1280, 0, 1280, 1000)); + QCOMPARE(workspace()->clientArea(PlacementArea, outputs[1], desktop), QRect(1280, 0, 1280, 1000)); + QCOMPARE(workspace()->clientArea(MaximizeArea, outputs[1], desktop), QRect(1280, 0, 1280, 1000)); QCOMPARE(workspace()->clientArea(WorkArea, outputs[0], desktop), QRect(0, 0, 2560, 1000)); } @@ -272,7 +273,7 @@ void StrutsTest::testWaylandMobilePanel() VirtualDesktop *desktop = VirtualDesktopManager::self()->currentDesktop(); const QVector outputs = kwinApp()->platform()->enabledOutputs(); - //First enable maxmizing policy + // First enable maxmizing policy KConfigGroup group = kwinApp()->config()->group("Windows"); group.writeEntry("Placement", "Maximizing"); group.sync(); @@ -383,106 +384,106 @@ void StrutsTest::testX11Struts_data() << QRect(0, 0, 2560, 980) << QRegion(0, 980, 1279, 44); QTest::newRow("top panel/no strut") << QRect(0, 0, 1280, 44) - << 0 << 0 << 0 << 0 - << 0 << 0 - << 0 << 0 - << 0 << 0 - << 0 << 0 - << QRect(0, 0, 1280, 1024) - << QRect(1280, 0, 1280, 1024) - << QRect(0, 0, 2560, 1024) - << QRegion(); + << 0 << 0 << 0 << 0 + << 0 << 0 + << 0 << 0 + << 0 << 0 + << 0 << 0 + << QRect(0, 0, 1280, 1024) + << QRect(1280, 0, 1280, 1024) + << QRect(0, 0, 2560, 1024) + << QRegion(); QTest::newRow("top panel/strut") << QRect(0, 0, 1280, 44) - << 0 << 0 << 44 << 0 - << 0 << 0 - << 0 << 0 - << 0 << 1279 - << 0 << 0 - << QRect(0, 44, 1280, 980) - << QRect(1280, 0, 1280, 1024) - << QRect(0, 44, 2560, 980) - << QRegion(0, 0, 1279, 44); + << 0 << 0 << 44 << 0 + << 0 << 0 + << 0 << 0 + << 0 << 1279 + << 0 << 0 + << QRect(0, 44, 1280, 980) + << QRect(1280, 0, 1280, 1024) + << QRect(0, 44, 2560, 980) + << QRegion(0, 0, 1279, 44); QTest::newRow("left panel/no strut") << QRect(0, 0, 60, 1024) - << 0 << 0 << 0 << 0 - << 0 << 0 - << 0 << 0 - << 0 << 0 - << 0 << 0 - << QRect(0, 0, 1280, 1024) - << QRect(1280, 0, 1280, 1024) - << QRect(0, 0, 2560, 1024) - << QRegion(); + << 0 << 0 << 0 << 0 + << 0 << 0 + << 0 << 0 + << 0 << 0 + << 0 << 0 + << QRect(0, 0, 1280, 1024) + << QRect(1280, 0, 1280, 1024) + << QRect(0, 0, 2560, 1024) + << QRegion(); QTest::newRow("left panel/strut") << QRect(0, 0, 60, 1024) - << 60 << 0 << 0 << 0 - << 0 << 1023 - << 0 << 0 - << 0 << 0 - << 0 << 0 - << QRect(60, 0, 1220, 1024) - << QRect(1280, 0, 1280, 1024) - << QRect(60, 0, 2500, 1024) - << QRegion(0, 0, 60, 1023); + << 60 << 0 << 0 << 0 + << 0 << 1023 + << 0 << 0 + << 0 << 0 + << 0 << 0 + << QRect(60, 0, 1220, 1024) + << QRect(1280, 0, 1280, 1024) + << QRect(60, 0, 2500, 1024) + << QRegion(0, 0, 60, 1023); QTest::newRow("right panel/no strut") << QRect(1220, 0, 60, 1024) - << 0 << 0 << 0 << 0 - << 0 << 0 - << 0 << 0 - << 0 << 0 - << 0 << 0 - << QRect(0, 0, 1280, 1024) - << QRect(1280, 0, 1280, 1024) - << QRect(0, 0, 2560, 1024) - << QRegion(); + << 0 << 0 << 0 << 0 + << 0 << 0 + << 0 << 0 + << 0 << 0 + << 0 << 0 + << QRect(0, 0, 1280, 1024) + << QRect(1280, 0, 1280, 1024) + << QRect(0, 0, 2560, 1024) + << QRegion(); QTest::newRow("right panel/strut") << QRect(1220, 0, 60, 1024) - << 0 << 1340 << 0 << 0 - << 0 << 0 - << 0 << 1023 - << 0 << 0 - << 0 << 0 - << QRect(0, 0, 1220, 1024) - << QRect(1280, 0, 1280, 1024) - << QRect(0, 0, 2560, 1024) - << QRegion(1220, 0, 60, 1023); + << 0 << 1340 << 0 << 0 + << 0 << 0 + << 0 << 1023 + << 0 << 0 + << 0 << 0 + << QRect(0, 0, 1220, 1024) + << QRect(1280, 0, 1280, 1024) + << QRect(0, 0, 2560, 1024) + << QRegion(1220, 0, 60, 1023); // second screen QTest::newRow("bottom panel 1/no strut") << QRect(1280, 980, 1280, 44) - << 0 << 0 << 0 << 0 - << 0 << 0 - << 0 << 0 - << 0 << 0 - << 0 << 0 - << QRect(0, 0, 1280, 1024) - << QRect(1280, 0, 1280, 1024) - << QRect(0, 0, 2560, 1024) - << QRegion(); + << 0 << 0 << 0 << 0 + << 0 << 0 + << 0 << 0 + << 0 << 0 + << 0 << 0 + << QRect(0, 0, 1280, 1024) + << QRect(1280, 0, 1280, 1024) + << QRect(0, 0, 2560, 1024) + << QRegion(); QTest::newRow("bottom panel 1/strut") << QRect(1280, 980, 1280, 44) - << 0 << 0 << 0 << 44 - << 0 << 0 - << 0 << 0 - << 0 << 0 - << 1280 << 2559 - << QRect(0, 0, 1280, 1024) - << QRect(1280, 0, 1280, 980) - << QRect(0, 0, 2560, 980) - << QRegion(1280, 980, 1279, 44); + << 0 << 0 << 0 << 44 + << 0 << 0 + << 0 << 0 + << 0 << 0 + << 1280 << 2559 + << QRect(0, 0, 1280, 1024) + << QRect(1280, 0, 1280, 980) + << QRect(0, 0, 2560, 980) + << QRegion(1280, 980, 1279, 44); QTest::newRow("top panel 1/no strut") << QRect(1280, 0, 1280, 44) - << 0 << 0 << 0 << 0 - << 0 << 0 - << 0 << 0 - << 0 << 0 - << 0 << 0 - << QRect(0, 0, 1280, 1024) - << QRect(1280, 0, 1280, 1024) - << QRect(0, 0, 2560, 1024) - << QRegion(); + << 0 << 0 << 0 << 0 + << 0 << 0 + << 0 << 0 + << 0 << 0 + << 0 << 0 + << QRect(0, 0, 1280, 1024) + << QRect(1280, 0, 1280, 1024) + << QRect(0, 0, 2560, 1024) + << QRegion(); QTest::newRow("top panel 1 /strut") << QRect(1280, 0, 1280, 44) - << 0 << 0 << 44 << 0 - << 0 << 0 - << 0 << 0 - << 1280 << 2559 - << 0 << 0 - << QRect(0, 0, 1280, 1024) - << QRect(1280, 44, 1280, 980) - << QRect(0, 44, 2560, 980) - << QRegion(1280, 0, 1279, 44); + << 0 << 0 << 44 << 0 + << 0 << 0 + << 0 << 0 + << 1280 << 2559 + << 0 << 0 + << QRect(0, 0, 1280, 1024) + << QRect(1280, 44, 1280, 980) + << QRect(0, 44, 2560, 980) + << QRegion(1280, 0, 1279, 44); QTest::newRow("left panel 1/no strut") << QRect(1280, 0, 60, 1024) << 0 << 0 << 0 << 0 << 0 << 0 @@ -494,46 +495,46 @@ void StrutsTest::testX11Struts_data() << QRect(0, 0, 2560, 1024) << QRegion(); QTest::newRow("left panel 1/strut") << QRect(1280, 0, 60, 1024) - << 1340 << 0 << 0 << 0 - << 0 << 1023 - << 0 << 0 - << 0 << 0 - << 0 << 0 - << QRect(0, 0, 1280, 1024) - << QRect(1340, 0, 1220, 1024) - << QRect(0, 0, 2560, 1024) - << QRegion(1280, 0, 60, 1023); + << 1340 << 0 << 0 << 0 + << 0 << 1023 + << 0 << 0 + << 0 << 0 + << 0 << 0 + << QRect(0, 0, 1280, 1024) + << QRect(1340, 0, 1220, 1024) + << QRect(0, 0, 2560, 1024) + << QRegion(1280, 0, 60, 1023); // invalid struts QTest::newRow("bottom panel/ invalid strut") << QRect(0, 980, 1280, 44) - << 1280 << 0 << 0 << 44 - << 980 << 1024 - << 0 << 0 - << 0 << 0 - << 0 << 1279 - << QRect(0, 0, 1280, 1024) - << QRect(1280, 0, 1280, 1024) - << QRect(0, 0, 2560, 1024) - << QRegion(0, 980, 1280, 44); + << 1280 << 0 << 0 << 44 + << 980 << 1024 + << 0 << 0 + << 0 << 0 + << 0 << 1279 + << QRect(0, 0, 1280, 1024) + << QRect(1280, 0, 1280, 1024) + << QRect(0, 0, 2560, 1024) + << QRegion(0, 980, 1280, 44); QTest::newRow("top panel/ invalid strut") << QRect(0, 0, 1280, 44) - << 1280 << 0 << 44 << 0 - << 0 << 44 - << 0 << 0 - << 0 << 1279 - << 0 << 0 - << QRect(0, 0, 1280, 1024) - << QRect(1280, 0, 1280, 1024) - << QRect(0, 0, 2560, 1024) - << QRegion(0, 0, 1280, 44); + << 1280 << 0 << 44 << 0 + << 0 << 44 + << 0 << 0 + << 0 << 1279 + << 0 << 0 + << QRect(0, 0, 1280, 1024) + << QRect(1280, 0, 1280, 1024) + << QRect(0, 0, 2560, 1024) + << QRegion(0, 0, 1280, 44); QTest::newRow("top panel/invalid strut 2") << QRect(0, 0, 1280, 44) - << 0 << 0 << 1024 << 0 - << 0 << 0 - << 0 << 0 - << 0 << 1279 - << 0 << 0 - << QRect(0, 0, 1280, 1024) - << QRect(1280, 0, 1280, 1024) - << QRect(0, 0, 2560, 1024) - << QRegion(); + << 0 << 0 << 1024 << 0 + << 0 << 0 + << 0 << 0 + << 0 << 1279 + << 0 << 0 + << QRect(0, 0, 1280, 1024) + << QRect(1280, 0, 1280, 1024) + << QRect(0, 0, 2560, 1024) + << QRegion(); } struct XcbConnectionDeleter @@ -925,7 +926,7 @@ void StrutsTest::testWindowMoveWithPanelBetweenScreens() NETExtendedStrut strut; strut.left_start = 0; strut.left_end = 1050; - strut.left_width = 1366+24; + strut.left_width = 1366 + 24; strut.right_start = 0; strut.right_end = 0; strut.right_width = 0; diff --git a/autotests/integration/tabbox_test.cpp b/autotests/integration/tabbox_test.cpp index ab4abe08c0..8ac26a3265 100644 --- a/autotests/integration/tabbox_test.cpp +++ b/autotests/integration/tabbox_test.cpp @@ -7,6 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "cursor.h" #include "input.h" @@ -15,8 +16,8 @@ #include "wayland_server.h" #include "workspace.h" -#include #include +#include #include @@ -40,7 +41,7 @@ private Q_SLOTS: void TabBoxTest::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); diff --git a/autotests/integration/test_helpers.cpp b/autotests/integration/test_helpers.cpp index 6e022d5dd8..0f90298c03 100644 --- a/autotests/integration/test_helpers.cpp +++ b/autotests/integration/test_helpers.cpp @@ -7,34 +7,36 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include + #include "kwin_wayland_test.h" + #if KWIN_BUILD_SCREENLOCKER #include "screenlockerwatcher.h" #endif +#include "inputmethod.h" #include "wayland_server.h" #include "workspace.h" -#include "inputmethod.h" +#include #include #include #include -#include +#include #include #include #include +#include #include #include #include #include -#include #include #include #include #include -#include #include -//screenlocker +// screenlocker #if KWIN_BUILD_SCREENLOCKER #include #endif @@ -42,8 +44,8 @@ #include // system -#include #include +#include #include using namespace KWayland::Client; @@ -223,7 +225,8 @@ IdleInhibitorV1::~IdleInhibitorV1() destroy(); } -static struct { +static struct +{ ConnectionThread *connection = nullptr; EventQueue *queue = nullptr; KWayland::Client::Compositor *compositor = nullptr; @@ -239,7 +242,7 @@ static struct { Registry *registry = nullptr; WaylandOutputManagementV2 *outputManagementV2 = nullptr; QThread *thread = nullptr; - QVector outputs; + QVector outputs; QVector outputDevicesV2; IdleInhibitManagerV1 *idleInhibitManagerV1 = nullptr; AppMenuManager *appMenu = nullptr; @@ -270,7 +273,6 @@ KWayland::Client::Surface *inputPanelSurface() MockInputMethod::MockInputMethod(struct wl_registry *registry, int id, int version) : QtWayland::zwp_input_method_v1(registry, id, version) { - } MockInputMethod::~MockInputMethod() { @@ -344,7 +346,7 @@ bool setupWaylandConnection(AdditionalWaylandInterfaces flags) registry->setEventQueue(s_waylandConnection.queue); QObject::connect(registry, &Registry::outputAnnounced, [=](quint32 name, quint32 version) { - Output* output = registry->createOutput(name, version, s_waylandConnection.registry); + Output *output = registry->createOutput(name, version, s_waylandConnection.registry); s_waylandConnection.outputs << output; QObject::connect(output, &Output::removed, [=]() { output->deleteLater(); @@ -464,28 +466,28 @@ bool setupWaylandConnection(AdditionalWaylandInterfaces flags) } if (flags.testFlag(AdditionalWaylandInterface::Decoration)) { s_waylandConnection.decoration = registry->createServerSideDecorationManager(registry->interface(Registry::Interface::ServerSideDecorationManager).name, - registry->interface(Registry::Interface::ServerSideDecorationManager).version); + registry->interface(Registry::Interface::ServerSideDecorationManager).version); if (!s_waylandConnection.decoration->isValid()) { return false; } } if (flags.testFlag(AdditionalWaylandInterface::PlasmaShell)) { s_waylandConnection.plasmaShell = registry->createPlasmaShell(registry->interface(Registry::Interface::PlasmaShell).name, - registry->interface(Registry::Interface::PlasmaShell).version); + registry->interface(Registry::Interface::PlasmaShell).version); if (!s_waylandConnection.plasmaShell->isValid()) { return false; } } if (flags.testFlag(AdditionalWaylandInterface::WindowManagement)) { s_waylandConnection.windowManagement = registry->createPlasmaWindowManagement(registry->interface(Registry::Interface::PlasmaWindowManagement).name, - registry->interface(Registry::Interface::PlasmaWindowManagement).version); + registry->interface(Registry::Interface::PlasmaWindowManagement).version); if (!s_waylandConnection.windowManagement->isValid()) { return false; } } if (flags.testFlag(AdditionalWaylandInterface::PointerConstraints)) { s_waylandConnection.pointerConstraints = registry->createPointerConstraints(registry->interface(Registry::Interface::PointerConstraintsUnstableV1).name, - registry->interface(Registry::Interface::PointerConstraintsUnstableV1).version); + registry->interface(Registry::Interface::PointerConstraintsUnstableV1).version); if (!s_waylandConnection.pointerConstraints->isValid()) { return false; } @@ -614,7 +616,7 @@ PointerConstraints *waylandPointerConstraints() return s_waylandConnection.pointerConstraints; } -AppMenuManager* waylandAppMenuManager() +AppMenuManager *waylandAppMenuManager() { return s_waylandConnection.appMenu; } diff --git a/autotests/integration/test_virtualkeyboard_dbus.cpp b/autotests/integration/test_virtualkeyboard_dbus.cpp index 63945d8d6a..3198d2a59e 100644 --- a/autotests/integration/test_virtualkeyboard_dbus.cpp +++ b/autotests/integration/test_virtualkeyboard_dbus.cpp @@ -14,11 +14,11 @@ #include "virtualkeyboard_dbus.h" #include "wayland_server.h" -#include #include #include #include #include +#include #include @@ -54,10 +54,7 @@ void VirtualKeyboardDBusTest::initTestCase() QVERIFY(applicationStartedSpy.wait()); Test::initWaylandWorkspace(); - QVERIFY(setupWaylandConnection(AdditionalWaylandInterface::Seat | - AdditionalWaylandInterface::InputMethodV1 | - AdditionalWaylandInterface::TextInputManagerV2 | - AdditionalWaylandInterface::TextInputManagerV3)); + QVERIFY(setupWaylandConnection(AdditionalWaylandInterface::Seat | AdditionalWaylandInterface::InputMethodV1 | AdditionalWaylandInterface::TextInputManagerV2 | AdditionalWaylandInterface::TextInputManagerV3)); } void VirtualKeyboardDBusTest::init() diff --git a/autotests/integration/touch_input_test.cpp b/autotests/integration/touch_input_test.cpp index 47c74e11e2..4fdcf7f49d 100644 --- a/autotests/integration/touch_input_test.cpp +++ b/autotests/integration/touch_input_test.cpp @@ -7,11 +7,12 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "abstract_output.h" +#include "cursor.h" #include "platform.h" #include "touch_input.h" -#include "cursor.h" #include "wayland_server.h" #include "workspace.h" @@ -48,7 +49,7 @@ private: void TouchInputTest::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -67,8 +68,7 @@ void TouchInputTest::initTestCase() void TouchInputTest::init() { using namespace KWayland::Client; - QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat | - Test::AdditionalWaylandInterface::XdgDecorationV1)); + QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat | Test::AdditionalWaylandInterface::XdgDecorationV1)); QVERIFY(Test::waitForWaylandTouch()); m_touch = Test::waylandSeat()->createTouch(Test::waylandSeat()); QVERIFY(m_touch); @@ -88,11 +88,11 @@ void TouchInputTest::cleanup() AbstractClient *TouchInputTest::showWindow(bool decorated) { using namespace KWayland::Client; -#define VERIFY(statement) \ - if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__))\ +#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__))\ +#define COMPARE(actual, expected) \ + if (!QTest::qCompare(actual, expected, #actual, #expected, __FILE__, __LINE__)) \ return nullptr; KWayland::Client::Surface *surface = Test::createSurface(Test::waylandCompositor()); diff --git a/autotests/integration/transient_placement.cpp b/autotests/integration/transient_placement.cpp index 4d1553db6f..0eb7a480ff 100644 --- a/autotests/integration/transient_placement.cpp +++ b/autotests/integration/transient_placement.cpp @@ -7,22 +7,23 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" -#include "abstract_output.h" -#include "platform.h" + #include "abstract_client.h" +#include "abstract_output.h" #include "cursor.h" +#include "platform.h" #include "screens.h" #include "wayland_server.h" #include "workspace.h" #include -#include #include +#include #include #include -#include #include #include +#include #include #include #include @@ -60,7 +61,7 @@ private Q_SLOTS: void TransientPlacementTest::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -104,82 +105,82 @@ void TransientPlacementTest::testXdgPopup_data() // ---------------------------------------------------------------- // window in the middle, plenty of room either side: Changing anchor - const PopupLayout layoutAnchorCenter { + const PopupLayout layoutAnchorCenter{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_none, .gravity = Test::XdgPositioner::gravity_bottom_right, }; - QTest::newRow("anchorCentre") << QSize(500, 500) << QPoint(300,300) << layoutAnchorCenter << QRect(550, 550, 200, 200); + QTest::newRow("anchorCentre") << QSize(500, 500) << QPoint(300, 300) << layoutAnchorCenter << QRect(550, 550, 200, 200); - const PopupLayout layoutAnchorTopLeft { + const PopupLayout layoutAnchorTopLeft{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_top_left, .gravity = Test::XdgPositioner::gravity_bottom_right, }; - QTest::newRow("anchorTopLeft") << QSize(500, 500) << QPoint(300,300) << layoutAnchorTopLeft << QRect(350,350, 200, 200); + QTest::newRow("anchorTopLeft") << QSize(500, 500) << QPoint(300, 300) << layoutAnchorTopLeft << QRect(350, 350, 200, 200); - const PopupLayout layoutAnchorTop { + const PopupLayout layoutAnchorTop{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_top, .gravity = Test::XdgPositioner::gravity_bottom_right, }; - QTest::newRow("anchorTop") << QSize(500, 500) << QPoint(300,300) << layoutAnchorTop << QRect(550, 350, 200, 200); + QTest::newRow("anchorTop") << QSize(500, 500) << QPoint(300, 300) << layoutAnchorTop << QRect(550, 350, 200, 200); - const PopupLayout layoutAnchorTopRight { + const PopupLayout layoutAnchorTopRight{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_top_right, .gravity = Test::XdgPositioner::gravity_bottom_right, }; - QTest::newRow("anchorTopRight") << QSize(500, 500) << QPoint(300,300) << layoutAnchorTopRight << QRect(750, 350, 200, 200); + QTest::newRow("anchorTopRight") << QSize(500, 500) << QPoint(300, 300) << layoutAnchorTopRight << QRect(750, 350, 200, 200); - const PopupLayout layoutAnchorRight { + const PopupLayout layoutAnchorRight{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_right, .gravity = Test::XdgPositioner::gravity_bottom_right, }; - QTest::newRow("anchorRight") << QSize(500, 500) << QPoint(300,300) << layoutAnchorRight << QRect(750, 550, 200, 200); + QTest::newRow("anchorRight") << QSize(500, 500) << QPoint(300, 300) << layoutAnchorRight << QRect(750, 550, 200, 200); - const PopupLayout layoutAnchorBottomRight { + const PopupLayout layoutAnchorBottomRight{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_bottom_right, .gravity = Test::XdgPositioner::gravity_bottom_right, }; - QTest::newRow("anchorBottomRight") << QSize(500,500) << QPoint(300,300) << layoutAnchorBottomRight << QRect(750, 750, 200, 200); + QTest::newRow("anchorBottomRight") << QSize(500, 500) << QPoint(300, 300) << layoutAnchorBottomRight << QRect(750, 750, 200, 200); - const PopupLayout layoutAnchorBottom { + const PopupLayout layoutAnchorBottom{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_bottom, .gravity = Test::XdgPositioner::gravity_bottom_right, }; - QTest::newRow("anchorBottom") << QSize(500, 500) << QPoint(300,300) << layoutAnchorBottom << QRect(550, 750, 200, 200); + QTest::newRow("anchorBottom") << QSize(500, 500) << QPoint(300, 300) << layoutAnchorBottom << QRect(550, 750, 200, 200); - const PopupLayout layoutAnchorBottomLeft { + const PopupLayout layoutAnchorBottomLeft{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_bottom_left, .gravity = Test::XdgPositioner::gravity_bottom_right, }; - QTest::newRow("anchorBottomLeft") << QSize(500, 500) << QPoint(300,300) << layoutAnchorBottomLeft << QRect(350, 750, 200, 200); + QTest::newRow("anchorBottomLeft") << QSize(500, 500) << QPoint(300, 300) << layoutAnchorBottomLeft << QRect(350, 750, 200, 200); - const PopupLayout layoutAnchorLeft { + const PopupLayout layoutAnchorLeft{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_left, .gravity = Test::XdgPositioner::gravity_bottom_right, }; - QTest::newRow("anchorLeft") << QSize(500, 500) << QPoint(300,300) << layoutAnchorLeft << QRect(350, 550, 200, 200); + QTest::newRow("anchorLeft") << QSize(500, 500) << QPoint(300, 300) << layoutAnchorLeft << QRect(350, 550, 200, 200); // ---------------------------------------------------------------- // window in the middle, plenty of room either side: Changing gravity around the bottom right anchor - const PopupLayout layoutGravityCenter { + const PopupLayout layoutGravityCenter{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_bottom_right, @@ -187,7 +188,7 @@ void TransientPlacementTest::testXdgPopup_data() }; QTest::newRow("gravityCentre") << QSize(500, 500) << QPoint(300, 300) << layoutGravityCenter << QRect(650, 650, 200, 200); - const PopupLayout layoutGravityTopLeft { + const PopupLayout layoutGravityTopLeft{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_bottom_right, @@ -195,7 +196,7 @@ void TransientPlacementTest::testXdgPopup_data() }; QTest::newRow("gravityTopLeft") << QSize(500, 500) << QPoint(300, 300) << layoutGravityTopLeft << QRect(550, 550, 200, 200); - const PopupLayout layoutGravityTop { + const PopupLayout layoutGravityTop{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_bottom_right, @@ -203,7 +204,7 @@ void TransientPlacementTest::testXdgPopup_data() }; QTest::newRow("gravityTop") << QSize(500, 500) << QPoint(300, 300) << layoutGravityTop << QRect(650, 550, 200, 200); - const PopupLayout layoutGravityTopRight { + const PopupLayout layoutGravityTopRight{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_bottom_right, @@ -211,7 +212,7 @@ void TransientPlacementTest::testXdgPopup_data() }; QTest::newRow("gravityTopRight") << QSize(500, 500) << QPoint(300, 300) << layoutGravityTopRight << QRect(750, 550, 200, 200); - const PopupLayout layoutGravityRight { + const PopupLayout layoutGravityRight{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_bottom_right, @@ -219,7 +220,7 @@ void TransientPlacementTest::testXdgPopup_data() }; QTest::newRow("gravityRight") << QSize(500, 500) << QPoint(300, 300) << layoutGravityRight << QRect(750, 650, 200, 200); - const PopupLayout layoutGravityBottomRight { + const PopupLayout layoutGravityBottomRight{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_bottom_right, @@ -227,7 +228,7 @@ void TransientPlacementTest::testXdgPopup_data() }; QTest::newRow("gravityBottomRight") << QSize(500, 500) << QPoint(300, 300) << layoutGravityBottomRight << QRect(750, 750, 200, 200); - const PopupLayout layoutGravityBottom { + const PopupLayout layoutGravityBottom{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_bottom_right, @@ -235,7 +236,7 @@ void TransientPlacementTest::testXdgPopup_data() }; QTest::newRow("gravityBottom") << QSize(500, 500) << QPoint(300, 300) << layoutGravityBottom << QRect(650, 750, 200, 200); - const PopupLayout layoutGravityBottomLeft { + const PopupLayout layoutGravityBottomLeft{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_bottom_right, @@ -243,7 +244,7 @@ void TransientPlacementTest::testXdgPopup_data() }; QTest::newRow("gravityBottomLeft") << QSize(500, 500) << QPoint(300, 300) << layoutGravityBottomLeft << QRect(550, 750, 200, 200); - const PopupLayout layoutGravityLeft { + const PopupLayout layoutGravityLeft{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_bottom_right, @@ -255,7 +256,7 @@ void TransientPlacementTest::testXdgPopup_data() // constrain and slide // popup is still 200,200. window moved near edge of screen, popup always comes out towards the screen edge - const PopupLayout layoutSlideTop { + const PopupLayout layoutSlideTop{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_top, @@ -264,7 +265,7 @@ void TransientPlacementTest::testXdgPopup_data() }; QTest::newRow("constraintSlideTop") << QSize(500, 500) << QPoint(80, 80) << layoutSlideTop << QRect(80 + 250 - 100, 0, 200, 200); - const PopupLayout layoutSlideLeft { + const PopupLayout layoutSlideLeft{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_left, @@ -273,7 +274,7 @@ void TransientPlacementTest::testXdgPopup_data() }; QTest::newRow("constraintSlideLeft") << QSize(500, 500) << QPoint(80, 80) << layoutSlideLeft << QRect(0, 80 + 250 - 100, 200, 200); - const PopupLayout layoutSlideRight { + const PopupLayout layoutSlideRight{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_right, @@ -282,7 +283,7 @@ void TransientPlacementTest::testXdgPopup_data() }; QTest::newRow("constraintSlideRight") << QSize(500, 500) << QPoint(700, 80) << layoutSlideRight << QRect(1280 - 200, 80 + 250 - 100, 200, 200); - const PopupLayout layoutSlideBottom { + const PopupLayout layoutSlideBottom{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_bottom, @@ -291,7 +292,7 @@ void TransientPlacementTest::testXdgPopup_data() }; QTest::newRow("constraintSlideBottom") << QSize(500, 500) << QPoint(80, 500) << layoutSlideBottom << QRect(80 + 250 - 100, 1024 - 200, 200, 200); - const PopupLayout layoutSlideBottomRight { + const PopupLayout layoutSlideBottomRight{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_bottom_right, @@ -303,7 +304,7 @@ void TransientPlacementTest::testXdgPopup_data() // ---------------------------------------------------------------- // constrain and flip - const PopupLayout layoutFlipTop { + const PopupLayout layoutFlipTop{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_top, @@ -312,7 +313,7 @@ void TransientPlacementTest::testXdgPopup_data() }; QTest::newRow("constraintFlipTop") << QSize(500, 500) << QPoint(80, 80) << layoutFlipTop << QRect(230, 80 + 500 - 50, 200, 200); - const PopupLayout layoutFlipLeft { + const PopupLayout layoutFlipLeft{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_left, @@ -321,7 +322,7 @@ void TransientPlacementTest::testXdgPopup_data() }; QTest::newRow("constraintFlipLeft") << QSize(500, 500) << QPoint(80, 80) << layoutFlipLeft << QRect(80 + 500 - 50, 230, 200, 200); - const PopupLayout layoutFlipRight { + const PopupLayout layoutFlipRight{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_right, @@ -330,7 +331,7 @@ void TransientPlacementTest::testXdgPopup_data() }; QTest::newRow("constraintFlipRight") << QSize(500, 500) << QPoint(700, 80) << layoutFlipRight << QRect(700 + 50 - 200, 230, 200, 200); - const PopupLayout layoutFlipBottom { + const PopupLayout layoutFlipBottom{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_bottom, @@ -339,7 +340,7 @@ void TransientPlacementTest::testXdgPopup_data() }; QTest::newRow("constraintFlipBottom") << QSize(500, 500) << QPoint(80, 500) << layoutFlipBottom << QRect(230, 500 + 50 - 200, 200, 200); - const PopupLayout layoutFlipBottomRight { + const PopupLayout layoutFlipBottomRight{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_bottom_right, @@ -348,9 +349,9 @@ void TransientPlacementTest::testXdgPopup_data() }; QTest::newRow("constraintFlipBottomRight") << QSize(500, 500) << QPoint(700, 500) << layoutFlipBottomRight << QRect(700 + 50 - 200, 500 + 50 - 200, 200, 200); - const PopupLayout layoutFlipRightNoAnchor { + const PopupLayout layoutFlipRightNoAnchor{ .anchorRect = QRect(50, 50, 400, 400), - //as popup is positioned in the middle of the parent we need a massive popup to be able to overflow + // as popup is positioned in the middle of the parent we need a massive popup to be able to overflow .size = QSize(400, 400), .anchor = Test::XdgPositioner::anchor_top, .gravity = Test::XdgPositioner::gravity_right, @@ -358,7 +359,7 @@ void TransientPlacementTest::testXdgPopup_data() }; QTest::newRow("constraintFlipRightNoAnchor") << QSize(500, 500) << QPoint(700, 80) << layoutFlipRightNoAnchor << QRect(700 + 250 - 400, 330, 400, 400); - const PopupLayout layoutFlipRightNoGravity { + const PopupLayout layoutFlipRightNoGravity{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(300, 200), .anchor = Test::XdgPositioner::anchor_right, @@ -370,7 +371,7 @@ void TransientPlacementTest::testXdgPopup_data() // ---------------------------------------------------------------- // resize - const PopupLayout layoutResizeTop { + const PopupLayout layoutResizeTop{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_top, @@ -379,7 +380,7 @@ void TransientPlacementTest::testXdgPopup_data() }; QTest::newRow("resizeTop") << QSize(500, 500) << QPoint(80, 80) << layoutResizeTop << QRect(80 + 250 - 100, 0, 200, 130); - const PopupLayout layoutResizeLeft { + const PopupLayout layoutResizeLeft{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_left, @@ -388,7 +389,7 @@ void TransientPlacementTest::testXdgPopup_data() }; QTest::newRow("resizeLeft") << QSize(500, 500) << QPoint(80, 80) << layoutResizeLeft << QRect(0, 80 + 250 - 100, 130, 200); - const PopupLayout layoutResizeRight { + const PopupLayout layoutResizeRight{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_right, @@ -397,7 +398,7 @@ void TransientPlacementTest::testXdgPopup_data() }; QTest::newRow("resizeRight") << QSize(500, 500) << QPoint(700, 80) << layoutResizeRight << QRect(700 + 50 + 400, 80 + 250 - 100, 130, 200); - const PopupLayout layoutResizeBottom { + const PopupLayout layoutResizeBottom{ .anchorRect = QRect(50, 50, 400, 400), .size = QSize(200, 200), .anchor = Test::XdgPositioner::anchor_bottom, @@ -430,7 +431,7 @@ void TransientPlacementTest::testXdgPopup() parent->move(parentPosition); QCOMPARE(parent->frameGeometry(), QRect(parentPosition, parentSize)); - //create popup + // create popup QFETCH(PopupLayout, layout); KWayland::Client::Surface *transientSurface = Test::createSurface(Test::waylandCompositor()); @@ -486,7 +487,7 @@ void TransientPlacementTest::testXdgPopupWithPanel() QCOMPARE(dock->hasStrut(), true); QVERIFY(workspace()->clientArea(PlacementArea, 0, 1) != workspace()->clientArea(FullScreenArea, 0, 1)); - //create parent + // create parent QScopedPointer parentSurface(Test::createSurface()); QVERIFY(parentSurface); auto parentShellSurface = Test::createXdgToplevelSurface(parentSurface.data()); @@ -536,7 +537,7 @@ void TransientPlacementTest::testXdgPopupWithPanel() transientSurface.reset(Test::createSurface()); QVERIFY(transientSurface); - const QRect anchorRect2(50, screens()->geometry(0).height()-100, 200,200); + const QRect anchorRect2(50, screens()->geometry(0).height() - 100, 200, 200); QScopedPointer positioner2(Test::createXdgPositioner()); positioner2->set_size(200, 200); positioner2->set_anchor_rect(anchorRect2.x(), anchorRect2.y(), anchorRect2.width(), anchorRect2.height()); diff --git a/autotests/integration/virtual_desktop_test.cpp b/autotests/integration/virtual_desktop_test.cpp index f6809b9106..0b1bb77d3f 100644 --- a/autotests/integration/virtual_desktop_test.cpp +++ b/autotests/integration/virtual_desktop_test.cpp @@ -7,6 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "main.h" #include "platform.h" @@ -37,7 +38,7 @@ private Q_SLOTS: void VirtualDesktopTest::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -174,7 +175,7 @@ void VirtualDesktopTest::testWindowOnMultipleDesktops() QCOMPARE(client->desktops().count(), 1u); QCOMPARE(VirtualDesktopManager::self()->currentDesktop(), client->desktops().first()); - //Set the window on desktop 2 as well + // Set the window on desktop 2 as well client->enterDesktop(VirtualDesktopManager::self()->desktopForX11Id(2)); QCOMPARE(client->desktops().count(), 2u); QCOMPARE(VirtualDesktopManager::self()->desktops()[2], client->desktops()[0]); @@ -182,45 +183,45 @@ void VirtualDesktopTest::testWindowOnMultipleDesktops() QVERIFY(client->isOnDesktop(2)); QVERIFY(client->isOnDesktop(3)); - //leave desktop 3 + // leave desktop 3 client->leaveDesktop(VirtualDesktopManager::self()->desktopForX11Id(3)); QCOMPARE(client->desktops().count(), 1u); - //leave desktop 2 + // leave desktop 2 client->leaveDesktop(VirtualDesktopManager::self()->desktopForX11Id(2)); QCOMPARE(client->desktops().count(), 0u); - //we should be on all desktops now + // we should be on all desktops now QVERIFY(client->isOnAllDesktops()); - //put on desktop 1 + // put on desktop 1 client->enterDesktop(VirtualDesktopManager::self()->desktopForX11Id(1)); QVERIFY(client->isOnDesktop(1)); QVERIFY(!client->isOnDesktop(2)); QVERIFY(!client->isOnDesktop(3)); QCOMPARE(client->desktops().count(), 1u); - //put on desktop 2 + // put on desktop 2 client->enterDesktop(VirtualDesktopManager::self()->desktopForX11Id(2)); QVERIFY(client->isOnDesktop(1)); QVERIFY(client->isOnDesktop(2)); QVERIFY(!client->isOnDesktop(3)); QCOMPARE(client->desktops().count(), 2u); - //put on desktop 3 + // put on desktop 3 client->enterDesktop(VirtualDesktopManager::self()->desktopForX11Id(3)); QVERIFY(client->isOnDesktop(1)); QVERIFY(client->isOnDesktop(2)); QVERIFY(client->isOnDesktop(3)); QCOMPARE(client->desktops().count(), 3u); - //entering twice dooes nothing + // entering twice dooes nothing client->enterDesktop(VirtualDesktopManager::self()->desktopForX11Id(3)); QCOMPARE(client->desktops().count(), 3u); - //adding to "all desktops" results in just that one desktop + // adding to "all desktops" results in just that one desktop client->setOnAllDesktops(true); QCOMPARE(client->desktops().count(), 0u); client->enterDesktop(VirtualDesktopManager::self()->desktopForX11Id(3)); QVERIFY(client->isOnDesktop(3)); QCOMPARE(client->desktops().count(), 1u); - //leaving a desktop on "all desktops" puts on everything else + // leaving a desktop on "all desktops" puts on everything else client->setOnAllDesktops(true); QCOMPARE(client->desktops().count(), 0u); client->leaveDesktop(VirtualDesktopManager::self()->desktopForX11Id(3)); @@ -253,7 +254,7 @@ void VirtualDesktopTest::testRemoveDesktopWithWindow() QCOMPARE(client->desktops().count(), 1u); QCOMPARE(VirtualDesktopManager::self()->currentDesktop(), client->desktops().first()); - //Set the window on desktop 2 as well + // Set the window on desktop 2 as well client->enterDesktop(VirtualDesktopManager::self()->desktops()[1]); QCOMPARE(client->desktops().count(), 2u); QCOMPARE(VirtualDesktopManager::self()->desktops()[2], client->desktops()[0]); @@ -261,25 +262,25 @@ void VirtualDesktopTest::testRemoveDesktopWithWindow() QVERIFY(client->isOnDesktop(2)); QVERIFY(client->isOnDesktop(3)); - //remove desktop 3 + // remove desktop 3 VirtualDesktopManager::self()->setCount(2); QCOMPARE(client->desktops().count(), 1u); - //window is only on desktop 2 + // window is only on desktop 2 QCOMPARE(VirtualDesktopManager::self()->desktops()[1], client->desktops()[0]); - //Again 3 desktops + // Again 3 desktops VirtualDesktopManager::self()->setCount(3); - //move window to be only on desktop 3 + // move window to be only on desktop 3 client->enterDesktop(VirtualDesktopManager::self()->desktops()[2]); client->leaveDesktop(VirtualDesktopManager::self()->desktops()[1]); QCOMPARE(client->desktops().count(), 1u); - //window is only on desktop 3 + // window is only on desktop 3 QCOMPARE(VirtualDesktopManager::self()->desktops()[2], client->desktops()[0]); - //remove desktop 3 + // remove desktop 3 VirtualDesktopManager::self()->setCount(2); QCOMPARE(client->desktops().count(), 1u); - //window is only on desktop 2 + // window is only on desktop 2 QCOMPARE(VirtualDesktopManager::self()->desktops()[1], client->desktops()[0]); } diff --git a/autotests/integration/window_rules_test.cpp b/autotests/integration/window_rules_test.cpp index 1987ae3a5c..b92ea7eb5c 100644 --- a/autotests/integration/window_rules_test.cpp +++ b/autotests/integration/window_rules_test.cpp @@ -7,15 +7,16 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_output.h" -#include "platform.h" #include "atoms.h" -#include "x11client.h" #include "cursor.h" #include "deleted.h" +#include "platform.h" #include "rules.h" #include "wayland_server.h" #include "workspace.h" +#include "x11client.h" #include #include @@ -39,8 +40,8 @@ private Q_SLOTS: void WindowRuleTest::initTestCase() { - qRegisterMetaType(); - qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -102,9 +103,7 @@ void WindowRuleTest::testApplyInitialMaximizeVert() xcb_window_t w = xcb_generate_id(c.data()); const QRect windowGeometry = QRect(0, 0, 10, 20); const uint32_t values[] = { - XCB_EVENT_MASK_ENTER_WINDOW | - XCB_EVENT_MASK_LEAVE_WINDOW - }; + XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW}; xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, w, rootWindow(), windowGeometry.x(), windowGeometry.y(), @@ -172,9 +171,7 @@ void WindowRuleTest::testWindowClassChange() xcb_window_t w = xcb_generate_id(c.data()); const QRect windowGeometry = QRect(0, 0, 10, 20); const uint32_t values[] = { - XCB_EVENT_MASK_ENTER_WINDOW | - XCB_EVENT_MASK_LEAVE_WINDOW - }; + XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW}; xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, w, rootWindow(), windowGeometry.x(), windowGeometry.y(), diff --git a/autotests/integration/window_selection_test.cpp b/autotests/integration/window_selection_test.cpp index 4c8ed1ea79..e0a89c099e 100644 --- a/autotests/integration/window_selection_test.cpp +++ b/autotests/integration/window_selection_test.cpp @@ -7,6 +7,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "abstract_output.h" #include "cursor.h" @@ -52,7 +53,7 @@ private Q_SLOTS: void TestWindowSelection::initTestCase() { - qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -107,7 +108,7 @@ void TestWindowSelection::testSelectOnWindowPointer() QVERIFY(pointerEnteredSpy.wait()); Toplevel *selectedWindow = nullptr; - auto callback = [&selectedWindow] (Toplevel *t) { + auto callback = [&selectedWindow](Toplevel *t) { selectedWindow = t; }; @@ -191,7 +192,7 @@ void TestWindowSelection::testSelectOnWindowKeyboard() QVERIFY(!client->frameGeometry().contains(KWin::Cursors::self()->mouse()->pos())); Toplevel *selectedWindow = nullptr; - auto callback = [&selectedWindow] (Toplevel *t) { + auto callback = [&selectedWindow](Toplevel *t) { selectedWindow = t; }; @@ -255,7 +256,7 @@ void TestWindowSelection::testSelectOnWindowTouch() QVERIFY(client); Toplevel *selectedWindow = nullptr; - auto callback = [&selectedWindow] (Toplevel *t) { + auto callback = [&selectedWindow](Toplevel *t) { selectedWindow = t; }; @@ -328,7 +329,7 @@ void TestWindowSelection::testCancelOnWindowPointer() QVERIFY(pointerEnteredSpy.wait()); Toplevel *selectedWindow = nullptr; - auto callback = [&selectedWindow] (Toplevel *t) { + auto callback = [&selectedWindow](Toplevel *t) { selectedWindow = t; }; @@ -387,7 +388,7 @@ void TestWindowSelection::testCancelOnWindowKeyboard() QVERIFY(pointerEnteredSpy.wait()); Toplevel *selectedWindow = nullptr; - auto callback = [&selectedWindow] (Toplevel *t) { + auto callback = [&selectedWindow](Toplevel *t) { selectedWindow = t; }; @@ -446,7 +447,7 @@ void TestWindowSelection::testSelectPointPointer() QVERIFY(pointerEnteredSpy.wait()); QPoint point; - auto callback = [&point] (const QPoint &p) { + auto callback = [&point](const QPoint &p) { point = p; }; @@ -465,7 +466,7 @@ void TestWindowSelection::testSelectPointPointer() // trying again should not be allowed QPoint point2; - kwinApp()->platform()->startInteractivePositionSelection([&point2] (const QPoint &p) { + kwinApp()->platform()->startInteractivePositionSelection([&point2](const QPoint &p) { point2 = p; }); QCOMPARE(point2, QPoint(-1, -1)); @@ -510,7 +511,7 @@ void TestWindowSelection::testSelectPointTouch() { // this test verifies point selection through touch works QPoint point; - auto callback = [&point] (const QPoint &p) { + auto callback = [&point](const QPoint &p) { point = p; }; diff --git a/autotests/integration/x11_client_test.cpp b/autotests/integration/x11_client_test.cpp index 131db1a359..d3597793b1 100644 --- a/autotests/integration/x11_client_test.cpp +++ b/autotests/integration/x11_client_test.cpp @@ -7,17 +7,18 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "atoms.h" -#include "x11client.h" #include "composite.h" -#include "effects.h" -#include "effectloader.h" #include "cursor.h" #include "deleted.h" +#include "effectloader.h" +#include "effects.h" #include "platform.h" #include "screens.h" #include "wayland_server.h" #include "workspace.h" +#include "x11client.h" #include @@ -30,7 +31,7 @@ static const QString s_socketName = QStringLiteral("wayland_test_x11_client-0"); class X11ClientTest : public QObject { -Q_OBJECT + Q_OBJECT private Q_SLOTS: void initTestCase(); void init(); @@ -55,8 +56,8 @@ private Q_SLOTS: void X11ClientTest::initTestCase() { - qRegisterMetaType(); - qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -726,8 +727,9 @@ void X11ClientTest::testX11WindowId() QUuid deletedUuid; QCOMPARE(deletedUuid.isNull(), true); - connect(client, &X11Client::windowClosed, this, [&deletedUuid] (Toplevel *, Deleted *d) { deletedUuid = d->internalId(); }); - + connect(client, &X11Client::windowClosed, this, [&deletedUuid](Toplevel *, Deleted *d) { + deletedUuid = d->internalId(); + }); NETRootInfo rootInfo(c.data(), NET::WMAllProperties); QCOMPARE(rootInfo.activeWindow(), client->window()); @@ -909,7 +911,6 @@ void X11ClientTest::testCaptionMultipleWindows() QTRY_COMPARE(QByteArray(info5.visibleIconName()), QByteArray()); } - void X11ClientTest::testFullscreenWindowGroups() { // this test creates an X11 window and puts it to full screen diff --git a/autotests/integration/xdgshellclient_rules_test.cpp b/autotests/integration/xdgshellclient_rules_test.cpp index 4036342880..f2a8b967fe 100644 --- a/autotests/integration/xdgshellclient_rules_test.cpp +++ b/autotests/integration/xdgshellclient_rules_test.cpp @@ -147,7 +147,8 @@ private Q_SLOTS: void testMatchAfterNameChange(); private: - template void setWindowRule(const QString &property, const T &value, int policy); + template + void setWindowRule(const QString &property, const T &value, int policy); private: KSharedConfig::Ptr m_config; @@ -220,7 +221,7 @@ std::tuple c return {client, surface, shellSurface}; } -template +template void TestXdgShellClientRules::setWindowRule(const QString &property, const T &value, int policy) { // Initialize RuleBook with the test rule. diff --git a/autotests/integration/xdgshellclient_test.cpp b/autotests/integration/xdgshellclient_test.cpp index eb4637aaa9..1b701fe1ef 100644 --- a/autotests/integration/xdgshellclient_test.cpp +++ b/autotests/integration/xdgshellclient_test.cpp @@ -8,13 +8,14 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "abstract_wayland_output.h" #include "cursor.h" #include "decorations/decorationbridge.h" #include "decorations/settings.h" -#include "effects.h" #include "deleted.h" +#include "effects.h" #include "platform.h" #include "screens.h" #include "virtualdesktops.h" @@ -25,15 +26,15 @@ #include #include -#include +#include #include +#include #include #include #include #include #include #include -#include #include #include @@ -41,8 +42,8 @@ #include // system -#include #include +#include #include #include @@ -165,9 +166,9 @@ void TestXdgShellClient::testXdgWindowRepositioning() void TestXdgShellClient::initTestCase() { - qRegisterMetaType(); - qRegisterMetaType(); - qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); @@ -186,13 +187,11 @@ void TestXdgShellClient::initTestCase() void TestXdgShellClient::init() { - QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat | - Test::AdditionalWaylandInterface::XdgDecorationV1 | - Test::AdditionalWaylandInterface::AppMenu)); + QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Seat | Test::AdditionalWaylandInterface::XdgDecorationV1 | Test::AdditionalWaylandInterface::AppMenu)); QVERIFY(Test::waitForWaylandPointer()); workspace()->setActiveOutput(QPoint(640, 512)); - //put mouse in the middle of screen one + // put mouse in the middle of screen one KWin::Cursors::self()->mouse()->setPos(QPoint(640, 512)); } @@ -288,11 +287,11 @@ void TestXdgShellClient::testDesktopPresenceChanged() QCOMPARE(desktopPresenceChangedEffectsSpy.count(), 1); // verify the arguments - QCOMPARE(desktopPresenceChangedClientSpy.first().at(0).value(), c); + QCOMPARE(desktopPresenceChangedClientSpy.first().at(0).value(), c); QCOMPARE(desktopPresenceChangedClientSpy.first().at(1).toInt(), 1); - QCOMPARE(desktopPresenceChangedWorkspaceSpy.first().at(0).value(), c); + QCOMPARE(desktopPresenceChangedWorkspaceSpy.first().at(0).value(), c); QCOMPARE(desktopPresenceChangedWorkspaceSpy.first().at(1).toInt(), 1); - QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(0).value(), c->effectWindow()); + QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(0).value(), c->effectWindow()); QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(1).toInt(), 1); QCOMPARE(desktopPresenceChangedEffectsSpy.first().at(2).toInt(), 2); } @@ -301,37 +300,37 @@ void TestXdgShellClient::testWindowOutputs() { QScopedPointer surface(Test::createSurface()); QScopedPointer shellSurface(Test::createXdgToplevelSurface(surface.data())); - auto size = QSize(200,200); + auto size = QSize(200, 200); QSignalSpy outputEnteredSpy(surface.data(), &KWayland::Client::Surface::outputEntered); QSignalSpy outputLeftSpy(surface.data(), &KWayland::Client::Surface::outputLeft); auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::blue); - //move to be in the first screen - c->moveResize(QRect(QPoint(100,100), size)); - //we don't don't know where the compositor first placed this window, - //this might fire, it might not + // move to be in the first screen + c->moveResize(QRect(QPoint(100, 100), size)); + // we don't don't know where the compositor first placed this window, + // this might fire, it might not outputEnteredSpy.wait(5); outputEnteredSpy.clear(); QCOMPARE(surface->outputs().count(), 1); - QCOMPARE(surface->outputs().first()->globalPosition(), QPoint(0,0)); + QCOMPARE(surface->outputs().first()->globalPosition(), QPoint(0, 0)); - //move to overlapping both first and second screen - c->moveResize(QRect(QPoint(1250,100), size)); + // move to overlapping both first and second screen + c->moveResize(QRect(QPoint(1250, 100), size)); QVERIFY(outputEnteredSpy.wait()); QCOMPARE(outputEnteredSpy.count(), 1); QCOMPARE(outputLeftSpy.count(), 0); QCOMPARE(surface->outputs().count(), 2); QVERIFY(surface->outputs()[0] != surface->outputs()[1]); - //move entirely into second screen - c->moveResize(QRect(QPoint(1400,100), size)); + // move entirely into second screen + c->moveResize(QRect(QPoint(1400, 100), size)); QVERIFY(outputLeftSpy.wait()); QCOMPARE(outputEnteredSpy.count(), 1); QCOMPARE(outputLeftSpy.count(), 1); QCOMPARE(surface->outputs().count(), 1); - QCOMPARE(surface->outputs().first()->globalPosition(), QPoint(1280,0)); + QCOMPARE(surface->outputs().first()->globalPosition(), QPoint(1280, 0)); } void TestXdgShellClient::testMinimizeActiveWindow() @@ -642,7 +641,7 @@ void TestXdgShellClient::testHidden() QVERIFY(c->wantsInput()); QVERIFY(c->wantsTabFocus()); - //QCOMPARE(workspace()->activeClient(), c); + // QCOMPARE(workspace()->activeClient(), c); } void TestXdgShellClient::testDesktopFileName() @@ -746,7 +745,7 @@ void TestXdgShellClient::testCaptionMultipleWindows() void TestXdgShellClient::testUnresponsiveWindow_data() { - QTest::addColumn("shellInterface");//see env selection in qwaylandintegration.cpp + QTest::addColumn("shellInterface"); // see env selection in qwaylandintegration.cpp QTest::addColumn("socketMode"); QTest::newRow("xdg display") << "xdg-shell" << false; @@ -793,45 +792,45 @@ void TestXdgShellClient::testUnresponsiveWindow() } ::kill(process->processId(), SIGUSR1); // send a signal to freeze the process - killClient = clientAddedSpy.first().first().value(); + killClient = clientAddedSpy.first().first().value(); QVERIFY(killClient); QSignalSpy unresponsiveSpy(killClient, &AbstractClient::unresponsiveChanged); - QSignalSpy killedSpy(process.data(), static_cast(&QProcess::finished)); + QSignalSpy killedSpy(process.data(), static_cast(&QProcess::finished)); QSignalSpy deletedSpy(killClient, &QObject::destroyed); qint64 startTime = QDateTime::currentMSecsSinceEpoch(); - //wait for the process to be frozen + // wait for the process to be frozen QTest::qWait(10); - //pretend the user clicked the close button + // pretend the user clicked the close button killClient->closeWindow(); - //client should not yet be marked unresponsive nor killed + // client should not yet be marked unresponsive nor killed QVERIFY(!killClient->unresponsive()); QVERIFY(killedSpy.isEmpty()); QVERIFY(unresponsiveSpy.wait()); - //client should be marked unresponsive but not killed + // client should be marked unresponsive but not killed auto elapsed1 = QDateTime::currentMSecsSinceEpoch() - startTime; - QVERIFY(elapsed1 > 900 && elapsed1 < 1200); //ping timer is 1s, but coarse timers on a test across two processes means we need a fuzzy compare + QVERIFY(elapsed1 > 900 && elapsed1 < 1200); // ping timer is 1s, but coarse timers on a test across two processes means we need a fuzzy compare QVERIFY(killClient->unresponsive()); QVERIFY(killedSpy.isEmpty()); QVERIFY(deletedSpy.wait()); if (!socketMode) { - //process was killed - because we're across process this could happen in either order + // process was killed - because we're across process this could happen in either order QVERIFY(killedSpy.count() || killedSpy.wait()); } auto elapsed2 = QDateTime::currentMSecsSinceEpoch() - startTime; - QVERIFY(elapsed2 > 1800); //second ping comes in a second later + QVERIFY(elapsed2 > 1800); // second ping comes in a second later } void TestXdgShellClient::testAppMenu() { - //register a faux appmenu client - QVERIFY (QDBusConnection::sessionBus().registerService("org.kde.kappmenu")); + // register a faux appmenu client + QVERIFY(QDBusConnection::sessionBus().registerService("org.kde.kappmenu")); QScopedPointer surface(Test::createSurface()); QScopedPointer shellSurface(Test::createXdgToplevelSurface(surface.data())); @@ -845,7 +844,7 @@ void TestXdgShellClient::testAppMenu() QCOMPARE(c->applicationMenuServiceName(), QString("service.name")); QCOMPARE(c->applicationMenuObjectPath(), QString("object/path")); - QVERIFY (QDBusConnection::sessionBus().unregisterService("org.kde.kappmenu")); + QVERIFY(QDBusConnection::sessionBus().unregisterService("org.kde.kappmenu")); } void TestXdgShellClient::testSendClientWithTransientToDesktop() @@ -938,7 +937,7 @@ void TestXdgShellClient::testXdgDecoration_data() QTest::addColumn("expectedMode"); QTest::newRow("client side requested") << Test::XdgToplevelDecorationV1::mode_client_side << Test::XdgToplevelDecorationV1::mode_client_side; - QTest::newRow("server side requested") << Test::XdgToplevelDecorationV1::mode_server_side << Test::XdgToplevelDecorationV1::mode_server_side; + QTest::newRow("server side requested") << Test::XdgToplevelDecorationV1::mode_server_side << Test::XdgToplevelDecorationV1::mode_server_side; } void TestXdgShellClient::testXdgDecoration() @@ -953,10 +952,10 @@ void TestXdgShellClient::testXdgDecoration() QFETCH(Test::XdgToplevelDecorationV1::mode, requestedMode); QFETCH(Test::XdgToplevelDecorationV1::mode, expectedMode); - //request a mode + // request a mode deco->set_mode(requestedMode); - //kwin will send a configure + // kwin will send a configure QVERIFY(surfaceConfigureRequestedSpy.wait()); QCOMPARE(decorationConfigureRequestedSpy.count(), 1); @@ -970,7 +969,7 @@ void TestXdgShellClient::testXdgDecoration() void TestXdgShellClient::testXdgNeverCommitted() { - //check we don't crash if we create a shell object but delete the XdgShellClient before committing it + // check we don't crash if we create a shell object but delete the XdgShellClient before committing it QScopedPointer surface(Test::createSurface()); QScopedPointer shellSurface(Test::createXdgToplevelSurface(surface.data(), Test::CreationSetup::CreateOnly)); } @@ -988,11 +987,11 @@ void TestXdgShellClient::testXdgInitialState() const auto size = toplevelConfigureRequestedSpy.first()[0].value(); - QCOMPARE(size, QSize(0, 0)); //client should chose it's preferred size + QCOMPARE(size, QSize(0, 0)); // client should chose it's preferred size shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.first()[0].toUInt()); - auto c = Test::renderAndWaitForShown(surface.data(), QSize(200,100), Qt::blue); + auto c = Test::renderAndWaitForShown(surface.data(), QSize(200, 100), Qt::blue); QCOMPARE(c->size(), QSize(200, 100)); } diff --git a/autotests/integration/xwayland_input_test.cpp b/autotests/integration/xwayland_input_test.cpp index 0cd6632fe5..9877abcbdb 100644 --- a/autotests/integration/xwayland_input_test.cpp +++ b/autotests/integration/xwayland_input_test.cpp @@ -7,13 +7,14 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_output.h" -#include "platform.h" -#include "x11client.h" #include "cursor.h" #include "deleted.h" +#include "platform.h" #include "wayland_server.h" #include "workspace.h" +#include "x11client.h" #include @@ -39,8 +40,8 @@ private Q_SLOTS: void XWaylandInputTest::initTestCase() { - qRegisterMetaType(); - qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); @@ -105,14 +106,16 @@ void X11EventReaderHelper::processXcbEvents() while (auto event = xcb_poll_for_event(m_connection)) { const uint8_t eventType = event->response_type & ~0x80; switch (eventType) { - case XCB_ENTER_NOTIFY: { - auto enterEvent = reinterpret_cast(event); - Q_EMIT entered(QPoint(enterEvent->event_x, enterEvent->event_y)); - break; } - case XCB_LEAVE_NOTIFY: { - auto leaveEvent = reinterpret_cast(event); - Q_EMIT left(QPoint(leaveEvent->event_x, leaveEvent->event_y)); - break; } + case XCB_ENTER_NOTIFY: { + auto enterEvent = reinterpret_cast(event); + Q_EMIT entered(QPoint(enterEvent->event_x, enterEvent->event_y)); + break; + } + case XCB_LEAVE_NOTIFY: { + auto leaveEvent = reinterpret_cast(event); + Q_EMIT left(QPoint(leaveEvent->event_x, leaveEvent->event_y)); + break; + } } free(event); } @@ -140,9 +143,7 @@ void XWaylandInputTest::testPointerEnterLeaveSsd() xcb_window_t w = xcb_generate_id(c.data()); const QRect windowGeometry = QRect(0, 0, 100, 200); const uint32_t values[] = { - XCB_EVENT_MASK_ENTER_WINDOW | - XCB_EVENT_MASK_LEAVE_WINDOW - }; + XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW}; xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, w, rootWindow(), windowGeometry.x(), windowGeometry.y(), @@ -231,9 +232,7 @@ void XWaylandInputTest::testPointerEventLeaveCsd() xcb_window_t window = xcb_generate_id(c.data()); const uint32_t values[] = { - XCB_EVENT_MASK_ENTER_WINDOW | - XCB_EVENT_MASK_LEAVE_WINDOW - }; + XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW}; xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, window, rootWindow(), boundingRect.x, boundingRect.y, boundingRect.width, boundingRect.height, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, XCB_CW_EVENT_MASK, values); diff --git a/autotests/integration/xwayland_selections_test.cpp b/autotests/integration/xwayland_selections_test.cpp index 0ee8dc0468..67e6340fc3 100644 --- a/autotests/integration/xwayland_selections_test.cpp +++ b/autotests/integration/xwayland_selections_test.cpp @@ -8,6 +8,7 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "kwin_wayland_test.h" + #include "abstract_client.h" #include "abstract_output.h" #include "platform.h" @@ -24,7 +25,8 @@ using namespace KWin; static const QString s_socketName = QStringLiteral("wayland_test_kwin_xwayland_selections-0"); -struct ProcessKillBeforeDeleter { +struct ProcessKillBeforeDeleter +{ static inline void cleanup(QProcess *pointer) { if (pointer) @@ -44,14 +46,14 @@ private Q_SLOTS: void XwaylandSelectionsTest::initTestCase() { -// QSKIP("Skipped as it fails for unknown reasons on build.kde.org"); - qRegisterMetaType(); + // QSKIP("Skipped as it fails for unknown reasons on build.kde.org"); + qRegisterMetaType(); qRegisterMetaType(); QSignalSpy applicationStartedSpy(kwinApp(), &Application::started); QVERIFY(applicationStartedSpy.isValid()); kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); -// QSignalSpy clipboardSyncDevicedCreated{waylandServer(), &WaylandServer::xclipboardSyncDataDeviceCreated}; -// QVERIFY(clipboardSyncDevicedCreated.isValid()); + // QSignalSpy clipboardSyncDevicedCreated{waylandServer(), &WaylandServer::xclipboardSyncDataDeviceCreated}; + // QVERIFY(clipboardSyncDevicedCreated.isValid()); QVERIFY(waylandServer()->init(s_socketName)); QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2)); @@ -62,10 +64,10 @@ void XwaylandSelectionsTest::initTestCase() QCOMPARE(outputs[0]->geometry(), QRect(0, 0, 1280, 1024)); QCOMPARE(outputs[1]->geometry(), QRect(1280, 0, 1280, 1024)); Test::initWaylandWorkspace(); -// // wait till the xclipboard sync data device is created -// if (clipboardSyncDevicedCreated.empty()) { -// QVERIFY(clipboardSyncDevicedCreated.wait()); -// } + // // wait till the xclipboard sync data device is created + // if (clipboardSyncDevicedCreated.empty()) { + // QVERIFY(clipboardSyncDevicedCreated.wait()); + // } } void XwaylandSelectionsTest::testSync_data() @@ -115,7 +117,7 @@ void XwaylandSelectionsTest::testSync() // start the paste process QScopedPointer pasteProcess(new QProcess()); - QSignalSpy finishedSpy(pasteProcess.data(), static_cast(&QProcess::finished)); + QSignalSpy finishedSpy(pasteProcess.data(), static_cast(&QProcess::finished)); QVERIFY(finishedSpy.isValid()); QFETCH(QString, pastePlatform); environment.insert(QStringLiteral("QT_QPA_PLATFORM"), pastePlatform); diff --git a/autotests/integration/xwaylandserver_crash_test.cpp b/autotests/integration/xwaylandserver_crash_test.cpp index c681b4f264..b486cb696e 100644 --- a/autotests/integration/xwaylandserver_crash_test.cpp +++ b/autotests/integration/xwaylandserver_crash_test.cpp @@ -5,6 +5,7 @@ */ #include "kwin_wayland_test.h" + #include "abstract_output.h" #include "composite.h" #include "main.h" @@ -100,7 +101,7 @@ void XwaylandServerCrashTest::testCrash() // Create an override-redirect window. xcb_window_t window2 = xcb_generate_id(c.data()); - const uint32_t values[] = { true }; + const uint32_t values[] = {true}; xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, window2, rootWindow(), windowGeometry.x(), windowGeometry.y(), windowGeometry.width(), windowGeometry.height(), 0, diff --git a/autotests/integration/xwaylandserver_restart_test.cpp b/autotests/integration/xwaylandserver_restart_test.cpp index 910b414afc..855157ab5e 100644 --- a/autotests/integration/xwaylandserver_restart_test.cpp +++ b/autotests/integration/xwaylandserver_restart_test.cpp @@ -5,6 +5,7 @@ */ #include "kwin_wayland_test.h" + #include "composite.h" #include "main.h" #include "platform.h" diff --git a/autotests/libinput/device_test.cpp b/autotests/libinput/device_test.cpp index 69be27ea70..ad6df4c6ea 100644 --- a/autotests/libinput/device_test.cpp +++ b/autotests/libinput/device_test.cpp @@ -6,14 +6,15 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include "mock_libinput.h" -#include "backends/libinput/device.h" #include +#include "backends/libinput/device.h" +#include "mock_libinput.h" + #include -#include #include +#include #include #include @@ -161,13 +162,16 @@ private Q_SLOTS: void testSwitch(); }; -namespace { -template +namespace +{ +template T dbusProperty(const QString &name, const char *property) { - QDBusInterface interface{QStringLiteral("org.kde.kwin.tests.libinputdevice"), - QStringLiteral("/org/kde/KWin/InputDevice/") + name, - QStringLiteral("org.kde.KWin.InputDevice")}; + QDBusInterface interface { + QStringLiteral("org.kde.kwin.tests.libinputdevice"), + QStringLiteral("/org/kde/KWin/InputDevice/") + name, + QStringLiteral("org.kde.KWin.InputDevice") + }; return interface.property(property).value(); } } @@ -930,7 +934,7 @@ void TestLibinputDevice::testLeftHanded_data() QTest::newRow("unsupported/true") << false << false << true << false << false; QTest::newRow("unsupported/false") << false << false << false << true << false; QTest::newRow("true -> false") << true << false << true << false << false; - QTest::newRow("false -> true") << true << false << false << true << true; + QTest::newRow("false -> true") << true << false << false << true << true; QTest::newRow("set fails") << true << true << true << false << true; QTest::newRow("true -> true") << true << false << true << true << true; QTest::newRow("false -> false") << true << false << false << false << false; @@ -967,23 +971,23 @@ void TestLibinputDevice::testSupportedButtons_data() QTest::addColumn("setButtons"); QTest::addColumn("expectedButtons"); - QTest::newRow("left") << true << Qt::MouseButtons(Qt::LeftButton) << Qt::MouseButtons(Qt::LeftButton); - QTest::newRow("right") << true << Qt::MouseButtons(Qt::RightButton) << Qt::MouseButtons(Qt::RightButton); - QTest::newRow("middle") << true << Qt::MouseButtons(Qt::MiddleButton) << Qt::MouseButtons(Qt::MiddleButton); - QTest::newRow("extra1") << true << Qt::MouseButtons(Qt::ExtraButton1) << Qt::MouseButtons(Qt::ExtraButton1); - QTest::newRow("extra2") << true << Qt::MouseButtons(Qt::ExtraButton2) << Qt::MouseButtons(Qt::ExtraButton2); - QTest::newRow("back") << true << Qt::MouseButtons(Qt::BackButton) << Qt::MouseButtons(Qt::BackButton); + QTest::newRow("left") << true << Qt::MouseButtons(Qt::LeftButton) << Qt::MouseButtons(Qt::LeftButton); + QTest::newRow("right") << true << Qt::MouseButtons(Qt::RightButton) << Qt::MouseButtons(Qt::RightButton); + QTest::newRow("middle") << true << Qt::MouseButtons(Qt::MiddleButton) << Qt::MouseButtons(Qt::MiddleButton); + QTest::newRow("extra1") << true << Qt::MouseButtons(Qt::ExtraButton1) << Qt::MouseButtons(Qt::ExtraButton1); + QTest::newRow("extra2") << true << Qt::MouseButtons(Qt::ExtraButton2) << Qt::MouseButtons(Qt::ExtraButton2); + QTest::newRow("back") << true << Qt::MouseButtons(Qt::BackButton) << Qt::MouseButtons(Qt::BackButton); QTest::newRow("forward") << true << Qt::MouseButtons(Qt::ForwardButton) << Qt::MouseButtons(Qt::ForwardButton); - QTest::newRow("task") << true << Qt::MouseButtons(Qt::TaskButton) << Qt::MouseButtons(Qt::TaskButton); + QTest::newRow("task") << true << Qt::MouseButtons(Qt::TaskButton) << Qt::MouseButtons(Qt::TaskButton); - QTest::newRow("no pointer/left") << false << Qt::MouseButtons(Qt::LeftButton) << Qt::MouseButtons(); - QTest::newRow("no pointer/right") << false << Qt::MouseButtons(Qt::RightButton) << Qt::MouseButtons(); - QTest::newRow("no pointer/middle") << false << Qt::MouseButtons(Qt::MiddleButton) << Qt::MouseButtons(); - QTest::newRow("no pointer/extra1") << false << Qt::MouseButtons(Qt::ExtraButton1) << Qt::MouseButtons(); - QTest::newRow("no pointer/extra2") << false << Qt::MouseButtons(Qt::ExtraButton2) << Qt::MouseButtons(); - QTest::newRow("no pointer/back") << false << Qt::MouseButtons(Qt::BackButton) << Qt::MouseButtons(); + QTest::newRow("no pointer/left") << false << Qt::MouseButtons(Qt::LeftButton) << Qt::MouseButtons(); + QTest::newRow("no pointer/right") << false << Qt::MouseButtons(Qt::RightButton) << Qt::MouseButtons(); + QTest::newRow("no pointer/middle") << false << Qt::MouseButtons(Qt::MiddleButton) << Qt::MouseButtons(); + QTest::newRow("no pointer/extra1") << false << Qt::MouseButtons(Qt::ExtraButton1) << Qt::MouseButtons(); + QTest::newRow("no pointer/extra2") << false << Qt::MouseButtons(Qt::ExtraButton2) << Qt::MouseButtons(); + QTest::newRow("no pointer/back") << false << Qt::MouseButtons(Qt::BackButton) << Qt::MouseButtons(); QTest::newRow("no pointer/forward") << false << Qt::MouseButtons(Qt::ForwardButton) << Qt::MouseButtons(); - QTest::newRow("no pointer/task") << false << Qt::MouseButtons(Qt::TaskButton) << Qt::MouseButtons(); + QTest::newRow("no pointer/task") << false << Qt::MouseButtons(Qt::TaskButton) << Qt::MouseButtons(); QTest::newRow("all") << true << Qt::MouseButtons(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton | Qt::ExtraButton1 | Qt::ExtraButton2 | Qt::BackButton | Qt::ForwardButton | Qt::TaskButton) @@ -1057,7 +1061,6 @@ void TestLibinputDevice::testAlphaNumericKeyboard() QTEST(dbusProperty(d.sysName(), "alphaNumericKeyboard"), "isAlpha"); } - void TestLibinputDevice::testEnabled_data() { QTest::addColumn("supported"); @@ -1069,7 +1072,7 @@ void TestLibinputDevice::testEnabled_data() QTest::newRow("unsupported/true") << false << false << true << false << true; QTest::newRow("unsupported/false") << false << false << false << true << true; QTest::newRow("true -> false") << true << false << true << false << false; - QTest::newRow("false -> true") << true << false << false << true << true; + QTest::newRow("false -> true") << true << false << false << true << true; QTest::newRow("set fails") << true << true << true << false << true; QTest::newRow("true -> true") << true << false << true << true << true; QTest::newRow("false -> false") << true << false << false << false << false; @@ -1392,7 +1395,8 @@ void TestLibinputDevice::testScrollTwoFinger() QFETCH(bool, setShouldFail); QFETCH(bool, supportsScrollTwoFinger); device.supportedScrollMethods = (supportsScrollTwoFinger ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL) | LIBINPUT_CONFIG_SCROLL_EDGE; - device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_2FG : otherValue ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; + device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_2FG : otherValue ? LIBINPUT_CONFIG_SCROLL_EDGE + : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; device.setScrollMethodReturnValue = setShouldFail; Device d(&device); @@ -1440,7 +1444,8 @@ void TestLibinputDevice::testScrollEdge() QFETCH(bool, setShouldFail); QFETCH(bool, supportsScrollEdge); device.supportedScrollMethods = (supportsScrollEdge ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL) | LIBINPUT_CONFIG_SCROLL_2FG; - device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_EDGE : otherValue ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; + device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_EDGE : otherValue ? LIBINPUT_CONFIG_SCROLL_2FG + : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; device.setScrollMethodReturnValue = setShouldFail; Device d(&device); @@ -1488,7 +1493,8 @@ void TestLibinputDevice::testScrollButtonDown() QFETCH(bool, setShouldFail); QFETCH(bool, supportsScrollButtonDown); device.supportedScrollMethods = (supportsScrollButtonDown ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : LIBINPUT_CONFIG_SCROLL_NO_SCROLL) | LIBINPUT_CONFIG_SCROLL_2FG; - device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : otherValue ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; + device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : otherValue ? LIBINPUT_CONFIG_SCROLL_2FG + : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; device.setScrollMethodReturnValue = setShouldFail; Device d(&device); @@ -1612,7 +1618,7 @@ void TestLibinputDevice::testLmrTapButtonMap_data() QTest::newRow("false -> true, fingerCount 0") << false << true << true << false << 0; // TODO: is this a fail in libinput? - //QTest::newRow("false -> true, fingerCount 1") << false << true << true << false << 1; + // QTest::newRow("false -> true, fingerCount 1") << false << true << true << false << 1; } void TestLibinputDevice::testLmrTapButtonMap() @@ -1777,13 +1783,13 @@ void TestLibinputDevice::testLoadPointerAccelerationProfile_data() QTest::addColumn("configValuePropNameString"); QTest::newRow("pointerAccelerationProfileFlat -> pointerAccelerationProfileAdaptive") - << (quint32) LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT << "pointerAccelerationProfileFlat" - << (quint32) LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE << "pointerAccelerationProfileAdaptive"; + << (quint32)LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT << "pointerAccelerationProfileFlat" + << (quint32)LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE << "pointerAccelerationProfileAdaptive"; QTest::newRow("pointerAccelerationProfileAdaptive -> pointerAccelerationProfileFlat") - << (quint32) LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE << "pointerAccelerationProfileAdaptive" - << (quint32) LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT << "pointerAccelerationProfileFlat"; + << (quint32)LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE << "pointerAccelerationProfileAdaptive" + << (quint32)LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT << "pointerAccelerationProfileFlat"; QTest::newRow("pointerAccelerationProfileAdaptive -> pointerAccelerationProfileAdaptive") - << (quint32) LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE << "pointerAccelerationProfileAdaptive" << (quint32) LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE << "pointerAccelerationProfileAdaptive"; + << (quint32)LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE << "pointerAccelerationProfileAdaptive" << (quint32)LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE << "pointerAccelerationProfileAdaptive"; } void TestLibinputDevice::testLoadPointerAccelerationProfile() @@ -1802,7 +1808,7 @@ void TestLibinputDevice::testLoadPointerAccelerationProfile() libinput_device device; device.supportedPointerAccelerationProfiles = LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT | LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE; - device.pointerAccelerationProfile = (libinput_config_accel_profile) initValue; + device.pointerAccelerationProfile = (libinput_config_accel_profile)initValue; device.setPointerAccelerationProfileReturnValue = false; Device d(&device); @@ -1836,17 +1842,17 @@ void TestLibinputDevice::testLoadClickMethod_data() QTest::addColumn("configValuePropNameString"); QTest::newRow("clickMethodAreas -> clickMethodClickfinger") - << static_cast(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) << "clickMethodAreas" - << static_cast(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) << "clickMethodClickfinger"; + << static_cast(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) << "clickMethodAreas" + << static_cast(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) << "clickMethodClickfinger"; QTest::newRow("clickMethodClickfinger -> clickMethodAreas") - << static_cast(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) << "clickMethodClickfinger" - << static_cast(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) << "clickMethodAreas"; + << static_cast(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) << "clickMethodClickfinger" + << static_cast(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) << "clickMethodAreas"; QTest::newRow("clickMethodAreas -> clickMethodAreas") - << static_cast(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) << "clickMethodAreas" - << static_cast(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) << "clickMethodAreas"; + << static_cast(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) << "clickMethodAreas" + << static_cast(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) << "clickMethodAreas"; QTest::newRow("clickMethodClickfinger -> clickMethodClickfinger") - << static_cast(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) << "clickMethodClickfinger" - << static_cast(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) << "clickMethodClickfinger"; + << static_cast(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) << "clickMethodClickfinger" + << static_cast(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) << "clickMethodClickfinger"; } void TestLibinputDevice::testLoadClickMethod() @@ -1865,7 +1871,7 @@ void TestLibinputDevice::testLoadClickMethod() libinput_device device; device.supportedClickMethods = LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS | LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; - device.clickMethod = (libinput_config_click_method) initValue; + device.clickMethod = (libinput_config_click_method)initValue; device.setClickMethodReturnValue = false; Device d(&device); @@ -2106,9 +2112,9 @@ void TestLibinputDevice::testLoadScrollMethod_data() QTest::addColumn("configValue"); QTest::addColumn("configValuePropNameString"); - QTest::newRow("scrollTwoFinger -> scrollEdge") << (quint32) LIBINPUT_CONFIG_SCROLL_2FG << "scrollTwoFinger" << (quint32) LIBINPUT_CONFIG_SCROLL_EDGE << "scrollEdge"; - QTest::newRow("scrollOnButtonDown -> scrollTwoFinger") << (quint32) LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN << "scrollOnButtonDown" << (quint32) LIBINPUT_CONFIG_SCROLL_2FG << "scrollTwoFinger"; - QTest::newRow("scrollEdge -> scrollEdge") << (quint32) LIBINPUT_CONFIG_SCROLL_EDGE << "scrollEdge" << (quint32) LIBINPUT_CONFIG_SCROLL_EDGE << "scrollEdge"; + QTest::newRow("scrollTwoFinger -> scrollEdge") << (quint32)LIBINPUT_CONFIG_SCROLL_2FG << "scrollTwoFinger" << (quint32)LIBINPUT_CONFIG_SCROLL_EDGE << "scrollEdge"; + QTest::newRow("scrollOnButtonDown -> scrollTwoFinger") << (quint32)LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN << "scrollOnButtonDown" << (quint32)LIBINPUT_CONFIG_SCROLL_2FG << "scrollTwoFinger"; + QTest::newRow("scrollEdge -> scrollEdge") << (quint32)LIBINPUT_CONFIG_SCROLL_EDGE << "scrollEdge" << (quint32)LIBINPUT_CONFIG_SCROLL_EDGE << "scrollEdge"; } void TestLibinputDevice::testLoadScrollMethod() @@ -2127,7 +2133,7 @@ void TestLibinputDevice::testLoadScrollMethod() libinput_device device; device.supportedScrollMethods = LIBINPUT_CONFIG_SCROLL_2FG | LIBINPUT_CONFIG_SCROLL_EDGE | LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; - device.scrollMethod = (libinput_config_scroll_method) initValue; + device.scrollMethod = (libinput_config_scroll_method)initValue; device.setScrollMethodReturnValue = false; Device d(&device); diff --git a/autotests/libinput/gesture_event_test.cpp b/autotests/libinput/gesture_event_test.cpp index c9e406c570..c3b080d5cb 100644 --- a/autotests/libinput/gesture_event_test.cpp +++ b/autotests/libinput/gesture_event_test.cpp @@ -86,10 +86,10 @@ void TestLibinputGestureEvent::testType() QCOMPARE(event->type(), type); QCOMPARE(event->device(), m_device); QCOMPARE(event->nativeDevice(), m_nativeDevice); - QCOMPARE((libinput_event*)(*event.data()), gestureEvent); + QCOMPARE((libinput_event *)(*event.data()), gestureEvent); // verify it's a pointer event - QVERIFY(dynamic_cast(event.data())); - QCOMPARE((libinput_event_gesture*)(*dynamic_cast(event.data())), gestureEvent); + QVERIFY(dynamic_cast(event.data())); + QCOMPARE((libinput_event_gesture *)(*dynamic_cast(event.data())), gestureEvent); } void TestLibinputGestureEvent::testStart_data() @@ -110,14 +110,14 @@ void TestLibinputGestureEvent::testStart() gestureEvent->time = 100u; QScopedPointer event(Event::create(gestureEvent)); - auto ge = dynamic_cast(event.data()); + auto ge = dynamic_cast(event.data()); QVERIFY(ge); QCOMPARE(ge->fingerCount(), gestureEvent->fingerCount); QVERIFY(!ge->isCancelled()); QCOMPARE(ge->time(), gestureEvent->time); QCOMPARE(ge->delta(), QSizeF(0, 0)); if (ge->type() == LIBINPUT_EVENT_GESTURE_PINCH_BEGIN) { - auto pe = dynamic_cast(event.data()); + auto pe = dynamic_cast(event.data()); QCOMPARE(pe->scale(), 1.0); QCOMPARE(pe->angleDelta(), 0.0); } @@ -133,7 +133,7 @@ void TestLibinputGestureEvent::testSwipeUpdate() gestureEvent->delta = QSizeF(2, 3); QScopedPointer event(Event::create(gestureEvent)); - auto se = dynamic_cast(event.data()); + auto se = dynamic_cast(event.data()); QVERIFY(se); QCOMPARE(se->fingerCount(), gestureEvent->fingerCount); QVERIFY(!se->isCancelled()); @@ -153,7 +153,7 @@ void TestLibinputGestureEvent::testPinchUpdate() gestureEvent->angleDelta = -30; QScopedPointer event(Event::create(gestureEvent)); - auto pe = dynamic_cast(event.data()); + auto pe = dynamic_cast(event.data()); QVERIFY(pe); QCOMPARE(pe->fingerCount(), gestureEvent->fingerCount); QVERIFY(!pe->isCancelled()); @@ -187,14 +187,14 @@ void TestLibinputGestureEvent::testEnd() gestureEvent->scale = 3; QScopedPointer event(Event::create(gestureEvent)); - auto ge = dynamic_cast(event.data()); + auto ge = dynamic_cast(event.data()); QVERIFY(ge); QCOMPARE(ge->fingerCount(), gestureEvent->fingerCount); QCOMPARE(ge->isCancelled(), cancelled); QCOMPARE(ge->time(), gestureEvent->time); QCOMPARE(ge->delta(), QSizeF(0, 0)); if (ge->type() == LIBINPUT_EVENT_GESTURE_PINCH_END) { - auto pe = dynamic_cast(event.data()); + auto pe = dynamic_cast(event.data()); QCOMPARE(pe->scale(), gestureEvent->scale); QCOMPARE(pe->angleDelta(), 0.0); } diff --git a/autotests/libinput/input_event_test.cpp b/autotests/libinput/input_event_test.cpp index 59d51fe2f2..897eec816c 100644 --- a/autotests/libinput/input_event_test.cpp +++ b/autotests/libinput/input_event_test.cpp @@ -115,7 +115,7 @@ void InputEventsTest::testInitWheelEvent_data() QTest::addColumn("expectedAngleDelta"); QTest::newRow("horiz") << Qt::Horizontal << 3.3 << 1 << QPoint(3, 0); - QTest::newRow("vert") << Qt::Vertical << 2.4 << 2 << QPoint(0, 2); + QTest::newRow("vert") << Qt::Vertical << 2.4 << 2 << QPoint(0, 2); } void InputEventsTest::testInitWheelEvent() @@ -146,7 +146,6 @@ void InputEventsTest::testInitWheelEvent() QCOMPARE(event.axisSource(), InputRedirection::PointerAxisSourceWheel); // and our custom argument QCOMPARE(event.device(), &d); - } void InputEventsTest::testInitSwitchEvent_data() diff --git a/autotests/libinput/key_event_test.cpp b/autotests/libinput/key_event_test.cpp index ad0dbd6020..47b8d8fc1b 100644 --- a/autotests/libinput/key_event_test.cpp +++ b/autotests/libinput/key_event_test.cpp @@ -62,10 +62,10 @@ void TestLibinputKeyEvent::testCreate() QCOMPARE(event->type(), LIBINPUT_EVENT_KEYBOARD_KEY); QCOMPARE(event->device(), m_device); QCOMPARE(event->nativeDevice(), m_nativeDevice); - QCOMPARE((libinput_event*)(*event.data()), keyEvent); + QCOMPARE((libinput_event *)(*event.data()), keyEvent); // verify it's a key event - QVERIFY(dynamic_cast(event.data())); - QCOMPARE((libinput_event_keyboard*)(*dynamic_cast(event.data())), keyEvent); + QVERIFY(dynamic_cast(event.data())); + QCOMPARE((libinput_event_keyboard *)(*dynamic_cast(event.data())), keyEvent); // verify that a nullptr passed to Event::create returns a nullptr QVERIFY(!Event::create(nullptr)); @@ -95,7 +95,7 @@ void TestLibinputKeyEvent::testEvent() keyEvent->time = time; QScopedPointer event(Event::create(keyEvent)); - auto ke = dynamic_cast(event.data()); + auto ke = dynamic_cast(event.data()); QVERIFY(ke); QTEST(ke->state(), "expectedKeyState"); QCOMPARE(ke->key(), key); diff --git a/autotests/libinput/mock_libinput.cpp b/autotests/libinput/mock_libinput.cpp index 3d8e5fe292..703ab70eda 100644 --- a/autotests/libinput/mock_libinput.cpp +++ b/autotests/libinput/mock_libinput.cpp @@ -6,9 +6,10 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include "mock_libinput.h" #include +#include "mock_libinput.h" + #include int libinput_device_keyboard_has_key(struct libinput_device *device, uint32_t code) @@ -258,7 +259,7 @@ enum libinput_config_accel_profile libinput_device_config_accel_get_default_prof enum libinput_config_status libinput_device_config_accel_set_profile(struct libinput_device *device, enum libinput_config_accel_profile profile) { if (device->setPointerAccelerationProfileReturnValue == 0) { - if (!(device->supportedPointerAccelerationProfiles & profile) && profile!= LIBINPUT_CONFIG_ACCEL_PROFILE_NONE) { + if (!(device->supportedPointerAccelerationProfiles & profile) && profile != LIBINPUT_CONFIG_ACCEL_PROFILE_NONE) { return LIBINPUT_CONFIG_STATUS_INVALID; } device->pointerAccelerationProfile = profile; @@ -384,7 +385,6 @@ enum libinput_config_status libinput_device_config_send_events_set_mode(struct l return LIBINPUT_CONFIG_STATUS_INVALID; } - enum libinput_event_type libinput_event_get_type(struct libinput_event *event) { return event->type; @@ -410,38 +410,44 @@ struct libinput_event_keyboard *libinput_event_get_keyboard_event(struct libinpu struct libinput_event_pointer *libinput_event_get_pointer_event(struct libinput_event *event) { - if (event->type == LIBINPUT_EVENT_POINTER_MOTION || - event->type == LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE || - event->type == LIBINPUT_EVENT_POINTER_BUTTON || - event->type == LIBINPUT_EVENT_POINTER_AXIS) { + switch (event->type) { + case LIBINPUT_EVENT_POINTER_MOTION: + case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE: + case LIBINPUT_EVENT_POINTER_BUTTON: + case LIBINPUT_EVENT_POINTER_AXIS: return reinterpret_cast(event); + default: + return nullptr; } - return nullptr; } struct libinput_event_touch *libinput_event_get_touch_event(struct libinput_event *event) { - if (event->type == LIBINPUT_EVENT_TOUCH_DOWN || - event->type == LIBINPUT_EVENT_TOUCH_UP || - event->type == LIBINPUT_EVENT_TOUCH_MOTION || - event->type == LIBINPUT_EVENT_TOUCH_CANCEL || - event->type == LIBINPUT_EVENT_TOUCH_FRAME) { + switch (event->type) { + case LIBINPUT_EVENT_TOUCH_DOWN: + case LIBINPUT_EVENT_TOUCH_UP: + case LIBINPUT_EVENT_TOUCH_MOTION: + case LIBINPUT_EVENT_TOUCH_CANCEL: + case LIBINPUT_EVENT_TOUCH_FRAME: return reinterpret_cast(event); + default: + return nullptr; } - return nullptr; } struct libinput_event_gesture *libinput_event_get_gesture_event(struct libinput_event *event) { - if (event->type == LIBINPUT_EVENT_GESTURE_PINCH_BEGIN || - event->type == LIBINPUT_EVENT_GESTURE_PINCH_UPDATE || - event->type == LIBINPUT_EVENT_GESTURE_PINCH_END || - event->type == LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN || - event->type == LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE || - event->type == LIBINPUT_EVENT_GESTURE_SWIPE_END) { + switch (event->type) { + case LIBINPUT_EVENT_GESTURE_PINCH_BEGIN: + case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE: + case LIBINPUT_EVENT_GESTURE_PINCH_END: + case LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN: + case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE: + case LIBINPUT_EVENT_GESTURE_SWIPE_END: return reinterpret_cast(event); + default: + return nullptr; } - return nullptr; } int libinput_event_gesture_get_cancelled(struct libinput_event_gesture *event) @@ -866,7 +872,7 @@ int libinput_device_switch_has_switch(struct libinput_device *device, enum libin struct libinput_event_switch *libinput_event_get_switch_event(struct libinput_event *event) { if (event->type == LIBINPUT_EVENT_SWITCH_TOGGLE) { - return reinterpret_cast(event); + return reinterpret_cast(event); } else { return nullptr; } @@ -886,7 +892,7 @@ enum libinput_switch_state libinput_event_switch_get_switch_state(struct libinpu uint32_t libinput_event_switch_get_time(struct libinput_event_switch *event) { - return event->time;; + return event->time; } uint64_t libinput_event_switch_get_time_usec(struct libinput_event_switch *event) @@ -905,28 +911,27 @@ struct libinput_event_tablet_pad *libinput_event_get_tablet_pad_event(struct lib struct libinput_event_tablet_tool * libinput_event_get_tablet_tool_event(struct libinput_event *event) { - if (event->type == LIBINPUT_EVENT_TABLET_TOOL_AXIS || - event->type == LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY || - event->type == LIBINPUT_EVENT_TABLET_TOOL_TIP) { + switch (event->type) { + case LIBINPUT_EVENT_TABLET_TOOL_AXIS: + case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY: + case LIBINPUT_EVENT_TABLET_TOOL_TIP: return reinterpret_cast(event); + default: + return nullptr; } - return nullptr; } -int -libinput_device_tablet_pad_get_num_strips(struct libinput_device *device) +int libinput_device_tablet_pad_get_num_strips(struct libinput_device *device) { return device->stripCount; } -int -libinput_device_tablet_pad_get_num_rings(struct libinput_device *device) +int libinput_device_tablet_pad_get_num_rings(struct libinput_device *device) { return device->ringCount; } -int -libinput_device_tablet_pad_get_num_buttons(struct libinput_device *device) +int libinput_device_tablet_pad_get_num_buttons(struct libinput_device *device) { return device->buttonCount; } @@ -945,9 +950,8 @@ libinput_device_group_get_user_data(struct libinput_device_group *group) return nullptr; } -void -libinput_device_led_update(struct libinput_device *device, - enum libinput_led leds) +void libinput_device_led_update(struct libinput_device *device, + enum libinput_led leds) { Q_UNUSED(device) Q_UNUSED(leds) diff --git a/autotests/libinput/mock_libinput.h b/autotests/libinput/mock_libinput.h index 2749100e74..f9f76966ee 100644 --- a/autotests/libinput/mock_libinput.h +++ b/autotests/libinput/mock_libinput.h @@ -17,7 +17,8 @@ #include -struct libinput_device { +struct libinput_device +{ bool keyboard = false; bool pointer = false; bool touch = false; @@ -100,22 +101,28 @@ struct libinput_device { uint32_t ringCount = 0; }; -struct libinput_event { - virtual ~libinput_event() {} +struct libinput_event +{ + virtual ~libinput_event() + { + } libinput_device *device = nullptr; libinput_event_type type = LIBINPUT_EVENT_NONE; quint32 time = 0; }; -struct libinput_event_keyboard : libinput_event { - libinput_event_keyboard() { +struct libinput_event_keyboard : libinput_event +{ + libinput_event_keyboard() + { type = LIBINPUT_EVENT_KEYBOARD_KEY; } libinput_key_state state = LIBINPUT_KEY_STATE_RELEASED; quint32 key = 0; }; -struct libinput_event_pointer : libinput_event { +struct libinput_event_pointer : libinput_event +{ libinput_button_state buttonState = LIBINPUT_BUTTON_STATE_RELEASED; quint32 button = 0; bool verticalAxis = false; @@ -129,12 +136,14 @@ struct libinput_event_pointer : libinput_event { QPointF absolutePos; }; -struct libinput_event_touch : libinput_event { +struct libinput_event_touch : libinput_event +{ qint32 slot = -1; QPointF absolutePos; }; -struct libinput_event_gesture : libinput_event { +struct libinput_event_gesture : libinput_event +{ int fingerCount = 0; bool cancelled = false; QSizeF delta = QSizeF(0, 0); @@ -142,7 +151,8 @@ struct libinput_event_gesture : libinput_event { qreal angleDelta = 0.0; }; -struct libinput_event_switch : libinput_event { +struct libinput_event_switch : libinput_event +{ enum class State { Off, On @@ -151,7 +161,8 @@ struct libinput_event_switch : libinput_event { quint64 timeMicroseconds = 0; }; -struct libinput { +struct libinput +{ int refCount = 1; QByteArray seat; int assignSeatRetVal = 0; diff --git a/autotests/libinput/pointer_event_test.cpp b/autotests/libinput/pointer_event_test.cpp index 40cab5049c..14d3d8439a 100644 --- a/autotests/libinput/pointer_event_test.cpp +++ b/autotests/libinput/pointer_event_test.cpp @@ -82,10 +82,10 @@ void TestLibinputPointerEvent::testType() QCOMPARE(event->type(), type); QCOMPARE(event->device(), m_device); QCOMPARE(event->nativeDevice(), m_nativeDevice); - QCOMPARE((libinput_event*)(*event.data()), pointerEvent); + QCOMPARE((libinput_event *)(*event.data()), pointerEvent); // verify it's a pointer event - QVERIFY(dynamic_cast(event.data())); - QCOMPARE((libinput_event_pointer*)(*dynamic_cast(event.data())), pointerEvent); + QVERIFY(dynamic_cast(event.data())); + QCOMPARE((libinput_event_pointer *)(*dynamic_cast(event.data())), pointerEvent); } void TestLibinputPointerEvent::testButton_data() @@ -113,7 +113,7 @@ void TestLibinputPointerEvent::testButton() pointerEvent->time = time; QScopedPointer event(Event::create(pointerEvent)); - auto pe = dynamic_cast(event.data()); + auto pe = dynamic_cast(event.data()); QVERIFY(pe); QCOMPARE(pe->type(), LIBINPUT_EVENT_POINTER_BUTTON); QTEST(pe->buttonState(), "expectedButtonState"); @@ -132,20 +132,20 @@ void TestLibinputPointerEvent::testAxis_data() QTest::addColumn("expectedAxisSource"); QTest::addColumn("time"); - QTest::newRow("wheel/horizontal") << true << false << QPointF(3.0, 0.0) << QPoint(1, 0) << LIBINPUT_POINTER_AXIS_SOURCE_WHEEL << KWin::InputRedirection::PointerAxisSourceWheel << 100u; - QTest::newRow("wheel/vertical") << false << true << QPointF(0.0, 2.5) << QPoint(0, 1) << LIBINPUT_POINTER_AXIS_SOURCE_WHEEL << KWin::InputRedirection::PointerAxisSourceWheel << 200u; - QTest::newRow("wheel/both") << true << true << QPointF(1.1, 4.2) << QPoint(1, 1) << LIBINPUT_POINTER_AXIS_SOURCE_WHEEL << KWin::InputRedirection::PointerAxisSourceWheel << 300u; + QTest::newRow("wheel/horizontal") << true << false << QPointF(3.0, 0.0) << QPoint(1, 0) << LIBINPUT_POINTER_AXIS_SOURCE_WHEEL << KWin::InputRedirection::PointerAxisSourceWheel << 100u; + QTest::newRow("wheel/vertical") << false << true << QPointF(0.0, 2.5) << QPoint(0, 1) << LIBINPUT_POINTER_AXIS_SOURCE_WHEEL << KWin::InputRedirection::PointerAxisSourceWheel << 200u; + QTest::newRow("wheel/both") << true << true << QPointF(1.1, 4.2) << QPoint(1, 1) << LIBINPUT_POINTER_AXIS_SOURCE_WHEEL << KWin::InputRedirection::PointerAxisSourceWheel << 300u; - QTest::newRow("finger/horizontal") << true << false << QPointF(3.0, 0.0) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 400u; - QTest::newRow("stop finger/horizontal") << true << false << QPointF(0.0, 0.0) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 500u; - QTest::newRow("finger/vertical") << false << true << QPointF(0.0, 2.5) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 600u; - QTest::newRow("stop finger/vertical") << false << true << QPointF(0.0, 0.0) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 700u; - QTest::newRow("finger/both") << true << true << QPointF(1.1, 4.2) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 800u; - QTest::newRow("stop finger/both") << true << true << QPointF(0.0, 0.0) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 900u; + QTest::newRow("finger/horizontal") << true << false << QPointF(3.0, 0.0) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 400u; + QTest::newRow("stop finger/horizontal") << true << false << QPointF(0.0, 0.0) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 500u; + QTest::newRow("finger/vertical") << false << true << QPointF(0.0, 2.5) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 600u; + QTest::newRow("stop finger/vertical") << false << true << QPointF(0.0, 0.0) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 700u; + QTest::newRow("finger/both") << true << true << QPointF(1.1, 4.2) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 800u; + QTest::newRow("stop finger/both") << true << true << QPointF(0.0, 0.0) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_FINGER << KWin::InputRedirection::PointerAxisSourceFinger << 900u; - QTest::newRow("continuous/horizontal") << true << false << QPointF(3.0, 0.0) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS << KWin::InputRedirection::PointerAxisSourceContinuous << 1000u; - QTest::newRow("continuous/vertical") << false << true << QPointF(0.0, 2.5) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS << KWin::InputRedirection::PointerAxisSourceContinuous << 1100u; - QTest::newRow("continuous/both") << true << true << QPointF(1.1, 4.2) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS << KWin::InputRedirection::PointerAxisSourceContinuous << 1200u; + QTest::newRow("continuous/horizontal") << true << false << QPointF(3.0, 0.0) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS << KWin::InputRedirection::PointerAxisSourceContinuous << 1000u; + QTest::newRow("continuous/vertical") << false << true << QPointF(0.0, 2.5) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS << KWin::InputRedirection::PointerAxisSourceContinuous << 1100u; + QTest::newRow("continuous/both") << true << true << QPointF(1.1, 4.2) << QPoint(0, 0) << LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS << KWin::InputRedirection::PointerAxisSourceContinuous << 1200u; } void TestLibinputPointerEvent::testAxis() @@ -170,7 +170,7 @@ void TestLibinputPointerEvent::testAxis() pointerEvent->time = time; QScopedPointer event(Event::create(pointerEvent)); - auto pe = dynamic_cast(event.data()); + auto pe = dynamic_cast(event.data()); QVERIFY(pe); QCOMPARE(pe->type(), LIBINPUT_EVENT_POINTER_AXIS); QCOMPARE(pe->axis().contains(KWin::InputRedirection::PointerAxisHorizontal), horizontal); @@ -193,7 +193,7 @@ void TestLibinputPointerEvent::testMotion() pointerEvent->time = 500u; QScopedPointer event(Event::create(pointerEvent)); - auto pe = dynamic_cast(event.data()); + auto pe = dynamic_cast(event.data()); QVERIFY(pe); QCOMPARE(pe->type(), LIBINPUT_EVENT_POINTER_MOTION); QCOMPARE(pe->time(), 500u); @@ -210,7 +210,7 @@ void TestLibinputPointerEvent::testAbsoluteMotion() pointerEvent->time = 500u; QScopedPointer event(Event::create(pointerEvent)); - auto pe = dynamic_cast(event.data()); + auto pe = dynamic_cast(event.data()); QVERIFY(pe); QCOMPARE(pe->type(), LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE); QCOMPARE(pe->time(), 500u); diff --git a/autotests/libinput/switch_event_test.cpp b/autotests/libinput/switch_event_test.cpp index fd585a2b99..2963d0ab95 100644 --- a/autotests/libinput/switch_event_test.cpp +++ b/autotests/libinput/switch_event_test.cpp @@ -75,7 +75,7 @@ void TestLibinputSwitchEvent::testToggled() nativeEvent->timeMicroseconds = 23456789; QScopedPointer event(Event::create(nativeEvent)); - auto se = dynamic_cast(event.data()); + auto se = dynamic_cast(event.data()); QVERIFY(se); QCOMPARE(se->device(), m_device.get()); QCOMPARE(se->nativeDevice(), m_nativeDevice.get()); diff --git a/autotests/libinput/touch_event_test.cpp b/autotests/libinput/touch_event_test.cpp index f80c70e2f4..cc7b628e46 100644 --- a/autotests/libinput/touch_event_test.cpp +++ b/autotests/libinput/touch_event_test.cpp @@ -79,13 +79,13 @@ void TestLibinputTouchEvent::testType() QCOMPARE(event->type(), type); QCOMPARE(event->device(), m_device); QCOMPARE(event->nativeDevice(), m_nativeDevice); - QCOMPARE((libinput_event*)(*event.data()), touchEvent); + QCOMPARE((libinput_event *)(*event.data()), touchEvent); // verify it's a pointer event - QVERIFY(dynamic_cast(event.data())); - QCOMPARE((libinput_event_touch*)(*dynamic_cast(event.data())), touchEvent); + QVERIFY(dynamic_cast(event.data())); + QCOMPARE((libinput_event_touch *)(*dynamic_cast(event.data())), touchEvent); QFETCH(bool, hasId); if (hasId) { - QCOMPARE(dynamic_cast(event.data())->id(), 0); + QCOMPARE(dynamic_cast(event.data())->id(), 0); } } @@ -108,7 +108,7 @@ void TestLibinputTouchEvent::testAbsoluteMotion() touchEvent->slot = 1; QScopedPointer event(Event::create(touchEvent)); - auto te = dynamic_cast(event.data()); + auto te = dynamic_cast(event.data()); QVERIFY(te); QCOMPARE(te->type(), type); QCOMPARE(te->time(), 500u); diff --git a/autotests/libkwineffects/mock_gl.cpp b/autotests/libkwineffects/mock_gl.cpp index de8c52bee9..13a258cd52 100644 --- a/autotests/libkwineffects/mock_gl.cpp +++ b/autotests/libkwineffects/mock_gl.cpp @@ -18,15 +18,15 @@ static const GLubyte *mock_glGetString(GLenum name) } switch (name) { case GL_VENDOR: - return (const GLubyte*)s_gl->getString.vendor.constData(); + return (const GLubyte *)s_gl->getString.vendor.constData(); case GL_RENDERER: - return (const GLubyte*)s_gl->getString.renderer.constData(); + return (const GLubyte *)s_gl->getString.renderer.constData(); case GL_VERSION: - return (const GLubyte*)s_gl->getString.version.constData(); + return (const GLubyte *)s_gl->getString.version.constData(); case GL_EXTENSIONS: - return (const GLubyte*)s_gl->getString.extensionsString.constData(); + return (const GLubyte *)s_gl->getString.extensionsString.constData(); case GL_SHADING_LANGUAGE_VERSION: - return (const GLubyte*)s_gl->getString.shadingLanguageVersion.constData(); + return (const GLubyte *)s_gl->getString.shadingLanguageVersion.constData(); default: return nullptr; } @@ -38,7 +38,7 @@ static const GLubyte *mock_glGetStringi(GLenum name, GLuint index) return nullptr; } if (name == GL_EXTENSIONS && index < uint(s_gl->getString.extensions.count())) { - return (const GLubyte*)s_gl->getString.extensions.at(index).constData(); + return (const GLubyte *)s_gl->getString.extensions.at(index).constData(); } return nullptr; } diff --git a/autotests/libkwineffects/mock_gl.h b/autotests/libkwineffects/mock_gl.h index a88ee2b0bb..ff715814ed 100644 --- a/autotests/libkwineffects/mock_gl.h +++ b/autotests/libkwineffects/mock_gl.h @@ -12,8 +12,10 @@ #include #include -struct MockGL { - struct { +struct MockGL +{ + struct + { QByteArray vendor; QByteArray renderer; QByteArray version; diff --git a/autotests/libkwineffects/timelinetest.cpp b/autotests/libkwineffects/timelinetest.cpp index 895bececc1..c81e1b1340 100644 --- a/autotests/libkwineffects/timelinetest.cpp +++ b/autotests/libkwineffects/timelinetest.cpp @@ -163,12 +163,12 @@ void TimeLineTest::testSetElapsed_data() QTest::addColumn("expectedDone"); QTest::addColumn("initiallyDone"); - QTest::newRow("Less than duration, not finished") << 1000ms << 300ms << 300ms << false << false; - QTest::newRow("Less than duration, finished") << 1000ms << 300ms << 300ms << false << true; - QTest::newRow("Greater than duration, not finished") << 1000ms << 3000ms << 1000ms << true << false; - QTest::newRow("Greater than duration, finished") << 1000ms << 3000ms << 1000ms << true << true; - QTest::newRow("Equal to duration, not finished") << 1000ms << 1000ms << 1000ms << true << false; - QTest::newRow("Equal to duration, finished") << 1000ms << 1000ms << 1000ms << true << true; + QTest::newRow("Less than duration, not finished") << 1000ms << 300ms << 300ms << false << false; + QTest::newRow("Less than duration, finished") << 1000ms << 300ms << 300ms << false << true; + QTest::newRow("Greater than duration, not finished") << 1000ms << 3000ms << 1000ms << true << false; + QTest::newRow("Greater than duration, finished") << 1000ms << 3000ms << 1000ms << true << true; + QTest::newRow("Equal to duration, not finished") << 1000ms << 1000ms << 1000ms << true << false; + QTest::newRow("Equal to duration, finished") << 1000ms << 1000ms << 1000ms << true << true; } void TimeLineTest::testSetElapsed() @@ -255,8 +255,8 @@ void TimeLineTest::testStrictRedirectSourceMode_data() QTest::addColumn("finalDirection"); QTest::addColumn("finalValue"); - QTest::newRow("forward -> backward") << KWin::TimeLine::Forward << 0.0 << KWin::TimeLine::Backward << 0.0; - QTest::newRow("backward -> forward") << KWin::TimeLine::Backward << 1.0 << KWin::TimeLine::Forward << 1.0; + QTest::newRow("forward -> backward") << KWin::TimeLine::Forward << 0.0 << KWin::TimeLine::Backward << 0.0; + QTest::newRow("backward -> forward") << KWin::TimeLine::Backward << 1.0 << KWin::TimeLine::Forward << 1.0; } void TimeLineTest::testStrictRedirectSourceMode() @@ -289,8 +289,8 @@ void TimeLineTest::testRelaxedRedirectSourceMode_data() QTest::addColumn("finalDirection"); QTest::addColumn("finalValue"); - QTest::newRow("forward -> backward") << KWin::TimeLine::Forward << 0.0 << KWin::TimeLine::Backward << 1.0; - QTest::newRow("backward -> forward") << KWin::TimeLine::Backward << 1.0 << KWin::TimeLine::Forward << 0.0; + QTest::newRow("forward -> backward") << KWin::TimeLine::Forward << 0.0 << KWin::TimeLine::Backward << 1.0; + QTest::newRow("backward -> forward") << KWin::TimeLine::Backward << 1.0 << KWin::TimeLine::Forward << 0.0; } void TimeLineTest::testRelaxedRedirectSourceMode() @@ -323,8 +323,8 @@ void TimeLineTest::testStrictRedirectTargetMode_data() QTest::addColumn("finalDirection"); QTest::addColumn("finalValue"); - QTest::newRow("forward -> backward") << KWin::TimeLine::Forward << 0.0 << KWin::TimeLine::Backward << 1.0; - QTest::newRow("backward -> forward") << KWin::TimeLine::Backward << 1.0 << KWin::TimeLine::Forward << 0.0; + QTest::newRow("forward -> backward") << KWin::TimeLine::Forward << 0.0 << KWin::TimeLine::Backward << 1.0; + QTest::newRow("backward -> forward") << KWin::TimeLine::Backward << 1.0 << KWin::TimeLine::Forward << 0.0; } void TimeLineTest::testStrictRedirectTargetMode() @@ -361,8 +361,8 @@ void TimeLineTest::testRelaxedRedirectTargetMode_data() QTest::addColumn("finalDirection"); QTest::addColumn("finalValue"); - QTest::newRow("forward -> backward") << KWin::TimeLine::Forward << 0.0 << KWin::TimeLine::Backward << 1.0; - QTest::newRow("backward -> forward") << KWin::TimeLine::Backward << 1.0 << KWin::TimeLine::Forward << 0.0; + QTest::newRow("forward -> backward") << KWin::TimeLine::Forward << 0.0 << KWin::TimeLine::Backward << 1.0; + QTest::newRow("backward -> forward") << KWin::TimeLine::Backward << 1.0 << KWin::TimeLine::Forward << 0.0; } void TimeLineTest::testRelaxedRedirectTargetMode() diff --git a/autotests/libkwineffects/windowquadlisttest.cpp b/autotests/libkwineffects/windowquadlisttest.cpp index 78e28d7aa2..165d9cf9e3 100644 --- a/autotests/libkwineffects/windowquadlisttest.cpp +++ b/autotests/libkwineffects/windowquadlisttest.cpp @@ -6,8 +6,8 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include #include +#include Q_DECLARE_METATYPE(KWin::WindowQuadList) @@ -27,10 +27,10 @@ private: KWin::WindowQuad WindowQuadListTest::makeQuad(const QRectF &r) { KWin::WindowQuad quad; - quad[ 0 ] = KWin::WindowVertex(r.x(), r.y(), r.x(), r.y()); - quad[ 1 ] = KWin::WindowVertex(r.x() + r.width(), r.y(), r.x() + r.width(), r.y()); - quad[ 2 ] = KWin::WindowVertex(r.x() + r.width(), r.y() + r.height(), r.x() + r.width(), r.y() + r.height()); - quad[ 3 ] = KWin::WindowVertex(r.x(), r.y() + r.height(), r.x(), r.y() + r.height()); + quad[0] = KWin::WindowVertex(r.x(), r.y(), r.x(), r.y()); + quad[1] = KWin::WindowVertex(r.x() + r.width(), r.y(), r.x() + r.width(), r.y()); + quad[2] = KWin::WindowVertex(r.x() + r.width(), r.y() + r.height(), r.x() + r.width(), r.y() + r.height()); + quad[3] = KWin::WindowVertex(r.x(), r.y() + r.height(), r.x(), r.y() + r.height()); return quad; } @@ -66,17 +66,17 @@ void WindowQuadListTest::testMakeGrid_data() orig.append(makeQuad(QRectF(0, 10, 4, 3))); expected.clear(); - expected.append(makeQuad(QRectF(0, 0, 4, 4))); - expected.append(makeQuad(QRectF(0, 4, 4, 4))); - expected.append(makeQuad(QRectF(0, 8, 4, 2))); + expected.append(makeQuad(QRectF(0, 0, 4, 4))); + expected.append(makeQuad(QRectF(0, 4, 4, 4))); + expected.append(makeQuad(QRectF(0, 8, 4, 2))); expected.append(makeQuad(QRectF(0, 10, 4, 2))); expected.append(makeQuad(QRectF(0, 12, 4, 1))); - expected.append(makeQuad(QRectF(4, 0, 4, 4))); - expected.append(makeQuad(QRectF(4, 4, 4, 4))); - expected.append(makeQuad(QRectF(4, 8, 4, 2))); - expected.append(makeQuad(QRectF(8, 0, 2, 4))); - expected.append(makeQuad(QRectF(8, 4, 2, 4))); - expected.append(makeQuad(QRectF(8, 8, 2, 2))); + expected.append(makeQuad(QRectF(4, 0, 4, 4))); + expected.append(makeQuad(QRectF(4, 4, 4, 4))); + expected.append(makeQuad(QRectF(4, 8, 4, 2))); + expected.append(makeQuad(QRectF(8, 0, 2, 4))); + expected.append(makeQuad(QRectF(8, 4, 2, 4))); + expected.append(makeQuad(QRectF(8, 8, 2, 2))); QTest::newRow("irregularGrid2") << orig << 4 << 11 << expected; } @@ -96,10 +96,14 @@ void WindowQuadListTest::testMakeGrid() auto vertexTest = [actualQuad, expectedQuad](int index) { const KWin::WindowVertex &actualVertex = actualQuad[index]; const KWin::WindowVertex &expectedVertex = expectedQuad[index]; - if (actualVertex.x() != expectedVertex.x()) return false; - if (actualVertex.y() != expectedVertex.y()) return false; - if (!qFuzzyIsNull(actualVertex.u() - expectedVertex.u())) return false; - if (!qFuzzyIsNull(actualVertex.v() - expectedVertex.v())) return false; + if (actualVertex.x() != expectedVertex.x()) + return false; + if (actualVertex.y() != expectedVertex.y()) + return false; + if (!qFuzzyIsNull(actualVertex.u() - expectedVertex.u())) + return false; + if (!qFuzzyIsNull(actualVertex.v() - expectedVertex.v())) + return false; return true; }; found = vertexTest(0) && vertexTest(1) && vertexTest(2) && vertexTest(3); @@ -107,10 +111,7 @@ void WindowQuadListTest::testMakeGrid() break; } } - QVERIFY2(found, qPrintable(QStringLiteral("%0, %1 / %2, %3").arg(QString::number(actualQuad.left()), - QString::number(actualQuad.top()), - QString::number(actualQuad.right()), - QString::number(actualQuad.bottom())))); + QVERIFY2(found, qPrintable(QStringLiteral("%0, %1 / %2, %3").arg(QString::number(actualQuad.left()), QString::number(actualQuad.top()), QString::number(actualQuad.right()), QString::number(actualQuad.bottom())))); } } @@ -150,15 +151,15 @@ void WindowQuadListTest::testMakeRegularGrid_data() orig.append(makeQuad(QRectF(0, 10, 4, 2))); expected.clear(); - expected.append(makeQuad(QRectF(0, 0, 5, 3))); - expected.append(makeQuad(QRectF(5, 0, 5, 3))); - expected.append(makeQuad(QRectF(0, 3, 5, 3))); - expected.append(makeQuad(QRectF(5, 3, 5, 3))); - expected.append(makeQuad(QRectF(0, 6, 5, 3))); - expected.append(makeQuad(QRectF(5, 6, 5, 3))); - expected.append(makeQuad(QRectF(0, 9, 5, 1))); + expected.append(makeQuad(QRectF(0, 0, 5, 3))); + expected.append(makeQuad(QRectF(5, 0, 5, 3))); + expected.append(makeQuad(QRectF(0, 3, 5, 3))); + expected.append(makeQuad(QRectF(5, 3, 5, 3))); + expected.append(makeQuad(QRectF(0, 6, 5, 3))); + expected.append(makeQuad(QRectF(5, 6, 5, 3))); + expected.append(makeQuad(QRectF(0, 9, 5, 1))); expected.append(makeQuad(QRectF(0, 10, 4, 2))); - expected.append(makeQuad(QRectF(5, 9, 5, 1))); + expected.append(makeQuad(QRectF(5, 9, 5, 1))); QTest::newRow("multipleQuads") << orig << 2 << 4 << 9 << expected; } @@ -179,10 +180,14 @@ void WindowQuadListTest::testMakeRegularGrid() auto vertexTest = [actualQuad, expectedQuad](int index) { const KWin::WindowVertex &actualVertex = actualQuad[index]; const KWin::WindowVertex &expectedVertex = expectedQuad[index]; - if (actualVertex.x() != expectedVertex.x()) return false; - if (actualVertex.y() != expectedVertex.y()) return false; - if (!qFuzzyIsNull(actualVertex.u() - expectedVertex.u())) return false; - if (!qFuzzyIsNull(actualVertex.v() - expectedVertex.v())) return false; + if (actualVertex.x() != expectedVertex.x()) + return false; + if (actualVertex.y() != expectedVertex.y()) + return false; + if (!qFuzzyIsNull(actualVertex.u() - expectedVertex.u())) + return false; + if (!qFuzzyIsNull(actualVertex.v() - expectedVertex.v())) + return false; return true; }; found = vertexTest(0) && vertexTest(1) && vertexTest(2) && vertexTest(3); @@ -190,10 +195,7 @@ void WindowQuadListTest::testMakeRegularGrid() break; } } - QVERIFY2(found, qPrintable(QStringLiteral("%0, %1 / %2, %3").arg(QString::number(actualQuad.left()), - QString::number(actualQuad.top()), - QString::number(actualQuad.right()), - QString::number(actualQuad.bottom())))); + QVERIFY2(found, qPrintable(QStringLiteral("%0, %1 / %2, %3").arg(QString::number(actualQuad.left()), QString::number(actualQuad.top()), QString::number(actualQuad.right()), QString::number(actualQuad.bottom())))); } } diff --git a/autotests/libxrenderutils/blendpicture_test.cpp b/autotests/libxrenderutils/blendpicture_test.cpp index 8e877941e5..b2d84d00d9 100644 --- a/autotests/libxrenderutils/blendpicture_test.cpp +++ b/autotests/libxrenderutils/blendpicture_test.cpp @@ -6,8 +6,8 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include #include +#include #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #include #else diff --git a/autotests/onscreennotificationtest.cpp b/autotests/onscreennotificationtest.cpp index 8bf994ca26..e174639074 100644 --- a/autotests/onscreennotificationtest.cpp +++ b/autotests/onscreennotificationtest.cpp @@ -7,11 +7,11 @@ #include "onscreennotificationtest.h" -#include "onscreennotification.h" #include "input.h" +#include "onscreennotification.h" -#include #include +#include #include #include diff --git a/autotests/opengl_context_attribute_builder_test.cpp b/autotests/opengl_context_attribute_builder_test.cpp index 1002c23344..c85f0ae59e 100644 --- a/autotests/opengl_context_attribute_builder_test.cpp +++ b/autotests/opengl_context_attribute_builder_test.cpp @@ -163,135 +163,153 @@ void OpenGLContextAttributeBuilderTest::testEgl_data() QTest::addColumn>("expectedAttribs"); QTest::newRow("fallback") << false << 0 << 0 << false << false << false << false << false << std::vector{EGL_NONE}; - QTest::newRow("legacy/robust") << false << 0 << 0 << true << false << false << false << false << - std::vector{ - EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR, - EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR, - EGL_NONE}; - QTest::newRow("legacy/robust/high priority") << false << 0 << 0 << true << false << false << false << true << - std::vector{ - EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR, - EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR, - EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, - EGL_NONE}; - QTest::newRow("core") << true << 3 << 1 << false << false << false << false << false << - std::vector{ - EGL_CONTEXT_MAJOR_VERSION_KHR, 3, - EGL_CONTEXT_MINOR_VERSION_KHR, 1, - EGL_NONE}; - QTest::newRow("core/high priority") << true << 3 << 1 << false << false << false << false << true << - std::vector{ - EGL_CONTEXT_MAJOR_VERSION_KHR, 3, - EGL_CONTEXT_MINOR_VERSION_KHR, 1, - EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, - EGL_NONE}; - QTest::newRow("core/robust") << true << 3 << 1 << true << false << false << false << false << - std::vector{ - EGL_CONTEXT_MAJOR_VERSION_KHR, 3, - EGL_CONTEXT_MINOR_VERSION_KHR, 1, - EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR, - EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR, - EGL_NONE}; - QTest::newRow("core/robust/high priority") << true << 3 << 1 << true << false << false << false << true << - std::vector{ - EGL_CONTEXT_MAJOR_VERSION_KHR, 3, - EGL_CONTEXT_MINOR_VERSION_KHR, 1, - EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR, - EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR, - EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, - EGL_NONE}; - QTest::newRow("core/robust/forward compatible") << true << 3 << 1 << true << true << false << false << false << - std::vector{ - EGL_CONTEXT_MAJOR_VERSION_KHR, 3, - EGL_CONTEXT_MINOR_VERSION_KHR, 1, - EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR, - EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, - EGL_NONE}; - QTest::newRow("core/robust/forward compatible/high priority") << true << 3 << 1 << true << true << false << false << true << - std::vector{ - EGL_CONTEXT_MAJOR_VERSION_KHR, 3, - EGL_CONTEXT_MINOR_VERSION_KHR, 1, - EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR, - EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, - EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, - EGL_NONE}; - QTest::newRow("core/forward compatible") << true << 3 << 1 << false << true << false << false << false << - std::vector{ - EGL_CONTEXT_MAJOR_VERSION_KHR, 3, - EGL_CONTEXT_MINOR_VERSION_KHR, 1, - EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, - EGL_NONE}; - QTest::newRow("core/forward compatible/high priority") << true << 3 << 1 << false << true << false << false << true << - std::vector{ - EGL_CONTEXT_MAJOR_VERSION_KHR, 3, - EGL_CONTEXT_MINOR_VERSION_KHR, 1, - EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, - EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, - EGL_NONE}; - QTest::newRow("core profile/forward compatible") << true << 3 << 2 << false << true << true << false << false << - std::vector{ - EGL_CONTEXT_MAJOR_VERSION_KHR, 3, - EGL_CONTEXT_MINOR_VERSION_KHR, 2, - EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, - EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR, - EGL_NONE}; - QTest::newRow("core profile/forward compatible/high priority") << true << 3 << 2 << false << true << true << false << true << - std::vector{ - EGL_CONTEXT_MAJOR_VERSION_KHR, 3, - EGL_CONTEXT_MINOR_VERSION_KHR, 2, - EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, - EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR, - EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, - EGL_NONE}; - QTest::newRow("compatibility profile/forward compatible") << true << 3 << 2 << false << true << false << true << false << - std::vector{ - EGL_CONTEXT_MAJOR_VERSION_KHR, 3, - EGL_CONTEXT_MINOR_VERSION_KHR, 2, - EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, - EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR, - EGL_NONE}; - QTest::newRow("compatibility profile/forward compatible/high priority") << true << 3 << 2 << false << true << false << true << true << - std::vector{ - EGL_CONTEXT_MAJOR_VERSION_KHR, 3, - EGL_CONTEXT_MINOR_VERSION_KHR, 2, - EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, - EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR, - EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, - EGL_NONE}; - QTest::newRow("core profile/robust/forward compatible") << true << 3 << 2 << true << true << true << false << false << - std::vector{ - EGL_CONTEXT_MAJOR_VERSION_KHR, 3, - EGL_CONTEXT_MINOR_VERSION_KHR, 2, - EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR, - EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, - EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR, - EGL_NONE}; - QTest::newRow("core profile/robust/forward compatible/high priority") << true << 3 << 2 << true << true << true << false << true << - std::vector{ - EGL_CONTEXT_MAJOR_VERSION_KHR, 3, - EGL_CONTEXT_MINOR_VERSION_KHR, 2, - EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR, - EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, - EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR, - EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, - EGL_NONE}; - QTest::newRow("compatibility profile/robust/forward compatible") << true << 3 << 2 << true << true << false << true << false << - std::vector{ - EGL_CONTEXT_MAJOR_VERSION_KHR, 3, - EGL_CONTEXT_MINOR_VERSION_KHR, 2, - EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR, - EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, - EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR, - EGL_NONE}; - QTest::newRow("compatibility profile/robust/forward compatible/high priority") << true << 3 << 2 << true << true << false << true << true << - std::vector{ - EGL_CONTEXT_MAJOR_VERSION_KHR, 3, - EGL_CONTEXT_MINOR_VERSION_KHR, 2, - EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR, - EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, - EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR, - EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, - EGL_NONE}; + QTest::newRow("legacy/robust") + << false << 0 << 0 << true << false << false << false << false + << std::vector{ + EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR, + EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR, + EGL_NONE}; + QTest::newRow("legacy/robust/high priority") + << false << 0 << 0 << true << false << false << false << true + << std::vector{ + EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR, + EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR, + EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, + EGL_NONE}; + QTest::newRow("core") + << true << 3 << 1 << false << false << false << false << false + << std::vector{ + EGL_CONTEXT_MAJOR_VERSION_KHR, 3, + EGL_CONTEXT_MINOR_VERSION_KHR, 1, + EGL_NONE}; + QTest::newRow("core/high priority") + << true << 3 << 1 << false << false << false << false << true + << std::vector{ + EGL_CONTEXT_MAJOR_VERSION_KHR, 3, + EGL_CONTEXT_MINOR_VERSION_KHR, 1, + EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, + EGL_NONE}; + QTest::newRow("core/robust") + << true << 3 << 1 << true << false << false << false << false + << std::vector{ + EGL_CONTEXT_MAJOR_VERSION_KHR, 3, + EGL_CONTEXT_MINOR_VERSION_KHR, 1, + EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR, + EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR, + EGL_NONE}; + QTest::newRow("core/robust/high priority") + << true << 3 << 1 << true << false << false << false << true + << std::vector{ + EGL_CONTEXT_MAJOR_VERSION_KHR, 3, + EGL_CONTEXT_MINOR_VERSION_KHR, 1, + EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR, + EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR, + EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, + EGL_NONE}; + QTest::newRow("core/robust/forward compatible") + << true << 3 << 1 << true << true << false << false << false + << std::vector{ + EGL_CONTEXT_MAJOR_VERSION_KHR, 3, + EGL_CONTEXT_MINOR_VERSION_KHR, 1, + EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR, + EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, + EGL_NONE}; + QTest::newRow("core/robust/forward compatible/high priority") + << true << 3 << 1 << true << true << false << false << true + << std::vector{ + EGL_CONTEXT_MAJOR_VERSION_KHR, 3, + EGL_CONTEXT_MINOR_VERSION_KHR, 1, + EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR, + EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, + EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, + EGL_NONE}; + QTest::newRow("core/forward compatible") + << true << 3 << 1 << false << true << false << false << false + << std::vector{ + EGL_CONTEXT_MAJOR_VERSION_KHR, 3, + EGL_CONTEXT_MINOR_VERSION_KHR, 1, + EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, + EGL_NONE}; + QTest::newRow("core/forward compatible/high priority") + << true << 3 << 1 << false << true << false << false << true + << std::vector{ + EGL_CONTEXT_MAJOR_VERSION_KHR, 3, + EGL_CONTEXT_MINOR_VERSION_KHR, 1, + EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, + EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, + EGL_NONE}; + QTest::newRow("core profile/forward compatible") + << true << 3 << 2 << false << true << true << false << false + << std::vector{ + EGL_CONTEXT_MAJOR_VERSION_KHR, 3, + EGL_CONTEXT_MINOR_VERSION_KHR, 2, + EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, + EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR, + EGL_NONE}; + QTest::newRow("core profile/forward compatible/high priority") + << true << 3 << 2 << false << true << true << false << true + << std::vector{ + EGL_CONTEXT_MAJOR_VERSION_KHR, 3, + EGL_CONTEXT_MINOR_VERSION_KHR, 2, + EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, + EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR, + EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, + EGL_NONE}; + QTest::newRow("compatibility profile/forward compatible") + << true << 3 << 2 << false << true << false << true << false + << std::vector{ + EGL_CONTEXT_MAJOR_VERSION_KHR, 3, + EGL_CONTEXT_MINOR_VERSION_KHR, 2, + EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, + EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR, + EGL_NONE}; + QTest::newRow("compatibility profile/forward compatible/high priority") + << true << 3 << 2 << false << true << false << true << true + << std::vector{ + EGL_CONTEXT_MAJOR_VERSION_KHR, 3, + EGL_CONTEXT_MINOR_VERSION_KHR, 2, + EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, + EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR, + EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, + EGL_NONE}; + QTest::newRow("core profile/robust/forward compatible") + << true << 3 << 2 << true << true << true << false << false + << std::vector{ + EGL_CONTEXT_MAJOR_VERSION_KHR, 3, + EGL_CONTEXT_MINOR_VERSION_KHR, 2, + EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR, + EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, + EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR, + EGL_NONE}; + QTest::newRow("core profile/robust/forward compatible/high priority") + << true << 3 << 2 << true << true << true << false << true + << std::vector{ + EGL_CONTEXT_MAJOR_VERSION_KHR, 3, + EGL_CONTEXT_MINOR_VERSION_KHR, 2, + EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR, + EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, + EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR, + EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, + EGL_NONE}; + QTest::newRow("compatibility profile/robust/forward compatible") + << true << 3 << 2 << true << true << false << true << false + << std::vector{ + EGL_CONTEXT_MAJOR_VERSION_KHR, 3, + EGL_CONTEXT_MINOR_VERSION_KHR, 2, + EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR, + EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, + EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR, + EGL_NONE}; + QTest::newRow("compatibility profile/robust/forward compatible/high priority") + << true << 3 << 2 << true << true << false << true << true + << std::vector{ + EGL_CONTEXT_MAJOR_VERSION_KHR, 3, + EGL_CONTEXT_MINOR_VERSION_KHR, 2, + EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR, EGL_LOSE_CONTEXT_ON_RESET_KHR, + EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR, + EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR, + EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, + EGL_NONE}; } void OpenGLContextAttributeBuilderTest::testEgl() @@ -325,24 +343,32 @@ void OpenGLContextAttributeBuilderTest::testGles_data() QTest::addColumn("highPriority"); QTest::addColumn>("expectedAttribs"); - QTest::newRow("robust") << true << false << std::vector{ - EGL_CONTEXT_CLIENT_VERSION, 2, - EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_TRUE, - EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, EGL_LOSE_CONTEXT_ON_RESET_EXT, - EGL_NONE}; - QTest::newRow("robust/high priority") << true << true << std::vector{ - EGL_CONTEXT_CLIENT_VERSION, 2, - EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_TRUE, - EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, EGL_LOSE_CONTEXT_ON_RESET_EXT, - EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, - EGL_NONE}; - QTest::newRow("normal") << false << false << std::vector{ - EGL_CONTEXT_CLIENT_VERSION, 2, - EGL_NONE}; - QTest::newRow("normal/high priority") << false << true << std::vector{ - EGL_CONTEXT_CLIENT_VERSION, 2, - EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, - EGL_NONE}; + QTest::newRow("robust") + << true << false + << std::vector{ + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_TRUE, + EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, EGL_LOSE_CONTEXT_ON_RESET_EXT, + EGL_NONE}; + QTest::newRow("robust/high priority") + << true << true + << std::vector{ + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT, EGL_TRUE, + EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, EGL_LOSE_CONTEXT_ON_RESET_EXT, + EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, + EGL_NONE}; + QTest::newRow("normal") + << false << false + << std::vector{ + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_NONE}; + QTest::newRow("normal/high priority") + << false << true + << std::vector{ + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, + EGL_NONE}; } void OpenGLContextAttributeBuilderTest::testGles() @@ -369,40 +395,48 @@ void OpenGLContextAttributeBuilderTest::testGlx_data() QTest::addColumn("videoPurge"); QTest::addColumn>("expectedAttribs"); - QTest::newRow("fallback") << true << 2 << 1 << false << false << std::vector{ - GLX_CONTEXT_MAJOR_VERSION_ARB, 2, - GLX_CONTEXT_MINOR_VERSION_ARB, 1, - 0}; - QTest::newRow("legacy/robust") << false << 0 << 0 << true << false << std::vector{ - GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB, - GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB, - 0 - }; - QTest::newRow("legacy/robust/videoPurge") << false << 0 << 0 << true << true << std::vector{ - GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB, - GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB, - GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV, GL_TRUE, - 0 - }; - QTest::newRow("core") << true << 3 << 1 << false << false << std::vector{ - GLX_CONTEXT_MAJOR_VERSION_ARB, 3, - GLX_CONTEXT_MINOR_VERSION_ARB, 1, - 0}; - QTest::newRow("core/robust") << true << 3 << 1 << true << false << std::vector{ - GLX_CONTEXT_MAJOR_VERSION_ARB, 3, - GLX_CONTEXT_MINOR_VERSION_ARB, 1, - GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB, - GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB, - 0 - }; - QTest::newRow("core/robust/videoPurge") << true << 3 << 1 << true << true << std::vector{ - GLX_CONTEXT_MAJOR_VERSION_ARB, 3, - GLX_CONTEXT_MINOR_VERSION_ARB, 1, - GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB, - GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB, - GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV, GL_TRUE, - 0 - }; + QTest::newRow("fallback") + << true << 2 << 1 << false << false + << std::vector{ + GLX_CONTEXT_MAJOR_VERSION_ARB, 2, + GLX_CONTEXT_MINOR_VERSION_ARB, 1, + 0}; + QTest::newRow("legacy/robust") + << false << 0 << 0 << true << false + << std::vector{ + GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB, + GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB, + 0}; + QTest::newRow("legacy/robust/videoPurge") + << false << 0 << 0 << true << true + << std::vector{ + GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB, + GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB, + GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV, GL_TRUE, + 0}; + QTest::newRow("core") + << true << 3 << 1 << false << false + << std::vector{ + GLX_CONTEXT_MAJOR_VERSION_ARB, 3, + GLX_CONTEXT_MINOR_VERSION_ARB, 1, + 0}; + QTest::newRow("core/robust") + << true << 3 << 1 << true << false + << std::vector{ + GLX_CONTEXT_MAJOR_VERSION_ARB, 3, + GLX_CONTEXT_MINOR_VERSION_ARB, 1, + GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB, + GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB, + 0}; + QTest::newRow("core/robust/videoPurge") + << true << 3 << 1 << true << true + << std::vector{ + GLX_CONTEXT_MAJOR_VERSION_ARB, 3, + GLX_CONTEXT_MINOR_VERSION_ARB, 1, + GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB, + GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, GLX_LOSE_CONTEXT_ON_RESET_ARB, + GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV, GL_TRUE, + 0}; #endif } diff --git a/autotests/tabbox/mock_tabboxclient.cpp b/autotests/tabbox/mock_tabboxclient.cpp index ced75db976..d4c22776eb 100644 --- a/autotests/tabbox/mock_tabboxclient.cpp +++ b/autotests/tabbox/mock_tabboxclient.cpp @@ -20,7 +20,7 @@ MockTabBoxClient::MockTabBoxClient(QString caption) void MockTabBoxClient::close() { - static_cast(TabBox::tabBox)->closeWindow(this); + static_cast(TabBox::tabBox)->closeWindow(this); } } // namespace KWin diff --git a/autotests/tabbox/mock_tabboxclient.h b/autotests/tabbox/mock_tabboxclient.h index d8a62a7edc..9c82905622 100644 --- a/autotests/tabbox/mock_tabboxclient.h +++ b/autotests/tabbox/mock_tabboxclient.h @@ -20,39 +20,50 @@ class MockTabBoxClient : public TabBox::TabBoxClient { public: explicit MockTabBoxClient(QString caption); - bool isMinimized() const override { + bool isMinimized() const override + { return false; } - QString caption() const override { + QString caption() const override + { return m_caption; } void close() override; - int height() const override { + int height() const override + { return 100; } - virtual QPixmap icon(const QSize &size = QSize(32, 32)) const { + virtual QPixmap icon(const QSize &size = QSize(32, 32)) const + { return QPixmap(size); } - bool isCloseable() const override { + bool isCloseable() const override + { return true; } - bool isFirstInTabBox() const override { + bool isFirstInTabBox() const override + { return false; } - int width() const override { + int width() const override + { return 100; } - int x() const override { + int x() const override + { return 0; } - int y() const override { + int y() const override + { return 0; } - QIcon icon() const override { + QIcon icon() const override + { return QIcon(); } - QUuid internalId() const override { + QUuid internalId() const override + { return QUuid{}; } diff --git a/autotests/tabbox/mock_tabboxhandler.cpp b/autotests/tabbox/mock_tabboxhandler.cpp index cc797e51d9..0395e54343 100644 --- a/autotests/tabbox/mock_tabboxhandler.cpp +++ b/autotests/tabbox/mock_tabboxhandler.cpp @@ -26,48 +26,48 @@ void MockTabBoxHandler::grabbedKeyEvent(QKeyEvent *event) const Q_UNUSED(event) } -QWeakPointer< TabBox::TabBoxClient > MockTabBoxHandler::activeClient() const +QWeakPointer MockTabBoxHandler::activeClient() const { return m_activeClient; } -void MockTabBoxHandler::setActiveClient(const QWeakPointer< TabBox::TabBoxClient >& client) +void MockTabBoxHandler::setActiveClient(const QWeakPointer &client) { m_activeClient = client; } -QWeakPointer< TabBox::TabBoxClient > MockTabBoxHandler::clientToAddToList(TabBox::TabBoxClient *client, int desktop) const +QWeakPointer MockTabBoxHandler::clientToAddToList(TabBox::TabBoxClient *client, int desktop) const { Q_UNUSED(desktop) - QList< QSharedPointer< TabBox::TabBoxClient > >::const_iterator it = m_windows.constBegin(); + QList>::const_iterator it = m_windows.constBegin(); for (; it != m_windows.constEnd(); ++it) { if ((*it).data() == client) { - return QWeakPointer< TabBox::TabBoxClient >(*it); + return QWeakPointer(*it); } } - return QWeakPointer< TabBox::TabBoxClient >(); + return QWeakPointer(); } -QWeakPointer< TabBox::TabBoxClient > MockTabBoxHandler::nextClientFocusChain(TabBox::TabBoxClient *client) const +QWeakPointer MockTabBoxHandler::nextClientFocusChain(TabBox::TabBoxClient *client) const { - QList< QSharedPointer< TabBox::TabBoxClient > >::const_iterator it = m_windows.constBegin(); + QList>::const_iterator it = m_windows.constBegin(); for (; it != m_windows.constEnd(); ++it) { if ((*it).data() == client) { ++it; if (it == m_windows.constEnd()) { - return QWeakPointer< TabBox::TabBoxClient >(m_windows.first()); + return QWeakPointer(m_windows.first()); } else { - return QWeakPointer< TabBox::TabBoxClient >(*it); + return QWeakPointer(*it); } } } if (!m_windows.isEmpty()) { - return QWeakPointer< TabBox::TabBoxClient >(m_windows.last()); + return QWeakPointer(m_windows.last()); } - return QWeakPointer< TabBox::TabBoxClient >(); + return QWeakPointer(); } -QWeakPointer< TabBox::TabBoxClient > MockTabBoxHandler::firstClientFocusChain() const +QWeakPointer MockTabBoxHandler::firstClientFocusChain() const { if (m_windows.isEmpty()) { return QWeakPointer(); @@ -80,7 +80,7 @@ bool MockTabBoxHandler::isInFocusChain(TabBox::TabBoxClient *client) const if (!client) { return false; } - QList< QSharedPointer< TabBox::TabBoxClient > >::const_iterator it = m_windows.constBegin(); + QList>::const_iterator it = m_windows.constBegin(); for (; it != m_windows.constEnd(); ++it) { if ((*it).data() == client) { return true; @@ -89,17 +89,17 @@ bool MockTabBoxHandler::isInFocusChain(TabBox::TabBoxClient *client) const return false; } -QWeakPointer< TabBox::TabBoxClient > MockTabBoxHandler::createMockWindow(const QString &caption) +QWeakPointer MockTabBoxHandler::createMockWindow(const QString &caption) { - QSharedPointer< TabBox::TabBoxClient > client(new MockTabBoxClient(caption)); + QSharedPointer client(new MockTabBoxClient(caption)); m_windows.append(client); m_activeClient = client; - return QWeakPointer< TabBox::TabBoxClient >(client); + return QWeakPointer(client); } void MockTabBoxHandler::closeWindow(TabBox::TabBoxClient *client) { - QList< QSharedPointer< TabBox::TabBoxClient > >::iterator it = m_windows.begin(); + QList>::iterator it = m_windows.begin(); for (; it != m_windows.end(); ++it) { if ((*it).data() == client) { m_windows.erase(it); diff --git a/autotests/tabbox/mock_tabboxhandler.h b/autotests/tabbox/mock_tabboxhandler.h index 719d899e2a..02038a2420 100644 --- a/autotests/tabbox/mock_tabboxhandler.h +++ b/autotests/tabbox/mock_tabboxhandler.h @@ -18,81 +18,100 @@ class MockTabBoxHandler : public TabBox::TabBoxHandler public: MockTabBoxHandler(QObject *parent = nullptr); ~MockTabBoxHandler() override; - void activateAndClose() override { + void activateAndClose() override + { } - QWeakPointer< TabBox::TabBoxClient > activeClient() const override; + QWeakPointer activeClient() const override; void setActiveClient(const QWeakPointer &client); - int activeScreen() const override { + int activeScreen() const override + { return 0; } - QWeakPointer< TabBox::TabBoxClient > clientToAddToList(TabBox::TabBoxClient *client, int desktop) const override; - int currentDesktop() const override { + QWeakPointer clientToAddToList(TabBox::TabBoxClient *client, int desktop) const override; + int currentDesktop() const override + { return 1; } - QWeakPointer< TabBox::TabBoxClient > desktopClient() const override { + QWeakPointer desktopClient() const override + { return QWeakPointer(); } - QString desktopName(int desktop) const override { + QString desktopName(int desktop) const override + { Q_UNUSED(desktop) return "desktop 1"; } - QString desktopName(TabBox::TabBoxClient *client) const override { + QString desktopName(TabBox::TabBoxClient *client) const override + { Q_UNUSED(client) return "desktop"; } - void elevateClient(TabBox::TabBoxClient *c, QWindow *tabbox, bool elevate) const override { + void elevateClient(TabBox::TabBoxClient *c, QWindow *tabbox, bool elevate) const override + { Q_UNUSED(c) Q_UNUSED(tabbox) Q_UNUSED(elevate) } - void shadeClient(TabBox::TabBoxClient *c, bool b) const override { + void shadeClient(TabBox::TabBoxClient *c, bool b) const override + { Q_UNUSED(c) Q_UNUSED(b) } - virtual void hideOutline() { + virtual void hideOutline() + { } - QWeakPointer< TabBox::TabBoxClient > nextClientFocusChain(TabBox::TabBoxClient *client) const override; + QWeakPointer nextClientFocusChain(TabBox::TabBoxClient *client) const override; QWeakPointer firstClientFocusChain() const override; - bool isInFocusChain (TabBox::TabBoxClient* client) const override; - int nextDesktopFocusChain(int desktop) const override { + bool isInFocusChain(TabBox::TabBoxClient *client) const override; + int nextDesktopFocusChain(int desktop) const override + { Q_UNUSED(desktop) return 1; } - int numberOfDesktops() const override { + int numberOfDesktops() const override + { return 1; } - bool isKWinCompositing() const override { + bool isKWinCompositing() const override + { return false; } - void raiseClient(TabBox::TabBoxClient *c) const override { + void raiseClient(TabBox::TabBoxClient *c) const override + { Q_UNUSED(c) } - void restack(TabBox::TabBoxClient *c, TabBox::TabBoxClient *under) override { + void restack(TabBox::TabBoxClient *c, TabBox::TabBoxClient *under) override + { Q_UNUSED(c) Q_UNUSED(under) } - virtual void showOutline(const QRect &outline) { + virtual void showOutline(const QRect &outline) + { Q_UNUSED(outline) } - TabBox::TabBoxClientList stackingOrder() const override { + TabBox::TabBoxClientList stackingOrder() const override + { return TabBox::TabBoxClientList(); } void grabbedKeyEvent(QKeyEvent *event) const override; - void highlightWindows(TabBox::TabBoxClient *window = nullptr, QWindow *controller = nullptr) override { + void highlightWindows(TabBox::TabBoxClient *window = nullptr, QWindow *controller = nullptr) override + { Q_UNUSED(window) Q_UNUSED(controller) } - bool noModifierGrab() const override { + bool noModifierGrab() const override + { return false; } // mock methods QWeakPointer createMockWindow(const QString &caption); void closeWindow(TabBox::TabBoxClient *client); + private: - QList< QSharedPointer > m_windows; + QList> m_windows; QWeakPointer m_activeClient; }; } // namespace KWin diff --git a/autotests/tabbox/test_tabbox_clientmodel.cpp b/autotests/tabbox/test_tabbox_clientmodel.cpp index 1800d834fd..b55b67081b 100644 --- a/autotests/tabbox/test_tabbox_clientmodel.cpp +++ b/autotests/tabbox/test_tabbox_clientmodel.cpp @@ -7,9 +7,9 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "test_tabbox_clientmodel.h" -#include "mock_tabboxhandler.h" -#include "clientmodel.h" #include "../testutils.h" +#include "clientmodel.h" +#include "mock_tabboxhandler.h" #include #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -21,7 +21,7 @@ using namespace KWin; void TestTabBoxClientModel::initTestCase() { - qApp->setProperty("x11Connection", QVariant::fromValue(QX11Info::connection())); + qApp->setProperty("x11Connection", QVariant::fromValue(QX11Info::connection())); } void TestTabBoxClientModel::testLongestCaptionWithNullClient() @@ -37,7 +37,7 @@ void TestTabBoxClientModel::testLongestCaptionWithNullClient() // delete the one client in the list QModelIndex index = clientModel->index(0, 0); QVERIFY(index.isValid()); - TabBox::TabBoxClient *client = static_cast(clientModel->data(index, TabBox::ClientModel::ClientRole).value()); + TabBox::TabBoxClient *client = static_cast(clientModel->data(index, TabBox::ClientModel::ClientRole).value()); client->close(); // internal model of ClientModel now contains a deleted pointer // longestCaption should behave just as if the window were not in the list diff --git a/autotests/tabbox/test_tabbox_handler.cpp b/autotests/tabbox/test_tabbox_handler.cpp index 49bae32dfa..c696376a60 100644 --- a/autotests/tabbox/test_tabbox_handler.cpp +++ b/autotests/tabbox/test_tabbox_handler.cpp @@ -6,9 +6,9 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include "mock_tabboxhandler.h" -#include "clientmodel.h" #include "../testutils.h" +#include "clientmodel.h" +#include "mock_tabboxhandler.h" #include #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #include @@ -35,7 +35,7 @@ private Q_SLOTS: void TestTabBoxHandler::initTestCase() { - qApp->setProperty("x11Connection", QVariant::fromValue(QX11Info::connection())); + qApp->setProperty("x11Connection", QVariant::fromValue(QX11Info::connection())); } void TestTabBoxHandler::testDontCrashUpdateOutlineNullClient() diff --git a/autotests/test_client_machine.cpp b/autotests/test_client_machine.cpp index d84e0cca12..8288ad474c 100644 --- a/autotests/test_client_machine.cpp +++ b/autotests/test_client_machine.cpp @@ -21,10 +21,10 @@ // xcb #include // system -#include -#include -#include #include +#include +#include +#include Q_LOGGING_CATEGORY(KWIN_CORE, "kwin_core") @@ -61,7 +61,7 @@ void TestClientMachine::initTestCase() char hostnamebuf[256]; #endif if (gethostname(hostnamebuf, sizeof hostnamebuf) >= 0) { - hostnamebuf[sizeof(hostnamebuf)-1] = 0; + hostnamebuf[sizeof(hostnamebuf) - 1] = 0; m_hostName = hostnamebuf; } addrinfo *res; @@ -78,7 +78,7 @@ void TestClientMachine::initTestCase() freeaddrinfo(res); qApp->setProperty("x11RootWindow", QVariant::fromValue(QX11Info::appRootWindow())); - qApp->setProperty("x11Connection", QVariant::fromValue(QX11Info::connection())); + qApp->setProperty("x11Connection", QVariant::fromValue(QX11Info::connection())); } void TestClientMachine::cleanupTestCase() @@ -91,26 +91,26 @@ void TestClientMachine::hostName_data() QTest::addColumn("expectedHost"); QTest::addColumn("local"); - QTest::newRow("empty") << QByteArray() << QByteArray("localhost") << true; + QTest::newRow("empty") << QByteArray() << QByteArray("localhost") << true; QTest::newRow("localhost") << QByteArray("localhost") << QByteArray("localhost") << true; - QTest::newRow("hostname") << m_hostName << m_hostName << true; - QTest::newRow("HOSTNAME") << m_hostName.toUpper() << m_hostName.toUpper() << true; + QTest::newRow("hostname") << m_hostName << m_hostName << true; + QTest::newRow("HOSTNAME") << m_hostName.toUpper() << m_hostName.toUpper() << true; QByteArray cutted(m_hostName); cutted.remove(0, 1); - QTest::newRow("ostname") << cutted << cutted << false; + QTest::newRow("ostname") << cutted << cutted << false; QByteArray domain("random.name.not.exist.tld"); - QTest::newRow("domain") << domain << domain << false; - QTest::newRow("fqdn") << m_fqdn << m_fqdn << true; - QTest::newRow("FQDN") << m_fqdn.toUpper() << m_fqdn.toUpper() << true; + QTest::newRow("domain") << domain << domain << false; + QTest::newRow("fqdn") << m_fqdn << m_fqdn << true; + QTest::newRow("FQDN") << m_fqdn.toUpper() << m_fqdn.toUpper() << true; cutted = m_fqdn; cutted.remove(0, 1); - QTest::newRow("qdn") << cutted << cutted << false; + QTest::newRow("qdn") << cutted << cutted << false; } void TestClientMachine::hostName() { const QRect geometry(0, 0, 10, 10); - const uint32_t values[] = { true }; + const uint32_t values[] = {true}; Xcb::Window window(geometry, XCB_WINDOW_CLASS_INPUT_ONLY, XCB_CW_OVERRIDE_REDIRECT, values); QFETCH(QByteArray, hostName); QFETCH(bool, local); @@ -121,7 +121,7 @@ void TestClientMachine::hostName() clientMachine.resolve(window, XCB_WINDOW_NONE); QTEST(clientMachine.hostName(), "expectedHost"); - int i=0; + int i = 0; while (clientMachine.isResolving() && i++ < 50) { // name is being resolved in an external thread, so let's wait a little bit QTest::qWait(250); @@ -134,7 +134,7 @@ void TestClientMachine::hostName() void TestClientMachine::emptyHostName() { const QRect geometry(0, 0, 10, 10); - const uint32_t values[] = { true }; + const uint32_t values[] = {true}; Xcb::Window window(geometry, XCB_WINDOW_CLASS_INPUT_ONLY, XCB_CW_OVERRIDE_REDIRECT, values); ClientMachine clientMachine; QSignalSpy spy(&clientMachine, &ClientMachine::localhostChanged); diff --git a/autotests/test_gestures.cpp b/autotests/test_gestures.cpp index 1833efc598..c1fc9b4c62 100644 --- a/autotests/test_gestures.cpp +++ b/autotests/test_gestures.cpp @@ -8,8 +8,8 @@ */ #include "gestures.h" -#include #include +#include #include #include @@ -34,7 +34,7 @@ private Q_SLOTS: void testPinchDirection_data(); void testPinchDirection(); - //swipe only + // swipe only void testMinimumX_data(); void testMinimumX(); void testMinimumY_data(); @@ -45,7 +45,7 @@ private Q_SLOTS: void testMaximumY(); void testStartGeometry(); - //swipe and pinch + // swipe and pinch void testSetMinimumDelta(); void testMinimumDeltaReached_data(); void testMinimumDeltaReached(); @@ -58,14 +58,14 @@ private Q_SLOTS: void testSwipeUpdateTrigger_data(); void testSwipeUpdateTrigger(); - //both + // both void testSwipeMinFingerStart_data(); void testSwipeMinFingerStart(); void testSwipeMaxFingerStart_data(); void testSwipeMaxFingerStart(); void testNotEmitCallbacksBeforeDirectionDecided(); - //swipe only + // swipe only void testSwipeGeometryStart_data(); void testSwipeGeometryStart(); }; @@ -351,7 +351,7 @@ void GestureTest::testMinimumDeltaReached() { GestureRecognizer recognizer; - //swipe gesture + // swipe gesture SwipeGesture gesture; QFETCH(SwipeGesture::Direction, direction); gesture.setDirection(direction); @@ -394,7 +394,7 @@ void GestureTest::testMinimumDeltaReached() void GestureTest::testMinimumScaleDelta() { - //pinch gesture + // pinch gesture PinchGesture gesture; gesture.setDirection(PinchGesture::Direction::Contracting); gesture.setMinimumScaleDelta(.5); @@ -514,7 +514,6 @@ void GestureTest::testSwipeCancel() QCOMPARE(triggeredSpy.count(), 0); } - void GestureTest::testSwipeUpdateTrigger_data() { QTest::addColumn("direction"); @@ -630,26 +629,26 @@ void GestureTest::testNotEmitCallbacksBeforeDirectionDecided() QSignalSpy expandSpy(&expand, &PinchGesture::progress); QSignalSpy contractSpy(&contract, &PinchGesture::progress); - //don't release callback until we know the direction of swipe gesture + // don't release callback until we know the direction of swipe gesture recognizer.startSwipeGesture(4); QCOMPARE(upSpy.count(), 0); QCOMPARE(downSpy.count(), 0); QCOMPARE(rightSpy.count(), 0); - //up (negative y) + // up (negative y) recognizer.updateSwipeGesture(QSizeF(0, -1.5)); QCOMPARE(upSpy.count(), 1); QCOMPARE(downSpy.count(), 0); QCOMPARE(rightSpy.count(), 0); - //down (positive y) - //recognizer.updateSwipeGesture(QSizeF(0, 0)); + // down (positive y) + // recognizer.updateSwipeGesture(QSizeF(0, 0)); recognizer.updateSwipeGesture(QSizeF(0, 3)); QCOMPARE(upSpy.count(), 1); QCOMPARE(downSpy.count(), 1); QCOMPARE(rightSpy.count(), 0); - //right + // right recognizer.cancelSwipeGesture(); recognizer.startSwipeGesture(4); recognizer.updateSwipeGesture(QSizeF(1, 0)); @@ -659,17 +658,17 @@ void GestureTest::testNotEmitCallbacksBeforeDirectionDecided() recognizer.cancelSwipeGesture(); - //same test for pinch gestures + // same test for pinch gestures recognizer.startPinchGesture(4); QCOMPARE(expandSpy.count(), 0); QCOMPARE(contractSpy.count(), 0); - //contracting + // contracting recognizer.updatePinchGesture(.5, 0, QSizeF(0, 0)); QCOMPARE(expandSpy.count(), 0); QCOMPARE(contractSpy.count(), 1); - //expanding + // expanding recognizer.updatePinchGesture(1.5, 0, QSizeF(0, 0)); QCOMPARE(expandSpy.count(), 1); QCOMPARE(contractSpy.count(), 1); @@ -708,7 +707,5 @@ void GestureTest::testSwipeGeometryStart() QTEST(!startedSpy.isEmpty(), "started"); } - - QTEST_MAIN(GestureTest) #include "test_gestures.moc" diff --git a/autotests/test_virtual_desktops.cpp b/autotests/test_virtual_desktops.cpp index 795acf8a45..28f5bc5bd2 100644 --- a/autotests/test_virtual_desktops.cpp +++ b/autotests/test_virtual_desktops.cpp @@ -14,7 +14,8 @@ #include #include -namespace KWin { +namespace KWin +{ int screen_number = 0; @@ -28,12 +29,12 @@ void InputRedirection::registerShortcut(const QKeySequence &shortcut, QAction *a void InputRedirection::registerAxisShortcut(Qt::KeyboardModifiers modifiers, PointerAxisDirection axis, QAction *action) { - Q_UNUSED(modifiers) - Q_UNUSED(axis) - Q_UNUSED(action) + Q_UNUSED(modifiers) + Q_UNUSED(axis) + Q_UNUSED(action) } -void InputRedirection::registerTouchpadSwipeShortcut(SwipeDirection, uint fingerCount, QAction*) +void InputRedirection::registerTouchpadSwipeShortcut(SwipeDirection, uint fingerCount, QAction *) { } @@ -106,12 +107,12 @@ void TestVirtualDesktops::count_data() QTest::addColumn("signal"); QTest::addColumn("removedSignal"); - QTest::newRow("Minimum") << (uint)1 << (uint)1 << true << true; + QTest::newRow("Minimum") << (uint)1 << (uint)1 << true << true; QTest::newRow("Below Minimum") << (uint)0 << (uint)1 << true << true; - QTest::newRow("Normal Value") << (uint)10 << (uint)10 << true << false; - QTest::newRow("Maximum") << VirtualDesktopManager::maximum() << VirtualDesktopManager::maximum() << true << false; + QTest::newRow("Normal Value") << (uint)10 << (uint)10 << true << false; + QTest::newRow("Maximum") << VirtualDesktopManager::maximum() << VirtualDesktopManager::maximum() << true << false; QTest::newRow("Above Maximum") << VirtualDesktopManager::maximum() + 1 << VirtualDesktopManager::maximum() << true << false; - QTest::newRow("Unchanged") << s_countInitValue << s_countInitValue << false << false; + QTest::newRow("Unchanged") << s_countInitValue << s_countInitValue << false << false; } void TestVirtualDesktops::count() @@ -145,7 +146,7 @@ void TestVirtualDesktops::count() if (!desktopsRemoved.isEmpty()) { QList arguments = desktopsRemoved.takeFirst(); QCOMPARE(arguments.count(), 1); - QCOMPARE(arguments.at(0).value(), vdToRemove); + QCOMPARE(arguments.at(0).value(), vdToRemove); } } @@ -156,9 +157,9 @@ void TestVirtualDesktops::navigationWrapsAround_data() QTest::addColumn("result"); QTest::addColumn("signal"); - QTest::newRow("enable") << false << true << true << true; - QTest::newRow("disable") << true << false << false << true; - QTest::newRow("keep enabled") << true << true << true << false; + QTest::newRow("enable") << false << true << true << true; + QTest::newRow("disable") << true << false << false << true; + QTest::newRow("keep enabled") << true << true << true << false; QTest::newRow("keep disabled") << false << false << false << false; } @@ -189,13 +190,13 @@ void TestVirtualDesktops::current_data() QTest::addColumn("result"); QTest::addColumn("signal"); - QTest::newRow("lower") << (uint)4 << (uint)3 << (uint)2 << (uint)2 << true; - QTest::newRow("higher") << (uint)4 << (uint)1 << (uint)2 << (uint)2 << true; - QTest::newRow("maximum") << (uint)4 << (uint)1 << (uint)4 << (uint)4 << true; + QTest::newRow("lower") << (uint)4 << (uint)3 << (uint)2 << (uint)2 << true; + QTest::newRow("higher") << (uint)4 << (uint)1 << (uint)2 << (uint)2 << true; + QTest::newRow("maximum") << (uint)4 << (uint)1 << (uint)4 << (uint)4 << true; QTest::newRow("above maximum") << (uint)4 << (uint)1 << (uint)5 << (uint)1 << false; - QTest::newRow("minimum") << (uint)4 << (uint)2 << (uint)1 << (uint)1 << true; + QTest::newRow("minimum") << (uint)4 << (uint)2 << (uint)1 << (uint)1 << true; QTest::newRow("below minimum") << (uint)4 << (uint)2 << (uint)0 << (uint)2 << false; - QTest::newRow("unchanged") << (uint)4 << (uint)2 << (uint)2 << (uint)2 << false; + QTest::newRow("unchanged") << (uint)4 << (uint)2 << (uint)2 << (uint)2 << false; } void TestVirtualDesktops::current() @@ -234,12 +235,12 @@ void TestVirtualDesktops::currentChangeOnCountChange_data() QTest::addColumn("current"); QTest::addColumn("signal"); - QTest::newRow("increment") << (uint)4 << (uint)2 << (uint)5 << (uint)2 << false; - QTest::newRow("increment on last") << (uint)4 << (uint)4 << (uint)5 << (uint)4 << false; - QTest::newRow("decrement") << (uint)4 << (uint)2 << (uint)3 << (uint)2 << false; + QTest::newRow("increment") << (uint)4 << (uint)2 << (uint)5 << (uint)2 << false; + QTest::newRow("increment on last") << (uint)4 << (uint)4 << (uint)5 << (uint)4 << false; + QTest::newRow("decrement") << (uint)4 << (uint)2 << (uint)3 << (uint)2 << false; QTest::newRow("decrement on second last") << (uint)4 << (uint)3 << (uint)3 << (uint)3 << false; - QTest::newRow("decrement on last") << (uint)4 << (uint)4 << (uint)3 << (uint)3 << true; - QTest::newRow("multiple decrement") << (uint)4 << (uint)2 << (uint)1 << (uint)1 << true; + QTest::newRow("decrement on last") << (uint)4 << (uint)4 << (uint)3 << (uint)3 << true; + QTest::newRow("multiple decrement") << (uint)4 << (uint)2 << (uint)1 << (uint)1 << true; } void TestVirtualDesktops::currentChangeOnCountChange() @@ -269,7 +270,7 @@ void TestVirtualDesktops::addDirectionColumns() QTest::addColumn("result"); } -template +template void TestVirtualDesktops::testDirection(const QString &actionName) { VirtualDesktopManager *vds = VirtualDesktopManager::self(); @@ -285,7 +286,7 @@ void TestVirtualDesktops::testDirection(const QString &actionName) vds->setNavigationWrappingAround(wrap); vds->initShortcuts(); - QAction *action = vds->findChild(actionName); + QAction *action = vds->findChild(actionName); QVERIFY(action); action->trigger(); QCOMPARE(vds->current(), result); @@ -296,11 +297,11 @@ void TestVirtualDesktops::next_data() { addDirectionColumns(); - QTest::newRow("one desktop, wrap") << (uint)1 << (uint)1 << true << (uint)1; - QTest::newRow("one desktop, no wrap") << (uint)1 << (uint)1 << false << (uint)1; - QTest::newRow("desktops, wrap") << (uint)4 << (uint)1 << true << (uint)2; - QTest::newRow("desktops, no wrap") << (uint)4 << (uint)1 << false << (uint)2; - QTest::newRow("desktops at end, wrap") << (uint)4 << (uint)4 << true << (uint)1; + QTest::newRow("one desktop, wrap") << (uint)1 << (uint)1 << true << (uint)1; + QTest::newRow("one desktop, no wrap") << (uint)1 << (uint)1 << false << (uint)1; + QTest::newRow("desktops, wrap") << (uint)4 << (uint)1 << true << (uint)2; + QTest::newRow("desktops, no wrap") << (uint)4 << (uint)1 << false << (uint)2; + QTest::newRow("desktops at end, wrap") << (uint)4 << (uint)4 << true << (uint)1; QTest::newRow("desktops at end, no wrap") << (uint)4 << (uint)4 << false << (uint)4; } @@ -313,11 +314,11 @@ void TestVirtualDesktops::previous_data() { addDirectionColumns(); - QTest::newRow("one desktop, wrap") << (uint)1 << (uint)1 << true << (uint)1; - QTest::newRow("one desktop, no wrap") << (uint)1 << (uint)1 << false << (uint)1; - QTest::newRow("desktops, wrap") << (uint)4 << (uint)3 << true << (uint)2; - QTest::newRow("desktops, no wrap") << (uint)4 << (uint)3 << false << (uint)2; - QTest::newRow("desktops at start, wrap") << (uint)4 << (uint)1 << true << (uint)4; + QTest::newRow("one desktop, wrap") << (uint)1 << (uint)1 << true << (uint)1; + QTest::newRow("one desktop, no wrap") << (uint)1 << (uint)1 << false << (uint)1; + QTest::newRow("desktops, wrap") << (uint)4 << (uint)3 << true << (uint)2; + QTest::newRow("desktops, no wrap") << (uint)4 << (uint)3 << false << (uint)2; + QTest::newRow("desktops at start, wrap") << (uint)4 << (uint)1 << true << (uint)4; QTest::newRow("desktops at start, no wrap") << (uint)4 << (uint)1 << false << (uint)1; } @@ -329,16 +330,16 @@ void TestVirtualDesktops::previous() void TestVirtualDesktops::left_data() { addDirectionColumns(); - QTest::newRow("one desktop, wrap") << (uint)1 << (uint)1 << true << (uint)1; - QTest::newRow("one desktop, no wrap") << (uint)1 << (uint)1 << false << (uint)1; - QTest::newRow("desktops, wrap, 1st row") << (uint)4 << (uint)2 << true << (uint)1; + QTest::newRow("one desktop, wrap") << (uint)1 << (uint)1 << true << (uint)1; + QTest::newRow("one desktop, no wrap") << (uint)1 << (uint)1 << false << (uint)1; + QTest::newRow("desktops, wrap, 1st row") << (uint)4 << (uint)2 << true << (uint)1; QTest::newRow("desktops, no wrap, 1st row") << (uint)4 << (uint)2 << false << (uint)1; - QTest::newRow("desktops, wrap, 2nd row") << (uint)4 << (uint)4 << true << (uint)3; + QTest::newRow("desktops, wrap, 2nd row") << (uint)4 << (uint)4 << true << (uint)3; QTest::newRow("desktops, no wrap, 2nd row") << (uint)4 << (uint)4 << false << (uint)3; - QTest::newRow("desktops at start, wrap, 1st row") << (uint)4 << (uint)1 << true << (uint)2; + QTest::newRow("desktops at start, wrap, 1st row") << (uint)4 << (uint)1 << true << (uint)2; QTest::newRow("desktops at start, no wrap, 1st row") << (uint)4 << (uint)1 << false << (uint)1; - QTest::newRow("desktops at start, wrap, 2nd row") << (uint)4 << (uint)3 << true << (uint)4; + QTest::newRow("desktops at start, wrap, 2nd row") << (uint)4 << (uint)3 << true << (uint)4; QTest::newRow("desktops at start, no wrap, 2nd row") << (uint)4 << (uint)3 << false << (uint)3; QTest::newRow("non symmetric, start") << (uint)5 << (uint)5 << false << (uint)4; @@ -354,16 +355,16 @@ void TestVirtualDesktops::left() void TestVirtualDesktops::right_data() { addDirectionColumns(); - QTest::newRow("one desktop, wrap") << (uint)1 << (uint)1 << true << (uint)1; - QTest::newRow("one desktop, no wrap") << (uint)1 << (uint)1 << false << (uint)1; - QTest::newRow("desktops, wrap, 1st row") << (uint)4 << (uint)1 << true << (uint)2; + QTest::newRow("one desktop, wrap") << (uint)1 << (uint)1 << true << (uint)1; + QTest::newRow("one desktop, no wrap") << (uint)1 << (uint)1 << false << (uint)1; + QTest::newRow("desktops, wrap, 1st row") << (uint)4 << (uint)1 << true << (uint)2; QTest::newRow("desktops, no wrap, 1st row") << (uint)4 << (uint)1 << false << (uint)2; - QTest::newRow("desktops, wrap, 2nd row") << (uint)4 << (uint)3 << true << (uint)4; + QTest::newRow("desktops, wrap, 2nd row") << (uint)4 << (uint)3 << true << (uint)4; QTest::newRow("desktops, no wrap, 2nd row") << (uint)4 << (uint)3 << false << (uint)4; - QTest::newRow("desktops at start, wrap, 1st row") << (uint)4 << (uint)2 << true << (uint)1; + QTest::newRow("desktops at start, wrap, 1st row") << (uint)4 << (uint)2 << true << (uint)1; QTest::newRow("desktops at start, no wrap, 1st row") << (uint)4 << (uint)2 << false << (uint)2; - QTest::newRow("desktops at start, wrap, 2nd row") << (uint)4 << (uint)4 << true << (uint)3; + QTest::newRow("desktops at start, wrap, 2nd row") << (uint)4 << (uint)4 << true << (uint)3; QTest::newRow("desktops at start, no wrap, 2nd row") << (uint)4 << (uint)4 << false << (uint)4; QTest::newRow("non symmetric, start") << (uint)5 << (uint)4 << false << (uint)5; @@ -379,16 +380,16 @@ void TestVirtualDesktops::right() void TestVirtualDesktops::above_data() { addDirectionColumns(); - QTest::newRow("one desktop, wrap") << (uint)1 << (uint)1 << true << (uint)1; - QTest::newRow("one desktop, no wrap") << (uint)1 << (uint)1 << false << (uint)1; - QTest::newRow("desktops, wrap, 1st column") << (uint)4 << (uint)3 << true << (uint)1; + QTest::newRow("one desktop, wrap") << (uint)1 << (uint)1 << true << (uint)1; + QTest::newRow("one desktop, no wrap") << (uint)1 << (uint)1 << false << (uint)1; + QTest::newRow("desktops, wrap, 1st column") << (uint)4 << (uint)3 << true << (uint)1; QTest::newRow("desktops, no wrap, 1st column") << (uint)4 << (uint)3 << false << (uint)1; - QTest::newRow("desktops, wrap, 2nd column") << (uint)4 << (uint)4 << true << (uint)2; + QTest::newRow("desktops, wrap, 2nd column") << (uint)4 << (uint)4 << true << (uint)2; QTest::newRow("desktops, no wrap, 2nd column") << (uint)4 << (uint)4 << false << (uint)2; - QTest::newRow("desktops at start, wrap, 1st column") << (uint)4 << (uint)1 << true << (uint)3; + QTest::newRow("desktops at start, wrap, 1st column") << (uint)4 << (uint)1 << true << (uint)3; QTest::newRow("desktops at start, no wrap, 1st column") << (uint)4 << (uint)1 << false << (uint)1; - QTest::newRow("desktops at start, wrap, 2nd column") << (uint)4 << (uint)2 << true << (uint)4; + QTest::newRow("desktops at start, wrap, 2nd column") << (uint)4 << (uint)2 << true << (uint)4; QTest::newRow("desktops at start, no wrap, 2nd column") << (uint)4 << (uint)2 << false << (uint)2; } @@ -400,16 +401,16 @@ void TestVirtualDesktops::above() void TestVirtualDesktops::below_data() { addDirectionColumns(); - QTest::newRow("one desktop, wrap") << (uint)1 << (uint)1 << true << (uint)1; - QTest::newRow("one desktop, no wrap") << (uint)1 << (uint)1 << false << (uint)1; - QTest::newRow("desktops, wrap, 1st column") << (uint)4 << (uint)1 << true << (uint)3; + QTest::newRow("one desktop, wrap") << (uint)1 << (uint)1 << true << (uint)1; + QTest::newRow("one desktop, no wrap") << (uint)1 << (uint)1 << false << (uint)1; + QTest::newRow("desktops, wrap, 1st column") << (uint)4 << (uint)1 << true << (uint)3; QTest::newRow("desktops, no wrap, 1st column") << (uint)4 << (uint)1 << false << (uint)3; - QTest::newRow("desktops, wrap, 2nd column") << (uint)4 << (uint)2 << true << (uint)4; + QTest::newRow("desktops, wrap, 2nd column") << (uint)4 << (uint)2 << true << (uint)4; QTest::newRow("desktops, no wrap, 2nd column") << (uint)4 << (uint)2 << false << (uint)4; - QTest::newRow("desktops at start, wrap, 1st column") << (uint)4 << (uint)3 << true << (uint)1; + QTest::newRow("desktops at start, wrap, 1st column") << (uint)4 << (uint)3 << true << (uint)1; QTest::newRow("desktops at start, no wrap, 1st column") << (uint)4 << (uint)3 << false << (uint)3; - QTest::newRow("desktops at start, wrap, 2nd column") << (uint)4 << (uint)4 << true << (uint)2; + QTest::newRow("desktops at start, wrap, 2nd column") << (uint)4 << (uint)4 << true << (uint)2; QTest::newRow("desktops at start, no wrap, 2nd column") << (uint)4 << (uint)4 << false << (uint)4; } @@ -428,8 +429,8 @@ void TestVirtualDesktops::updateGrid_data() const Qt::Orientation h = Qt::Horizontal; const Qt::Orientation v = Qt::Vertical; - QTest::newRow("one desktop, h") << (uint)1 << QSize(1, 1) << h << QPoint(0, 0) << (uint)1; - QTest::newRow("one desktop, v") << (uint)1 << QSize(1, 1) << v << QPoint(0, 0) << (uint)1; + QTest::newRow("one desktop, h") << (uint)1 << QSize(1, 1) << h << QPoint(0, 0) << (uint)1; + QTest::newRow("one desktop, v") << (uint)1 << QSize(1, 1) << v << QPoint(0, 0) << (uint)1; QTest::newRow("one desktop, h, 0") << (uint)1 << QSize(1, 1) << h << QPoint(1, 0) << (uint)0; QTest::newRow("one desktop, v, 0") << (uint)1 << QSize(1, 1) << v << QPoint(0, 1) << (uint)0; @@ -492,15 +493,15 @@ void TestVirtualDesktops::updateLayout_data() QTest::addColumn("desktop"); QTest::addColumn("result"); - QTest::newRow("01") << (uint)1 << QSize(1, 1); - QTest::newRow("02") << (uint)2 << QSize(1, 2); - QTest::newRow("03") << (uint)3 << QSize(2, 2); - QTest::newRow("04") << (uint)4 << QSize(2, 2); - QTest::newRow("05") << (uint)5 << QSize(3, 2); - QTest::newRow("06") << (uint)6 << QSize(3, 2); - QTest::newRow("07") << (uint)7 << QSize(4, 2); - QTest::newRow("08") << (uint)8 << QSize(4, 2); - QTest::newRow("09") << (uint)9 << QSize(5, 2); + QTest::newRow("01") << (uint)1 << QSize(1, 1); + QTest::newRow("02") << (uint)2 << QSize(1, 2); + QTest::newRow("03") << (uint)3 << QSize(2, 2); + QTest::newRow("04") << (uint)4 << QSize(2, 2); + QTest::newRow("05") << (uint)5 << QSize(3, 2); + QTest::newRow("06") << (uint)6 << QSize(3, 2); + QTest::newRow("07") << (uint)7 << QSize(4, 2); + QTest::newRow("08") << (uint)8 << QSize(4, 2); + QTest::newRow("09") << (uint)9 << QSize(5, 2); QTest::newRow("10") << (uint)10 << QSize(5, 2); QTest::newRow("11") << (uint)11 << QSize(6, 2); QTest::newRow("12") << (uint)12 << QSize(6, 2); @@ -568,9 +569,9 @@ void TestVirtualDesktops::switchToShortcuts() QCOMPARE(vds->current(), vds->maximum()); vds->initShortcuts(); const QString toDesktop = QStringLiteral("Switch to Desktop %1"); - for (uint i=1; i<=vds->maximum(); ++i) { + for (uint i = 1; i <= vds->maximum(); ++i) { const QString desktop(toDesktop.arg(i)); - QAction *action = vds->findChild(desktop); + QAction *action = vds->findChild(desktop); QVERIFY2(action, desktop.toUtf8().constData()); action->trigger(); QCOMPARE(vds->current(), i); diff --git a/autotests/test_window_paint_data.cpp b/autotests/test_window_paint_data.cpp index 73f98087ba..c9db8e485a 100644 --- a/autotests/test_window_paint_data.cpp +++ b/autotests/test_window_paint_data.cpp @@ -11,9 +11,9 @@ #include "virtualdesktops.h" -#include #include #include +#include #include @@ -46,219 +46,294 @@ public: void minimize() override; void unminimize() override; void closeWindow() override; - void referencePreviousWindowPixmap() override {} - void unreferencePreviousWindowPixmap() override {} - QWindow *internalWindow() const override { + void referencePreviousWindowPixmap() override + { + } + void unreferencePreviousWindowPixmap() override + { + } + QWindow *internalWindow() const override + { return nullptr; } - bool isDeleted() const override { + bool isDeleted() const override + { return false; } - bool isMinimized() const override { + bool isMinimized() const override + { return false; } - double opacity() const override { + double opacity() const override + { return m_opacity; } - void setOpacity(qreal opacity) { + void setOpacity(qreal opacity) + { m_opacity = opacity; } - bool hasAlpha() const override { + bool hasAlpha() const override + { return true; } - QStringList activities() const override { + QStringList activities() const override + { return QStringList(); } - int desktop() const override { + int desktop() const override + { return 0; } - QVector desktops() const override { + QVector desktops() const override + { return {}; } - int x() const override { + int x() const override + { return 0; } - int y() const override { + int y() const override + { return 0; } - int width() const override { + int width() const override + { return 100; } - int height() const override { + int height() const override + { return 100; } - QSize basicUnit() const override { + QSize basicUnit() const override + { return QSize(); } - QRect geometry() const override { + QRect geometry() const override + { return QRect(); } - QRect expandedGeometry() const override { + QRect expandedGeometry() const override + { return QRect(); } - QRect frameGeometry() const override { + QRect frameGeometry() const override + { return QRect(); } - QRect bufferGeometry() const override { + QRect bufferGeometry() const override + { return QRect(); } - QRect clientGeometry() const override { + QRect clientGeometry() const override + { return QRect(); } - EffectScreen *screen() const override { + EffectScreen *screen() const override + { return nullptr; } - QPoint pos() const override { + QPoint pos() const override + { return QPoint(); } - QSize size() const override { - return QSize(100,100); + QSize size() const override + { + return QSize(100, 100); } - QRect rect() const override { - return QRect(0,0,100,100); + QRect rect() const override + { + return QRect(0, 0, 100, 100); } - bool isMovable() const override { + bool isMovable() const override + { return true; } - bool isMovableAcrossScreens() const override { + bool isMovableAcrossScreens() const override + { return true; } - bool isUserMove() const override { + bool isUserMove() const override + { return false; } - bool isUserResize() const override { + bool isUserResize() const override + { return false; } - QRect iconGeometry() const override { + QRect iconGeometry() const override + { return QRect(); } - bool isDesktop() const override { + bool isDesktop() const override + { return false; } - bool isDock() const override { + bool isDock() const override + { return false; } - bool isToolbar() const override { + bool isToolbar() const override + { return false; } - bool isMenu() const override { + bool isMenu() const override + { return false; } - bool isNormalWindow() const override { + bool isNormalWindow() const override + { return true; } - bool isSpecialWindow() const override { + bool isSpecialWindow() const override + { return false; } - bool isDialog() const override { + bool isDialog() const override + { return false; } - bool isSplash() const override { + bool isSplash() const override + { return false; } - bool isUtility() const override { + bool isUtility() const override + { return false; } - bool isDropdownMenu() const override { + bool isDropdownMenu() const override + { return false; } - bool isPopupMenu() const override { + bool isPopupMenu() const override + { return false; } - bool isTooltip() const override { + bool isTooltip() const override + { return false; } - bool isNotification() const override { + bool isNotification() const override + { return false; } - bool isCriticalNotification() const override { + bool isCriticalNotification() const override + { return false; } - bool isOnScreenDisplay() const override { + bool isOnScreenDisplay() const override + { return false; } - bool isComboBox() const override { + bool isComboBox() const override + { return false; } - bool isDNDIcon() const override { + bool isDNDIcon() const override + { return false; } - QRect contentsRect() const override { + QRect contentsRect() const override + { return QRect(); } - bool decorationHasAlpha() const override { + bool decorationHasAlpha() const override + { return false; } - KDecoration2::Decoration *decoration() const override { + KDecoration2::Decoration *decoration() const override + { return nullptr; } - QString caption() const override { + QString caption() const override + { return QString(); } - QIcon icon() const override { + QIcon icon() const override + { return QIcon(); } - QString windowClass() const override { + QString windowClass() const override + { return QString(); } - QString windowRole() const override { + QString windowRole() const override + { return QString(); } - NET::WindowType windowType() const override { + NET::WindowType windowType() const override + { return NET::Normal; } - bool acceptsFocus() const override { + bool acceptsFocus() const override + { return true; } - bool keepAbove() const override { + bool keepAbove() const override + { return false; } - bool keepBelow() const override { + bool keepBelow() const override + { return false; } - bool isModal() const override { + bool isModal() const override + { return false; } - bool isSkipSwitcher() const override { + bool isSkipSwitcher() const override + { return false; } - bool isCurrentTab() const override { + bool isCurrentTab() const override + { return true; } - bool skipsCloseAnimation() const override { + bool skipsCloseAnimation() const override + { return false; } - KWaylandServer::SurfaceInterface *surface() const override { + KWaylandServer::SurfaceInterface *surface() const override + { return nullptr; } - bool isFullScreen() const override { + bool isFullScreen() const override + { return false; } - bool isUnresponsive() const override { + bool isUnresponsive() const override + { return false; } - bool isPopupWindow() const override { + bool isPopupWindow() const override + { return false; } - bool isManaged() const override { + bool isManaged() const override + { return true; } - bool isWaylandClient() const override { + bool isWaylandClient() const override + { return true; } - bool isX11Client() const override { + bool isX11Client() const override + { return false; } - bool isOutline() const override { + bool isOutline() const override + { return false; } - bool isLockScreen() const override { + bool isLockScreen() const override + { return false; } - pid_t pid() const override { + pid_t pid() const override + { return 0; } - qlonglong windowId() const override { + qlonglong windowId() const override + { return 0; } diff --git a/autotests/test_x11_timestamp_update.cpp b/autotests/test_x11_timestamp_update.cpp index 499af97aae..744d6bdef4 100644 --- a/autotests/test_x11_timestamp_update.cpp +++ b/autotests/test_x11_timestamp_update.cpp @@ -31,7 +31,6 @@ public: protected: void performStartup() override; - }; X11TestApplication::X11TestApplication(int &argc, char **argv) @@ -47,7 +46,7 @@ X11TestApplication::X11TestApplication(int &argc, char **argv) addLibraryPath(ownPath); const KPluginMetaData plugin = KPluginMetaData::findPluginById(QStringLiteral("org.kde.kwin.platforms"), - QStringLiteral("KWinX11Platform")); + QStringLiteral("KWinX11Platform")); if (!plugin.isValid()) { quit(); return; diff --git a/autotests/test_xcb_size_hints.cpp b/autotests/test_xcb_size_hints.cpp index ec03807b85..b7c177d694 100644 --- a/autotests/test_xcb_size_hints.cpp +++ b/autotests/test_xcb_size_hints.cpp @@ -46,12 +46,12 @@ private: void TestXcbSizeHints::initTestCase() { qApp->setProperty("x11RootWindow", QVariant::fromValue(QX11Info::appRootWindow())); - qApp->setProperty("x11Connection", QVariant::fromValue(QX11Info::connection())); + qApp->setProperty("x11Connection", QVariant::fromValue(QX11Info::connection())); } void TestXcbSizeHints::init() { - const uint32_t values[] = { true }; + const uint32_t values[] = {true}; m_testWindow.create(QRect(0, 0, 10, 10), XCB_WINDOW_CLASS_INPUT_ONLY, XCB_CW_OVERRIDE_REDIRECT, values); QVERIFY(m_testWindow.isValid()); } @@ -101,44 +101,44 @@ void TestXcbSizeHints::testSizeHints_data() QTest::addColumn("expectedGravity"); QTest::newRow("userPos") << QPoint(1, 2) << QSize() << QSize() << QSize() << QSize() << QSize() << QSize() << QSize() << 0 - << 1 << 1 << 2 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 - << QSize(0, 0) << QSize(INT_MAX, INT_MAX) << QSize(1, 1) << QSize(1, INT_MAX) << QSize(INT_MAX, 1) << QSize(0, 0) << qint32(XCB_GRAVITY_NORTH_WEST); + << 1 << 1 << 2 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 + << QSize(0, 0) << QSize(INT_MAX, INT_MAX) << QSize(1, 1) << QSize(1, INT_MAX) << QSize(INT_MAX, 1) << QSize(0, 0) << qint32(XCB_GRAVITY_NORTH_WEST); QTest::newRow("userSize") << QPoint() << QSize(1, 2) << QSize() << QSize() << QSize() << QSize() << QSize() << QSize() << 0 - << 2 << 0 << 0 << 1 << 2 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 - << QSize(0, 0) << QSize(INT_MAX, INT_MAX) << QSize(1, 1) << QSize(1, INT_MAX) << QSize(INT_MAX, 1) << QSize(0, 0) << qint32(XCB_GRAVITY_NORTH_WEST); + << 2 << 0 << 0 << 1 << 2 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 + << QSize(0, 0) << QSize(INT_MAX, INT_MAX) << QSize(1, 1) << QSize(1, INT_MAX) << QSize(INT_MAX, 1) << QSize(0, 0) << qint32(XCB_GRAVITY_NORTH_WEST); QTest::newRow("minSize") << QPoint() << QSize() << QSize(1, 2) << QSize() << QSize() << QSize() << QSize() << QSize() << 0 - << 16 << 0 << 0 << 0 << 0 << 1 << 2 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 - << QSize(1, 2) << QSize(INT_MAX, INT_MAX) << QSize(1, 1) << QSize(1, INT_MAX) << QSize(INT_MAX, 1) << QSize(0, 0) << qint32(XCB_GRAVITY_NORTH_WEST); + << 16 << 0 << 0 << 0 << 0 << 1 << 2 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 + << QSize(1, 2) << QSize(INT_MAX, INT_MAX) << QSize(1, 1) << QSize(1, INT_MAX) << QSize(INT_MAX, 1) << QSize(0, 0) << qint32(XCB_GRAVITY_NORTH_WEST); QTest::newRow("maxSize") << QPoint() << QSize() << QSize() << QSize(1, 2) << QSize() << QSize() << QSize() << QSize() << 0 - << 32 << 0 << 0 << 0 << 0 << 0 << 0 << 1 << 2 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 - << QSize(0, 0) << QSize(1, 2) << QSize(1, 1) << QSize(1, INT_MAX) << QSize(INT_MAX, 1) << QSize(0, 0) << qint32(XCB_GRAVITY_NORTH_WEST); + << 32 << 0 << 0 << 0 << 0 << 0 << 0 << 1 << 2 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 + << QSize(0, 0) << QSize(1, 2) << QSize(1, 1) << QSize(1, INT_MAX) << QSize(INT_MAX, 1) << QSize(0, 0) << qint32(XCB_GRAVITY_NORTH_WEST); QTest::newRow("maxSize0") << QPoint() << QSize() << QSize() << QSize(0, 0) << QSize() << QSize() << QSize() << QSize() << 0 - << 32 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 - << QSize(0, 0) << QSize(1, 1) << QSize(1, 1) << QSize(1, INT_MAX) << QSize(INT_MAX, 1) << QSize(0, 0) << qint32(XCB_GRAVITY_NORTH_WEST); + << 32 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 + << QSize(0, 0) << QSize(1, 1) << QSize(1, 1) << QSize(1, INT_MAX) << QSize(INT_MAX, 1) << QSize(0, 0) << qint32(XCB_GRAVITY_NORTH_WEST); QTest::newRow("min/maxSize") << QPoint() << QSize() << QSize(1, 2) << QSize(3, 4) << QSize() << QSize() << QSize() << QSize() << 0 - << 48 << 0 << 0 << 0 << 0 << 1 << 2 << 3 << 4 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 - << QSize(1, 2) << QSize(3, 4) << QSize(1, 1) << QSize(1, INT_MAX) << QSize(INT_MAX, 1) << QSize(0, 0) << qint32(XCB_GRAVITY_NORTH_WEST); + << 48 << 0 << 0 << 0 << 0 << 1 << 2 << 3 << 4 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 + << QSize(1, 2) << QSize(3, 4) << QSize(1, 1) << QSize(1, INT_MAX) << QSize(INT_MAX, 1) << QSize(0, 0) << qint32(XCB_GRAVITY_NORTH_WEST); QTest::newRow("resizeInc") << QPoint() << QSize() << QSize() << QSize() << QSize(1, 2) << QSize() << QSize() << QSize() << 0 - << 64 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 1 << 2 << 0 << 0 << 0 << 0 << 0 << 0 - << QSize(0, 0) << QSize(INT_MAX, INT_MAX) << QSize(1, 2) << QSize(1, INT_MAX) << QSize(INT_MAX, 1) << QSize(0, 0) << qint32(XCB_GRAVITY_NORTH_WEST); + << 64 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 1 << 2 << 0 << 0 << 0 << 0 << 0 << 0 + << QSize(0, 0) << QSize(INT_MAX, INT_MAX) << QSize(1, 2) << QSize(1, INT_MAX) << QSize(INT_MAX, 1) << QSize(0, 0) << qint32(XCB_GRAVITY_NORTH_WEST); QTest::newRow("resizeInc0") << QPoint() << QSize() << QSize() << QSize() << QSize(0, 0) << QSize() << QSize() << QSize() << 0 - << 64 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 - << QSize(0, 0) << QSize(INT_MAX, INT_MAX) << QSize(1, 1) << QSize(1, INT_MAX) << QSize(INT_MAX, 1) << QSize(0, 0) << qint32(XCB_GRAVITY_NORTH_WEST); + << 64 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 + << QSize(0, 0) << QSize(INT_MAX, INT_MAX) << QSize(1, 1) << QSize(1, INT_MAX) << QSize(INT_MAX, 1) << QSize(0, 0) << qint32(XCB_GRAVITY_NORTH_WEST); QTest::newRow("aspect") << QPoint() << QSize() << QSize() << QSize() << QSize() << QSize(1, 2) << QSize(3, 4) << QSize() << 0 - << 128 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 1 << 2 << 3 << 4 << 0 << 0 - << QSize(0, 0) << QSize(INT_MAX, INT_MAX) << QSize(1, 1) << QSize(1, 2) << QSize(3, 4) << QSize(0, 0) << qint32(XCB_GRAVITY_NORTH_WEST); + << 128 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 1 << 2 << 3 << 4 << 0 << 0 + << QSize(0, 0) << QSize(INT_MAX, INT_MAX) << QSize(1, 1) << QSize(1, 2) << QSize(3, 4) << QSize(0, 0) << qint32(XCB_GRAVITY_NORTH_WEST); QTest::newRow("aspectDivision0") << QPoint() << QSize() << QSize() << QSize() << QSize() << QSize(1, 0) << QSize(3, 0) << QSize() << 0 - << 128 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 1 << 0 << 3 << 0 << 0 << 0 - << QSize(0, 0) << QSize(INT_MAX, INT_MAX) << QSize(1, 1) << QSize(1, 1) << QSize(3, 1) << QSize(0, 0) << qint32(XCB_GRAVITY_NORTH_WEST); + << 128 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 1 << 0 << 3 << 0 << 0 << 0 + << QSize(0, 0) << QSize(INT_MAX, INT_MAX) << QSize(1, 1) << QSize(1, 1) << QSize(3, 1) << QSize(0, 0) << qint32(XCB_GRAVITY_NORTH_WEST); QTest::newRow("baseSize") << QPoint() << QSize() << QSize() << QSize() << QSize() << QSize() << QSize() << QSize(1, 2) << 0 - << 256 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 1 << 2 - << QSize(1, 2) << QSize(INT_MAX, INT_MAX) << QSize(1, 1) << QSize(1, INT_MAX) << QSize(INT_MAX, 1) << QSize(1, 2) << qint32(XCB_GRAVITY_NORTH_WEST); + << 256 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 1 << 2 + << QSize(1, 2) << QSize(INT_MAX, INT_MAX) << QSize(1, 1) << QSize(1, INT_MAX) << QSize(INT_MAX, 1) << QSize(1, 2) << qint32(XCB_GRAVITY_NORTH_WEST); QTest::newRow("gravity") << QPoint() << QSize() << QSize() << QSize() << QSize() << QSize() << QSize() << QSize() << qint32(XCB_GRAVITY_STATIC) - << 512 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 - << QSize(0, 0) << QSize(INT_MAX, INT_MAX) << QSize(1, 1) << QSize(1, INT_MAX) << QSize(INT_MAX, 1) << QSize(0, 0) << qint32(XCB_GRAVITY_STATIC); + << 512 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 << 0 + << QSize(0, 0) << QSize(INT_MAX, INT_MAX) << QSize(1, 1) << QSize(1, INT_MAX) << QSize(INT_MAX, 1) << QSize(0, 0) << qint32(XCB_GRAVITY_STATIC); QTest::newRow("all") << QPoint(1, 2) << QSize(3, 4) << QSize(5, 6) << QSize(7, 8) << QSize(9, 10) << QSize(11, 12) << QSize(13, 14) << QSize(15, 16) << 1 - << 1011 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 - << QSize(5, 6) << QSize(7, 8) << QSize(9, 10) << QSize(11, 12) << QSize(13, 14) << QSize(15, 16) << qint32(XCB_GRAVITY_NORTH_WEST); + << 1011 << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10 << 11 << 12 << 13 << 14 << 15 << 16 + << QSize(5, 6) << QSize(7, 8) << QSize(9, 10) << QSize(11, 12) << QSize(13, 14) << QSize(15, 16) << qint32(XCB_GRAVITY_NORTH_WEST); } void TestXcbSizeHints::testSizeHints() diff --git a/autotests/test_xcb_window.cpp b/autotests/test_xcb_window.cpp index 4bfa98a8ee..849aa43445 100644 --- a/autotests/test_xcb_window.cpp +++ b/autotests/test_xcb_window.cpp @@ -40,7 +40,7 @@ private Q_SLOTS: void TestXcbWindow::initTestCase() { qApp->setProperty("x11RootWindow", QVariant::fromValue(QX11Info::appRootWindow())); - qApp->setProperty("x11Connection", QVariant::fromValue(QX11Info::connection())); + qApp->setProperty("x11Connection", QVariant::fromValue(QX11Info::connection())); } void TestXcbWindow::defaultCtor() diff --git a/autotests/test_xcb_wrapper.cpp b/autotests/test_xcb_wrapper.cpp index 30f2468cc8..e6440a93fe 100644 --- a/autotests/test_xcb_wrapper.cpp +++ b/autotests/test_xcb_wrapper.cpp @@ -49,6 +49,7 @@ private Q_SLOTS: void testMotifEmpty(); void testMotif_data(); void testMotif(); + private: void testEmpty(WindowGeometry &geometry); void testGeometry(WindowGeometry &geometry, const QRect &rect); @@ -58,12 +59,12 @@ private: void TestXcbWrapper::initTestCase() { qApp->setProperty("x11RootWindow", QVariant::fromValue(QX11Info::appRootWindow())); - qApp->setProperty("x11Connection", QVariant::fromValue(QX11Info::connection())); + qApp->setProperty("x11Connection", QVariant::fromValue(QX11Info::connection())); } void TestXcbWrapper::init() { - const uint32_t values[] = { true }; + const uint32_t values[] = {true}; m_testWindow.create(QRect(0, 0, 10, 10), XCB_WINDOW_CLASS_INPUT_ONLY, XCB_CW_OVERRIDE_REDIRECT, values); QVERIFY(m_testWindow.isValid()); } @@ -160,14 +161,14 @@ void TestXcbWrapper::assignementEmpty() testEmpty(other); QVERIFY(!other.isRetrieved()); -QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wself-assign-overloaded") + QT_WARNING_PUSH + QT_WARNING_DISABLE_CLANG("-Wself-assign-overloaded") // test assignment to self geometry = geometry; other = other; testEmpty(geometry); testEmpty(other); -QT_WARNING_POP + QT_WARNING_POP } void TestXcbWrapper::assignmentBeforeRetrieve() @@ -186,13 +187,13 @@ void TestXcbWrapper::assignmentBeforeRetrieve() other = WindowGeometry(); testEmpty(geometry); -QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wself-assign-overloaded") + QT_WARNING_PUSH + QT_WARNING_DISABLE_CLANG("-Wself-assign-overloaded") // test assignment to self geometry = geometry; other = other; testEmpty(geometry); -QT_WARNING_POP + QT_WARNING_POP } void TestXcbWrapper::assignmentAfterRetrieve() @@ -206,14 +207,14 @@ void TestXcbWrapper::assignmentAfterRetrieve() QVERIFY(other.isRetrieved()); testGeometry(other, QRect(0, 0, 10, 10)); -QT_WARNING_PUSH -QT_WARNING_DISABLE_CLANG("-Wself-assign-overloaded") + QT_WARNING_PUSH + QT_WARNING_DISABLE_CLANG("-Wself-assign-overloaded") // test assignment to self geometry = geometry; other = other; testEmpty(geometry); testGeometry(other, QRect(0, 0, 10, 10)); -QT_WARNING_POP + QT_WARNING_POP // set to empty again other = WindowGeometry(); @@ -318,9 +319,9 @@ void TestXcbWrapper::testTransientFor() QVERIFY(ok); ok = false; QCOMPARE(realTransient.value(), (xcb_window_t)m_testWindow); - QCOMPARE(realTransient.value(nullptr, &ok)[0], (xcb_window_t)m_testWindow); + QCOMPARE(realTransient.value(nullptr, &ok)[0], (xcb_window_t)m_testWindow); QVERIFY(ok); - QCOMPARE(realTransient.value()[0], (xcb_window_t)m_testWindow); + QCOMPARE(realTransient.value()[0], (xcb_window_t)m_testWindow); // test for a not existing window TransientFor doesntExist(XCB_WINDOW_NONE); @@ -336,8 +337,8 @@ void TestXcbWrapper::testPropertyByteArray() QCOMPARE(prop.toByteArray(&ok), QByteArray()); QVERIFY(!ok); ok = true; - QVERIFY(!prop.value()); - QCOMPARE(prop.value("bar", &ok), "bar"); + QVERIFY(!prop.value()); + QCOMPARE(prop.value("bar", &ok), "bar"); QVERIFY(!ok); QCOMPARE(QByteArray(StringProperty(testWindow, XCB_ATOM_WM_NAME)), QByteArray()); @@ -346,7 +347,7 @@ void TestXcbWrapper::testPropertyByteArray() QCOMPARE(prop.toByteArray(), QByteArrayLiteral("foo")); QCOMPARE(prop.toByteArray(&ok), QByteArrayLiteral("foo")); QVERIFY(ok); - QCOMPARE(prop.value(nullptr, &ok), "foo"); + QCOMPARE(prop.value(nullptr, &ok), "foo"); QVERIFY(ok); QCOMPARE(QByteArray(StringProperty(testWindow, XCB_ATOM_WM_NAME)), QByteArrayLiteral("foo")); @@ -359,13 +360,13 @@ void TestXcbWrapper::testPropertyByteArray() prop = Property(false, testWindow, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 0, 100000); QCOMPARE(prop.toByteArray(), QByteArray()); QCOMPARE(prop.toByteArray(&ok), QByteArray()); - //valid bytearray + // valid bytearray QVERIFY(ok); - //The bytearray should be empty + // The bytearray should be empty QVERIFY(prop.toByteArray().isEmpty()); - //The bytearray should be not null + // The bytearray should be not null QVERIFY(!prop.toByteArray().isNull()); - QVERIFY(!prop.value()); + QVERIFY(!prop.value()); QCOMPARE(QByteArray(StringProperty(testWindow, XCB_ATOM_WM_NAME)), QByteArray()); // verify non existing property @@ -373,13 +374,13 @@ void TestXcbWrapper::testPropertyByteArray() prop = Property(false, testWindow, invalid, XCB_ATOM_STRING, 0, 100000); QCOMPARE(prop.toByteArray(), QByteArray()); QCOMPARE(prop.toByteArray(&ok), QByteArray()); - //invalid bytearray + // invalid bytearray QVERIFY(!ok); - //The bytearray should be empty + // The bytearray should be empty QVERIFY(prop.toByteArray().isEmpty()); - //The bytearray should be not null + // The bytearray should be not null QVERIFY(prop.toByteArray().isNull()); - QVERIFY(!prop.value()); + QVERIFY(!prop.value()); QCOMPARE(QByteArray(StringProperty(testWindow, XCB_ATOM_WM_NAME)), QByteArray()); } @@ -432,7 +433,7 @@ void TestXcbWrapper::testAtom() QVERIFY(atom2 == XCB_ATOM_WM_CLIENT_MACHINE); QCOMPARE(atom2.name(), QByteArrayLiteral("WM_CLIENT_MACHINE")); - //destroy before retrieved + // destroy before retrieved Atom atom3(QByteArrayLiteral("WM_CLIENT_MACHINE")); QCOMPARE(atom3.name(), QByteArrayLiteral("WM_CLIENT_MACHINE")); } @@ -483,20 +484,20 @@ void TestXcbWrapper::testMotif_data() QTest::addColumn("expectedMaximize"); QTest::addColumn("expectedClose"); - QTest::newRow("none") << 0u << 0u << 0u << false << false << true << true << true << true << true; - QTest::newRow("noborder") << 2u << 5u << 0u << true << true << true << true << true << true << true; - QTest::newRow("border") << 2u << 5u << 1u << true << false << true << true << true << true << true; - QTest::newRow("resize") << 1u << 2u << 1u << false << false << true << false << false << false << false; - QTest::newRow("move") << 1u << 4u << 1u << false << false << false << true << false << false << false; - QTest::newRow("minimize") << 1u << 8u << 1u << false << false << false << false << true << false << false; - QTest::newRow("maximize") << 1u << 16u << 1u << false << false << false << false << false << true << false; - QTest::newRow("close") << 1u << 32u << 1u << false << false << false << false << false << false << true; + QTest::newRow("none") << 0u << 0u << 0u << false << false << true << true << true << true << true; + QTest::newRow("noborder") << 2u << 5u << 0u << true << true << true << true << true << true << true; + QTest::newRow("border") << 2u << 5u << 1u << true << false << true << true << true << true << true; + QTest::newRow("resize") << 1u << 2u << 1u << false << false << true << false << false << false << false; + QTest::newRow("move") << 1u << 4u << 1u << false << false << false << true << false << false << false; + QTest::newRow("minimize") << 1u << 8u << 1u << false << false << false << false << true << false << false; + QTest::newRow("maximize") << 1u << 16u << 1u << false << false << false << false << false << true << false; + QTest::newRow("close") << 1u << 32u << 1u << false << false << false << false << false << false << true; - QTest::newRow("resize/all") << 1u << 3u << 1u << false << false << false << true << true << true << true; - QTest::newRow("move/all") << 1u << 5u << 1u << false << false << true << false << true << true << true; - QTest::newRow("minimize/all") << 1u << 9u << 1u << false << false << true << true << false << true << true; - QTest::newRow("maximize/all") << 1u << 17u << 1u << false << false << true << true << true << false << true; - QTest::newRow("close/all") << 1u << 33u << 1u << false << false << true << true << true << true << false; + QTest::newRow("resize/all") << 1u << 3u << 1u << false << false << false << true << true << true << true; + QTest::newRow("move/all") << 1u << 5u << 1u << false << false << true << false << true << true << true; + QTest::newRow("minimize/all") << 1u << 9u << 1u << false << false << true << true << false << true << true; + QTest::newRow("maximize/all") << 1u << 17u << 1u << false << false << true << true << true << false << true; + QTest::newRow("close/all") << 1u << 33u << 1u << false << false << true << true << true << true << false; QTest::newRow("all") << 1u << 62u << 1u << false << false << true << true << true << true << true; QTest::newRow("all/all") << 1u << 63u << 1u << false << false << false << false << false << false << false; @@ -514,8 +515,7 @@ void TestXcbWrapper::testMotif() functions, decorations, 0, - 0 - }; + 0}; xcb_change_property(QX11Info::connection(), XCB_PROP_MODE_REPLACE, m_testWindow, atom, atom, 32, 5, data); xcb_flush(QX11Info::connection()); MotifHints hints(atom); diff --git a/autotests/test_xkb.cpp b/autotests/test_xkb.cpp index c25ef1971e..043788b655 100644 --- a/autotests/test_xkb.cpp +++ b/autotests/test_xkb.cpp @@ -23,443 +23,443 @@ private Q_SLOTS: // from kwindowsystem/src/platforms/xcb/kkeyserver.cpp // adjusted to xkb -struct TransKey { +struct TransKey +{ Qt::Key keySymQt; xkb_keysym_t keySymX; Qt::KeyboardModifiers modifiers; }; static const TransKey g_rgQtToSymX[] = { - { Qt::Key_Escape, XKB_KEY_Escape, Qt::KeyboardModifiers() }, - { Qt::Key_Tab, XKB_KEY_Tab, Qt::KeyboardModifiers() }, - { Qt::Key_Backtab, XKB_KEY_ISO_Left_Tab, Qt::KeyboardModifiers() }, - { Qt::Key_Backspace, XKB_KEY_BackSpace, Qt::KeyboardModifiers() }, - { Qt::Key_Return, XKB_KEY_Return, Qt::KeyboardModifiers() }, - { Qt::Key_Insert, XKB_KEY_Insert, Qt::KeyboardModifiers() }, - { Qt::Key_Delete, XKB_KEY_Delete, Qt::KeyboardModifiers() }, - { Qt::Key_Pause, XKB_KEY_Pause, Qt::KeyboardModifiers() }, - { Qt::Key_Print, XKB_KEY_Print, Qt::KeyboardModifiers() }, - { Qt::Key_SysReq, XKB_KEY_Sys_Req, Qt::KeyboardModifiers() }, - { Qt::Key_Home, XKB_KEY_Home, Qt::KeyboardModifiers() }, - { Qt::Key_End, XKB_KEY_End, Qt::KeyboardModifiers() }, - { Qt::Key_Left, XKB_KEY_Left, Qt::KeyboardModifiers() }, - { Qt::Key_Up, XKB_KEY_Up, Qt::KeyboardModifiers() }, - { Qt::Key_Right, XKB_KEY_Right, Qt::KeyboardModifiers() }, - { Qt::Key_Down, XKB_KEY_Down, Qt::KeyboardModifiers() }, - { Qt::Key_PageUp, XKB_KEY_Prior, Qt::KeyboardModifiers() }, - { Qt::Key_PageDown, XKB_KEY_Next, Qt::KeyboardModifiers() }, - { Qt::Key_CapsLock, XKB_KEY_Caps_Lock, Qt::KeyboardModifiers() }, - { Qt::Key_NumLock, XKB_KEY_Num_Lock, Qt::KeyboardModifiers() }, - { Qt::Key_ScrollLock, XKB_KEY_Scroll_Lock, Qt::KeyboardModifiers() }, - { Qt::Key_F1, XKB_KEY_F1, Qt::KeyboardModifiers() }, - { Qt::Key_F2, XKB_KEY_F2, Qt::KeyboardModifiers() }, - { Qt::Key_F3, XKB_KEY_F3, Qt::KeyboardModifiers() }, - { Qt::Key_F4, XKB_KEY_F4, Qt::KeyboardModifiers() }, - { Qt::Key_F5, XKB_KEY_F5, Qt::KeyboardModifiers() }, - { Qt::Key_F6, XKB_KEY_F6, Qt::KeyboardModifiers() }, - { Qt::Key_F7, XKB_KEY_F7, Qt::KeyboardModifiers() }, - { Qt::Key_F8, XKB_KEY_F8, Qt::KeyboardModifiers() }, - { Qt::Key_F9, XKB_KEY_F9, Qt::KeyboardModifiers() }, - { Qt::Key_F10, XKB_KEY_F10, Qt::KeyboardModifiers() }, - { Qt::Key_F11, XKB_KEY_F11, Qt::KeyboardModifiers() }, - { Qt::Key_F12, XKB_KEY_F12, Qt::KeyboardModifiers() }, - { Qt::Key_F13, XKB_KEY_F13, Qt::KeyboardModifiers() }, - { Qt::Key_F14, XKB_KEY_F14, Qt::KeyboardModifiers() }, - { Qt::Key_F15, XKB_KEY_F15, Qt::KeyboardModifiers() }, - { Qt::Key_F16, XKB_KEY_F16, Qt::KeyboardModifiers() }, - { Qt::Key_F17, XKB_KEY_F17, Qt::KeyboardModifiers() }, - { Qt::Key_F18, XKB_KEY_F18, Qt::KeyboardModifiers() }, - { Qt::Key_F19, XKB_KEY_F19, Qt::KeyboardModifiers() }, - { Qt::Key_F20, XKB_KEY_F20, Qt::KeyboardModifiers() }, - { Qt::Key_F21, XKB_KEY_F21, Qt::KeyboardModifiers() }, - { Qt::Key_F22, XKB_KEY_F22, Qt::KeyboardModifiers() }, - { Qt::Key_F23, XKB_KEY_F23, Qt::KeyboardModifiers() }, - { Qt::Key_F24, XKB_KEY_F24, Qt::KeyboardModifiers() }, - { Qt::Key_F25, XKB_KEY_F25, Qt::KeyboardModifiers() }, - { Qt::Key_F26, XKB_KEY_F26, Qt::KeyboardModifiers() }, - { Qt::Key_F27, XKB_KEY_F27, Qt::KeyboardModifiers() }, - { Qt::Key_F28, XKB_KEY_F28, Qt::KeyboardModifiers() }, - { Qt::Key_F29, XKB_KEY_F29, Qt::KeyboardModifiers() }, - { Qt::Key_F30, XKB_KEY_F30, Qt::KeyboardModifiers() }, - { Qt::Key_F31, XKB_KEY_F31, Qt::KeyboardModifiers() }, - { Qt::Key_F32, XKB_KEY_F32, Qt::KeyboardModifiers() }, - { Qt::Key_F33, XKB_KEY_F33, Qt::KeyboardModifiers() }, - { Qt::Key_F34, XKB_KEY_F34, Qt::KeyboardModifiers() }, - { Qt::Key_F35, XKB_KEY_F35, Qt::KeyboardModifiers() }, - { Qt::Key_Super_L, XKB_KEY_Super_L, Qt::KeyboardModifiers() }, - { Qt::Key_Super_R, XKB_KEY_Super_R, Qt::KeyboardModifiers() }, - { Qt::Key_Menu, XKB_KEY_Menu, Qt::KeyboardModifiers() }, - { Qt::Key_Hyper_L, XKB_KEY_Hyper_L, Qt::KeyboardModifiers() }, - { Qt::Key_Hyper_R, XKB_KEY_Hyper_R, Qt::KeyboardModifiers() }, - { Qt::Key_Help, XKB_KEY_Help, Qt::KeyboardModifiers() }, - { Qt::Key_Space, XKB_KEY_KP_Space, Qt::KeypadModifier }, - { Qt::Key_Tab, XKB_KEY_KP_Tab, Qt::KeypadModifier }, - { Qt::Key_Enter, XKB_KEY_KP_Enter, Qt::KeypadModifier }, - { Qt::Key_Home, XKB_KEY_KP_Home, Qt::KeypadModifier }, - { Qt::Key_Left, XKB_KEY_KP_Left, Qt::KeypadModifier }, - { Qt::Key_Up, XKB_KEY_KP_Up, Qt::KeypadModifier }, - { Qt::Key_Right, XKB_KEY_KP_Right, Qt::KeypadModifier }, - { Qt::Key_Down, XKB_KEY_KP_Down, Qt::KeypadModifier }, - { Qt::Key_PageUp, XKB_KEY_KP_Prior, Qt::KeypadModifier }, - { Qt::Key_PageDown, XKB_KEY_KP_Next, Qt::KeypadModifier }, - { Qt::Key_End, XKB_KEY_KP_End, Qt::KeypadModifier }, - { Qt::Key_Clear, XKB_KEY_KP_Begin, Qt::KeypadModifier }, - { Qt::Key_Insert, XKB_KEY_KP_Insert, Qt::KeypadModifier }, - { Qt::Key_Delete, XKB_KEY_KP_Delete, Qt::KeypadModifier }, - { Qt::Key_Equal, XKB_KEY_KP_Equal, Qt::KeypadModifier }, - { Qt::Key_Asterisk, XKB_KEY_KP_Multiply, Qt::KeypadModifier }, - { Qt::Key_Plus, XKB_KEY_KP_Add, Qt::KeypadModifier }, - { Qt::Key_Comma, XKB_KEY_KP_Separator, Qt::KeypadModifier }, - { Qt::Key_Minus, XKB_KEY_KP_Subtract, Qt::KeypadModifier }, - { Qt::Key_Period, XKB_KEY_KP_Decimal, Qt::KeypadModifier }, - { Qt::Key_Slash, XKB_KEY_KP_Divide, Qt::KeypadModifier }, - { Qt::Key_Back, XKB_KEY_XF86Back, Qt::KeyboardModifiers() }, - { Qt::Key_Forward, XKB_KEY_XF86Forward, Qt::KeyboardModifiers() }, - { Qt::Key_Stop, XKB_KEY_XF86Stop, Qt::KeyboardModifiers() }, - { Qt::Key_Refresh, XKB_KEY_XF86Refresh, Qt::KeyboardModifiers() }, - { Qt::Key_Favorites, XKB_KEY_XF86Favorites, Qt::KeyboardModifiers() }, - { Qt::Key_LaunchMedia, XKB_KEY_XF86AudioMedia, Qt::KeyboardModifiers() }, - { Qt::Key_OpenUrl, XKB_KEY_XF86OpenURL, Qt::KeyboardModifiers() }, - { Qt::Key_HomePage, XKB_KEY_XF86HomePage, Qt::KeyboardModifiers() }, - { Qt::Key_Search, XKB_KEY_XF86Search, Qt::KeyboardModifiers() }, - { Qt::Key_VolumeDown, XKB_KEY_XF86AudioLowerVolume, Qt::KeyboardModifiers() }, - { Qt::Key_VolumeMute, XKB_KEY_XF86AudioMute, Qt::KeyboardModifiers() }, - { Qt::Key_VolumeUp, XKB_KEY_XF86AudioRaiseVolume, Qt::KeyboardModifiers() }, - { Qt::Key_MediaPlay, XKB_KEY_XF86AudioPlay, Qt::KeyboardModifiers() }, - { Qt::Key_MediaPause, XKB_KEY_XF86AudioPause, Qt::KeyboardModifiers() }, - { Qt::Key_MediaStop, XKB_KEY_XF86AudioStop, Qt::KeyboardModifiers() }, - { Qt::Key_MediaPrevious, XKB_KEY_XF86AudioPrev, Qt::KeyboardModifiers() }, - { Qt::Key_MediaNext, XKB_KEY_XF86AudioNext, Qt::KeyboardModifiers() }, - { Qt::Key_MediaRecord, XKB_KEY_XF86AudioRecord, Qt::KeyboardModifiers() }, - { Qt::Key_LaunchMail, XKB_KEY_XF86Mail, Qt::KeyboardModifiers() }, - { Qt::Key_Launch0, XKB_KEY_XF86MyComputer, Qt::KeyboardModifiers() }, - { Qt::Key_Launch1, XKB_KEY_XF86Calculator, Qt::KeyboardModifiers() }, - { Qt::Key_Memo, XKB_KEY_XF86Memo, Qt::KeyboardModifiers() }, - { Qt::Key_ToDoList, XKB_KEY_XF86ToDoList, Qt::KeyboardModifiers() }, - { Qt::Key_Calendar, XKB_KEY_XF86Calendar, Qt::KeyboardModifiers() }, - { Qt::Key_PowerDown, XKB_KEY_XF86PowerDown, Qt::KeyboardModifiers() }, - { Qt::Key_ContrastAdjust, XKB_KEY_XF86ContrastAdjust, Qt::KeyboardModifiers() }, - { Qt::Key_Standby, XKB_KEY_XF86Standby, Qt::KeyboardModifiers() }, - { Qt::Key_MonBrightnessUp, XKB_KEY_XF86MonBrightnessUp, Qt::KeyboardModifiers() }, - { Qt::Key_MonBrightnessDown, XKB_KEY_XF86MonBrightnessDown, Qt::KeyboardModifiers() }, - { Qt::Key_KeyboardLightOnOff, XKB_KEY_XF86KbdLightOnOff, Qt::KeyboardModifiers() }, - { Qt::Key_KeyboardBrightnessUp, XKB_KEY_XF86KbdBrightnessUp, Qt::KeyboardModifiers() }, - { Qt::Key_KeyboardBrightnessDown, XKB_KEY_XF86KbdBrightnessDown, Qt::KeyboardModifiers() }, - { Qt::Key_PowerOff, XKB_KEY_XF86PowerOff, Qt::KeyboardModifiers() }, - { Qt::Key_WakeUp, XKB_KEY_XF86WakeUp, Qt::KeyboardModifiers() }, - { Qt::Key_Eject, XKB_KEY_XF86Eject, Qt::KeyboardModifiers() }, - { Qt::Key_ScreenSaver, XKB_KEY_XF86ScreenSaver, Qt::KeyboardModifiers() }, - { Qt::Key_WWW, XKB_KEY_XF86WWW, Qt::KeyboardModifiers() }, - { Qt::Key_Sleep, XKB_KEY_XF86Sleep, Qt::KeyboardModifiers() }, - { Qt::Key_LightBulb, XKB_KEY_XF86LightBulb, Qt::KeyboardModifiers() }, - { Qt::Key_Shop, XKB_KEY_XF86Shop, Qt::KeyboardModifiers() }, - { Qt::Key_History, XKB_KEY_XF86History, Qt::KeyboardModifiers() }, - { Qt::Key_AddFavorite, XKB_KEY_XF86AddFavorite, Qt::KeyboardModifiers() }, - { Qt::Key_HotLinks, XKB_KEY_XF86HotLinks, Qt::KeyboardModifiers() }, - { Qt::Key_BrightnessAdjust, XKB_KEY_XF86BrightnessAdjust, Qt::KeyboardModifiers() }, - { Qt::Key_Finance, XKB_KEY_XF86Finance, Qt::KeyboardModifiers() }, - { Qt::Key_Community, XKB_KEY_XF86Community, Qt::KeyboardModifiers() }, - { Qt::Key_AudioRewind, XKB_KEY_XF86AudioRewind, Qt::KeyboardModifiers() }, - { Qt::Key_BackForward, XKB_KEY_XF86BackForward, Qt::KeyboardModifiers() }, - { Qt::Key_ApplicationLeft, XKB_KEY_XF86ApplicationLeft, Qt::KeyboardModifiers() }, - { Qt::Key_ApplicationRight, XKB_KEY_XF86ApplicationRight, Qt::KeyboardModifiers() }, - { Qt::Key_Book, XKB_KEY_XF86Book, Qt::KeyboardModifiers() }, - { Qt::Key_CD, XKB_KEY_XF86CD, Qt::KeyboardModifiers() }, - { Qt::Key_Calculator, XKB_KEY_XF86Calculater, Qt::KeyboardModifiers() }, - { Qt::Key_Clear, XKB_KEY_XF86Clear, Qt::KeyboardModifiers() }, - { Qt::Key_ClearGrab, XKB_KEY_XF86ClearGrab, Qt::KeyboardModifiers() }, - { Qt::Key_Close, XKB_KEY_XF86Close, Qt::KeyboardModifiers() }, - { Qt::Key_Copy, XKB_KEY_XF86Copy, Qt::KeyboardModifiers() }, - { Qt::Key_Cut, XKB_KEY_XF86Cut, Qt::KeyboardModifiers() }, - { Qt::Key_Display, XKB_KEY_XF86Display, Qt::KeyboardModifiers() }, - { Qt::Key_DOS, XKB_KEY_XF86DOS, Qt::KeyboardModifiers() }, - { Qt::Key_Documents, XKB_KEY_XF86Documents, Qt::KeyboardModifiers() }, - { Qt::Key_Excel, XKB_KEY_XF86Excel, Qt::KeyboardModifiers() }, - { Qt::Key_Explorer, XKB_KEY_XF86Explorer, Qt::KeyboardModifiers() }, - { Qt::Key_Game, XKB_KEY_XF86Game, Qt::KeyboardModifiers() }, - { Qt::Key_Go, XKB_KEY_XF86Go, Qt::KeyboardModifiers() }, - { Qt::Key_iTouch, XKB_KEY_XF86iTouch, Qt::KeyboardModifiers() }, - { Qt::Key_LogOff, XKB_KEY_XF86LogOff, Qt::KeyboardModifiers() }, - { Qt::Key_Market, XKB_KEY_XF86Market, Qt::KeyboardModifiers() }, - { Qt::Key_Meeting, XKB_KEY_XF86Meeting, Qt::KeyboardModifiers() }, - { Qt::Key_MenuKB, XKB_KEY_XF86MenuKB, Qt::KeyboardModifiers() }, - { Qt::Key_MenuPB, XKB_KEY_XF86MenuPB, Qt::KeyboardModifiers() }, - { Qt::Key_MySites, XKB_KEY_XF86MySites, Qt::KeyboardModifiers() }, - { Qt::Key_News, XKB_KEY_XF86News, Qt::KeyboardModifiers() }, - { Qt::Key_OfficeHome, XKB_KEY_XF86OfficeHome, Qt::KeyboardModifiers() }, - { Qt::Key_Option, XKB_KEY_XF86Option, Qt::KeyboardModifiers() }, - { Qt::Key_Paste, XKB_KEY_XF86Paste, Qt::KeyboardModifiers() }, - { Qt::Key_Phone, XKB_KEY_XF86Phone, Qt::KeyboardModifiers() }, - { Qt::Key_Reply, XKB_KEY_XF86Reply, Qt::KeyboardModifiers() }, - { Qt::Key_Reload, XKB_KEY_XF86Reload, Qt::KeyboardModifiers() }, - { Qt::Key_RotateWindows, XKB_KEY_XF86RotateWindows, Qt::KeyboardModifiers() }, - { Qt::Key_RotationPB, XKB_KEY_XF86RotationPB, Qt::KeyboardModifiers() }, - { Qt::Key_RotationKB, XKB_KEY_XF86RotationKB, Qt::KeyboardModifiers() }, - { Qt::Key_Save, XKB_KEY_XF86Save, Qt::KeyboardModifiers() }, - { Qt::Key_Send, XKB_KEY_XF86Send, Qt::KeyboardModifiers() }, - { Qt::Key_Spell, XKB_KEY_XF86Spell, Qt::KeyboardModifiers() }, - { Qt::Key_SplitScreen, XKB_KEY_XF86SplitScreen, Qt::KeyboardModifiers() }, - { Qt::Key_Support, XKB_KEY_XF86Support, Qt::KeyboardModifiers() }, - { Qt::Key_TaskPane, XKB_KEY_XF86TaskPane, Qt::KeyboardModifiers() }, - { Qt::Key_Terminal, XKB_KEY_XF86Terminal, Qt::KeyboardModifiers() }, - { Qt::Key_Tools, XKB_KEY_XF86Tools, Qt::KeyboardModifiers() }, - { Qt::Key_Travel, XKB_KEY_XF86Travel, Qt::KeyboardModifiers() }, - { Qt::Key_Video, XKB_KEY_XF86Video, Qt::KeyboardModifiers() }, - { Qt::Key_Word, XKB_KEY_XF86Word, Qt::KeyboardModifiers() }, - { Qt::Key_Xfer, XKB_KEY_XF86Xfer, Qt::KeyboardModifiers() }, - { Qt::Key_ZoomIn, XKB_KEY_XF86ZoomIn, Qt::KeyboardModifiers() }, - { Qt::Key_ZoomOut, XKB_KEY_XF86ZoomOut, Qt::KeyboardModifiers() }, - { Qt::Key_Away, XKB_KEY_XF86Away, Qt::KeyboardModifiers() }, - { Qt::Key_Messenger, XKB_KEY_XF86Messenger, Qt::KeyboardModifiers() }, - { Qt::Key_WebCam, XKB_KEY_XF86WebCam, Qt::KeyboardModifiers() }, - { Qt::Key_MailForward, XKB_KEY_XF86MailForward, Qt::KeyboardModifiers() }, - { Qt::Key_Pictures, XKB_KEY_XF86Pictures, Qt::KeyboardModifiers() }, - { Qt::Key_Music, XKB_KEY_XF86Music, Qt::KeyboardModifiers() }, - { Qt::Key_Battery, XKB_KEY_XF86Battery, Qt::KeyboardModifiers() }, - { Qt::Key_Bluetooth, XKB_KEY_XF86Bluetooth, Qt::KeyboardModifiers() }, - { Qt::Key_WLAN, XKB_KEY_XF86WLAN, Qt::KeyboardModifiers() }, - { Qt::Key_UWB, XKB_KEY_XF86UWB, Qt::KeyboardModifiers() }, - { Qt::Key_AudioForward, XKB_KEY_XF86AudioForward, Qt::KeyboardModifiers() }, - { Qt::Key_AudioRepeat, XKB_KEY_XF86AudioRepeat, Qt::KeyboardModifiers() }, - { Qt::Key_AudioRandomPlay, XKB_KEY_XF86AudioRandomPlay, Qt::KeyboardModifiers() }, - { Qt::Key_Subtitle, XKB_KEY_XF86Subtitle, Qt::KeyboardModifiers() }, - { Qt::Key_AudioCycleTrack, XKB_KEY_XF86AudioCycleTrack, Qt::KeyboardModifiers() }, - { Qt::Key_Time, XKB_KEY_XF86Time, Qt::KeyboardModifiers() }, - { Qt::Key_Select, XKB_KEY_XF86Select, Qt::KeyboardModifiers() }, - { Qt::Key_View, XKB_KEY_XF86View, Qt::KeyboardModifiers() }, - { Qt::Key_TopMenu, XKB_KEY_XF86TopMenu, Qt::KeyboardModifiers() }, - { Qt::Key_Bluetooth, XKB_KEY_XF86Bluetooth, Qt::KeyboardModifiers() }, - { Qt::Key_Suspend, XKB_KEY_XF86Suspend, Qt::KeyboardModifiers() }, - { Qt::Key_Hibernate, XKB_KEY_XF86Hibernate, Qt::KeyboardModifiers() }, - { Qt::Key_TouchpadToggle, XKB_KEY_XF86TouchpadToggle, Qt::KeyboardModifiers() }, - { Qt::Key_TouchpadOn, XKB_KEY_XF86TouchpadOn, Qt::KeyboardModifiers() }, - { Qt::Key_TouchpadOff, XKB_KEY_XF86TouchpadOff, Qt::KeyboardModifiers() }, - { Qt::Key_MicMute, XKB_KEY_XF86AudioMicMute, Qt::KeyboardModifiers() }, - { Qt::Key_Launch2, XKB_KEY_XF86Launch0, Qt::KeyboardModifiers() }, - { Qt::Key_Launch3, XKB_KEY_XF86Launch1, Qt::KeyboardModifiers() }, - { Qt::Key_Launch4, XKB_KEY_XF86Launch2, Qt::KeyboardModifiers() }, - { Qt::Key_Launch5, XKB_KEY_XF86Launch3, Qt::KeyboardModifiers() }, - { Qt::Key_Launch6, XKB_KEY_XF86Launch4, Qt::KeyboardModifiers() }, - { Qt::Key_Launch7, XKB_KEY_XF86Launch5, Qt::KeyboardModifiers() }, - { Qt::Key_Launch8, XKB_KEY_XF86Launch6, Qt::KeyboardModifiers() }, - { Qt::Key_Launch9, XKB_KEY_XF86Launch7, Qt::KeyboardModifiers() }, - { Qt::Key_LaunchA, XKB_KEY_XF86Launch8, Qt::KeyboardModifiers() }, - { Qt::Key_LaunchB, XKB_KEY_XF86Launch9, Qt::KeyboardModifiers() }, - { Qt::Key_LaunchC, XKB_KEY_XF86LaunchA, Qt::KeyboardModifiers() }, - { Qt::Key_LaunchD, XKB_KEY_XF86LaunchB, Qt::KeyboardModifiers() }, - { Qt::Key_LaunchE, XKB_KEY_XF86LaunchC, Qt::KeyboardModifiers() }, - { Qt::Key_LaunchF, XKB_KEY_XF86LaunchD, Qt::KeyboardModifiers() }, + {Qt::Key_Escape, XKB_KEY_Escape, Qt::KeyboardModifiers()}, + {Qt::Key_Tab, XKB_KEY_Tab, Qt::KeyboardModifiers()}, + {Qt::Key_Backtab, XKB_KEY_ISO_Left_Tab, Qt::KeyboardModifiers()}, + {Qt::Key_Backspace, XKB_KEY_BackSpace, Qt::KeyboardModifiers()}, + {Qt::Key_Return, XKB_KEY_Return, Qt::KeyboardModifiers()}, + {Qt::Key_Insert, XKB_KEY_Insert, Qt::KeyboardModifiers()}, + {Qt::Key_Delete, XKB_KEY_Delete, Qt::KeyboardModifiers()}, + {Qt::Key_Pause, XKB_KEY_Pause, Qt::KeyboardModifiers()}, + {Qt::Key_Print, XKB_KEY_Print, Qt::KeyboardModifiers()}, + {Qt::Key_SysReq, XKB_KEY_Sys_Req, Qt::KeyboardModifiers()}, + {Qt::Key_Home, XKB_KEY_Home, Qt::KeyboardModifiers()}, + {Qt::Key_End, XKB_KEY_End, Qt::KeyboardModifiers()}, + {Qt::Key_Left, XKB_KEY_Left, Qt::KeyboardModifiers()}, + {Qt::Key_Up, XKB_KEY_Up, Qt::KeyboardModifiers()}, + {Qt::Key_Right, XKB_KEY_Right, Qt::KeyboardModifiers()}, + {Qt::Key_Down, XKB_KEY_Down, Qt::KeyboardModifiers()}, + {Qt::Key_PageUp, XKB_KEY_Prior, Qt::KeyboardModifiers()}, + {Qt::Key_PageDown, XKB_KEY_Next, Qt::KeyboardModifiers()}, + {Qt::Key_CapsLock, XKB_KEY_Caps_Lock, Qt::KeyboardModifiers()}, + {Qt::Key_NumLock, XKB_KEY_Num_Lock, Qt::KeyboardModifiers()}, + {Qt::Key_ScrollLock, XKB_KEY_Scroll_Lock, Qt::KeyboardModifiers()}, + {Qt::Key_F1, XKB_KEY_F1, Qt::KeyboardModifiers()}, + {Qt::Key_F2, XKB_KEY_F2, Qt::KeyboardModifiers()}, + {Qt::Key_F3, XKB_KEY_F3, Qt::KeyboardModifiers()}, + {Qt::Key_F4, XKB_KEY_F4, Qt::KeyboardModifiers()}, + {Qt::Key_F5, XKB_KEY_F5, Qt::KeyboardModifiers()}, + {Qt::Key_F6, XKB_KEY_F6, Qt::KeyboardModifiers()}, + {Qt::Key_F7, XKB_KEY_F7, Qt::KeyboardModifiers()}, + {Qt::Key_F8, XKB_KEY_F8, Qt::KeyboardModifiers()}, + {Qt::Key_F9, XKB_KEY_F9, Qt::KeyboardModifiers()}, + {Qt::Key_F10, XKB_KEY_F10, Qt::KeyboardModifiers()}, + {Qt::Key_F11, XKB_KEY_F11, Qt::KeyboardModifiers()}, + {Qt::Key_F12, XKB_KEY_F12, Qt::KeyboardModifiers()}, + {Qt::Key_F13, XKB_KEY_F13, Qt::KeyboardModifiers()}, + {Qt::Key_F14, XKB_KEY_F14, Qt::KeyboardModifiers()}, + {Qt::Key_F15, XKB_KEY_F15, Qt::KeyboardModifiers()}, + {Qt::Key_F16, XKB_KEY_F16, Qt::KeyboardModifiers()}, + {Qt::Key_F17, XKB_KEY_F17, Qt::KeyboardModifiers()}, + {Qt::Key_F18, XKB_KEY_F18, Qt::KeyboardModifiers()}, + {Qt::Key_F19, XKB_KEY_F19, Qt::KeyboardModifiers()}, + {Qt::Key_F20, XKB_KEY_F20, Qt::KeyboardModifiers()}, + {Qt::Key_F21, XKB_KEY_F21, Qt::KeyboardModifiers()}, + {Qt::Key_F22, XKB_KEY_F22, Qt::KeyboardModifiers()}, + {Qt::Key_F23, XKB_KEY_F23, Qt::KeyboardModifiers()}, + {Qt::Key_F24, XKB_KEY_F24, Qt::KeyboardModifiers()}, + {Qt::Key_F25, XKB_KEY_F25, Qt::KeyboardModifiers()}, + {Qt::Key_F26, XKB_KEY_F26, Qt::KeyboardModifiers()}, + {Qt::Key_F27, XKB_KEY_F27, Qt::KeyboardModifiers()}, + {Qt::Key_F28, XKB_KEY_F28, Qt::KeyboardModifiers()}, + {Qt::Key_F29, XKB_KEY_F29, Qt::KeyboardModifiers()}, + {Qt::Key_F30, XKB_KEY_F30, Qt::KeyboardModifiers()}, + {Qt::Key_F31, XKB_KEY_F31, Qt::KeyboardModifiers()}, + {Qt::Key_F32, XKB_KEY_F32, Qt::KeyboardModifiers()}, + {Qt::Key_F33, XKB_KEY_F33, Qt::KeyboardModifiers()}, + {Qt::Key_F34, XKB_KEY_F34, Qt::KeyboardModifiers()}, + {Qt::Key_F35, XKB_KEY_F35, Qt::KeyboardModifiers()}, + {Qt::Key_Super_L, XKB_KEY_Super_L, Qt::KeyboardModifiers()}, + {Qt::Key_Super_R, XKB_KEY_Super_R, Qt::KeyboardModifiers()}, + {Qt::Key_Menu, XKB_KEY_Menu, Qt::KeyboardModifiers()}, + {Qt::Key_Hyper_L, XKB_KEY_Hyper_L, Qt::KeyboardModifiers()}, + {Qt::Key_Hyper_R, XKB_KEY_Hyper_R, Qt::KeyboardModifiers()}, + {Qt::Key_Help, XKB_KEY_Help, Qt::KeyboardModifiers()}, + {Qt::Key_Space, XKB_KEY_KP_Space, Qt::KeypadModifier}, + {Qt::Key_Tab, XKB_KEY_KP_Tab, Qt::KeypadModifier}, + {Qt::Key_Enter, XKB_KEY_KP_Enter, Qt::KeypadModifier}, + {Qt::Key_Home, XKB_KEY_KP_Home, Qt::KeypadModifier}, + {Qt::Key_Left, XKB_KEY_KP_Left, Qt::KeypadModifier}, + {Qt::Key_Up, XKB_KEY_KP_Up, Qt::KeypadModifier}, + {Qt::Key_Right, XKB_KEY_KP_Right, Qt::KeypadModifier}, + {Qt::Key_Down, XKB_KEY_KP_Down, Qt::KeypadModifier}, + {Qt::Key_PageUp, XKB_KEY_KP_Prior, Qt::KeypadModifier}, + {Qt::Key_PageDown, XKB_KEY_KP_Next, Qt::KeypadModifier}, + {Qt::Key_End, XKB_KEY_KP_End, Qt::KeypadModifier}, + {Qt::Key_Clear, XKB_KEY_KP_Begin, Qt::KeypadModifier}, + {Qt::Key_Insert, XKB_KEY_KP_Insert, Qt::KeypadModifier}, + {Qt::Key_Delete, XKB_KEY_KP_Delete, Qt::KeypadModifier}, + {Qt::Key_Equal, XKB_KEY_KP_Equal, Qt::KeypadModifier}, + {Qt::Key_Asterisk, XKB_KEY_KP_Multiply, Qt::KeypadModifier}, + {Qt::Key_Plus, XKB_KEY_KP_Add, Qt::KeypadModifier}, + {Qt::Key_Comma, XKB_KEY_KP_Separator, Qt::KeypadModifier}, + {Qt::Key_Minus, XKB_KEY_KP_Subtract, Qt::KeypadModifier}, + {Qt::Key_Period, XKB_KEY_KP_Decimal, Qt::KeypadModifier}, + {Qt::Key_Slash, XKB_KEY_KP_Divide, Qt::KeypadModifier}, + {Qt::Key_Back, XKB_KEY_XF86Back, Qt::KeyboardModifiers()}, + {Qt::Key_Forward, XKB_KEY_XF86Forward, Qt::KeyboardModifiers()}, + {Qt::Key_Stop, XKB_KEY_XF86Stop, Qt::KeyboardModifiers()}, + {Qt::Key_Refresh, XKB_KEY_XF86Refresh, Qt::KeyboardModifiers()}, + {Qt::Key_Favorites, XKB_KEY_XF86Favorites, Qt::KeyboardModifiers()}, + {Qt::Key_LaunchMedia, XKB_KEY_XF86AudioMedia, Qt::KeyboardModifiers()}, + {Qt::Key_OpenUrl, XKB_KEY_XF86OpenURL, Qt::KeyboardModifiers()}, + {Qt::Key_HomePage, XKB_KEY_XF86HomePage, Qt::KeyboardModifiers()}, + {Qt::Key_Search, XKB_KEY_XF86Search, Qt::KeyboardModifiers()}, + {Qt::Key_VolumeDown, XKB_KEY_XF86AudioLowerVolume, Qt::KeyboardModifiers()}, + {Qt::Key_VolumeMute, XKB_KEY_XF86AudioMute, Qt::KeyboardModifiers()}, + {Qt::Key_VolumeUp, XKB_KEY_XF86AudioRaiseVolume, Qt::KeyboardModifiers()}, + {Qt::Key_MediaPlay, XKB_KEY_XF86AudioPlay, Qt::KeyboardModifiers()}, + {Qt::Key_MediaPause, XKB_KEY_XF86AudioPause, Qt::KeyboardModifiers()}, + {Qt::Key_MediaStop, XKB_KEY_XF86AudioStop, Qt::KeyboardModifiers()}, + {Qt::Key_MediaPrevious, XKB_KEY_XF86AudioPrev, Qt::KeyboardModifiers()}, + {Qt::Key_MediaNext, XKB_KEY_XF86AudioNext, Qt::KeyboardModifiers()}, + {Qt::Key_MediaRecord, XKB_KEY_XF86AudioRecord, Qt::KeyboardModifiers()}, + {Qt::Key_LaunchMail, XKB_KEY_XF86Mail, Qt::KeyboardModifiers()}, + {Qt::Key_Launch0, XKB_KEY_XF86MyComputer, Qt::KeyboardModifiers()}, + {Qt::Key_Launch1, XKB_KEY_XF86Calculator, Qt::KeyboardModifiers()}, + {Qt::Key_Memo, XKB_KEY_XF86Memo, Qt::KeyboardModifiers()}, + {Qt::Key_ToDoList, XKB_KEY_XF86ToDoList, Qt::KeyboardModifiers()}, + {Qt::Key_Calendar, XKB_KEY_XF86Calendar, Qt::KeyboardModifiers()}, + {Qt::Key_PowerDown, XKB_KEY_XF86PowerDown, Qt::KeyboardModifiers()}, + {Qt::Key_ContrastAdjust, XKB_KEY_XF86ContrastAdjust, Qt::KeyboardModifiers()}, + {Qt::Key_Standby, XKB_KEY_XF86Standby, Qt::KeyboardModifiers()}, + {Qt::Key_MonBrightnessUp, XKB_KEY_XF86MonBrightnessUp, Qt::KeyboardModifiers()}, + {Qt::Key_MonBrightnessDown, XKB_KEY_XF86MonBrightnessDown, Qt::KeyboardModifiers()}, + {Qt::Key_KeyboardLightOnOff, XKB_KEY_XF86KbdLightOnOff, Qt::KeyboardModifiers()}, + {Qt::Key_KeyboardBrightnessUp, XKB_KEY_XF86KbdBrightnessUp, Qt::KeyboardModifiers()}, + {Qt::Key_KeyboardBrightnessDown, XKB_KEY_XF86KbdBrightnessDown, Qt::KeyboardModifiers()}, + {Qt::Key_PowerOff, XKB_KEY_XF86PowerOff, Qt::KeyboardModifiers()}, + {Qt::Key_WakeUp, XKB_KEY_XF86WakeUp, Qt::KeyboardModifiers()}, + {Qt::Key_Eject, XKB_KEY_XF86Eject, Qt::KeyboardModifiers()}, + {Qt::Key_ScreenSaver, XKB_KEY_XF86ScreenSaver, Qt::KeyboardModifiers()}, + {Qt::Key_WWW, XKB_KEY_XF86WWW, Qt::KeyboardModifiers()}, + {Qt::Key_Sleep, XKB_KEY_XF86Sleep, Qt::KeyboardModifiers()}, + {Qt::Key_LightBulb, XKB_KEY_XF86LightBulb, Qt::KeyboardModifiers()}, + {Qt::Key_Shop, XKB_KEY_XF86Shop, Qt::KeyboardModifiers()}, + {Qt::Key_History, XKB_KEY_XF86History, Qt::KeyboardModifiers()}, + {Qt::Key_AddFavorite, XKB_KEY_XF86AddFavorite, Qt::KeyboardModifiers()}, + {Qt::Key_HotLinks, XKB_KEY_XF86HotLinks, Qt::KeyboardModifiers()}, + {Qt::Key_BrightnessAdjust, XKB_KEY_XF86BrightnessAdjust, Qt::KeyboardModifiers()}, + {Qt::Key_Finance, XKB_KEY_XF86Finance, Qt::KeyboardModifiers()}, + {Qt::Key_Community, XKB_KEY_XF86Community, Qt::KeyboardModifiers()}, + {Qt::Key_AudioRewind, XKB_KEY_XF86AudioRewind, Qt::KeyboardModifiers()}, + {Qt::Key_BackForward, XKB_KEY_XF86BackForward, Qt::KeyboardModifiers()}, + {Qt::Key_ApplicationLeft, XKB_KEY_XF86ApplicationLeft, Qt::KeyboardModifiers()}, + {Qt::Key_ApplicationRight, XKB_KEY_XF86ApplicationRight, Qt::KeyboardModifiers()}, + {Qt::Key_Book, XKB_KEY_XF86Book, Qt::KeyboardModifiers()}, + {Qt::Key_CD, XKB_KEY_XF86CD, Qt::KeyboardModifiers()}, + {Qt::Key_Calculator, XKB_KEY_XF86Calculater, Qt::KeyboardModifiers()}, + {Qt::Key_Clear, XKB_KEY_XF86Clear, Qt::KeyboardModifiers()}, + {Qt::Key_ClearGrab, XKB_KEY_XF86ClearGrab, Qt::KeyboardModifiers()}, + {Qt::Key_Close, XKB_KEY_XF86Close, Qt::KeyboardModifiers()}, + {Qt::Key_Copy, XKB_KEY_XF86Copy, Qt::KeyboardModifiers()}, + {Qt::Key_Cut, XKB_KEY_XF86Cut, Qt::KeyboardModifiers()}, + {Qt::Key_Display, XKB_KEY_XF86Display, Qt::KeyboardModifiers()}, + {Qt::Key_DOS, XKB_KEY_XF86DOS, Qt::KeyboardModifiers()}, + {Qt::Key_Documents, XKB_KEY_XF86Documents, Qt::KeyboardModifiers()}, + {Qt::Key_Excel, XKB_KEY_XF86Excel, Qt::KeyboardModifiers()}, + {Qt::Key_Explorer, XKB_KEY_XF86Explorer, Qt::KeyboardModifiers()}, + {Qt::Key_Game, XKB_KEY_XF86Game, Qt::KeyboardModifiers()}, + {Qt::Key_Go, XKB_KEY_XF86Go, Qt::KeyboardModifiers()}, + {Qt::Key_iTouch, XKB_KEY_XF86iTouch, Qt::KeyboardModifiers()}, + {Qt::Key_LogOff, XKB_KEY_XF86LogOff, Qt::KeyboardModifiers()}, + {Qt::Key_Market, XKB_KEY_XF86Market, Qt::KeyboardModifiers()}, + {Qt::Key_Meeting, XKB_KEY_XF86Meeting, Qt::KeyboardModifiers()}, + {Qt::Key_MenuKB, XKB_KEY_XF86MenuKB, Qt::KeyboardModifiers()}, + {Qt::Key_MenuPB, XKB_KEY_XF86MenuPB, Qt::KeyboardModifiers()}, + {Qt::Key_MySites, XKB_KEY_XF86MySites, Qt::KeyboardModifiers()}, + {Qt::Key_News, XKB_KEY_XF86News, Qt::KeyboardModifiers()}, + {Qt::Key_OfficeHome, XKB_KEY_XF86OfficeHome, Qt::KeyboardModifiers()}, + {Qt::Key_Option, XKB_KEY_XF86Option, Qt::KeyboardModifiers()}, + {Qt::Key_Paste, XKB_KEY_XF86Paste, Qt::KeyboardModifiers()}, + {Qt::Key_Phone, XKB_KEY_XF86Phone, Qt::KeyboardModifiers()}, + {Qt::Key_Reply, XKB_KEY_XF86Reply, Qt::KeyboardModifiers()}, + {Qt::Key_Reload, XKB_KEY_XF86Reload, Qt::KeyboardModifiers()}, + {Qt::Key_RotateWindows, XKB_KEY_XF86RotateWindows, Qt::KeyboardModifiers()}, + {Qt::Key_RotationPB, XKB_KEY_XF86RotationPB, Qt::KeyboardModifiers()}, + {Qt::Key_RotationKB, XKB_KEY_XF86RotationKB, Qt::KeyboardModifiers()}, + {Qt::Key_Save, XKB_KEY_XF86Save, Qt::KeyboardModifiers()}, + {Qt::Key_Send, XKB_KEY_XF86Send, Qt::KeyboardModifiers()}, + {Qt::Key_Spell, XKB_KEY_XF86Spell, Qt::KeyboardModifiers()}, + {Qt::Key_SplitScreen, XKB_KEY_XF86SplitScreen, Qt::KeyboardModifiers()}, + {Qt::Key_Support, XKB_KEY_XF86Support, Qt::KeyboardModifiers()}, + {Qt::Key_TaskPane, XKB_KEY_XF86TaskPane, Qt::KeyboardModifiers()}, + {Qt::Key_Terminal, XKB_KEY_XF86Terminal, Qt::KeyboardModifiers()}, + {Qt::Key_Tools, XKB_KEY_XF86Tools, Qt::KeyboardModifiers()}, + {Qt::Key_Travel, XKB_KEY_XF86Travel, Qt::KeyboardModifiers()}, + {Qt::Key_Video, XKB_KEY_XF86Video, Qt::KeyboardModifiers()}, + {Qt::Key_Word, XKB_KEY_XF86Word, Qt::KeyboardModifiers()}, + {Qt::Key_Xfer, XKB_KEY_XF86Xfer, Qt::KeyboardModifiers()}, + {Qt::Key_ZoomIn, XKB_KEY_XF86ZoomIn, Qt::KeyboardModifiers()}, + {Qt::Key_ZoomOut, XKB_KEY_XF86ZoomOut, Qt::KeyboardModifiers()}, + {Qt::Key_Away, XKB_KEY_XF86Away, Qt::KeyboardModifiers()}, + {Qt::Key_Messenger, XKB_KEY_XF86Messenger, Qt::KeyboardModifiers()}, + {Qt::Key_WebCam, XKB_KEY_XF86WebCam, Qt::KeyboardModifiers()}, + {Qt::Key_MailForward, XKB_KEY_XF86MailForward, Qt::KeyboardModifiers()}, + {Qt::Key_Pictures, XKB_KEY_XF86Pictures, Qt::KeyboardModifiers()}, + {Qt::Key_Music, XKB_KEY_XF86Music, Qt::KeyboardModifiers()}, + {Qt::Key_Battery, XKB_KEY_XF86Battery, Qt::KeyboardModifiers()}, + {Qt::Key_Bluetooth, XKB_KEY_XF86Bluetooth, Qt::KeyboardModifiers()}, + {Qt::Key_WLAN, XKB_KEY_XF86WLAN, Qt::KeyboardModifiers()}, + {Qt::Key_UWB, XKB_KEY_XF86UWB, Qt::KeyboardModifiers()}, + {Qt::Key_AudioForward, XKB_KEY_XF86AudioForward, Qt::KeyboardModifiers()}, + {Qt::Key_AudioRepeat, XKB_KEY_XF86AudioRepeat, Qt::KeyboardModifiers()}, + {Qt::Key_AudioRandomPlay, XKB_KEY_XF86AudioRandomPlay, Qt::KeyboardModifiers()}, + {Qt::Key_Subtitle, XKB_KEY_XF86Subtitle, Qt::KeyboardModifiers()}, + {Qt::Key_AudioCycleTrack, XKB_KEY_XF86AudioCycleTrack, Qt::KeyboardModifiers()}, + {Qt::Key_Time, XKB_KEY_XF86Time, Qt::KeyboardModifiers()}, + {Qt::Key_Select, XKB_KEY_XF86Select, Qt::KeyboardModifiers()}, + {Qt::Key_View, XKB_KEY_XF86View, Qt::KeyboardModifiers()}, + {Qt::Key_TopMenu, XKB_KEY_XF86TopMenu, Qt::KeyboardModifiers()}, + {Qt::Key_Bluetooth, XKB_KEY_XF86Bluetooth, Qt::KeyboardModifiers()}, + {Qt::Key_Suspend, XKB_KEY_XF86Suspend, Qt::KeyboardModifiers()}, + {Qt::Key_Hibernate, XKB_KEY_XF86Hibernate, Qt::KeyboardModifiers()}, + {Qt::Key_TouchpadToggle, XKB_KEY_XF86TouchpadToggle, Qt::KeyboardModifiers()}, + {Qt::Key_TouchpadOn, XKB_KEY_XF86TouchpadOn, Qt::KeyboardModifiers()}, + {Qt::Key_TouchpadOff, XKB_KEY_XF86TouchpadOff, Qt::KeyboardModifiers()}, + {Qt::Key_MicMute, XKB_KEY_XF86AudioMicMute, Qt::KeyboardModifiers()}, + {Qt::Key_Launch2, XKB_KEY_XF86Launch0, Qt::KeyboardModifiers()}, + {Qt::Key_Launch3, XKB_KEY_XF86Launch1, Qt::KeyboardModifiers()}, + {Qt::Key_Launch4, XKB_KEY_XF86Launch2, Qt::KeyboardModifiers()}, + {Qt::Key_Launch5, XKB_KEY_XF86Launch3, Qt::KeyboardModifiers()}, + {Qt::Key_Launch6, XKB_KEY_XF86Launch4, Qt::KeyboardModifiers()}, + {Qt::Key_Launch7, XKB_KEY_XF86Launch5, Qt::KeyboardModifiers()}, + {Qt::Key_Launch8, XKB_KEY_XF86Launch6, Qt::KeyboardModifiers()}, + {Qt::Key_Launch9, XKB_KEY_XF86Launch7, Qt::KeyboardModifiers()}, + {Qt::Key_LaunchA, XKB_KEY_XF86Launch8, Qt::KeyboardModifiers()}, + {Qt::Key_LaunchB, XKB_KEY_XF86Launch9, Qt::KeyboardModifiers()}, + {Qt::Key_LaunchC, XKB_KEY_XF86LaunchA, Qt::KeyboardModifiers()}, + {Qt::Key_LaunchD, XKB_KEY_XF86LaunchB, Qt::KeyboardModifiers()}, + {Qt::Key_LaunchE, XKB_KEY_XF86LaunchC, Qt::KeyboardModifiers()}, + {Qt::Key_LaunchF, XKB_KEY_XF86LaunchD, Qt::KeyboardModifiers()}, -/* - * Latin 1 - * (ISO/IEC 8859-1 = Unicode U+0020..U+00FF) - * Byte 3 = 0 - */ - { Qt::Key_Exclam, XKB_KEY_exclam , Qt::KeyboardModifiers() }, - { Qt::Key_QuoteDbl, XKB_KEY_quotedbl , Qt::KeyboardModifiers() }, - { Qt::Key_NumberSign, XKB_KEY_numbersign , Qt::KeyboardModifiers() }, - { Qt::Key_Dollar, XKB_KEY_dollar , Qt::KeyboardModifiers() }, - { Qt::Key_Percent, XKB_KEY_percent , Qt::KeyboardModifiers() }, - { Qt::Key_Ampersand, XKB_KEY_ampersand , Qt::KeyboardModifiers() }, - { Qt::Key_Apostrophe, XKB_KEY_apostrophe , Qt::KeyboardModifiers() }, - { Qt::Key_ParenLeft, XKB_KEY_parenleft , Qt::KeyboardModifiers() }, - { Qt::Key_ParenRight, XKB_KEY_parenright , Qt::KeyboardModifiers() }, - { Qt::Key_Asterisk, XKB_KEY_asterisk , Qt::KeyboardModifiers() }, - { Qt::Key_Plus, XKB_KEY_plus , Qt::KeyboardModifiers() }, - { Qt::Key_Comma, XKB_KEY_comma , Qt::KeyboardModifiers() }, - { Qt::Key_Minus, XKB_KEY_minus , Qt::KeyboardModifiers() }, - { Qt::Key_Period, XKB_KEY_period , Qt::KeyboardModifiers() }, - { Qt::Key_Slash, XKB_KEY_slash , Qt::KeyboardModifiers() }, - { Qt::Key_0, XKB_KEY_0 , Qt::KeyboardModifiers() }, - { Qt::Key_1, XKB_KEY_1 , Qt::KeyboardModifiers() }, - { Qt::Key_2, XKB_KEY_2 , Qt::KeyboardModifiers() }, - { Qt::Key_3, XKB_KEY_3 , Qt::KeyboardModifiers() }, - { Qt::Key_4, XKB_KEY_4 , Qt::KeyboardModifiers() }, - { Qt::Key_5, XKB_KEY_5 , Qt::KeyboardModifiers() }, - { Qt::Key_6, XKB_KEY_6 , Qt::KeyboardModifiers() }, - { Qt::Key_7, XKB_KEY_7 , Qt::KeyboardModifiers() }, - { Qt::Key_8, XKB_KEY_8 , Qt::KeyboardModifiers() }, - { Qt::Key_9, XKB_KEY_9 , Qt::KeyboardModifiers() }, - { Qt::Key_Colon, XKB_KEY_colon , Qt::KeyboardModifiers() }, - { Qt::Key_Semicolon, XKB_KEY_semicolon , Qt::KeyboardModifiers() }, - { Qt::Key_Less, XKB_KEY_less , Qt::KeyboardModifiers() }, - { Qt::Key_Equal, XKB_KEY_equal , Qt::KeyboardModifiers() }, - { Qt::Key_Greater, XKB_KEY_greater , Qt::KeyboardModifiers() }, - { Qt::Key_Question, XKB_KEY_question , Qt::KeyboardModifiers() }, - { Qt::Key_At, XKB_KEY_at , Qt::KeyboardModifiers() }, - { Qt::Key_A, XKB_KEY_A , Qt::ShiftModifier }, - { Qt::Key_B, XKB_KEY_B , Qt::ShiftModifier }, - { Qt::Key_C, XKB_KEY_C , Qt::ShiftModifier }, - { Qt::Key_D, XKB_KEY_D , Qt::ShiftModifier }, - { Qt::Key_E, XKB_KEY_E , Qt::ShiftModifier }, - { Qt::Key_F, XKB_KEY_F , Qt::ShiftModifier }, - { Qt::Key_G, XKB_KEY_G , Qt::ShiftModifier }, - { Qt::Key_H, XKB_KEY_H , Qt::ShiftModifier }, - { Qt::Key_I, XKB_KEY_I , Qt::ShiftModifier }, - { Qt::Key_J, XKB_KEY_J , Qt::ShiftModifier }, - { Qt::Key_K, XKB_KEY_K , Qt::ShiftModifier }, - { Qt::Key_L, XKB_KEY_L , Qt::ShiftModifier }, - { Qt::Key_M, XKB_KEY_M , Qt::ShiftModifier }, - { Qt::Key_N, XKB_KEY_N , Qt::ShiftModifier }, - { Qt::Key_O, XKB_KEY_O , Qt::ShiftModifier }, - { Qt::Key_P, XKB_KEY_P , Qt::ShiftModifier }, - { Qt::Key_Q, XKB_KEY_Q , Qt::ShiftModifier }, - { Qt::Key_R, XKB_KEY_R , Qt::ShiftModifier }, - { Qt::Key_S, XKB_KEY_S , Qt::ShiftModifier }, - { Qt::Key_T, XKB_KEY_T , Qt::ShiftModifier }, - { Qt::Key_U, XKB_KEY_U , Qt::ShiftModifier }, - { Qt::Key_V, XKB_KEY_V , Qt::ShiftModifier }, - { Qt::Key_W, XKB_KEY_W , Qt::ShiftModifier }, - { Qt::Key_X, XKB_KEY_X , Qt::ShiftModifier }, - { Qt::Key_Y, XKB_KEY_Y , Qt::ShiftModifier }, - { Qt::Key_Z, XKB_KEY_Z , Qt::ShiftModifier }, - { Qt::Key_BracketLeft, XKB_KEY_bracketleft, Qt::KeyboardModifiers() }, - { Qt::Key_Backslash, XKB_KEY_backslash , Qt::KeyboardModifiers() }, - { Qt::Key_BracketRight, XKB_KEY_bracketright, Qt::KeyboardModifiers()}, - { Qt::Key_AsciiCircum, XKB_KEY_asciicircum, Qt::KeyboardModifiers() }, - { Qt::Key_Underscore, XKB_KEY_underscore , Qt::KeyboardModifiers() }, - { Qt::Key_QuoteLeft, XKB_KEY_quoteleft , Qt::KeyboardModifiers() }, - { Qt::Key_A, XKB_KEY_a , Qt::KeyboardModifiers() }, - { Qt::Key_B, XKB_KEY_b , Qt::KeyboardModifiers() }, - { Qt::Key_C, XKB_KEY_c , Qt::KeyboardModifiers() }, - { Qt::Key_D, XKB_KEY_d , Qt::KeyboardModifiers() }, - { Qt::Key_E, XKB_KEY_e , Qt::KeyboardModifiers() }, - { Qt::Key_F, XKB_KEY_f , Qt::KeyboardModifiers() }, - { Qt::Key_G, XKB_KEY_g , Qt::KeyboardModifiers() }, - { Qt::Key_H, XKB_KEY_h , Qt::KeyboardModifiers() }, - { Qt::Key_I, XKB_KEY_i , Qt::KeyboardModifiers() }, - { Qt::Key_J, XKB_KEY_j , Qt::KeyboardModifiers() }, - { Qt::Key_K, XKB_KEY_k , Qt::KeyboardModifiers() }, - { Qt::Key_L, XKB_KEY_l , Qt::KeyboardModifiers() }, - { Qt::Key_M, XKB_KEY_m , Qt::KeyboardModifiers() }, - { Qt::Key_N, XKB_KEY_n , Qt::KeyboardModifiers() }, - { Qt::Key_O, XKB_KEY_o , Qt::KeyboardModifiers() }, - { Qt::Key_P, XKB_KEY_p , Qt::KeyboardModifiers() }, - { Qt::Key_Q, XKB_KEY_q , Qt::KeyboardModifiers() }, - { Qt::Key_R, XKB_KEY_r , Qt::KeyboardModifiers() }, - { Qt::Key_S, XKB_KEY_s , Qt::KeyboardModifiers() }, - { Qt::Key_T, XKB_KEY_t , Qt::KeyboardModifiers() }, - { Qt::Key_U, XKB_KEY_u , Qt::KeyboardModifiers() }, - { Qt::Key_V, XKB_KEY_v , Qt::KeyboardModifiers() }, - { Qt::Key_W, XKB_KEY_w , Qt::KeyboardModifiers() }, - { Qt::Key_X, XKB_KEY_x , Qt::KeyboardModifiers() }, - { Qt::Key_Y, XKB_KEY_y , Qt::KeyboardModifiers() }, - { Qt::Key_Z, XKB_KEY_z , Qt::KeyboardModifiers() }, - { Qt::Key_BraceLeft, XKB_KEY_braceleft , Qt::KeyboardModifiers() }, - { Qt::Key_Bar, XKB_KEY_bar , Qt::KeyboardModifiers() }, - { Qt::Key_BraceRight, XKB_KEY_braceright , Qt::KeyboardModifiers() }, - { Qt::Key_AsciiTilde, XKB_KEY_asciitilde , Qt::KeyboardModifiers() }, + /* + * Latin 1 + * (ISO/IEC 8859-1 = Unicode U+0020..U+00FF) + * Byte 3 = 0 + */ + {Qt::Key_Exclam, XKB_KEY_exclam, Qt::KeyboardModifiers()}, + {Qt::Key_QuoteDbl, XKB_KEY_quotedbl, Qt::KeyboardModifiers()}, + {Qt::Key_NumberSign, XKB_KEY_numbersign, Qt::KeyboardModifiers()}, + {Qt::Key_Dollar, XKB_KEY_dollar, Qt::KeyboardModifiers()}, + {Qt::Key_Percent, XKB_KEY_percent, Qt::KeyboardModifiers()}, + {Qt::Key_Ampersand, XKB_KEY_ampersand, Qt::KeyboardModifiers()}, + {Qt::Key_Apostrophe, XKB_KEY_apostrophe, Qt::KeyboardModifiers()}, + {Qt::Key_ParenLeft, XKB_KEY_parenleft, Qt::KeyboardModifiers()}, + {Qt::Key_ParenRight, XKB_KEY_parenright, Qt::KeyboardModifiers()}, + {Qt::Key_Asterisk, XKB_KEY_asterisk, Qt::KeyboardModifiers()}, + {Qt::Key_Plus, XKB_KEY_plus, Qt::KeyboardModifiers()}, + {Qt::Key_Comma, XKB_KEY_comma, Qt::KeyboardModifiers()}, + {Qt::Key_Minus, XKB_KEY_minus, Qt::KeyboardModifiers()}, + {Qt::Key_Period, XKB_KEY_period, Qt::KeyboardModifiers()}, + {Qt::Key_Slash, XKB_KEY_slash, Qt::KeyboardModifiers()}, + {Qt::Key_0, XKB_KEY_0, Qt::KeyboardModifiers()}, + {Qt::Key_1, XKB_KEY_1, Qt::KeyboardModifiers()}, + {Qt::Key_2, XKB_KEY_2, Qt::KeyboardModifiers()}, + {Qt::Key_3, XKB_KEY_3, Qt::KeyboardModifiers()}, + {Qt::Key_4, XKB_KEY_4, Qt::KeyboardModifiers()}, + {Qt::Key_5, XKB_KEY_5, Qt::KeyboardModifiers()}, + {Qt::Key_6, XKB_KEY_6, Qt::KeyboardModifiers()}, + {Qt::Key_7, XKB_KEY_7, Qt::KeyboardModifiers()}, + {Qt::Key_8, XKB_KEY_8, Qt::KeyboardModifiers()}, + {Qt::Key_9, XKB_KEY_9, Qt::KeyboardModifiers()}, + {Qt::Key_Colon, XKB_KEY_colon, Qt::KeyboardModifiers()}, + {Qt::Key_Semicolon, XKB_KEY_semicolon, Qt::KeyboardModifiers()}, + {Qt::Key_Less, XKB_KEY_less, Qt::KeyboardModifiers()}, + {Qt::Key_Equal, XKB_KEY_equal, Qt::KeyboardModifiers()}, + {Qt::Key_Greater, XKB_KEY_greater, Qt::KeyboardModifiers()}, + {Qt::Key_Question, XKB_KEY_question, Qt::KeyboardModifiers()}, + {Qt::Key_At, XKB_KEY_at, Qt::KeyboardModifiers()}, + {Qt::Key_A, XKB_KEY_A, Qt::ShiftModifier}, + {Qt::Key_B, XKB_KEY_B, Qt::ShiftModifier}, + {Qt::Key_C, XKB_KEY_C, Qt::ShiftModifier}, + {Qt::Key_D, XKB_KEY_D, Qt::ShiftModifier}, + {Qt::Key_E, XKB_KEY_E, Qt::ShiftModifier}, + {Qt::Key_F, XKB_KEY_F, Qt::ShiftModifier}, + {Qt::Key_G, XKB_KEY_G, Qt::ShiftModifier}, + {Qt::Key_H, XKB_KEY_H, Qt::ShiftModifier}, + {Qt::Key_I, XKB_KEY_I, Qt::ShiftModifier}, + {Qt::Key_J, XKB_KEY_J, Qt::ShiftModifier}, + {Qt::Key_K, XKB_KEY_K, Qt::ShiftModifier}, + {Qt::Key_L, XKB_KEY_L, Qt::ShiftModifier}, + {Qt::Key_M, XKB_KEY_M, Qt::ShiftModifier}, + {Qt::Key_N, XKB_KEY_N, Qt::ShiftModifier}, + {Qt::Key_O, XKB_KEY_O, Qt::ShiftModifier}, + {Qt::Key_P, XKB_KEY_P, Qt::ShiftModifier}, + {Qt::Key_Q, XKB_KEY_Q, Qt::ShiftModifier}, + {Qt::Key_R, XKB_KEY_R, Qt::ShiftModifier}, + {Qt::Key_S, XKB_KEY_S, Qt::ShiftModifier}, + {Qt::Key_T, XKB_KEY_T, Qt::ShiftModifier}, + {Qt::Key_U, XKB_KEY_U, Qt::ShiftModifier}, + {Qt::Key_V, XKB_KEY_V, Qt::ShiftModifier}, + {Qt::Key_W, XKB_KEY_W, Qt::ShiftModifier}, + {Qt::Key_X, XKB_KEY_X, Qt::ShiftModifier}, + {Qt::Key_Y, XKB_KEY_Y, Qt::ShiftModifier}, + {Qt::Key_Z, XKB_KEY_Z, Qt::ShiftModifier}, + {Qt::Key_BracketLeft, XKB_KEY_bracketleft, Qt::KeyboardModifiers()}, + {Qt::Key_Backslash, XKB_KEY_backslash, Qt::KeyboardModifiers()}, + {Qt::Key_BracketRight, XKB_KEY_bracketright, Qt::KeyboardModifiers()}, + {Qt::Key_AsciiCircum, XKB_KEY_asciicircum, Qt::KeyboardModifiers()}, + {Qt::Key_Underscore, XKB_KEY_underscore, Qt::KeyboardModifiers()}, + {Qt::Key_QuoteLeft, XKB_KEY_quoteleft, Qt::KeyboardModifiers()}, + {Qt::Key_A, XKB_KEY_a, Qt::KeyboardModifiers()}, + {Qt::Key_B, XKB_KEY_b, Qt::KeyboardModifiers()}, + {Qt::Key_C, XKB_KEY_c, Qt::KeyboardModifiers()}, + {Qt::Key_D, XKB_KEY_d, Qt::KeyboardModifiers()}, + {Qt::Key_E, XKB_KEY_e, Qt::KeyboardModifiers()}, + {Qt::Key_F, XKB_KEY_f, Qt::KeyboardModifiers()}, + {Qt::Key_G, XKB_KEY_g, Qt::KeyboardModifiers()}, + {Qt::Key_H, XKB_KEY_h, Qt::KeyboardModifiers()}, + {Qt::Key_I, XKB_KEY_i, Qt::KeyboardModifiers()}, + {Qt::Key_J, XKB_KEY_j, Qt::KeyboardModifiers()}, + {Qt::Key_K, XKB_KEY_k, Qt::KeyboardModifiers()}, + {Qt::Key_L, XKB_KEY_l, Qt::KeyboardModifiers()}, + {Qt::Key_M, XKB_KEY_m, Qt::KeyboardModifiers()}, + {Qt::Key_N, XKB_KEY_n, Qt::KeyboardModifiers()}, + {Qt::Key_O, XKB_KEY_o, Qt::KeyboardModifiers()}, + {Qt::Key_P, XKB_KEY_p, Qt::KeyboardModifiers()}, + {Qt::Key_Q, XKB_KEY_q, Qt::KeyboardModifiers()}, + {Qt::Key_R, XKB_KEY_r, Qt::KeyboardModifiers()}, + {Qt::Key_S, XKB_KEY_s, Qt::KeyboardModifiers()}, + {Qt::Key_T, XKB_KEY_t, Qt::KeyboardModifiers()}, + {Qt::Key_U, XKB_KEY_u, Qt::KeyboardModifiers()}, + {Qt::Key_V, XKB_KEY_v, Qt::KeyboardModifiers()}, + {Qt::Key_W, XKB_KEY_w, Qt::KeyboardModifiers()}, + {Qt::Key_X, XKB_KEY_x, Qt::KeyboardModifiers()}, + {Qt::Key_Y, XKB_KEY_y, Qt::KeyboardModifiers()}, + {Qt::Key_Z, XKB_KEY_z, Qt::KeyboardModifiers()}, + {Qt::Key_BraceLeft, XKB_KEY_braceleft, Qt::KeyboardModifiers()}, + {Qt::Key_Bar, XKB_KEY_bar, Qt::KeyboardModifiers()}, + {Qt::Key_BraceRight, XKB_KEY_braceright, Qt::KeyboardModifiers()}, + {Qt::Key_AsciiTilde, XKB_KEY_asciitilde, Qt::KeyboardModifiers()}, - { Qt::Key_nobreakspace, XKB_KEY_nobreakspace , Qt::KeyboardModifiers() }, - { Qt::Key_exclamdown, XKB_KEY_exclamdown , Qt::KeyboardModifiers() }, - { Qt::Key_cent, XKB_KEY_cent , Qt::KeyboardModifiers() }, - { Qt::Key_sterling, XKB_KEY_sterling , Qt::KeyboardModifiers() }, - { Qt::Key_currency, XKB_KEY_currency , Qt::KeyboardModifiers() }, - { Qt::Key_yen, XKB_KEY_yen , Qt::KeyboardModifiers() }, - { Qt::Key_brokenbar, XKB_KEY_brokenbar , Qt::KeyboardModifiers() }, - { Qt::Key_section, XKB_KEY_section , Qt::KeyboardModifiers() }, - { Qt::Key_diaeresis, XKB_KEY_diaeresis , Qt::KeyboardModifiers() }, - { Qt::Key_copyright, XKB_KEY_copyright , Qt::KeyboardModifiers() }, - { Qt::Key_ordfeminine, XKB_KEY_ordfeminine , Qt::KeyboardModifiers() }, - { Qt::Key_guillemotleft, XKB_KEY_guillemotleft , Qt::KeyboardModifiers() }, - { Qt::Key_notsign, XKB_KEY_notsign , Qt::KeyboardModifiers() }, - { Qt::Key_hyphen, XKB_KEY_hyphen , Qt::KeyboardModifiers() }, - { Qt::Key_registered, XKB_KEY_registered , Qt::KeyboardModifiers() }, - { Qt::Key_macron, XKB_KEY_macron , Qt::KeyboardModifiers() }, - { Qt::Key_degree, XKB_KEY_degree , Qt::KeyboardModifiers() }, - { Qt::Key_plusminus, XKB_KEY_plusminus , Qt::KeyboardModifiers() }, - { Qt::Key_twosuperior, XKB_KEY_twosuperior , Qt::KeyboardModifiers() }, - { Qt::Key_threesuperior, XKB_KEY_threesuperior , Qt::KeyboardModifiers() }, - { Qt::Key_acute, XKB_KEY_acute , Qt::KeyboardModifiers() }, - { Qt::Key_mu, XKB_KEY_mu , Qt::KeyboardModifiers() }, - { Qt::Key_paragraph, XKB_KEY_paragraph , Qt::KeyboardModifiers() }, - { Qt::Key_periodcentered, XKB_KEY_periodcentered, Qt::KeyboardModifiers() }, - { Qt::Key_cedilla, XKB_KEY_cedilla , Qt::KeyboardModifiers() }, - { Qt::Key_onesuperior, XKB_KEY_onesuperior , Qt::KeyboardModifiers() }, - { Qt::Key_masculine, XKB_KEY_masculine , Qt::KeyboardModifiers() }, - { Qt::Key_guillemotright, XKB_KEY_guillemotright, Qt::KeyboardModifiers() }, - { Qt::Key_onequarter, XKB_KEY_onequarter , Qt::KeyboardModifiers() }, - { Qt::Key_onehalf, XKB_KEY_onehalf , Qt::KeyboardModifiers() }, - { Qt::Key_threequarters, XKB_KEY_threequarters , Qt::KeyboardModifiers() }, - { Qt::Key_questiondown, XKB_KEY_questiondown , Qt::KeyboardModifiers() }, - { Qt::Key_Agrave, XKB_KEY_Agrave , Qt::ShiftModifier }, - { Qt::Key_Aacute, XKB_KEY_Aacute , Qt::ShiftModifier }, - { Qt::Key_Acircumflex, XKB_KEY_Acircumflex , Qt::ShiftModifier }, - { Qt::Key_Atilde, XKB_KEY_Atilde , Qt::ShiftModifier }, - { Qt::Key_Adiaeresis, XKB_KEY_Adiaeresis , Qt::ShiftModifier }, - { Qt::Key_Aring, XKB_KEY_Aring , Qt::ShiftModifier }, - { Qt::Key_AE, XKB_KEY_AE , Qt::ShiftModifier }, - { Qt::Key_Ccedilla, XKB_KEY_Ccedilla , Qt::ShiftModifier }, - { Qt::Key_Egrave, XKB_KEY_Egrave , Qt::ShiftModifier }, - { Qt::Key_Eacute, XKB_KEY_Eacute , Qt::ShiftModifier }, - { Qt::Key_Ecircumflex, XKB_KEY_Ecircumflex , Qt::ShiftModifier }, - { Qt::Key_Ediaeresis, XKB_KEY_Ediaeresis , Qt::ShiftModifier }, - { Qt::Key_Igrave, XKB_KEY_Igrave , Qt::ShiftModifier }, - { Qt::Key_Iacute, XKB_KEY_Iacute , Qt::ShiftModifier }, - { Qt::Key_Icircumflex, XKB_KEY_Icircumflex , Qt::ShiftModifier }, - { Qt::Key_Idiaeresis, XKB_KEY_Idiaeresis , Qt::ShiftModifier }, - { Qt::Key_ETH, XKB_KEY_ETH , Qt::ShiftModifier }, - { Qt::Key_Ntilde, XKB_KEY_Ntilde , Qt::ShiftModifier }, - { Qt::Key_Ograve, XKB_KEY_Ograve , Qt::ShiftModifier }, - { Qt::Key_Oacute, XKB_KEY_Oacute , Qt::ShiftModifier }, - { Qt::Key_Ocircumflex, XKB_KEY_Ocircumflex , Qt::ShiftModifier }, - { Qt::Key_Otilde, XKB_KEY_Otilde , Qt::ShiftModifier }, - { Qt::Key_Odiaeresis, XKB_KEY_Odiaeresis , Qt::ShiftModifier }, - { Qt::Key_multiply, XKB_KEY_multiply , Qt::ShiftModifier }, - { Qt::Key_Ooblique, XKB_KEY_Ooblique , Qt::ShiftModifier }, - { Qt::Key_Ugrave, XKB_KEY_Ugrave , Qt::ShiftModifier }, - { Qt::Key_Uacute, XKB_KEY_Uacute , Qt::ShiftModifier }, - { Qt::Key_Ucircumflex, XKB_KEY_Ucircumflex , Qt::ShiftModifier }, - { Qt::Key_Udiaeresis, XKB_KEY_Udiaeresis , Qt::ShiftModifier }, - { Qt::Key_Yacute, XKB_KEY_Yacute , Qt::ShiftModifier }, - { Qt::Key_THORN, XKB_KEY_THORN , Qt::ShiftModifier }, - { Qt::Key_ssharp, XKB_KEY_ssharp , Qt::KeyboardModifiers() }, - { Qt::Key_Agrave, XKB_KEY_agrave , Qt::KeyboardModifiers() }, - { Qt::Key_Aacute, XKB_KEY_aacute , Qt::KeyboardModifiers() }, - { Qt::Key_Acircumflex, XKB_KEY_acircumflex , Qt::KeyboardModifiers() }, - { Qt::Key_Atilde, XKB_KEY_atilde , Qt::KeyboardModifiers() }, - { Qt::Key_Adiaeresis, XKB_KEY_adiaeresis , Qt::KeyboardModifiers() }, - { Qt::Key_Aring, XKB_KEY_aring , Qt::KeyboardModifiers() }, - { Qt::Key_AE, XKB_KEY_ae , Qt::KeyboardModifiers() }, - { Qt::Key_Ccedilla, XKB_KEY_ccedilla , Qt::KeyboardModifiers() }, - { Qt::Key_Egrave, XKB_KEY_egrave , Qt::KeyboardModifiers() }, - { Qt::Key_Eacute, XKB_KEY_eacute , Qt::KeyboardModifiers() }, - { Qt::Key_Ecircumflex, XKB_KEY_ecircumflex , Qt::KeyboardModifiers() }, - { Qt::Key_Ediaeresis, XKB_KEY_ediaeresis , Qt::KeyboardModifiers() }, - { Qt::Key_Igrave, XKB_KEY_igrave , Qt::KeyboardModifiers() }, - { Qt::Key_Iacute, XKB_KEY_iacute , Qt::KeyboardModifiers() }, - { Qt::Key_Icircumflex, XKB_KEY_icircumflex , Qt::KeyboardModifiers() }, - { Qt::Key_Idiaeresis, XKB_KEY_idiaeresis , Qt::KeyboardModifiers() }, - { Qt::Key_ETH, XKB_KEY_eth , Qt::KeyboardModifiers() }, - { Qt::Key_Ntilde, XKB_KEY_ntilde , Qt::KeyboardModifiers() }, - { Qt::Key_Ograve, XKB_KEY_ograve , Qt::KeyboardModifiers() }, - { Qt::Key_Oacute, XKB_KEY_oacute , Qt::KeyboardModifiers() }, - { Qt::Key_Ocircumflex, XKB_KEY_ocircumflex , Qt::KeyboardModifiers() }, - { Qt::Key_Otilde, XKB_KEY_otilde , Qt::KeyboardModifiers() }, - { Qt::Key_Odiaeresis, XKB_KEY_odiaeresis , Qt::KeyboardModifiers() }, - { Qt::Key_division, XKB_KEY_division , Qt::KeyboardModifiers() }, - { Qt::Key_Ooblique, XKB_KEY_ooblique , Qt::KeyboardModifiers() }, - { Qt::Key_Ugrave, XKB_KEY_ugrave , Qt::KeyboardModifiers() }, - { Qt::Key_Uacute, XKB_KEY_uacute , Qt::KeyboardModifiers() }, - { Qt::Key_Ucircumflex, XKB_KEY_ucircumflex , Qt::KeyboardModifiers() }, - { Qt::Key_Udiaeresis, XKB_KEY_udiaeresis , Qt::KeyboardModifiers() }, - { Qt::Key_Yacute, XKB_KEY_yacute , Qt::KeyboardModifiers() }, - { Qt::Key_THORN, XKB_KEY_thorn , Qt::KeyboardModifiers() }, - { Qt::Key_ydiaeresis, XKB_KEY_ydiaeresis, Qt::KeyboardModifiers() }, + {Qt::Key_nobreakspace, XKB_KEY_nobreakspace, Qt::KeyboardModifiers()}, + {Qt::Key_exclamdown, XKB_KEY_exclamdown, Qt::KeyboardModifiers()}, + {Qt::Key_cent, XKB_KEY_cent, Qt::KeyboardModifiers()}, + {Qt::Key_sterling, XKB_KEY_sterling, Qt::KeyboardModifiers()}, + {Qt::Key_currency, XKB_KEY_currency, Qt::KeyboardModifiers()}, + {Qt::Key_yen, XKB_KEY_yen, Qt::KeyboardModifiers()}, + {Qt::Key_brokenbar, XKB_KEY_brokenbar, Qt::KeyboardModifiers()}, + {Qt::Key_section, XKB_KEY_section, Qt::KeyboardModifiers()}, + {Qt::Key_diaeresis, XKB_KEY_diaeresis, Qt::KeyboardModifiers()}, + {Qt::Key_copyright, XKB_KEY_copyright, Qt::KeyboardModifiers()}, + {Qt::Key_ordfeminine, XKB_KEY_ordfeminine, Qt::KeyboardModifiers()}, + {Qt::Key_guillemotleft, XKB_KEY_guillemotleft, Qt::KeyboardModifiers()}, + {Qt::Key_notsign, XKB_KEY_notsign, Qt::KeyboardModifiers()}, + {Qt::Key_hyphen, XKB_KEY_hyphen, Qt::KeyboardModifiers()}, + {Qt::Key_registered, XKB_KEY_registered, Qt::KeyboardModifiers()}, + {Qt::Key_macron, XKB_KEY_macron, Qt::KeyboardModifiers()}, + {Qt::Key_degree, XKB_KEY_degree, Qt::KeyboardModifiers()}, + {Qt::Key_plusminus, XKB_KEY_plusminus, Qt::KeyboardModifiers()}, + {Qt::Key_twosuperior, XKB_KEY_twosuperior, Qt::KeyboardModifiers()}, + {Qt::Key_threesuperior, XKB_KEY_threesuperior, Qt::KeyboardModifiers()}, + {Qt::Key_acute, XKB_KEY_acute, Qt::KeyboardModifiers()}, + {Qt::Key_mu, XKB_KEY_mu, Qt::KeyboardModifiers()}, + {Qt::Key_paragraph, XKB_KEY_paragraph, Qt::KeyboardModifiers()}, + {Qt::Key_periodcentered, XKB_KEY_periodcentered, Qt::KeyboardModifiers()}, + {Qt::Key_cedilla, XKB_KEY_cedilla, Qt::KeyboardModifiers()}, + {Qt::Key_onesuperior, XKB_KEY_onesuperior, Qt::KeyboardModifiers()}, + {Qt::Key_masculine, XKB_KEY_masculine, Qt::KeyboardModifiers()}, + {Qt::Key_guillemotright, XKB_KEY_guillemotright, Qt::KeyboardModifiers()}, + {Qt::Key_onequarter, XKB_KEY_onequarter, Qt::KeyboardModifiers()}, + {Qt::Key_onehalf, XKB_KEY_onehalf, Qt::KeyboardModifiers()}, + {Qt::Key_threequarters, XKB_KEY_threequarters, Qt::KeyboardModifiers()}, + {Qt::Key_questiondown, XKB_KEY_questiondown, Qt::KeyboardModifiers()}, + {Qt::Key_Agrave, XKB_KEY_Agrave, Qt::ShiftModifier}, + {Qt::Key_Aacute, XKB_KEY_Aacute, Qt::ShiftModifier}, + {Qt::Key_Acircumflex, XKB_KEY_Acircumflex, Qt::ShiftModifier}, + {Qt::Key_Atilde, XKB_KEY_Atilde, Qt::ShiftModifier}, + {Qt::Key_Adiaeresis, XKB_KEY_Adiaeresis, Qt::ShiftModifier}, + {Qt::Key_Aring, XKB_KEY_Aring, Qt::ShiftModifier}, + {Qt::Key_AE, XKB_KEY_AE, Qt::ShiftModifier}, + {Qt::Key_Ccedilla, XKB_KEY_Ccedilla, Qt::ShiftModifier}, + {Qt::Key_Egrave, XKB_KEY_Egrave, Qt::ShiftModifier}, + {Qt::Key_Eacute, XKB_KEY_Eacute, Qt::ShiftModifier}, + {Qt::Key_Ecircumflex, XKB_KEY_Ecircumflex, Qt::ShiftModifier}, + {Qt::Key_Ediaeresis, XKB_KEY_Ediaeresis, Qt::ShiftModifier}, + {Qt::Key_Igrave, XKB_KEY_Igrave, Qt::ShiftModifier}, + {Qt::Key_Iacute, XKB_KEY_Iacute, Qt::ShiftModifier}, + {Qt::Key_Icircumflex, XKB_KEY_Icircumflex, Qt::ShiftModifier}, + {Qt::Key_Idiaeresis, XKB_KEY_Idiaeresis, Qt::ShiftModifier}, + {Qt::Key_ETH, XKB_KEY_ETH, Qt::ShiftModifier}, + {Qt::Key_Ntilde, XKB_KEY_Ntilde, Qt::ShiftModifier}, + {Qt::Key_Ograve, XKB_KEY_Ograve, Qt::ShiftModifier}, + {Qt::Key_Oacute, XKB_KEY_Oacute, Qt::ShiftModifier}, + {Qt::Key_Ocircumflex, XKB_KEY_Ocircumflex, Qt::ShiftModifier}, + {Qt::Key_Otilde, XKB_KEY_Otilde, Qt::ShiftModifier}, + {Qt::Key_Odiaeresis, XKB_KEY_Odiaeresis, Qt::ShiftModifier}, + {Qt::Key_multiply, XKB_KEY_multiply, Qt::ShiftModifier}, + {Qt::Key_Ooblique, XKB_KEY_Ooblique, Qt::ShiftModifier}, + {Qt::Key_Ugrave, XKB_KEY_Ugrave, Qt::ShiftModifier}, + {Qt::Key_Uacute, XKB_KEY_Uacute, Qt::ShiftModifier}, + {Qt::Key_Ucircumflex, XKB_KEY_Ucircumflex, Qt::ShiftModifier}, + {Qt::Key_Udiaeresis, XKB_KEY_Udiaeresis, Qt::ShiftModifier}, + {Qt::Key_Yacute, XKB_KEY_Yacute, Qt::ShiftModifier}, + {Qt::Key_THORN, XKB_KEY_THORN, Qt::ShiftModifier}, + {Qt::Key_ssharp, XKB_KEY_ssharp, Qt::KeyboardModifiers()}, + {Qt::Key_Agrave, XKB_KEY_agrave, Qt::KeyboardModifiers()}, + {Qt::Key_Aacute, XKB_KEY_aacute, Qt::KeyboardModifiers()}, + {Qt::Key_Acircumflex, XKB_KEY_acircumflex, Qt::KeyboardModifiers()}, + {Qt::Key_Atilde, XKB_KEY_atilde, Qt::KeyboardModifiers()}, + {Qt::Key_Adiaeresis, XKB_KEY_adiaeresis, Qt::KeyboardModifiers()}, + {Qt::Key_Aring, XKB_KEY_aring, Qt::KeyboardModifiers()}, + {Qt::Key_AE, XKB_KEY_ae, Qt::KeyboardModifiers()}, + {Qt::Key_Ccedilla, XKB_KEY_ccedilla, Qt::KeyboardModifiers()}, + {Qt::Key_Egrave, XKB_KEY_egrave, Qt::KeyboardModifiers()}, + {Qt::Key_Eacute, XKB_KEY_eacute, Qt::KeyboardModifiers()}, + {Qt::Key_Ecircumflex, XKB_KEY_ecircumflex, Qt::KeyboardModifiers()}, + {Qt::Key_Ediaeresis, XKB_KEY_ediaeresis, Qt::KeyboardModifiers()}, + {Qt::Key_Igrave, XKB_KEY_igrave, Qt::KeyboardModifiers()}, + {Qt::Key_Iacute, XKB_KEY_iacute, Qt::KeyboardModifiers()}, + {Qt::Key_Icircumflex, XKB_KEY_icircumflex, Qt::KeyboardModifiers()}, + {Qt::Key_Idiaeresis, XKB_KEY_idiaeresis, Qt::KeyboardModifiers()}, + {Qt::Key_ETH, XKB_KEY_eth, Qt::KeyboardModifiers()}, + {Qt::Key_Ntilde, XKB_KEY_ntilde, Qt::KeyboardModifiers()}, + {Qt::Key_Ograve, XKB_KEY_ograve, Qt::KeyboardModifiers()}, + {Qt::Key_Oacute, XKB_KEY_oacute, Qt::KeyboardModifiers()}, + {Qt::Key_Ocircumflex, XKB_KEY_ocircumflex, Qt::KeyboardModifiers()}, + {Qt::Key_Otilde, XKB_KEY_otilde, Qt::KeyboardModifiers()}, + {Qt::Key_Odiaeresis, XKB_KEY_odiaeresis, Qt::KeyboardModifiers()}, + {Qt::Key_division, XKB_KEY_division, Qt::KeyboardModifiers()}, + {Qt::Key_Ooblique, XKB_KEY_ooblique, Qt::KeyboardModifiers()}, + {Qt::Key_Ugrave, XKB_KEY_ugrave, Qt::KeyboardModifiers()}, + {Qt::Key_Uacute, XKB_KEY_uacute, Qt::KeyboardModifiers()}, + {Qt::Key_Ucircumflex, XKB_KEY_ucircumflex, Qt::KeyboardModifiers()}, + {Qt::Key_Udiaeresis, XKB_KEY_udiaeresis, Qt::KeyboardModifiers()}, + {Qt::Key_Yacute, XKB_KEY_yacute, Qt::KeyboardModifiers()}, + {Qt::Key_THORN, XKB_KEY_thorn, Qt::KeyboardModifiers()}, + {Qt::Key_ydiaeresis, XKB_KEY_ydiaeresis, Qt::KeyboardModifiers()}, /* * Numpad */ - { Qt::Key_0, XKB_KEY_KP_0, Qt::KeypadModifier }, - { Qt::Key_1, XKB_KEY_KP_1, Qt::KeypadModifier }, - { Qt::Key_2, XKB_KEY_KP_2, Qt::KeypadModifier }, - { Qt::Key_3, XKB_KEY_KP_3, Qt::KeypadModifier }, - { Qt::Key_4, XKB_KEY_KP_4, Qt::KeypadModifier }, - { Qt::Key_5, XKB_KEY_KP_5, Qt::KeypadModifier }, - { Qt::Key_6, XKB_KEY_KP_6, Qt::KeypadModifier }, - { Qt::Key_7, XKB_KEY_KP_7, Qt::KeypadModifier }, - { Qt::Key_8, XKB_KEY_KP_8, Qt::KeypadModifier }, - { Qt::Key_9, XKB_KEY_KP_9, Qt::KeypadModifier } -}; + {Qt::Key_0, XKB_KEY_KP_0, Qt::KeypadModifier}, + {Qt::Key_1, XKB_KEY_KP_1, Qt::KeypadModifier}, + {Qt::Key_2, XKB_KEY_KP_2, Qt::KeypadModifier}, + {Qt::Key_3, XKB_KEY_KP_3, Qt::KeypadModifier}, + {Qt::Key_4, XKB_KEY_KP_4, Qt::KeypadModifier}, + {Qt::Key_5, XKB_KEY_KP_5, Qt::KeypadModifier}, + {Qt::Key_6, XKB_KEY_KP_6, Qt::KeypadModifier}, + {Qt::Key_7, XKB_KEY_KP_7, Qt::KeypadModifier}, + {Qt::Key_8, XKB_KEY_KP_8, Qt::KeypadModifier}, + {Qt::Key_9, XKB_KEY_KP_9, Qt::KeypadModifier}}; void XkbTest::testToQtKey_data() { diff --git a/autotests/testutils.h b/autotests/testutils.h index 3924e2231f..e9b5e7650a 100644 --- a/autotests/testutils.h +++ b/autotests/testutils.h @@ -13,13 +13,16 @@ // XCB #include -namespace { - static void forceXcb() { - qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("xcb")); - } +namespace +{ +static void forceXcb() +{ + qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("xcb")); +} } -namespace KWin { +namespace KWin +{ /** * Wrapper to create an 0,0x10,10 input only window for testing purposes @@ -28,7 +31,7 @@ namespace KWin { static xcb_window_t createWindow() { xcb_window_t w = xcb_generate_id(connection()); - const uint32_t values[] = { true }; + const uint32_t values[] = {true}; xcb_create_window(connection(), 0, w, rootWindow(), 0, 0, 10, 10, 0, XCB_WINDOW_CLASS_INPUT_ONLY, XCB_COPY_FROM_PARENT, diff --git a/data/update_default_rules.cpp b/data/update_default_rules.cpp index 10e2e2ac0d..eb29b0cef9 100644 --- a/data/update_default_rules.cpp +++ b/data/update_default_rules.cpp @@ -9,50 +9,47 @@ // read additional window rules and add them to kwinrulesrc +#include +#include +#include #include #include -#include -#include -#include -int main( int argc, char* argv[] ) - { - if( argc != 2 ) +int main(int argc, char *argv[]) +{ + if (argc != 2) return 1; - QCoreApplication::setApplicationName ("kwin_update_default_rules"); + QCoreApplication::setApplicationName("kwin_update_default_rules"); - QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QString( "kwin/default_rules/%1" ).arg(argv[ 1 ] )); - if( file.isEmpty()) - { - qWarning() << "File " << argv[ 1 ] << " not found!" ; + QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QString("kwin/default_rules/%1").arg(argv[1])); + if (file.isEmpty()) { + qWarning() << "File " << argv[1] << " not found!"; return 1; - } - KConfig src_cfg( file ); + } + KConfig src_cfg(file); KConfig dest_cfg("kwinrulesrc", KConfig::NoGlobals); - KConfigGroup scg(&src_cfg, "General"); - KConfigGroup dcg(&dest_cfg, "General"); - int count = scg.readEntry( "count", 0 ); - int pos = dcg.readEntry( "count", 0 ); - for( int group = 1; + KConfigGroup scg(&src_cfg, "General"); + KConfigGroup dcg(&dest_cfg, "General"); + int count = scg.readEntry("count", 0); + int pos = dcg.readEntry("count", 0); + for (int group = 1; group <= count; - ++group ) - { - QMap< QString, QString > entries = src_cfg.entryMap( QString::number( group )); + ++group) { + QMap entries = src_cfg.entryMap(QString::number(group)); ++pos; - dest_cfg.deleteGroup( QString::number( pos )); - KConfigGroup dcg2 (&dest_cfg, QString::number( pos )); - for( QMap< QString, QString >::ConstIterator it = entries.constBegin(); + dest_cfg.deleteGroup(QString::number(pos)); + KConfigGroup dcg2(&dest_cfg, QString::number(pos)); + for (QMap::ConstIterator it = entries.constBegin(); it != entries.constEnd(); - ++it ) - dcg2.writeEntry( it.key(), *it ); - } - dcg.writeEntry( "count", pos ); + ++it) + dcg2.writeEntry(it.key(), *it); + } + dcg.writeEntry("count", pos); scg.sync(); dcg.sync(); // Send signal to all kwin instances QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); QDBusConnection::sessionBus().send(message); - - } +} diff --git a/src/abstract_client.cpp b/src/abstract_client.cpp index 2000152e99..e933ab9f43 100644 --- a/src/abstract_client.cpp +++ b/src/abstract_client.cpp @@ -16,8 +16,8 @@ #endif #include "appmenu.h" #include "decorations/decoratedclient.h" -#include "decorations/decorationpalette.h" #include "decorations/decorationbridge.h" +#include "decorations/decorationpalette.h" #include "focuschain.h" #include "outline.h" #include "platform.h" @@ -31,8 +31,8 @@ #include "workspace.h" #include "wayland_server.h" -#include #include +#include #include #include @@ -61,9 +61,9 @@ AbstractClient::AbstractClient() #endif , m_colorScheme(QStringLiteral("kdeglobals")) { - connect(this, &AbstractClient::clientStartUserMovedResized, this, &AbstractClient::moveResizedChanged); + connect(this, &AbstractClient::clientStartUserMovedResized, this, &AbstractClient::moveResizedChanged); connect(this, &AbstractClient::clientFinishUserMovedResized, this, &AbstractClient::moveResizedChanged); - connect(this, &AbstractClient::clientStartUserMovedResized, this, &AbstractClient::removeCheckOutputConnection); + connect(this, &AbstractClient::clientStartUserMovedResized, this, &AbstractClient::removeCheckOutputConnection); connect(this, &AbstractClient::clientFinishUserMovedResized, this, &AbstractClient::setupCheckOutputConnection); connect(this, &AbstractClient::windowShown, this, &AbstractClient::hiddenChanged); @@ -72,26 +72,24 @@ AbstractClient::AbstractClient() connect(this, &AbstractClient::paletteChanged, this, &AbstractClient::triggerDecorationRepaint); // If the user manually moved the window, don't restore it after the keyboard closes - connect(this, &AbstractClient::clientFinishUserMovedResized, this, [this] () { + connect(this, &AbstractClient::clientFinishUserMovedResized, this, [this]() { m_keyboardGeometryRestore = QRect(); }); - connect(this, qOverload(&AbstractClient::clientMaximizedStateChanged), this, [this] () { + connect(this, qOverload(&AbstractClient::clientMaximizedStateChanged), this, [this]() { m_keyboardGeometryRestore = QRect(); }); - connect(this, &AbstractClient::fullScreenChanged, this, [this] () { + connect(this, &AbstractClient::fullScreenChanged, this, [this]() { m_keyboardGeometryRestore = QRect(); }); // replace on-screen-display on size changes - connect(this, &AbstractClient::frameGeometryChanged, this, - [this] (Toplevel *c, const QRect &old) { - Q_UNUSED(c) - if (isOnScreenDisplay() && !frameGeometry().isEmpty() && old.size() != frameGeometry().size() && isPlaceable()) { - GeometryUpdatesBlocker blocker(this); - Placement::self()->place(this, workspace()->clientArea(PlacementArea, this, workspace()->activeOutput())); - } + connect(this, &AbstractClient::frameGeometryChanged, this, [this](Toplevel *c, const QRect &old) { + Q_UNUSED(c) + if (isOnScreenDisplay() && !frameGeometry().isEmpty() && old.size() != frameGeometry().size() && isPlaceable()) { + GeometryUpdatesBlocker blocker(this); + Placement::self()->place(this, workspace()->clientArea(PlacementArea, this, workspace()->activeOutput())); } - ); + }); connect(ApplicationMenu::self(), &ApplicationMenu::applicationMenuEnabledChanged, this, [this] { Q_EMIT hasApplicationMenuChanged(hasApplicationMenu()); @@ -176,12 +174,10 @@ void AbstractClient::setOriginalSkipTaskbar(bool b) void AbstractClient::doSetSkipTaskbar() { - } void AbstractClient::doSetSkipSwitcher() { - } void AbstractClient::setIcon(const QIcon &icon) @@ -200,8 +196,8 @@ void AbstractClient::setActive(bool act) } m_active = act; const int ruledOpacity = m_active - ? rules()->checkOpacityActive(qRound(opacity() * 100.0)) - : rules()->checkOpacityInactive(qRound(opacity() * 100.0)); + ? rules()->checkOpacityActive(qRound(opacity() * 100.0)) + : rules()->checkOpacityInactive(qRound(opacity() * 100.0)); setOpacity(ruledOpacity / 100.0); workspace()->setActiveClient(act ? this : nullptr); @@ -214,10 +210,8 @@ void AbstractClient::setActive(bool act) StackingUpdatesBlocker blocker(workspace()); updateLayer(); // active windows may get different layer auto mainclients = mainClients(); - for (auto it = mainclients.constBegin(); - it != mainclients.constEnd(); - ++it) - if ((*it)->isFullScreen()) // fullscreens go high even if their transient is active + for (auto it = mainclients.constBegin(); it != mainclients.constEnd(); ++it) + if ((*it)->isFullScreen()) // fullscreens go high even if their transient is active (*it)->updateLayer(); doSetActive(); @@ -243,7 +237,7 @@ void AbstractClient::markAsZombie() Layer AbstractClient::layer() const { if (m_layer == UnknownLayer) - const_cast< AbstractClient* >(this)->m_layer = belongsToLayer(); + const_cast(this)->m_layer = belongsToLayer(); return m_layer; } @@ -253,8 +247,7 @@ void AbstractClient::updateLayer() return; StackingUpdatesBlocker blocker(workspace()); invalidateLayer(); // invalidate, will be updated when doing restacking - for (auto it = transients().constBegin(), - end = transients().constEnd(); it != end; ++it) + for (auto it = transients().constBegin(), end = transients().constEnd(); it != end; ++it) (*it)->updateLayer(); } @@ -278,7 +271,7 @@ Layer AbstractClient::belongsToLayer() const return UnmanagedLayer; if (isDesktop()) return workspace()->showingDesktop() ? AboveLayer : DesktopLayer; - if (isSplash()) // no damn annoying splashscreens + if (isSplash()) // no damn annoying splashscreens return NormalLayer; // getting in the way of everything else if (isDock()) { if (workspace()->showingDesktop()) @@ -420,21 +413,21 @@ void AbstractClient::doSetDemandsAttention() void AbstractClient::setDesktop(int desktop) { const int numberOfDesktops = VirtualDesktopManager::self()->count(); - if (desktop != NET::OnAllDesktops) // Do range check + if (desktop != NET::OnAllDesktops) // Do range check desktop = qMax(1, qMin(numberOfDesktops, desktop)); QVector desktops; if (desktop != NET::OnAllDesktops) { - desktops << VirtualDesktopManager::self()->desktopForX11Id(desktop); + desktops << VirtualDesktopManager::self()->desktopForX11Id(desktop); } setDesktops(desktops); } -void AbstractClient::setDesktops(QVector desktops) +void AbstractClient::setDesktops(QVector desktops) { - //on x11 we can have only one desktop at a time + // on x11 we can have only one desktop at a time if (kwinApp()->operationMode() == Application::OperationModeX11 && desktops.size() > 1) { - desktops = QVector({desktops.last()}); + desktops = QVector({desktops.last()}); } desktops = rules()->checkDesktops(desktops); @@ -453,14 +446,14 @@ void AbstractClient::setDesktops(QVector desktops) } else { windowManagementInterface()->setOnAllDesktops(false); auto currentDesktops = windowManagementInterface()->plasmaVirtualDesktops(); - for (auto desktop: qAsConst(m_desktops)) { + for (auto desktop : qAsConst(m_desktops)) { if (!currentDesktops.contains(desktop->id())) { windowManagementInterface()->addPlasmaVirtualDesktop(desktop->id()); } else { currentDesktops.removeOne(desktop->id()); } } - for (const auto &desktopId: qAsConst(currentDesktops)) { + for (const auto &desktopId : qAsConst(currentDesktops)) { windowManagementInterface()->removePlasmaVirtualDesktop(desktopId); } } @@ -475,14 +468,12 @@ void AbstractClient::setDesktops(QVector desktops) } auto transients_stacking_order = workspace()->ensureStackingOrder(transients()); - for (auto it = transients_stacking_order.constBegin(); - it != transients_stacking_order.constEnd(); - ++it) + for (auto it = transients_stacking_order.constBegin(); it != transients_stacking_order.constEnd(); ++it) (*it)->setDesktops(desktops); - if (isModal()) // if a modal dialog is moved, move the mainwindow with it as otherwise - // the (just moved) modal dialog will confusingly return to the mainwindow with - // the next desktop change + if (isModal()) // if a modal dialog is moved, move the mainwindow with it as otherwise + // the (just moved) modal dialog will confusingly return to the mainwindow with + // the next desktop change { const auto clients = mainClients(); for (AbstractClient *c2 : clients) { @@ -524,7 +515,7 @@ void AbstractClient::enterDesktop(VirtualDesktop *virtualDesktop) void AbstractClient::leaveDesktop(VirtualDesktop *virtualDesktop) { - QVector currentDesktops; + QVector currentDesktops; if (m_desktops.isEmpty()) { currentDesktops = VirtualDesktopManager::self()->desktops(); } else { @@ -562,11 +553,10 @@ QVector AbstractClient::x11DesktopIds() const QVector x11Ids; x11Ids.reserve(desks.count()); std::transform(desks.constBegin(), desks.constEnd(), - std::back_inserter(x11Ids), - [] (const VirtualDesktop *vd) { - return vd->x11DesktopNumber(); - } - ); + std::back_inserter(x11Ids), + [](const VirtualDesktop *vd) { + return vd->x11DesktopNumber(); + }); return x11Ids; } @@ -577,10 +567,9 @@ QStringList AbstractClient::desktopIds() const ids.reserve(desks.count()); std::transform(desks.constBegin(), desks.constEnd(), std::back_inserter(ids), - [] (const VirtualDesktop *vd) { + [](const VirtualDesktop *vd) { return vd->id(); - } - ); + }); return ids; }; @@ -997,7 +986,7 @@ bool AbstractClient::startInteractiveMoveResize() checkUnrestrictedInteractiveMoveResize(); Q_EMIT clientStartUserMovedResized(this); if (ScreenEdges::self()->isDesktopSwitchingMovingClients()) - ScreenEdges::self()->reserveDesktopSwitching(true, Qt::Vertical|Qt::Horizontal); + ScreenEdges::self()->reserveDesktopSwitching(true, Qt::Vertical | Qt::Horizontal); return true; } @@ -1056,7 +1045,7 @@ void AbstractClient::checkUnrestrictedInteractiveMoveResize() setUnrestrictedInteractiveMoveResize(true); if (moveResizeGeom.left() > desktopArea.right() - right_marge) setUnrestrictedInteractiveMoveResize(true); - if (!isUnrestrictedInteractiveMoveResize() && moveResizeGeom.top() < desktopArea.top()) // titlebar mustn't go out + if (!isUnrestrictedInteractiveMoveResize() && moveResizeGeom.top() < desktopArea.top()) // titlebar mustn't go out setUnrestrictedInteractiveMoveResize(true); } if (isInteractiveMove()) { @@ -1080,16 +1069,14 @@ void AbstractClient::startDelayedInteractiveMoveResize() Q_ASSERT(!m_interactiveMoveResize.delayedTimer); m_interactiveMoveResize.delayedTimer = new QTimer(this); m_interactiveMoveResize.delayedTimer->setSingleShot(true); - connect(m_interactiveMoveResize.delayedTimer, &QTimer::timeout, this, - [this]() { - Q_ASSERT(isInteractiveMoveResizePointerButtonDown()); - if (!startInteractiveMoveResize()) { - setInteractiveMoveResizePointerButtonDown(false); - } - updateCursor(); - stopDelayedInteractiveMoveResize(); + connect(m_interactiveMoveResize.delayedTimer, &QTimer::timeout, this, [this]() { + Q_ASSERT(isInteractiveMoveResizePointerButtonDown()); + if (!startInteractiveMoveResize()) { + setInteractiveMoveResizePointerButtonDown(false); } - ); + updateCursor(); + stopDelayedInteractiveMoveResize(); + }); m_interactiveMoveResize.delayedTimer->start(QApplication::startDragTime()); } @@ -1114,7 +1101,7 @@ void AbstractClient::handleInteractiveMoveResize(const QPoint &local, const QPoi setQuickTileMode(QuickTileFlag::None); const QRect &geom_restore = geometryRestore(); setInteractiveMoveOffset(QPoint(double(interactiveMoveOffset().x()) / double(oldGeo.width()) * double(geom_restore.width()), - double(interactiveMoveOffset().y()) / double(oldGeo.height()) * double(geom_restore.height()))); + double(interactiveMoveOffset().y()) / double(oldGeo.height()) * double(geom_restore.height()))); if (rules()->checkMaximize(MaximizeRestore) == MaximizeRestore) setMoveResizeGeometry(geom_restore); handleInteractiveMoveResize(local.x(), local.y(), global.x(), global.y()); // fix position @@ -1131,12 +1118,12 @@ void AbstractClient::handleInteractiveMoveResize(int x, int y, int x_root, int y const Gravity gravity = interactiveMoveResizeGravity(); if ((gravity == Gravity::None && !isMovableAcrossScreens()) - || (gravity != Gravity::None && (isShade() || !isResizable()))) { + || (gravity != Gravity::None && (isShade() || !isResizable()))) { return; } if (!isInteractiveMoveResize()) { - QPoint p(QPoint(x/* - padding_left*/, y/* - padding_top*/) - interactiveMoveOffset()); + QPoint p(QPoint(x /* - padding_left*/, y /* - padding_top*/) - interactiveMoveOffset()); if (p.manhattanLength() >= QApplication::startDragDistance()) { if (!startInteractiveMoveResize()) { setInteractiveMoveResizePointerButtonDown(false); @@ -1165,7 +1152,7 @@ void AbstractClient::handleInteractiveMoveResize(int x, int y, int x_root, int y auto titleBarRect = [this](bool &transposed, int &requiredPixels) -> QRect { const QRect &moveResizeGeom = moveResizeGeometry(); QRect r(moveResizeGeom); - r.moveTopLeft(QPoint(0,0)); + r.moveTopLeft(QPoint(0, 0)); switch (titlebarPosition()) { default: case Qt::TopEdge: @@ -1281,10 +1268,10 @@ void AbstractClient::handleInteractiveMoveResize(int x, int y, int x_root, int y // precedence. The opposing edge has no impact on visiblePixels and only one of // the adjacent can alter at a time, ie. it's enough to ignore adjacent edges // if the title edge altered - bool leftChanged = previousMoveResizeGeom.left() != moveResizeGeom.left(); - bool rightChanged = previousMoveResizeGeom.right() != moveResizeGeom.right(); - bool topChanged = previousMoveResizeGeom.top() != moveResizeGeom.top(); - bool btmChanged = previousMoveResizeGeom.bottom() != moveResizeGeom.bottom(); + bool leftChanged = previousMoveResizeGeom.left() != moveResizeGeom.left(); + bool rightChanged = previousMoveResizeGeom.right() != moveResizeGeom.right(); + bool topChanged = previousMoveResizeGeom.top() != moveResizeGeom.top(); + bool btmChanged = previousMoveResizeGeom.bottom() != moveResizeGeom.bottom(); auto fixChangedState = [titleFailed](bool &major, bool &counter, bool &ad1, bool &ad2) { counter = false; if (titleFailed) @@ -1362,13 +1349,13 @@ void AbstractClient::handleInteractiveMoveResize(int x, int y, int x_root, int y QRect moveResizeGeom = moveResizeGeometry(); moveResizeGeom.moveTopLeft(topleft); moveResizeGeom.moveTopLeft(workspace()->adjustClientPosition(this, moveResizeGeom.topLeft(), - isUnrestrictedInteractiveMoveResize())); + isUnrestrictedInteractiveMoveResize())); setMoveResizeGeometry(moveResizeGeom); if (!isUnrestrictedInteractiveMoveResize()) { const QRegion strut = workspace()->restrictedMoveArea(VirtualDesktopManager::self()->currentDesktop()); QRegion availableArea(workspace()->clientArea(FullArea, this, workspace()->activeOutput())); - availableArea -= strut; // Strut areas + availableArea -= strut; // Strut areas bool transposed = false; int requiredPixels; QRect bTitleRect = titleBarRect(transposed, requiredPixels); @@ -1510,141 +1497,115 @@ void AbstractClient::setupWindowManagementInterface() w->setVirtualDesktopChangeable(true); // FIXME Matches X11Client::actionSupported(), but both should be implemented. w->setParentWindow(transientFor() ? transientFor()->windowManagementInterface() : nullptr); w->setGeometry(frameGeometry()); - connect(this, &AbstractClient::skipTaskbarChanged, w, - [w, this] { - w->setSkipTaskbar(skipTaskbar()); - } - ); - connect(this, &AbstractClient::skipSwitcherChanged, w, - [w, this] { - w->setSkipSwitcher(skipSwitcher()); - } - ); - connect(this, &AbstractClient::captionChanged, w, [w, this] { w->setTitle(caption()); }); + connect(this, &AbstractClient::skipTaskbarChanged, w, [w, this]() { + w->setSkipTaskbar(skipTaskbar()); + }); + connect(this, &AbstractClient::skipSwitcherChanged, w, [w, this]() { + w->setSkipSwitcher(skipSwitcher()); + }); + connect(this, &AbstractClient::captionChanged, w, [w, this] { + w->setTitle(caption()); + }); - connect(this, &AbstractClient::activeChanged, w, [w, this] { w->setActive(isActive()); }); - connect(this, &AbstractClient::fullScreenChanged, w, [w, this] { w->setFullscreen(isFullScreen()); }); + connect(this, &AbstractClient::activeChanged, w, [w, this] { + w->setActive(isActive()); + }); + connect(this, &AbstractClient::fullScreenChanged, w, [w, this] { + w->setFullscreen(isFullScreen()); + }); connect(this, &AbstractClient::keepAboveChanged, w, &PlasmaWindowInterface::setKeepAbove); connect(this, &AbstractClient::keepBelowChanged, w, &PlasmaWindowInterface::setKeepBelow); - connect(this, &AbstractClient::minimizedChanged, w, [w, this] { w->setMinimized(isMinimized()); }); - connect(this, static_cast(&AbstractClient::clientMaximizedStateChanged), w, - [w] (KWin::AbstractClient *c, MaximizeMode mode) { - Q_UNUSED(c); - w->setMaximized(mode == KWin::MaximizeFull); - } - ); - connect(this, &AbstractClient::demandsAttentionChanged, w, [w, this] { w->setDemandsAttention(isDemandingAttention()); }); - connect(this, &AbstractClient::iconChanged, w, - [w, this] { - w->setIcon(icon()); - } - ); + connect(this, &AbstractClient::minimizedChanged, w, [w, this] { + w->setMinimized(isMinimized()); + }); + connect(this, static_cast(&AbstractClient::clientMaximizedStateChanged), w, [w](KWin::AbstractClient *c, MaximizeMode mode) { + Q_UNUSED(c); + w->setMaximized(mode == KWin::MaximizeFull); + }); + connect(this, &AbstractClient::demandsAttentionChanged, w, [w, this] { + w->setDemandsAttention(isDemandingAttention()); + }); + connect(this, &AbstractClient::iconChanged, w, [w, this]() { + w->setIcon(icon()); + }); connect(this, &AbstractClient::windowClassChanged, w, updateAppId); connect(this, &AbstractClient::desktopFileNameChanged, w, updateAppId); - connect(this, &AbstractClient::shadeChanged, w, [w, this] { w->setShaded(isShade()); }); - connect(this, &AbstractClient::transientChanged, w, - [w, this] { - w->setParentWindow(transientFor() ? transientFor()->windowManagementInterface() : nullptr); + connect(this, &AbstractClient::shadeChanged, w, [w, this] { + w->setShaded(isShade()); + }); + connect(this, &AbstractClient::transientChanged, w, [w, this]() { + w->setParentWindow(transientFor() ? transientFor()->windowManagementInterface() : nullptr); + }); + connect(this, &AbstractClient::frameGeometryChanged, w, [w, this]() { + w->setGeometry(frameGeometry()); + }); + connect(this, &AbstractClient::applicationMenuChanged, w, [w, this]() { + w->setApplicationMenuPaths(applicationMenuServiceName(), applicationMenuObjectPath()); + }); + connect(w, &PlasmaWindowInterface::closeRequested, this, [this] { + closeWindow(); + }); + connect(w, &PlasmaWindowInterface::moveRequested, this, [this]() { + Cursors::self()->mouse()->setPos(frameGeometry().center()); + performMouseCommand(Options::MouseMove, Cursors::self()->mouse()->pos()); + }); + connect(w, &PlasmaWindowInterface::resizeRequested, this, [this]() { + Cursors::self()->mouse()->setPos(frameGeometry().bottomRight()); + performMouseCommand(Options::MouseResize, Cursors::self()->mouse()->pos()); + }); + connect(w, &PlasmaWindowInterface::fullscreenRequested, this, [this](bool set) { + setFullScreen(set, false); + }); + connect(w, &PlasmaWindowInterface::minimizedRequested, this, [this](bool set) { + if (set) { + minimize(); + } else { + unminimize(); } - ); - connect(this, &AbstractClient::frameGeometryChanged, w, - [w, this] { - w->setGeometry(frameGeometry()); + }); + connect(w, &PlasmaWindowInterface::maximizedRequested, this, [this](bool set) { + maximize(set ? MaximizeFull : MaximizeRestore); + }); + connect(w, &PlasmaWindowInterface::keepAboveRequested, this, [this](bool set) { + setKeepAbove(set); + }); + connect(w, &PlasmaWindowInterface::keepBelowRequested, this, [this](bool set) { + setKeepBelow(set); + }); + connect(w, &PlasmaWindowInterface::demandsAttentionRequested, this, [this](bool set) { + demandAttention(set); + }); + connect(w, &PlasmaWindowInterface::activeRequested, this, [this](bool set) { + if (set) { + workspace()->activateClient(this, true); } - ); - connect(this, &AbstractClient::applicationMenuChanged, w, - [w, this] { - w->setApplicationMenuPaths(applicationMenuServiceName(), applicationMenuObjectPath()); - } - ); - connect(w, &PlasmaWindowInterface::closeRequested, this, [this] { closeWindow(); }); - connect(w, &PlasmaWindowInterface::moveRequested, this, - [this] { - Cursors::self()->mouse()->setPos(frameGeometry().center()); - performMouseCommand(Options::MouseMove, Cursors::self()->mouse()->pos()); - } - ); - connect(w, &PlasmaWindowInterface::resizeRequested, this, - [this] { - Cursors::self()->mouse()->setPos(frameGeometry().bottomRight()); - performMouseCommand(Options::MouseResize, Cursors::self()->mouse()->pos()); - } - ); - connect(w, &PlasmaWindowInterface::fullscreenRequested, this, - [this] (bool set) { - setFullScreen(set, false); - } - ); - connect(w, &PlasmaWindowInterface::minimizedRequested, this, - [this] (bool set) { - if (set) { - minimize(); - } else { - unminimize(); - } - } - ); - connect(w, &PlasmaWindowInterface::maximizedRequested, this, - [this] (bool set) { - maximize(set ? MaximizeFull : MaximizeRestore); - } - ); - connect(w, &PlasmaWindowInterface::keepAboveRequested, this, - [this] (bool set) { - setKeepAbove(set); - } - ); - connect(w, &PlasmaWindowInterface::keepBelowRequested, this, - [this] (bool set) { - setKeepBelow(set); - } - ); - connect(w, &PlasmaWindowInterface::demandsAttentionRequested, this, - [this] (bool set) { - demandAttention(set); - } - ); - connect(w, &PlasmaWindowInterface::activeRequested, this, - [this] (bool set) { - if (set) { - workspace()->activateClient(this, true); - } - } - ); - connect(w, &PlasmaWindowInterface::shadedRequested, this, - [this] (bool set) { - setShade(set); - } - ); + }); + connect(w, &PlasmaWindowInterface::shadedRequested, this, [this](bool set) { + setShade(set); + }); for (const auto vd : qAsConst(m_desktops)) { w->addPlasmaVirtualDesktop(vd->id()); } - //Plasma Virtual desktop management - //show/hide when the window enters/exits from desktop - connect(w, &PlasmaWindowInterface::enterPlasmaVirtualDesktopRequested, this, - [this] (const QString &desktopId) { - VirtualDesktop *vd = VirtualDesktopManager::self()->desktopForId(desktopId); - if (vd) { - enterDesktop(vd); - } + // Plasma Virtual desktop management + // show/hide when the window enters/exits from desktop + connect(w, &PlasmaWindowInterface::enterPlasmaVirtualDesktopRequested, this, [this](const QString &desktopId) { + VirtualDesktop *vd = VirtualDesktopManager::self()->desktopForId(desktopId); + if (vd) { + enterDesktop(vd); } - ); - connect(w, &PlasmaWindowInterface::enterNewPlasmaVirtualDesktopRequested, this, - [this] () { - VirtualDesktopManager::self()->setCount(VirtualDesktopManager::self()->count() + 1); - enterDesktop(VirtualDesktopManager::self()->desktops().last()); + }); + connect(w, &PlasmaWindowInterface::enterNewPlasmaVirtualDesktopRequested, this, [this]() { + VirtualDesktopManager::self()->setCount(VirtualDesktopManager::self()->count() + 1); + enterDesktop(VirtualDesktopManager::self()->desktops().last()); + }); + connect(w, &PlasmaWindowInterface::leavePlasmaVirtualDesktopRequested, this, [this](const QString &desktopId) { + VirtualDesktop *vd = VirtualDesktopManager::self()->desktopForId(desktopId); + if (vd) { + leaveDesktop(vd); } - ); - connect(w, &PlasmaWindowInterface::leavePlasmaVirtualDesktopRequested, this, - [this] (const QString &desktopId) { - VirtualDesktop *vd = VirtualDesktopManager::self()->desktopForId(desktopId); - if (vd) { - leaveDesktop(vd); - } - } - ); + }); for (const auto &activity : qAsConst(m_activityList)) { w->addPlasmaActivity(activity); @@ -1667,23 +1628,17 @@ void AbstractClient::setupWindowManagementInterface() } }); - //Plasma Activities management - //show/hide when the window enters/exits activity - connect(w, &PlasmaWindowInterface::enterPlasmaActivityRequested, this, - [this] (const QString &activityId) { - setOnActivity(activityId, true); - } - ); - connect(w, &PlasmaWindowInterface::leavePlasmaActivityRequested, this, - [this] (const QString &activityId) { - setOnActivity(activityId, false); - } - ); - connect(w, &PlasmaWindowInterface::sendToOutput, this, - [this] (KWaylandServer::OutputInterface *output) { - sendToOutput(waylandServer()->findOutput(output)); - } - ); + // Plasma Activities management + // show/hide when the window enters/exits activity + connect(w, &PlasmaWindowInterface::enterPlasmaActivityRequested, this, [this](const QString &activityId) { + setOnActivity(activityId, true); + }); + connect(w, &PlasmaWindowInterface::leavePlasmaActivityRequested, this, [this](const QString &activityId) { + setOnActivity(activityId, false); + }); + connect(w, &PlasmaWindowInterface::sendToOutput, this, [this](KWaylandServer::OutputInterface *output) { + sendToOutput(waylandServer()->findOutput(output)); + }); m_windowManagementInterface = w; } @@ -1732,7 +1687,7 @@ Options::MouseCommand AbstractClient::getWheelCommand(Qt::Orientation orientatio bool AbstractClient::performMouseCommand(Options::MouseCommand cmd, const QPoint &globalPos) { bool replay = false; - switch(cmd) { + switch (cmd) { case Options::MouseRaise: workspace()->raiseClient(this); break; @@ -1760,9 +1715,9 @@ bool AbstractClient::performMouseCommand(Options::MouseCommand cmd, const QPoint bool mustReplay = !rules()->checkAcceptFocus(acceptsFocus()); if (mustReplay) { auto it = workspace()->stackingOrder().constEnd(), - begin = workspace()->stackingOrder().constBegin(); + begin = workspace()->stackingOrder().constBegin(); while (mustReplay && --it != begin && *it != this) { - AbstractClient *c = qobject_cast(*it); + AbstractClient *c = qobject_cast(*it); if (!c || (c->keepAbove() && !keepAbove()) || (keepBelow() && !c->keepBelow())) continue; // can never raise above "it" mustReplay = !(c->isOnCurrentDesktop() && c->isOnCurrentActivity() && c->frameGeometry().intersects(frameGeometry())); @@ -1827,11 +1782,11 @@ bool AbstractClient::performMouseCommand(Options::MouseCommand cmd, const QPoint workspace()->windowToNextDesktop(this); break; case Options::MouseOpacityMore: - if (!isDesktop()) // No point in changing the opacity of the desktop + if (!isDesktop()) // No point in changing the opacity of the desktop setOpacity(qMin(opacity() + 0.1, 1.0)); break; case Options::MouseOpacityLess: - if (!isDesktop()) // No point in changing the opacity of the desktop + if (!isDesktop()) // No point in changing the opacity of the desktop setOpacity(qMax(opacity() - 0.1, 0.1)); break; case Options::MouseClose: @@ -1851,10 +1806,10 @@ bool AbstractClient::performMouseCommand(Options::MouseCommand cmd, const QPoint finishInteractiveMoveResize(false); setInteractiveMoveResizeGravity(Gravity::None); setInteractiveMoveResizePointerButtonDown(true); - setInteractiveMoveOffset(QPoint(globalPos.x() - x(), globalPos.y() - y())); // map from global + setInteractiveMoveOffset(QPoint(globalPos.x() - x(), globalPos.y() - y())); // map from global setInvertedInteractiveMoveOffset(rect().bottomRight() - interactiveMoveOffset()); setUnrestrictedInteractiveMoveResize((cmd == Options::MouseActivateRaiseAndUnrestrictedMove - || cmd == Options::MouseUnrestrictedMove)); + || cmd == Options::MouseUnrestrictedMove)); if (!startInteractiveMoveResize()) setInteractiveMoveResizePointerButtonDown(false); updateCursor(); @@ -1867,7 +1822,7 @@ bool AbstractClient::performMouseCommand(Options::MouseCommand cmd, const QPoint if (isInteractiveMoveResize()) finishInteractiveMoveResize(false); setInteractiveMoveResizePointerButtonDown(true); - const QPoint moveOffset = QPoint(globalPos.x() - x(), globalPos.y() - y()); // map from global + const QPoint moveOffset = QPoint(globalPos.x() - x(), globalPos.y() - y()); // map from global setInteractiveMoveOffset(moveOffset); int x = moveOffset.x(), y = moveOffset.y(); bool left = x < width() / 3; @@ -1951,15 +1906,15 @@ bool AbstractClient::hasTransient(const AbstractClient *c, bool indirect) const return c->transientFor() == this; } -QList< AbstractClient* > AbstractClient::mainClients() const +QList AbstractClient::mainClients() const { if (const AbstractClient *t = transientFor()) { - return QList{const_cast< AbstractClient* >(t)}; + return QList{const_cast(t)}; } - return QList(); + return QList(); } -QList AbstractClient::allMainClients() const +QList AbstractClient::allMainClients() const { auto result = mainClients(); for (const auto *cl : result) { @@ -2041,12 +1996,12 @@ bool AbstractClient::isActiveFullScreen() const // according to NETWM spec implementation notes suggests // "focused windows having state _NET_WM_STATE_FULLSCREEN" to be on the highest layer. // we'll also take the screen into account - return ac && (ac == this || !ac->isOnOutput(output()) || ac->allMainClients().contains(const_cast(this))); + return ac && (ac == this || !ac->isOnOutput(output()) || ac->allMainClients().contains(const_cast(this))); } -#define BORDER(which) \ - int AbstractClient::border##which() const \ - { \ +#define BORDER(which) \ + int AbstractClient::border##which() const \ + { \ return isDecorated() ? decoration()->border##which() : 0; \ } @@ -2111,7 +2066,7 @@ void AbstractClient::leaveInteractiveMoveResize() workspace()->setMoveResizeClient(nullptr); setInteractiveMoveResize(false); if (ScreenEdges::self()->isDesktopSwitchingMovingClients()) - ScreenEdges::self()->reserveDesktopSwitching(false, Qt::Vertical|Qt::Horizontal); + ScreenEdges::self()->reserveDesktopSwitching(false, Qt::Vertical | Qt::Horizontal); if (isElectricBorderMaximizing()) { outline()->hide(); elevate(false); @@ -2173,7 +2128,7 @@ void AbstractClient::checkQuickTilingMaximizationZones(int xroot, int yroot) if (mode != QuickTileMode(QuickTileFlag::None)) { if (yroot <= area.y() + area.height() * options->electricBorderCornerRatio()) mode |= QuickTileFlag::Top; - else if (yroot >= area.y() + area.height() - area.height() * options->electricBorderCornerRatio()) + else if (yroot >= area.y() + area.height() - area.height() * options->electricBorderCornerRatio()) mode |= QuickTileFlag::Bottom; } else if (options->electricBorderMaximize() && yroot <= area.y() + 5 && isMaximizable()) { mode = QuickTileFlag::Maximize; @@ -2207,9 +2162,10 @@ void AbstractClient::keyPressEvent(uint key_code) bool is_control = key_code & Qt::CTRL; bool is_alt = key_code & Qt::ALT; key_code = key_code & ~Qt::KeyboardModifierMask; - int delta = is_control ? 1 : is_alt ? 32 : 8; + int delta = is_control ? 1 : is_alt ? 32 + : 8; QPoint pos = Cursors::self()->mouse()->pos(); - switch(key_code) { + switch (key_code) { case Qt::Key_Left: pos.rx() -= delta; break; @@ -2257,24 +2213,24 @@ Gravity AbstractClient::mouseGravity() const { if (isDecorated()) { switch (decoration()->sectionUnderMouse()) { - case Qt::BottomLeftSection: - return Gravity::BottomLeft; - case Qt::BottomRightSection: - return Gravity::BottomRight; - case Qt::BottomSection: - return Gravity::Bottom; - case Qt::LeftSection: - return Gravity::Left; - case Qt::RightSection: - return Gravity::Right; - case Qt::TopSection: - return Gravity::Top; - case Qt::TopLeftSection: - return Gravity::TopLeft; - case Qt::TopRightSection: - return Gravity::TopRight; - default: - return Gravity::None; + case Qt::BottomLeftSection: + return Gravity::BottomLeft; + case Qt::BottomRightSection: + return Gravity::BottomRight; + case Qt::BottomSection: + return Gravity::Bottom; + case Qt::LeftSection: + return Gravity::Left; + case Qt::RightSection: + return Gravity::Right; + case Qt::TopSection: + return Gravity::Top; + case Qt::TopLeftSection: + return Gravity::TopLeft; + case Qt::TopRightSection: + return Gravity::TopRight; + default: + return Gravity::None; } } return Gravity::None; @@ -2385,7 +2341,7 @@ bool AbstractClient::processDecorationButtonPress(QMouseEvent *event, bool ignor { Options::MouseCommand com = Options::MouseNothing; bool active = isActive(); - if (!wantsInput()) // we cannot be active, use it anyway + if (!wantsInput()) // we cannot be active, use it anyway active = true; // check whether it is a double click @@ -2400,8 +2356,7 @@ bool AbstractClient::processDecorationButtonPress(QMouseEvent *event, bool ignor dontInteractiveMoveResize(); return false; } - } - else { + } else { m_decoration.doubleClickTimer.start(); // new first click and pot. init, could be invalidated by release - see below } } @@ -2413,8 +2368,8 @@ bool AbstractClient::processDecorationButtonPress(QMouseEvent *event, bool ignor else if (event->button() == Qt::RightButton) com = active ? options->commandActiveTitlebar3() : options->commandInactiveTitlebar3(); if (event->button() == Qt::LeftButton - && com != Options::MouseOperationsMenu // actions where it's not possible to get the matching - && com != Options::MouseMinimize) // mouse release event + && com != Options::MouseOperationsMenu // actions where it's not possible to get the matching + && com != Options::MouseMinimize) // mouse release event { setInteractiveMoveResizeGravity(mouseGravity()); setInteractiveMoveResizePointerButtonDown(true); @@ -2429,13 +2384,7 @@ bool AbstractClient::processDecorationButtonPress(QMouseEvent *event, bool ignor if (!ignoreMenu || com != Options::MouseOperationsMenu) performMouseCommand(com, event->globalPos()); return !( // Return events that should be passed to the decoration in the new API - com == Options::MouseRaise || - com == Options::MouseOperationsMenu || - com == Options::MouseActivateAndRaise || - com == Options::MouseActivate || - com == Options::MouseActivateRaiseAndPassClick || - com == Options::MouseActivateAndPassClick || - com == Options::MouseNothing); + com == Options::MouseRaise || com == Options::MouseOperationsMenu || com == Options::MouseActivateAndRaise || com == Options::MouseActivate || com == Options::MouseActivateRaiseAndPassClick || com == Options::MouseActivateAndPassClick || com == Options::MouseNothing); } void AbstractClient::processDecorationButtonRelease(QMouseEvent *event) @@ -2457,7 +2406,6 @@ void AbstractClient::processDecorationButtonRelease(QMouseEvent *event) } } - void AbstractClient::startDecorationDoubleClickTimer() { m_decoration.doubleClickTimer.start(); @@ -2482,7 +2430,7 @@ QPointer AbstractClient::decoratedClient() cons return m_decoration.client; } -void AbstractClient::setDecoratedClient(QPointer< Decoration::DecoratedClientImpl > client) +void AbstractClient::setDecoratedClient(QPointer client) { m_decoration.client = client; } @@ -2497,11 +2445,7 @@ void AbstractClient::pointerEnterEvent(const QPoint &globalPos) if (options->focusPolicy() == Options::ClickToFocus || workspace()->userActionsMenu()->isShown()) return; - if (options->isAutoRaise() && !isDesktop() && - !isDock() && workspace()->focusChangeEnabled() && - globalPos != workspace()->focusMousePosition() && - workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop(), - options->isSeparateScreenFocus() ? output() : nullptr) != this) { + if (options->isAutoRaise() && !isDesktop() && !isDock() && workspace()->focusChangeEnabled() && globalPos != workspace()->focusMousePosition() && workspace()->topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop(), options->isSeparateScreenFocus() ? output() : nullptr) != this) { startAutoRaise(); } @@ -2510,7 +2454,7 @@ void AbstractClient::pointerEnterEvent(const QPoint &globalPos) // for FocusFollowsMouse, change focus only if the mouse has actually been moved, not if the focus // change came because of window changes (e.g. closing a window) - #92290 if (options->focusPolicy() != Options::FocusFollowsMouse - || globalPos != workspace()->focusMousePosition()) { + || globalPos != workspace()->focusMousePosition()) { workspace()->requestDelayFocus(this); } } @@ -2588,7 +2532,7 @@ void AbstractClient::setVirtualKeyboardGeometry(const QRect &geo) m_keyboardGeometryRestore = QRect(); } else if (geo.isEmpty()) { return; - // The keyboard has just been opened (rather than resized) save client geometry for a restore + // The keyboard has just been opened (rather than resized) save client geometry for a restore } else if (m_keyboardGeometryRestore.isEmpty()) { m_keyboardGeometryRestore = moveResizeGeometry(); } @@ -2767,7 +2711,7 @@ QString AbstractClient::caption() const return cap; } -void AbstractClient::removeRule(Rules* rule) +void AbstractClient::removeRule(Rules *rule) { m_rules.remove(rule); } @@ -2808,13 +2752,13 @@ void AbstractClient::setOnActivity(const QString &activity, bool enable) } QStringList newActivitiesList = activities(); if (newActivitiesList.contains(activity) == enable) { - //nothing to do + // nothing to do return; } if (enable) { QStringList allActivities = Activities::self()->all(); if (!allActivities.contains(activity)) { - //bogus ID + // bogus ID return; } newActivitiesList.append(activity); @@ -3046,13 +2990,13 @@ QRect AbstractClient::quickTileGeometry(QuickTileMode mode, const QPoint &pos) c QRect ret = workspace()->clientArea(MaximizeArea, this, pos); if (mode & QuickTileFlag::Left) - ret.setRight(ret.left()+ret.width()/2 - 1); + ret.setRight(ret.left() + ret.width() / 2 - 1); else if (mode & QuickTileFlag::Right) - ret.setLeft(ret.right()-(ret.width()-ret.width()/2) + 1); + ret.setLeft(ret.right() - (ret.width() - ret.width() / 2) + 1); if (mode & QuickTileFlag::Top) - ret.setBottom(ret.top()+ret.height()/2 - 1); + ret.setBottom(ret.top() + ret.height() / 2 - 1); else if (mode & QuickTileFlag::Bottom) - ret.setTop(ret.bottom()-(ret.height()-ret.height()/2) + 1); + ret.setTop(ret.bottom() - (ret.height() - ret.height() / 2) + 1); return ret; } @@ -3336,7 +3280,7 @@ void AbstractClient::checkWorkspacePosition(QRect oldGeometry, const VirtualDesk } if (requestedMaximizeMode() != MaximizeRestore) { - changeMaximize(false, false, true); // adjust size + changeMaximize(false, false, true); // adjust size QRect geom = moveResizeGeometry(); const QRect screenArea = workspace()->clientArea(ScreenArea, this, geom.center()); checkOffscreenPosition(&geom, screenArea); @@ -3384,8 +3328,8 @@ void AbstractClient::checkWorkspacePosition(QRect oldGeometry, const VirtualDesk oldScreenArea = workspace()->clientArea(ScreenArea, kwinApp()->platform()->outputAt(oldGeometry.center()), oldDesktop); screenArea = workspace()->clientArea(ScreenArea, this, newGeom.center()); } - const QRect oldGeomTall = QRect(oldGeometry.x(), oldScreenArea.y(), oldGeometry.width(), oldScreenArea.height()); // Full screen height - const QRect oldGeomWide = QRect(oldScreenArea.x(), oldGeometry.y(), oldScreenArea.width(), oldGeometry.height()); // Full screen width + const QRect oldGeomTall = QRect(oldGeometry.x(), oldScreenArea.y(), oldGeometry.width(), oldScreenArea.height()); // Full screen height + const QRect oldGeomWide = QRect(oldScreenArea.x(), oldGeometry.y(), oldScreenArea.width(), oldGeometry.height()); // Full screen width int oldTopMax = oldScreenArea.y(); int oldRightMax = oldScreenArea.x() + oldScreenArea.width(); int oldBottomMax = oldScreenArea.y() + oldScreenArea.height(); @@ -3394,15 +3338,14 @@ void AbstractClient::checkWorkspacePosition(QRect oldGeometry, const VirtualDesk int rightMax = screenArea.x() + screenArea.width(); int bottomMax = screenArea.y() + screenArea.height(); int leftMax = screenArea.x(); - const QRect newGeomTall = QRect(newGeom.x(), screenArea.y(), newGeom.width(), screenArea.height()); // Full screen height - const QRect newGeomWide = QRect(screenArea.x(), newGeom.y(), screenArea.width(), newGeom.height()); // Full screen width + const QRect newGeomTall = QRect(newGeom.x(), screenArea.y(), newGeom.width(), screenArea.height()); // Full screen height + const QRect newGeomWide = QRect(screenArea.x(), newGeom.y(), screenArea.width(), newGeom.height()); // Full screen width // Get the max strut point for each side where the window is (E.g. Highest point for // the bottom struts bounded by the window's left and right sides). // These 4 compute old bounds ... - auto moveAreaFunc = workspace()->inUpdateClientArea() ? - &Workspace::previousRestrictedMoveArea : //... the restricted areas changed - &Workspace::restrictedMoveArea; //... when e.g. active desktop or screen changes + auto moveAreaFunc = workspace()->inUpdateClientArea() ? &Workspace::previousRestrictedMoveArea : //... the restricted areas changed + &Workspace::restrictedMoveArea; //... when e.g. active desktop or screen changes for (const QRect &r : (workspace()->*moveAreaFunc)(oldDesktop, StrutAreaTop)) { QRect rect = r & oldGeomTall; @@ -3447,9 +3390,13 @@ void AbstractClient::checkWorkspacePosition(QRect oldGeometry, const VirtualDesk leftMax = qMax(leftMax, rect.x() + rect.width()); } - // Check if the sides were inside or touching but are no longer - enum { Left = 0, Top, Right, Bottom }; + enum { + Left = 0, + Top, + Right, + Bottom, + }; bool keep[4] = {false, false, false, false}; bool save[4] = {false, false, false, false}; if (oldGeometry.x() >= oldLeftMax) @@ -3472,7 +3419,6 @@ void AbstractClient::checkWorkspacePosition(QRect oldGeometry, const VirtualDesk if (oldGeometry.bottom() == oldBottomMax - 1) keep[Bottom] = newGeom.bottom() != bottomMax - 1; - // if randomly touches opposing edges, do not favor either if (keep[Left] && keep[Right]) { keep[Left] = keep[Right] = false; @@ -3503,17 +3449,17 @@ void AbstractClient::checkWorkspacePosition(QRect oldGeometry, const VirtualDesk moveResize(newGeom); } -void AbstractClient::checkOffscreenPosition(QRect* geom, const QRect& screenArea) +void AbstractClient::checkOffscreenPosition(QRect *geom, const QRect &screenArea) { if (geom->left() > screenArea.right()) { - geom->moveLeft(screenArea.right() - screenArea.width()/4); + geom->moveLeft(screenArea.right() - screenArea.width() / 4); } else if (geom->right() < screenArea.left()) { - geom->moveRight(screenArea.left() + screenArea.width()/4); + geom->moveRight(screenArea.left() + screenArea.width() / 4); } if (geom->top() > screenArea.bottom()) { - geom->moveTop(screenArea.bottom() - screenArea.height()/4); + geom->moveTop(screenArea.bottom() - screenArea.height() / 4); } else if (geom->bottom() < screenArea.top()) { - geom->moveBottom(screenArea.top() + screenArea.width()/4); + geom->moveBottom(screenArea.top() + screenArea.width() / 4); } } diff --git a/src/abstract_client.h b/src/abstract_client.h index ad44487efe..89d1b28797 100644 --- a/src/abstract_client.h +++ b/src/abstract_client.h @@ -10,10 +10,10 @@ #ifndef KWIN_ABSTRACT_CLIENT_H #define KWIN_ABSTRACT_CLIENT_H -#include "toplevel.h" +#include "cursor.h" #include "options.h" #include "rules.h" -#include "cursor.h" +#include "toplevel.h" #include @@ -342,37 +342,45 @@ class KWIN_EXPORT AbstractClient : public Toplevel public: ~AbstractClient() override; - QWeakPointer tabBoxClient() const { + QWeakPointer tabBoxClient() const + { return m_tabBoxClient.toWeakRef(); } - bool isFirstInTabBox() const { + bool isFirstInTabBox() const + { return m_firstInTabBox; } - bool skipSwitcher() const { + bool skipSwitcher() const + { return m_skipSwitcher; } void setSkipSwitcher(bool set); - bool skipTaskbar() const { + bool skipTaskbar() const + { return m_skipTaskbar; } void setSkipTaskbar(bool set); void setOriginalSkipTaskbar(bool set); - bool originalSkipTaskbar() const { + bool originalSkipTaskbar() const + { return m_originalSkipTaskbar; } - bool skipPager() const { + bool skipPager() const + { return m_skipPager; } void setSkipPager(bool set); - const QIcon &icon() const { + const QIcon &icon() const + { return m_icon; } bool isZombie() const; - bool isActive() const { + bool isActive() const + { return m_active; } /** @@ -387,17 +395,20 @@ public: */ void setActive(bool); - bool keepAbove() const { + bool keepAbove() const + { return m_keepAbove; } void setKeepAbove(bool); - bool keepBelow() const { + bool keepBelow() const + { return m_keepBelow; } void setKeepBelow(bool); void demandAttention(bool set = true); - bool isDemandingAttention() const { + bool isDemandingAttention() const + { return m_demandsAttention; } @@ -406,7 +417,8 @@ public: bool wantsTabFocus() const; QMargins frameMargins() const override; - QPoint clientPos() const override { + QPoint clientPos() const override + { return QPoint(borderLeft(), borderTop()); } @@ -451,19 +463,19 @@ public: * @returns The position the transient wishes to position itself */ virtual QRect transientPlacement(const QRect &bounds) const; - const AbstractClient* transientFor() const; - AbstractClient* transientFor(); + 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 bool hasTransient(const AbstractClient *c, bool indirect) const; + const QList &transients() const; // Is not indirect virtual void addTransient(AbstractClient *client); - 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 + 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.) @@ -473,7 +485,8 @@ public: bool isSpecialWindow() const; void sendToOutput(AbstractOutput *output); void updateGeometryRestoresForFullscreen(AbstractOutput *output); - const QKeySequence &shortcut() const { + const QKeySequence &shortcut() const + { return _shortcut; } void setShortcut(const QString &cut); @@ -490,7 +503,8 @@ public: void setDesktops(QVector desktops); int desktop() const override; - QVector desktops() const override { + QVector desktops() const override + { return m_desktops; } QVector x11DesktopIds() const; @@ -502,7 +516,8 @@ public: */ void minimize(bool avoid_animation = false); void unminimize(bool avoid_animation = false); - bool isMinimized() const { + bool isMinimized() const + { return m_minimized; } virtual void setFullScreen(bool set, bool user = true); @@ -536,7 +551,8 @@ public: /** * @c true only for @c ShadeNormal */ - bool isShade() const override { + bool isShade() const override + { return shadeMode() == ShadeNormal; } ShadeMode shadeMode() const; // Prefer isShade() @@ -562,10 +578,11 @@ public: virtual void updateActivities(bool includeTransients); void blockActivityUpdates(bool b = true); - const WindowRules* rules() const { + const WindowRules *rules() const + { return &m_rules; } - void removeRule(Rules* r); + void removeRule(Rules *r); void setupWindowRules(bool ignore_temporary); void evaluateWindowRules(); virtual void applyWindowRules(); @@ -614,7 +631,8 @@ public: * @param keyboard Defines whether to take keyboard cursor into account. */ void setQuickTileMode(QuickTileMode mode, bool keyboard = false); - QuickTileMode quickTileMode() const { + QuickTileMode quickTileMode() const + { return QuickTileMode(m_quickTileMode); } Layer layer() const override; @@ -624,7 +642,7 @@ public: void resize(const QSize &size); void moveResize(const QRect &rect); - virtual void resizeWithChecks(const QSize& s) = 0; + virtual void resizeWithChecks(const QSize &s) = 0; void keepInArea(QRect area, bool partial = false); virtual QSize minSize() const; virtual QSize maxSize() const; @@ -694,19 +712,22 @@ public: /** * Returns @c true if the Client is being interactively moved; otherwise @c false. */ - bool isInteractiveMove() const { + bool isInteractiveMove() const + { return isInteractiveMoveResize() && interactiveMoveResizeGravity() == Gravity::None; } /** * Returns @c true if the Client is being interactively resized; otherwise @c false. */ - bool isInteractiveResize() const { + bool isInteractiveResize() const + { return isInteractiveMoveResize() && interactiveMoveResizeGravity() != Gravity::None; } /** * Cursor shape for move/resize mode. */ - CursorShape cursor() const { + CursorShape cursor() const + { return m_interactiveMoveResize.cursor; } @@ -728,13 +749,16 @@ public: Options::MouseCommand getWheelCommand(Qt::Orientation orientation, bool *handled) const; // decoration related - KDecoration2::Decoration *decoration() { + KDecoration2::Decoration *decoration() + { return m_decoration.decoration.data(); } - const KDecoration2::Decoration *decoration() const { + const KDecoration2::Decoration *decoration() const + { return m_decoration.decoration.data(); } - bool isDecorated() const { + bool isDecorated() const + { return m_decoration.decoration != nullptr; } QPointer decoratedClient() const; @@ -791,7 +815,8 @@ public: */ virtual void showOnScreenEdge(); - QByteArray desktopFileName() const { + QByteArray desktopFileName() const + { return m_desktopFileName; } @@ -808,18 +833,21 @@ public: AllowCrossProcesses = 1 << 1 }; Q_DECLARE_FLAGS(SameApplicationChecks, SameApplicationCheck) - static bool belongToSameApplication(const AbstractClient* c1, const AbstractClient* c2, SameApplicationChecks checks = SameApplicationChecks()); + static bool belongToSameApplication(const AbstractClient *c1, const AbstractClient *c2, SameApplicationChecks checks = SameApplicationChecks()); bool hasApplicationMenu() const; - bool applicationMenuActive() const { + bool applicationMenuActive() const + { return m_applicationMenuActive; } void setApplicationMenuActive(bool applicationMenuActive); - QString applicationMenuServiceName() const { + QString applicationMenuServiceName() const + { return m_applicationMenuServiceName; } - QString applicationMenuObjectPath() const { + QString applicationMenuObjectPath() const + { return m_applicationMenuObjectPath; } @@ -870,7 +898,8 @@ public: /** * Return window management interface */ - KWaylandServer::PlasmaWindowInterface *windowManagementInterface() const { + KWaylandServer::PlasmaWindowInterface *windowManagementInterface() const + { return m_windowManagementInterface; } @@ -899,26 +928,26 @@ Q_SIGNALS: * Emitted whenever the demands attention state changes. */ void demandsAttentionChanged(); - void desktopPresenceChanged(KWin::AbstractClient*, int); // to be forwarded by Workspace + void desktopPresenceChanged(KWin::AbstractClient *, int); // to be forwarded by Workspace void desktopChanged(); - void activitiesChanged(KWin::AbstractClient* client); + void activitiesChanged(KWin::AbstractClient *client); void x11DesktopIdsChanged(); void minimizedChanged(); - void clientMinimized(KWin::AbstractClient* client, bool animate); - void clientUnminimized(KWin::AbstractClient* client, bool animate); + 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 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 clientStartUserMovedResized(KWin::AbstractClient *); + void clientStepUserMovedResized(KWin::AbstractClient *, const QRect &); + void clientFinishUserMovedResized(KWin::AbstractClient *); void closeableChanged(bool); void minimizeableChanged(bool); void shadeableChanged(bool); @@ -933,7 +962,8 @@ Q_SIGNALS: protected: AbstractClient(); - void setFirstInTabBox(bool enable) { + void setFirstInTabBox(bool enable) + { m_firstInTabBox = enable; } void setIcon(const QIcon &icon); @@ -1012,7 +1042,7 @@ protected: /** * Just removes the @p cl from the transients without any further checks. */ - void removeTransientFromList(AbstractClient* cl); + void removeTransientFromList(AbstractClient *cl); virtual Layer belongsToLayer() const; virtual bool belongsToDesktop() const; @@ -1022,17 +1052,20 @@ protected: // electric border / quick tiling void setElectricBorderMode(QuickTileMode mode); - QuickTileMode electricBorderMode() const { + QuickTileMode electricBorderMode() const + { return m_electricMode; } void setElectricBorderMaximizing(bool maximizing); - bool isElectricBorderMaximizing() const { + bool isElectricBorderMaximizing() const + { return m_electricMaximizing; } void updateElectricGeometryRestore(); QRect quickTileGeometryRestore() const; QRect quickTileGeometry(QuickTileMode mode, const QPoint &pos) const; - void updateQuickTileMode(QuickTileMode newMode) { + void updateQuickTileMode(QuickTileMode newMode) + { m_quickTileMode = newMode; } @@ -1045,7 +1078,6 @@ protected: virtual void changeMaximize(bool horizontal, bool vertical, bool adjust); void setGeometryRestore(const QRect &rect); - void blockGeometryUpdates(bool block); void blockGeometryUpdates(); void unblockGeometryUpdates(); @@ -1063,40 +1095,49 @@ protected: /** * @returns whether the Client is currently in move resize mode */ - bool isInteractiveMoveResize() const { + bool isInteractiveMoveResize() const + { return m_interactiveMoveResize.enabled; } /** * Sets whether the Client is in move resize mode to @p enabled. */ - void setInteractiveMoveResize(bool enabled) { + void setInteractiveMoveResize(bool enabled) + { m_interactiveMoveResize.enabled = enabled; } /** * @returns whether the move resize mode is unrestricted. */ - bool isUnrestrictedInteractiveMoveResize() const { + bool isUnrestrictedInteractiveMoveResize() const + { return m_interactiveMoveResize.unrestricted; } /** * Sets whether move resize mode is unrestricted to @p set. */ - void setUnrestrictedInteractiveMoveResize(bool set) { + void setUnrestrictedInteractiveMoveResize(bool set) + { m_interactiveMoveResize.unrestricted = set; } - QPoint interactiveMoveOffset() const { + QPoint interactiveMoveOffset() const + { return m_interactiveMoveResize.offset; } - void setInteractiveMoveOffset(const QPoint &offset) { + void setInteractiveMoveOffset(const QPoint &offset) + { m_interactiveMoveResize.offset = offset; } - QPoint invertedInteractiveMoveOffset() const { + QPoint invertedInteractiveMoveOffset() const + { return m_interactiveMoveResize.invertedOffset; } - void setInvertedInteractiveMoveOffset(const QPoint &offset) { + void setInvertedInteractiveMoveOffset(const QPoint &offset) + { m_interactiveMoveResize.invertedOffset = offset; } - QRect initialInteractiveMoveResizeGeometry() const { + QRect initialInteractiveMoveResizeGeometry() const + { return m_interactiveMoveResize.initialGeometry; } /** @@ -1104,19 +1145,24 @@ protected: */ void updateInitialMoveResizeGeometry(); void setMoveResizeGeometry(const QRect &geo); - Gravity interactiveMoveResizeGravity() const { + Gravity interactiveMoveResizeGravity() const + { return m_interactiveMoveResize.gravity; } - void setInteractiveMoveResizeGravity(Gravity gravity) { + void setInteractiveMoveResizeGravity(Gravity gravity) + { m_interactiveMoveResize.gravity = gravity; } - bool isInteractiveMoveResizePointerButtonDown() const { + bool isInteractiveMoveResizePointerButtonDown() const + { return m_interactiveMoveResize.buttonDown; } - void setInteractiveMoveResizePointerButtonDown(bool down) { + void setInteractiveMoveResizePointerButtonDown(bool down) + { m_interactiveMoveResize.buttonDown = down; } - AbstractOutput *interactiveMoveResizeStartOutput() const { + AbstractOutput *interactiveMoveResizeStartOutput() const + { return m_interactiveMoveResize.startOutput; } void checkUnrestrictedInteractiveMoveResize(); @@ -1242,7 +1288,7 @@ private: QTimer *m_autoRaiseTimer = nullptr; QTimer *m_shadeHoverTimer = nullptr; ShadeMode m_shadeMode = ShadeNone; - QVector m_desktops; + QVector m_desktops; int m_activityUpdatesBlocked = 0; bool m_blockedActivityUpdatesRequireTransients = false; @@ -1255,7 +1301,7 @@ private: KWaylandServer::PlasmaWindowInterface *m_windowManagementInterface = nullptr; AbstractClient *m_transientFor = nullptr; - QList m_transients; + QList m_transients; bool m_modal = false; Layer m_layer = UnknownLayer; @@ -1276,7 +1322,8 @@ private: QRect m_maximizeGeometryRestore; QRect m_fullscreenGeometryRestore; - struct { + struct + { bool enabled = false; bool unrestricted = false; QPoint offset; @@ -1289,7 +1336,8 @@ private: QTimer *delayedTimer = nullptr; } m_interactiveMoveResize; - struct { + struct + { QSharedPointer decoration; QPointer client; QElapsedTimer doubleClickTimer; @@ -1314,19 +1362,21 @@ private: class GeometryUpdatesBlocker { public: - explicit GeometryUpdatesBlocker(AbstractClient* c) - : cl(c) { + explicit GeometryUpdatesBlocker(AbstractClient *c) + : cl(c) + { cl->blockGeometryUpdates(true); } - ~GeometryUpdatesBlocker() { + ~GeometryUpdatesBlocker() + { cl->blockGeometryUpdates(false); } private: - AbstractClient* cl; + AbstractClient *cl; }; -inline const QList& AbstractClient::transients() const +inline const QList &AbstractClient::transients() const { return m_transients; } @@ -1358,8 +1408,8 @@ inline void AbstractClient::setPendingMoveResizeMode(MoveResizeMode mode) } -Q_DECLARE_METATYPE(KWin::AbstractClient*) -Q_DECLARE_METATYPE(QList) +Q_DECLARE_METATYPE(KWin::AbstractClient *) +Q_DECLARE_METATYPE(QList) Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::AbstractClient::SameApplicationChecks) #endif diff --git a/src/abstract_output.cpp b/src/abstract_output.cpp index f74adfcf9f..6ea73ad065 100644 --- a/src/abstract_output.cpp +++ b/src/abstract_output.cpp @@ -9,8 +9,8 @@ #include "abstract_output.h" #include "outputlayer.h" -#include #include +#include namespace KWin { @@ -165,7 +165,7 @@ bool AbstractOutput::directScanoutInhibited() const std::chrono::milliseconds AbstractOutput::dimAnimationTime() { // See kscreen.kcfg - return std::chrono::milliseconds (KSharedConfig::openConfig()->group("Effect-Kscreen").readEntry("Duration", 250)); + return std::chrono::milliseconds(KSharedConfig::openConfig()->group("Effect-Kscreen").readEntry("Duration", 250)); } bool AbstractOutput::usesSoftwareCursor() const diff --git a/src/abstract_output.h b/src/abstract_output.h index ee83852228..3c65b6dee6 100644 --- a/src/abstract_output.h +++ b/src/abstract_output.h @@ -221,7 +221,10 @@ public: Flipped270 }; Q_ENUM(Transform) - virtual Transform transform() const { return Transform::Normal; } + virtual Transform transform() const + { + return Transform::Normal; + } virtual bool usesSoftwareCursor() const; diff --git a/src/abstract_wayland_output.cpp b/src/abstract_wayland_output.cpp index 32e656bd3a..de8f8fcf32 100644 --- a/src/abstract_wayland_output.cpp +++ b/src/abstract_wayland_output.cpp @@ -107,7 +107,8 @@ QByteArray AbstractWaylandOutput::edid() const return m_edid; } -bool AbstractWaylandOutput::Mode::operator==(const Mode &other) const { +bool AbstractWaylandOutput::Mode::operator==(const Mode &other) const +{ return id == other.id && other.flags == flags && size == other.size && refreshRate == other.refreshRate; } @@ -231,8 +232,7 @@ void AbstractWaylandOutput::initialize(const QString &model, const QString &manu QSize AbstractWaylandOutput::orientateSize(const QSize &size) const { - if (m_transform == Transform::Rotated90 || m_transform == Transform::Rotated270 || - m_transform == Transform::Flipped90 || m_transform == Transform::Flipped270) { + if (m_transform == Transform::Rotated90 || m_transform == Transform::Rotated270 || m_transform == Transform::Flipped90 || m_transform == Transform::Flipped270) { return size.transposed(); } return size; diff --git a/src/abstract_wayland_output.h b/src/abstract_wayland_output.h index fa3ceb31c1..a94dd1be01 100644 --- a/src/abstract_wayland_output.h +++ b/src/abstract_wayland_output.h @@ -10,13 +10,13 @@ #define KWIN_ABSTRACT_WAYLAND_OUTPUT_H #include "abstract_output.h" -#include "utils/common.h" #include "renderloop.h" +#include "utils/common.h" #include #include -#include #include +#include namespace KWin { @@ -106,7 +106,8 @@ public: int refreshRate() const override; - bool isInternal() const override { + bool isInternal() const override + { return m_internal; } @@ -162,17 +163,21 @@ protected: const QSize &physicalSize, const QVector &modes, const QByteArray &edid); - void setName(const QString &name) { + void setName(const QString &name) + { m_name = name; } - void setInternal(bool set) { + void setInternal(bool set) + { m_internal = set; } - virtual void updateEnablement(bool enable) { + virtual void updateEnablement(bool enable) + { Q_UNUSED(enable); } - virtual void updateTransform(Transform transform) { + virtual void updateTransform(Transform transform) + { Q_UNUSED(transform); } diff --git a/src/activation.cpp b/src/activation.cpp index 8e3910e609..102045d7b1 100644 --- a/src/activation.cpp +++ b/src/activation.cpp @@ -15,20 +15,20 @@ */ -#include "x11client.h" #include "cursor.h" #include "focuschain.h" #include "netinfo.h" #include "platform.h" #include "workspace.h" +#include "x11client.h" #if KWIN_BUILD_ACTIVITIES #include "activities.h" #endif #include "virtualdesktops.h" +#include #include #include -#include #include "atoms.h" #include "group.h" @@ -203,12 +203,10 @@ namespace KWin data.l[1]= timestamp */ - //**************************************** // Workspace //**************************************** - /** * Informs the workspace about the active client, i.e. the client that * has the focus (or None if no client has the focus). This functions @@ -217,7 +215,7 @@ namespace KWin * activeClient(). And of course, to propagate the active client to the * world. */ -void Workspace::setActiveClient(AbstractClient* c) +void Workspace::setActiveClient(AbstractClient *c) { if (active_client == c) return; @@ -280,7 +278,7 @@ void Workspace::setActiveClient(AbstractClient* c) * @see setActiveClient * @see requestFocus */ -void Workspace::activateClient(AbstractClient* c, bool force) +void Workspace::activateClient(AbstractClient *c, bool force) { if (c == nullptr) { focusToNull(); @@ -296,8 +294,8 @@ void Workspace::activateClient(AbstractClient* c, bool force) #if KWIN_BUILD_ACTIVITIES if (!c->isOnCurrentActivity()) { ++block_focus; - //DBUS! - Activities::self()->setCurrent(c->activities().constFirst()); //first isn't necessarily best, but it's easiest + // DBUS! + Activities::self()->setCurrent(c->activities().constFirst()); // first isn't necessarily best, but it's easiest --block_focus; } #endif @@ -307,7 +305,7 @@ void Workspace::activateClient(AbstractClient* c, bool force) // ensure the window is really visible - could eg. be a hidden utility window, see bug #348083 c->showClient(); -// TODO force should perhaps allow this only if the window already contains the mouse + // TODO force should perhaps allow this only if the window already contains the mouse if (options->focusPolicyIsReasonable() || force) requestFocus(c, force); @@ -331,12 +329,12 @@ void Workspace::activateClient(AbstractClient* c, bool force) * * @see activateClient */ -bool Workspace::requestFocus(AbstractClient* c, bool force) +bool Workspace::requestFocus(AbstractClient *c, bool force) { return takeActivity(c, force ? ActivityFocusForce : ActivityFocus); } -bool Workspace::takeActivity(AbstractClient* c, ActivityFlags flags) +bool Workspace::takeActivity(AbstractClient *c, ActivityFlags flags) { // the 'if ( c == active_client ) return;' optimization mustn't be done here if (!focusChangeEnabled() && (c != active_client)) @@ -348,13 +346,13 @@ bool Workspace::takeActivity(AbstractClient* c, ActivityFlags flags) } if (flags & ActivityFocus) { - AbstractClient* modal = c->findModal(); + AbstractClient *modal = c->findModal(); if (modal != nullptr && modal != c) { if (modal->desktops() != c->desktops()) { modal->setDesktops(c->desktops()); } - if (!modal->isShown() && !modal->isMinimized()) // forced desktop or utility window - activateClient(modal); // activating a minimized blocked window will unminimize its modal implicitly + if (!modal->isShown() && !modal->isMinimized()) // forced desktop or utility window + activateClient(modal); // activating a minimized blocked window will unminimize its modal implicitly // if the click was inside the window (i.e. handled is set), // but it has a modal, there's no need to use handled mode, because // the modal doesn't get the click anyway @@ -368,9 +366,9 @@ bool Workspace::takeActivity(AbstractClient* c, ActivityFlags flags) if (!flags.testFlag(ActivityFocusForce) && (c->isDock() || c->isSplash())) { // toplevel menus and dock windows don't take focus if not forced // and don't have a flag that they take focus - if (!c->dockWantsInput()) { - flags &= ~ActivityFocus; - } + if (!c->dockWantsInput()) { + flags &= ~ActivityFocus; + } } if (c->isShade()) { if (c->wantsInput() && (flags & ActivityFocus)) { @@ -380,8 +378,8 @@ bool Workspace::takeActivity(AbstractClient* c, ActivityFlags flags) } flags &= ~ActivityFocus; } - if (!c->isShown()) { // shouldn't happen, call activateClient() if needed - qCWarning(KWIN_CORE) << "takeActivity: not shown" ; + if (!c->isShown()) { // shouldn't happen, call activateClient() if needed + qCWarning(KWIN_CORE) << "takeActivity: not shown"; return false; } @@ -406,7 +404,7 @@ bool Workspace::takeActivity(AbstractClient* c, ActivityFlags flags) * * @note @p c may already be destroyed. */ -void Workspace::clientHidden(AbstractClient* c) +void Workspace::clientHidden(AbstractClient *c) { Q_ASSERT(!c->isShown() || !c->isOnCurrentDesktop() || !c->isOnCurrentActivity()); activateNextClient(c); @@ -416,15 +414,14 @@ AbstractClient *Workspace::clientUnderMouse(AbstractOutput *output) const { auto it = stackingOrder().constEnd(); while (it != stackingOrder().constBegin()) { - AbstractClient *client = qobject_cast(*(--it)); + AbstractClient *client = qobject_cast(*(--it)); if (!client) { continue; } // rule out clients which are not really visible. // the screen test is rather superfluous for xrandr & twinview since the geometry would differ -> TODO: might be dropped - if (!(client->isShown() && client->isOnCurrentDesktop() && - client->isOnCurrentActivity() && client->isOnOutput(output) && !client->isShade())) + if (!(client->isShown() && client->isOnCurrentDesktop() && client->isOnCurrentActivity() && client->isOnOutput(output) && !client->isShade())) continue; if (client->frameGeometry().contains(Cursors::self()->mouse()->pos())) { @@ -435,7 +432,7 @@ AbstractClient *Workspace::clientUnderMouse(AbstractOutput *output) const } // deactivates 'c' and activates next client -bool Workspace::activateNextClient(AbstractClient* c) +bool Workspace::activateNextClient(AbstractClient *c) { // if 'c' is not the active or the to-become active one, do nothing if (!(c == active_client || (should_get_focus.count() > 0 && c == should_get_focus.last()))) @@ -459,7 +456,7 @@ bool Workspace::activateNextClient(AbstractClient* c) if (!options->focusPolicyIsReasonable()) return false; - AbstractClient* get_focus = nullptr; + AbstractClient *get_focus = nullptr; VirtualDesktop *desktop = VirtualDesktopManager::self()->currentDesktop(); @@ -480,7 +477,7 @@ bool Workspace::activateNextClient(AbstractClient* c) auto leaders = c->mainClients(); if (leaders.count() == 1 && FocusChain::self()->isUsableFocusCandidate(leaders.at(0), c)) { get_focus = leaders.at(0); - raiseClient(get_focus); // also raise - we don't know where it came from + raiseClient(get_focus); // also raise - we don't know where it came from } } if (!get_focus) { @@ -489,7 +486,7 @@ bool Workspace::activateNextClient(AbstractClient* c) } } - if (get_focus == nullptr) // last chance: focus the desktop + if (get_focus == nullptr) // last chance: focus the desktop get_focus = findDesktop(true, desktop); if (get_focus != nullptr) @@ -498,7 +495,6 @@ bool Workspace::activateNextClient(AbstractClient* c) focusToNull(); return true; - } void Workspace::switchToOutput(AbstractOutput *output) @@ -515,9 +511,9 @@ void Workspace::switchToOutput(AbstractOutput *output) setActiveOutput(output); } -void Workspace::gotFocusIn(const AbstractClient* c) +void Workspace::gotFocusIn(const AbstractClient *c) { - if (should_get_focus.contains(const_cast< AbstractClient* >(c))) { + if (should_get_focus.contains(const_cast(c))) { // remove also all sooner elements that should have got FocusIn, // but didn't for some reason (and also won't anymore, because they were sooner) while (should_get_focus.first() != c) @@ -526,15 +522,21 @@ void Workspace::gotFocusIn(const AbstractClient* c) } } -void Workspace::setShouldGetFocus(AbstractClient* c) +void Workspace::setShouldGetFocus(AbstractClient *c) { should_get_focus.append(c); updateStackingOrder(); // e.g. fullscreens have different layer when active/not-active } - -namespace FSP { - enum Level { None = 0, Low, Medium, High, Extreme }; +namespace FSP +{ +enum Level { + None = 0, + Low, + Medium, + High, + Extreme, +}; } // focus_in -> the window got FocusIn event @@ -556,15 +558,15 @@ bool Workspace::allowClientActivation(const KWin::AbstractClient *c, xcb_timesta if (sessionManager()->state() == SessionState::Saving && level <= FSP::Medium) { // <= normal return true; } - AbstractClient* ac = mostRecentlyActivatedClient(); + AbstractClient *ac = mostRecentlyActivatedClient(); if (focus_in) { - if (should_get_focus.contains(const_cast< AbstractClient* >(c))) + if (should_get_focus.contains(const_cast(c))) return true; // FocusIn was result of KWin's action // Before getting FocusIn, the active Client already // got FocusOut, and therefore got deactivated. ac = last_active_client; } - if (time == 0) { // explicitly asked not to get focus + if (time == 0) { // explicitly asked not to get focus if (!c->rules()->checkAcceptFocus(false)) return false; } @@ -605,7 +607,7 @@ bool Workspace::allowClientActivation(const KWin::AbstractClient *c, xcb_timesta if (level > FSP::Medium && protection > FSP::Low) return false; - if (time == -1U) { // no time known + if (time == -1U) { // no time known qCDebug(KWIN_CORE) << "Activation: No timestamp at all"; // Only allow for Low protection unless active client has High interest in focus if (level < FSP::Medium && protection < FSP::High) @@ -619,8 +621,8 @@ bool Workspace::allowClientActivation(const KWin::AbstractClient *c, xcb_timesta // Low or medium FSP, usertime comparism is possible const xcb_timestamp_t user_time = ac->userTime(); qCDebug(KWIN_CORE) << "Activation, compared:" << c << ":" << time << ":" << user_time - << ":" << (NET::timestampCompare(time, user_time) >= 0); - return NET::timestampCompare(time, user_time) >= 0; // time >= user_time + << ":" << (NET::timestampCompare(time, user_time) >= 0); + return NET::timestampCompare(time, user_time) >= 0; // time >= user_time } // basically the same like allowClientActivation(), this time allowing @@ -633,10 +635,10 @@ bool Workspace::allowFullClientRaising(const KWin::AbstractClient *c, xcb_timest if (sessionManager()->state() == SessionState::Saving && level <= 2) { // <= normal return true; } - AbstractClient* ac = mostRecentlyActivatedClient(); - if (level == 0) // none + AbstractClient *ac = mostRecentlyActivatedClient(); + if (level == 0) // none return true; - if (level == 4) // extreme + if (level == 4) // extreme return false; if (ac == nullptr || ac->isDesktop()) { qCDebug(KWIN_CORE) << "Raising: No client active, allowing"; @@ -647,12 +649,12 @@ bool Workspace::allowFullClientRaising(const KWin::AbstractClient *c, xcb_timest qCDebug(KWIN_CORE) << "Raising: Belongs to active application"; return true; } - if (level == 3) // high + if (level == 3) // high return false; xcb_timestamp_t user_time = ac->userTime(); qCDebug(KWIN_CORE) << "Raising, compared:" << time << ":" << user_time - << ":" << (NET::timestampCompare(time, user_time) >= 0); - return NET::timestampCompare(time, user_time) >= 0; // time >= user_time + << ":" << (NET::timestampCompare(time, user_time) >= 0); + return NET::timestampCompare(time, user_time) >= 0; // time >= user_time } /** @@ -675,7 +677,7 @@ bool Workspace::restoreFocus() return true; } -void Workspace::clientAttentionChanged(AbstractClient* c, bool set) +void Workspace::clientAttentionChanged(AbstractClient *c, bool set) { if (set) { attention_chain.removeAll(c); @@ -703,8 +705,8 @@ void X11Client::updateUserTime(xcb_timestamp_t time) time = xTime(); } if (time != -1U - && (m_userTime == XCB_TIME_CURRENT_TIME - || NET::timestampCompare(time, m_userTime) > 0)) { // time > user_time + && (m_userTime == XCB_TIME_CURRENT_TIME + || NET::timestampCompare(time, m_userTime) > 0)) { // time > user_time m_userTime = time; shade_below = nullptr; // do not hover re-shade a window after it got interaction } @@ -718,17 +720,17 @@ xcb_timestamp_t X11Client::readUserCreationTime() const } xcb_timestamp_t X11Client::readUserTimeMapTimestamp(const KStartupInfoId *asn_id, const KStartupInfoData *asn_data, - bool session) const + bool session) const { xcb_timestamp_t time = info->userTime(); - //qDebug() << "User timestamp, initial:" << time; + // qDebug() << "User timestamp, initial:" << time; //^^ this deadlocks kwin --replace sometimes. // newer ASN timestamp always replaces user timestamp, unless user timestamp is 0 // helps e.g. with konqy reusing if (asn_data != nullptr && time != 0) { if (asn_id->timestamp() != 0 - && (time == -1U || NET::timestampCompare(asn_id->timestamp(), time) > 0)) { + && (time == -1U || NET::timestampCompare(asn_id->timestamp(), time) > 0)) { time = asn_id->timestamp(); } } @@ -748,14 +750,14 @@ xcb_timestamp_t X11Client::readUserTimeMapTimestamp(const KStartupInfoId *asn_id // ignore already existing splashes, toolbars, utilities and menus, // as the app may show those before the main window return !cl->isSplash() && !cl->isToolbar() && !cl->isUtility() && !cl->isMenu() - && cl != this && X11Client::belongToSameApplication(cl, this, SameApplicationCheck::RelaxedForActive); + && cl != this && X11Client::belongToSameApplication(cl, this, SameApplicationCheck::RelaxedForActive); }; if (isTransient()) { auto clientMainClients = [this]() { QList ret; const auto mcs = mainClients(); - for (auto mc: mcs) { - if (X11Client *c = dynamic_cast(mc)) { + for (auto mc : mcs) { + if (X11Client *c = dynamic_cast(mc)) { ret << c; } } @@ -764,8 +766,7 @@ xcb_timestamp_t X11Client::readUserTimeMapTimestamp(const KStartupInfoId *asn_id if (act->hasTransient(this, true)) ; // is transient for currently active window, even though it's not // the same app (e.g. kcookiejar dialog) -> allow activation - else if (groupTransient() && - findInList(clientMainClients(), sameApplicationActiveHackPredicate) == nullptr) + else if (groupTransient() && findInList(clientMainClients(), sameApplicationActiveHackPredicate) == nullptr) ; // standalone transient else first_window = false; @@ -799,12 +800,12 @@ xcb_timestamp_t X11Client::readUserTimeMapTimestamp(const KStartupInfoId *asn_id xcb_timestamp_t X11Client::userTime() const { xcb_timestamp_t time = m_userTime; - if (time == 0) // doesn't want focus after showing + if (time == 0) // doesn't want focus after showing return 0; Q_ASSERT(group() != nullptr); if (time == -1U - || (group()->userTime() != -1U - && NET::timestampCompare(group()->userTime(), time) > 0)) + || (group()->userTime() != -1U + && NET::timestampCompare(group()->userTime(), time) > 0)) time = group()->userTime(); return time; } @@ -866,7 +867,7 @@ void Group::startupIdChanged() if (!asn_valid) return; if (asn_id.timestamp() != 0 && user_time != -1U - && NET::timestampCompare(asn_id.timestamp(), user_time) > 0) { + && NET::timestampCompare(asn_id.timestamp(), user_time) > 0) { user_time = asn_id.timestamp(); } } @@ -879,8 +880,8 @@ void Group::updateUserTime(xcb_timestamp_t time) time = xTime(); } if (time != -1U - && (user_time == XCB_CURRENT_TIME - || NET::timestampCompare(time, user_time) > 0)) // time > user_time + && (user_time == XCB_CURRENT_TIME + || NET::timestampCompare(time, user_time) > 0)) // time > user_time user_time = time; } diff --git a/src/activities.cpp b/src/activities.cpp index 52ca9c7038..0284721cf8 100644 --- a/src/activities.cpp +++ b/src/activities.cpp @@ -13,10 +13,10 @@ // KDE #include // Qt -#include #include #include #include +#include namespace KWin { @@ -29,7 +29,7 @@ Activities::Activities(QObject *parent) { connect(m_controller, &KActivities::Controller::activityRemoved, this, &Activities::slotRemoved); connect(m_controller, &KActivities::Controller::activityRemoved, this, &Activities::removed); - connect(m_controller, &KActivities::Controller::activityAdded, this, &Activities::added); + connect(m_controller, &KActivities::Controller::activityAdded, this, &Activities::added); connect(m_controller, &KActivities::Controller::currentActivityChanged, this, &Activities::slotCurrentChanged); } @@ -61,43 +61,42 @@ void Activities::slotCurrentChanged(const QString &newActivity) void Activities::slotRemoved(const QString &activity) { const auto clients = Workspace::self()->allClientList(); - for (auto * const client : clients) { + for (auto *const client : clients) { if (client->isDesktop()) continue; client->setOnActivity(activity, false); } - //toss out any session data for it + // toss out any session data for it KConfigGroup cg(KSharedConfig::openConfig(), QByteArray("SubSession: ").append(activity.toUtf8()).constData()); cg.deleteGroup(); } void Activities::toggleClientOnActivity(AbstractClient *c, const QString &activity, bool dont_activate) { - //int old_desktop = c->desktop(); + // int old_desktop = c->desktop(); bool was_on_activity = c->isOnActivity(activity); bool was_on_all = c->isOnAllActivities(); - //note: all activities === no activities + // note: all activities === no activities bool enable = was_on_all || !was_on_activity; c->setOnActivity(activity, enable); - if (c->isOnActivity(activity) == was_on_activity && c->isOnAllActivities() == was_on_all) // No change + if (c->isOnActivity(activity) == was_on_activity && c->isOnAllActivities() == was_on_all) // No change return; Workspace *ws = Workspace::self(); if (c->isOnCurrentActivity()) { - if (c->wantsTabFocus() && options->focusPolicyIsReasonable() && - !was_on_activity && // for stickyness changes - //FIXME not sure if the line above refers to the correct activity - !dont_activate) + if (c->wantsTabFocus() && options->focusPolicyIsReasonable() && !was_on_activity && // for stickyness changes + // FIXME not sure if the line above refers to the correct activity + !dont_activate) ws->requestFocus(c); else ws->restackClientUnderActive(c); } else ws->raiseClient(c); - //notifyWindowDesktopChanged( c, old_desktop ); + // notifyWindowDesktopChanged( c, old_desktop ); const auto transients_stacking_order = ws->ensureStackingOrder(c->transients()); - for (auto * const c : transients_stacking_order) { + for (auto *const c : transients_stacking_order) { if (!c) { continue; } @@ -110,11 +109,11 @@ bool Activities::start(const QString &id) { Workspace *ws = Workspace::self(); if (ws->sessionManager()->state() == SessionState::Saving) { - return false; //ksmserver doesn't queue requests (yet) + return false; // ksmserver doesn't queue requests (yet) } if (!all().contains(id)) { - return false; //bogus id + return false; // bogus id } ws->loadSubSessionInfo(id); @@ -132,13 +131,13 @@ bool Activities::start(const QString &id) bool Activities::stop(const QString &id) { if (Workspace::self()->sessionManager()->state() == SessionState::Saving) { - return false; //ksmserver doesn't queue requests (yet) - //FIXME what about session *loading*? + return false; // ksmserver doesn't queue requests (yet) + // FIXME what about session *loading*? } - //ugly hack to avoid dbus deadlocks + // ugly hack to avoid dbus deadlocks QMetaObject::invokeMethod(this, "reallyStop", Qt::QueuedConnection, Q_ARG(QString, id)); - //then lie and assume it worked. + // then lie and assume it worked. return true; } @@ -146,26 +145,26 @@ void Activities::reallyStop(const QString &id) { Workspace *ws = Workspace::self(); if (ws->sessionManager()->state() == SessionState::Saving) - return; //ksmserver doesn't queue requests (yet) + return; // ksmserver doesn't queue requests (yet) qCDebug(KWIN_CORE) << id; QSet saveSessionIds; QSet dontCloseSessionIds; const auto clients = ws->allClientList(); - for (auto * const c : clients) { + for (auto *const c : clients) { if (c->isDesktop()) continue; const QByteArray sessionId = c->sessionId(); if (sessionId.isEmpty()) { - continue; //TODO support old wm_command apps too? + continue; // TODO support old wm_command apps too? } - //qDebug() << sessionId; + // qDebug() << sessionId; - //if it's on the activity that's closing, it needs saving - //but if a process is on some other open activity, I don't wanna close it yet - //this is, of course, complicated by a process having many windows. + // if it's on the activity that's closing, it needs saving + // but if a process is on some other open activity, I don't wanna close it yet + // this is, of course, complicated by a process having many windows. if (c->isOnAllActivities()) { dontCloseSessionIds << sessionId; continue; @@ -195,7 +194,7 @@ void Activities::reallyStop(const QString &id) qCDebug(KWIN_CORE) << "saveActivity" << id << saveAndClose << saveOnly; - //pass off to ksmserver + // pass off to ksmserver QDBusInterface ksmserver("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface"); if (ksmserver.isValid()) { ksmserver.asyncCall("saveSubSession", id, saveAndClose, saveOnly); diff --git a/src/activities.h b/src/activities.h index a026a71fa4..067d6fd73e 100644 --- a/src/activities.h +++ b/src/activities.h @@ -16,7 +16,8 @@ #include -namespace KActivities { +namespace KActivities +{ class Controller; } @@ -72,7 +73,7 @@ Q_SIGNALS: private Q_SLOTS: void slotRemoved(const QString &activity); void slotCurrentChanged(const QString &newActivity); - void reallyStop(const QString &id); //dbus deadlocks suck + void reallyStop(const QString &id); // dbus deadlocks suck private: QString m_previous; @@ -82,32 +83,27 @@ private: KWIN_SINGLETON(Activities) }; -inline -QStringList Activities::all() const +inline QStringList Activities::all() const { return m_controller->activities(); } -inline -const QString &Activities::current() const +inline const QString &Activities::current() const { return m_current; } -inline -const QString &Activities::previous() const +inline const QString &Activities::previous() const { return m_previous; } -inline -QStringList Activities::running() const +inline QStringList Activities::running() const { return m_controller->activities(KActivities::Info::Running); } -inline -QString Activities::nullUuid() +inline QString Activities::nullUuid() { // cloned from kactivities/src/lib/core/consumer.cpp return QStringLiteral("00000000-0000-0000-0000-000000000000"); diff --git a/src/appmenu.cpp b/src/appmenu.cpp index 8f99d02d2a..24795bed6e 100644 --- a/src/appmenu.cpp +++ b/src/appmenu.cpp @@ -9,8 +9,8 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "appmenu.h" -#include "x11client.h" #include "workspace.h" +#include "x11client.h" #include #include @@ -35,18 +35,16 @@ ApplicationMenu::ApplicationMenu(QObject *parent) connect(m_appmenuInterface, &OrgKdeKappmenuInterface::menuHidden, this, &ApplicationMenu::slotMenuHidden); m_kappMenuWatcher = new QDBusServiceWatcher(QStringLiteral("org.kde.kappmenu"), QDBusConnection::sessionBus(), - QDBusServiceWatcher::WatchForRegistration|QDBusServiceWatcher::WatchForUnregistration, this); + QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration, this); - connect(m_kappMenuWatcher, &QDBusServiceWatcher::serviceRegistered, - this, [this] () { - m_applicationMenuEnabled = true; - Q_EMIT applicationMenuEnabledChanged(true); - }); - connect(m_kappMenuWatcher, &QDBusServiceWatcher::serviceUnregistered, - this, [this] () { - m_applicationMenuEnabled = false; - Q_EMIT applicationMenuEnabledChanged(false); - }); + connect(m_kappMenuWatcher, &QDBusServiceWatcher::serviceRegistered, this, [this]() { + m_applicationMenuEnabled = true; + Q_EMIT applicationMenuEnabledChanged(true); + }); + connect(m_kappMenuWatcher, &QDBusServiceWatcher::serviceUnregistered, this, [this]() { + m_applicationMenuEnabled = false; + Q_EMIT applicationMenuEnabledChanged(false); + }); m_applicationMenuEnabled = QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.kde.kappmenu")); } @@ -65,8 +63,8 @@ void ApplicationMenu::setViewEnabled(bool enabled) { if (enabled) { QDBusConnection::sessionBus().interface()->registerService(s_viewService, - QDBusConnectionInterface::QueueService, - QDBusConnectionInterface::DontAllowReplacement); + QDBusConnectionInterface::QueueService, + QDBusConnectionInterface::DontAllowReplacement); } else { QDBusConnection::sessionBus().interface()->unregisterService(s_viewService); } @@ -77,7 +75,7 @@ void ApplicationMenu::slotShowRequest(const QString &serviceName, const QDBusObj // Ignore show request when user has not configured the application menu title bar button auto decorationSettings = Decoration::DecorationBridge::self()->settings(); if (decorationSettings && !decorationSettings->decorationButtonsLeft().contains(KDecoration2::DecorationButtonType::ApplicationMenu) - && !decorationSettings->decorationButtonsRight().contains(KDecoration2::DecorationButtonType::ApplicationMenu)) { + && !decorationSettings->decorationButtonsRight().contains(KDecoration2::DecorationButtonType::ApplicationMenu)) { return; } @@ -116,7 +114,7 @@ AbstractClient *ApplicationMenu::findAbstractClientWithApplicationMenu(const QSt return Workspace::self()->findAbstractClient([&](const AbstractClient *c) { return c->applicationMenuServiceName() == serviceName - && c->applicationMenuObjectPath() == menuObjectPath.path(); + && c->applicationMenuObjectPath() == menuObjectPath.path(); }); } diff --git a/src/atoms.h b/src/atoms.h index 72321ce9c4..d21886e59d 100644 --- a/src/atoms.h +++ b/src/atoms.h @@ -91,8 +91,7 @@ private: bool m_helpersRetrieved; }; - -extern KWIN_EXPORT Atoms* atoms; +extern KWIN_EXPORT Atoms *atoms; } // namespace diff --git a/src/backends/drm/drm_abstract_output.cpp b/src/backends/drm/drm_abstract_output.cpp index 3e2d2de0c2..017852c034 100644 --- a/src/backends/drm/drm_abstract_output.cpp +++ b/src/backends/drm/drm_abstract_output.cpp @@ -7,8 +7,8 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "drm_abstract_output.h" -#include "drm_gpu.h" #include "drm_backend.h" +#include "drm_gpu.h" #include "renderloop_p.h" namespace KWin diff --git a/src/backends/drm/drm_backend.cpp b/src/backends/drm/drm_backend.cpp index bc2ab005c3..a1988064aa 100644 --- a/src/backends/drm/drm_backend.cpp +++ b/src/backends/drm/drm_backend.cpp @@ -7,14 +7,22 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "drm_backend.h" -#include "backends/libinput/libinputbackend.h" + #include -#include "drm_output.h" + +#include "backends/libinput/libinputbackend.h" +#include "composite.h" +#include "cursor.h" +#include "drm_gpu.h" #include "drm_object_connector.h" #include "drm_object_crtc.h" #include "drm_object_plane.h" -#include "composite.h" -#include "cursor.h" +#include "drm_output.h" +#include "drm_pipeline.h" +#include "drm_render_backend.h" +#include "drm_virtual_output.h" +#include "egl_gbm_backend.h" +#include "gbm_dmabuf.h" #include "logging.h" #include "main.h" #include "renderloop.h" @@ -22,13 +30,7 @@ #include "scene_qpainter_drm_backend.h" #include "session.h" #include "udev.h" -#include "drm_gpu.h" -#include "drm_pipeline.h" -#include "drm_virtual_output.h" #include "waylandoutputconfig.h" -#include "egl_gbm_backend.h" -#include "gbm_dmabuf.h" -#include "drm_render_backend.h" // KF5 #include #include @@ -41,14 +43,14 @@ #include // system #include -#include -#include #include #include +#include +#include // drm #include -#include #include +#include namespace KWin { @@ -322,7 +324,7 @@ void DrmBackend::updateOutputs() } } - std::sort(m_outputs.begin(), m_outputs.end(), [] (DrmAbstractOutput *a, DrmAbstractOutput *b) { + std::sort(m_outputs.begin(), m_outputs.end(), [](DrmAbstractOutput *a, DrmAbstractOutput *b) { auto da = qobject_cast(a); auto db = qobject_cast(b); if (da && !db) { @@ -341,94 +343,94 @@ void DrmBackend::updateOutputs() namespace KWinKScreenIntegration { - /// See KScreen::Output::hashMd5 - QString outputHash(DrmAbstractOutput *output) - { - QCryptographicHash hash(QCryptographicHash::Md5); - if (!output->edid().isEmpty()) { - hash.addData(output->edid()); - } else { - hash.addData(output->name().toLatin1()); - } - return QString::fromLatin1(hash.result().toHex()); - } - - /// See KScreen::Config::connectedOutputsHash in libkscreen - QString connectedOutputsHash(const QVector &outputs) - { - QStringList hashedOutputs; - hashedOutputs.reserve(outputs.count()); - for (auto output : qAsConst(outputs)) { - if (!output->isPlaceholder()) { - hashedOutputs << outputHash(output); - } - } - std::sort(hashedOutputs.begin(), hashedOutputs.end()); - const auto hash = QCryptographicHash::hash(hashedOutputs.join(QString()).toLatin1(), QCryptographicHash::Md5); - return QString::fromLatin1(hash.toHex()); - } - - QMap outputsConfig(const QVector &outputs) - { - const QString kscreenJsonPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kscreen/") % connectedOutputsHash(outputs)); - if (kscreenJsonPath.isEmpty()) { - return {}; - } - - QFile f(kscreenJsonPath); - if (!f.open(QIODevice::ReadOnly)) { - qCWarning(KWIN_DRM) << "Could not open file" << kscreenJsonPath; - return {}; - } - - QJsonParseError error; - const auto doc = QJsonDocument::fromJson(f.readAll(), &error); - if (error.error != QJsonParseError::NoError) { - qCWarning(KWIN_DRM) << "Failed to parse" << kscreenJsonPath << error.errorString(); - return {}; - } - - QMap ret; - const auto outputsJson = doc.array(); - for (const auto &outputJson : outputsJson) { - const auto outputObject = outputJson.toObject(); - for (auto it = outputs.constBegin(), itEnd = outputs.constEnd(); it != itEnd; ) { - if (!ret.contains(*it) && outputObject["id"] == outputHash(*it)) { - ret[*it] = outputObject; - continue; - } - ++it; - } - } - return ret; - } - - /// See KScreen::Output::Rotation - enum Rotation { - None = 1, - Left = 2, - Inverted = 4, - Right = 8, - }; - - DrmOutput::Transform toDrmTransform(int rotation) - { - switch (Rotation(rotation)) { - case None: - return DrmOutput::Transform::Normal; - case Left: - return DrmOutput::Transform::Rotated90; - case Inverted: - return DrmOutput::Transform::Rotated180; - case Right: - return DrmOutput::Transform::Rotated270; - default: - Q_UNREACHABLE(); - } +/// See KScreen::Output::hashMd5 +QString outputHash(DrmAbstractOutput *output) +{ + QCryptographicHash hash(QCryptographicHash::Md5); + if (!output->edid().isEmpty()) { + hash.addData(output->edid()); + } else { + hash.addData(output->name().toLatin1()); } + return QString::fromLatin1(hash.result().toHex()); } -bool DrmBackend::readOutputsConfiguration(const QVector &outputs) +/// See KScreen::Config::connectedOutputsHash in libkscreen +QString connectedOutputsHash(const QVector &outputs) +{ + QStringList hashedOutputs; + hashedOutputs.reserve(outputs.count()); + for (auto output : qAsConst(outputs)) { + if (!output->isPlaceholder()) { + hashedOutputs << outputHash(output); + } + } + std::sort(hashedOutputs.begin(), hashedOutputs.end()); + const auto hash = QCryptographicHash::hash(hashedOutputs.join(QString()).toLatin1(), QCryptographicHash::Md5); + return QString::fromLatin1(hash.toHex()); +} + +QMap outputsConfig(const QVector &outputs) +{ + const QString kscreenJsonPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kscreen/") % connectedOutputsHash(outputs)); + if (kscreenJsonPath.isEmpty()) { + return {}; + } + + QFile f(kscreenJsonPath); + if (!f.open(QIODevice::ReadOnly)) { + qCWarning(KWIN_DRM) << "Could not open file" << kscreenJsonPath; + return {}; + } + + QJsonParseError error; + const auto doc = QJsonDocument::fromJson(f.readAll(), &error); + if (error.error != QJsonParseError::NoError) { + qCWarning(KWIN_DRM) << "Failed to parse" << kscreenJsonPath << error.errorString(); + return {}; + } + + QMap ret; + const auto outputsJson = doc.array(); + for (const auto &outputJson : outputsJson) { + const auto outputObject = outputJson.toObject(); + for (auto it = outputs.constBegin(), itEnd = outputs.constEnd(); it != itEnd;) { + if (!ret.contains(*it) && outputObject["id"] == outputHash(*it)) { + ret[*it] = outputObject; + continue; + } + ++it; + } + } + return ret; +} + +/// See KScreen::Output::Rotation +enum Rotation { + None = 1, + Left = 2, + Inverted = 4, + Right = 8, +}; + +DrmOutput::Transform toDrmTransform(int rotation) +{ + switch (Rotation(rotation)) { + case None: + return DrmOutput::Transform::Normal; + case Left: + return DrmOutput::Transform::Rotated90; + case Inverted: + return DrmOutput::Transform::Rotated180; + case Right: + return DrmOutput::Transform::Rotated270; + default: + Q_UNREACHABLE(); + } +} +} + +bool DrmBackend::readOutputsConfiguration(const QVector &outputs) { Q_ASSERT(!outputs.isEmpty()); const auto outputsInfo = KWinKScreenIntegration::outputsConfig(outputs); @@ -573,7 +575,8 @@ QString DrmBackend::supportInformation() const QString supportInfo; QDebug s(&supportInfo); s.nospace(); - s << "Name: " << "DRM" << Qt::endl; + s << "Name: " + << "DRM" << Qt::endl; s << "Active: " << m_active << Qt::endl; for (int g = 0; g < m_gpus.size(); g++) { s << "Atomic Mode Setting on GPU " << g << ": " << m_gpus.at(g)->atomicModeSetting() << Qt::endl; @@ -600,7 +603,7 @@ void DrmBackend::removeVirtualOutput(AbstractOutput *output) DmaBufTexture *DrmBackend::createDmaBufTexture(const QSize &size) { - if (const auto eglBackend = dynamic_cast(m_renderBackend); eglBackend && primaryGpu()->gbmDevice()) { + if (const auto eglBackend = dynamic_cast(m_renderBackend); eglBackend && primaryGpu()->gbmDevice()) { eglBackend->makeCurrent(); return GbmDmaBuf::createBuffer(size, primaryGpu()->gbmDevice()); } else { @@ -635,12 +638,12 @@ DrmGpu *DrmBackend::findGpuByFd(int fd) const bool DrmBackend::applyOutputChanges(const WaylandOutputConfig &config) { - QVector toBeEnabled; - QVector toBeDisabled; + QVector toBeEnabled; + QVector toBeDisabled; for (const auto &gpu : qAsConst(m_gpus)) { const auto &outputs = gpu->outputs(); for (const auto &o : outputs) { - DrmOutput *output = qobject_cast(o); + DrmOutput *output = qobject_cast(o); if (!output) { // virtual outputs don't need testing continue; @@ -672,7 +675,7 @@ bool DrmBackend::applyOutputChanges(const WaylandOutputConfig &config) } // only then apply changes to the virtual outputs for (const auto &output : qAsConst(m_outputs)) { - if (!qobject_cast(output)) { + if (!qobject_cast(output)) { output->applyChanges(config); } } diff --git a/src/backends/drm/drm_backend.h b/src/backends/drm/drm_backend.h index 895eecb008..5763a90a8b 100644 --- a/src/backends/drm/drm_backend.h +++ b/src/backends/drm/drm_backend.h @@ -43,7 +43,7 @@ public: InputBackend *createInputBackend() override; QPainterBackend *createQPainterBackend() override; - OpenGLBackend* createOpenGLBackend() override; + OpenGLBackend *createOpenGLBackend() override; DmaBufTexture *createDmaBufTexture(const QSize &size) override; Session *session() const override; bool initialize() override; @@ -85,13 +85,13 @@ protected: private: friend class DrmGpu; - void addOutput(DrmAbstractOutput* output); - void removeOutput(DrmAbstractOutput* output); + void addOutput(DrmAbstractOutput *output); + void removeOutput(DrmAbstractOutput *output); void activate(bool active); void reactivate(); void deactivate(); void updateOutputs(); - bool readOutputsConfiguration(const QVector &outputs); + bool readOutputsConfiguration(const QVector &outputs); void handleUdevEvent(); DrmGpu *addGpu(const QString &fileName); @@ -99,21 +99,19 @@ private: QScopedPointer m_udevMonitor; Session *m_session = nullptr; // all outputs, enabled and disabled - QVector m_outputs; + QVector m_outputs; // only enabled outputs - QVector m_enabledOutputs; + QVector m_enabledOutputs; DrmVirtualOutput *m_placeHolderOutput = nullptr; bool m_active = false; const QStringList m_explicitGpus; - QVector m_gpus; + QVector m_gpus; QScopedPointer m_dpmsFilter; QScopedPointer m_placeholderFilter; DrmRenderBackend *m_renderBackend = nullptr; }; - } #endif - diff --git a/src/backends/drm/drm_buffer.cpp b/src/backends/drm/drm_buffer.cpp index 4220ceca52..206dc93e21 100644 --- a/src/backends/drm/drm_buffer.cpp +++ b/src/backends/drm/drm_buffer.cpp @@ -8,17 +8,17 @@ */ #include "drm_buffer.h" -#include "logging.h" #include "drm_gpu.h" +#include "logging.h" // system #include // c++ #include // drm +#include #include #include -#include namespace KWin { @@ -102,8 +102,9 @@ DrmDumbBuffer::~DrmDumbBuffer() } } -bool DrmDumbBuffer::needsModeChange(DrmBuffer *b) const { - if (DrmDumbBuffer *db = dynamic_cast(b)) { +bool DrmDumbBuffer::needsModeChange(DrmBuffer *b) const +{ + if (DrmDumbBuffer *db = dynamic_cast(b)) { return m_stride != db->stride(); } else { return true; @@ -126,7 +127,7 @@ bool DrmDumbBuffer::map(QImage::Format format) return false; } m_memory = address; - m_image = new QImage((uchar*)m_memory, m_size.width(), m_size.height(), m_stride, format); + m_image = new QImage((uchar *)m_memory, m_size.width(), m_size.height(), m_stride, format); return !m_image->isNull(); } diff --git a/src/backends/drm/drm_buffer.h b/src/backends/drm/drm_buffer.h index 02bc8b13c3..5290997615 100644 --- a/src/backends/drm/drm_buffer.h +++ b/src/backends/drm/drm_buffer.h @@ -23,7 +23,11 @@ public: DrmBuffer(DrmGpu *gpu, uint32_t format, uint64_t modifier); virtual ~DrmBuffer() = default; - virtual bool needsModeChange(DrmBuffer *b) const {Q_UNUSED(b) return false;} + virtual bool needsModeChange(DrmBuffer *b) const + { + Q_UNUSED(b) + return false; + } quint32 bufferId() const; const QSize &size() const; @@ -64,4 +68,3 @@ private: } #endif - diff --git a/src/backends/drm/drm_buffer_gbm.cpp b/src/backends/drm/drm_buffer_gbm.cpp index 775b658ee6..cf2fb31cc9 100644 --- a/src/backends/drm/drm_buffer_gbm.cpp +++ b/src/backends/drm/drm_buffer_gbm.cpp @@ -10,18 +10,18 @@ #include "drm_buffer_gbm.h" #include "gbm_surface.h" -#include "logging.h" #include "drm_gpu.h" +#include "logging.h" // system #include // c++ #include // drm +#include +#include #include #include -#include -#include // KWaylandServer #include "KWaylandServer/clientbuffer.h" #include "KWaylandServer/linuxdmabufv1clientbuffer.h" @@ -44,8 +44,8 @@ GbmBuffer::GbmBuffer(DrmGpu *gpu, KWaylandServer::LinuxDmaBufV1ClientBuffer *cli if (planes.first().modifier != DRM_FORMAT_MOD_INVALID || planes.first().offset > 0 || planes.count() > 1) { gbm_import_fd_modifier_data data = {}; data.format = clientBuffer->format(); - data.width = (uint32_t) clientBuffer->size().width(); - data.height = (uint32_t) clientBuffer->size().height(); + data.width = (uint32_t)clientBuffer->size().width(); + data.height = (uint32_t)clientBuffer->size().height(); data.num_fds = planes.count(); data.modifier = planes.first().modifier; for (int i = 0; i < planes.count(); i++) { @@ -58,8 +58,8 @@ GbmBuffer::GbmBuffer(DrmGpu *gpu, KWaylandServer::LinuxDmaBufV1ClientBuffer *cli const auto &plane = planes.first(); gbm_import_fd_data data = {}; data.fd = plane.fd; - data.width = (uint32_t) clientBuffer->size().width(); - data.height = (uint32_t) clientBuffer->size().height(); + data.width = (uint32_t)clientBuffer->size().width(); + data.height = (uint32_t)clientBuffer->size().height(); data.stride = plane.stride; data.format = clientBuffer->format(); m_bo = gbm_bo_import(gpu->gbmDevice(), GBM_BO_IMPORT_FD, &data, GBM_BO_USE_SCANOUT); @@ -114,7 +114,7 @@ KWaylandServer::ClientBuffer *GbmBuffer::clientBuffer() const return m_clientBuffer; } -gbm_bo* GbmBuffer::getBo() const +gbm_bo *GbmBuffer::getBo() const { return m_bo; } @@ -129,7 +129,6 @@ uint32_t GbmBuffer::stride() const return m_stride; } - DrmGbmBuffer::DrmGbmBuffer(DrmGpu *gpu, GbmSurface *surface, gbm_bo *bo) : DrmBuffer(gpu, gbm_bo_get_format(bo), gbm_bo_get_modifier(bo)) , GbmBuffer(surface, bo) @@ -159,10 +158,10 @@ void DrmGbmBuffer::initialize() return; } m_size = QSize(gbm_bo_get_width(m_bo), gbm_bo_get_height(m_bo)); - uint32_t handles[4] = { }; - uint32_t strides[4] = { }; - uint32_t offsets[4] = { }; - uint64_t modifiers[4] = { }; + uint32_t handles[4] = {}; + uint32_t strides[4] = {}; + uint32_t offsets[4] = {}; + uint64_t modifiers[4] = {}; if (gbm_bo_get_handle_for_plane(m_bo, 0).s32 != -1) { for (int i = 0; i < gbm_bo_get_plane_count(m_bo); i++) { @@ -203,7 +202,7 @@ void DrmGbmBuffer::initialize() bool DrmGbmBuffer::needsModeChange(DrmBuffer *b) const { - if (DrmGbmBuffer *sb = dynamic_cast(b)) { + if (DrmGbmBuffer *sb = dynamic_cast(b)) { return hasBo() != sb->hasBo(); } else { return true; diff --git a/src/backends/drm/drm_buffer_gbm.h b/src/backends/drm/drm_buffer_gbm.h index c58302d70c..c6ee25c6d4 100644 --- a/src/backends/drm/drm_buffer_gbm.h +++ b/src/backends/drm/drm_buffer_gbm.h @@ -41,7 +41,7 @@ public: void *mappedData() const; uint32_t stride() const; KWaylandServer::ClientBuffer *clientBuffer() const; - gbm_bo* getBo() const; + gbm_bo *getBo() const; protected: GbmSurface *m_surface = nullptr; @@ -70,4 +70,3 @@ private: } #endif - diff --git a/src/backends/drm/drm_gpu.cpp b/src/backends/drm/drm_gpu.cpp index 537f59db84..3022e35ab6 100644 --- a/src/backends/drm/drm_gpu.cpp +++ b/src/backends/drm/drm_gpu.cpp @@ -6,37 +6,38 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "drm_gpu.h" + #include + +#include "abstract_egl_backend.h" #include "drm_backend.h" -#include "drm_output.h" +#include "drm_lease_output.h" #include "drm_object_connector.h" #include "drm_object_crtc.h" -#include "abstract_egl_backend.h" -#include "logging.h" -#include "session.h" -#include "renderloop_p.h" -#include "main.h" +#include "drm_object_plane.h" +#include "drm_output.h" #include "drm_pipeline.h" #include "drm_virtual_output.h" -#include "wayland_server.h" -#include "drm_lease_output.h" #include "egl_gbm_backend.h" #include "gbm_dmabuf.h" -#include "drm_object_plane.h" +#include "logging.h" +#include "main.h" +#include "renderloop_p.h" +#include "session.h" +#include "wayland_server.h" // system #include #include +#include #include #include -#include // drm +#include #include +#include #include #include -#include -#include // KWaylandServer #include "KWaylandServer/drmleasedevice_v1_interface.h" @@ -79,7 +80,7 @@ DrmGpu::DrmGpu(DrmBackend *backend, const QString &devNode, int fd, dev_t device DrmScopedPointer version(drmGetVersion(fd)); m_isNVidia = strstr(version->name, "nvidia-drm"); m_isVirtualMachine = strstr(version->name, "virtio") || strstr(version->name, "qxl") - || strstr(version->name, "vmwgfx") || strstr(version->name, "vboxvideo"); + || strstr(version->name, "vmwgfx") || strstr(version->name, "vboxvideo"); m_gbmDevice = gbm_create_device(m_fd); m_socketNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this); @@ -87,7 +88,7 @@ DrmGpu::DrmGpu(DrmBackend *backend, const QString &devNode, int fd, dev_t device initDrmResources(); - m_leaseDevice = new KWaylandServer::DrmLeaseDeviceV1Interface(waylandServer()->display(), [this]{ + m_leaseDevice = new KWaylandServer::DrmLeaseDeviceV1Interface(waylandServer()->display(), [this] { char *path = drmGetDeviceNameFromFd2(m_fd); int fd = open(path, O_RDWR | O_CLOEXEC); if (fd < 0) { @@ -126,7 +127,7 @@ DrmGpu::~DrmGpu() if (auto drmOutput = qobject_cast(output)) { removeOutput(drmOutput); } else { - removeVirtualOutput(dynamic_cast(output)); + removeVirtualOutput(dynamic_cast(output)); } } if (m_eglDisplay != EGL_NO_DISPLAY) { @@ -156,7 +157,7 @@ void DrmGpu::initDrmResources() qCWarning(KWIN_DRM, "Atomic Mode Setting disabled on GPU %s because of cursor offset issues in virtual machines", qPrintable(m_devNode)); } else if (noAMS) { qCWarning(KWIN_DRM) << "Atomic Mode Setting requested off via environment variable. Using legacy mode on GPU" << m_devNode; - } else if(drmSetClientCap(m_fd, DRM_CLIENT_CAP_ATOMIC, 1) != 0) { + } else if (drmSetClientCap(m_fd, DRM_CLIENT_CAP_ATOMIC, 1) != 0) { qCWarning(KWIN_DRM) << "drmSetClientCap for Atomic Mode Setting failed. Using legacy mode on GPU" << m_devNode; } else { DrmScopedPointer planeResources(drmModeGetPlaneResources(m_fd)); @@ -252,7 +253,9 @@ bool DrmGpu::updateOutputs() QVector removedConnectors = m_connectors; for (int i = 0; i < resources->count_connectors; ++i) { const uint32_t currentConnector = resources->connectors[i]; - auto it = std::find_if(m_connectors.constBegin(), m_connectors.constEnd(), [currentConnector] (DrmConnector *c) { return c->id() == currentConnector; }); + auto it = std::find_if(m_connectors.constBegin(), m_connectors.constEnd(), [currentConnector](DrmConnector *c) { + return c->id() == currentConnector; + }); DrmConnector *conn = it == m_connectors.constEnd() ? nullptr : *it; bool updateSuccess = true; if (!conn) { @@ -327,7 +330,7 @@ bool DrmGpu::updateOutputs() return true; } -bool DrmGpu::checkCrtcAssignment(QVector connectors, const QVector &crtcs) +bool DrmGpu::checkCrtcAssignment(QVector connectors, const QVector &crtcs) { if (connectors.isEmpty() || crtcs.isEmpty()) { if (m_pipelines.isEmpty()) { @@ -396,11 +399,11 @@ bool DrmGpu::testPendingConfiguration(TestMode mode) } if (m_atomicModeSetting) { // sort outputs by being already connected (to any CRTC) so that already working outputs get preferred - std::sort(connectors.begin(), connectors.end(), [](auto c1, auto c2){ + std::sort(connectors.begin(), connectors.end(), [](auto c1, auto c2) { return c1->getProp(DrmConnector::PropertyIndex::CrtcId)->current() > c2->getProp(DrmConnector::PropertyIndex::CrtcId)->current(); }); } - const auto &test = [&connectors, &crtcs, this, mode](){ + const auto &test = [&connectors, &crtcs, this, mode]() { if (mode == TestMode::TestWithCrtcReallocation) { return checkCrtcAssignment(connectors, crtcs); } else { @@ -423,7 +426,7 @@ bool DrmGpu::testPendingConfiguration(TestMode mode) bool DrmGpu::testPipelines() { // pipelines that are enabled but not active need to be activated for the test - QVector inactivePipelines; + QVector inactivePipelines; for (const auto &pipeline : qAsConst(m_pipelines)) { if (!pipeline->pending.layer) { pipeline->pending.layer = m_platform->renderBackend()->createDrmPipelineLayer(pipeline); @@ -447,7 +450,7 @@ bool DrmGpu::testPipelines() DrmOutput *DrmGpu::findOutput(quint32 connector) { - auto it = std::find_if(m_drmOutputs.constBegin(), m_drmOutputs.constEnd(), [connector] (DrmOutput *o) { + auto it = std::find_if(m_drmOutputs.constBegin(), m_drmOutputs.constEnd(), [connector](DrmOutput *o) { return o->connector()->id() == connector; }); if (it != m_drmOutputs.constEnd()) { @@ -460,7 +463,7 @@ void DrmGpu::waitIdle() { m_socketNotifier->setEnabled(false); while (true) { - const bool idle = std::all_of(m_drmOutputs.constBegin(), m_drmOutputs.constEnd(), [](DrmOutput *output){ + const bool idle = std::all_of(m_drmOutputs.constBegin(), m_drmOutputs.constEnd(), [](DrmOutput *output) { return !output->pipeline()->pageflipPending(); }); if (idle) { @@ -512,7 +515,7 @@ void DrmGpu::pageFlipHandler(int fd, unsigned int sequence, unsigned int sec, un { Q_UNUSED(sequence) Q_UNUSED(user_data) - auto backend = dynamic_cast(kwinApp()->platform()); + auto backend = dynamic_cast(kwinApp()->platform()); if (!backend) { return; } @@ -527,7 +530,7 @@ void DrmGpu::pageFlipHandler(int fd, unsigned int sequence, unsigned int sec, un // year 2038), similarly long can't hold all the bits of an // unsigned multiplication. std::chrono::nanoseconds timestamp = convertTimestamp(gpu->presentationClock(), CLOCK_MONOTONIC, - { static_cast(sec), static_cast(usec * 1000) }); + {static_cast(sec), static_cast(usec * 1000)}); if (timestamp == std::chrono::nanoseconds::zero()) { qCDebug(KWIN_DRM, "Got invalid timestamp (sec: %u, usec: %u) on gpu %s", sec, usec, qPrintable(gpu->devNode())); @@ -566,11 +569,12 @@ void DrmGpu::removeOutput(DrmOutput *output) delete output; } -DrmBackend *DrmGpu::platform() const { +DrmBackend *DrmGpu::platform() const +{ return m_platform; } -const QVector DrmGpu::pipelines() const +const QVector DrmGpu::pipelines() const { return m_pipelines; } @@ -596,7 +600,7 @@ void DrmGpu::removeVirtualOutput(DrmVirtualOutput *output) DrmLeaseOutput *DrmGpu::findLeaseOutput(quint32 connector) { - auto it = std::find_if(m_leaseOutputs.constBegin(), m_leaseOutputs.constEnd(), [connector] (DrmLeaseOutput *o) { + auto it = std::find_if(m_leaseOutputs.constBegin(), m_leaseOutputs.constEnd(), [connector](DrmLeaseOutput *o) { return o->pipeline()->connector()->id() == connector; }); if (it != m_leaseOutputs.constEnd()) { @@ -608,10 +612,10 @@ DrmLeaseOutput *DrmGpu::findLeaseOutput(quint32 connector) void DrmGpu::handleLeaseRequest(KWaylandServer::DrmLeaseV1Interface *leaseRequest) { QVector objects; - QVector outputs; + QVector outputs; const auto conns = leaseRequest->connectors(); for (const auto &connector : conns) { - auto output = qobject_cast(connector); + auto output = qobject_cast(connector); if (m_leaseOutputs.contains(output) && !output->lease()) { if (!output->addLeaseObjects(objects)) { leaseRequest->deny(); @@ -645,7 +649,7 @@ void DrmGpu::handleLeaseRevoked(KWaylandServer::DrmLeaseV1Interface *lease) { const auto conns = lease->connectors(); for (const auto &connector : conns) { - auto output = qobject_cast(connector); + auto output = qobject_cast(connector); if (m_leaseOutputs.contains(output)) { output->leaseEnded(); } @@ -663,7 +667,7 @@ void DrmGpu::removeLeaseOutput(DrmLeaseOutput *output) delete output; } -QVector DrmGpu::outputs() const +QVector DrmGpu::outputs() const { return m_outputs; } @@ -716,10 +720,11 @@ bool DrmGpu::isNVidia() const bool DrmGpu::needsModeset() const { return std::any_of(m_pipelines.constBegin(), m_pipelines.constEnd(), [](const auto &pipeline) { - return pipeline->needsModeset(); - }) || std::any_of(m_allObjects.constBegin(), m_allObjects.constEnd(), [](const auto &object) { - return object->needsModeset(); - }); + return pipeline->needsModeset(); + }) + || std::any_of(m_allObjects.constBegin(), m_allObjects.constEnd(), [](const auto &object) { + return object->needsModeset(); + }); } bool DrmGpu::maybeModeset() @@ -751,12 +756,12 @@ bool DrmGpu::maybeModeset() return ok; } -QVector DrmGpu::unusedObjects() const +QVector DrmGpu::unusedObjects() const { if (!m_atomicModeSetting) { return {}; } - QVector ret = m_allObjects; + QVector ret = m_allObjects; for (const auto &pipeline : m_pipelines) { ret.removeOne(pipeline->connector()); if (pipeline->pending.crtc) { @@ -779,7 +784,7 @@ void DrmGpu::recreateSurfaces() pipeline->pending.layer = m_platform->renderBackend()->createDrmPipelineLayer(pipeline); } for (const auto &output : qAsConst(m_outputs)) { - if (const auto virtualOutput = qobject_cast(output)) { + if (const auto virtualOutput = qobject_cast(output)) { virtualOutput->recreateSurface(); } } diff --git a/src/backends/drm/drm_gpu.h b/src/backends/drm/drm_gpu.h index 1e1f7e3b15..a5e6aabbdc 100644 --- a/src/backends/drm/drm_gpu.h +++ b/src/backends/drm/drm_gpu.h @@ -10,11 +10,11 @@ #ifndef DRM_GPU_H #define DRM_GPU_H -#include -#include -#include #include #include +#include +#include +#include #include #include @@ -67,14 +67,17 @@ public: clockid_t presentationClock() const; QSize cursorSize() const; - QVector outputs() const; - const QVector pipelines() const; + QVector outputs() const; + const QVector pipelines() const; void setEglDisplay(EGLDisplay display); bool updateOutputs(); - enum VirtualOutputMode { Placeholder, Full }; + enum VirtualOutputMode { + Placeholder, + Full, + }; DrmVirtualOutput *createVirtualOutput(const QString &name, const QSize &size, double scale, VirtualOutputMode mode); void removeVirtualOutput(DrmVirtualOutput *output); @@ -103,9 +106,9 @@ private: void initDrmResources(); void waitIdle(); - bool checkCrtcAssignment(QVector connectors, const QVector &crtcs); + bool checkCrtcAssignment(QVector connectors, const QVector &crtcs); bool testPipelines(); - QVector unusedObjects() const; + QVector unusedObjects() const; void handleLeaseRequest(KWaylandServer::DrmLeaseV1Interface *leaseRequest); void handleLeaseRevoked(KWaylandServer::DrmLeaseV1Interface *lease); @@ -120,19 +123,19 @@ private: bool m_isNVidia; bool m_isVirtualMachine; clockid_t m_presentationClock; - gbm_device* m_gbmDevice; + gbm_device *m_gbmDevice; EGLDisplay m_eglDisplay = EGL_NO_DISPLAY; - DrmBackend* const m_platform; + DrmBackend *const m_platform; - QVector m_planes; - QVector m_crtcs; - QVector m_connectors; - QVector m_allObjects; - QVector m_pipelines; + QVector m_planes; + QVector m_crtcs; + QVector m_connectors; + QVector m_allObjects; + QVector m_pipelines; - QVector m_drmOutputs; - QVector m_outputs; - QVector m_leaseOutputs; + QVector m_drmOutputs; + QVector m_outputs; + QVector m_leaseOutputs; KWaylandServer::DrmLeaseDeviceV1Interface *m_leaseDevice = nullptr; QSocketNotifier *m_socketNotifier = nullptr; diff --git a/src/backends/drm/drm_layer.h b/src/backends/drm/drm_layer.h index a042027c8b..58799370ef 100644 --- a/src/backends/drm/drm_layer.h +++ b/src/backends/drm/drm_layer.h @@ -8,10 +8,10 @@ */ #pragma once -#include +#include #include #include -#include +#include namespace KWin { diff --git a/src/backends/drm/drm_lease_egl_gbm_layer.cpp b/src/backends/drm/drm_lease_egl_gbm_layer.cpp index 115d6fd696..7f8e40338e 100644 --- a/src/backends/drm/drm_lease_egl_gbm_layer.cpp +++ b/src/backends/drm/drm_lease_egl_gbm_layer.cpp @@ -8,9 +8,9 @@ */ #include "drm_lease_egl_gbm_layer.h" #include "drm_buffer_gbm.h" -#include "egl_gbm_backend.h" -#include "drm_pipeline.h" #include "drm_gpu.h" +#include "drm_pipeline.h" +#include "egl_gbm_backend.h" #include "logging.h" #include diff --git a/src/backends/drm/drm_lease_output.cpp b/src/backends/drm/drm_lease_output.cpp index 37a2545137..5585b426e8 100644 --- a/src/backends/drm/drm_lease_output.cpp +++ b/src/backends/drm/drm_lease_output.cpp @@ -10,11 +10,11 @@ #include "drm_lease_output.h" #include "KWaylandServer/drmleasedevice_v1_interface.h" +#include "drm_layer.h" #include "drm_object_connector.h" #include "drm_object_crtc.h" #include "drm_object_plane.h" #include "drm_pipeline.h" -#include "drm_layer.h" #include "logging.h" @@ -28,8 +28,7 @@ DrmLeaseOutput::DrmLeaseOutput(DrmPipeline *pipeline, KWaylandServer::DrmLeaseDe leaseDevice, pipeline->connector()->id(), pipeline->connector()->modelName(), - QStringLiteral("%1 %2").arg(pipeline->connector()->edid()->manufacturerString(), pipeline->connector()->modelName()) - ) + QStringLiteral("%1 %2").arg(pipeline->connector()->edid()->manufacturerString(), pipeline->connector()->modelName())) , m_pipeline(pipeline) { qCDebug(KWIN_DRM) << "offering connector" << m_pipeline->connector()->id() << "for lease"; diff --git a/src/backends/drm/drm_lease_output.h b/src/backends/drm/drm_lease_output.h index ae8db03128..6df0fd7010 100644 --- a/src/backends/drm/drm_lease_output.h +++ b/src/backends/drm/drm_lease_output.h @@ -9,9 +9,9 @@ #pragma once +#include #include #include -#include namespace KWin { diff --git a/src/backends/drm/drm_object.cpp b/src/backends/drm/drm_object.cpp index 358ce41e53..2e4ce6de3b 100644 --- a/src/backends/drm/drm_object.cpp +++ b/src/backends/drm/drm_object.cpp @@ -38,7 +38,7 @@ bool DrmObject::initProps() } if (KWIN_DRM().isDebugEnabled()) { auto debug = QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC, KWIN_DRM().categoryName()).debug().nospace(); - switch(m_objectType) { + switch (m_objectType) { case DRM_MODE_OBJECT_CONNECTOR: debug << "Connector "; break; @@ -208,7 +208,7 @@ QDebug operator<<(QDebug s, const KWin::DrmObject *obj) { QDebugStateSaver saver(s); if (obj) { - s.nospace() << "DrmObject(id=" << obj->id() << ", gpu="<< obj->gpu() << ')'; + s.nospace() << "DrmObject(id=" << obj->id() << ", gpu=" << obj->gpu() << ')'; } else { s << "DrmObject(0x0)"; } diff --git a/src/backends/drm/drm_object.h b/src/backends/drm/drm_object.h index ad34a67b3e..aa377872d2 100644 --- a/src/backends/drm/drm_object.h +++ b/src/backends/drm/drm_object.h @@ -8,9 +8,9 @@ */ #pragma once -#include #include #include +#include // drm #include @@ -45,7 +45,7 @@ public: DrmGpu *gpu() const; uint32_t type() const; QString typeName() const; - QVector properties(); + QVector properties(); void commit(); void commitPending(); @@ -55,7 +55,7 @@ public: virtual bool needsModeset() const = 0; virtual bool updateProperties(); - template + template bool setPending(T prop, uint64_t new_value) { if (auto &property = m_props.at(static_cast(prop))) { @@ -65,15 +65,16 @@ public: return false; } - template + template bool propHasEnum(T prop, uint64_t value) const { const auto &property = m_props.at(static_cast(prop)); return property ? property->hasEnum(value) : false; } - template - DrmProperty *getProp(T propIndex) const { + template + DrmProperty *getProp(T propIndex) const + { return m_props[static_cast(propIndex)]; } @@ -100,7 +101,7 @@ protected: bool initProps(); - template + template void deleteProp(T prop) { delete m_props[static_cast(prop)]; @@ -118,4 +119,4 @@ private: } -QDebug operator<<(QDebug stream, const KWin::DrmObject*); +QDebug operator<<(QDebug stream, const KWin::DrmObject *); diff --git a/src/backends/drm/drm_object_connector.cpp b/src/backends/drm/drm_object_connector.cpp index baf129ffbe..4ca7a92d0c 100644 --- a/src/backends/drm/drm_object_connector.cpp +++ b/src/backends/drm/drm_object_connector.cpp @@ -9,11 +9,11 @@ */ #include "drm_object_connector.h" #include "drm_gpu.h" -#include "drm_pointer.h" -#include "logging.h" -#include "drm_pipeline.h" #include "drm_object_crtc.h" #include "drm_output.h" +#include "drm_pipeline.h" +#include "drm_pointer.h" +#include "logging.h" #include // frameworks @@ -26,18 +26,18 @@ namespace KWin static bool checkIfEqual(const drmModeModeInfo *one, const drmModeModeInfo *two) { - return one->clock == two->clock - && one->hdisplay == two->hdisplay + return one->clock == two->clock + && one->hdisplay == two->hdisplay && one->hsync_start == two->hsync_start - && one->hsync_end == two->hsync_end - && one->htotal == two->htotal - && one->hskew == two->hskew - && one->vdisplay == two->vdisplay + && one->hsync_end == two->hsync_end + && one->htotal == two->htotal + && one->hskew == two->hskew + && one->vdisplay == two->vdisplay && one->vsync_start == two->vsync_start - && one->vsync_end == two->vsync_end - && one->vtotal == two->vtotal - && one->vscan == two->vscan - && one->vrefresh == two->vrefresh; + && one->vsync_end == two->vsync_end + && one->vtotal == two->vtotal + && one->vscan == two->vscan + && one->vrefresh == two->vrefresh; } static quint64 refreshRateForMode(_drmModeModeInfo *m) @@ -105,30 +105,20 @@ bool DrmConnectorMode::operator==(const DrmConnectorMode &otherMode) DrmConnector::DrmConnector(DrmGpu *gpu, uint32_t connectorId) : DrmObject(gpu, connectorId, { - PropertyDefinition(QByteArrayLiteral("CRTC_ID"), Requirement::Required), - PropertyDefinition(QByteArrayLiteral("non-desktop"), Requirement::Optional), - PropertyDefinition(QByteArrayLiteral("DPMS"), Requirement::RequiredForLegacy), - PropertyDefinition(QByteArrayLiteral("EDID"), Requirement::Optional), - PropertyDefinition(QByteArrayLiteral("overscan"), Requirement::Optional), - PropertyDefinition(QByteArrayLiteral("vrr_capable"), Requirement::Optional), - PropertyDefinition(QByteArrayLiteral("underscan"), Requirement::Optional, { - QByteArrayLiteral("off"), - QByteArrayLiteral("on"), - QByteArrayLiteral("auto") - }), - PropertyDefinition(QByteArrayLiteral("underscan vborder"), Requirement::Optional), - PropertyDefinition(QByteArrayLiteral("underscan hborder"), Requirement::Optional), - PropertyDefinition(QByteArrayLiteral("Broadcast RGB"), Requirement::Optional, { - QByteArrayLiteral("Automatic"), - QByteArrayLiteral("Full"), - QByteArrayLiteral("Limited 16:235") - }), - PropertyDefinition(QByteArrayLiteral("max bpc"), Requirement::Optional), - PropertyDefinition(QByteArrayLiteral("link-status"), Requirement::Optional, { - QByteArrayLiteral("Good"), - QByteArrayLiteral("Bad") - }), - }, DRM_MODE_OBJECT_CONNECTOR) + PropertyDefinition(QByteArrayLiteral("CRTC_ID"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("non-desktop"), Requirement::Optional), + PropertyDefinition(QByteArrayLiteral("DPMS"), Requirement::RequiredForLegacy), + PropertyDefinition(QByteArrayLiteral("EDID"), Requirement::Optional), + PropertyDefinition(QByteArrayLiteral("overscan"), Requirement::Optional), + PropertyDefinition(QByteArrayLiteral("vrr_capable"), Requirement::Optional), + PropertyDefinition(QByteArrayLiteral("underscan"), Requirement::Optional, {QByteArrayLiteral("off"), QByteArrayLiteral("on"), QByteArrayLiteral("auto")}), + PropertyDefinition(QByteArrayLiteral("underscan vborder"), Requirement::Optional), + PropertyDefinition(QByteArrayLiteral("underscan hborder"), Requirement::Optional), + PropertyDefinition(QByteArrayLiteral("Broadcast RGB"), Requirement::Optional, {QByteArrayLiteral("Automatic"), QByteArrayLiteral("Full"), QByteArrayLiteral("Limited 16:235")}), + PropertyDefinition(QByteArrayLiteral("max bpc"), Requirement::Optional), + PropertyDefinition(QByteArrayLiteral("link-status"), Requirement::Optional, {QByteArrayLiteral("Good"), QByteArrayLiteral("Bad")}), + }, + DRM_MODE_OBJECT_CONNECTOR) , m_pipeline(new DrmPipeline(this)) , m_conn(drmModeGetConnector(gpu->fd(), connectorId)) { @@ -206,7 +196,7 @@ QString DrmConnector::modelName() const bool DrmConnector::isInternal() const { return m_conn->connector_type == DRM_MODE_CONNECTOR_LVDS || m_conn->connector_type == DRM_MODE_CONNECTOR_eDP - || m_conn->connector_type == DRM_MODE_CONNECTOR_DSI; + || m_conn->connector_type == DRM_MODE_CONNECTOR_DSI; } QSize DrmConnector::physicalSize() const @@ -346,9 +336,7 @@ bool DrmConnector::updateProperties() // the size might be completely borked. E.g. Samsung SyncMaster 2494HS reports 160x90 while in truth it's 520x292 // as this information is used to calculate DPI info, it's going to result in everything being huge const QByteArray unknown = QByteArrayLiteral("unknown"); - KConfigGroup group = kwinApp()->config()->group("EdidOverwrite").group(m_edid.eisaId().isEmpty() ? unknown : m_edid.eisaId()) - .group(m_edid.monitorName().isEmpty() ? unknown : m_edid.monitorName()) - .group(m_edid.serialNumber().isEmpty() ? unknown : m_edid.serialNumber()); + KConfigGroup group = kwinApp()->config()->group("EdidOverwrite").group(m_edid.eisaId().isEmpty() ? unknown : m_edid.eisaId()).group(m_edid.monitorName().isEmpty() ? unknown : m_edid.monitorName()).group(m_edid.serialNumber().isEmpty() ? unknown : m_edid.serialNumber()); if (group.hasKey("PhysicalSize")) { const QSize overwriteSize = group.readEntry("PhysicalSize", m_physicalSize); qCWarning(KWIN_DRM) << "Overwriting monitor physical size for" << m_edid.eisaId() << "/" << m_edid.monitorName() << "/" << m_edid.serialNumber() << " from " << m_physicalSize << "to " << overwriteSize; @@ -415,7 +403,7 @@ DrmConnector::LinkStatus DrmConnector::linkStatus() const return LinkStatus::Good; } -QDebug& operator<<(QDebug& s, const KWin::DrmConnector *obj) +QDebug &operator<<(QDebug &s, const KWin::DrmConnector *obj) { QDebugStateSaver saver(s); if (obj) { @@ -427,11 +415,7 @@ QDebug& operator<<(QDebug& s, const KWin::DrmConnector *obj) connState = QStringLiteral("Connected"); } - s.nospace() << "DrmConnector(id=" << obj->id() << - ", gpu="<< obj->gpu() << - ", name="<< obj->modelName() << - ", connection=" << connState << - ", countMode=" << (obj->m_conn ? obj->m_conn->count_modes : 0) + s.nospace() << "DrmConnector(id=" << obj->id() << ", gpu=" << obj->gpu() << ", name=" << obj->modelName() << ", connection=" << connState << ", countMode=" << (obj->m_conn ? obj->m_conn->count_modes : 0) << ')'; } else { s << "DrmConnector(0x0)"; diff --git a/src/backends/drm/drm_object_connector.h b/src/backends/drm/drm_object_connector.h index a92e951211..b7a8a70808 100644 --- a/src/backends/drm/drm_object_connector.h +++ b/src/backends/drm/drm_object_connector.h @@ -14,10 +14,10 @@ #include -#include "drm_object.h" -#include "edid.h" -#include "drm_pointer.h" #include "abstract_wayland_output.h" +#include "drm_object.h" +#include "drm_pointer.h" +#include "edid.h" namespace KWin { @@ -117,9 +117,9 @@ private: QVector> m_modes; uint32_t m_possibleCrtcs = 0; - friend QDebug& operator<<(QDebug& s, const KWin::DrmConnector *obj); + friend QDebug &operator<<(QDebug &s, const KWin::DrmConnector *obj); }; -QDebug& operator<<(QDebug& s, const KWin::DrmConnector *obj); +QDebug &operator<<(QDebug &s, const KWin::DrmConnector *obj); } diff --git a/src/backends/drm/drm_object_crtc.cpp b/src/backends/drm/drm_object_crtc.cpp index b314c7c514..2c0e6c9b77 100644 --- a/src/backends/drm/drm_object_crtc.cpp +++ b/src/backends/drm/drm_object_crtc.cpp @@ -8,24 +8,18 @@ */ #include "drm_object_crtc.h" #include "drm_backend.h" -#include "drm_output.h" #include "drm_buffer.h" +#include "drm_gpu.h" +#include "drm_output.h" #include "drm_pointer.h" #include "logging.h" -#include "drm_gpu.h" #include namespace KWin { DrmCrtc::DrmCrtc(DrmGpu *gpu, uint32_t crtcId, int pipeIndex, DrmPlane *primaryPlane, DrmPlane *cursorPlane) - : DrmObject(gpu, crtcId, { - PropertyDefinition(QByteArrayLiteral("MODE_ID"), Requirement::Required), - PropertyDefinition(QByteArrayLiteral("ACTIVE"), Requirement::Required), - PropertyDefinition(QByteArrayLiteral("VRR_ENABLED"), Requirement::Optional), - PropertyDefinition(QByteArrayLiteral("GAMMA_LUT"), Requirement::Optional), - PropertyDefinition(QByteArrayLiteral("GAMMA_LUT_SIZE"), Requirement::Optional) - }, DRM_MODE_OBJECT_CRTC) + : DrmObject(gpu, crtcId, {PropertyDefinition(QByteArrayLiteral("MODE_ID"), Requirement::Required), PropertyDefinition(QByteArrayLiteral("ACTIVE"), Requirement::Required), PropertyDefinition(QByteArrayLiteral("VRR_ENABLED"), Requirement::Optional), PropertyDefinition(QByteArrayLiteral("GAMMA_LUT"), Requirement::Optional), PropertyDefinition(QByteArrayLiteral("GAMMA_LUT_SIZE"), Requirement::Optional)}, DRM_MODE_OBJECT_CRTC) , m_crtc(drmModeGetCrtc(gpu->fd(), crtcId)) , m_pipeIndex(pipeIndex) , m_primaryPlane(primaryPlane) diff --git a/src/backends/drm/drm_object_crtc.h b/src/backends/drm/drm_object_crtc.h index 049dc00c4d..bba4560ec0 100644 --- a/src/backends/drm/drm_object_crtc.h +++ b/src/backends/drm/drm_object_crtc.h @@ -11,8 +11,8 @@ #include "drm_object.h" -#include #include +#include namespace KWin { @@ -66,4 +66,3 @@ private: } #endif - diff --git a/src/backends/drm/drm_object_plane.cpp b/src/backends/drm/drm_object_plane.cpp index 6967fdd50d..2d58f71560 100644 --- a/src/backends/drm/drm_object_plane.cpp +++ b/src/backends/drm/drm_object_plane.cpp @@ -7,11 +7,13 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "drm_object_plane.h" + +#include "config-kwin.h" + #include "drm_buffer.h" #include "drm_gpu.h" #include "drm_pointer.h" #include "logging.h" -#include "config-kwin.h" #include @@ -20,29 +22,21 @@ namespace KWin DrmPlane::DrmPlane(DrmGpu *gpu, uint32_t planeId) : DrmObject(gpu, planeId, { - PropertyDefinition(QByteArrayLiteral("type"), Requirement::Required, { - QByteArrayLiteral("Overlay"), - QByteArrayLiteral("Primary"), - QByteArrayLiteral("Cursor")}), - PropertyDefinition(QByteArrayLiteral("SRC_X"), Requirement::Required), - PropertyDefinition(QByteArrayLiteral("SRC_Y"), Requirement::Required), - PropertyDefinition(QByteArrayLiteral("SRC_W"), Requirement::Required), - PropertyDefinition(QByteArrayLiteral("SRC_H"), Requirement::Required), - PropertyDefinition(QByteArrayLiteral("CRTC_X"), Requirement::Required), - PropertyDefinition(QByteArrayLiteral("CRTC_Y"), Requirement::Required), - PropertyDefinition(QByteArrayLiteral("CRTC_W"), Requirement::Required), - PropertyDefinition(QByteArrayLiteral("CRTC_H"), Requirement::Required), - PropertyDefinition(QByteArrayLiteral("FB_ID"), Requirement::Required), - PropertyDefinition(QByteArrayLiteral("CRTC_ID"), Requirement::Required), - PropertyDefinition(QByteArrayLiteral("rotation"), Requirement::Optional, { - QByteArrayLiteral("rotate-0"), - QByteArrayLiteral("rotate-90"), - QByteArrayLiteral("rotate-180"), - QByteArrayLiteral("rotate-270"), - QByteArrayLiteral("reflect-x"), - QByteArrayLiteral("reflect-y")}), - PropertyDefinition(QByteArrayLiteral("IN_FORMATS"), Requirement::Optional), - }, DRM_MODE_OBJECT_PLANE) + PropertyDefinition(QByteArrayLiteral("type"), Requirement::Required, {QByteArrayLiteral("Overlay"), QByteArrayLiteral("Primary"), QByteArrayLiteral("Cursor")}), + PropertyDefinition(QByteArrayLiteral("SRC_X"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("SRC_Y"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("SRC_W"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("SRC_H"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("CRTC_X"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("CRTC_Y"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("CRTC_W"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("CRTC_H"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("FB_ID"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("CRTC_ID"), Requirement::Required), + PropertyDefinition(QByteArrayLiteral("rotation"), Requirement::Optional, {QByteArrayLiteral("rotate-0"), QByteArrayLiteral("rotate-90"), QByteArrayLiteral("rotate-180"), QByteArrayLiteral("rotate-270"), QByteArrayLiteral("reflect-x"), QByteArrayLiteral("reflect-y")}), + PropertyDefinition(QByteArrayLiteral("IN_FORMATS"), Requirement::Optional), + }, + DRM_MODE_OBJECT_PLANE) { } @@ -60,7 +54,7 @@ bool DrmPlane::init() bool success = initProps(); if (success) { m_supportedTransformations = Transformations(); - auto checkSupport = [this] (uint64_t value, Transformation t) { + auto checkSupport = [this](uint64_t value, Transformation t) { if (propHasEnum(PropertyIndex::Rotation, value)) { m_supportedTransformations |= t; } @@ -76,9 +70,9 @@ bool DrmPlane::init() if (auto formatProp = getProp(PropertyIndex::In_Formats); formatProp && gpu()->addFB2ModifiersSupported()) { DrmScopedPointer propertyBlob(drmModeGetPropertyBlob(gpu()->fd(), formatProp->current())); if (propertyBlob && propertyBlob->data) { - auto blob = static_cast(propertyBlob->data); - auto modifiers = reinterpret_cast(reinterpret_cast(blob) + blob->modifiers_offset); - uint32_t *formatarr = reinterpret_cast(reinterpret_cast(blob) + blob->formats_offset); + auto blob = static_cast(propertyBlob->data); + auto modifiers = reinterpret_cast(reinterpret_cast(blob) + blob->modifiers_offset); + uint32_t *formatarr = reinterpret_cast(reinterpret_cast(blob) + blob->formats_offset); for (uint32_t f = 0; f < blob->count_formats; f++) { auto format = formatarr[f]; diff --git a/src/backends/drm/drm_object_plane.h b/src/backends/drm/drm_object_plane.h index 0e77dee7f9..b487b92029 100644 --- a/src/backends/drm/drm_object_plane.h +++ b/src/backends/drm/drm_object_plane.h @@ -10,9 +10,9 @@ #include "drm_object.h" -#include -#include #include +#include +#include namespace KWin { @@ -53,12 +53,12 @@ public: Q_ENUM(TypeIndex) enum class Transformation : uint32_t { - Rotate0 = 1 << 0, - Rotate90 = 1 << 1, - Rotate180 = 1 << 2, - Rotate270 = 1 << 3, - ReflectX = 1 << 4, - ReflectY = 1 << 5 + Rotate0 = 1 << 0, + Rotate90 = 1 << 1, + Rotate180 = 1 << 2, + Rotate270 = 1 << 3, + ReflectX = 1 << 4, + ReflectY = 1 << 5 }; Q_ENUM(Transformation) Q_DECLARE_FLAGS(Transformations, Transformation); @@ -96,4 +96,3 @@ private: } Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::DrmPlane::Transformations) - diff --git a/src/backends/drm/drm_output.cpp b/src/backends/drm/drm_output.cpp index 3a0c9614e4..ef0233a38c 100644 --- a/src/backends/drm/drm_output.cpp +++ b/src/backends/drm/drm_output.cpp @@ -8,14 +8,16 @@ */ #include "drm_output.h" #include "drm_backend.h" -#include "drm_object_crtc.h" -#include "drm_object_connector.h" -#include "drm_gpu.h" -#include "drm_pipeline.h" #include "drm_buffer.h" +#include "drm_gpu.h" +#include "drm_object_connector.h" +#include "drm_object_crtc.h" +#include "drm_pipeline.h" #include "composite.h" #include "cursor.h" +#include "drm_layer.h" +#include "dumb_swapchain.h" #include "logging.h" #include "main.h" #include "renderloop.h" @@ -24,19 +26,16 @@ #include "screens.h" #include "session.h" #include "waylandoutputconfig.h" -#include "dumb_swapchain.h" -#include "cursor.h" -#include "drm_layer.h" // Qt -#include #include +#include #include // c++ #include // drm -#include -#include #include +#include +#include namespace KWin { diff --git a/src/backends/drm/drm_output.h b/src/backends/drm/drm_output.h index c19ce5ae46..8aeeca949e 100644 --- a/src/backends/drm/drm_output.h +++ b/src/backends/drm/drm_output.h @@ -10,17 +10,17 @@ #define KWIN_DRM_OUTPUT_H #include "drm_abstract_output.h" -#include "drm_pointer.h" #include "drm_object.h" #include "drm_object_plane.h" +#include "drm_pointer.h" #include #include +#include #include #include -#include -#include #include +#include namespace KWin { @@ -82,6 +82,6 @@ private: } -Q_DECLARE_METATYPE(KWin::DrmOutput*) +Q_DECLARE_METATYPE(KWin::DrmOutput *) #endif diff --git a/src/backends/drm/drm_pipeline.cpp b/src/backends/drm/drm_pipeline.cpp index 17073dd318..4c4bff5d71 100644 --- a/src/backends/drm/drm_pipeline.cpp +++ b/src/backends/drm/drm_pipeline.cpp @@ -11,22 +11,22 @@ #include -#include "logging.h" +#include "cursor.h" +#include "drm_backend.h" +#include "drm_buffer.h" +#include "drm_buffer_gbm.h" #include "drm_gpu.h" +#include "drm_layer.h" #include "drm_object_connector.h" #include "drm_object_crtc.h" #include "drm_object_plane.h" -#include "drm_buffer.h" -#include "cursor.h" -#include "session.h" #include "drm_output.h" -#include "drm_backend.h" #include "egl_gbm_backend.h" -#include "drm_buffer_gbm.h" -#include "drm_layer.h" +#include "logging.h" +#include "session.h" -#include #include +#include namespace KWin { @@ -79,7 +79,7 @@ bool DrmPipeline::present() return true; } -bool DrmPipeline::commitPipelines(const QVector &pipelines, CommitMode mode, const QVector &unusedObjects) +bool DrmPipeline::commitPipelines(const QVector &pipelines, CommitMode mode, const QVector &unusedObjects) { Q_ASSERT(!pipelines.isEmpty()); if (pipelines[0]->gpu()->atomicModeSetting()) { @@ -89,7 +89,7 @@ bool DrmPipeline::commitPipelines(const QVector &pipelines, Commit } } -bool DrmPipeline::commitPipelinesAtomic(const QVector &pipelines, CommitMode mode, const QVector &unusedObjects) +bool DrmPipeline::commitPipelinesAtomic(const QVector &pipelines, CommitMode mode, const QVector &unusedObjects) { drmModeAtomicReq *req = drmModeAtomicAlloc(); if (!req) { @@ -97,7 +97,7 @@ bool DrmPipeline::commitPipelinesAtomic(const QVector &pipelines, return false; } uint32_t flags = 0; - const auto &failed = [pipelines, req, &flags, unusedObjects](){ + const auto &failed = [pipelines, req, &flags, unusedObjects]() { drmModeAtomicFree(req); printFlags(flags); for (const auto &pipeline : pipelines) { @@ -413,8 +413,7 @@ DrmOutput *DrmPipeline::output() const } static const QMap> legacyFormats = { - {DRM_FORMAT_XRGB8888, {}} -}; + {DRM_FORMAT_XRGB8888, {}}}; bool DrmPipeline::isFormatSupported(uint32_t drmFormat) const { @@ -528,17 +527,17 @@ uint32_t DrmGammaRamp::size() const uint16_t *DrmGammaRamp::red() const { - return const_cast(m_lut.red()); + return const_cast(m_lut.red()); } uint16_t *DrmGammaRamp::green() const { - return const_cast(m_lut.green()); + return const_cast(m_lut.green()); } uint16_t *DrmGammaRamp::blue() const { - return const_cast(m_lut.blue()); + return const_cast(m_lut.blue()); } void DrmPipeline::printFlags(uint32_t flags) @@ -562,9 +561,9 @@ void DrmPipeline::printFlags(uint32_t flags) void DrmPipeline::printProps(DrmObject *object, PrintMode mode) { auto list = object->properties(); - bool any = mode == PrintMode::All || std::any_of(list.constBegin(), list.constEnd(), [](const auto &prop){ - return prop && !prop->isImmutable() && prop->needsCommit(); - }); + bool any = mode == PrintMode::All || std::any_of(list.constBegin(), list.constEnd(), [](const auto &prop) { + return prop && !prop->isImmutable() && prop->needsCommit(); + }); if (!any) { return; } diff --git a/src/backends/drm/drm_pipeline.h b/src/backends/drm/drm_pipeline.h index 60cb5a61f6..7f2065d752 100644 --- a/src/backends/drm/drm_pipeline.h +++ b/src/backends/drm/drm_pipeline.h @@ -10,16 +10,16 @@ #pragma once #include +#include #include #include -#include -#include #include +#include +#include "abstract_wayland_output.h" #include "drm_object_plane.h" #include "renderloop_p.h" -#include "abstract_wayland_output.h" namespace KWin { @@ -96,10 +96,11 @@ public: void setOutput(DrmOutput *output); DrmOutput *output() const; - struct State { + struct State + { DrmCrtc *crtc = nullptr; bool active = true; // whether or not the pipeline should be currently used - bool enabled = true;// whether or not the pipeline needs a crtc + bool enabled = true; // whether or not the pipeline needs a crtc QSharedPointer mode; uint32_t overscan = 0; AbstractWaylandOutput::RgbRange rgbRange = AbstractWaylandOutput::RgbRange::Automatic; @@ -125,7 +126,7 @@ public: CommitModeset }; Q_ENUM(CommitMode); - static bool commitPipelines(const QVector &pipelines, CommitMode mode, const QVector &unusedObjects = {}); + static bool commitPipelines(const QVector &pipelines, CommitMode mode, const QVector &unusedObjects = {}); private: bool activePending() const; @@ -139,17 +140,20 @@ private: bool applyPendingChangesLegacy(); bool setCursorLegacy(); bool moveCursorLegacy(); - static bool commitPipelinesLegacy(const QVector &pipelines, CommitMode mode); + static bool commitPipelinesLegacy(const QVector &pipelines, CommitMode mode); // atomic modesetting only bool populateAtomicValues(drmModeAtomicReq *req, uint32_t &flags); void atomicCommitFailed(); void atomicCommitSuccessful(CommitMode mode); void prepareAtomicModeset(); - static bool commitPipelinesAtomic(const QVector &pipelines, CommitMode mode, const QVector &unusedObjects); + static bool commitPipelinesAtomic(const QVector &pipelines, CommitMode mode, const QVector &unusedObjects); // logging helpers - enum class PrintMode { OnlyChanged, All }; + enum class PrintMode { + OnlyChanged, + All, + }; static void printFlags(uint32_t flags); static void printProps(DrmObject *object, PrintMode mode); diff --git a/src/backends/drm/drm_pipeline_legacy.cpp b/src/backends/drm/drm_pipeline_legacy.cpp index 2b5f1c19eb..8c178c7aa5 100644 --- a/src/backends/drm/drm_pipeline_legacy.cpp +++ b/src/backends/drm/drm_pipeline_legacy.cpp @@ -7,13 +7,13 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "drm_pipeline.h" -#include "drm_gpu.h" #include "drm_buffer.h" -#include "drm_object_crtc.h" -#include "drm_object_connector.h" -#include "logging.h" +#include "drm_gpu.h" #include "drm_layer.h" +#include "drm_object_connector.h" +#include "drm_object_crtc.h" +#include "drm_pipeline.h" +#include "logging.h" #include @@ -52,7 +52,7 @@ bool DrmPipeline::legacyModeset() return true; } -bool DrmPipeline::commitPipelinesLegacy(const QVector &pipelines, CommitMode mode) +bool DrmPipeline::commitPipelinesLegacy(const QVector &pipelines, CommitMode mode) { bool failure = false; for (const auto &pipeline : pipelines) { @@ -102,11 +102,10 @@ bool DrmPipeline::applyPendingChangesLegacy() m_connector->getProp(DrmConnector::PropertyIndex::Underscan_vborder)->setPropertyLegacy(pending.overscan); m_connector->getProp(DrmConnector::PropertyIndex::Underscan_hborder)->setPropertyLegacy(hborder); } - if (needsModeset() &&!legacyModeset()) { + if (needsModeset() && !legacyModeset()) { return false; } - if (pending.gamma && drmModeCrtcSetGamma(gpu()->fd(), pending.crtc->id(), pending.gamma->size(), - pending.gamma->red(), pending.gamma->green(), pending.gamma->blue()) != 0) { + if (pending.gamma && drmModeCrtcSetGamma(gpu()->fd(), pending.crtc->id(), pending.gamma->size(), pending.gamma->red(), pending.gamma->green(), pending.gamma->blue()) != 0) { qCWarning(KWIN_DRM) << "Setting gamma failed!" << strerror(errno); return false; } diff --git a/src/backends/drm/drm_pointer.h b/src/backends/drm/drm_pointer.h index d27c28c227..8b216bf0b3 100644 --- a/src/backends/drm/drm_pointer.h +++ b/src/backends/drm/drm_pointer.h @@ -12,16 +12,16 @@ #include -#include #include +#include namespace KWin { -template +template struct DrmDeleter; -template <> +template<> struct DrmDeleter { static void cleanup(drmVersion *version) @@ -30,7 +30,7 @@ struct DrmDeleter } }; -template <> +template<> struct DrmDeleter { static void cleanup(drmModeAtomicReq *req) @@ -39,7 +39,7 @@ struct DrmDeleter } }; -template <> +template<> struct DrmDeleter { static void cleanup(drmModeConnector *connector) @@ -48,7 +48,7 @@ struct DrmDeleter } }; -template <> +template<> struct DrmDeleter { static void cleanup(drmModeCrtc *crtc) @@ -57,7 +57,7 @@ struct DrmDeleter } }; -template <> +template<> struct DrmDeleter { static void cleanup(drmModeFB *fb) @@ -66,7 +66,7 @@ struct DrmDeleter } }; -template <> +template<> struct DrmDeleter { static void cleanup(drmModeEncoder *encoder) @@ -75,7 +75,7 @@ struct DrmDeleter } }; -template <> +template<> struct DrmDeleter { static void cleanup(drmModeModeInfo *info) @@ -84,7 +84,7 @@ struct DrmDeleter } }; -template <> +template<> struct DrmDeleter { static void cleanup(drmModeObjectProperties *properties) @@ -93,7 +93,7 @@ struct DrmDeleter } }; -template <> +template<> struct DrmDeleter { static void cleanup(drmModePlane *plane) @@ -102,7 +102,7 @@ struct DrmDeleter } }; -template <> +template<> struct DrmDeleter { static void cleanup(drmModePlaneRes *resources) @@ -111,7 +111,7 @@ struct DrmDeleter } }; -template <> +template<> struct DrmDeleter { static void cleanup(drmModePropertyRes *property) @@ -120,7 +120,7 @@ struct DrmDeleter } }; -template <> +template<> struct DrmDeleter { static void cleanup(drmModePropertyBlobRes *blob) @@ -129,7 +129,7 @@ struct DrmDeleter } }; -template <> +template<> struct DrmDeleter { static void cleanup(drmModeRes *resources) @@ -138,10 +138,9 @@ struct DrmDeleter } }; -template +template using DrmScopedPointer = QScopedPointer>; } #endif - diff --git a/src/backends/drm/drm_property.cpp b/src/backends/drm/drm_property.cpp index 28af8ec07f..050a2a9eaa 100644 --- a/src/backends/drm/drm_property.cpp +++ b/src/backends/drm/drm_property.cpp @@ -9,8 +9,8 @@ */ #include "drm_property.h" -#include "drm_object.h" #include "drm_gpu.h" +#include "drm_object.h" #include "logging.h" #include @@ -75,10 +75,10 @@ bool DrmProperty::setPropertyLegacy(uint64_t value) void DrmProperty::initEnumMap(drmModePropertyRes *prop) { - if ( ( !(prop->flags & DRM_MODE_PROP_ENUM) && !(prop->flags & DRM_MODE_PROP_BITMASK) ) - || prop->count_enums < 1 ) { + if ((!(prop->flags & DRM_MODE_PROP_ENUM) && !(prop->flags & DRM_MODE_PROP_BITMASK)) + || prop->count_enums < 1) { qCWarning(KWIN_DRM) << "Property '" << prop->name << "' ( id =" - << m_propId << ") should be enum valued, but it is not."; + << m_propId << ") should be enum valued, but it is not."; return; } diff --git a/src/backends/drm/drm_property.h b/src/backends/drm/drm_property.h index 48bdeafdc2..9d0386d31d 100644 --- a/src/backends/drm/drm_property.h +++ b/src/backends/drm/drm_property.h @@ -12,9 +12,9 @@ #include -#include -#include #include +#include +#include namespace KWin { @@ -32,12 +32,14 @@ public: QVector enumNames() const; bool hasEnum(uint64_t value) const; bool hasAllEnums() const; - template - T enumForValue(uint64_t value) const { + template + T enumForValue(uint64_t value) const + { return static_cast(m_enumMap[value]); } - template - bool setEnum(T index) { + template + bool setEnum(T index) + { if (hasEnum(static_cast(index))) { setPending(m_enumMap[static_cast(index)]); return true; @@ -50,8 +52,8 @@ public: bool isImmutable() const; bool isLegacy() const; /** - * Makes this property be ignored by DrmObject::atomicPopulate - */ + * Makes this property be ignored by DrmObject::atomicPopulate + */ void setLegacy(); void setPending(uint64_t value); @@ -70,7 +72,8 @@ public: bool setPropertyLegacy(uint64_t value); template - bool setEnumLegacy(T value) { + bool setEnumLegacy(T value) + { if (hasEnum(static_cast(value))) { return setPropertyLegacy(m_enumMap[static_cast(value)]); } diff --git a/src/backends/drm/drm_qpainter_layer.cpp b/src/backends/drm/drm_qpainter_layer.cpp index 044c43ac30..cc66350a1e 100644 --- a/src/backends/drm/drm_qpainter_layer.cpp +++ b/src/backends/drm/drm_qpainter_layer.cpp @@ -7,15 +7,15 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "drm_qpainter_layer.h" -#include "dumb_swapchain.h" #include "drm_abstract_output.h" -#include "drm_buffer.h" -#include "scene_qpainter_drm_backend.h" -#include "drm_gpu.h" #include "drm_backend.h" +#include "drm_buffer.h" +#include "drm_gpu.h" +#include "drm_output.h" #include "drm_pipeline.h" #include "drm_virtual_output.h" -#include "drm_output.h" +#include "dumb_swapchain.h" +#include "scene_qpainter_drm_backend.h" #include @@ -77,7 +77,6 @@ QImage *DrmQPainterLayer::image() return m_swapchain ? m_swapchain->currentBuffer()->image() : nullptr; } - DrmVirtualQPainterLayer::DrmVirtualQPainterLayer(DrmVirtualOutput *output) : m_output(output) { @@ -107,7 +106,6 @@ QImage *DrmVirtualQPainterLayer::image() return &m_image; } - DrmLeaseQPainterLayer::DrmLeaseQPainterLayer(DrmQPainterBackend *backend, DrmPipeline *pipeline) : DrmPipelineLayer(pipeline) { diff --git a/src/backends/drm/drm_render_backend.h b/src/backends/drm/drm_render_backend.h index 5834bc5467..eaf186e6af 100644 --- a/src/backends/drm/drm_render_backend.h +++ b/src/backends/drm/drm_render_backend.h @@ -25,7 +25,6 @@ public: virtual QSharedPointer createDrmPipelineLayer(DrmPipeline *pipeline) = 0; virtual QSharedPointer createLayer(DrmVirtualOutput *output) = 0; - }; } diff --git a/src/backends/drm/drm_virtual_output.cpp b/src/backends/drm/drm_virtual_output.cpp index fb39c79023..e7a8e396cd 100644 --- a/src/backends/drm/drm_virtual_output.cpp +++ b/src/backends/drm/drm_virtual_output.cpp @@ -9,13 +9,13 @@ */ #include "drm_virtual_output.h" -#include "renderloop_p.h" -#include "softwarevsyncmonitor.h" -#include "drm_gpu.h" #include "drm_backend.h" -#include "logging.h" +#include "drm_gpu.h" #include "drm_layer.h" #include "drm_render_backend.h" +#include "logging.h" +#include "renderloop_p.h" +#include "softwarevsyncmonitor.h" namespace KWin { diff --git a/src/backends/drm/dumb_swapchain.cpp b/src/backends/drm/dumb_swapchain.cpp index a1d9502a01..e2d3f1d788 100644 --- a/src/backends/drm/dumb_swapchain.cpp +++ b/src/backends/drm/dumb_swapchain.cpp @@ -8,8 +8,8 @@ */ #include "dumb_swapchain.h" -#include "drm_gpu.h" #include "drm_buffer.h" +#include "drm_gpu.h" #include "logging.h" namespace KWin @@ -28,7 +28,10 @@ DumbSwapchain::DumbSwapchain(DrmGpu *gpu, const QSize &size, uint32_t drmFormat, break; } buffer->image()->fill(Qt::black); - m_slots.append(Slot{.buffer = buffer, .age = 0,}); + m_slots.append(Slot{ + .buffer = buffer, + .age = 0, + }); } m_damageJournal.setCapacity(2); if (m_slots.count() < 2) { diff --git a/src/backends/drm/dumb_swapchain.h b/src/backends/drm/dumb_swapchain.h index 991d4e6e5d..c1b5173ce5 100644 --- a/src/backends/drm/dumb_swapchain.h +++ b/src/backends/drm/dumb_swapchain.h @@ -11,10 +11,10 @@ #include "utils/damagejournal.h" -#include -#include -#include #include +#include +#include +#include namespace KWin { diff --git a/src/backends/drm/edid.cpp b/src/backends/drm/edid.cpp index e107b5539c..f768e5489f 100644 --- a/src/backends/drm/edid.cpp +++ b/src/backends/drm/edid.cpp @@ -7,8 +7,8 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "edid.h" + #include "config-kwin.h" #include @@ -26,7 +26,9 @@ static bool verifyHeader(const uint8_t *data) } return std::all_of(data + 1, data + 7, - [](uint8_t byte) { return byte == 0xff; }); + [](uint8_t byte) { + return byte == 0xff; + }); } static QSize parsePhysicalSize(const uint8_t *data) @@ -59,7 +61,6 @@ static QByteArray parsePnpId(const uint8_t *data) return QByteArray(pnpId); } - static QByteArray parseEisaId(const uint8_t *data) { for (int i = 72; i <= 108; i += 18) { diff --git a/src/backends/drm/egl_gbm_backend.cpp b/src/backends/drm/egl_gbm_backend.cpp index b0211f67d0..a4b40f748e 100644 --- a/src/backends/drm/egl_gbm_backend.cpp +++ b/src/backends/drm/egl_gbm_backend.cpp @@ -11,38 +11,38 @@ #include "basiceglsurfacetexture_wayland.h" // kwin #include "composite.h" +#include "drm_abstract_output.h" #include "drm_backend.h" #include "drm_buffer_gbm.h" +#include "drm_gpu.h" +#include "drm_lease_egl_gbm_layer.h" #include "drm_output.h" +#include "drm_pipeline.h" +#include "dumb_swapchain.h" +#include "egl_dmabuf.h" +#include "egl_gbm_layer.h" #include "gbm_surface.h" +#include "kwineglutils_p.h" +#include "linux_dmabuf.h" #include "logging.h" #include "options.h" #include "renderloop_p.h" #include "screens.h" -#include "surfaceitem_wayland.h" -#include "drm_gpu.h" -#include "linux_dmabuf.h" -#include "dumb_swapchain.h" -#include "kwineglutils_p.h" #include "shadowbuffer.h" -#include "drm_pipeline.h" -#include "drm_abstract_output.h" -#include "egl_dmabuf.h" -#include "egl_gbm_layer.h" +#include "surfaceitem_wayland.h" #include "virtual_egl_gbm_layer.h" -#include "drm_lease_egl_gbm_layer.h" // kwin libs -#include #include +#include // system +#include +#include #include #include -#include -#include // kwayland server -#include "KWaylandServer/surface_interface.h" -#include "KWaylandServer/linuxdmabufv1clientbuffer.h" #include "KWaylandServer/clientconnection.h" +#include "KWaylandServer/linuxdmabufv1clientbuffer.h" +#include "KWaylandServer/surface_interface.h" namespace KWin { @@ -74,8 +74,7 @@ bool EglGbmBackend::initializeEgl() const bool hasKHRGBM = hasClientExtension(QByteArrayLiteral("EGL_KHR_platform_gbm")); const GLenum platform = hasMesaGBM ? EGL_PLATFORM_GBM_MESA : EGL_PLATFORM_GBM_KHR; - if (!hasClientExtension(QByteArrayLiteral("EGL_EXT_platform_base")) || - (!hasMesaGBM && !hasKHRGBM)) { + if (!hasClientExtension(QByteArrayLiteral("EGL_EXT_platform_base")) || (!hasMesaGBM && !hasKHRGBM)) { setFailed("Missing one or more extensions between EGL_EXT_platform_base, " "EGL_MESA_platform_gbm, EGL_KHR_platform_gbm"); return false; @@ -127,13 +126,20 @@ bool EglGbmBackend::initRenderingContext() bool EglGbmBackend::initBufferConfigs() { const EGLint config_attribs[] = { - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_RED_SIZE, 1, - EGL_GREEN_SIZE, 1, - EGL_BLUE_SIZE, 1, - EGL_ALPHA_SIZE, 0, - EGL_RENDERABLE_TYPE, isOpenGLES() ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT, - EGL_CONFIG_CAVEAT, EGL_NONE, + EGL_SURFACE_TYPE, + EGL_WINDOW_BIT, + EGL_RED_SIZE, + 1, + EGL_GREEN_SIZE, + 1, + EGL_BLUE_SIZE, + 1, + EGL_ALPHA_SIZE, + 0, + EGL_RENDERABLE_TYPE, + isOpenGLES() ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT, + EGL_CONFIG_CAVEAT, + EGL_NONE, EGL_NONE, }; @@ -205,14 +211,14 @@ bool EglGbmBackend::initBufferConfigs() eglGetConfigAttrib(eglDisplay(), configs[i], EGL_ALPHA_SIZE, &alphaSize); gbm_format_name_desc name; gbm_format_get_name(gbmFormat, &name); - qCCritical(KWIN_DRM, "EGL config %d has format %s with %d,%d,%d,%d bits for r,g,b,a", i, name.name, redSize, greenSize, blueSize, alphaSize); + qCCritical(KWIN_DRM, "EGL config %d has format %s with %d,%d,%d,%d bits for r,g,b,a", i, name.name, redSize, greenSize, blueSize, alphaSize); } return false; } void EglGbmBackend::aboutToStartPainting(AbstractOutput *output, const QRegion &damagedRegion) { - static_cast(output)->outputLayer()->aboutToStartPainting(damagedRegion); + static_cast(output)->outputLayer()->aboutToStartPainting(damagedRegion); } SurfaceTexture *EglGbmBackend::createSurfaceTextureInternal(SurfacePixmapInternal *pixmap) @@ -227,7 +233,7 @@ SurfaceTexture *EglGbmBackend::createSurfaceTextureWayland(SurfacePixmapWayland QRegion EglGbmBackend::beginFrame(AbstractOutput *output) { - return static_cast(output)->outputLayer()->startRendering().value_or(QRegion()); + return static_cast(output)->outputLayer()->startRendering().value_or(QRegion()); } void EglGbmBackend::endFrame(AbstractOutput *output, const QRegion &renderedRegion, @@ -235,14 +241,14 @@ void EglGbmBackend::endFrame(AbstractOutput *output, const QRegion &renderedRegi { Q_UNUSED(renderedRegion) - const auto drmOutput = static_cast(output); + const auto drmOutput = static_cast(output); drmOutput->outputLayer()->endRendering(damagedRegion); drmOutput->present(); } bool EglGbmBackend::scanout(AbstractOutput *output, SurfaceItem *surfaceItem) { - const auto drmOutput = static_cast(output); + const auto drmOutput = static_cast(output); if (drmOutput->outputLayer()->scanout(surfaceItem)) { drmOutput->present(); return true; @@ -253,8 +259,8 @@ bool EglGbmBackend::scanout(AbstractOutput *output, SurfaceItem *surfaceItem) QSharedPointer EglGbmBackend::textureForOutput(AbstractOutput *output) const { - const auto drmOutput = static_cast(output); - return static_cast(drmOutput->outputLayer())->texture(); + const auto drmOutput = static_cast(output); + return static_cast(drmOutput->outputLayer())->texture(); } GbmFormat EglGbmBackend::gbmFormatForDrmFormat(uint32_t format) const @@ -264,7 +270,7 @@ GbmFormat EglGbmBackend::gbmFormatForDrmFormat(uint32_t format) const return gbmFormat.drmFormat == format; }); if (it == m_formats.end()) { - return GbmFormat { + return GbmFormat{ .drmFormat = DRM_FORMAT_XRGB8888, .redSize = 8, .greenSize = 8, diff --git a/src/backends/drm/egl_gbm_backend.h b/src/backends/drm/egl_gbm_backend.h index 55ed9bde98..77803df117 100644 --- a/src/backends/drm/egl_gbm_backend.h +++ b/src/backends/drm/egl_gbm_backend.h @@ -41,7 +41,8 @@ class EglGbmLayer; class DrmOutputLayer; class DrmPipeline; -struct GbmFormat { +struct GbmFormat +{ uint32_t drmFormat = 0; EGLint redSize = -1; EGLint greenSize = -1; diff --git a/src/backends/drm/egl_gbm_layer.cpp b/src/backends/drm/egl_gbm_layer.cpp index 2325139067..38f86e3578 100644 --- a/src/backends/drm/egl_gbm_layer.cpp +++ b/src/backends/drm/egl_gbm_layer.cpp @@ -7,28 +7,28 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "egl_gbm_layer.h" -#include "gbm_surface.h" #include "drm_abstract_output.h" +#include "drm_backend.h" #include "drm_gpu.h" -#include "egl_gbm_backend.h" -#include "shadowbuffer.h" #include "drm_output.h" #include "drm_pipeline.h" #include "dumb_swapchain.h" -#include "logging.h" #include "egl_dmabuf.h" -#include "surfaceitem_wayland.h" +#include "egl_gbm_backend.h" +#include "gbm_surface.h" #include "kwineglimagetexture.h" -#include "drm_backend.h" #include "kwineglutils_p.h" +#include "logging.h" +#include "shadowbuffer.h" +#include "surfaceitem_wayland.h" -#include "KWaylandServer/surface_interface.h" #include "KWaylandServer/linuxdmabufv1clientbuffer.h" +#include "KWaylandServer/surface_interface.h" #include #include -#include #include +#include #include namespace KWin @@ -196,7 +196,7 @@ bool EglGbmLayer::createGbmSurface(uint32_t format, const QVector &mod static bool modifiersEnvSet = false; static const bool modifiersEnv = qEnvironmentVariableIntValue("KWIN_DRM_USE_MODIFIERS", &modifiersEnvSet) != 0; const bool allowModifiers = m_eglBackend->gpu()->addFB2ModifiersSupported() && m_pipeline->gpu()->addFB2ModifiersSupported() - && ((m_eglBackend->gpu()->isNVidia() && !modifiersEnvSet) || (modifiersEnvSet && modifiersEnv)); + && ((m_eglBackend->gpu()->isNVidia() && !modifiersEnvSet) || (modifiersEnvSet && modifiersEnv)); const auto size = m_pipeline->bufferSize(); const auto config = m_eglBackend->config(format); @@ -283,7 +283,7 @@ QSharedPointer EglGbmLayer::texture() const return QSharedPointer::create(m_eglBackend->eglDisplay(), image, GL_RGBA8, m_pipeline->sourceSize()); }; if (m_scanoutBuffer) { - return createImage(dynamic_cast(m_scanoutBuffer.data())); + return createImage(dynamic_cast(m_scanoutBuffer.data())); } if (m_shadowBuffer) { return m_shadowBuffer->texture(); diff --git a/src/backends/drm/egl_gbm_layer.h b/src/backends/drm/egl_gbm_layer.h index 1160718e16..9b22b28bc9 100644 --- a/src/backends/drm/egl_gbm_layer.h +++ b/src/backends/drm/egl_gbm_layer.h @@ -9,12 +9,12 @@ #pragma once #include "drm_layer.h" -#include -#include #include +#include #include -#include +#include #include +#include namespace KWaylandServer { @@ -68,7 +68,8 @@ private: }; MultiGpuImportMode m_importMode = MultiGpuImportMode::Dmabuf; - struct { + struct + { QPointer surface; QMap> attemptedFormats; bool attemptedThisFrame = false; diff --git a/src/backends/drm/gbm_dmabuf.cpp b/src/backends/drm/gbm_dmabuf.cpp index 3a23d647b6..28c0a30674 100644 --- a/src/backends/drm/gbm_dmabuf.cpp +++ b/src/backends/drm/gbm_dmabuf.cpp @@ -18,7 +18,8 @@ GbmDmaBuf::GbmDmaBuf(GLTexture *texture, gbm_bo *bo, int fd) : DmaBufTexture(texture) , m_bo(bo) , m_fd(fd) -{} +{ +} GbmDmaBuf::~GbmDmaBuf() { @@ -63,8 +64,7 @@ GbmDmaBuf *GbmDmaBuf::createBuffer(const QSize &size, gbm_device *device) EGL_DMA_BUF_PLANE0_FD_EXT, fd, EGL_DMA_BUF_PLANE0_OFFSET_EXT, EGLint(gbm_bo_get_offset(bo, 0)), EGL_DMA_BUF_PLANE0_PITCH_EXT, EGLint(gbm_bo_get_stride(bo)), - EGL_NONE - }; + EGL_NONE}; EGLDisplay display = kwinApp()->platform()->sceneEglDisplay(); if (display == EGL_NO_DISPLAY) { @@ -81,4 +81,3 @@ GbmDmaBuf *GbmDmaBuf::createBuffer(const QSize &size, gbm_device *device) } } - diff --git a/src/backends/drm/gbm_dmabuf.h b/src/backends/drm/gbm_dmabuf.h index 57ebf2ac26..067c46bb14 100644 --- a/src/backends/drm/gbm_dmabuf.h +++ b/src/backends/drm/gbm_dmabuf.h @@ -7,9 +7,9 @@ #pragma once #include "dmabuftexture.h" -#include #include #include +#include namespace KWin { diff --git a/src/backends/drm/gbm_surface.cpp b/src/backends/drm/gbm_surface.cpp index 77169fd3e3..7a7f6169a2 100644 --- a/src/backends/drm/gbm_surface.cpp +++ b/src/backends/drm/gbm_surface.cpp @@ -8,22 +8,22 @@ */ #include "gbm_surface.h" -#include #include +#include -#include "egl_gbm_backend.h" +#include "drm_backend.h" #include "drm_gpu.h" -#include "logging.h" +#include "egl_gbm_backend.h" #include "kwineglutils_p.h" #include "kwinglplatform.h" -#include "drm_backend.h" +#include "logging.h" namespace KWin { GbmSurface::GbmSurface(DrmGpu *gpu, const QSize &size, uint32_t format, uint32_t flags, EGLConfig config) : m_surface(gbm_surface_create(gpu->gbmDevice(), size.width(), size.height(), format, flags)) - , m_eglBackend(static_cast(gpu->platform()->renderBackend())) + , m_eglBackend(static_cast(gpu->platform()->renderBackend())) , m_size(size) , m_format(format) , m_renderTarget(new GLRenderTarget(0, size)) @@ -40,7 +40,7 @@ GbmSurface::GbmSurface(DrmGpu *gpu, const QSize &size, uint32_t format, uint32_t GbmSurface::GbmSurface(DrmGpu *gpu, const QSize &size, uint32_t format, QVector modifiers, EGLConfig config) : m_surface(gbm_surface_create_with_modifiers(gpu->gbmDevice(), size.width(), size.height(), format, modifiers.isEmpty() ? nullptr : modifiers.constData(), modifiers.count())) - , m_eglBackend(static_cast(gpu->platform()->renderBackend())) + , m_eglBackend(static_cast(gpu->platform()->renderBackend())) , m_size(size) , m_format(format) , m_modifiers(modifiers) diff --git a/src/backends/drm/gbm_surface.h b/src/backends/drm/gbm_surface.h index 67a9633122..1e57ece5fd 100644 --- a/src/backends/drm/gbm_surface.h +++ b/src/backends/drm/gbm_surface.h @@ -9,9 +9,9 @@ #ifndef KWIN_DRM_GBM_SURFACE_H #define KWIN_DRM_GBM_SURFACE_H +#include #include #include -#include #include #include "drm_buffer_gbm.h" @@ -63,7 +63,7 @@ private: QSharedPointer m_currentBuffer; QSharedPointer m_currentDrmBuffer; - QVector m_lockedBuffers; + QVector m_lockedBuffers; QScopedPointer m_renderTarget; }; diff --git a/src/backends/drm/scene_qpainter_drm_backend.cpp b/src/backends/drm/scene_qpainter_drm_backend.cpp index 4013e9cfea..b0e878a12b 100644 --- a/src/backends/drm/scene_qpainter_drm_backend.cpp +++ b/src/backends/drm/scene_qpainter_drm_backend.cpp @@ -8,13 +8,13 @@ */ #include "scene_qpainter_drm_backend.h" #include "drm_backend.h" -#include "drm_output.h" -#include "drm_gpu.h" #include "drm_buffer.h" -#include "renderloop_p.h" +#include "drm_gpu.h" +#include "drm_output.h" +#include "drm_pipeline.h" #include "drm_qpainter_layer.h" #include "drm_virtual_output.h" -#include "drm_pipeline.h" +#include "renderloop_p.h" #include @@ -35,22 +35,22 @@ DrmQPainterBackend::~DrmQPainterBackend() QImage *DrmQPainterBackend::bufferForScreen(AbstractOutput *output) { - const auto drmOutput = static_cast(output); - return dynamic_cast(drmOutput->outputLayer())->image(); + const auto drmOutput = static_cast(output); + return dynamic_cast(drmOutput->outputLayer())->image(); } QRegion DrmQPainterBackend::beginFrame(AbstractOutput *output) { - const auto drmOutput = static_cast(output); + const auto drmOutput = static_cast(output); return drmOutput->outputLayer()->startRendering().value_or(QRegion()); } void DrmQPainterBackend::endFrame(AbstractOutput *output, const QRegion &renderedRegion, const QRegion &damage) { Q_UNUSED(renderedRegion) - const auto drmOutput = static_cast(output); + const auto drmOutput = static_cast(output); drmOutput->outputLayer()->endRendering(damage); - static_cast(output)->present(); + static_cast(output)->present(); } QSharedPointer DrmQPainterBackend::createDrmPipelineLayer(DrmPipeline *pipeline) diff --git a/src/backends/drm/scene_qpainter_drm_backend.h b/src/backends/drm/scene_qpainter_drm_backend.h index 7ba129ddae..31042dec2b 100644 --- a/src/backends/drm/scene_qpainter_drm_backend.h +++ b/src/backends/drm/scene_qpainter_drm_backend.h @@ -7,13 +7,13 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #pragma once -#include "qpainterbackend.h" #include "drm_render_backend.h" #include "dumb_swapchain.h" +#include "qpainterbackend.h" #include -#include #include +#include namespace KWin { diff --git a/src/backends/drm/shadowbuffer.cpp b/src/backends/drm/shadowbuffer.cpp index 0b5f34478c..b7f4cd9ad3 100644 --- a/src/backends/drm/shadowbuffer.cpp +++ b/src/backends/drm/shadowbuffer.cpp @@ -8,31 +8,36 @@ */ #include "shadowbuffer.h" -#include "logging.h" #include "drm_output.h" +#include "logging.h" namespace KWin { static const float vertices[] = { - -1.0f, 1.0f, - -1.0f, -1.0f, - 1.0f, -1.0f, + -1.0f, + 1.0f, + -1.0f, + -1.0f, + 1.0f, + -1.0f, - -1.0f, 1.0f, - 1.0f, -1.0f, - 1.0f, 1.0f, + -1.0f, + 1.0f, + 1.0f, + -1.0f, + 1.0f, + 1.0f, }; static const float texCoords[] = { - 0.0f, 1.0f, - 0.0f, 0.0f, - 1.0f, 0.0f, + 0.0f, 1.0f, + 0.0f, 0.0f, + 1.0f, 0.0f, - 0.0f, 1.0f, - 1.0f, 0.0f, - 1.0f, 1.0f -}; + 0.0f, 1.0f, + 1.0f, 0.0f, + 1.0f, 1.0f}; ShadowBuffer::ShadowBuffer(const QSize &size, const GbmFormat &format) : m_size(size) diff --git a/src/backends/drm/shadowbuffer.h b/src/backends/drm/shadowbuffer.h index 5b3d5f7bc0..a73d11686e 100644 --- a/src/backends/drm/shadowbuffer.h +++ b/src/backends/drm/shadowbuffer.h @@ -11,8 +11,8 @@ #include #include -#include "egl_gbm_backend.h" #include "drm_object_plane.h" +#include "egl_gbm_backend.h" namespace KWin { diff --git a/src/backends/drm/virtual_egl_gbm_layer.cpp b/src/backends/drm/virtual_egl_gbm_layer.cpp index 2244e21bea..21f0284914 100644 --- a/src/backends/drm/virtual_egl_gbm_layer.cpp +++ b/src/backends/drm/virtual_egl_gbm_layer.cpp @@ -7,29 +7,29 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "virtual_egl_gbm_layer.h" -#include "gbm_surface.h" #include "drm_abstract_output.h" +#include "drm_backend.h" #include "drm_gpu.h" -#include "egl_gbm_backend.h" -#include "shadowbuffer.h" #include "drm_output.h" #include "drm_pipeline.h" -#include "dumb_swapchain.h" -#include "logging.h" -#include "egl_dmabuf.h" -#include "surfaceitem_wayland.h" -#include "kwineglimagetexture.h" -#include "drm_backend.h" #include "drm_virtual_output.h" +#include "dumb_swapchain.h" +#include "egl_dmabuf.h" +#include "egl_gbm_backend.h" +#include "gbm_surface.h" +#include "kwineglimagetexture.h" #include "kwineglutils_p.h" +#include "logging.h" +#include "shadowbuffer.h" +#include "surfaceitem_wayland.h" -#include "KWaylandServer/surface_interface.h" #include "KWaylandServer/linuxdmabufv1clientbuffer.h" +#include "KWaylandServer/surface_interface.h" #include #include -#include #include +#include #include namespace KWin diff --git a/src/backends/drm/virtual_egl_gbm_layer.h b/src/backends/drm/virtual_egl_gbm_layer.h index 6ef2aa549d..4f3b202418 100644 --- a/src/backends/drm/virtual_egl_gbm_layer.h +++ b/src/backends/drm/virtual_egl_gbm_layer.h @@ -9,12 +9,12 @@ #pragma once #include "drm_layer.h" -#include -#include #include +#include #include -#include +#include #include +#include namespace KWaylandServer { diff --git a/src/backends/fakeinput/fakeinputbackend.cpp b/src/backends/fakeinput/fakeinputbackend.cpp index a30d2c5bdf..8361458072 100644 --- a/src/backends/fakeinput/fakeinputbackend.cpp +++ b/src/backends/fakeinput/fakeinputbackend.cpp @@ -21,16 +21,14 @@ FakeInputBackend::FakeInputBackend(QObject *parent) void FakeInputBackend::initialize() { auto fakeInput = new KWaylandServer::FakeInputInterface(waylandServer()->display(), this); - connect(fakeInput, &KWaylandServer::FakeInputInterface::deviceCreated, this, - [this] (KWaylandServer::FakeInputDevice *fakeDevice) { - auto device = new FakeInputDevice(fakeDevice, this); - Q_EMIT deviceAdded(device); + connect(fakeInput, &KWaylandServer::FakeInputInterface::deviceCreated, this, [this](KWaylandServer::FakeInputDevice *fakeDevice) { + auto device = new FakeInputDevice(fakeDevice, this); + Q_EMIT deviceAdded(device); - connect(fakeDevice, &QObject::destroyed, this, [this, device]() { - Q_EMIT deviceRemoved(device); - }); - } - ); + connect(fakeDevice, &QObject::destroyed, this, [this, device]() { + Q_EMIT deviceRemoved(device); + }); + }); } } // namespace KWin diff --git a/src/backends/fakeinput/fakeinputdevice.cpp b/src/backends/fakeinput/fakeinputdevice.cpp index 75500b75c4..e260c2388a 100644 --- a/src/backends/fakeinput/fakeinputdevice.cpp +++ b/src/backends/fakeinput/fakeinputdevice.cpp @@ -16,97 +16,71 @@ FakeInputDevice::FakeInputDevice(KWaylandServer::FakeInputDevice *device, QObjec : InputDevice(parent) , m_name(QStringLiteral("Fake Input Device %1").arg(++s_lastDeviceId)) { - connect(device, &KWaylandServer::FakeInputDevice::authenticationRequested, this, - [device] (const QString &application, const QString &reason) { - Q_UNUSED(application) - Q_UNUSED(reason) - // TODO: make secure - device->setAuthentication(true); + connect(device, &KWaylandServer::FakeInputDevice::authenticationRequested, this, [device](const QString &application, const QString &reason) { + Q_UNUSED(application) + Q_UNUSED(reason) + // TODO: make secure + device->setAuthentication(true); + }); + connect(device, &KWaylandServer::FakeInputDevice::pointerMotionRequested, this, [this](const QSizeF &delta) { + // TODO: Fix time + Q_EMIT pointerMotion(delta, delta, 0, 0, this); + }); + connect(device, &KWaylandServer::FakeInputDevice::pointerMotionAbsoluteRequested, this, [this](const QPointF &pos) { + // TODO: Fix time + Q_EMIT pointerMotionAbsolute(pos, 0, this); + }); + connect(device, &KWaylandServer::FakeInputDevice::pointerButtonPressRequested, this, [this](quint32 button) { + // TODO: Fix time + Q_EMIT pointerButtonChanged(button, InputRedirection::PointerButtonPressed, 0, this); + }); + connect(device, &KWaylandServer::FakeInputDevice::pointerButtonReleaseRequested, this, [this](quint32 button) { + // TODO: Fix time + Q_EMIT pointerButtonChanged(button, InputRedirection::PointerButtonReleased, 0, this); + }); + connect(device, &KWaylandServer::FakeInputDevice::pointerAxisRequested, this, [this](Qt::Orientation orientation, qreal delta) { + // TODO: Fix time + InputRedirection::PointerAxis axis; + switch (orientation) { + case Qt::Horizontal: + axis = InputRedirection::PointerAxisHorizontal; + break; + case Qt::Vertical: + axis = InputRedirection::PointerAxisVertical; + break; + default: + Q_UNREACHABLE(); + break; } - ); - connect(device, &KWaylandServer::FakeInputDevice::pointerMotionRequested, this, - [this] (const QSizeF &delta) { - // TODO: Fix time - Q_EMIT pointerMotion(delta, delta, 0, 0, this); - } - ); - connect(device, &KWaylandServer::FakeInputDevice::pointerMotionAbsoluteRequested, this, - [this] (const QPointF &pos) { - // TODO: Fix time - Q_EMIT pointerMotionAbsolute(pos, 0, this); - } - ); - connect(device, &KWaylandServer::FakeInputDevice::pointerButtonPressRequested, this, - [this] (quint32 button) { - // TODO: Fix time - Q_EMIT pointerButtonChanged(button, InputRedirection::PointerButtonPressed, 0, this); - } - ); - connect(device, &KWaylandServer::FakeInputDevice::pointerButtonReleaseRequested, this, - [this] (quint32 button) { - // TODO: Fix time - Q_EMIT pointerButtonChanged(button, InputRedirection::PointerButtonReleased, 0, this); - } - ); - connect(device, &KWaylandServer::FakeInputDevice::pointerAxisRequested, this, - [this] (Qt::Orientation orientation, qreal delta) { - // TODO: Fix time - InputRedirection::PointerAxis axis; - switch (orientation) { - case Qt::Horizontal: - axis = InputRedirection::PointerAxisHorizontal; - break; - case Qt::Vertical: - axis = InputRedirection::PointerAxisVertical; - break; - default: - Q_UNREACHABLE(); - break; - } - // TODO: Fix time - Q_EMIT pointerAxisChanged(axis, delta, 0, InputRedirection::PointerAxisSourceUnknown, 0, this); - } - ); - connect(device, &KWaylandServer::FakeInputDevice::touchDownRequested, this, - [this] (qint32 id, const QPointF &pos) { - // TODO: Fix time - Q_EMIT touchDown(id, pos, 0, this); - } - ); - connect(device, &KWaylandServer::FakeInputDevice::touchMotionRequested, this, - [this] (qint32 id, const QPointF &pos) { - // TODO: Fix time - Q_EMIT touchMotion(id, pos, 0, this); - } - ); - connect(device, &KWaylandServer::FakeInputDevice::touchUpRequested, this, - [this] (qint32 id) { - // TODO: Fix time - Q_EMIT touchUp(id, 0, this); - } - ); - connect(device, &KWaylandServer::FakeInputDevice::touchCancelRequested, this, - [this] () { - Q_EMIT touchCanceled(this); - } - ); - connect(device, &KWaylandServer::FakeInputDevice::touchFrameRequested, this, - [this] () { - Q_EMIT touchFrame(this); - } - ); - connect(device, &KWaylandServer::FakeInputDevice::keyboardKeyPressRequested, this, - [this] (quint32 button) { - // TODO: Fix time - Q_EMIT keyChanged(button, InputRedirection::KeyboardKeyPressed, 0, this); - } - ); - connect(device, &KWaylandServer::FakeInputDevice::keyboardKeyReleaseRequested, this, - [this] (quint32 button) { - // TODO: Fix time - Q_EMIT keyChanged(button, InputRedirection::KeyboardKeyReleased, 0, this); - } - ); + // TODO: Fix time + Q_EMIT pointerAxisChanged(axis, delta, 0, InputRedirection::PointerAxisSourceUnknown, 0, this); + }); + connect(device, &KWaylandServer::FakeInputDevice::touchDownRequested, this, [this](qint32 id, const QPointF &pos) { + // TODO: Fix time + Q_EMIT touchDown(id, pos, 0, this); + }); + connect(device, &KWaylandServer::FakeInputDevice::touchMotionRequested, this, [this](qint32 id, const QPointF &pos) { + // TODO: Fix time + Q_EMIT touchMotion(id, pos, 0, this); + }); + connect(device, &KWaylandServer::FakeInputDevice::touchUpRequested, this, [this](qint32 id) { + // TODO: Fix time + Q_EMIT touchUp(id, 0, this); + }); + connect(device, &KWaylandServer::FakeInputDevice::touchCancelRequested, this, [this]() { + Q_EMIT touchCanceled(this); + }); + connect(device, &KWaylandServer::FakeInputDevice::touchFrameRequested, this, [this]() { + Q_EMIT touchFrame(this); + }); + connect(device, &KWaylandServer::FakeInputDevice::keyboardKeyPressRequested, this, [this](quint32 button) { + // TODO: Fix time + Q_EMIT keyChanged(button, InputRedirection::KeyboardKeyPressed, 0, this); + }); + connect(device, &KWaylandServer::FakeInputDevice::keyboardKeyReleaseRequested, this, [this](quint32 button) { + // TODO: Fix time + Q_EMIT keyChanged(button, InputRedirection::KeyboardKeyReleased, 0, this); + }); } QString FakeInputDevice::sysName() const diff --git a/src/backends/libinput/connection.cpp b/src/backends/libinput/connection.cpp index e3c9cbd719..95fae76a4c 100644 --- a/src/backends/libinput/connection.cpp +++ b/src/backends/libinput/connection.cpp @@ -13,24 +13,24 @@ // TODO: Make it compile also in testing environment #ifndef KWIN_BUILD_TESTING +#include "abstract_client.h" #include "abstract_wayland_output.h" #include "main.h" #include "platform.h" #include "workspace.h" -#include "abstract_client.h" #endif #include "input_event.h" +#include "libinput_logging.h" #include "session.h" #include "udev.h" -#include "libinput_logging.h" #include #include #include -#include #include +#include namespace KWin { @@ -61,15 +61,16 @@ public: QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/kde/KWin/InputDevice"), QStringLiteral("org.kde.KWin.InputDeviceManager"), this, - QDBusConnection::ExportAllProperties | QDBusConnection::ExportAllSignals - ); + QDBusConnection::ExportAllProperties | QDBusConnection::ExportAllSignals); } - ~ConnectionAdaptor() override { + ~ConnectionAdaptor() override + { QDBusConnection::sessionBus().unregisterObject(QStringLiteral("/org/kde/KWin/InputDeviceManager")); } - QStringList devicesSysNames() { + QStringList devicesSysNames() + { return m_con->devicesSysNames(); } @@ -121,7 +122,6 @@ Connection *Connection::create(QObject *parent) return s_self; } - Connection::Connection(Context *input, QObject *parent) : QObject(parent) , m_input(input) @@ -130,7 +130,7 @@ Connection::Connection(Context *input, QObject *parent) 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))); + QStringLiteral("notifyChange"), this, SLOT(slotKGlobalSettingsNotifyChange(int, int))); } Connection::~Connection() @@ -284,251 +284,253 @@ void Connection::processEvents() 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(thread()); - m_devices << device; + case LIBINPUT_EVENT_DEVICE_ADDED: { + auto device = new Device(event->nativeDevice()); + device->moveToThread(thread()); + m_devices << device; - applyDeviceConfig(device); - applyScreenToDevice(device); + applyDeviceConfig(device); + applyScreenToDevice(device); - Q_EMIT deviceAdded(device); + Q_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; } - 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); - Q_EMIT deviceRemoved(device); - device->deleteLater(); - break; + auto device = *it; + m_devices.erase(it); + Q_EMIT deviceRemoved(device); + device->deleteLater(); + break; + } + case LIBINPUT_EVENT_KEYBOARD_KEY: { + KeyEvent *ke = static_cast(event.data()); + Q_EMIT ke->device()->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) { + Q_EMIT pe->device()->pointerAxisChanged(axis, pe->axisValue(axis), pe->discreteAxisValue(axis), + pe->axisSource(), pe->time(), pe->device()); } - case LIBINPUT_EVENT_KEYBOARD_KEY: { - KeyEvent *ke = static_cast(event.data()); - Q_EMIT ke->device()->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) { - Q_EMIT pe->device()->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()); - Q_EMIT pe->device()->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; - } - } - Q_EMIT pe->device()->pointerMotion(delta, deltaNonAccel, latestTime, latestTimeUsec, pe->device()); - break; - } - case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE: { - PointerEvent *pe = static_cast(event.data()); - Q_EMIT pe->device()->pointerMotionAbsolute(pe->absolutePos(workspace()->geometry().size()), pe->time(), pe->device()); - break; - } - case LIBINPUT_EVENT_TOUCH_DOWN: { -#ifndef KWIN_BUILD_TESTING - TouchEvent *te = static_cast(event.data()); - const auto *output = static_cast(te->device()->output()); - const QPointF globalPos = - devicePointToGlobalPosition(te->absolutePos(output->modeSize()), - output); - Q_EMIT te->device()->touchDown(te->id(), globalPos, te->time(), te->device()); - break; -#endif - } - case LIBINPUT_EVENT_TOUCH_UP: { - TouchEvent *te = static_cast(event.data()); - Q_EMIT te->device()->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 *output = static_cast(te->device()->output()); - const QPointF globalPos = - devicePointToGlobalPosition(te->absolutePos(output->modeSize()), - output); - Q_EMIT te->device()->touchMotion(te->id(), globalPos, te->time(), te->device()); - break; -#endif - } - case LIBINPUT_EVENT_TOUCH_CANCEL: { - Q_EMIT event->device()->touchCanceled(event->device()); - break; - } - case LIBINPUT_EVENT_TOUCH_FRAME: { - Q_EMIT event->device()->touchFrame(event->device()); - break; - } - case LIBINPUT_EVENT_GESTURE_PINCH_BEGIN: { - PinchGestureEvent *pe = static_cast(event.data()); - Q_EMIT pe->device()->pinchGestureBegin(pe->fingerCount(), pe->time(), pe->device()); - break; - } - case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE: { - PinchGestureEvent *pe = static_cast(event.data()); - Q_EMIT pe->device()->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()) { - Q_EMIT pe->device()->pinchGestureCancelled(pe->time(), pe->device()); + break; + } + case LIBINPUT_EVENT_POINTER_BUTTON: { + PointerEvent *pe = static_cast(event.data()); + Q_EMIT pe->device()->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 { - Q_EMIT pe->device()->pinchGestureEnd(pe->time(), pe->device()); - } - break; - } - case LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN: { - SwipeGestureEvent *se = static_cast(event.data()); - Q_EMIT se->device()->swipeGestureBegin(se->fingerCount(), se->time(), se->device()); - break; - } - case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE: { - SwipeGestureEvent *se = static_cast(event.data()); - Q_EMIT se->device()->swipeGestureUpdate(se->delta(), se->time(), se->device()); - break; - } - case LIBINPUT_EVENT_GESTURE_SWIPE_END: { - SwipeGestureEvent *se = static_cast(event.data()); - if (se->isCancelled()) { - Q_EMIT se->device()->swipeGestureCancelled(se->time(), se->device()); - } else { - Q_EMIT se->device()->swipeGestureEnd(se->time(), se->device()); - } - break; - } - case LIBINPUT_EVENT_GESTURE_HOLD_BEGIN: { - HoldGestureEvent *he = static_cast(event.data()); - Q_EMIT he->device()->holdGestureBegin(he->fingerCount(), he->time(), he->device()); - break; - } - case LIBINPUT_EVENT_GESTURE_HOLD_END: { - HoldGestureEvent *he = static_cast(event.data()); - if (he->isCancelled()) { - Q_EMIT he->device()->holdGestureCancelled(he->time(), he->device()); - } else { - Q_EMIT he->device()->holdGestureEnd(he->time(), he->device()); - } - break; - } - case LIBINPUT_EVENT_SWITCH_TOGGLE: { - SwitchEvent *se = static_cast(event.data()); - switch (se->state()) { - case SwitchEvent::State::Off: - Q_EMIT se->device()->switchToggledOff(se->time(), se->timeMicroseconds(), se->device()); - break; - case SwitchEvent::State::On: - Q_EMIT se->device()->switchToggledOn(se->time(), se->timeMicroseconds(), se->device()); - break; - default: - Q_UNREACHABLE(); - } - break; - } - case LIBINPUT_EVENT_TABLET_TOOL_AXIS: - case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY: - case LIBINPUT_EVENT_TABLET_TOOL_TIP: { - auto *tte = static_cast(event.data()); - - KWin::InputRedirection::TabletEventType tabletEventType; - switch (event->type()) { - case LIBINPUT_EVENT_TABLET_TOOL_AXIS: - tabletEventType = KWin::InputRedirection::Axis; - break; - case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY: - tabletEventType = KWin::InputRedirection::Proximity; - break; - case LIBINPUT_EVENT_TABLET_TOOL_TIP: - default: - tabletEventType = KWin::InputRedirection::Tip; break; } - - if (workspace()) { + } + Q_EMIT pe->device()->pointerMotion(delta, deltaNonAccel, latestTime, latestTimeUsec, pe->device()); + break; + } + case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE: { + PointerEvent *pe = static_cast(event.data()); + Q_EMIT pe->device()->pointerMotionAbsolute(pe->absolutePos(workspace()->geometry().size()), pe->time(), pe->device()); + break; + } + case LIBINPUT_EVENT_TOUCH_DOWN: { #ifndef KWIN_BUILD_TESTING - AbstractWaylandOutput *output = static_cast(tte->device()->output()); - if (!output && workspace()->activeClient()) { - output = static_cast(workspace()->activeClient()->output()); - } - if (!output) { - output = static_cast(workspace()->activeOutput()); - } - const QPointF globalPos = - devicePointToGlobalPosition(tte->transformedPosition(output->modeSize()), - output); -#else - const QPointF globalPos; + TouchEvent *te = static_cast(event.data()); + const auto *output = static_cast(te->device()->output()); + const QPointF globalPos = + devicePointToGlobalPosition(te->absolutePos(output->modeSize()), + output); + Q_EMIT te->device()->touchDown(te->id(), globalPos, te->time(), te->device()); + break; #endif - Q_EMIT event->device()->tabletToolEvent(tabletEventType, - globalPos, tte->pressure(), - tte->xTilt(), tte->yTilt(), tte->rotation(), - tte->isTipDown(), tte->isNearby(), createTabletId(tte->tool(), event->device()->groupUserData()), tte->time()); - } - break; + } + case LIBINPUT_EVENT_TOUCH_UP: { + TouchEvent *te = static_cast(event.data()); + Q_EMIT te->device()->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 *output = static_cast(te->device()->output()); + const QPointF globalPos = + devicePointToGlobalPosition(te->absolutePos(output->modeSize()), + output); + Q_EMIT te->device()->touchMotion(te->id(), globalPos, te->time(), te->device()); + break; +#endif + } + case LIBINPUT_EVENT_TOUCH_CANCEL: { + Q_EMIT event->device()->touchCanceled(event->device()); + break; + } + case LIBINPUT_EVENT_TOUCH_FRAME: { + Q_EMIT event->device()->touchFrame(event->device()); + break; + } + case LIBINPUT_EVENT_GESTURE_PINCH_BEGIN: { + PinchGestureEvent *pe = static_cast(event.data()); + Q_EMIT pe->device()->pinchGestureBegin(pe->fingerCount(), pe->time(), pe->device()); + break; + } + case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE: { + PinchGestureEvent *pe = static_cast(event.data()); + Q_EMIT pe->device()->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()) { + Q_EMIT pe->device()->pinchGestureCancelled(pe->time(), pe->device()); + } else { + Q_EMIT pe->device()->pinchGestureEnd(pe->time(), pe->device()); } - case LIBINPUT_EVENT_TABLET_TOOL_BUTTON: { - auto *tabletEvent = static_cast(event.data()); - Q_EMIT event->device()->tabletToolButtonEvent(tabletEvent->buttonId(), - tabletEvent->isButtonPressed(), - createTabletId(tabletEvent->tool(), event->device()->groupUserData())); - break; + break; + } + case LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN: { + SwipeGestureEvent *se = static_cast(event.data()); + Q_EMIT se->device()->swipeGestureBegin(se->fingerCount(), se->time(), se->device()); + break; + } + case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE: { + SwipeGestureEvent *se = static_cast(event.data()); + Q_EMIT se->device()->swipeGestureUpdate(se->delta(), se->time(), se->device()); + break; + } + case LIBINPUT_EVENT_GESTURE_SWIPE_END: { + SwipeGestureEvent *se = static_cast(event.data()); + if (se->isCancelled()) { + Q_EMIT se->device()->swipeGestureCancelled(se->time(), se->device()); + } else { + Q_EMIT se->device()->swipeGestureEnd(se->time(), se->device()); } - case LIBINPUT_EVENT_TABLET_PAD_BUTTON: { - auto *tabletEvent = static_cast(event.data()); - Q_EMIT event->device()->tabletPadButtonEvent(tabletEvent->buttonId(), - tabletEvent->isButtonPressed(), - { event->device()->groupUserData() }); - break; + break; + } + case LIBINPUT_EVENT_GESTURE_HOLD_BEGIN: { + HoldGestureEvent *he = static_cast(event.data()); + Q_EMIT he->device()->holdGestureBegin(he->fingerCount(), he->time(), he->device()); + break; + } + case LIBINPUT_EVENT_GESTURE_HOLD_END: { + HoldGestureEvent *he = static_cast(event.data()); + if (he->isCancelled()) { + Q_EMIT he->device()->holdGestureCancelled(he->time(), he->device()); + } else { + Q_EMIT he->device()->holdGestureEnd(he->time(), he->device()); } - case LIBINPUT_EVENT_TABLET_PAD_RING: { - auto *tabletEvent = static_cast(event.data()); - tabletEvent->position(); - Q_EMIT event->device()->tabletPadRingEvent(tabletEvent->number(), - tabletEvent->position(), - tabletEvent->source() == LIBINPUT_TABLET_PAD_RING_SOURCE_FINGER, - { event->device()->groupUserData() }); + break; + } + case LIBINPUT_EVENT_SWITCH_TOGGLE: { + SwitchEvent *se = static_cast(event.data()); + switch (se->state()) { + case SwitchEvent::State::Off: + Q_EMIT se->device()->switchToggledOff(se->time(), se->timeMicroseconds(), se->device()); break; - } - case LIBINPUT_EVENT_TABLET_PAD_STRIP: { - auto *tabletEvent = static_cast(event.data()); - Q_EMIT event->device()->tabletPadStripEvent(tabletEvent->number(), - tabletEvent->position(), - tabletEvent->source() == LIBINPUT_TABLET_PAD_STRIP_SOURCE_FINGER, - { event->device()->groupUserData() }); + case SwitchEvent::State::On: + Q_EMIT se->device()->switchToggledOn(se->time(), se->timeMicroseconds(), se->device()); break; - } default: - // nothing + Q_UNREACHABLE(); + } + break; + } + case LIBINPUT_EVENT_TABLET_TOOL_AXIS: + case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY: + case LIBINPUT_EVENT_TABLET_TOOL_TIP: { + auto *tte = static_cast(event.data()); + + KWin::InputRedirection::TabletEventType tabletEventType; + switch (event->type()) { + case LIBINPUT_EVENT_TABLET_TOOL_AXIS: + tabletEventType = KWin::InputRedirection::Axis; break; + case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY: + tabletEventType = KWin::InputRedirection::Proximity; + break; + case LIBINPUT_EVENT_TABLET_TOOL_TIP: + default: + tabletEventType = KWin::InputRedirection::Tip; + break; + } + + if (workspace()) { +#ifndef KWIN_BUILD_TESTING + AbstractWaylandOutput *output = static_cast(tte->device()->output()); + if (!output && workspace()->activeClient()) { + output = static_cast(workspace()->activeClient()->output()); + } + if (!output) { + output = static_cast(workspace()->activeOutput()); + } + const QPointF globalPos = + devicePointToGlobalPosition(tte->transformedPosition(output->modeSize()), + output); +#else + const QPointF globalPos; +#endif + Q_EMIT event->device()->tabletToolEvent(tabletEventType, + globalPos, tte->pressure(), + tte->xTilt(), tte->yTilt(), tte->rotation(), + tte->isTipDown(), tte->isNearby(), createTabletId(tte->tool(), event->device()->groupUserData()), tte->time()); + } + break; + } + case LIBINPUT_EVENT_TABLET_TOOL_BUTTON: { + auto *tabletEvent = static_cast(event.data()); + Q_EMIT event->device()->tabletToolButtonEvent(tabletEvent->buttonId(), + tabletEvent->isButtonPressed(), + createTabletId(tabletEvent->tool(), event->device()->groupUserData())); + break; + } + case LIBINPUT_EVENT_TABLET_PAD_BUTTON: { + auto *tabletEvent = static_cast(event.data()); + Q_EMIT event->device()->tabletPadButtonEvent(tabletEvent->buttonId(), + tabletEvent->isButtonPressed(), + {event->device()->groupUserData()}); + break; + } + case LIBINPUT_EVENT_TABLET_PAD_RING: { + auto *tabletEvent = static_cast(event.data()); + tabletEvent->position(); + Q_EMIT event->device()->tabletPadRingEvent(tabletEvent->number(), + tabletEvent->position(), + tabletEvent->source() == LIBINPUT_TABLET_PAD_RING_SOURCE_FINGER, + {event->device()->groupUserData()}); + break; + } + case LIBINPUT_EVENT_TABLET_PAD_STRIP: { + auto *tabletEvent = static_cast(event.data()); + Q_EMIT event->device()->tabletPadStripEvent(tabletEvent->number(), + tabletEvent->position(), + tabletEvent->source() == LIBINPUT_TABLET_PAD_STRIP_SOURCE_FINGER, + {event->device()->groupUserData()}); + break; + } + default: + // nothing + break; } } } @@ -536,12 +538,11 @@ void Connection::processEvents() void Connection::updateScreens() { QMutexLocker locker(&m_mutex); - for (auto device: qAsConst(m_devices)) { + for (auto device : qAsConst(m_devices)) { applyScreenToDevice(device); } } - void Connection::applyScreenToDevice(Device *device) { #ifndef KWIN_BUILD_TESTING @@ -574,7 +575,7 @@ void Connection::applyScreenToDevice(Device *device) break; } } - auto testScreenMatches = [device] (const AbstractOutput *output) { + auto testScreenMatches = [device](const AbstractOutput *output) { const auto &size = device->size(); const auto &screenSize = output->physicalSize(); return std::round(size.width()) == std::round(screenSize.width()) @@ -645,7 +646,8 @@ void Connection::slotKGlobalSettingsNotifyChange(int type, int arg) } } -QStringList Connection::devicesSysNames() const { +QStringList Connection::devicesSysNames() const +{ QStringList sl; for (Device *d : qAsConst(m_devices)) { sl.append(d->sysName()); diff --git a/src/backends/libinput/connection.h b/src/backends/libinput/connection.h index ea700762bd..c1cf4f6005 100644 --- a/src/backends/libinput/connection.h +++ b/src/backends/libinput/connection.h @@ -15,10 +15,10 @@ #include #include -#include #include -#include +#include #include +#include class QSocketNotifier; class QThread; @@ -39,7 +39,8 @@ class KWIN_EXPORT Connection : public QObject public: ~Connection() override; - void setInputConfig(const KSharedConfigPtr &config) { + void setInputConfig(const KSharedConfigPtr &config) + { m_config = config; } @@ -68,8 +69,8 @@ private: Context *m_input; QSocketNotifier *m_notifier; QRecursiveMutex m_mutex; - QVector m_eventQueue; - QVector m_devices; + QVector m_eventQueue; + QVector m_devices; KSharedConfigPtr m_config; KWIN_SINGLETON(Connection) diff --git a/src/backends/libinput/context.cpp b/src/backends/libinput/context.cpp index ec31494f14..1c41091d48 100644 --- a/src/backends/libinput/context.cpp +++ b/src/backends/libinput/context.cpp @@ -84,17 +84,17 @@ void Context::dispatch() const struct libinput_interface Context::s_interface = { Context::openRestrictedCallback, - Context::closeRestrictedCallBack + Context::closeRestrictedCallBack, }; int Context::openRestrictedCallback(const char *path, int flags, void *user_data) { - return ((Context*)user_data)->openRestricted(path, flags); + return ((Context *)user_data)->openRestricted(path, flags); } void Context::closeRestrictedCallBack(int fd, void *user_data) { - ((Context*)user_data)->closeRestricted(fd); + ((Context *)user_data)->closeRestricted(fd); } int Context::openRestricted(const char *path, int flags) @@ -116,7 +116,7 @@ int Context::openRestricted(const char *path, int flags) } if (flags & O_NONBLOCK) { - fl |= O_NONBLOCK; + fl |= O_NONBLOCK; } if (fcntl(fd, F_SETFL, fl) < 0) { @@ -131,7 +131,7 @@ int Context::openRestricted(const char *path, int flags) } if (!(flags & O_CLOEXEC)) { - fl &= ~FD_CLOEXEC; + fl &= ~FD_CLOEXEC; } if (fcntl(fd, F_SETFD, fl) < 0) { diff --git a/src/backends/libinput/context.h b/src/backends/libinput/context.h index d05e8b45d9..72e96fd805 100644 --- a/src/backends/libinput/context.h +++ b/src/backends/libinput/context.h @@ -27,10 +27,12 @@ public: Context(const Udev &udev); ~Context(); bool assignSeat(const char *seat); - bool isValid() const { + bool isValid() const + { return m_libinput != nullptr; } - bool isSuspended() const { + bool isSuspended() const + { return m_suspended; } @@ -39,10 +41,12 @@ public: void suspend(); void resume(); - operator libinput*() { + operator libinput *() + { return m_libinput; } - operator libinput*() const { + operator libinput *() const + { return m_libinput; } diff --git a/src/backends/libinput/device.cpp b/src/backends/libinput/device.cpp index f247b66d74..8baee01559 100644 --- a/src/backends/libinput/device.cpp +++ b/src/backends/libinput/device.cpp @@ -7,10 +7,13 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "device.h" + +#include + #include "abstract_output.h" +#include "libinput_logging.h" #include "main.h" #include "platform.h" -#include "libinput_logging.h" #include #include @@ -18,8 +21,6 @@ #include -#include - QDBusArgument &operator<<(QDBusArgument &argument, const QMatrix4x4 &matrix) { argument.beginArray(qMetaTypeId()); @@ -76,15 +77,14 @@ static bool checkAlphaNumericKeyboard(libinput_device *device) return true; } -QVector Device::s_devices; +QVector Device::s_devices; Device *Device::getDevice(libinput_device *native) { auto it = std::find_if(s_devices.constBegin(), s_devices.constEnd(), - [native] (const Device *d) { - return d->device() == native; - } - ); + [native](const Device *d) { + return d->device() == native; + }); if (it != s_devices.constEnd()) { return *it; } @@ -112,18 +112,23 @@ enum class ConfigKey { OutputName }; -struct ConfigDataBase { - ConfigDataBase(const QByteArray &_key) : key(_key) { } +struct ConfigDataBase +{ + ConfigDataBase(const QByteArray &_key) + : key(_key) + { + } virtual ~ConfigDataBase() = default; QByteArray key; - virtual void read(Device */*device*/, const KConfigGroup &/*values*/) const = 0; + virtual void read(Device * /*device*/, const KConfigGroup & /*values*/) const = 0; }; -template -struct ConfigData : public ConfigDataBase { - using SetterFunction = std::function; - using DefaultValueFunction = std::function; +template +struct ConfigData : public ConfigDataBase +{ + using SetterFunction = std::function; + using DefaultValueFunction = std::function; explicit ConfigData(const QByteArray &_key, const SetterFunction &_setter, const DefaultValueFunction &_defaultValue) : ConfigDataBase(_key) @@ -153,9 +158,13 @@ struct ConfigData : public ConfigDataBase { using DeviceOrientation = Qt::ScreenOrientation; -template <> -struct ConfigData : public ConfigDataBase { - explicit ConfigData() : ConfigDataBase(QByteArrayLiteral("Orientation") ) { } +template<> +struct ConfigData : public ConfigDataBase +{ + explicit ConfigData() + : ConfigDataBase(QByteArrayLiteral("Orientation")) + { + } void read(Device *device, const KConfigGroup &values) const override { @@ -166,9 +175,13 @@ struct ConfigData : public ConfigDataBase { using CalibrationMatrix = QMatrix4x4; -template <> -struct ConfigData : public ConfigDataBase { - explicit ConfigData() : ConfigDataBase(QByteArrayLiteral("CalibrationMatrix")) { } +template<> +struct ConfigData : public ConfigDataBase +{ + explicit ConfigData() + : ConfigDataBase(QByteArrayLiteral("CalibrationMatrix")) + { + } void read(Device *device, const KConfigGroup &values) const override { @@ -184,7 +197,7 @@ struct ConfigData : public ConfigDataBase { } }; -static const QMap s_configData { +static const QMap s_configData{ {ConfigKey::Enabled, new ConfigData(QByteArrayLiteral("Enabled"), &Device::setEnabled, &Device::isEnabledByDefault)}, {ConfigKey::LeftHanded, new ConfigData(QByteArrayLiteral("LeftHanded"), &Device::setLeftHanded, &Device::leftHandedEnabledByDefault)}, {ConfigKey::DisableWhileTyping, new ConfigData(QByteArrayLiteral("DisableWhileTyping"), &Device::setDisableWhileTyping, &Device::disableWhileTypingEnabledByDefault)}, @@ -202,48 +215,43 @@ static const QMap s_configData { {ConfigKey::ScrollFactor, new ConfigData(QByteArrayLiteral("ScrollFactor"), &Device::setScrollFactor, &Device::scrollFactorDefault)}, {ConfigKey::Orientation, new ConfigData{}}, {ConfigKey::Calibration, new ConfigData{}}, - {ConfigKey::OutputName, new ConfigData(QByteArrayLiteral("OutputName"), &Device::setOutputName, &Device::defaultOutputName)} -}; + {ConfigKey::OutputName, new ConfigData(QByteArrayLiteral("OutputName"), &Device::setOutputName, &Device::defaultOutputName)}}; -namespace { +namespace +{ QMatrix4x4 getMatrix(libinput_device *device, std::function getter) { float matrix[6]; if (!getter(device, matrix)) { return {}; } - return QMatrix4x4 { + return QMatrix4x4{ matrix[0], matrix[1], matrix[2], 0.0f, matrix[3], matrix[4], matrix[5], 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f - }; - + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; } bool setOrientedCalibrationMatrix(libinput_device *device, QMatrix4x4 matrix, Qt::ScreenOrientation orientation) { // 90 deg cw - static const QMatrix4x4 portraitMatrix { + static const QMatrix4x4 portraitMatrix{ 0.0f, -1.0f, 1.0f, 0.0f, - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f - }; + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; // 180 deg cw - static const QMatrix4x4 invertedLandscapeMatrix { - -1.0f, 0.0f, 1.0f, 0.0f, - 0.0f, -1.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f - }; - // 270 deg cw - static const QMatrix4x4 invertedPortraitMatrix { - 0.0f, 1.0f, 0.0f, 0.0f, + static const QMatrix4x4 invertedLandscapeMatrix{ -1.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f - }; + 0.0f, -1.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; + // 270 deg cw + static const QMatrix4x4 invertedPortraitMatrix{ + 0.0f, 1.0f, 0.0f, 0.0f, + -1.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; switch (orientation) { case Qt::PortraitOrientation: @@ -381,8 +389,7 @@ Device::Device(libinput_device *device, QObject *parent) QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/kde/KWin/InputDevice/") + m_sysName, QStringLiteral("org.kde.KWin.InputDevice"), this, - QDBusConnection::ExportAllProperties - ); + QDBusConnection::ExportAllProperties); } Device::~Device() @@ -392,7 +399,7 @@ Device::~Device() libinput_device_unref(m_device); } -template +template void Device::writeEntry(const ConfigKey &key, const T &value) { if (!m_config.isValid()) { @@ -450,7 +457,7 @@ void Device::setScrollButton(quint32 button) } } -void Device::setPointerAccelerationProfile(bool set, enum libinput_config_accel_profile profile) +void Device::setPointerAccelerationProfile(bool set, enum libinput_config_accel_profile profile) { if (!(m_supportedPointerAccelerationProfiles & profile)) { return; @@ -466,7 +473,7 @@ void Device::setPointerAccelerationProfile(bool set, enum libinput_config_accel if (m_pointerAccelerationProfile != profile) { m_pointerAccelerationProfile = profile; Q_EMIT pointerAccelerationProfileChanged(); - writeEntry(ConfigKey::PointerAccelerationProfile, (quint32) profile); + writeEntry(ConfigKey::PointerAccelerationProfile, (quint32)profile); } } } @@ -487,7 +494,7 @@ void Device::setClickMethod(bool set, enum libinput_config_click_method method) if (m_clickMethod != method) { m_clickMethod = method; Q_EMIT clickMethodChanged(); - writeEntry(ConfigKey::ClickMethod, (quint32) method); + writeEntry(ConfigKey::ClickMethod, (quint32)method); } } } @@ -512,7 +519,7 @@ void Device::setScrollMethod(bool set, enum libinput_config_scroll_method method if (!isCurrent) { m_scrollMethod = method; Q_EMIT scrollMethodChanged(); - writeEntry(ConfigKey::ScrollMethod, (quint32) method); + writeEntry(ConfigKey::ScrollMethod, (quint32)method); } } } @@ -553,41 +560,40 @@ void *Device::groupUserData() const return libinput_device_group_get_user_data(deviceGroup); } - -#define CONFIG(method, condition, function, variable, key) \ -void Device::method(bool set) \ -{ \ - if (condition) { \ - return; \ - } \ - if (libinput_device_config_##function(m_device, set) == LIBINPUT_CONFIG_STATUS_SUCCESS) { \ - if (m_##variable != set) { \ - m_##variable = set; \ - writeEntry(ConfigKey::key, m_##variable); \ - Q_EMIT variable##Changed(); \ - }\ - } \ -} +#define CONFIG(method, condition, function, variable, key) \ + void Device::method(bool set) \ + { \ + if (condition) { \ + return; \ + } \ + if (libinput_device_config_##function(m_device, set) == LIBINPUT_CONFIG_STATUS_SUCCESS) { \ + if (m_##variable != set) { \ + m_##variable = set; \ + writeEntry(ConfigKey::key, m_##variable); \ + Q_EMIT variable##Changed(); \ + } \ + } \ + } CONFIG(setLeftHanded, !m_supportsLeftHanded, left_handed_set, leftHanded, LeftHanded) CONFIG(setNaturalScroll, !m_supportsNaturalScroll, scroll_set_natural_scroll_enabled, naturalScroll, NaturalScroll) #undef CONFIG -#define CONFIG(method, condition, function, enum, variable, key) \ -void Device::method(bool set) \ -{ \ - if (condition) { \ - return; \ - } \ - if (libinput_device_config_##function(m_device, set ? LIBINPUT_CONFIG_##enum##_ENABLED : LIBINPUT_CONFIG_##enum##_DISABLED) == LIBINPUT_CONFIG_STATUS_SUCCESS) { \ - if (m_##variable != set) { \ - m_##variable = set; \ - writeEntry(ConfigKey::key, m_##variable); \ - Q_EMIT variable##Changed(); \ - }\ - } \ -} +#define CONFIG(method, condition, function, enum, variable, key) \ + void Device::method(bool set) \ + { \ + if (condition) { \ + return; \ + } \ + if (libinput_device_config_##function(m_device, set ? LIBINPUT_CONFIG_##enum##_ENABLED : LIBINPUT_CONFIG_##enum##_DISABLED) == LIBINPUT_CONFIG_STATUS_SUCCESS) { \ + if (m_##variable != set) { \ + m_##variable = set; \ + writeEntry(ConfigKey::key, m_##variable); \ + Q_EMIT variable##Changed(); \ + } \ + } \ + } CONFIG(setEnabled, !m_supportsDisableEvents, send_events_set_mode, SEND_EVENTS, enabled, Enabled) CONFIG(setDisableWhileTyping, !m_supportsDisableWhileTyping, dwt_set_enabled, DWT, disableWhileTyping, DisableWhileTyping) diff --git a/src/backends/libinput/device.h b/src/backends/libinput/device.h index 152ea1e012..3951c4fb59 100644 --- a/src/backends/libinput/device.h +++ b/src/backends/libinput/device.h @@ -15,8 +15,8 @@ #include -#include #include +#include #include #include #include @@ -142,208 +142,268 @@ public: explicit Device(libinput_device *device, QObject *parent = nullptr); ~Device() override; - bool isKeyboard() const override { + bool isKeyboard() const override + { return m_keyboard; } - bool isAlphaNumericKeyboard() const override { + bool isAlphaNumericKeyboard() const override + { return m_alphaNumericKeyboard; } - bool isPointer() const override { + bool isPointer() const override + { return m_pointer; } - bool isTouchpad() const override { + bool isTouchpad() const override + { 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); + // 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 override { + bool isTouch() const override + { return m_touch; } - bool isTabletTool() const override { + bool isTabletTool() const override + { return m_tabletTool; } - bool isTabletPad() const override { + bool isTabletPad() const override + { return m_tabletPad; } - bool supportsGesture() const { + bool supportsGesture() const + { return m_supportsGesture; } - QString name() const override { + QString name() const override + { return m_name; } - QString sysName() const override { + QString sysName() const override + { return m_sysName; } - QString outputName() const { + QString outputName() const + { return m_outputName; } - QSizeF size() const { + QSizeF size() const + { return m_size; } - quint32 product() const { + quint32 product() const + { return m_product; } - quint32 vendor() const { + quint32 vendor() const + { return m_vendor; } - Qt::MouseButtons supportedButtons() const { + Qt::MouseButtons supportedButtons() const + { return m_supportedButtons; } - int tapFingerCount() const { + int tapFingerCount() const + { return m_tapFingerCount; } - bool tapToClickEnabledByDefault() const { + bool tapToClickEnabledByDefault() const + { return defaultValue("TapToClick", m_tapToClickEnabledByDefault); } - bool isTapToClick() const { + 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 { + bool tapAndDragEnabledByDefault() const + { return defaultValue("TapAndDrag", m_tapAndDragEnabledByDefault); } - bool isTapAndDrag() const { + bool isTapAndDrag() const + { return m_tapAndDrag; } void setTapAndDrag(bool set); - bool tapDragLockEnabledByDefault() const { + bool tapDragLockEnabledByDefault() const + { return defaultValue("TapDragLock", m_tapDragLockEnabledByDefault); } - bool isTapDragLock() const { + bool isTapDragLock() const + { return m_tapDragLock; } void setTapDragLock(bool set); - bool supportsDisableWhileTyping() const { + bool supportsDisableWhileTyping() const + { return m_supportsDisableWhileTyping; } - bool disableWhileTypingEnabledByDefault() const { + bool disableWhileTypingEnabledByDefault() const + { return defaultValue("DisableWhileTyping", m_disableWhileTypingEnabledByDefault); } - bool supportsPointerAcceleration() const { + bool supportsPointerAcceleration() const + { return m_supportsPointerAcceleration; } - bool supportsLeftHanded() const { + bool supportsLeftHanded() const + { return m_supportsLeftHanded; } - bool supportsCalibrationMatrix() const { + bool supportsCalibrationMatrix() const + { return m_supportsCalibrationMatrix; } - bool supportsDisableEvents() const { + bool supportsDisableEvents() const + { return m_supportsDisableEvents; } - bool supportsDisableEventsOnExternalMouse() const { + bool supportsDisableEventsOnExternalMouse() const + { return m_supportsDisableEventsOnExternalMouse; } - bool supportsMiddleEmulation() const { + bool supportsMiddleEmulation() const + { return m_supportsMiddleEmulation; } - bool supportsNaturalScroll() const { + bool supportsNaturalScroll() const + { return m_supportsNaturalScroll; } - bool supportsScrollTwoFinger() const { + bool supportsScrollTwoFinger() const + { return (m_supportedScrollMethods & LIBINPUT_CONFIG_SCROLL_2FG); } - bool supportsScrollEdge() const { + bool supportsScrollEdge() const + { return (m_supportedScrollMethods & LIBINPUT_CONFIG_SCROLL_EDGE); } - bool supportsScrollOnButtonDown() const { + bool supportsScrollOnButtonDown() const + { return (m_supportedScrollMethods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN); } - bool leftHandedEnabledByDefault() const { + bool leftHandedEnabledByDefault() const + { return defaultValue("LeftHanded", m_leftHandedEnabledByDefault); } - bool middleEmulationEnabledByDefault() const { + bool middleEmulationEnabledByDefault() const + { return defaultValue("MiddleButtonEmulation", m_middleEmulationEnabledByDefault); } - bool naturalScrollEnabledByDefault() const { + bool naturalScrollEnabledByDefault() const + { return defaultValue("NaturalScroll", m_naturalScrollEnabledByDefault); } - enum libinput_config_scroll_method defaultScrollMethod() const { + enum libinput_config_scroll_method defaultScrollMethod() const + { quint32 defaultScrollMethod = defaultValue("ScrollMethod", static_cast(m_defaultScrollMethod)); return static_cast(defaultScrollMethod); } - quint32 defaultScrollMethodToInt() const { + quint32 defaultScrollMethodToInt() const + { return static_cast(defaultScrollMethod()); } - bool scrollTwoFingerEnabledByDefault() const { + bool scrollTwoFingerEnabledByDefault() const + { return defaultScrollMethod() == LIBINPUT_CONFIG_SCROLL_2FG; } - bool scrollEdgeEnabledByDefault() const { + bool scrollEdgeEnabledByDefault() const + { return defaultScrollMethod() == LIBINPUT_CONFIG_SCROLL_EDGE; } - bool scrollOnButtonDownEnabledByDefault() const { + bool scrollOnButtonDownEnabledByDefault() const + { return defaultScrollMethod() == LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; } - bool supportsLmrTapButtonMap() const { + bool supportsLmrTapButtonMap() const + { return m_tapFingerCount > 1; } - bool lmrTapButtonMapEnabledByDefault() const { + bool lmrTapButtonMapEnabledByDefault() const + { quint32 lmrButtonMap = defaultValue("LmrTapButtonMap", static_cast(m_defaultTapButtonMap)); return lmrButtonMap == LIBINPUT_CONFIG_TAP_MAP_LMR; } void setLmrTapButtonMap(bool set); - bool lmrTapButtonMap() const { + bool lmrTapButtonMap() const + { return m_tapButtonMap & LIBINPUT_CONFIG_TAP_MAP_LMR; } - quint32 defaultScrollButton() const { + quint32 defaultScrollButton() const + { return m_defaultScrollButton; } - bool isMiddleEmulation() const { + bool isMiddleEmulation() const + { return m_middleEmulation; } void setMiddleEmulation(bool set); - bool isNaturalScroll() const { + bool isNaturalScroll() const + { return m_naturalScroll; } void setNaturalScroll(bool set); void setScrollMethod(bool set, enum libinput_config_scroll_method method); - bool isScrollTwoFinger() const { + bool isScrollTwoFinger() const + { return m_scrollMethod & LIBINPUT_CONFIG_SCROLL_2FG; } - void setScrollTwoFinger(bool set) { + void setScrollTwoFinger(bool set) + { setScrollMethod(set, LIBINPUT_CONFIG_SCROLL_2FG); } - bool isScrollEdge() const { + bool isScrollEdge() const + { return m_scrollMethod & LIBINPUT_CONFIG_SCROLL_EDGE; } - void setScrollEdge(bool set) { + void setScrollEdge(bool set) + { setScrollMethod(set, LIBINPUT_CONFIG_SCROLL_EDGE); } - bool isScrollOnButtonDown() const { + bool isScrollOnButtonDown() const + { return m_scrollMethod & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; } - void setScrollOnButtonDown(bool set) { + void setScrollOnButtonDown(bool set) + { setScrollMethod(set, LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN); } - void activateScrollMethodFromInt(quint32 method) { - setScrollMethod(true, (libinput_config_scroll_method) method); + void activateScrollMethodFromInt(quint32 method) + { + setScrollMethod(true, (libinput_config_scroll_method)method); } - quint32 scrollButton() const { + quint32 scrollButton() const + { return m_scrollButton; } void setScrollButton(quint32 button); - qreal scrollFactorDefault() const { + qreal scrollFactorDefault() const + { return defaultValue("ScrollFactor", 1.0); } - qreal scrollFactor() const { + qreal scrollFactor() const + { return m_scrollFactor; } void setScrollFactor(qreal factor); void setDisableWhileTyping(bool set); - bool isDisableWhileTyping() const { + bool isDisableWhileTyping() const + { return m_disableWhileTyping; } - bool isLeftHanded() const { + bool isLeftHanded() const + { return m_leftHanded; } /** @@ -382,98 +442,126 @@ public: setOrientation(Qt::ScreenOrientation(orientation)); } - qreal defaultPointerAcceleration() const { + qreal defaultPointerAcceleration() const + { return m_defaultPointerAcceleration; } - qreal pointerAcceleration() const { + 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(const QString &acceleration) { + void setPointerAccelerationFromString(const QString &acceleration) + { setPointerAcceleration(acceleration.toDouble()); } - QString defaultPointerAccelerationToString() const { + QString defaultPointerAccelerationToString() const + { return QString::number(m_pointerAcceleration, 'f', 3); } - bool supportsPointerAccelerationProfileFlat() const { + bool supportsPointerAccelerationProfileFlat() const + { return (m_supportedPointerAccelerationProfiles & LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT); } - bool supportsPointerAccelerationProfileAdaptive() const { + bool supportsPointerAccelerationProfileAdaptive() const + { return (m_supportedPointerAccelerationProfiles & LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); } - bool defaultPointerAccelerationProfileFlat() const { + bool defaultPointerAccelerationProfileFlat() const + { return (m_defaultPointerAccelerationProfile & LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT); } - bool defaultPointerAccelerationProfileAdaptive() const { + bool defaultPointerAccelerationProfileAdaptive() const + { return (m_defaultPointerAccelerationProfile & LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); } - bool pointerAccelerationProfileFlat() const { + bool pointerAccelerationProfileFlat() const + { return (m_pointerAccelerationProfile & LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT); } - bool pointerAccelerationProfileAdaptive() const { + 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) { + 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) { + void setPointerAccelerationProfileAdaptive(bool set) + { setPointerAccelerationProfile(set, LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE); } - void setPointerAccelerationProfileFromInt(quint32 profile) { - setPointerAccelerationProfile(true, (libinput_config_accel_profile) profile); + void setPointerAccelerationProfileFromInt(quint32 profile) + { + setPointerAccelerationProfile(true, (libinput_config_accel_profile)profile); } - quint32 defaultPointerAccelerationProfileToInt() const { + quint32 defaultPointerAccelerationProfileToInt() const + { return defaultValue("PointerAccelerationProfile", static_cast(m_defaultPointerAccelerationProfile)); } - bool supportsClickMethodAreas() const { + bool supportsClickMethodAreas() const + { return (m_supportedClickMethods & LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS); } - bool defaultClickMethodAreas() const { + bool defaultClickMethodAreas() const + { return (defaultClickMethod() == LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS); } - bool isClickMethodAreas() const { + bool isClickMethodAreas() const + { return (m_clickMethod == LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS); } - bool supportsClickMethodClickfinger() const { + bool supportsClickMethodClickfinger() const + { return (m_supportedClickMethods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER); } - bool defaultClickMethodClickfinger() const { + bool defaultClickMethodClickfinger() const + { return (defaultClickMethod() == LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER); } - bool isClickMethodClickfinger() const { + 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) { + void setClickMethodAreas(bool set) + { setClickMethod(set, LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS); } - void setClickMethodClickfinger(bool set) { + void setClickMethodClickfinger(bool set) + { setClickMethod(set, LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER); } - void setClickMethodFromInt(quint32 method) { - setClickMethod(true, (libinput_config_click_method) method); + void setClickMethodFromInt(quint32 method) + { + setClickMethod(true, (libinput_config_click_method)method); } - libinput_config_click_method defaultClickMethod() const { + libinput_config_click_method defaultClickMethod() const + { return static_cast(defaultClickMethodToInt()); } - quint32 defaultClickMethodToInt() const { + quint32 defaultClickMethodToInt() const + { return defaultValue("ClickMethod", static_cast(m_defaultClickMethod)); } - bool isEnabled() const override { + bool isEnabled() const override + { return m_enabled; } void setEnabled(bool enabled) override; - bool isEnabledByDefault() const { + bool isEnabledByDefault() const + { return defaultValue("Enabled", true); } - libinput_device *device() const { + libinput_device *device() const + { return m_device; } @@ -481,11 +569,13 @@ public: * Sets the @p config to load the Device configuration from and to store each * successful Device configuration. */ - void setConfig(const KConfigGroup &config) { + void setConfig(const KConfigGroup &config) + { m_config = config; } - void setDefaultConfig(const KConfigGroup &config) { + void setDefaultConfig(const KConfigGroup &config) + { m_defaultConfig = config; } @@ -503,15 +593,18 @@ public: */ void loadConfiguration(); - bool isSwitch() const { + bool isSwitch() const + { return m_switch; } - bool isLidSwitch() const override { + bool isLidSwitch() const override + { return m_lidSwitch; } - bool isTabletModeSwitch() const override { + bool isTabletModeSwitch() const override + { return m_tabletSwitch; } @@ -529,7 +622,8 @@ public: /** * All created Devices */ - static QVector devices() { + static QVector devices() + { return s_devices; } /** @@ -558,11 +652,11 @@ Q_SIGNALS: void clickMethodChanged(); private: - template + template void writeEntry(const ConfigKey &key, const T &value); - template - T defaultValue(const char* key, const T &fallback) const + template + T defaultValue(const char *key, const T &fallback) const { if (m_defaultConfig.isValid() && m_defaultConfig.hasKey(key)) { return m_defaultConfig.readEntry(key, fallback); @@ -642,12 +736,12 @@ private: enum libinput_config_click_method m_clickMethod; LEDs m_leds; - static QVector s_devices; + static QVector s_devices; }; } } -Q_DECLARE_METATYPE(KWin::LibInput::Device*) +Q_DECLARE_METATYPE(KWin::LibInput::Device *) #endif diff --git a/src/backends/libinput/events.cpp b/src/backends/libinput/events.cpp index 6ae200ffb1..c9f779b27f 100644 --- a/src/backends/libinput/events.cpp +++ b/src/backends/libinput/events.cpp @@ -206,8 +206,8 @@ qreal PointerEvent::axisValue(InputRedirection::PointerAxis axis) const { Q_ASSERT(type() == LIBINPUT_EVENT_POINTER_AXIS); const libinput_pointer_axis a = axis == InputRedirection::PointerAxisHorizontal - ? LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL - : LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL; + ? LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL + : LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL; return libinput_event_pointer_get_axis_value(m_pointerEvent, a) * device()->scrollFactor(); } @@ -341,8 +341,7 @@ SwitchEvent::~SwitchEvent() = default; SwitchEvent::State SwitchEvent::state() const { - switch (libinput_event_switch_get_switch_state(m_switchEvent)) - { + switch (libinput_event_switch_get_switch_state(m_switchEvent)) { case LIBINPUT_SWITCH_STATE_OFF: return State::Off; case LIBINPUT_SWITCH_STATE_ON: diff --git a/src/backends/libinput/events.h b/src/backends/libinput/events.h index 7d01bada2e..93d5cd4dcd 100644 --- a/src/backends/libinput/events.h +++ b/src/backends/libinput/events.h @@ -29,10 +29,12 @@ public: Device *device() const; libinput_device *nativeDevice() const; - operator libinput_event*() { + operator libinput_event *() + { return m_event; } - operator libinput_event*() const { + operator libinput_event *() const + { return m_event; } @@ -57,10 +59,12 @@ public: InputRedirection::KeyboardKeyState state() const; uint32_t time() const; - operator libinput_event_keyboard*() { + operator libinput_event_keyboard *() + { return m_keyboardEvent; } - operator libinput_event_keyboard*() const { + operator libinput_event_keyboard *() const + { return m_keyboardEvent; } @@ -71,7 +75,7 @@ private: class PointerEvent : public Event { public: - PointerEvent(libinput_event* event, libinput_event_type type); + PointerEvent(libinput_event *event, libinput_event_type type); ~PointerEvent() override; QPointF absolutePos() const; @@ -87,10 +91,12 @@ public: qint32 discreteAxisValue(InputRedirection::PointerAxis axis) const; InputRedirection::PointerAxisSource axisSource() const; - operator libinput_event_pointer*() { + operator libinput_event_pointer *() + { return m_pointerEvent; } - operator libinput_event_pointer*() const { + operator libinput_event_pointer *() const + { return m_pointerEvent; } @@ -109,10 +115,12 @@ public: QPointF absolutePos(const QSize &size) const; qint32 id() const; - operator libinput_event_touch*() { + operator libinput_event_touch *() + { return m_touchEvent; } - operator libinput_event_touch*() const { + operator libinput_event_touch *() const + { return m_touchEvent; } @@ -132,10 +140,12 @@ public: bool isCancelled() const; - operator libinput_event_gesture*() { + operator libinput_event_gesture *() + { return m_gestureEvent; } - operator libinput_event_gesture*() const { + operator libinput_event_gesture *() const + { return m_gestureEvent; } @@ -168,7 +178,6 @@ public: ~HoldGestureEvent() override; }; - class SwitchEvent : public Event { public: @@ -197,28 +206,36 @@ public: { return libinput_event_tablet_tool_get_time(m_tabletToolEvent); } - bool xHasChanged() const { + bool xHasChanged() const + { return libinput_event_tablet_tool_x_has_changed(m_tabletToolEvent); } - bool yHasChanged() const { + bool yHasChanged() const + { return libinput_event_tablet_tool_y_has_changed(m_tabletToolEvent); } - bool pressureHasChanged() const { + bool pressureHasChanged() const + { return libinput_event_tablet_tool_pressure_has_changed(m_tabletToolEvent); } - bool distanceHasChanged() const { + bool distanceHasChanged() const + { return libinput_event_tablet_tool_distance_has_changed(m_tabletToolEvent); } - bool tiltXHasChanged() const { + bool tiltXHasChanged() const + { return libinput_event_tablet_tool_tilt_x_has_changed(m_tabletToolEvent); } - bool tiltYHasChanged() const { + bool tiltYHasChanged() const + { return libinput_event_tablet_tool_tilt_y_has_changed(m_tabletToolEvent); } - bool rotationHasChanged() const { + bool rotationHasChanged() const + { return libinput_event_tablet_tool_rotation_has_changed(m_tabletToolEvent); } - bool sliderHasChanged() const { + bool sliderHasChanged() const + { return libinput_event_tablet_tool_slider_has_changed(m_tabletToolEvent); } @@ -227,33 +244,42 @@ public: // libinput_event_tablet_tool_size_major_has_changed(m_tabletToolEvent); } bool // sizeMinorHasChanged() const { return // libinput_event_tablet_tool_size_minor_has_changed(m_tabletToolEvent); } - bool wheelHasChanged() const { + bool wheelHasChanged() const + { return libinput_event_tablet_tool_wheel_has_changed(m_tabletToolEvent); } - QPointF position() const { + QPointF position() const + { return {libinput_event_tablet_tool_get_x(m_tabletToolEvent), libinput_event_tablet_tool_get_y(m_tabletToolEvent)}; } - QPointF delta() const { + QPointF delta() const + { return {libinput_event_tablet_tool_get_dx(m_tabletToolEvent), libinput_event_tablet_tool_get_dy(m_tabletToolEvent)}; } - qreal pressure() const { + qreal pressure() const + { return libinput_event_tablet_tool_get_pressure(m_tabletToolEvent); } - qreal distance() const { + qreal distance() const + { return libinput_event_tablet_tool_get_distance(m_tabletToolEvent); } - int xTilt() const { + int xTilt() const + { return libinput_event_tablet_tool_get_tilt_x(m_tabletToolEvent); } - int yTilt() const { + int yTilt() const + { return libinput_event_tablet_tool_get_tilt_y(m_tabletToolEvent); } - qreal rotation() const { + qreal rotation() const + { return libinput_event_tablet_tool_get_rotation(m_tabletToolEvent); } - qreal sliderPosition() const { + qreal sliderPosition() const + { return libinput_event_tablet_tool_get_slider_position(m_tabletToolEvent); } // Uncomment when depending on libinput 1.14 or when implementing totems @@ -261,28 +287,34 @@ public: // libinput_event_tablet_tool_get_size_major(m_tabletToolEvent); } // qreal sizeMinor() const { // return libinput_event_tablet_tool_get_size_minor(m_tabletToolEvent); } - qreal wheelDelta() const { + qreal wheelDelta() const + { return libinput_event_tablet_tool_get_wheel_delta(m_tabletToolEvent); } - int wheelDeltaDiscrete() const { + int wheelDeltaDiscrete() const + { return libinput_event_tablet_tool_get_wheel_delta_discrete(m_tabletToolEvent); } - bool isTipDown() const { + bool isTipDown() const + { const auto state = libinput_event_tablet_tool_get_tip_state(m_tabletToolEvent); return state == LIBINPUT_TABLET_TOOL_TIP_DOWN; } - bool isNearby() const { + bool isNearby() const + { const auto state = libinput_event_tablet_tool_get_proximity_state(m_tabletToolEvent); return state == LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN; } - QPointF transformedPosition(const QSize &size) const { + QPointF transformedPosition(const QSize &size) const + { return {libinput_event_tablet_tool_get_x_transformed(m_tabletToolEvent, size.width()), libinput_event_tablet_tool_get_y_transformed(m_tabletToolEvent, size.height())}; } - struct libinput_tablet_tool *tool() { + struct libinput_tablet_tool *tool() + { return libinput_event_tablet_tool_get_tool(m_tabletToolEvent); } @@ -295,16 +327,19 @@ class TabletToolButtonEvent : public Event public: TabletToolButtonEvent(libinput_event *event, libinput_event_type type); - uint buttonId() const { + uint buttonId() const + { return libinput_event_tablet_tool_get_button(m_tabletToolEvent); } - bool isButtonPressed() const { + bool isButtonPressed() const + { const auto state = libinput_event_tablet_tool_get_button_state(m_tabletToolEvent); return state == LIBINPUT_BUTTON_STATE_PRESSED; } - struct libinput_tablet_tool *tool() { + struct libinput_tablet_tool *tool() + { return libinput_event_tablet_tool_get_tool(m_tabletToolEvent); } @@ -317,13 +352,16 @@ class TabletPadRingEvent : public Event public: TabletPadRingEvent(libinput_event *event, libinput_event_type type); - int position() const { + int position() const + { return libinput_event_tablet_pad_get_ring_position(m_tabletPadEvent); } - int number() const { + int number() const + { return libinput_event_tablet_pad_get_ring_number(m_tabletPadEvent); } - libinput_tablet_pad_ring_axis_source source() const { + libinput_tablet_pad_ring_axis_source source() const + { return libinput_event_tablet_pad_get_ring_source(m_tabletPadEvent); } @@ -336,13 +374,16 @@ class TabletPadStripEvent : public Event public: TabletPadStripEvent(libinput_event *event, libinput_event_type type); - int position() const { + int position() const + { return libinput_event_tablet_pad_get_strip_position(m_tabletPadEvent); } - int number() const { + int number() const + { return libinput_event_tablet_pad_get_strip_number(m_tabletPadEvent); } - libinput_tablet_pad_strip_axis_source source() const { + libinput_tablet_pad_strip_axis_source source() const + { return libinput_event_tablet_pad_get_strip_source(m_tabletPadEvent); } @@ -355,10 +396,12 @@ class TabletPadButtonEvent : public Event public: TabletPadButtonEvent(libinput_event *event, libinput_event_type type); - uint buttonId() const { + uint buttonId() const + { return libinput_event_tablet_pad_get_button_number(m_tabletPadEvent); } - bool isButtonPressed() const { + bool isButtonPressed() const + { const auto state = libinput_event_tablet_pad_get_button_state(m_tabletPadEvent); return state == LIBINPUT_BUTTON_STATE_PRESSED; } @@ -367,8 +410,7 @@ private: libinput_event_tablet_pad *m_tabletPadEvent; }; -inline -libinput_event_type Event::type() const +inline libinput_event_type Event::type() const { return m_type; } diff --git a/src/backends/libinput/libinputbackend.cpp b/src/backends/libinput/libinputbackend.cpp index aacc849741..303f1158af 100644 --- a/src/backends/libinput/libinputbackend.cpp +++ b/src/backends/libinput/libinputbackend.cpp @@ -21,9 +21,11 @@ LibinputBackend::LibinputBackend(QObject *parent) m_connection = LibInput::Connection::create(this); m_connection->moveToThread(m_thread); - connect(m_connection, &LibInput::Connection::eventsRead, this, [this]() { - m_connection->processEvents(); - }, Qt::QueuedConnection); + connect( + m_connection, &LibInput::Connection::eventsRead, this, [this]() { + m_connection->processEvents(); + }, + Qt::QueuedConnection); // Direct connection because the deviceAdded() and the deviceRemoved() signals are emitted // from the main thread. diff --git a/src/backends/virtual/egl_gbm_backend.cpp b/src/backends/virtual/egl_gbm_backend.cpp index 96c9089eb2..01919c4f64 100644 --- a/src/backends/virtual/egl_gbm_backend.cpp +++ b/src/backends/virtual/egl_gbm_backend.cpp @@ -11,10 +11,10 @@ #include "basiceglsurfacetexture_internal.h" #include "basiceglsurfacetexture_wayland.h" #include "composite.h" -#include "virtual_backend.h" #include "options.h" #include "screens.h" #include "softwarevsyncmonitor.h" +#include "virtual_backend.h" #include "virtual_output.h" #include // kwin libs @@ -117,13 +117,20 @@ bool EglGbmBackend::initRenderingContext() bool EglGbmBackend::initBufferConfigs() { const EGLint config_attribs[] = { - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_RED_SIZE, 1, - EGL_GREEN_SIZE, 1, - EGL_BLUE_SIZE, 1, - EGL_ALPHA_SIZE, 0, - EGL_RENDERABLE_TYPE, isOpenGLES() ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT, - EGL_CONFIG_CAVEAT, EGL_NONE, + EGL_SURFACE_TYPE, + EGL_WINDOW_BIT, + EGL_RED_SIZE, + 1, + EGL_GREEN_SIZE, + 1, + EGL_BLUE_SIZE, + 1, + EGL_ALPHA_SIZE, + 0, + EGL_RENDERABLE_TYPE, + isOpenGLES() ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT, + EGL_CONFIG_CAVEAT, + EGL_NONE, EGL_NONE, }; @@ -176,16 +183,15 @@ static void convertFromGLImage(QImage &img, int w, int h) } else { // OpenGL gives ABGR (i.e. RGBA backwards); Qt wants ARGB for (int y = 0; y < h; y++) { - uint *q = reinterpret_cast(img.scanLine(y)); + uint *q = reinterpret_cast(img.scanLine(y)); for (int x = 0; x < w; ++x) { const uint pixel = *q; *q = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) - | (pixel & 0xff00ff00); + | (pixel & 0xff00ff00); q++; } } - } img = img.mirrored(); } @@ -200,7 +206,7 @@ void EglGbmBackend::endFrame(AbstractOutput *output, const QRegion &renderedRegi if (m_backend->saveFrames()) { QImage img = QImage(QSize(m_backBuffer->width(), m_backBuffer->height()), QImage::Format_ARGB32); - glReadnPixels(0, 0, m_backBuffer->width(), m_backBuffer->height(), GL_RGBA, GL_UNSIGNED_BYTE, img.sizeInBytes(), (GLvoid*)img.bits()); + glReadnPixels(0, 0, m_backBuffer->width(), m_backBuffer->height(), GL_RGBA, GL_UNSIGNED_BYTE, img.sizeInBytes(), (GLvoid *)img.bits()); convertFromGLImage(img, m_backBuffer->width(), m_backBuffer->height()); img.save(QStringLiteral("%1/%2.png").arg(m_backend->saveFrames()).arg(QString::number(m_frameCounter++))); } diff --git a/src/backends/virtual/scene_qpainter_virtual_backend.h b/src/backends/virtual/scene_qpainter_virtual_backend.h index 4c1d728c64..089d9a506a 100644 --- a/src/backends/virtual/scene_qpainter_virtual_backend.h +++ b/src/backends/virtual/scene_qpainter_virtual_backend.h @@ -11,9 +11,9 @@ #include "qpainterbackend.h" +#include #include #include -#include namespace KWin { diff --git a/src/backends/virtual/virtual_backend.cpp b/src/backends/virtual/virtual_backend.cpp index 8b76000c4e..359255c086 100644 --- a/src/backends/virtual/virtual_backend.cpp +++ b/src/backends/virtual/virtual_backend.cpp @@ -7,17 +7,19 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "virtual_backend.h" -#include "virtual_output.h" + +#include + +#include "egl_gbm_backend.h" #include "scene_qpainter_virtual_backend.h" #include "session.h" +#include "virtual_output.h" #include "wayland_server.h" -#include "egl_gbm_backend.h" // Qt #include // system #include #include -#include namespace KWin { @@ -64,7 +66,7 @@ bool VirtualBackend::initialize() if (m_outputs.isEmpty()) { VirtualOutput *dummyOutput = new VirtualOutput(this); dummyOutput->init(QPoint(0, 0), initialWindowSize()); - m_outputs << dummyOutput ; + m_outputs << dummyOutput; m_outputsEnabled << dummyOutput; Q_EMIT outputAdded(dummyOutput); Q_EMIT outputEnabled(dummyOutput); diff --git a/src/backends/virtual/virtual_backend.h b/src/backends/virtual/virtual_backend.h index 3445c4633a..7547400027 100644 --- a/src/backends/virtual/virtual_backend.h +++ b/src/backends/virtual/virtual_backend.h @@ -36,12 +36,13 @@ public: Session *session() const override; bool initialize() override; - bool saveFrames() const { + bool saveFrames() const + { return !m_screenshotDir.isNull(); } QString screenshotDirPath() const; - QPainterBackend* createQPainterBackend() override; + QPainterBackend *createQPainterBackend() override; OpenGLBackend *createOpenGLBackend() override; Q_INVOKABLE void setVirtualOutputs(int count, QVector geometries = QVector(), QVector scales = QVector()); @@ -49,7 +50,8 @@ public: Outputs outputs() const override; Outputs enabledOutputs() const override; - QVector supportedCompositors() const override { + QVector supportedCompositors() const override + { if (selectedCompositor() != NoCompositing) { return {selectedCompositor()}; } @@ -64,8 +66,8 @@ Q_SIGNALS: void virtualOutputsSet(bool countChanged); private: - QVector m_outputs; - QVector m_outputsEnabled; + QVector m_outputs; + QVector m_outputsEnabled; QScopedPointer m_screenshotDir; Session *m_session; }; diff --git a/src/backends/virtual/virtual_output.cpp b/src/backends/virtual/virtual_output.cpp index d91219cda6..96d8f876f4 100644 --- a/src/backends/virtual/virtual_output.cpp +++ b/src/backends/virtual/virtual_output.cpp @@ -57,7 +57,7 @@ void VirtualOutput::init(const QPoint &logicalPosition, const QSize &pixelSize) QByteArray("manufacturer_").append(QByteArray::number(m_identifier)), QByteArray("eisa_").append(QByteArray::number(m_identifier)), QByteArray("serial_").append(QByteArray::number(m_identifier)), - pixelSize, { mode }, QByteArray("EDID_").append(QByteArray::number(m_identifier))); + pixelSize, {mode}, QByteArray("EDID_").append(QByteArray::number(m_identifier))); setGeometry(QRect(logicalPosition, pixelSize)); } diff --git a/src/backends/virtual/virtual_output.h b/src/backends/virtual/virtual_output.h index a8f45662fe..42cce32f16 100644 --- a/src/backends/virtual/virtual_output.h +++ b/src/backends/virtual/virtual_output.h @@ -35,10 +35,12 @@ public: void setGeometry(const QRect &geo); - int gammaRampSize() const override { + int gammaRampSize() const override + { return m_gammaSize; } - bool setGammaRamp(const GammaRamp &gamma) override { + bool setGammaRamp(const GammaRamp &gamma) override + { Q_UNUSED(gamma); return m_gammaResult; } diff --git a/src/backends/wayland/egl_wayland_backend.cpp b/src/backends/wayland/egl_wayland_backend.cpp index f9a3ec53fa..e51e1dbfb9 100644 --- a/src/backends/wayland/egl_wayland_backend.cpp +++ b/src/backends/wayland/egl_wayland_backend.cpp @@ -21,11 +21,11 @@ #include "logging.h" #include "options.h" -#include "wayland_server.h" #include "screens.h" +#include "wayland_server.h" -#include #include +#include // kwin libs #include @@ -64,7 +64,7 @@ bool EglWaylandOutput::init(EglWaylandBackend *backend) EGLSurface eglSurface = EGL_NO_SURFACE; if (backend->havePlatformBase()) { - eglSurface = eglCreatePlatformWindowSurfaceEXT(backend->eglDisplay(), backend->config(), (void *) overlay, nullptr); + eglSurface = eglCreatePlatformWindowSurfaceEXT(backend->eglDisplay(), backend->config(), (void *)overlay, nullptr); } else { eglSurface = eglCreateWindowSurface(backend->eglDisplay(), backend->config(), overlay, nullptr); } @@ -112,7 +112,7 @@ EglWaylandBackend::EglWaylandBackend(WaylandBackend *b) setFailed("Wayland Backend has not been created"); return; } - qCDebug(KWIN_WAYLAND_BACKEND) << "Connected to Wayland display?" << (m_backend->display() ? "yes" : "no" ); + qCDebug(KWIN_WAYLAND_BACKEND) << "Connected to Wayland display?" << (m_backend->display() ? "yes" : "no"); if (!m_backend->display()) { setFailed("Could not connect to Wayland compositor"); return; @@ -122,20 +122,16 @@ EglWaylandBackend::EglWaylandBackend(WaylandBackend *b) setIsDirectRendering(true); connect(m_backend, &WaylandBackend::outputAdded, this, &EglWaylandBackend::createEglWaylandOutput); - connect(m_backend, &WaylandBackend::outputRemoved, this, - [this] (AbstractOutput *output) { - auto it = std::find_if(m_outputs.begin(), m_outputs.end(), - [output] (const EglWaylandOutput *o) { - return o->m_waylandOutput == output; - } - ); - if (it == m_outputs.end()) { - return; - } - cleanupOutput(*it); - m_outputs.erase(it); + connect(m_backend, &WaylandBackend::outputRemoved, this, [this](AbstractOutput *output) { + auto it = std::find_if(m_outputs.begin(), m_outputs.end(), [output](const EglWaylandOutput *o) { + return o->m_waylandOutput == output; + }); + if (it == m_outputs.end()) { + return; } - ); + cleanupOutput(*it); + m_outputs.erase(it); + }); } EglWaylandBackend::~EglWaylandBackend() @@ -264,13 +260,20 @@ bool EglWaylandBackend::makeContextCurrent(EglWaylandOutput *output) bool EglWaylandBackend::initBufferConfigs() { const EGLint config_attribs[] = { - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_RED_SIZE, 1, - EGL_GREEN_SIZE, 1, - EGL_BLUE_SIZE, 1, - EGL_ALPHA_SIZE, 0, - EGL_RENDERABLE_TYPE, isOpenGLES() ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT, - EGL_CONFIG_CAVEAT, EGL_NONE, + EGL_SURFACE_TYPE, + EGL_WINDOW_BIT, + EGL_RED_SIZE, + 1, + EGL_GREEN_SIZE, + 1, + EGL_BLUE_SIZE, + 1, + EGL_ALPHA_SIZE, + 0, + EGL_RENDERABLE_TYPE, + isOpenGLES() ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT, + EGL_CONFIG_CAVEAT, + EGL_NONE, EGL_NONE, }; @@ -309,7 +312,6 @@ static QVector regionToRects(const QRegion ®ion, AbstractWaylandOutpu return rects; } - QSharedPointer EglWaylandBackend::textureForOutput(KWin::AbstractOutput *output) const { QSharedPointer texture(new GLTexture(GL_RGBA8, output->pixelSize())); @@ -328,7 +330,7 @@ void EglWaylandBackend::aboutToStartPainting(AbstractOutput *output, const QRegi if (eglOutput->m_bufferAge > 0 && !damagedRegion.isEmpty() && supportsPartialUpdate()) { QVector rects = regionToRects(damagedRegion, eglOutput->m_waylandOutput); const bool correct = eglSetDamageRegionKHR(eglDisplay(), eglOutput->m_eglSurface, - rects.data(), rects.count()/4); + rects.data(), rects.count() / 4); if (!correct) { qCWarning(KWIN_WAYLAND_BACKEND) << "failed eglSetDamageRegionKHR" << eglGetError(); } @@ -358,7 +360,6 @@ void EglWaylandBackend::presentOnSurface(EglWaylandOutput *output, const QRegion if (supportsBufferAge()) { eglQuerySurface(eglDisplay(), output->m_eglSurface, EGL_BUFFER_AGE_EXT, &output->m_bufferAge); } - } SurfaceTexture *EglWaylandBackend::createSurfaceTextureInternal(SurfacePixmapInternal *pixmap) diff --git a/src/backends/wayland/egl_wayland_backend.h b/src/backends/wayland/egl_wayland_backend.h index 3d04ff1a02..0bce58af3f 100644 --- a/src/backends/wayland/egl_wayland_backend.h +++ b/src/backends/wayland/egl_wayland_backend.h @@ -79,7 +79,8 @@ public: void endFrame(AbstractOutput *output, const QRegion &renderedRegion, const QRegion &damagedRegion) override; void init() override; - bool havePlatformBase() const { + bool havePlatformBase() const + { return m_havePlatformBase; } @@ -100,7 +101,7 @@ private: void presentOnSurface(EglWaylandOutput *output, const QRegion &damagedRegion); WaylandBackend *m_backend; - QMap m_outputs; + QMap m_outputs; bool m_havePlatformBase; friend class EglWaylandTexture; }; diff --git a/src/backends/wayland/scene_qpainter_wayland_backend.cpp b/src/backends/wayland/scene_qpainter_wayland_backend.cpp index bac191b00f..77f4c8ec2c 100644 --- a/src/backends/wayland/scene_qpainter_wayland_backend.cpp +++ b/src/backends/wayland/scene_qpainter_wayland_backend.cpp @@ -121,7 +121,7 @@ WaylandQPainterBufferSlot *WaylandQPainterOutput::acquire() m_back = new WaylandQPainterBufferSlot(buffer); m_slots.append(m_back); -// qCDebug(KWIN_WAYLAND_BACKEND) << "Created a new back buffer for output surface" << m_waylandOutput->surface(); + // qCDebug(KWIN_WAYLAND_BACKEND) << "Created a new back buffer for output surface" << m_waylandOutput->surface(); return m_back; } @@ -141,24 +141,20 @@ WaylandQPainterBackend::WaylandQPainterBackend(Wayland::WaylandBackend *b) { const auto waylandOutputs = m_backend->waylandOutputs(); - for (auto *output: waylandOutputs) { + for (auto *output : waylandOutputs) { createOutput(output); } connect(m_backend, &WaylandBackend::outputAdded, this, &WaylandQPainterBackend::createOutput); - connect(m_backend, &WaylandBackend::outputRemoved, this, - [this] (AbstractOutput *waylandOutput) { - auto it = std::find_if(m_outputs.begin(), m_outputs.end(), - [waylandOutput] (WaylandQPainterOutput *output) { - return output->m_waylandOutput == waylandOutput; - } - ); - if (it == m_outputs.end()) { - return; - } - delete *it; - m_outputs.erase(it); + connect(m_backend, &WaylandBackend::outputRemoved, this, [this](AbstractOutput *waylandOutput) { + auto it = std::find_if(m_outputs.begin(), m_outputs.end(), [waylandOutput](WaylandQPainterOutput *output) { + return output->m_waylandOutput == waylandOutput; + }); + if (it == m_outputs.end()) { + return; } - ); + delete *it; + m_outputs.erase(it); + }); } WaylandQPainterBackend::~WaylandQPainterBackend() diff --git a/src/backends/wayland/scene_qpainter_wayland_backend.h b/src/backends/wayland/scene_qpainter_wayland_backend.h index 5a78ac6c68..0c5504085f 100644 --- a/src/backends/wayland/scene_qpainter_wayland_backend.h +++ b/src/backends/wayland/scene_qpainter_wayland_backend.h @@ -13,8 +13,8 @@ #include "qpainterbackend.h" #include "utils/damagejournal.h" -#include #include +#include #include namespace KWayland @@ -93,7 +93,7 @@ private: void frameRendered(); WaylandBackend *m_backend; - QMap m_outputs; + QMap m_outputs; }; } diff --git a/src/backends/wayland/wayland_backend.cpp b/src/backends/wayland/wayland_backend.cpp index 55e1e1a169..91cfec7a15 100644 --- a/src/backends/wayland/wayland_backend.cpp +++ b/src/backends/wayland/wayland_backend.cpp @@ -9,10 +9,9 @@ */ #include "wayland_backend.h" - #if HAVE_WAYLAND_EGL -#include "egl_wayland_backend.h" #include "../drm/gbm_dmabuf.h" +#include "egl_wayland_backend.h" #include #endif #include "logging.h" @@ -23,13 +22,13 @@ #include "composite.h" #include "cursor.h" +#include "dpmsinputeventfilter.h" #include "input.h" #include "main.h" +#include "pointer_input.h" #include "scene.h" #include "screens.h" -#include "pointer_input.h" #include "wayland_server.h" -#include "dpmsinputeventfilter.h" #include #include @@ -53,9 +52,9 @@ #include #include +#include #include #include -#include #include @@ -582,7 +581,6 @@ WaylandBackend::WaylandBackend(QObject *parent) supportsOutputChanges(); connect(this, &WaylandBackend::connectionFailed, qApp, &QCoreApplication::quit); - #if HAVE_WAYLAND_EGL char const *drm_render_node = "/dev/dri/renderD128"; m_drmFileDescriptor = open(drm_render_node, O_RDWR); @@ -639,80 +637,64 @@ bool WaylandBackend::initialize() } m_compositor->setup(m_registry->bindCompositor(name, version)); }); - connect(m_registry, &Registry::subCompositorAnnounced, this, - [this](quint32 name) { - m_subCompositor->setup(m_registry->bindSubCompositor(name, 1)); + connect(m_registry, &Registry::subCompositorAnnounced, this, [this](quint32 name) { + m_subCompositor->setup(m_registry->bindSubCompositor(name, 1)); + }); + connect(m_registry, &Registry::shmAnnounced, this, [this](quint32 name) { + m_shm->setup(m_registry->bindShm(name, 1)); + }); + connect(m_registry, &Registry::relativePointerManagerUnstableV1Announced, this, [this](quint32 name, quint32 version) { + if (m_relativePointerManager) { + return; } - ); - connect(m_registry, &Registry::shmAnnounced, this, - [this](quint32 name) { - m_shm->setup(m_registry->bindShm(name, 1)); + m_relativePointerManager = m_registry->createRelativePointerManager(name, version, this); + if (m_pointerConstraints) { + Q_EMIT pointerLockSupportedChanged(); } - ); - connect(m_registry, &Registry::relativePointerManagerUnstableV1Announced, this, - [this](quint32 name, quint32 version) { - if (m_relativePointerManager) { - return; - } - m_relativePointerManager = m_registry->createRelativePointerManager(name, version, this); - if (m_pointerConstraints) { - Q_EMIT pointerLockSupportedChanged(); - } + }); + connect(m_registry, &Registry::pointerConstraintsUnstableV1Announced, this, [this](quint32 name, quint32 version) { + if (m_pointerConstraints) { + return; } - ); - connect(m_registry, &Registry::pointerConstraintsUnstableV1Announced, this, - [this](quint32 name, quint32 version) { - if (m_pointerConstraints) { - return; - } - m_pointerConstraints = m_registry->createPointerConstraints(name, version, this); - if (m_relativePointerManager) { - Q_EMIT pointerLockSupportedChanged(); - } + m_pointerConstraints = m_registry->createPointerConstraints(name, version, this); + if (m_relativePointerManager) { + Q_EMIT pointerLockSupportedChanged(); } - ); - connect(m_registry, &Registry::pointerGesturesUnstableV1Announced, this, - [this](quint32 name, quint32 version) { - if (m_pointerGestures) { - return; - } - m_pointerGestures = m_registry->createPointerGestures(name, version, this); + }); + connect(m_registry, &Registry::pointerGesturesUnstableV1Announced, this, [this](quint32 name, quint32 version) { + if (m_pointerGestures) { + return; } - ); + m_pointerGestures = m_registry->createPointerGestures(name, version, this); + }); connect(m_registry, &Registry::interfacesAnnounced, this, &WaylandBackend::createOutputs); - connect(m_registry, &Registry::interfacesAnnounced, this, - [this] { - const auto seatInterface = m_registry->interface(Registry::Interface::Seat); - if (seatInterface.name == 0) { - return; - } - - m_seat = new WaylandSeat(m_registry->createSeat(seatInterface.name, std::min(2u, seatInterface.version), this), this); - Q_EMIT seatCreated(); - - m_waylandCursor = new WaylandCursor(this); + connect(m_registry, &Registry::interfacesAnnounced, this, [this]() { + const auto seatInterface = m_registry->interface(Registry::Interface::Seat); + if (seatInterface.name == 0) { + return; } - ); + + m_seat = new WaylandSeat(m_registry->createSeat(seatInterface.name, std::min(2u, seatInterface.version), this), this); + Q_EMIT seatCreated(); + + m_waylandCursor = new WaylandCursor(this); + }); if (!deviceIdentifier().isEmpty()) { m_connectionThreadObject->setSocketName(deviceIdentifier()); } - connect(Cursors::self(), &Cursors::currentCursorChanged, this, - [this] { - if (!m_seat || !m_waylandCursor) { - return; - } - m_waylandCursor->installImage(); + connect(Cursors::self(), &Cursors::currentCursorChanged, this, [this]() { + if (!m_seat || !m_waylandCursor) { + return; } - ); - connect(Cursors::self(), &Cursors::positionChanged, this, - [this](Cursor *cursor, const QPoint &position) { - Q_UNUSED(cursor) - if (m_waylandCursor) { - m_waylandCursor->move(position); - } + m_waylandCursor->installImage(); + }); + connect(Cursors::self(), &Cursors::positionChanged, this, [this](Cursor *cursor, const QPoint &position) { + Q_UNUSED(cursor) + if (m_waylandCursor) { + m_waylandCursor->move(position); } - ); - connect(this, &WaylandBackend::pointerLockChanged, this, [this] (bool locked) { + }); + connect(this, &WaylandBackend::pointerLockChanged, this, [this](bool locked) { delete m_waylandCursor; if (locked) { m_waylandCursor = new WaylandSubSurfaceCursor(this); @@ -735,8 +717,8 @@ Session *WaylandBackend::session() const void WaylandBackend::initConnection() { - connect(m_connectionThreadObject, &ConnectionThread::connected, this, - [this]() { + connect( + m_connectionThreadObject, &ConnectionThread::connected, this, [this]() { // create the event queue for the main gui thread m_display = m_connectionThreadObject->display(); m_eventQueue->setup(m_connectionThreadObject); @@ -746,8 +728,8 @@ void WaylandBackend::initConnection() m_registry->setup(); }, Qt::QueuedConnection); - connect(m_connectionThreadObject, &ConnectionThread::connectionDied, this, - [this]() { + connect( + m_connectionThreadObject, &ConnectionThread::connectionDied, this, [this]() { setReady(false); Q_EMIT systemCompositorDied(); delete m_seat; @@ -778,14 +760,14 @@ void WaylandBackend::initConnection() void WaylandBackend::updateScreenSize(WaylandOutput *output) { - auto it = std::find(m_outputs.constBegin(), m_outputs.constEnd(), output); + auto it = std::find(m_outputs.constBegin(), m_outputs.constEnd(), output); - int nextLogicalPosition = output->geometry().topRight().x(); - while (++it != m_outputs.constEnd()) { - const QRect geo = (*it)->geometry(); - (*it)->setGeometry(QPoint(nextLogicalPosition, 0), geo.size()); - nextLogicalPosition = geo.topRight().x(); - } + int nextLogicalPosition = output->geometry().topRight().x(); + while (++it != m_outputs.constEnd()) { + const QRect geo = (*it)->geometry(); + (*it)->setGeometry(QPoint(nextLogicalPosition, 0), geo.size()); + nextLogicalPosition = geo.topRight().x(); + } } KWayland::Client::ServerSideDecorationManager *WaylandBackend::ssdManager() @@ -802,7 +784,6 @@ void WaylandBackend::createOutputs() { using namespace KWayland::Client; - const auto xdgIface = m_registry->interface(Registry::Interface::XdgShellStable); if (xdgIface.name != 0) { m_xdgShell = m_registry->createXdgShell(xdgIface.name, xdgIface.version, this); @@ -909,7 +890,7 @@ void WaylandBackend::flush() } } -WaylandOutput* WaylandBackend::getOutputAt(const QPointF &globalPosition) +WaylandOutput *WaylandBackend::getOutputAt(const QPointF &globalPosition) { const auto pos = globalPosition.toPoint(); auto checkPosition = [pos](WaylandOutput *output) { @@ -1009,7 +990,7 @@ void WaylandBackend::addConfiguredOutput(WaylandOutput *output) } } -DmaBufTexture *WaylandBackend::createDmaBufTexture(const QSize& size) +DmaBufTexture *WaylandBackend::createDmaBufTexture(const QSize &size) { #if HAVE_WAYLAND_EGL return GbmDmaBuf::createBuffer(size, m_gbmDevice); diff --git a/src/backends/wayland/wayland_backend.h b/src/backends/wayland/wayland_backend.h index efbaf62fe0..9d1c021292 100644 --- a/src/backends/wayland/wayland_backend.h +++ b/src/backends/wayland/wayland_backend.h @@ -9,11 +9,11 @@ */ #ifndef KWIN_WAYLAND_BACKEND_H #define KWIN_WAYLAND_BACKEND_H +#include // KWin #include "inputbackend.h" #include "inputdevice.h" #include "platform.h" -#include #include // Qt #include @@ -76,7 +76,8 @@ public: ~WaylandCursor() override; virtual void init(); - virtual void move(const QPointF &globalPosition) { + virtual void move(const QPointF &globalPosition) + { Q_UNUSED(globalPosition) } @@ -87,10 +88,12 @@ protected: virtual void doInstallImage(wl_buffer *image, const QSize &size, qreal scale); void drawSurface(wl_buffer *image, const QSize &size, qreal scale); - KWayland::Client::Surface *surface() const { + KWayland::Client::Surface *surface() const + { return m_surface; } - WaylandBackend *backend() const { + WaylandBackend *backend() const + { return m_backend; } @@ -187,12 +190,27 @@ public: WaylandSeat(KWayland::Client::Seat *nativeSeat, WaylandBackend *backend); ~WaylandSeat() override; - WaylandBackend *backend() const { return m_backend; } + WaylandBackend *backend() const + { + return m_backend; + } - WaylandInputDevice *pointerDevice() const { return m_pointerDevice; } - WaylandInputDevice *relativePointerDevice() const { return m_relativePointerDevice; } - WaylandInputDevice *keyboardDevice() const { return m_keyboardDevice; } - WaylandInputDevice *touchDevice() const { return m_touchDevice; } + WaylandInputDevice *pointerDevice() const + { + return m_pointerDevice; + } + WaylandInputDevice *relativePointerDevice() const + { + return m_relativePointerDevice; + } + WaylandInputDevice *keyboardDevice() const + { + return m_keyboardDevice; + } + WaylandInputDevice *touchDevice() const + { + return m_touchDevice; + } void createRelativePointer(); void destroyRelativePointer(); @@ -219,11 +237,11 @@ private: }; /** -* @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. -*/ + * @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 @@ -246,16 +264,20 @@ public: void flush(); - WaylandSeat *seat() const { + WaylandSeat *seat() const + { return m_seat; } - KWayland::Client::PointerGestures *pointerGestures() const { + KWayland::Client::PointerGestures *pointerGestures() const + { return m_pointerGestures; } - KWayland::Client::PointerConstraints *pointerConstraints() const { + KWayland::Client::PointerConstraints *pointerConstraints() const + { return m_pointerConstraints; } - KWayland::Client::RelativePointerManager *relativePointerManager() const { + KWayland::Client::RelativePointerManager *relativePointerManager() const + { return m_relativePointerManager; } @@ -265,11 +287,12 @@ public: QVector supportedCompositors() const override; - WaylandOutput* getOutputAt(const QPointF &globalPosition); + WaylandOutput *getOutputAt(const QPointF &globalPosition); WaylandOutput *findOutput(KWayland::Client::Surface *nativeSurface) const; Outputs outputs() const override; Outputs enabledOutputs() const override; - QVector waylandOutputs() const { + QVector waylandOutputs() const + { return m_outputs; } void addConfiguredOutput(WaylandOutput *output); @@ -311,7 +334,7 @@ private: KWayland::Client::PointerGestures *m_pointerGestures = nullptr; QThread *m_connectionThread; - QVector m_outputs; + QVector m_outputs; int m_pendingInitialOutputs = 0; WaylandCursor *m_waylandCursor = nullptr; @@ -328,26 +351,22 @@ private: #endif }; -inline -wl_display *WaylandBackend::display() +inline wl_display *WaylandBackend::display() { return m_display; } -inline -KWayland::Client::Compositor *WaylandBackend::compositor() +inline KWayland::Client::Compositor *WaylandBackend::compositor() { return m_compositor; } -inline -KWayland::Client::SubCompositor *WaylandBackend::subCompositor() +inline KWayland::Client::SubCompositor *WaylandBackend::subCompositor() { return m_subCompositor; } -inline -KWayland::Client::ShmPool* WaylandBackend::shmPool() +inline KWayland::Client::ShmPool *WaylandBackend::shmPool() { return m_shm; } diff --git a/src/backends/wayland/wayland_output.cpp b/src/backends/wayland/wayland_output.cpp index a16819780f..18bab33f57 100644 --- a/src/backends/wayland/wayland_output.cpp +++ b/src/backends/wayland/wayland_output.cpp @@ -61,7 +61,7 @@ void WaylandOutput::init(const QPoint &logicalPosition, const QSize &pixelSize) { m_renderLoop->setRefreshRate(s_refreshRate); - const Mode mode { + const Mode mode{ .size = pixelSize, .refreshRate = s_refreshRate, .flags = ModeFlag::Current, @@ -69,7 +69,7 @@ void WaylandOutput::init(const QPoint &logicalPosition, const QSize &pixelSize) }; static uint i = 0; - initialize(QStringLiteral("model_%1").arg(i++), "manufacturer_TODO", "eisa_TODO", "serial_TODO", pixelSize, { mode }, {}); + initialize(QStringLiteral("model_%1").arg(i++), "manufacturer_TODO", "eisa_TODO", "serial_TODO", pixelSize, {mode}, {}); moveTo(logicalPosition); setCurrentModeInternal(mode.size, mode.refreshRate); @@ -78,7 +78,7 @@ void WaylandOutput::init(const QPoint &logicalPosition, const QSize &pixelSize) void WaylandOutput::setGeometry(const QPoint &logicalPosition, const QSize &pixelSize) { - const Mode mode { + const Mode mode{ .size = pixelSize, .refreshRate = s_refreshRate, .flags = ModeFlag::Current, @@ -214,20 +214,16 @@ void XdgShellOutput::lockPointer(Pointer *pointer, bool lock) m_pointerLock = nullptr; return; } - connect(m_pointerLock, &LockedPointer::locked, this, - [this] { - m_hasPointerLock = true; - Q_EMIT backend()->pointerLockChanged(true); - } - ); - connect(m_pointerLock, &LockedPointer::unlocked, this, - [this] { - delete m_pointerLock; - m_pointerLock = nullptr; - m_hasPointerLock = false; - Q_EMIT backend()->pointerLockChanged(false); - } - ); + connect(m_pointerLock, &LockedPointer::locked, this, [this]() { + m_hasPointerLock = true; + Q_EMIT backend()->pointerLockChanged(true); + }); + connect(m_pointerLock, &LockedPointer::unlocked, this, [this]() { + delete m_pointerLock; + m_pointerLock = nullptr; + m_hasPointerLock = false; + Q_EMIT backend()->pointerLockChanged(false); + }); } } diff --git a/src/backends/wayland/wayland_output.h b/src/backends/wayland/wayland_output.h index aedd23677b..3650069655 100644 --- a/src/backends/wayland/wayland_output.h +++ b/src/backends/wayland/wayland_output.h @@ -46,12 +46,16 @@ public: void init(const QPoint &logicalPosition, const QSize &pixelSize); - virtual void lockPointer(KWayland::Client::Pointer *pointer, bool lock) { + virtual void lockPointer(KWayland::Client::Pointer *pointer, bool lock) + { Q_UNUSED(pointer) Q_UNUSED(lock) } - virtual bool pointerIsLocked() { return false; } + virtual bool pointerIsLocked() + { + return false; + } /** * @brief defines the geometry of the output @@ -60,14 +64,17 @@ public: */ void setGeometry(const QPoint &logicalPosition, const QSize &pixelSize); - KWayland::Client::Surface* surface() const { + KWayland::Client::Surface *surface() const + { return m_surface; } - bool rendered() const { + bool rendered() const + { return m_rendered; } - void resetRendered() { + void resetRendered() + { m_rendered = false; } @@ -80,7 +87,8 @@ Q_SIGNALS: void frameRendered(); protected: - WaylandBackend *backend() { + WaylandBackend *backend() + { return m_backend; } diff --git a/src/backends/x11/common/eglonxbackend.cpp b/src/backends/x11/common/eglonxbackend.cpp index 00fbcdd00d..94719e743d 100644 --- a/src/backends/x11/common/eglonxbackend.cpp +++ b/src/backends/x11/common/eglonxbackend.cpp @@ -16,8 +16,8 @@ #include "platform.h" #include "utils/xcbutils.h" // Qt -#include #include +#include Q_LOGGING_CATEGORY(KWIN_CORE, "kwin_core", QtWarningMsg) @@ -75,9 +75,7 @@ void EglOnXBackend::init() } initKWinGL(); - if (!hasExtension(QByteArrayLiteral("EGL_KHR_image")) && - (!hasExtension(QByteArrayLiteral("EGL_KHR_image_base")) || - !hasExtension(QByteArrayLiteral("EGL_KHR_image_pixmap")))) { + if (!hasExtension(QByteArrayLiteral("EGL_KHR_image")) && (!hasExtension(QByteArrayLiteral("EGL_KHR_image_base")) || !hasExtension(QByteArrayLiteral("EGL_KHR_image_pixmap")))) { setFailed(QStringLiteral("Required support for binding pixmaps to EGLImages not found, disabling compositing")); return; } @@ -135,8 +133,7 @@ bool EglOnXBackend::initRenderingContext() setHavePlatformBase(havePlatformBase); if (havePlatformBase) { // Make sure that the X11 platform is supported - if (!hasClientExtension(QByteArrayLiteral("EGL_EXT_platform_x11")) && - !hasClientExtension(QByteArrayLiteral("EGL_KHR_platform_x11"))) { + if (!hasClientExtension(QByteArrayLiteral("EGL_EXT_platform_x11")) && !hasClientExtension(QByteArrayLiteral("EGL_KHR_platform_x11"))) { qCWarning(KWIN_CORE) << "EGL_EXT_platform_base is supported, but neither EGL_EXT_platform_x11 nor EGL_KHR_platform_x11 is supported." << "Cannot create EGLDisplay on X11"; return false; @@ -219,7 +216,7 @@ EGLSurface EglOnXBackend::createSurface(xcb_window_t window) EGLSurface surface = EGL_NO_SURFACE; if (havePlatformBase()) { // eglCreatePlatformWindowSurfaceEXT() expects a pointer to the Window. - surface = eglCreatePlatformWindowSurfaceEXT(eglDisplay(), config(), (void *) &nativeWindow, nullptr); + surface = eglCreatePlatformWindowSurfaceEXT(eglDisplay(), config(), (void *)&nativeWindow, nullptr); } else { // eglCreateWindowSurface() expects a Window, not a pointer to the Window. Use // a c style cast as there are (buggy) platforms where the size of the Window @@ -235,13 +232,20 @@ bool EglOnXBackend::initBufferConfigs() { initBufferAge(); const EGLint config_attribs[] = { - EGL_SURFACE_TYPE, EGL_WINDOW_BIT | (supportsBufferAge() ? 0 : EGL_SWAP_BEHAVIOR_PRESERVED_BIT), - EGL_RED_SIZE, 1, - EGL_GREEN_SIZE, 1, - EGL_BLUE_SIZE, 1, - EGL_ALPHA_SIZE, 0, - EGL_RENDERABLE_TYPE, isOpenGLES() ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT, - EGL_CONFIG_CAVEAT, EGL_NONE, + EGL_SURFACE_TYPE, + EGL_WINDOW_BIT | (supportsBufferAge() ? 0 : EGL_SWAP_BEHAVIOR_PRESERVED_BIT), + EGL_RED_SIZE, + 1, + EGL_GREEN_SIZE, + 1, + EGL_BLUE_SIZE, + 1, + EGL_ALPHA_SIZE, + 0, + EGL_RENDERABLE_TYPE, + isOpenGLES() ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT, + EGL_CONFIG_CAVEAT, + EGL_NONE, EGL_NONE, }; @@ -274,7 +278,7 @@ bool EglOnXBackend::initBufferConfigs() return true; } -OverlayWindow* EglOnXBackend::overlayWindow() const +OverlayWindow *EglOnXBackend::overlayWindow() const { return m_overlayWindow; } diff --git a/src/backends/x11/common/eglonxbackend.h b/src/backends/x11/common/eglonxbackend.h index d8423da974..209457a531 100644 --- a/src/backends/x11/common/eglonxbackend.h +++ b/src/backends/x11/common/eglonxbackend.h @@ -29,19 +29,22 @@ public: EglOnXBackend(Display *display); explicit EglOnXBackend(xcb_connection_t *connection, Display *display, xcb_window_t rootWindow, int screenNumber, xcb_window_t renderingWindow); ~EglOnXBackend() override; - OverlayWindow* overlayWindow() const override; + OverlayWindow *overlayWindow() const override; void init() override; protected: virtual bool createSurfaces(); EGLSurface createSurface(xcb_window_t window); - void setHavePlatformBase(bool have) { + void setHavePlatformBase(bool have) + { m_havePlatformBase = have; } - bool havePlatformBase() const { + bool havePlatformBase() const + { return m_havePlatformBase; } - bool havePostSubBuffer() const { + bool havePostSubBuffer() const + { return surfaceHasSubPost; } bool makeContextCurrent(const EGLSurface &surface); diff --git a/src/backends/x11/common/ge_event_mem_mover.h b/src/backends/x11/common/ge_event_mem_mover.h index 9540d55afe..35bc51c5ce 100644 --- a/src/backends/x11/common/ge_event_mem_mover.h +++ b/src/backends/x11/common/ge_event_mem_mover.h @@ -25,15 +25,16 @@ public: // adds an extra 4 bytes and generic events cookie data is on the wire right after the standard 32 bytes. // Move this data back to have the same layout in memory as it was on the wire // and allow casting, overwriting the full_sequence field. - memmove((char*) m_event + 32, (char*) m_event + 36, m_event->length * 4); + memmove((char *)m_event + 32, (char *)m_event + 36, m_event->length * 4); } ~GeEventMemMover() { // move memory layout back, so that Qt can do the same without breaking - memmove((char*) m_event + 36, (char *) m_event + 32, m_event->length * 4); + memmove((char *)m_event + 36, (char *)m_event + 32, m_event->length * 4); } - xcb_ge_generic_event_t *operator->() const { + xcb_ge_generic_event_t *operator->() const + { return m_event; } diff --git a/src/backends/x11/standalone/edge.cpp b/src/backends/x11/standalone/edge.cpp index e605ce52f5..ef7839cb19 100644 --- a/src/backends/x11/standalone/edge.cpp +++ b/src/backends/x11/standalone/edge.cpp @@ -54,14 +54,13 @@ void WindowBasedEdge::createWindow() const uint32_t mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK; const uint32_t values[] = { true, - XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW | XCB_EVENT_MASK_POINTER_MOTION - }; + XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW | XCB_EVENT_MASK_POINTER_MOTION}; m_window.create(geometry(), XCB_WINDOW_CLASS_INPUT_ONLY, mask, values); m_window.map(); // Set XdndAware on the windows, so that DND enter events are received (#86998) xcb_atom_t version = 4; // XDND version xcb_change_property(connection(), XCB_PROP_MODE_REPLACE, m_window, - atoms->xdnd_aware, XCB_ATOM_ATOM, 32, 1, (unsigned char*)(&version)); + atoms->xdnd_aware, XCB_ATOM_ATOM, 32, 1, (unsigned char *)(&version)); } void WindowBasedEdge::createApproachWindow() @@ -78,8 +77,7 @@ void WindowBasedEdge::createApproachWindow() const uint32_t mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK; const uint32_t values[] = { true, - XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW | XCB_EVENT_MASK_POINTER_MOTION - }; + XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW | XCB_EVENT_MASK_POINTER_MOTION}; m_approachWindow.create(approachGeometry(), XCB_WINDOW_CLASS_INPUT_ONLY, mask, values); m_approachWindow.map(); } diff --git a/src/backends/x11/standalone/effects_mouse_interception_x11_filter.cpp b/src/backends/x11/standalone/effects_mouse_interception_x11_filter.cpp index b163dfdd9f..7ef57b3644 100644 --- a/src/backends/x11/standalone/effects_mouse_interception_x11_filter.cpp +++ b/src/backends/x11/standalone/effects_mouse_interception_x11_filter.cpp @@ -26,7 +26,7 @@ bool EffectsMouseInterceptionX11Filter::event(xcb_generic_event_t *event) { const uint8_t eventType = event->response_type & ~0x80; if (eventType == XCB_BUTTON_PRESS || eventType == XCB_BUTTON_RELEASE) { - auto *me = reinterpret_cast(event); + auto *me = reinterpret_cast(event); if (m_window == me->event) { const bool isWheel = me->detail >= 4 && me->detail <= 7; if (isWheel) { @@ -78,7 +78,7 @@ bool EffectsMouseInterceptionX11Filter::event(xcb_generic_event_t *event) return m_effects->checkInputWindowEvent(&ev); } } else if (eventType == XCB_MOTION_NOTIFY) { - const auto *me = reinterpret_cast(event); + const auto *me = reinterpret_cast(event); if (m_window == me->event) { QMouseEvent ev(QEvent::MouseMove, QPoint(me->event_x, me->event_y), QPoint(me->root_x, me->root_y), Qt::NoButton, x11ToQtMouseButtons(me->state), x11ToQtKeyboardModifiers(me->state)); diff --git a/src/backends/x11/standalone/effects_x11.cpp b/src/backends/x11/standalone/effects_x11.cpp index 36e9d02d0a..0df82606c4 100644 --- a/src/backends/x11/standalone/effects_x11.cpp +++ b/src/backends/x11/standalone/effects_x11.cpp @@ -8,8 +8,8 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "effects_x11.h" -#include "effects_mouse_interception_x11_filter.h" #include "cursor.h" +#include "effects_mouse_interception_x11_filter.h" #include "screenedge.h" #include "screens.h" #include "utils/common.h" @@ -70,8 +70,7 @@ void EffectsHandlerImplX11::doStartMouseInterception(Qt::CursorShape shape) const uint32_t mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK; const uint32_t values[] = { true, - XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION - }; + XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION}; m_mouseInterceptionWindow.reset(Xcb::createInputWindow(geo, mask, values)); defineCursor(shape); } else { diff --git a/src/backends/x11/standalone/eglbackend.cpp b/src/backends/x11/standalone/eglbackend.cpp index 2b7abaa637..c715104a2a 100644 --- a/src/backends/x11/standalone/eglbackend.cpp +++ b/src/backends/x11/standalone/eglbackend.cpp @@ -147,7 +147,7 @@ void EglBackend::endFrame(AbstractOutput *output, const QRegion &renderedRegion, presentSurface(surface(), effectiveRenderedRegion, screens()->geometry()); if (overlayWindow() && overlayWindow()->window()) { // show the window only after the first pass, - overlayWindow()->show(); // since that pass may take long + overlayWindow()->show(); // since that pass may take long } // Save the damaged region to history @@ -239,8 +239,7 @@ bool EglPixmapTexturePrivate::create(SurfacePixmapX11 *pixmap) q->bind(); const EGLint attribs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, - EGL_NONE - }; + EGL_NONE}; m_image = eglCreateImageKHR(m_backend->eglDisplay(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, diff --git a/src/backends/x11/standalone/glxbackend.cpp b/src/backends/x11/standalone/glxbackend.cpp index 07032bb678..881454c1a2 100644 --- a/src/backends/x11/standalone/glxbackend.cpp +++ b/src/backends/x11/standalone/glxbackend.cpp @@ -13,17 +13,17 @@ // own #include "glxbackend.h" +#include "glx_context_attribute_builder.h" #include "glxconvenience.h" #include "logging.h" -#include "glx_context_attribute_builder.h" #include "omlsynccontrolvsyncmonitor.h" #include "sgivideosyncvsyncmonitor.h" #include "softwarevsyncmonitor.h" #include "x11_platform.h" // kwin +#include "composite.h" #include "options.h" #include "overlaywindow.h" -#include "composite.h" #include "platform.h" #include "renderloop_p.h" #include "scene.h" @@ -49,26 +49,27 @@ // system #include -#include #include +#include #if HAVE_DL_LIBRARY #include #endif #ifndef XCB_GLX_BUFFER_SWAP_COMPLETE #define XCB_GLX_BUFFER_SWAP_COMPLETE 1 -typedef struct xcb_glx_buffer_swap_complete_event_t { - uint8_t response_type; /**< */ - uint8_t pad0; /**< */ - uint16_t sequence; /**< */ - uint16_t event_type; /**< */ - uint8_t pad1[2]; /**< */ +typedef struct xcb_glx_buffer_swap_complete_event_t +{ + uint8_t response_type; /**< */ + uint8_t pad0; /**< */ + uint16_t sequence; /**< */ + uint16_t event_type; /**< */ + uint8_t pad1[2]; /**< */ xcb_glx_drawable_t drawable; /**< */ - uint32_t ust_hi; /**< */ - uint32_t ust_lo; /**< */ - uint32_t msc_hi; /**< */ - uint32_t msc_lo; /**< */ - uint32_t sbc; /**< */ + uint32_t ust_hi; /**< */ + uint32_t ust_lo; /**< */ + uint32_t msc_hi; /**< */ + uint32_t msc_lo; /**< */ + uint32_t sbc; /**< */ } xcb_glx_buffer_swap_complete_event_t; #endif @@ -78,16 +79,16 @@ namespace KWin { SwapEventFilter::SwapEventFilter(xcb_drawable_t drawable, xcb_glx_drawable_t glxDrawable) - : X11EventFilter(Xcb::Extensions::self()->glxEventBase() + XCB_GLX_BUFFER_SWAP_COMPLETE), - m_drawable(drawable), - m_glxDrawable(glxDrawable) + : X11EventFilter(Xcb::Extensions::self()->glxEventBase() + XCB_GLX_BUFFER_SWAP_COMPLETE) + , m_drawable(drawable) + , m_glxDrawable(glxDrawable) { } bool SwapEventFilter::event(xcb_generic_event_t *event) { const xcb_glx_buffer_swap_complete_event_t *swapEvent = - reinterpret_cast(event); + reinterpret_cast(event); if (swapEvent->drawable != m_drawable && swapEvent->drawable != m_glxDrawable) { return false; } @@ -113,12 +114,12 @@ GlxBackend::GlxBackend(Display *display, X11StandalonePlatform *backend) , m_x11Display(display) , m_backend(backend) { - // Force initialization of GLX integration in the Qt's xcb backend - // to make it call XESetWireToEvent callbacks, which is required - // by Mesa when using DRI2. - QOpenGLContext::supportsThreadedOpenGL(); + // Force initialization of GLX integration in the Qt's xcb backend + // to make it call XESetWireToEvent callbacks, which is required + // by Mesa when using DRI2. + QOpenGLContext::supportsThreadedOpenGL(); - connect(screens(), &Screens::sizeChanged, this, &GlxBackend::screenGeometryChanged); + connect(screens(), &Screens::sizeChanged, this, &GlxBackend::screenGeometryChanged); } GlxBackend::~GlxBackend() @@ -156,15 +157,15 @@ GlxBackend::~GlxBackend() typedef void (*glXFuncPtr)(); -static glXFuncPtr getProcAddress(const char* name) +static glXFuncPtr getProcAddress(const char *name) { glXFuncPtr ret = nullptr; #if HAVE_EPOXY_GLX - ret = glXGetProcAddress((const GLubyte*) name); + ret = glXGetProcAddress((const GLubyte *)name); #endif #if HAVE_DL_LIBRARY if (ret == nullptr) - ret = (glXFuncPtr) dlsym(RTLD_DEFAULT, name); + ret = (glXFuncPtr)dlsym(RTLD_DEFAULT, name); #endif return ret; } @@ -182,7 +183,7 @@ void GlxBackend::init() // resolve glXSwapIntervalMESA if available if (hasExtension(QByteArrayLiteral("GLX_MESA_swap_control"))) { - glXSwapIntervalMESA = (glXSwapIntervalMESA_func) getProcAddress("glXSwapIntervalMESA"); + glXSwapIntervalMESA = (glXSwapIntervalMESA_func)getProcAddress("glXSwapIntervalMESA"); } else { glXSwapIntervalMESA = nullptr; } @@ -226,9 +227,9 @@ void GlxBackend::init() // Check whether certain features are supported m_haveMESACopySubBuffer = hasExtension(QByteArrayLiteral("GLX_MESA_copy_sub_buffer")); - m_haveMESASwapControl = hasExtension(QByteArrayLiteral("GLX_MESA_swap_control")); - m_haveEXTSwapControl = hasExtension(QByteArrayLiteral("GLX_EXT_swap_control")); - m_haveSGISwapControl = hasExtension(QByteArrayLiteral("GLX_SGI_swap_control")); + m_haveMESASwapControl = hasExtension(QByteArrayLiteral("GLX_MESA_swap_control")); + m_haveEXTSwapControl = hasExtension(QByteArrayLiteral("GLX_EXT_swap_control")); + m_haveSGISwapControl = hasExtension(QByteArrayLiteral("GLX_SGI_swap_control")); bool haveSwapInterval = m_haveMESASwapControl || m_haveEXTSwapControl || m_haveSGISwapControl; @@ -312,7 +313,7 @@ bool GlxBackend::checkVersion() void GlxBackend::initExtensions() { - const QByteArray string = (const char *) glXQueryExtensionsString(display(), QX11Info::appScreen()); + const QByteArray string = (const char *)glXQueryExtensionsString(display(), QX11Info::appScreen()); setExtensions(string.split(' ')); } @@ -420,15 +421,15 @@ bool GlxBackend::initBuffer() return false; if (overlayWindow()->create()) { - xcb_connection_t * const c = connection(); + xcb_connection_t *const c = connection(); // Try to create double-buffered window in the overlay xcb_visualid_t visual; - glXGetFBConfigAttrib(display(), fbconfig, GLX_VISUAL_ID, (int *) &visual); + glXGetFBConfigAttrib(display(), fbconfig, GLX_VISUAL_ID, (int *)&visual); if (!visual) { - qCCritical(KWIN_X11STANDALONE) << "The GLXFBConfig does not have an associated X visual"; - return false; + qCCritical(KWIN_X11STANDALONE) << "The GLXFBConfig does not have an associated X visual"; + return false; } xcb_colormap_t colormap = xcb_generate_id(c); @@ -454,33 +455,31 @@ bool GlxBackend::initBuffer() bool GlxBackend::initFbConfig() { const int attribs[] = { - GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, - GLX_RED_SIZE, 1, - GLX_GREEN_SIZE, 1, - GLX_BLUE_SIZE, 1, - GLX_ALPHA_SIZE, 0, - GLX_DEPTH_SIZE, 0, - GLX_STENCIL_SIZE, 0, - GLX_CONFIG_CAVEAT, GLX_NONE, - GLX_DOUBLEBUFFER, true, - 0 - }; + GLX_RENDER_TYPE, GLX_RGBA_BIT, + GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_ALPHA_SIZE, 0, + GLX_DEPTH_SIZE, 0, + GLX_STENCIL_SIZE, 0, + GLX_CONFIG_CAVEAT, GLX_NONE, + GLX_DOUBLEBUFFER, true, + 0}; const int attribs_srgb[] = { - GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, - GLX_RED_SIZE, 1, - GLX_GREEN_SIZE, 1, - GLX_BLUE_SIZE, 1, - GLX_ALPHA_SIZE, 0, - GLX_DEPTH_SIZE, 0, - GLX_STENCIL_SIZE, 0, - GLX_CONFIG_CAVEAT, GLX_NONE, - GLX_DOUBLEBUFFER, true, + GLX_RENDER_TYPE, GLX_RGBA_BIT, + GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + GLX_ALPHA_SIZE, 0, + GLX_DEPTH_SIZE, 0, + GLX_STENCIL_SIZE, 0, + GLX_CONFIG_CAVEAT, GLX_NONE, + GLX_DOUBLEBUFFER, true, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, true, - 0 - }; + 0}; // Only request sRGB configurations with default depth 24 as it can cause problems with other default depths. See bugs #408594 and #423014. if (Xcb::defaultDepth() == 24) { @@ -496,13 +495,13 @@ bool GlxBackend::initFbConfig() } int fbconfig_id, visual_id, red, green, blue, alpha, depth, stencil, srgb; - glXGetFBConfigAttrib(display(), fbconfig, GLX_FBCONFIG_ID, &fbconfig_id); - glXGetFBConfigAttrib(display(), fbconfig, GLX_VISUAL_ID, &visual_id); - glXGetFBConfigAttrib(display(), fbconfig, GLX_RED_SIZE, &red); - glXGetFBConfigAttrib(display(), fbconfig, GLX_GREEN_SIZE, &green); - glXGetFBConfigAttrib(display(), fbconfig, GLX_BLUE_SIZE, &blue); - glXGetFBConfigAttrib(display(), fbconfig, GLX_ALPHA_SIZE, &alpha); - glXGetFBConfigAttrib(display(), fbconfig, GLX_DEPTH_SIZE, &depth); + glXGetFBConfigAttrib(display(), fbconfig, GLX_FBCONFIG_ID, &fbconfig_id); + glXGetFBConfigAttrib(display(), fbconfig, GLX_VISUAL_ID, &visual_id); + glXGetFBConfigAttrib(display(), fbconfig, GLX_RED_SIZE, &red); + glXGetFBConfigAttrib(display(), fbconfig, GLX_GREEN_SIZE, &green); + glXGetFBConfigAttrib(display(), fbconfig, GLX_BLUE_SIZE, &blue); + glXGetFBConfigAttrib(display(), fbconfig, GLX_ALPHA_SIZE, &alpha); + glXGetFBConfigAttrib(display(), fbconfig, GLX_DEPTH_SIZE, &depth); glXGetFBConfigAttrib(display(), fbconfig, GLX_STENCIL_SIZE, &stencil); glXGetFBConfigAttrib(display(), fbconfig, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &srgb); @@ -557,11 +556,11 @@ FBConfigInfo *GlxBackend::infoForVisual(xcb_visualid_t visual) FBConfigInfo *info = new FBConfigInfo; m_fbconfigHash.insert(visual, info); - info->fbconfig = nullptr; + info->fbconfig = nullptr; info->bind_texture_format = 0; - info->texture_targets = 0; - info->y_inverted = 0; - info->mipmap = 0; + info->texture_targets = 0; + info->y_inverted = 0; + info->mipmap = 0; const xcb_render_pictformat_t format = XRenderUtils::findPictFormat(visual); const xcb_render_directformat_t *direct = XRenderUtils::findPictFormatInfo(format); @@ -571,9 +570,9 @@ FBConfigInfo *GlxBackend::infoForVisual(xcb_visualid_t visual) return info; } - const int red_bits = bitCount(direct->red_mask); + const int red_bits = bitCount(direct->red_mask); const int green_bits = bitCount(direct->green_mask); - const int blue_bits = bitCount(direct->blue_mask); + const int blue_bits = bitCount(direct->blue_mask); const int alpha_bits = bitCount(direct->alpha_mask); const int depth = visualDepth(visual); @@ -581,21 +580,20 @@ FBConfigInfo *GlxBackend::infoForVisual(xcb_visualid_t visual) const auto rgb_sizes = std::tie(red_bits, green_bits, blue_bits); const int attribs[] = { - GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT | GLX_PIXMAP_BIT, - GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR, - GLX_X_RENDERABLE, true, - GLX_CONFIG_CAVEAT, int(GLX_DONT_CARE), // The ARGB32 visual is marked non-conformant in Catalyst - GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT, int(GLX_DONT_CARE), // The ARGB32 visual is marked sRGB capable in mesa/i965 - GLX_BUFFER_SIZE, red_bits + green_bits + blue_bits + alpha_bits, - GLX_RED_SIZE, red_bits, - GLX_GREEN_SIZE, green_bits, - GLX_BLUE_SIZE, blue_bits, - GLX_ALPHA_SIZE, alpha_bits, - GLX_STENCIL_SIZE, 0, - GLX_DEPTH_SIZE, 0, - 0 - }; + GLX_RENDER_TYPE, GLX_RGBA_BIT, + GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT | GLX_PIXMAP_BIT, + GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR, + GLX_X_RENDERABLE, true, + GLX_CONFIG_CAVEAT, int(GLX_DONT_CARE), // The ARGB32 visual is marked non-conformant in Catalyst + GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT, int(GLX_DONT_CARE), // The ARGB32 visual is marked sRGB capable in mesa/i965 + GLX_BUFFER_SIZE, red_bits + green_bits + blue_bits + alpha_bits, + GLX_RED_SIZE, red_bits, + GLX_GREEN_SIZE, green_bits, + GLX_BLUE_SIZE, blue_bits, + GLX_ALPHA_SIZE, alpha_bits, + GLX_STENCIL_SIZE, 0, + GLX_DEPTH_SIZE, 0, + 0}; int count = 0; GLXFBConfig *configs = glXChooseFBConfig(display(), DefaultScreen(display()), attribs, &count); @@ -605,7 +603,8 @@ FBConfigInfo *GlxBackend::infoForVisual(xcb_visualid_t visual) return info; } - struct FBConfig { + struct FBConfig + { GLXFBConfig config; int depth; int stencil; @@ -616,28 +615,28 @@ FBConfigInfo *GlxBackend::infoForVisual(xcb_visualid_t visual) for (int i = 0; i < count; i++) { int red, green, blue; - glXGetFBConfigAttrib(display(), configs[i], GLX_RED_SIZE, &red); + glXGetFBConfigAttrib(display(), configs[i], GLX_RED_SIZE, &red); glXGetFBConfigAttrib(display(), configs[i], GLX_GREEN_SIZE, &green); - glXGetFBConfigAttrib(display(), configs[i], GLX_BLUE_SIZE, &blue); + glXGetFBConfigAttrib(display(), configs[i], GLX_BLUE_SIZE, &blue); if (std::tie(red, green, blue) != rgb_sizes) continue; xcb_visualid_t visual; - glXGetFBConfigAttrib(display(), configs[i], GLX_VISUAL_ID, (int *) &visual); + glXGetFBConfigAttrib(display(), configs[i], GLX_VISUAL_ID, (int *)&visual); if (visualDepth(visual) != depth) continue; int bind_rgb, bind_rgba; glXGetFBConfigAttrib(display(), configs[i], GLX_BIND_TO_TEXTURE_RGBA_EXT, &bind_rgba); - glXGetFBConfigAttrib(display(), configs[i], GLX_BIND_TO_TEXTURE_RGB_EXT, &bind_rgb); + glXGetFBConfigAttrib(display(), configs[i], GLX_BIND_TO_TEXTURE_RGB_EXT, &bind_rgb); if (!bind_rgb && !bind_rgba) continue; int depth, stencil; - glXGetFBConfigAttrib(display(), configs[i], GLX_DEPTH_SIZE, &depth); + glXGetFBConfigAttrib(display(), configs[i], GLX_DEPTH_SIZE, &depth); glXGetFBConfigAttrib(display(), configs[i], GLX_STENCIL_SIZE, &stencil); int texture_format; @@ -669,11 +668,11 @@ FBConfigInfo *GlxBackend::infoForVisual(xcb_visualid_t visual) glXGetFBConfigAttrib(display(), candidate.config, GLX_BIND_TO_TEXTURE_TARGETS_EXT, &texture_targets); glXGetFBConfigAttrib(display(), candidate.config, GLX_Y_INVERTED_EXT, &y_inverted); - info->fbconfig = candidate.config; + info->fbconfig = candidate.config; info->bind_texture_format = candidate.format; - info->texture_targets = texture_targets; - info->y_inverted = y_inverted; - info->mipmap = 0; + info->texture_targets = texture_targets; + info->y_inverted = y_inverted; + info->mipmap = 0; } if (info->fbconfig) { @@ -681,7 +680,7 @@ FBConfigInfo *GlxBackend::infoForVisual(xcb_visualid_t visual) int visual_id = 0; glXGetFBConfigAttrib(display(), info->fbconfig, GLX_FBCONFIG_ID, &fbc_id); - glXGetFBConfigAttrib(display(), info->fbconfig, GLX_VISUAL_ID, &visual_id); + glXGetFBConfigAttrib(display(), info->fbconfig, GLX_VISUAL_ID, &visual_id); qCDebug(KWIN_X11STANDALONE).nospace() << "Using FBConfig 0x" << Qt::hex << fbc_id << " for visual 0x" << Qt::hex << visual_id; } @@ -708,7 +707,7 @@ void GlxBackend::present(const QRegion &damage) if (fullRepaint) { glXSwapBuffers(display(), glxWindow); if (supportsBufferAge()) { - glXQueryDrawable(display(), glxWindow, GLX_BACK_BUFFER_AGE_EXT, (GLuint *) &m_bufferAge); + glXQueryDrawable(display(), glxWindow, GLX_BACK_BUFFER_AGE_EXT, (GLuint *)&m_bufferAge); } } else if (m_haveMESACopySubBuffer) { for (const QRect &r : damage) { @@ -788,8 +787,8 @@ void GlxBackend::endFrame(AbstractOutput *output, const QRegion &renderedRegion, present(effectiveRenderedRegion); - if (overlayWindow()->window()) // show the window only after the first pass, - overlayWindow()->show(); // since that pass may take long + if (overlayWindow()->window()) // show the window only after the first pass, + overlayWindow()->show(); // since that pass may take long // Save the damaged region to history if (supportsBufferAge()) { @@ -818,7 +817,7 @@ void GlxBackend::doneCurrent() glXMakeCurrent(display(), None, nullptr); } -OverlayWindow* GlxBackend::overlayWindow() const +OverlayWindow *GlxBackend::overlayWindow() const { return m_overlayWindow; } @@ -907,12 +906,11 @@ bool GlxPixmapTexturePrivate::create(SurfacePixmapX11 *texture) GLX_TEXTURE_FORMAT_EXT, info->bind_texture_format, GLX_MIPMAP_TEXTURE_EXT, false, GLX_TEXTURE_TARGET_EXT, m_target == GL_TEXTURE_2D ? GLX_TEXTURE_2D_EXT : GLX_TEXTURE_RECTANGLE_EXT, - 0 - }; + 0}; - m_glxPixmap = glXCreatePixmap(m_backend->display(), info->fbconfig, texture->pixmap(), attrs); - m_size = texture->size(); - m_yInverted = info->y_inverted ? true : false; + m_glxPixmap = glXCreatePixmap(m_backend->display(), info->fbconfig, texture->pixmap(), attrs); + m_size = texture->size(); + m_yInverted = info->y_inverted ? true : false; m_canUseMipmaps = false; glGenTextures(1, &m_texture); diff --git a/src/backends/x11/standalone/glxbackend.h b/src/backends/x11/standalone/glxbackend.h index 9b017a3276..f78db22324 100644 --- a/src/backends/x11/standalone/glxbackend.h +++ b/src/backends/x11/standalone/glxbackend.h @@ -10,12 +10,12 @@ #define KWIN_GLX_BACKEND_H #include "openglbackend.h" #include "openglsurfacetexture_x11.h" -#include "x11eventfilter.h" #include "utils/damagejournal.h" +#include "x11eventfilter.h" -#include #include #include +#include #include #include @@ -45,10 +45,8 @@ public: int mipmap; }; - // ------------------------------------------------------------------ - class SwapEventFilter : public X11EventFilter { public: @@ -60,7 +58,6 @@ private: xcb_glx_drawable_t m_glxDrawable; }; - /** * @brief OpenGL Backend using GLX over an X overlay window. */ @@ -76,10 +73,13 @@ public: void endFrame(AbstractOutput *output, const QRegion &renderedRegion, const QRegion &damagedRegion) override; bool makeCurrent() override; void doneCurrent() override; - OverlayWindow* overlayWindow() const override; + OverlayWindow *overlayWindow() const override; void init() override; - Display *display() const { return m_x11Display; } + Display *display() const + { + return m_x11Display; + } private: void vblank(std::chrono::nanoseconds timestamp); diff --git a/src/backends/x11/standalone/glxconvenience.cpp b/src/backends/x11/standalone/glxconvenience.cpp index 58b24ffb79..b725f8cbfc 100644 --- a/src/backends/x11/standalone/glxconvenience.cpp +++ b/src/backends/x11/standalone/glxconvenience.cpp @@ -20,7 +20,8 @@ GLXFBConfig chooseGlxFbConfig(Display *display, const int attributes[]) GLXFBConfig *configs = glXChooseFBConfig(display, DefaultScreen(display), attributes, &configCount); - struct FBConfig { + struct FBConfig + { GLXFBConfig config; int depth; int stencil; diff --git a/src/backends/x11/standalone/non_composited_outline.cpp b/src/backends/x11/standalone/non_composited_outline.cpp index 3c2759702d..c50254c333 100644 --- a/src/backends/x11/standalone/non_composited_outline.cpp +++ b/src/backends/x11/standalone/non_composited_outline.cpp @@ -37,7 +37,7 @@ void NonCompositedOutlineVisual::show() m_rightOutline.create(geo, XCB_CW_OVERRIDE_REDIRECT, values); m_topOutline.create(geo, XCB_CW_OVERRIDE_REDIRECT, values); m_bottomOutline.create(geo, XCB_CW_OVERRIDE_REDIRECT, values); - m_initialized = true; + m_initialized = true; } const int defaultDepth = Xcb::defaultDepth(); @@ -59,8 +59,7 @@ void NonCompositedOutlineVisual::show() uint16_t(0xffff * qGray.redF()), uint16_t(0xffff * qGray.greenF()), uint16_t(0xffff * qGray.blueF()), - 0xffff - }; + 0xffff}; const xcb_render_color_t black = {0, 0, 0, 0xffff}; { xcb_pixmap_t xpix = xcb_generate_id(connection()); @@ -89,16 +88,14 @@ void NonCompositedOutlineVisual::show() xcb_rectangle_t rect = {0, 0, horizontalWidth, horizontalHeight}; xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, pic, white, 1, &rect); xcb_rectangle_t grayRects[] = { - {1, 1, uint16_t(horizontalWidth -2), 3}, + {1, 1, uint16_t(horizontalWidth - 2), 3}, {1, 4, 3, 1}, - {int16_t(horizontalWidth - 4), 4, 3, 1} - }; + {int16_t(horizontalWidth - 4), 4, 3, 1}}; xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, pic, gray, 3, grayRects); xcb_rectangle_t blackRects[] = { - {2, 2, uint16_t(horizontalWidth -4), 1}, + {2, 2, uint16_t(horizontalWidth - 4), 1}, {2, 3, 1, 2}, - {int16_t(horizontalWidth - 3), 3, 1, 2} - }; + {int16_t(horizontalWidth - 3), 3, 1, 2}}; xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, pic, black, 3, blackRects); m_topOutline.setBackgroundPixmap(xpix); // According to the XSetWindowBackgroundPixmap documentation the pixmap can be freed. @@ -112,16 +109,14 @@ void NonCompositedOutlineVisual::show() xcb_rectangle_t rect = {0, 0, horizontalWidth, horizontalHeight}; xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, pic, white, 1, &rect); xcb_rectangle_t grayRects[] = { - {1, 1, uint16_t(horizontalWidth -2), 3}, + {1, 1, uint16_t(horizontalWidth - 2), 3}, {1, 0, 3, 1}, - {int16_t(horizontalWidth - 4), 0, 3, 1} - }; + {int16_t(horizontalWidth - 4), 0, 3, 1}}; xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, pic, gray, 3, grayRects); xcb_rectangle_t blackRects[] = { - {2, 2, uint16_t(horizontalWidth -4), 1}, + {2, 2, uint16_t(horizontalWidth - 4), 1}, {2, 0, 1, 2}, - {int16_t(horizontalWidth - 3), 0, 1, 2} - }; + {int16_t(horizontalWidth - 3), 0, 1, 2}}; xcb_render_fill_rectangles(connection(), XCB_RENDER_PICT_OP_SRC, pic, black, 3, blackRects); m_bottomOutline.setBackgroundPixmap(xpix); // According to the XSetWindowBackgroundPixmap documentation the pixmap can be freed. diff --git a/src/backends/x11/standalone/non_composited_outline.h b/src/backends/x11/standalone/non_composited_outline.h index 52e863c0e6..7e7403b9b0 100644 --- a/src/backends/x11/standalone/non_composited_outline.h +++ b/src/backends/x11/standalone/non_composited_outline.h @@ -24,7 +24,7 @@ public: private: // TODO: variadic template arguments for adding method arguments - template + template void forEachWindow(T method); bool m_initialized; Xcb::Window m_topOutline; @@ -33,9 +33,8 @@ private: Xcb::Window m_leftOutline; }; -template -inline -void NonCompositedOutlineVisual::forEachWindow(T method) +template +inline void NonCompositedOutlineVisual::forEachWindow(T method) { (m_topOutline.*method)(); (m_rightOutline.*method)(); diff --git a/src/backends/x11/standalone/omlsynccontrolvsyncmonitor.cpp b/src/backends/x11/standalone/omlsynccontrolvsyncmonitor.cpp index 0a7d259a6a..894064f90c 100644 --- a/src/backends/x11/standalone/omlsynccontrolvsyncmonitor.cpp +++ b/src/backends/x11/standalone/omlsynccontrolvsyncmonitor.cpp @@ -48,8 +48,7 @@ OMLSyncControlVsyncMonitorHelper::OMLSyncControlVsyncMonitorHelper(QObject *pare const int attribs[] = { GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, - 0 - }; + 0}; GLXFBConfig config = chooseGlxFbConfig(m_display, attribs); if (!config) { diff --git a/src/backends/x11/standalone/omlsynccontrolvsyncmonitor.h b/src/backends/x11/standalone/omlsynccontrolvsyncmonitor.h index 7c1ba4c18b..ced7dd6e1e 100644 --- a/src/backends/x11/standalone/omlsynccontrolvsyncmonitor.h +++ b/src/backends/x11/standalone/omlsynccontrolvsyncmonitor.h @@ -9,8 +9,7 @@ #include "vsyncmonitor.h" #include -#include -#include "fixx11h.h" +#include #include diff --git a/src/backends/x11/standalone/overlaywindow_x11.cpp b/src/backends/x11/standalone/overlaywindow_x11.cpp index c257353273..c5563d8427 100644 --- a/src/backends/x11/standalone/overlaywindow_x11.cpp +++ b/src/backends/x11/standalone/overlaywindow_x11.cpp @@ -9,8 +9,8 @@ #include "overlaywindow_x11.h" -#include "kwinglobals.h" #include "composite.h" +#include "kwinglobals.h" #include "scene.h" #include "screens.h" #include "utils/common.h" @@ -24,7 +24,8 @@ #define KWIN_HAVE_XCOMPOSITE_OVERLAY #endif -namespace KWin { +namespace KWin +{ OverlayWindowX11::OverlayWindowX11() : OverlayWindow() , X11EventFilter(QVector{XCB_EXPOSE, XCB_VISIBILITY_NOTIFY}) @@ -43,7 +44,7 @@ bool OverlayWindowX11::create() Q_ASSERT(m_window == XCB_WINDOW_NONE); if (!Xcb::Extensions::self()->isCompositeOverlayAvailable()) return false; - if (!Xcb::Extensions::self()->isShapeInputAvailable()) // needed in setupOverlay() + if (!Xcb::Extensions::self()->isShapeInputAvailable()) // needed in setupOverlay() return false; #ifdef KWIN_HAVE_XCOMPOSITE_OVERLAY Xcb::OverlayWindow overlay(rootWindow()); @@ -106,7 +107,7 @@ void OverlayWindowX11::hide() setShape(QRect(0, 0, s.width(), s.height())); } -void OverlayWindowX11::setShape(const QRegion& reg) +void OverlayWindowX11::setShape(const QRegion ®) { // Avoid setting the same shape again, it causes flicker (apparently it is not a no-op // and triggers something). @@ -124,8 +125,7 @@ void OverlayWindowX11::resize(const QSize &size) Q_ASSERT(m_window != XCB_WINDOW_NONE); const uint32_t geometry[2] = { static_cast(size.width()), - static_cast(size.height()) - }; + static_cast(size.height())}; xcb_configure_window(connection(), m_window, XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, geometry); setShape(QRegion(0, 0, size.width(), size.height())); } @@ -146,7 +146,7 @@ void OverlayWindowX11::destroy() return; // reset the overlay shape const QSize &s = screens()->size(); - xcb_rectangle_t rec = { 0, 0, static_cast(s.width()), static_cast(s.height()) }; + xcb_rectangle_t rec = {0, 0, static_cast(s.width()), static_cast(s.height())}; xcb_shape_rectangles(connection(), XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED, m_window, 0, 0, 1, &rec); xcb_shape_rectangles(connection(), XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED, m_window, 0, 0, 1, &rec); #ifdef KWIN_HAVE_XCOMPOSITE_OVERLAY @@ -165,13 +165,13 @@ bool OverlayWindowX11::event(xcb_generic_event_t *event) { const uint8_t eventType = event->response_type & ~0x80; if (eventType == XCB_EXPOSE) { - const auto *expose = reinterpret_cast(event); - if (expose->window == rootWindow() // root window needs repainting - || (m_window != XCB_WINDOW_NONE && expose->window == m_window)) { // overlay needs repainting + const auto *expose = reinterpret_cast(event); + if (expose->window == rootWindow() // root window needs repainting + || (m_window != XCB_WINDOW_NONE && expose->window == m_window)) { // overlay needs repainting Compositor::self()->scene()->addRepaint(expose->x, expose->y, expose->width, expose->height); } } else if (eventType == XCB_VISIBILITY_NOTIFY) { - const auto *visibility = reinterpret_cast(event); + const auto *visibility = reinterpret_cast(event); if (m_window != XCB_WINDOW_NONE && visibility->window == m_window) { bool was_visible = isVisible(); setVisibility((visibility->state != XCB_VISIBILITY_FULLY_OBSCURED)); @@ -192,4 +192,3 @@ bool OverlayWindowX11::event(xcb_generic_event_t *event) } } // namespace KWin - diff --git a/src/backends/x11/standalone/overlaywindow_x11.h b/src/backends/x11/standalone/overlaywindow_x11.h index 1dfde4cabc..16b70cc0d0 100644 --- a/src/backends/x11/standalone/overlaywindow_x11.h +++ b/src/backends/x11/standalone/overlaywindow_x11.h @@ -13,8 +13,10 @@ #include "overlaywindow.h" #include "x11eventfilter.h" -namespace KWin { -class KWIN_EXPORT OverlayWindowX11 : public OverlayWindow, public X11EventFilter { +namespace KWin +{ +class KWIN_EXPORT OverlayWindowX11 : public OverlayWindow, public X11EventFilter +{ public: OverlayWindowX11(); ~OverlayWindowX11() override; @@ -24,7 +26,7 @@ public: 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 setShape(const QRegion ®) override; void resize(const QSize &size) override; /// Destroys XComposite overlay window void destroy() override; @@ -33,6 +35,7 @@ public: 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); @@ -43,4 +46,4 @@ private: }; } // namespace -#endif //KWIN_OVERLAYWINDOW_H +#endif // KWIN_OVERLAYWINDOW_H diff --git a/src/backends/x11/standalone/screenedges_filter.cpp b/src/backends/x11/standalone/screenedges_filter.cpp index 23ca5d6679..680d9b2a51 100644 --- a/src/backends/x11/standalone/screenedges_filter.cpp +++ b/src/backends/x11/standalone/screenedges_filter.cpp @@ -26,7 +26,7 @@ bool ScreenEdgesFilter::event(xcb_generic_event_t *event) const uint8_t eventType = event->response_type & ~0x80; switch (eventType) { case XCB_MOTION_NOTIFY: { - const auto mouseEvent = reinterpret_cast(event); + const auto mouseEvent = reinterpret_cast(event); const QPoint rootPos(mouseEvent->root_x, mouseEvent->root_y); if (QWidget::mouseGrabber()) { ScreenEdges::self()->check(rootPos, QDateTime::fromMSecsSinceEpoch(xTime(), Qt::UTC), true); @@ -37,11 +37,11 @@ bool ScreenEdgesFilter::event(xcb_generic_event_t *event) break; } case XCB_ENTER_NOTIFY: { - const auto enter = reinterpret_cast(event); + const auto enter = reinterpret_cast(event); return ScreenEdges::self()->handleEnterNotifiy(enter->event, QPoint(enter->root_x, enter->root_y), QDateTime::fromMSecsSinceEpoch(enter->time, Qt::UTC)); } case XCB_CLIENT_MESSAGE: { - const auto ce = reinterpret_cast(event); + const auto ce = reinterpret_cast(event); if (ce->type != atoms->xdnd_position) { return false; } diff --git a/src/backends/x11/standalone/sgivideosyncvsyncmonitor.cpp b/src/backends/x11/standalone/sgivideosyncvsyncmonitor.cpp index 3ac69601d0..7febbb82c8 100644 --- a/src/backends/x11/standalone/sgivideosyncvsyncmonitor.cpp +++ b/src/backends/x11/standalone/sgivideosyncvsyncmonitor.cpp @@ -48,8 +48,7 @@ SGIVideoSyncVsyncMonitorHelper::SGIVideoSyncVsyncMonitorHelper(QObject *parent) const int attribs[] = { GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, - 0 - }; + 0}; GLXFBConfig config = chooseGlxFbConfig(m_display, attribs); if (!config) { diff --git a/src/backends/x11/standalone/sgivideosyncvsyncmonitor.h b/src/backends/x11/standalone/sgivideosyncvsyncmonitor.h index 709b4e3d10..9d2456c9d7 100644 --- a/src/backends/x11/standalone/sgivideosyncvsyncmonitor.h +++ b/src/backends/x11/standalone/sgivideosyncvsyncmonitor.h @@ -9,8 +9,7 @@ #include "vsyncmonitor.h" #include -#include -#include "fixx11h.h" +#include #include diff --git a/src/backends/x11/standalone/windowselector.cpp b/src/backends/x11/standalone/windowselector.cpp index 545e02cf44..fb68f447bb 100644 --- a/src/backends/x11/standalone/windowselector.cpp +++ b/src/backends/x11/standalone/windowselector.cpp @@ -9,14 +9,14 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "windowselector.h" -#include "x11client.h" #include "cursor.h" #include "unmanaged.h" -#include "workspace.h" #include "utils/xcbutils.h" +#include "workspace.h" +#include "x11client.h" // XLib -#include #include +#include #include // XCB #include @@ -25,15 +25,16 @@ namespace KWin { WindowSelector::WindowSelector() - : X11EventFilter(QVector{XCB_BUTTON_PRESS, - XCB_BUTTON_RELEASE, - XCB_MOTION_NOTIFY, - XCB_ENTER_NOTIFY, - XCB_LEAVE_NOTIFY, - XCB_KEY_PRESS, - XCB_KEY_RELEASE, - XCB_FOCUS_IN, - XCB_FOCUS_OUT + : X11EventFilter(QVector{ + XCB_BUTTON_PRESS, + XCB_BUTTON_RELEASE, + XCB_MOTION_NOTIFY, + XCB_ENTER_NOTIFY, + XCB_LEAVE_NOTIFY, + XCB_KEY_PRESS, + XCB_KEY_RELEASE, + XCB_FOCUS_IN, + XCB_FOCUS_OUT, }) , m_active(false) { @@ -43,7 +44,7 @@ WindowSelector::~WindowSelector() { } -void WindowSelector::start(std::function callback, const QByteArray &cursorName) +void WindowSelector::start(std::function callback, const QByteArray &cursorName) { if (m_active) { callback(nullptr); @@ -58,7 +59,7 @@ void WindowSelector::start(std::function callback, const m_callback = callback; } -void WindowSelector::start(std::function callback) +void WindowSelector::start(std::function callback) { if (m_active) { callback(QPoint(-1, -1)); @@ -78,12 +79,7 @@ bool WindowSelector::activate(const QByteArray &cursorName) xcb_cursor_t cursor = createCursor(cursorName); xcb_connection_t *c = connection(); - ScopedCPointer grabPointer(xcb_grab_pointer_reply(c, xcb_grab_pointer_unchecked(c, false, rootWindow(), - XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | - XCB_EVENT_MASK_POINTER_MOTION | - XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW, - XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_WINDOW_NONE, - cursor, XCB_TIME_CURRENT_TIME), nullptr)); + ScopedCPointer grabPointer(xcb_grab_pointer_reply(c, xcb_grab_pointer_unchecked(c, false, rootWindow(), XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_WINDOW_NONE, cursor, XCB_TIME_CURRENT_TIME), nullptr)); if (grabPointer.isNull() || grabPointer->status != XCB_GRAB_STATUS_SUCCESS) { return false; } @@ -114,12 +110,12 @@ xcb_cursor_t WindowSelector::createCursor(const QByteArray &cursorName) // fallback on font xcb_connection_t *c = connection(); const xcb_font_t cursorFont = xcb_generate_id(c); - xcb_open_font(c, cursorFont, strlen ("cursor"), "cursor"); + xcb_open_font(c, cursorFont, strlen("cursor"), "cursor"); cursor = xcb_generate_id(c); xcb_create_glyph_cursor(c, cursor, cursorFont, cursorFont, - XC_pirate, /* source character glyph */ - XC_pirate + 1, /* mask character glyph */ - 0, 0, 0, 0, 0, 0); /* r b g r b g */ + XC_pirate, /* source character glyph */ + XC_pirate + 1, /* mask character glyph */ + 0, 0, 0, 0, 0, 0); /* r b g r b g */ kill_cursor = cursor; } return cursor; @@ -128,10 +124,10 @@ xcb_cursor_t WindowSelector::createCursor(const QByteArray &cursorName) void WindowSelector::processEvent(xcb_generic_event_t *event) { if (event->response_type == XCB_BUTTON_RELEASE) { - xcb_button_release_event_t *buttonEvent = reinterpret_cast(event); + xcb_button_release_event_t *buttonEvent = reinterpret_cast(event); handleButtonRelease(buttonEvent->detail, buttonEvent->child); } else if (event->response_type == XCB_KEY_PRESS) { - xcb_key_press_event_t *keyEvent = reinterpret_cast(event); + xcb_key_press_event_t *keyEvent = reinterpret_cast(event); handleKeyPress(keyEvent->detail, keyEvent->state); } } @@ -219,8 +215,8 @@ void WindowSelector::release() xcb_ungrab_pointer(connection(), XCB_TIME_CURRENT_TIME); ungrabXServer(); m_active = false; - m_callback = std::function(); - m_pointSelectionFallback = std::function(); + m_callback = std::function(); + m_pointSelectionFallback = std::function(); } void WindowSelector::selectWindowId(xcb_window_t window_to_select) @@ -241,7 +237,7 @@ void WindowSelector::selectWindowId(xcb_window_t window_to_select) // We didn't find the client, probably an override-redirect window break; } - window = tree->parent; // Go up + window = tree->parent; // Go up } if (client) { m_callback(client); diff --git a/src/backends/x11/standalone/windowselector.h b/src/backends/x11/standalone/windowselector.h index 51163c2813..72267572e9 100644 --- a/src/backends/x11/standalone/windowselector.h +++ b/src/backends/x11/standalone/windowselector.h @@ -27,13 +27,13 @@ class Toplevel; class WindowSelector : public X11EventFilter { public: - WindowSelector(); ~WindowSelector() override; - void start(std::function callback, const QByteArray &cursorName); - void start(std::function callback); - bool isActive() const { + 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); @@ -50,7 +50,7 @@ private: bool activate(const QByteArray &cursorName = QByteArray()); void cancelCallback(); bool m_active; - std::function m_callback; + std::function m_callback; std::function m_pointSelectionFallback; }; diff --git a/src/backends/x11/standalone/x11_output.cpp b/src/backends/x11/standalone/x11_output.cpp index 7c0df9c83f..12d2074a03 100644 --- a/src/backends/x11/standalone/x11_output.cpp +++ b/src/backends/x11/standalone/x11_output.cpp @@ -78,7 +78,7 @@ bool X11Output::setGammaRamp(const GammaRamp &gamma) } xcb_randr_set_crtc_gamma(kwinApp()->x11Connection(), m_crtc, gamma.size(), gamma.red(), - gamma.green(), gamma.blue()); + gamma.green(), gamma.blue()); return true; } diff --git a/src/backends/x11/standalone/x11_platform.cpp b/src/backends/x11/standalone/x11_platform.cpp index b3a42e7a3c..203f391973 100644 --- a/src/backends/x11/standalone/x11_platform.cpp +++ b/src/backends/x11/standalone/x11_platform.cpp @@ -7,12 +7,14 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "x11_platform.h" -#include "x11cursor.h" -#include "x11placeholderoutput.h" + +#include + #include "edge.h" #include "session.h" #include "windowselector.h" -#include +#include "x11cursor.h" +#include "x11placeholderoutput.h" #include #if HAVE_EPOXY_GLX #include "glxbackend.h" @@ -25,23 +27,23 @@ #include "eglbackend.h" #include "keyboard_input.h" #include "logging.h" -#include "screenedges_filter.h" +#include "non_composited_outline.h" #include "options.h" #include "overlaywindow_x11.h" -#include "non_composited_outline.h" +#include "renderloop.h" +#include "screenedges_filter.h" +#include "utils/xcbutils.h" #include "workspace.h" #include "x11_output.h" -#include "utils/xcbutils.h" -#include "renderloop.h" #include #include -#include #include +#include -#include #include +#include #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #include #else @@ -75,7 +77,7 @@ bool XrandrEventFilter::event(xcb_generic_event_t *event) m_backend->scheduleUpdateOutputs(); // update default screen - auto *xrrEvent = reinterpret_cast(event); + auto *xrrEvent = reinterpret_cast(event); xcb_screen_t *screen = kwinApp()->x11DefaultScreen(); if (xrrEvent->rotation & (XCB_RANDR_ROTATION_ROTATE_90 | XCB_RANDR_ROTATION_ROTATE_270)) { screen->width_in_pixels = xrrEvent->height; @@ -213,8 +215,7 @@ QString X11StandalonePlatform::compositingNotPossibleReason() const // first off, check whether we figured that we'll crash on detection because of a buggy driver KConfigGroup gl_workaround_group(kwinApp()->config(), "Compositing"); const QString unsafeKey(QLatin1String("OpenGLIsUnsafe") + (kwinApp()->isX11MultiHead() ? QString::number(kwinApp()->x11ScreenNumber()) : QString())); - if (gl_workaround_group.readEntry("Backend", "OpenGL") == QLatin1String("OpenGL") && - gl_workaround_group.readEntry(unsafeKey, false)) + if (gl_workaround_group.readEntry("Backend", "OpenGL") == QLatin1String("OpenGL") && gl_workaround_group.readEntry(unsafeKey, false)) return i18n("OpenGL compositing (the default) has crashed KWin in the past.
" "This was most likely due to a driver bug." "

If you think that you have meanwhile upgraded to a stable driver,
" @@ -234,8 +235,7 @@ bool X11StandalonePlatform::compositingPossible() const // first off, check whether we figured that we'll crash on detection because of a buggy driver KConfigGroup gl_workaround_group(kwinApp()->config(), "Compositing"); const QString unsafeKey(QLatin1String("OpenGLIsUnsafe") + (kwinApp()->isX11MultiHead() ? QString::number(kwinApp()->x11ScreenNumber()) : QString())); - if (gl_workaround_group.readEntry("Backend", "OpenGL") == QLatin1String("OpenGL") && - gl_workaround_group.readEntry(unsafeKey, false)) { + if (gl_workaround_group.readEntry("Backend", "OpenGL") == QLatin1String("OpenGL") && gl_workaround_group.readEntry(unsafeKey, false)) { qCWarning(KWIN_X11STANDALONE) << "Compositing disabled: video driver seems unstable. If you think it's a false positive, please remove " << unsafeKey << " from [Compositing] in kwinrc and restart kwin."; return false; @@ -287,7 +287,8 @@ void X11StandalonePlatform::createOpenGLSafePoint(OpenGLSafePoint safePoint) m_openGLFreezeProtection->start(); const QString configName = kwinApp()->config()->name(); m_openGLFreezeProtection->moveToThread(m_openGLFreezeProtectionThread); - connect(m_openGLFreezeProtection, &QTimer::timeout, m_openGLFreezeProtection, + connect( + m_openGLFreezeProtection, &QTimer::timeout, m_openGLFreezeProtection, [configName] { const QString unsafeKey(QLatin1String("OpenGLIsUnsafe") + (kwinApp()->isX11MultiHead() ? QString::number(kwinApp()->x11ScreenNumber()) : QString())); auto group = KConfigGroup(KSharedConfig::openConfig(configName), "Compositing"); @@ -295,7 +296,8 @@ void X11StandalonePlatform::createOpenGLSafePoint(OpenGLSafePoint safePoint) group.sync(); KCrash::setDrKonqiEnabled(false); qFatal("Freeze in OpenGL initialization detected"); - }, Qt::DirectConnection); + }, + Qt::DirectConnection); } else { Q_ASSERT(m_openGLFreezeProtection); QMetaObject::invokeMethod(m_openGLFreezeProtection, QOverload<>::of(&QTimer::start), Qt::QueuedConnection); @@ -331,7 +333,7 @@ PlatformCursorImage X11StandalonePlatform::cursorImage() const return PlatformCursorImage(); } - QImage qcursorimg((uchar *) xcb_xfixes_get_cursor_image_cursor_image(cursor.data()), cursor->width, cursor->height, + QImage qcursorimg((uchar *)xcb_xfixes_get_cursor_image_cursor_image(cursor.data()), cursor->width, cursor->height, QImage::Format_ARGB32_Premultiplied); // deep copy of image as the data is going to be freed return PlatformCursorImage(qcursorimg.copy(), QPoint(cursor->xhot, cursor->yhot)); @@ -346,7 +348,7 @@ void X11StandalonePlatform::updateCursor() } } -void X11StandalonePlatform::startInteractiveWindowSelection(std::function callback, const QByteArray &cursorName) +void X11StandalonePlatform::startInteractiveWindowSelection(std::function callback, const QByteArray &cursorName) { if (m_windowSelector.isNull()) { m_windowSelector.reset(new WindowSelector); @@ -354,7 +356,7 @@ void X11StandalonePlatform::startInteractiveWindowSelection(std::functionstart(callback, cursorName); } -void X11StandalonePlatform::startInteractivePositionSelection(std::function callback) +void X11StandalonePlatform::startInteractivePositionSelection(std::function callback) { if (m_windowSelector.isNull()) { m_windowSelector.reset(new WindowSelector); @@ -463,7 +465,7 @@ void X11StandalonePlatform::updateOutputs() updateRefreshRate(); } -template +template void X11StandalonePlatform::doUpdateOutputs() { QVector changed; @@ -508,7 +510,7 @@ void X11StandalonePlatform::doUpdateOutputs() dotclock *= 2; if (modes[j].mode_flags & XCB_RANDR_MODE_FLAG_DOUBLE_SCAN) vtotal *= 2; - refreshRate = dotclock/float(modes[j].htotal*vtotal); + refreshRate = dotclock / float(modes[j].htotal * vtotal); } break; // found mode } diff --git a/src/backends/x11/standalone/x11_platform.h b/src/backends/x11/standalone/x11_platform.h index 86f4d86e1b..9e0493f3ef 100644 --- a/src/backends/x11/standalone/x11_platform.h +++ b/src/backends/x11/standalone/x11_platform.h @@ -46,8 +46,8 @@ public: 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; + void startInteractiveWindowSelection(std::function callback, const QByteArray &cursorName = QByteArray()) override; + void startInteractivePositionSelection(std::function callback) override; PlatformCursorImage cursorImage() const override; @@ -82,7 +82,7 @@ private: static bool hasGlx(); X11Output *findX11Output(const QString &name) const; - template + template void doUpdateOutputs(); void updateRefreshRate(); void updateCursor(); diff --git a/src/backends/x11/standalone/x11cursor.cpp b/src/backends/x11/standalone/x11cursor.cpp index d75b3faa0a..5b37576362 100644 --- a/src/backends/x11/standalone/x11cursor.cpp +++ b/src/backends/x11/standalone/x11cursor.cpp @@ -40,13 +40,11 @@ X11Cursor::X11Cursor(QObject *parent, bool xInputSupport) } #ifndef KCMRULES - connect(kwinApp(), &Application::workspaceCreated, this, - [this] { - if (Xcb::Extensions::self()->isFixesAvailable()) { - m_xfixesFilter = std::make_unique(this); - } + connect(kwinApp(), &Application::workspaceCreated, this, [this]() { + if (Xcb::Extensions::self()->isFixesAvailable()) { + m_xfixesFilter = std::make_unique(this); } - ); + }); #endif } @@ -64,8 +62,7 @@ void X11Cursor::doSetPos() void X11Cursor::doGetPos() { - if (m_timeStamp != XCB_TIME_CURRENT_TIME && - m_timeStamp == xTime()) { + if (m_timeStamp != XCB_TIME_CURRENT_TIME && m_timeStamp == xTime()) { // time stamps did not change, no need to query again return; } @@ -123,8 +120,8 @@ void X11Cursor::mousePolled() doGetPos(); // Update if needed if (lastPos != currentPos() || lastMask != m_buttonMask) { Q_EMIT mouseChanged(currentPos(), lastPos, - x11ToQtMouseButtons(m_buttonMask), x11ToQtMouseButtons(lastMask), - x11ToQtKeyboardModifiers(m_buttonMask), x11ToQtKeyboardModifiers(lastMask)); + x11ToQtMouseButtons(m_buttonMask), x11ToQtMouseButtons(lastMask), + x11ToQtKeyboardModifiers(m_buttonMask), x11ToQtKeyboardModifiers(lastMask)); lastPos = currentPos(); lastMask = m_buttonMask; } diff --git a/src/backends/x11/standalone/x11cursor.h b/src/backends/x11/standalone/x11cursor.h index ad97e7b722..788d6ebe92 100644 --- a/src/backends/x11/standalone/x11cursor.h +++ b/src/backends/x11/standalone/x11cursor.h @@ -23,7 +23,8 @@ public: X11Cursor(QObject *parent, bool xInputSupport = false); ~X11Cursor() override; - void schedulePoll() { + void schedulePoll() + { m_needsPoll = true; } @@ -51,6 +52,7 @@ private Q_SLOTS: void resetTimeStamp(); void mousePolled(); void aboutToBlock(); + private: xcb_timestamp_t m_timeStamp; uint16_t m_buttonMask; @@ -64,7 +66,6 @@ private: friend class Cursor; }; - } #endif diff --git a/src/backends/x11/standalone/xfixes_cursor_event_filter.cpp b/src/backends/x11/standalone/xfixes_cursor_event_filter.cpp index abe5e6d757..e2b984ef5a 100644 --- a/src/backends/x11/standalone/xfixes_cursor_event_filter.cpp +++ b/src/backends/x11/standalone/xfixes_cursor_event_filter.cpp @@ -7,8 +7,8 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "xfixes_cursor_event_filter.h" -#include "x11cursor.h" #include "utils/xcbutils.h" +#include "x11cursor.h" namespace KWin { diff --git a/src/backends/x11/standalone/xinputintegration.cpp b/src/backends/x11/standalone/xinputintegration.cpp index 0bc5b915ca..3912b7b575 100644 --- a/src/backends/x11/standalone/xinputintegration.cpp +++ b/src/backends/x11/standalone/xinputintegration.cpp @@ -7,21 +7,21 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "xinputintegration.h" -#include "main.h" -#include "logging.h" +#include "ge_event_mem_mover.h" #include "gestures.h" +#include "logging.h" +#include "main.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 "x11eventfilter.h" #include -#include #include +#include #include @@ -30,7 +30,7 @@ namespace KWin static inline qreal fixed1616ToReal(FP1616 val) { - return (val) * 1.0 / (1 << 16); + return (val)*1.0 / (1 << 16); } class XInputEventFilter : public X11EventFilter @@ -38,81 +38,83 @@ 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}) - {} + { + } ~XInputEventFilter() override = default; - bool event(xcb_generic_event_t *event) override { + bool event(xcb_generic_event_t *event) override + { GeEventMemMover ge(event); switch (ge->event_type) { case XI_RawKeyPress: { - auto re = reinterpret_cast(event); + auto re = reinterpret_cast(event); kwinApp()->platform()->keyboardKeyPressed(re->detail - 8, re->time); break; } case XI_RawKeyRelease: { - auto re = reinterpret_cast(event); + 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; + 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; + 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); + 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); + 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); @@ -122,7 +124,7 @@ public: break; } case XI_TouchEnd: { - auto e = reinterpret_cast(event); + auto e = reinterpret_cast(event); if (e->detail == m_trackingTouchId) { ScreenEdges::self()->gestureRecognizer()->endSwipeGesture(); } @@ -131,10 +133,10 @@ public: break; } case XI_TouchOwnership: { - auto e = reinterpret_cast(event); + 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); + XIAllowTouchEvents(display(), e->deviceid, e->sourceid, e->touchid, XIRejectTouch); } else { if (ScreenEdges::self()->gestureRecognizer()->startSwipeGesture(it.value()) > 0) { m_trackingTouchId = e->touchid; @@ -152,15 +154,18 @@ public: return false; } - void setCursor(const QPointer &cursor) { + void setCursor(const QPointer &cursor) + { m_x11Cursor = cursor; } - void setDisplay(Display *display) { + void setDisplay(Display *display) + { m_x11Display = display; } private: - Display *display() const { + Display *display() const + { return m_x11Display; } @@ -175,10 +180,12 @@ class XKeyPressReleaseEventFilter : public X11EventFilter public: XKeyPressReleaseEventFilter(uint32_t type) : X11EventFilter(type) - {} + { + } ~XKeyPressReleaseEventFilter() override = default; - bool event(xcb_generic_event_t *event) override { + 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; @@ -250,7 +257,7 @@ void XInputIntegration::startListening() XISetMask(mask1, XI_RawKeyPress); XISetMask(mask1, XI_RawKeyRelease); } - if (m_majorVersion >=2 && m_minorVersion >= 2) { + if (m_majorVersion >= 2 && m_minorVersion >= 2) { // touch events since 2.2 XISetMask(mask1, XI_TouchBegin); XISetMask(mask1, XI_TouchUpdate); diff --git a/src/backends/x11/standalone/xinputintegration.h b/src/backends/x11/standalone/xinputintegration.h index 1959d17709..6d2d88ec38 100644 --- a/src/backends/x11/standalone/xinputintegration.h +++ b/src/backends/x11/standalone/xinputintegration.h @@ -31,13 +31,15 @@ public: void init(); void startListening(); - bool hasXinput() const { + bool hasXinput() const + { return m_hasXInput; } void setCursor(X11Cursor *cursor); private: - Display *display() const { + Display *display() const + { return m_x11Display; } diff --git a/src/backends/x11/windowed/scene_qpainter_x11_backend.h b/src/backends/x11/windowed/scene_qpainter_x11_backend.h index 6f6e8cdce9..d65a6729b4 100644 --- a/src/backends/x11/windowed/scene_qpainter_x11_backend.h +++ b/src/backends/x11/windowed/scene_qpainter_x11_backend.h @@ -11,10 +11,10 @@ #include "qpainterbackend.h" -#include #include -#include #include +#include +#include #include @@ -38,11 +38,12 @@ private: void createOutputs(); xcb_gcontext_t m_gc = XCB_NONE; X11WindowedBackend *m_backend; - struct Output { + struct Output + { xcb_window_t window; QImage buffer; }; - QMap m_outputs; + QMap m_outputs; }; } diff --git a/src/backends/x11/windowed/x11windowed_backend.cpp b/src/backends/x11/windowed/x11windowed_backend.cpp index e49fccc65b..96a585fb69 100644 --- a/src/backends/x11/windowed/x11windowed_backend.cpp +++ b/src/backends/x11/windowed/x11windowed_backend.cpp @@ -7,17 +7,19 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "x11windowed_backend.h" -#include "x11windowed_output.h" + #include -#include "scene_qpainter_x11_backend.h" -#include "logging.h" -#include "wayland_server.h" -#include "utils/xcbutils.h" + #include "egl_x11_backend.h" +#include "logging.h" +#include "scene_qpainter_x11_backend.h" #include "screens.h" #include "session.h" -#include +#include "utils/xcbutils.h" +#include "wayland_server.h" +#include "x11windowed_output.h" #include +#include #include // KDE #include @@ -29,13 +31,13 @@ // X11 #if HAVE_X11_XINPUT #include "ge_event_mem_mover.h" -#include #include +#include #endif // system -#include #include #include +#include namespace KWin { @@ -201,8 +203,8 @@ bool X11WindowedBackend::initialize() m_screenNumber = screen; m_display = xDisplay; for (xcb_screen_iterator_t it = xcb_setup_roots_iterator(xcb_get_setup(m_connection)); - it.rem; - --screen, xcb_screen_next(&it)) { + it.rem; + --screen, xcb_screen_next(&it)) { if (screen == m_screenNumber) { m_screen = it.data; } @@ -211,12 +213,10 @@ bool X11WindowedBackend::initialize() XRenderUtils::init(m_connection, m_screen->root); createOutputs(); connect(kwinApp(), &Application::workspaceCreated, this, &X11WindowedBackend::startEventReading); - connect(Cursors::self(), &Cursors::currentCursorChanged, this, - [this] { - KWin::Cursor* c = KWin::Cursors::self()->currentCursor(); - createCursor(c->image(), c->hotspot()); - } - ); + connect(Cursors::self(), &Cursors::currentCursorChanged, this, [this]() { + KWin::Cursor *c = KWin::Cursors::self()->currentCursor(); + createCursor(c->image(), c->hotspot()); + }); setReady(true); m_pointerDevice = new X11WindowedInputDevice(this); m_pointerDevice->setPointer(true); @@ -262,17 +262,16 @@ void X11WindowedBackend::initXInput() m_xiOpcode = xi_opcode; m_majorVersion = major; m_minorVersion = minor; - m_hasXInput = m_majorVersion >=2 && m_minorVersion >= 2; + m_hasXInput = m_majorVersion >= 2 && m_minorVersion >= 2; #endif } X11WindowedOutput *X11WindowedBackend::findOutput(xcb_window_t window) const { auto it = std::find_if(m_outputs.constBegin(), m_outputs.constEnd(), - [window] (X11WindowedOutput *output) { - return output->window() == window; - } - ); + [window](X11WindowedOutput *output) { + return output->window() == window; + }); if (it != m_outputs.constEnd()) { return *it; } @@ -336,7 +335,7 @@ void X11WindowedBackend::startEventReading() static inline qreal fixed1616ToReal(FP1616 val) { - return (val) * 1.0 / (1 << 16); + return (val)*1.0 / (1 << 16); } #endif @@ -346,69 +345,66 @@ void X11WindowedBackend::handleEvent(xcb_generic_event_t *e) switch (eventType) { case XCB_BUTTON_PRESS: case XCB_BUTTON_RELEASE: - handleButtonPress(reinterpret_cast(e)); + handleButtonPress(reinterpret_cast(e)); break; case XCB_MOTION_NOTIFY: { - auto event = reinterpret_cast(e); - const X11WindowedOutput *output = findOutput(event->event); - if (!output) { - break; - } - const QPointF position = output->mapFromGlobal(QPointF(event->root_x, event->root_y)); - Q_EMIT m_pointerDevice->pointerMotionAbsolute(position, event->time, m_pointerDevice); + auto event = reinterpret_cast(e); + const X11WindowedOutput *output = findOutput(event->event); + if (!output) { + break; } - break; + const QPointF position = output->mapFromGlobal(QPointF(event->root_x, event->root_y)); + Q_EMIT m_pointerDevice->pointerMotionAbsolute(position, event->time, m_pointerDevice); + } break; case XCB_KEY_PRESS: case XCB_KEY_RELEASE: { - auto event = reinterpret_cast(e); - if (eventType == XCB_KEY_PRESS) { - if (!m_keySymbols) { - m_keySymbols = xcb_key_symbols_alloc(m_connection); - } - const xcb_keysym_t kc = xcb_key_symbols_get_keysym(m_keySymbols, event->detail, 0); - if (kc == XK_Control_R) { - grabKeyboard(event->time); - } - Q_EMIT m_keyboardDevice->keyChanged(event->detail - 8, - InputRedirection::KeyboardKeyPressed, - event->time, - m_keyboardDevice); - } else { - Q_EMIT m_keyboardDevice->keyChanged(event->detail - 8, - InputRedirection::KeyboardKeyReleased, - event->time, - m_keyboardDevice); + auto event = reinterpret_cast(e); + if (eventType == XCB_KEY_PRESS) { + if (!m_keySymbols) { + m_keySymbols = xcb_key_symbols_alloc(m_connection); } + const xcb_keysym_t kc = xcb_key_symbols_get_keysym(m_keySymbols, event->detail, 0); + if (kc == XK_Control_R) { + grabKeyboard(event->time); + } + Q_EMIT m_keyboardDevice->keyChanged(event->detail - 8, + InputRedirection::KeyboardKeyPressed, + event->time, + m_keyboardDevice); + } else { + Q_EMIT m_keyboardDevice->keyChanged(event->detail - 8, + InputRedirection::KeyboardKeyReleased, + event->time, + m_keyboardDevice); } - break; + } break; case XCB_CONFIGURE_NOTIFY: - updateSize(reinterpret_cast(e)); + updateSize(reinterpret_cast(e)); break; case XCB_ENTER_NOTIFY: { - auto event = reinterpret_cast(e); - const X11WindowedOutput *output = findOutput(event->event); - if (!output) { - break; - } - const QPointF position = output->mapFromGlobal(QPointF(event->root_x, event->root_y)); - Q_EMIT m_pointerDevice->pointerMotionAbsolute(position, event->time, m_pointerDevice); + auto event = reinterpret_cast(e); + const X11WindowedOutput *output = findOutput(event->event); + if (!output) { + break; } - break; + const QPointF position = output->mapFromGlobal(QPointF(event->root_x, event->root_y)); + Q_EMIT m_pointerDevice->pointerMotionAbsolute(position, event->time, m_pointerDevice); + } break; case XCB_CLIENT_MESSAGE: - handleClientMessage(reinterpret_cast(e)); + handleClientMessage(reinterpret_cast(e)); break; case XCB_EXPOSE: - handleExpose(reinterpret_cast(e)); + handleExpose(reinterpret_cast(e)); break; case XCB_MAPPING_NOTIFY: if (m_keySymbols) { - xcb_refresh_keyboard_mapping(m_keySymbols, reinterpret_cast(e)); + xcb_refresh_keyboard_mapping(m_keySymbols, reinterpret_cast(e)); } break; #if HAVE_X11_XINPUT case XCB_GE_GENERIC: { GeEventMemMover ge(e); - auto te = reinterpret_cast(e); + auto te = reinterpret_cast(e); const X11WindowedOutput *output = findOutput(te->event); if (!output) { break; @@ -434,7 +430,7 @@ void X11WindowedBackend::handleEvent(xcb_generic_event_t *e) break; } case XI_TouchOwnership: { - auto te = reinterpret_cast(e); + auto te = reinterpret_cast(e); XIAllowTouchEvents(m_display, te->deviceid, te->sourceid, te->touchid, XIAcceptTouch); break; } @@ -463,9 +459,7 @@ void X11WindowedBackend::grabKeyboard(xcb_timestamp_t time) } if (grab->status == XCB_GRAB_STATUS_SUCCESS) { const auto c = xcb_grab_pointer_unchecked(m_connection, false, window(), - XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | - XCB_EVENT_MASK_POINTER_MOTION | - XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW, + XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, window(), XCB_CURSOR_NONE, time); ScopedCPointer grab(xcb_grab_pointer_reply(m_connection, c, nullptr)); @@ -485,9 +479,7 @@ void X11WindowedBackend::grabKeyboard(xcb_timestamp_t time) void X11WindowedBackend::updateWindowTitle() { const QString grab = m_keyboardGrabbed ? i18n("Press right control to ungrab input") : i18n("Press right control key to grab input"); - const QString title = QStringLiteral("%1 (%2) - %3").arg(i18n("KDE Wayland Compositor"), - waylandServer()->socketName(), - grab); + const QString title = QStringLiteral("%1 (%2) - %3").arg(i18n("KDE Wayland Compositor"), waylandServer()->socketName(), grab); for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { (*it)->setWindowTitle(title); } @@ -496,8 +488,9 @@ void X11WindowedBackend::updateWindowTitle() void X11WindowedBackend::handleClientMessage(xcb_client_message_event_t *event) { auto it = std::find_if(m_outputs.begin(), m_outputs.end(), - [event] (X11WindowedOutput *output) { return output->window() == event->window; } - ); + [event](X11WindowedOutput *output) { + return output->window() == event->window; + }); if (it == m_outputs.end()) { return; } @@ -610,7 +603,7 @@ void X11WindowedBackend::createCursor(const QImage &srcImage, const QPoint &hots const xcb_gcontext_t gc = xcb_generate_id(m_connection); const xcb_cursor_t cid = xcb_generate_id(m_connection); - //right now on X we only have one scale between all screens, and we know we will have at least one screen + // right now on X we only have one scale between all screens, and we know we will have at least one screen const qreal outputScale = 1; const QSize targetSize = srcImage.size() * outputScale / srcImage.devicePixelRatio(); const QImage img = srcImage.scaled(targetSize, Qt::KeepAspectRatio); @@ -660,7 +653,7 @@ X11WindowedInputDevice *X11WindowedBackend::touchDevice() const OpenGLBackend *X11WindowedBackend::createOpenGLBackend() { - return new EglX11Backend(this); + return new EglX11Backend(this); } QPainterBackend *X11WindowedBackend::createQPainterBackend() @@ -685,7 +678,7 @@ xcb_window_t X11WindowedBackend::windowForScreen(AbstractOutput *output) const if (!output) { return XCB_WINDOW_NONE; } - return static_cast(output)->window(); + return static_cast(output)->window(); } xcb_window_t X11WindowedBackend::window() const diff --git a/src/backends/x11/windowed/x11windowed_backend.h b/src/backends/x11/windowed/x11windowed_backend.h index e9dd7c7b0e..0b6e093bdf 100644 --- a/src/backends/x11/windowed/x11windowed_backend.h +++ b/src/backends/x11/windowed/x11windowed_backend.h @@ -93,31 +93,37 @@ public: bool initialize() override; Session *session() const override; - xcb_connection_t *connection() const { + xcb_connection_t *connection() const + { return m_connection; } - xcb_screen_t *screen() const { + xcb_screen_t *screen() const + { return m_screen; } - int screenNumer() const { + int screenNumer() const + { return m_screenNumber; } xcb_window_t window() const; xcb_window_t windowForScreen(AbstractOutput *output) const; - Display *display() const { + Display *display() const + { return m_display; } xcb_window_t rootWindow() const; - bool hasXInput() const { + bool hasXInput() const + { return m_hasXInput; } OpenGLBackend *createOpenGLBackend() override; - QPainterBackend* createQPainterBackend() override; + QPainterBackend *createQPainterBackend() override; InputBackend *createInputBackend() override; void warpPointer(const QPointF &globalPos) override; - QVector supportedCompositors() const override { + QVector supportedCompositors() const override + { if (selectedCompositor() != NoCompositing) { return {selectedCompositor()}; } @@ -169,7 +175,7 @@ private: int m_majorVersion = 0; int m_minorVersion = 0; - QVector m_outputs; + QVector m_outputs; }; } diff --git a/src/backends/x11/windowed/x11windowed_output.cpp b/src/backends/x11/windowed/x11windowed_output.cpp index 0b98b549f9..07d6be65a5 100644 --- a/src/backends/x11/windowed/x11windowed_output.cpp +++ b/src/backends/x11/windowed/x11windowed_output.cpp @@ -7,7 +7,9 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "x11windowed_output.h" + #include + #include "renderloop_p.h" #include "softwarevsyncmonitor.h" #include "x11windowed_backend.h" @@ -71,23 +73,27 @@ void X11WindowedOutput::init(const QPoint &logicalPosition, const QSize &pixelSi // Physicial size must be adjusted, such that QPA calculates correct sizes of // internal elements. const QSize physicalSize = pixelSize / 96.0 * 25.4 / m_backend->initialOutputScale(); - initialize("model_TODO", "manufacturer_TODO", "eisa_TODO", "serial_TODO", physicalSize, { mode }, {}); + initialize("model_TODO", "manufacturer_TODO", "eisa_TODO", "serial_TODO", physicalSize, {mode}, {}); setGeometry(logicalPosition, pixelSize); setScale(m_backend->initialOutputScale()); - uint32_t mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; + const uint32_t eventMask = XCB_EVENT_MASK_KEY_PRESS + | XCB_EVENT_MASK_KEY_RELEASE + | XCB_EVENT_MASK_BUTTON_PRESS + | XCB_EVENT_MASK_BUTTON_RELEASE + | XCB_EVENT_MASK_POINTER_MOTION + | XCB_EVENT_MASK_ENTER_WINDOW + | XCB_EVENT_MASK_LEAVE_WINDOW + | XCB_EVENT_MASK_STRUCTURE_NOTIFY + | XCB_EVENT_MASK_EXPOSURE; + const uint32_t values[] = { m_backend->screen()->black_pixel, - XCB_EVENT_MASK_KEY_PRESS | - XCB_EVENT_MASK_KEY_RELEASE | - XCB_EVENT_MASK_BUTTON_PRESS | - XCB_EVENT_MASK_BUTTON_RELEASE | - XCB_EVENT_MASK_POINTER_MOTION | - XCB_EVENT_MASK_ENTER_WINDOW | - XCB_EVENT_MASK_LEAVE_WINDOW | - XCB_EVENT_MASK_STRUCTURE_NOTIFY | - XCB_EVENT_MASK_EXPOSURE + eventMask, }; + + uint32_t valueMask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; + xcb_create_window(m_backend->connection(), XCB_COPY_FROM_PARENT, m_window, @@ -95,7 +101,7 @@ void X11WindowedOutput::init(const QPoint &logicalPosition, const QSize &pixelSi 0, 0, pixelSize.width(), pixelSize.height(), 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, - mask, values); + valueMask, values); // select xinput 2 events initXInputForWindow(); @@ -108,7 +114,7 @@ void X11WindowedOutput::init(const QPoint &logicalPosition, const QSize &pixelSi m_winInfo->setWindowType(NET::Normal); m_winInfo->setPid(QCoreApplication::applicationPid()); QIcon windowIcon = QIcon::fromTheme(QStringLiteral("kwin")); - auto addIcon = [&windowIcon, this] (const QSize &size) { + auto addIcon = [&windowIcon, this](const QSize &size) { if (windowIcon.actualSize(size) != size) { return; } diff --git a/src/backends/x11/windowed/x11windowed_output.h b/src/backends/x11/windowed/x11windowed_output.h index 523949376e..aa508acf13 100644 --- a/src/backends/x11/windowed/x11windowed_output.h +++ b/src/backends/x11/windowed/x11windowed_output.h @@ -41,12 +41,14 @@ public: void init(const QPoint &logicalPosition, const QSize &pixelSize); - xcb_window_t window() const { + xcb_window_t window() const + { return m_window; } QPoint internalPosition() const; - QPoint hostPosition() const { + QPoint hostPosition() const + { return m_hostPosition; } void setHostPosition(const QPoint &pos); diff --git a/src/client_machine.cpp b/src/client_machine.cpp index d7d3419ccc..b04a29616f 100644 --- a/src/client_machine.cpp +++ b/src/client_machine.cpp @@ -13,15 +13,16 @@ // KF5 #include // Qt -#include #include +#include // system -#include -#include -#include #include +#include +#include +#include -namespace KWin { +namespace KWin +{ static QByteArray getHostName() { @@ -31,7 +32,7 @@ static QByteArray getHostName() char hostnamebuf[256]; #endif if (gethostname(hostnamebuf, sizeof hostnamebuf) >= 0) { - hostnamebuf[sizeof(hostnamebuf)-1] = 0; + hostnamebuf[sizeof(hostnamebuf) - 1] = 0; return QByteArray(hostnamebuf); } return QByteArray(); @@ -111,7 +112,7 @@ void GetAddrInfo::slotOwnAddressResolved() } } -bool GetAddrInfo::resolved(QFutureWatcher< int >* watcher) +bool GetAddrInfo::resolved(QFutureWatcher *watcher) { if (!watcher->isFinished()) { return false; @@ -136,7 +137,7 @@ void GetAddrInfo::compare() addrinfo *ownAddress = m_ownAddress; bool localFound = false; while (ownAddress) { - if (ownAddress->ai_canonname && QByteArray(ownAddress->ai_canonname).toLower() == m_hostName) { + if (ownAddress->ai_canonname && QByteArray(ownAddress->ai_canonname).toLower() == m_hostName) { localFound = true; break; } @@ -152,7 +153,6 @@ void GetAddrInfo::compare() deleteLater(); } - ClientMachine::ClientMachine(QObject *parent) : QObject(parent) , m_localhost(false) diff --git a/src/client_machine.h b/src/client_machine.h index c2c191d258..586072b745 100644 --- a/src/client_machine.h +++ b/src/client_machine.h @@ -14,10 +14,11 @@ // forward declaration struct addrinfo; -template +template class QFutureWatcher; -namespace KWin { +namespace KWin +{ class GetAddrInfo : public QObject { @@ -77,26 +78,22 @@ private: bool m_resolving; }; -inline -bool ClientMachine::isLocal() const +inline bool ClientMachine::isLocal() const { return m_localhost; } -inline -const QByteArray &ClientMachine::hostName() const +inline const QByteArray &ClientMachine::hostName() const { return m_hostName; } -inline -QByteArray ClientMachine::localhost() +inline QByteArray ClientMachine::localhost() { return "localhost"; } -inline -bool ClientMachine::isResolving() const +inline bool ClientMachine::isResolving() const { return m_resolving; } diff --git a/src/colordevice.cpp b/src/colordevice.cpp index cd3460e506..f5591a28c1 100644 --- a/src/colordevice.cpp +++ b/src/colordevice.cpp @@ -17,13 +17,13 @@ namespace KWin { -template +template struct CmsDeleter; -template +template using CmsScopedPointer = QScopedPointer>; -template <> +template<> struct CmsDeleter { static inline void cleanup(cmsPipeline *pipeline) @@ -34,7 +34,7 @@ struct CmsDeleter } }; -template <> +template<> struct CmsDeleter { static inline void cleanup(cmsStage *stage) @@ -45,7 +45,7 @@ struct CmsDeleter } }; -template <> +template<> struct CmsDeleter { static inline void cleanup(cmsToneCurve *toneCurve) @@ -163,9 +163,9 @@ void ColorDevicePrivate::updateTemperatureToneCurves() blackbodyColor[blackBodyColorIndex + 5], blendFactor); - const double redCurveParams[] = { 1.0, xWhitePoint, 0.0 }; - const double greenCurveParams[] = { 1.0, yWhitePoint, 0.0 }; - const double blueCurveParams[] = { 1.0, zWhitePoint, 0.0 }; + const double redCurveParams[] = {1.0, xWhitePoint, 0.0}; + const double greenCurveParams[] = {1.0, yWhitePoint, 0.0}; + const double blueCurveParams[] = {1.0, zWhitePoint, 0.0}; CmsScopedPointer redCurve(cmsBuildParametricToneCurve(nullptr, 2, redCurveParams)); if (!redCurve) { @@ -184,7 +184,7 @@ void ColorDevicePrivate::updateTemperatureToneCurves() } // The ownership of the tone curves will be moved to the pipeline stage. - cmsToneCurve *toneCurves[] = { redCurve.take(), greenCurve.take(), blueCurve.take() }; + cmsToneCurve *toneCurves[] = {redCurve.take(), greenCurve.take(), blueCurve.take()}; temperatureStage.reset(cmsStageAllocToneCurves(nullptr, 3, toneCurves)); if (!temperatureStage) { @@ -200,7 +200,7 @@ void ColorDevicePrivate::updateBrightnessToneCurves() return; } - const double curveParams[] = { 1.0, brightness / 100.0, 0.0 }; + const double curveParams[] = {1.0, brightness / 100.0, 0.0}; CmsScopedPointer redCurve(cmsBuildParametricToneCurve(nullptr, 2, curveParams)); if (!redCurve) { @@ -221,7 +221,7 @@ void ColorDevicePrivate::updateBrightnessToneCurves() } // The ownership of the tone curves will be moved to the pipeline stage. - cmsToneCurve *toneCurves[] = { redCurve.take(), greenCurve.take(), blueCurve.take() }; + cmsToneCurve *toneCurves[] = {redCurve.take(), greenCurve.take(), blueCurve.take()}; brightnessStage.reset(cmsStageAllocToneCurves(nullptr, 3, toneCurves)); if (!brightnessStage) { @@ -356,8 +356,8 @@ void ColorDevice::update() // ensure 64 bit calculation to prevent overflows const uint16_t index = (static_cast(i) * 0xffff) / (gammaRamp.size() - 1); - const uint16_t in[3] = { index, index, index }; - uint16_t out[3] = { 0 }; + const uint16_t in[3] = {index, index, index}; + uint16_t out[3] = {0}; cmsPipelineEval16(in, out, d->pipeline.data()); redChannel[i] = out[0]; diff --git a/src/composite.cpp b/src/composite.cpp index 59dbff27f3..1fdedd7c3e 100644 --- a/src/composite.cpp +++ b/src/composite.cpp @@ -6,13 +6,14 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include #include "composite.h" + +#include + #include "abstract_output.h" #include "cursorview_opengl.h" #include "cursorview_qpainter.h" #include "dbusinterface.h" -#include "x11client.h" #include "decorations/decoratedclient.h" #include "deleted.h" #include "effects.h" @@ -34,10 +35,11 @@ #include "unmanaged.h" #include "useractions.h" #include "utils/common.h" +#include "utils/xcbutils.h" #include "wayland_server.h" #include "workspace.h" +#include "x11client.h" #include "x11syncmanager.h" -#include "utils/xcbutils.h" #include #include @@ -56,9 +58,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -104,20 +106,25 @@ public: : KSelectionOwner(selection, kwinApp()->x11Connection(), kwinApp()->x11RootWindow()) , m_owning(false) { - connect (this, &CompositorSelectionOwner::lostOwnership, - this, [this]() { m_owning = false; }); + connect(this, &CompositorSelectionOwner::lostOwnership, + this, [this]() { + m_owning = false; + }); } - bool owning() const { + bool owning() const + { return m_owning; } - void setOwning(bool own) { + void setOwning(bool own) + { m_owning = own; } + private: bool m_owning; }; -Compositor::Compositor(QObject* workspace) +Compositor::Compositor(QObject *workspace) : QObject(workspace) { connect(options, &Options::configChanged, this, &Compositor::configChanged); @@ -143,15 +150,15 @@ Compositor::Compositor(QObject* workspace) if (kwinApp()->platform()->isReady()) { QTimer::singleShot(0, this, &Compositor::start); } - connect(kwinApp()->platform(), &Platform::readyChanged, this, - [this] (bool ready) { + connect( + kwinApp()->platform(), &Platform::readyChanged, this, [this](bool ready) { if (ready) { start(); } else { stop(); } - }, Qt::QueuedConnection - ); + }, + Qt::QueuedConnection); // register DBus new CompositorDBusInterface(this); @@ -262,7 +269,7 @@ bool Compositor::setupStart() supportedCompositors.prepend(options->compositingMode()); } else { qCWarning(KWIN_CORE) - << "Configured compositor not supported by Platform. Falling back to defaults"; + << "Configured compositor not supported by Platform. Falling back to defaults"; } for (auto type : qAsConst(supportedCompositors)) { @@ -330,7 +337,7 @@ void Compositor::initializeX11() } if (!m_selectionOwner) { - char selection_name[ 100 ]; + char selection_name[100]; sprintf(selection_name, "_NET_WM_CM_S%d", Application::x11ScreenNumber()); m_selectionOwner = new CompositorSelectionOwner(selection_name); connect(m_selectionOwner, &CompositorSelectionOwner::lostOwnership, @@ -688,7 +695,7 @@ void Compositor::composite(RenderLoop *renderLoop) // TODO: Put it inside the cursor layer once the cursor layer can be backed by a real output layer. if (waylandServer()) { const std::chrono::milliseconds frameTime = - std::chrono::duration_cast(output->renderLoop()->lastPresentationTimestamp()); + std::chrono::duration_cast(output->renderLoop()->lastPresentationTimestamp()); if (!Cursors::self()->isCursorHidden()) { Cursor *cursor = Cursors::self()->currentCursor(); @@ -835,13 +842,13 @@ void X11Compositor::suspend(X11Compositor::SuspendReason reason) if (reason & ScriptSuspend) { // When disabled show a shortcut how the user can get back compositing. const auto shortcuts = KGlobalAccel::self()->shortcut( - workspace()->findChild(QStringLiteral("Suspend Compositing"))); + workspace()->findChild(QStringLiteral("Suspend Compositing"))); if (!shortcuts.isEmpty()) { // Display notification only if there is the shortcut. const QString message = - i18n("Desktop effects have been suspended by another application.
" - "You can resume using the '%1' shortcut.", - shortcuts.first().toString(QKeySequence::NativeText)); + i18n("Desktop effects have been suspended by another application.
" + "You can resume using the '%1' shortcut.", + shortcuts.first().toString(QKeySequence::NativeText)); #if KWIN_BUILD_NOTIFICATIONS KNotification::event(QStringLiteral("compositingsuspendeddbus"), message); #endif @@ -977,12 +984,13 @@ void X11Compositor::updateClientCompositeBlocking(X11Client *c) if (c->isBlockingCompositing()) { // Do NOT attempt to call suspend(true) from within the eventchain! if (!(m_suspended & BlockRuleSuspend)) - QMetaObject::invokeMethod(this, [this]() { + QMetaObject::invokeMethod( + this, [this]() { suspend(BlockRuleSuspend); - }, Qt::QueuedConnection); + }, + Qt::QueuedConnection); } - } - else if (m_suspended & BlockRuleSuspend) { + } else if (m_suspended & BlockRuleSuspend) { // If !c we just check if we can resume in case a blocking client was lost. bool shouldResume = true; @@ -995,9 +1003,11 @@ void X11Compositor::updateClientCompositeBlocking(X11Client *c) } if (shouldResume) { // Do NOT attempt to call suspend(false) from within the eventchain! - QMetaObject::invokeMethod(this, [this]() { - resume(BlockRuleSuspend); - }, Qt::QueuedConnection); + QMetaObject::invokeMethod( + this, [this]() { + resume(BlockRuleSuspend); + }, + Qt::QueuedConnection); } } } diff --git a/src/composite.h b/src/composite.h index 80ea6124c8..37070b6709 100644 --- a/src/composite.h +++ b/src/composite.h @@ -12,8 +12,8 @@ #include #include -#include #include +#include namespace KWin { @@ -67,10 +67,12 @@ public: */ bool isActive(); - Scene *scene() const { + Scene *scene() const + { return m_scene; } - RenderBackend *backend() const { + RenderBackend *backend() const + { return m_backend; } @@ -79,7 +81,8 @@ public: * * @return bool @c true if there is a Compositor and it is active, @c false otherwise */ - static bool compositing() { + static bool compositing() + { return s_compositor != nullptr && s_compositor->isActive(); } @@ -175,11 +178,11 @@ class KWIN_EXPORT X11Compositor final : public Compositor Q_OBJECT public: enum SuspendReason { - NoReasonSuspend = 0, - UserSuspend = 1 << 0, - BlockRuleSuspend = 1 << 1, - ScriptSuspend = 1 << 2, - AllReasonSuspend = 0xff + NoReasonSuspend = 0, + UserSuspend = 1 << 0, + BlockRuleSuspend = 1 << 1, + ScriptSuspend = 1 << 2, + AllReasonSuspend = 0xff }; Q_DECLARE_FLAGS(SuspendReasons, SuspendReason) Q_ENUM(SuspendReason) diff --git a/src/cursor.cpp b/src/cursor.cpp index ec45f2e0fa..8c0d169bcb 100644 --- a/src/cursor.cpp +++ b/src/cursor.cpp @@ -10,15 +10,14 @@ #include "cursor.h" // kwin #include "abstract_output.h" +#include "composite.h" #include "input.h" #include "keyboard_input.h" #include "main.h" #include "platform.h" +#include "scene.h" #include "utils/common.h" #include "utils/xcbutils.h" -#include "abstract_output.h" -#include "composite.h" -#include "scene.h" // KDE #include #include @@ -33,24 +32,25 @@ namespace KWin { Cursors *Cursors::s_self = nullptr; -Cursors *Cursors::self() { +Cursors *Cursors::self() +{ if (!s_self) s_self = new Cursors; return s_self; } -void Cursors::addCursor(Cursor* cursor) +void Cursors::addCursor(Cursor *cursor) { Q_ASSERT(!m_cursors.contains(cursor)); m_cursors += cursor; - connect(cursor, &Cursor::posChanged, this, [this, cursor] (const QPoint &pos) { + connect(cursor, &Cursor::posChanged, this, [this, cursor](const QPoint &pos) { setCurrentCursor(cursor); Q_EMIT positionChanged(cursor, pos); }); } -void Cursors::removeCursor(Cursor* cursor) +void Cursors::removeCursor(Cursor *cursor) { m_cursors.removeOne(cursor); if (m_currentCursor == cursor) { @@ -85,7 +85,7 @@ bool Cursors::isCursorHidden() const return m_cursorHideCounter > 0; } -void Cursors::setCurrentCursor(Cursor* cursor) +void Cursors::setCurrentCursor(Cursor *cursor) { if (m_currentCursor == cursor) return; @@ -115,7 +115,7 @@ Cursor::Cursor(QObject *parent) { loadThemeSettings(); QDBusConnection::sessionBus().connect(QString(), QStringLiteral("/KGlobalSettings"), QStringLiteral("org.kde.KGlobalSettings"), - QStringLiteral("notifyChange"), this, SLOT(slotKGlobalSettingsNotifyChange(int,int))); + QStringLiteral("notifyChange"), this, SLOT(slotKGlobalSettingsNotifyChange(int, int))); } Cursor::~Cursor() @@ -157,7 +157,7 @@ void Cursor::updateTheme(const QString &name, int size) void Cursor::slotKGlobalSettingsNotifyChange(int type, int arg) { -// #endif + // #endif Q_UNUSED(arg) if (type == 5 /*CursorChanged*/) { InputConfig::self()->inputConfig()->reparseConfiguration(); @@ -333,127 +333,272 @@ void Cursor::doStopCursorTracking() QVector Cursor::cursorAlternativeNames(const QByteArray &name) { static const QHash> alternatives = { - {QByteArrayLiteral("left_ptr"), {QByteArrayLiteral("arrow"), - QByteArrayLiteral("dnd-none"), - QByteArrayLiteral("op_left_arrow")}}, - {QByteArrayLiteral("cross"), {QByteArrayLiteral("crosshair"), - QByteArrayLiteral("diamond-cross"), - QByteArrayLiteral("cross-reverse")}}, - {QByteArrayLiteral("up_arrow"), {QByteArrayLiteral("center_ptr"), - QByteArrayLiteral("sb_up_arrow"), - QByteArrayLiteral("centre_ptr")}}, - {QByteArrayLiteral("wait"), {QByteArrayLiteral("watch"), - QByteArrayLiteral("progress")}}, - {QByteArrayLiteral("ibeam"), {QByteArrayLiteral("xterm"), - QByteArrayLiteral("text")}}, - {QByteArrayLiteral("size_all"), {QByteArrayLiteral("fleur")}}, - {QByteArrayLiteral("pointing_hand"), {QByteArrayLiteral("hand2"), - QByteArrayLiteral("hand"), - QByteArrayLiteral("hand1"), - QByteArrayLiteral("pointer"), - QByteArrayLiteral("e29285e634086352946a0e7090d73106"), - QByteArrayLiteral("9d800788f1b08800ae810202380a0822")}}, - {QByteArrayLiteral("size_ver"), {QByteArrayLiteral("00008160000006810000408080010102"), - QByteArrayLiteral("sb_v_double_arrow"), - QByteArrayLiteral("v_double_arrow"), - QByteArrayLiteral("n-resize"), - QByteArrayLiteral("s-resize"), - QByteArrayLiteral("col-resize"), - QByteArrayLiteral("top_side"), - QByteArrayLiteral("bottom_side"), - QByteArrayLiteral("base_arrow_up"), - QByteArrayLiteral("base_arrow_down"), - QByteArrayLiteral("based_arrow_down"), - QByteArrayLiteral("based_arrow_up")}}, - {QByteArrayLiteral("size_hor"), {QByteArrayLiteral("028006030e0e7ebffc7f7070c0600140"), - QByteArrayLiteral("sb_h_double_arrow"), - QByteArrayLiteral("h_double_arrow"), - QByteArrayLiteral("e-resize"), - QByteArrayLiteral("w-resize"), - QByteArrayLiteral("row-resize"), - QByteArrayLiteral("right_side"), - QByteArrayLiteral("left_side")}}, - {QByteArrayLiteral("size_bdiag"), {QByteArrayLiteral("fcf1c3c7cd4491d801f1e1c78f100000"), - QByteArrayLiteral("fd_double_arrow"), - QByteArrayLiteral("bottom_left_corner"), - QByteArrayLiteral("top_right_corner")}}, - {QByteArrayLiteral("size_fdiag"), {QByteArrayLiteral("c7088f0f3e6c8088236ef8e1e3e70000"), - QByteArrayLiteral("bd_double_arrow"), - QByteArrayLiteral("bottom_right_corner"), - QByteArrayLiteral("top_left_corner")}}, - {QByteArrayLiteral("whats_this"), {QByteArrayLiteral("d9ce0ab605698f320427677b458ad60b"), - QByteArrayLiteral("left_ptr_help"), - QByteArrayLiteral("help"), - QByteArrayLiteral("question_arrow"), - QByteArrayLiteral("dnd-ask"), - QByteArrayLiteral("5c6cd98b3f3ebcb1f9c7f1c204630408")}}, - {QByteArrayLiteral("split_h"), {QByteArrayLiteral("14fef782d02440884392942c11205230"), - QByteArrayLiteral("size_hor")}}, - {QByteArrayLiteral("split_v"), {QByteArrayLiteral("2870a09082c103050810ffdffffe0204"), - QByteArrayLiteral("size_ver")}}, - {QByteArrayLiteral("forbidden"), {QByteArrayLiteral("03b6e0fcb3499374a867c041f52298f0"), - QByteArrayLiteral("circle"), - QByteArrayLiteral("dnd-no-drop"), - QByteArrayLiteral("not-allowed")}}, - {QByteArrayLiteral("left_ptr_watch"), {QByteArrayLiteral("3ecb610c1bf2410f44200f48c40d3599"), - QByteArrayLiteral("00000000000000020006000e7e9ffc3f"), - QByteArrayLiteral("08e8e1c95fe2fc01f976f1e063a24ccd")}}, - {QByteArrayLiteral("openhand"), {QByteArrayLiteral("9141b49c8149039304290b508d208c40"), - QByteArrayLiteral("all_scroll"), - QByteArrayLiteral("all-scroll")}}, - {QByteArrayLiteral("closedhand"), {QByteArrayLiteral("05e88622050804100c20044008402080"), - QByteArrayLiteral("4498f0e0c1937ffe01fd06f973665830"), - QByteArrayLiteral("9081237383d90e509aa00f00170e968f"), - QByteArrayLiteral("fcf21c00b30f7e3f83fe0dfd12e71cff")}}, - {QByteArrayLiteral("dnd-link"), {QByteArrayLiteral("link"), - QByteArrayLiteral("alias"), - QByteArrayLiteral("3085a0e285430894940527032f8b26df"), - QByteArrayLiteral("640fb0e74195791501fd1ed57b41487f"), - QByteArrayLiteral("a2a266d0498c3104214a47bd64ab0fc8")}}, - {QByteArrayLiteral("dnd-copy"), {QByteArrayLiteral("copy"), - QByteArrayLiteral("1081e37283d90000800003c07f3ef6bf"), - QByteArrayLiteral("6407b0e94181790501fd1e167b474872"), - QByteArrayLiteral("b66166c04f8c3109214a4fbd64a50fc8")}}, - {QByteArrayLiteral("dnd-move"), {QByteArrayLiteral("move")}}, - {QByteArrayLiteral("sw-resize"), {QByteArrayLiteral("size_bdiag"), - QByteArrayLiteral("fcf1c3c7cd4491d801f1e1c78f100000"), - QByteArrayLiteral("fd_double_arrow"), - QByteArrayLiteral("bottom_left_corner")}}, - {QByteArrayLiteral("se-resize"), {QByteArrayLiteral("size_fdiag"), - QByteArrayLiteral("c7088f0f3e6c8088236ef8e1e3e70000"), - QByteArrayLiteral("bd_double_arrow"), - QByteArrayLiteral("bottom_right_corner")}}, - {QByteArrayLiteral("ne-resize"), {QByteArrayLiteral("size_bdiag"), - QByteArrayLiteral("fcf1c3c7cd4491d801f1e1c78f100000"), - QByteArrayLiteral("fd_double_arrow"), - QByteArrayLiteral("top_right_corner")}}, - {QByteArrayLiteral("nw-resize"), {QByteArrayLiteral("size_fdiag"), - QByteArrayLiteral("c7088f0f3e6c8088236ef8e1e3e70000"), - QByteArrayLiteral("bd_double_arrow"), - QByteArrayLiteral("top_left_corner")}}, - {QByteArrayLiteral("n-resize"), {QByteArrayLiteral("size_ver"), - QByteArrayLiteral("00008160000006810000408080010102"), - QByteArrayLiteral("sb_v_double_arrow"), - QByteArrayLiteral("v_double_arrow"), - QByteArrayLiteral("col-resize"), - QByteArrayLiteral("top_side")}}, - {QByteArrayLiteral("e-resize"), {QByteArrayLiteral("size_hor"), - QByteArrayLiteral("028006030e0e7ebffc7f7070c0600140"), - QByteArrayLiteral("sb_h_double_arrow"), - QByteArrayLiteral("h_double_arrow"), - QByteArrayLiteral("row-resize"), - QByteArrayLiteral("left_side")}}, - {QByteArrayLiteral("s-resize"), {QByteArrayLiteral("size_ver"), - QByteArrayLiteral("00008160000006810000408080010102"), - QByteArrayLiteral("sb_v_double_arrow"), - QByteArrayLiteral("v_double_arrow"), - QByteArrayLiteral("col-resize"), - QByteArrayLiteral("bottom_side")}}, - {QByteArrayLiteral("w-resize"), {QByteArrayLiteral("size_hor"), - QByteArrayLiteral("028006030e0e7ebffc7f7070c0600140"), - QByteArrayLiteral("sb_h_double_arrow"), - QByteArrayLiteral("h_double_arrow"), - QByteArrayLiteral("right_side")}} + { + QByteArrayLiteral("left_ptr"), + { + QByteArrayLiteral("arrow"), + QByteArrayLiteral("dnd-none"), + QByteArrayLiteral("op_left_arrow"), + }, + }, + { + QByteArrayLiteral("cross"), + { + QByteArrayLiteral("crosshair"), + QByteArrayLiteral("diamond-cross"), + QByteArrayLiteral("cross-reverse"), + }, + }, + { + QByteArrayLiteral("up_arrow"), + { + QByteArrayLiteral("center_ptr"), + QByteArrayLiteral("sb_up_arrow"), + QByteArrayLiteral("centre_ptr"), + }, + }, + { + QByteArrayLiteral("wait"), + { + QByteArrayLiteral("watch"), + QByteArrayLiteral("progress"), + }, + }, + { + QByteArrayLiteral("ibeam"), + { + QByteArrayLiteral("xterm"), + QByteArrayLiteral("text"), + }, + }, + { + QByteArrayLiteral("size_all"), + { + QByteArrayLiteral("fleur"), + }, + }, + { + QByteArrayLiteral("pointing_hand"), + { + QByteArrayLiteral("hand2"), + QByteArrayLiteral("hand"), + QByteArrayLiteral("hand1"), + QByteArrayLiteral("pointer"), + QByteArrayLiteral("e29285e634086352946a0e7090d73106"), + QByteArrayLiteral("9d800788f1b08800ae810202380a0822"), + }, + }, + { + QByteArrayLiteral("size_ver"), + { + QByteArrayLiteral("00008160000006810000408080010102"), + QByteArrayLiteral("sb_v_double_arrow"), + QByteArrayLiteral("v_double_arrow"), + QByteArrayLiteral("n-resize"), + QByteArrayLiteral("s-resize"), + QByteArrayLiteral("col-resize"), + QByteArrayLiteral("top_side"), + QByteArrayLiteral("bottom_side"), + QByteArrayLiteral("base_arrow_up"), + QByteArrayLiteral("base_arrow_down"), + QByteArrayLiteral("based_arrow_down"), + QByteArrayLiteral("based_arrow_up"), + }, + }, + { + QByteArrayLiteral("size_hor"), + { + QByteArrayLiteral("028006030e0e7ebffc7f7070c0600140"), + QByteArrayLiteral("sb_h_double_arrow"), + QByteArrayLiteral("h_double_arrow"), + QByteArrayLiteral("e-resize"), + QByteArrayLiteral("w-resize"), + QByteArrayLiteral("row-resize"), + QByteArrayLiteral("right_side"), + QByteArrayLiteral("left_side"), + }, + }, + { + QByteArrayLiteral("size_bdiag"), + { + QByteArrayLiteral("fcf1c3c7cd4491d801f1e1c78f100000"), + QByteArrayLiteral("fd_double_arrow"), + QByteArrayLiteral("bottom_left_corner"), + QByteArrayLiteral("top_right_corner"), + }, + }, + { + QByteArrayLiteral("size_fdiag"), + { + QByteArrayLiteral("c7088f0f3e6c8088236ef8e1e3e70000"), + QByteArrayLiteral("bd_double_arrow"), + QByteArrayLiteral("bottom_right_corner"), + QByteArrayLiteral("top_left_corner"), + }, + }, + { + QByteArrayLiteral("whats_this"), + { + QByteArrayLiteral("d9ce0ab605698f320427677b458ad60b"), + QByteArrayLiteral("left_ptr_help"), + QByteArrayLiteral("help"), + QByteArrayLiteral("question_arrow"), + QByteArrayLiteral("dnd-ask"), + QByteArrayLiteral("5c6cd98b3f3ebcb1f9c7f1c204630408"), + }, + }, + { + QByteArrayLiteral("split_h"), + { + QByteArrayLiteral("14fef782d02440884392942c11205230"), + QByteArrayLiteral("size_hor"), + }, + }, + { + QByteArrayLiteral("split_v"), + { + QByteArrayLiteral("2870a09082c103050810ffdffffe0204"), + QByteArrayLiteral("size_ver"), + }, + }, + { + QByteArrayLiteral("forbidden"), + { + QByteArrayLiteral("03b6e0fcb3499374a867c041f52298f0"), + QByteArrayLiteral("circle"), + QByteArrayLiteral("dnd-no-drop"), + QByteArrayLiteral("not-allowed"), + }, + }, + { + QByteArrayLiteral("left_ptr_watch"), + { + QByteArrayLiteral("3ecb610c1bf2410f44200f48c40d3599"), + QByteArrayLiteral("00000000000000020006000e7e9ffc3f"), + QByteArrayLiteral("08e8e1c95fe2fc01f976f1e063a24ccd"), + }, + }, + { + QByteArrayLiteral("openhand"), + { + QByteArrayLiteral("9141b49c8149039304290b508d208c40"), + QByteArrayLiteral("all_scroll"), + QByteArrayLiteral("all-scroll"), + }, + }, + { + QByteArrayLiteral("closedhand"), + { + QByteArrayLiteral("05e88622050804100c20044008402080"), + QByteArrayLiteral("4498f0e0c1937ffe01fd06f973665830"), + QByteArrayLiteral("9081237383d90e509aa00f00170e968f"), + QByteArrayLiteral("fcf21c00b30f7e3f83fe0dfd12e71cff"), + }, + }, + { + QByteArrayLiteral("dnd-link"), + { + QByteArrayLiteral("link"), + QByteArrayLiteral("alias"), + QByteArrayLiteral("3085a0e285430894940527032f8b26df"), + QByteArrayLiteral("640fb0e74195791501fd1ed57b41487f"), + QByteArrayLiteral("a2a266d0498c3104214a47bd64ab0fc8"), + }, + }, + { + QByteArrayLiteral("dnd-copy"), + { + QByteArrayLiteral("copy"), + QByteArrayLiteral("1081e37283d90000800003c07f3ef6bf"), + QByteArrayLiteral("6407b0e94181790501fd1e167b474872"), + QByteArrayLiteral("b66166c04f8c3109214a4fbd64a50fc8"), + }, + }, + { + QByteArrayLiteral("dnd-move"), + { + QByteArrayLiteral("move"), + }, + }, + { + QByteArrayLiteral("sw-resize"), + { + QByteArrayLiteral("size_bdiag"), + QByteArrayLiteral("fcf1c3c7cd4491d801f1e1c78f100000"), + QByteArrayLiteral("fd_double_arrow"), + QByteArrayLiteral("bottom_left_corner"), + }, + }, + { + QByteArrayLiteral("se-resize"), + { + QByteArrayLiteral("size_fdiag"), + QByteArrayLiteral("c7088f0f3e6c8088236ef8e1e3e70000"), + QByteArrayLiteral("bd_double_arrow"), + QByteArrayLiteral("bottom_right_corner"), + }, + }, + { + QByteArrayLiteral("ne-resize"), + { + QByteArrayLiteral("size_bdiag"), + QByteArrayLiteral("fcf1c3c7cd4491d801f1e1c78f100000"), + QByteArrayLiteral("fd_double_arrow"), + QByteArrayLiteral("top_right_corner"), + }, + }, + { + QByteArrayLiteral("nw-resize"), + { + QByteArrayLiteral("size_fdiag"), + QByteArrayLiteral("c7088f0f3e6c8088236ef8e1e3e70000"), + QByteArrayLiteral("bd_double_arrow"), + QByteArrayLiteral("top_left_corner"), + }, + }, + { + QByteArrayLiteral("n-resize"), + { + QByteArrayLiteral("size_ver"), + QByteArrayLiteral("00008160000006810000408080010102"), + QByteArrayLiteral("sb_v_double_arrow"), + QByteArrayLiteral("v_double_arrow"), + QByteArrayLiteral("col-resize"), + QByteArrayLiteral("top_side"), + }, + }, + { + QByteArrayLiteral("e-resize"), + { + QByteArrayLiteral("size_hor"), + QByteArrayLiteral("028006030e0e7ebffc7f7070c0600140"), + QByteArrayLiteral("sb_h_double_arrow"), + QByteArrayLiteral("h_double_arrow"), + QByteArrayLiteral("row-resize"), + QByteArrayLiteral("left_side"), + }, + }, + { + QByteArrayLiteral("s-resize"), + { + QByteArrayLiteral("size_ver"), + QByteArrayLiteral("00008160000006810000408080010102"), + QByteArrayLiteral("sb_v_double_arrow"), + QByteArrayLiteral("v_double_arrow"), + QByteArrayLiteral("col-resize"), + QByteArrayLiteral("bottom_side"), + }, + }, + { + QByteArrayLiteral("w-resize"), + { + QByteArrayLiteral("size_hor"), + QByteArrayLiteral("028006030e0e7ebffc7f7070c0600140"), + QByteArrayLiteral("sb_h_double_arrow"), + QByteArrayLiteral("h_double_arrow"), + QByteArrayLiteral("right_side"), + }, + }, }; auto it = alternatives.find(name); if (it != alternatives.end()) { @@ -518,7 +663,7 @@ QByteArray CursorShape::name() const case Qt::DragLinkCursor: return QByteArrayLiteral("dnd-link"); case KWin::ExtendedCursor::SizeNorthEast: - return QByteArrayLiteral("ne-resize"); + return QByteArrayLiteral("ne-resize"); case KWin::ExtendedCursor::SizeNorth: return QByteArrayLiteral("n-resize"); case KWin::ExtendedCursor::SizeNorthWest: @@ -539,7 +684,8 @@ QByteArray CursorShape::name() const } InputConfig *InputConfig::s_self = nullptr; -InputConfig *InputConfig::self() { +InputConfig *InputConfig::self() +{ if (!s_self) s_self = new InputConfig; return s_self; diff --git a/src/cursor.h b/src/cursor.h index 46ec5a7ceb..ee8bf377bf 100644 --- a/src/cursor.h +++ b/src/cursor.h @@ -1,4 +1,4 @@ - /* +/* KWin - the KDE window manager This file is part of the KDE project. @@ -26,7 +26,8 @@ namespace KWin class AbstractOutput; -namespace ExtendedCursor { +namespace ExtendedCursor +{ /** * Extension of Qt::CursorShape with values not currently present there */ @@ -45,25 +46,31 @@ enum Shape { /** * @brief Wrapper round Qt::CursorShape with extensions enums into a single entity */ -class KWIN_EXPORT CursorShape { +class KWIN_EXPORT CursorShape +{ public: CursorShape() = default; - CursorShape(Qt::CursorShape qtShape) { + CursorShape(Qt::CursorShape qtShape) + { m_shape = qtShape; } - CursorShape(KWin::ExtendedCursor::Shape kwinShape) { + CursorShape(KWin::ExtendedCursor::Shape kwinShape) + { m_shape = kwinShape; } - bool operator==(const CursorShape &o) const { + bool operator==(const CursorShape &o) const + { return m_shape == o.m_shape; } - operator int() const { + 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; }; @@ -90,7 +97,7 @@ class KWIN_EXPORT Cursor : public QObject { Q_OBJECT public: - Cursor(QObject* parent); + Cursor(QObject *parent); ~Cursor() override; void startMousePolling(); void stopMousePolling(); @@ -162,8 +169,14 @@ public: */ xcb_cursor_t x11Cursor(const QByteArray &name); - QImage image() const { return m_image; } - QPoint hotspot() const { return m_hotspot; } + QImage image() const + { + return m_image; + } + QPoint hotspot() const + { + return m_hotspot; + } QRect geometry() const; QRect rect() const; @@ -176,8 +189,8 @@ public: void markAsRendered(std::chrono::milliseconds timestamp); Q_SIGNALS: - void posChanged(const QPoint& pos); - void mouseChanged(const QPoint& pos, const QPoint& oldpos, + void posChanged(const QPoint &pos); + void mouseChanged(const QPoint &pos, const QPoint &oldpos, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); /** @@ -243,7 +256,7 @@ private Q_SLOTS: private: void updateTheme(const QString &name, int size); void loadThemeFromKConfig(); - QHash m_cursors; + QHash m_cursors; QPoint m_pos; QPoint m_hotspot; QImage m_image; @@ -253,16 +266,17 @@ private: int m_themeSize; }; - class KWIN_EXPORT Cursors : public QObject { Q_OBJECT public: - Cursor* mouse() const { + Cursor *mouse() const + { return m_mouse; } - void setMouse(Cursor* mouse) { + void setMouse(Cursor *mouse) + { if (m_mouse != mouse) { m_mouse = mouse; @@ -271,11 +285,12 @@ public: } } - void addCursor(Cursor* cursor); - void removeCursor(Cursor* cursor); + void addCursor(Cursor *cursor); + void removeCursor(Cursor *cursor); ///@returns the last cursor that moved - Cursor* currentCursor() const { + Cursor *currentCursor() const + { return m_currentCursor; } @@ -283,35 +298,38 @@ public: void showCursor(); bool isCursorHidden() const; - static Cursors* self(); + static Cursors *self(); Q_SIGNALS: - void currentCursorChanged(Cursor* cursor); + void currentCursorChanged(Cursor *cursor); void hiddenChanged(); - void positionChanged(Cursor* cursor, const QPoint &position); + void positionChanged(Cursor *cursor, const QPoint &position); private: void emitCurrentCursorChanged(); - void setCurrentCursor(Cursor* cursor); + void setCurrentCursor(Cursor *cursor); - static Cursors* s_self; - Cursor* m_currentCursor = nullptr; - Cursor* m_mouse = nullptr; - QVector m_cursors; + static Cursors *s_self; + Cursor *m_currentCursor = nullptr; + Cursor *m_mouse = nullptr; + QVector m_cursors; int m_cursorHideCounter = 0; }; class InputConfig { public: - KSharedConfigPtr inputConfig() const { + KSharedConfigPtr inputConfig() const + { return m_inputConfig; } - void setInputConfig(KSharedConfigPtr config) { + void setInputConfig(KSharedConfigPtr config) + { m_inputConfig = std::move(config); } static InputConfig *self(); + private: InputConfig(); @@ -329,7 +347,7 @@ inline void Cursor::updatePos(int x, int y) updatePos(QPoint(x, y)); } -inline const QString& Cursor::themeName() const +inline const QString &Cursor::themeName() const { return m_themeName; } diff --git a/src/dbusinterface.cpp b/src/dbusinterface.cpp index 9048025843..bd28ed7951 100644 --- a/src/dbusinterface.cpp +++ b/src/dbusinterface.cpp @@ -18,22 +18,22 @@ #include "atoms.h" #include "composite.h" #include "debug_console.h" +#include "kwinadaptor.h" #include "main.h" #include "placement.h" #include "platform.h" #include "pluginmanager.h" #include "renderbackend.h" -#include "kwinadaptor.h" #include "unmanaged.h" -#include "workspace.h" #include "virtualdesktops.h" +#include "workspace.h" #if KWIN_BUILD_ACTIVITIES #include "activities.h" #endif // Qt -#include #include +#include namespace KWin { @@ -42,7 +42,7 @@ DBusInterface::DBusInterface(QObject *parent) : QObject(parent) , m_serviceName(QStringLiteral("org.kde.KWin")) { - (void) new KWinAdaptor(this); + (void)new KWinAdaptor(this); QDBusConnection dbus = QDBusConnection::sessionBus(); dbus.registerObject(QStringLiteral("/KWin"), this); @@ -92,11 +92,11 @@ void DBusInterface::announceService() } // wrap void methods with no arguments to Workspace -#define WRAP(name) \ -void DBusInterface::name() \ -{\ - Workspace::self()->name();\ -} +#define WRAP(name) \ + void DBusInterface::name() \ + { \ + Workspace::self()->name(); \ + } WRAP(reconfigure) @@ -107,11 +107,11 @@ void DBusInterface::killWindow() Workspace::self()->slotKillWindow(); } -#define WRAP(name) \ -void DBusInterface::name() \ -{\ - Placement::self()->name();\ -} +#define WRAP(name) \ + void DBusInterface::name() \ + { \ + Placement::self()->name(); \ + } WRAP(cascadeDesktop) WRAP(unclutterDesktop) @@ -119,11 +119,11 @@ WRAP(unclutterDesktop) #undef WRAP // wrap returning methods with no arguments to Workspace -#define WRAP( rettype, name ) \ -rettype DBusInterface::name( ) \ -{\ - return Workspace::self()->name(); \ -} +#define WRAP(rettype, name) \ + rettype DBusInterface::name() \ + { \ + return Workspace::self()->name(); \ + } WRAP(QString, supportInformation) @@ -186,36 +186,38 @@ void DBusInterface::replace() QCoreApplication::exit(133); } -namespace { +namespace +{ QVariantMap clientToVariantMap(const AbstractClient *c) { - return { + return + { {QStringLiteral("resourceClass"), c->resourceClass()}, - {QStringLiteral("resourceName"), c->resourceName()}, - {QStringLiteral("desktopFile"), c->desktopFileName()}, - {QStringLiteral("role"), c->windowRole()}, - {QStringLiteral("caption"), c->captionNormal()}, - {QStringLiteral("clientMachine"), c->wmClientMachine(true)}, - {QStringLiteral("localhost"), c->isLocalhost()}, - {QStringLiteral("type"), c->windowType()}, - {QStringLiteral("x"), c->x()}, - {QStringLiteral("y"), c->y()}, - {QStringLiteral("width"), c->width()}, - {QStringLiteral("height"), c->height()}, - {QStringLiteral("desktops"), c->desktopIds()}, - {QStringLiteral("minimized"), c->isMinimized()}, - {QStringLiteral("shaded"), c->isShade()}, - {QStringLiteral("fullscreen"), c->isFullScreen()}, - {QStringLiteral("keepAbove"), c->keepAbove()}, - {QStringLiteral("keepBelow"), c->keepBelow()}, - {QStringLiteral("noBorder"), c->noBorder()}, - {QStringLiteral("skipTaskbar"), c->skipTaskbar()}, - {QStringLiteral("skipPager"), c->skipPager()}, - {QStringLiteral("skipSwitcher"), c->skipSwitcher()}, - {QStringLiteral("maximizeHorizontal"), c->maximizeMode() & MaximizeHorizontal}, - {QStringLiteral("maximizeVertical"), c->maximizeMode() & MaximizeVertical}, + {QStringLiteral("resourceName"), c->resourceName()}, + {QStringLiteral("desktopFile"), c->desktopFileName()}, + {QStringLiteral("role"), c->windowRole()}, + {QStringLiteral("caption"), c->captionNormal()}, + {QStringLiteral("clientMachine"), c->wmClientMachine(true)}, + {QStringLiteral("localhost"), c->isLocalhost()}, + {QStringLiteral("type"), c->windowType()}, + {QStringLiteral("x"), c->x()}, + {QStringLiteral("y"), c->y()}, + {QStringLiteral("width"), c->width()}, + {QStringLiteral("height"), c->height()}, + {QStringLiteral("desktops"), c->desktopIds()}, + {QStringLiteral("minimized"), c->isMinimized()}, + {QStringLiteral("shaded"), c->isShade()}, + {QStringLiteral("fullscreen"), c->isFullScreen()}, + {QStringLiteral("keepAbove"), c->keepAbove()}, + {QStringLiteral("keepBelow"), c->keepBelow()}, + {QStringLiteral("noBorder"), c->noBorder()}, + {QStringLiteral("skipTaskbar"), c->skipTaskbar()}, + {QStringLiteral("skipPager"), c->skipPager()}, + {QStringLiteral("skipSwitcher"), c->skipSwitcher()}, + {QStringLiteral("maximizeHorizontal"), c->maximizeMode() & MaximizeHorizontal}, + {QStringLiteral("maximizeVertical"), c->maximizeMode() & MaximizeVertical}, #if KWIN_BUILD_ACTIVITIES - {QStringLiteral("activities"), c->activities()}, + {QStringLiteral("activities"), c->activities()}, #endif }; } @@ -226,10 +228,10 @@ QVariantMap DBusInterface::queryWindowInfo() m_replyQueryWindowInfo = message(); setDelayedReply(true); kwinApp()->platform()->startInteractiveWindowSelection( - [this] (Toplevel *t) { - if (auto c = qobject_cast(t)) { + [this](Toplevel *t) { + if (auto c = qobject_cast(t)) { QDBusConnection::sessionBus().send(m_replyQueryWindowInfo.createReply(clientToVariantMap(c))); - } else if (qobject_cast(t)) { + } else if (qobject_cast(t)) { QDBusConnection::sessionBus().send(m_replyQueryWindowInfo.createErrorReply( QStringLiteral("org.kde.KWin.Error.InvalidWindow"), QStringLiteral("Tried to query information about an unmanaged window"))); @@ -238,15 +240,16 @@ QVariantMap DBusInterface::queryWindowInfo() QStringLiteral("org.kde.KWin.Error.UserCancel"), QStringLiteral("User cancelled the query"))); } - } - ); + }); return QVariantMap{}; } QVariantMap DBusInterface::getWindowInfo(const QString &uuid) { const auto id = QUuid::fromString(uuid); - const auto client = workspace()->findAbstractClient([&id] (const AbstractClient *c) { return c->internalId() == id; }); + const auto client = workspace()->findAbstractClient([&id](const AbstractClient *c) { + return c->internalId() == id; + }); if (client) { return clientToVariantMap(client); } else { @@ -314,14 +317,14 @@ bool CompositorDBusInterface::platformRequiresCompositing() const void CompositorDBusInterface::resume() { if (kwinApp()->operationMode() == Application::OperationModeX11) { - static_cast(m_compositor)->resume(X11Compositor::ScriptSuspend); + static_cast(m_compositor)->resume(X11Compositor::ScriptSuspend); } } void CompositorDBusInterface::suspend() { if (kwinApp()->operationMode() == Application::OperationModeX11) { - static_cast(m_compositor)->suspend(X11Compositor::ScriptSuspend); + static_cast(m_compositor)->suspend(X11Compositor::ScriptSuspend); } } @@ -347,9 +350,6 @@ QStringList CompositorDBusInterface::supportedOpenGLPlatformInterfaces() const return interfaces; } - - - VirtualDesktopManagerDBusInterface::VirtualDesktopManagerDBusInterface(VirtualDesktopManager *parent) : QObject(parent) , m_manager(parent) @@ -359,78 +359,59 @@ VirtualDesktopManagerDBusInterface::VirtualDesktopManagerDBusInterface(VirtualDe new VirtualDesktopManagerAdaptor(this); QDBusConnection::sessionBus().registerObject(QStringLiteral("/VirtualDesktopManager"), - QStringLiteral("org.kde.KWin.VirtualDesktopManager"), - this - ); + QStringLiteral("org.kde.KWin.VirtualDesktopManager"), + this); - connect(m_manager, &VirtualDesktopManager::currentChanged, this, - [this](uint previousDesktop, uint newDesktop) { - Q_UNUSED(previousDesktop); - Q_UNUSED(newDesktop); - Q_EMIT currentChanged(m_manager->currentDesktop()->id()); - } - ); + connect(m_manager, &VirtualDesktopManager::currentChanged, this, [this](uint previousDesktop, uint newDesktop) { + Q_UNUSED(previousDesktop); + Q_UNUSED(newDesktop); + Q_EMIT currentChanged(m_manager->currentDesktop()->id()); + }); - connect(m_manager, &VirtualDesktopManager::countChanged, this, - [this](uint previousCount, uint newCount) { - Q_UNUSED(previousCount); - Q_EMIT countChanged(newCount); - Q_EMIT desktopsChanged(desktops()); - } - ); + connect(m_manager, &VirtualDesktopManager::countChanged, this, [this](uint previousCount, uint newCount) { + Q_UNUSED(previousCount); + Q_EMIT countChanged(newCount); + Q_EMIT desktopsChanged(desktops()); + }); - connect(m_manager, &VirtualDesktopManager::navigationWrappingAroundChanged, this, - [this]() { - Q_EMIT navigationWrappingAroundChanged(isNavigationWrappingAround()); - } - ); + connect(m_manager, &VirtualDesktopManager::navigationWrappingAroundChanged, this, [this]() { + Q_EMIT navigationWrappingAroundChanged(isNavigationWrappingAround()); + }); connect(m_manager, &VirtualDesktopManager::rowsChanged, this, &VirtualDesktopManagerDBusInterface::rowsChanged); const QVector allDesks = m_manager->desktops(); for (auto *vd : allDesks) { - connect(vd, &VirtualDesktop::x11DesktopNumberChanged, this, - [this, vd]() { - DBusDesktopDataStruct data{.position = vd->x11DesktopNumber() - 1, .id = vd->id(), .name = vd->name()}; - Q_EMIT desktopDataChanged(vd->id(), data); - Q_EMIT desktopsChanged(desktops()); - } - ); - connect(vd, &VirtualDesktop::nameChanged, this, - [this, vd]() { - DBusDesktopDataStruct data{.position = vd->x11DesktopNumber() - 1, .id = vd->id(), .name = vd->name()}; - Q_EMIT desktopDataChanged(vd->id(), data); - Q_EMIT desktopsChanged(desktops()); - } - ); - } - connect(m_manager, &VirtualDesktopManager::desktopCreated, this, - [this](VirtualDesktop *vd) { - connect(vd, &VirtualDesktop::x11DesktopNumberChanged, this, - [this, vd]() { - DBusDesktopDataStruct data{.position = vd->x11DesktopNumber() - 1, .id = vd->id(), .name = vd->name()}; - Q_EMIT desktopDataChanged(vd->id(), data); - Q_EMIT desktopsChanged(desktops()); - } - ); - connect(vd, &VirtualDesktop::nameChanged, this, - [this, vd]() { - DBusDesktopDataStruct data{.position = vd->x11DesktopNumber() - 1, .id = vd->id(), .name = vd->name()}; - Q_EMIT desktopDataChanged(vd->id(), data); - Q_EMIT desktopsChanged(desktops()); - } - ); + connect(vd, &VirtualDesktop::x11DesktopNumberChanged, this, [this, vd]() { DBusDesktopDataStruct data{.position = vd->x11DesktopNumber() - 1, .id = vd->id(), .name = vd->name()}; - Q_EMIT desktopCreated(vd->id(), data); + Q_EMIT desktopDataChanged(vd->id(), data); Q_EMIT desktopsChanged(desktops()); - } - ); - connect(m_manager, &VirtualDesktopManager::desktopRemoved, this, - [this](VirtualDesktop *vd) { - Q_EMIT desktopRemoved(vd->id()); + }); + connect(vd, &VirtualDesktop::nameChanged, this, [this, vd]() { + DBusDesktopDataStruct data{.position = vd->x11DesktopNumber() - 1, .id = vd->id(), .name = vd->name()}; + Q_EMIT desktopDataChanged(vd->id(), data); Q_EMIT desktopsChanged(desktops()); - } - ); + }); + } + connect(m_manager, &VirtualDesktopManager::desktopCreated, this, [this](VirtualDesktop *vd) { + connect(vd, &VirtualDesktop::x11DesktopNumberChanged, this, [this, vd]() { + DBusDesktopDataStruct data{.position = vd->x11DesktopNumber() - 1, .id = vd->id(), .name = vd->name()}; + Q_EMIT desktopDataChanged(vd->id(), data); + Q_EMIT desktopsChanged(desktops()); + }); + connect(vd, &VirtualDesktop::nameChanged, this, [this, vd]() { + DBusDesktopDataStruct data{.position = vd->x11DesktopNumber() - 1, .id = vd->id(), .name = vd->name()}; + Q_EMIT desktopDataChanged(vd->id(), data); + Q_EMIT desktopsChanged(desktops()); + }); + DBusDesktopDataStruct data{.position = vd->x11DesktopNumber() - 1, .id = vd->id(), .name = vd->name()}; + Q_EMIT desktopCreated(vd->id(), data); + Q_EMIT desktopsChanged(desktops()); + }); + connect(m_manager, &VirtualDesktopManager::desktopRemoved, this, [this](VirtualDesktop *vd) { + Q_EMIT desktopRemoved(vd->id()); + Q_EMIT desktopsChanged(desktops()); + }); } uint VirtualDesktopManagerDBusInterface::count() const @@ -491,11 +472,10 @@ DBusDesktopDataVector VirtualDesktopManagerDBusInterface::desktops() const desktopVect.reserve(m_manager->count()); std::transform(desks.constBegin(), desks.constEnd(), - std::back_inserter(desktopVect), - [] (const VirtualDesktop *vd) { - return DBusDesktopDataStruct{.position = vd->x11DesktopNumber() - 1, .id = vd->id(), .name = vd->name()}; - } - ); + std::back_inserter(desktopVect), + [](const VirtualDesktop *vd) { + return DBusDesktopDataStruct{.position = vd->x11DesktopNumber() - 1, .id = vd->id(), .name = vd->name()}; + }); return desktopVect; } diff --git a/src/dbusinterface.h b/src/dbusinterface.h index f123ce82be..95157e12c6 100644 --- a/src/dbusinterface.h +++ b/src/dbusinterface.h @@ -36,7 +36,7 @@ class VirtualDesktopManager; * * @author Martin Gräßlin */ -class DBusInterface: public QObject, protected QDBusContext +class DBusInterface : public QObject, protected QDBusContext { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.KWin") @@ -58,29 +58,29 @@ public Q_SLOTS: // METHODS QString supportInformation(); Q_NOREPLY void unclutterDesktop(); Q_NOREPLY void showDebugConsole(); - - /** + + /** * Instructs kwin_wayland to restart itself. - * + * * This acts as an implementation detail of: kwin_wayland --replace */ Q_NOREPLY void replace(); - /** + /** * Allows the user to pick a window and get info on it. - * + * * When called the user's mouse cursor will become a targeting reticule. * On clicking a window with the target a map will be returned - * with various information about the picked window, such as: + * with various information about the picked window, such as: * height, width, minimized, fullscreen, etc. */ QVariantMap queryWindowInfo(); - /** + /** * Returns a map with information about the window. - * + * * The map includes entries such as position, size, status, and more. - * + * * @param uuid is a QUuid from Toplevel::internalId(). */ QVariantMap getWindowInfo(const QString &uuid); @@ -200,7 +200,7 @@ private: Compositor *m_compositor; }; -//TODO: disable all of this in case of kiosk? +// TODO: disable all of this in case of kiosk? class VirtualDesktopManagerDBusInterface : public QObject { diff --git a/src/debug_console.cpp b/src/debug_console.cpp index e76a653853..5c1bd41883 100644 --- a/src/debug_console.cpp +++ b/src/debug_console.cpp @@ -20,9 +20,9 @@ #include "waylandclient.h" #include "workspace.h" #include "x11client.h" +#include #include #include -#include #include "ui_debug_console.h" @@ -61,15 +61,13 @@ namespace KWin { - static QString tableHeaderRow(const QString &title) { return QStringLiteral("%1").arg(title); } template -static -QString tableRow(const QString &title, const T &argument) +static QString tableRow(const QString &title, const T &argument) { return QStringLiteral("%1%2").arg(title).arg(argument); } @@ -87,60 +85,60 @@ static QString timestampRowUsec(quint64 timestamp) static QString buttonToString(Qt::MouseButton button) { switch (button) { - case Qt::LeftButton: - return i18nc("A mouse button", "Left"); - case Qt::RightButton: - return i18nc("A mouse button", "Right"); - case Qt::MiddleButton: - return i18nc("A mouse button", "Middle"); - case Qt::BackButton: - return i18nc("A mouse button", "Back"); - case Qt::ForwardButton: - return i18nc("A mouse button", "Forward"); - case Qt::TaskButton: - return i18nc("A mouse button", "Task"); - case Qt::ExtraButton4: - return i18nc("A mouse button", "Extra Button 4"); - case Qt::ExtraButton5: - return i18nc("A mouse button", "Extra Button 5"); - case Qt::ExtraButton6: - return i18nc("A mouse button", "Extra Button 6"); - case Qt::ExtraButton7: - return i18nc("A mouse button", "Extra Button 7"); - case Qt::ExtraButton8: - return i18nc("A mouse button", "Extra Button 8"); - case Qt::ExtraButton9: - return i18nc("A mouse button", "Extra Button 9"); - case Qt::ExtraButton10: - return i18nc("A mouse button", "Extra Button 10"); - case Qt::ExtraButton11: - return i18nc("A mouse button", "Extra Button 11"); - case Qt::ExtraButton12: - return i18nc("A mouse button", "Extra Button 12"); - case Qt::ExtraButton13: - return i18nc("A mouse button", "Extra Button 13"); - case Qt::ExtraButton14: - return i18nc("A mouse button", "Extra Button 14"); - case Qt::ExtraButton15: - return i18nc("A mouse button", "Extra Button 15"); - case Qt::ExtraButton16: - return i18nc("A mouse button", "Extra Button 16"); - case Qt::ExtraButton17: - return i18nc("A mouse button", "Extra Button 17"); - case Qt::ExtraButton18: - return i18nc("A mouse button", "Extra Button 18"); - case Qt::ExtraButton19: - return i18nc("A mouse button", "Extra Button 19"); - case Qt::ExtraButton20: - return i18nc("A mouse button", "Extra Button 20"); - case Qt::ExtraButton21: - return i18nc("A mouse button", "Extra Button 21"); - case Qt::ExtraButton22: - return i18nc("A mouse button", "Extra Button 22"); - case Qt::ExtraButton23: - return i18nc("A mouse button", "Extra Button 23"); - case Qt::ExtraButton24: - return i18nc("A mouse button", "Extra Button 24"); + case Qt::LeftButton: + return i18nc("A mouse button", "Left"); + case Qt::RightButton: + return i18nc("A mouse button", "Right"); + case Qt::MiddleButton: + return i18nc("A mouse button", "Middle"); + case Qt::BackButton: + return i18nc("A mouse button", "Back"); + case Qt::ForwardButton: + return i18nc("A mouse button", "Forward"); + case Qt::TaskButton: + return i18nc("A mouse button", "Task"); + case Qt::ExtraButton4: + return i18nc("A mouse button", "Extra Button 4"); + case Qt::ExtraButton5: + return i18nc("A mouse button", "Extra Button 5"); + case Qt::ExtraButton6: + return i18nc("A mouse button", "Extra Button 6"); + case Qt::ExtraButton7: + return i18nc("A mouse button", "Extra Button 7"); + case Qt::ExtraButton8: + return i18nc("A mouse button", "Extra Button 8"); + case Qt::ExtraButton9: + return i18nc("A mouse button", "Extra Button 9"); + case Qt::ExtraButton10: + return i18nc("A mouse button", "Extra Button 10"); + case Qt::ExtraButton11: + return i18nc("A mouse button", "Extra Button 11"); + case Qt::ExtraButton12: + return i18nc("A mouse button", "Extra Button 12"); + case Qt::ExtraButton13: + return i18nc("A mouse button", "Extra Button 13"); + case Qt::ExtraButton14: + return i18nc("A mouse button", "Extra Button 14"); + case Qt::ExtraButton15: + return i18nc("A mouse button", "Extra Button 15"); + case Qt::ExtraButton16: + return i18nc("A mouse button", "Extra Button 16"); + case Qt::ExtraButton17: + return i18nc("A mouse button", "Extra Button 17"); + case Qt::ExtraButton18: + return i18nc("A mouse button", "Extra Button 18"); + case Qt::ExtraButton19: + return i18nc("A mouse button", "Extra Button 19"); + case Qt::ExtraButton20: + return i18nc("A mouse button", "Extra Button 20"); + case Qt::ExtraButton21: + return i18nc("A mouse button", "Extra Button 21"); + case Qt::ExtraButton22: + return i18nc("A mouse button", "Extra Button 22"); + case Qt::ExtraButton23: + return i18nc("A mouse button", "Extra Button 23"); + case Qt::ExtraButton24: + return i18nc("A mouse button", "Extra Button 24"); default: return QString(); } @@ -208,7 +206,7 @@ void DebugConsoleFilter::pointerEvent(MouseEvent *event) text.append(deviceRow(event->device())); text.append(timestamp); text.append(tableRow(i18nc("A button in a mouse press/release event", "Button"), buttonToString(event->button()))); - text.append(tableRow(i18nc("A button in a mouse press/release event", "Native Button code"), event->nativeButton())); + text.append(tableRow(i18nc("A button in a mouse press/release event", "Native Button code"), event->nativeButton())); text.append(tableRow(i18nc("All currently pressed buttons in a mouse press/release event", "Pressed Buttons"), buttonsToString(event->buttons()))); break; case QEvent::MouseButtonRelease: @@ -500,16 +498,16 @@ void DebugConsoleFilter::tabletToolEvent(TabletEvent *event) } QString text = s_hr + s_tableStart + tableHeaderRow(i18n("Tablet Tool")) - + tableRow(i18n("EventType"), typeString) - + tableRow(i18n("Position"), - QStringLiteral("%1,%2").arg(event->pos().x()).arg(event->pos().y())) - + tableRow(i18n("Tilt"), - QStringLiteral("%1,%2").arg(event->xTilt()).arg(event->yTilt())) - + tableRow(i18n("Rotation"), QString::number(event->rotation())) - + tableRow(i18n("Pressure"), QString::number(event->pressure())) - + tableRow(i18n("Buttons"), QString::number(event->buttons())) - + tableRow(i18n("Modifiers"), QString::number(event->modifiers())) - + s_tableEnd; + + tableRow(i18n("EventType"), typeString) + + tableRow(i18n("Position"), + QStringLiteral("%1,%2").arg(event->pos().x()).arg(event->pos().y())) + + tableRow(i18n("Tilt"), + QStringLiteral("%1,%2").arg(event->xTilt()).arg(event->yTilt())) + + tableRow(i18n("Rotation"), QString::number(event->rotation())) + + tableRow(i18n("Pressure"), QString::number(event->pressure())) + + tableRow(i18n("Buttons"), QString::number(event->buttons())) + + tableRow(i18n("Modifiers"), QString::number(event->modifiers())) + + s_tableEnd; m_textEdit->insertHtml(text); m_textEdit->ensureCursorVisible(); @@ -518,10 +516,10 @@ void DebugConsoleFilter::tabletToolEvent(TabletEvent *event) void DebugConsoleFilter::tabletToolButtonEvent(uint button, bool pressed, const TabletToolId &tabletToolId) { QString text = s_hr + s_tableStart + tableHeaderRow(i18n("Tablet Tool Button")) - + tableRow(i18n("Button"), button) - + tableRow(i18n("Pressed"), pressed) - + tableRow(i18n("Tablet"), qHash(tabletToolId.m_deviceGroupData)) - + s_tableEnd; + + tableRow(i18n("Button"), button) + + tableRow(i18n("Pressed"), pressed) + + tableRow(i18n("Tablet"), qHash(tabletToolId.m_deviceGroupData)) + + s_tableEnd; m_textEdit->insertHtml(text); m_textEdit->ensureCursorVisible(); @@ -530,11 +528,11 @@ void DebugConsoleFilter::tabletToolButtonEvent(uint button, bool pressed, const void DebugConsoleFilter::tabletPadButtonEvent(uint button, bool pressed, const TabletPadId &tabletPadId) { QString text = s_hr + s_tableStart - + tableHeaderRow(i18n("Tablet Pad Button")) - + tableRow(i18n("Button"), button) - + tableRow(i18n("Pressed"), pressed) - + tableRow(i18n("Tablet"), qHash(tabletPadId.data)) - + s_tableEnd; + + tableHeaderRow(i18n("Tablet Pad Button")) + + tableRow(i18n("Button"), button) + + tableRow(i18n("Pressed"), pressed) + + tableRow(i18n("Tablet"), qHash(tabletPadId.data)) + + s_tableEnd; m_textEdit->insertHtml(text); m_textEdit->ensureCursorVisible(); @@ -543,11 +541,11 @@ void DebugConsoleFilter::tabletPadButtonEvent(uint button, bool pressed, const T void DebugConsoleFilter::tabletPadStripEvent(int number, int position, bool isFinger, const TabletPadId &tabletPadId) { QString text = s_hr + s_tableStart + tableHeaderRow(i18n("Tablet Pad Strip")) - + tableRow(i18n("Number"), number) - + tableRow(i18n("Position"), position) - + tableRow(i18n("isFinger"), isFinger) - + tableRow(i18n("Tablet"), qHash(tabletPadId.data)) - + s_tableEnd; + + tableRow(i18n("Number"), number) + + tableRow(i18n("Position"), position) + + tableRow(i18n("isFinger"), isFinger) + + tableRow(i18n("Tablet"), qHash(tabletPadId.data)) + + s_tableEnd; m_textEdit->insertHtml(text); m_textEdit->ensureCursorVisible(); @@ -556,11 +554,11 @@ void DebugConsoleFilter::tabletPadStripEvent(int number, int position, bool isFi void DebugConsoleFilter::tabletPadRingEvent(int number, int position, bool isFinger, const TabletPadId &tabletPadId) { QString text = s_hr + s_tableStart + tableHeaderRow(i18n("Tablet Pad Ring")) - + tableRow(i18n("Number"), number) - + tableRow(i18n("Position"), position) - + tableRow(i18n("isFinger"), isFinger) - + tableRow(i18n("Tablet"), qHash(tabletPadId.data)) - + s_tableEnd; + + tableRow(i18n("Number"), number) + + tableRow(i18n("Position"), position) + + tableRow(i18n("isFinger"), isFinger) + + tableRow(i18n("Tablet"), qHash(tabletPadId.data)) + + s_tableEnd; m_textEdit->insertHtml(text); m_textEdit->ensureCursorVisible(); @@ -612,33 +610,31 @@ DebugConsole::DebugConsole() } connect(m_ui->quitButton, &QAbstractButton::clicked, this, &DebugConsole::deleteLater); - connect(m_ui->tabWidget, &QTabWidget::currentChanged, this, - [this] (int index) { - // delay creation of input event filter until the tab is selected - if (index == 2 && m_inputFilter.isNull()) { - m_inputFilter.reset(new DebugConsoleFilter(m_ui->inputTextEdit)); - input()->installInputEventSpy(m_inputFilter.data()); - } - if (index == 5) { - updateKeyboardTab(); - connect(input(), &InputRedirection::keyStateChanged, this, &DebugConsole::updateKeyboardTab); - } - if (index == 6) { - static_cast(m_ui->clipboardContent->model())->setSource(waylandServer()->seat()->selection()); - m_ui->clipboardSource->setText(sourceString(waylandServer()->seat()->selection())); - connect(waylandServer()->seat(), &KWaylandServer::SeatInterface::selectionChanged, this, [this](KWaylandServer::AbstractDataSource *source) { - static_cast(m_ui->clipboardContent->model())->setSource(source); - m_ui->clipboardSource->setText(sourceString(source)); - }); - static_cast(m_ui->primaryContent->model())->setSource(waylandServer()->seat()->primarySelection()); - m_ui->primarySource->setText(sourceString(waylandServer()->seat()->primarySelection())); - connect(waylandServer()->seat(), &KWaylandServer::SeatInterface::primarySelectionChanged, this, [this](KWaylandServer::AbstractDataSource *source) { - static_cast(m_ui->primaryContent->model())->setSource(source); - m_ui->primarySource->setText(sourceString(source)); - }); - } + connect(m_ui->tabWidget, &QTabWidget::currentChanged, this, [this](int index) { + // delay creation of input event filter until the tab is selected + if (index == 2 && m_inputFilter.isNull()) { + m_inputFilter.reset(new DebugConsoleFilter(m_ui->inputTextEdit)); + input()->installInputEventSpy(m_inputFilter.data()); } - ); + if (index == 5) { + updateKeyboardTab(); + connect(input(), &InputRedirection::keyStateChanged, this, &DebugConsole::updateKeyboardTab); + } + if (index == 6) { + static_cast(m_ui->clipboardContent->model())->setSource(waylandServer()->seat()->selection()); + m_ui->clipboardSource->setText(sourceString(waylandServer()->seat()->selection())); + connect(waylandServer()->seat(), &KWaylandServer::SeatInterface::selectionChanged, this, [this](KWaylandServer::AbstractDataSource *source) { + static_cast(m_ui->clipboardContent->model())->setSource(source); + m_ui->clipboardSource->setText(sourceString(source)); + }); + static_cast(m_ui->primaryContent->model())->setSource(waylandServer()->seat()->primarySelection()); + m_ui->primarySource->setText(sourceString(waylandServer()->seat()->primarySelection())); + connect(waylandServer()->seat(), &KWaylandServer::SeatInterface::primarySelectionChanged, this, [this](KWaylandServer::AbstractDataSource *source) { + static_cast(m_ui->primaryContent->model())->setSource(source); + m_ui->primarySource->setText(sourceString(source)); + }); + } + }); // for X11 setWindowFlags(Qt::X11BypassWindowManagerHint); @@ -667,7 +663,7 @@ void DebugConsole::initGLTab() m_ui->glVersionLabel->setText(GLPlatform::versionToString(gl->glVersion())); m_ui->glslLabel->setText(GLPlatform::versionToString(gl->glslVersion())); - auto extensionsString = [] (const auto &extensions) { + auto extensionsString = [](const auto &extensions) { QString text = QStringLiteral("

    "); for (auto extension : extensions) { text.append(QStringLiteral("
  • %1
  • ").arg(QString::fromLocal8Bit(extension))); @@ -680,8 +676,8 @@ void DebugConsole::initGLTab() m_ui->openGLExtensionsLabel->setText(extensionsString(openGLExtensions())); } -template -QString keymapComponentToString(xkb_keymap *map, const T &count, std::function f) +template +QString keymapComponentToString(xkb_keymap *map, const T &count, std::function f) { QString text = QStringLiteral("
      "); for (T i = 0; i < count; i++) { @@ -691,8 +687,8 @@ QString keymapComponentToString(xkb_keymap *map, const T &count, std::function -QString stateActiveComponents(xkb_state *state, const T &count, std::function f, std::function name) +template +QString stateActiveComponents(xkb_state *state, const T &count, std::function f, std::function name) { QString text = QStringLiteral("
        "); xkb_keymap *map = xkb_state_get_keymap(state); @@ -726,15 +722,13 @@ void DebugConsole::showEvent(QShowEvent *event) QWidget::showEvent(event); // delay the connection to the show event as in ctor the windowHandle returns null - connect(windowHandle(), &QWindow::visibleChanged, this, - [this] (bool visible) { - if (visible) { - // ignore - return; - } - deleteLater(); + connect(windowHandle(), &QWindow::visibleChanged, this, [this](bool visible) { + if (visible) { + // ignore + return; } - ); + deleteLater(); + }); } DebugConsoleDelegate::DebugConsoleDelegate(QObject *parent) @@ -768,8 +762,8 @@ QString DebugConsoleDelegate::displayText(const QVariant &value, const QLocale & return QStringLiteral("%1,%2 %3x%4").arg(r.x()).arg(r.y()).arg(r.width()).arg(r.height()); } default: - if (value.userType() == qMetaTypeId()) { - if (auto s = value.value()) { + if (value.userType() == qMetaTypeId()) { + if (auto s = value.value()) { return QStringLiteral("KWaylandServer::SurfaceInterface(0x%1)").arg(qulonglong(s), 0, 16); } else { return QStringLiteral("nullptr"); @@ -883,19 +877,19 @@ static const int s_x11UnmanagedId = 2; static const int s_waylandClientId = 3; static const int s_workspaceInternalId = 4; static const quint32 s_propertyBitMask = 0xFFFF0000; -static const quint32 s_clientBitMask = 0x0000FFFF; +static const quint32 s_clientBitMask = 0x0000FFFF; static const quint32 s_idDistance = 10000; -template -void DebugConsoleModel::add(int parentRow, QVector &clients, T *client) +template +void DebugConsoleModel::add(int parentRow, QVector &clients, T *client) { beginInsertRows(index(parentRow, 0, QModelIndex()), clients.count(), clients.count()); clients.append(client); endInsertRows(); } -template -void DebugConsoleModel::remove(int parentRow, QVector &clients, T *client) +template +void DebugConsoleModel::remove(int parentRow, QVector &clients, T *client) { const int remove = clients.indexOf(client); if (remove == -1) { @@ -920,29 +914,21 @@ DebugConsoleModel::DebugConsoleModel(QObject *parent) for (auto u : unmangeds) { m_unmanageds.append(u); } - connect(workspace(), &Workspace::unmanagedAdded, this, - [this] (Unmanaged *u) { - add(s_x11UnmanagedId -1, m_unmanageds, u); - } - ); - connect(workspace(), &Workspace::unmanagedRemoved, this, - [this] (Unmanaged *u) { - remove(s_x11UnmanagedId -1, m_unmanageds, u); - } - ); + connect(workspace(), &Workspace::unmanagedAdded, this, [this](Unmanaged *u) { + add(s_x11UnmanagedId - 1, m_unmanageds, u); + }); + connect(workspace(), &Workspace::unmanagedRemoved, this, [this](Unmanaged *u) { + remove(s_x11UnmanagedId - 1, m_unmanageds, u); + }); for (InternalClient *client : workspace()->internalClients()) { m_internalClients.append(client); } - connect(workspace(), &Workspace::internalClientAdded, this, - [this](InternalClient *client) { - add(s_workspaceInternalId -1, m_internalClients, client); - } - ); - connect(workspace(), &Workspace::internalClientRemoved, this, - [this](InternalClient *client) { - remove(s_workspaceInternalId -1, m_internalClients, client); - } - ); + connect(workspace(), &Workspace::internalClientAdded, this, [this](InternalClient *client) { + add(s_workspaceInternalId - 1, m_internalClients, client); + }); + connect(workspace(), &Workspace::internalClientRemoved, this, [this](InternalClient *client) { + remove(s_workspaceInternalId - 1, m_internalClients, client); + }); } void DebugConsoleModel::handleClientAdded(AbstractClient *client) @@ -988,8 +974,8 @@ int DebugConsoleModel::topLevelRowCount() const return kwinApp()->shouldUseWaylandForCompositing() ? 4 : 2; } -template -int DebugConsoleModel::propertyCount(const QModelIndex &parent, T *(DebugConsoleModel::*filter)(const QModelIndex&) const) const +template +int DebugConsoleModel::propertyCount(const QModelIndex &parent, T *(DebugConsoleModel::*filter)(const QModelIndex &) const) const { if (T *t = (this->*filter)(parent)) { return t->metaObject()->propertyCount(); @@ -1034,8 +1020,8 @@ int DebugConsoleModel::rowCount(const QModelIndex &parent) const return 0; } -template -QModelIndex DebugConsoleModel::indexForClient(int row, int column, const QVector &clients, int id) const +template +QModelIndex DebugConsoleModel::indexForClient(int row, int column, const QVector &clients, int id) const { if (column != 0) { return QModelIndex(); @@ -1046,8 +1032,8 @@ QModelIndex DebugConsoleModel::indexForClient(int row, int column, const QVector return createIndex(row, column, s_idDistance * id + row); } -template -QModelIndex DebugConsoleModel::indexForProperty(int row, int column, const QModelIndex &parent, T *(DebugConsoleModel::*filter)(const QModelIndex&) const) const +template +QModelIndex DebugConsoleModel::indexForProperty(int row, int column, const QModelIndex &parent, T *(DebugConsoleModel::*filter)(const QModelIndex &) const) const { if (T *t = (this->*filter)(parent)) { if (row >= t->metaObject()->propertyCount()) { @@ -1119,13 +1105,13 @@ QModelIndex DebugConsoleModel::parent(const QModelIndex &child) const return QModelIndex(); } if (child.internalId() < s_idDistance * (s_x11ClientId + 1)) { - return createIndex(s_x11ClientId -1, 0, s_x11ClientId); + return createIndex(s_x11ClientId - 1, 0, s_x11ClientId); } else if (child.internalId() < s_idDistance * (s_x11UnmanagedId + 1)) { - return createIndex(s_x11UnmanagedId -1, 0, s_x11UnmanagedId); + return createIndex(s_x11UnmanagedId - 1, 0, s_x11UnmanagedId); } else if (child.internalId() < s_idDistance * (s_waylandClientId + 1)) { - return createIndex(s_waylandClientId -1, 0, s_waylandClientId); + return createIndex(s_waylandClientId - 1, 0, s_waylandClientId); } else if (child.internalId() < s_idDistance * (s_workspaceInternalId + 1)) { - return createIndex(s_workspaceInternalId -1, 0, s_workspaceInternalId); + return createIndex(s_workspaceInternalId - 1, 0, s_workspaceInternalId); } return QModelIndex(); } @@ -1188,8 +1174,8 @@ QVariant DebugConsoleModel::propertyData(QObject *object, const QModelIndex &ind return QVariant(); } -template -QVariant DebugConsoleModel::clientData(const QModelIndex &index, int role, const QVector clients, const std::function &toString) const +template +QVariant DebugConsoleModel::clientData(const QModelIndex &index, int role, const QVector clients, const std::function &toString) const { if (index.row() >= clients.count()) { return QVariant(); @@ -1244,7 +1230,7 @@ QVariant DebugConsoleModel::data(const QModelIndex &index, int role) const return QVariant(); } - auto generic = [] (AbstractClient *c) -> QString { + auto generic = [](AbstractClient *c) -> QString { return c->caption() + QLatin1Char(' ') + QString::fromUtf8(c->metaObject()->className()); }; switch (index.parent().internalId()) { @@ -1275,7 +1261,7 @@ QVariant DebugConsoleModel::data(const QModelIndex &index, int role) const } template -static T *clientForIndex(const QModelIndex &index, const QVector &clients, int id) +static T *clientForIndex(const QModelIndex &index, const QVector &clients, int id) { const qint32 row = (index.internalId() & s_clientBitMask) - (s_idDistance * id); if (row < 0 || row >= clients.count()) { @@ -1322,18 +1308,16 @@ SurfaceTreeModel::SurfaceTreeModel(QObject *parent) auto monitor = new SubSurfaceMonitor(c->surface(), this); connect(monitor, &SubSurfaceMonitor::subSurfaceAdded, this, reset); connect(monitor, &SubSurfaceMonitor::subSurfaceRemoved, this, reset); - connect (c, &QObject::destroyed, monitor, &QObject::deleteLater); + connect(c, &QObject::destroyed, monitor, &QObject::deleteLater); }; for (auto c : workspace()->allClientList()) { watchSubsurfaces(c); } - connect(workspace(), &Workspace::clientAdded, this, - [reset, watchSubsurfaces] (AbstractClient *c) { - watchSubsurfaces(c); - reset(); - } - ); + connect(workspace(), &Workspace::clientAdded, this, [reset, watchSubsurfaces](AbstractClient *c) { + watchSubsurfaces(c); + reset(); + }); connect(workspace(), &Workspace::clientRemoved, this, reset); connect(workspace(), &Workspace::unmanagedAdded, this, reset); connect(workspace(), &Workspace::unmanagedRemoved, this, reset); @@ -1351,14 +1335,13 @@ int SurfaceTreeModel::rowCount(const QModelIndex &parent) const { if (parent.isValid()) { using namespace KWaylandServer; - if (SurfaceInterface *surface = static_cast(parent.internalPointer())) { + if (SurfaceInterface *surface = static_cast(parent.internalPointer())) { return surface->below().count() + surface->above().count(); } return 0; } // toplevel are all windows - return workspace()->allClientList().count() + - workspace()->unmanagedList().count(); + return workspace()->allClientList().count() + workspace()->unmanagedList().count(); } QModelIndex SurfaceTreeModel::index(int row, int column, const QModelIndex &parent) const @@ -1370,7 +1353,7 @@ QModelIndex SurfaceTreeModel::index(int row, int column, const QModelIndex &pare if (parent.isValid()) { using namespace KWaylandServer; - if (SurfaceInterface *surface = static_cast(parent.internalPointer())) { + if (SurfaceInterface *surface = static_cast(parent.internalPointer())) { int reference = 0; const auto &below = surface->below(); if (row < reference + below.count()) { @@ -1394,7 +1377,7 @@ QModelIndex SurfaceTreeModel::index(int row, int column, const QModelIndex &pare int reference = allClients.count(); const auto &unmanaged = workspace()->unmanagedList(); if (row < reference + unmanaged.count()) { - return createIndex(row, column, unmanaged.at(row-reference)->surface()); + return createIndex(row, column, unmanaged.at(row - reference)->surface()); } reference += unmanaged.count(); // not found @@ -1404,7 +1387,7 @@ QModelIndex SurfaceTreeModel::index(int row, int column, const QModelIndex &pare QModelIndex SurfaceTreeModel::parent(const QModelIndex &child) const { using namespace KWaylandServer; - if (SurfaceInterface *surface = static_cast(child.internalPointer())) { + if (SurfaceInterface *surface = static_cast(child.internalPointer())) { const auto &subsurface = surface->subSurface(); if (!subsurface) { // doesn't reference a subsurface, this is a top-level window @@ -1464,11 +1447,9 @@ QVariant SurfaceTreeModel::data(const QModelIndex &index, int role) const return QVariant(); } using namespace KWaylandServer; - if (SurfaceInterface *surface = static_cast(index.internalPointer())) { + if (SurfaceInterface *surface = static_cast(index.internalPointer())) { if (role == Qt::DisplayRole || role == Qt::ToolTipRole) { - return QStringLiteral("%1 (%2) - %3").arg(surface->client()->executablePath()) - .arg(surface->client()->processId()) - .arg(surface->id()); + return QStringLiteral("%1 (%2) - %3").arg(surface->client()->executablePath()).arg(surface->client()->processId()).arg(surface->id()); } else if (role == Qt::DecorationRole) { if (auto buffer = qobject_cast(surface->buffer())) { return buffer->data().scaled(QSize(64, 64), Qt::KeepAspectRatio); @@ -1486,30 +1467,25 @@ InputDeviceModel::InputDeviceModel(QObject *parent) setupDeviceConnections(*it); } - connect(input(), &InputRedirection::deviceAdded, this, - [this] (InputDevice *d) { - beginInsertRows(QModelIndex(), m_devices.count(), m_devices.count()); - m_devices << d; - setupDeviceConnections(d); - endInsertRows(); + connect(input(), &InputRedirection::deviceAdded, this, [this](InputDevice *d) { + beginInsertRows(QModelIndex(), m_devices.count(), m_devices.count()); + m_devices << d; + setupDeviceConnections(d); + endInsertRows(); + }); + connect(input(), &InputRedirection::deviceRemoved, this, [this](InputDevice *d) { + const int index = m_devices.indexOf(d); + if (index == -1) { + return; } - ); - connect(input(), &InputRedirection::deviceRemoved, this, - [this] (InputDevice *d) { - const int index = m_devices.indexOf(d); - if (index == -1) { - return; - } - beginRemoveRows(QModelIndex(), index, index); - m_devices.removeAt(index); - endRemoveRows(); - } - ); + beginRemoveRows(QModelIndex(), index, index); + m_devices.removeAt(index); + endRemoveRows(); + }); } InputDeviceModel::~InputDeviceModel() = default; - int InputDeviceModel::columnCount(const QModelIndex &parent) const { Q_UNUSED(parent) diff --git a/src/debug_console.h b/src/debug_console.h index 7bd91cc0ab..79c438d195 100644 --- a/src/debug_console.h +++ b/src/debug_console.h @@ -9,10 +9,10 @@ #ifndef KWIN_DEBUG_CONSOLE_H #define KWIN_DEBUG_CONSOLE_H -#include -#include #include "input.h" #include "input_event_spy.h" +#include +#include #include #include @@ -48,10 +48,9 @@ public: explicit DebugConsoleModel(QObject *parent = nullptr); ~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; + 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; @@ -60,19 +59,19 @@ private Q_SLOTS: void handleClientRemoved(AbstractClient *client); 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; + 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 std::function &toString) const; - template - void add(int parentRow, QVector &clients, T *client); - template - void remove(int parentRow, QVector &clients, T *client); + template + QVariant clientData(const QModelIndex &index, int role, const QVector clients, const std::function &toString) const; + template + void add(int parentRow, QVector &clients, T *client); + template + void remove(int parentRow, QVector &clients, T *client); WaylandClient *waylandClient(const QModelIndex &index) const; InternalClient *internalClient(const QModelIndex &index) const; X11Client *x11Client(const QModelIndex &index) const; @@ -80,10 +79,9 @@ private: int topLevelRowCount() const; QVector m_waylandClients; - QVector m_internalClients; + QVector m_internalClients; QVector m_x11Clients; - QVector m_unmanageds; - + QVector m_unmanageds; }; class DebugConsoleDelegate : public QStyledItemDelegate @@ -123,7 +121,7 @@ public: 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; + 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; }; @@ -172,7 +170,7 @@ public: 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; + 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; diff --git a/src/decorationitem.cpp b/src/decorationitem.cpp index 6b70d16055..195db9de16 100644 --- a/src/decorationitem.cpp +++ b/src/decorationitem.cpp @@ -16,8 +16,8 @@ #include -#include #include +#include #include diff --git a/src/decorationitem.h b/src/decorationitem.h index b9a5c98686..bdb25cd48b 100644 --- a/src/decorationitem.h +++ b/src/decorationitem.h @@ -53,10 +53,12 @@ protected: Decoration::DecoratedClientImpl *client() const; - bool areImageSizesDirty() const { + bool areImageSizesDirty() const + { return m_imageSizesDirty; } - void resetImageSizesDirty() { + void resetImageSizesDirty() + { m_imageSizesDirty = false; } QImage renderToImage(const QRect &geo); diff --git a/src/decorations/decoratedclient.cpp b/src/decorations/decoratedclient.cpp index 52552686c5..f3e9cb02b1 100644 --- a/src/decorations/decoratedclient.cpp +++ b/src/decorations/decoratedclient.cpp @@ -7,10 +7,10 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "decoratedclient.h" -#include "decorationbridge.h" -#include "decorationpalette.h" #include "abstract_client.h" #include "cursor.h" +#include "decorationbridge.h" +#include "decorationpalette.h" #include "workspace.h" #include @@ -32,51 +32,38 @@ DecoratedClientImpl::DecoratedClientImpl(AbstractClient *client, KDecoration2::D , m_clientSize(client->clientSize()) { client->setDecoratedClient(QPointer(this)); - connect(client, &AbstractClient::activeChanged, this, - [decoratedClient, client]() { - Q_EMIT decoratedClient->activeChanged(client->isActive()); + connect(client, &AbstractClient::activeChanged, this, [decoratedClient, client]() { + Q_EMIT decoratedClient->activeChanged(client->isActive()); + }); + connect(client, &AbstractClient::clientGeometryChanged, this, [decoratedClient, this]() { + if (m_client->clientSize() == m_clientSize) { + return; } - ); - connect(client, &AbstractClient::clientGeometryChanged, this, - [decoratedClient, this]() { - if (m_client->clientSize() == m_clientSize) { - return; - } - const auto oldSize = m_clientSize; - m_clientSize = m_client->clientSize(); - if (oldSize.width() != m_clientSize.width()) { - Q_EMIT decoratedClient->widthChanged(m_clientSize.width()); - } - if (oldSize.height() != m_clientSize.height()) { - Q_EMIT decoratedClient->heightChanged(m_clientSize.height()); - } - Q_EMIT decoratedClient->sizeChanged(m_clientSize); + const auto oldSize = m_clientSize; + m_clientSize = m_client->clientSize(); + if (oldSize.width() != m_clientSize.width()) { + Q_EMIT decoratedClient->widthChanged(m_clientSize.width()); } - ); - connect(client, &AbstractClient::desktopChanged, this, - [decoratedClient, client]() { - Q_EMIT decoratedClient->onAllDesktopsChanged(client->isOnAllDesktops()); + if (oldSize.height() != m_clientSize.height()) { + Q_EMIT decoratedClient->heightChanged(m_clientSize.height()); } - ); - connect(client, &AbstractClient::captionChanged, this, - [decoratedClient, client]() { - Q_EMIT decoratedClient->captionChanged(client->caption()); - } - ); - connect(client, &AbstractClient::iconChanged, this, - [decoratedClient, client]() { - Q_EMIT decoratedClient->iconChanged(client->icon()); - } - ); - connect(client, &AbstractClient::shadeChanged, this, - &Decoration::DecoratedClientImpl::signalShadeChange); + Q_EMIT decoratedClient->sizeChanged(m_clientSize); + }); + connect(client, &AbstractClient::desktopChanged, this, [decoratedClient, client]() { + Q_EMIT decoratedClient->onAllDesktopsChanged(client->isOnAllDesktops()); + }); + connect(client, &AbstractClient::captionChanged, this, [decoratedClient, client]() { + Q_EMIT decoratedClient->captionChanged(client->caption()); + }); + connect(client, &AbstractClient::iconChanged, this, [decoratedClient, client]() { + Q_EMIT decoratedClient->iconChanged(client->icon()); + }); + connect(client, &AbstractClient::shadeChanged, this, &Decoration::DecoratedClientImpl::signalShadeChange); connect(client, &AbstractClient::keepAboveChanged, decoratedClient, &KDecoration2::DecoratedClient::keepAboveChanged); connect(client, &AbstractClient::keepBelowChanged, decoratedClient, &KDecoration2::DecoratedClient::keepBelowChanged); - connect(client, &AbstractClient::quickTileModeChanged, decoratedClient, - [this, decoratedClient]() { - Q_EMIT decoratedClient->adjacentScreenEdgesChanged(adjacentScreenEdges()); - } - ); + connect(client, &AbstractClient::quickTileModeChanged, decoratedClient, [this, decoratedClient]() { + Q_EMIT decoratedClient->adjacentScreenEdgesChanged(adjacentScreenEdges()); + }); connect(client, &AbstractClient::closeableChanged, decoratedClient, &KDecoration2::DecoratedClient::closeableChanged); connect(client, &AbstractClient::shadeableChanged, decoratedClient, &KDecoration2::DecoratedClient::shadeableChanged); connect(client, &AbstractClient::minimizeableChanged, decoratedClient, &KDecoration2::DecoratedClient::minimizeableChanged); @@ -88,15 +75,13 @@ DecoratedClientImpl::DecoratedClientImpl(AbstractClient *client, KDecoration2::D connect(client, &AbstractClient::applicationMenuActiveChanged, decoratedClient, &KDecoration2::DecoratedClient::applicationMenuActiveChanged); m_toolTipWakeUp.setSingleShot(true); - connect(&m_toolTipWakeUp, &QTimer::timeout, this, - [this]() { - int fallAsleepDelay = QApplication::style()->styleHint(QStyle::SH_ToolTip_FallAsleepDelay); - this->m_toolTipFallAsleep.setRemainingTime(fallAsleepDelay); + connect(&m_toolTipWakeUp, &QTimer::timeout, this, [this]() { + int fallAsleepDelay = QApplication::style()->styleHint(QStyle::SH_ToolTip_FallAsleepDelay); + this->m_toolTipFallAsleep.setRemainingTime(fallAsleepDelay); - QToolTip::showText(Cursors::self()->mouse()->pos(), this->m_toolTipText); - m_toolTipShowing = true; - } - ); + QToolTip::showText(Cursors::self()->mouse()->pos(), this->m_toolTipText); + m_toolTipShowing = true; + }); } DecoratedClientImpl::~DecoratedClientImpl() @@ -106,14 +91,15 @@ DecoratedClientImpl::~DecoratedClientImpl() } } -void DecoratedClientImpl::signalShadeChange() { +void DecoratedClientImpl::signalShadeChange() +{ Q_EMIT decoratedClient()->shadedChanged(m_client->isShade()); } -#define DELEGATE(type, name, clientName) \ +#define DELEGATE(type, name, clientName) \ type DecoratedClientImpl::name() const \ - { \ - return m_client->clientName(); \ + { \ + return m_client->clientName(); \ } #define DELEGATE2(type, name) DELEGATE(type, name, name) @@ -136,10 +122,10 @@ DELEGATE2(QIcon, icon) #undef DELEGATE2 #undef DELEGATE -#define DELEGATE(type, name, clientName) \ +#define DELEGATE(type, name, clientName) \ type DecoratedClientImpl::name() const \ - { \ - return m_client->clientName(); \ + { \ + return m_client->clientName(); \ } DELEGATE(bool, isKeepAbove, keepAbove) @@ -150,9 +136,9 @@ DELEGATE(WId, decorationId, frameId) #undef DELEGATE -#define DELEGATE(name, op) \ - void DecoratedClientImpl::name() \ - { \ +#define DELEGATE(name, op) \ + void DecoratedClientImpl::name() \ + { \ Workspace::self()->performWindowOperation(m_client, Options::op); \ } @@ -163,10 +149,10 @@ DELEGATE(requestToggleKeepBelow, KeepBelowOp) #undef DELEGATE -#define DELEGATE(name, clientName) \ +#define DELEGATE(name, clientName) \ void DecoratedClientImpl::name() \ - { \ - m_client->clientName(); \ + { \ + m_client->clientName(); \ } DELEGATE(requestContextHelp, showContextHelp) diff --git a/src/decorations/decoratedclient.h b/src/decorations/decoratedclient.h index 78d036788e..65812403b5 100644 --- a/src/decorations/decoratedclient.h +++ b/src/decorations/decoratedclient.h @@ -77,10 +77,12 @@ public: void showApplicationMenu(int actionId) override; - AbstractClient *client() { + AbstractClient *client() + { return m_client; } - KDecoration2::DecoratedClient *decoratedClient() { + KDecoration2::DecoratedClient *decoratedClient() + { return KDecoration2::DecoratedClientPrivate::client(); } diff --git a/src/decorations/decorationbridge.cpp b/src/decorations/decorationbridge.cpp index de0d35085d..33a0f7e483 100644 --- a/src/decorations/decorationbridge.cpp +++ b/src/decorations/decorationbridge.cpp @@ -7,6 +7,9 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "decorationbridge.h" + +#include + #include "decoratedclient.h" #include "decorations_logging.h" #include "settings.h" @@ -14,11 +17,10 @@ #include "abstract_client.h" #include "wayland_server.h" #include "workspace.h" -#include // KDecoration -#include #include +#include #include // KWayland @@ -140,7 +142,9 @@ void DecorationBridge::initPlugin() static void recreateDecorations() { - Workspace::self()->forEachAbstractClient([](AbstractClient *c) { c->invalidateDecoration(); }); + Workspace::self()->forEachAbstractClient([](AbstractClient *c) { + c->invalidateDecoration(); + }); } void DecorationBridge::reconfigure() @@ -228,7 +232,7 @@ void DecorationBridge::findTheme(const QVariantMap &map) std::unique_ptr DecorationBridge::createClient(KDecoration2::DecoratedClient *client, KDecoration2::Decoration *decoration) { - return std::unique_ptr(new DecoratedClientImpl(static_cast(decoration->parent()), client, decoration)); + return std::unique_ptr(new DecoratedClientImpl(static_cast(decoration->parent()), client, decoration)); } std::unique_ptr DecorationBridge::settings(KDecoration2::DecorationSettings *parent) @@ -244,7 +248,7 @@ KDecoration2::Decoration *DecorationBridge::createDecoration(AbstractClient *cli if (!m_factory) { return nullptr; } - QVariantMap args({ {QStringLiteral("bridge"), QVariant::fromValue(this)} }); + QVariantMap args({{QStringLiteral("bridge"), QVariant::fromValue(this)}}); if (!m_theme.isEmpty()) { args.insert(QStringLiteral("theme"), m_theme); @@ -255,8 +259,7 @@ KDecoration2::Decoration *DecorationBridge::createDecoration(AbstractClient *cli return deco; } -static -QString settingsProperty(const QVariant &variant) +static QString settingsProperty(const QVariant &variant) { if (QLatin1String(variant.typeName()) == QLatin1String("KDecoration2::BorderSize")) { return QString::number(variant.toInt()); @@ -284,7 +287,7 @@ QString DecorationBridge::supportInformation() const b.append(QStringLiteral("Theme: %1\n").arg(m_theme)); b.append(QStringLiteral("Plugin recommends border size: %1\n").arg(m_recommendedBorderSize.isNull() ? "No" : m_recommendedBorderSize)); const QMetaObject *metaOptions = m_settings->metaObject(); - for (int i=0; ipropertyCount(); ++i) { + for (int i = 0; i < metaOptions->propertyCount(); ++i) { const QMetaProperty property = metaOptions->property(i); if (QLatin1String(property.name()) == QLatin1String("objectName")) { continue; diff --git a/src/decorations/decorationbridge.h b/src/decorations/decorationbridge.h index bb2662d7b9..3f0235b824 100644 --- a/src/decorations/decorationbridge.h +++ b/src/decorations/decorationbridge.h @@ -45,17 +45,20 @@ public: std::unique_ptr createClient(KDecoration2::DecoratedClient *client, KDecoration2::Decoration *decoration) override; std::unique_ptr settings(KDecoration2::DecorationSettings *parent) override; - QString recommendedBorderSize() const { + QString recommendedBorderSize() const + { return m_recommendedBorderSize; } - bool showToolTips() const { + bool showToolTips() const + { return m_showToolTips; } void reconfigure(); - const QSharedPointer &settings() const { + const QSharedPointer &settings() const + { return m_settings; } diff --git a/src/decorations/decorationpalette.cpp b/src/decorations/decorationpalette.cpp index a365b1513e..e69df95b13 100644 --- a/src/decorations/decorationpalette.cpp +++ b/src/decorations/decorationpalette.cpp @@ -24,7 +24,7 @@ namespace Decoration { DecorationPalette::DecorationPalette(const QString &colorScheme) - : m_colorScheme(colorScheme != QStringLiteral("kdeglobals") ? colorScheme : QString() ) + : m_colorScheme(colorScheme != QStringLiteral("kdeglobals") ? colorScheme : QString()) { if (m_colorScheme.isEmpty()) { m_colorSchemeConfig = KSharedConfig::openConfig(m_colorScheme, KConfig::FullConfig); @@ -45,77 +45,77 @@ bool DecorationPalette::isValid() const QColor DecorationPalette::color(KDecoration2::ColorGroup group, KDecoration2::ColorRole role) const { - using KDecoration2::ColorRole; using KDecoration2::ColorGroup; + using KDecoration2::ColorRole; if (m_legacyPalette.has_value()) { switch (role) { - case ColorRole::Frame: - switch (group) { - case ColorGroup::Active: - return m_legacyPalette->activeFrameColor; - case ColorGroup::Inactive: - return m_legacyPalette->inactiveFrameColor; - default: - return QColor(); - } - case ColorRole::TitleBar: - switch (group) { - case ColorGroup::Active: - return m_legacyPalette->activeTitleBarColor; - case ColorGroup::Inactive: - return m_legacyPalette->inactiveTitleBarColor; - default: - return QColor(); - } - case ColorRole::Foreground: - switch (group) { - case ColorGroup::Active: - return m_legacyPalette->activeForegroundColor; - case ColorGroup::Inactive: - return m_legacyPalette->inactiveForegroundColor; - case ColorGroup::Warning: - return m_legacyPalette->warningForegroundColor; - default: - return QColor(); - } + case ColorRole::Frame: + switch (group) { + case ColorGroup::Active: + return m_legacyPalette->activeFrameColor; + case ColorGroup::Inactive: + return m_legacyPalette->inactiveFrameColor; default: return QColor(); + } + case ColorRole::TitleBar: + switch (group) { + case ColorGroup::Active: + return m_legacyPalette->activeTitleBarColor; + case ColorGroup::Inactive: + return m_legacyPalette->inactiveTitleBarColor; + default: + return QColor(); + } + case ColorRole::Foreground: + switch (group) { + case ColorGroup::Active: + return m_legacyPalette->activeForegroundColor; + case ColorGroup::Inactive: + return m_legacyPalette->inactiveForegroundColor; + case ColorGroup::Warning: + return m_legacyPalette->warningForegroundColor; + default: + return QColor(); + } + default: + return QColor(); } } switch (role) { - case ColorRole::Frame: - switch (group) { - case ColorGroup::Active: - return m_palette.active.background().color(); - case ColorGroup::Inactive: - return m_palette.inactive.background().color(); - default: - return QColor(); - } - case ColorRole::TitleBar: - switch (group) { - case ColorGroup::Active: - return m_palette.active.background().color(); - case ColorGroup::Inactive: - return m_palette.inactive.background().color(); - default: - return QColor(); - } - case ColorRole::Foreground: - switch (group) { - case ColorGroup::Active: - return m_palette.active.foreground().color(); - case ColorGroup::Inactive: - return m_palette.inactive.foreground().color(); - case ColorGroup::Warning: - return m_palette.inactive.foreground(KColorScheme::ForegroundRole::NegativeText).color(); - default: - return QColor(); - } + case ColorRole::Frame: + switch (group) { + case ColorGroup::Active: + return m_palette.active.background().color(); + case ColorGroup::Inactive: + return m_palette.inactive.background().color(); default: return QColor(); + } + case ColorRole::TitleBar: + switch (group) { + case ColorGroup::Active: + return m_palette.active.background().color(); + case ColorGroup::Inactive: + return m_palette.inactive.background().color(); + default: + return QColor(); + } + case ColorRole::Foreground: + switch (group) { + case ColorGroup::Active: + return m_palette.active.foreground().color(); + case ColorGroup::Inactive: + return m_palette.inactive.foreground().color(); + case ColorGroup::Warning: + return m_palette.inactive.foreground(KColorScheme::ForegroundRole::NegativeText).color(); + default: + return QColor(); + } + default: + return QColor(); } } @@ -146,11 +146,11 @@ void DecorationPalette::update() m_legacyPalette = LegacyPalette{}; m_legacyPalette->palette = KColorScheme::createApplicationPalette(m_colorSchemeConfig); - m_legacyPalette->activeFrameColor = wmConfig.readEntry("frame", m_legacyPalette->palette.color(QPalette::Active, QPalette::Window)); - m_legacyPalette->inactiveFrameColor = wmConfig.readEntry("inactiveFrame", m_legacyPalette->activeFrameColor); - m_legacyPalette->activeTitleBarColor = wmConfig.readEntry("activeBackground", m_legacyPalette->palette.color(QPalette::Active, QPalette::Highlight)); - m_legacyPalette->inactiveTitleBarColor = wmConfig.readEntry("inactiveBackground", m_legacyPalette->inactiveTitleBarColor); - m_legacyPalette->activeForegroundColor = wmConfig.readEntry("activeForeground", m_legacyPalette->palette.color(QPalette::Active, QPalette::HighlightedText)); + m_legacyPalette->activeFrameColor = wmConfig.readEntry("frame", m_legacyPalette->palette.color(QPalette::Active, QPalette::Window)); + m_legacyPalette->inactiveFrameColor = wmConfig.readEntry("inactiveFrame", m_legacyPalette->activeFrameColor); + m_legacyPalette->activeTitleBarColor = wmConfig.readEntry("activeBackground", m_legacyPalette->palette.color(QPalette::Active, QPalette::Highlight)); + m_legacyPalette->inactiveTitleBarColor = wmConfig.readEntry("inactiveBackground", m_legacyPalette->inactiveTitleBarColor); + m_legacyPalette->activeForegroundColor = wmConfig.readEntry("activeForeground", m_legacyPalette->palette.color(QPalette::Active, QPalette::HighlightedText)); m_legacyPalette->inactiveForegroundColor = wmConfig.readEntry("inactiveForeground", m_legacyPalette->activeForegroundColor.darker()); KConfigGroup windowColorsConfig(m_colorSchemeConfig, QStringLiteral("Colors:Window")); diff --git a/src/decorations/decorationpalette.h b/src/decorations/decorationpalette.h index a0737cda92..c6af060777 100644 --- a/src/decorations/decorationpalette.h +++ b/src/decorations/decorationpalette.h @@ -12,12 +12,12 @@ #ifndef KWIN_DECORATION_PALETTE_H #define KWIN_DECORATION_PALETTE_H -#include -#include -#include -#include #include #include +#include +#include +#include +#include #include @@ -39,13 +39,15 @@ public: Q_SIGNALS: void changed(); + private: void update(); QString m_colorScheme; KConfigWatcher::Ptr m_watcher; - struct LegacyPalette { + struct LegacyPalette + { QPalette palette; QColor activeTitleBarColor; @@ -59,7 +61,8 @@ private: QColor warningForegroundColor; }; - struct ModernPalette { + struct ModernPalette + { KColorScheme active; KColorScheme inactive; }; diff --git a/src/decorations/settings.cpp b/src/decorations/settings.cpp index e493da6bc8..d2b51ec276 100644 --- a/src/decorations/settings.cpp +++ b/src/decorations/settings.cpp @@ -6,19 +6,17 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include "settings.h" -// KWin -#include "decorationbridge.h" -#include "composite.h" -#include "virtualdesktops.h" -#include "workspace.h" -#include "appmenu.h" - #include -#include +#include "appmenu.h" +#include "composite.h" +#include "decorationbridge.h" +#include "settings.h" +#include "virtualdesktops.h" +#include "workspace.h" #include +#include #include @@ -34,19 +32,17 @@ SettingsImpl::SettingsImpl(KDecoration2::DecorationSettings *parent) readSettings(); auto c = connect(Compositor::self(), &Compositor::compositingToggled, - parent, &KDecoration2::DecorationSettings::alphaChannelSupportedChanged); - connect(VirtualDesktopManager::self(), &VirtualDesktopManager::countChanged, this, - [parent](uint previous, uint current) { - if (previous != 1 && current != 1) { - return; - } - Q_EMIT parent->onAllDesktopsAvailableChanged(current > 1); + parent, &KDecoration2::DecorationSettings::alphaChannelSupportedChanged); + connect(VirtualDesktopManager::self(), &VirtualDesktopManager::countChanged, this, [parent](uint previous, uint current) { + if (previous != 1 && current != 1) { + return; } - ); + Q_EMIT parent->onAllDesktopsAvailableChanged(current > 1); + }); // prevent changes in Decoration due to Compositor being destroyed - connect(Compositor::self(), &Compositor::aboutToDestroy, this, - [c] { disconnect(c); } - ); + connect(Compositor::self(), &Compositor::aboutToDestroy, this, [c]() { + disconnect(c); + }); connect(Workspace::self(), &Workspace::configChanged, this, &SettingsImpl::readSettings); connect(DecorationBridge::self(), &DecorationBridge::metaDataLoaded, this, &SettingsImpl::readSettings); } @@ -74,16 +70,16 @@ static void initButtons() if (!s_buttonNames.isEmpty()) { return; } - s_buttonNames[KDecoration2::DecorationButtonType::Menu] = QChar('M'); + s_buttonNames[KDecoration2::DecorationButtonType::Menu] = QChar('M'); s_buttonNames[KDecoration2::DecorationButtonType::ApplicationMenu] = QChar('N'); - s_buttonNames[KDecoration2::DecorationButtonType::OnAllDesktops] = QChar('S'); - s_buttonNames[KDecoration2::DecorationButtonType::ContextHelp] = QChar('H'); - s_buttonNames[KDecoration2::DecorationButtonType::Minimize] = QChar('I'); - s_buttonNames[KDecoration2::DecorationButtonType::Maximize] = QChar('A'); - s_buttonNames[KDecoration2::DecorationButtonType::Close] = QChar('X'); - s_buttonNames[KDecoration2::DecorationButtonType::KeepAbove] = QChar('F'); - s_buttonNames[KDecoration2::DecorationButtonType::KeepBelow] = QChar('B'); - s_buttonNames[KDecoration2::DecorationButtonType::Shade] = QChar('L'); + s_buttonNames[KDecoration2::DecorationButtonType::OnAllDesktops] = QChar('S'); + s_buttonNames[KDecoration2::DecorationButtonType::ContextHelp] = QChar('H'); + s_buttonNames[KDecoration2::DecorationButtonType::Minimize] = QChar('I'); + s_buttonNames[KDecoration2::DecorationButtonType::Maximize] = QChar('A'); + s_buttonNames[KDecoration2::DecorationButtonType::Close] = QChar('X'); + s_buttonNames[KDecoration2::DecorationButtonType::KeepAbove] = QChar('F'); + s_buttonNames[KDecoration2::DecorationButtonType::KeepBelow] = QChar('B'); + s_buttonNames[KDecoration2::DecorationButtonType::Shade] = QChar('L'); } static QString buttonsToString(const QVector &buttons) @@ -102,9 +98,9 @@ static QString buttonsToString(const QVector return ret; } -QVector< KDecoration2::DecorationButtonType > SettingsImpl::readDecorationButtons(const KConfigGroup &config, - const char *key, - const QVector< KDecoration2::DecorationButtonType > &defaultValue) const +QVector SettingsImpl::readDecorationButtons(const KConfigGroup &config, + const char *key, + const QVector &defaultValue) const { initButtons(); auto buttonsFromString = [](const QString &buttons) -> QVector { @@ -123,17 +119,15 @@ QVector< KDecoration2::DecorationButtonType > SettingsImpl::readDecorationButton static KDecoration2::BorderSize stringToSize(const QString &name) { - static const QMap s_sizes = QMap({ - {QStringLiteral("None"), KDecoration2::BorderSize::None}, - {QStringLiteral("NoSides"), KDecoration2::BorderSize::NoSides}, - {QStringLiteral("Tiny"), KDecoration2::BorderSize::Tiny}, - {QStringLiteral("Normal"), KDecoration2::BorderSize::Normal}, - {QStringLiteral("Large"), KDecoration2::BorderSize::Large}, - {QStringLiteral("VeryLarge"), KDecoration2::BorderSize::VeryLarge}, - {QStringLiteral("Huge"), KDecoration2::BorderSize::Huge}, - {QStringLiteral("VeryHuge"), KDecoration2::BorderSize::VeryHuge}, - {QStringLiteral("Oversized"), KDecoration2::BorderSize::Oversized} - }); + static const QMap s_sizes = QMap({{QStringLiteral("None"), KDecoration2::BorderSize::None}, + {QStringLiteral("NoSides"), KDecoration2::BorderSize::NoSides}, + {QStringLiteral("Tiny"), KDecoration2::BorderSize::Tiny}, + {QStringLiteral("Normal"), KDecoration2::BorderSize::Normal}, + {QStringLiteral("Large"), KDecoration2::BorderSize::Large}, + {QStringLiteral("VeryLarge"), KDecoration2::BorderSize::VeryLarge}, + {QStringLiteral("Huge"), KDecoration2::BorderSize::Huge}, + {QStringLiteral("VeryHuge"), KDecoration2::BorderSize::VeryHuge}, + {QStringLiteral("Oversized"), KDecoration2::BorderSize::Oversized}}); auto it = s_sizes.constFind(name); if (it == s_sizes.constEnd()) { // non sense values are interpreted just like normal @@ -145,20 +139,12 @@ static KDecoration2::BorderSize stringToSize(const QString &name) void SettingsImpl::readSettings() { KConfigGroup config = kwinApp()->config()->group(QStringLiteral("org.kde.kdecoration2")); - const auto &left = readDecorationButtons(config, "ButtonsOnLeft", QVector({ - KDecoration2::DecorationButtonType::Menu, - KDecoration2::DecorationButtonType::OnAllDesktops - })); + const auto &left = readDecorationButtons(config, "ButtonsOnLeft", QVector({KDecoration2::DecorationButtonType::Menu, KDecoration2::DecorationButtonType::OnAllDesktops})); if (left != m_leftButtons) { m_leftButtons = left; Q_EMIT decorationSettings()->decorationButtonsLeftChanged(m_leftButtons); } - const auto &right = readDecorationButtons(config, "ButtonsOnRight", QVector({ - KDecoration2::DecorationButtonType::ContextHelp, - KDecoration2::DecorationButtonType::Minimize, - KDecoration2::DecorationButtonType::Maximize, - KDecoration2::DecorationButtonType::Close - })); + const auto &right = readDecorationButtons(config, "ButtonsOnRight", QVector({KDecoration2::DecorationButtonType::ContextHelp, KDecoration2::DecorationButtonType::Minimize, KDecoration2::DecorationButtonType::Maximize, KDecoration2::DecorationButtonType::Close})); if (right != m_rightButtons) { m_rightButtons = right; Q_EMIT decorationSettings()->decorationButtonsRightChanged(m_rightButtons); diff --git a/src/decorations/settings.h b/src/decorations/settings.h index 250447f055..a9f0d643c1 100644 --- a/src/decorations/settings.h +++ b/src/decorations/settings.h @@ -29,26 +29,30 @@ public: bool isAlphaChannelSupported() const override; bool isOnAllDesktopsAvailable() const override; bool isCloseOnDoubleClickOnMenu() const override; - KDecoration2::BorderSize borderSize() const override { + KDecoration2::BorderSize borderSize() const override + { return m_borderSize; } - QVector< KDecoration2::DecorationButtonType > decorationButtonsLeft() const override { + QVector decorationButtonsLeft() const override + { return m_leftButtons; } - QVector< KDecoration2::DecorationButtonType > decorationButtonsRight() const override { + QVector decorationButtonsRight() const override + { return m_rightButtons; } - QFont font() const override { + QFont font() const override + { return m_font; } private: void readSettings(); - QVector< KDecoration2::DecorationButtonType > readDecorationButtons(const KConfigGroup &config, + QVector readDecorationButtons(const KConfigGroup &config, const char *key, - const QVector< KDecoration2::DecorationButtonType > &defaultValue) const; - QVector< KDecoration2::DecorationButtonType > m_leftButtons; - QVector< KDecoration2::DecorationButtonType > m_rightButtons; + const QVector &defaultValue) const; + QVector m_leftButtons; + QVector m_rightButtons; KDecoration2::BorderSize m_borderSize; bool m_autoBorderSize = true; bool m_closeDoubleClickMenu = false; diff --git a/src/deleted.cpp b/src/deleted.cpp index ff0ad2aab9..66836ddb29 100644 --- a/src/deleted.cpp +++ b/src/deleted.cpp @@ -9,12 +9,12 @@ #include "deleted.h" -#include "workspace.h" #include "abstract_client.h" #include "group.h" #include "netinfo.h" #include "shadow.h" #include "virtualdesktops.h" +#include "workspace.h" #include @@ -51,9 +51,9 @@ Deleted::~Deleted() deleteShadow(); } -Deleted* Deleted::create(Toplevel* c) +Deleted *Deleted::create(Toplevel *c) { - Deleted* d = new Deleted(); + Deleted *d = new Deleted(); d->copyToDeleted(c); workspace()->addDeleted(d, c); return d; @@ -66,9 +66,9 @@ void Deleted::discard() delete this; } -void Deleted::copyToDeleted(Toplevel* c) +void Deleted::copyToDeleted(Toplevel *c) { - Q_ASSERT(dynamic_cast< Deleted* >(c) == nullptr); + Q_ASSERT(dynamic_cast(c) == nullptr); Toplevel::copyToDeleted(c); m_frameMargins = c->frameMargins(); desk = c->desktop(); @@ -80,9 +80,9 @@ void Deleted::copyToDeleted(Toplevel* c) m_type = c->windowType(); m_windowRole = c->windowRole(); m_shade = c->isShade(); - if (WinInfo* cinfo = dynamic_cast< WinInfo* >(info)) + if (WinInfo *cinfo = dynamic_cast(info)) cinfo->disable(); - if (AbstractClient *client = dynamic_cast(c)) { + if (AbstractClient *client = dynamic_cast(c)) { if (client->isDecorated()) { client->layoutDecorationRects(decoration_left, decoration_top, @@ -149,7 +149,7 @@ QPoint Deleted::clientPos() const return contentsRect.topLeft(); } -void Deleted::layoutDecorationRects(QRect& left, QRect& top, QRect& right, QRect& bottom) const +void Deleted::layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom) const { left = decoration_left; top = decoration_top; @@ -171,7 +171,7 @@ NET::WindowType Deleted::windowType(bool direct, int supportedTypes) const void Deleted::mainClientClosed(Toplevel *client) { - if (AbstractClient *c = dynamic_cast(client)) + if (AbstractClient *c = dynamic_cast(client)) m_mainClients.removeAll(c); } @@ -191,13 +191,11 @@ QVector Deleted::x11DesktopIds() const QVector x11Ids; x11Ids.reserve(desks.count()); std::transform(desks.constBegin(), desks.constEnd(), - std::back_inserter(x11Ids), - [] (const VirtualDesktop *vd) { - return vd->x11DesktopNumber(); - } - ); + std::back_inserter(x11Ids), + [](const VirtualDesktop *vd) { + return vd->x11DesktopNumber(); + }); return x11Ids; } } // namespace - diff --git a/src/deleted.h b/src/deleted.h index 373e062db4..6072a4469a 100644 --- a/src/deleted.h +++ b/src/deleted.h @@ -22,7 +22,7 @@ class KWIN_EXPORT Deleted : public Toplevel Q_OBJECT public: - static Deleted* create(Toplevel* c); + 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(); @@ -35,38 +35,48 @@ public: bool isDeleted() const override; xcb_window_t frameId() const override; void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom) const; - Layer layer() const override { + Layer layer() const override + { return m_layer; } - bool isShade() const override { + bool isShade() const override + { return m_shade; } - bool isMinimized() const { + bool isMinimized() const + { return m_minimized; } - bool isModal() const { + bool isModal() const + { return m_modal; } - QList mainClients() const { + QList mainClients() const + { return m_mainClients; } NET::WindowType windowType(bool direct = false, int supported_types = 0) const override; - bool wasClient() const { + bool wasClient() const + { return m_wasClient; } QByteArray windowRole() const override; - bool isFullScreen() const { + bool isFullScreen() const + { return m_fullscreen; } - bool keepAbove() const { + bool keepAbove() const + { return m_keepAbove; } - bool keepBelow() const { + bool keepBelow() const + { return m_keepBelow; } - QString caption() const { + QString caption() const + { return m_caption; } @@ -75,7 +85,8 @@ public: * * @returns @c true if the client was a popup, @c false otherwise. */ - bool isPopupWindow() const override { + bool isPopupWindow() const override + { return m_wasPopupWindow; } @@ -84,10 +95,12 @@ public: /** * Whether this Deleted represents the outline. */ - bool isOutline() const override { + bool isOutline() const override + { return m_wasOutline; } - bool isLockScreen() const override { + bool isLockScreen() const override + { return m_wasLockScreen; } @@ -95,8 +108,8 @@ private Q_SLOTS: void mainClientClosed(KWin::Toplevel *client); private: - Deleted(); // use create() - void copyToDeleted(Toplevel* c); + Deleted(); // use create() + void copyToDeleted(Toplevel *c); ~Deleted() override; // deleted only using unrefWindow() QMargins m_frameMargins; @@ -106,7 +119,7 @@ private: QStringList activityList; QRect contentsRect; // for clientPos()/clientSize() xcb_window_t m_frame; - QVector m_desktops; + QVector m_desktops; QRect decoration_left; QRect decoration_right; @@ -116,7 +129,7 @@ private: bool m_shade; bool m_minimized; bool m_modal; - QList m_mainClients; + QList m_mainClients; bool m_wasClient; NET::WindowType m_type = NET::Unknown; QByteArray m_windowRole; @@ -136,6 +149,6 @@ inline void Deleted::refWindow() } // namespace -Q_DECLARE_METATYPE(KWin::Deleted*) +Q_DECLARE_METATYPE(KWin::Deleted *) #endif diff --git a/src/dmabuftexture.h b/src/dmabuftexture.h index 8246502a8b..04c2166d14 100644 --- a/src/dmabuftexture.h +++ b/src/dmabuftexture.h @@ -16,13 +16,13 @@ class GLTexture; class KWIN_EXPORT DmaBufTexture { public: - explicit DmaBufTexture(KWin::GLTexture* texture); + explicit DmaBufTexture(KWin::GLTexture *texture); virtual ~DmaBufTexture(); virtual quint32 stride() const = 0; virtual int fd() const = 0; KWin::GLTexture *texture() const; - KWin::GLRenderTarget* framebuffer() const; + KWin::GLRenderTarget *framebuffer() const; protected: QScopedPointer m_texture; diff --git a/src/dpmsinputeventfilter.cpp b/src/dpmsinputeventfilter.cpp index 95a3104e6e..058810a416 100644 --- a/src/dpmsinputeventfilter.cpp +++ b/src/dpmsinputeventfilter.cpp @@ -7,10 +7,10 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "dpmsinputeventfilter.h" -#include "platform.h" #include "abstract_wayland_output.h" -#include "wayland_server.h" #include "main.h" +#include "platform.h" +#include "wayland_server.h" #include #include diff --git a/src/dpmsinputeventfilter.h b/src/dpmsinputeventfilter.h index 46e9b039db..0f1bf6374e 100644 --- a/src/dpmsinputeventfilter.h +++ b/src/dpmsinputeventfilter.h @@ -42,6 +42,4 @@ private: } - #endif - diff --git a/src/effectloader.cpp b/src/effectloader.cpp index de9ebc8b88..63db469d5f 100644 --- a/src/effectloader.cpp +++ b/src/effectloader.cpp @@ -8,22 +8,23 @@ */ // own #include "effectloader.h" -// KWin +// config #include -#include +// KWin #include "plugin.h" #include "scripting/scriptedeffect.h" #include "utils/common.h" +#include // KDE #include #include #include // Qt -#include #include #include #include #include +#include namespace KWin { @@ -131,11 +132,9 @@ bool ScriptedEffectLoader::loadEffect(const KPluginMetaData &effect, LoadEffectF qCDebug(KWIN_CORE) << "Could not initialize scripted effect: " << name; return false; } - connect(e, &ScriptedEffect::destroyed, this, - [this, name]() { - m_loadedEffects.removeAll(name); - } - ); + connect(e, &ScriptedEffect::destroyed, this, [this, name]() { + m_loadedEffects.removeAll(name); + }); qCDebug(KWIN_CORE) << "Successfully loaded scripted effect: " << name; Q_EMIT effectLoaded(e, name); @@ -150,8 +149,8 @@ void ScriptedEffectLoader::queryAndLoadAll() } // perform querying for the services in a thread QFutureWatcher> *watcher = new QFutureWatcher>(this); - m_queryConnection = connect(watcher, &QFutureWatcher>::finished, this, - [this, watcher]() { + m_queryConnection = connect( + watcher, &QFutureWatcher>::finished, this, [this, watcher]() { const auto effects = watcher->result(); for (const auto &effect : effects) { const LoadEffectFlags flags = readConfig(effect.pluginId(), effect.isEnabledByDefault()); @@ -178,17 +177,15 @@ QList ScriptedEffectLoader::findAllEffects() const KPluginMetaData ScriptedEffectLoader::findEffect(const QString &name) const { const auto plugins = KPackage::PackageLoader::self()->findPackages(s_serviceType, QStringLiteral("kwin/effects"), - [name] (const KPluginMetaData &metadata) { - return metadata.pluginId().compare(name, Qt::CaseInsensitive) == 0; - } - ); + [name](const KPluginMetaData &metadata) { + return metadata.pluginId().compare(name, Qt::CaseInsensitive) == 0; + }); if (!plugins.isEmpty()) { return plugins.first(); } return KPluginMetaData(); } - void ScriptedEffectLoader::clear() { disconnect(m_queryConnection); @@ -215,10 +212,9 @@ bool PluginEffectLoader::hasEffect(const QString &name) const KPluginMetaData PluginEffectLoader::findEffect(const QString &name) const { const auto plugins = KPluginMetaData::findPlugins(m_pluginSubDirectory, - [name] (const KPluginMetaData &data) { - return data.pluginId().compare(name, Qt::CaseInsensitive) == 0; - } - ); + [name](const KPluginMetaData &data) { + return data.pluginId().compare(name, Qt::CaseInsensitive) == 0; + }); if (plugins.isEmpty()) { return KPluginMetaData(); } @@ -256,7 +252,7 @@ EffectPluginFactory *PluginEffectLoader::factory(const KPluginMetaData &info) co qCDebug(KWIN_CORE) << "Did not get KPluginFactory for " << info.pluginId(); return nullptr; } - return dynamic_cast< EffectPluginFactory* >(factory); + return dynamic_cast(factory); } QStringList PluginEffectLoader::listOfKnownEffects() const @@ -321,11 +317,9 @@ bool PluginEffectLoader::loadEffect(const KPluginMetaData &info, LoadEffectFlags } // insert in our loaded effects m_loadedEffects << name; - connect(e, &Effect::destroyed, this, - [this, name]() { - m_loadedEffects.removeAll(name); - } - ); + connect(e, &Effect::destroyed, this, [this, name]() { + m_loadedEffects.removeAll(name); + }); qCDebug(KWIN_CORE) << "Successfully loaded plugin effect: " << name; Q_EMIT effectLoaded(e, name); return true; @@ -370,15 +364,15 @@ EffectLoader::~EffectLoader() { } -#define BOOL_MERGE( method ) \ - bool EffectLoader::method(const QString &name) const \ - { \ +#define BOOL_MERGE(method) \ + bool EffectLoader::method(const QString &name) const \ + { \ for (auto it = m_loaders.constBegin(); it != m_loaders.constEnd(); ++it) { \ - if ((*it)->method(name)) { \ - return true; \ - } \ - } \ - return false; \ + if ((*it)->method(name)) { \ + return true; \ + } \ + } \ + return false; \ } BOOL_MERGE(hasEffect) diff --git a/src/effectloader.h b/src/effectloader.h index 8c2a132b19..9a0fa93c75 100644 --- a/src/effectloader.h +++ b/src/effectloader.h @@ -13,12 +13,12 @@ #include #include // Qt -#include #include #include +#include #include -#include #include +#include namespace KWin { @@ -187,7 +187,7 @@ private: KSharedConfig::Ptr m_config; }; -template +template class EffectLoadQueue; /** * @brief Helper class to queue the loading of Effects. @@ -212,17 +212,17 @@ class AbstractEffectLoadQueue : public QObject public: explicit AbstractEffectLoadQueue(QObject *parent = nullptr) : QObject(parent) - { - } + { + } protected Q_SLOTS: virtual void dequeue() = 0; private: - template + template friend class EffectLoadQueue; }; -template +template class EffectLoadQueue : public AbstractEffectLoadQueue { public: @@ -242,6 +242,7 @@ public: m_queue.clear(); m_dequeueScheduled = false; } + protected: void dequeue() override { @@ -253,6 +254,7 @@ protected: m_effectLoader->loadEffect(pair.first, pair.second); scheduleDequeue(); } + private: void scheduleDequeue() { @@ -274,7 +276,7 @@ class KWIN_EXPORT ScriptedEffectLoader : public AbstractEffectLoader { Q_OBJECT public: - explicit ScriptedEffectLoader(QObject* parent = nullptr); + explicit ScriptedEffectLoader(QObject *parent = nullptr); ~ScriptedEffectLoader() override; bool hasEffect(const QString &name) const override; @@ -290,7 +292,7 @@ private: QList findAllEffects() const; KPluginMetaData findEffect(const QString &name) const; QStringList m_loadedEffects; - EffectLoadQueue< ScriptedEffectLoader, KPluginMetaData > *m_queue; + EffectLoadQueue *m_queue; QMetaObject::Connection m_queryConnection; }; @@ -335,7 +337,7 @@ public: void clear() override; private: - QList m_loaders; + QList m_loaders; }; } diff --git a/src/effects.cpp b/src/effects.cpp index 0703a486a5..95bd4c3eaf 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -13,55 +13,53 @@ #include #include "abstract_output.h" -#include "effectsadaptor.h" #include "effectloader.h" +#include "effectsadaptor.h" #if KWIN_BUILD_ACTIVITIES #include "activities.h" #endif -#include "deleted.h" -#include "x11client.h" #include "cursor.h" +#include "deleted.h" #include "group.h" +#include "input_event.h" #include "internal_client.h" #include "osd.h" #include "pointer_input.h" #include "renderbackend.h" #include "unmanaged.h" -#include "input_event.h" +#include "x11client.h" #if KWIN_BUILD_TABBOX #include "tabbox.h" #endif #include "screenedge.h" -#include "scripting/scriptedeffect.h" #include "screens.h" +#include "scripting/scriptedeffect.h" #if KWIN_BUILD_SCREENLOCKER #include "screenlockerwatcher.h" #endif -#include "virtualdesktops.h" -#include "window_property_notify_x11_filter.h" -#include "workspace.h" -#include "kwinglutils.h" -#include "kwinoffscreenquickview.h" - +#include "composite.h" +#include "decorations/decorationbridge.h" #include "inputmethod.h" #include "inputpanelv1client.h" +#include "kwinglutils.h" +#include "kwinoffscreenquickview.h" +#include "platform.h" +#include "utils/xcbutils.h" +#include "virtualdesktops.h" +#include "wayland_server.h" +#include "waylandclient.h" +#include "window_property_notify_x11_filter.h" +#include "workspace.h" + +#include + +#include +#include #include #include #include -#include - -#include "composite.h" -#include "platform.h" -#include "utils/xcbutils.h" -#include "waylandclient.h" -#include "wayland_server.h" - -#include "decorations/decorationbridge.h" -#include -#include - namespace KWin { //--------------------- @@ -103,8 +101,8 @@ static xcb_atom_t registerSupportProperty(const QByteArray &propertyName) } // get the atom for the propertyName ScopedCPointer atomReply(xcb_intern_atom_reply(c, - xcb_intern_atom_unchecked(c, false, propertyName.size(), propertyName.constData()), - nullptr)); + xcb_intern_atom_unchecked(c, false, propertyName.size(), propertyName.constData()), + nullptr)); if (atomReply.isNull()) { return XCB_ATOM_NONE; } @@ -128,14 +126,12 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene) , m_effectLoader(new EffectLoader(this)) , m_trackingCursorChanges(0) { - qRegisterMetaType>(); - connect(m_effectLoader, &AbstractEffectLoader::effectLoaded, this, - [this](Effect *effect, const QString &name) { - effect_order.insert(effect->requestedEffectChainPosition(), EffectPair(name, effect)); - loaded_effects << EffectPair(name, effect); - effectsChanged(); - } - ); + qRegisterMetaType>(); + connect(m_effectLoader, &AbstractEffectLoader::effectLoaded, this, [this](Effect *effect, const QString &name) { + effect_order.insert(effect->requestedEffectChainPosition(), EffectPair(name, effect)); + loaded_effects << EffectPair(name, effect); + effectsChanged(); + }); m_effectLoader->setConfig(kwinApp()->config()); new EffectsAdaptor(this); QDBusConnection dbus = QDBusConnection::sessionBus(); @@ -145,74 +141,59 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene) VirtualDesktopManager *vds = VirtualDesktopManager::self(); connect(ws, &Workspace::showingDesktopChanged, this, &EffectsHandlerImpl::showingDesktopChanged); - connect(ws, &Workspace::currentDesktopChanged, this, - [this](int old, AbstractClient *c) { - const int newDesktop = VirtualDesktopManager::self()->current(); - if (old != 0 && newDesktop != old) { - Q_EMIT desktopChanged(old, newDesktop, c ? c->effectWindow() : nullptr); - // TODO: remove in 4.10 - Q_EMIT desktopChanged(old, newDesktop); - } + connect(ws, &Workspace::currentDesktopChanged, this, [this](int old, AbstractClient *c) { + const int newDesktop = VirtualDesktopManager::self()->current(); + if (old != 0 && newDesktop != old) { + Q_EMIT desktopChanged(old, newDesktop, c ? c->effectWindow() : nullptr); + // TODO: remove in 4.10 + Q_EMIT desktopChanged(old, newDesktop); } - ); - connect(ws, &Workspace::desktopPresenceChanged, this, - [this](AbstractClient *c, int old) { - if (!c->effectWindow()) { - return; - } - Q_EMIT desktopPresenceChanged(c->effectWindow(), old, c->desktop()); + }); + connect(ws, &Workspace::desktopPresenceChanged, this, [this](AbstractClient *c, int old) { + if (!c->effectWindow()) { + return; } - ); - connect(ws, &Workspace::clientAdded, this, - [this](AbstractClient *c) { - if (c->readyForPainting()) - slotClientShown(c); - else - connect(c, &Toplevel::windowShown, this, &EffectsHandlerImpl::slotClientShown); - } - ); - connect(ws, &Workspace::unmanagedAdded, this, - [this](Unmanaged *u) { - // it's never initially ready but has synthetic 50ms delay - connect(u, &Toplevel::windowShown, this, &EffectsHandlerImpl::slotUnmanagedShown); - } - ); - connect(ws, &Workspace::internalClientAdded, this, - [this](InternalClient *client) { - setupClientConnections(client); - Q_EMIT windowAdded(client->effectWindow()); - } - ); - connect(ws, &Workspace::clientActivated, this, - [this](KWin::AbstractClient *c) { - Q_EMIT windowActivated(c ? c->effectWindow() : nullptr); - } - ); - connect(ws, &Workspace::deletedRemoved, this, - [this](KWin::Deleted *d) { - Q_EMIT windowDeleted(d->effectWindow()); - elevated_windows.removeAll(d->effectWindow()); - } - ); - connect(ws->sessionManager(), &SessionManager::stateChanged, this, - &KWin::EffectsHandler::sessionStateChanged); + Q_EMIT desktopPresenceChanged(c->effectWindow(), old, c->desktop()); + }); + connect(ws, &Workspace::clientAdded, this, [this](AbstractClient *c) { + if (c->readyForPainting()) + slotClientShown(c); + else + connect(c, &Toplevel::windowShown, this, &EffectsHandlerImpl::slotClientShown); + }); + connect(ws, &Workspace::unmanagedAdded, this, [this](Unmanaged *u) { + // it's never initially ready but has synthetic 50ms delay + connect(u, &Toplevel::windowShown, this, &EffectsHandlerImpl::slotUnmanagedShown); + }); + connect(ws, &Workspace::internalClientAdded, this, [this](InternalClient *client) { + setupClientConnections(client); + Q_EMIT windowAdded(client->effectWindow()); + }); + connect(ws, &Workspace::clientActivated, this, [this](KWin::AbstractClient *c) { + Q_EMIT windowActivated(c ? c->effectWindow() : nullptr); + }); + connect(ws, &Workspace::deletedRemoved, this, [this](KWin::Deleted *d) { + Q_EMIT windowDeleted(d->effectWindow()); + elevated_windows.removeAll(d->effectWindow()); + }); + connect(ws->sessionManager(), &SessionManager::stateChanged, this, &KWin::EffectsHandler::sessionStateChanged); connect(vds, &VirtualDesktopManager::countChanged, this, &EffectsHandler::numberDesktopsChanged); connect(Cursors::self()->mouse(), &Cursor::mouseChanged, this, &EffectsHandler::mouseChanged); connect(Screens::self(), &Screens::sizeChanged, this, &EffectsHandler::virtualScreenSizeChanged); connect(Screens::self(), &Screens::geometryChanged, this, &EffectsHandler::virtualScreenGeometryChanged); #if KWIN_BUILD_ACTIVITIES if (Activities *activities = Activities::self()) { - connect(activities, &Activities::added, this, &EffectsHandler::activityAdded); - connect(activities, &Activities::removed, this, &EffectsHandler::activityRemoved); + connect(activities, &Activities::added, this, &EffectsHandler::activityAdded); + connect(activities, &Activities::removed, this, &EffectsHandler::activityRemoved); connect(activities, &Activities::currentChanged, this, &EffectsHandler::currentActivityChanged); } #endif connect(ws, &Workspace::stackingOrderChanged, this, &EffectsHandler::stackingOrderChanged); #if KWIN_BUILD_TABBOX TabBox::TabBox *tabBox = TabBox::TabBox::self(); - connect(tabBox, &TabBox::TabBox::tabBoxAdded, this, &EffectsHandler::tabBoxAdded); - connect(tabBox, &TabBox::TabBox::tabBoxUpdated, this, &EffectsHandler::tabBoxUpdated); - connect(tabBox, &TabBox::TabBox::tabBoxClosed, this, &EffectsHandler::tabBoxClosed); + connect(tabBox, &TabBox::TabBox::tabBoxAdded, this, &EffectsHandler::tabBoxAdded); + connect(tabBox, &TabBox::TabBox::tabBoxUpdated, this, &EffectsHandler::tabBoxUpdated); + connect(tabBox, &TabBox::TabBox::tabBoxClosed, this, &EffectsHandler::tabBoxClosed); connect(tabBox, &TabBox::TabBox::tabBoxKeyEvent, this, &EffectsHandler::tabBoxKeyEvent); #endif connect(ScreenEdges::self(), &ScreenEdges::approaching, this, &EffectsHandler::screenEdgeApproaching); @@ -221,26 +202,24 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene) connect(ScreenLockerWatcher::self(), &ScreenLockerWatcher::aboutToLock, this, &EffectsHandler::screenAboutToLock); #endif - connect(kwinApp(), &Application::x11ConnectionChanged, this, - [this] { - registered_atoms.clear(); - for (auto it = m_propertiesForEffects.keyBegin(); it != m_propertiesForEffects.keyEnd(); it++) { - const auto atom = registerSupportProperty(*it); - if (atom == XCB_ATOM_NONE) { - continue; - } - m_compositor->keepSupportProperty(atom); - m_managedProperties.insert(*it, atom); - registerPropertyType(atom, true); + connect(kwinApp(), &Application::x11ConnectionChanged, this, [this]() { + registered_atoms.clear(); + for (auto it = m_propertiesForEffects.keyBegin(); it != m_propertiesForEffects.keyEnd(); it++) { + const auto atom = registerSupportProperty(*it); + if (atom == XCB_ATOM_NONE) { + continue; } - if (kwinApp()->x11Connection()) { - m_x11WindowPropertyNotify = std::make_unique(this); - } else { - m_x11WindowPropertyNotify.reset(); - } - Q_EMIT xcbConnectionChanged(); + m_compositor->keepSupportProperty(atom); + m_managedProperties.insert(*it, atom); + registerPropertyType(atom, true); } - ); + if (kwinApp()->x11Connection()) { + m_x11WindowPropertyNotify = std::make_unique(this); + } else { + m_x11WindowPropertyNotify.reset(); + } + Q_EMIT xcbConnectionChanged(); + }); if (kwinApp()->x11Connection()) { m_x11WindowPropertyNotify = std::make_unique(this); @@ -291,95 +270,72 @@ void EffectsHandlerImpl::unloadAllEffects() effectsChanged(); } -void EffectsHandlerImpl::setupClientConnections(AbstractClient* c) +void EffectsHandlerImpl::setupClientConnections(AbstractClient *c) { connect(c, &AbstractClient::windowClosed, this, &EffectsHandlerImpl::slotWindowClosed); - connect(c, static_cast(&AbstractClient::clientMaximizedStateChanged), + connect(c, static_cast(&AbstractClient::clientMaximizedStateChanged), this, &EffectsHandlerImpl::slotClientMaximized); - connect(c, &AbstractClient::clientStartUserMovedResized, this, - [this](AbstractClient *c) { - Q_EMIT windowStartUserMovedResized(c->effectWindow()); - } - ); - connect(c, &AbstractClient::clientStepUserMovedResized, this, - [this](AbstractClient *c, const QRect &geometry) { - Q_EMIT windowStepUserMovedResized(c->effectWindow(), geometry); - } - ); - connect(c, &AbstractClient::clientFinishUserMovedResized, this, - [this](AbstractClient *c) { - Q_EMIT windowFinishUserMovedResized(c->effectWindow()); - } - ); + connect(c, &AbstractClient::clientStartUserMovedResized, this, [this](AbstractClient *c) { + Q_EMIT windowStartUserMovedResized(c->effectWindow()); + }); + connect(c, &AbstractClient::clientStepUserMovedResized, this, [this](AbstractClient *c, const QRect &geometry) { + Q_EMIT windowStepUserMovedResized(c->effectWindow(), geometry); + }); + connect(c, &AbstractClient::clientFinishUserMovedResized, this, [this](AbstractClient *c) { + Q_EMIT windowFinishUserMovedResized(c->effectWindow()); + }); connect(c, &AbstractClient::opacityChanged, this, &EffectsHandlerImpl::slotOpacityChanged); - connect(c, &AbstractClient::clientMinimized, this, - [this](AbstractClient *c, bool animate) { - // TODO: notify effects even if it should not animate? - if (animate) { - Q_EMIT windowMinimized(c->effectWindow()); - } + connect(c, &AbstractClient::clientMinimized, this, [this](AbstractClient *c, bool animate) { + // TODO: notify effects even if it should not animate? + if (animate) { + Q_EMIT windowMinimized(c->effectWindow()); } - ); - connect(c, &AbstractClient::clientUnminimized, this, - [this](AbstractClient* c, bool animate) { - // TODO: notify effects even if it should not animate? - if (animate) { - Q_EMIT windowUnminimized(c->effectWindow()); - } + }); + connect(c, &AbstractClient::clientUnminimized, this, [this](AbstractClient *c, bool animate) { + // TODO: notify effects even if it should not animate? + if (animate) { + Q_EMIT windowUnminimized(c->effectWindow()); } - ); - connect(c, &AbstractClient::modalChanged, this, &EffectsHandlerImpl::slotClientModalityChanged); + }); + connect(c, &AbstractClient::modalChanged, this, &EffectsHandlerImpl::slotClientModalityChanged); connect(c, &AbstractClient::geometryShapeChanged, this, &EffectsHandlerImpl::slotGeometryShapeChanged); connect(c, &AbstractClient::frameGeometryChanged, this, &EffectsHandlerImpl::slotFrameGeometryChanged); - connect(c, &AbstractClient::damaged, this, &EffectsHandlerImpl::slotWindowDamaged); - connect(c, &AbstractClient::unresponsiveChanged, this, - [this, c](bool unresponsive) { - Q_EMIT windowUnresponsiveChanged(c->effectWindow(), unresponsive); - } - ); - connect(c, &AbstractClient::windowShown, this, - [this](Toplevel *c) { - Q_EMIT windowShown(c->effectWindow()); - } - ); - connect(c, &AbstractClient::windowHidden, this, - [this](Toplevel *c) { - Q_EMIT windowHidden(c->effectWindow()); - } - ); - connect(c, &AbstractClient::keepAboveChanged, this, - [this, c](bool above) { - Q_UNUSED(above) - Q_EMIT windowKeepAboveChanged(c->effectWindow()); - } - ); - connect(c, &AbstractClient::keepBelowChanged, this, - [this, c](bool below) { - Q_UNUSED(below) - Q_EMIT windowKeepBelowChanged(c->effectWindow()); - } - ); - connect(c, &AbstractClient::fullScreenChanged, this, - [this, c]() { - Q_EMIT windowFullScreenChanged(c->effectWindow()); - } - ); + connect(c, &AbstractClient::damaged, this, &EffectsHandlerImpl::slotWindowDamaged); + connect(c, &AbstractClient::unresponsiveChanged, this, [this, c](bool unresponsive) { + Q_EMIT windowUnresponsiveChanged(c->effectWindow(), unresponsive); + }); + connect(c, &AbstractClient::windowShown, this, [this](Toplevel *c) { + Q_EMIT windowShown(c->effectWindow()); + }); + connect(c, &AbstractClient::windowHidden, this, [this](Toplevel *c) { + Q_EMIT windowHidden(c->effectWindow()); + }); + connect(c, &AbstractClient::keepAboveChanged, this, [this, c](bool above) { + Q_UNUSED(above) + Q_EMIT windowKeepAboveChanged(c->effectWindow()); + }); + connect(c, &AbstractClient::keepBelowChanged, this, [this, c](bool below) { + Q_UNUSED(below) + Q_EMIT windowKeepBelowChanged(c->effectWindow()); + }); + connect(c, &AbstractClient::fullScreenChanged, this, [this, c]() { + Q_EMIT windowFullScreenChanged(c->effectWindow()); + }); connect(c, &AbstractClient::visibleGeometryChanged, this, [this, c]() { Q_EMIT windowExpandedGeometryChanged(c->effectWindow()); }); - connect(c, &AbstractClient::decorationChanged, this, [this, c]() { Q_EMIT windowDecorationChanged(c->effectWindow()); }); } -void EffectsHandlerImpl::setupUnmanagedConnections(Unmanaged* u) +void EffectsHandlerImpl::setupUnmanagedConnections(Unmanaged *u) { - connect(u, &Unmanaged::windowClosed, this, &EffectsHandlerImpl::slotWindowClosed); - connect(u, &Unmanaged::opacityChanged, this, &EffectsHandlerImpl::slotOpacityChanged); + connect(u, &Unmanaged::windowClosed, this, &EffectsHandlerImpl::slotWindowClosed); + connect(u, &Unmanaged::opacityChanged, this, &EffectsHandlerImpl::slotOpacityChanged); connect(u, &Unmanaged::geometryShapeChanged, this, &EffectsHandlerImpl::slotGeometryShapeChanged); connect(u, &Unmanaged::frameGeometryChanged, this, &EffectsHandlerImpl::slotFrameGeometryChanged); - connect(u, &Unmanaged::damaged, this, &EffectsHandlerImpl::slotWindowDamaged); + connect(u, &Unmanaged::damaged, this, &EffectsHandlerImpl::slotWindowDamaged); connect(u, &Unmanaged::visibleGeometryChanged, this, [this, u]() { Q_EMIT windowExpandedGeometryChanged(u->effectWindow()); }); @@ -391,7 +347,7 @@ void EffectsHandlerImpl::reconfigure() } // the idea is that effects call this function again which calls the next one -void EffectsHandlerImpl::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) +void EffectsHandlerImpl::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) { if (m_currentPaintScreenIterator != m_activeEffects.constEnd()) { (*m_currentPaintScreenIterator++)->prePaintScreen(data, presentTime); @@ -400,7 +356,7 @@ void EffectsHandlerImpl::prePaintScreen(ScreenPrePaintData& data, std::chrono::m // no special final code } -void EffectsHandlerImpl::paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) +void EffectsHandlerImpl::paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) { if (m_currentPaintScreenIterator != m_activeEffects.constEnd()) { (*m_currentPaintScreenIterator++)->paintScreen(mask, region, data); @@ -434,7 +390,7 @@ void EffectsHandlerImpl::postPaintScreen() // no special final code } -void EffectsHandlerImpl::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime) +void EffectsHandlerImpl::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) { if (m_currentPaintWindowIterator != m_activeEffects.constEnd()) { (*m_currentPaintWindowIterator++)->prePaintWindow(w, data, presentTime); @@ -443,27 +399,27 @@ void EffectsHandlerImpl::prePaintWindow(EffectWindow* w, WindowPrePaintData& dat // no special final code } -void EffectsHandlerImpl::paintWindow(EffectWindow* w, int mask, const QRegion ®ion, WindowPaintData& data) +void EffectsHandlerImpl::paintWindow(EffectWindow *w, int mask, const QRegion ®ion, WindowPaintData &data) { if (m_currentPaintWindowIterator != m_activeEffects.constEnd()) { (*m_currentPaintWindowIterator++)->paintWindow(w, mask, region, data); --m_currentPaintWindowIterator; } else - m_scene->finalPaintWindow(static_cast(w), mask, region, data); + m_scene->finalPaintWindow(static_cast(w), mask, region, data); } -void EffectsHandlerImpl::paintEffectFrame(EffectFrame* frame, const QRegion ®ion, double opacity, double frameOpacity) +void EffectsHandlerImpl::paintEffectFrame(EffectFrame *frame, const QRegion ®ion, double opacity, double frameOpacity) { if (m_currentPaintEffectFrameIterator != m_activeEffects.constEnd()) { (*m_currentPaintEffectFrameIterator++)->paintEffectFrame(frame, region, opacity, frameOpacity); --m_currentPaintEffectFrameIterator; } else { - const EffectFrameImpl* frameImpl = static_cast(frame); + const EffectFrameImpl *frameImpl = static_cast(frame); frameImpl->finalRender(region, opacity, frameOpacity); } } -void EffectsHandlerImpl::postPaintWindow(EffectWindow* w) +void EffectsHandlerImpl::postPaintWindow(EffectWindow *w) { if (m_currentPaintWindowIterator != m_activeEffects.constEnd()) { (*m_currentPaintWindowIterator++)->postPaintWindow(w); @@ -480,13 +436,13 @@ Effect *EffectsHandlerImpl::provides(Effect::Feature ef) return nullptr; } -void EffectsHandlerImpl::drawWindow(EffectWindow* w, int mask, const QRegion ®ion, WindowPaintData& data) +void EffectsHandlerImpl::drawWindow(EffectWindow *w, int mask, const QRegion ®ion, WindowPaintData &data) { if (m_currentDrawWindowIterator != m_activeEffects.constEnd()) { (*m_currentDrawWindowIterator++)->drawWindow(w, mask, region, data); --m_currentDrawWindowIterator; } else - m_scene->finalDrawWindow(static_cast(w), mask, region, data); + m_scene->finalDrawWindow(static_cast(w), mask, region, data); } bool EffectsHandlerImpl::hasDecorationShadows() const @@ -504,7 +460,7 @@ void EffectsHandlerImpl::startPaint() { m_activeEffects.clear(); m_activeEffects.reserve(loaded_effects.count()); - for(QVector< KWin::EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) { + for (QVector::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) { if (it->second->isActive()) { m_activeEffects << it->second; } @@ -558,9 +514,9 @@ void EffectsHandlerImpl::slotClientShown(KWin::Toplevel *t) } void EffectsHandlerImpl::slotUnmanagedShown(KWin::Toplevel *t) -{ // regardless, unmanaged windows are -yet?- not synced anyway +{ // regardless, unmanaged windows are -yet?- not synced anyway Q_ASSERT(qobject_cast(t)); - Unmanaged *u = static_cast(t); + Unmanaged *u = static_cast(t); setupUnmanagedConnections(u); Q_EMIT windowAdded(u->effectWindow()); } @@ -583,17 +539,17 @@ void EffectsHandlerImpl::slotCurrentTabAboutToChange(EffectWindow *from, EffectW Q_EMIT currentTabAboutToChange(from, to); } -void EffectsHandlerImpl::slotTabAdded(EffectWindow* w, EffectWindow* to) +void EffectsHandlerImpl::slotTabAdded(EffectWindow *w, EffectWindow *to) { Q_EMIT tabAdded(w, to); } -void EffectsHandlerImpl::slotTabRemoved(EffectWindow *w, EffectWindow* leaderOfFormerGroup) +void EffectsHandlerImpl::slotTabRemoved(EffectWindow *w, EffectWindow *leaderOfFormerGroup) { Q_EMIT tabRemoved(w, leaderOfFormerGroup); } -void EffectsHandlerImpl::slotWindowDamaged(Toplevel* t, const QRegion& r) +void EffectsHandlerImpl::slotWindowDamaged(Toplevel *t, const QRegion &r) { if (!t->effectWindow()) { // can happen during tear down of window @@ -602,7 +558,7 @@ void EffectsHandlerImpl::slotWindowDamaged(Toplevel* t, const QRegion& r) Q_EMIT windowDamaged(t->effectWindow(), r); } -void EffectsHandlerImpl::slotGeometryShapeChanged(Toplevel* t, const QRect& old) +void EffectsHandlerImpl::slotGeometryShapeChanged(Toplevel *t, const QRect &old) { // during late cleanup effectWindow() may be already NULL // in some functions that may still call this @@ -619,7 +575,7 @@ void EffectsHandlerImpl::slotFrameGeometryChanged(Toplevel *toplevel, const QRec } } -void EffectsHandlerImpl::setActiveFullScreenEffect(Effect* e) +void EffectsHandlerImpl::setActiveFullScreenEffect(Effect *e) { if (fullscreen_effect == e) { return; @@ -632,7 +588,7 @@ void EffectsHandlerImpl::setActiveFullScreenEffect(Effect* e) } } -Effect* EffectsHandlerImpl::activeFullScreenEffect() const +Effect *EffectsHandlerImpl::activeFullScreenEffect() const { return fullscreen_effect; } @@ -642,7 +598,7 @@ bool EffectsHandlerImpl::hasActiveFullScreenEffect() const return fullscreen_effect; } -bool EffectsHandlerImpl::grabKeyboard(Effect* effect) +bool EffectsHandlerImpl::grabKeyboard(Effect *effect) { if (keyboard_grab_effect != nullptr) return false; @@ -669,7 +625,7 @@ void EffectsHandlerImpl::doUngrabKeyboard() { } -void EffectsHandlerImpl::grabbedKeyboardEvent(QKeyEvent* e) +void EffectsHandlerImpl::grabbedKeyboardEvent(QKeyEvent *e) { if (keyboard_grab_effect != nullptr) keyboard_grab_effect->grabbedKeyboardEvent(e); @@ -713,7 +669,6 @@ bool EffectsHandlerImpl::isMouseInterception() const return m_grabbedMouseEffects.count() > 0; } - bool EffectsHandlerImpl::touchDown(qint32 id, const QPointF &pos, quint32 time) { // TODO: reverse call order? @@ -802,7 +757,6 @@ bool EffectsHandlerImpl::tabletPadRingEvent(int number, int position, bool isFin return false; } - void EffectsHandlerImpl::registerGlobalShortcut(const QKeySequence &shortcut, QAction *action) { input()->registerShortcut(shortcut, action); @@ -818,7 +772,7 @@ void EffectsHandlerImpl::registerAxisShortcut(Qt::KeyboardModifiers modifiers, P input()->registerAxisShortcut(modifiers, axis, action); } -void EffectsHandlerImpl::registerRealtimeTouchpadSwipeShortcut(SwipeDirection dir, uint fingerCount, QAction* onUp, std::function progressCallback) +void EffectsHandlerImpl::registerRealtimeTouchpadSwipeShortcut(SwipeDirection dir, uint fingerCount, QAction *onUp, std::function progressCallback) { input()->registerRealtimeTouchpadSwipeShortcut(dir, fingerCount, onUp, progressCallback); } @@ -828,19 +782,19 @@ void EffectsHandlerImpl::registerTouchpadSwipeShortcut(SwipeDirection direction, input()->registerTouchpadSwipeShortcut(direction, fingerCount, action); } -void EffectsHandlerImpl::registerRealtimeTouchpadPinchShortcut(PinchDirection dir, uint fingerCount, QAction* onUp, std::function progressCallback) +void EffectsHandlerImpl::registerRealtimeTouchpadPinchShortcut(PinchDirection dir, uint fingerCount, QAction *onUp, std::function progressCallback) { - input()->registerRealtimeTouchpadPinchShortcut(dir, fingerCount, onUp, progressCallback); + input()->registerRealtimeTouchpadPinchShortcut(dir, fingerCount, onUp, progressCallback); } void EffectsHandlerImpl::registerTouchpadPinchShortcut(PinchDirection direction, uint fingerCount, QAction *action) { - input()->registerTouchpadPinchShortcut(direction, fingerCount, action); + input()->registerTouchpadPinchShortcut(direction, fingerCount, action); } -void* EffectsHandlerImpl::getProxy(QString name) +void *EffectsHandlerImpl::getProxy(QString name) { - for (QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) + for (QVector::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) if ((*it).first == name) return (*it).second->proxy(); @@ -867,9 +821,9 @@ bool EffectsHandlerImpl::hasKeyboardGrab() const void EffectsHandlerImpl::registerPropertyType(long atom, bool reg) { if (reg) - ++registered_atoms[ atom ]; // initialized to 0 if not present yet + ++registered_atoms[atom]; // initialized to 0 if not present yet else { - if (--registered_atoms[ atom ] == 0) + if (--registered_atoms[atom] == 0) registered_atoms.remove(atom); } } @@ -885,7 +839,7 @@ xcb_atom_t EffectsHandlerImpl::announceSupportProperty(const QByteArray &propert } return m_managedProperties.value(propertyName, XCB_ATOM_NONE); } - m_propertiesForEffects.insert(propertyName, QList() << effect); + m_propertiesForEffects.insert(propertyName, QList() << effect); const auto atom = registerSupportProperty(propertyName); if (atom == XCB_ATOM_NONE) { return atom; @@ -926,19 +880,19 @@ QByteArray EffectsHandlerImpl::readRootProperty(long atom, long type, int format return readWindowProperty(kwinApp()->x11RootWindow(), atom, type, format); } -void EffectsHandlerImpl::activateWindow(EffectWindow* c) +void EffectsHandlerImpl::activateWindow(EffectWindow *c) { if (auto cl = qobject_cast(static_cast(c)->window())) { Workspace::self()->activateClient(cl, true); } } -EffectWindow* EffectsHandlerImpl::activeWindow() const +EffectWindow *EffectsHandlerImpl::activeWindow() const { return Workspace::self()->activeClient() ? Workspace::self()->activeClient()->effectWindow() : nullptr; } -void EffectsHandlerImpl::moveWindow(EffectWindow* w, const QPoint& pos, bool snap, double snapAdjust) +void EffectsHandlerImpl::moveWindow(EffectWindow *w, const QPoint &pos, bool snap, double snapAdjust) { auto cl = qobject_cast(static_cast(w)->window()); if (!cl || !cl->isMovable()) @@ -950,7 +904,7 @@ void EffectsHandlerImpl::moveWindow(EffectWindow* w, const QPoint& pos, bool sna cl->move(pos); } -void EffectsHandlerImpl::windowToDesktop(EffectWindow* w, int desktop) +void EffectsHandlerImpl::windowToDesktop(EffectWindow *w, int desktop) { auto cl = qobject_cast(static_cast(w)->window()); if (cl && !cl->isDesktop() && !cl->isDock()) { @@ -960,13 +914,13 @@ void EffectsHandlerImpl::windowToDesktop(EffectWindow* w, int desktop) void EffectsHandlerImpl::windowToDesktops(EffectWindow *w, const QVector &desktopIds) { - AbstractClient* cl = qobject_cast< AbstractClient* >(static_cast(w)->window()); + AbstractClient *cl = qobject_cast(static_cast(w)->window()); if (!cl || cl->isDesktop() || cl->isDock()) { return; } - QVector desktops; + QVector desktops; desktops.reserve(desktopIds.count()); - for (uint x11Id: desktopIds) { + for (uint x11Id : desktopIds) { if (x11Id > VirtualDesktopManager::self()->count()) { continue; } @@ -980,7 +934,7 @@ void EffectsHandlerImpl::windowToDesktops(EffectWindow *w, const QVector & cl->setDesktops(desktops); } -void EffectsHandlerImpl::windowToScreen(EffectWindow* w, EffectScreen *screen) +void EffectsHandlerImpl::windowToScreen(EffectWindow *w, EffectScreen *screen) { auto cl = qobject_cast(static_cast(w)->window()); if (cl && !cl->isDesktop() && !cl->isDock()) { @@ -1109,16 +1063,16 @@ double EffectsHandlerImpl::animationTimeFactor() const return options->animationTimeFactor(); } -EffectWindow* EffectsHandlerImpl::findWindow(WId id) const +EffectWindow *EffectsHandlerImpl::findWindow(WId id) const { if (X11Client *w = Workspace::self()->findClient(Predicate::WindowMatch, id)) return w->effectWindow(); - if (Unmanaged* w = Workspace::self()->findUnmanaged(id)) + if (Unmanaged *w = Workspace::self()->findUnmanaged(id)) return w->effectWindow(); return nullptr; } -EffectWindow* EffectsHandlerImpl::findWindow(KWaylandServer::SurfaceInterface *surf) const +EffectWindow *EffectsHandlerImpl::findWindow(KWaylandServer::SurfaceInterface *surf) const { if (waylandServer()) { if (AbstractClient *w = waylandServer()->findClient(surf)) { @@ -1138,10 +1092,14 @@ EffectWindow *EffectsHandlerImpl::findWindow(QWindow *w) const EffectWindow *EffectsHandlerImpl::findWindow(const QUuid &id) const { - if (const auto client = workspace()->findAbstractClient([&id] (const AbstractClient *c) { return c->internalId() == id; })) { + if (const auto client = workspace()->findAbstractClient([&id](const AbstractClient *c) { + return c->internalId() == id; + })) { return client->effectWindow(); } - if (const auto unmanaged = workspace()->findUnmanaged([&id] (const Unmanaged *c) { return c->internalId() == id; })) { + if (const auto unmanaged = workspace()->findUnmanaged([&id](const Unmanaged *c) { + return c->internalId() == id; + })) { return unmanaged->effectWindow(); } return nullptr; @@ -1158,14 +1116,14 @@ EffectWindowList EffectsHandlerImpl::stackingOrder() const return ret; } -void EffectsHandlerImpl::setElevatedWindow(KWin::EffectWindow* w, bool set) +void EffectsHandlerImpl::setElevatedWindow(KWin::EffectWindow *w, bool set) { elevated_windows.removeAll(w); if (set) elevated_windows.append(w); } -void EffectsHandlerImpl::setTabBoxWindow(EffectWindow* w) +void EffectsHandlerImpl::setTabBoxWindow(EffectWindow *w) { #if KWIN_BUILD_TABBOX if (auto c = qobject_cast(static_cast(w)->window())) { @@ -1192,8 +1150,10 @@ EffectWindowList EffectsHandlerImpl::currentTabBoxWindowList() const EffectWindowList ret; ret.reserve(clients.size()); std::transform(std::cbegin(clients), std::cend(clients), - std::back_inserter(ret), - [](auto client) { return client->effectWindow(); }); + std::back_inserter(ret), + [](auto client) { + return client->effectWindow(); + }); return ret; #else return EffectWindowList(); @@ -1221,12 +1181,12 @@ void EffectsHandlerImpl::closeTabBox() #endif } -QList< int > EffectsHandlerImpl::currentTabBoxDesktopList() const +QList EffectsHandlerImpl::currentTabBoxDesktopList() const { #if KWIN_BUILD_TABBOX return TabBox::TabBox::self()->currentDesktopList(); #else - return QList< int >(); + return QList(); #endif } @@ -1239,7 +1199,7 @@ int EffectsHandlerImpl::currentTabBoxDesktop() const #endif } -EffectWindow* EffectsHandlerImpl::currentTabBoxWindow() const +EffectWindow *EffectsHandlerImpl::currentTabBoxWindow() const { #if KWIN_BUILD_TABBOX if (auto c = TabBox::TabBox::self()->currentClient()) @@ -1253,12 +1213,12 @@ void EffectsHandlerImpl::addRepaintFull() m_compositor->scene()->addRepaintFull(); } -void EffectsHandlerImpl::addRepaint(const QRect& r) +void EffectsHandlerImpl::addRepaint(const QRect &r) { m_compositor->scene()->addRepaint(r); } -void EffectsHandlerImpl::addRepaint(const QRegion& r) +void EffectsHandlerImpl::addRepaint(const QRegion &r) { m_compositor->scene()->addRepaint(r); } @@ -1286,13 +1246,13 @@ QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const EffectScreen *s return Workspace::self()->clientArea(opt, screenImpl->platformOutput(), virtualDesktop); } -QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const EffectWindow* c) const +QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const EffectWindow *c) const { - const Toplevel* t = static_cast< const EffectWindowImpl* >(c)->window(); + const Toplevel *t = static_cast(c)->window(); return Workspace::self()->clientArea(opt, t); } -QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const QPoint& p, int desktop) const +QRect EffectsHandlerImpl::clientArea(clientAreaOption opt, const QPoint &p, int desktop) const { return Workspace::self()->clientArea(opt, p, desktop); } @@ -1358,7 +1318,6 @@ void EffectsHandlerImpl::disconnectNotify(const QMetaMethod &signal) EffectsHandler::disconnectNotify(signal); } - void EffectsHandlerImpl::checkInputWindowStacking() { if (m_grabbedMouseEffects.isEmpty()) { @@ -1393,7 +1352,7 @@ void EffectsHandlerImpl::registerTouchBorder(ElectricBorder border, QAction *act void EffectsHandlerImpl::registerRealtimeTouchBorder(ElectricBorder border, QAction *action, EffectsHandler::TouchBorderCallback progressCallback) { - ScreenEdges::self()->reserveTouch(border, action, [progressCallback] (ElectricBorder border, const QSizeF &deltaProgress, AbstractOutput *output) { + ScreenEdges::self()->reserveTouch(border, action, [progressCallback](ElectricBorder border, const QSizeF &deltaProgress, AbstractOutput *output) { progressCallback(border, deltaProgress, EffectScreenImpl::get(output)); }); } @@ -1408,7 +1367,7 @@ QPainter *EffectsHandlerImpl::scenePainter() return m_scene->scenePainter(); } -void EffectsHandlerImpl::toggleEffect(const QString& name) +void EffectsHandlerImpl::toggleEffect(const QString &name) { if (isEffectLoaded(name)) unloadEffect(name); @@ -1421,8 +1380,10 @@ QStringList EffectsHandlerImpl::loadedEffects() const QStringList listModules; listModules.reserve(loaded_effects.count()); std::transform(loaded_effects.constBegin(), loaded_effects.constEnd(), - std::back_inserter(listModules), - [](const EffectPair &pair) { return pair.first; }); + std::back_inserter(listModules), + [](const EffectPair &pair) { + return pair.first; + }); return listModules; } @@ -1431,7 +1392,7 @@ QStringList EffectsHandlerImpl::listOfEffects() const return m_effectLoader->listOfKnownEffects(); } -bool EffectsHandlerImpl::loadEffect(const QString& name) +bool EffectsHandlerImpl::loadEffect(const QString &name) { makeOpenGLContextCurrent(); m_compositor->scene()->addRepaintFull(); @@ -1439,13 +1400,12 @@ bool EffectsHandlerImpl::loadEffect(const QString& name) return m_effectLoader->loadEffect(name); } -void EffectsHandlerImpl::unloadEffect(const QString& name) +void EffectsHandlerImpl::unloadEffect(const QString &name) { auto it = std::find_if(effect_order.begin(), effect_order.end(), - [name](EffectPair &pair) { - return pair.first == name; - } - ); + [name](EffectPair &pair) { + return pair.first == name; + }); if (it == effect_order.end()) { qCDebug(KWIN_CORE) << "EffectsHandler::unloadEffect : Effect not loaded :" << name; return; @@ -1481,9 +1441,9 @@ void EffectsHandlerImpl::destroyEffect(Effect *effect) delete effect; } -void EffectsHandlerImpl::reconfigureEffect(const QString& name) +void EffectsHandlerImpl::reconfigureEffect(const QString &name) { - for (QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) + for (QVector::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) if ((*it).first == name) { kwinApp()->config()->reparseConfiguration(); makeOpenGLContextCurrent(); @@ -1492,10 +1452,12 @@ void EffectsHandlerImpl::reconfigureEffect(const QString& name) } } -bool EffectsHandlerImpl::isEffectLoaded(const QString& name) const +bool EffectsHandlerImpl::isEffectLoaded(const QString &name) const { auto it = std::find_if(loaded_effects.constBegin(), loaded_effects.constEnd(), - [&name](const EffectPair &pair) { return pair.first == name; }); + [&name](const EffectPair &pair) { + return pair.first == name; + }); return it != loaded_effects.constEnd(); } @@ -1510,7 +1472,6 @@ bool EffectsHandlerImpl::isEffectSupported(const QString &name) makeOpenGLContextCurrent(); return m_effectLoader->isEffectSupported(name); - } QList EffectsHandlerImpl::areEffectsSupported(const QStringList &names) @@ -1518,17 +1479,17 @@ QList EffectsHandlerImpl::areEffectsSupported(const QStringList &names) QList retList; retList.reserve(names.count()); std::transform(names.constBegin(), names.constEnd(), - std::back_inserter(retList), - [this](const QString &name) { - return isEffectSupported(name); - }); + std::back_inserter(retList), + [this](const QString &name) { + return isEffectSupported(name); + }); return retList; } void EffectsHandlerImpl::reloadEffect(Effect *effect) { QString effectName; - for (QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) { + for (QVector::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) { if ((*it).second == effect) { effectName = (*it).first; break; @@ -1547,7 +1508,7 @@ void EffectsHandlerImpl::effectsChanged() loaded_effects.reserve(effect_order.count()); std::copy(effect_order.constBegin(), effect_order.constEnd(), - std::back_inserter(loaded_effects)); + std::back_inserter(loaded_effects)); m_activeEffects.reserve(loaded_effects.count()); } @@ -1555,19 +1516,21 @@ void EffectsHandlerImpl::effectsChanged() QStringList EffectsHandlerImpl::activeEffects() const { QStringList ret; - for(QVector< KWin::EffectPair >::const_iterator it = loaded_effects.constBegin(), - end = loaded_effects.constEnd(); it != end; ++it) { - if (it->second->isActive()) { - ret << it->first; - } + for (QVector::const_iterator it = loaded_effects.constBegin(), + end = loaded_effects.constEnd(); + it != end; ++it) { + if (it->second->isActive()) { + ret << it->first; } + } return ret; } bool EffectsHandlerImpl::blocksDirectScanout() const { - for(QVector< KWin::EffectPair >::const_iterator it = loaded_effects.constBegin(), - end = loaded_effects.constEnd(); it != end; ++it) { + for (QVector::const_iterator it = loaded_effects.constBegin(), + end = loaded_effects.constEnd(); + it != end; ++it) { if (it->second->isActive() && it->second->blocksDirectScanout()) { return true; } @@ -1583,12 +1546,11 @@ KWaylandServer::Display *EffectsHandlerImpl::waylandDisplay() const return nullptr; } -EffectFrame* EffectsHandlerImpl::effectFrame(EffectFrameStyle style, bool staticSize, const QPoint& position, Qt::Alignment alignment) const +EffectFrame *EffectsHandlerImpl::effectFrame(EffectFrameStyle style, bool staticSize, const QPoint &position, Qt::Alignment alignment) const { return new EffectFrameImpl(style, staticSize, position, alignment); } - QVariant EffectsHandlerImpl::kwinOption(KWinOption kwopt) { switch (kwopt) { @@ -1609,14 +1571,16 @@ QVariant EffectsHandlerImpl::kwinOption(KWinOption kwopt) QString EffectsHandlerImpl::supportInformation(const QString &name) const { auto it = std::find_if(loaded_effects.constBegin(), loaded_effects.constEnd(), - [name](const EffectPair &pair) { return pair.first == name; }); + [name](const EffectPair &pair) { + return pair.first == name; + }); if (it == loaded_effects.constEnd()) { return QString(); } QString support((*it).first + QLatin1String(":\n")); const QMetaObject *metaOptions = (*it).second->metaObject(); - for (int i=0; ipropertyCount(); ++i) { + for (int i = 0; i < metaOptions->propertyCount(); ++i) { const QMetaProperty property = metaOptions->property(i); if (qstrcmp(property.name(), "objectName") == 0) { continue; @@ -1627,7 +1591,6 @@ QString EffectsHandlerImpl::supportInformation(const QString &name) const return support; } - bool EffectsHandlerImpl::isScreenLocked() const { #if KWIN_BUILD_SCREENLOCKER @@ -1637,10 +1600,10 @@ bool EffectsHandlerImpl::isScreenLocked() const #endif } -QString EffectsHandlerImpl::debug(const QString& name, const QString& parameter) const +QString EffectsHandlerImpl::debug(const QString &name, const QString ¶meter) const { - QString internalName = name.toLower();; - for (QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) { + QString internalName = name.toLower(); + for (QVector::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) { if ((*it).first == internalName) { return it->second->debug(parameter); } @@ -1692,20 +1655,18 @@ void EffectsHandlerImpl::showCursor() Cursors::self()->showCursor(); } -void EffectsHandlerImpl::startInteractiveWindowSelection(std::function callback) +void EffectsHandlerImpl::startInteractiveWindowSelection(std::function callback) { - kwinApp()->platform()->startInteractiveWindowSelection( - [callback] (KWin::Toplevel *t) { - if (t && t->effectWindow()) { - callback(t->effectWindow()); - } else { - callback(nullptr); - } + kwinApp()->platform()->startInteractiveWindowSelection([callback](KWin::Toplevel *t) { + if (t && t->effectWindow()) { + callback(t->effectWindow()); + } else { + callback(nullptr); } - ); + }); } -void EffectsHandlerImpl::startInteractivePositionSelection(std::function callback) +void EffectsHandlerImpl::startInteractivePositionSelection(std::function callback) { kwinApp()->platform()->startInteractivePositionSelection(callback); } @@ -1736,11 +1697,9 @@ KSharedConfigPtr EffectsHandlerImpl::inputConfig() const Effect *EffectsHandlerImpl::findEffect(const QString &name) const { - auto it = std::find_if(loaded_effects.constBegin(), loaded_effects.constEnd(), - [name] (const EffectPair &pair) { - return pair.first == name; - } - ); + auto it = std::find_if(loaded_effects.constBegin(), loaded_effects.constEnd(), [name](const EffectPair &pair) { + return pair.first == name; + }); if (it == loaded_effects.constEnd()) { return nullptr; } @@ -1923,15 +1882,14 @@ EffectWindowImpl::EffectWindowImpl(Toplevel *toplevel) managed = toplevel->isClient(); waylandClient = qobject_cast(toplevel) != nullptr; - x11Client = qobject_cast(toplevel) != nullptr || - qobject_cast(toplevel) != nullptr; + x11Client = qobject_cast(toplevel) != nullptr || qobject_cast(toplevel) != nullptr; } EffectWindowImpl::~EffectWindowImpl() { QVariant cachedTextureVariant = data(LanczosCacheRole); if (cachedTextureVariant.isValid()) { - GLTexture *cachedTexture = static_cast< GLTexture*>(cachedTextureVariant.value()); + GLTexture *cachedTexture = static_cast(cachedTextureVariant.value()); delete cachedTexture; } } @@ -1976,7 +1934,7 @@ void EffectWindowImpl::addLayerRepaint(int x, int y, int w, int h) toplevel->addLayerRepaint(x, y, w, h); } -const EffectWindowGroup* EffectWindowImpl::group() const +const EffectWindowGroup *EffectWindowImpl::group() const { if (auto c = qobject_cast(toplevel)) { return c->group()->effectGroup(); @@ -1995,7 +1953,7 @@ void EffectWindowImpl::refWindow() void EffectWindowImpl::unrefWindow() { if (auto d = qobject_cast(toplevel)) { - return d->unrefWindow(); // delays deletion in case + return d->unrefWindow(); // delays deletion in case } Q_UNREACHABLE(); // TODO } @@ -2005,10 +1963,10 @@ EffectScreen *EffectWindowImpl::screen() const return EffectScreenImpl::get(toplevel->output()); } -#define TOPLEVEL_HELPER( rettype, prototype, toplevelPrototype) \ - rettype EffectWindowImpl::prototype ( ) const \ - { \ - return toplevel->toplevelPrototype(); \ +#define TOPLEVEL_HELPER(rettype, prototype, toplevelPrototype) \ + rettype EffectWindowImpl::prototype() const \ + { \ + return toplevel->toplevelPrototype(); \ } TOPLEVEL_HELPER(double, opacity, opacity) @@ -2055,18 +2013,18 @@ TOPLEVEL_HELPER(qlonglong, windowId, window) #undef TOPLEVEL_HELPER -#define CLIENT_HELPER_WITH_DELETED( rettype, prototype, propertyname, defaultValue ) \ - rettype EffectWindowImpl::prototype ( ) const \ - { \ - auto client = qobject_cast(toplevel); \ - if (client) { \ - return client->propertyname(); \ - } \ - auto deleted = qobject_cast(toplevel); \ - if (deleted) { \ - return deleted->propertyname(); \ - } \ - return defaultValue; \ +#define CLIENT_HELPER_WITH_DELETED(rettype, prototype, propertyname, defaultValue) \ + rettype EffectWindowImpl::prototype() const \ + { \ + auto client = qobject_cast(toplevel); \ + if (client) { \ + return client->propertyname(); \ + } \ + auto deleted = qobject_cast(toplevel); \ + if (deleted) { \ + return deleted->propertyname(); \ + } \ + return defaultValue; \ } CLIENT_HELPER_WITH_DELETED(bool, isMinimized, isMinimized, false) @@ -2100,14 +2058,14 @@ NET::WindowType EffectWindowImpl::windowType() const return toplevel->windowType(); } -#define CLIENT_HELPER( rettype, prototype, propertyname, defaultValue ) \ - rettype EffectWindowImpl::prototype ( ) const \ - { \ - auto client = qobject_cast(toplevel); \ - if (client) { \ - return client->propertyname(); \ - } \ - return defaultValue; \ +#define CLIENT_HELPER(rettype, prototype, propertyname, defaultValue) \ + rettype EffectWindowImpl::prototype() const \ + { \ + auto client = qobject_cast(toplevel); \ + if (client) { \ + return client->propertyname(); \ + } \ + return defaultValue; \ } CLIENT_HELPER(bool, isMovable, isMovable, false) @@ -2126,19 +2084,19 @@ CLIENT_HELPER(bool, isUnresponsive, unresponsive, false) QSize EffectWindowImpl::basicUnit() const { - if (auto client = qobject_cast(toplevel)){ + if (auto client = qobject_cast(toplevel)) { return client->basicUnit(); } - return QSize(1,1); + return QSize(1, 1); } -void EffectWindowImpl::setWindow(Toplevel* w) +void EffectWindowImpl::setWindow(Toplevel *w) { toplevel = w; setParent(w); } -void EffectWindowImpl::setSceneWindow(Scene::Window* w) +void EffectWindowImpl::setSceneWindow(Scene::Window *w) { sw = w; } @@ -2173,7 +2131,7 @@ void EffectWindowImpl::deleteProperty(long int atom) const } } -EffectWindow* EffectWindowImpl::findModal() +EffectWindow *EffectWindowImpl::findModal() { auto client = qobject_cast(toplevel); if (!client) { @@ -2188,7 +2146,7 @@ EffectWindow* EffectWindowImpl::findModal() return nullptr; } -EffectWindow* EffectWindowImpl::transientFor() +EffectWindow *EffectWindowImpl::transientFor() { auto client = qobject_cast(toplevel); if (!client) { @@ -2212,15 +2170,17 @@ QWindow *EffectWindowImpl::internalWindow() const return client->internalWindow(); } -template +template EffectWindowList getMainWindows(T *c) { const auto mainclients = c->mainClients(); EffectWindowList ret; ret.reserve(mainclients.size()); std::transform(std::cbegin(mainclients), std::cend(mainclients), - std::back_inserter(ret), - [](auto client) { return client->effectWindow(); }); + std::back_inserter(ret), + [](auto client) { + return client->effectWindow(); + }); return ret; } @@ -2238,7 +2198,7 @@ EffectWindowList EffectWindowImpl::mainWindows() const void EffectWindowImpl::setData(int role, const QVariant &data) { if (!data.isNull()) - dataMap[ role ] = data; + dataMap[role] = data; else dataMap.remove(role); Q_EMIT effects->windowDataChanged(this, role); @@ -2249,15 +2209,15 @@ QVariant EffectWindowImpl::data(int role) const return dataMap.value(role); } -EffectWindow* effectWindow(Toplevel* w) +EffectWindow *effectWindow(Toplevel *w) { - EffectWindowImpl* ret = w->effectWindow(); + EffectWindowImpl *ret = w->effectWindow(); return ret; } -EffectWindow* effectWindow(Scene::Window* w) +EffectWindow *effectWindow(Scene::Window *w) { - EffectWindowImpl* ret = w->window()->effectWindow(); + EffectWindowImpl *ret = w->window()->effectWindow(); ret->setSceneWindow(w); return ret; } @@ -2317,20 +2277,20 @@ bool EffectWindowImpl::isX11Client() const return x11Client; } - //**************************************** // EffectWindowGroupImpl //**************************************** - EffectWindowList EffectWindowGroupImpl::members() const { const auto memberList = group->members(); EffectWindowList ret; ret.reserve(memberList.size()); std::transform(std::cbegin(memberList), std::cend(memberList), - std::back_inserter(ret), - [](auto toplevel) { return toplevel->effectWindow(); }); + std::back_inserter(ret), + [](auto toplevel) { + return toplevel->effectWindow(); + }); return ret; } @@ -2366,12 +2326,12 @@ EffectFrameImpl::~EffectFrameImpl() delete m_sceneFrame; } -const QFont& EffectFrameImpl::font() const +const QFont &EffectFrameImpl::font() const { return m_font; } -void EffectFrameImpl::setFont(const QFont& font) +void EffectFrameImpl::setFont(const QFont &font) { if (m_font == font) { return; @@ -2392,12 +2352,12 @@ void EffectFrameImpl::free() m_sceneFrame->free(); } -const QRect& EffectFrameImpl::geometry() const +const QRect &EffectFrameImpl::geometry() const { return m_geometry; } -void EffectFrameImpl::setGeometry(const QRect& geometry, bool force) +void EffectFrameImpl::setGeometry(const QRect &geometry, bool force) { QRect oldGeom = m_geometry; m_geometry = geometry; @@ -2412,19 +2372,19 @@ void EffectFrameImpl::setGeometry(const QRect& geometry, bool force) if (m_style == EffectFrameStyled) { qreal left, top, right, bottom; - m_frame.getMargins(left, top, right, bottom); // m_geometry is the inner geometry + m_frame.getMargins(left, top, right, bottom); // m_geometry is the inner geometry m_frame.resizeFrame(m_geometry.adjusted(-left, -top, right, bottom).size()); } free(); } -const QIcon& EffectFrameImpl::icon() const +const QIcon &EffectFrameImpl::icon() const { return m_icon; } -void EffectFrameImpl::setIcon(const QIcon& icon) +void EffectFrameImpl::setIcon(const QIcon &icon) { m_icon = icon; if (isCrossFade()) { @@ -2436,12 +2396,12 @@ void EffectFrameImpl::setIcon(const QIcon& icon) m_sceneFrame->freeIconFrame(); } -const QSize& EffectFrameImpl::iconSize() const +const QSize &EffectFrameImpl::iconSize() const { return m_iconSize; } -void EffectFrameImpl::setIconSize(const QSize& size) +void EffectFrameImpl::setIconSize(const QSize &size) { if (m_iconSize == size) { return; @@ -2462,7 +2422,7 @@ void EffectFrameImpl::render(const QRegion ®ion, double opacity, double frame return; // Nothing to display } m_shader = nullptr; - setScreenProjectionMatrix(static_cast(effects)->scene()->screenProjectionMatrix()); + setScreenProjectionMatrix(static_cast(effects)->scene()->screenProjectionMatrix()); effects->paintEffectFrame(this, region, opacity, frameOpacity); } @@ -2478,9 +2438,7 @@ Qt::Alignment EffectFrameImpl::alignment() const return m_alignment; } - -void -EffectFrameImpl::align(QRect &geometry) +void EffectFrameImpl::align(QRect &geometry) { if (m_alignment & Qt::AlignLeft) geometry.moveLeft(m_point.x()); @@ -2496,7 +2454,6 @@ EffectFrameImpl::align(QRect &geometry) geometry.moveTop(m_point.y() - geometry.height() / 2); } - void EffectFrameImpl::setAlignment(Qt::Alignment alignment) { m_alignment = alignment; @@ -2504,7 +2461,7 @@ void EffectFrameImpl::setAlignment(Qt::Alignment alignment) setGeometry(m_geometry); } -void EffectFrameImpl::setPosition(const QPoint& point) +void EffectFrameImpl::setPosition(const QPoint &point) { m_point = point; QRect geometry = m_geometry; // this is important, setGeometry need call repaint for old & new geometry @@ -2512,12 +2469,12 @@ void EffectFrameImpl::setPosition(const QPoint& point) setGeometry(geometry); } -const QString& EffectFrameImpl::text() const +const QString &EffectFrameImpl::text() const { return m_text; } -void EffectFrameImpl::setText(const QString& text) +void EffectFrameImpl::setText(const QString &text) { if (m_text == text) { return; @@ -2534,7 +2491,7 @@ void EffectFrameImpl::setText(const QString& text) } } -void EffectFrameImpl::setSelection(const QRect& selection) +void EffectFrameImpl::setSelection(const QRect &selection) { if (selection == m_selectionGeometry) { return; diff --git a/src/effects.h b/src/effects.h index fb1f71213d..30298d40ea 100644 --- a/src/effects.h +++ b/src/effects.h @@ -15,15 +15,16 @@ #include "scene.h" -#include #include +#include #include class QMouseEvent; class QWheelEvent; -namespace Plasma { +namespace Plasma +{ class Theme; } @@ -35,7 +36,6 @@ class Display; class QDBusPendingCallWatcher; class QDBusServiceWatcher; - namespace KWin { class AbstractClient; @@ -60,27 +60,27 @@ class KWIN_EXPORT EffectsHandlerImpl : public EffectsHandler public: EffectsHandlerImpl(Compositor *compositor, Scene *scene); ~EffectsHandlerImpl() override; - void prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) override; - void paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) override; + void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; + void paintScreen(int mask, const QRegion ®ion, 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 paintDesktop(int desktop, int mask, QRegion region, ScreenPaintData &data); void postPaintScreen() override; - void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime) override; - void paintWindow(EffectWindow* w, int mask, const QRegion ®ion, WindowPaintData& data) override; - void postPaintWindow(EffectWindow* w) override; - void paintEffectFrame(EffectFrame* frame, const QRegion ®ion, double opacity, double frameOpacity) override; + void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) override; + void paintWindow(EffectWindow *w, int mask, const QRegion ®ion, WindowPaintData &data) override; + void postPaintWindow(EffectWindow *w) override; + void paintEffectFrame(EffectFrame *frame, const QRegion ®ion, double opacity, double frameOpacity) override; Effect *provides(Effect::Feature ef); - void drawWindow(EffectWindow* w, int mask, const QRegion ®ion, WindowPaintData& data) override; + void drawWindow(EffectWindow *w, int mask, const QRegion ®ion, WindowPaintData &data) 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, EffectScreen *screen) 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, EffectScreen *screen) override; void setShowingDesktop(bool showing) override; QString currentActivity() const override; @@ -104,7 +104,7 @@ public: bool optionRollOverDesktops() const override; QPoint cursorPos() const override; - bool grabKeyboard(Effect* effect) override; + bool grabKeyboard(Effect *effect) override; void ungrabKeyboard() override; // not performing XGrabPointer void startMouseInterception(Effect *effect, Qt::CursorShape shape) override; @@ -113,42 +113,42 @@ public: 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 registerRealtimeTouchpadSwipeShortcut(SwipeDirection dir, uint fingerCount, QAction* onUp, std::function progressCallback) override; + void registerRealtimeTouchpadSwipeShortcut(SwipeDirection dir, uint fingerCount, QAction *onUp, std::function progressCallback) override; void registerTouchpadSwipeShortcut(SwipeDirection direction, uint fingerCount, QAction *action) override; - void registerRealtimeTouchpadPinchShortcut(PinchDirection dir, uint fingerCount, QAction* onUp, std::function progressCallback) override; + void registerRealtimeTouchpadPinchShortcut(PinchDirection dir, uint fingerCount, QAction *onUp, std::function progressCallback) override; void registerTouchpadPinchShortcut(PinchDirection direction, uint fingerCount, QAction *action) override; - void* getProxy(QString name) override; + void *getProxy(QString name) override; void startMousePolling() override; void stopMousePolling() override; - EffectWindow* findWindow(WId id) const override; - EffectWindow* findWindow(KWaylandServer::SurfaceInterface *surf) const override; + EffectWindow *findWindow(WId id) const override; + EffectWindow *findWindow(KWaylandServer::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 setElevatedWindow(KWin::EffectWindow *w, bool set) override; - void setTabBoxWindow(EffectWindow*) 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; + QList currentTabBoxDesktopList() const override; int currentTabBoxDesktop() const override; - EffectWindow* currentTabBoxWindow() const override; + EffectWindow *currentTabBoxWindow() const override; - void setActiveFullScreenEffect(Effect* e) override; - Effect* activeFullScreenEffect() 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(const QRect &r) override; + void addRepaint(const QRegion &r) override; void addRepaint(int x, int y, int w, int h) override; EffectScreen *activeScreen() const override; QRect clientArea(clientAreaOption, const EffectScreen *screen, int desktop) const override; - QRect clientArea(clientAreaOption, const EffectWindow* c) const override; - QRect clientArea(clientAreaOption, const QPoint& p, 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; @@ -165,17 +165,17 @@ public: void registerRealtimeTouchBorder(ElectricBorder border, QAction *action, EffectsHandler::TouchBorderCallback progressCallback) override; void unregisterTouchBorder(ElectricBorder border, QAction *action) override; - QPainter* scenePainter() 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; + 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; - EffectFrame* effectFrame(EffectFrameStyle style, bool staticSize, const QPoint& position, Qt::Alignment alignment) 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; @@ -188,7 +188,7 @@ public: // internal (used by kwin core or compositing code) void startPaint(); - void grabbedKeyboardEvent(QKeyEvent* e); + void grabbedKeyboardEvent(QKeyEvent *e); bool hasKeyboardGrab() const; void reloadEffect(Effect *effect) override; @@ -196,7 +196,7 @@ public: QStringList listOfEffects() const; void unloadAllEffects(); - QList elevatedWindows() const; + QList elevatedWindows() const; QStringList activeEffects() const; /** @@ -207,13 +207,15 @@ public: /** * @returns Whether we are currently in a desktop rendering process triggered by paintDesktop hook */ - bool isDesktopRendering() const { + bool isDesktopRendering() const + { return m_desktopRendering; } /** * @returns the desktop currently being rendered in the paintDesktop hook. */ - int currentRenderedDesktop() const { + int currentRenderedDesktop() const + { return m_currentRenderedDesktop; } @@ -226,7 +228,7 @@ public: void hideCursor() override; void showCursor() override; - void startInteractiveWindowSelection(std::function callback) override; + void startInteractiveWindowSelection(std::function callback) override; void startInteractivePositionSelection(std::function callback) override; void showOnScreenMessage(const QString &message, const QString &iconName = QString()) override; @@ -235,7 +237,8 @@ public: KSharedConfigPtr config() const override; KSharedConfigPtr inputConfig() const override; - Scene *scene() const { + Scene *scene() const + { return m_scene; } @@ -251,7 +254,8 @@ public: void highlightWindows(const QVector &windows); - bool isPropertyTypeRegistered(xcb_atom_t atom) const { + bool isPropertyTypeRegistered(xcb_atom_t atom) const + { return registered_atoms.contains(atom); } @@ -282,31 +286,31 @@ public: bool isInputPanelOverlay() const override; public Q_SLOTS: - void slotCurrentTabAboutToChange(EffectWindow* from, EffectWindow* to); - void slotTabAdded(EffectWindow* from, EffectWindow* to); - void slotTabRemoved(EffectWindow* c, EffectWindow* newActiveWindow); + 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 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; + Q_SCRIPTABLE QString supportInformation(const QString &name) const; + Q_SCRIPTABLE QString debug(const QString &name, const QString ¶meter = QString()) const; protected Q_SLOTS: - void slotClientShown(KWin::Toplevel*); - void slotUnmanagedShown(KWin::Toplevel*); + void slotClientShown(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 slotFrameGeometryChanged(Toplevel *toplevel, const QRect &oldGeometry); - void slotWindowDamaged(KWin::Toplevel *t, const QRegion& r); + void slotWindowDamaged(KWin::Toplevel *t, const QRegion &r); void slotOutputEnabled(AbstractOutput *output); void slotOutputDisabled(AbstractOutput *output); @@ -341,31 +345,31 @@ protected: */ virtual void doCheckInputWindowStacking(); - Effect* keyboard_grab_effect; - Effect* fullscreen_effect; - QList elevated_windows; - QMultiMap< int, EffectPair > effect_order; - QHash< long, int > registered_atoms; + Effect *keyboard_grab_effect; + Effect *fullscreen_effect; + QList elevated_windows; + QMultiMap effect_order; + QHash registered_atoms; private: void registerPropertyType(long atom, bool reg); void destroyEffect(Effect *effect); - typedef QVector< Effect*> EffectsList; + typedef QVector EffectsList; typedef EffectsList::const_iterator EffectsIterator; EffectsList m_activeEffects; EffectsIterator m_currentDrawWindowIterator; EffectsIterator m_currentPaintWindowIterator; EffectsIterator m_currentPaintEffectFrameIterator; EffectsIterator m_currentPaintScreenIterator; - typedef QHash< QByteArray, QList< Effect*> > PropertyEffectMap; + typedef QHash> PropertyEffectMap; PropertyEffectMap m_propertiesForEffects; QHash m_managedProperties; Compositor *m_compositor; Scene *m_scene; bool m_desktopRendering; int m_currentRenderedDesktop; - QList m_grabbedMouseEffects; + QList m_grabbedMouseEffects; EffectLoader *m_effectLoader; int m_trackingCursorChanges; std::unique_ptr m_x11WindowPropertyNotify; @@ -413,7 +417,7 @@ public: void refWindow() override; void unrefWindow() override; - const EffectWindowGroup* group() const override; + const EffectWindowGroup *group() const override; bool isDeleted() const override; bool isMinimized() const override; @@ -500,8 +504,8 @@ public: QByteArray readProperty(long atom, long type, int format) const override; void deleteProperty(long atom) const override; - EffectWindow* findModal() override; - EffectWindow* transientFor() override; + EffectWindow *findModal() override; + EffectWindow *transientFor() override; EffectWindowList mainWindows() const override; void minimize() override; @@ -513,13 +517,13 @@ public: QWindow *internalWindow() const override; - const Toplevel* window() const; - Toplevel* window(); + 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 setWindow(Toplevel *w); // internal + void setSceneWindow(Scene::Window *w); // internal + const Scene::Window *sceneWindow() const; // internal + Scene::Window *sceneWindow(); // internal void elevate(bool elevate); @@ -527,8 +531,8 @@ public: QVariant data(int role) const override; private: - Toplevel* toplevel; - Scene::Window* sw; // This one is used only during paint pass. + Toplevel *toplevel; + Scene::Window *sw; // This one is used only during paint pass. QHash dataMap; bool managed = false; bool waylandClient; @@ -539,14 +543,16 @@ class EffectWindowGroupImpl : public EffectWindowGroup { public: - explicit EffectWindowGroupImpl(Group* g); + explicit EffectWindowGroupImpl(Group *g); EffectWindowList members() const override; + private: - Group* group; + Group *group; }; class KWIN_EXPORT EffectFrameImpl - : public QObject, public EffectFrame + : public QObject, + public EffectFrame { Q_OBJECT public: @@ -558,38 +564,45 @@ public: void render(const QRegion ®ion = 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 { + 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() { + Plasma::FrameSvg &frame() + { return m_frame; } - bool isStatic() const { + bool isStatic() const + { return m_static; } void finalRender(QRegion region, double opacity, double frameOpacity) const; - void setShader(GLShader* shader) override { + void setShader(GLShader *shader) override + { m_shader = shader; } - GLShader* shader() const override { + GLShader *shader() const override + { return m_shader; } - void setSelection(const QRect& selection) override; - const QRect& selection() const { + void setSelection(const QRect &selection) override; + const QRect &selection() const + { return m_selectionGeometry; } - Plasma::FrameSvg& selectionFrame() { + Plasma::FrameSvg &selectionFrame() + { return m_selection; } /** @@ -601,8 +614,8 @@ 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 + 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; @@ -622,66 +635,57 @@ private: QSize m_iconSize; QRect m_selectionGeometry; - Scene::EffectFrame* m_sceneFrame; - GLShader* m_shader; + Scene::EffectFrame *m_sceneFrame; + GLShader *m_shader; Plasma::Theme *m_theme; }; -inline -QList EffectsHandlerImpl::elevatedWindows() const +inline QList EffectsHandlerImpl::elevatedWindows() const { if (isScreenLocked()) - return QList(); + return QList(); return elevated_windows; } -inline -xcb_window_t EffectsHandlerImpl::x11RootWindow() const +inline xcb_window_t EffectsHandlerImpl::x11RootWindow() const { return kwinApp()->x11RootWindow(); } -inline -xcb_connection_t *EffectsHandlerImpl::xcbConnection() const +inline xcb_connection_t *EffectsHandlerImpl::xcbConnection() const { return kwinApp()->x11Connection(); } -inline -EffectWindowGroupImpl::EffectWindowGroupImpl(Group* g) +inline EffectWindowGroupImpl::EffectWindowGroupImpl(Group *g) : group(g) { } -EffectWindow* effectWindow(Toplevel* w); -EffectWindow* effectWindow(Scene::Window* w); +EffectWindow *effectWindow(Toplevel *w); +EffectWindow *effectWindow(Scene::Window *w); -inline -const Scene::Window* EffectWindowImpl::sceneWindow() const +inline const Scene::Window *EffectWindowImpl::sceneWindow() const { return sw; } -inline -Scene::Window* EffectWindowImpl::sceneWindow() +inline Scene::Window *EffectWindowImpl::sceneWindow() { return sw; } -inline -const Toplevel* EffectWindowImpl::window() const +inline const Toplevel *EffectWindowImpl::window() const { return toplevel; } -inline -Toplevel* EffectWindowImpl::window() +inline Toplevel *EffectWindowImpl::window() { return toplevel; } - } // namespace #endif diff --git a/src/effects/backgroundcontrast/contrast.cpp b/src/effects/backgroundcontrast/contrast.cpp index a8e29b8181..722b3642ef 100644 --- a/src/effects/backgroundcontrast/contrast.cpp +++ b/src/effects/backgroundcontrast/contrast.cpp @@ -15,8 +15,8 @@ #include #include -#include #include +#include namespace KWin { @@ -57,13 +57,11 @@ ContrastEffect::ContrastEffect() connect(effects, &EffectsHandler::windowDeleted, this, &ContrastEffect::slotWindowDeleted); connect(effects, &EffectsHandler::propertyNotify, this, &ContrastEffect::slotPropertyNotify); connect(effects, &EffectsHandler::virtualScreenGeometryChanged, this, &ContrastEffect::slotScreenGeometryChanged); - connect(effects, &EffectsHandler::xcbConnectionChanged, this, - [this] { - if (shader && shader->isValid()) { - net_wm_contrast_region = effects->announceSupportProperty(s_contrastAtomName, this); - } + connect(effects, &EffectsHandler::xcbConnectionChanged, this, [this]() { + if (shader && shader->isValid()) { + net_wm_contrast_region = effects->announceSupportProperty(s_contrastAtomName, this); } - ); + }); // Fetch the contrast regions for all windows const EffectWindowList windowList = effects->stackingOrder(); @@ -105,8 +103,8 @@ void ContrastEffect::updateContrastRegion(EffectWindow *w) const QByteArray value = w->readProperty(net_wm_contrast_region, net_wm_contrast_region, 32); if (value.size() > 0 && !((value.size() - (16 * sizeof(uint32_t))) % ((4 * sizeof(uint32_t))))) { - const uint32_t *cardinals = reinterpret_cast(value.constData()); - const float *floatCardinals = reinterpret_cast(value.constData()); + const uint32_t *cardinals = reinterpret_cast(value.constData()); + const float *floatCardinals = reinterpret_cast(value.constData()); unsigned int i = 0; for (; i < ((value.size() - (16 * sizeof(uint32_t)))) / sizeof(uint32_t);) { int x = cardinals[i++]; @@ -173,8 +171,7 @@ void ContrastEffect::slotWindowAdded(EffectWindow *w) KWaylandServer::SurfaceInterface *surf = w->surface(); if (surf) { - m_contrastChangedConnections[w] = connect(surf, &KWaylandServer::SurfaceInterface::contrastChanged, this, [this, w] () { - + m_contrastChangedConnections[w] = connect(surf, &KWaylandServer::SurfaceInterface::contrastChanged, this, [this, w]() { if (w) { updateContrastRegion(w); } @@ -190,13 +187,10 @@ void ContrastEffect::slotWindowAdded(EffectWindow *w) bool ContrastEffect::eventFilter(QObject *watched, QEvent *event) { - auto internal = qobject_cast(watched); + auto internal = qobject_cast(watched); if (internal && event->type() == QEvent::DynamicPropertyChange) { - QDynamicPropertyChangeEvent *pe = static_cast(event); - if (pe->propertyName() == "kwin_background_region" || - pe->propertyName() == "kwin_background_contrast" || - pe->propertyName() == "kwin_background_intensity" || - pe->propertyName() == "kwin_background_saturation") { + QDynamicPropertyChangeEvent *pe = static_cast(event); + if (pe->propertyName() == "kwin_background_region" || pe->propertyName() == "kwin_background_contrast" || pe->propertyName() == "kwin_background_intensity" || pe->propertyName() == "kwin_background_saturation") { if (auto w = effects->findWindow(internal)) { updateContrastRegion(w); } @@ -223,39 +217,39 @@ void ContrastEffect::slotPropertyNotify(EffectWindow *w, long atom) QMatrix4x4 ContrastEffect::colorMatrix(qreal contrast, qreal intensity, qreal saturation) { - QMatrix4x4 satMatrix; //saturation - QMatrix4x4 intMatrix; //intensity - QMatrix4x4 contMatrix; //contrast + QMatrix4x4 satMatrix; // saturation + QMatrix4x4 intMatrix; // intensity + QMatrix4x4 contMatrix; // contrast - //Saturation matrix + // Saturation matrix if (!qFuzzyCompare(saturation, 1.0)) { const qreal rval = (1.0 - saturation) * .2126; const qreal gval = (1.0 - saturation) * .7152; const qreal bval = (1.0 - saturation) * .0722; - satMatrix = QMatrix4x4(rval + saturation, rval, rval, 0.0, - gval, gval + saturation, gval, 0.0, - bval, bval, bval + saturation, 0.0, - 0, 0, 0, 1.0); + satMatrix = QMatrix4x4(rval + saturation, rval, rval, 0.0, + gval, gval + saturation, gval, 0.0, + bval, bval, bval + saturation, 0.0, + 0, 0, 0, 1.0); } - //IntensityMatrix + // IntensityMatrix if (!qFuzzyCompare(intensity, 1.0)) { intMatrix.scale(intensity, intensity, intensity); } - //Contrast Matrix + // Contrast Matrix if (!qFuzzyCompare(contrast, 1.0)) { const float transl = (1.0 - contrast) / 2.0; - contMatrix = QMatrix4x4(contrast, 0, 0, 0.0, - 0, contrast, 0, 0.0, - 0, 0, contrast, 0.0, - transl, transl, transl, 1.0); + contMatrix = QMatrix4x4(contrast, 0, 0, 0.0, + 0, contrast, 0, 0.0, + 0, 0, contrast, 0.0, + transl, transl, transl, 1.0); } QMatrix4x4 colorMatrix = contMatrix * satMatrix * intMatrix; - //colorMatrix = colorMatrix.transposed(); + // colorMatrix = colorMatrix.transposed(); return colorMatrix; } @@ -298,8 +292,7 @@ QRegion ContrastEffect::contrastRegion(const EffectWindow *w) const if (value.isValid()) { const QRegion appRegion = qvariant_cast(value); if (!appRegion.isEmpty()) { - region |= appRegion.translated(w->contentsRect().topLeft()) & - w->decorationInnerRect(); + region |= appRegion.translated(w->contentsRect().topLeft()) & w->decorationInnerRect(); } else { // An empty region means that the blur effect should be enabled // for the whole window. @@ -336,14 +329,13 @@ void ContrastEffect::uploadGeometry(GLVertexBuffer *vbo, const QRegion ®ion) if (!vertexCount) return; - QVector2D *map = (QVector2D *) vbo->map(vertexCount * sizeof(QVector2D)); + QVector2D *map = (QVector2D *)vbo->map(vertexCount * sizeof(QVector2D)); uploadRegion(map, region); vbo->unmap(); const GLVertexAttrib layout[] = { - { VA_Position, 2, GL_FLOAT, 0 }, - { VA_TexCoord, 2, GL_FLOAT, 0 } - }; + {VA_Position, 2, GL_FLOAT, 0}, + {VA_TexCoord, 2, GL_FLOAT, 0}}; vbo->setAttribLayout(layout, 2, sizeof(QVector2D)); } @@ -385,14 +377,14 @@ void ContrastEffect::drawWindow(EffectWindow *w, int mask, const QRegion ®ion QRegion scaledShape; for (QRect r : shape) { r.moveTo(pt.x() + (r.x() - pt.x()) * data.xScale() + data.xTranslation(), - pt.y() + (r.y() - pt.y()) * data.yScale() + data.yTranslation()); + pt.y() + (r.y() - pt.y()) * data.yScale() + data.yTranslation()); r.setWidth(r.width() * data.xScale()); r.setHeight(r.height() * data.yScale()); scaledShape |= r; } shape = scaledShape & region; - //Only translated, not scaled + // Only translated, not scaled } else if (translated) { shape = shape.translated(data.xTranslation(), data.yTranslation()); shape = shape & region; @@ -409,11 +401,11 @@ void ContrastEffect::drawWindow(EffectWindow *w, int mask, const QRegion ®ion void ContrastEffect::paintEffectFrame(EffectFrame *frame, const QRegion ®ion, double opacity, double frameOpacity) { - //FIXME: this is a no-op for now, it should figure out the right contrast, intensity, saturation + // FIXME: this is a no-op for now, it should figure out the right contrast, intensity, saturation effects->paintEffectFrame(frame, region, opacity, frameOpacity); } -void ContrastEffect::doContrast(EffectWindow *w, const QRegion& shape, const QRect& screen, const float opacity, const QMatrix4x4 &screenProjection) +void ContrastEffect::doContrast(EffectWindow *w, const QRegion &shape, const QRect &screen, const float opacity, const QMatrix4x4 &screenProjection) { const QRegion actualShape = shape & screen; const QRect r = actualShape.boundingRect(); @@ -442,7 +434,6 @@ void ContrastEffect::doContrast(EffectWindow *w, const QRegion& shape, const QRe shader->setColorMatrix(m_colorMatrices.value(w)); shader->bind(); - shader->setOpacity(opacity); // Set up the texture matrix to transform from screen coordinates // to texture coordinates. @@ -477,4 +468,3 @@ bool ContrastEffect::blocksDirectScanout() const } } // namespace KWin - diff --git a/src/effects/backgroundcontrast/contrast.h b/src/effects/backgroundcontrast/contrast.h index 8e3614e1a8..236eaa867d 100644 --- a/src/effects/backgroundcontrast/contrast.h +++ b/src/effects/backgroundcontrast/contrast.h @@ -12,8 +12,8 @@ #include #include -#include #include +#include #include @@ -39,7 +39,8 @@ public: bool provides(Feature feature) override; bool isActive() const override; - int requestedEffectChainPosition() const override { + int requestedEffectChainPosition() const override + { return 76; } @@ -64,14 +65,13 @@ private: private: ContrastShader *shader; long net_wm_contrast_region = 0; - QHash< const EffectWindow*, QMatrix4x4> m_colorMatrices; - QHash< const EffectWindow*, QMetaObject::Connection > m_contrastChangedConnections; // used only in Wayland to keep track of effect changed + QHash m_colorMatrices; + QHash m_contrastChangedConnections; // used only in Wayland to keep track of effect changed static KWaylandServer::ContrastManagerInterface *s_contrastManager; static QTimer *s_contrastManagerRemoveTimer; }; -inline -bool ContrastEffect::provides(Effect::Feature feature) +inline bool ContrastEffect::provides(Effect::Feature feature) { if (feature == Contrast) { return true; @@ -79,8 +79,6 @@ bool ContrastEffect::provides(Effect::Feature feature) return KWin::Effect::provides(feature); } - } // namespace KWin #endif - diff --git a/src/effects/backgroundcontrast/contrastshader.cpp b/src/effects/backgroundcontrast/contrastshader.cpp index 568db6b9bc..7951f4271a 100644 --- a/src/effects/backgroundcontrast/contrastshader.cpp +++ b/src/effects/backgroundcontrast/contrastshader.cpp @@ -21,7 +21,9 @@ namespace KWin { ContrastShader::ContrastShader() - : mValid(false), shader(nullptr), m_opacity(1) + : mValid(false) + , shader(nullptr) + , m_opacity(1) { } @@ -107,11 +109,11 @@ void ContrastShader::init() QByteArray vertexSource; QByteArray fragmentSource; - const QByteArray attribute = core ? "in" : "attribute"; - const QByteArray varying_in = core ? (gles ? "in" : "noperspective in") : "varying"; + const QByteArray attribute = core ? "in" : "attribute"; + const QByteArray varying_in = core ? (gles ? "in" : "noperspective in") : "varying"; const QByteArray varying_out = core ? (gles ? "out" : "noperspective out") : "varying"; - const QByteArray texture2D = core ? "texture" : "texture2D"; - const QByteArray fragColor = core ? "fragColor" : "gl_FragColor"; + const QByteArray texture2D = core ? "texture" : "texture2D"; + const QByteArray fragColor = core ? "fragColor" : "gl_FragColor"; // Vertex shader // =================================================================== @@ -138,7 +140,6 @@ void ContrastShader::init() stream << "}\n"; stream.flush(); - // Fragment shader // =================================================================== QTextStream stream2(&fragmentSource); @@ -178,8 +179,8 @@ void ContrastShader::init() if (shader->isValid()) { colorMatrixLocation = shader->uniformLocation("colorMatrix"); textureMatrixLocation = shader->uniformLocation("textureMatrix"); - mvpMatrixLocation = shader->uniformLocation("modelViewProjectionMatrix"); - opacityLocation = shader->uniformLocation("opacity"); + mvpMatrixLocation = shader->uniformLocation("modelViewProjectionMatrix"); + opacityLocation = shader->uniformLocation("opacity"); QMatrix4x4 modelViewProjection; const QSize screenSize = effects->virtualScreenSize(); diff --git a/src/effects/backgroundcontrast/contrastshader.h b/src/effects/backgroundcontrast/contrastshader.h index 8e254bcc50..badab490c4 100644 --- a/src/effects/backgroundcontrast/contrastshader.h +++ b/src/effects/backgroundcontrast/contrastshader.h @@ -25,7 +25,8 @@ public: static ContrastShader *create(); - bool isValid() const { + bool isValid() const + { return mValid; } @@ -41,7 +42,8 @@ public: float opacity() const; protected: - void setIsValid(bool value) { + void setIsValid(bool value) + { mValid = value; } void reset(); @@ -56,8 +58,6 @@ private: float m_opacity; }; - } // namespace KWin #endif - diff --git a/src/effects/backgroundcontrast/main.cpp b/src/effects/backgroundcontrast/main.cpp index e9047af1fe..ad7e6d810c 100644 --- a/src/effects/backgroundcontrast/main.cpp +++ b/src/effects/backgroundcontrast/main.cpp @@ -11,7 +11,8 @@ namespace KWin KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED(ContrastEffect, "metadata.json.stripped", - return ContrastEffect::supported();, + return ContrastEffect::supported(); + , return ContrastEffect::enabledByDefault();) } // namespace KWin diff --git a/src/effects/blur/blur.cpp b/src/effects/blur/blur.cpp index 09f3bbaf2e..8af5b7a187 100644 --- a/src/effects/blur/blur.cpp +++ b/src/effects/blur/blur.cpp @@ -20,11 +20,11 @@ #include // for ceil() #include -#include -#include -#include -#include #include +#include +#include +#include +#include #include @@ -71,13 +71,11 @@ BlurEffect::BlurEffect() connect(effects, &EffectsHandler::windowDecorationChanged, this, &BlurEffect::setupDecorationConnections); connect(effects, &EffectsHandler::propertyNotify, this, &BlurEffect::slotPropertyNotify); connect(effects, &EffectsHandler::virtualScreenGeometryChanged, this, &BlurEffect::slotScreenGeometryChanged); - connect(effects, &EffectsHandler::xcbConnectionChanged, this, - [this] { - if (m_shader && m_shader->isValid() && m_renderTargetsValid) { - net_wm_blur_region = effects->announceSupportProperty(s_blurAtomName, this); - } + connect(effects, &EffectsHandler::xcbConnectionChanged, this, [this]() { + if (m_shader && m_shader->isValid() && m_renderTargetsValid) { + net_wm_blur_region = effects->announceSupportProperty(s_blurAtomName, this); } - ); + }); // Fetch the blur regions for all windows const auto stackingOrder = effects->stackingOrder(); @@ -110,10 +108,10 @@ void BlurEffect::slotScreenGeometryChanged() bool BlurEffect::renderTargetsValid() const { - return !m_renderTargets.isEmpty() && std::find_if(m_renderTargets.cbegin(), m_renderTargets.cend(), - [](const GLRenderTarget *target) { - return !target->valid(); - }) == m_renderTargets.cend(); + return !m_renderTargets.isEmpty() && std::find_if(m_renderTargets.cbegin(), m_renderTargets.cend(), [](const GLRenderTarget *target) { + return !target->valid(); + }) + == m_renderTargets.cend(); } void BlurEffect::deleteFBOs() @@ -228,12 +226,12 @@ void BlurEffect::initBlurStrengthValues() */ // {minOffset, maxOffset, expandSize} - blurOffsets.append({1.0, 2.0, 10}); // Down sample size / 2 - blurOffsets.append({2.0, 3.0, 20}); // Down sample size / 4 - blurOffsets.append({2.0, 5.0, 50}); // Down sample size / 8 - blurOffsets.append({3.0, 8.0, 150}); // Down sample size / 16 - //blurOffsets.append({5.0, 10.0, 400}); // Down sample size / 32 - //blurOffsets.append({7.0, ?.0}); // Down sample size / 64 + blurOffsets.append({1.0, 2.0, 10}); // Down sample size / 2 + blurOffsets.append({2.0, 3.0, 20}); // Down sample size / 4 + blurOffsets.append({2.0, 5.0, 50}); // Down sample size / 8 + blurOffsets.append({3.0, 8.0, 150}); // Down sample size / 16 + // blurOffsets.append({5.0, 10.0, 400}); // Down sample size / 32 + // blurOffsets.append({7.0, ?.0}); // Down sample size / 64 float offsetSum = 0; @@ -286,7 +284,7 @@ void BlurEffect::updateBlurRegion(EffectWindow *w) const if (net_wm_blur_region != XCB_ATOM_NONE) { const QByteArray value = w->readProperty(net_wm_blur_region, XCB_ATOM_CARDINAL, 32); if (value.size() > 0 && !(value.size() % (4 * sizeof(uint32_t)))) { - const uint32_t *cardinals = reinterpret_cast(value.constData()); + const uint32_t *cardinals = reinterpret_cast(value.constData()); for (unsigned int i = 0; i < value.size() / sizeof(uint32_t);) { int x = cardinals[i++]; int y = cardinals[i++]; @@ -329,7 +327,7 @@ void BlurEffect::slotWindowAdded(EffectWindow *w) KWaylandServer::SurfaceInterface *surf = w->surface(); if (surf) { - windowBlurChangedConnections[w] = connect(surf, &KWaylandServer::SurfaceInterface::blurChanged, this, [this, w] () { + windowBlurChangedConnections[w] = connect(surf, &KWaylandServer::SurfaceInterface::blurChanged, this, [this, w]() { if (w) { updateBlurRegion(w); } @@ -366,16 +364,16 @@ void BlurEffect::setupDecorationConnections(EffectWindow *w) return; } - connect(w->decoration(), &KDecoration2::Decoration::blurRegionChanged, this, [this, w] () { + connect(w->decoration(), &KDecoration2::Decoration::blurRegionChanged, this, [this, w]() { updateBlurRegion(w); }); } bool BlurEffect::eventFilter(QObject *watched, QEvent *event) { - auto internal = qobject_cast(watched); + auto internal = qobject_cast(watched); if (internal && event->type() == QEvent::DynamicPropertyChange) { - QDynamicPropertyChangeEvent *pe = static_cast(event); + QDynamicPropertyChangeEvent *pe = static_cast(event); if (pe->propertyName() == "kwin_blur") { if (auto w = effects->findWindow(internal)) { updateBlurRegion(w); @@ -459,8 +457,7 @@ QRegion BlurEffect::blurRegion(const EffectWindow *w) const if (w->decorationHasAlpha() && decorationSupportsBlurBehind(w)) { region = decorationBlurRegion(w); } - region |= appRegion.translated(w->contentsRect().topLeft()) & - w->decorationInnerRect(); + region |= appRegion.translated(w->contentsRect().topLeft()) & w->decorationInnerRect(); } else { // An empty region means that the blur effect should be enabled // for the whole window. @@ -481,9 +478,9 @@ void BlurEffect::uploadRegion(QVector2D *&map, const QRegion ®ion, const int const int divisionRatio = (1 << i); for (const QRect &r : region) { - const QVector2D topLeft( r.x() / divisionRatio, r.y() / divisionRatio); - const QVector2D topRight( (r.x() + r.width()) / divisionRatio, r.y() / divisionRatio); - const QVector2D bottomLeft( r.x() / divisionRatio, (r.y() + r.height()) / divisionRatio); + const QVector2D topLeft(r.x() / divisionRatio, r.y() / divisionRatio); + const QVector2D topRight((r.x() + r.width()) / divisionRatio, r.y() / divisionRatio); + const QVector2D bottomLeft(r.x() / divisionRatio, (r.y() + r.height()) / divisionRatio); const QVector2D bottomRight((r.x() + r.width()) / divisionRatio, (r.y() + r.height()) / divisionRatio); // First triangle @@ -506,7 +503,7 @@ void BlurEffect::uploadGeometry(GLVertexBuffer *vbo, const QRegion &blurRegion, if (!vertexCount) return; - QVector2D *map = (QVector2D *) vbo->map(vertexCount * sizeof(QVector2D)); + QVector2D *map = (QVector2D *)vbo->map(vertexCount * sizeof(QVector2D)); uploadRegion(map, blurRegion, m_downSampleIterations); uploadRegion(map, windowRegion, 0); @@ -514,9 +511,8 @@ void BlurEffect::uploadGeometry(GLVertexBuffer *vbo, const QRegion &blurRegion, vbo->unmap(); const GLVertexAttrib layout[] = { - { VA_Position, 2, GL_FLOAT, 0 }, - { VA_TexCoord, 2, GL_FLOAT, 0 } - }; + {VA_Position, 2, GL_FLOAT, 0}, + {VA_TexCoord, 2, GL_FLOAT, 0}}; vbo->setAttribLayout(layout, 2, sizeof(QVector2D)); } @@ -529,7 +525,7 @@ void BlurEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseco effects->prePaintScreen(data, presentTime); } -void BlurEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime) +void BlurEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) { // this effect relies on prePaintWindow being called in the bottom to top order @@ -622,20 +618,20 @@ void BlurEffect::drawWindow(EffectWindow *w, int mask, const QRegion ®ion, Wi QRegion scaledShape; for (QRect r : shape) { r.moveTo(pt.x() + (r.x() - pt.x()) * data.xScale() + data.xTranslation(), - pt.y() + (r.y() - pt.y()) * data.yScale() + data.yTranslation()); + pt.y() + (r.y() - pt.y()) * data.yScale() + data.yTranslation()); r.setWidth(r.width() * data.xScale()); r.setHeight(r.height() * data.yScale()); scaledShape |= r; } shape = scaledShape & region; - //Only translated, not scaled + // Only translated, not scaled } else if (translated) { shape = shape.translated(data.xTranslation(), data.yTranslation()); shape = shape & region; } - EffectWindow* modal = w->transientFor(); + EffectWindow *modal = w->transientFor(); const bool transientForIsDock = (modal ? modal->isDock() : false); if (!shape.isEmpty()) { @@ -672,7 +668,7 @@ void BlurEffect::generateNoiseTexture() QImage noiseImage(QSize(256, 256), QImage::Format_Grayscale8); for (int y = 0; y < noiseImage.height(); y++) { - uint8_t *noiseImageLine = (uint8_t *) noiseImage.scanLine(y); + uint8_t *noiseImageLine = (uint8_t *)noiseImage.scanLine(y); for (int x = 0; x < noiseImage.width(); x++) { noiseImageLine[x] = std::rand() % m_noiseStrength; @@ -687,7 +683,7 @@ void BlurEffect::generateNoiseTexture() m_noiseTexture->setWrapMode(GL_REPEAT); } -void BlurEffect::doBlur(const QRegion& shape, const QRect& screen, const float opacity, const QMatrix4x4 &screenProjection, bool isDock, QRect windowRect) +void BlurEffect::doBlur(const QRegion &shape, const QRect &screen, const float opacity, const QMatrix4x4 &screenProjection, bool isDock, QRect windowRect) { // Blur would not render correctly on a secondary monitor because of wrong coordinates // BUG: 393723 @@ -747,10 +743,10 @@ void BlurEffect::doBlur(const QRegion& shape, const QRect& screen, const float o if (opacity < 1.0) { glEnable(GL_BLEND); #if 1 // bow shape, always above y = x - float o = 1.0f-opacity; - o = 1.0f - o*o; + float o = 1.0f - opacity; + o = 1.0f - o * o; #else // sigmoid shape, above y = x for x > 0.5, below y = x for x < 0.5 - float o = 2.0f*opacity - 1.0f; + float o = 2.0f * opacity - 1.0f; o = 0.5f + o / (1.0f + qAbs(o)); #endif glBlendColor(0, 0, 0, o); @@ -801,7 +797,7 @@ void BlurEffect::upscaleRenderToScreen(GLVertexBuffer *vbo, int vboStart, int bl m_shader->setOffset(m_offset); m_shader->setModelViewProjectionMatrix(screenProjection); - //Render to the screen + // Render to the screen vbo->draw(GL_TRIANGLES, vboStart, blurRectCount); m_shader->unbind(); } @@ -831,12 +827,12 @@ void BlurEffect::downSampleTexture(GLVertexBuffer *vbo, int blurRectCount) for (int i = 1; i <= m_downSampleIterations; i++) { modelViewProjectionMatrix.setToIdentity(); - modelViewProjectionMatrix.ortho(0, m_renderTextures[i]->width(), m_renderTextures[i]->height(), 0 , 0, 65535); + modelViewProjectionMatrix.ortho(0, m_renderTextures[i]->width(), m_renderTextures[i]->height(), 0, 0, 65535); m_shader->setModelViewProjectionMatrix(modelViewProjectionMatrix); m_shader->setTargetTextureSize(m_renderTextures[i]->size()); - //Copy the image from this texture + // Copy the image from this texture m_renderTextures[i - 1]->bind(); vbo->draw(GL_TRIANGLES, blurRectCount * i, blurRectCount); @@ -855,12 +851,12 @@ void BlurEffect::upSampleTexture(GLVertexBuffer *vbo, int blurRectCount) for (int i = m_downSampleIterations - 1; i >= 1; i--) { modelViewProjectionMatrix.setToIdentity(); - modelViewProjectionMatrix.ortho(0, m_renderTextures[i]->width(), m_renderTextures[i]->height(), 0 , 0, 65535); + modelViewProjectionMatrix.ortho(0, m_renderTextures[i]->width(), m_renderTextures[i]->height(), 0, 0, 65535); m_shader->setModelViewProjectionMatrix(modelViewProjectionMatrix); m_shader->setTargetTextureSize(m_renderTextures[i]->size()); - //Copy the image from this texture + // Copy the image from this texture m_renderTextures[i + 1]->bind(); vbo->draw(GL_TRIANGLES, blurRectCount * i, blurRectCount); @@ -901,4 +897,3 @@ bool BlurEffect::blocksDirectScanout() const } } // namespace KWin - diff --git a/src/effects/blur/blur.h b/src/effects/blur/blur.h index 448915a777..45ff3434ca 100644 --- a/src/effects/blur/blur.h +++ b/src/effects/blur/blur.h @@ -12,9 +12,9 @@ #include #include -#include -#include #include +#include +#include #include @@ -38,14 +38,15 @@ public: void reconfigure(ReconfigureFlags flags) override; void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; - void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime) override; + void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) override; void drawWindow(EffectWindow *w, int mask, const QRegion ®ion, WindowPaintData &data) override; void paintEffectFrame(EffectFrame *frame, const QRegion ®ion, double opacity, double frameOpacity) override; bool provides(Feature feature) override; bool isActive() const override; - int requestedEffectChainPosition() const override { + int requestedEffectChainPosition() const override + { return 75; } @@ -85,9 +86,9 @@ private: private: BlurShader *m_shader; - QVector m_renderTargets; + QVector m_renderTargets; QVector m_renderTextures; - QStack m_renderTargetStack; + QStack m_renderTargetStack; QScopedPointer m_noiseTexture; @@ -102,29 +103,30 @@ private: int m_noiseStrength; int m_scalingFactor; - struct OffsetStruct { + struct OffsetStruct + { float minOffset; float maxOffset; int expandSize; }; - QVector blurOffsets; + QVector blurOffsets; - struct BlurValuesStruct { + struct BlurValuesStruct + { int iteration; float offset; }; - QVector blurStrengthValues; + QVector blurStrengthValues; - QMap windowBlurChangedConnections; + QMap windowBlurChangedConnections; static KWaylandServer::BlurManagerInterface *s_blurManager; static QTimer *s_blurManagerRemoveTimer; }; -inline -bool BlurEffect::provides(Effect::Feature feature) +inline bool BlurEffect::provides(Effect::Feature feature) { if (feature == Blur) { return true; @@ -132,8 +134,6 @@ bool BlurEffect::provides(Effect::Feature feature) return KWin::Effect::provides(feature); } - } // namespace KWin #endif - diff --git a/src/effects/blur/blur_config.cpp b/src/effects/blur/blur_config.cpp index c342ead828..b97aa7ecc3 100644 --- a/src/effects/blur/blur_config.cpp +++ b/src/effects/blur/blur_config.cpp @@ -3,14 +3,15 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "blur_config.h" -// KConfigSkeleton -#include "blurconfig.h" + #include -#include +// KConfigSkeleton +#include "blurconfig.h" + #include +#include K_PLUGIN_CLASS(KWin::BlurEffectConfig) diff --git a/src/effects/blur/blur_config.h b/src/effects/blur/blur_config.h index 45a7ddcbd2..faccb91ed1 100644 --- a/src/effects/blur/blur_config.h +++ b/src/effects/blur/blur_config.h @@ -7,8 +7,8 @@ #ifndef BLUR_CONFIG_H #define BLUR_CONFIG_H -#include #include "ui_blur_config.h" +#include namespace KWin { @@ -18,7 +18,7 @@ class BlurEffectConfig : public KCModule Q_OBJECT public: - explicit BlurEffectConfig(QWidget *parent = nullptr, const QVariantList& args = QVariantList()); + explicit BlurEffectConfig(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); ~BlurEffectConfig() override; void save() override; @@ -30,4 +30,3 @@ private: } // namespace KWin #endif - diff --git a/src/effects/blur/blurshader.cpp b/src/effects/blur/blurshader.cpp index 8923e2e8eb..8bad250c9e 100644 --- a/src/effects/blur/blurshader.cpp +++ b/src/effects/blur/blurshader.cpp @@ -29,8 +29,8 @@ BlurShader::BlurShader(QObject *parent) QByteArray fragmentCopySource; QByteArray fragmentNoiseSource; - const QByteArray attribute = core ? "in" : "attribute"; - const QByteArray texture2D = core ? "texture" : "texture2D"; + const QByteArray attribute = core ? "in" : "attribute"; + const QByteArray texture2D = core ? "texture" : "texture2D"; const QByteArray fragColor = core ? "fragColor" : "gl_FragColor"; QString glHeaderString; @@ -46,9 +46,9 @@ BlurShader::BlurShader(QObject *parent) } QString glUniformString = "uniform sampler2D texUnit;\n" - "uniform float offset;\n" - "uniform vec2 renderTextureSize;\n" - "uniform vec2 halfpixel;\n"; + "uniform float offset;\n" + "uniform vec2 renderTextureSize;\n" + "uniform vec2 halfpixel;\n"; if (core) { glUniformString += "out vec4 fragColor;\n\n"; @@ -155,10 +155,7 @@ BlurShader::BlurShader(QObject *parent) m_shaderCopysample.reset(ShaderManager::instance()->loadShaderFromCode(vertexSource, fragmentCopySource)); m_shaderNoisesample.reset(ShaderManager::instance()->loadShaderFromCode(vertexSource, fragmentNoiseSource)); - m_valid = m_shaderDownsample->isValid() && - m_shaderUpsample->isValid() && - m_shaderCopysample->isValid() && - m_shaderNoisesample->isValid(); + m_valid = m_shaderDownsample->isValid() && m_shaderUpsample->isValid() && m_shaderCopysample->isValid() && m_shaderNoisesample->isValid(); if (m_valid) { m_mvpMatrixLocationDownsample = m_shaderDownsample->uniformLocation("modelViewProjectionMatrix"); @@ -186,7 +183,7 @@ BlurShader::BlurShader(QObject *parent) const QSize screenSize = effects->virtualScreenSize(); modelViewProjection.ortho(0, screenSize.width(), screenSize.height(), 0, 0, 65535); - //Add default values to the uniforms of the shaders + // Add default values to the uniforms of the shaders ShaderManager::instance()->pushShader(m_shaderDownsample.data()); m_shaderDownsample->setUniform(m_mvpMatrixLocationDownsample, modelViewProjection); m_shaderDownsample->setUniform(m_offsetLocationDownsample, float(1.0)); @@ -368,11 +365,10 @@ void BlurShader::setBlurRect(const QRect &blurRect, const QSize &screenSize) } const QVector4D rect( - blurRect.left() / float(screenSize.width()), + blurRect.left() / float(screenSize.width()), 1.0 - blurRect.bottom() / float(screenSize.height()), - blurRect.right() / float(screenSize.width()), - 1.0 - blurRect.top() / float(screenSize.height()) - ); + blurRect.right() / float(screenSize.width()), + 1.0 - blurRect.top() / float(screenSize.height())); m_shaderCopysample->setUniform(m_blurRectLocationCopysample, rect); } diff --git a/src/effects/blur/blurshader.h b/src/effects/blur/blurshader.h index 3ecbb0288c..0f57ecec27 100644 --- a/src/effects/blur/blurshader.h +++ b/src/effects/blur/blurshader.h @@ -73,7 +73,7 @@ private: int m_texStartPosLocationNoisesample; int m_halfpixelLocationNoisesample; - //Caching uniform values to aviod unnecessary setUniform calls + // Caching uniform values to aviod unnecessary setUniform calls int m_activeSampleType = -1; float m_offsetDownsample = 0.0; diff --git a/src/effects/blur/main.cpp b/src/effects/blur/main.cpp index af9e484321..b5370621cb 100644 --- a/src/effects/blur/main.cpp +++ b/src/effects/blur/main.cpp @@ -11,7 +11,8 @@ namespace KWin KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED(BlurEffect, "metadata.json.stripped", - return BlurEffect::supported();, + return BlurEffect::supported(); + , return BlurEffect::enabledByDefault();) } // namespace KWin diff --git a/src/effects/colorpicker/colorpicker.cpp b/src/effects/colorpicker/colorpicker.cpp index fcd19008ce..6d9504e9de 100644 --- a/src/effects/colorpicker/colorpicker.cpp +++ b/src/effects/colorpicker/colorpicker.cpp @@ -7,15 +7,15 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "colorpicker.h" +#include +#include +#include #include #include -#include -#include -#include Q_DECLARE_METATYPE(QColor) -QDBusArgument &operator<< (QDBusArgument &argument, const QColor &color) +QDBusArgument &operator<<(QDBusArgument &argument, const QColor &color) { argument.beginStructure(); argument << color.rgba(); @@ -81,7 +81,7 @@ QColor ColorPickerEffect::pick() setDelayedReply(true); showInfoMessage(); effects->startInteractivePositionSelection( - [this] (const QPoint &p) { + [this](const QPoint &p) { hideInfoMessage(); if (p == QPoint(-1, -1)) { // error condition @@ -91,8 +91,7 @@ QColor ColorPickerEffect::pick() m_scheduledPosition = p; effects->addRepaintFull(); } - } - ); + }); return QColor(); } diff --git a/src/effects/colorpicker/colorpicker.h b/src/effects/colorpicker/colorpicker.h index 2f6f73c40a..1d95f1004e 100644 --- a/src/effects/colorpicker/colorpicker.h +++ b/src/effects/colorpicker/colorpicker.h @@ -9,12 +9,12 @@ #ifndef KWIN_COLORPICKER_H #define KWIN_COLORPICKER_H -#include +#include #include #include #include #include -#include +#include namespace KWin { @@ -29,7 +29,8 @@ public: void paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) override; bool isActive() const override; - int requestedEffectChainPosition() const override { + int requestedEffectChainPosition() const override + { return 0; } diff --git a/src/effects/desktopgrid/desktopgrid.cpp b/src/effects/desktopgrid/desktopgrid.cpp index 4296cff037..4f7ab66cd7 100644 --- a/src/effects/desktopgrid/desktopgrid.cpp +++ b/src/effects/desktopgrid/desktopgrid.cpp @@ -16,20 +16,20 @@ #include "../presentwindows/presentwindows_proxy.h" -#include -#include #include #include -#include +#include #include +#include +#include #include #include #include #include -#include +#include -#include #include +#include #include @@ -64,7 +64,7 @@ DesktopGridEffect::DesktopGridEffect() initConfig(); // First we set up the gestures... - QAction* a = m_gestureAction; + QAction *a = m_gestureAction; connect(a, &QAction::triggered, this, [this]() { if (effects->hasActiveFullScreenEffect() && effects->activeFullScreenEffect() != this) { @@ -113,7 +113,7 @@ DesktopGridEffect::DesktopGridEffect() }); // Now we set up the shortcut - QAction* s = m_shortcutAction; + QAction *s = m_shortcutAction; s->setObjectName(QStringLiteral("ShowDesktopGrid")); s->setText(i18n("Show Desktop Grid")); @@ -194,7 +194,8 @@ void DesktopGridEffect::reconfigure(ReconfigureFlags) } effects->registerRealtimeTouchBorder(ElectricBorder(i), m_gestureAction, [this](ElectricBorder border, const QSizeF &deltaProgress, const EffectScreen *screen) { - if (activated) return; + if (activated) + return; if (timeline.currentValue() == 0) { activated = true; @@ -203,9 +204,9 @@ void DesktopGridEffect::reconfigure(ReconfigureFlags) } qreal progress = 0; if (border == ElectricTop || border == ElectricBottom) { - progress = qAbs(deltaProgress.height() / (screen->geometry().height()/2)); + progress = qAbs(deltaProgress.height() / (screen->geometry().height() / 2)); } else { - progress = qAbs(deltaProgress.width() / (screen->geometry().width()/2)); + progress = qAbs(deltaProgress.width() / (screen->geometry().width() / 2)); } timeline.setDirection(QTimeLine::Forward); @@ -218,7 +219,7 @@ void DesktopGridEffect::reconfigure(ReconfigureFlags) //----------------------------------------------------------------------------- // Screen painting -void DesktopGridEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) +void DesktopGridEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) { // The animation code assumes that the time diff cannot be 0, let's work around it. int time; @@ -242,7 +243,7 @@ void DesktopGridEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::mi for (int i = 0; i < effects->numberOfDesktops(); i++) { auto item = hoverTimeline[i]; - if (i == highlightedDesktop-1) { // if this is the highlighted desktop, we want to progress the animation from "not highlighted" to "highlight" + if (i == highlightedDesktop - 1) { // if this is the highlighted desktop, we want to progress the animation from "not highlighted" to "highlight" item->setCurrentTime(item->currentTime() + time); } else { // otherwise we progress from "highlighted" to "not highlighted" item->setCurrentTime(item->currentTime() - time); @@ -271,7 +272,7 @@ void DesktopGridEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::mi effects->prePaintScreen(data, presentTime); } -void DesktopGridEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) +void DesktopGridEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) { if (timeline.currentValue() == 0 && !isUsingPresentWindows()) { effects->paintScreen(mask, region, data); @@ -304,7 +305,7 @@ void DesktopGridEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaint for (EffectScreen *screen : screens) { QRect screenGeom = effects->clientArea(ScreenArea, screen, effects->currentDesktop()); int desktop = 1; - for (EffectFrame * frame : qAsConst(desktopNames)) { + for (EffectFrame *frame : qAsConst(desktopNames)) { QPointF posTL(scalePos(screenGeom.topLeft(), desktop, screen)); QPointF posBR(scalePos(screenGeom.bottomRight(), desktop, screen)); QRect textArea(posTL.x(), posTL.y(), posBR.x() - posTL.x(), posBR.y() - posTL.y()); @@ -368,7 +369,7 @@ void DesktopGridEffect::postPaintScreen() //----------------------------------------------------------------------------- // Window painting -void DesktopGridEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime) +void DesktopGridEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) { if (timeline.currentValue() != 0 || (isUsingPresentWindows() && isMotionManagerMovingWindows())) { w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP); @@ -383,15 +384,13 @@ void DesktopGridEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data effects->prePaintWindow(w, data, presentTime); } -void DesktopGridEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) +void DesktopGridEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) { if (timeline.currentValue() != 0 || (isUsingPresentWindows() && isMotionManagerMovingWindows())) { if (!w->isOnDesktop(paintingDesktop)) { return; } - if (isUsingPresentWindows() && w == windowMove && wasWindowMove && - ((!wasWindowCopy && sourceDesktop == paintingDesktop) || - (sourceDesktop != highlightedDesktop && highlightedDesktop == paintingDesktop))) { + if (isUsingPresentWindows() && w == windowMove && wasWindowMove && ((!wasWindowCopy && sourceDesktop == paintingDesktop) || (sourceDesktop != highlightedDesktop && highlightedDesktop == paintingDesktop))) { return; // will be painted on top of all other windows } @@ -406,7 +405,7 @@ void DesktopGridEffect::paintWindow(EffectWindow* w, int mask, QRegion region, W QRectF transformedGeo = w->frameGeometry(); if (isUsingPresentWindows()) { - WindowMotionManager& manager = m_managers[screen][paintingDesktop - 1]; + WindowMotionManager &manager = m_managers[screen][paintingDesktop - 1]; if (manager.isManaging(w)) { transformedGeo = manager.transformedGeometry(w); if (!manager.areWindowsMoving() && timeline.currentValue() == 1.0) @@ -450,7 +449,7 @@ void DesktopGridEffect::paintWindow(EffectWindow* w, int mask, QRegion region, W //----------------------------------------------------------------------------- // User interaction -void DesktopGridEffect::slotWindowAdded(EffectWindow* w) +void DesktopGridEffect::slotWindowAdded(EffectWindow *w) { if (!activated) return; @@ -460,7 +459,7 @@ void DesktopGridEffect::slotWindowAdded(EffectWindow* w) } const auto desktops = desktopList(w); for (const int i : desktops) { - WindowMotionManager& manager = m_managers[w->screen()][i]; + WindowMotionManager &manager = m_managers[w->screen()][i]; manager.manage(w); m_proxy->calculateWindowTransformations(manager.managedWindows(), w->screen(), manager); } @@ -468,7 +467,7 @@ void DesktopGridEffect::slotWindowAdded(EffectWindow* w) effects->addRepaintFull(); } -void DesktopGridEffect::slotWindowClosed(EffectWindow* w) +void DesktopGridEffect::slotWindowClosed(EffectWindow *w) { if (!activated && timeline.currentValue() == 0) return; @@ -479,7 +478,7 @@ void DesktopGridEffect::slotWindowClosed(EffectWindow* w) if (isUsingPresentWindows()) { const auto desktops = desktopList(w); for (const int i : desktops) { - WindowMotionManager& manager = m_managers[w->screen()][i]; + WindowMotionManager &manager = m_managers[w->screen()][i]; manager.unmanage(w); m_proxy->calculateWindowTransformations(manager.managedWindows(), w->screen(), manager); } @@ -487,7 +486,7 @@ void DesktopGridEffect::slotWindowClosed(EffectWindow* w) effects->addRepaintFull(); } -void DesktopGridEffect::slotWindowDeleted(EffectWindow* w) +void DesktopGridEffect::slotWindowDeleted(EffectWindow *w) { if (w == windowMove) windowMove = nullptr; @@ -500,7 +499,7 @@ void DesktopGridEffect::slotWindowDeleted(EffectWindow* w) } } -void DesktopGridEffect::slotWindowFrameGeometryChanged(EffectWindow* w, const QRect& old) +void DesktopGridEffect::slotWindowFrameGeometryChanged(EffectWindow *w, const QRect &old) { Q_UNUSED(old) if (!activated) @@ -510,20 +509,20 @@ void DesktopGridEffect::slotWindowFrameGeometryChanged(EffectWindow* w, const QR if (isUsingPresentWindows()) { const auto desktops = desktopList(w); for (const int i : desktops) { - WindowMotionManager& manager = m_managers[w->screen()][i]; + WindowMotionManager &manager = m_managers[w->screen()][i]; m_proxy->calculateWindowTransformations(manager.managedWindows(), w->screen(), manager); } } } -void DesktopGridEffect::windowInputMouseEvent(QEvent* e) +void DesktopGridEffect::windowInputMouseEvent(QEvent *e) { if ((e->type() != QEvent::MouseMove - && e->type() != QEvent::MouseButtonPress - && e->type() != QEvent::MouseButtonRelease) - || timeline.currentValue() != 1) // Block user input during animations + && e->type() != QEvent::MouseButtonPress + && e->type() != QEvent::MouseButtonRelease) + || timeline.currentValue() != 1) // Block user input during animations return; - QMouseEvent* me = static_cast< QMouseEvent* >(e); + QMouseEvent *me = static_cast(e); if (!(wasWindowMove || wasDesktopMove)) { for (OffscreenQuickScene *view : qAsConst(m_desktopButtons)) { view->forwardMouseEvent(me); @@ -535,8 +534,7 @@ void DesktopGridEffect::windowInputMouseEvent(QEvent* e) if (e->type() == QEvent::MouseMove) { int d = posToDesktop(me->pos()); - if (windowMove != nullptr && - (me->pos() - dragStartPos).manhattanLength() > QGuiApplication::styleHints()->startDragDistance()) { + if (windowMove != nullptr && (me->pos() - dragStartPos).manhattanLength() > QGuiApplication::styleHints()->startDragDistance()) { // Handle window moving if (windowMoveElevateTimer->isActive()) { // Window started moving, but is not elevated yet! windowMoveElevateTimer->stop(); @@ -546,17 +544,17 @@ void DesktopGridEffect::windowInputMouseEvent(QEvent* e) if (isUsingPresentWindows()) { const auto desktops = desktopList(windowMove); for (const int i : desktops) { - WindowMotionManager& manager = m_managers[windowMove->screen()][i]; + WindowMotionManager &manager = m_managers[windowMove->screen()][i]; if ((i + 1) == sourceDesktop) { const QRectF transformedGeo = manager.transformedGeometry(windowMove); const QPointF pos = scalePos(transformedGeo.topLeft().toPoint(), sourceDesktop, windowMove->screen()); - const QSize size(scale[windowMove->screen()] *(float)transformedGeo.width(), - scale[windowMove->screen()] *(float)transformedGeo.height()); + const QSize size(scale[windowMove->screen()] * (float)transformedGeo.width(), + scale[windowMove->screen()] * (float)transformedGeo.height()); m_windowMoveGeometry = QRect(pos.toPoint(), size); m_windowMoveStartPoint = me->pos(); } manager.unmanage(windowMove); - if (EffectWindow* modal = windowMove->findModal()) { + if (EffectWindow *modal = windowMove->findModal()) { if (manager.isManaging(modal)) manager.unmanage(modal); } @@ -593,8 +591,7 @@ void DesktopGridEffect::windowInputMouseEvent(QEvent* e) } effects->addRepaintFull(); } - } else if ((me->buttons() & Qt::LeftButton) && !wasDesktopMove && - (me->pos() - dragStartPos).manhattanLength() > QGuiApplication::styleHints()->startDragDistance()) { + } else if ((me->buttons() & Qt::LeftButton) && !wasDesktopMove && (me->pos() - dragStartPos).manhattanLength() > QGuiApplication::styleHints()->startDragDistance()) { wasDesktopMove = true; effects->defineCursor(Qt::ClosedHandCursor); } @@ -603,8 +600,9 @@ void DesktopGridEffect::windowInputMouseEvent(QEvent* e) EffectWindowList windows = effects->stackingOrder(); EffectWindowList stack[3]; for (EffectWindowList::const_iterator it = windows.constBegin(), - end = windows.constEnd(); it != end; ++it) { - EffectWindow *w = const_cast(*it); // we're not really touching it here but below + end = windows.constEnd(); + it != end; ++it) { + EffectWindow *w = const_cast(*it); // we're not really touching it here but below if (w->isOnAllDesktops()) continue; if (w->isOnDesktop(highlightedDesktop)) @@ -615,13 +613,13 @@ void DesktopGridEffect::windowInputMouseEvent(QEvent* e) stack[2] << w; } const int desks[4] = {highlightedDesktop, d, m_originalMovingDesktop, highlightedDesktop}; - for (int i = 0; i < 3; ++i ) { - if (desks[i] == desks[i+1]) + for (int i = 0; i < 3; ++i) { + if (desks[i] == desks[i + 1]) continue; for (EffectWindow *w : qAsConst(stack[i])) { auto desktops = w->desktops(); desktops.removeOne(desks[i]); - desktops.append(desks[i+1]); + desktops.append(desks[i + 1]); effects->windowToDesktops(w, desktops); if (isUsingPresentWindows()) { @@ -634,7 +632,7 @@ void DesktopGridEffect::windowInputMouseEvent(QEvent* e) const QList screens = effects->screens(); for (EffectScreen *screen : screens) { for (int j = 0; j < 3; ++j) { - WindowMotionManager& manager = m_managers[screen][desks[j] - 1]; + WindowMotionManager &manager = m_managers[screen][desks[j] - 1]; m_proxy->calculateWindowTransformations(manager.managedWindows(), screen, manager); } } @@ -650,7 +648,7 @@ void DesktopGridEffect::windowInputMouseEvent(QEvent* e) dragStartPos = me->pos(); sourceDesktop = posToDesktop(me->pos()); bool isDesktop = (me->modifiers() & Qt::ShiftModifier); - EffectWindow* w = isDesktop ? nullptr : windowAt(me->pos()); + EffectWindow *w = isDesktop ? nullptr : windowAt(me->pos()); if (w != nullptr) isDesktop = w->isDesktop(); if (isDesktop) @@ -664,7 +662,7 @@ void DesktopGridEffect::windowInputMouseEvent(QEvent* e) windowMoveElevateTimer->start(); } } else if ((me->buttons() == Qt::MiddleButton || me->buttons() == Qt::RightButton) && windowMove == nullptr) { - EffectWindow* w = windowAt(me->pos()); + EffectWindow *w = windowAt(me->pos()); if (w && w->isDesktop()) { w = nullptr; } @@ -679,7 +677,7 @@ void DesktopGridEffect::windowInputMouseEvent(QEvent* e) if (isUsingPresentWindows()) { for (int i = 0; i < effects->numberOfDesktops(); i++) { if (i != desktop - 1) { - WindowMotionManager& manager = m_managers[w->screen()][i]; + WindowMotionManager &manager = m_managers[w->screen()][i]; if (isOnAllDesktops) manager.manage(w); else @@ -718,9 +716,9 @@ void DesktopGridEffect::windowInputMouseEvent(QEvent* e) const int targetDesktop = posToDesktop(cursorPos()); const auto desktops = desktopList(windowMove); for (const int i : desktops) { - WindowMotionManager& manager = m_managers[windowMove->screen()][i]; + WindowMotionManager &manager = m_managers[windowMove->screen()][i]; manager.manage(windowMove); - if (EffectWindow* modal = windowMove->findModal()) + if (EffectWindow *modal = windowMove->findModal()) manager.manage(modal); if (i + 1 == targetDesktop) { // for the desktop the window is dropped on, we use the current geometry @@ -760,12 +758,15 @@ void DesktopGridEffect::deactivate() void DesktopGridEffect::toggle() { - if (activated) deactivate(); else activate(); + if (activated) + deactivate(); + else + activate(); } -void DesktopGridEffect::grabbedKeyboardEvent(QKeyEvent* e) +void DesktopGridEffect::grabbedKeyboardEvent(QKeyEvent *e) { - if (timeline.currentValue() != 1) // Block user input during animations + if (timeline.currentValue() != 1) // Block user input during animations return; if (windowMove != nullptr) return; @@ -791,7 +792,7 @@ void DesktopGridEffect::grabbedKeyboardEvent(QKeyEvent* e) } return; } - switch(e->key()) { + switch (e->key()) { // Wrap only on autorepeat case Qt::Key_Left: setHighlightedDesktop(desktopToLeft(highlightedDesktop, !e->isAutoRepeat())); @@ -840,7 +841,7 @@ bool DesktopGridEffect::borderActivated(ElectricBorder border) // Helper functions // Transform a point to its position on the scaled grid -QPointF DesktopGridEffect::scalePos(const QPoint& pos, int desktop, EffectScreen *screen) const +QPointF DesktopGridEffect::scalePos(const QPoint &pos, int desktop, EffectScreen *screen) const { QRect screenGeom = effects->clientArea(ScreenArea, screen, 0); QPoint desktopCell; @@ -856,48 +857,47 @@ QPointF DesktopGridEffect::scalePos(const QPoint& pos, int desktop, EffectScreen QPointF point( interpolate( ( - (screenGeom.width() + unscaledBorder[screen]) *(desktopCell.x() - 1) - - (screenGeom.width() + unscaledBorder[screen]) *(activeCell.x() - 1) - ) + pos.x(), + (screenGeom.width() + unscaledBorder[screen]) * (desktopCell.x() - 1) + - (screenGeom.width() + unscaledBorder[screen]) * (activeCell.x() - 1)) + + pos.x(), ( - (scaledSize[screen].width() + border) *(desktopCell.x() - 1) + (scaledSize[screen].width() + border) * (desktopCell.x() - 1) + scaledOffset[screen].x() - + (pos.x() - screenGeom.x()) * scale[screen] - ), + + (pos.x() - screenGeom.x()) * scale[screen]), progress), interpolate( ( - (screenGeom.height() + unscaledBorder[screen]) *(desktopCell.y() - 1) - - (screenGeom.height() + unscaledBorder[screen]) *(activeCell.y() - 1) - ) + pos.y(), + (screenGeom.height() + unscaledBorder[screen]) * (desktopCell.y() - 1) + - (screenGeom.height() + unscaledBorder[screen]) * (activeCell.y() - 1)) + + pos.y(), ( - (scaledSize[screen].height() + border) *(desktopCell.y() - 1) + (scaledSize[screen].height() + border) * (desktopCell.y() - 1) + scaledOffset[screen].y() - + (pos.y() - screenGeom.y()) * scale[screen] - ), - progress) - ); + + (pos.y() - screenGeom.y()) * scale[screen]), + progress)); return point; } // Detransform a point to its position on the full grid // TODO: Doesn't correctly interpolate (Final position is correct though), don't forget to copy to posToDesktop() -QPoint DesktopGridEffect::unscalePos(const QPoint& pos, int* desktop) const +QPoint DesktopGridEffect::unscalePos(const QPoint &pos, int *desktop) const { EffectScreen *screen = effects->screenAt(pos); QRect screenGeom = effects->clientArea(ScreenArea, screen, effects->currentDesktop()); - //double progress = timeline.currentValue(); + // double progress = timeline.currentValue(); double scaledX = /*interpolate( ( pos.x() - screenGeom.x() + unscaledBorder[screen] / 2.0 ) / ( screenGeom.width() + unscaledBorder[screen] ) + activeCell.x() - 1,*/ - (pos.x() - scaledOffset[screen].x() + double(border) / 2.0) / (scaledSize[screen].width() + border)/*, - progress )*/; + (pos.x() - scaledOffset[screen].x() + double(border) / 2.0) / (scaledSize[screen].width() + border) /*, + progress )*/ + ; double scaledY = /*interpolate( ( pos.y() - screenGeom.y() + unscaledBorder[screen] / 2.0 ) / ( screenGeom.height() + unscaledBorder[screen] ) + activeCell.y() - 1,*/ - (pos.y() - scaledOffset[screen].y() + double(border) / 2.0) / (scaledSize[screen].height() + border)/*, - progress )*/; - int gx = qBound(0, int(scaledX), gridSize.width() - 1); // Zero-based + (pos.y() - scaledOffset[screen].y() + double(border) / 2.0) / (scaledSize[screen].height() + border) /*, + progress )*/ + ; + int gx = qBound(0, int(scaledX), gridSize.width() - 1); // Zero-based int gy = qBound(0, int(scaledY), gridSize.height() - 1); scaledX -= gx; scaledY -= gy; @@ -909,42 +909,37 @@ QPoint DesktopGridEffect::unscalePos(const QPoint& pos, int* desktop) const } return QPoint( - qBound( - screenGeom.x(), - qRound( - scaledX * (screenGeom.width() + unscaledBorder[screen]) - - unscaledBorder[screen] / 2.0 - + screenGeom.x() - ), - screenGeom.right() - ), - qBound( - screenGeom.y(), - qRound( - scaledY * (screenGeom.height() + unscaledBorder[screen]) - - unscaledBorder[screen] / 2.0 - + screenGeom.y() - ), - screenGeom.bottom() - ) - ); + qBound( + screenGeom.x(), + qRound( + scaledX * (screenGeom.width() + unscaledBorder[screen]) + - unscaledBorder[screen] / 2.0 + + screenGeom.x()), + screenGeom.right()), + qBound( + screenGeom.y(), + qRound( + scaledY * (screenGeom.height() + unscaledBorder[screen]) + - unscaledBorder[screen] / 2.0 + + screenGeom.y()), + screenGeom.bottom())); } -int DesktopGridEffect::posToDesktop(const QPoint& pos) const +int DesktopGridEffect::posToDesktop(const QPoint &pos) const { // Copied from unscalePos() EffectScreen *screen = effects->screenAt(pos); double scaledX = (pos.x() - scaledOffset[screen].x() + double(border) / 2.0) / (scaledSize[screen].width() + border); double scaledY = (pos.y() - scaledOffset[screen].y() + double(border) / 2.0) / (scaledSize[screen].height() + border); - int gx = qBound(0, int(scaledX), gridSize.width() - 1); // Zero-based + int gx = qBound(0, int(scaledX), gridSize.width() - 1); // Zero-based int gy = qBound(0, int(scaledY), gridSize.height() - 1); if (orientation == Qt::Horizontal) return gy * gridSize.width() + gx + 1; return gx * gridSize.height() + gy + 1; } -EffectWindow* DesktopGridEffect::windowAt(QPoint pos) const +EffectWindow *DesktopGridEffect::windowAt(QPoint pos) const { // Get stacking order top first EffectWindowList windows = effects->stackingOrder(); @@ -963,13 +958,13 @@ EffectWindow* DesktopGridEffect::windowAt(QPoint pos) const EffectWindow *w = m_managers[screen][desktop - 1].windowAtPoint(pos, false); if (w) return w; - for (EffectWindow * w : qAsConst(windows)) { + for (EffectWindow *w : qAsConst(windows)) { if (w->isOnDesktop(desktop) && w->isDesktop() && w->frameGeometry().contains(pos)) { return w; } } } else { - for (EffectWindow * w : qAsConst(windows)) { + for (EffectWindow *w : qAsConst(windows)) { if (w->isOnDesktop(desktop) && w->isOnCurrentActivity() && !w->isMinimized() && w->frameGeometry().contains(pos)) { return w; } @@ -996,11 +991,11 @@ void DesktopGridEffect::setHighlightedDesktop(int d) if (d == highlightedDesktop || d <= 0 || d > effects->numberOfDesktops()) return; if (highlightedDesktop > 0 && highlightedDesktop <= hoverTimeline.count()) - hoverTimeline[highlightedDesktop-1]->setCurrentTime(qMin(hoverTimeline[highlightedDesktop-1]->currentTime(), - hoverTimeline[highlightedDesktop-1]->duration())); + hoverTimeline[highlightedDesktop - 1]->setCurrentTime(qMin(hoverTimeline[highlightedDesktop - 1]->currentTime(), + hoverTimeline[highlightedDesktop - 1]->duration())); highlightedDesktop = d; if (highlightedDesktop <= hoverTimeline.count()) - hoverTimeline[highlightedDesktop-1]->setCurrentTime(qMax(hoverTimeline[highlightedDesktop-1]->currentTime(), 0)); + hoverTimeline[highlightedDesktop - 1]->setCurrentTime(qMax(hoverTimeline[highlightedDesktop - 1]->currentTime(), 0)); effects->addRepaintFull(); } @@ -1134,7 +1129,7 @@ void DesktopGridEffect::setup() font.setBold(true); font.setPointSize(12); for (int i = 0; i < effects->numberOfDesktops(); i++) { - EffectFrame* frame = effects->effectFrame(EffectFrameUnstyled, false); + EffectFrame *frame = effects->effectFrame(EffectFrameUnstyled, false); frame->setFont(font); frame->setText(effects->desktopName(i + 1)); frame->setAlignment(desktopNameAlignment); @@ -1146,22 +1141,22 @@ void DesktopGridEffect::setup() // setup the motion managers if (clickBehavior == SwitchDesktopAndActivateWindow) - m_proxy = static_cast(effects->getProxy(QStringLiteral("presentwindows"))); + m_proxy = static_cast(effects->getProxy(QStringLiteral("presentwindows"))); if (isUsingPresentWindows()) { m_proxy->reCreateGrids(); // revalidation on multiscreen, bug #351724 const QList screens = effects->screens(); for (EffectScreen *screen : screens) { QList managers; for (int i = 1; i <= effects->numberOfDesktops(); i++) { - WindowMotionManager manager; - const auto stackingOrder = effects->stackingOrder(); - for (EffectWindow * w : stackingOrder) { - if (w->isOnDesktop(i) && w->screen() == screen &&isRelevantWithPresentWindows(w)) { - manager.manage(w); - } + WindowMotionManager manager; + const auto stackingOrder = effects->stackingOrder(); + for (EffectWindow *w : stackingOrder) { + if (w->isOnDesktop(i) && w->screen() == screen && isRelevantWithPresentWindows(w)) { + manager.manage(w); } - m_proxy->calculateWindowTransformations(manager.managedWindows(), screen, manager); - managers.append(manager); + } + m_proxy->calculateWindowTransformations(manager.managedWindows(), screen, manager); + managers.append(manager); } m_managers[screen] = managers; } @@ -1199,8 +1194,8 @@ void DesktopGridEffect::setup() } const QRect screenRect = effects->clientArea(FullScreenArea, screen, 1); view->show(); // pseudo show must happen before geometry changes - const QPoint position(screenRect.right() - border/3 - size.width(), - screenRect.bottom() - border/3 - size.height()); + const QPoint position(screenRect.right() - border / 3 - size.width(), + screenRect.bottom() - border / 3 - size.height()); view->setGeometry(QRect(position, size)); } while (it != m_desktopButtons.end()) { @@ -1214,7 +1209,7 @@ void DesktopGridEffect::setupGrid() // We need these variables for every paint so lets cache them int x, y; int numDesktops = effects->numberOfDesktops(); - switch(layoutMode) { + switch (layoutMode) { default: case LayoutPager: orientation = Qt::Horizontal; @@ -1255,12 +1250,10 @@ void DesktopGridEffect::setupGrid() double sBorder = border / sScale; QSizeF size( double(geom.width()) * sScale, - double(geom.height()) * sScale - ); + double(geom.height()) * sScale); QPointF offset( - geom.x() + (geom.width() - size.width() * gridSize.width() - border *(gridSize.width() - 1)) / 2.0, - geom.y() + (geom.height() - size.height() * gridSize.height() - border *(gridSize.height() - 1)) / 2.0 - ); + geom.x() + (geom.width() - size.width() * gridSize.width() - border * (gridSize.width() - 1)) / 2.0, + geom.y() + (geom.height() - size.height() * gridSize.height() - border * (gridSize.height() - 1)) / 2.0); scale[screen] = sScale; unscaledBorder[screen] = sBorder; scaledSize[screen] = size; @@ -1279,22 +1272,21 @@ void DesktopGridEffect::finish() for (auto it = m_managers.begin(); it != m_managers.end(); ++it) { for (WindowMotionManager &manager : *it) { const auto windows = manager.managedWindows(); - for (EffectWindow * w : windows) { + for (EffectWindow *w : windows) { manager.moveWindow(w, w->frameGeometry()); } } } } QTimer::singleShot(zoomDuration + 1, this, - [this] { - if (activated) - return; - for (OffscreenQuickScene *view : qAsConst(m_desktopButtons)) { - view->hide(); - } - } - ); - setHighlightedDesktop(effects->currentDesktop()); // Ensure selected desktop is highlighted + [this] { + if (activated) + return; + for (OffscreenQuickScene *view : qAsConst(m_desktopButtons)) { + view->hide(); + } + }); + setHighlightedDesktop(effects->currentDesktop()); // Ensure selected desktop is highlighted windowMoveElevateTimer->stop(); @@ -1317,7 +1309,7 @@ void DesktopGridEffect::finish() effects->addRepaintFull(); } -void DesktopGridEffect::globalShortcutChanged(QAction *action, const QKeySequence& seq) +void DesktopGridEffect::globalShortcutChanged(QAction *action, const QKeySequence &seq) { if (action->objectName() != QStringLiteral("ShowDesktopGrid")) { return; @@ -1349,19 +1341,16 @@ bool DesktopGridEffect::isUsingPresentWindows() const QRectF DesktopGridEffect::moveGeometryToDesktop(int desktop) const { QPointF point = unscalePos(m_windowMoveGeometry.topLeft() + cursorPos() - m_windowMoveStartPoint); - const double scaleFactor = scale[ windowMove->screen()]; + const double scaleFactor = scale[windowMove->screen()]; if (posToDesktop(m_windowMoveGeometry.topLeft() + cursorPos() - m_windowMoveStartPoint) != desktop) { // topLeft is not on the desktop - check other corners // if all corners are not on the desktop the window is bigger than the desktop - no matter what it will look strange if (posToDesktop(m_windowMoveGeometry.topRight() + cursorPos() - m_windowMoveStartPoint) == desktop) { - point = unscalePos(m_windowMoveGeometry.topRight() + cursorPos() - m_windowMoveStartPoint) - - QPointF(m_windowMoveGeometry.width(), 0) / scaleFactor; + point = unscalePos(m_windowMoveGeometry.topRight() + cursorPos() - m_windowMoveStartPoint) - QPointF(m_windowMoveGeometry.width(), 0) / scaleFactor; } else if (posToDesktop(m_windowMoveGeometry.bottomLeft() + cursorPos() - m_windowMoveStartPoint) == desktop) { - point = unscalePos(m_windowMoveGeometry.bottomLeft() + cursorPos() - m_windowMoveStartPoint) - - QPointF(0, m_windowMoveGeometry.height()) / scaleFactor; + point = unscalePos(m_windowMoveGeometry.bottomLeft() + cursorPos() - m_windowMoveStartPoint) - QPointF(0, m_windowMoveGeometry.height()) / scaleFactor; } else if (posToDesktop(m_windowMoveGeometry.bottomRight() + cursorPos() - m_windowMoveStartPoint) == desktop) { - point = unscalePos(m_windowMoveGeometry.bottomRight() + cursorPos() - m_windowMoveStartPoint) - - QPointF(m_windowMoveGeometry.width(), m_windowMoveGeometry.height()) / scaleFactor; + point = unscalePos(m_windowMoveGeometry.bottomRight() + cursorPos() - m_windowMoveStartPoint) - QPointF(m_windowMoveGeometry.width(), m_windowMoveGeometry.height()) / scaleFactor; } } return QRectF(point, m_windowMoveGeometry.size() / scaleFactor); @@ -1404,7 +1393,7 @@ void DesktopGridEffect::desktopsAdded(int old) font.setBold(true); font.setPointSize(12); for (int i = old; i < desktop; i++) { - EffectFrame* frame = effects->effectFrame(EffectFrameUnstyled, false); + EffectFrame *frame = effects->effectFrame(EffectFrameUnstyled, false); frame->setFont(font); frame->setText(effects->desktopName(i + 1)); frame->setAlignment(desktopNameAlignment); @@ -1415,11 +1404,11 @@ void DesktopGridEffect::desktopsAdded(int old) if (isUsingPresentWindows()) { const QList screens = effects->screens(); for (EffectScreen *screen : screens) { - for (int i = old+1; i <= effects->numberOfDesktops(); ++i) { + for (int i = old + 1; i <= effects->numberOfDesktops(); ++i) { WindowMotionManager manager; const auto stackingOrder = effects->stackingOrder(); - for (EffectWindow * w : stackingOrder) { - if (w->isOnDesktop(i) && w->screen() == screen &&isRelevantWithPresentWindows(w)) { + for (EffectWindow *w : stackingOrder) { + if (w->isOnDesktop(i) && w->screen() == screen && isRelevantWithPresentWindows(w)) { manager.manage(w); } } @@ -1447,7 +1436,7 @@ void DesktopGridEffect::desktopsRemoved(int old) if (isUsingPresentWindows()) { const QList screens = effects->screens(); for (EffectScreen *screen : screens) { - WindowMotionManager& manager = m_managers[screen].last(); + WindowMotionManager &manager = m_managers[screen].last(); manager.unmanageAll(); m_managers[screen].removeLast(); } @@ -1457,9 +1446,9 @@ void DesktopGridEffect::desktopsRemoved(int old) if (isUsingPresentWindows()) { const QList screens = effects->screens(); for (EffectScreen *screen : screens) { - WindowMotionManager& manager = m_managers[screen][desktop - 1]; + WindowMotionManager &manager = m_managers[screen][desktop - 1]; const auto stackingOrder = effects->stackingOrder(); - for (EffectWindow * w : stackingOrder) { + for (EffectWindow *w : stackingOrder) { if (manager.isManaging(w)) continue; if (w->isOnDesktop(desktop) && w->screen() == screen && isRelevantWithPresentWindows(w)) { @@ -1475,7 +1464,7 @@ void DesktopGridEffect::desktopsRemoved(int old) // and repaint effects->addRepaintFull(); } -//TODO: kill this function? or at least keep a consistent numeration with desktops starting from 1 +// TODO: kill this function? or at least keep a consistent numeration with desktops starting from 1 QVector DesktopGridEffect::desktopList(const EffectWindow *w) const { if (w->isOnAllDesktops()) { @@ -1494,7 +1483,7 @@ QVector DesktopGridEffect::desktopList(const EffectWindow *w) const const QVector allDesks = w->desktops(); for (const int desk : allDesks) { - desks[i++] = desk-1; + desks[i++] = desk - 1; } return desks; } @@ -1530,4 +1519,3 @@ bool DesktopGridEffect::isRelevantWithPresentWindows(EffectWindow *w) const } } // namespace - diff --git a/src/effects/desktopgrid/desktopgrid.h b/src/effects/desktopgrid/desktopgrid.h index 4b5c502984..d5af4f60a1 100644 --- a/src/effects/desktopgrid/desktopgrid.h +++ b/src/effects/desktopgrid/desktopgrid.h @@ -11,9 +11,9 @@ #ifndef KWIN_DESKTOPGRID_H #define KWIN_DESKTOPGRID_H -#include #include #include +#include class QTimer; @@ -39,17 +39,18 @@ public: DesktopGridEffect(); ~DesktopGridEffect() override; void reconfigure(ReconfigureFlags) override; - void prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) override; - void paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) override; + void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; + void paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) override; void postPaintScreen() override; - void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime) override; - void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override; - void windowInputMouseEvent(QEvent* e) override; - void grabbedKeyboardEvent(QKeyEvent* e) override; + void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) 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 { + int requestedEffectChainPosition() const override + { return 50; } @@ -64,41 +65,47 @@ public: }; // Click behavior // for properties - int configuredZoomDuration() const { + int configuredZoomDuration() const + { return zoomDuration; } - int configuredBorder() const { + int configuredBorder() const + { return border; } - Qt::Alignment configuredDesktopNameAlignment() const { + Qt::Alignment configuredDesktopNameAlignment() const + { return desktopNameAlignment; } - int configuredLayoutMode() const { + int configuredLayoutMode() const + { return layoutMode; } - int configuredCustomLayoutRows() const { + int configuredCustomLayoutRows() const + { return customLayoutRows; } - bool isUsePresentWindows() const { + bool isUsePresentWindows() const + { return clickBehavior == SwitchDesktopAndActivateWindow; } private Q_SLOTS: // slots for global shortcut changed // needed to toggle the effect - void globalShortcutChanged(QAction *action, const QKeySequence& seq); + void globalShortcutChanged(QAction *action, const QKeySequence &seq); void slotAddDesktop(); void slotRemoveDesktop(); - void slotWindowAdded(KWin::EffectWindow* w); + void slotWindowAdded(KWin::EffectWindow *w); void slotWindowClosed(KWin::EffectWindow *w); void slotWindowDeleted(KWin::EffectWindow *w); void slotNumberDesktopsChanged(uint old); void slotWindowFrameGeometryChanged(KWin::EffectWindow *w, const QRect &old); private: - QPointF scalePos(const QPoint& pos, int desktop, EffectScreen *screen) const; - QPoint unscalePos(const QPoint& pos, int* desktop = nullptr) const; - int posToDesktop(const QPoint& pos) const; - EffectWindow* windowAt(QPoint pos) const; + QPointF scalePos(const QPoint &pos, int desktop, EffectScreen *screen) const; + QPoint unscalePos(const QPoint &pos, int *desktop = nullptr) 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; @@ -140,16 +147,16 @@ private: int m_originalMovingDesktop; bool keyboardGrab; bool wasWindowMove, wasWindowCopy, wasDesktopMove, isValidMove; - EffectWindow* windowMove; + EffectWindow *windowMove; QPoint windowMoveDiff; QPoint dragStartPos; QTimer *windowMoveElevateTimer; std::chrono::milliseconds lastPresentTime; // Soft highlighting - QList hoverTimeline; + QList hoverTimeline; - QList< EffectFrame* > desktopNames; + QList desktopNames; QSize gridSize; Qt::Orientation orientation; @@ -163,16 +170,15 @@ private: // Shortcut - needed to toggle the effect QList shortcut; - PresentWindowsEffectProxy* m_proxy; + PresentWindowsEffectProxy *m_proxy; QMap> m_managers; QRect m_windowMoveGeometry; QPoint m_windowMoveStartPoint; - QVector m_desktopButtons; + QVector m_desktopButtons; QAction *m_gestureAction; QAction *m_shortcutAction; - }; } // namespace diff --git a/src/effects/desktopgrid/desktopgrid_config.cpp b/src/effects/desktopgrid/desktopgrid_config.cpp index 26fc295cb8..e5be9b3c96 100644 --- a/src/effects/desktopgrid/desktopgrid_config.cpp +++ b/src/effects/desktopgrid/desktopgrid_config.cpp @@ -7,20 +7,21 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "desktopgrid_config.h" + +#include + // KConfigSkeleton #include "desktopgridconfig.h" -#include #include #include -#include #include #include #include #include +#include #include @@ -29,17 +30,18 @@ K_PLUGIN_CLASS(KWin::DesktopGridEffectConfig) namespace KWin { -DesktopGridEffectConfigForm::DesktopGridEffectConfigForm(QWidget* parent) : QWidget(parent) +DesktopGridEffectConfigForm::DesktopGridEffectConfigForm(QWidget *parent) + : QWidget(parent) { setupUi(this); } -DesktopGridEffectConfig::DesktopGridEffectConfig(QWidget* parent, const QVariantList& args) - : KCModule(parent, args) +DesktopGridEffectConfig::DesktopGridEffectConfig(QWidget *parent, const QVariantList &args) + : KCModule(parent, args) { m_ui = new DesktopGridEffectConfigForm(this); - QVBoxLayout* layout = new QVBoxLayout(this); + QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(m_ui); @@ -50,7 +52,7 @@ DesktopGridEffectConfig::DesktopGridEffectConfig(QWidget* parent, const QVariant m_actionCollection->setConfigGroup(QStringLiteral("DesktopGrid")); m_actionCollection->setConfigGlobal(true); - QAction* a = m_actionCollection->addAction(QStringLiteral("ShowDesktopGrid")); + QAction *a = m_actionCollection->addAction(QStringLiteral("ShowDesktopGrid")); a->setText(i18n("Show Desktop Grid")); a->setProperty("isConfigurationAction", true); KGlobalAccel::self()->setDefaultShortcut(a, QList() << (Qt::CTRL | Qt::Key_F8)); @@ -58,7 +60,6 @@ DesktopGridEffectConfig::DesktopGridEffectConfig(QWidget* parent, const QVariant m_ui->shortcutEditor->addCollection(m_actionCollection); - m_ui->desktopNameAlignmentCombo->addItem(i18nc("Desktop name alignment:", "Disabled"), QVariant(Qt::Alignment())); m_ui->desktopNameAlignmentCombo->addItem(i18n("Top"), QVariant(Qt::AlignHCenter | Qt::AlignTop)); m_ui->desktopNameAlignmentCombo->addItem(i18n("Top-Right"), QVariant(Qt::AlignRight | Qt::AlignTop)); diff --git a/src/effects/desktopgrid/desktopgrid_config.h b/src/effects/desktopgrid/desktopgrid_config.h index fe3bdba17d..4bc24d06dc 100644 --- a/src/effects/desktopgrid/desktopgrid_config.h +++ b/src/effects/desktopgrid/desktopgrid_config.h @@ -13,8 +13,8 @@ #include -#include "ui_desktopgrid_config.h" #include "desktopgrid.h" +#include "ui_desktopgrid_config.h" namespace KWin { @@ -23,14 +23,14 @@ class DesktopGridEffectConfigForm : public QWidget, public Ui::DesktopGridEffect { Q_OBJECT public: - explicit DesktopGridEffectConfigForm(QWidget* parent); + explicit DesktopGridEffectConfigForm(QWidget *parent); }; class DesktopGridEffectConfig : public KCModule { Q_OBJECT public: - explicit DesktopGridEffectConfig(QWidget* parent = nullptr, const QVariantList& args = QVariantList()); + explicit DesktopGridEffectConfig(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); ~DesktopGridEffectConfig() override; public Q_SLOTS: @@ -42,8 +42,8 @@ private Q_SLOTS: void layoutSelectionChanged(); private: - DesktopGridEffectConfigForm* m_ui; - KActionCollection* m_actionCollection; + DesktopGridEffectConfigForm *m_ui; + KActionCollection *m_actionCollection; }; } // namespace diff --git a/src/effects/diminactive/diminactive.cpp b/src/effects/diminactive/diminactive.cpp index 71e8c22e0c..23cbe0372b 100644 --- a/src/effects/diminactive/diminactive.cpp +++ b/src/effects/diminactive/diminactive.cpp @@ -391,8 +391,7 @@ void DimInactiveEffect::activeFullScreenEffectChanged() m_fullScreenTransition.timeLine.setDirection( effects->activeFullScreenEffect() ? TimeLine::Forward - : TimeLine::Backward - ); + : TimeLine::Backward); m_fullScreenTransition.active = true; effects->addRepaintFull(); diff --git a/src/effects/diminactive/diminactive.h b/src/effects/diminactive/diminactive.h index 18c90a10a0..101822716d 100644 --- a/src/effects/diminactive/diminactive.h +++ b/src/effects/diminactive/diminactive.h @@ -75,11 +75,12 @@ private: EffectWindow *m_activeWindow = nullptr; const EffectWindowGroup *m_activeWindowGroup; - QHash m_transitions; - QHash m_forceDim; + QHash m_transitions; + QHash m_forceDim; std::chrono::milliseconds m_lastPresentTime = std::chrono::milliseconds::zero(); - struct { + struct + { bool active = false; TimeLine timeLine; } m_fullScreenTransition; diff --git a/src/effects/diminactive/diminactive_config.cpp b/src/effects/diminactive/diminactive_config.cpp index cf0ebbd68f..8fe6898d5a 100644 --- a/src/effects/diminactive/diminactive_config.cpp +++ b/src/effects/diminactive/diminactive_config.cpp @@ -7,12 +7,12 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "diminactive_config.h" +#include + // KConfigSkeleton #include "diminactiveconfig.h" -#include #include diff --git a/src/effects/fallapart/fallapart.cpp b/src/effects/fallapart/fallapart.cpp index 9c8edb0ed4..b7e4cbef03 100644 --- a/src/effects/fallapart/fallapart.cpp +++ b/src/effects/fallapart/fallapart.cpp @@ -38,14 +38,14 @@ void FallApartEffect::reconfigure(ReconfigureFlags) blockSize = FallApartConfig::blockSize(); } -void FallApartEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) +void FallApartEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) { if (!windows.isEmpty()) data.mask |= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS; effects->prePaintScreen(data, presentTime); } -void FallApartEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime) +void FallApartEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) { auto animationIt = windows.find(w); if (animationIt != windows.end() && isRealWindow(w)) { @@ -81,7 +81,7 @@ void FallApartEffect::deform(EffectWindow *w, int mask, WindowPaintData &data, W for (WindowQuad &quad : quads) { // make fragments move in various directions, based on where // they are (left pieces generally move to the left, etc.) - QPointF p1(quad[ 0 ].x(), quad[ 0 ].y()); + QPointF p1(quad[0].x(), quad[0].y()); double xdiff = 0; if (p1.x() < w->width() / 2) xdiff = -(w->width() / 2 - p1.x()) / w->width() * 100; @@ -93,29 +93,29 @@ void FallApartEffect::deform(EffectWindow *w, int mask, WindowPaintData &data, W if (p1.y() > w->height() / 2) ydiff = (p1.y() - w->height() / 2) / w->height() * 100; double modif = t * t * 64; - srandom(cnt); // change direction randomly but consistently + srandom(cnt); // change direction randomly but consistently xdiff += (rand() % 21 - 10); ydiff += (rand() % 21 - 10); for (int j = 0; - j < 4; - ++j) { - quad[ j ].move(quad[ j ].x() + xdiff * modif, quad[ j ].y() + ydiff * modif); + j < 4; + ++j) { + quad[j].move(quad[j].x() + xdiff * modif, quad[j].y() + ydiff * modif); } // also make the fragments rotate around their center - QPointF center((quad[ 0 ].x() + quad[ 1 ].x() + quad[ 2 ].x() + quad[ 3 ].x()) / 4, - (quad[ 0 ].y() + quad[ 1 ].y() + quad[ 2 ].y() + quad[ 3 ].y()) / 4); - double adiff = (rand() % 720 - 360) / 360. * 2 * M_PI; // spin randomly + QPointF center((quad[0].x() + quad[1].x() + quad[2].x() + quad[3].x()) / 4, + (quad[0].y() + quad[1].y() + quad[2].y() + quad[3].y()) / 4); + double adiff = (rand() % 720 - 360) / 360. * 2 * M_PI; // spin randomly for (int j = 0; - j < 4; - ++j) { - double x = quad[ j ].x() - center.x(); - double y = quad[ j ].y() - center.y(); + j < 4; + ++j) { + double x = quad[j].x() - center.x(); + double y = quad[j].y() - center.y(); double angle = atan2(y, x); angle += animationIt->progress * adiff; double dist = sqrt(x * x + y * y); x = dist * cos(angle); y = dist * sin(angle); - quad[ j ].move(center.x() + x, center.y() + y); + quad[j].move(center.x() + x, center.y() + y); } ++cnt; } @@ -130,7 +130,7 @@ void FallApartEffect::postPaintScreen() effects->postPaintScreen(); } -bool FallApartEffect::isRealWindow(EffectWindow* w) +bool FallApartEffect::isRealWindow(EffectWindow *w) { // TODO: isSpecialWindow is rather generic, maybe tell windowtypes separately? /* @@ -155,7 +155,7 @@ bool FallApartEffect::isRealWindow(EffectWindow* w) return true; } -void FallApartEffect::slotWindowClosed(EffectWindow* c) +void FallApartEffect::slotWindowClosed(EffectWindow *c) { if (effects->activeFullScreenEffect()) return; @@ -163,27 +163,27 @@ void FallApartEffect::slotWindowClosed(EffectWindow* c) return; if (!c->isVisible()) return; - const void* e = c->data(WindowClosedGrabRole).value(); + const void *e = c->data(WindowClosedGrabRole).value(); if (e && e != this) return; - c->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast(this))); - windows[ c ].progress = 0; + c->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast(this))); + windows[c].progress = 0; c->refWindow(); redirect(c); } -void FallApartEffect::slotWindowDeleted(EffectWindow* c) +void FallApartEffect::slotWindowDeleted(EffectWindow *c) { windows.remove(c); } -void FallApartEffect::slotWindowDataChanged(EffectWindow* w, int role) +void FallApartEffect::slotWindowDataChanged(EffectWindow *w, int role) { if (role != WindowClosedGrabRole) { return; } - if (w->data(role).value() == this) { + if (w->data(role).value() == this) { return; } diff --git a/src/effects/fallapart/fallapart.h b/src/effects/fallapart/fallapart.h index d0b54a91f1..781551de0c 100644 --- a/src/effects/fallapart/fallapart.h +++ b/src/effects/fallapart/fallapart.h @@ -28,17 +28,19 @@ class FallApartEffect : public DeformEffect public: FallApartEffect(); void reconfigure(ReconfigureFlags) override; - void prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) override; - void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime) override; + void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; + void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) override; void postPaintScreen() override; bool isActive() const override; - int requestedEffectChainPosition() const override { + int requestedEffectChainPosition() const override + { return 70; } // for properties - int configuredBlockSize() const { + int configuredBlockSize() const + { return blockSize; } @@ -53,8 +55,8 @@ public Q_SLOTS: void slotWindowDataChanged(KWin::EffectWindow *w, int role); private: - QHash< EffectWindow*, FallApartAnimation > windows; - bool isRealWindow(EffectWindow* w); + QHash windows; + bool isRealWindow(EffectWindow *w); int blockSize; }; diff --git a/src/effects/glide/glide.cpp b/src/effects/glide/glide.cpp index 70edca759f..02f8f8229e 100644 --- a/src/effects/glide/glide.cpp +++ b/src/effects/glide/glide.cpp @@ -23,7 +23,7 @@ namespace KWin { -static const QSet s_blacklist { +static const QSet s_blacklist{ QStringLiteral("ksmserver ksmserver"), QStringLiteral("ksmserver-logout-greeter ksmserver-logout-greeter"), QStringLiteral("ksplashqml ksplashqml"), @@ -210,12 +210,12 @@ void GlideEffect::windowAdded(EffectWindow *w) return; } - const void *addGrab = w->data(WindowAddedGrabRole).value(); + const void *addGrab = w->data(WindowAddedGrabRole).value(); if (addGrab && addGrab != this) { return; } - w->setData(WindowAddedGrabRole, QVariant::fromValue(static_cast(this))); + w->setData(WindowAddedGrabRole, QVariant::fromValue(static_cast(this))); GlideAnimation &animation = m_animations[w]; animation.timeLine.reset(); @@ -240,13 +240,13 @@ void GlideEffect::windowClosed(EffectWindow *w) return; } - const void *closeGrab = w->data(WindowClosedGrabRole).value(); + const void *closeGrab = w->data(WindowClosedGrabRole).value(); if (closeGrab && closeGrab != this) { return; } w->refWindow(); - w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast(this))); + w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast(this))); GlideAnimation &animation = m_animations[w]; animation.timeLine.reset(); @@ -268,7 +268,7 @@ void GlideEffect::windowDataChanged(EffectWindow *w, int role) return; } - if (w->data(role).value() == this) { + if (w->data(role).value() == this) { return; } @@ -293,7 +293,7 @@ bool GlideEffect::isGlideWindow(EffectWindow *w) const // to use a heuristic: if a window has decoration, then it's most // likely a dialog or a settings window so we have to animate it. if (w->windowClass() == QLatin1String("plasmashell plasmashell") - || w->windowClass() == QLatin1String("plasmashell org.kde.plasmashell")) { + || w->windowClass() == QLatin1String("plasmashell org.kde.plasmashell")) { return w->hasDecoration(); } diff --git a/src/effects/glide/glide.h b/src/effects/glide/glide.h index 13b315fdab..b02c79e826 100644 --- a/src/effects/glide/glide.h +++ b/src/effects/glide/glide.h @@ -55,10 +55,10 @@ public: static bool supported(); enum RotationEdge { - Top = 0, - Right = 1, + Top = 0, + Right = 1, Bottom = 2, - Left = 3 + Left = 3 }; Q_ENUM(RotationEdge) @@ -84,9 +84,11 @@ private: std::chrono::milliseconds m_duration; QHash m_animations; - struct GlideParams { + struct GlideParams + { RotationEdge edge; - struct { + struct + { qreal from; qreal to; } angle, distance, opacity; diff --git a/src/effects/glide/glide_config.cpp b/src/effects/glide/glide_config.cpp index 532bbd603f..937e0087e2 100644 --- a/src/effects/glide/glide_config.cpp +++ b/src/effects/glide/glide_config.cpp @@ -4,14 +4,15 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "glide_config.h" -// KConfigSkeleton -#include "glideconfig.h" + #include -#include +// KConfigSkeleton +#include "glideconfig.h" + #include +#include K_PLUGIN_CLASS(KWin::GlideEffectConfig) diff --git a/src/effects/glide/glide_config.h b/src/effects/glide/glide_config.h index 252751257f..5af4d40365 100644 --- a/src/effects/glide/glide_config.h +++ b/src/effects/glide/glide_config.h @@ -8,8 +8,8 @@ #ifndef GLIDE_CONFIG_H #define GLIDE_CONFIG_H -#include #include "ui_glide_config.h" +#include namespace KWin { @@ -31,4 +31,3 @@ private: } // namespace KWin #endif - diff --git a/src/effects/highlightwindow/highlightwindow.cpp b/src/effects/highlightwindow/highlightwindow.cpp index 0cbe177b64..5d260faa4c 100644 --- a/src/effects/highlightwindow/highlightwindow.cpp +++ b/src/effects/highlightwindow/highlightwindow.cpp @@ -27,16 +27,12 @@ HighlightWindowEffect::HighlightWindowEffect() connect(effects, &EffectsHandler::windowAdded, this, &HighlightWindowEffect::slotWindowAdded); connect(effects, &EffectsHandler::windowClosed, this, &HighlightWindowEffect::slotWindowClosed); connect(effects, &EffectsHandler::windowDeleted, this, &HighlightWindowEffect::slotWindowDeleted); - connect(effects, &EffectsHandler::propertyNotify, this, - [this](EffectWindow *w, long atom) { - slotPropertyNotify(w, atom, nullptr); - } - ); - connect(effects, &EffectsHandler::xcbConnectionChanged, this, - [this] { - m_atom = effects->announceSupportProperty("_KDE_WINDOW_HIGHLIGHT", this); - } - ); + connect(effects, &EffectsHandler::propertyNotify, this, [this](EffectWindow *w, long atom) { + slotPropertyNotify(w, atom, nullptr); + }); + connect(effects, &EffectsHandler::xcbConnectionChanged, this, [this]() { + m_atom = effects->announceSupportProperty("_KDE_WINDOW_HIGHLIGHT", this); + }); QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/kde/KWin/HighlightWindow"), QStringLiteral("org.kde.KWin.HighlightWindow"), @@ -50,7 +46,7 @@ HighlightWindowEffect::~HighlightWindowEffect() QDBusConnection::sessionBus().unregisterService(QStringLiteral("org.kde.KWin.HighlightWindow")); } -static bool isInitiallyHidden(EffectWindow* w) +static bool isInitiallyHidden(EffectWindow *w) { // Is the window initially hidden until it is highlighted? return w->isMinimized() || !w->isOnCurrentDesktop(); @@ -63,19 +59,19 @@ static bool isHighlightWindow(EffectWindow *window) void HighlightWindowEffect::highlightWindows(const QStringList &windows) { - QVector effectWindows; + QVector effectWindows; effectWindows.reserve(windows.count()); for (const auto &window : windows) { if (auto effectWindow = effects->findWindow(QUuid(window)); effectWindow) { effectWindows.append(effectWindow); } else if (auto effectWindow = effects->findWindow(window.toLong()); effectWindow) { - effectWindows.append(effectWindow); + effectWindows.append(effectWindow); } } highlightWindows(effectWindows); } -void HighlightWindowEffect::slotWindowAdded(EffectWindow* w) +void HighlightWindowEffect::slotWindowAdded(EffectWindow *w) { if (!m_highlightedWindows.isEmpty()) { // On X11, the tabbox may ask us to highlight itself before the windowAdded signal @@ -96,35 +92,34 @@ void HighlightWindowEffect::slotWindowAdded(EffectWindow* w) complete(animationId); } } - slotPropertyNotify(w, m_atom, w); // Check initial value + slotPropertyNotify(w, m_atom, w); // Check initial value } -void HighlightWindowEffect::slotWindowClosed(EffectWindow* w) +void HighlightWindowEffect::slotWindowClosed(EffectWindow *w) { - if (m_monitorWindow == w) // The monitoring window was destroyed + if (m_monitorWindow == w) // The monitoring window was destroyed finishHighlighting(); } -void HighlightWindowEffect::slotWindowDeleted(EffectWindow* w) +void HighlightWindowEffect::slotWindowDeleted(EffectWindow *w) { m_animations.remove(w); } -void HighlightWindowEffect::slotPropertyNotify(EffectWindow* w, long a, EffectWindow *addedWindow) +void HighlightWindowEffect::slotPropertyNotify(EffectWindow *w, long a, EffectWindow *addedWindow) { if (a != m_atom || m_atom == XCB_ATOM_NONE) return; // Not our atom // if the window is null, the property was set on the root window - see events.cpp - QByteArray byteData = w ? w->readProperty(m_atom, m_atom, 32) : - effects->readRootProperty(m_atom, m_atom, 32); + QByteArray byteData = w ? w->readProperty(m_atom, m_atom, 32) : effects->readRootProperty(m_atom, m_atom, 32); if (byteData.length() < 1) { // Property was removed, clearing highlight if (!addedWindow || w != addedWindow) finishHighlighting(); return; } - auto* data = reinterpret_cast(byteData.data()); + auto *data = reinterpret_cast(byteData.data()); if (!data[0]) { // Purposely clearing highlight by issuing a NULL target @@ -134,13 +129,13 @@ void HighlightWindowEffect::slotPropertyNotify(EffectWindow* w, long a, EffectWi m_monitorWindow = w; bool found = false; int length = byteData.length() / sizeof(data[0]); - //foreach ( EffectWindow* e, m_highlightedWindows ) - // effects->setElevatedWindow( e, false ); + // foreach ( EffectWindow* e, m_highlightedWindows ) + // effects->setElevatedWindow( e, false ); m_highlightedWindows.clear(); m_highlightedIds.clear(); for (int i = 0; i < length; i++) { m_highlightedIds << data[i]; - EffectWindow* foundWin = effects->findWindow(data[i]); + EffectWindow *foundWin = effects->findWindow(data[i]); if (!foundWin) { qCDebug(KWIN_HIGHLIGHTWINDOW) << "Invalid window targetted for highlight. Requested:" << data[i]; continue; // might come in later. @@ -148,7 +143,7 @@ void HighlightWindowEffect::slotPropertyNotify(EffectWindow* w, long a, EffectWi m_highlightedWindows.append(foundWin); // TODO: We cannot just simply elevate the window as this will elevate it over // Plasma tooltips and other such windows as well - //effects->setElevatedWindow( foundWin, true ); + // effects->setElevatedWindow( foundWin, true ); found = true; } if (!found) { @@ -271,7 +266,7 @@ bool HighlightWindowEffect::perform(Feature feature, const QVariantList &argumen if (arguments.size() != 1) { return false; } - highlightWindows(arguments.first().value>()); + highlightWindows(arguments.first().value>()); return true; } diff --git a/src/effects/highlightwindow/highlightwindow.h b/src/effects/highlightwindow/highlightwindow.h index f78b43026c..6f929ec003 100644 --- a/src/effects/highlightwindow/highlightwindow.h +++ b/src/effects/highlightwindow/highlightwindow.h @@ -23,7 +23,8 @@ public: HighlightWindowEffect(); ~HighlightWindowEffect() override; - int requestedEffectChainPosition() const override { + int requestedEffectChainPosition() const override + { return 70; } @@ -32,10 +33,10 @@ public: Q_SCRIPTABLE void highlightWindows(const QStringList &windows); public Q_SLOTS: - void slotWindowAdded(KWin::EffectWindow* w); + void slotWindowAdded(KWin::EffectWindow *w); void slotWindowClosed(KWin::EffectWindow *w); void slotWindowDeleted(KWin::EffectWindow *w); - void slotPropertyNotify(KWin::EffectWindow* w, long atom, EffectWindow *addedWindow = nullptr); + void slotPropertyNotify(KWin::EffectWindow *w, long atom, EffectWindow *addedWindow = nullptr); private: quint64 startGhostAnimation(EffectWindow *window); diff --git a/src/effects/invert/invert.cpp b/src/effects/invert/invert.cpp index b64fc1b6fb..5b5ef7b20a 100644 --- a/src/effects/invert/invert.cpp +++ b/src/effects/invert/invert.cpp @@ -10,13 +10,13 @@ #include "invert.h" -#include -#include -#include -#include #include #include +#include +#include #include +#include +#include #include @@ -32,12 +32,12 @@ namespace KWin { InvertEffect::InvertEffect() - : m_inited(false), - m_valid(true), - m_shader(nullptr), - m_allWindows(false) + : m_inited(false) + , m_valid(true) + , m_shader(nullptr) + , m_allWindows(false) { - QAction* a = new QAction(this); + QAction *a = new QAction(this); a->setObjectName(QStringLiteral("Invert")); a->setText(i18n("Toggle Invert Effect")); KGlobalAccel::self()->setDefaultShortcut(a, QList() << (Qt::CTRL | Qt::META | Qt::Key_I)); @@ -45,7 +45,7 @@ InvertEffect::InvertEffect() effects->registerGlobalShortcut(Qt::CTRL | Qt::META | Qt::Key_I, a); connect(a, &QAction::triggered, this, &InvertEffect::toggleScreenInversion); - QAction* b = new QAction(this); + QAction *b = new QAction(this); b->setObjectName(QStringLiteral("InvertWindow")); b->setText(i18n("Toggle Invert Effect on Window")); KGlobalAccel::self()->setDefaultShortcut(b, QList() << (Qt::CTRL | Qt::META | Qt::Key_U)); @@ -80,7 +80,7 @@ bool InvertEffect::loadData() return true; } -void InvertEffect::drawWindow(EffectWindow* w, int mask, const QRegion ®ion, WindowPaintData& data) +void InvertEffect::drawWindow(EffectWindow *w, int mask, const QRegion ®ion, WindowPaintData &data) { // Load if we haven't already if (m_valid && !m_inited) @@ -101,7 +101,7 @@ void InvertEffect::drawWindow(EffectWindow* w, int mask, const QRegion ®ion, } } -void InvertEffect::paintEffectFrame(KWin::EffectFrame* frame, const QRegion ®ion, double opacity, double frameOpacity) +void InvertEffect::paintEffectFrame(KWin::EffectFrame *frame, const QRegion ®ion, double opacity, double frameOpacity) { if (m_valid && m_allWindows) { frame->setShader(m_shader); @@ -112,7 +112,7 @@ void InvertEffect::paintEffectFrame(KWin::EffectFrame* frame, const QRegion ® } } -void InvertEffect::slotWindowClosed(EffectWindow* w) +void InvertEffect::slotWindowClosed(EffectWindow *w) { m_windows.removeOne(w); } @@ -146,4 +146,3 @@ bool InvertEffect::provides(Feature f) } } // namespace - diff --git a/src/effects/invert/invert.h b/src/effects/invert/invert.h index aa23f73801..bb5d5b19b5 100644 --- a/src/effects/invert/invert.h +++ b/src/effects/invert/invert.h @@ -29,8 +29,8 @@ public: InvertEffect(); ~InvertEffect() override; - void drawWindow(EffectWindow* w, int mask, const QRegion ®ion, WindowPaintData& data) override; - void paintEffectFrame(KWin::EffectFrame* frame, const QRegion ®ion, double opacity, double frameOpacity) override; + void drawWindow(EffectWindow *w, int mask, const QRegion ®ion, WindowPaintData &data) override; + void paintEffectFrame(KWin::EffectFrame *frame, const QRegion ®ion, double opacity, double frameOpacity) override; bool isActive() const override; bool provides(Feature) override; @@ -49,9 +49,9 @@ protected: private: bool m_inited; bool m_valid; - GLShader* m_shader; + GLShader *m_shader; bool m_allWindows; - QList m_windows; + QList m_windows; }; inline int InvertEffect::requestedEffectChainPosition() const diff --git a/src/effects/invert/invert_config.cpp b/src/effects/invert/invert_config.cpp index 2470a82a85..db8731396e 100644 --- a/src/effects/invert/invert_config.cpp +++ b/src/effects/invert/invert_config.cpp @@ -12,11 +12,11 @@ #include +#include #include #include -#include -#include #include +#include #include @@ -25,22 +25,22 @@ K_PLUGIN_CLASS(KWin::InvertEffectConfig) namespace KWin { -InvertEffectConfig::InvertEffectConfig(QWidget* parent, const QVariantList& args) : - KCModule(parent, args) +InvertEffectConfig::InvertEffectConfig(QWidget *parent, const QVariantList &args) + : KCModule(parent, args) { - QVBoxLayout* layout = new QVBoxLayout(this); + QVBoxLayout *layout = new QVBoxLayout(this); // Shortcut config. The shortcut belongs to the component "kwin"! KActionCollection *actionCollection = new KActionCollection(this, QStringLiteral("kwin")); actionCollection->setComponentDisplayName(i18n("KWin")); - QAction* a = actionCollection->addAction(QStringLiteral("Invert")); + QAction *a = actionCollection->addAction(QStringLiteral("Invert")); a->setText(i18n("Toggle Invert Effect")); a->setProperty("isConfigurationAction", true); KGlobalAccel::self()->setDefaultShortcut(a, QList() << (Qt::CTRL | Qt::META | Qt::Key_I)); KGlobalAccel::self()->setShortcut(a, QList() << (Qt::CTRL | Qt::META | Qt::Key_I)); - QAction* b = actionCollection->addAction(QStringLiteral("InvertWindow")); + QAction *b = actionCollection->addAction(QStringLiteral("InvertWindow")); b->setText(i18n("Toggle Invert Effect on Window")); b->setProperty("isConfigurationAction", true); KGlobalAccel::self()->setDefaultShortcut(b, QList() << (Qt::CTRL | Qt::META | Qt::Key_U)); @@ -69,7 +69,7 @@ void InvertEffectConfig::save() { KCModule::save(); - mShortcutEditor->save(); // undo() will restore to this state from now on + mShortcutEditor->save(); // undo() will restore to this state from now on Q_EMIT changed(false); OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), @@ -85,7 +85,6 @@ void InvertEffectConfig::defaults() Q_EMIT changed(true); } - } // namespace #include "invert_config.moc" diff --git a/src/effects/invert/invert_config.h b/src/effects/invert/invert_config.h index 421878b8e4..374d0e89f8 100644 --- a/src/effects/invert/invert_config.h +++ b/src/effects/invert/invert_config.h @@ -21,7 +21,7 @@ class InvertEffectConfig : public KCModule { Q_OBJECT public: - explicit InvertEffectConfig(QWidget* parent = nullptr, const QVariantList& args = QVariantList()); + explicit InvertEffectConfig(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); ~InvertEffectConfig() override; public Q_SLOTS: @@ -30,7 +30,7 @@ public Q_SLOTS: void defaults() override; private: - KShortcutsEditor* mShortcutEditor; + KShortcutsEditor *mShortcutEditor; }; } // namespace diff --git a/src/effects/kscreen/kscreen.cpp b/src/effects/kscreen/kscreen.cpp index 9484399756..1b92efad4a 100644 --- a/src/effects/kscreen/kscreen.cpp +++ b/src/effects/kscreen/kscreen.cpp @@ -48,11 +48,9 @@ KscreenEffect::KscreenEffect() { initConfig(); connect(effects, &EffectsHandler::propertyNotify, this, &KscreenEffect::propertyNotify); - connect(effects, &EffectsHandler::xcbConnectionChanged, this, - [this] { - m_atom = effects->announceSupportProperty(QByteArrayLiteral("_KDE_KWIN_KSCREEN_SUPPORT"), this); - } - ); + connect(effects, &EffectsHandler::xcbConnectionChanged, this, [this]() { + m_atom = effects->announceSupportProperty(QByteArrayLiteral("_KDE_KWIN_KSCREEN_SUPPORT"), this); + }); reconfigure(ReconfigureAll); const QList screens = effects->screens(); @@ -60,7 +58,7 @@ KscreenEffect::KscreenEffect() addScreen(screen); } connect(effects, &EffectsHandler::screenAdded, this, &KscreenEffect::addScreen); - connect(effects, &EffectsHandler::screenRemoved, this, [this] (KWin::EffectScreen *screen) { + connect(effects, &EffectsHandler::screenRemoved, this, [this](KWin::EffectScreen *screen) { m_waylandStates.remove(screen); }); } @@ -76,7 +74,7 @@ void KscreenEffect::addScreen(EffectScreen *screen) state.m_timeLine.setDuration(std::chrono::milliseconds(animationTime(250))); setState(state, StateFadingIn); }); - connect(screen, &EffectScreen::aboutToTurnOff, this, [this, screen] (std::chrono::milliseconds dimmingIn) { + connect(screen, &EffectScreen::aboutToTurnOff, this, [this, screen](std::chrono::milliseconds dimmingIn) { auto &state = m_waylandStates[screen]; state.m_timeLine.setDuration(dimmingIn); setState(state, StateFadingOut); @@ -147,23 +145,23 @@ void KscreenEffect::paintWindow(EffectWindow *w, int mask, QRegion region, Windo auto screen = w->screen(); if (isScreenActive(screen)) { auto &state = !effects->waylandDisplay() ? m_xcbState : m_waylandStates[screen]; - //fade to black and fully opaque + // fade to black and fully opaque switch (state.m_state) { - case StateFadingOut: - data.setOpacity(data.opacity() + (1.0 - data.opacity()) * state.m_timeLine.value()); - data.multiplyBrightness(1.0 - state.m_timeLine.value()); - break; - case StateFadedOut: - data.multiplyOpacity(0.0); - data.multiplyBrightness(0.0); - break; - case StateFadingIn: - data.setOpacity(data.opacity() + (1.0 - data.opacity()) * (1.0 - state.m_timeLine.value())); - data.multiplyBrightness(state.m_timeLine.value()); - break; - default: - // no adjustment - break; + case StateFadingOut: + data.setOpacity(data.opacity() + (1.0 - data.opacity()) * state.m_timeLine.value()); + data.multiplyBrightness(1.0 - state.m_timeLine.value()); + break; + case StateFadedOut: + data.multiplyOpacity(0.0); + data.multiplyBrightness(0.0); + break; + case StateFadingIn: + data.setOpacity(data.opacity() + (1.0 - data.opacity()) * (1.0 - state.m_timeLine.value())); + data.multiplyBrightness(state.m_timeLine.value()); + break; + default: + // no adjustment + break; } } effects->paintWindow(w, mask, region, data); diff --git a/src/effects/kscreen/kscreen.h b/src/effects/kscreen/kscreen.h index fb256a2512..5612e8c7f3 100644 --- a/src/effects/kscreen/kscreen.h +++ b/src/effects/kscreen/kscreen.h @@ -30,7 +30,8 @@ public: void reconfigure(ReconfigureFlags flags) override; bool isActive() const override; - int requestedEffectChainPosition() const override { + int requestedEffectChainPosition() const override + { return 99; } @@ -45,7 +46,8 @@ private: StateFadingIn, LastState }; - struct ScreenState { + struct ScreenState + { TimeLine m_timeLine; std::chrono::milliseconds m_lastPresentTime = std::chrono::milliseconds::zero(); FadeOutState m_state = StateNormal; @@ -62,6 +64,5 @@ private: xcb_atom_t m_atom; }; - } // namespace KWin #endif // KWIN_KSCREEN_H diff --git a/src/effects/lookingglass/lookingglass.cpp b/src/effects/lookingglass/lookingglass.cpp index 4c441378e0..14823eed6c 100644 --- a/src/effects/lookingglass/lookingglass.cpp +++ b/src/effects/lookingglass/lookingglass.cpp @@ -14,14 +14,14 @@ #include "lookingglassconfig.h" #include -#include #include +#include -#include #include #include -#include +#include #include +#include #include @@ -51,7 +51,7 @@ LookingGlassEffect::LookingGlassEffect() , m_valid(false) { initConfig(); - QAction* a; + QAction *a; a = KStandardAction::zoomIn(this, SLOT(zoomIn()), this); KGlobalAccel::self()->setDefaultShortcut(a, QList() << (Qt::META | Qt::Key_Equal)); KGlobalAccel::self()->setShortcut(a, QList() << (Qt::META | Qt::Key_Equal)); @@ -196,7 +196,7 @@ QRect LookingGlassEffect::magnifierArea() const return QRect(cursorPos().x() - radius, cursorPos().y() - radius, 2 * radius, 2 * radius); } -void LookingGlassEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) +void LookingGlassEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) { const int time = m_lastPresentTime.count() ? (presentTime - m_lastPresentTime).count() : 0; if (zoom != target_zoom) { @@ -228,8 +228,8 @@ void LookingGlassEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::m effects->prePaintScreen(data, presentTime); } -void LookingGlassEffect::slotMouseChanged(const QPoint& pos, const QPoint& old, Qt::MouseButtons, - Qt::MouseButtons, Qt::KeyboardModifiers, Qt::KeyboardModifiers) +void LookingGlassEffect::slotMouseChanged(const QPoint &pos, const QPoint &old, Qt::MouseButtons, + Qt::MouseButtons, Qt::KeyboardModifiers, Qt::KeyboardModifiers) { if (pos != old && m_enabled) { effects->addRepaint(pos.x() - radius, pos.y() - radius, 2 * radius, 2 * radius); @@ -250,7 +250,7 @@ void LookingGlassEffect::paintScreen(int mask, const QRegion ®ion, ScreenPain effects->paintScreen(mask, region, data); if (m_valid && m_enabled) { // Disable render texture - GLRenderTarget* target = GLRenderTarget::popRenderTarget(); + GLRenderTarget *target = GLRenderTarget::popRenderTarget(); Q_ASSERT(target == m_fbo); Q_UNUSED(target); m_texture->bind(); @@ -273,4 +273,3 @@ bool LookingGlassEffect::isActive() const } } // namespace - diff --git a/src/effects/lookingglass/lookingglass.h b/src/effects/lookingglass/lookingglass.h index 8c16f36439..37bf4a2ef0 100644 --- a/src/effects/lookingglass/lookingglass.h +++ b/src/effects/lookingglass/lookingglass.h @@ -34,14 +34,15 @@ public: void reconfigure(ReconfigureFlags) override; - void prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) override; + void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; void paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) override; bool isActive() const override; static bool supported(); // for properties - int initialRadius() const { + int initialRadius() const + { return initialradius; } QRect magnifierArea() const; @@ -50,9 +51,9 @@ 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); + void slotMouseChanged(const QPoint &pos, const QPoint &old, + Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, + Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); void slotWindowDamaged(); private: diff --git a/src/effects/lookingglass/lookingglass_config.cpp b/src/effects/lookingglass/lookingglass_config.cpp index d7b77c1c5b..cc215dc2dc 100644 --- a/src/effects/lookingglass/lookingglass_config.cpp +++ b/src/effects/lookingglass/lookingglass_config.cpp @@ -6,42 +6,42 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "lookingglass_config.h" +#include + // KConfigSkeleton #include "lookingglassconfig.h" -#include #include -#include - +#include #include #include -#include -#include #include +#include +#include #include -#include #include +#include K_PLUGIN_CLASS(KWin::LookingGlassEffectConfig) namespace KWin { -LookingGlassEffectConfigForm::LookingGlassEffectConfigForm(QWidget* parent) : QWidget(parent) +LookingGlassEffectConfigForm::LookingGlassEffectConfigForm(QWidget *parent) + : QWidget(parent) { setupUi(this); } -LookingGlassEffectConfig::LookingGlassEffectConfig(QWidget* parent, const QVariantList& args) : - KCModule(parent, args) +LookingGlassEffectConfig::LookingGlassEffectConfig(QWidget *parent, const QVariantList &args) + : KCModule(parent, args) { m_ui = new LookingGlassEffectConfigForm(this); - QVBoxLayout* layout = new QVBoxLayout(this); + QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(m_ui); @@ -56,7 +56,7 @@ LookingGlassEffectConfig::LookingGlassEffectConfig(QWidget* parent, const QVaria m_actionCollection->setConfigGroup(QStringLiteral("LookingGlass")); m_actionCollection->setConfigGlobal(true); - QAction* a; + QAction *a; a = m_actionCollection->addAction(KStandardAction::ZoomIn); a->setProperty("isConfigurationAction", true); KGlobalAccel::self()->setDefaultShortcut(a, QList() << (Qt::META | Qt::Key_Equal)); @@ -83,10 +83,10 @@ LookingGlassEffectConfig::~LookingGlassEffectConfig() void LookingGlassEffectConfig::save() { - qDebug() << "Saving config of LookingGlass" ; + qDebug() << "Saving config of LookingGlass"; KCModule::save(); - m_ui->editor->save(); // undo() will restore to this state from now on + m_ui->editor->save(); // undo() will restore to this state from now on OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Effects"), diff --git a/src/effects/lookingglass/lookingglass_config.h b/src/effects/lookingglass/lookingglass_config.h index 786f359421..df0a96fd9e 100644 --- a/src/effects/lookingglass/lookingglass_config.h +++ b/src/effects/lookingglass/lookingglass_config.h @@ -23,22 +23,22 @@ class LookingGlassEffectConfigForm : public QWidget, public Ui::LookingGlassEffe { Q_OBJECT public: - explicit LookingGlassEffectConfigForm(QWidget* parent); + explicit LookingGlassEffectConfigForm(QWidget *parent); }; class LookingGlassEffectConfig : public KCModule { Q_OBJECT public: - explicit LookingGlassEffectConfig(QWidget* parent = nullptr, const QVariantList& args = QVariantList()); + explicit LookingGlassEffectConfig(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); ~LookingGlassEffectConfig() override; void save() override; void defaults() override; private: - LookingGlassEffectConfigForm* m_ui; - KActionCollection* m_actionCollection; + LookingGlassEffectConfigForm *m_ui; + KActionCollection *m_actionCollection; }; } // namespace diff --git a/src/effects/magiclamp/magiclamp.cpp b/src/effects/magiclamp/magiclamp.cpp index 9219a175f4..d7a4e6cb0b 100644 --- a/src/effects/magiclamp/magiclamp.cpp +++ b/src/effects/magiclamp/magiclamp.cpp @@ -42,7 +42,7 @@ void MagicLampEffect::reconfigure(ReconfigureFlags) m_duration = std::chrono::milliseconds(static_cast(animationTime(d))); } -void MagicLampEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) +void MagicLampEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) { auto animationIt = m_animations.begin(); while (animationIt != m_animations.end()) { @@ -63,7 +63,7 @@ void MagicLampEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::mill effects->prePaintScreen(data, presentTime); } -void MagicLampEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime) +void MagicLampEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) { // Schedule window for transformation if the animation is still in // progress @@ -76,7 +76,7 @@ void MagicLampEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, effects->prePaintWindow(w, data, presentTime); } -void MagicLampEffect::deform(EffectWindow* w, int mask, WindowPaintData& data, WindowQuadList &quads) +void MagicLampEffect::deform(EffectWindow *w, int mask, WindowPaintData &data, WindowQuadList &quads) { Q_UNUSED(mask) Q_UNUSED(data) @@ -94,9 +94,8 @@ void MagicLampEffect::deform(EffectWindow* w, int mask, WindowPaintData& data, W QPoint pt = cursorPos(); // focussing inside the window is no good, leads to ugly artefacts, find nearest border if (extG.contains(pt)) { - const int d[2][2] = { {pt.x() - extG.x(), extG.right() - pt.x()}, - {pt.y() - extG.y(), extG.bottom() - pt.y()} - }; + const int d[2][2] = {{pt.x() - extG.x(), extG.right() - pt.x()}, + {pt.y() - extG.y(), extG.bottom() - pt.y()}}; int di = d[1][0]; position = Top; if (d[0][0] < di) { @@ -109,11 +108,19 @@ void MagicLampEffect::deform(EffectWindow* w, int mask, WindowPaintData& data, W } if (d[0][1] < di) position = Right; - switch(position) { - case Top: pt.setY(extG.y()); break; - case Left: pt.setX(extG.x()); break; - case Bottom: pt.setY(extG.bottom()); break; - case Right: pt.setX(extG.right()); break; + switch (position) { + case Top: + pt.setY(extG.y()); + break; + case Left: + pt.setX(extG.x()); + break; + case Bottom: + pt.setY(extG.bottom()); + break; + case Right: + pt.setX(extG.right()); + break; } } else { if (pt.y() < geo.y()) @@ -128,7 +135,7 @@ void MagicLampEffect::deform(EffectWindow* w, int mask, WindowPaintData& data, W icon = QRect(pt, QSize(0, 0)); } else { // Assumption: there is a panel containing the icon position - EffectWindow* panel = nullptr; + EffectWindow *panel = nullptr; const auto stackingOrder = effects->stackingOrder(); for (EffectWindow *window : stackingOrder) { if (!window->isDock()) @@ -146,13 +153,13 @@ void MagicLampEffect::deform(EffectWindow* w, int mask, WindowPaintData& data, W QRect panelScreen = effects->clientArea(ScreenArea, panel); if (panel->width() >= panel->height()) { // horizontal panel - if (panel->y() <= panelScreen.height()/2) + if (panel->y() <= panelScreen.height() / 2) position = Top; else position = Bottom; } else { // vertical panel - if (panel->x() <= panelScreen.width()/2) + if (panel->x() <= panelScreen.width() / 2) position = Left; else position = Right; @@ -178,28 +185,30 @@ void MagicLampEffect::deform(EffectWindow* w, int mask, WindowPaintData& data, W } } -#define SANITIZE_PROGRESS if (p_progress[0] < 0)\ - p_progress[0] = -p_progress[0];\ - if (p_progress[1] < 0)\ - p_progress[1] = -p_progress[1] -#define SET_QUADS(_SET_A_, _A_, _DA_, _SET_B_, _B_, _O0_, _O1_, _O2_, _O3_) quad[0]._SET_A_((icon._A_() + icon._DA_()*(quad[0]._A_() / geo._DA_()) - (quad[0]._A_() + geo._A_()))*p_progress[_O0_] + quad[0]._A_());\ - quad[1]._SET_A_((icon._A_() + icon._DA_()*(quad[1]._A_() / geo._DA_()) - (quad[1]._A_() + geo._A_()))*p_progress[_O1_] + quad[1]._A_());\ - quad[2]._SET_A_((icon._A_() + icon._DA_()*(quad[2]._A_() / geo._DA_()) - (quad[2]._A_() + geo._A_()))*p_progress[_O2_] + quad[2]._A_());\ - quad[3]._SET_A_((icon._A_() + icon._DA_()*(quad[3]._A_() / geo._DA_()) - (quad[3]._A_() + geo._A_()))*p_progress[_O3_] + quad[3]._A_());\ - \ - quad[0]._SET_B_(quad[0]._B_() + offset[_O0_]);\ - quad[1]._SET_B_(quad[1]._B_() + offset[_O1_]);\ - quad[2]._SET_B_(quad[2]._B_() + offset[_O2_]);\ - quad[3]._SET_B_(quad[3]._B_() + offset[_O3_]) +#define SANITIZE_PROGRESS \ + if (p_progress[0] < 0) \ + p_progress[0] = -p_progress[0]; \ + if (p_progress[1] < 0) \ + p_progress[1] = -p_progress[1] +#define SET_QUADS(_SET_A_, _A_, _DA_, _SET_B_, _B_, _O0_, _O1_, _O2_, _O3_) \ + quad[0]._SET_A_((icon._A_() + icon._DA_() * (quad[0]._A_() / geo._DA_()) - (quad[0]._A_() + geo._A_())) * p_progress[_O0_] + quad[0]._A_()); \ + quad[1]._SET_A_((icon._A_() + icon._DA_() * (quad[1]._A_() / geo._DA_()) - (quad[1]._A_() + geo._A_())) * p_progress[_O1_] + quad[1]._A_()); \ + quad[2]._SET_A_((icon._A_() + icon._DA_() * (quad[2]._A_() / geo._DA_()) - (quad[2]._A_() + geo._A_())) * p_progress[_O2_] + quad[2]._A_()); \ + quad[3]._SET_A_((icon._A_() + icon._DA_() * (quad[3]._A_() / geo._DA_()) - (quad[3]._A_() + geo._A_())) * p_progress[_O3_] + quad[3]._A_()); \ + \ + quad[0]._SET_B_(quad[0]._B_() + offset[_O0_]); \ + quad[1]._SET_B_(quad[1]._B_() + offset[_O1_]); \ + quad[2]._SET_B_(quad[2]._B_() + offset[_O2_]); \ + quad[3]._SET_B_(quad[3]._B_() + offset[_O3_]) quads = quads.makeGrid(40); - float quadFactor; // defines how fast a quad is vertically moved: y coordinates near to window top are slowed down - // it is used as quadFactor^3/windowHeight^3 - // quadFactor is the y position of the quad but is changed towards becomming the window height - // by that the factor becomes 1 and has no influence any more - float offset[2] = {0,0}; // how far has a quad to be moved? Distance between icon and window multiplied by the progress and by the quadFactor - float p_progress[2] = {0,0}; // the factor which defines how far the x values have to be changed - // factor is the current moved y value diveded by the distance between icon and window + float quadFactor; // defines how fast a quad is vertically moved: y coordinates near to window top are slowed down + // it is used as quadFactor^3/windowHeight^3 + // quadFactor is the y position of the quad but is changed towards becomming the window height + // by that the factor becomes 1 and has no influence any more + float offset[2] = {0, 0}; // how far has a quad to be moved? Distance between icon and window multiplied by the progress and by the quadFactor + float p_progress[2] = {0, 0}; // the factor which defines how far the x values have to be changed + // factor is the current moved y value diveded by the distance between icon and window WindowQuad lastQuad; lastQuad[0].setX(-1); lastQuad[0].setY(-1); @@ -224,7 +233,7 @@ void MagicLampEffect::deform(EffectWindow* w, int mask, WindowPaintData& data, W SANITIZE_PROGRESS; // x values are moved towards the center of the icon - SET_QUADS(setX, x, width, setY, y, 0,0,1,1); + SET_QUADS(setX, x, width, setY, y, 0, 0, 1, 1); } } else if (position == Top) { float height_cube = float(geo.height()) * float(geo.height()) * float(geo.height()); @@ -245,7 +254,7 @@ void MagicLampEffect::deform(EffectWindow* w, int mask, WindowPaintData& data, W SANITIZE_PROGRESS; // x values are moved towards the center of the icon - SET_QUADS(setX, x, width, setY, y, 0,0,1,1); + SET_QUADS(setX, x, width, setY, y, 0, 0, 1, 1); } } else if (position == Left) { float width_cube = float(geo.width()) * float(geo.width()) * float(geo.width()); @@ -266,7 +275,7 @@ void MagicLampEffect::deform(EffectWindow* w, int mask, WindowPaintData& data, W SANITIZE_PROGRESS; // y values are moved towards the center of the icon - SET_QUADS(setY, y, height, setX, x, 0,1,1,0); + SET_QUADS(setY, y, height, setX, x, 0, 1, 1, 0); } } else if (position == Right) { float width_cube = float(geo.width()) * float(geo.width()) * float(geo.width()); @@ -284,7 +293,7 @@ void MagicLampEffect::deform(EffectWindow* w, int mask, WindowPaintData& data, W SANITIZE_PROGRESS; // y values are moved towards the center of the icon - SET_QUADS(setY, y, height, setX, x, 0,1,1,0); + SET_QUADS(setY, y, height, setX, x, 0, 1, 1, 0); } } } @@ -308,12 +317,12 @@ void MagicLampEffect::postPaintScreen() effects->postPaintScreen(); } -void MagicLampEffect::slotWindowDeleted(EffectWindow* w) +void MagicLampEffect::slotWindowDeleted(EffectWindow *w) { m_animations.remove(w); } -void MagicLampEffect::slotWindowMinimized(EffectWindow* w) +void MagicLampEffect::slotWindowMinimized(EffectWindow *w) { if (effects->activeFullScreenEffect()) return; @@ -332,7 +341,7 @@ void MagicLampEffect::slotWindowMinimized(EffectWindow* w) effects->addRepaintFull(); } -void MagicLampEffect::slotWindowUnminimized(EffectWindow* w) +void MagicLampEffect::slotWindowUnminimized(EffectWindow *w) { if (effects->activeFullScreenEffect()) return; diff --git a/src/effects/magiclamp/magiclamp.h b/src/effects/magiclamp/magiclamp.h index 8effa2721a..fc65564718 100644 --- a/src/effects/magiclamp/magiclamp.h +++ b/src/effects/magiclamp/magiclamp.h @@ -29,12 +29,13 @@ public: MagicLampEffect(); void reconfigure(ReconfigureFlags) override; - void prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) override; - void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime) override; + void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; + void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) override; void postPaintScreen() override; bool isActive() const override; - int requestedEffectChainPosition() const override { + int requestedEffectChainPosition() const override + { return 50; } diff --git a/src/effects/magiclamp/magiclamp_config.cpp b/src/effects/magiclamp/magiclamp_config.cpp index 030a9c0910..84ea154a3c 100644 --- a/src/effects/magiclamp/magiclamp_config.cpp +++ b/src/effects/magiclamp/magiclamp_config.cpp @@ -7,14 +7,16 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "magiclamp_config.h" + +#include + // KConfigSkeleton #include "magiclampconfig.h" -#include #include -#include #include +#include #include @@ -23,17 +25,18 @@ K_PLUGIN_CLASS(KWin::MagicLampEffectConfig) namespace KWin { -MagicLampEffectConfigForm::MagicLampEffectConfigForm(QWidget* parent) : QWidget(parent) +MagicLampEffectConfigForm::MagicLampEffectConfigForm(QWidget *parent) + : QWidget(parent) { setupUi(this); } -MagicLampEffectConfig::MagicLampEffectConfig(QWidget* parent, const QVariantList& args) : - KCModule(parent, args) +MagicLampEffectConfig::MagicLampEffectConfig(QWidget *parent, const QVariantList &args) + : KCModule(parent, args) { m_ui = new MagicLampEffectConfigForm(this); - QVBoxLayout* layout = new QVBoxLayout(this); + QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(m_ui); diff --git a/src/effects/magiclamp/magiclamp_config.h b/src/effects/magiclamp/magiclamp_config.h index a389d9ada5..86f3a0c427 100644 --- a/src/effects/magiclamp/magiclamp_config.h +++ b/src/effects/magiclamp/magiclamp_config.h @@ -14,7 +14,6 @@ #include "ui_magiclamp_config.h" - namespace KWin { @@ -22,20 +21,20 @@ class MagicLampEffectConfigForm : public QWidget, public Ui::MagicLampEffectConf { Q_OBJECT public: - explicit MagicLampEffectConfigForm(QWidget* parent); + explicit MagicLampEffectConfigForm(QWidget *parent); }; class MagicLampEffectConfig : public KCModule { Q_OBJECT public: - explicit MagicLampEffectConfig(QWidget* parent = nullptr, const QVariantList& args = QVariantList()); + explicit MagicLampEffectConfig(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); public Q_SLOTS: void save() override; private: - MagicLampEffectConfigForm* m_ui; + MagicLampEffectConfigForm *m_ui; }; } // namespace diff --git a/src/effects/magnifier/magnifier.cpp b/src/effects/magnifier/magnifier.cpp index 8e35ff6987..c6b084c6d6 100644 --- a/src/effects/magnifier/magnifier.cpp +++ b/src/effects/magnifier/magnifier.cpp @@ -14,11 +14,11 @@ #include "magnifierconfig.h" #include -#include #include +#include -#include #include +#include namespace KWin { @@ -34,7 +34,7 @@ MagnifierEffect::MagnifierEffect() , m_fbo(nullptr) { initConfig(); - QAction* a; + QAction *a; a = KStandardAction::zoomIn(this, &MagnifierEffect::zoomIn, this); KGlobalAccel::self()->setDefaultShortcut(a, QList() << (Qt::META | Qt::Key_Equal)); KGlobalAccel::self()->setShortcut(a, QList() << (Qt::META | Qt::Key_Equal)); @@ -83,7 +83,7 @@ void MagnifierEffect::reconfigure(ReconfigureFlags) toggle(); } -void MagnifierEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) +void MagnifierEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) { const int time = m_lastPresentTime.count() ? (presentTime - m_lastPresentTime).count() : 0; @@ -114,16 +114,16 @@ void MagnifierEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::mill data.paint |= magnifierArea().adjusted(-FRAME_WIDTH, -FRAME_WIDTH, FRAME_WIDTH, FRAME_WIDTH); } -void MagnifierEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) +void MagnifierEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) { - effects->paintScreen(mask, region, data); // paint normal screen + effects->paintScreen(mask, region, data); // paint normal screen if (zoom != 1.0) { // get the right area from the current rendered screen const QRect area = magnifierArea(); const QPoint cursor = cursorPos(); - QRect srcArea(cursor.x() - (double)area.width() / (zoom*2), - cursor.y() - (double)area.height() / (zoom*2), + QRect srcArea(cursor.x() - (double)area.width() / (zoom * 2), + cursor.y() - (double)area.height() / (zoom * 2), (double)area.width() / zoom, (double)area.height() / zoom); if (effects->isOpenGLCompositing()) { m_fbo->blitFromFramebuffer(effects->mapToRenderTarget(srcArea)); @@ -257,8 +257,8 @@ void MagnifierEffect::toggle() effects->addRepaint(magnifierArea().adjusted(-FRAME_WIDTH, -FRAME_WIDTH, FRAME_WIDTH, FRAME_WIDTH)); } -void MagnifierEffect::slotMouseChanged(const QPoint& pos, const QPoint& old, - Qt::MouseButtons, Qt::MouseButtons, Qt::KeyboardModifiers, Qt::KeyboardModifiers) +void MagnifierEffect::slotMouseChanged(const QPoint &pos, const QPoint &old, + Qt::MouseButtons, Qt::MouseButtons, Qt::KeyboardModifiers, Qt::KeyboardModifiers) { if (pos != old && zoom != 1) // need full repaint as we might lose some change events on fast mouse movements @@ -279,4 +279,3 @@ bool MagnifierEffect::isActive() const } } // namespace - diff --git a/src/effects/magnifier/magnifier.h b/src/effects/magnifier/magnifier.h index f98cfd13e7..683b05ebdb 100644 --- a/src/effects/magnifier/magnifier.h +++ b/src/effects/magnifier/magnifier.h @@ -29,27 +29,30 @@ public: MagnifierEffect(); ~MagnifierEffect() override; void reconfigure(ReconfigureFlags) override; - void prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) override; - void paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) override; + void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; + void paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) override; void postPaintScreen() override; bool isActive() const override; static bool supported(); // for properties - QSize magnifierSize() const { + QSize magnifierSize() const + { return magnifier_size; } - qreal targetZoom() const { + 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 slotMouseChanged(const QPoint &pos, const QPoint &old, + Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, + Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); void slotWindowDamaged(); + private: QRect magnifierArea(QPoint pos = cursorPos()) const; double zoom; diff --git a/src/effects/magnifier/magnifier_config.cpp b/src/effects/magnifier/magnifier_config.cpp index 46ae3744cf..944cec1fba 100644 --- a/src/effects/magnifier/magnifier_config.cpp +++ b/src/effects/magnifier/magnifier_config.cpp @@ -6,41 +6,43 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "magnifier_config.h" + +#include + // KConfigSkeleton #include "magnifierconfig.h" -#include #include #include +#include #include #include -#include -#include #include +#include #include -#include #include +#include K_PLUGIN_CLASS(KWin::MagnifierEffectConfig) namespace KWin { -MagnifierEffectConfigForm::MagnifierEffectConfigForm(QWidget* parent) : QWidget(parent) +MagnifierEffectConfigForm::MagnifierEffectConfigForm(QWidget *parent) + : QWidget(parent) { setupUi(this); } -MagnifierEffectConfig::MagnifierEffectConfig(QWidget* parent, const QVariantList& args) : - KCModule(parent, args) +MagnifierEffectConfig::MagnifierEffectConfig(QWidget *parent, const QVariantList &args) + : KCModule(parent, args) { m_ui = new MagnifierEffectConfigForm(this); - QVBoxLayout* layout = new QVBoxLayout(this); + QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(m_ui); @@ -56,7 +58,7 @@ MagnifierEffectConfig::MagnifierEffectConfig(QWidget* parent, const QVariantList m_actionCollection->setConfigGroup(QStringLiteral("Magnifier")); m_actionCollection->setConfigGlobal(true); - QAction* a; + QAction *a; a = m_actionCollection->addAction(KStandardAction::ZoomIn); a->setProperty("isConfigurationAction", true); KGlobalAccel::self()->setDefaultShortcut(a, QList() << (Qt::META | Qt::Key_Equal)); @@ -83,9 +85,9 @@ MagnifierEffectConfig::~MagnifierEffectConfig() void MagnifierEffectConfig::save() { - qDebug() << "Saving config of Magnifier" ; + qDebug() << "Saving config of Magnifier"; - m_ui->editor->save(); // undo() will restore to this state from now on + m_ui->editor->save(); // undo() will restore to this state from now on KCModule::save(); OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Effects"), diff --git a/src/effects/magnifier/magnifier_config.h b/src/effects/magnifier/magnifier_config.h index 313c0d991c..f6b52e8e68 100644 --- a/src/effects/magnifier/magnifier_config.h +++ b/src/effects/magnifier/magnifier_config.h @@ -23,22 +23,22 @@ class MagnifierEffectConfigForm : public QWidget, public Ui::MagnifierEffectConf { Q_OBJECT public: - explicit MagnifierEffectConfigForm(QWidget* parent); + explicit MagnifierEffectConfigForm(QWidget *parent); }; class MagnifierEffectConfig : public KCModule { Q_OBJECT public: - explicit MagnifierEffectConfig(QWidget* parent = nullptr, const QVariantList& args = QVariantList()); + explicit MagnifierEffectConfig(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); ~MagnifierEffectConfig() override; void save() override; void defaults() override; private: - MagnifierEffectConfigForm* m_ui; - KActionCollection* m_actionCollection; + MagnifierEffectConfigForm *m_ui; + KActionCollection *m_actionCollection; }; } // namespace diff --git a/src/effects/mouseclick/mouseclick.cpp b/src/effects/mouseclick/mouseclick.cpp index cf82c6d72b..891229804b 100644 --- a/src/effects/mouseclick/mouseclick.cpp +++ b/src/effects/mouseclick/mouseclick.cpp @@ -29,7 +29,7 @@ MouseClickEffect::MouseClickEffect() initConfig(); m_enabled = false; - QAction* a = new QAction(this); + QAction *a = new QAction(this); a->setObjectName(QStringLiteral("ToggleMouseClick")); a->setText(i18n("Toggle Mouse Click Effect")); KGlobalAccel::self()->setDefaultShortcut(a, QList() << (Qt::META | Qt::Key_Asterisk)); @@ -70,11 +70,11 @@ void MouseClickEffect::reconfigure(ReconfigureFlags) m_font = MouseClickConfig::font(); } -void MouseClickEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) +void MouseClickEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) { const int time = m_lastPresentTime.count() ? (presentTime - m_lastPresentTime).count() : 0; - for (MouseEvent* click : qAsConst(m_clicks)) { + for (MouseEvent *click : qAsConst(m_clicks)) { click->m_time += time; } @@ -85,7 +85,7 @@ void MouseClickEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::mil } while (m_clicks.size() > 0) { - MouseEvent* first = m_clicks[0]; + MouseEvent *first = m_clicks[0]; if (first->m_time <= m_ringLife) { break; } @@ -102,7 +102,7 @@ void MouseClickEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::mil effects->prePaintScreen(data, presentTime); } -void MouseClickEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) +void MouseClickEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) { effects->paintScreen(mask, region, data); @@ -124,7 +124,7 @@ void MouseClickEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintD click->m_frame->render(infiniteRegion(), frameAlpha, frameAlpha); } } - for (const auto &tool: qAsConst(m_tabletTools)) { + for (const auto &tool : qAsConst(m_tabletTools)) { const int step = m_ringMaxSize * (1. - tool.m_pressure); for (qreal size = m_ringMaxSize; size > 0; size -= step) { drawCircle(tool.m_color, tool.m_globalPosition.x(), tool.m_globalPosition.y(), size); @@ -139,7 +139,7 @@ void MouseClickEffect::postPaintScreen() repaint(); } -float MouseClickEffect::computeRadius(const MouseEvent* click, int ring) +float MouseClickEffect::computeRadius(const MouseEvent *click, int ring) { float ringDistance = m_ringLife / (m_ringCount * 3); if (click->m_press) { @@ -148,23 +148,23 @@ float MouseClickEffect::computeRadius(const MouseEvent* click, int ring) return ((m_ringLife - click->m_time - ringDistance * ring) / m_ringLife) * m_ringMaxSize; } -float MouseClickEffect::computeAlpha(const MouseEvent* click, int ring) +float MouseClickEffect::computeAlpha(const MouseEvent *click, int ring) { float ringDistance = m_ringLife / (m_ringCount * 3); return (m_ringLife - (float)click->m_time - ringDistance * (ring)) / m_ringLife; } -void MouseClickEffect::slotMouseChanged(const QPoint& pos, const QPoint&, +void MouseClickEffect::slotMouseChanged(const QPoint &pos, const QPoint &, Qt::MouseButtons buttons, Qt::MouseButtons oldButtons, Qt::KeyboardModifiers, Qt::KeyboardModifiers) { if (buttons == oldButtons) return; - MouseEvent* m = nullptr; + MouseEvent *m = nullptr; int i = BUTTON_COUNT; while (--i >= 0) { - MouseButton* b = m_buttons[i]; + MouseButton *b = m_buttons[i]; if (isPressed(b->m_button, buttons, oldButtons)) { m = new MouseEvent(i, pos, 0, createEffectFrame(pos, b->m_labelDown), true); break; @@ -182,12 +182,13 @@ void MouseClickEffect::slotMouseChanged(const QPoint& pos, const QPoint&, repaint(); } -EffectFrame* MouseClickEffect::createEffectFrame(const QPoint& pos, const QString& text) { +EffectFrame *MouseClickEffect::createEffectFrame(const QPoint &pos, const QString &text) +{ if (!m_showText) { return nullptr; } QPoint point(pos.x() + m_ringMaxSize, pos.y()); - EffectFrame* frame = effects->effectFrame(EffectFrameStyled, false, point, Qt::AlignLeft); + EffectFrame *frame = effects->effectFrame(EffectFrameStyled, false, point, Qt::AlignLeft); frame->setFont(m_font); frame->setText(text); return frame; @@ -199,10 +200,10 @@ void MouseClickEffect::repaint() QRegion dirtyRegion; const int radius = m_ringMaxSize + m_lineWidth; for (MouseEvent *click : qAsConst(m_clicks)) { - dirtyRegion |= QRect(click->m_pos.x() - radius, click->m_pos.y() - radius, 2*radius, 2*radius); + dirtyRegion |= QRect(click->m_pos.x() - radius, click->m_pos.y() - radius, 2 * radius, 2 * radius); if (click->m_frame) { // we grant the plasma style 32px padding for stuff like shadows... - dirtyRegion |= click->m_frame->geometry().adjusted(-32,-32,32,32); + dirtyRegion |= click->m_frame->geometry().adjusted(-32, -32, 32, 32); } } effects->addRepaint(dirtyRegion); @@ -211,7 +212,7 @@ void MouseClickEffect::repaint() QRegion dirtyRegion; const int radius = m_ringMaxSize + m_lineWidth; for (const auto &event : qAsConst(m_tabletTools)) { - dirtyRegion |= QRect(event.m_globalPosition.x() - radius, event.m_globalPosition.y() - radius, 2*radius, 2*radius); + dirtyRegion |= QRect(event.m_globalPosition.x() - radius, event.m_globalPosition.y() - radius, 2 * radius, 2 * radius); } effects->addRepaint(dirtyRegion); } @@ -254,7 +255,7 @@ bool MouseClickEffect::isActive() const return m_enabled && (!m_clicks.isEmpty() || !m_tabletTools.isEmpty()); } -void MouseClickEffect::drawCircle(const QColor& color, float cx, float cy, float r) +void MouseClickEffect::drawCircle(const QColor &color, float cx, float cy, float r) { if (effects->isOpenGLCompositing()) drawCircleGl(color, cx, cy, r); @@ -262,30 +263,30 @@ void MouseClickEffect::drawCircle(const QColor& color, float cx, float cy, float drawCircleQPainter(color, cx, cy, r); } -void MouseClickEffect::paintScreenSetup(int mask, QRegion region, ScreenPaintData& data) +void MouseClickEffect::paintScreenSetup(int mask, QRegion region, ScreenPaintData &data) { if (effects->isOpenGLCompositing()) paintScreenSetupGl(mask, region, data); } -void MouseClickEffect::paintScreenFinish(int mask, QRegion region, ScreenPaintData& data) +void MouseClickEffect::paintScreenFinish(int mask, QRegion region, ScreenPaintData &data) { if (effects->isOpenGLCompositing()) paintScreenFinishGl(mask, region, data); } -void MouseClickEffect::drawCircleGl(const QColor& color, float cx, float cy, float r) +void MouseClickEffect::drawCircleGl(const QColor &color, float cx, float cy, float r) { static const int num_segments = 80; static const float theta = 2 * 3.1415926 / float(num_segments); - static const float c = cosf(theta); //precalculate the sine and cosine + static const float c = cosf(theta); // precalculate the sine and cosine static const float s = sinf(theta); float t; - float x = r;//we start at angle = 0 + float x = r; // we start at angle = 0 float y = 0; - GLVertexBuffer* vbo = GLVertexBuffer::streamingBuffer(); + GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); vbo->reset(); vbo->setUseColor(true); vbo->setColor(color); @@ -293,8 +294,8 @@ void MouseClickEffect::drawCircleGl(const QColor& color, float cx, float cy, flo verts.reserve(num_segments * 2); for (int ii = 0; ii < num_segments; ++ii) { - verts << x + cx << y + cy;//output vertex - //apply the rotation matrix + verts << x + cx << y + cy; // output vertex + // apply the rotation matrix t = x; x = c * x - s * y; y = s * t + c * y; @@ -322,7 +323,7 @@ void MouseClickEffect::paintScreenSetupGl(int, QRegion, ScreenPaintData &data) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } -void MouseClickEffect::paintScreenFinishGl(int, QRegion, ScreenPaintData&) +void MouseClickEffect::paintScreenFinishGl(int, QRegion, ScreenPaintData &) { glDisable(GL_BLEND); @@ -335,44 +336,44 @@ bool MouseClickEffect::tabletToolEvent(QTabletEvent *event) if (!tabletEvent.m_color.isValid()) { switch (event->pointerType()) { #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - case QTabletEvent::UnknownPointer: - case QTabletEvent::Pen: - tabletEvent.m_color = MouseClickConfig::color1(); - break; - case QTabletEvent::Eraser: - tabletEvent.m_color = MouseClickConfig::color2(); - break; - case QTabletEvent::Cursor: - tabletEvent.m_color = MouseClickConfig::color3(); - break; + case QTabletEvent::UnknownPointer: + case QTabletEvent::Pen: + tabletEvent.m_color = MouseClickConfig::color1(); + break; + case QTabletEvent::Eraser: + tabletEvent.m_color = MouseClickConfig::color2(); + break; + case QTabletEvent::Cursor: + tabletEvent.m_color = MouseClickConfig::color3(); + break; #else - case QPointingDevice::PointerType::Unknown: - case QPointingDevice::PointerType::Generic: - case QPointingDevice::PointerType::Finger: - case QPointingDevice::PointerType::Pen: - tabletEvent.m_color = MouseClickConfig::color1(); - break; - case QPointingDevice::PointerType::Eraser: - tabletEvent.m_color = MouseClickConfig::color2(); - break; - case QPointingDevice::PointerType::Cursor: - tabletEvent.m_color = MouseClickConfig::color3(); - break; + case QPointingDevice::PointerType::Unknown: + case QPointingDevice::PointerType::Generic: + case QPointingDevice::PointerType::Finger: + case QPointingDevice::PointerType::Pen: + tabletEvent.m_color = MouseClickConfig::color1(); + break; + case QPointingDevice::PointerType::Eraser: + tabletEvent.m_color = MouseClickConfig::color2(); + break; + case QPointingDevice::PointerType::Cursor: + tabletEvent.m_color = MouseClickConfig::color3(); + break; #endif } } switch (event->type()) { - case QEvent::TabletPress: - tabletEvent.m_pressed = true; - break; - case QEvent::TabletRelease: - tabletEvent.m_pressed = false; - break; - case QEvent::TabletLeaveProximity: - m_tabletTools.remove(event->uniqueId()); - return false; - default: - break; + case QEvent::TabletPress: + tabletEvent.m_pressed = true; + break; + case QEvent::TabletRelease: + tabletEvent.m_pressed = false; + break; + case QEvent::TabletLeaveProximity: + m_tabletTools.remove(event->uniqueId()); + return false; + default: + break; } tabletEvent.m_globalPosition = event->globalPos(); tabletEvent.m_pressure = event->pressure(); @@ -381,4 +382,3 @@ bool MouseClickEffect::tabletToolEvent(QTabletEvent *event) } } // namespace - diff --git a/src/effects/mouseclick/mouseclick.h b/src/effects/mouseclick/mouseclick.h index 1c03307851..296c8fbde4 100644 --- a/src/effects/mouseclick/mouseclick.h +++ b/src/effects/mouseclick/mouseclick.h @@ -10,11 +10,11 @@ #ifndef KWIN_MOUSECLICK_H #define KWIN_MOUSECLICK_H -#include -#include #include #include #include +#include +#include namespace KWin { @@ -27,16 +27,16 @@ public: int m_button; QPoint m_pos; int m_time; - EffectFrame* m_frame; + 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(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() { @@ -61,13 +61,14 @@ public: 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_labelUp(label) + , m_labelDown(label) + , m_button(button) + , m_isPressed(false) + , m_time(0) { m_labelDown.append(i18n("↓")); m_labelUp.append(i18n("↑")); @@ -101,68 +102,79 @@ public: MouseClickEffect(); ~MouseClickEffect() override; void reconfigure(ReconfigureFlags) override; - void prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) override; - void paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) override; + void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; + void paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) override; void postPaintScreen() override; bool isActive() const override; // for properties - QColor color1() const { + QColor color1() const + { return m_colors[0]; } - QColor color2() const { + QColor color2() const + { return m_colors[1]; } - QColor color3() const { + QColor color3() const + { return m_colors[2]; } - qreal lineWidth() const { + qreal lineWidth() const + { return m_lineWidth; } - int ringLife() const { + int ringLife() const + { return m_ringLife; } - int ringSize() const { + int ringSize() const + { return m_ringMaxSize; } - int ringCount() const { + int ringCount() const + { return m_ringCount; } - bool isShowText() const { + bool isShowText() const + { return m_showText; } - QFont font() const { + QFont font() const + { return m_font; } - bool isEnabled() const { + bool isEnabled() const + { return m_enabled; } - bool tabletToolEvent(QTabletEvent * event) override; + bool tabletToolEvent(QTabletEvent *event) override; private Q_SLOTS: void toggleEnabled(); - void slotMouseChanged(const QPoint& pos, const QPoint& old, + 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); + 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); + 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 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); + void drawCircleGl(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; @@ -173,12 +185,11 @@ private: QFont m_font; std::chrono::milliseconds m_lastPresentTime = std::chrono::milliseconds::zero(); - QList m_clicks; - MouseButton* m_buttons[BUTTON_COUNT]; + QList m_clicks; + MouseButton *m_buttons[BUTTON_COUNT]; QHash m_tabletTools; bool m_enabled; - }; } // namespace diff --git a/src/effects/mouseclick/mouseclick_config.cpp b/src/effects/mouseclick/mouseclick_config.cpp index 51585f5fb0..fb03067a9e 100644 --- a/src/effects/mouseclick/mouseclick_config.cpp +++ b/src/effects/mouseclick/mouseclick_config.cpp @@ -6,11 +6,12 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "mouseclick_config.h" + +#include + // KConfigSkeleton #include "mouseclickconfig.h" -#include #include #include @@ -27,17 +28,18 @@ K_PLUGIN_CLASS(KWin::MouseClickEffectConfig) namespace KWin { -MouseClickEffectConfigForm::MouseClickEffectConfigForm(QWidget* parent) : QWidget(parent) +MouseClickEffectConfigForm::MouseClickEffectConfigForm(QWidget *parent) + : QWidget(parent) { setupUi(this); } -MouseClickEffectConfig::MouseClickEffectConfig(QWidget* parent, const QVariantList& args) : - KCModule(parent, args) +MouseClickEffectConfig::MouseClickEffectConfig(QWidget *parent, const QVariantList &args) + : KCModule(parent, args) { m_ui = new MouseClickEffectConfigForm(this); - QVBoxLayout* layout = new QVBoxLayout(this); + QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(m_ui); connect(m_ui->editor, &KShortcutsEditor::keyChange, this, &MouseClickEffectConfig::markAsChanged); @@ -46,7 +48,7 @@ MouseClickEffectConfig::MouseClickEffectConfig(QWidget* parent, const QVariantLi m_actionCollection = new KActionCollection(this, QStringLiteral("kwin")); m_actionCollection->setComponentDisplayName(i18n("KWin")); - QAction* a = m_actionCollection->addAction(QStringLiteral("ToggleMouseClick")); + QAction *a = m_actionCollection->addAction(QStringLiteral("ToggleMouseClick")); a->setText(i18n("Toggle Mouse Click Effect")); a->setProperty("isConfigurationAction", true); KGlobalAccel::self()->setDefaultShortcut(a, QList() << (Qt::META | Qt::Key_Asterisk)); @@ -67,7 +69,7 @@ MouseClickEffectConfig::~MouseClickEffectConfig() void MouseClickEffectConfig::save() { KCModule::save(); - m_ui->editor->save(); // undo() will restore to this state from now on + m_ui->editor->save(); // undo() will restore to this state from now on OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Effects"), QDBusConnection::sessionBus()); diff --git a/src/effects/mouseclick/mouseclick_config.h b/src/effects/mouseclick/mouseclick_config.h index 1723cb3805..f738331f0b 100644 --- a/src/effects/mouseclick/mouseclick_config.h +++ b/src/effects/mouseclick/mouseclick_config.h @@ -23,21 +23,21 @@ class MouseClickEffectConfigForm : public QWidget, public Ui::MouseClickEffectCo { Q_OBJECT public: - explicit MouseClickEffectConfigForm(QWidget* parent); + explicit MouseClickEffectConfigForm(QWidget *parent); }; class MouseClickEffectConfig : public KCModule { Q_OBJECT public: - explicit MouseClickEffectConfig(QWidget* parent = nullptr, const QVariantList& args = QVariantList()); + explicit MouseClickEffectConfig(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); ~MouseClickEffectConfig() override; void save() override; private: - MouseClickEffectConfigForm* m_ui; - KActionCollection* m_actionCollection; + MouseClickEffectConfigForm *m_ui; + KActionCollection *m_actionCollection; }; } // namespace diff --git a/src/effects/mousemark/mousemark.cpp b/src/effects/mousemark/mousemark.cpp index 1175f44fad..52eecc54b1 100644 --- a/src/effects/mousemark/mousemark.cpp +++ b/src/effects/mousemark/mousemark.cpp @@ -13,11 +13,11 @@ // KConfigSkeleton #include "mousemarkconfig.h" +#include +#include #include #include #include -#include -#include #include @@ -26,12 +26,12 @@ namespace KWin { -#define NULL_POINT (QPoint( -1, -1 )) // null point is (0,0), which is valid :-/ +#define NULL_POINT (QPoint(-1, -1)) // null point is (0,0), which is valid :-/ MouseMarkEffect::MouseMarkEffect() { initConfig(); - QAction* a = new QAction(this); + QAction *a = new QAction(this); a->setObjectName(QStringLiteral("ClearMouseMarks")); a->setText(i18n("Clear All Mouse Marks")); KGlobalAccel::self()->setDefaultShortcut(a, QList() << (Qt::SHIFT | Qt::META | Qt::Key_F11)); @@ -68,12 +68,12 @@ void MouseMarkEffect::reconfigure(ReconfigureFlags) color.setAlphaF(1.0); } -void MouseMarkEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) +void MouseMarkEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) { - effects->paintScreen(mask, region, data); // paint normal screen + effects->paintScreen(mask, region, data); // paint normal screen if (marks.isEmpty() && drawing.isEmpty()) return; - if ( effects->isOpenGLCompositing()) { + if (effects->isOpenGLCompositing()) { if (!GLPlatform::instance()->isGLES()) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -132,15 +132,15 @@ void MouseMarkEffect::drawMark(QPainter *painter, const Mark &mark) return; } for (int i = 0; i < mark.count() - 1; ++i) { - painter->drawLine(mark[i], mark[i+1]); + painter->drawLine(mark[i], mark[i + 1]); } } -void MouseMarkEffect::slotMouseChanged(const QPoint& pos, const QPoint&, - Qt::MouseButtons, Qt::MouseButtons, - Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers) +void MouseMarkEffect::slotMouseChanged(const QPoint &pos, const QPoint &, + Qt::MouseButtons, Qt::MouseButtons, + Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers) { - if (modifiers == (Qt::META | Qt::SHIFT | Qt::CTRL)) { // start/finish arrow + if (modifiers == (Qt::META | Qt::SHIFT | Qt::CTRL)) { // start/finish arrow if (arrow_start != NULL_POINT) { marks.append(createArrow(arrow_start, pos)); arrow_start = NULL_POINT; @@ -152,7 +152,7 @@ void MouseMarkEffect::slotMouseChanged(const QPoint& pos, const QPoint&, if (arrow_start != NULL_POINT) return; // TODO the shortcuts now trigger this right before they're activated - if (modifiers == (Qt::META | Qt::SHIFT)) { // activated + if (modifiers == (Qt::META | Qt::SHIFT)) { // activated if (drawing.isEmpty()) drawing.append(pos); if (drawing.last() == pos) @@ -194,12 +194,12 @@ MouseMarkEffect::Mark MouseMarkEffect::createArrow(QPoint arrow_start, QPoint ar Mark ret; double angle = atan2((double)(arrow_end.y() - arrow_start.y()), (double)(arrow_end.x() - arrow_start.x())); ret += arrow_start + QPoint(50 * cos(angle + M_PI / 6), - 50 * sin(angle + M_PI / 6)); // right one + 50 * sin(angle + M_PI / 6)); // right one ret += arrow_start; ret += arrow_end; ret += arrow_start; // it's connected lines, so go back with the middle one ret += arrow_start + QPoint(50 * cos(angle - M_PI / 6), - 50 * sin(angle - M_PI / 6)); // left one + 50 * sin(angle - M_PI / 6)); // left one return ret; } @@ -221,6 +221,4 @@ bool MouseMarkEffect::isActive() const return (!marks.isEmpty() || !drawing.isEmpty()) && !effects->isScreenLocked(); } - } // namespace - diff --git a/src/effects/mousemark/mousemark.h b/src/effects/mousemark/mousemark.h index 01577a279e..561c1c662a 100644 --- a/src/effects/mousemark/mousemark.h +++ b/src/effects/mousemark/mousemark.h @@ -26,28 +26,31 @@ public: MouseMarkEffect(); ~MouseMarkEffect() override; void reconfigure(ReconfigureFlags) override; - void paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) override; + void paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) override; bool isActive() const override; // for properties - int configuredWidth() const { + int configuredWidth() const + { return width; } - QColor configuredColor() const { + 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 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; + typedef QVector Mark; void drawMark(QPainter *painter, const Mark &mark); static Mark createArrow(QPoint arrow_start, QPoint arrow_end); - QVector< Mark > marks; + QVector marks; Mark drawing; QPoint arrow_start; int width; diff --git a/src/effects/mousemark/mousemark_config.cpp b/src/effects/mousemark/mousemark_config.cpp index 502d287fbc..5feda05f4b 100644 --- a/src/effects/mousemark/mousemark_config.cpp +++ b/src/effects/mousemark/mousemark_config.cpp @@ -6,19 +6,19 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "mousemark_config.h" +#include + // KConfigSkeleton #include "mousemarkconfig.h" -#include #include #include -#include #include #include +#include #include #include @@ -29,17 +29,18 @@ K_PLUGIN_CLASS(KWin::MouseMarkEffectConfig) namespace KWin { -MouseMarkEffectConfigForm::MouseMarkEffectConfigForm(QWidget* parent) : QWidget(parent) +MouseMarkEffectConfigForm::MouseMarkEffectConfigForm(QWidget *parent) + : QWidget(parent) { setupUi(this); } -MouseMarkEffectConfig::MouseMarkEffectConfig(QWidget* parent, const QVariantList& args) : - KCModule(parent, args) +MouseMarkEffectConfig::MouseMarkEffectConfig(QWidget *parent, const QVariantList &args) + : KCModule(parent, args) { m_ui = new MouseMarkEffectConfigForm(this); - QVBoxLayout* layout = new QVBoxLayout(this); + QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(m_ui); @@ -50,7 +51,7 @@ MouseMarkEffectConfig::MouseMarkEffectConfig(QWidget* parent, const QVariantList m_actionCollection = new KActionCollection(this, QStringLiteral("kwin")); m_actionCollection->setComponentDisplayName(i18n("KWin")); - QAction* a = m_actionCollection->addAction(QStringLiteral("ClearMouseMarks")); + QAction *a = m_actionCollection->addAction(QStringLiteral("ClearMouseMarks")); a->setText(i18n("Clear Mouse Marks")); a->setProperty("isConfigurationAction", true); KGlobalAccel::self()->setDefaultShortcut(a, QList() << (Qt::SHIFT | Qt::META | Qt::Key_F11)); @@ -84,11 +85,11 @@ void MouseMarkEffectConfig::load() void MouseMarkEffectConfig::save() { - qDebug() << "Saving config of MouseMark" ; + qDebug() << "Saving config of MouseMark"; KCModule::save(); m_actionCollection->writeSettings(); - m_ui->editor->save(); // undo() will restore to this state from now on + m_ui->editor->save(); // undo() will restore to this state from now on OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), QStringLiteral("/Effects"), diff --git a/src/effects/mousemark/mousemark_config.h b/src/effects/mousemark/mousemark_config.h index 4c03de800b..51de1800cf 100644 --- a/src/effects/mousemark/mousemark_config.h +++ b/src/effects/mousemark/mousemark_config.h @@ -23,14 +23,14 @@ class MouseMarkEffectConfigForm : public QWidget, public Ui::MouseMarkEffectConf { Q_OBJECT public: - explicit MouseMarkEffectConfigForm(QWidget* parent); + explicit MouseMarkEffectConfigForm(QWidget *parent); }; class MouseMarkEffectConfig : public KCModule { Q_OBJECT public: - explicit MouseMarkEffectConfig(QWidget* parent = nullptr, const QVariantList& args = QVariantList()); + explicit MouseMarkEffectConfig(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); ~MouseMarkEffectConfig() override; void load() override; @@ -39,8 +39,8 @@ public: private: void updateSpinBoxSuffix(); - MouseMarkEffectConfigForm* m_ui; - KActionCollection* m_actionCollection; + MouseMarkEffectConfigForm *m_ui; + KActionCollection *m_actionCollection; }; } // namespace diff --git a/src/effects/overview/expolayout.cpp b/src/effects/overview/expolayout.cpp index 2e9dfcff8e..713424f16f 100644 --- a/src/effects/overview/expolayout.cpp +++ b/src/effects/overview/expolayout.cpp @@ -330,7 +330,7 @@ static int distance(const QPoint &a, const QPoint &b) static QRect centered(ExpoCell *cell, const QRect &bounds) { const QSize scaled = QSize(cell->naturalWidth(), cell->naturalHeight()) - .scaled(bounds.size(), Qt::KeepAspectRatio); + .scaled(bounds.size(), Qt::KeepAspectRatio); return QRect(bounds.center().x() - scaled.width() / 2, bounds.center().y() - scaled.height() / 2, @@ -367,7 +367,7 @@ void ExpoLayout::calculateWindowTransformationsClosest() int slotCandidate = -1, slotCandidateDistance = INT_MAX; const QPoint pos = cell->naturalRect().center(); - for (int i = 0; i < columns*rows; ++i) { // all slots + for (int i = 0; i < columns * rows; ++i) { // all slots const int dist = distance(pos, slotCenters[i]); if (dist < slotCandidateDistance) { // window is interested in this slot ExpoCell *occupier = takenSlots[i]; @@ -397,7 +397,7 @@ void ExpoLayout::calculateWindowTransformationsClosest() QRect target(area.x() + (slot % columns) * slotWidth, area.y() + (slot / columns) * slotHeight, slotWidth, slotHeight); - target.adjust(m_spacing, m_spacing, -m_spacing, -m_spacing); // Borders + target.adjust(m_spacing, m_spacing, -m_spacing, -m_spacing); // Borders target = target.marginsRemoved(cell->margins()); qreal scale; @@ -416,9 +416,9 @@ void ExpoLayout::calculateWindowTransformationsClosest() if (scale > 2.0 || (scale > 1.0 && (cell->naturalWidth() > 300 || cell->naturalHeight() > 300))) { scale = (cell->naturalWidth() > 300 || cell->naturalHeight() > 300) ? 1.0 : 2.0; target = QRect( - target.center().x() - int(cell->naturalWidth() * scale) / 2, - target.center().y() - int(cell->naturalHeight() * scale) / 2, - scale * cell->naturalWidth(), scale * cell->naturalHeight()); + target.center().x() - int(cell->naturalWidth() * scale) / 2, + target.center().y() - int(cell->naturalHeight() * scale) / 2, + scale * cell->naturalWidth(), scale * cell->naturalHeight()); } cell->setX(target.x()); @@ -510,9 +510,9 @@ void ExpoLayout::calculateWindowTransformationsNatural() diff.setX(1); } // Try to keep screen aspect ratio - //if (bounds.height() / bounds.width() > area.height() / area.width()) + // if (bounds.height() / bounds.width() > area.height() / area.width()) // diff.setY(diff.y() / 2); - //else + // else // diff.setX(diff.x() / 2); // Approximate a vector of between 10px and 20px in magnitude in the same direction diff *= m_accuracy / qreal(diff.manhattanLength()); @@ -606,7 +606,7 @@ void ExpoLayout::calculateWindowTransformationsNatural() // This may cause some slight distortion if the windows are enlarged a large amount int widthDiff = m_accuracy; int heightDiff = heightForWidth(cell, target->width() + widthDiff) - target->height(); - int xDiff = widthDiff / 2; // Also move a bit in the direction of the enlarge, allows the + int xDiff = widthDiff / 2; // Also move a bit in the direction of the enlarge, allows the int yDiff = heightDiff / 2; // center windows to be enlarged if there is gaps on the side. // heightDiff (and yDiff) will be re-computed after each successful enlargement attempt diff --git a/src/effects/overview/kcm/overvieweffectkcm.cpp b/src/effects/overview/kcm/overvieweffectkcm.cpp index ac514fc2b9..6bbcd30ec9 100644 --- a/src/effects/overview/kcm/overvieweffectkcm.cpp +++ b/src/effects/overview/kcm/overvieweffectkcm.cpp @@ -3,11 +3,12 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "overvieweffectkcm.h" -#include "overviewconfig.h" #include + +#include "overviewconfig.h" + #include #include diff --git a/src/effects/overview/overvieweffect.cpp b/src/effects/overview/overvieweffect.cpp index bb270b8272..21c4649493 100644 --- a/src/effects/overview/overvieweffect.cpp +++ b/src/effects/overview/overvieweffect.cpp @@ -55,9 +55,9 @@ OverviewEffect::~OverviewEffect() QVariantMap OverviewEffect::initialProperties(EffectScreen *screen) { - return QVariantMap { - { QStringLiteral("effect"), QVariant::fromValue(this) }, - { QStringLiteral("targetScreen"), QVariant::fromValue(screen) }, + return QVariantMap{ + {QStringLiteral("effect"), QVariant::fromValue(this)}, + {QStringLiteral("targetScreen"), QVariant::fromValue(screen)}, }; } @@ -88,7 +88,7 @@ void OverviewEffect::reconfigure(ReconfigureFlags) const QList touchActivateBorders = OverviewConfig::touchBorderActivate(); for (const int &border : touchActivateBorders) { m_touchBorderActivate.append(ElectricBorder(border)); - effects->registerRealtimeTouchBorder(ElectricBorder(border), m_toggleAction, [this] (ElectricBorder border, const QSizeF &deltaProgress, const EffectScreen *screen) { + effects->registerRealtimeTouchBorder(ElectricBorder(border), m_toggleAction, [this](ElectricBorder border, const QSizeF &deltaProgress, const EffectScreen *screen) { Q_UNUSED(screen) if (m_status == Status::Active) { return; @@ -101,7 +101,7 @@ void OverviewEffect::reconfigure(ReconfigureFlags) m_partialActivationFactor = std::min(1.0, qAbs(deltaProgress.width()) / maxDelta); } Q_EMIT partialActivationFactorChanged(); - if ( !wasInProgress) { + if (!wasInProgress) { Q_EMIT gestureInProgressChanged(); } if (!isRunning()) { diff --git a/src/effects/presentwindows/presentwindows.cpp b/src/effects/presentwindows/presentwindows.cpp index 9f7e5fce19..b2e2559c15 100644 --- a/src/effects/presentwindows/presentwindows.cpp +++ b/src/effects/presentwindows/presentwindows.cpp @@ -9,12 +9,12 @@ */ #include "presentwindows.h" -//KConfigSkeleton +// KConfigSkeleton #include "presentwindowsconfig.h" -#include -#include #include #include +#include +#include #include @@ -22,11 +22,11 @@ #include #include +#include #include #include #include #include -#include #include #include #include @@ -66,7 +66,7 @@ PresentWindowsEffect::PresentWindowsEffect() announceSupportProperties(); connect(effects, &EffectsHandler::xcbConnectionChanged, this, announceSupportProperties); - QAction* exposeAction = m_exposeAction; + QAction *exposeAction = m_exposeAction; exposeAction->setObjectName(QStringLiteral("Expose")); exposeAction->setText(i18n("Toggle Present Windows (Current desktop)")); KGlobalAccel::self()->setDefaultShortcut(exposeAction, QList() << (Qt::CTRL | Qt::Key_F9)); @@ -75,7 +75,7 @@ PresentWindowsEffect::PresentWindowsEffect() effects->registerGlobalShortcut(Qt::CTRL | Qt::Key_F9, exposeAction); connect(exposeAction, &QAction::triggered, this, &PresentWindowsEffect::toggleActive); - QAction* exposeAllAction = m_exposeAllAction; + QAction *exposeAllAction = m_exposeAllAction; exposeAllAction->setObjectName(QStringLiteral("ExposeAll")); exposeAllAction->setText(i18n("Toggle Present Windows (All desktops)")); KGlobalAccel::self()->setDefaultShortcut(exposeAllAction, QList() << (Qt::CTRL | Qt::Key_F10) << Qt::Key_LaunchC); @@ -85,7 +85,7 @@ PresentWindowsEffect::PresentWindowsEffect() effects->registerTouchpadSwipeShortcut(SwipeDirection::Down, 4, exposeAllAction); connect(exposeAllAction, &QAction::triggered, this, &PresentWindowsEffect::toggleActiveAllDesktops); - QAction* exposeClassAction = m_exposeClassAction; + QAction *exposeClassAction = m_exposeClassAction; exposeClassAction->setObjectName(QStringLiteral("ExposeClass")); exposeClassAction->setText(i18n("Toggle Present Windows (Window class)")); KGlobalAccel::self()->setDefaultShortcut(exposeClassAction, QList() << (Qt::CTRL | Qt::Key_F7)); @@ -178,7 +178,7 @@ void PresentWindowsEffect::reconfigure(ReconfigureFlags) effects->unregisterTouchBorder(e, m_exposeAllAction); effects->unregisterTouchBorder(e, m_exposeClassAction); } - auto touchEdge = [&relevantBorders] (const QList touchBorders, QAction *action) { + auto touchEdge = [&relevantBorders](const QList touchBorders, QAction *action) { for (int i : touchBorders) { if (!relevantBorders.contains(ElectricBorder(i))) { continue; @@ -191,7 +191,7 @@ void PresentWindowsEffect::reconfigure(ReconfigureFlags) touchEdge(PresentWindowsConfig::touchBorderActivateClass(), m_exposeClassAction); } -void* PresentWindowsEffect::proxy() +void *PresentWindowsEffect::proxy() { return &m_proxy; } @@ -293,8 +293,7 @@ void PresentWindowsEffect::postPaintScreen() i.key()->addRepaintFull(); resetLastPresentTime = false; } - } - else if (i.value().highlight > 0.0 && i.value().highlight < 1.0) { + } else if (i.value().highlight > 0.0 && i.value().highlight < 1.0) { i.key()->addRepaintFull(); resetLastPresentTime = false; } @@ -320,7 +319,7 @@ void PresentWindowsEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &d effects->prePaintWindow(w, data, presentTime); return; } - w->enablePainting(EffectWindow::PAINT_DISABLED_BY_MINIMIZE); // Display always + w->enablePainting(EffectWindow::PAINT_DISABLED_BY_MINIMIZE); // Display always w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP); // The animation code assumes that the time diff cannot be 0, let's work around it. @@ -339,7 +338,7 @@ void PresentWindowsEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &d winData->opacity = qMax(0.0, winData->opacity - time / m_fadeDuration); else winData->opacity = qMin(/*(w->isMinimized() || !w->isOnCurrentDesktop()) ? 0.75 :*/ 1.0, - winData->opacity + time / m_fadeDuration); + winData->opacity + time / m_fadeDuration); } else winData->opacity = qMax(0.0, winData->opacity - time / m_fadeDuration); @@ -386,7 +385,7 @@ void PresentWindowsEffect::paintWindow(EffectWindow *w, int mask, QRegion region if (m_activated || m_motionManager.areWindowsMoving()) { DataHash::const_iterator winData = m_windowData.constFind(w); if (winData == m_windowData.constEnd() || (w->isDock() && m_showPanel)) { - // we are darkening the panel to communicate that it's not interactive + // we are darkening the panel to communicate that it's not interactive data.multiplyBrightness(interpolate(0.40, 1.0, winData->highlight)); effects->paintWindow(w, mask, region, data); return; @@ -408,21 +407,21 @@ void PresentWindowsEffect::paintWindow(EffectWindow *w, int mask, QRegion region // scale the window (interpolated by the highlight level) to at least 105% or to cover 1/16 of the screen size - yet keep it in screen bounds QRect area = effects->clientArea(FullScreenArea, w); - QSizeF effSize(w->width()*data.xScale(), w->height()*data.yScale()); - const float xr = area.width()/effSize.width(); - const float yr = area.height()/effSize.height(); + QSizeF effSize(w->width() * data.xScale(), w->height() * data.yScale()); + const float xr = area.width() / effSize.width(); + const float yr = area.height() / effSize.height(); float tScale = 0.0; if (xr < yr) { - tScale = qMax(xr/4.0, yr/32.0); + tScale = qMax(xr / 4.0, yr / 32.0); } else { - tScale = qMax(xr/32.0, yr/4.0); + tScale = qMax(xr / 32.0, yr / 4.0); } if (tScale < 1.05) { tScale = 1.05; } - if (effSize.width()*tScale > area.width()) + if (effSize.width() * tScale > area.width()) tScale = area.width() / effSize.width(); - if (effSize.height()*tScale > area.height()) + if (effSize.height() * tScale > area.height()) tScale = area.height() / effSize.height(); const qreal scale = interpolate(1.0, tScale, winData->highlight); @@ -430,18 +429,18 @@ void PresentWindowsEffect::paintWindow(EffectWindow *w, int mask, QRegion region if (scale < tScale) // don't use lanczos during transition mask &= ~PAINT_WINDOW_LANCZOS; - const float df = (tScale-1.0f)*0.5f; - int tx = qRound(rect.width()*df); - int ty = qRound(rect.height()*df); + const float df = (tScale - 1.0f) * 0.5f; + int tx = qRound(rect.width() * df); + int ty = qRound(rect.height() * df); QRect tRect(rect.adjusted(-tx, -ty, tx, ty)); - tx = qMax(tRect.x(), area.x()) + qMin(0, area.right()-tRect.right()); - ty = qMax(tRect.y(), area.y()) + qMin(0, area.bottom()-tRect.bottom()); - tx = qRound((tx-rect.x())*winData->highlight); - ty = qRound((ty-rect.y())*winData->highlight); + tx = qMax(tRect.x(), area.x()) + qMin(0, area.right() - tRect.right()); + ty = qMax(tRect.y(), area.y()) + qMin(0, area.bottom() - tRect.bottom()); + tx = qRound((tx - rect.x()) * winData->highlight); + ty = qRound((ty - rect.y()) * winData->highlight); - rect.translate(tx,ty); - rect.setWidth(rect.width()*scale); - rect.setHeight(rect.height()*scale); + rect.translate(tx, ty); + rect.setWidth(rect.width() * scale); + rect.setHeight(rect.height() * scale); data *= QVector2D(scale, scale); data += QPoint(tx, ty); @@ -536,9 +535,9 @@ void PresentWindowsEffect::slotWindowClosed(EffectWindow *w) for (EffectWindow *w : managedWindows) { winData = m_windowData.find(w); if (winData != m_windowData.end() && !winData->deleted) - return; // found one that is not deleted? then we go on + return; // found one that is not deleted? then we go on } - setActive(false); //else no need to keep this open + setActive(false); // else no need to keep this open } void PresentWindowsEffect::slotWindowDeleted(EffectWindow *w) @@ -553,7 +552,7 @@ void PresentWindowsEffect::slotWindowDeleted(EffectWindow *w) m_motionManager.unmanage(w); } -void PresentWindowsEffect::slotWindowFrameGeometryChanged(EffectWindow* w, const QRect& old) +void PresentWindowsEffect::slotWindowFrameGeometryChanged(EffectWindow *w, const QRect &old) { Q_UNUSED(old) @@ -592,7 +591,7 @@ bool PresentWindowsEffect::borderActivated(ElectricBorder border) void PresentWindowsEffect::windowInputMouseEvent(QEvent *e) { - QMouseEvent* me = dynamic_cast< QMouseEvent* >(e); + QMouseEvent *me = dynamic_cast(e); if (!me) { return; } @@ -624,8 +623,7 @@ void PresentWindowsEffect::inputEventUpdate(const QPoint &pos, QEvent::Type type continue; } - if (m_motionManager.transformedGeometry(windows.at(i)).contains(pos) && - winData->visible && !winData->deleted) { + if (m_motionManager.transformedGeometry(windows.at(i)).contains(pos) && winData->visible && !winData->deleted) { hovering = true; if (windows.at(i) && m_highlightedWindow != windows.at(i)) { highlightCandidate = windows.at(i); @@ -731,9 +729,9 @@ bool PresentWindowsEffect::touchUp(qint32 id, quint32 time) return true; } -void PresentWindowsEffect::mouseActionWindow(WindowMouseAction& action) +void PresentWindowsEffect::mouseActionWindow(WindowMouseAction &action) { - switch(action) { + switch (action) { case WindowActivateAction: if (m_highlightedWindow) effects->activateWindow(m_highlightedWindow); @@ -772,9 +770,9 @@ void PresentWindowsEffect::mouseActionWindow(WindowMouseAction& action) } } -void PresentWindowsEffect::mouseActionDesktop(DesktopMouseAction& action) +void PresentWindowsEffect::mouseActionDesktop(DesktopMouseAction &action) { - switch(action) { + switch (action) { case DesktopActivateAction: if (m_highlightedWindow) effects->activateWindow(m_highlightedWindow); @@ -809,7 +807,7 @@ void PresentWindowsEffect::grabbedKeyboardEvent(QKeyEvent *e) return; } - switch(e->key()) { + switch (e->key()) { // Wrap only if not auto-repeating case Qt::Key_Left: setHighlightedWindow(relativeWindow(m_highlightedWindow, -1, 0, !e->isAutoRepeat())); @@ -877,7 +875,7 @@ void PresentWindowsEffect::grabbedKeyboardEvent(QKeyEvent *e) //----------------------------------------------------------------------------- // Atom handling -void PresentWindowsEffect::slotPropertyNotify(EffectWindow* w, long a) +void PresentWindowsEffect::slotPropertyNotify(EffectWindow *w, long a) { if (m_atomDesktop == XCB_ATOM_NONE && m_atomWindows == XCB_ATOM_NONE) { return; @@ -892,7 +890,7 @@ void PresentWindowsEffect::slotPropertyNotify(EffectWindow* w, long a) setActive(false); return; } - auto* data = reinterpret_cast(byteData.data()); + auto *data = reinterpret_cast(byteData.data()); if (!data[0]) { // Purposely ending present windows by issuing a NULL target @@ -921,7 +919,7 @@ void PresentWindowsEffect::slotPropertyNotify(EffectWindow* w, long a) setActive(false); return; } - auto* data = reinterpret_cast(byteData.data()); + auto *data = reinterpret_cast(byteData.data()); if (!data[0]) { // Purposely ending present windows by issuing a NULL target @@ -936,7 +934,7 @@ void PresentWindowsEffect::slotPropertyNotify(EffectWindow* w, long a) m_selectedWindows.clear(); int length = byteData.length() / sizeof(data[0]); for (int i = 0; i < length; i++) { - EffectWindow* foundWin = effects->findWindow(data[i]); + EffectWindow *foundWin = effects->findWindow(data[i]); if (!foundWin) { qCDebug(KWIN_PRESENTWINDOWS) << "Invalid window targetted for present windows. Requested:" << data[i]; continue; @@ -959,11 +957,10 @@ void PresentWindowsEffect::presentWindows(const QStringList &windows) m_selectedWindows.append(effectWindow); } } - m_mode = ModeWindowGroup; - setActive(true); + m_mode = ModeWindowGroup; + setActive(true); } - //----------------------------------------------------------------------------- // Window rearranging @@ -982,7 +979,7 @@ void PresentWindowsEffect::rearrangeWindows() if (m_windowFilter.isEmpty()) { windowlist = m_motionManager.managedWindows(); - for (EffectWindow * w : qAsConst(windowlist)) { + for (EffectWindow *w : qAsConst(windowlist)) { DataHash::iterator winData = m_windowData.find(w); if (winData == m_windowData.end() || winData->deleted) continue; // don't include closed windows @@ -997,9 +994,7 @@ void PresentWindowsEffect::rearrangeWindows() if (winData == m_windowData.end() || winData->deleted) continue; // don't include closed windows - if (w->caption().contains(m_windowFilter, Qt::CaseInsensitive) || - w->windowClass().contains(m_windowFilter, Qt::CaseInsensitive) || - w->windowRole().contains(m_windowFilter, Qt::CaseInsensitive)) { + if (w->caption().contains(m_windowFilter, Qt::CaseInsensitive) || w->windowClass().contains(m_windowFilter, Qt::CaseInsensitive) || w->windowRole().contains(m_windowFilter, Qt::CaseInsensitive)) { windowlist.append(w); windowlists[w->screen()].append(w); winData->visible = true; @@ -1027,12 +1022,7 @@ void PresentWindowsEffect::rearrangeWindows() // Don't rearrange if the grid is the same size as what it was before to prevent // windows moving to a better spot if one was filtered out. - if (m_layoutMode == LayoutRegularGrid && - m_gridSizes[screen].columns && - m_gridSizes[screen].rows && - windows.size() < m_gridSizes[screen].columns * m_gridSizes[screen].rows && - windows.size() > (m_gridSizes[screen].columns - 1) * m_gridSizes[screen].rows && - windows.size() > m_gridSizes[screen].columns *(m_gridSizes[screen].rows - 1)) + if (m_layoutMode == LayoutRegularGrid && m_gridSizes[screen].columns && m_gridSizes[screen].rows && windows.size() < m_gridSizes[screen].columns * m_gridSizes[screen].rows && windows.size() > (m_gridSizes[screen].columns - 1) * m_gridSizes[screen].rows && windows.size() > m_gridSizes[screen].columns * (m_gridSizes[screen].rows - 1)) continue; // No point continuing if there is no windows to process @@ -1043,7 +1033,7 @@ void PresentWindowsEffect::rearrangeWindows() } // Resize text frames if required - QFontMetrics* metrics = nullptr; // All fonts are the same + QFontMetrics *metrics = nullptr; // All fonts are the same const auto managedWindows = m_motionManager.managedWindows(); for (EffectWindow *w : managedWindows) { DataHash::iterator winData = m_windowData.find(w); @@ -1062,7 +1052,7 @@ void PresentWindowsEffect::rearrangeWindows() } void PresentWindowsEffect::calculateWindowTransformations(EffectWindowList windowlist, EffectScreen *screen, - WindowMotionManager& motionManager, bool external) + WindowMotionManager &motionManager, bool external) { if (m_layoutMode == LayoutRegularGrid) calculateWindowTransformationsClosest(windowlist, screen, motionManager); @@ -1080,18 +1070,18 @@ static inline int distance(QPoint &pos1, QPoint &pos2) { const int xdiff = pos1.x() - pos2.x(); const int ydiff = pos1.y() - pos2.y(); - return int(sqrt(float(xdiff*xdiff + ydiff*ydiff))); + return int(sqrt(float(xdiff * xdiff + ydiff * ydiff))); } void PresentWindowsEffect::calculateWindowTransformationsClosest(EffectWindowList windowlist, EffectScreen *screen, - WindowMotionManager& motionManager) + WindowMotionManager &motionManager) { // This layout mode requires at least one window visible if (windowlist.count() == 0) return; QRect area = effects->clientArea(ScreenArea, screen, effects->currentDesktop()); - if (m_showPanel) // reserve space for the panel + if (m_showPanel) // reserve space for the panel area = effects->clientArea(MaximizeArea, screen, effects->currentDesktop()); int columns = int(ceil(sqrt(double(windowlist.count())))); int rows = int(ceil(windowlist.count() / double(columns))); @@ -1106,17 +1096,17 @@ void PresentWindowsEffect::calculateWindowTransformationsClosest(EffectWindowLis // Assign slots int slotWidth = area.width() / columns; int slotHeight = area.height() / rows; - QVector takenSlots; - takenSlots.resize(rows*columns); + QVector takenSlots; + takenSlots.resize(rows * columns); takenSlots.fill(0); // precalculate all slot centers QVector slotCenters; - slotCenters.resize(rows*columns); + slotCenters.resize(rows * columns); for (int x = 0; x < columns; ++x) for (int y = 0; y < rows; ++y) { - slotCenters[x + y*columns] = QPoint(area.x() + slotWidth * x + slotWidth / 2, - area.y() + slotHeight * y + slotHeight / 2); + slotCenters[x + y * columns] = QPoint(area.x() + slotWidth * x + slotWidth / 2, + area.y() + slotHeight * y + slotHeight / 2); } // Assign each window to the closest available slot @@ -1127,7 +1117,7 @@ void PresentWindowsEffect::calculateWindowTransformationsClosest(EffectWindowLis int slotCandidate = -1, slotCandidateDistance = INT_MAX; QPoint pos = w->frameGeometry().center(); - for (int i = 0; i < columns*rows; ++i) { // all slots + for (int i = 0; i < columns * rows; ++i) { // all slots const int dist = distance(pos, slotCenters[i]); if (dist < slotCandidateDistance) { // window is interested in this slot EffectWindow *occupier = takenSlots[i]; @@ -1146,7 +1136,7 @@ void PresentWindowsEffect::calculateWindowTransformationsClosest(EffectWindowLis takenSlots[slotCandidate] = w; // ...and we rumble in =) } - for (int slot = 0; slot < columns*rows; ++slot) { + for (int slot = 0; slot < columns * rows; ++slot) { EffectWindow *w = takenSlots[slot]; if (!w) // some slots might be empty continue; @@ -1156,7 +1146,7 @@ void PresentWindowsEffect::calculateWindowTransformationsClosest(EffectWindowLis area.x() + (slot % columns) * slotWidth, area.y() + (slot / columns) * slotHeight, slotWidth, slotHeight); - target.adjust(10, 10, -10, -10); // Borders + target.adjust(10, 10, -10, -10); // Borders double scale; if (target.width() / double(w->width()) < target.height() / double(w->height())) { @@ -1174,25 +1164,25 @@ void PresentWindowsEffect::calculateWindowTransformationsClosest(EffectWindowLis if (scale > 2.0 || (scale > 1.0 && (w->width() > 300 || w->height() > 300))) { scale = (w->width() > 300 || w->height() > 300) ? 1.0 : 2.0; target = QRect( - target.center().x() - int(w->width() * scale) / 2, - target.center().y() - int(w->height() * scale) / 2, - scale * w->width(), scale * w->height()); + target.center().x() - int(w->width() * scale) / 2, + target.center().y() - int(w->height() * scale) / 2, + scale * w->width(), scale * w->height()); } motionManager.moveWindow(w, target); } } void PresentWindowsEffect::calculateWindowTransformationsKompose(EffectWindowList windowlist, EffectScreen *screen, - WindowMotionManager& motionManager) + WindowMotionManager &motionManager) { // This layout mode requires at least one window visible if (windowlist.count() == 0) return; QRect availRect = effects->clientArea(ScreenArea, screen, effects->currentDesktop()); - if (m_showPanel) // reserve space for the panel + if (m_showPanel) // reserve space for the panel availRect = effects->clientArea(MaximizeArea, screen, effects->currentDesktop()); - std::sort(windowlist.begin(), windowlist.end()); // The location of the windows should not depend on the stacking order + std::sort(windowlist.begin(), windowlist.end()); // The location of the windows should not depend on the stacking order // Following code is taken from Kompose 0.5.4, src/komposelayout.cpp int spacing = 10; @@ -1206,7 +1196,7 @@ void PresentWindowsEffect::calculateWindowTransformationsKompose(EffectWindowLis rows = (int)ceil(sqrt((double)windowlist.count())); columns = (int)ceil((double)windowlist.count() / (double)rows); } - //qCDebug(KWIN_PRESENTWINDOWS) << "Using " << rows << " rows & " << columns << " columns for " << windowlist.count() << " clients"; + // qCDebug(KWIN_PRESENTWINDOWS) << "Using " << rows << " rows & " << columns << " columns for " << windowlist.count() << " clients"; // Calculate width & height int w = (availRect.width() - (columns + 1) * spacing) / columns; @@ -1221,7 +1211,7 @@ void PresentWindowsEffect::calculateWindowTransformationsKompose(EffectWindowLis int maxHeightInRow = 0; // Process columns for (int j = 0; j < columns; ++j) { - EffectWindow* window; + EffectWindow *window; // Check for end of List if (it == windowlist.end()) @@ -1255,12 +1245,10 @@ void PresentWindowsEffect::calculateWindowTransformationsKompose(EffectWindowLis } else { double widthByHeight = widthForHeight(window, usableH); double heightByWidth = heightForWidth(window, usableW); - if ((ratio >= 1.0 && heightByWidth <= usableH) || - (ratio < 1.0 && widthByHeight > usableW)) { + if ((ratio >= 1.0 && heightByWidth <= usableH) || (ratio < 1.0 && widthByHeight > usableW)) { widgetw = usableW; widgeth = (int)heightByWidth; - } else if ((ratio < 1.0 && widthByHeight <= usableW) || - (ratio >= 1.0 && heightByWidth > usableH)) { + } else if ((ratio < 1.0 && widthByHeight <= usableW) || (ratio >= 1.0 && heightByWidth > usableH)) { widgeth = usableH; widgetw = (int)widthByHeight; } @@ -1279,8 +1267,8 @@ void PresentWindowsEffect::calculateWindowTransformationsKompose(EffectWindowLis alignmentYoffset = h - widgeth; if (j == 0 && w > widgetw) alignmentXoffset = w - widgetw; - QRect geom(availRect.x() + j *(w + spacing) + spacing + alignmentXoffset + xOffsetFromLastCol, - availRect.y() + i *(h + spacing) + spacing + alignmentYoffset, + QRect geom(availRect.x() + j * (w + spacing) + spacing + alignmentXoffset + xOffsetFromLastCol, + availRect.y() + i * (h + spacing) + spacing + alignmentYoffset, widgetw, widgeth); geometryRects.append(geom); @@ -1300,18 +1288,18 @@ void PresentWindowsEffect::calculateWindowTransformationsKompose(EffectWindowLis if (pos >= windowlist.count()) break; - EffectWindow* window = windowlist[pos]; + EffectWindow *window = windowlist[pos]; QRect target = geometryRects[pos]; target.setY(target.y() + topOffset); // @Marrtin: any idea what this is good for? -// DataHash::iterator winData = m_windowData.find(window); -// if (winData != m_windowData.end()) -// winData->slot = pos; + // DataHash::iterator winData = m_windowData.find(window); + // if (winData != m_windowData.end()) + // winData->slot = pos; motionManager.moveWindow(window, target); - //qCDebug(KWIN_PRESENTWINDOWS) << "Window '" << window->caption() << "' gets moved to (" << - // mWindowData[window].area.left() << "; " << mWindowData[window].area.right() << - // "), scale: " << mWindowData[window].scale << endl; + // qCDebug(KWIN_PRESENTWINDOWS) << "Window '" << window->caption() << "' gets moved to (" << + // mWindowData[window].area.left() << "; " << mWindowData[window].area.right() << + // "), scale: " << mWindowData[window].scale << endl; } if (maxRowHeights[i] - h > 0) topOffset += maxRowHeights[i] - h; @@ -1319,7 +1307,7 @@ void PresentWindowsEffect::calculateWindowTransformationsKompose(EffectWindowLis } void PresentWindowsEffect::calculateWindowTransformationsNatural(EffectWindowList windowlist, EffectScreen *screen, - WindowMotionManager& motionManager) + WindowMotionManager &motionManager) { // If windows do not overlap they scale into nothingness, fix by resetting. To reproduce // just have a single window on a Xinerama screen or have two windows that do not touch. @@ -1343,12 +1331,12 @@ void PresentWindowsEffect::calculateWindowTransformationsNatural(EffectWindowLis std::sort(windowlist.begin(), windowlist.end()); QRect area = effects->clientArea(ScreenArea, screen, effects->currentDesktop()); - if (m_showPanel) // reserve space for the panel + if (m_showPanel) // reserve space for the panel area = effects->clientArea(MaximizeArea, screen, effects->currentDesktop()); QRect bounds = area; int direction = 0; - QHash targets; - QHash directions; + QHash targets; + QHash directions; for (EffectWindow *w : qAsConst(windowlist)) { bounds = bounds.united(w->frameGeometry()); targets[w] = w->frameGeometry(); @@ -1381,9 +1369,9 @@ void PresentWindowsEffect::calculateWindowTransformationsNatural(EffectWindowLis if (diff.x() == 0 && diff.y() == 0) diff.setX(1); // Try to keep screen aspect ratio - //if (bounds.height() / bounds.width() > area.height() / area.width()) + // if (bounds.height() / bounds.width() > area.height() / area.width()) // diff.setY(diff.y() / 2); - //else + // else // diff.setX(diff.x() / 2); // Approximate a vector of between 10px and 20px in magnitude in the same direction diff *= m_accuracy / double(diff.manhattanLength()); @@ -1442,20 +1430,18 @@ void PresentWindowsEffect::calculateWindowTransformationsNatural(EffectWindowLis scale = (area.height() - 20) / double(bounds.height()); // Make bounding rect fill the screen size for later steps bounds = QRect( - (bounds.x() * scale - (area.width() - 20 - bounds.width() * scale) / 2 - 10) / scale, - (bounds.y() * scale - (area.height() - 20 - bounds.height() * scale) / 2 - 10) / scale, - area.width() / scale, - area.height() / scale - ); + (bounds.x() * scale - (area.width() - 20 - bounds.width() * scale) / 2 - 10) / scale, + (bounds.y() * scale - (area.height() - 20 - bounds.height() * scale) / 2 - 10) / scale, + area.width() / scale, + area.height() / scale); // Move all windows back onto the screen and set their scale - QHash::iterator target = targets.begin(); + QHash::iterator target = targets.begin(); while (target != targets.end()) { target->setRect((target->x() - bounds.x()) * scale + area.x(), (target->y() - bounds.y()) * scale + area.y(), target->width() * scale, - target->height() * scale - ); + target->height() * scale); ++target; } @@ -1474,7 +1460,7 @@ void PresentWindowsEffect::calculateWindowTransformationsNatural(EffectWindowLis // This may cause some slight distortion if the windows are enlarged a large amount int widthDiff = m_accuracy; int heightDiff = heightForWidth(w, target->width() + widthDiff) - target->height(); - int xDiff = widthDiff / 2; // Also move a bit in the direction of the enlarge, allows the + int xDiff = widthDiff / 2; // Also move a bit in the direction of the enlarge, allows the int yDiff = heightDiff / 2; // center windows to be enlarged if there is gaps on the side. // heightDiff (and yDiff) will be re-computed after each successful enlargement attempt @@ -1485,8 +1471,7 @@ void PresentWindowsEffect::calculateWindowTransformationsNatural(EffectWindowLis target->setRect(target->x() + xDiff, target->y() - yDiff - heightDiff, target->width() + widthDiff, - target->height() + heightDiff - ); + target->height() + heightDiff); if (isOverlappingAny(w, targets, borderRegion)) *target = oldRect; else { @@ -1498,11 +1483,10 @@ void PresentWindowsEffect::calculateWindowTransformationsNatural(EffectWindowLis // Attempt enlarging to the bottom-right oldRect = *target; target->setRect( - target->x() + xDiff, - target->y() + yDiff, - target->width() + widthDiff, - target->height() + heightDiff - ); + target->x() + xDiff, + target->y() + yDiff, + target->width() + widthDiff, + target->height() + heightDiff); if (isOverlappingAny(w, targets, borderRegion)) *target = oldRect; else { @@ -1514,11 +1498,10 @@ void PresentWindowsEffect::calculateWindowTransformationsNatural(EffectWindowLis // Attempt enlarging to the bottom-left oldRect = *target; target->setRect( - target->x() - xDiff - widthDiff, - target->y() + yDiff, - target->width() + widthDiff, - target->height() + heightDiff - ); + target->x() - xDiff - widthDiff, + target->y() + yDiff, + target->width() + widthDiff, + target->height() + heightDiff); if (isOverlappingAny(w, targets, borderRegion)) *target = oldRect; else { @@ -1530,11 +1513,10 @@ void PresentWindowsEffect::calculateWindowTransformationsNatural(EffectWindowLis // Attempt enlarging to the top-left oldRect = *target; target->setRect( - target->x() - xDiff - widthDiff, - target->y() - yDiff - heightDiff, - target->width() + widthDiff, - target->height() + heightDiff - ); + target->x() - xDiff - widthDiff, + target->y() - yDiff - heightDiff, + target->width() + widthDiff, + target->height() + heightDiff); if (isOverlappingAny(w, targets, borderRegion)) *target = oldRect; else @@ -1545,16 +1527,16 @@ void PresentWindowsEffect::calculateWindowTransformationsNatural(EffectWindowLis // The expanding code above can actually enlarge windows over 1.0/2.0 scale, we don't like this // We can't add this to the loop above as it would cause a never-ending loop so we have to make // do with the less-than-optimal space usage with using this method. - for (EffectWindow * w : qAsConst(windowlist)) { + for (EffectWindow *w : qAsConst(windowlist)) { QRect *target = &targets[w]; double scale = target->width() / double(w->width()); if (scale > 2.0 || (scale > 1.0 && (w->width() > 300 || w->height() > 300))) { scale = (w->width() > 300 || w->height() > 300) ? 1.0 : 2.0; target->setRect( - target->center().x() - int(w->width() * scale) / 2, - target->center().y() - int(w->height() * scale) / 2, - w->width() * scale, - w->height() * scale); + target->center().x() - int(w->width() * scale) / 2, + target->center().y() - int(w->height() * scale) / 2, + w->width() * scale, + w->height() * scale); } } } @@ -1565,16 +1547,16 @@ void PresentWindowsEffect::calculateWindowTransformationsNatural(EffectWindowLis } } -bool PresentWindowsEffect::isOverlappingAny(EffectWindow *w, const QHash &targets, const QRegion &border) +bool PresentWindowsEffect::isOverlappingAny(EffectWindow *w, const QHash &targets, const QRegion &border) { - QHash::const_iterator winTarget = targets.find(w); + QHash::const_iterator winTarget = targets.find(w); if (winTarget == targets.constEnd()) return false; if (border.intersects(*winTarget)) return true; // Is there a better way to do this? - QHash::const_iterator target; + QHash::const_iterator target; for (target = targets.constBegin(); target != targets.constEnd(); ++target) { if (target == winTarget) continue; @@ -1677,7 +1659,7 @@ void PresentWindowsEffect::setActive(bool active) rearrangeWindows(); setHighlightedWindow(effects->activeWindow()); - for (EffectWindow * w : stackingOrder) { + for (EffectWindow *w : stackingOrder) { w->setData(WindowForceBlurRole, QVariant(true)); w->setData(WindowForceBackgroundContrastRole, QVariant(true)); } @@ -1693,11 +1675,10 @@ void PresentWindowsEffect::setActive(bool active) desktop = activeWindow->desktop(); } const auto stackingOrder = effects->stackingOrder(); - for (EffectWindow * w : stackingOrder) { + for (EffectWindow *w : stackingOrder) { DataHash::iterator winData = m_windowData.find(w); if (winData != m_windowData.end()) { - winData->visible = (w->isOnDesktop(desktop) || w->isOnAllDesktops()) && - !w->isMinimized(); + winData->visible = (w->isOnDesktop(desktop) || w->isOnAllDesktops()) && !w->isMinimized(); } } if (m_closeView) { @@ -1706,7 +1687,7 @@ void PresentWindowsEffect::setActive(bool active) // Move all windows back to their original position const auto managedWindows = m_motionManager.managedWindows(); - for (EffectWindow * w : managedWindows) { + for (EffectWindow *w : managedWindows) { m_motionManager.moveWindow(w, w->frameGeometry()); } if (m_filterFrame) { @@ -1768,7 +1749,7 @@ bool PresentWindowsEffect::isSelectableWindow(EffectWindow *w) if (m_ignoreMinimized && w->isMinimized()) return false; - switch(m_mode) { + switch (m_mode) { default: case ModeAllDesktops: return true; @@ -1823,24 +1804,27 @@ void PresentWindowsEffect::updateCloseWindow() return; const QRectF rect(m_motionManager.targetGeometry(m_highlightedWindow)); - if (2*m_closeView->geometry().width() > rect.width() && 2*m_closeView->geometry().height() > rect.height()) { + if (2 * m_closeView->geometry().width() > rect.width() && 2 * m_closeView->geometry().height() > rect.height()) { // not for tiny windows (eg. with many windows) - they might become unselectable m_closeView->hide(); return; } - QRect cvr(QPoint(0,0), m_closeView->size()); - switch (m_closeButtonCorner) - { + QRect cvr(QPoint(0, 0), m_closeView->size()); + switch (m_closeButtonCorner) { case Qt::TopLeftCorner: default: - cvr.moveTopLeft(rect.topLeft().toPoint()); break; + cvr.moveTopLeft(rect.topLeft().toPoint()); + break; case Qt::TopRightCorner: - cvr.moveTopRight(rect.topRight().toPoint()); break; + cvr.moveTopRight(rect.topRight().toPoint()); + break; case Qt::BottomLeftCorner: - cvr.moveBottomLeft(rect.bottomLeft().toPoint()); break; + cvr.moveBottomLeft(rect.bottomLeft().toPoint()); + break; case Qt::BottomRightCorner: - cvr.moveBottomRight(rect.bottomRight().toPoint()); break; + cvr.moveBottomRight(rect.bottomRight().toPoint()); + break; } m_closeView->setGeometry(cvr); @@ -1848,8 +1832,7 @@ void PresentWindowsEffect::updateCloseWindow() if (rect.contains(effects->cursorPos())) { m_closeView->show(); m_closeView->disarm(); - } - else + } else m_closeView->hide(); } @@ -1859,13 +1842,13 @@ void PresentWindowsEffect::closeWindow() m_highlightedWindow->closeWindow(); } -EffectWindow* PresentWindowsEffect::relativeWindow(EffectWindow *w, int xdiff, int ydiff, bool wrap) const +EffectWindow *PresentWindowsEffect::relativeWindow(EffectWindow *w, int xdiff, int ydiff, bool wrap) const { if (!w) return m_motionManager.managedWindows().constFirst(); // TODO: Is it possible to select hidden windows? - EffectWindow* next; + EffectWindow *next; QRect area = effects->virtualScreenGeometry(); QRect detectRect; @@ -1879,14 +1862,13 @@ EffectWindow* PresentWindowsEffect::relativeWindow(EffectWindow *w, int xdiff, i next = nullptr; const auto managedWindows = m_motionManager.managedWindows(); - for (EffectWindow * e : managedWindows) { + for (EffectWindow *e : managedWindows) { DataHash::const_iterator winData = m_windowData.find(e); if (winData == m_windowData.end() || !winData->visible) continue; QRectF eArea = m_motionManager.transformedGeometry(e); - if (eArea.intersects(detectRect) && - eArea.x() > wArea.x()) { + if (eArea.intersects(detectRect) && eArea.x() > wArea.x()) { if (next == nullptr) next = e; else { @@ -1897,7 +1879,7 @@ EffectWindow* PresentWindowsEffect::relativeWindow(EffectWindow *w, int xdiff, i } } if (next == nullptr) { - if (wrap) // We are at the right-most window, now get the left-most one to wrap + if (wrap) // We are at the right-most window, now get the left-most one to wrap return relativeWindow(w, -1000, 0, false); break; // No more windows to the right } @@ -1912,13 +1894,13 @@ EffectWindow* PresentWindowsEffect::relativeWindow(EffectWindow *w, int xdiff, i next = nullptr; const auto managedWindows = m_motionManager.managedWindows(); - for (EffectWindow *e : managedWindows) { DataHash::const_iterator winData = m_windowData.find(e); + for (EffectWindow *e : managedWindows) { + DataHash::const_iterator winData = m_windowData.find(e); if (winData == m_windowData.end() || !winData->visible) continue; QRectF eArea = m_motionManager.transformedGeometry(e); - if (eArea.intersects(detectRect) && - eArea.x() + eArea.width() < wArea.x() + wArea.width()) { + if (eArea.intersects(detectRect) && eArea.x() + eArea.width() < wArea.x() + wArea.width()) { if (next == nullptr) next = e; else { @@ -1929,7 +1911,7 @@ EffectWindow* PresentWindowsEffect::relativeWindow(EffectWindow *w, int xdiff, i } } if (next == nullptr) { - if (wrap) // We are at the left-most window, now get the right-most one to wrap + if (wrap) // We are at the left-most window, now get the right-most one to wrap return relativeWindow(w, 1000, 0, false); break; // No more windows to the left } @@ -1955,8 +1937,7 @@ EffectWindow* PresentWindowsEffect::relativeWindow(EffectWindow *w, int xdiff, i continue; QRectF eArea = m_motionManager.transformedGeometry(e); - if (eArea.intersects(detectRect) && - eArea.y() > wArea.y()) { + if (eArea.intersects(detectRect) && eArea.y() > wArea.y()) { if (next == nullptr) next = e; else { @@ -1967,7 +1948,7 @@ EffectWindow* PresentWindowsEffect::relativeWindow(EffectWindow *w, int xdiff, i } } if (next == nullptr) { - if (wrap) // We are at the bottom-most window, now get the top-most one to wrap + if (wrap) // We are at the bottom-most window, now get the top-most one to wrap return relativeWindow(w, 0, -1000, false); break; // No more windows to the bottom } @@ -1988,8 +1969,7 @@ EffectWindow* PresentWindowsEffect::relativeWindow(EffectWindow *w, int xdiff, i continue; QRectF eArea = m_motionManager.transformedGeometry(e); - if (eArea.intersects(detectRect) && - eArea.y() + eArea.height() < wArea.y() + wArea.height()) { + if (eArea.intersects(detectRect) && eArea.y() + eArea.height() < wArea.y() + wArea.height()) { if (next == nullptr) next = e; else { @@ -2000,7 +1980,7 @@ EffectWindow* PresentWindowsEffect::relativeWindow(EffectWindow *w, int xdiff, i } } if (next == nullptr) { - if (wrap) // We are at the top-most window, now get the bottom-most one to wrap + if (wrap) // We are at the top-most window, now get the bottom-most one to wrap return relativeWindow(w, 0, 1000, false); break; // No more windows to the top } @@ -2013,7 +1993,7 @@ EffectWindow* PresentWindowsEffect::relativeWindow(EffectWindow *w, int xdiff, i Q_UNREACHABLE(); // Should never get here } -EffectWindow* PresentWindowsEffect::findFirstWindow() const +EffectWindow *PresentWindowsEffect::findFirstWindow() const { EffectWindow *topLeft = nullptr; QRectF topLeftGeometry; @@ -2039,7 +2019,7 @@ EffectWindow* PresentWindowsEffect::findFirstWindow() const return topLeft; } -void PresentWindowsEffect::globalShortcutChanged(QAction *action, const QKeySequence& seq) +void PresentWindowsEffect::globalShortcutChanged(QAction *action, const QKeySequence &seq) { if (action->objectName() == QStringLiteral("Expose")) { shortcut.clear(); @@ -2099,5 +2079,4 @@ void CloseWindowView::disarm() m_armTimer.restart(); } - } // namespace diff --git a/src/effects/presentwindows/presentwindows.h b/src/effects/presentwindows/presentwindows.h index 671075ad7b..872e82fcc8 100644 --- a/src/effects/presentwindows/presentwindows.h +++ b/src/effects/presentwindows/presentwindows.h @@ -33,6 +33,7 @@ Q_SIGNALS: void requestClose(); private Q_SLOTS: void clicked(); + private: QElapsedTimer m_armTimer; }; @@ -63,18 +64,20 @@ class PresentWindowsEffect // TODO: electric borders private: // Structures - struct WindowData { + struct WindowData + { std::chrono::milliseconds lastPresentTime = std::chrono::milliseconds::zero(); bool visible; bool deleted; bool referenced; double opacity; double highlight; - EffectFrame* textFrame; - EffectFrame* iconFrame; + EffectFrame *textFrame; + EffectFrame *iconFrame; }; - typedef QHash DataHash; - struct GridSize { + typedef QHash DataHash; + struct GridSize + { int columns; int rows; }; @@ -84,7 +87,7 @@ public: ~PresentWindowsEffect() override; void reconfigure(ReconfigureFlags) override; - void* proxy() override; + void *proxy() override; // Screen painting void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; @@ -105,7 +108,8 @@ public: bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override; bool touchUp(qint32 id, quint32 time) override; - int requestedEffectChainPosition() const override { + int requestedEffectChainPosition() const override + { return 70; } @@ -138,59 +142,76 @@ public: }; // for properties - int layoutMode() const { + int layoutMode() const + { return m_layoutMode; } - bool isShowCaptions() const { + bool isShowCaptions() const + { return m_showCaptions; } - bool isShowIcons() const { + bool isShowIcons() const + { return m_showIcons; } - bool isDoNotCloseWindows() const { + bool isDoNotCloseWindows() const + { return m_doNotCloseWindows; } - bool isIgnoreMinimized() const { + bool isIgnoreMinimized() const + { return m_ignoreMinimized; } - int accuracy() const { + int accuracy() const + { return m_accuracy; } - bool isFillGaps() const { + bool isFillGaps() const + { return m_fillGaps; } - int fadeDuration() const { + int fadeDuration() const + { return m_fadeDuration; } - bool isShowPanel() const { + bool isShowPanel() const + { return m_showPanel; } - int leftButtonWindow() const { + int leftButtonWindow() const + { return m_leftButtonWindow; } - int rightButtonWindow() const { + int rightButtonWindow() const + { return m_rightButtonWindow; } - int middleButtonWindow() const { + int middleButtonWindow() const + { return m_middleButtonWindow; } - int leftButtonDesktop() const { + int leftButtonDesktop() const + { return m_leftButtonDesktop; } - int middleButtonDesktop() const { + int middleButtonDesktop() const + { return m_middleButtonDesktop; } - int rightButtonDesktop() const { + int rightButtonDesktop() const + { return m_rightButtonDesktop; } public Q_SLOTS: Q_SCRIPTABLE void presentWindows(const QStringList &windows); void setActive(bool active); - void toggleActive() { + void toggleActive() + { m_mode = ModeCurrentDesktop; setActive(!m_activated); } - void toggleActiveAllDesktops() { + void toggleActiveAllDesktops() + { m_mode = ModeAllDesktops; setActive(!m_activated); } @@ -205,7 +226,7 @@ public Q_SLOTS: void slotWindowDeleted(KWin::EffectWindow *w); void slotWindowFrameGeometryChanged(KWin::EffectWindow *w, const QRect &old); // atoms - void slotPropertyNotify(KWin::EffectWindow* w, long atom); + void slotPropertyNotify(KWin::EffectWindow *w, long atom); private Q_SLOTS: void closeWindow(); @@ -216,25 +237,28 @@ protected: void reCreateGrids(); void maybeRecreateGrids(); void calculateWindowTransformations(EffectWindowList windowlist, EffectScreen *screen, - WindowMotionManager& motionManager, bool external = false); + WindowMotionManager &motionManager, bool external = false); void calculateWindowTransformationsClosest(EffectWindowList windowlist, EffectScreen *screen, - WindowMotionManager& motionManager); + WindowMotionManager &motionManager); void calculateWindowTransformationsKompose(EffectWindowList windowlist, EffectScreen *screen, - WindowMotionManager& motionManager); + WindowMotionManager &motionManager); void calculateWindowTransformationsNatural(EffectWindowList windowlist, EffectScreen *screen, - WindowMotionManager& motionManager); + WindowMotionManager &motionManager); // Helper functions for window rearranging - inline double aspectRatio(EffectWindow *w) { + inline double aspectRatio(EffectWindow *w) + { return w->width() / double(w->height()); } - inline int widthForHeight(EffectWindow *w, int height) { + inline int widthForHeight(EffectWindow *w, int height) + { return int((height / double(w->height())) * w->width()); } - inline int heightForWidth(EffectWindow *w, int 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); + bool isOverlappingAny(EffectWindow *w, const QHash &targets, const QRegion &border); // Filter box void updateFilterFrame(); @@ -243,13 +267,13 @@ protected: 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; + 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 mouseActionWindow(WindowMouseAction &action); + void mouseActionDesktop(DesktopMouseAction &action); void inputEventUpdate(const QPoint &pos, QEvent::Type type = QEvent::None, Qt::MouseButton button = Qt::NoButton); private: @@ -293,7 +317,7 @@ private: QMap m_gridSizes; // Filter box - EffectFrame* m_filterFrame; + EffectFrame *m_filterFrame; QString m_windowFilter; // Shortcut - needed to toggle the effect @@ -316,9 +340,10 @@ private: DesktopMouseAction m_middleButtonDesktop; DesktopMouseAction m_rightButtonDesktop; - CloseWindowView* m_closeView; + CloseWindowView *m_closeView; Qt::Corner m_closeButtonCorner; - struct { + struct + { qint32 id = 0; bool active = false; } m_touch; diff --git a/src/effects/presentwindows/presentwindows_config.cpp b/src/effects/presentwindows/presentwindows_config.cpp index b2b96b9bff..5d15d2e6a8 100644 --- a/src/effects/presentwindows/presentwindows_config.cpp +++ b/src/effects/presentwindows/presentwindows_config.cpp @@ -7,19 +7,20 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "presentwindows_config.h" + +#include + // KConfigSkeleton #include "presentwindowsconfig.h" -#include -#include #include +#include -#include #include #include #include #include +#include #include @@ -28,17 +29,18 @@ K_PLUGIN_CLASS(KWin::PresentWindowsEffectConfig) namespace KWin { -PresentWindowsEffectConfigForm::PresentWindowsEffectConfigForm(QWidget* parent) : QWidget(parent) +PresentWindowsEffectConfigForm::PresentWindowsEffectConfigForm(QWidget *parent) + : QWidget(parent) { setupUi(this); } -PresentWindowsEffectConfig::PresentWindowsEffectConfig(QWidget* parent, const QVariantList& args) - : KCModule(parent, args) +PresentWindowsEffectConfig::PresentWindowsEffectConfig(QWidget *parent, const QVariantList &args) + : KCModule(parent, args) { m_ui = new PresentWindowsEffectConfigForm(this); - QVBoxLayout* layout = new QVBoxLayout(this); + QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(m_ui); @@ -49,19 +51,19 @@ PresentWindowsEffectConfig::PresentWindowsEffectConfig(QWidget* parent, const QV m_actionCollection->setConfigGroup(QStringLiteral("PresentWindows")); m_actionCollection->setConfigGlobal(true); - QAction* a = m_actionCollection->addAction(QStringLiteral("ExposeAll")); + QAction *a = m_actionCollection->addAction(QStringLiteral("ExposeAll")); a->setText(i18n("Toggle Present Windows (All desktops)")); a->setProperty("isConfigurationAction", true); KGlobalAccel::self()->setDefaultShortcut(a, QList() << (Qt::CTRL | Qt::Key_F10) << Qt::Key_LaunchC); KGlobalAccel::self()->setShortcut(a, QList() << (Qt::CTRL | Qt::Key_F10) << Qt::Key_LaunchC); - QAction* b = m_actionCollection->addAction(QStringLiteral("Expose")); + QAction *b = m_actionCollection->addAction(QStringLiteral("Expose")); b->setText(i18n("Toggle Present Windows (Current desktop)")); b->setProperty("isConfigurationAction", true); KGlobalAccel::self()->setDefaultShortcut(b, QList() << (Qt::CTRL | Qt::Key_F9)); KGlobalAccel::self()->setShortcut(b, QList() << (Qt::CTRL | Qt::Key_F9)); - QAction* c = m_actionCollection->addAction(QStringLiteral("ExposeClass")); + QAction *c = m_actionCollection->addAction(QStringLiteral("ExposeClass")); c->setText(i18n("Toggle Present Windows (Window class)")); c->setProperty("isConfigurationAction", true); KGlobalAccel::self()->setDefaultShortcut(c, QList() << (Qt::CTRL | Qt::Key_F7)); diff --git a/src/effects/presentwindows/presentwindows_config.h b/src/effects/presentwindows/presentwindows_config.h index d2b9b47a85..4f4902f06b 100644 --- a/src/effects/presentwindows/presentwindows_config.h +++ b/src/effects/presentwindows/presentwindows_config.h @@ -22,14 +22,14 @@ class PresentWindowsEffectConfigForm : public QWidget, public Ui::PresentWindows { Q_OBJECT public: - explicit PresentWindowsEffectConfigForm(QWidget* parent); + explicit PresentWindowsEffectConfigForm(QWidget *parent); }; class PresentWindowsEffectConfig : public KCModule { Q_OBJECT public: - explicit PresentWindowsEffectConfig(QWidget* parent = nullptr, const QVariantList& args = QVariantList()); + explicit PresentWindowsEffectConfig(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); ~PresentWindowsEffectConfig() override; public Q_SLOTS: @@ -37,8 +37,8 @@ public Q_SLOTS: void defaults() override; private: - PresentWindowsEffectConfigForm* m_ui; - KActionCollection* m_actionCollection; + PresentWindowsEffectConfigForm *m_ui; + KActionCollection *m_actionCollection; }; } // namespace diff --git a/src/effects/presentwindows/presentwindows_proxy.cpp b/src/effects/presentwindows/presentwindows_proxy.cpp index d1580fc103..969ef33015 100644 --- a/src/effects/presentwindows/presentwindows_proxy.cpp +++ b/src/effects/presentwindows/presentwindows_proxy.cpp @@ -13,7 +13,7 @@ namespace KWin { -PresentWindowsEffectProxy::PresentWindowsEffectProxy(PresentWindowsEffect* effect) +PresentWindowsEffectProxy::PresentWindowsEffectProxy(PresentWindowsEffect *effect) : m_effect(effect) { } @@ -23,7 +23,7 @@ PresentWindowsEffectProxy::~PresentWindowsEffectProxy() } void PresentWindowsEffectProxy::calculateWindowTransformations(EffectWindowList windows, EffectScreen *screen, - WindowMotionManager& manager) + WindowMotionManager &manager) { return m_effect->calculateWindowTransformations(windows, screen, manager, true); } diff --git a/src/effects/presentwindows/presentwindows_proxy.h b/src/effects/presentwindows/presentwindows_proxy.h index 8d6240550a..bbd222f6ef 100644 --- a/src/effects/presentwindows/presentwindows_proxy.h +++ b/src/effects/presentwindows/presentwindows_proxy.h @@ -19,15 +19,15 @@ class PresentWindowsEffect; class PresentWindowsEffectProxy { public: - explicit PresentWindowsEffectProxy(PresentWindowsEffect* effect); + explicit PresentWindowsEffectProxy(PresentWindowsEffect *effect); ~PresentWindowsEffectProxy(); - void calculateWindowTransformations(EffectWindowList windows, EffectScreen *screen, WindowMotionManager& manager); + void calculateWindowTransformations(EffectWindowList windows, EffectScreen *screen, WindowMotionManager &manager); void reCreateGrids(); private: - PresentWindowsEffect* m_effect; + PresentWindowsEffect *m_effect; }; } // namespace diff --git a/src/effects/screenedge/screenedgeeffect.cpp b/src/effects/screenedge/screenedgeeffect.cpp index d6500ac63e..c153da7487 100644 --- a/src/effects/screenedge/screenedgeeffect.cpp +++ b/src/effects/screenedge/screenedgeeffect.cpp @@ -8,16 +8,17 @@ */ #include "screenedgeeffect.h" // KWin -#include #include +#include // KDE #include // Qt -#include #include +#include #include -namespace KWin { +namespace KWin +{ ScreenEdgeEffect::ScreenEdgeEffect() : Effect() @@ -27,13 +28,11 @@ ScreenEdgeEffect::ScreenEdgeEffect() m_cleanupTimer->setInterval(5000); m_cleanupTimer->setSingleShot(true); connect(m_cleanupTimer, &QTimer::timeout, this, &ScreenEdgeEffect::cleanup); - connect(effects, &EffectsHandler::screenLockingChanged, this, - [this] (bool locked) { - if (locked) { - cleanup(); - } + connect(effects, &EffectsHandler::screenLockingChanged, this, [this](bool locked) { + if (locked) { + cleanup(); } - ); + }); } ScreenEdgeEffect::~ScreenEdgeEffect() @@ -51,9 +50,9 @@ void ScreenEdgeEffect::ensureGlowSvg() void ScreenEdgeEffect::cleanup() { - for (QHash::iterator it = m_borders.begin(); - it != m_borders.end(); - ++it) { + for (QHash::iterator it = m_borders.begin(); + it != m_borders.end(); + ++it) { effects->addRepaint((*it)->geometry); } qDeleteAll(m_borders); @@ -63,9 +62,9 @@ void ScreenEdgeEffect::cleanup() void ScreenEdgeEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) { effects->prePaintScreen(data, presentTime); - for (QHash::iterator it = m_borders.begin(); - it != m_borders.end(); - ++it) { + for (QHash::iterator it = m_borders.begin(); + it != m_borders.end(); + ++it) { if ((*it)->strength == 0.0) { continue; } @@ -76,9 +75,9 @@ void ScreenEdgeEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::mil void ScreenEdgeEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) { effects->paintScreen(mask, region, data); - for (QHash::iterator it = m_borders.begin(); - it != m_borders.end(); - ++it) { + for (QHash::iterator it = m_borders.begin(); + it != m_borders.end(); + ++it) { const qreal opacity = (*it)->strength; if (opacity == 0.0) { continue; @@ -114,19 +113,19 @@ void ScreenEdgeEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintD int x = rect.x(); int y = rect.y(); switch ((*it)->border) { - case ElectricTopRight: - x = rect.x() + rect.width() - size.width(); - break; - case ElectricBottomRight: - x = rect.x() + rect.width() - size.width(); - y = rect.y() + rect.height() - size.height(); - break; - case ElectricBottomLeft: - y = rect.y() + rect.height() - size.height(); - break; - default: - // nothing - break; + case ElectricTopRight: + x = rect.x() + rect.width() - size.width(); + break; + case ElectricBottomRight: + x = rect.x() + rect.width() - size.width(); + y = rect.y() + rect.height() - size.height(); + break; + case ElectricBottomLeft: + y = rect.y() + rect.height() - size.height(); + break; + default: + // nothing + break; } painter->drawImage(QPoint(x, y), tmp); } @@ -135,7 +134,7 @@ void ScreenEdgeEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintD void ScreenEdgeEffect::edgeApproaching(ElectricBorder border, qreal factor, const QRect &geometry) { - QHash::iterator it = m_borders.find(border); + QHash::iterator it = m_borders.find(border); if (it != m_borders.end()) { // need to update effects->addRepaint((*it)->geometry); @@ -205,7 +204,7 @@ Glow *ScreenEdgeEffect::createGlow(ElectricBorder border, qreal factor, const QR return glow; } -template +template T *ScreenEdgeEffect::createCornerGlow(ElectricBorder border) { ensureGlowSvg(); @@ -214,7 +213,7 @@ T *ScreenEdgeEffect::createCornerGlow(ElectricBorder border) case ElectricTopLeft: return new T(m_glow->pixmap(QStringLiteral("bottomright")).toImage()); case ElectricTopRight: - return new T(m_glow->pixmap(QStringLiteral("bottomleft")).toImage()); + return new T(m_glow->pixmap(QStringLiteral("bottomleft")).toImage()); case ElectricBottomRight: return new T(m_glow->pixmap(QStringLiteral("topleft")).toImage()); case ElectricBottomLeft: @@ -232,7 +231,7 @@ QSize ScreenEdgeEffect::cornerGlowSize(ElectricBorder border) case ElectricTopLeft: return m_glow->elementSize(QStringLiteral("bottomright")); case ElectricTopRight: - return m_glow->elementSize(QStringLiteral("bottomleft")); + return m_glow->elementSize(QStringLiteral("bottomleft")); case ElectricBottomRight: return m_glow->elementSize(QStringLiteral("topleft")); case ElectricBottomLeft: @@ -242,7 +241,7 @@ QSize ScreenEdgeEffect::cornerGlowSize(ElectricBorder border) } } -template +template T *ScreenEdgeEffect::createEdgeGlow(ElectricBorder border, const QSize &size) { ensureGlowSvg(); diff --git a/src/effects/screenedge/screenedgeeffect.h b/src/effects/screenedge/screenedgeeffect.h index c9126573cc..b58f951327 100644 --- a/src/effects/screenedge/screenedgeeffect.h +++ b/src/effects/screenedge/screenedgeeffect.h @@ -11,11 +11,13 @@ #include class QTimer; -namespace Plasma { - class Svg; +namespace Plasma +{ +class Svg; } -namespace KWin { +namespace KWin +{ class Glow; class GLTexture; @@ -29,23 +31,25 @@ public: void paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) override; bool isActive() const override; - int requestedEffectChainPosition() 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 + template T *createCornerGlow(ElectricBorder border); - template + template T *createEdgeGlow(ElectricBorder border, const QSize &size); QSize cornerGlowSize(ElectricBorder border); Plasma::Svg *m_glow = nullptr; - QHash m_borders; + QHash m_borders; QTimer *m_cleanupTimer; }; diff --git a/src/effects/screenshot/screenshot.cpp b/src/effects/screenshot/screenshot.cpp index a20c7a01c4..37071eae66 100644 --- a/src/effects/screenshot/screenshot.cpp +++ b/src/effects/screenshot/screenshot.cpp @@ -64,12 +64,11 @@ static void convertFromGLImage(QImage &img, int w, int h) for (int x = 0; x < w; ++x) { const uint pixel = *q; *q = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) - | (pixel & 0xff00ff00); + | (pixel & 0xff00ff00); q++; } } - } img = img.mirrored(); } @@ -392,7 +391,7 @@ void ScreenShotEffect::grabPointerImage(QImage &snapshot, int xOffset, int yOffs bool ScreenShotEffect::isActive() const { return (!m_windowScreenShots.isEmpty() || !m_areaScreenShots.isEmpty() || !m_screenScreenShots.isEmpty()) - && !effects->isScreenLocked(); + && !effects->isScreenLocked(); } int ScreenShotEffect::requestedEffectChainPosition() const diff --git a/src/effects/screenshot/screenshotdbusinterface1.cpp b/src/effects/screenshot/screenshotdbusinterface1.cpp index 74464f6dce..138e56ec2f 100644 --- a/src/effects/screenshot/screenshotdbusinterface1.cpp +++ b/src/effects/screenshot/screenshotdbusinterface1.cpp @@ -4,9 +4,10 @@ SPDX-License-Identifier: GPL-2.0-or-later */ +#include "screenshotdbusinterface1.h" #include -#include "screenshotdbusinterface1.h" + #include "screenshotlogging.h" #include "utils/serviceutils.h" @@ -344,7 +345,8 @@ void ScreenShotSinkPipe1::flush(const QImage &image) } else { close(fd); } - }, m_fileDescriptor, image); + }, + m_fileDescriptor, image); // The ownership of the pipe file descriptor has been moved to the worker thread. m_fileDescriptor = -1; @@ -366,7 +368,8 @@ void ScreenShotSinkPipe1::flushMulti(const QList &images) } else { close(fd); } - }, m_fileDescriptor, images); + }, + m_fileDescriptor, images); // The ownership of the pipe file descriptor has been moved to the worker thread. m_fileDescriptor = -1; @@ -417,7 +420,7 @@ static xcb_pixmap_t xpixmapFromImage(const QImage &image) xcb_gcontext_t gc = xcb_generate_id(c); xcb_create_pixmap(c, image.depth(), pixmap, effects->x11RootWindow(), - image.width(), image.height()); + image.width(), image.height()); xcb_create_gc(c, gc, pixmap, 0, nullptr); const int bytesPerPixel = image.depth() >> 3; @@ -541,9 +544,9 @@ void ScreenShotDBusInterface1::screenshotWindowUnderCursor(int mask) while (it != first) { hoveredWindow = *(--it); if (hoveredWindow->isOnCurrentDesktop() - && !hoveredWindow->isMinimized() - && !hoveredWindow->isDeleted() - && hoveredWindow->frameGeometry().contains(cursor)) { + && !hoveredWindow->isMinimized() + && !hoveredWindow->isDeleted() + && hoveredWindow->frameGeometry().contains(cursor)) { break; } hoveredWindow = nullptr; diff --git a/src/effects/screenshot/screenshotdbusinterface1.h b/src/effects/screenshot/screenshotdbusinterface1.h index 3cff6dbdb7..d40ebcca88 100644 --- a/src/effects/screenshot/screenshotdbusinterface1.h +++ b/src/effects/screenshot/screenshotdbusinterface1.h @@ -151,7 +151,10 @@ private Q_SLOTS: void handleSourceCancelled(); private: - enum class InfoMessageMode { Window, Screen, }; + enum class InfoMessageMode { + Window, + Screen, + }; void takeScreenShot(EffectScreen *screen, ScreenShotFlags flags, ScreenShotSink1 *sink); void takeScreenShot(const QList &screens, ScreenShotFlags flags, ScreenShotSink1 *sink); diff --git a/src/effects/screenshot/screenshotdbusinterface2.cpp b/src/effects/screenshot/screenshotdbusinterface2.cpp index f51284da10..c1cf8ec60e 100644 --- a/src/effects/screenshot/screenshotdbusinterface2.cpp +++ b/src/effects/screenshot/screenshotdbusinterface2.cpp @@ -252,7 +252,8 @@ void ScreenShotSinkPipe2::flush(const QImage &image) const QByteArray buffer(reinterpret_cast(image.constBits()), image.sizeInBytes()); writeBufferToPipe(fileDescriptor, buffer); - }, m_fileDescriptor, image); + }, + m_fileDescriptor, image); // The ownership of the pipe file descriptor has been moved to the worker thread. m_fileDescriptor = -1; diff --git a/src/effects/screentransform/screentransform.cpp b/src/effects/screentransform/screentransform.cpp index 8f2a2fc2ce..f4138a2fca 100644 --- a/src/effects/screentransform/screentransform.cpp +++ b/src/effects/screentransform/screentransform.cpp @@ -34,7 +34,8 @@ bool ScreenTransformEffect::supported() qreal transformAngle(EffectScreen::Transform current, EffectScreen::Transform old) { auto ensureShort = [](int angle) { - return angle > 180 ? angle - 360 : angle < -180 ? angle + 360 : angle; + return angle > 180 ? angle - 360 : angle < -180 ? angle + 360 + : angle; }; // % 4 to ignore flipped cases (for now) return ensureShort((int(current) % 4 - int(old) % 4) * 90); diff --git a/src/effects/screentransform/screentransform.h b/src/effects/screentransform/screentransform.h index b41fb74bfb..6fb0470db4 100644 --- a/src/effects/screentransform/screentransform.h +++ b/src/effects/screentransform/screentransform.h @@ -38,7 +38,8 @@ public: static bool supported(); private: - struct ScreenState { + struct ScreenState + { ~ScreenState(); bool isSecondHalf() const { diff --git a/src/effects/sheet/sheet.cpp b/src/effects/sheet/sheet.cpp index 3a0b14e9b6..72e8e0ddb7 100644 --- a/src/effects/sheet/sheet.cpp +++ b/src/effects/sheet/sheet.cpp @@ -39,8 +39,8 @@ void SheetEffect::reconfigure(ReconfigureFlags flags) // TODO: Rename AnimationTime config key to Duration. const int d = animationTime(SheetConfig::animationTime() != 0 - ? SheetConfig::animationTime() - : 300); + ? SheetConfig::animationTime() + : 300); m_duration = std::chrono::milliseconds(static_cast(d)); } @@ -164,14 +164,14 @@ void SheetEffect::slotWindowAdded(EffectWindow *w) const auto windows = effects->stackingOrder(); auto parentIt = std::find_if(windows.constBegin(), windows.constEnd(), - [w](EffectWindow *p) { - return p->findModal() == w; - }); + [w](EffectWindow *p) { + return p->findModal() == w; + }); if (parentIt != windows.constEnd()) { animation.parentY = (*parentIt)->y(); } - w->setData(WindowAddedGrabRole, QVariant::fromValue(static_cast(this))); + w->setData(WindowAddedGrabRole, QVariant::fromValue(static_cast(this))); w->addRepaintFull(); } @@ -198,14 +198,14 @@ void SheetEffect::slotWindowClosed(EffectWindow *w) const auto windows = effects->stackingOrder(); auto parentIt = std::find_if(windows.constBegin(), windows.constEnd(), - [w](EffectWindow *p) { - return p->findModal() == w; - }); + [w](EffectWindow *p) { + return p->findModal() == w; + }); if (parentIt != windows.constEnd()) { animation.parentY = (*parentIt)->y(); } - w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast(this))); + w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast(this))); w->addRepaintFull(); } diff --git a/src/effects/sheet/sheet.h b/src/effects/sheet/sheet.h index 3665552fd8..728a1a9e65 100644 --- a/src/effects/sheet/sheet.h +++ b/src/effects/sheet/sheet.h @@ -51,13 +51,14 @@ private: private: std::chrono::milliseconds m_duration; - struct Animation { + struct Animation + { TimeLine timeLine; int parentY; std::chrono::milliseconds lastPresentTime = std::chrono::milliseconds::zero(); }; - QHash m_animations; + QHash m_animations; }; inline int SheetEffect::requestedEffectChainPosition() const diff --git a/src/effects/showfps/showfps.cpp b/src/effects/showfps/showfps.cpp index 86babb0b41..1ee992f9f6 100644 --- a/src/effects/showfps/showfps.cpp +++ b/src/effects/showfps/showfps.cpp @@ -19,8 +19,8 @@ #include #include -#include #include +#include #include @@ -37,15 +37,15 @@ ShowFpsEffect::ShowFpsEffect() { initConfig(); for (int i = 0; - i < NUM_PAINTS; - ++i) { - paints[ i ] = 0; - paint_size[ i ] = 0; + i < NUM_PAINTS; + ++i) { + paints[i] = 0; + paint_size[i] = 0; } for (int i = 0; - i < MAX_FPS; - ++i) - frames[ i ] = 0; + i < MAX_FPS; + ++i) + frames[i] = 0; m_noBenchmark->setAlignment(Qt::AlignTop | Qt::AlignRight); m_noBenchmark->setText(i18n("This effect is not a benchmark")); reconfigure(ReconfigureAll); @@ -62,7 +62,7 @@ void ShowFpsEffect::reconfigure(ReconfigureFlags) x = ShowFpsConfig::x(); y = ShowFpsConfig::y(); const QSize screenSize = effects->virtualScreenSize(); - if (x == -10000) // there's no -0 :( + if (x == -10000) // there's no -0 :( x = screenSize.width() - 2 * NUM_PAINTS - FPS_WIDTH; else if (x < 0) x = screenSize.width() - 2 * NUM_PAINTS - FPS_WIDTH - x; @@ -82,7 +82,7 @@ void ShowFpsEffect::reconfigure(ReconfigureFlags) textColor = QPalette().color(QPalette::Active, QPalette::WindowText); textColor.setAlphaF(textAlpha); - switch(textPosition) { + switch (textPosition) { case TOP_LEFT: fpsTextRect = QRect(0, 0, 100, 100); textAlign = Qt::AlignTop | Qt::AlignLeft; @@ -110,19 +110,19 @@ void ShowFpsEffect::reconfigure(ReconfigureFlags) } } -void ShowFpsEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) +void ShowFpsEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) { - frames[ frames_pos ] = QDateTime::currentMSecsSinceEpoch(); + frames[frames_pos] = QDateTime::currentMSecsSinceEpoch(); if (++frames_pos == MAX_FPS) frames_pos = 0; effects->prePaintScreen(data, presentTime); data.paint += fps_rect; - paint_size[ paints_pos ] = 0; + paint_size[paints_pos] = 0; t.restart(); } -void ShowFpsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) +void ShowFpsEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) { effects->paintWindow(w, mask, region, data); @@ -134,10 +134,10 @@ void ShowFpsEffect::paintWindow(EffectWindow* w, int mask, QRegion region, Windo for (const QRect &r : r2) { winsize += r.width() * r.height(); } - paint_size[ paints_pos ] += winsize; + paint_size[paints_pos] += winsize; } -void ShowFpsEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) +void ShowFpsEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) { effects->paintScreen(mask, region, data); int lastFrame = frames_pos - 1; @@ -146,9 +146,9 @@ void ShowFpsEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData const qint64 lastTimestamp = frames[lastFrame]; int fps = 0; for (int i = 0; - i < MAX_FPS; - ++i) - if (abs(lastTimestamp - frames[ i ]) < 1000) + i < MAX_FPS; + ++i) + if (abs(lastTimestamp - frames[i]) < 1000) ++fps; // count all frames in the last second if (fps > MAX_TIME) fps = MAX_TIME; // keep it the same height @@ -200,13 +200,12 @@ void ShowFpsEffect::paintGL(int fps, const QMatrix4x4 &projectionMatrix) vbo->setData(6, 2, verts.constData(), nullptr); vbo->render(GL_TRIANGLES); - color.setBlue(0); vbo->setColor(color); QVector vertices; for (int i = 10; - i < MAX_TIME; - i += 10) { + i < MAX_TIME; + i += 10) { vertices << x << y - i; vertices << x + FPS_WIDTH << y - i; } @@ -278,9 +277,9 @@ void ShowFpsEffect::paintFPSGraph(int x, int y) lines << 10 << 20 << 50; QList values; for (int i = 0; - i < NUM_PAINTS; - ++i) { - values.append(paints[(i + paints_pos) % NUM_PAINTS ]); + i < NUM_PAINTS; + ++i) { + values.append(paints[(i + paints_pos) % NUM_PAINTS]); } paintGraph(x, y, values, lines, true); } @@ -289,12 +288,12 @@ void ShowFpsEffect::paintDrawSizeGraph(int x, int y) { int max_drawsize = 0; for (int i = 0; i < NUM_PAINTS; i++) - max_drawsize = qMax(max_drawsize, paint_size[ i ]); + max_drawsize = qMax(max_drawsize, paint_size[i]); // Log of min/max values shown on graph const float max_pixels_log = 7.2f; const float min_pixels_log = 2.0f; - const int minh = 5; // Minimum height of the bar when value > 0 + const int minh = 5; // Minimum height of the bar when value > 0 float drawscale = (MAX_TIME - minh) / (max_pixels_log - min_pixels_log); QList drawlines; @@ -304,9 +303,9 @@ void ShowFpsEffect::paintDrawSizeGraph(int x, int y) QList drawvalues; for (int i = 0; - i < NUM_PAINTS; - ++i) { - int value = paint_size[(i + paints_pos) % NUM_PAINTS ]; + i < NUM_PAINTS; + ++i) { + int value = paint_size[(i + paints_pos) % NUM_PAINTS]; int h = 0; if (value > 0) { h = (int)((log10((double)value) - min_pixels_log) * drawscale); @@ -337,7 +336,7 @@ void ShowFpsEffect::paintGraph(int x, int y, QList values, QList lines int lastValue = 0; verts.clear(); for (int i = 0; i < values.count(); i++) { - int value = values[ i ]; + int value = values[i]; if (colorize && value != lastValue) { if (!verts.isEmpty()) { vbo->setData(verts.size() / 2, 2, verts.constData(), nullptr); @@ -373,7 +372,7 @@ void ShowFpsEffect::paintGraph(int x, int y, QList values, QList lines QColor color(0, 0, 0); color.setAlphaF(alpha); for (int i = 0; i < values.count(); i++) { - int value = values[ i ]; + int value = values[i]; if (colorize) { if (value <= 10) { color = QColor(0, 255, 0); @@ -394,7 +393,7 @@ void ShowFpsEffect::paintGraph(int x, int y, QList values, QList lines void ShowFpsEffect::postPaintScreen() { effects->postPaintScreen(); - paints[ paints_pos ] = t.elapsed(); + paints[paints_pos] = t.elapsed(); if (++paints_pos == NUM_PAINTS) paints_pos = 0; effects->addRepaint(fps_rect); diff --git a/src/effects/showfps/showfps.h b/src/effects/showfps/showfps.h index d645cb9e6a..6ca2b0bd90 100644 --- a/src/effects/showfps/showfps.h +++ b/src/effects/showfps/showfps.h @@ -15,7 +15,6 @@ #include - namespace KWin { class GLTexture; @@ -36,9 +35,9 @@ public: ~ShowFpsEffect() override; void reconfigure(ReconfigureFlags) override; - void prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) override; - void paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) override; - void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override; + void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; + void paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) override; + void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override; void postPaintScreen() override; enum { INSIDE_GRAPH, @@ -50,27 +49,35 @@ public: }; // fps text position // for properties - qreal configuredAlpha() const { + qreal configuredAlpha() const + { return alpha; } - int configuredX() const { + int configuredX() const + { return x; } - int configuredY() const { + int configuredY() const + { return y; } - QRect configuredFpsTextRect() const { + QRect configuredFpsTextRect() const + { return fpsTextRect; } - int configuredTextAlign() const { + int configuredTextAlign() const + { return textAlign; } - QFont configuredTextFont() const { + QFont configuredTextFont() const + { return textFont; } - QColor configuredTextColor() const { + QColor configuredTextColor() const + { return textColor; } + private: void paintGL(int fps, const QMatrix4x4 &projectionMatrix); void paintQPainter(int fps); @@ -82,13 +89,13 @@ private: 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 + 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, }; - qint64 frames[ MAX_FPS ]; // the time when the frame was done + qint64 frames[MAX_FPS]; // the time when the frame was done int frames_pos; // position in the queue double alpha; int x; diff --git a/src/effects/showfps/showfps_config.cpp b/src/effects/showfps/showfps_config.cpp index cd1defd055..3dba80621a 100644 --- a/src/effects/showfps/showfps_config.cpp +++ b/src/effects/showfps/showfps_config.cpp @@ -6,12 +6,12 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "showfps_config.h" +#include + // KConfigSkeleton #include "showfpsconfig.h" -#include #include #include @@ -22,8 +22,8 @@ K_PLUGIN_CLASS(KWin::ShowFpsEffectConfig) namespace KWin { -ShowFpsEffectConfig::ShowFpsEffectConfig(QWidget* parent, const QVariantList& args) : - KCModule(parent, args) +ShowFpsEffectConfig::ShowFpsEffectConfig(QWidget *parent, const QVariantList &args) + : KCModule(parent, args) { m_ui = new Ui::ShowFpsEffectConfigForm; m_ui->setupUi(this); diff --git a/src/effects/showfps/showfps_config.h b/src/effects/showfps/showfps_config.h index 2bff6ce576..a0c6621137 100644 --- a/src/effects/showfps/showfps_config.h +++ b/src/effects/showfps/showfps_config.h @@ -21,7 +21,7 @@ class ShowFpsEffectConfig : public KCModule { Q_OBJECT public: - explicit ShowFpsEffectConfig(QWidget* parent = nullptr, const QVariantList& args = QVariantList()); + explicit ShowFpsEffectConfig(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); ~ShowFpsEffectConfig() override; public Q_SLOTS: diff --git a/src/effects/showpaint/showpaint.cpp b/src/effects/showpaint/showpaint.cpp index 6286ca876e..12700caeec 100644 --- a/src/effects/showpaint/showpaint.cpp +++ b/src/effects/showpaint/showpaint.cpp @@ -22,15 +22,14 @@ namespace KWin { static const qreal s_alpha = 0.2; -static const QVector s_colors { +static const QVector s_colors{ Qt::red, Qt::green, Qt::blue, Qt::cyan, Qt::magenta, Qt::yellow, - Qt::gray -}; + Qt::gray}; ShowPaintEffect::ShowPaintEffect() { diff --git a/src/effects/slide/slide.cpp b/src/effects/slide/slide.cpp index 87880fd2dd..07497b4293 100644 --- a/src/effects/slide/slide.cpp +++ b/src/effects/slide/slide.cpp @@ -67,11 +67,11 @@ inline QRegion buildClipRegion(const QPoint &pos, int w, int h) const QSize screenSize = effects->virtualScreenSize(); QRegion r = QRect(pos, screenSize); if (effects->optionRollOverDesktops()) { - r |= (r & QRect(-w, 0, w, h)).translated(w, 0); // W - r |= (r & QRect(w, 0, w, h)).translated(-w, 0); // E + r |= (r & QRect(-w, 0, w, h)).translated(w, 0); // W + r |= (r & QRect(w, 0, w, h)).translated(-w, 0); // E - r |= (r & QRect(0, -h, w, h)).translated(0, h); // N - r |= (r & QRect(0, h, w, h)).translated(0, -h); // S + r |= (r & QRect(0, -h, w, h)).translated(0, h); // N + r |= (r & QRect(0, h, w, h)).translated(0, -h); // S r |= (r & QRect(-w, -h, w, h)).translated(w, h); // NW r |= (r & QRect(w, -h, w, h)).translated(-w, h); // NE @@ -130,15 +130,15 @@ void SlideEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::millisec */ inline void wrapDiff(QPoint &diff, int w, int h) { - if (diff.x() > w/2) { + if (diff.x() > w / 2) { diff.setX(diff.x() - w); - } else if (diff.x() < -w/2) { + } else if (diff.x() < -w / 2) { diff.setX(diff.x() + w); } - if (diff.y() > h/2) { + if (diff.y() > h / 2) { diff.setY(diff.y() - h); - } else if (diff.y() < -h/2) { + } else if (diff.y() < -h / 2) { diff.setY(diff.y() + h); } } diff --git a/src/effects/slide/slide.h b/src/effects/slide/slide.h index 328c61f9bb..d3c6317ade 100644 --- a/src/effects/slide/slide.h +++ b/src/effects/slide/slide.h @@ -40,11 +40,13 @@ public: void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) override; void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override; - bool isActive() const override { + bool isActive() const override + { return m_active; } - int requestedEffectChainPosition() const override { + int requestedEffectChainPosition() const override + { return 50; } @@ -87,7 +89,8 @@ private: EffectWindow *m_movingWindow = nullptr; std::chrono::milliseconds m_lastPresentTime = std::chrono::milliseconds::zero(); - struct { + struct + { int desktop; bool firstPass; bool lastPass; diff --git a/src/effects/slide/slide_config.cpp b/src/effects/slide/slide_config.cpp index 1a3e444604..31d84c0b36 100644 --- a/src/effects/slide/slide_config.cpp +++ b/src/effects/slide/slide_config.cpp @@ -6,11 +6,12 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "slide_config.h" + +#include + // KConfigSkeleton #include "slideconfig.h" -#include #include diff --git a/src/effects/slide/slide_config.h b/src/effects/slide/slide_config.h index 929e310bc3..fda3a1fb47 100644 --- a/src/effects/slide/slide_config.h +++ b/src/effects/slide/slide_config.h @@ -7,12 +7,11 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #ifndef SLIDE_CONFIG_H #define SLIDE_CONFIG_H -#include #include "ui_slide_config.h" +#include namespace KWin { diff --git a/src/effects/slideback/slideback.cpp b/src/effects/slideback/slideback.cpp index 16f724012c..79ce2cec9f 100644 --- a/src/effects/slideback/slideback.cpp +++ b/src/effects/slideback/slideback.cpp @@ -42,14 +42,13 @@ void SlideBackEffect::slotStackingOrderChanged() m_upmostWindow = usableNewStackingOrder.last(); - if (m_upmostWindow == m_justMapped ) // a window was added, got on top, stacking changed. Nothing impressive + if (m_upmostWindow == m_justMapped) // a window was added, got on top, stacking changed. Nothing impressive m_justMapped = nullptr; else if (!usableOldStackingOrder.isEmpty() && m_upmostWindow != usableOldStackingOrder.last()) windowRaised(m_upmostWindow); oldStackingOrder = newStackingOrder; usableOldStackingOrder = usableNewStackingOrder; - } void SlideBackEffect::windowRaised(EffectWindow *w) @@ -74,7 +73,7 @@ void SlideBackEffect::windowRaised(EffectWindow *w) destinationList.insert(tmp, slideRect); coveringWindows.append(tmp); } else { - //Does it intersect with a moved (elevated) window and do we have to elevate it too? + // Does it intersect with a moved (elevated) window and do we have to elevate it too? for (EffectWindow *elevatedWindow : qAsConst(elevatedList)) { if (tmp->frameGeometry().intersects(elevatedWindow->frameGeometry())) { effects->setElevatedWindow(tmp, true); @@ -82,7 +81,6 @@ void SlideBackEffect::windowRaised(EffectWindow *w) break; } } - } } if (tmp->isDock() || tmp->keepAbove()) { @@ -94,7 +92,7 @@ void SlideBackEffect::windowRaised(EffectWindow *w) // If a window is minimized it could happen that the panels stay elevated without any windows sliding. // clear all elevation settings if (!motionManager.managingWindows()) { - for (EffectWindow * tmp : qAsConst(elevatedList)) { + for (EffectWindow *tmp : qAsConst(elevatedList)) { effects->setElevatedWindow(tmp, false); } } @@ -105,7 +103,7 @@ QRect SlideBackEffect::getSlideDestination(const QRect &windowUnderGeometry, con // Determine the shortest way: int leftSlide = windowUnderGeometry.left() - windowOverGeometry.right() - 20; int rightSlide = windowUnderGeometry.right() - windowOverGeometry.left() + 20; - int upSlide = windowUnderGeometry.top() - windowOverGeometry.bottom() - 20; + int upSlide = windowUnderGeometry.top() - windowOverGeometry.bottom() - 20; int downSlide = windowUnderGeometry.bottom() - windowOverGeometry.top() + 20; int horizSlide = leftSlide; @@ -181,7 +179,7 @@ void SlideBackEffect::paintWindow(EffectWindow *w, int mask, QRegion region, Win clippedRegions.clear(); } -void SlideBackEffect::postPaintWindow(EffectWindow* w) +void SlideBackEffect::postPaintWindow(EffectWindow *w) { if (motionManager.isManaging(w)) { if (destinationList.contains(w)) { @@ -190,7 +188,7 @@ void SlideBackEffect::postPaintWindow(EffectWindow* w) // restore the stacking order of all windows not intersecting any more except panels if (coveringWindows.contains(w)) { EffectWindowList tmpList; - for (EffectWindow * tmp : qAsConst(elevatedList)) { + for (EffectWindow *tmp : qAsConst(elevatedList)) { QRect elevatedGeometry = tmp->frameGeometry(); if (motionManager.isManaging(tmp)) { elevatedGeometry = motionManager.transformedGeometry(tmp).toAlignedRect(); @@ -206,7 +204,7 @@ void SlideBackEffect::postPaintWindow(EffectWindow* w) } else { if (!tmp->isDock()) { bool keepElevated = false; - for (EffectWindow * elevatedWindow : qAsConst(tmpList)) { + for (EffectWindow *elevatedWindow : qAsConst(tmpList)) { if (tmp->frameGeometry().intersects(elevatedWindow->frameGeometry())) { keepElevated = true; } @@ -239,7 +237,7 @@ void SlideBackEffect::postPaintWindow(EffectWindow* w) coveringWindows.removeAll(w); if (coveringWindows.isEmpty()) { // Restore correct stacking order - for (EffectWindow * tmp : qAsConst(elevatedList)) { + for (EffectWindow *tmp : qAsConst(elevatedList)) { effects->setElevatedWindow(tmp, false); } elevatedList.clear(); @@ -253,7 +251,7 @@ void SlideBackEffect::postPaintWindow(EffectWindow* w) effects->postPaintWindow(w); } -void SlideBackEffect::slotWindowDeleted(EffectWindow* w) +void SlideBackEffect::slotWindowDeleted(EffectWindow *w) { if (w == m_upmostWindow) m_upmostWindow = nullptr; @@ -273,7 +271,7 @@ void SlideBackEffect::slotWindowAdded(EffectWindow *w) m_justMapped = w; } -void SlideBackEffect::slotWindowUnminimized(EffectWindow* w) +void SlideBackEffect::slotWindowUnminimized(EffectWindow *w) { // SlideBack should not be triggered on an unminimized window. For this we need to store the last unminimized window. m_justMapped = w; @@ -290,28 +288,28 @@ void SlideBackEffect::slotTabBoxAdded() void SlideBackEffect::slotTabBoxClosed() { - m_tabboxActive = qMax(m_tabboxActive-1, 0); + m_tabboxActive = qMax(m_tabboxActive - 1, 0); } -bool SlideBackEffect::isWindowUsable(EffectWindow* w) +bool SlideBackEffect::isWindowUsable(EffectWindow *w) { return w && (w->isNormalWindow() || w->isDialog()) && !w->keepAbove() && !w->isDeleted() && !w->isMinimized() - && w->isPaintingEnabled(); + && w->isPaintingEnabled(); } -bool SlideBackEffect::intersects(EffectWindow* windowUnder, const QRect &windowOverGeometry) +bool SlideBackEffect::intersects(EffectWindow *windowUnder, const QRect &windowOverGeometry) { QRect windowUnderGeometry = getModalGroupGeometry(windowUnder); return windowUnderGeometry.intersects(windowOverGeometry); } -EffectWindowList SlideBackEffect::usableWindows(const EffectWindowList & allWindows) +EffectWindowList SlideBackEffect::usableWindows(const EffectWindowList &allWindows) { EffectWindowList retList; - auto isWindowVisible = [] (const EffectWindow *window) { + auto isWindowVisible = [](const EffectWindow *window) { return window && effects->virtualScreenGeometry().intersects(window->frameGeometry()); }; - for (EffectWindow * tmp : qAsConst(allWindows)) { + for (EffectWindow *tmp : qAsConst(allWindows)) { if (isWindowUsable(tmp) && isWindowVisible(tmp)) { retList.append(tmp); } @@ -324,7 +322,7 @@ QRect SlideBackEffect::getModalGroupGeometry(EffectWindow *w) QRect modalGroupGeometry = w->frameGeometry(); if (w->isModal()) { const auto mainWindows = w->mainWindows(); - for (EffectWindow * modalWindow : mainWindows) { + for (EffectWindow *modalWindow : mainWindows) { modalGroupGeometry = modalGroupGeometry.united(getModalGroupGeometry(modalWindow)); } } @@ -336,4 +334,4 @@ bool SlideBackEffect::isActive() const return motionManager.managingWindows(); } -} //Namespace +} // Namespace diff --git a/src/effects/slideback/slideback.h b/src/effects/slideback/slideback.h index cf49a345eb..707019eeec 100644 --- a/src/effects/slideback/slideback.h +++ b/src/effects/slideback/slideback.h @@ -24,14 +24,15 @@ public: SlideBackEffect(); void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) override; - void paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) override; - void postPaintWindow(EffectWindow* w) override; + void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override; + void postPaintWindow(EffectWindow *w) override; void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; void postPaintScreen() override; bool isActive() const override; - int requestedEffectChainPosition() const override { + int requestedEffectChainPosition() const override + { return 50; } @@ -44,7 +45,6 @@ public Q_SLOTS: void slotTabBoxClosed(); private: - WindowMotionManager motionManager; EffectWindowList usableOldStackingOrder; EffectWindowList oldStackingOrder; @@ -53,7 +53,7 @@ private: EffectWindow *m_justMapped, *m_upmostWindow; QHash destinationList; int m_tabboxActive; - QList clippedRegions; + QList clippedRegions; std::chrono::milliseconds m_lastPresentTime = std::chrono::milliseconds::zero(); QRect getSlideDestination(const QRect &windowUnderGeometry, const QRect &windowOverGeometry); @@ -62,7 +62,6 @@ private: EffectWindowList usableWindows(const EffectWindowList &allWindows); QRect getModalGroupGeometry(EffectWindow *w); void windowRaised(EffectWindow *w); - }; } // namespace diff --git a/src/effects/slidingpopups/slidingpopups.cpp b/src/effects/slidingpopups/slidingpopups.cpp index 7fd4ce21ac..d41182c534 100644 --- a/src/effects/slidingpopups/slidingpopups.cpp +++ b/src/effects/slidingpopups/slidingpopups.cpp @@ -11,13 +11,13 @@ #include "slidingpopups.h" #include "slidingpopupsconfig.h" -#include #include +#include #include #include -#include #include +#include #include @@ -58,11 +58,9 @@ SlidingPopupsEffect::SlidingPopupsEffect() connect(effects, &EffectsHandler::propertyNotify, this, &SlidingPopupsEffect::slotPropertyNotify); connect(effects, &EffectsHandler::windowShown, this, &SlidingPopupsEffect::slideIn); connect(effects, &EffectsHandler::windowHidden, this, &SlidingPopupsEffect::slideOut); - connect(effects, &EffectsHandler::xcbConnectionChanged, this, - [this] { - m_atom = effects->announceSupportProperty(QByteArrayLiteral("_KDE_SLIDE"), this); - } - ); + connect(effects, &EffectsHandler::xcbConnectionChanged, this, [this]() { + m_atom = effects->announceSupportProperty(QByteArrayLiteral("_KDE_SLIDE"), this); + }); connect(effects, qOverload(&EffectsHandler::desktopChanged), this, &SlidingPopupsEffect::stopAnimations); connect(effects, &EffectsHandler::activeFullScreenEffectChanged, @@ -87,7 +85,7 @@ SlidingPopupsEffect::~SlidingPopupsEffect() bool SlidingPopupsEffect::supported() { - return effects->animationsSupported(); + return effects->animationsSupported(); } void SlidingPopupsEffect::reconfigure(ReconfigureFlags flags) @@ -212,12 +210,12 @@ void SlidingPopupsEffect::postPaintWindow(EffectWindow *w) void SlidingPopupsEffect::setupSlideData(EffectWindow *w) { - //X11 + // X11 if (m_atom != XCB_ATOM_NONE) { slotPropertyNotify(w, m_atom); } - //Wayland + // Wayland if (auto surf = w->surface()) { slotWaylandSlideOnShowChanged(w); connect(surf, &KWaylandServer::SurfaceInterface::slideOnShowHideChanged, this, [this, surf] { @@ -376,10 +374,10 @@ void SlidingPopupsEffect::setupAnimData(EffectWindow *w) : m_slideOutDuration; // Grab the window, so other windowClosed effects will ignore it - w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast(this))); + w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast(this))); } -void SlidingPopupsEffect::slotWaylandSlideOnShowChanged(EffectWindow* w) +void SlidingPopupsEffect::slotWaylandSlideOnShowChanged(EffectWindow *w) { if (!w) { return; @@ -484,9 +482,9 @@ void SlidingPopupsEffect::setupInputPanelSlide() bool SlidingPopupsEffect::eventFilter(QObject *watched, QEvent *event) { - auto internal = qobject_cast(watched); + auto internal = qobject_cast(watched); if (internal && event->type() == QEvent::DynamicPropertyChange) { - QDynamicPropertyChangeEvent *pe = static_cast(event); + QDynamicPropertyChangeEvent *pe = static_cast(event); if (pe->propertyName() == "kwin_slide" || pe->propertyName() == "kwin_slide_offset") { if (auto w = effects->findWindow(internal)) { setupInternalWindowSlide(w); @@ -524,7 +522,7 @@ void SlidingPopupsEffect::slideIn(EffectWindow *w) animation.timeLine.reset(); } - w->setData(WindowAddedGrabRole, QVariant::fromValue(static_cast(this))); + w->setData(WindowAddedGrabRole, QVariant::fromValue(static_cast(this))); w->setData(WindowForceBackgroundContrastRole, QVariant(true)); w->setData(WindowForceBlurRole, QVariant(true)); @@ -564,7 +562,7 @@ void SlidingPopupsEffect::slideOut(EffectWindow *w) animation.timeLine.reset(); } - w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast(this))); + w->setData(WindowClosedGrabRole, QVariant::fromValue(static_cast(this))); w->setData(WindowForceBackgroundContrastRole, QVariant(true)); w->setData(WindowForceBlurRole, QVariant(true)); diff --git a/src/effects/slidingpopups/slidingpopups.h b/src/effects/slidingpopups/slidingpopups.h index 931e09aac3..bc4a163abf 100644 --- a/src/effects/slidingpopups/slidingpopups.h +++ b/src/effects/slidingpopups/slidingpopups.h @@ -35,7 +35,8 @@ public: void reconfigure(ReconfigureFlags flags) override; bool isActive() const override; - int requestedEffectChainPosition() const override { + int requestedEffectChainPosition() const override + { return 40; } @@ -76,7 +77,8 @@ private: Out }; - struct Animation { + struct Animation + { AnimationKind kind; TimeLine timeLine; std::chrono::milliseconds lastPresentTime = std::chrono::milliseconds::zero(); @@ -90,14 +92,15 @@ private: Bottom }; - struct AnimationData { + struct AnimationData + { int offset; Location location; std::chrono::milliseconds slideInDuration; std::chrono::milliseconds slideOutDuration; int slideLength; }; - QHash m_animationsData; + QHash m_animationsData; }; inline int SlidingPopupsEffect::slideInDuration() const diff --git a/src/effects/snaphelper/snaphelper.cpp b/src/effects/snaphelper/snaphelper.cpp index d5028b7a18..0bed146785 100644 --- a/src/effects/snaphelper/snaphelper.cpp +++ b/src/effects/snaphelper/snaphelper.cpp @@ -26,8 +26,7 @@ static QRegion computeDirtyRegion(const QRect &windowRect) s_lineWidth / 2, s_lineWidth / 2, s_lineWidth / 2, - s_lineWidth / 2 - ); + s_lineWidth / 2); QRegion dirtyRegion; @@ -49,11 +48,11 @@ static QRegion computeDirtyRegion(const QRect &windowRect) dirtyRegion += horizontalBarRect; const QRect outlineOuterRect = screenWindowRect - .marginsAdded(outlineMargins) - .adjusted(-1, -1, 1, 1); + .marginsAdded(outlineMargins) + .adjusted(-1, -1, 1, 1); const QRect outlineInnerRect = screenWindowRect - .marginsRemoved(outlineMargins) - .adjusted(1, 1, -1, -1); + .marginsRemoved(outlineMargins) + .adjusted(1, 1, -1, -1); dirtyRegion += QRegion(outlineOuterRect) - QRegion(outlineInnerRect); } @@ -126,7 +125,7 @@ void SnapHelperEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintD for (EffectScreen *screen : screens) { const QRect rect = effects->clientArea(ScreenArea, screen, effects->currentDesktop()); const int midX = rect.x() + rect.width() / 2; - const int midY = rect.y() + rect.height() / 2 ; + const int midY = rect.y() + rect.height() / 2; const int halfWidth = m_geometry.width() / 2; const int halfHeight = m_geometry.height() / 2; diff --git a/src/effects/snaphelper/snaphelper.h b/src/effects/snaphelper/snaphelper.h index e965c049d8..09b5e00d18 100644 --- a/src/effects/snaphelper/snaphelper.h +++ b/src/effects/snaphelper/snaphelper.h @@ -42,7 +42,8 @@ private: QRect m_geometry; EffectWindow *m_window = nullptr; - struct Animation { + struct Animation + { bool active = false; TimeLine timeLine; std::chrono::milliseconds lastPresentTime = std::chrono::milliseconds::zero(); diff --git a/src/effects/startupfeedback/startupfeedback.cpp b/src/effects/startupfeedback/startupfeedback.cpp index f7aa9610f6..387a3a68be 100644 --- a/src/effects/startupfeedback/startupfeedback.cpp +++ b/src/effects/startupfeedback/startupfeedback.cpp @@ -20,8 +20,8 @@ #include // KDE #include -#include #include +#include #include // KWin #include @@ -52,22 +52,17 @@ static const int BLINKING_FRAMES = 5; static const int BLINKING_FRAME_DURATION = 100; // duration of one blinking animation static const int BLINKING_DURATION = BLINKING_FRAME_DURATION * BLINKING_FRAMES; -//const int color_to_pixmap[] = { 0, 1, 2, 3, 2, 1 }; +// const int color_to_pixmap[] = { 0, 1, 2, 3, 2, 1 }; static const int FRAME_TO_BOUNCE_YOFFSET[] = { - -5, -1, 2, 5, 8, 10, 12, 13, 15, 15, 15, 15, 14, 12, 10, 8, 5, 2, -1, -5 -}; + -5, -1, 2, 5, 8, 10, 12, 13, 15, 15, 15, 15, 14, 12, 10, 8, 5, 2, -1, -5}; static const QSize BOUNCE_SIZES[] = { - QSize(16, 16), QSize(14, 18), QSize(12, 20), QSize(18, 14), QSize(20, 12) -}; + QSize(16, 16), QSize(14, 18), QSize(12, 20), QSize(18, 14), QSize(20, 12)}; static const int FRAME_TO_BOUNCE_TEXTURE[] = { - 0, 0, 0, 1, 2, 2, 1, 0, 3, 4, 4, 3, 0, 1, 2, 2, 1, 0, 0, 0 -}; + 0, 0, 0, 1, 2, 2, 1, 0, 3, 4, 4, 3, 0, 1, 2, 2, 1, 0, 0, 0}; static const int FRAME_TO_BLINKING_COLOR[] = { - 0, 1, 2, 3, 2, 1 -}; + 0, 1, 2, 3, 2, 1}; static const QColor BLINKING_COLORS[] = { - Qt::black, Qt::darkGray, Qt::lightGray, Qt::white, Qt::white -}; + Qt::black, Qt::darkGray, Qt::lightGray, Qt::white, Qt::white}; static const int s_startupDefaultTimeout = 5; StartupFeedbackEffect::StartupFeedbackEffect() @@ -169,7 +164,7 @@ void StartupFeedbackEffect::reconfigure(Effect::ReconfigureFlags flags) } } -void StartupFeedbackEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) +void StartupFeedbackEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) { int time = 0; if (m_lastPresentTime.count()) { @@ -182,7 +177,7 @@ void StartupFeedbackEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono } if (m_active) { // need the unclipped version - switch(m_type) { + switch (m_type) { case BouncingFeedback: m_progress = (m_progress + time) % BOUNCE_DURATION; m_frame = qRound((qreal)m_progress / (qreal)BOUNCE_FRAME_DURATION) % BOUNCE_FRAMES; @@ -200,14 +195,14 @@ void StartupFeedbackEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono effects->prePaintScreen(data, presentTime); } -void StartupFeedbackEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) +void StartupFeedbackEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) { effects->paintScreen(mask, region, data); if (m_active) { - GLTexture* texture; - switch(m_type) { + GLTexture *texture; + switch (m_type) { case BouncingFeedback: - texture = m_bouncingTextures[ FRAME_TO_BOUNCE_TEXTURE[ m_frame ]].get(); + texture = m_bouncingTextures[FRAME_TO_BOUNCE_TEXTURE[m_frame]].get(); break; case BlinkingFeedback: // fall through case PassiveFeedback: @@ -220,7 +215,7 @@ void StartupFeedbackEffect::paintScreen(int mask, const QRegion ®ion, ScreenP glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); texture->bind(); if (m_type == BlinkingFeedback && m_blinkingShader && m_blinkingShader->isValid()) { - const QColor& blinkingColor = BLINKING_COLORS[ FRAME_TO_BLINKING_COLOR[ m_frame ]]; + const QColor &blinkingColor = BLINKING_COLORS[FRAME_TO_BLINKING_COLOR[m_frame]]; ShaderManager::instance()->pushShader(m_blinkingShader.get()); m_blinkingShader->setUniform(GLShader::Color, blinkingColor); } else { @@ -246,8 +241,8 @@ void StartupFeedbackEffect::postPaintScreen() effects->postPaintScreen(); } -void StartupFeedbackEffect::slotMouseChanged(const QPoint& pos, const QPoint& oldpos, Qt::MouseButtons buttons, - Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers) +void StartupFeedbackEffect::slotMouseChanged(const QPoint &pos, const QPoint &oldpos, Qt::MouseButtons buttons, + Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers) { Q_UNUSED(pos) Q_UNUSED(oldpos) @@ -289,7 +284,7 @@ void StartupFeedbackEffect::gotRemoveStartup(const QString &id) return; } m_currentStartup = m_startups.begin().key(); - start(m_startups[ m_currentStartup ]); + start(m_startups[m_currentStartup]); } void StartupFeedbackEffect::gotStartupChange(const QString &id, const QIcon &icon) @@ -335,7 +330,7 @@ void StartupFeedbackEffect::stop() m_active = false; m_lastPresentTime = std::chrono::milliseconds::zero(); effects->makeOpenGLContextCurrent(); - switch(m_type) { + switch (m_type) { case BouncingFeedback: for (int i = 0; i < 5; ++i) { m_bouncingTextures[i].reset(); @@ -353,10 +348,10 @@ void StartupFeedbackEffect::stop() effects->addRepaintFull(); } -void StartupFeedbackEffect::prepareTextures(const QPixmap& pix) +void StartupFeedbackEffect::prepareTextures(const QPixmap &pix) { effects->makeOpenGLContextCurrent(); - switch(m_type) { + switch (m_type) { case BouncingFeedback: for (int i = 0; i < 5; ++i) { m_bouncingTextures[i].reset(new GLTexture(scalePixmap(pix, BOUNCE_SIZES[i]))); @@ -378,9 +373,9 @@ void StartupFeedbackEffect::prepareTextures(const QPixmap& pix) } } -QImage StartupFeedbackEffect::scalePixmap(const QPixmap& pm, const QSize& size) const +QImage StartupFeedbackEffect::scalePixmap(const QPixmap &pm, const QSize &size) const { - const QSize& adjustedSize = size * m_bounceSizesRatio; + const QSize &adjustedSize = size * m_bounceSizesRatio; QImage scaled = pm.toImage().scaled(adjustedSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); if (scaled.format() != QImage::Format_ARGB32_Premultiplied && scaled.format() != QImage::Format_ARGB32) scaled = scaled.convertToFormat(QImage::Format_ARGB32); @@ -389,7 +384,7 @@ QImage StartupFeedbackEffect::scalePixmap(const QPixmap& pm, const QSize& size) QPainter p(&result); p.setCompositionMode(QPainter::CompositionMode_Source); p.fillRect(result.rect(), Qt::transparent); - p.drawImage((20 * m_bounceSizesRatio - adjustedSize.width()) / 2, (20*m_bounceSizesRatio - adjustedSize.height()) / 2, scaled, 0, 0, adjustedSize.width(), adjustedSize.height() * m_bounceSizesRatio); + p.drawImage((20 * m_bounceSizesRatio - adjustedSize.width()) / 2, (20 * m_bounceSizesRatio - adjustedSize.height()) / 2, scaled, 0, 0, adjustedSize.width(), adjustedSize.height() * m_bounceSizesRatio); return result; } @@ -405,12 +400,12 @@ QRect StartupFeedbackEffect::feedbackRect() const else xDiff = 32 + 7; int yDiff = xDiff; - GLTexture* texture = nullptr; + GLTexture *texture = nullptr; int yOffset = 0; - switch(m_type) { + switch (m_type) { case BouncingFeedback: - texture = m_bouncingTextures[ FRAME_TO_BOUNCE_TEXTURE[ m_frame ]].get(); - yOffset = FRAME_TO_BOUNCE_YOFFSET[ m_frame ] * m_bounceSizesRatio; + texture = m_bouncingTextures[FRAME_TO_BOUNCE_TEXTURE[m_frame]].get(); + yOffset = FRAME_TO_BOUNCE_YOFFSET[m_frame] * m_bounceSizesRatio; break; case BlinkingFeedback: // fall through case PassiveFeedback: @@ -422,8 +417,8 @@ QRect StartupFeedbackEffect::feedbackRect() const } const QPoint cursorPos = effects->cursorPos() + QPoint(xDiff, yDiff + yOffset); QRect rect; - if( texture ) - rect = QRect(cursorPos, texture->size()); + if (texture) + rect = QRect(cursorPos, texture->size()); return rect; } diff --git a/src/effects/startupfeedback/startupfeedback.h b/src/effects/startupfeedback/startupfeedback.h index 5c58a44807..46af3aa0fe 100644 --- a/src/effects/startupfeedback/startupfeedback.h +++ b/src/effects/startupfeedback/startupfeedback.h @@ -9,10 +9,10 @@ #ifndef KWIN_STARTUPFEEDBACK_H #define KWIN_STARTUPFEEDBACK_H +#include +#include #include #include -#include -#include #include @@ -31,16 +31,18 @@ public: ~StartupFeedbackEffect() override; void reconfigure(ReconfigureFlags flags) override; - void prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) override; - void paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) override; + void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; + void paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) override; void postPaintScreen() override; bool isActive() const override; - int requestedEffectChainPosition() const override { + int requestedEffectChainPosition() const override + { return 90; } - int type() const { + int type() const + { return int(m_type); } @@ -50,7 +52,7 @@ private Q_SLOTS: void gotNewStartup(const QString &id, const QIcon &icon); void gotRemoveStartup(const QString &id); void gotStartupChange(const QString &id, const QIcon &icon); - void slotMouseChanged(const QPoint& pos, const QPoint& oldpos, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); + void slotMouseChanged(const QPoint &pos, const QPoint &oldpos, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); private: enum FeedbackType { @@ -60,20 +62,21 @@ private: PassiveFeedback }; - struct Startup { + struct Startup + { QIcon icon; QSharedPointer expiredTimer; }; void start(const Startup &startup); void stop(); - QImage scalePixmap(const QPixmap& pm, const QSize& size) const; - void prepareTextures(const QPixmap& pix); + 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; + KStartupInfo *m_startupInfo; + KSelectionOwner *m_selection; QString m_currentStartup; QMap m_startups; bool m_active; diff --git a/src/effects/thumbnailaside/thumbnailaside.cpp b/src/effects/thumbnailaside/thumbnailaside.cpp index d660721b56..24803a6c3c 100644 --- a/src/effects/thumbnailaside/thumbnailaside.cpp +++ b/src/effects/thumbnailaside/thumbnailaside.cpp @@ -24,7 +24,7 @@ namespace KWin ThumbnailAsideEffect::ThumbnailAsideEffect() { initConfig(); - QAction* a = new QAction(this); + QAction *a = new QAction(this); a->setObjectName(QStringLiteral("ToggleCurrentThumbnail")); a->setText(i18n("Toggle Thumbnail for Current Window")); KGlobalAccel::self()->setDefaultShortcut(a, QList() << (Qt::META | Qt::CTRL | Qt::Key_T)); @@ -44,12 +44,12 @@ void ThumbnailAsideEffect::reconfigure(ReconfigureFlags) ThumbnailAsideConfig::self()->read(); maxwidth = ThumbnailAsideConfig::maxWidth(); spacing = ThumbnailAsideConfig::spacing(); - opacity = ThumbnailAsideConfig::opacity()/100.0; + opacity = ThumbnailAsideConfig::opacity() / 100.0; screen = ThumbnailAsideConfig::screen(); // Xinerama screen TODO add gui option arrange(); } -void ThumbnailAsideEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) +void ThumbnailAsideEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) { painted = QRegion(); effects->paintScreen(mask, region, data); @@ -73,7 +73,7 @@ void ThumbnailAsideEffect::paintWindow(EffectWindow *w, int mask, QRegion region painted |= region; } -void ThumbnailAsideEffect::slotWindowDamaged(EffectWindow* w, const QRegion&) +void ThumbnailAsideEffect::slotWindowDamaged(EffectWindow *w, const QRegion &) { for (const Data &d : qAsConst(windows)) { if (d.window == w) @@ -81,7 +81,7 @@ void ThumbnailAsideEffect::slotWindowDamaged(EffectWindow* w, const QRegion&) } } -void ThumbnailAsideEffect::slotWindowFrameGeometryChanged(EffectWindow* w, const QRect& old) +void ThumbnailAsideEffect::slotWindowFrameGeometryChanged(EffectWindow *w, const QRect &old) { for (const Data &d : qAsConst(windows)) { if (d.window == w) { @@ -94,14 +94,14 @@ void ThumbnailAsideEffect::slotWindowFrameGeometryChanged(EffectWindow* w, const } } -void ThumbnailAsideEffect::slotWindowClosed(EffectWindow* w) +void ThumbnailAsideEffect::slotWindowClosed(EffectWindow *w) { removeThumbnail(w); } void ThumbnailAsideEffect::toggleCurrentThumbnail() { - EffectWindow* active = effects->activeWindow(); + EffectWindow *active = effects->activeWindow(); if (active == nullptr) return; if (windows.contains(active)) @@ -110,27 +110,27 @@ void ThumbnailAsideEffect::toggleCurrentThumbnail() addThumbnail(active); } -void ThumbnailAsideEffect::addThumbnail(EffectWindow* w) +void ThumbnailAsideEffect::addThumbnail(EffectWindow *w) { repaintAll(); // repaint old areas Data d; d.window = w; d.index = windows.count(); - windows[ w ] = d; + windows[w] = d; arrange(); } -void ThumbnailAsideEffect::removeThumbnail(EffectWindow* w) +void ThumbnailAsideEffect::removeThumbnail(EffectWindow *w) { if (!windows.contains(w)) return; repaintAll(); // repaint old areas - int index = windows[ w ].index; + int index = windows[w].index; windows.remove(w); - for (QHash< EffectWindow*, Data >::Iterator it = windows.begin(); - it != windows.end(); - ++it) { - Data& d = *it; + for (QHash::Iterator it = windows.begin(); + it != windows.end(); + ++it) { + Data &d = *it; if (d.index > index) --d.index; } @@ -142,34 +142,34 @@ void ThumbnailAsideEffect::arrange() if (windows.size() == 0) return; int height = 0; - QVector< int > pos(windows.size()); + QVector pos(windows.size()); int mwidth = 0; for (const Data &d : qAsConst(windows)) { height += d.window->height(); mwidth = qMax(mwidth, d.window->width()); - pos[ d.index ] = d.window->height(); + pos[d.index] = d.window->height(); } EffectScreen *effectiveScreen = effects->findScreen(screen); - if (!effectiveScreen ) { + if (!effectiveScreen) { effectiveScreen = effects->activeScreen(); } QRect area = effects->clientArea(MaximizeArea, effectiveScreen, effects->currentDesktop()); double scale = area.height() / double(height); - scale = qMin(scale, maxwidth / double(mwidth)); // don't be wider than maxwidth pixels + scale = qMin(scale, maxwidth / double(mwidth)); // don't be wider than maxwidth pixels int add = 0; for (int i = 0; - i < windows.size(); - ++i) { - pos[ i ] = int(pos[ i ] * scale); - pos[ i ] += spacing + add; // compute offset of each item - add = pos[ i ]; + i < windows.size(); + ++i) { + pos[i] = int(pos[i] * scale); + pos[i] += spacing + add; // compute offset of each item + add = pos[i]; } - for (QHash< EffectWindow*, Data >::Iterator it = windows.begin(); - it != windows.end(); - ++it) { - Data& d = *it; + for (QHash::Iterator it = windows.begin(); + it != windows.end(); + ++it) { + Data &d = *it; int width = int(d.window->width() * scale); - d.rect = QRect(area.right() - width, area.bottom() - pos[ d.index ], width, int(d.window->height() * scale)); + d.rect = QRect(area.right() - width, area.bottom() - pos[d.index], width, int(d.window->height() * scale)); } repaintAll(); } @@ -187,4 +187,3 @@ bool ThumbnailAsideEffect::isActive() const } } // namespace - diff --git a/src/effects/thumbnailaside/thumbnailaside.h b/src/effects/thumbnailaside/thumbnailaside.h index 88d26f1ca5..957483f611 100644 --- a/src/effects/thumbnailaside/thumbnailaside.h +++ b/src/effects/thumbnailaside/thumbnailaside.h @@ -35,20 +35,24 @@ class ThumbnailAsideEffect public: ThumbnailAsideEffect(); void reconfigure(ReconfigureFlags) override; - void paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) override; + void paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) override; void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override; // for properties - int configuredMaxWidth() const { + int configuredMaxWidth() const + { return maxwidth; } - int configuredSpacing() const { + int configuredSpacing() const + { return spacing; } - qreal configuredOpacity() const { + qreal configuredOpacity() const + { return opacity; } - int configuredScreen() const { + int configuredScreen() const + { return screen; } bool isActive() const override; @@ -57,18 +61,20 @@ private Q_SLOTS: void toggleCurrentThumbnail(); void slotWindowClosed(KWin::EffectWindow *w); void slotWindowFrameGeometryChanged(KWin::EffectWindow *w, const QRect &old); - void slotWindowDamaged(KWin::EffectWindow* w, const QRegion& damage); + void slotWindowDamaged(KWin::EffectWindow *w, const QRegion &damage); void repaintAll(); + private: - void addThumbnail(EffectWindow* w); - void removeThumbnail(EffectWindow* w); + 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) + struct Data + { + EffectWindow *window; // the same like the key in the hash (makes code simpler) int index; QRect rect; }; - QHash< EffectWindow*, Data > windows; + QHash windows; int maxwidth; int spacing; double opacity; diff --git a/src/effects/thumbnailaside/thumbnailaside_config.cpp b/src/effects/thumbnailaside/thumbnailaside_config.cpp index 6a3ea0810e..8238da99a7 100644 --- a/src/effects/thumbnailaside/thumbnailaside_config.cpp +++ b/src/effects/thumbnailaside/thumbnailaside_config.cpp @@ -6,40 +6,42 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "thumbnailaside_config.h" + +#include + // KConfigSkeleton #include "thumbnailasideconfig.h" -#include #include #include -#include -#include #include #include +#include #include +#include -#include #include +#include K_PLUGIN_CLASS(KWin::ThumbnailAsideEffectConfig) namespace KWin { -ThumbnailAsideEffectConfigForm::ThumbnailAsideEffectConfigForm(QWidget* parent) : QWidget(parent) +ThumbnailAsideEffectConfigForm::ThumbnailAsideEffectConfigForm(QWidget *parent) + : QWidget(parent) { setupUi(this); } -ThumbnailAsideEffectConfig::ThumbnailAsideEffectConfig(QWidget* parent, const QVariantList& args) : - KCModule(parent, args) +ThumbnailAsideEffectConfig::ThumbnailAsideEffectConfig(QWidget *parent, const QVariantList &args) + : KCModule(parent, args) { m_ui = new ThumbnailAsideEffectConfigForm(this); - QVBoxLayout* layout = new QVBoxLayout(this); + QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(m_ui); @@ -55,7 +57,7 @@ ThumbnailAsideEffectConfig::ThumbnailAsideEffectConfig(QWidget* parent, const QV m_actionCollection->setConfigGroup(QStringLiteral("ThumbnailAside")); m_actionCollection->setConfigGlobal(true); - QAction* a = m_actionCollection->addAction(QStringLiteral("ToggleCurrentThumbnail")); + QAction *a = m_actionCollection->addAction(QStringLiteral("ToggleCurrentThumbnail")); a->setText(i18n("Toggle Thumbnail for Current Window")); a->setProperty("isConfigurationAction", true); KGlobalAccel::self()->setDefaultShortcut(a, QList() << (Qt::META | Qt::CTRL | Qt::Key_T)); diff --git a/src/effects/thumbnailaside/thumbnailaside_config.h b/src/effects/thumbnailaside/thumbnailaside_config.h index 5f8ab08c34..41a51bf2e8 100644 --- a/src/effects/thumbnailaside/thumbnailaside_config.h +++ b/src/effects/thumbnailaside/thumbnailaside_config.h @@ -23,21 +23,21 @@ class ThumbnailAsideEffectConfigForm : public QWidget, public Ui::ThumbnailAside { Q_OBJECT public: - explicit ThumbnailAsideEffectConfigForm(QWidget* parent); + explicit ThumbnailAsideEffectConfigForm(QWidget *parent); }; class ThumbnailAsideEffectConfig : public KCModule { Q_OBJECT public: - explicit ThumbnailAsideEffectConfig(QWidget* parent = nullptr, const QVariantList& args = QVariantList()); + explicit ThumbnailAsideEffectConfig(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); ~ThumbnailAsideEffectConfig() override; void save() override; private: - ThumbnailAsideEffectConfigForm* m_ui; - KActionCollection* m_actionCollection; + ThumbnailAsideEffectConfigForm *m_ui; + KActionCollection *m_actionCollection; }; } // namespace diff --git a/src/effects/touchpoints/touchpoints.cpp b/src/effects/touchpoints/touchpoints.cpp index 6965e6c9e9..94023072f0 100644 --- a/src/effects/touchpoints/touchpoints.cpp +++ b/src/effects/touchpoints/touchpoints.cpp @@ -40,8 +40,7 @@ static const Qt::GlobalColor s_colors[] = { Qt::gray, Qt::darkBlue, Qt::darkRed, - Qt::darkGreen -}; + Qt::darkGreen}; Qt::GlobalColor TouchPointsEffect::colorForId(quint32 id) { @@ -95,7 +94,7 @@ bool TouchPointsEffect::touchUp(qint32 id, quint32 time) return false; } -void TouchPointsEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) +void TouchPointsEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) { int time = 0; if (m_lastPresentTime.count()) { @@ -121,7 +120,7 @@ void TouchPointsEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::mi effects->prePaintScreen(data, presentTime); } -void TouchPointsEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) +void TouchPointsEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) { effects->paintScreen(mask, region, data); @@ -167,7 +166,7 @@ void TouchPointsEffect::repaint() QRegion dirtyRegion; const int radius = m_ringMaxSize + m_lineWidth; for (auto it = m_points.constBegin(), end = m_points.constEnd(); it != end; ++it) { - dirtyRegion |= QRect(it->pos.x() - radius, it->pos.y() - radius, 2*radius, 2*radius); + dirtyRegion |= QRect(it->pos.x() - radius, it->pos.y() - radius, 2 * radius, 2 * radius); } effects->addRepaint(dirtyRegion); } @@ -178,7 +177,7 @@ bool TouchPointsEffect::isActive() const return !m_points.isEmpty(); } -void TouchPointsEffect::drawCircle(const QColor& color, float cx, float cy, float r) +void TouchPointsEffect::drawCircle(const QColor &color, float cx, float cy, float r) { if (effects->isOpenGLCompositing()) drawCircleGl(color, cx, cy, r); @@ -186,30 +185,30 @@ void TouchPointsEffect::drawCircle(const QColor& color, float cx, float cy, floa drawCircleQPainter(color, cx, cy, r); } -void TouchPointsEffect::paintScreenSetup(int mask, QRegion region, ScreenPaintData& data) +void TouchPointsEffect::paintScreenSetup(int mask, QRegion region, ScreenPaintData &data) { if (effects->isOpenGLCompositing()) paintScreenSetupGl(mask, region, data); } -void TouchPointsEffect::paintScreenFinish(int mask, QRegion region, ScreenPaintData& data) +void TouchPointsEffect::paintScreenFinish(int mask, QRegion region, ScreenPaintData &data) { if (effects->isOpenGLCompositing()) paintScreenFinishGl(mask, region, data); } -void TouchPointsEffect::drawCircleGl(const QColor& color, float cx, float cy, float r) +void TouchPointsEffect::drawCircleGl(const QColor &color, float cx, float cy, float r) { static const int num_segments = 80; static const float theta = 2 * 3.1415926 / float(num_segments); - static const float c = cosf(theta); //precalculate the sine and cosine + static const float c = cosf(theta); // precalculate the sine and cosine static const float s = sinf(theta); float t; - float x = r;//we start at angle = 0 + float x = r; // we start at angle = 0 float y = 0; - GLVertexBuffer* vbo = GLVertexBuffer::streamingBuffer(); + GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); vbo->reset(); vbo->setUseColor(true); vbo->setColor(color); @@ -217,8 +216,8 @@ void TouchPointsEffect::drawCircleGl(const QColor& color, float cx, float cy, fl verts.reserve(num_segments * 2); for (int ii = 0; ii < num_segments; ++ii) { - verts << x + cx << y + cy;//output vertex - //apply the rotation matrix + verts << x + cx << y + cy; // output vertex + // apply the rotation matrix t = x; x = c * x - s * y; y = s * t + c * y; @@ -246,7 +245,7 @@ void TouchPointsEffect::paintScreenSetupGl(int, QRegion, ScreenPaintData &data) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } -void TouchPointsEffect::paintScreenFinishGl(int, QRegion, ScreenPaintData&) +void TouchPointsEffect::paintScreenFinishGl(int, QRegion, ScreenPaintData &) { glDisable(GL_BLEND); @@ -254,4 +253,3 @@ void TouchPointsEffect::paintScreenFinishGl(int, QRegion, ScreenPaintData&) } } // namespace - diff --git a/src/effects/touchpoints/touchpoints.h b/src/effects/touchpoints/touchpoints.h index 35cc23f048..eaa402e25b 100644 --- a/src/effects/touchpoints/touchpoints.h +++ b/src/effects/touchpoints/touchpoints.h @@ -27,8 +27,8 @@ class TouchPointsEffect public: TouchPointsEffect(); ~TouchPointsEffect() override; - void prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) override; - void paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) override; + void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; + void paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) override; void postPaintScreen() override; bool isActive() const override; bool touchDown(qint32 id, const QPointF &pos, quint32 time) override; @@ -36,32 +36,36 @@ public: bool touchUp(qint32 id, quint32 time) override; // for properties - qreal lineWidth() const { + qreal lineWidth() const + { return m_lineWidth; } - int ringLife() const { + int ringLife() const + { return m_ringLife; } - int ringSize() const { + int ringSize() const + { return m_ringMaxSize; } - int ringCount() const { + 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); + 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 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); + void drawCircleGl(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); @@ -70,7 +74,8 @@ private: int m_ringLife = 300; float m_ringMaxSize = 20.0; - struct TouchPoint { + struct TouchPoint + { QPointF pos; int time = 0; bool press; @@ -80,7 +85,6 @@ private: QHash m_latestPositions; QHash m_colors; std::chrono::milliseconds m_lastPresentTime = std::chrono::milliseconds::zero(); - }; } // namespace diff --git a/src/effects/trackmouse/trackmouse.cpp b/src/effects/trackmouse/trackmouse.cpp index 97fb816e60..237c95c67d 100644 --- a/src/effects/trackmouse/trackmouse.cpp +++ b/src/effects/trackmouse/trackmouse.cpp @@ -15,9 +15,9 @@ #include "trackmouseconfig.h" #include +#include #include #include -#include #include #include @@ -35,7 +35,7 @@ TrackMouseEffect::TrackMouseEffect() { initConfig(); m_texture[0] = m_texture[1] = nullptr; - if ( effects->isOpenGLCompositing() || effects->compositingType() == QPainterCompositing) + if (effects->isOpenGLCompositing() || effects->compositingType() == QPainterCompositing) m_angleBase = 90.0; m_mousePolling = false; @@ -57,7 +57,8 @@ TrackMouseEffect::~TrackMouseEffect() if (m_mousePolling) effects->stopMousePolling(); for (int i = 0; i < 2; ++i) { - delete m_texture[i]; m_texture[i] = nullptr; + delete m_texture[i]; + m_texture[i] = nullptr; } } @@ -79,27 +80,27 @@ void TrackMouseEffect::reconfigure(ReconfigureFlags) effects->startMousePolling(); m_mousePolling = true; } else if (m_mousePolling) { - effects->stopMousePolling(); + effects->stopMousePolling(); m_mousePolling = false; } } -void TrackMouseEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) +void TrackMouseEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) { QTime t = QTime::currentTime(); m_angle = ((t.second() % 4) * m_angleBase) + (t.msec() / 1000.0 * m_angleBase); m_lastRect[0].moveCenter(cursorPos()); m_lastRect[1].moveCenter(cursorPos()); - data.paint |= m_lastRect[0].adjusted(-1,-1,1,1); + data.paint |= m_lastRect[0].adjusted(-1, -1, 1, 1); effects->prePaintScreen(data, presentTime); } -void TrackMouseEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) +void TrackMouseEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) { - effects->paintScreen(mask, region, data); // paint normal screen + effects->paintScreen(mask, region, data); // paint normal screen - if ( effects->isOpenGLCompositing() && m_texture[0] && m_texture[1]) { + if (effects->isOpenGLCompositing() && m_texture[0] && m_texture[1]) { ShaderBinder binder(ShaderTrait::MapTexture); GLShader *shader(binder.shader()); if (!shader) { @@ -108,12 +109,12 @@ void TrackMouseEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintD glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); QMatrix4x4 matrix(data.projectionMatrix()); - const QPointF p = m_lastRect[0].topLeft() + QPoint(m_lastRect[0].width()/2.0, m_lastRect[0].height()/2.0); - const float x = p.x()*data.xScale() + data.xTranslation(); - const float y = p.y()*data.yScale() + data.yTranslation(); + const QPointF p = m_lastRect[0].topLeft() + QPoint(m_lastRect[0].width() / 2.0, m_lastRect[0].height() / 2.0); + const float x = p.x() * data.xScale() + data.xTranslation(); + const float y = p.y() * data.yScale() + data.yTranslation(); for (int i = 0; i < 2; ++i) { matrix.translate(x, y, 0.0); - matrix.rotate(i ? -2*m_angle : m_angle, 0, 0, 1.0); + matrix.rotate(i ? -2 * m_angle : m_angle, 0, 0, 1.0); matrix.translate(-x, -y, 0.0); QMatrix4x4 mvp(matrix); mvp.translate(m_lastRect[i].x(), m_lastRect[i].y()); @@ -125,11 +126,11 @@ void TrackMouseEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintD glDisable(GL_BLEND); } else if (effects->compositingType() == QPainterCompositing && !m_image[0].isNull() && !m_image[1].isNull()) { QPainter *painter = effects->scenePainter(); - const QPointF p = m_lastRect[0].topLeft() + QPoint(m_lastRect[0].width()/2.0, m_lastRect[0].height()/2.0); + const QPointF p = m_lastRect[0].topLeft() + QPoint(m_lastRect[0].width() / 2.0, m_lastRect[0].height() / 2.0); for (int i = 0; i < 2; ++i) { painter->save(); painter->translate(p.x(), p.y()); - painter->rotate(i ? -2*m_angle : m_angle); + painter->rotate(i ? -2 * m_angle : m_angle); painter->translate(-p.x(), -p.y()); painter->drawImage(m_lastRect[i], m_image[i]); painter->restore(); @@ -139,7 +140,7 @@ void TrackMouseEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintD void TrackMouseEffect::postPaintScreen() { - effects->addRepaint(m_lastRect[0].adjusted(-1,-1,1,1)); + effects->addRepaint(m_lastRect[0].adjusted(-1, -1, 1, 1)); effects->postPaintScreen(); } @@ -183,7 +184,7 @@ void TrackMouseEffect::toggle() effects->addRepaint(m_lastRect[0].adjusted(-1, -1, 1, 1)); } -void TrackMouseEffect::slotMouseChanged(const QPoint&, const QPoint&, +void TrackMouseEffect::slotMouseChanged(const QPoint &, const QPoint &, Qt::MouseButtons, Qt::MouseButtons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers) { @@ -228,7 +229,7 @@ void TrackMouseEffect::loadTexture() return; for (int i = 0; i < 2; ++i) { - if ( effects->isOpenGLCompositing()) { + if (effects->isOpenGLCompositing()) { QImage img(f[i]); m_texture[i] = new GLTexture(img); m_lastRect[i].setSize(img.size()); diff --git a/src/effects/trackmouse/trackmouse.h b/src/effects/trackmouse/trackmouse.h index cf96456a1c..670c7f3aaf 100644 --- a/src/effects/trackmouse/trackmouse.h +++ b/src/effects/trackmouse/trackmouse.h @@ -29,24 +29,27 @@ class TrackMouseEffect public: TrackMouseEffect(); ~TrackMouseEffect() override; - void prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) override; - void paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) override; + void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; + void paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) override; void postPaintScreen() override; void reconfigure(ReconfigureFlags) override; bool isActive() const override; // for properties - Qt::KeyboardModifiers modifiers() const { + Qt::KeyboardModifiers modifiers() const + { return m_modifiers; } - bool isMousePolling() const { + 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); + 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(); @@ -54,8 +57,8 @@ private: bool m_mousePolling; float m_angle; float m_angleBase; - GLTexture* m_texture[2]; - QAction* m_action; + GLTexture *m_texture[2]; + QAction *m_action; QImage m_image[2]; Qt::KeyboardModifiers m_modifiers; diff --git a/src/effects/trackmouse/trackmouse_config.cpp b/src/effects/trackmouse/trackmouse_config.cpp index 3774589c99..680badc68b 100644 --- a/src/effects/trackmouse/trackmouse_config.cpp +++ b/src/effects/trackmouse/trackmouse_config.cpp @@ -7,24 +7,24 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - #include "trackmouse_config.h" +#include + // KConfigSkeleton #include "trackmouseconfig.h" +#include + +#include +#include +#include +#include + +#include +#include +#include + K_PLUGIN_CLASS(KWin::TrackMouseEffectConfig) namespace KWin @@ -32,17 +32,18 @@ namespace KWin static const QString s_toggleTrackMouseActionName = QStringLiteral("TrackMouse"); -TrackMouseEffectConfigForm::TrackMouseEffectConfigForm(QWidget* parent) : QWidget(parent) +TrackMouseEffectConfigForm::TrackMouseEffectConfigForm(QWidget *parent) + : QWidget(parent) { setupUi(this); } -TrackMouseEffectConfig::TrackMouseEffectConfig(QWidget* parent, const QVariantList& args) : - KCModule(parent, args) +TrackMouseEffectConfig::TrackMouseEffectConfig(QWidget *parent, const QVariantList &args) + : KCModule(parent, args) { TrackMouseConfig::instance(KWIN_CONFIG); m_ui = new TrackMouseEffectConfigForm(this); - QVBoxLayout* layout = new QVBoxLayout(this); + QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(m_ui); addConfig(TrackMouseConfig::self(), m_ui); diff --git a/src/effects/trackmouse/trackmouse_config.h b/src/effects/trackmouse/trackmouse_config.h index 9701806ca8..447c9133a2 100644 --- a/src/effects/trackmouse/trackmouse_config.h +++ b/src/effects/trackmouse/trackmouse_config.h @@ -24,14 +24,14 @@ class TrackMouseEffectConfigForm : public QWidget, public Ui::TrackMouseEffectCo { Q_OBJECT public: - explicit TrackMouseEffectConfigForm(QWidget* parent); + explicit TrackMouseEffectConfigForm(QWidget *parent); }; class TrackMouseEffectConfig : public KCModule { Q_OBJECT public: - explicit TrackMouseEffectConfig(QWidget* parent = nullptr, const QVariantList& args = QVariantList()); + explicit TrackMouseEffectConfig(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); ~TrackMouseEffectConfig() override; public Q_SLOTS: @@ -40,9 +40,10 @@ public Q_SLOTS: void defaults() override; private Q_SLOTS: void shortcutChanged(const QKeySequence &seq); + private: - TrackMouseEffectConfigForm* m_ui; - KActionCollection* m_actionCollection; + TrackMouseEffectConfigForm *m_ui; + KActionCollection *m_actionCollection; }; } // namespace diff --git a/src/effects/wobblywindows/wobblywindows.cpp b/src/effects/wobblywindows/wobblywindows.cpp index b904aed668..029594454c 100644 --- a/src/effects/wobblywindows/wobblywindows.cpp +++ b/src/effects/wobblywindows/wobblywindows.cpp @@ -7,7 +7,6 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "wobblywindows.h" #include "wobblywindowsconfig.h" @@ -21,9 +20,9 @@ //#define VERBOSE_MODE #if defined COMPUTE_STATS && !defined VERBOSE_MODE -# ifdef __GNUC__ -# warning "You enable COMPUTE_STATS without VERBOSE_MODE, computed stats will not be printed." -# endif +#ifdef __GNUC__ +#warning "You enable COMPUTE_STATS without VERBOSE_MODE, computed stats will not be printed." +#endif #endif Q_LOGGING_CATEGORY(KWIN_WOBBLYWINDOWS, "kwin_effect_wobblywindows", QtWarningMsg) @@ -31,7 +30,8 @@ Q_LOGGING_CATEGORY(KWIN_WOBBLYWINDOWS, "kwin_effect_wobblywindows", QtWarningMsg namespace KWin { -struct ParameterSet { +struct ParameterSet +{ qreal stiffness; qreal drag; qreal move_factor; @@ -117,7 +117,7 @@ static const ParameterSet set_4 = { 0.5, }; -static const ParameterSet pset[5] = { set_0, set_1, set_2, set_3, set_4 }; +static const ParameterSet pset[5] = {set_0, set_1, set_2, set_3, set_4}; WobblyWindowsEffect::WobblyWindowsEffect() { @@ -135,7 +135,7 @@ WobblyWindowsEffect::~WobblyWindowsEffect() // we should be empty at this point... // emit a warning and clean the list. qCDebug(KWIN_WOBBLYWINDOWS) << "Windows list not empty. Left items : " << windows.count(); - QHash< const EffectWindow*, WindowWobblyInfos >::iterator i; + QHash::iterator i; for (i = windows.begin(); i != windows.end(); ++i) { freeWobblyInfo(i.value()); } @@ -180,11 +180,11 @@ void WobblyWindowsEffect::reconfigure(ReconfigureFlags) m_resizeWobble = WobblyWindowsConfig::resizeWobble(); #if defined VERBOSE_MODE - qCDebug(KWIN_WOBBLYWINDOWS) << "Parameters :\n" << - "grid(" << m_stiffness << ", " << m_drag << ", " << m_move_factor << ")\n" << - "velocity(" << m_minVelocity << ", " << m_maxVelocity << ", " << m_stopVelocity << ")\n" << - "acceleration(" << m_minAcceleration << ", " << m_maxAcceleration << ", " << m_stopAcceleration << ")\n" << - "tesselation(" << m_xTesselation << ", " << m_yTesselation << ")"; + qCDebug(KWIN_WOBBLYWINDOWS) << "Parameters :\n" + << "grid(" << m_stiffness << ", " << m_drag << ", " << m_move_factor << ")\n" + << "velocity(" << m_minVelocity << ", " << m_maxVelocity << ", " << m_stopVelocity << ")\n" + << "acceleration(" << m_minAcceleration << ", " << m_maxAcceleration << ", " << m_stopAcceleration << ")\n" + << "tesselation(" << m_xTesselation << ", " << m_yTesselation << ")"; #endif } @@ -193,7 +193,7 @@ bool WobblyWindowsEffect::supported() return DeformEffect::supported() && effects->animationsSupported(); } -void WobblyWindowsEffect::setParameterSet(const ParameterSet& pset) +void WobblyWindowsEffect::setParameterSet(const ParameterSet &pset) { m_stiffness = pset.stiffness; m_drag = pset.drag; @@ -202,12 +202,12 @@ void WobblyWindowsEffect::setParameterSet(const ParameterSet& pset) m_xTesselation = pset.xTesselation; m_yTesselation = pset.yTesselation; - m_minVelocity = pset.minVelocity; - m_maxVelocity = pset.maxVelocity; - m_stopVelocity = pset.stopVelocity; - m_minAcceleration = pset.minAcceleration; - m_maxAcceleration = pset.maxAcceleration; - m_stopAcceleration = pset.stopAcceleration; + m_minVelocity = pset.minVelocity; + m_maxVelocity = pset.maxVelocity; + m_stopVelocity = pset.stopVelocity; + m_minAcceleration = pset.minAcceleration; + m_maxAcceleration = pset.maxAcceleration; + m_stopAcceleration = pset.stopAcceleration; } void WobblyWindowsEffect::setVelocityThreshold(qreal m_minVelocity) @@ -230,7 +230,7 @@ void WobblyWindowsEffect::setDrag(qreal drag) m_drag = drag; } -void WobblyWindowsEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) +void WobblyWindowsEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) { // We need to mark the screen windows as transformed. Otherwise the whole // screen won't be repainted, resulting in artefacts. @@ -244,7 +244,7 @@ void WobblyWindowsEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono:: static const std::chrono::milliseconds integrationStep(10); -void WobblyWindowsEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime) +void WobblyWindowsEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) { auto infoIt = windows.find(w); if (infoIt != windows.end()) { @@ -272,7 +272,7 @@ void WobblyWindowsEffect::deform(EffectWindow *w, int mask, WindowPaintData &dat if (!(mask & PAINT_SCREEN_TRANSFORMED) && windows.contains(w)) { quads = quads.makeRegularGrid(m_xTesselation, m_yTesselation); - WindowWobblyInfos& wwi = windows[w]; + WindowWobblyInfos &wwi = windows[w]; int tx = w->frameGeometry().x(); int ty = w->frameGeometry().y(); int width = w->frameGeometry().width(); @@ -283,14 +283,14 @@ void WobblyWindowsEffect::deform(EffectWindow *w, int mask, WindowPaintData &dat double bottom = w->height(); for (int i = 0; i < quads.count(); ++i) { for (int j = 0; j < 4; ++j) { - WindowVertex& v = quads[i][j]; + WindowVertex &v = quads[i][j]; Pair uv = {v.x() / width, v.y() / height}; Pair newPos = computeBezierPoint(wwi, uv); v.move(newPos.x - tx, newPos.y - ty); } - left = qMin(left, quads[i].left()); - top = qMin(top, quads[i].top()); - right = qMax(right, quads[i].right()); + left = qMin(left, quads[i].left()); + top = qMin(top, quads[i].top()); + right = qMax(right, quads[i].right()); bottom = qMax(bottom, quads[i].bottom()); } QRectF dirtyRect( @@ -329,25 +329,33 @@ void WobblyWindowsEffect::slotWindowStepUserMovedResized(EffectWindow *w, const { Q_UNUSED(geometry) if (windows.contains(w)) { - WindowWobblyInfos& wwi = windows[w]; + WindowWobblyInfos &wwi = windows[w]; const QRect rect = w->frameGeometry(); - if (rect.y() != wwi.resize_original_rect.y()) wwi.can_wobble_top = true; - if (rect.x() != wwi.resize_original_rect.x()) wwi.can_wobble_left = true; - if (rect.right() != wwi.resize_original_rect.right()) wwi.can_wobble_right = true; - if (rect.bottom() != wwi.resize_original_rect.bottom()) wwi.can_wobble_bottom = true; + if (rect.y() != wwi.resize_original_rect.y()) + wwi.can_wobble_top = true; + if (rect.x() != wwi.resize_original_rect.x()) + wwi.can_wobble_left = true; + if (rect.right() != wwi.resize_original_rect.right()) + wwi.can_wobble_right = true; + if (rect.bottom() != wwi.resize_original_rect.bottom()) + wwi.can_wobble_bottom = true; } } void WobblyWindowsEffect::slotWindowFinishUserMovedResized(EffectWindow *w) { if (windows.contains(w)) { - WindowWobblyInfos& wwi = windows[w]; + WindowWobblyInfos &wwi = windows[w]; wwi.status = Free; const QRect rect = w->frameGeometry(); - if (rect.y() != wwi.resize_original_rect.y()) wwi.can_wobble_top = true; - if (rect.x() != wwi.resize_original_rect.x()) wwi.can_wobble_left = true; - if (rect.right() != wwi.resize_original_rect.right()) wwi.can_wobble_right = true; - if (rect.bottom() != wwi.resize_original_rect.bottom()) wwi.can_wobble_bottom = true; + if (rect.y() != wwi.resize_original_rect.y()) + wwi.can_wobble_top = true; + if (rect.x() != wwi.resize_original_rect.x()) + wwi.can_wobble_left = true; + if (rect.right() != wwi.resize_original_rect.right()) + wwi.can_wobble_right = true; + if (rect.bottom() != wwi.resize_original_rect.bottom()) + wwi.can_wobble_bottom = true; } } @@ -364,16 +372,20 @@ void WobblyWindowsEffect::slotWindowMaximizeStateChanged(EffectWindow *w, bool h } if (windows.contains(w)) { - WindowWobblyInfos& wwi = windows[w]; + WindowWobblyInfos &wwi = windows[w]; const QRect rect = w->frameGeometry(); - if (rect.y() != wwi.resize_original_rect.y()) wwi.can_wobble_top = true; - if (rect.x() != wwi.resize_original_rect.x()) wwi.can_wobble_left = true; - if (rect.right() != wwi.resize_original_rect.right()) wwi.can_wobble_right = true; - if (rect.bottom() != wwi.resize_original_rect.bottom()) wwi.can_wobble_bottom = true; + if (rect.y() != wwi.resize_original_rect.y()) + wwi.can_wobble_top = true; + if (rect.x() != wwi.resize_original_rect.x()) + wwi.can_wobble_left = true; + if (rect.right() != wwi.resize_original_rect.right()) + wwi.can_wobble_right = true; + if (rect.bottom() != wwi.resize_original_rect.bottom()) + wwi.can_wobble_bottom = true; } } -void WobblyWindowsEffect::startMovedResized(EffectWindow* w) +void WobblyWindowsEffect::startMovedResized(EffectWindow *w) { if (!windows.contains(w)) { WindowWobblyInfos new_wwi; @@ -382,9 +394,9 @@ void WobblyWindowsEffect::startMovedResized(EffectWindow* w) redirect(w); } - WindowWobblyInfos& wwi = windows[w]; + WindowWobblyInfos &wwi = windows[w]; wwi.status = Moving; - const QRectF& rect = w->frameGeometry(); + const QRectF &rect = w->frameGeometry(); qreal x_increment = rect.width() / (wwi.width - 1.0); qreal y_increment = rect.height() / (wwi.height - 1.0); @@ -415,7 +427,7 @@ void WobblyWindowsEffect::startMovedResized(EffectWindow* w) } } -void WobblyWindowsEffect::stepMovedResized(EffectWindow* w) +void WobblyWindowsEffect::stepMovedResized(EffectWindow *w) { QRect new_geometry = w->frameGeometry(); if (!windows.contains(w)) { @@ -424,29 +436,28 @@ void WobblyWindowsEffect::stepMovedResized(EffectWindow* w) windows[w] = new_wwi; } - WindowWobblyInfos& wwi = windows[w]; + WindowWobblyInfos &wwi = windows[w]; wwi.status = Free; QRect maximized_area = effects->clientArea(MaximizeArea, w); - bool throb_direction_out = (new_geometry.top() == maximized_area.top() && new_geometry.bottom() == maximized_area.bottom()) || - (new_geometry.left() == maximized_area.left() && new_geometry.right() == maximized_area.right()); + bool throb_direction_out = (new_geometry.top() == maximized_area.top() && new_geometry.bottom() == maximized_area.bottom()) || (new_geometry.left() == maximized_area.left() && new_geometry.right() == maximized_area.right()); qreal magnitude = throb_direction_out ? 10 : -30; // a small throb out when maximized, a larger throb inwards when restored for (unsigned int j = 0; j < wwi.height; ++j) { for (unsigned int i = 0; i < wwi.width; ++i) { - Pair v = { magnitude*(i / qreal(wwi.width - 1) - 0.5), magnitude*(j / qreal(wwi.height - 1) - 0.5) }; - wwi.velocity[j*wwi.width+i] = v; + Pair v = {magnitude * (i / qreal(wwi.width - 1) - 0.5), magnitude * (j / qreal(wwi.height - 1) - 0.5)}; + wwi.velocity[j * wwi.width + i] = v; } } // constrain the middle of the window, so that any asymetry wont cause it to drift off-center for (unsigned int j = 1; j < wwi.height - 1; ++j) { for (unsigned int i = 1; i < wwi.width - 1; ++i) { - wwi.constraint[j*wwi.width+i] = true; + wwi.constraint[j * wwi.width + i] = true; } } } -void WobblyWindowsEffect::initWobblyInfo(WindowWobblyInfos& wwi, QRect geometry) const +void WobblyWindowsEffect::initWobblyInfo(WindowWobblyInfos &wwi, QRect geometry) const { wwi.count = 4 * 4; wwi.width = 4; @@ -467,7 +478,7 @@ void WobblyWindowsEffect::initWobblyInfo(WindowWobblyInfos& wwi, QRect geometry) wwi.status = Moving; wwi.clock = std::chrono::duration_cast( - std::chrono::steady_clock::now().time_since_epoch()); + std::chrono::steady_clock::now().time_since_epoch()); qreal x = geometry.x(), y = geometry.y(); qreal width = geometry.width(), height = geometry.height(); @@ -503,7 +514,7 @@ void WobblyWindowsEffect::initWobblyInfo(WindowWobblyInfos& wwi, QRect geometry) } } -void WobblyWindowsEffect::freeWobblyInfo(WindowWobblyInfos& wwi) const +void WobblyWindowsEffect::freeWobblyInfo(WindowWobblyInfos &wwi) const { delete[] wwi.origin; delete[] wwi.position; @@ -515,7 +526,7 @@ void WobblyWindowsEffect::freeWobblyInfo(WindowWobblyInfos& wwi) const delete[] wwi.bezierSurface; } -WobblyWindowsEffect::Pair WobblyWindowsEffect::computeBezierPoint(const WindowWobblyInfos& wwi, Pair point) const +WobblyWindowsEffect::Pair WobblyWindowsEffect::computeBezierPoint(const WindowWobblyInfos &wwi, Pair point) const { const qreal tx = point.x; const qreal ty = point.y; @@ -550,7 +561,7 @@ WobblyWindowsEffect::Pair WobblyWindowsEffect::computeBezierPoint(const WindowWo namespace { -static inline void fixVectorBounds(WobblyWindowsEffect::Pair& vec, qreal min, qreal max) +static inline void fixVectorBounds(WobblyWindowsEffect::Pair &vec, qreal min, qreal max) { if (fabs(vec.x) < min) { vec.x = 0.0; @@ -574,7 +585,7 @@ static inline void fixVectorBounds(WobblyWindowsEffect::Pair& vec, qreal min, qr } #if defined COMPUTE_STATS -static inline void computeVectorBounds(WobblyWindowsEffect::Pair& vec, WobblyWindowsEffect::Pair& bound) +static inline void computeVectorBounds(WobblyWindowsEffect::Pair &vec, WobblyWindowsEffect::Pair &bound) { if (fabs(vec.x) < bound.x) { bound.x = fabs(vec.x); @@ -591,24 +602,24 @@ static inline void computeVectorBounds(WobblyWindowsEffect::Pair& vec, WobblyWin } // close the anonymous namespace -bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) +bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow *w, qreal time) { QRectF rect = w->frameGeometry(); - WindowWobblyInfos& wwi = windows[w]; + WindowWobblyInfos &wwi = windows[w]; qreal x_length = rect.width() / (wwi.width - 1.0); qreal y_length = rect.height() / (wwi.height - 1.0); #if defined VERBOSE_MODE qCDebug(KWIN_WOBBLYWINDOWS) << "time " << time; - qCDebug(KWIN_WOBBLYWINDOWS) << "increment x " << x_length << " // y" << y_length; + qCDebug(KWIN_WOBBLYWINDOWS) << "increment x " << x_length << " // y" << y_length; #endif Pair origine = {rect.x(), rect.y()}; for (unsigned int j = 0; j < wwi.height; ++j) { for (unsigned int i = 0; i < wwi.width; ++i) { - wwi.origin[wwi.width*j + i] = origine; + wwi.origin[wwi.width * j + i] = origine; if (i != wwi.width - 2) { origine.x += x_length; } else { @@ -639,10 +650,10 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) Pair window_pos = wwi.origin[0]; Pair current_pos = wwi.position[0]; Pair move = {window_pos.x - current_pos.x, window_pos.y - current_pos.y}; - Pair accel = {move.x*m_stiffness, move.y*m_stiffness}; + Pair accel = {move.x * m_stiffness, move.y * m_stiffness}; wwi.acceleration[0] = accel; } else { - Pair& pos = wwi.position[0]; + Pair &pos = wwi.position[0]; neibourgs[0] = wwi.position[1]; neibourgs[1] = wwi.position[wwi.width]; @@ -657,16 +668,16 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) // top-right - if (wwi.constraint[wwi.width-1]) { - Pair window_pos = wwi.origin[wwi.width-1]; - Pair current_pos = wwi.position[wwi.width-1]; + if (wwi.constraint[wwi.width - 1]) { + Pair window_pos = wwi.origin[wwi.width - 1]; + Pair current_pos = wwi.position[wwi.width - 1]; Pair move = {window_pos.x - current_pos.x, window_pos.y - current_pos.y}; - Pair accel = {move.x*m_stiffness, move.y*m_stiffness}; - wwi.acceleration[wwi.width-1] = accel; + Pair accel = {move.x * m_stiffness, move.y * m_stiffness}; + wwi.acceleration[wwi.width - 1] = accel; } else { - Pair& pos = wwi.position[wwi.width-1]; - neibourgs[0] = wwi.position[wwi.width-2]; - neibourgs[1] = wwi.position[2*wwi.width-1]; + Pair &pos = wwi.position[wwi.width - 1]; + neibourgs[0] = wwi.position[wwi.width - 2]; + neibourgs[1] = wwi.position[2 * wwi.width - 1]; acceleration.x = (x_length - (pos.x - neibourgs[0].x)) * m_stiffness + (neibourgs[1].x - pos.x) * m_stiffness; acceleration.y = ((neibourgs[1].y - pos.y) - y_length) * m_stiffness + (neibourgs[0].y - pos.y) * m_stiffness; @@ -674,21 +685,21 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) acceleration.x /= 2; acceleration.y /= 2; - wwi.acceleration[wwi.width-1] = acceleration; + wwi.acceleration[wwi.width - 1] = acceleration; } // bottom-left - if (wwi.constraint[wwi.width*(wwi.height-1)]) { - Pair window_pos = wwi.origin[wwi.width*(wwi.height-1)]; - Pair current_pos = wwi.position[wwi.width*(wwi.height-1)]; + if (wwi.constraint[wwi.width * (wwi.height - 1)]) { + Pair window_pos = wwi.origin[wwi.width * (wwi.height - 1)]; + Pair current_pos = wwi.position[wwi.width * (wwi.height - 1)]; Pair move = {window_pos.x - current_pos.x, window_pos.y - current_pos.y}; - Pair accel = {move.x*m_stiffness, move.y*m_stiffness}; - wwi.acceleration[wwi.width*(wwi.height-1)] = accel; + Pair accel = {move.x * m_stiffness, move.y * m_stiffness}; + wwi.acceleration[wwi.width * (wwi.height - 1)] = accel; } else { - Pair& pos = wwi.position[wwi.width*(wwi.height-1)]; - neibourgs[0] = wwi.position[wwi.width*(wwi.height-1)+1]; - neibourgs[1] = wwi.position[wwi.width*(wwi.height-2)]; + Pair &pos = wwi.position[wwi.width * (wwi.height - 1)]; + neibourgs[0] = wwi.position[wwi.width * (wwi.height - 1) + 1]; + neibourgs[1] = wwi.position[wwi.width * (wwi.height - 2)]; acceleration.x = ((neibourgs[0].x - pos.x) - x_length) * m_stiffness + (neibourgs[1].x - pos.x) * m_stiffness; acceleration.y = (y_length - (pos.y - neibourgs[1].y)) * m_stiffness + (neibourgs[0].y - pos.y) * m_stiffness; @@ -696,21 +707,21 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) acceleration.x /= 2; acceleration.y /= 2; - wwi.acceleration[wwi.width*(wwi.height-1)] = acceleration; + wwi.acceleration[wwi.width * (wwi.height - 1)] = acceleration; } // bottom-right - if (wwi.constraint[wwi.count-1]) { - Pair window_pos = wwi.origin[wwi.count-1]; - Pair current_pos = wwi.position[wwi.count-1]; + if (wwi.constraint[wwi.count - 1]) { + Pair window_pos = wwi.origin[wwi.count - 1]; + Pair current_pos = wwi.position[wwi.count - 1]; Pair move = {window_pos.x - current_pos.x, window_pos.y - current_pos.y}; - Pair accel = {move.x*m_stiffness, move.y*m_stiffness}; - wwi.acceleration[wwi.count-1] = accel; + Pair accel = {move.x * m_stiffness, move.y * m_stiffness}; + wwi.acceleration[wwi.count - 1] = accel; } else { - Pair& pos = wwi.position[wwi.count-1]; - neibourgs[0] = wwi.position[wwi.count-2]; - neibourgs[1] = wwi.position[wwi.width*(wwi.height-1)-1]; + Pair &pos = wwi.position[wwi.count - 1]; + neibourgs[0] = wwi.position[wwi.count - 2]; + neibourgs[1] = wwi.position[wwi.width * (wwi.height - 1) - 1]; acceleration.x = (x_length - (pos.x - neibourgs[0].x)) * m_stiffness + (neibourgs[1].x - pos.x) * m_stiffness; acceleration.y = (y_length - (pos.y - neibourgs[1].y)) * m_stiffness + (neibourgs[0].y - pos.y) * m_stiffness; @@ -718,10 +729,9 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) acceleration.x /= 2; acceleration.y /= 2; - wwi.acceleration[wwi.count-1] = acceleration; + wwi.acceleration[wwi.count - 1] = acceleration; } - // for borders // top border @@ -730,13 +740,13 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) Pair window_pos = wwi.origin[i]; Pair current_pos = wwi.position[i]; Pair move = {window_pos.x - current_pos.x, window_pos.y - current_pos.y}; - Pair accel = {move.x*m_stiffness, move.y*m_stiffness}; + Pair accel = {move.x * m_stiffness, move.y * m_stiffness}; wwi.acceleration[i] = accel; } else { - Pair& pos = wwi.position[i]; - neibourgs[0] = wwi.position[i-1]; - neibourgs[1] = wwi.position[i+1]; - neibourgs[2] = wwi.position[i+wwi.width]; + Pair &pos = wwi.position[i]; + neibourgs[0] = wwi.position[i - 1]; + neibourgs[1] = wwi.position[i + 1]; + neibourgs[2] = wwi.position[i + wwi.width]; acceleration.x = (x_length - (pos.x - neibourgs[0].x)) * m_stiffness + ((neibourgs[1].x - pos.x) - x_length) * m_stiffness + (neibourgs[2].x - pos.x) * m_stiffness; acceleration.y = ((neibourgs[2].y - pos.y) - y_length) * m_stiffness + (neibourgs[0].y - pos.y) * m_stiffness + (neibourgs[1].y - pos.y) * m_stiffness; @@ -754,13 +764,13 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) Pair window_pos = wwi.origin[i]; Pair current_pos = wwi.position[i]; Pair move = {window_pos.x - current_pos.x, window_pos.y - current_pos.y}; - Pair accel = {move.x*m_stiffness, move.y*m_stiffness}; + Pair accel = {move.x * m_stiffness, move.y * m_stiffness}; wwi.acceleration[i] = accel; } else { - Pair& pos = wwi.position[i]; - neibourgs[0] = wwi.position[i-1]; - neibourgs[1] = wwi.position[i+1]; - neibourgs[2] = wwi.position[i-wwi.width]; + Pair &pos = wwi.position[i]; + neibourgs[0] = wwi.position[i - 1]; + neibourgs[1] = wwi.position[i + 1]; + neibourgs[2] = wwi.position[i - wwi.width]; acceleration.x = (x_length - (pos.x - neibourgs[0].x)) * m_stiffness + ((neibourgs[1].x - pos.x) - x_length) * m_stiffness + (neibourgs[2].x - pos.x) * m_stiffness; acceleration.y = (y_length - (pos.y - neibourgs[2].y)) * m_stiffness + (neibourgs[0].y - pos.y) * m_stiffness + (neibourgs[1].y - pos.y) * m_stiffness; @@ -773,18 +783,18 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) } // left border - for (unsigned int i = wwi.width; i < wwi.width*(wwi.height - 1); i += wwi.width) { + for (unsigned int i = wwi.width; i < wwi.width * (wwi.height - 1); i += wwi.width) { if (wwi.constraint[i]) { Pair window_pos = wwi.origin[i]; Pair current_pos = wwi.position[i]; Pair move = {window_pos.x - current_pos.x, window_pos.y - current_pos.y}; - Pair accel = {move.x*m_stiffness, move.y*m_stiffness}; + Pair accel = {move.x * m_stiffness, move.y * m_stiffness}; wwi.acceleration[i] = accel; } else { - Pair& pos = wwi.position[i]; - neibourgs[0] = wwi.position[i+1]; - neibourgs[1] = wwi.position[i-wwi.width]; - neibourgs[2] = wwi.position[i+wwi.width]; + Pair &pos = wwi.position[i]; + neibourgs[0] = wwi.position[i + 1]; + neibourgs[1] = wwi.position[i - wwi.width]; + neibourgs[2] = wwi.position[i + wwi.width]; acceleration.x = ((neibourgs[0].x - pos.x) - x_length) * m_stiffness + (neibourgs[1].x - pos.x) * m_stiffness + (neibourgs[2].x - pos.x) * m_stiffness; acceleration.y = (y_length - (pos.y - neibourgs[1].y)) * m_stiffness + ((neibourgs[2].y - pos.y) - y_length) * m_stiffness + (neibourgs[0].y - pos.y) * m_stiffness; @@ -802,13 +812,13 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) Pair window_pos = wwi.origin[i]; Pair current_pos = wwi.position[i]; Pair move = {window_pos.x - current_pos.x, window_pos.y - current_pos.y}; - Pair accel = {move.x*m_stiffness, move.y*m_stiffness}; + Pair accel = {move.x * m_stiffness, move.y * m_stiffness}; wwi.acceleration[i] = accel; } else { - Pair& pos = wwi.position[i]; - neibourgs[0] = wwi.position[i-1]; - neibourgs[1] = wwi.position[i-wwi.width]; - neibourgs[2] = wwi.position[i+wwi.width]; + Pair &pos = wwi.position[i]; + neibourgs[0] = wwi.position[i - 1]; + neibourgs[1] = wwi.position[i - wwi.width]; + neibourgs[2] = wwi.position[i + wwi.width]; acceleration.x = (x_length - (pos.x - neibourgs[0].x)) * m_stiffness + (neibourgs[1].x - pos.x) * m_stiffness + (neibourgs[2].x - pos.x) * m_stiffness; acceleration.y = (y_length - (pos.y - neibourgs[1].y)) * m_stiffness + ((neibourgs[2].y - pos.y) - y_length) * m_stiffness + (neibourgs[0].y - pos.y) * m_stiffness; @@ -829,23 +839,17 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) Pair window_pos = wwi.origin[index]; Pair current_pos = wwi.position[index]; Pair move = {window_pos.x - current_pos.x, window_pos.y - current_pos.y}; - Pair accel = {move.x*m_stiffness, move.y*m_stiffness}; + Pair accel = {move.x * m_stiffness, move.y * m_stiffness}; wwi.acceleration[index] = accel; } else { - Pair& pos = wwi.position[index]; - neibourgs[0] = wwi.position[index-1]; - neibourgs[1] = wwi.position[index+1]; - neibourgs[2] = wwi.position[index-wwi.width]; - neibourgs[3] = wwi.position[index+wwi.width]; + Pair &pos = wwi.position[index]; + neibourgs[0] = wwi.position[index - 1]; + neibourgs[1] = wwi.position[index + 1]; + neibourgs[2] = wwi.position[index - wwi.width]; + neibourgs[3] = wwi.position[index + wwi.width]; - acceleration.x = ((neibourgs[0].x - pos.x) - x_length) * m_stiffness + - (x_length - (pos.x - neibourgs[1].x)) * m_stiffness + - (neibourgs[2].x - pos.x) * m_stiffness + - (neibourgs[3].x - pos.x) * m_stiffness; - acceleration.y = (y_length - (pos.y - neibourgs[2].y)) * m_stiffness + - ((neibourgs[3].y - pos.y) - y_length) * m_stiffness + - (neibourgs[0].y - pos.y) * m_stiffness + - (neibourgs[1].y - pos.y) * m_stiffness; + acceleration.x = ((neibourgs[0].x - pos.x) - x_length) * m_stiffness + (x_length - (pos.x - neibourgs[1].x)) * m_stiffness + (neibourgs[2].x - pos.x) * m_stiffness + (neibourgs[3].x - pos.x) * m_stiffness; + acceleration.y = (y_length - (pos.y - neibourgs[2].y)) * m_stiffness + ((neibourgs[3].y - pos.y) - y_length) * m_stiffness + (neibourgs[0].y - pos.y) * m_stiffness + (neibourgs[1].y - pos.y) * m_stiffness; acceleration.x /= 4; acceleration.y /= 4; @@ -871,7 +875,7 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) computeVectorBounds(acc, accBound); #endif - Pair& vel = wwi.velocity[i]; + Pair &vel = wwi.velocity[i]; vel.x = acc.x * time + vel.x * m_drag; vel.y = acc.y * time + vel.y * m_drag; @@ -882,8 +886,8 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) // compute the new pos of each vertex. for (unsigned int i = 0; i < wwi.count; ++i) { - Pair& pos = wwi.position[i]; - Pair& vel = wwi.velocity[i]; + Pair &pos = wwi.position[i]; + Pair &vel = wwi.velocity[i]; fixVectorBounds(vel, m_minVelocity, m_maxVelocity); #if defined COMPUTE_STATS @@ -897,7 +901,7 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) #if defined VERBOSE_MODE if (wwi.constraint[i]) { - qCDebug(KWIN_WOBBLYWINDOWS) << "Constraint point ** vel : " << vel.x << "," << vel.y << " ** move : " << vel.x*time << "," << vel.y*time; + qCDebug(KWIN_WOBBLYWINDOWS) << "Constraint point ** vel : " << vel.x << "," << vel.y << " ** move : " << vel.x * time << "," << vel.y * time; } #endif } @@ -905,29 +909,29 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) if (!wwi.can_wobble_top) { for (unsigned int i = 0; i < wwi.width; ++i) for (unsigned j = 0; j < wwi.width - 1; ++j) - wwi.position[i+wwi.width*j].y = wwi.origin[i+wwi.width*j].y; + wwi.position[i + wwi.width * j].y = wwi.origin[i + wwi.width * j].y; } if (!wwi.can_wobble_bottom) { for (unsigned int i = wwi.width * (wwi.height - 1); i < wwi.count; ++i) for (unsigned j = 0; j < wwi.width - 1; ++j) - wwi.position[i-wwi.width*j].y = wwi.origin[i-wwi.width*j].y; + wwi.position[i - wwi.width * j].y = wwi.origin[i - wwi.width * j].y; } if (!wwi.can_wobble_left) { for (unsigned int i = 0; i < wwi.count; i += wwi.width) for (unsigned j = 0; j < wwi.width - 1; ++j) - wwi.position[i+j].x = wwi.origin[i+j].x; + wwi.position[i + j].x = wwi.origin[i + j].x; } if (!wwi.can_wobble_right) { for (unsigned int i = wwi.width - 1; i < wwi.count; i += wwi.width) for (unsigned j = 0; j < wwi.width - 1; ++j) - wwi.position[i-j].x = wwi.origin[i-j].x; + wwi.position[i - j].x = wwi.origin[i - j].x; } #if defined VERBOSE_MODE -# if defined COMPUTE_STATS +#if defined COMPUTE_STATS qCDebug(KWIN_WOBBLYWINDOWS) << "Acceleration bounds (" << accBound.x << ", " << accBound.y << ")"; qCDebug(KWIN_WOBBLYWINDOWS) << "Velocity bounds (" << velBound.x << ", " << velBound.y << ")"; -# endif +#endif qCDebug(KWIN_WOBBLYWINDOWS) << "sum_acc : " << acc_sum << " *** sum_vel :" << vel_sum; #endif @@ -943,76 +947,72 @@ bool WobblyWindowsEffect::updateWindowWobblyDatas(EffectWindow* w, qreal time) return true; } -void WobblyWindowsEffect::heightRingLinearMean(Pair** data_pointer, WindowWobblyInfos& wwi) +void WobblyWindowsEffect::heightRingLinearMean(Pair **data_pointer, WindowWobblyInfos &wwi) { - Pair* data = *data_pointer; + Pair *data = *data_pointer; Pair neibourgs[8]; // for corners // top-left { - Pair& res = wwi.buffer[0]; + Pair &res = wwi.buffer[0]; Pair vit = data[0]; neibourgs[0] = data[1]; neibourgs[1] = data[wwi.width]; - neibourgs[2] = data[wwi.width+1]; + neibourgs[2] = data[wwi.width + 1]; res.x = (neibourgs[0].x + neibourgs[1].x + neibourgs[2].x + 3.0 * vit.x) / 6.0; res.y = (neibourgs[0].y + neibourgs[1].y + neibourgs[2].y + 3.0 * vit.y) / 6.0; } - // top-right { - Pair& res = wwi.buffer[wwi.width-1]; - Pair vit = data[wwi.width-1]; - neibourgs[0] = data[wwi.width-2]; - neibourgs[1] = data[2*wwi.width-1]; - neibourgs[2] = data[2*wwi.width-2]; + Pair &res = wwi.buffer[wwi.width - 1]; + Pair vit = data[wwi.width - 1]; + neibourgs[0] = data[wwi.width - 2]; + neibourgs[1] = data[2 * wwi.width - 1]; + neibourgs[2] = data[2 * wwi.width - 2]; res.x = (neibourgs[0].x + neibourgs[1].x + neibourgs[2].x + 3.0 * vit.x) / 6.0; res.y = (neibourgs[0].y + neibourgs[1].y + neibourgs[2].y + 3.0 * vit.y) / 6.0; } - // bottom-left { - Pair& res = wwi.buffer[wwi.width*(wwi.height-1)]; - Pair vit = data[wwi.width*(wwi.height-1)]; - neibourgs[0] = data[wwi.width*(wwi.height-1)+1]; - neibourgs[1] = data[wwi.width*(wwi.height-2)]; - neibourgs[2] = data[wwi.width*(wwi.height-2)+1]; + Pair &res = wwi.buffer[wwi.width * (wwi.height - 1)]; + Pair vit = data[wwi.width * (wwi.height - 1)]; + neibourgs[0] = data[wwi.width * (wwi.height - 1) + 1]; + neibourgs[1] = data[wwi.width * (wwi.height - 2)]; + neibourgs[2] = data[wwi.width * (wwi.height - 2) + 1]; res.x = (neibourgs[0].x + neibourgs[1].x + neibourgs[2].x + 3.0 * vit.x) / 6.0; res.y = (neibourgs[0].y + neibourgs[1].y + neibourgs[2].y + 3.0 * vit.y) / 6.0; } - // bottom-right { - Pair& res = wwi.buffer[wwi.count-1]; - Pair vit = data[wwi.count-1]; - neibourgs[0] = data[wwi.count-2]; - neibourgs[1] = data[wwi.width*(wwi.height-1)-1]; - neibourgs[2] = data[wwi.width*(wwi.height-1)-2]; + Pair &res = wwi.buffer[wwi.count - 1]; + Pair vit = data[wwi.count - 1]; + neibourgs[0] = data[wwi.count - 2]; + neibourgs[1] = data[wwi.width * (wwi.height - 1) - 1]; + neibourgs[2] = data[wwi.width * (wwi.height - 1) - 2]; res.x = (neibourgs[0].x + neibourgs[1].x + neibourgs[2].x + 3.0 * vit.x) / 6.0; res.y = (neibourgs[0].y + neibourgs[1].y + neibourgs[2].y + 3.0 * vit.y) / 6.0; } - // for borders // top border for (unsigned int i = 1; i < wwi.width - 1; ++i) { - Pair& res = wwi.buffer[i]; + Pair &res = wwi.buffer[i]; Pair vit = data[i]; - neibourgs[0] = data[i-1]; - neibourgs[1] = data[i+1]; - neibourgs[2] = data[i+wwi.width]; - neibourgs[3] = data[i+wwi.width-1]; - neibourgs[4] = data[i+wwi.width+1]; + neibourgs[0] = data[i - 1]; + neibourgs[1] = data[i + 1]; + neibourgs[2] = data[i + wwi.width]; + neibourgs[3] = data[i + wwi.width - 1]; + neibourgs[4] = data[i + wwi.width + 1]; res.x = (neibourgs[0].x + neibourgs[1].x + neibourgs[2].x + neibourgs[3].x + neibourgs[4].x + 5.0 * vit.x) / 10.0; res.y = (neibourgs[0].y + neibourgs[1].y + neibourgs[2].y + neibourgs[3].y + neibourgs[4].y + 5.0 * vit.y) / 10.0; @@ -1020,27 +1020,27 @@ void WobblyWindowsEffect::heightRingLinearMean(Pair** data_pointer, WindowWobbly // bottom border for (unsigned int i = wwi.width * (wwi.height - 1) + 1; i < wwi.count - 1; ++i) { - Pair& res = wwi.buffer[i]; + Pair &res = wwi.buffer[i]; Pair vit = data[i]; - neibourgs[0] = data[i-1]; - neibourgs[1] = data[i+1]; - neibourgs[2] = data[i-wwi.width]; - neibourgs[3] = data[i-wwi.width-1]; - neibourgs[4] = data[i-wwi.width+1]; + neibourgs[0] = data[i - 1]; + neibourgs[1] = data[i + 1]; + neibourgs[2] = data[i - wwi.width]; + neibourgs[3] = data[i - wwi.width - 1]; + neibourgs[4] = data[i - wwi.width + 1]; res.x = (neibourgs[0].x + neibourgs[1].x + neibourgs[2].x + neibourgs[3].x + neibourgs[4].x + 5.0 * vit.x) / 10.0; res.y = (neibourgs[0].y + neibourgs[1].y + neibourgs[2].y + neibourgs[3].y + neibourgs[4].y + 5.0 * vit.y) / 10.0; } // left border - for (unsigned int i = wwi.width; i < wwi.width*(wwi.height - 1); i += wwi.width) { - Pair& res = wwi.buffer[i]; + for (unsigned int i = wwi.width; i < wwi.width * (wwi.height - 1); i += wwi.width) { + Pair &res = wwi.buffer[i]; Pair vit = data[i]; - neibourgs[0] = data[i+1]; - neibourgs[1] = data[i-wwi.width]; - neibourgs[2] = data[i+wwi.width]; - neibourgs[3] = data[i-wwi.width+1]; - neibourgs[4] = data[i+wwi.width+1]; + neibourgs[0] = data[i + 1]; + neibourgs[1] = data[i - wwi.width]; + neibourgs[2] = data[i + wwi.width]; + neibourgs[3] = data[i - wwi.width + 1]; + neibourgs[4] = data[i + wwi.width + 1]; res.x = (neibourgs[0].x + neibourgs[1].x + neibourgs[2].x + neibourgs[3].x + neibourgs[4].x + 5.0 * vit.x) / 10.0; res.y = (neibourgs[0].y + neibourgs[1].y + neibourgs[2].y + neibourgs[3].y + neibourgs[4].y + 5.0 * vit.y) / 10.0; @@ -1048,13 +1048,13 @@ void WobblyWindowsEffect::heightRingLinearMean(Pair** data_pointer, WindowWobbly // right border for (unsigned int i = 2 * wwi.width - 1; i < wwi.count - 1; i += wwi.width) { - Pair& res = wwi.buffer[i]; + Pair &res = wwi.buffer[i]; Pair vit = data[i]; - neibourgs[0] = data[i-1]; - neibourgs[1] = data[i-wwi.width]; - neibourgs[2] = data[i+wwi.width]; - neibourgs[3] = data[i-wwi.width-1]; - neibourgs[4] = data[i+wwi.width-1]; + neibourgs[0] = data[i - 1]; + neibourgs[1] = data[i - wwi.width]; + neibourgs[2] = data[i + wwi.width]; + neibourgs[3] = data[i - wwi.width - 1]; + neibourgs[4] = data[i + wwi.width - 1]; res.x = (neibourgs[0].x + neibourgs[1].x + neibourgs[2].x + neibourgs[3].x + neibourgs[4].x + 5.0 * vit.x) / 10.0; res.y = (neibourgs[0].y + neibourgs[1].y + neibourgs[2].y + neibourgs[3].y + neibourgs[4].y + 5.0 * vit.y) / 10.0; @@ -1065,23 +1065,23 @@ void WobblyWindowsEffect::heightRingLinearMean(Pair** data_pointer, WindowWobbly for (unsigned int i = 1; i < wwi.width - 1; ++i) { unsigned int index = i + j * wwi.width; - Pair& res = wwi.buffer[index]; - Pair& vit = data[index]; - neibourgs[0] = data[index-1]; - neibourgs[1] = data[index+1]; - neibourgs[2] = data[index-wwi.width]; - neibourgs[3] = data[index+wwi.width]; - neibourgs[4] = data[index-wwi.width-1]; - neibourgs[5] = data[index-wwi.width+1]; - neibourgs[6] = data[index+wwi.width-1]; - neibourgs[7] = data[index+wwi.width+1]; + Pair &res = wwi.buffer[index]; + Pair &vit = data[index]; + neibourgs[0] = data[index - 1]; + neibourgs[1] = data[index + 1]; + neibourgs[2] = data[index - wwi.width]; + neibourgs[3] = data[index + wwi.width]; + neibourgs[4] = data[index - wwi.width - 1]; + neibourgs[5] = data[index - wwi.width + 1]; + neibourgs[6] = data[index + wwi.width - 1]; + neibourgs[7] = data[index + wwi.width + 1]; res.x = (neibourgs[0].x + neibourgs[1].x + neibourgs[2].x + neibourgs[3].x + neibourgs[4].x + neibourgs[5].x + neibourgs[6].x + neibourgs[7].x + 8.0 * vit.x) / 16.0; res.y = (neibourgs[0].y + neibourgs[1].y + neibourgs[2].y + neibourgs[3].y + neibourgs[4].y + neibourgs[5].y + neibourgs[6].y + neibourgs[7].y + 8.0 * vit.y) / 16.0; } } - Pair* tmp = data; + Pair *tmp = data; *data_pointer = wwi.buffer; wwi.buffer = tmp; } diff --git a/src/effects/wobblywindows/wobblywindows.h b/src/effects/wobblywindows/wobblywindows.h index 5039aa3412..2e7abb5121 100644 --- a/src/effects/wobblywindows/wobblywindows.h +++ b/src/effects/wobblywindows/wobblywindows.h @@ -38,17 +38,17 @@ class WobblyWindowsEffect : public DeformEffect Q_PROPERTY(bool moveWobble READ isMoveWobble) Q_PROPERTY(bool resizeWobble READ isResizeWobble) public: - WobblyWindowsEffect(); ~WobblyWindowsEffect() override; void reconfigure(ReconfigureFlags) override; - void prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) override; - void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime) override; + void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; + void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) override; void postPaintScreen() override; bool isActive() const override; - int requestedEffectChainPosition() 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. @@ -61,7 +61,8 @@ public: void setVelocityThreshold(qreal velocityThreshold); void setMoveFactor(qreal factor); - struct Pair { + struct Pair + { qreal x; qreal y; }; @@ -74,43 +75,56 @@ public: static bool supported(); // for properties - qreal stiffness() const { + qreal stiffness() const + { return m_stiffness; } - qreal drag() const { + qreal drag() const + { return m_drag; } - qreal moveFactor() const { + qreal moveFactor() const + { return m_move_factor; } - qreal xTesselation() const { + qreal xTesselation() const + { return m_xTesselation; } - qreal yTesselation() const { + qreal yTesselation() const + { return m_yTesselation; } - qreal minVelocity() const { + qreal minVelocity() const + { return m_minVelocity; } - qreal maxVelocity() const { + qreal maxVelocity() const + { return m_maxVelocity; } - qreal stopVelocity() const { + qreal stopVelocity() const + { return m_stopVelocity; } - qreal minAcceleration() const { + qreal minAcceleration() const + { return m_minAcceleration; } - qreal maxAcceleration() const { + qreal maxAcceleration() const + { return m_maxAcceleration; } - qreal stopAcceleration() const { + qreal stopAcceleration() const + { return m_stopAcceleration; } - bool isMoveWobble() const { + bool isMoveWobble() const + { return m_moveWobble; } - bool isResizeWobble() const { + bool isResizeWobble() const + { return m_resizeWobble; } @@ -124,26 +138,27 @@ public Q_SLOTS: void slotWindowMaximizeStateChanged(KWin::EffectWindow *w, bool horizontal, bool vertical); private: - void startMovedResized(EffectWindow* w); - void stepMovedResized(EffectWindow* w); - bool updateWindowWobblyDatas(EffectWindow* w, qreal time); + 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; + 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; + bool *constraint; unsigned int width; unsigned int height; unsigned int count; - Pair* bezierSurface; + Pair *bezierSurface; unsigned int bezierWidth; unsigned int bezierHeight; unsigned int bezierCount; @@ -157,7 +172,7 @@ private: std::chrono::milliseconds clock; }; - QHash< const EffectWindow*, WindowWobblyInfos > windows; + QHash windows; QRegion m_updateRegion; @@ -181,14 +196,14 @@ private: bool m_moveWobble; bool m_resizeWobble; - void initWobblyInfo(WindowWobblyInfos& wwi, QRect geometry) const; - void freeWobblyInfo(WindowWobblyInfos& wwi) const; + void initWobblyInfo(WindowWobblyInfos &wwi, QRect geometry) const; + void freeWobblyInfo(WindowWobblyInfos &wwi) const; - WobblyWindowsEffect::Pair computeBezierPoint(const WindowWobblyInfos& wwi, Pair point) const; + WobblyWindowsEffect::Pair computeBezierPoint(const WindowWobblyInfos &wwi, Pair point) const; - static void heightRingLinearMean(Pair** data_pointer, WindowWobblyInfos& wwi); + static void heightRingLinearMean(Pair **data_pointer, WindowWobblyInfos &wwi); - void setParameterSet(const ParameterSet& pset); + void setParameterSet(const ParameterSet &pset); }; } // namespace KWin diff --git a/src/effects/wobblywindows/wobblywindows_config.cpp b/src/effects/wobblywindows/wobblywindows_config.cpp index 66cd2ca703..f788d14637 100644 --- a/src/effects/wobblywindows/wobblywindows_config.cpp +++ b/src/effects/wobblywindows/wobblywindows_config.cpp @@ -7,16 +7,17 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "wobblywindows_config.h" + +#include + // KConfigSkeleton #include "wobblywindowsconfig.h" -#include #include #include -#include #include +#include K_PLUGIN_CLASS(KWin::WobblyWindowsEffectConfig) @@ -26,7 +27,8 @@ namespace KWin //----------------------------------------------------------------------------- // WARNING: This is (kinda) copied from wobblywindows.cpp -struct ParameterSet { +struct ParameterSet +{ int stiffness; int drag; int move_factor; @@ -35,39 +37,34 @@ struct ParameterSet { static const ParameterSet set_0 = { 15, 80, - 10 -}; + 10}; static const ParameterSet set_1 = { 10, 85, - 10 -}; + 10}; static const ParameterSet set_2 = { 6, 90, - 10 -}; + 10}; static const ParameterSet set_3 = { 3, 92, - 20 -}; + 20}; static const ParameterSet set_4 = { 1, 97, - 25 -}; + 25}; -ParameterSet pset[5] = { set_0, set_1, set_2, set_3, set_4 }; +ParameterSet pset[5] = {set_0, set_1, set_2, set_3, set_4}; //----------------------------------------------------------------------------- -WobblyWindowsEffectConfig::WobblyWindowsEffectConfig(QWidget* parent, const QVariantList& args) : - KCModule(parent, args) +WobblyWindowsEffectConfig::WobblyWindowsEffectConfig(QWidget *parent, const QVariantList &args) + : KCModule(parent, args) { WobblyWindowsConfig::instance(KWIN_CONFIG); m_ui.setupUi(this); diff --git a/src/effects/wobblywindows/wobblywindows_config.h b/src/effects/wobblywindows/wobblywindows_config.h index 4228d99f58..781b3735df 100644 --- a/src/effects/wobblywindows/wobblywindows_config.h +++ b/src/effects/wobblywindows/wobblywindows_config.h @@ -15,7 +15,6 @@ #include "ui_wobblywindows_config.h" - namespace KWin { @@ -23,7 +22,7 @@ class WobblyWindowsEffectConfig : public KCModule { Q_OBJECT public: - explicit WobblyWindowsEffectConfig(QWidget* parent = nullptr, const QVariantList& args = QVariantList()); + explicit WobblyWindowsEffectConfig(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); ~WobblyWindowsEffectConfig() override; public Q_SLOTS: diff --git a/src/effects/zoom/zoom.cpp b/src/effects/zoom/zoom.cpp index d1d9589b86..fe3ad9ffb7 100644 --- a/src/effects/zoom/zoom.cpp +++ b/src/effects/zoom/zoom.cpp @@ -16,13 +16,13 @@ #include "accessibilityintegration.h" #endif +#include +#include +#include #include #include #include #include -#include -#include -#include #include @@ -37,7 +37,7 @@ ZoomEffect::ZoomEffect() , zoomFactor(1.25) , mouseTracking(MouseTrackingProportional) , mousePointer(MousePointerScale) - , focusDelay(350) // in milliseconds + , focusDelay(350) // in milliseconds , isMouseHidden(false) , xMove(0) , yMove(0) @@ -45,7 +45,7 @@ ZoomEffect::ZoomEffect() , lastPresentTime(std::chrono::milliseconds::zero()) { initConfig(); - QAction* a = nullptr; + QAction *a = nullptr; a = KStandardAction::zoomIn(this, SLOT(zoomIn()), this); KGlobalAccel::self()->setDefaultShortcut(a, QList() << (Qt::META | Qt::Key_Equal)); KGlobalAccel::self()->setShortcut(a, QList() << (Qt::META | Qt::Key_Equal)); @@ -232,7 +232,7 @@ void ZoomEffect::reconfigure(ReconfigureFlags) } } -void ZoomEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) +void ZoomEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) { if (zoom != target_zoom) { int time = 0; @@ -242,9 +242,9 @@ void ZoomEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseco const float zoomDist = qAbs(target_zoom - source_zoom); if (target_zoom > zoom) - zoom = qMin(zoom + ((zoomDist * time) / animationTime(150*zoomFactor)), target_zoom); + zoom = qMin(zoom + ((zoomDist * time) / animationTime(150 * zoomFactor)), target_zoom); else - zoom = qMax(zoom - ((zoomDist * time) / animationTime(150*zoomFactor)), target_zoom); + zoom = qMax(zoom - ((zoomDist * time) / animationTime(150 * zoomFactor)), target_zoom); } if (zoom == 1.0) { @@ -257,17 +257,17 @@ void ZoomEffect::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseco effects->prePaintScreen(data, presentTime); } -void ZoomEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) +void ZoomEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) { if (zoom != 1.0) { data *= QVector2D(zoom, zoom); const QSize screenSize = effects->virtualScreenSize(); // mouse-tracking allows navigation of the zoom-area using the mouse. - switch(mouseTracking) { + switch (mouseTracking) { case MouseTrackingProportional: - data.setXTranslation(- int(cursorPoint.x() * (zoom - 1.0))); - data.setYTranslation(- int(cursorPoint.y() * (zoom - 1.0))); + data.setXTranslation(-int(cursorPoint.x() * (zoom - 1.0))); + data.setYTranslation(-int(cursorPoint.y() * (zoom - 1.0))); prevPoint = cursorPoint; break; case MouseTrackingCentred: @@ -278,27 +278,27 @@ void ZoomEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData& d data.setYTranslation(qMin(0, qMax(int(screenSize.height() - screenSize.height() * zoom), int(screenSize.height() / 2 - prevPoint.y() * zoom)))); break; case MouseTrackingPush: { - // touching an edge of the screen moves the zoom-area in that direction. - int x = cursorPoint.x() * zoom - prevPoint.x() * (zoom - 1.0); - int y = cursorPoint.y() * zoom - prevPoint.y() * (zoom - 1.0); - int threshold = 4; - xMove = yMove = 0; - if (x < threshold) - xMove = (x - threshold) / zoom; - else if (x + threshold > screenSize.width()) - xMove = (x + threshold - screenSize.width()) / zoom; - if (y < threshold) - yMove = (y - threshold) / zoom; - else if (y + threshold > screenSize.height()) - yMove = (y + threshold - screenSize.height()) / zoom; - if (xMove) - prevPoint.setX(qMax(0, qMin(screenSize.width(), prevPoint.x() + xMove))); - if (yMove) - prevPoint.setY(qMax(0, qMin(screenSize.height(), prevPoint.y() + yMove))); - data.setXTranslation(- int(prevPoint.x() * (zoom - 1.0))); - data.setYTranslation(- int(prevPoint.y() * (zoom - 1.0))); - break; - } + // touching an edge of the screen moves the zoom-area in that direction. + int x = cursorPoint.x() * zoom - prevPoint.x() * (zoom - 1.0); + int y = cursorPoint.y() * zoom - prevPoint.y() * (zoom - 1.0); + int threshold = 4; + xMove = yMove = 0; + if (x < threshold) + xMove = (x - threshold) / zoom; + else if (x + threshold > screenSize.width()) + xMove = (x + threshold - screenSize.width()) / zoom; + if (y < threshold) + yMove = (y - threshold) / zoom; + else if (y + threshold > screenSize.height()) + yMove = (y + threshold - screenSize.height()) / zoom; + if (xMove) + prevPoint.setX(qMax(0, qMin(screenSize.width(), prevPoint.x() + xMove))); + if (yMove) + prevPoint.setY(qMax(0, qMin(screenSize.height(), prevPoint.y() + yMove))); + data.setXTranslation(-int(prevPoint.x() * (zoom - 1.0))); + data.setYTranslation(-int(prevPoint.y() * (zoom - 1.0))); + break; + } } // use the focusPoint if focus tracking is enabled @@ -311,8 +311,8 @@ void ZoomEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData& d acceptFocus = msecs > focusDelay; } if (acceptFocus) { - data.setXTranslation(- int(focusPoint.x() * (zoom - 1.0))); - data.setYTranslation(- int(focusPoint.y() * (zoom - 1.0))); + data.setXTranslation(-int(focusPoint.x() * (zoom - 1.0))); + data.setYTranslation(-int(focusPoint.y() * (zoom - 1.0))); prevPoint = focusPoint; } } @@ -420,14 +420,14 @@ void ZoomEffect::moveZoom(int x, int y) const QSize screenSize = effects->virtualScreenSize(); if (x < 0) - xMove = - qMax(1.0, screenSize.width() / zoom / moveFactor); + xMove = -qMax(1.0, screenSize.width() / zoom / moveFactor); else if (x > 0) - xMove = qMax(1.0, screenSize.width() / zoom / moveFactor); + xMove = qMax(1.0, screenSize.width() / zoom / moveFactor); else xMove = 0; if (y < 0) - yMove = - qMax(1.0, screenSize.height() / zoom / moveFactor); + yMove = -qMax(1.0, screenSize.height() / zoom / moveFactor); else if (y > 0) yMove = qMax(1.0, screenSize.height() / zoom / moveFactor); else @@ -467,8 +467,8 @@ void ZoomEffect::moveMouseToCenter() QCursor::setPos(r.x() + r.width() / 2, r.y() + r.height() / 2); } -void ZoomEffect::slotMouseChanged(const QPoint& pos, const QPoint& old, Qt::MouseButtons, - Qt::MouseButtons, Qt::KeyboardModifiers, Qt::KeyboardModifiers) +void ZoomEffect::slotMouseChanged(const QPoint &pos, const QPoint &old, Qt::MouseButtons, + Qt::MouseButtons, Qt::KeyboardModifiers, Qt::KeyboardModifiers) { if (zoom == 1.0) return; @@ -501,4 +501,3 @@ bool ZoomEffect::isActive() const } } // namespace - diff --git a/src/effects/zoom/zoom.h b/src/effects/zoom/zoom.h index cbc9ed6eba..4896cf0265 100644 --- a/src/effects/zoom/zoom.h +++ b/src/effects/zoom/zoom.h @@ -13,9 +13,9 @@ #include -#include #include #include +#include namespace KWin { @@ -42,33 +42,42 @@ public: ZoomEffect(); ~ZoomEffect() override; void reconfigure(ReconfigureFlags flags) override; - void prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) override; - void paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) override; + void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; + void paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) override; void postPaintScreen() override; bool isActive() const override; // for properties - qreal configuredZoomFactor() const { + qreal configuredZoomFactor() const + { return zoomFactor; } - int configuredMousePointer() const { + int configuredMousePointer() const + { return mousePointer; } - int configuredMouseTracking() const { + int configuredMouseTracking() const + { return mouseTracking; } bool isFocusTrackingEnabled() const; bool isTextCaretTrackingEnabled() const; - int configuredFocusDelay() const { + int configuredFocusDelay() const + { return focusDelay; } - qreal configuredMoveFactor() const { + qreal configuredMoveFactor() const + { return moveFactor; } - qreal targetZoom() const { + qreal targetZoom() const + { return target_zoom; } private Q_SLOTS: - inline void zoomIn() { zoomIn(-1.0); }; + inline void zoomIn() + { + zoomIn(-1.0); + }; void zoomIn(double to); void zoomOut(); void actualSize(); @@ -80,14 +89,16 @@ private Q_SLOTS: void moveMouseToCenter(); void timelineFrameChanged(int frame); void moveFocus(const QPoint &point); - void slotMouseChanged(const QPoint& pos, const QPoint& old, - Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, - Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); + void slotMouseChanged(const QPoint &pos, const QPoint &old, + Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, + Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers); void slotWindowDamaged(); + private: void showCursor(); void hideCursor(); void moveZoom(int x, int y); + private: GLTexture *ensureCursorTexture(); void markCursorTextureDirty(); diff --git a/src/effects/zoom/zoom_config.cpp b/src/effects/zoom/zoom_config.cpp index be6d6b2225..59c0603157 100644 --- a/src/effects/zoom/zoom_config.cpp +++ b/src/effects/zoom/zoom_config.cpp @@ -7,18 +7,19 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "zoom_config.h" + +#include + // KConfigSkeleton #include "zoomconfig.h" -#include #include #include +#include #include #include -#include #include #include @@ -28,18 +29,19 @@ K_PLUGIN_CLASS(KWin::ZoomEffectConfig) namespace KWin { -ZoomEffectConfigForm::ZoomEffectConfigForm(QWidget* parent) : QWidget(parent) +ZoomEffectConfigForm::ZoomEffectConfigForm(QWidget *parent) + : QWidget(parent) { setupUi(this); } -ZoomEffectConfig::ZoomEffectConfig(QWidget* parent, const QVariantList& args) : - KCModule(parent, args) +ZoomEffectConfig::ZoomEffectConfig(QWidget *parent, const QVariantList &args) + : KCModule(parent, args) { ZoomConfig::instance(KWIN_CONFIG); m_ui = new ZoomEffectConfigForm(this); - QVBoxLayout* layout = new QVBoxLayout(this); + QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(m_ui); addConfig(ZoomConfig::self(), m_ui); @@ -57,7 +59,7 @@ ZoomEffectConfig::ZoomEffectConfig(QWidget* parent, const QVariantList& args) : actionCollection->setConfigGroup(QStringLiteral("Zoom")); actionCollection->setConfigGlobal(true); - QAction* a; + QAction *a; a = actionCollection->addAction(KStandardAction::ZoomIn); a->setProperty("isConfigurationAction", true); KGlobalAccel::self()->setDefaultShortcut(a, QList() << (Qt::META | Qt::Key_Equal)); diff --git a/src/effects/zoom/zoom_config.h b/src/effects/zoom/zoom_config.h index a61d7586d6..6b01565ee8 100644 --- a/src/effects/zoom/zoom_config.h +++ b/src/effects/zoom/zoom_config.h @@ -15,7 +15,6 @@ #include "ui_zoom_config.h" - namespace KWin { @@ -23,21 +22,21 @@ class ZoomEffectConfigForm : public QWidget, public Ui::ZoomEffectConfigForm { Q_OBJECT public: - explicit ZoomEffectConfigForm(QWidget* parent = nullptr); + explicit ZoomEffectConfigForm(QWidget *parent = nullptr); }; class ZoomEffectConfig : public KCModule { Q_OBJECT public: - explicit ZoomEffectConfig(QWidget* parent = nullptr, const QVariantList& args = QVariantList()); + explicit ZoomEffectConfig(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); ~ZoomEffectConfig() override; public Q_SLOTS: void save() override; private: - ZoomEffectConfigForm* m_ui; + ZoomEffectConfigForm *m_ui; enum MouseTracking { MouseCentred = 0, MouseProportional = 1, diff --git a/src/events.cpp b/src/events.cpp index 1495fd89cb..1d4d1c1663 100644 --- a/src/events.cpp +++ b/src/events.cpp @@ -14,22 +14,22 @@ */ -#include "x11client.h" +#include "atoms.h" #include "cursor.h" #include "focuschain.h" #include "netinfo.h" #include "workspace.h" -#include "atoms.h" +#include "x11client.h" #if KWIN_BUILD_TABBOX #include "tabbox.h" #endif +#include "effects.h" #include "group.h" #include "rules.h" -#include "unmanaged.h" -#include "useractions.h" -#include "effects.h" #include "screenedge.h" #include "screens.h" +#include "unmanaged.h" +#include "useractions.h" #include "utils/xcbutils.h" #include @@ -58,13 +58,14 @@ #ifndef XCB_GE_GENERIC #define XCB_GE_GENERIC 35 -typedef struct xcb_ge_generic_event_t { - uint8_t response_type; /**< */ - uint8_t extension; /**< */ +typedef struct xcb_ge_generic_event_t +{ + uint8_t response_type; /**< */ + uint8_t extension; /**< */ uint16_t sequence; /**< */ uint32_t length; /**< */ uint16_t event_type; /**< */ - uint8_t pad0[22]; /**< */ + uint8_t pad0[22]; /**< */ uint32_t full_sequence; /**< */ } xcb_ge_generic_event_t; #endif @@ -79,65 +80,65 @@ namespace KWin static xcb_window_t findEventWindow(xcb_generic_event_t *event) { const uint8_t eventType = event->response_type & ~0x80; - switch(eventType) { + switch (eventType) { case XCB_KEY_PRESS: case XCB_KEY_RELEASE: - return reinterpret_cast(event)->event; + return reinterpret_cast(event)->event; case XCB_BUTTON_PRESS: case XCB_BUTTON_RELEASE: - return reinterpret_cast(event)->event; + return reinterpret_cast(event)->event; case XCB_MOTION_NOTIFY: - return reinterpret_cast(event)->event; + return reinterpret_cast(event)->event; case XCB_ENTER_NOTIFY: case XCB_LEAVE_NOTIFY: - return reinterpret_cast(event)->event; + return reinterpret_cast(event)->event; case XCB_FOCUS_IN: case XCB_FOCUS_OUT: - return reinterpret_cast(event)->event; + return reinterpret_cast(event)->event; case XCB_EXPOSE: - return reinterpret_cast(event)->window; + return reinterpret_cast(event)->window; case XCB_GRAPHICS_EXPOSURE: - return reinterpret_cast(event)->drawable; + return reinterpret_cast(event)->drawable; case XCB_NO_EXPOSURE: - return reinterpret_cast(event)->drawable; + return reinterpret_cast(event)->drawable; case XCB_VISIBILITY_NOTIFY: - return reinterpret_cast(event)->window; + return reinterpret_cast(event)->window; case XCB_CREATE_NOTIFY: - return reinterpret_cast(event)->window; + return reinterpret_cast(event)->window; case XCB_DESTROY_NOTIFY: - return reinterpret_cast(event)->window; + return reinterpret_cast(event)->window; case XCB_UNMAP_NOTIFY: - return reinterpret_cast(event)->window; + return reinterpret_cast(event)->window; case XCB_MAP_NOTIFY: - return reinterpret_cast(event)->window; + return reinterpret_cast(event)->window; case XCB_MAP_REQUEST: - return reinterpret_cast(event)->window; + return reinterpret_cast(event)->window; case XCB_REPARENT_NOTIFY: - return reinterpret_cast(event)->window; + return reinterpret_cast(event)->window; case XCB_CONFIGURE_NOTIFY: - return reinterpret_cast(event)->window; + return reinterpret_cast(event)->window; case XCB_CONFIGURE_REQUEST: - return reinterpret_cast(event)->window; + return reinterpret_cast(event)->window; case XCB_GRAVITY_NOTIFY: - return reinterpret_cast(event)->window; + return reinterpret_cast(event)->window; case XCB_RESIZE_REQUEST: - return reinterpret_cast(event)->window; + return reinterpret_cast(event)->window; case XCB_CIRCULATE_NOTIFY: case XCB_CIRCULATE_REQUEST: - return reinterpret_cast(event)->window; + return reinterpret_cast(event)->window; case XCB_PROPERTY_NOTIFY: - return reinterpret_cast(event)->window; + return reinterpret_cast(event)->window; case XCB_COLORMAP_NOTIFY: - return reinterpret_cast(event)->window; + return reinterpret_cast(event)->window; case XCB_CLIENT_MESSAGE: - return reinterpret_cast(event)->window; + return reinterpret_cast(event)->window; default: // extension handling if (eventType == Xcb::Extensions::self()->shapeNotifyEvent()) { - return reinterpret_cast(event)->affected_window; + return reinterpret_cast(event)->affected_window; } if (eventType == Xcb::Extensions::self()->damageNotifyEvent()) { - return reinterpret_cast(event)->drawable; + return reinterpret_cast(event)->drawable; } return XCB_WINDOW_NONE; } @@ -149,14 +150,14 @@ static xcb_window_t findEventWindow(xcb_generic_event_t *event) bool Workspace::workspaceEvent(xcb_generic_event_t *e) { const uint8_t eventType = e->response_type & ~0x80; - if (effects && static_cast< EffectsHandlerImpl* >(effects)->hasKeyboardGrab() - && (eventType == XCB_KEY_PRESS || eventType == XCB_KEY_RELEASE)) + if (effects && static_cast(effects)->hasKeyboardGrab() + && (eventType == XCB_KEY_PRESS || eventType == XCB_KEY_RELEASE)) return false; // let Qt process it, it'll be intercepted again in eventFilter() // events that should be handled before Clients can get them switch (eventType) { case XCB_CONFIGURE_NOTIFY: - if (reinterpret_cast(e)->event == kwinApp()->x11RootWindow()) + if (reinterpret_cast(e)->event == kwinApp()->x11RootWindow()) markXStackingOrderAsDirty(); break; }; @@ -175,7 +176,7 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e) } else if (X11Client *c = findClient(Predicate::InputIdMatch, eventWindow)) { if (c->windowEvent(e)) return true; - } else if (Unmanaged* c = findUnmanaged(eventWindow)) { + } else if (Unmanaged *c = findUnmanaged(eventWindow)) { if (c->windowEvent(e)) return true; } @@ -183,10 +184,8 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e) switch (eventType) { case XCB_CREATE_NOTIFY: { - const auto *event = reinterpret_cast(e); - if (event->parent == kwinApp()->x11RootWindow() && - !QWidget::find(event->window) && - !event->override_redirect) { + const auto *event = reinterpret_cast(e); + if (event->parent == kwinApp()->x11RootWindow() && !QWidget::find(event->window) && !event->override_redirect) { // see comments for allowClientActivation() updateXTime(); const xcb_timestamp_t t = xTime(); @@ -195,24 +194,24 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e) break; } case XCB_UNMAP_NOTIFY: { - const auto *event = reinterpret_cast(e); - return (event->event != event->window); // hide wm typical event from Qt + const auto *event = reinterpret_cast(e); + return (event->event != event->window); // hide wm typical event from Qt } case XCB_REPARENT_NOTIFY: { - //do not confuse Qt with these events. After all, _we_ are the - //window manager who does the reparenting. + // do not confuse Qt with these events. After all, _we_ are the + // window manager who does the reparenting. return true; } case XCB_MAP_REQUEST: { updateXTime(); - const auto *event = reinterpret_cast(e); + const auto *event = reinterpret_cast(e); if (X11Client *c = findClient(Predicate::WindowMatch, event->window)) { // e->xmaprequest.window is different from e->xany.window // TODO this shouldn't be necessary now c->windowEvent(e); FocusChain::self()->update(c, FocusChain::Update); - } else if ( true /*|| e->xmaprequest.parent != root */ ) { + } else if (true /*|| e->xmaprequest.parent != root */) { // NOTICE don't check for the parent being the root window, this breaks when some app unmaps // a window, changes something and immediately maps it back, without giving KWin // a chance to reparent it back to root @@ -222,16 +221,16 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e) // this code doesn't check the parent to be root. if (!createClient(event->window, false)) { xcb_map_window(kwinApp()->x11Connection(), event->window); - const uint32_t values[] = { XCB_STACK_MODE_ABOVE }; + const uint32_t values[] = {XCB_STACK_MODE_ABOVE}; xcb_configure_window(kwinApp()->x11Connection(), event->window, XCB_CONFIG_WINDOW_STACK_MODE, values); } } return true; } case XCB_MAP_NOTIFY: { - const auto *event = reinterpret_cast(e); + const auto *event = reinterpret_cast(e); if (event->override_redirect) { - Unmanaged* c = findUnmanaged(event->window); + Unmanaged *c = findUnmanaged(event->window); if (c == nullptr) c = createUnmanaged(event->window); if (c) { @@ -246,15 +245,15 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e) return c->windowEvent(e); } } - return (event->event != event->window); // hide wm typical event from Qt + return (event->event != event->window); // hide wm typical event from Qt } case XCB_CONFIGURE_REQUEST: { - const auto *event = reinterpret_cast(e); + const auto *event = reinterpret_cast(e); if (event->parent == kwinApp()->x11RootWindow()) { - uint32_t values[5] = { 0, 0, 0, 0, 0}; + uint32_t values[5] = {0, 0, 0, 0, 0}; const uint32_t value_mask = event->value_mask - & (XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT | XCB_CONFIG_WINDOW_BORDER_WIDTH); + & (XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT | XCB_CONFIG_WINDOW_BORDER_WIDTH); int i = 0; if (value_mask & XCB_CONFIG_WINDOW_X) { values[i++] = event->x; @@ -277,16 +276,16 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e) break; } case XCB_FOCUS_IN: { - const auto *event = reinterpret_cast(e); + const auto *event = reinterpret_cast(e); if (event->event == kwinApp()->x11RootWindow() - && (event->detail == XCB_NOTIFY_DETAIL_NONE || event->detail == XCB_NOTIFY_DETAIL_POINTER_ROOT || event->detail == XCB_NOTIFY_DETAIL_INFERIOR)) { + && (event->detail == XCB_NOTIFY_DETAIL_NONE || event->detail == XCB_NOTIFY_DETAIL_POINTER_ROOT || event->detail == XCB_NOTIFY_DETAIL_INFERIOR)) { Xcb::CurrentInput currentInput; updateXTime(); // focusToNull() uses xTime(), which is old now (FocusIn has no timestamp) // it seems we can "loose" focus reversions when the closing client hold a grab // => catch the typical pattern (though we don't want the focus on the root anyway) #348935 const bool lostFocusPointerToRoot = currentInput->focus == kwinApp()->x11RootWindow() && event->detail == XCB_NOTIFY_DETAIL_INFERIOR; if (!currentInput.isNull() && (currentInput->focus == XCB_WINDOW_NONE || currentInput->focus == XCB_INPUT_FOCUS_POINTER_ROOT || lostFocusPointerToRoot)) { - //kWarning( 1212 ) << "X focus set to None/PointerRoot, reseting focus" ; + // kWarning( 1212 ) << "X focus set to None/PointerRoot, reseting focus" ; AbstractClient *c = mostRecentlyActivatedClient(); if (c != nullptr) requestFocus(c, true); @@ -309,11 +308,11 @@ bool Workspace::workspaceEvent(xcb_generic_event_t *e) // Used only to filter events that need to be processed by Qt first // (e.g. keyboard input to be composed), otherwise events are // handle by the XEvent filter above -bool Workspace::workspaceEvent(QEvent* e) +bool Workspace::workspaceEvent(QEvent *e) { if ((e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease || e->type() == QEvent::ShortcutOverride) - && effects && static_cast< EffectsHandlerImpl* >(effects)->hasKeyboardGrab()) { - static_cast< EffectsHandlerImpl* >(effects)->grabbedKeyboardEvent(static_cast< QKeyEvent* >(e)); + && effects && static_cast(effects)->hasKeyboardGrab()) { + static_cast(effects)->grabbedKeyboardEvent(static_cast(e)); return true; } return false; @@ -331,14 +330,14 @@ bool X11Client::windowEvent(xcb_generic_event_t *e) if (findEventWindow(e) == window()) { // avoid doing stuff on frame or wrapper NET::Properties dirtyProperties; NET::Properties2 dirtyProperties2; - info->event(e, &dirtyProperties, &dirtyProperties2); // pass through the NET stuff + info->event(e, &dirtyProperties, &dirtyProperties2); // pass through the NET stuff if ((dirtyProperties & NET::WMName) != 0) fetchName(); if ((dirtyProperties & NET::WMIconName) != 0) fetchIconicName(); if ((dirtyProperties & NET::WMStrut) != 0 - || (dirtyProperties2 & NET::WM2ExtendedStrut) != 0) { + || (dirtyProperties2 & NET::WM2ExtendedStrut) != 0) { workspace()->updateClientArea(); } if ((dirtyProperties & NET::WMIcon) != 0) @@ -389,27 +388,27 @@ bool X11Client::windowEvent(xcb_generic_event_t *e) } const uint8_t eventType = e->response_type & ~0x80; - switch(eventType) { + switch (eventType) { case XCB_UNMAP_NOTIFY: - unmapNotifyEvent(reinterpret_cast(e)); + unmapNotifyEvent(reinterpret_cast(e)); break; case XCB_DESTROY_NOTIFY: - destroyNotifyEvent(reinterpret_cast(e)); + destroyNotifyEvent(reinterpret_cast(e)); break; case XCB_MAP_REQUEST: // this one may pass the event to workspace - return mapRequestEvent(reinterpret_cast(e)); + return mapRequestEvent(reinterpret_cast(e)); case XCB_CONFIGURE_REQUEST: - configureRequestEvent(reinterpret_cast(e)); + configureRequestEvent(reinterpret_cast(e)); break; case XCB_PROPERTY_NOTIFY: - propertyNotifyEvent(reinterpret_cast(e)); + propertyNotifyEvent(reinterpret_cast(e)); break; case XCB_KEY_PRESS: - updateUserTime(reinterpret_cast(e)->time); + updateUserTime(reinterpret_cast(e)->time); break; case XCB_BUTTON_PRESS: { - const auto *event = reinterpret_cast(e); + const auto *event = reinterpret_cast(e); updateUserTime(event->time); buttonPressEvent(event->event, event->detail, event->state, event->event_x, event->event_y, event->root_x, event->root_y, event->time); @@ -421,7 +420,7 @@ bool X11Client::windowEvent(xcb_generic_event_t *e) // would appear as user input to the currently active window break; case XCB_BUTTON_RELEASE: { - const auto *event = reinterpret_cast(e); + const auto *event = reinterpret_cast(e); // don't update user time on releases // e.g. if the user presses Alt+F2, the Alt release // would appear as user input to the currently active window @@ -430,14 +429,14 @@ bool X11Client::windowEvent(xcb_generic_event_t *e) break; } case XCB_MOTION_NOTIFY: { - const auto *event = reinterpret_cast(e); + const auto *event = reinterpret_cast(e); motionNotifyEvent(event->event, event->state, event->event_x, event->event_y, event->root_x, event->root_y); workspace()->updateFocusMousePosition(QPoint(event->root_x, event->root_y)); break; } case XCB_ENTER_NOTIFY: { - auto *event = reinterpret_cast(e); + auto *event = reinterpret_cast(e); enterNotifyEvent(event); // MotionNotify is guaranteed to be generated only if the mouse // move start and ends in the window; for cases when it only @@ -450,7 +449,7 @@ bool X11Client::windowEvent(xcb_generic_event_t *e) break; } case XCB_LEAVE_NOTIFY: { - auto *event = reinterpret_cast(e); + auto *event = reinterpret_cast(e); motionNotifyEvent(event->event, event->state, event->event_x, event->event_y, event->root_x, event->root_y); leaveNotifyEvent(event); @@ -459,18 +458,18 @@ bool X11Client::windowEvent(xcb_generic_event_t *e) break; } case XCB_FOCUS_IN: - focusInEvent(reinterpret_cast(e)); + focusInEvent(reinterpret_cast(e)); break; case XCB_FOCUS_OUT: - focusOutEvent(reinterpret_cast(e)); + focusOutEvent(reinterpret_cast(e)); break; case XCB_REPARENT_NOTIFY: break; case XCB_CLIENT_MESSAGE: - clientMessageEvent(reinterpret_cast(e)); + clientMessageEvent(reinterpret_cast(e)); break; case XCB_EXPOSE: { - xcb_expose_event_t *event = reinterpret_cast(e); + xcb_expose_event_t *event = reinterpret_cast(e); if (event->window == frameId() && !Compositor::self()->isActive()) { // TODO: only repaint required areas triggerDecorationRepaint(); @@ -478,11 +477,11 @@ bool X11Client::windowEvent(xcb_generic_event_t *e) break; } default: - if (eventType == Xcb::Extensions::self()->shapeNotifyEvent() && reinterpret_cast(e)->affected_window == window()) { - detectShape(window()); // workaround for #19644 + if (eventType == Xcb::Extensions::self()->shapeNotifyEvent() && reinterpret_cast(e)->affected_window == window()) { + detectShape(window()); // workaround for #19644 updateShape(); } - if (eventType == Xcb::Extensions::self()->damageNotifyEvent() && reinterpret_cast(e)->drawable == frameId()) + if (eventType == Xcb::Extensions::self()->damageNotifyEvent() && reinterpret_cast(e)->drawable == frameId()) damageNotifyEvent(); break; } @@ -560,7 +559,6 @@ void X11Client::destroyNotifyEvent(xcb_destroy_notify_event_t *e) destroyClient(); } - /** * Handles client messages for the client window */ @@ -577,7 +575,6 @@ void X11Client::clientMessageEvent(xcb_client_message_event_t *e) } } - /** * Handles configure requests of the client window */ @@ -593,7 +590,7 @@ void X11Client::configureRequestEvent(xcb_configure_request_event_t *e) sendSyntheticConfigureNotify(); return; } - if (isSplash()) { // no manipulations with splashscreens either + if (isSplash()) { // no manipulations with splashscreens either sendSyntheticConfigureNotify(); return; } @@ -620,7 +617,6 @@ void X11Client::configureRequestEvent(xcb_configure_request_event_t *e) // may get XRANDR resize event before kwin), but check it's still at the bottom? } - /** * Handles property changes of the client window */ @@ -629,7 +625,7 @@ void X11Client::propertyNotifyEvent(xcb_property_notify_event_t *e) Toplevel::propertyNotifyEvent(e); if (e->window != window()) return; // ignore frame/wrapper - switch(e->atom) { + switch (e->atom) { case XCB_ATOM_WM_NORMAL_HINTS: getWmNormalHints(); break; @@ -666,7 +662,6 @@ void X11Client::propertyNotifyEvent(xcb_property_notify_event_t *e) } } - void X11Client::enterNotifyEvent(xcb_enter_notify_event_t *e) { if (waylandServer()) { @@ -675,8 +670,7 @@ void X11Client::enterNotifyEvent(xcb_enter_notify_event_t *e) if (e->event != frameId()) return; // care only about entering the whole frame -#define MOUSE_DRIVEN_FOCUS (!options->focusPolicyIsReasonable() || \ - (options->focusPolicy() == Options::FocusFollowsMouse && options->isNextFocusPrefersMouse())) +#define MOUSE_DRIVEN_FOCUS (!options->focusPolicyIsReasonable() || (options->focusPolicy() == Options::FocusFollowsMouse && options->isNextFocusPrefersMouse())) if (e->mode == XCB_NOTIFY_MODE_NORMAL || (e->mode == XCB_NOTIFY_MODE_UNGRAB && MOUSE_DRIVEN_FOCUS)) { #undef MOUSE_DRIVEN_FOCUS @@ -752,30 +746,24 @@ void X11Client::establishCommandWindowGrab(uint8_t button) uint16_t x11Modifier = x11CommandAllModifier(); - unsigned int mods[ 8 ] = { + unsigned int mods[8] = { 0, XCapL, XNumL, XNumL | XCapL, XScrL, XScrL | XCapL, - XScrL | XNumL, XScrL | XNumL | XCapL - }; - for (int i = 0; - i < 8; - ++i) - m_wrapper.ungrabButton(x11Modifier | mods[ i ], button); + XScrL | XNumL, XScrL | XNumL | XCapL}; + for (int i = 0; i < 8; ++i) + m_wrapper.ungrabButton(x11Modifier | mods[i], button); } void X11Client::establishCommandAllGrab(uint8_t button) { uint16_t x11Modifier = x11CommandAllModifier(); - unsigned int mods[ 8 ] = { + unsigned int mods[8] = { 0, XCapL, XNumL, XNumL | XCapL, XScrL, XScrL | XCapL, - XScrL | XNumL, XScrL | XNumL | XCapL - }; - for (int i = 0; - i < 8; - ++i) - m_wrapper.grabButton(XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, x11Modifier | mods[ i ], button); + XScrL | XNumL, XScrL | XNumL | XCapL}; + for (int i = 0; i < 8; ++i) + m_wrapper.grabButton(XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, x11Modifier | mods[i], button); } #undef XCapL #undef XNumL @@ -803,8 +791,7 @@ void X11Client::updateMouseGrab() // // The passive grab below is established so the window can be raised or activated when it // is clicked. - if ((options->focusPolicyIsReasonable() && !isActive()) || - (options->isClickRaise() && !isMostRecentlyRaised())) { + if ((options->focusPolicyIsReasonable() && !isActive()) || (options->isClickRaise() && !isMostRecentlyRaised())) { if (options->commandWindow1() != Options::MouseNothing) { establishCommandWindowGrab(XCB_BUTTON_INDEX_1); } @@ -841,13 +828,12 @@ void X11Client::updateMouseGrab() } } -static bool modKeyDown(int state) { - const uint keyModX = (options->keyCmdAllModKey() == Qt::Key_Meta) ? - KKeyServer::modXMeta() : KKeyServer::modXAlt(); - return keyModX && (state & KKeyServer::accelModMaskX()) == keyModX; +static bool modKeyDown(int state) +{ + const uint keyModX = (options->keyCmdAllModKey() == Qt::Key_Meta) ? KKeyServer::modXMeta() : KKeyServer::modXAlt(); + return keyModX && (state & KKeyServer::accelModMaskX()) == keyModX; } - // return value matters only when filtering events before decoration gets them bool X11Client::buttonPressEvent(xcb_window_t w, int button, int state, int x, int y, int x_root, int y_root, xcb_timestamp_t time) { @@ -856,7 +842,7 @@ bool X11Client::buttonPressEvent(xcb_window_t w, int button, int state, int x, i } if (isInteractiveMoveResizePointerButtonDown()) { if (w == wrapperId()) - xcb_allow_events(kwinApp()->x11Connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); //xTime()); + xcb_allow_events(kwinApp()->x11Connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); // xTime()); return true; } @@ -866,11 +852,11 @@ bool X11Client::buttonPressEvent(xcb_window_t w, int button, int state, int x, i const bool bModKeyHeld = modKeyDown(state); if (isSplash() - && button == XCB_BUTTON_INDEX_1 && !bModKeyHeld) { + && button == XCB_BUTTON_INDEX_1 && !bModKeyHeld) { // hide splashwindow if the user clicks on it hideClient(); if (w == wrapperId()) - xcb_allow_events(kwinApp()->x11Connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); //xTime()); + xcb_allow_events(kwinApp()->x11Connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); // xTime()); return true; } @@ -878,7 +864,7 @@ bool X11Client::buttonPressEvent(xcb_window_t w, int button, int state, int x, i bool was_action = false; if (bModKeyHeld) { was_action = true; - switch(button) { + switch (button) { case XCB_BUTTON_INDEX_1: com = options->commandAll1(); break; @@ -908,14 +894,14 @@ bool X11Client::buttonPressEvent(xcb_window_t w, int button, int state, int x, i if (isSpecialWindow()) replay = true; - if (w == wrapperId()) // these can come only from a grab - xcb_allow_events(kwinApp()->x11Connection(), replay ? XCB_ALLOW_REPLAY_POINTER : XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); //xTime()); + if (w == wrapperId()) // these can come only from a grab + xcb_allow_events(kwinApp()->x11Connection(), replay ? XCB_ALLOW_REPLAY_POINTER : XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); // xTime()); return true; } } if (w == wrapperId()) { // these can come only from a grab - xcb_allow_events(kwinApp()->x11Connection(), XCB_ALLOW_REPLAY_POINTER, XCB_TIME_CURRENT_TIME); //xTime()); + xcb_allow_events(kwinApp()->x11Connection(), XCB_ALLOW_REPLAY_POINTER, XCB_TIME_CURRENT_TIME); // xTime()); return true; } if (w == inputId()) { @@ -932,7 +918,7 @@ bool X11Client::buttonPressEvent(xcb_window_t w, int button, int state, int x, i // Logic borrowed from qapplication_x11.cpp const int delta = 120 * ((button == 4 || button == 6) ? 1 : -1); const bool hor = (((button == 4 || button == 5) && (modifiers & Qt::AltModifier)) - || (button == 6 || button == 7)); + || (button == 6 || button == 7)); const QPoint angle = hor ? QPoint(delta, 0) : QPoint(0, delta); QWheelEvent event(QPointF(x, y), @@ -952,7 +938,7 @@ bool X11Client::buttonPressEvent(xcb_window_t w, int button, int state, int x, i } } else { QMouseEvent event(QEvent::MouseButtonPress, QPointF(x, y), QPointF(x_root, y_root), - x11ToQtMouseButton(button), x11ToQtMouseButtons(state), x11ToQtKeyboardModifiers(state)); + x11ToQtMouseButton(button), x11ToQtMouseButtons(state), x11ToQtKeyboardModifiers(state)); event.setTimestamp(time); event.setAccepted(false); QCoreApplication::sendEvent(decoration(), &event); @@ -988,13 +974,13 @@ bool X11Client::buttonReleaseEvent(xcb_window_t w, int button, int state, int x, } } if (w == wrapperId()) { - xcb_allow_events(kwinApp()->x11Connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); //xTime()); + xcb_allow_events(kwinApp()->x11Connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); // xTime()); return true; } if (w != frameId() && w != inputId() && w != moveResizeGrabWindow()) return true; if (w == frameId() && workspace()->userActionsMenu() && workspace()->userActionsMenu()->isShown()) { - const_cast(workspace()->userActionsMenu())->grabInput(); + const_cast(workspace()->userActionsMenu())->grabInput(); } x = this->x(); // translate from grab window to local coords y = this->y(); @@ -1029,8 +1015,8 @@ bool X11Client::motionNotifyEvent(xcb_window_t w, int state, int x, int y, int x return true; // care only about the whole frame if (!isInteractiveMoveResizePointerButtonDown()) { if (w == inputId()) { - int x = x_root - frameGeometry().x();// + padding_left; - int y = y_root - frameGeometry().y();// + padding_top; + int x = x_root - frameGeometry().x(); // + padding_left; + int y = y_root - frameGeometry().y(); // + padding_top; if (isDecorated()) { QHoverEvent event(QEvent::HoverMove, QPointF(x, y), QPointF(x, y)); @@ -1064,15 +1050,15 @@ void X11Client::focusInEvent(xcb_focus_in_event_t *e) if (e->mode == XCB_NOTIFY_MODE_UNGRAB) return; // we don't care if (e->detail == XCB_NOTIFY_DETAIL_POINTER) - return; // we don't care - if (isShade() || !isShown() || !isOnCurrentDesktop()) // we unmapped it, but it got focus meanwhile -> - return; // activateNextClient() already transferred focus elsewhere + return; // we don't care + if (isShade() || !isShown() || !isOnCurrentDesktop()) // we unmapped it, but it got focus meanwhile -> + return; // activateNextClient() already transferred focus elsewhere workspace()->forEachClient([](X11Client *client) { client->cancelFocusOutTimer(); }); // check if this client is in should_get_focus list or if activation is allowed - bool activate = workspace()->allowClientActivation(this, -1U, true); - workspace()->gotFocusIn(this); // remove from should_get_focus list + bool activate = workspace()->allowClientActivation(this, -1U, true); + workspace()->gotFocusIn(this); // remove from should_get_focus list if (activate) { setActive(true); } else { @@ -1094,7 +1080,7 @@ void X11Client::focusOutEvent(xcb_focus_out_event_t *e) if (isShade()) return; // here neither if (e->detail != XCB_NOTIFY_DETAIL_NONLINEAR - && e->detail != XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL) + && e->detail != XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL) // SELI check all this return; // hack for motif apps like netscape if (QApplication::activePopupWidget()) @@ -1148,14 +1134,13 @@ void X11Client::NETMoveResize(int x_root, int y_root, NET::Direction direction) Gravity::BottomRight, Gravity::Bottom, Gravity::BottomLeft, - Gravity::Left - }; + Gravity::Left}; if (!isResizable() || isShade()) return; if (isInteractiveMoveResize()) finishInteractiveMoveResize(false); setInteractiveMoveResizePointerButtonDown(true); - setInteractiveMoveOffset(QPoint(x_root - x(), y_root - y())); // map from global + setInteractiveMoveOffset(QPoint(x_root - x(), y_root - y())); // map from global setInvertedInteractiveMoveOffset(rect().bottomRight() - interactiveMoveOffset()); setUnrestrictedInteractiveMoveResize(false); setInteractiveMoveResizeGravity(convert[direction]); @@ -1187,7 +1172,7 @@ bool Unmanaged::windowEvent(xcb_generic_event_t *e) { NET::Properties dirtyProperties; NET::Properties2 dirtyProperties2; - info->event(e, &dirtyProperties, &dirtyProperties2); // pass through the NET stuff + info->event(e, &dirtyProperties, &dirtyProperties2); // pass through the NET stuff if (dirtyProperties2 & NET::WM2Opacity) { if (Compositor::compositing()) { setOpacity(info->opacityF()); @@ -1207,7 +1192,7 @@ bool Unmanaged::windowEvent(xcb_generic_event_t *e) case XCB_DESTROY_NOTIFY: release(ReleaseReason::Destroyed); break; - case XCB_UNMAP_NOTIFY:{ + case XCB_UNMAP_NOTIFY: { workspace()->updateFocusMousePosition(Cursors::self()->mouse()->pos()); // may cause leave event // unmap notify might have been emitted due to a destroy notify @@ -1226,23 +1211,25 @@ bool Unmanaged::windowEvent(xcb_generic_event_t *e) // It's of course still possible that we miss the destroy in which case non-fatal // X errors are reported to the event loop and logged by Qt. m_scheduledRelease = true; - QTimer::singleShot(1, this, [this]() { release(); }); + QTimer::singleShot(1, this, [this]() { + release(); + }); break; } case XCB_CONFIGURE_NOTIFY: - configureNotifyEvent(reinterpret_cast(e)); + configureNotifyEvent(reinterpret_cast(e)); break; case XCB_PROPERTY_NOTIFY: - propertyNotifyEvent(reinterpret_cast(e)); + propertyNotifyEvent(reinterpret_cast(e)); break; case XCB_CLIENT_MESSAGE: - clientMessageEvent(reinterpret_cast(e)); + clientMessageEvent(reinterpret_cast(e)); break; default: { if (eventType == Xcb::Extensions::self()->shapeNotifyEvent()) { detectShape(window()); addRepaintFull(); - addWorkspaceRepaint(frameGeometry()); // in case shape change removes part of this window + addWorkspaceRepaint(frameGeometry()); // in case shape change removes part of this window Q_EMIT geometryShapeChanged(this, frameGeometry()); } if (eventType == Xcb::Extensions::self()->damageNotifyEvent()) @@ -1256,7 +1243,7 @@ bool Unmanaged::windowEvent(xcb_generic_event_t *e) void Unmanaged::configureNotifyEvent(xcb_configure_notify_event_t *e) { if (effects) - static_cast(effects)->checkInputWindowStacking(); // keep them on top + static_cast(effects)->checkInputWindowStacking(); // keep them on top QRect newgeom(e->x, e->y, e->width, e->height); if (newgeom != m_frameGeometry) { QRect old = m_frameGeometry; @@ -1278,7 +1265,7 @@ void Toplevel::propertyNotifyEvent(xcb_property_notify_event_t *e) { if (e->window != window()) return; // ignore frame/wrapper - switch(e->atom) { + switch (e->atom) { default: if (e->atom == atoms->wm_client_leader) getWmClientLeader(); diff --git a/src/focuschain.cpp b/src/focuschain.cpp index 67803e57de..c4c2f71871 100644 --- a/src/focuschain.cpp +++ b/src/focuschain.cpp @@ -30,8 +30,8 @@ FocusChain::~FocusChain() void FocusChain::remove(AbstractClient *client) { for (auto it = m_desktopFocusChains.begin(); - it != m_desktopFocusChains.end(); - ++it) { + it != m_desktopFocusChains.end(); + ++it) { it.value().removeAll(client); } m_mostRecentlyUsed.removeAll(client); @@ -66,7 +66,7 @@ AbstractClient *FocusChain::getForActivation(VirtualDesktop *desktop, AbstractOu auto tmp = chain.at(i); // TODO: move the check into Client if (!tmp->isShade() && tmp->isShown() && tmp->isOnCurrentActivity() - && ( !m_separateScreenFocus || tmp->output() == output)) { + && (!m_separateScreenFocus || tmp->output() == output)) { return tmp; } } @@ -84,12 +84,12 @@ void FocusChain::update(AbstractClient *client, FocusChain::Change change) if (client->isOnAllDesktops()) { // Now on all desktops, add it to focus chains it is not already in for (auto it = m_desktopFocusChains.begin(); - it != m_desktopFocusChains.end(); - ++it) { + it != m_desktopFocusChains.end(); + ++it) { auto &chain = it.value(); // Making first/last works only on current desktop, don't affect all desktops if (it.key() == m_currentDesktop - && (change == MakeFirst || change == MakeLast)) { + && (change == MakeFirst || change == MakeLast)) { if (change == MakeFirst) { makeFirstInChain(client, chain); } else { @@ -102,8 +102,8 @@ void FocusChain::update(AbstractClient *client, FocusChain::Change change) } else { // Now only on desktop, remove it anywhere else for (auto it = m_desktopFocusChains.begin(); - it != m_desktopFocusChains.end(); - ++it) { + it != m_desktopFocusChains.end(); + ++it) { auto &chain = it.value(); if (client->isOnDesktop(it.key())) { updateClientInChain(client, change, chain); @@ -133,8 +133,7 @@ void FocusChain::insertClientIntoChain(AbstractClient *client, Chain &chain) if (chain.contains(client)) { return; } - if (m_activeClient && m_activeClient != client && - !chain.empty() && chain.last() == m_activeClient) { + if (m_activeClient && m_activeClient != client && !chain.empty() && chain.last() == m_activeClient) { // Add it after the active client chain.insert(chain.size() - 1, client); } else { @@ -150,8 +149,8 @@ void FocusChain::moveAfterClient(AbstractClient *client, AbstractClient *referen } for (auto it = m_desktopFocusChains.begin(); - it != m_desktopFocusChains.end(); - ++it) { + it != m_desktopFocusChains.end(); + ++it) { if (!client->isOnDesktop(it.key())) { continue; } @@ -205,9 +204,7 @@ AbstractClient *FocusChain::nextMostRecentlyUsed(AbstractClient *reference) cons // copied from activation.cpp bool FocusChain::isUsableFocusCandidate(AbstractClient *c, AbstractClient *prev) const { - return c != prev && - !c->isShade() && c->isShown() && c->isOnCurrentDesktop() && c->isOnCurrentActivity() && - (!m_separateScreenFocus || c->isOnOutput(prev ? prev->output() : workspace()->activeOutput())); + return c != prev && !c->isShade() && c->isShown() && c->isOnCurrentDesktop() && c->isOnCurrentActivity() && (!m_separateScreenFocus || c->isOnOutput(prev ? prev->output() : workspace()->activeOutput())); } AbstractClient *FocusChain::nextForDesktop(AbstractClient *reference, VirtualDesktop *desktop) const @@ -231,9 +228,9 @@ void FocusChain::makeFirstInChain(AbstractClient *client, Chain &chain) chain.removeAll(client); if (options->moveMinimizedWindowsToEndOfTabBoxFocusChain()) { if (client->isMinimized()) { // add it before the first minimized ... - for (int i = chain.count()-1; i >= 0; --i) { + for (int i = chain.count() - 1; i >= 0; --i) { if (chain.at(i)->isMinimized()) { - chain.insert(i+1, client); + chain.insert(i + 1, client); return; } } diff --git a/src/focuschain.h b/src/focuschain.h index 5647c87006..2026004514 100644 --- a/src/focuschain.h +++ b/src/focuschain.h @@ -11,8 +11,8 @@ // KWin #include // Qt -#include #include +#include namespace KWin { @@ -173,7 +173,7 @@ public Q_SLOTS: void removeDesktop(VirtualDesktop *desktop); private: - using Chain = QList; + using Chain = QList; /** * @brief Makes @p client the first Client in the given focus @p chain. * @@ -208,26 +208,22 @@ private: KWIN_SINGLETON_VARIABLE(FocusChain, s_manager) }; -inline -bool FocusChain::contains(AbstractClient *client) const +inline bool FocusChain::contains(AbstractClient *client) const { return m_mostRecentlyUsed.contains(client); } -inline -void FocusChain::setSeparateScreenFocus(bool enabled) +inline void FocusChain::setSeparateScreenFocus(bool enabled) { m_separateScreenFocus = enabled; } -inline -void FocusChain::setActiveClient(AbstractClient *client) +inline void FocusChain::setActiveClient(AbstractClient *client) { m_activeClient = client; } -inline -void FocusChain::setCurrentDesktop(VirtualDesktop *desktop) +inline void FocusChain::setCurrentDesktop(VirtualDesktop *desktop) { m_currentDesktop = desktop; } diff --git a/src/ftrace.h b/src/ftrace.h index b3586571f9..22dabea9fd 100644 --- a/src/ftrace.h +++ b/src/ftrace.h @@ -43,7 +43,8 @@ public: * Main log function * Takes any number of arguments that can be written into QTextStream */ - template void trace(Args... args) + template + void trace(Args... args) { Q_ASSERT(isEnabled()); QMutexLocker lock(&m_mutex); @@ -71,7 +72,8 @@ private: class KWIN_EXPORT FTraceDuration { public: - template FTraceDuration(Args... args) + template + FTraceDuration(Args... args) { static QAtomicInteger s_context = 0; QTextStream stream(&m_message); @@ -93,13 +95,13 @@ private: /** * Optimised macro, arguments are only copied if tracing is enabled */ -#define fTrace(...) \ - if (KWin::FTraceLogger::self()->isEnabled()) \ +#define fTrace(...) \ + if (KWin::FTraceLogger::self()->isEnabled()) \ KWin::FTraceLogger::self()->trace(__VA_ARGS__); /** * Will insert two markers into the log. Once when called, and the second at the end of the relevant block * In GPUVis this will appear as a timed block with begin_ctx and end_ctx markers */ -#define fTraceDuration(...) \ +#define fTraceDuration(...) \ QScopedPointer _duration(KWin::FTraceLogger::self()->isEnabled() ? new KWin::FTraceDuration(__VA_ARGS__) : nullptr); diff --git a/src/gestures.cpp b/src/gestures.cpp index 774e90672e..8ec7c98c8c 100644 --- a/src/gestures.cpp +++ b/src/gestures.cpp @@ -8,10 +8,10 @@ */ #include "gestures.h" -#include -#include -#include #include +#include +#include +#include namespace KWin { @@ -231,7 +231,7 @@ void GestureRecognizer::updateSwipeGesture(const QSizeF &delta) break; default: return; - } + } // Eliminate wrong gestures (takes two iterations) for (int i = 0; i < 2; i++) { @@ -257,11 +257,10 @@ void GestureRecognizer::updateSwipeGesture(const QSizeF &delta) } // Send progress update - for (SwipeGesture *g: std::as_const(m_activeSwipeGestures)) { + for (SwipeGesture *g : std::as_const(m_activeSwipeGestures)) { Q_EMIT g->progress(g->minimumDeltaReachedProgress(m_currentDelta)); Q_EMIT g->deltaProgress(m_currentDelta); } - } void GestureRecognizer::cancelActiveGestures() @@ -375,7 +374,7 @@ void GestureRecognizer::cancelPinchGesture() m_currentSwipeAxis = Axis::None; } -void GestureRecognizer::endPinchGesture()//because fingers up +void GestureRecognizer::endPinchGesture() // because fingers up { for (auto g : qAsConst(m_activePinchGestures)) { if (g->minimumScaleDeltaReached(m_currentScale)) { diff --git a/src/gestures.h b/src/gestures.h index 9de3dd2874..4ce7c0b8c6 100644 --- a/src/gestures.h +++ b/src/gestures.h @@ -11,10 +11,10 @@ #include +#include #include #include #include -#include #include namespace KWin @@ -30,6 +30,7 @@ class Gesture : public QObject Q_OBJECT public: ~Gesture() override; + protected: explicit Gesture(QObject *parent); @@ -153,9 +154,9 @@ public: qreal minimumScaleDelta() const; /** - * scaleDelta is the % scale difference needed to trigger - * 0.25 will trigger when scale reaches 0.75 or 1.25 - */ + * scaleDelta is the % scale difference needed to trigger + * 0.25 will trigger when scale reaches 0.75 or 1.25 + */ void setMinimumScaleDelta(const qreal &scaleDelta); bool isMinimumScaleDeltaRelevant() const; @@ -199,7 +200,7 @@ public: void endSwipeGesture(); int startPinchGesture(uint fingerCount); - void updatePinchGesture(qreal scale, qreal angleDelta, const QSizeF& posDelta); + void updatePinchGesture(qreal scale, qreal angleDelta, const QSizeF &posDelta); void cancelPinchGesture(); void endPinchGesture(); diff --git a/src/globalshortcuts.cpp b/src/globalshortcuts.cpp index 3084a81208..637147f09f 100644 --- a/src/globalshortcuts.cpp +++ b/src/globalshortcuts.cpp @@ -8,19 +8,21 @@ */ // own #include "globalshortcuts.h" +// config +#include // kwin #include "gestures.h" #include "kwinglobals.h" #include "main.h" #include "utils/common.h" -#include // KDE #include #include // Qt #include -#include +// system #include +#include namespace KWin { @@ -36,8 +38,7 @@ GlobalShortcut::GlobalShortcut(Shortcut &&sc, QAction *action) }; static const QMap pinchDirs = { {PinchDirection::Expanding, PinchGesture::Direction::Expanding}, - {PinchDirection::Contracting, PinchGesture::Direction::Contracting} - }; + {PinchDirection::Contracting, PinchGesture::Direction::Contracting}}; if (auto swipeGesture = std::get_if(&sc)) { m_swipeGesture.reset(new SwipeGesture()); m_swipeGesture->setDirection(swipeDirs[swipeGesture->direction]); @@ -173,7 +174,7 @@ void GlobalShortcutsManager::registerTouchpadSwipe(QAction *action, SwipeDirecti addIfNotExists(GlobalShortcut(SwipeShortcut{direction, fingerCount}, action)); } -void GlobalShortcutsManager::registerRealtimeTouchpadSwipe(QAction *action, std::function progressCallback, SwipeDirection direction, uint fingerCount) +void GlobalShortcutsManager::registerRealtimeTouchpadSwipe(QAction *action, std::function progressCallback, SwipeDirection direction, uint fingerCount) { addIfNotExists(GlobalShortcut(RealtimeFeedbackSwipeShortcut{direction, progressCallback, fingerCount}, action)); } diff --git a/src/group.cpp b/src/group.cpp index 843259f7ac..740d2bd854 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -11,9 +11,9 @@ //#define QT_CLEAN_NAMESPACE #include "group.h" +#include "effects.h" #include "workspace.h" #include "x11client.h" -#include "effects.h" #include #include @@ -26,11 +26,11 @@ namespace KWin //******************************************** Group::Group(xcb_window_t leader_P) - : leader_client(nullptr), - leader_wid(leader_P), - leader_info(nullptr), - user_time(-1U), - refcount(0) + : leader_client(nullptr) + , leader_wid(leader_P) + , leader_info(nullptr) + , user_time(-1U) + , refcount(0) { if (leader_P != XCB_WINDOW_NONE) { leader_client = workspace()->findClient(Predicate::WindowMatch, leader_P); @@ -73,20 +73,20 @@ QIcon Group::icon() const void Group::addMember(X11Client *member_P) { _members.append(member_P); -// qDebug() << "GROUPADD:" << this << ":" << member_P; -// qDebug() << kBacktrace(); + // qDebug() << "GROUPADD:" << this << ":" << member_P; + // qDebug() << kBacktrace(); } void Group::removeMember(X11Client *member_P) { -// qDebug() << "GROUPREMOVE:" << this << ":" << member_P; -// qDebug() << kBacktrace(); + // qDebug() << "GROUPREMOVE:" << this << ":" << member_P; + // qDebug() << kBacktrace(); Q_ASSERT(_members.contains(member_P)); _members.removeAll(member_P); -// there are cases when automatic deleting of groups must be delayed, -// e.g. when removing a member and doing some operation on the possibly -// other members of the group (which would be however deleted already -// if there were no other members) + // there are cases when automatic deleting of groups must be delayed, + // e.g. when removing a member and doing some operation on the possibly + // other members of the group (which would be however deleted already + // if there were no other members) if (refcount == 0 && _members.isEmpty()) { workspace()->removeGroup(this); delete this; diff --git a/src/group.h b/src/group.h index 5d514173bd..077b95e043 100644 --- a/src/group.h +++ b/src/group.h @@ -38,16 +38,17 @@ public: xcb_timestamp_t userTime() const; void ref(); void deref(); - EffectWindowGroupImpl* effectGroup(); + EffectWindowGroupImpl *effectGroup(); + private: void startupIdChanged(); QList _members; X11Client *leader_client; xcb_window_t leader_wid; - NETWinInfo* leader_info; + NETWinInfo *leader_info; xcb_timestamp_t user_time; int refcount; - EffectWindowGroupImpl* effect_group; + EffectWindowGroupImpl *effect_group; }; inline xcb_window_t Group::leader() const @@ -75,8 +76,7 @@ inline xcb_timestamp_t Group::userTime() const return user_time; } -inline -EffectWindowGroupImpl* Group::effectGroup() +inline EffectWindowGroupImpl *Group::effectGroup() { return effect_group; } diff --git a/src/helpers/killer/killer.cpp b/src/helpers/killer/killer.cpp index 3a6d073acb..50af5d9c7b 100644 --- a/src/helpers/killer/killer.cpp +++ b/src/helpers/killer/killer.cpp @@ -5,8 +5,8 @@ */ -#include #include +#include #include #if KAUTH_VERSION >= QT_VERSION_CHECK(5, 92, 0) #include @@ -27,7 +27,7 @@ #include #include -int main(int argc, char* argv[]) +int main(int argc, char *argv[]) { KLocalizedString::setApplicationDomain("kwin"); qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("xcb")); @@ -39,7 +39,6 @@ int main(int argc, char* argv[]) QApplication::setApplicationDisplayName(i18n("Window Manager")); QCoreApplication::setApplicationVersion(QStringLiteral("1.0")); - QCommandLineOption pidOption(QStringLiteral("pid"), i18n("PID of the application to terminate"), i18n("pid")); QCommandLineOption hostNameOption(QStringLiteral("hostname"), @@ -76,7 +75,7 @@ int main(int argc, char* argv[]) bool time_ok = false; xcb_timestamp_t timestamp = parser.value(timestampOption).toULong(&time_ok); if (!pid_ok || pid == 0 || !id_ok || id == XCB_WINDOW_NONE || !time_ok || timestamp == XCB_TIME_CURRENT_TIME - || hostname.isEmpty() || caption.isEmpty() || appname.isEmpty()) { + || hostname.isEmpty() || caption.isEmpty() || appname.isEmpty()) { fprintf(stdout, "%s\n", qPrintable(i18n("This helper utility is not supposed to be called directly."))); parser.showHelp(1); } @@ -90,13 +89,12 @@ int main(int argc, char* argv[]) QString question = i18nc("@info", "Application \"%1\" is not responding", appname); question += isLocal ? xi18nc("@info", "You tried to close window \"%1\" from application \"%2\" (Process ID: %3) but the application is not responding.", - caption, appname, pidString) + caption, appname, pidString) : xi18nc("@info", "You tried to close window \"%1\" from application \"%2\" (Process ID: %3), running on host \"%4\", but the application is not responding.", - caption, appname, pidString, hostname); + caption, appname, pidString, hostname); question += xi18nc("@info", - "Do you want to terminate this application?" - "Terminating the application will close all of its child windows. Any unsaved data will be lost." - ); + "Do you want to terminate this application?" + "Terminating the application will close all of its child windows. Any unsaved data will be lost."); KGuiItem continueButton = KGuiItem(i18n("&Terminate Application %1", appname), QStringLiteral("edit-bomb")); KGuiItem cancelButton = KGuiItem(i18n("Wait Longer"), QStringLiteral("chronometer")); diff --git a/src/helpers/wayland_wrapper/kwin_wrapper.cpp b/src/helpers/wayland_wrapper/kwin_wrapper.cpp index 67ab0c4ba7..5a8866a608 100644 --- a/src/helpers/wayland_wrapper/kwin_wrapper.cpp +++ b/src/helpers/wayland_wrapper/kwin_wrapper.cpp @@ -21,20 +21,20 @@ */ #include +#include #include #include #include -#include -#include #include +#include #include #include "wl-socket.h" -#include "xwaylandsocket.h" -#include "xauthority.h" #include "wrapper_logging.h" +#include "xauthority.h" +#include "xwaylandsocket.h" class KWinWrapper : public QObject { @@ -109,7 +109,6 @@ void KWinWrapper::run() if (m_xauthorityFile.open()) { args << "--xwayland-xauthority" << m_xauthorityFile.fileName(); } - } // attach our main process arguments diff --git a/src/helpers/wayland_wrapper/wl-socket.h b/src/helpers/wayland_wrapper/wl-socket.h index ba327206e8..ac69ca955c 100644 --- a/src/helpers/wayland_wrapper/wl-socket.h +++ b/src/helpers/wayland_wrapper/wl-socket.h @@ -13,7 +13,6 @@ extern "C" { #endif - /** * Allocate and create a socket * It is bound and accepted diff --git a/src/hide_cursor_spy.cpp b/src/hide_cursor_spy.cpp index af6c19f413..e335c6061b 100644 --- a/src/hide_cursor_spy.cpp +++ b/src/hide_cursor_spy.cpp @@ -7,10 +7,10 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "hide_cursor_spy.h" +#include "cursor.h" +#include "input_event.h" #include "main.h" #include "platform.h" -#include "input_event.h" -#include "cursor.h" namespace KWin { diff --git a/src/idle_inhibition.cpp b/src/idle_inhibition.cpp index f4446729ef..3eb3d6a826 100644 --- a/src/idle_inhibition.cpp +++ b/src/idle_inhibition.cpp @@ -45,16 +45,14 @@ void IdleInhibition::registerClient(AbstractClient *client) connect(client, &AbstractClient::clientUnminimized, this, updateInhibit); connect(client, &AbstractClient::windowHidden, this, updateInhibit); connect(client, &AbstractClient::windowShown, this, updateInhibit); - connect(client, &AbstractClient::windowClosed, this, - [this, client] { - uninhibit(client); - auto it = m_connections.find(client); - if (it != m_connections.end()) { - disconnect(it.value()); - m_connections.erase(it); - } + connect(client, &AbstractClient::windowClosed, this, [this, client]() { + uninhibit(client); + auto it = m_connections.find(client); + if (it != m_connections.end()) { + disconnect(it.value()); + m_connections.erase(it); } - ); + }); updateInhibit(); } @@ -104,7 +102,9 @@ void IdleInhibition::slotWorkspaceCreated() void IdleInhibition::slotDesktopChanged() { - workspace()->forEachAbstractClient([this] (AbstractClient *c) { update(c); }); + workspace()->forEachAbstractClient([this](AbstractClient *c) { + update(c); + }); } } diff --git a/src/idle_inhibition.h b/src/idle_inhibition.h index dc70b1ca41..1e1d0dc98d 100644 --- a/src/idle_inhibition.h +++ b/src/idle_inhibition.h @@ -9,9 +9,9 @@ */ #pragma once +#include #include #include -#include namespace KWaylandServer { @@ -33,10 +33,12 @@ public: void registerClient(AbstractClient *client); - bool isInhibited() const { + bool isInhibited() const + { return !m_idleInhibitors.isEmpty(); } - bool isInhibited(AbstractClient *client) const { + bool isInhibited(AbstractClient *client) const + { return m_idleInhibitors.contains(client); } diff --git a/src/input.cpp b/src/input.cpp index fccb0752d0..80f67adefd 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -8,14 +8,15 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include #include "input.h" + #include "backends/fakeinput/fakeinputbackend.h" #include "backends/libinput/connection.h" #include "backends/libinput/device.h" #include "effects.h" #include "gestures.h" #include "globalshortcuts.h" +#include "hide_cursor_spy.h" #include "input_event.h" #include "input_event_spy.h" #include "inputbackend.h" @@ -25,12 +26,12 @@ #include "pointer_input.h" #include "session.h" #include "tablet_input.h" -#include "hide_cursor_spy.h" #include "touch_input.h" #include "x11client.h" #if KWIN_BUILD_TABBOX #include "tabbox/tabbox.h" #endif +#include "cursor.h" #include "internal_client.h" #include "platform.h" #include "popup_input_filter.h" @@ -41,7 +42,6 @@ #include "wayland_server.h" #include "workspace.h" #include "xwl/xwayland_interface.h" -#include "cursor.h" #include #include #include @@ -53,7 +53,7 @@ #include #include -//screenlocker +// screenlocker #if KWIN_BUILD_SCREENLOCKER #include #endif @@ -296,9 +296,11 @@ bool InputEventFilter::passToInputMethod(QKeyEvent *event) return false; } -class VirtualTerminalFilter : public InputEventFilter { +class VirtualTerminalFilter : public InputEventFilter +{ public: - bool keyEvent(QKeyEvent *event) override { + bool keyEvent(QKeyEvent *event) override + { // really on press and not on release? X11 switches on press. if (event->type() == QEvent::KeyPress && !event->isAutoRepeat()) { const xkb_keysym_t keysym = event->nativeVirtualKey(); @@ -311,9 +313,11 @@ public: } }; -class TerminateServerFilter : public InputEventFilter { +class TerminateServerFilter : public InputEventFilter +{ public: - bool keyEvent(QKeyEvent *event) override { + bool keyEvent(QKeyEvent *event) override + { if (event->type() == QEvent::KeyPress && !event->isAutoRepeat()) { if (event->nativeVirtualKey() == XKB_KEY_Terminate_Server) { qCWarning(KWIN_CORE) << "Request to terminate server"; @@ -325,9 +329,11 @@ public: } }; -class LockScreenFilter : public InputEventFilter { +class LockScreenFilter : public InputEventFilter +{ public: - bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { + bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override + { if (!waylandServer()->isScreenLocked()) { return false; } @@ -358,7 +364,8 @@ public: } return true; } - bool wheelEvent(QWheelEvent *event) override { + bool wheelEvent(QWheelEvent *event) override + { if (!waylandServer()->isScreenLocked()) { return false; } @@ -373,7 +380,8 @@ public: } return true; } - bool keyEvent(QKeyEvent * event) override { + bool keyEvent(QKeyEvent *event) override + { if (!waylandServer()->isScreenLocked()) { return false; } @@ -412,7 +420,8 @@ public: } return true; } - bool touchDown(qint32 id, const QPointF &pos, quint32 time) override { + bool touchDown(qint32 id, const QPointF &pos, quint32 time) override + { if (!waylandServer()->isScreenLocked()) { return false; } @@ -423,7 +432,8 @@ public: } return true; } - bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override { + bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override + { if (!waylandServer()->isScreenLocked()) { return false; } @@ -434,7 +444,8 @@ public: } return true; } - bool touchUp(qint32 id, quint32 time) override { + bool touchUp(qint32 id, quint32 time) override + { if (!waylandServer()->isScreenLocked()) { return false; } @@ -445,13 +456,15 @@ public: } return true; } - bool pinchGestureBegin(int fingerCount, quint32 time) override { + bool pinchGestureBegin(int fingerCount, quint32 time) override + { Q_UNUSED(fingerCount) Q_UNUSED(time) // no touchpad multi-finger gestures on lock screen return waylandServer()->isScreenLocked(); } - bool pinchGestureUpdate(qreal scale, qreal angleDelta, const QSizeF &delta, quint32 time) override { + bool pinchGestureUpdate(qreal scale, qreal angleDelta, const QSizeF &delta, quint32 time) override + { Q_UNUSED(scale) Q_UNUSED(angleDelta) Q_UNUSED(delta) @@ -459,52 +472,62 @@ public: // no touchpad multi-finger gestures on lock screen return waylandServer()->isScreenLocked(); } - bool pinchGestureEnd(quint32 time) override { + bool pinchGestureEnd(quint32 time) override + { Q_UNUSED(time) // no touchpad multi-finger gestures on lock screen return waylandServer()->isScreenLocked(); } - bool pinchGestureCancelled(quint32 time) override { + bool pinchGestureCancelled(quint32 time) override + { Q_UNUSED(time) // no touchpad multi-finger gestures on lock screen return waylandServer()->isScreenLocked(); } - bool swipeGestureBegin(int fingerCount, quint32 time) override { + bool swipeGestureBegin(int fingerCount, quint32 time) override + { Q_UNUSED(fingerCount) Q_UNUSED(time) // no touchpad multi-finger gestures on lock screen return waylandServer()->isScreenLocked(); } - bool swipeGestureUpdate(const QSizeF &delta, quint32 time) override { + bool swipeGestureUpdate(const QSizeF &delta, quint32 time) override + { Q_UNUSED(delta) Q_UNUSED(time) // no touchpad multi-finger gestures on lock screen return waylandServer()->isScreenLocked(); } - bool swipeGestureEnd(quint32 time) override { + bool swipeGestureEnd(quint32 time) override + { Q_UNUSED(time) // no touchpad multi-finger gestures on lock screen return waylandServer()->isScreenLocked(); } - bool swipeGestureCancelled(quint32 time) override { + bool swipeGestureCancelled(quint32 time) override + { Q_UNUSED(time) // no touchpad multi-finger gestures on lock screen return waylandServer()->isScreenLocked(); } - bool holdGestureBegin(int fingerCount, quint32 time) override { + bool holdGestureBegin(int fingerCount, quint32 time) override + { Q_UNUSED(fingerCount) Q_UNUSED(time) // no touchpad multi-finger gestures on lock screen return waylandServer()->isScreenLocked(); } - bool holdGestureEnd(quint32 time) override { + bool holdGestureEnd(quint32 time) override + { Q_UNUSED(time) // no touchpad multi-finger gestures on lock screen return waylandServer()->isScreenLocked(); } + private: - bool surfaceAllowed(KWaylandServer::SurfaceInterface *(KWaylandServer::SeatInterface::*method)() const) const { + bool surfaceAllowed(KWaylandServer::SurfaceInterface *(KWaylandServer::SeatInterface::*method)() const) const + { if (KWaylandServer::SurfaceInterface *s = (waylandServer()->seat()->*method)()) { if (Toplevel *t = waylandServer()->findClient(s)) { return t->isLockScreen() || t->isInputMethod(); @@ -513,94 +536,111 @@ private: } return true; } - bool pointerSurfaceAllowed() const { + bool pointerSurfaceAllowed() const + { return surfaceAllowed(&KWaylandServer::SeatInterface::focusedPointerSurface); } - bool keyboardSurfaceAllowed() const { + bool keyboardSurfaceAllowed() const + { return surfaceAllowed(&KWaylandServer::SeatInterface::focusedKeyboardSurface); } - bool touchSurfaceAllowed() const { + bool touchSurfaceAllowed() const + { return surfaceAllowed(&KWaylandServer::SeatInterface::focusedTouchSurface); } }; -class EffectsFilter : public InputEventFilter { +class EffectsFilter : public InputEventFilter +{ public: - bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { + bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override + { Q_UNUSED(nativeButton) if (!effects) { return false; } - return static_cast(effects)->checkInputWindowEvent(event); + return static_cast(effects)->checkInputWindowEvent(event); } - bool wheelEvent(QWheelEvent *event) override { + bool wheelEvent(QWheelEvent *event) override + { if (!effects) { return false; } - return static_cast(effects)->checkInputWindowEvent(event); + return static_cast(effects)->checkInputWindowEvent(event); } - bool keyEvent(QKeyEvent *event) override { - if (!effects || !static_cast< EffectsHandlerImpl* >(effects)->hasKeyboardGrab()) { + bool keyEvent(QKeyEvent *event) override + { + if (!effects || !static_cast(effects)->hasKeyboardGrab()) { return false; } waylandServer()->seat()->setFocusedKeyboardSurface(nullptr); passToWaylandServer(event); - static_cast< EffectsHandlerImpl* >(effects)->grabbedKeyboardEvent(event); + static_cast(effects)->grabbedKeyboardEvent(event); return true; } - bool touchDown(qint32 id, const QPointF &pos, quint32 time) override { + bool touchDown(qint32 id, const QPointF &pos, quint32 time) override + { if (!effects) { return false; } - return static_cast< EffectsHandlerImpl* >(effects)->touchDown(id, pos, time); + return static_cast(effects)->touchDown(id, pos, time); } - bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override { + bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override + { if (!effects) { return false; } - return static_cast< EffectsHandlerImpl* >(effects)->touchMotion(id, pos, time); + return static_cast(effects)->touchMotion(id, pos, time); } - bool touchUp(qint32 id, quint32 time) override { + bool touchUp(qint32 id, quint32 time) override + { if (!effects) { return false; } - return static_cast< EffectsHandlerImpl* >(effects)->touchUp(id, time); + return static_cast(effects)->touchUp(id, time); } - bool tabletToolEvent(TabletEvent *event) override { + bool tabletToolEvent(TabletEvent *event) override + { if (!effects) { return false; } - return static_cast< EffectsHandlerImpl* >(effects)->tabletToolEvent(event); + return static_cast(effects)->tabletToolEvent(event); } - bool tabletToolButtonEvent(uint button, bool pressed, const TabletToolId &tabletToolId) override { + bool tabletToolButtonEvent(uint button, bool pressed, const TabletToolId &tabletToolId) override + { if (!effects) { return false; } - return static_cast< EffectsHandlerImpl* >(effects)->tabletToolButtonEvent(button, pressed, tabletToolId); + return static_cast(effects)->tabletToolButtonEvent(button, pressed, tabletToolId); } - bool tabletPadButtonEvent(uint button, bool pressed, const TabletPadId &tabletPadId) override { + bool tabletPadButtonEvent(uint button, bool pressed, const TabletPadId &tabletPadId) override + { if (!effects) { return false; } - return static_cast< EffectsHandlerImpl* >(effects)->tabletPadButtonEvent(button, pressed, tabletPadId); + return static_cast(effects)->tabletPadButtonEvent(button, pressed, tabletPadId); } - bool tabletPadStripEvent(int number, int position, bool isFinger, const TabletPadId &tabletPadId) override { + bool tabletPadStripEvent(int number, int position, bool isFinger, const TabletPadId &tabletPadId) override + { if (!effects) { return false; } - return static_cast< EffectsHandlerImpl* >(effects)->tabletPadStripEvent(number, position, isFinger, tabletPadId); + return static_cast(effects)->tabletPadStripEvent(number, position, isFinger, tabletPadId); } - bool tabletPadRingEvent(int number, int position, bool isFinger, const TabletPadId &tabletPadId) override { + bool tabletPadRingEvent(int number, int position, bool isFinger, const TabletPadId &tabletPadId) override + { if (!effects) { return false; } - return static_cast< EffectsHandlerImpl* >(effects)->tabletPadRingEvent(number, position, isFinger, tabletPadId); + return static_cast(effects)->tabletPadRingEvent(number, position, isFinger, tabletPadId); } }; -class MoveResizeFilter : public InputEventFilter { +class MoveResizeFilter : public InputEventFilter +{ public: - bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { + bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override + { Q_UNUSED(nativeButton) AbstractClient *c = workspace()->moveResizeClient(); if (!c) { @@ -620,12 +660,14 @@ public: } return true; } - bool wheelEvent(QWheelEvent *event) override { + bool wheelEvent(QWheelEvent *event) override + { Q_UNUSED(event) // filter out while moving a window return workspace()->moveResizeClient() != nullptr; } - bool keyEvent(QKeyEvent *event) override { + bool keyEvent(QKeyEvent *event) override + { AbstractClient *c = workspace()->moveResizeClient(); if (!c) { return false; @@ -640,7 +682,8 @@ public: return true; } - bool touchDown(qint32 id, const QPointF &pos, quint32 time) override { + bool touchDown(qint32 id, const QPointF &pos, quint32 time) override + { Q_UNUSED(id) Q_UNUSED(pos) Q_UNUSED(time) @@ -651,7 +694,8 @@ public: return true; } - bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override { + bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override + { Q_UNUSED(time) AbstractClient *c = workspace()->moveResizeClient(); if (!c) { @@ -667,7 +711,8 @@ public: return true; } - bool touchUp(qint32 id, quint32 time) override { + bool touchUp(qint32 id, quint32 time) override + { Q_UNUSED(time) AbstractClient *c = workspace()->moveResizeClient(); if (!c) { @@ -683,7 +728,8 @@ public: return true; } - bool tabletToolEvent(TabletEvent *event) override { + bool tabletToolEvent(TabletEvent *event) override + { AbstractClient *c = workspace()->moveResizeClient(); if (!c) { return false; @@ -701,14 +747,17 @@ public: // Let TabletInputFilter receive the event, so the cursor position can be updated. return false; } + private: qint32 m_id = 0; bool m_set = false; }; -class WindowSelectorFilter : public InputEventFilter { +class WindowSelectorFilter : public InputEventFilter +{ public: - bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { + bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override + { Q_UNUSED(nativeButton) if (!m_active) { return false; @@ -728,12 +777,14 @@ public: } return true; } - bool wheelEvent(QWheelEvent *event) override { + bool wheelEvent(QWheelEvent *event) override + { Q_UNUSED(event) // filter out while selecting a window return m_active; } - bool keyEvent(QKeyEvent *event) override { + bool keyEvent(QKeyEvent *event) override + { Q_UNUSED(event) if (!m_active) { return false; @@ -745,9 +796,7 @@ public: // x11 variant does this on key press, so do the same if (event->key() == Qt::Key_Escape) { cancel(); - } else if (event->key() == Qt::Key_Enter || - event->key() == Qt::Key_Return || - event->key() == Qt::Key_Space) { + } else if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return || event->key() == Qt::Key_Space) { accept(input()->globalPointer()); } if (input()->supportsPointerWarping()) { @@ -776,7 +825,8 @@ public: return true; } - bool touchDown(qint32 id, const QPointF &pos, quint32 time) override { + bool touchDown(qint32 id, const QPointF &pos, quint32 time) override + { Q_UNUSED(time) if (!isActive()) { return false; @@ -785,7 +835,8 @@ public: return true; } - bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override { + bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override + { Q_UNUSED(time) if (!isActive()) { return false; @@ -797,7 +848,8 @@ public: return true; } - bool touchUp(qint32 id, quint32 time) override { + bool touchUp(qint32 id, quint32 time) override + { Q_UNUSED(time) if (!isActive()) { return false; @@ -813,33 +865,39 @@ public: return true; } - bool isActive() const { + bool isActive() const + { return m_active; } - void start(std::function callback) { + void start(std::function callback) + { Q_ASSERT(!m_active); m_active = true; m_callback = callback; input()->keyboard()->update(); input()->touch()->cancel(); } - void start(std::function callback) { + void start(std::function callback) + { Q_ASSERT(!m_active); m_active = true; m_pointSelectionFallback = callback; input()->keyboard()->update(); input()->touch()->cancel(); } + private: - void deactivate() { + void deactivate() + { m_active = false; - m_callback = std::function(); + m_callback = std::function(); m_pointSelectionFallback = std::function(); input()->pointer()->removeWindowSelectionCursor(); input()->keyboard()->update(); m_touchPoints.clear(); } - void cancel() { + void cancel() + { if (m_callback) { m_callback(nullptr); } @@ -848,7 +906,8 @@ private: } deactivate(); } - void accept(const QPoint &pos) { + void accept(const QPoint &pos) + { if (m_callback) { // TODO: this ignores shaped windows m_callback(input()->findToplevel(pos)); @@ -858,27 +917,32 @@ private: } deactivate(); } - void accept(const QPointF &pos) { + void accept(const QPointF &pos) + { accept(pos.toPoint()); } bool m_active = false; - std::function m_callback; + std::function m_callback; std::function m_pointSelectionFallback; QMap m_touchPoints; }; -class GlobalShortcutFilter : public InputEventFilter { +class GlobalShortcutFilter : public InputEventFilter +{ public: - GlobalShortcutFilter() { + GlobalShortcutFilter() + { m_powerDown = new QTimer; m_powerDown->setSingleShot(true); m_powerDown->setInterval(1000); } - ~GlobalShortcutFilter() { + ~GlobalShortcutFilter() + { delete m_powerDown; } - bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { + bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override + { Q_UNUSED(nativeButton); if (event->type() == QEvent::MouseButtonPress) { if (input()->shortcuts()->processPointerPressed(event->modifiers(), event->buttons())) { @@ -887,7 +951,8 @@ public: } return false; } - bool wheelEvent(QWheelEvent *event) override { + bool wheelEvent(QWheelEvent *event) override + { if (event->modifiers() == Qt::NoModifier) { return false; } @@ -903,9 +968,10 @@ public: } return input()->shortcuts()->processAxis(event->modifiers(), direction); } - bool keyEvent(QKeyEvent *event) override { + bool keyEvent(QKeyEvent *event) override + { if (event->key() == Qt::Key_PowerOff) { - const auto modifiers = static_cast(event)->modifiersRelevantForGlobalShortcuts(); + const auto modifiers = static_cast(event)->modifiersRelevantForGlobalShortcuts(); if (event->type() == QEvent::KeyPress && !event->isAutoRepeat()) { QObject::connect(m_powerDown, &QTimer::timeout, input()->shortcuts(), [this, modifiers] { QObject::disconnect(m_powerDown, &QTimer::timeout, input()->shortcuts(), nullptr); @@ -921,60 +987,68 @@ public: } } else if (event->type() == QEvent::KeyPress) { if (!waylandServer()->isKeyboardShortcutsInhibited()) { - return input()->shortcuts()->processKey(static_cast(event)->modifiersRelevantForGlobalShortcuts(), event->key()); + return input()->shortcuts()->processKey(static_cast(event)->modifiersRelevantForGlobalShortcuts(), event->key()); } } return false; } - bool swipeGestureBegin(int fingerCount, quint32 time) override { + bool swipeGestureBegin(int fingerCount, quint32 time) override + { Q_UNUSED(time) input()->shortcuts()->processSwipeStart(fingerCount); return false; } - bool swipeGestureUpdate(const QSizeF &delta, quint32 time) override { + bool swipeGestureUpdate(const QSizeF &delta, quint32 time) override + { Q_UNUSED(time) input()->shortcuts()->processSwipeUpdate(delta); return false; } - bool swipeGestureCancelled(quint32 time) override { + bool swipeGestureCancelled(quint32 time) override + { Q_UNUSED(time) input()->shortcuts()->processSwipeCancel(); return false; } - bool swipeGestureEnd(quint32 time) override { + bool swipeGestureEnd(quint32 time) override + { Q_UNUSED(time) input()->shortcuts()->processSwipeEnd(); return false; } - bool pinchGestureBegin(int fingerCount, quint32 time) override { + bool pinchGestureBegin(int fingerCount, quint32 time) override + { Q_UNUSED(time); if (fingerCount >= 3) { input()->shortcuts()->processPinchStart(fingerCount); } return false; } - bool pinchGestureUpdate(qreal scale, qreal angleDelta, const QSizeF &delta, quint32 time) override { + bool pinchGestureUpdate(qreal scale, qreal angleDelta, const QSizeF &delta, quint32 time) override + { Q_UNUSED(time); input()->shortcuts()->processPinchUpdate(scale, angleDelta, delta); return false; } - bool pinchGestureEnd(quint32 time) override { + bool pinchGestureEnd(quint32 time) override + { Q_UNUSED(time); input()->shortcuts()->processPinchEnd(); return false; } - bool pinchGestureCancelled(quint32 time) override { + bool pinchGestureCancelled(quint32 time) override + { Q_UNUSED(time); input()->shortcuts()->processPinchCancel(); return false; } private: - QTimer* m_powerDown = nullptr; + QTimer *m_powerDown = nullptr; }; - -namespace { +namespace +{ enum class MouseAction { ModifierOnly, @@ -984,7 +1058,7 @@ std::pair performClientMouseAction(QMouseEvent *event, AbstractClien { Options::MouseCommand command = Options::MouseNothing; bool wasAction = false; - if (static_cast(event)->modifiersRelevantForGlobalShortcuts() == options->commandAllModifier()) { + if (static_cast(event)->modifiersRelevantForGlobalShortcuts() == options->commandAllModifier()) { if (!input()->pointer()->isConstrained() && !workspace()->globalShortcutsDisabled()) { wasAction = true; switch (event->button()) { @@ -1017,7 +1091,7 @@ std::pair performClientWheelAction(QWheelEvent *event, AbstractClien { bool wasAction = false; Options::MouseCommand command = Options::MouseNothing; - if (static_cast(event)->modifiersRelevantForGlobalShortcuts() == options->commandAllModifier()) { + if (static_cast(event)->modifiersRelevantForGlobalShortcuts() == options->commandAllModifier()) { if (!input()->pointer()->isConstrained() && !workspace()->globalShortcutsDisabled()) { wasAction = true; command = options->operationWindowMouseWheel(-1 * event->angleDelta().y()); @@ -1035,8 +1109,10 @@ std::pair performClientWheelAction(QWheelEvent *event, AbstractClien } -class InternalWindowEventFilter : public InputEventFilter { - bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { +class InternalWindowEventFilter : public InputEventFilter +{ + bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override + { Q_UNUSED(nativeButton) if (!input()->pointer()->focus() || !input()->pointer()->focus()->isInternal()) { return false; @@ -1049,7 +1125,8 @@ class InternalWindowEventFilter : public InputEventFilter { QCoreApplication::sendEvent(internal, &mouseEvent); return mouseEvent.isAccepted(); } - bool wheelEvent(QWheelEvent *event) override { + bool wheelEvent(QWheelEvent *event) override + { if (!input()->pointer()->focus() || !input()->pointer()->focus()->isInternal()) { return false; } @@ -1066,7 +1143,8 @@ class InternalWindowEventFilter : public InputEventFilter { QCoreApplication::sendEvent(internal, &wheelEvent); return wheelEvent.isAccepted(); } - bool keyEvent(QKeyEvent *event) override { + bool keyEvent(QKeyEvent *event) override + { const QList &clients = workspace()->internalClients(); QWindow *found = nullptr; for (auto it = clients.crbegin(); it != clients.crend(); ++it) { @@ -1097,10 +1175,10 @@ class InternalWindowEventFilter : public InputEventFilter { return false; } auto xkb = input()->keyboard()->xkb(); - Qt::Key key = xkb->toQtKey( xkb->toKeysym(event->nativeScanCode()), - event->nativeScanCode(), - Qt::KeyboardModifiers(), - true /* workaround for QTBUG-62102 */ ); + Qt::Key key = xkb->toQtKey(xkb->toKeysym(event->nativeScanCode()), + event->nativeScanCode(), + Qt::KeyboardModifiers(), + true /* workaround for QTBUG-62102 */); QKeyEvent internalEvent(event->type(), key, event->modifiers(), event->nativeScanCode(), event->nativeVirtualKey(), event->nativeModifiers(), event->text()); @@ -1113,7 +1191,8 @@ class InternalWindowEventFilter : public InputEventFilter { return false; } - bool touchDown(qint32 id, const QPointF &pos, quint32 time) override { + bool touchDown(qint32 id, const QPointF &pos, quint32 time) override + { auto seat = waylandServer()->seat(); if (seat->isTouchSequence()) { // something else is getting the events @@ -1144,7 +1223,8 @@ class InternalWindowEventFilter : public InputEventFilter { QCoreApplication::sendEvent(internal, &e); return true; } - bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override { + bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override + { auto touch = input()->touch(); if (!input()->touch()->focus() || !input()->touch()->focus()->isInternal()) { return false; @@ -1165,7 +1245,8 @@ class InternalWindowEventFilter : public InputEventFilter { QCoreApplication::instance()->sendEvent(internal, &e); return true; } - bool touchUp(qint32 id, quint32 time) override { + bool touchUp(qint32 id, quint32 time) override + { auto touch = input()->touch(); const bool removed = m_pressedIds.remove(id); if (touch->internalPressId() == -1) { @@ -1193,15 +1274,18 @@ class InternalWindowEventFilter : public InputEventFilter { input()->touch()->setInternalPressId(-1); return true; } + private: QSet m_pressedIds; QPointF m_lastGlobalTouchPos; QPointF m_lastLocalTouchPos; }; -class DecorationEventFilter : public InputEventFilter { +class DecorationEventFilter : public InputEventFilter +{ public: - bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { + bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override + { Q_UNUSED(nativeButton) auto decoration = input()->pointer()->decoration(); if (!decoration) { @@ -1238,7 +1322,8 @@ public: } return false; } - bool wheelEvent(QWheelEvent *event) override { + bool wheelEvent(QWheelEvent *event) override + { auto decoration = input()->pointer()->decoration(); if (!decoration) { return false; @@ -1254,11 +1339,11 @@ public: const Qt::Orientation orientation = (event->angleDelta().x() != 0) ? Qt::Horizontal : Qt::Vertical; const int delta = event->angleDelta().x() != 0 ? event->angleDelta().x() : event->angleDelta().y(); QWheelEvent e(localPos, event->globalPosition(), QPoint(), - event->angleDelta(), - event->buttons(), - event->modifiers(), - Qt::NoScrollPhase, - false); + event->angleDelta(), + event->buttons(), + event->modifiers(), + Qt::NoScrollPhase, + false); e.setAccepted(false); QCoreApplication::sendEvent(decoration, &e); if (e.isAccepted()) { @@ -1266,11 +1351,12 @@ public: } if ((orientation == Qt::Vertical) && decoration->client()->titlebarPositionUnderMouse()) { decoration->client()->performMouseCommand(options->operationTitlebarMouseWheel(delta * -1), - event->globalPosition().toPoint()); + event->globalPosition().toPoint()); } return true; } - bool touchDown(qint32 id, const QPointF &pos, quint32 time) override { + bool touchDown(qint32 id, const QPointF &pos, quint32 time) override + { auto seat = waylandServer()->seat(); if (seat->isTouchSequence()) { return false; @@ -1300,7 +1386,8 @@ public: } return true; } - bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override { + bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override + { Q_UNUSED(time) auto decoration = input()->touch()->decoration(); if (!decoration) { @@ -1321,7 +1408,8 @@ public: decoration->client()->processDecorationMove(m_lastLocalTouchPos.toPoint(), pos.toPoint()); return true; } - bool touchUp(qint32 id, quint32 time) override { + bool touchUp(qint32 id, quint32 time) override + { Q_UNUSED(time); auto decoration = input()->touch()->decoration(); if (!decoration) { @@ -1356,7 +1444,8 @@ public: input()->touch()->setDecorationPressId(-1); return true; } - bool tabletToolEvent(TabletEvent *event) override { + bool tabletToolEvent(TabletEvent *event) override + { auto decoration = input()->tablet()->decoration(); if (!decoration) { return false; @@ -1400,6 +1489,7 @@ public: // Let TabletInputFilter receive the event, so the tablet can be registered and the cursor position can be updated. return false; } + private: QPointF m_lastGlobalTouchPos; QPointF m_lastLocalTouchPos; @@ -1409,14 +1499,16 @@ private: class TabBoxInputFilter : public InputEventFilter { public: - bool pointerEvent(QMouseEvent *event, quint32 button) override { + bool pointerEvent(QMouseEvent *event, quint32 button) override + { Q_UNUSED(button) if (!TabBox::TabBox::self() || !TabBox::TabBox::self()->isGrabbed()) { return false; } return TabBox::TabBox::self()->handleMouseEvent(event); } - bool keyEvent(QKeyEvent *event) override { + bool keyEvent(QKeyEvent *event) override + { if (!TabBox::TabBox::self() || !TabBox::TabBox::self()->isGrabbed()) { return false; } @@ -1429,12 +1521,13 @@ public: if (event->type() == QEvent::KeyPress) { TabBox::TabBox::self()->keyPress(event->modifiers() | event->key()); - } else if (static_cast(event)->modifiersRelevantForGlobalShortcuts() == Qt::NoModifier) { + } else if (static_cast(event)->modifiersRelevantForGlobalShortcuts() == Qt::NoModifier) { TabBox::TabBox::self()->modifiersReleased(); } return true; } - bool wheelEvent(QWheelEvent *event) override { + bool wheelEvent(QWheelEvent *event) override + { if (!TabBox::TabBox::self() || !TabBox::TabBox::self()->isGrabbed()) { return false; } @@ -1446,13 +1539,15 @@ public: class ScreenEdgeInputFilter : public InputEventFilter { public: - bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { + bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override + { Q_UNUSED(nativeButton) ScreenEdges::self()->isEntered(event); // always forward return false; } - bool touchDown(qint32 id, const QPointF &pos, quint32 time) override { + bool touchDown(qint32 id, const QPointF &pos, quint32 time) override + { Q_UNUSED(time) // TODO: better check whether a touch sequence is in progress if (m_touchInProgress || waylandServer()->seat()->isTouchSequence()) { @@ -1470,7 +1565,8 @@ public: } return false; } - bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override { + bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override + { Q_UNUSED(time) if (m_touchInProgress && m_id == id) { ScreenEdges::self()->gestureRecognizer()->updateSwipeGesture(QSizeF(pos.x() - m_lastPos.x(), pos.y() - m_lastPos.y())); @@ -1479,7 +1575,8 @@ public: } return false; } - bool touchUp(qint32 id, quint32 time) override { + bool touchUp(qint32 id, quint32 time) override + { Q_UNUSED(time) if (m_touchInProgress && m_id == id) { ScreenEdges::self()->gestureRecognizer()->endSwipeGesture(); @@ -1488,6 +1585,7 @@ public: } return false; } + private: bool m_touchInProgress = false; qint32 m_id = 0; @@ -1501,12 +1599,13 @@ private: class WindowActionInputFilter : public InputEventFilter { public: - bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { + bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override + { Q_UNUSED(nativeButton) if (event->type() != QEvent::MouseButtonPress) { return false; } - AbstractClient *c = dynamic_cast(input()->pointer()->focus()); + AbstractClient *c = dynamic_cast(input()->pointer()->focus()); if (!c) { return false; } @@ -1516,12 +1615,13 @@ public: } return false; } - bool wheelEvent(QWheelEvent *event) override { + bool wheelEvent(QWheelEvent *event) override + { if (event->angleDelta().y() == 0) { // only actions on vertical scroll return false; } - AbstractClient *c = dynamic_cast(input()->pointer()->focus()); + AbstractClient *c = dynamic_cast(input()->pointer()->focus()); if (!c) { return false; } @@ -1531,14 +1631,15 @@ public: } return false; } - bool touchDown(qint32 id, const QPointF &pos, quint32 time) override { + bool touchDown(qint32 id, const QPointF &pos, quint32 time) override + { Q_UNUSED(id) Q_UNUSED(time) auto seat = waylandServer()->seat(); if (seat->isTouchSequence()) { return false; } - AbstractClient *c = dynamic_cast(input()->touch()->focus()); + AbstractClient *c = dynamic_cast(input()->touch()->focus()); if (!c) { return false; } @@ -1549,11 +1650,12 @@ public: } return false; } - bool tabletToolEvent(TabletEvent *event) override { + bool tabletToolEvent(TabletEvent *event) override + { if (event->type() != QEvent::TabletPress) { return false; } - AbstractClient *c = dynamic_cast(input()->tablet()->focus()); + AbstractClient *c = dynamic_cast(input()->tablet()->focus()); if (!c) { return false; } @@ -1581,13 +1683,14 @@ public: class ForwardInputFilter : public InputEventFilter { public: - bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { + bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override + { auto seat = waylandServer()->seat(); seat->setTimestamp(event->timestamp()); switch (event->type()) { case QEvent::MouseMove: { seat->notifyPointerMotion(event->globalPos()); - MouseEvent *e = static_cast(event); + MouseEvent *e = static_cast(event); if (e->delta() != QSizeF()) { seat->relativePointerMotion(e->delta(), e->deltaUnaccelerated(), e->timestampMicroseconds()); } @@ -1607,7 +1710,8 @@ public: } return true; } - bool wheelEvent(QWheelEvent *event) override { + bool wheelEvent(QWheelEvent *event) override + { auto seat = waylandServer()->seat(); seat->setTimestamp(event->timestamp()); auto _event = static_cast(event); @@ -1616,7 +1720,8 @@ public: seat->notifyPointerFrame(); return true; } - bool keyEvent(QKeyEvent *event) override { + bool keyEvent(QKeyEvent *event) override + { if (event->isAutoRepeat()) { // handled by Wayland client return false; @@ -1627,68 +1732,79 @@ public: passToWaylandServer(event); return true; } - bool touchDown(qint32 id, const QPointF &pos, quint32 time) override { + bool touchDown(qint32 id, const QPointF &pos, quint32 time) override + { auto seat = waylandServer()->seat(); seat->setTimestamp(time); seat->notifyTouchDown(id, pos); return true; } - bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override { + bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override + { auto seat = waylandServer()->seat(); seat->setTimestamp(time); seat->notifyTouchMotion(id, pos); return true; } - bool touchUp(qint32 id, quint32 time) override { + bool touchUp(qint32 id, quint32 time) override + { auto seat = waylandServer()->seat(); seat->setTimestamp(time); seat->notifyTouchUp(id); return true; } - bool pinchGestureBegin(int fingerCount, quint32 time) override { + bool pinchGestureBegin(int fingerCount, quint32 time) override + { auto seat = waylandServer()->seat(); seat->setTimestamp(time); seat->startPointerPinchGesture(fingerCount); return true; } - bool pinchGestureUpdate(qreal scale, qreal angleDelta, const QSizeF &delta, quint32 time) override { + bool pinchGestureUpdate(qreal scale, qreal angleDelta, const QSizeF &delta, quint32 time) override + { auto seat = waylandServer()->seat(); seat->setTimestamp(time); seat->updatePointerPinchGesture(delta, scale, angleDelta); return true; } - bool pinchGestureEnd(quint32 time) override { + bool pinchGestureEnd(quint32 time) override + { auto seat = waylandServer()->seat(); seat->setTimestamp(time); seat->endPointerPinchGesture(); return true; } - bool pinchGestureCancelled(quint32 time) override { + bool pinchGestureCancelled(quint32 time) override + { auto seat = waylandServer()->seat(); seat->setTimestamp(time); seat->cancelPointerPinchGesture(); return true; } - bool swipeGestureBegin(int fingerCount, quint32 time) override { + bool swipeGestureBegin(int fingerCount, quint32 time) override + { auto seat = waylandServer()->seat(); seat->setTimestamp(time); seat->startPointerSwipeGesture(fingerCount); return true; } - bool swipeGestureUpdate(const QSizeF &delta, quint32 time) override { + bool swipeGestureUpdate(const QSizeF &delta, quint32 time) override + { auto seat = waylandServer()->seat(); seat->setTimestamp(time); seat->updatePointerSwipeGesture(delta); return true; } - bool swipeGestureEnd(quint32 time) override { + bool swipeGestureEnd(quint32 time) override + { auto seat = waylandServer()->seat(); seat->setTimestamp(time); seat->endPointerSwipeGesture(); return true; } - bool swipeGestureCancelled(quint32 time) override { + bool swipeGestureCancelled(quint32 time) override + { auto seat = waylandServer()->seat(); seat->setTimestamp(time); seat->cancelPointerSwipeGesture(); @@ -1729,10 +1845,13 @@ static KWaylandServer::SeatInterface *findSeat() class SurfaceCursor : public Cursor { public: - explicit SurfaceCursor(QObject *parent) : Cursor(parent) - {} + explicit SurfaceCursor(QObject *parent) + : Cursor(parent) + { + } - void updateCursorSurface(KWaylandServer::SurfaceInterface *surface, const QPoint &hotspot) { + void updateCursorSurface(KWaylandServer::SurfaceInterface *surface, const QPoint &hotspot) + { if (m_surface == surface && hotspot == m_hotspot) { return; } @@ -1841,7 +1960,8 @@ public: } } - KWaylandServer::TabletToolV2Interface::Type getType(const KWin::TabletToolId &tabletToolId) { + KWaylandServer::TabletToolV2Interface::Type getType(const KWin::TabletToolId &tabletToolId) + { using Type = KWaylandServer::TabletToolV2Interface::Type; switch (tabletToolId.m_toolType) { case InputRedirection::Pen: @@ -1898,7 +2018,7 @@ public: Cursors::self()->addCursor(cursor); m_cursorByTool[tool] = cursor; - connect(tool, &TabletToolV2Interface::cursorChanged, cursor, [cursor] (TabletCursorV2 *tcursor) { + connect(tool, &TabletToolV2Interface::cursorChanged, cursor, [cursor](TabletCursorV2 *tcursor) { static const auto createDefaultCursor = [] { WaylandCursorImage defaultCursor; WaylandCursorImage::Image ret; @@ -1960,13 +2080,15 @@ public: tool->sendMotion(pos); m_cursorByTool[tool]->setPos(event->globalPos()); break; - } case QEvent::TabletEnterProximity: { + } + case QEvent::TabletEnterProximity: { const QPoint pos = event->globalPos(); m_cursorByTool[tool]->setPos(pos); tool->sendProximityIn(tablet); tool->sendMotion(toplevel->mapToLocal(event->globalPosF())); break; - } case QEvent::TabletLeaveProximity: + } + case QEvent::TabletLeaveProximity: tool->sendProximityOut(); break; case QEvent::TabletPress: { @@ -2091,7 +2213,7 @@ public: return true; } - QHash m_cursorByTool; + QHash m_cursorByTool; }; static KWaylandServer::AbstractDropHandler *dropHandler(Toplevel *toplevel) @@ -2102,9 +2224,11 @@ static KWaylandServer::AbstractDropHandler *dropHandler(Toplevel *toplevel) } auto seat = waylandServer()->seat(); auto dropTarget = seat->dropHandlerForSurface(surface); - if (dropTarget) {return dropTarget;} + if (dropTarget) { + return dropTarget; + } - if (qobject_cast(toplevel) && xwayland()) { + if (qobject_cast(toplevel) && xwayland()) { return xwayland()->xwlDropHandler(); } @@ -2122,7 +2246,8 @@ public: connect(&m_raiseTimer, &QTimer::timeout, this, &DragAndDropInputFilter::raiseDragTarget); } - bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override { + bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override + { auto seat = waylandServer()->seat(); if (!seat->isDragPointer()) { return false; @@ -2140,7 +2265,7 @@ public: const auto eventPos = event->globalPos(); // TODO: use InputDeviceHandler::at() here and check isClient()? Toplevel *t = input()->findManagedToplevel(eventPos); - const auto dragTarget = qobject_cast(t); + const auto dragTarget = qobject_cast(t); if (dragTarget) { if (dragTarget != m_dragTarget) { workspace()->takeActivity(dragTarget, Workspace::ActivityFlag::ActivityFocus); @@ -2192,7 +2317,8 @@ public: return true; } - bool touchDown(qint32 id, const QPointF &pos, quint32 time) override { + bool touchDown(qint32 id, const QPointF &pos, quint32 time) override + { auto seat = waylandServer()->seat(); if (seat->isDragPointer()) { return true; @@ -2208,7 +2334,8 @@ public: m_lastPos = pos; return true; } - bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override { + bool touchMotion(qint32 id, const QPointF &pos, quint32 time) override + { auto seat = waylandServer()->seat(); if (seat->isDragPointer()) { return true; @@ -2231,7 +2358,7 @@ public: if (Toplevel *t = input()->findToplevel(pos.toPoint())) { // TODO: consider decorations if (t->surface() != seat->dragSurface()) { - if ((m_dragTarget = qobject_cast(t))) { + if ((m_dragTarget = qobject_cast(t))) { workspace()->takeActivity(m_dragTarget, Workspace::ActivityFlag::ActivityFocus); m_raiseTimer.start(); } @@ -2249,7 +2376,8 @@ public: } return true; } - bool touchUp(qint32 id, quint32 time) override { + bool touchUp(qint32 id, quint32 time) override + { auto seat = waylandServer()->seat(); if (!seat->isDragTouch()) { return false; @@ -2278,6 +2406,7 @@ public: return true; } + private: void raiseDragTarget() { @@ -2537,7 +2666,7 @@ void InputRedirection::setupInputFilters() { const bool hasGlobalShortcutSupport = waylandServer()->hasGlobalShortcutSupport(); if ((kwinApp()->platform()->session()->capabilities() & Session::Capability::SwitchTerminal) - && hasGlobalShortcutSupport) { + && hasGlobalShortcutSupport) { installInputEventFilter(new VirtualTerminalFilter); } installInputEventSpy(new HideCursorSpy); @@ -2628,7 +2757,7 @@ void InputRedirection::addInputDevice(InputDevice *device) connect(device, &InputDevice::touchCanceled, m_touch, &TouchInputRedirection::cancel); connect(device, &InputDevice::touchFrame, m_touch, &TouchInputRedirection::frame); - auto handleSwitchEvent = [this] (SwitchEvent::State state, quint32 time, quint64 timeMicroseconds, InputDevice *device) { + auto handleSwitchEvent = [this](SwitchEvent::State state, quint32 time, quint64 timeMicroseconds, InputDevice *device) { SwitchEvent event(state, time, timeMicroseconds, device); processSpies(std::bind(&InputEventSpy::switchEvent, std::placeholders::_1, &event)); processFilters(std::bind(&InputEventFilter::switchEvent, std::placeholders::_1, &event)); @@ -2727,8 +2856,7 @@ void InputRedirection::toggleTouchpads() QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.plasmashell"), QStringLiteral("/org/kde/osdService"), QStringLiteral("org.kde.osdService"), - QStringLiteral("touchpadEnabledChanged") - ); + QStringLiteral("touchpadEnabledChanged")); msg.setArguments({m_touchpadsEnabled}); QDBusConnection::sessionBus().asyncCall(msg); } @@ -2838,7 +2966,7 @@ Toplevel *InputRedirection::findToplevel(const QPoint &pos) // TODO: check whether the unmanaged wants input events at all if (!isScreenLocked) { // if an effect overrides the cursor we don't have a window to focus - if (effects && static_cast(effects)->isMouseInterception()) { + if (effects && static_cast(effects)->isMouseInterception()) { return nullptr; } const QList &unmanaged = Workspace::self()->unmanagedList(); @@ -2869,7 +2997,7 @@ Toplevel *InputRedirection::findManagedToplevel(const QPoint &pos) // a deleted window doesn't get mouse events continue; } - if (AbstractClient *c = dynamic_cast(t)) { + if (AbstractClient *c = dynamic_cast(t)) { if (!c->isOnCurrentActivity() || !c->isOnCurrentDesktop() || c->isMinimized() || c->isHiddenInternal()) { continue; } @@ -2955,7 +3083,7 @@ QPointF InputRedirection::globalPointer() const return m_pointer->pos(); } -void InputRedirection::startInteractiveWindowSelection(std::function callback, const QByteArray &cursorName) +void InputRedirection::startInteractiveWindowSelection(std::function callback, const QByteArray &cursorName) { if (!m_windowSelector || m_windowSelector->isActive()) { callback(nullptr); @@ -3037,7 +3165,7 @@ void InputDeviceHandler::updateFocus() // Therefore listen for its creation. if (!m_hover.surfaceCreatedConnection) { m_hover.surfaceCreatedConnection = connect(m_hover.window, &Toplevel::surfaceChanged, - this, &InputDeviceHandler::update); + this, &InputDeviceHandler::update); } focus = nullptr; } @@ -3048,7 +3176,7 @@ void InputDeviceHandler::updateFocus() void InputDeviceHandler::updateDecoration() { Decoration::DecoratedClientImpl *decoration = nullptr; - auto *ac = qobject_cast(m_hover.window); + auto *ac = qobject_cast(m_hover.window); if (ac && ac->decoratedClient()) { if (!ac->clientGeometry().contains(position().toPoint())) { // input device above decoration diff --git a/src/input.h b/src/input.h index 963f4a28f6..65de17a0ba 100644 --- a/src/input.h +++ b/src/input.h @@ -10,12 +10,13 @@ */ #ifndef KWIN_INPUT_H #define KWIN_INPUT_H -#include +#include + #include #include #include #include -#include +#include #include #include @@ -130,7 +131,7 @@ public: * 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 + 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); @@ -165,7 +166,8 @@ public: Toplevel *findToplevel(const QPoint &pos); Toplevel *findManagedToplevel(const QPoint &pos); - GlobalShortcutsManager *shortcuts() const { + GlobalShortcutsManager *shortcuts() const + { return m_shortcuts; } @@ -183,8 +185,9 @@ public: * The intended usage is to std::bind the method to invoke on the filter with all arguments * bind. */ - template - void processFilters(UnaryPredicate function) { + template + void processFilters(UnaryPredicate function) + { std::any_of(m_filters.constBegin(), m_filters.constEnd(), function); } @@ -201,21 +204,26 @@ public: * The intended usage is to std::bind the method to invoke on the spies with all arguments * bind. */ - template - void processSpies(UnaryFunction function) { + template + void processSpies(UnaryFunction function) + { std::for_each(m_spies.constBegin(), m_spies.constEnd(), function); } - KeyboardInputRedirection *keyboard() const { + KeyboardInputRedirection *keyboard() const + { return m_keyboard; } - PointerInputRedirection *pointer() const { + PointerInputRedirection *pointer() const + { return m_pointer; } - TabletInputRedirection *tablet() const { + TabletInputRedirection *tablet() const + { return m_tablet; } - TouchInputRedirection *touch() const { + TouchInputRedirection *touch() const + { return m_touch; } @@ -232,7 +240,7 @@ public: bool hasTouch() const; bool hasTabletModeSwitch(); - void startInteractiveWindowSelection(std::function callback, const QByteArray &cursorName); + void startInteractiveWindowSelection(std::function callback, const QByteArray &cursorName); void startInteractivePositionSelection(std::function callback); bool isSelectingWindow() const; @@ -316,8 +324,8 @@ private: WindowSelectorFilter *m_windowSelector = nullptr; - QVector m_filters; - QVector m_spies; + QVector m_filters; + QVector m_spies; KConfigWatcher::Ptr m_inputConfigWatcher; LEDs m_leds; @@ -470,17 +478,21 @@ protected: * position. An example are touch screens when no finger/pen * is resting on the surface (no touch point). */ - virtual bool positionValid() const { + virtual bool positionValid() const + { return true; } - virtual bool focusUpdatesBlocked() { + virtual bool focusUpdatesBlocked() + { return false; } - inline bool inited() const { + inline bool inited() const + { return m_inited; } - inline void setInited(bool set) { + inline void setInited(bool set) + { m_inited = set; } @@ -489,12 +501,14 @@ private: void updateFocus(); void updateDecoration(); - struct { + struct + { QPointer window; QMetaObject::Connection surfaceCreatedConnection; } m_hover; - struct { + struct + { QPointer window; QPointer decoration; } m_focus; @@ -502,8 +516,7 @@ private: bool m_inited = false; }; -inline -InputRedirection *input() +inline InputRedirection *input() { return InputRedirection::s_self; } @@ -513,9 +526,9 @@ inline QList InputRedirection::devices() const return m_inputDevices; } -template -inline -void InputRedirection::registerShortcut(const QKeySequence &shortcut, QAction *action, T *receiver, Slot slot) { +template +inline void InputRedirection::registerShortcut(const QKeySequence &shortcut, QAction *action, T *receiver, Slot slot) +{ registerShortcut(shortcut, action); connect(action, &QAction::triggered, receiver, slot); } diff --git a/src/input_event.cpp b/src/input_event.cpp index 665a02310b..4fac01c638 100644 --- a/src/input_event.cpp +++ b/src/input_event.cpp @@ -15,11 +15,11 @@ MouseEvent::MouseEvent(QEvent::Type type, const QPointF &pos, Qt::MouseButton bu Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, quint32 timestamp, const QSizeF &delta, const QSizeF &deltaNonAccelerated, quint64 timestampMicroseconds, InputDevice *device) - : QMouseEvent(type, pos, pos, button, buttons, modifiers) - , m_delta(delta) - , m_deltaUnccelerated(deltaNonAccelerated) - , m_timestampMicroseconds(timestampMicroseconds) - , m_device(device) + : QMouseEvent(type, pos, pos, button, buttons, modifiers) + , m_delta(delta) + , m_deltaUnccelerated(deltaNonAccelerated) + , m_timestampMicroseconds(timestampMicroseconds) + , m_device(device) { setTimestamp(timestamp); } @@ -27,25 +27,25 @@ MouseEvent::MouseEvent(QEvent::Type type, const QPointF &pos, Qt::MouseButton bu WheelEvent::WheelEvent(const QPointF &pos, qreal delta, qint32 discreteDelta, Qt::Orientation orientation, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, InputRedirection::PointerAxisSource source, quint32 timestamp, InputDevice *device) - : QWheelEvent(pos, pos, QPoint(), (orientation == Qt::Horizontal) ? QPoint(delta, 0) : QPoint(0, delta), buttons, modifiers, Qt::NoScrollPhase, false) - , m_device(device) - , m_orientation(orientation) - , m_delta(delta) - , m_discreteDelta(discreteDelta) - , m_source(source) + : QWheelEvent(pos, pos, QPoint(), (orientation == Qt::Horizontal) ? QPoint(delta, 0) : QPoint(0, delta), buttons, modifiers, Qt::NoScrollPhase, false) + , m_device(device) + , m_orientation(orientation) + , m_delta(delta) + , m_discreteDelta(discreteDelta) + , m_source(source) { setTimestamp(timestamp); } KeyEvent::KeyEvent(QEvent::Type type, Qt::Key key, Qt::KeyboardModifiers modifiers, quint32 code, quint32 keysym, const QString &text, bool autorepeat, quint32 timestamp, InputDevice *device) - : QKeyEvent(type, key, modifiers, code, keysym, 0, text, autorepeat) - , m_device(device) + : QKeyEvent(type, key, modifiers, code, keysym, 0, text, autorepeat) + , m_device(device) { setTimestamp(timestamp); } -SwitchEvent::SwitchEvent(State state, quint32 timestamp, quint64 timestampMicroseconds, InputDevice* device) +SwitchEvent::SwitchEvent(State state, quint32 timestamp, quint64 timestampMicroseconds, InputDevice *device) : QInputEvent(QEvent::User) , m_state(state) , m_timestampMicroseconds(timestampMicroseconds) @@ -55,10 +55,10 @@ SwitchEvent::SwitchEvent(State state, quint32 timestamp, quint64 timestampMicros } TabletEvent::TabletEvent(Type t, const QPointF &pos, const QPointF &globalPos, - int device, int pointerType, qreal pressure, int xTilt, int yTilt, - qreal tangentialPressure, qreal rotation, int z, - Qt::KeyboardModifiers keyState, qint64 uniqueID, - Qt::MouseButton button, Qt::MouseButtons buttons, const TabletToolId &tabletId) + int device, int pointerType, qreal pressure, int xTilt, int yTilt, + qreal tangentialPressure, qreal rotation, int z, + Qt::KeyboardModifiers keyState, qint64 uniqueID, + Qt::MouseButton button, Qt::MouseButtons buttons, const TabletToolId &tabletId) : QTabletEvent(t, pos, globalPos, device, pointerType, pressure, xTilt, yTilt, tangentialPressure, rotation, z, keyState, uniqueID, button, buttons) , m_id(tabletId) { diff --git a/src/input_event.h b/src/input_event.h index acf134b80e..7cac99887f 100644 --- a/src/input_event.h +++ b/src/input_event.h @@ -26,35 +26,43 @@ public: const QSizeF &delta, const QSizeF &deltaNonAccelerated, quint64 timestampMicroseconds, InputDevice *device); - QSizeF delta() const { + QSizeF delta() const + { return m_delta; } - QSizeF deltaUnaccelerated() const { + QSizeF deltaUnaccelerated() const + { return m_deltaUnccelerated; } - quint64 timestampMicroseconds() const { + quint64 timestampMicroseconds() const + { return m_timestampMicroseconds; } - InputDevice *device() const { + InputDevice *device() const + { return m_device; } - Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const { + Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const + { return m_modifiersRelevantForShortcuts; } - void setModifiersRelevantForGlobalShortcuts(const Qt::KeyboardModifiers &mods) { + void setModifiersRelevantForGlobalShortcuts(const Qt::KeyboardModifiers &mods) + { m_modifiersRelevantForShortcuts = mods; } - quint32 nativeButton() const { + quint32 nativeButton() const + { return m_nativeButton; } - void setNativeButton(quint32 button) { + void setNativeButton(quint32 button) + { m_nativeButton = button; } @@ -75,31 +83,38 @@ public: Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, InputRedirection::PointerAxisSource source, quint32 timestamp, InputDevice *device); - Qt::Orientation orientation() const { + Qt::Orientation orientation() const + { return m_orientation; } - qreal delta() const { + qreal delta() const + { return m_delta; } - qint32 discreteDelta() const { + qint32 discreteDelta() const + { return m_discreteDelta; } - InputRedirection::PointerAxisSource axisSource() const { + InputRedirection::PointerAxisSource axisSource() const + { return m_source; } - InputDevice *device() const { + InputDevice *device() const + { return m_device; } - Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const { + Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const + { return m_modifiersRelevantForShortcuts; } - void setModifiersRelevantForGlobalShortcuts(const Qt::KeyboardModifiers &mods) { + void setModifiersRelevantForGlobalShortcuts(const Qt::KeyboardModifiers &mods) + { m_modifiersRelevantForShortcuts = mods; } @@ -118,15 +133,18 @@ public: explicit KeyEvent(QEvent::Type type, Qt::Key key, Qt::KeyboardModifiers modifiers, quint32 code, quint32 keysym, const QString &text, bool autorepeat, quint32 timestamp, InputDevice *device); - InputDevice *device() const { + InputDevice *device() const + { return m_device; } - Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const { + Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const + { return m_modifiersRelevantForShortcuts; } - void setModifiersRelevantForGlobalShortcuts(const Qt::KeyboardModifiers &mods) { + void setModifiersRelevantForGlobalShortcuts(const Qt::KeyboardModifiers &mods) + { m_modifiersRelevantForShortcuts = mods; } @@ -144,15 +162,18 @@ public: }; explicit SwitchEvent(State state, quint32 timestamp, quint64 timestampMicroseconds, InputDevice *device); - State state() const { + State state() const + { return m_state; } - quint64 timestampMicroseconds() const { + quint64 timestampMicroseconds() const + { return m_timestampMicroseconds; } - InputDevice *device() const { + InputDevice *device() const + { return m_device; } @@ -187,7 +208,8 @@ public: Qt::KeyboardModifiers keyState, qint64 uniqueID, Qt::MouseButton button, Qt::MouseButtons buttons, const TabletToolId &tabletId); - const TabletToolId &tabletId() const { + const TabletToolId &tabletId() const + { return m_id; } diff --git a/src/input_event_spy.h b/src/input_event_spy.h index 0d081d39af..b8e4208e25 100644 --- a/src/input_event_spy.h +++ b/src/input_event_spy.h @@ -87,7 +87,6 @@ public: virtual void tabletPadRingEvent(int number, int position, bool isFinger, const TabletPadId &tabletPadId); }; - } // namespace KWin #endif diff --git a/src/inputbackend.h b/src/inputbackend.h index ec51e8274d..6b33cf6656 100644 --- a/src/inputbackend.h +++ b/src/inputbackend.h @@ -27,7 +27,9 @@ public: KSharedConfigPtr config() const; void setConfig(KSharedConfigPtr config); - virtual void initialize() {} + virtual void initialize() + { + } Q_SIGNALS: void deviceAdded(InputDevice *device); diff --git a/src/inputdevice.h b/src/inputdevice.h index 5d2bad2bff..0fe5ffe8ac 100644 --- a/src/inputdevice.h +++ b/src/inputdevice.h @@ -7,8 +7,8 @@ #pragma once -#include "kwin_export.h" #include "input.h" +#include "kwin_export.h" #include diff --git a/src/inputmethod.cpp b/src/inputmethod.cpp index 344f86646c..47ac7b23df 100644 --- a/src/inputmethod.cpp +++ b/src/inputmethod.cpp @@ -6,43 +6,44 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include #include "inputmethod.h" + +#include + #include "abstract_client.h" -#include "virtualkeyboard_dbus.h" #include "input.h" #include "inputpanelv1client.h" #include "keyboard_input.h" -#include "utils/common.h" #include "screens.h" +#include "utils/common.h" +#include "virtualkeyboard_dbus.h" #include "wayland_server.h" #include "workspace.h" #if KWIN_BUILD_SCREENLOCKER #include "screenlockerwatcher.h" #endif #include "deleted.h" -#include "touch_input.h" #include "tablet_input.h" +#include "touch_input.h" +#include +#include #include +#include #include #include -#include #include -#include - -#include -#include +#include #include -#include #include -#include +#include #include +#include #include -#include #include +#include using namespace KWaylandServer; @@ -190,7 +191,7 @@ void InputMethod::setPanel(InputPanelV1Client *client) Q_EMIT panelChanged(); } -void InputMethod::setTrackedClient(AbstractClient* trackedClient) +void InputMethod::setTrackedClient(AbstractClient *trackedClient) { // Reset the old client virtual keybaord geom if necessary // Old and new clients could be the same if focus moves between subsurfaces @@ -340,8 +341,7 @@ void InputMethod::setEnabled(bool enabled) QStringLiteral("org.kde.plasmashell"), QStringLiteral("/org/kde/osdService"), QStringLiteral("org.kde.osdService"), - QStringLiteral("virtualKeyboardEnabledChanged") - ); + QStringLiteral("virtualKeyboardEnabledChanged")); msg.setArguments({enabled}); QDBusConnection::sessionBus().asyncCall(msg); if (!m_enabled) { @@ -357,7 +357,7 @@ void InputMethod::setEnabled(bool enabled) static quint32 keysymToKeycode(quint32 sym) { - switch(sym) { + switch (sym) { case XKB_KEY_BackSpace: return KEY_BACKSPACE; case XKB_KEY_Return: @@ -520,7 +520,7 @@ void InputMethod::setPreeditString(uint32_t serial, const QString &text, const Q if (preedit.highlightRanges.front().first == cursor) { quint32 end = preedit.highlightRanges.front().second; bool nonContinousHighlight = false; - for (size_t i = 1 ; i < preedit.highlightRanges.size(); i ++) { + for (size_t i = 1; i < preedit.highlightRanges.size(); i++) { if (end >= preedit.highlightRanges[i].first) { end = std::max(end, preedit.highlightRanges[i].second); } else { @@ -752,7 +752,8 @@ bool InputMethod::isAvailable() const return !m_inputMethodCommand.isEmpty(); } -void InputMethod::resetPendingPreedit() { +void InputMethod::resetPendingPreedit() +{ preedit.text = QString(); preedit.cursor = 0; preedit.highlightRanges.clear(); diff --git a/src/inputmethod.h b/src/inputmethod.h index 7bcd299803..19cb750a13 100644 --- a/src/inputmethod.h +++ b/src/inputmethod.h @@ -9,17 +9,17 @@ #ifndef KWIN_VIRTUAL_KEYBOARD_H #define KWIN_VIRTUAL_KEYBOARD_H -#include #include +#include #include -#include #include +#include +#include #include #include -#include class QProcess; @@ -42,13 +42,17 @@ class KWIN_EXPORT InputMethod : public QObject { Q_OBJECT public: - enum ForwardModifiersForce { NoForce = 0, Force = 1 }; + enum ForwardModifiersForce { + NoForce = 0, + Force = 1, + }; ~InputMethod() override; void init(); void setEnabled(bool enable); - bool isEnabled() const { + bool isEnabled() const + { return m_enabled; } bool isActive() const; @@ -59,7 +63,7 @@ public: bool isAvailable() const; InputPanelV1Client *panel() const; - void setPanel(InputPanelV1Client* client); + void setPanel(InputPanelV1Client *client); void setInputMethodCommand(const QString &path); KWaylandServer::InputMethodGrabV1 *keyboardGrab(); @@ -109,7 +113,8 @@ private: bool touchEventTriggered() const; void resetPendingPreedit(); - struct { + struct + { QString text = QString(); qint32 cursor = 0; std::vector> highlightRanges; diff --git a/src/inputpanelv1client.cpp b/src/inputpanelv1client.cpp index 477eeabb50..3eec3f8f0c 100644 --- a/src/inputpanelv1client.cpp +++ b/src/inputpanelv1client.cpp @@ -8,12 +8,12 @@ */ #include "inputpanelv1client.h" +#include "abstract_wayland_output.h" #include "deleted.h" +#include "inputmethod.h" +#include "platform.h" #include "wayland_server.h" #include "workspace.h" -#include "abstract_wayland_output.h" -#include "platform.h" -#include "inputmethod.h" #include #include #include @@ -74,69 +74,69 @@ void KWin::InputPanelV1Client::reposition() } switch (m_mode) { - case Toplevel: { - QSize panelSize = surface()->size(); - if (!panelSize.isValid() || panelSize.isEmpty()) { - return; - } + case Toplevel: { + QSize panelSize = surface()->size(); + if (!panelSize.isValid() || panelSize.isEmpty()) { + return; + } - QRect availableArea; - QRect outputArea; - if (m_output) { - outputArea = m_output->geometry(); - if (waylandServer()->isScreenLocked()) { - availableArea = outputArea; - } else { - availableArea = workspace()->clientArea(MaximizeArea, this, m_output); - } + QRect availableArea; + QRect outputArea; + if (m_output) { + outputArea = m_output->geometry(); + if (waylandServer()->isScreenLocked()) { + availableArea = outputArea; } else { - availableArea = workspace()->clientArea(MaximizeArea, this); - outputArea = workspace()->clientArea(FullScreenArea, this); + availableArea = workspace()->clientArea(MaximizeArea, this, m_output); } + } else { + availableArea = workspace()->clientArea(MaximizeArea, this); + outputArea = workspace()->clientArea(FullScreenArea, this); + } - panelSize = panelSize.boundedTo(availableArea.size()); + panelSize = panelSize.boundedTo(availableArea.size()); - QRect geo(availableArea.bottomLeft() - QPoint{0, panelSize.height()}, panelSize); - geo.translate((availableArea.width() - panelSize.width())/2, availableArea.height() - outputArea.height()); - moveResize(geo); - } break; - case Overlay: { - auto textInputSurface = waylandServer()->seat()->focusedTextInputSurface(); - auto textClient = waylandServer()->findClient(textInputSurface); - QRect cursorRectangle; - auto textInputV2 = waylandServer()->seat()->textInputV2(); - if (textInputV2 && textInputV2->isEnabled() && textInputV2->surface() == textInputSurface) { - cursorRectangle = textInputV2->cursorRectangle(); + QRect geo(availableArea.bottomLeft() - QPoint{0, panelSize.height()}, panelSize); + geo.translate((availableArea.width() - panelSize.width()) / 2, availableArea.height() - outputArea.height()); + moveResize(geo); + } break; + case Overlay: { + auto textInputSurface = waylandServer()->seat()->focusedTextInputSurface(); + auto textClient = waylandServer()->findClient(textInputSurface); + QRect cursorRectangle; + auto textInputV2 = waylandServer()->seat()->textInputV2(); + if (textInputV2 && textInputV2->isEnabled() && textInputV2->surface() == textInputSurface) { + cursorRectangle = textInputV2->cursorRectangle(); + } + auto textInputV3 = waylandServer()->seat()->textInputV3(); + if (textInputV3 && textInputV3->isEnabled() && textInputV3->surface() == textInputSurface) { + cursorRectangle = textInputV3->cursorRectangle(); + } + if (textClient) { + cursorRectangle.translate(textClient->bufferGeometry().topLeft()); + const QRect screen = Workspace::self()->clientArea(PlacementArea, cursorRectangle.bottomLeft(), 0); + + // Reuse the similar logic like xdg popup + QRect popupRect(popupOffset(cursorRectangle, Qt::BottomEdge | Qt::LeftEdge, Qt::RightEdge | Qt::BottomEdge, surface()->size()), surface()->size()); + + if (popupRect.left() < screen.left()) { + popupRect.moveLeft(screen.left()); } - auto textInputV3 = waylandServer()->seat()->textInputV3(); - if (textInputV3 && textInputV3->isEnabled() && textInputV3->surface() == textInputSurface) { - cursorRectangle = textInputV3->cursorRectangle(); + if (popupRect.right() > screen.right()) { + popupRect.moveRight(screen.right()); } - if (textClient) { - cursorRectangle.translate(textClient->bufferGeometry().topLeft()); - const QRect screen = Workspace::self()->clientArea(PlacementArea, cursorRectangle.bottomLeft(), 0); + if (popupRect.top() < screen.top() || popupRect.bottom() > screen.bottom()) { + auto flippedPopupRect = + QRect(popupOffset(cursorRectangle, Qt::TopEdge | Qt::LeftEdge, Qt::RightEdge | Qt::TopEdge, surface()->size()), surface()->size()); - // Reuse the similar logic like xdg popup - QRect popupRect(popupOffset(cursorRectangle, Qt::BottomEdge | Qt::LeftEdge, Qt::RightEdge | Qt::BottomEdge, surface()->size()), surface()->size()); - - if (popupRect.left() < screen.left()) { - popupRect.moveLeft(screen.left()); + // if it still doesn't fit we should continue with the unflipped version + if (flippedPopupRect.top() >= screen.top() || flippedPopupRect.bottom() <= screen.bottom()) { + popupRect.moveTop(flippedPopupRect.top()); } - if (popupRect.right() > screen.right()) { - popupRect.moveRight(screen.right()); - } - if (popupRect.top() < screen.top() || popupRect.bottom() > screen.bottom()) { - auto flippedPopupRect = - QRect(popupOffset(cursorRectangle, Qt::TopEdge | Qt::LeftEdge, Qt::RightEdge | Qt::TopEdge, surface()->size()), surface()->size()); - - // if it still doesn't fit we should continue with the unflipped version - if (flippedPopupRect.top() >= screen.top() || flippedPopupRect.bottom() <= screen.bottom()) { - popupRect.moveTop(flippedPopupRect.top()); - } - } - moveResize(popupRect); } - } break; + moveResize(popupRect); + } + } break; } } diff --git a/src/inputpanelv1client.h b/src/inputpanelv1client.h index 66ae8a1234..97172074f8 100644 --- a/src/inputpanelv1client.h +++ b/src/inputpanelv1client.h @@ -10,8 +10,8 @@ #pragma once #include "waylandclient.h" -#include #include +#include namespace KWin { @@ -30,16 +30,45 @@ public: Q_ENUM(Mode) void destroyClient() override; - bool isPlaceable() const override { return false; } - bool isCloseable() const override { return false; } - bool isResizable() const override { return false; } - bool isMovable() const override { return false; } - bool isMovableAcrossScreens() const override { return false; } - bool acceptsFocus() const override { return false; } - void closeWindow() override {} - bool takeFocus() override { return false; } - bool wantsInput() const override { return false; } - bool isInputMethod() const override { return true; } + bool isPlaceable() const override + { + return false; + } + bool isCloseable() const override + { + return false; + } + bool isResizable() const override + { + return false; + } + bool isMovable() const override + { + return false; + } + bool isMovableAcrossScreens() const override + { + return false; + } + bool acceptsFocus() const override + { + return false; + } + void closeWindow() override + { + } + bool takeFocus() override + { + return false; + } + bool wantsInput() const override + { + return false; + } + bool isInputMethod() const override + { + return true; + } NET::WindowType windowType(bool /*direct*/, int /*supported_types*/) const override; QRect inputGeometry() const override; @@ -56,7 +85,7 @@ private: void showTopLevel(KWaylandServer::OutputInterface *output, KWaylandServer::InputPanelSurfaceV1Interface::Position position); void showOverlayPanel(); void reposition(); - void setOutput(KWaylandServer::OutputInterface* output); + void setOutput(KWaylandServer::OutputInterface *output); QPointer m_output; Mode m_mode = Toplevel; diff --git a/src/internal_client.cpp b/src/internal_client.cpp index f5159ae64c..b6903feb69 100644 --- a/src/internal_client.cpp +++ b/src/internal_client.cpp @@ -107,7 +107,7 @@ void InternalClient::pointerLeaveEvent() bool InternalClient::eventFilter(QObject *watched, QEvent *event) { if (watched == m_internalWindow && event->type() == QEvent::DynamicPropertyChange) { - QDynamicPropertyChangeEvent *pe = static_cast(event); + QDynamicPropertyChangeEvent *pe = static_cast(event); if (pe->propertyName() == s_skipClosePropertyName) { setSkipCloseAnimation(m_internalWindow->property(s_skipClosePropertyName).toBool()); } @@ -377,9 +377,7 @@ void InternalClient::destroyClient() bool InternalClient::hasPopupGrab() const { - return !m_internalWindow->flags().testFlag(Qt::WindowTransparentForInput) && - m_internalWindow->flags().testFlag(Qt::Popup) && - !m_internalWindow->flags().testFlag(Qt::ToolTip); + return !m_internalWindow->flags().testFlag(Qt::WindowTransparentForInput) && m_internalWindow->flags().testFlag(Qt::Popup) && !m_internalWindow->flags().testFlag(Qt::ToolTip); } void InternalClient::popupDone() @@ -437,8 +435,7 @@ bool InternalClient::belongsToSameApplication(const AbstractClient *other, SameA if (otherInternal == this) { return true; } - return otherInternal->internalWindow()->isAncestorOf(internalWindow()) || - internalWindow()->isAncestorOf(otherInternal->internalWindow()); + return otherInternal->internalWindow()->isAncestorOf(internalWindow()) || internalWindow()->isAncestorOf(otherInternal->internalWindow()); } void InternalClient::doInteractiveResizeSync() @@ -526,7 +523,9 @@ void InternalClient::syncGeometryToInternalWindow() return; } - QTimer::singleShot(0, this, [this] { requestGeometry(frameGeometry()); }); + QTimer::singleShot(0, this, [this] { + requestGeometry(frameGeometry()); + }); } void InternalClient::updateInternalWindowGeometry() diff --git a/src/item.h b/src/item.h index 92fb7dbc9e..92f31c0977 100644 --- a/src/item.h +++ b/src/item.h @@ -6,8 +6,8 @@ #pragma once -#include "kwinglobals.h" #include "kwineffects.h" +#include "kwinglobals.h" #include #include diff --git a/src/kcmkwin/common/effectsmodel.cpp b/src/kcmkwin/common/effectsmodel.cpp index 737f6652da..30746f63ac 100644 --- a/src/kcmkwin/common/effectsmodel.cpp +++ b/src/kcmkwin/common/effectsmodel.cpp @@ -7,10 +7,10 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "effectsmodel.h" #include + #include #include @@ -46,8 +46,7 @@ static QString translatedCategory(const QString &category) QStringLiteral("Tools"), QStringLiteral("Virtual Desktop Switching Animation"), QStringLiteral("Window Management"), - QStringLiteral("Window Open/Close Animation") - }; + QStringLiteral("Window Open/Close Animation")}; static const QVector translatedCategories = { i18nc("Category of Desktop Effects, used as section header", "Accessibility"), @@ -57,8 +56,7 @@ static QString translatedCategory(const QString &category) i18nc("Category of Desktop Effects, used as section header", "Tools"), i18nc("Category of Desktop Effects, used as section header", "Virtual Desktop Switching Animation"), i18nc("Category of Desktop Effects, used as section header", "Window Management"), - i18nc("Category of Desktop Effects, used as section header", "Window Open/Close Animation") - }; + i18nc("Category of Desktop Effects, used as section header", "Window Open/Close Animation")}; const int index = knownCategories.indexOf(category); if (index == -1) { @@ -288,8 +286,7 @@ void EffectsModel::loadJavascriptEffects(const KConfigGroup &kwinConfig) { const auto plugins = KPackage::PackageLoader::self()->listPackages( QStringLiteral("KWin/Effect"), - QStringLiteral("kwin/effects") - ); + QStringLiteral("kwin/effects")); for (const KPluginMetaData &plugin : plugins) { EffectData effect; @@ -320,7 +317,7 @@ void EffectsModel::loadJavascriptEffects(const KConfigGroup &kwinConfig) QDir package(QFileInfo(plugin.metaDataFileName()).dir()); package.cd(QStringLiteral("contents")); const QString xmlFile = package.filePath(QStringLiteral("config/main.xml")); - const QString uiFile =package.filePath(QStringLiteral("ui/config.ui")); + const QString uiFile = package.filePath(QStringLiteral("ui/config.ui")); effect.configurable = QFileInfo::exists(xmlFile) && QFileInfo::exists(uiFile); } else { effect.configurable = false; @@ -358,7 +355,7 @@ void EffectsModel::loadPluginEffects(const KConfigGroup &kwinConfig) for (int i = 0; i < pluginEffect.authors().count(); ++i) { effect.authorName.append(pluginEffect.authors().at(i).name()); effect.authorEmail.append(pluginEffect.authors().at(i).emailAddress()); - if (i+1 < pluginEffect.authors().count()) { + if (i + 1 < pluginEffect.authors().count()) { effect.authorName.append(", "); effect.authorEmail.append(", "); } @@ -402,16 +399,15 @@ void EffectsModel::load(LoadOptions options) loadPluginEffects(kwinConfig); std::sort(m_pendingEffects.begin(), m_pendingEffects.end(), - [](const EffectData &a, const EffectData &b) { - if (a.category == b.category) { - if (a.exclusiveGroup == b.exclusiveGroup) { - return a.name < b.name; - } - return a.exclusiveGroup < b.exclusiveGroup; - } - return a.category < b.category; - } - ); + [](const EffectData &a, const EffectData &b) { + if (a.category == b.category) { + if (a.exclusiveGroup == b.exclusiveGroup) { + return a.name < b.name; + } + return a.exclusiveGroup < b.exclusiveGroup; + } + return a.category < b.category; + }); auto commit = [this, options] { if (options == LoadOptions::KeepDirty) { @@ -420,10 +416,9 @@ void EffectsModel::load(LoadOptions options) continue; } auto effectIt = std::find_if(m_pendingEffects.begin(), m_pendingEffects.end(), - [oldEffect](const EffectData &data) { - return data.serviceName == oldEffect.serviceName; - } - ); + [oldEffect](const EffectData &data) { + return data.serviceName == oldEffect.serviceName; + }); if (effectIt == m_pendingEffects.end()) { continue; } @@ -454,46 +449,43 @@ void EffectsModel::load(LoadOptions options) const int serial = ++m_lastSerial; QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(interface.areEffectsSupported(effectNames), this); - connect(watcher, &QDBusPendingCallWatcher::finished, this, - [=](QDBusPendingCallWatcher *self) { - self->deleteLater(); + connect(watcher, &QDBusPendingCallWatcher::finished, this, [=](QDBusPendingCallWatcher *self) { + self->deleteLater(); - if (m_lastSerial != serial) { - return; - } - - const QDBusPendingReply > reply = *self; - if (reply.isError()) { - commit(); - return; - } - - const QList supportedValues = reply.value(); - if (supportedValues.count() != effectNames.count()) { - return; - } - - for (int i = 0; i < effectNames.size(); ++i) { - const bool supported = supportedValues.at(i); - const QString effectName = effectNames.at(i); - - auto it = std::find_if(m_pendingEffects.begin(), m_pendingEffects.end(), - [effectName](const EffectData &data) { - return data.serviceName == effectName; - } - ); - if (it == m_pendingEffects.end()) { - continue; - } - - if ((*it).supported != supported) { - (*it).supported = supported; - } - } - - commit(); + if (m_lastSerial != serial) { + return; } - ); + + const QDBusPendingReply> reply = *self; + if (reply.isError()) { + commit(); + return; + } + + const QList supportedValues = reply.value(); + if (supportedValues.count() != effectNames.count()) { + return; + } + + for (int i = 0; i < effectNames.size(); ++i) { + const bool supported = supportedValues.at(i); + const QString effectName = effectNames.at(i); + + auto it = std::find_if(m_pendingEffects.begin(), m_pendingEffects.end(), + [effectName](const EffectData &data) { + return data.serviceName == effectName; + }); + if (it == m_pendingEffects.end()) { + continue; + } + + if ((*it).supported != supported) { + (*it).supported = supported; + } + } + + commit(); + }); } else { commit(); } @@ -583,19 +575,17 @@ bool EffectsModel::isDefaults() const bool EffectsModel::needsSave() const { return std::any_of(m_effects.constBegin(), m_effects.constEnd(), - [](const EffectData &data) { - return data.changed; - } - ); + [](const EffectData &data) { + return data.changed; + }); } QModelIndex EffectsModel::findByPluginId(const QString &pluginId) const { auto it = std::find_if(m_effects.constBegin(), m_effects.constEnd(), - [pluginId](const EffectData &data) { - return data.serviceName == pluginId; - } - ); + [pluginId](const EffectData &data) { + return data.serviceName == pluginId; + }); if (it == m_effects.constEnd()) { return {}; } @@ -638,15 +628,12 @@ void EffectsModel::requestConfigure(const QModelIndex &index, QWindow *transient dialog->windowHandle()->setTransientParent(transientParent); auto buttons = new QDialogButtonBox( - QDialogButtonBox::Ok | - QDialogButtonBox::Cancel | - QDialogButtonBox::RestoreDefaults, - dialog - ); + QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults, + dialog); connect(buttons, &QDialogButtonBox::accepted, dialog, &QDialog::accept); connect(buttons, &QDialogButtonBox::rejected, dialog, &QDialog::reject); connect(buttons->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, - module, &KCModule::defaults); + module, &KCModule::defaults); connect(module, &KCModule::defaulted, this, [=](bool defaulted) { buttons->button(QDialogButtonBox::RestoreDefaults)->setEnabled(!defaulted); }); diff --git a/src/kcmkwin/common/effectsmodel.h b/src/kcmkwin/common/effectsmodel.h index 7567f6cd6e..186c232a78 100644 --- a/src/kcmkwin/common/effectsmodel.h +++ b/src/kcmkwin/common/effectsmodel.h @@ -223,7 +223,8 @@ protected: Scripted }; - struct EffectData { + struct EffectData + { QString name; QString description; QString authorName; diff --git a/src/kcmkwin/kwincompositing/main.cpp b/src/kcmkwin/kwincompositing/main.cpp index f93b0a4373..8c70b0f1a9 100644 --- a/src/kcmkwin/kwincompositing/main.cpp +++ b/src/kcmkwin/kwincompositing/main.cpp @@ -8,7 +8,6 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "ui_compositing.h" #include @@ -16,9 +15,9 @@ #include #include +#include #include #include -#include #include #include @@ -35,7 +34,6 @@ class KWinCompositingKCM : public KCModule { Q_OBJECT public: - explicit KWinCompositingKCM(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); public Q_SLOTS: @@ -102,7 +100,7 @@ void KWinCompositingKCM::reenableGl() void KWinCompositingKCM::init() { - auto currentIndexChangedSignal = static_cast(&QComboBox::currentIndexChanged); + auto currentIndexChangedSignal = static_cast(&QComboBox::currentIndexChanged); // animation speed m_form.animationDurationFactor->setMaximum(s_animationMultipliers.size() - 1); @@ -117,47 +115,41 @@ void KWinCompositingKCM::init() } // gl scale filter - connect(m_form.kcfg_glTextureFilter, currentIndexChangedSignal, this, - [this](int index) { - if (index == 2) { - m_form.scaleWarning->animatedShow(); - } else { - m_form.scaleWarning->animatedHide(); - } + connect(m_form.kcfg_glTextureFilter, currentIndexChangedSignal, this, [this](int index) { + if (index == 2) { + m_form.scaleWarning->animatedShow(); + } else { + m_form.scaleWarning->animatedHide(); } - ); + }); // tearing prevention - connect(m_form.kcfg_glPreferBufferSwap, currentIndexChangedSignal, this, - [this](int index) { - if (index == 1) { - // only when cheap - tearing - m_form.tearingWarning->setText(i18n("\"Only when cheap\" only prevents tearing for full screen changes like a video.")); - m_form.tearingWarning->animatedShow(); - } else if (index == 2) { - // full screen repaints - m_form.tearingWarning->setText(i18n("\"Full screen repaints\" can cause performance problems.")); - m_form.tearingWarning->animatedShow(); - } else if (index == 3) { - // re-use screen content - m_form.tearingWarning->setText(i18n("\"Re-use screen content\" causes severe performance problems on MESA drivers.")); - m_form.tearingWarning->animatedShow(); - } else { - m_form.tearingWarning->animatedHide(); - } + connect(m_form.kcfg_glPreferBufferSwap, currentIndexChangedSignal, this, [this](int index) { + if (index == 1) { + // only when cheap - tearing + m_form.tearingWarning->setText(i18n("\"Only when cheap\" only prevents tearing for full screen changes like a video.")); + m_form.tearingWarning->animatedShow(); + } else if (index == 2) { + // full screen repaints + m_form.tearingWarning->setText(i18n("\"Full screen repaints\" can cause performance problems.")); + m_form.tearingWarning->animatedShow(); + } else if (index == 3) { + // re-use screen content + m_form.tearingWarning->setText(i18n("\"Re-use screen content\" causes severe performance problems on MESA drivers.")); + m_form.tearingWarning->animatedShow(); + } else { + m_form.tearingWarning->animatedHide(); } - ); + }); // windowThumbnail - connect(m_form.kcfg_HiddenPreviews, currentIndexChangedSignal, this, - [this](int index) { - if (index == 2) { - m_form.windowThumbnailWarning->animatedShow(); - } else { - m_form.windowThumbnailWarning->animatedHide(); - } + connect(m_form.kcfg_HiddenPreviews, currentIndexChangedSignal, this, [this](int index) { + if (index == 2) { + m_form.windowThumbnailWarning->animatedShow(); + } else { + m_form.windowThumbnailWarning->animatedHide(); } - ); + }); if (m_settings->openGLIsUnsafe()) { m_form.glCrashedWarning->animatedShow(); @@ -172,7 +164,7 @@ void KWinCompositingKCM::updateUnmanagedItemStatus() bool changed = false; if (!inPlasma) { - changed |= (animationDuration != m_settings->animationDurationFactor()); + changed |= (animationDuration != m_settings->animationDurationFactor()); } unmanagedWidgetChangeState(changed); @@ -227,7 +219,6 @@ void KWinCompositingKCM::save() K_PLUGIN_FACTORY(KWinCompositingConfigFactory, registerPlugin(); - registerPlugin(); - ) + registerPlugin();) #include "main.moc" diff --git a/src/kcmkwin/kwindecoration/declarative-plugin/buttonsmodel.cpp b/src/kcmkwin/kwindecoration/declarative-plugin/buttonsmodel.cpp index befdb2d786..b29ad3d6c1 100644 --- a/src/kcmkwin/kwindecoration/declarative-plugin/buttonsmodel.cpp +++ b/src/kcmkwin/kwindecoration/declarative-plugin/buttonsmodel.cpp @@ -15,25 +15,24 @@ namespace KDecoration2 namespace Preview { -ButtonsModel::ButtonsModel(const QVector< DecorationButtonType > &buttons, QObject *parent) +ButtonsModel::ButtonsModel(const QVector &buttons, QObject *parent) : QAbstractListModel(parent) , m_buttons(buttons) { } -ButtonsModel::ButtonsModel(QObject* parent) - : ButtonsModel(QVector({ - DecorationButtonType::Menu, - DecorationButtonType::ApplicationMenu, - DecorationButtonType::OnAllDesktops, - DecorationButtonType::Minimize, - DecorationButtonType::Maximize, - DecorationButtonType::Close, - DecorationButtonType::ContextHelp, - DecorationButtonType::Shade, - DecorationButtonType::KeepBelow, - DecorationButtonType::KeepAbove - }), parent) +ButtonsModel::ButtonsModel(QObject *parent) + : ButtonsModel(QVector({DecorationButtonType::Menu, + DecorationButtonType::ApplicationMenu, + DecorationButtonType::OnAllDesktops, + DecorationButtonType::Minimize, + DecorationButtonType::Maximize, + DecorationButtonType::Close, + DecorationButtonType::ContextHelp, + DecorationButtonType::Shade, + DecorationButtonType::KeepBelow, + DecorationButtonType::KeepAbove}), + parent) { } @@ -50,37 +49,34 @@ int ButtonsModel::rowCount(const QModelIndex &parent) const static QString buttonToName(DecorationButtonType type) { switch (type) { - case DecorationButtonType::Menu: - return i18n("More actions for this window"); - case DecorationButtonType::ApplicationMenu: - return i18n("Application menu"); - case DecorationButtonType::OnAllDesktops: - return i18n("On all desktops"); - case DecorationButtonType::Minimize: - return i18n("Minimize"); - case DecorationButtonType::Maximize: - return i18n("Maximize"); - case DecorationButtonType::Close: - return i18n("Close"); - case DecorationButtonType::ContextHelp: - return i18n("Context help"); - case DecorationButtonType::Shade: - return i18n("Shade"); - case DecorationButtonType::KeepBelow: - return i18n("Keep below other windows"); - case DecorationButtonType::KeepAbove: - return i18n("Keep above other windows"); - default: - return QString(); + case DecorationButtonType::Menu: + return i18n("More actions for this window"); + case DecorationButtonType::ApplicationMenu: + return i18n("Application menu"); + case DecorationButtonType::OnAllDesktops: + return i18n("On all desktops"); + case DecorationButtonType::Minimize: + return i18n("Minimize"); + case DecorationButtonType::Maximize: + return i18n("Maximize"); + case DecorationButtonType::Close: + return i18n("Close"); + case DecorationButtonType::ContextHelp: + return i18n("Context help"); + case DecorationButtonType::Shade: + return i18n("Shade"); + case DecorationButtonType::KeepBelow: + return i18n("Keep below other windows"); + case DecorationButtonType::KeepAbove: + return i18n("Keep above other windows"); + default: + return QString(); } } QVariant ButtonsModel::data(const QModelIndex &index, int role) const { - if (!index.isValid() || - index.row() < 0 || - index.row() >= m_buttons.count() || - index.column() != 0) { + if (!index.isValid() || index.row() < 0 || index.row() >= m_buttons.count() || index.column() != 0) { return QVariant(); } switch (role) { @@ -92,7 +88,7 @@ QVariant ButtonsModel::data(const QModelIndex &index, int role) const return QVariant(); } -QHash< int, QByteArray > ButtonsModel::roleNames() const +QHash ButtonsModel::roleNames() const { QHash roles; roles.insert(Qt::DisplayRole, QByteArrayLiteral("display")); @@ -112,11 +108,11 @@ void ButtonsModel::remove(int row) void ButtonsModel::down(int index) { - if (m_buttons.count() < 2 || index == m_buttons.count() -1) { + if (m_buttons.count() < 2 || index == m_buttons.count() - 1) { return; } beginMoveRows(QModelIndex(), index, index, QModelIndex(), index + 2); - m_buttons.insert(index +1, m_buttons.takeAt(index)); + m_buttons.insert(index + 1, m_buttons.takeAt(index)); endMoveRows(); } @@ -125,8 +121,8 @@ void ButtonsModel::up(int index) if (m_buttons.count() < 2 || index == 0) { return; } - beginMoveRows(QModelIndex(), index, index, QModelIndex(), index -1); - m_buttons.insert(index -1, m_buttons.takeAt(index)); + beginMoveRows(QModelIndex(), index, index, QModelIndex(), index - 1); + m_buttons.insert(index - 1, m_buttons.takeAt(index)); endMoveRows(); } @@ -171,7 +167,7 @@ void ButtonsModel::clear() endResetModel(); } -void ButtonsModel::replace(const QVector< DecorationButtonType > &buttons) +void ButtonsModel::replace(const QVector &buttons) { if (buttons.isEmpty()) { return; @@ -184,4 +180,3 @@ void ButtonsModel::replace(const QVector< DecorationButtonType > &buttons) } } - diff --git a/src/kcmkwin/kwindecoration/declarative-plugin/buttonsmodel.h b/src/kcmkwin/kwindecoration/declarative-plugin/buttonsmodel.h index efa5f9d2b9..d7913c67c6 100644 --- a/src/kcmkwin/kwindecoration/declarative-plugin/buttonsmodel.h +++ b/src/kcmkwin/kwindecoration/declarative-plugin/buttonsmodel.h @@ -20,14 +20,15 @@ class ButtonsModel : public QAbstractListModel { Q_OBJECT public: - explicit ButtonsModel(const QVector< DecorationButtonType > &buttons, QObject *parent = nullptr); + explicit ButtonsModel(const QVector &buttons, QObject *parent = nullptr); explicit ButtonsModel(QObject *parent = nullptr); ~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; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + QHash roleNames() const override; - QVector< DecorationButtonType > buttons() const { + QVector buttons() const + { return m_buttons; } @@ -37,16 +38,15 @@ public: Q_INVOKABLE void down(int index); Q_INVOKABLE void move(int sourceIndex, int targetIndex); - void replace(const QVector< DecorationButtonType > &buttons); + void replace(const QVector &buttons); void add(DecorationButtonType type); Q_INVOKABLE void add(int index, int type); private: - QVector< DecorationButtonType > m_buttons; + QVector m_buttons; }; } } #endif - diff --git a/src/kcmkwin/kwindecoration/declarative-plugin/plugin.cpp b/src/kcmkwin/kwindecoration/declarative-plugin/plugin.cpp index 9fb045c961..a31c511093 100644 --- a/src/kcmkwin/kwindecoration/declarative-plugin/plugin.cpp +++ b/src/kcmkwin/kwindecoration/declarative-plugin/plugin.cpp @@ -5,8 +5,8 @@ */ #include "plugin.h" #include "buttonsmodel.h" -#include "previewbutton.h" #include "previewbridge.h" +#include "previewbutton.h" #include "previewclient.h" #include "previewitem.h" #include "previewsettings.h" @@ -35,5 +35,3 @@ void Plugin::registerTypes(const char *uri) } } - - diff --git a/src/kcmkwin/kwindecoration/declarative-plugin/previewbridge.cpp b/src/kcmkwin/kwindecoration/declarative-plugin/previewbridge.cpp index 74135faeca..b39136d261 100644 --- a/src/kcmkwin/kwindecoration/declarative-plugin/previewbridge.cpp +++ b/src/kcmkwin/kwindecoration/declarative-plugin/previewbridge.cpp @@ -15,9 +15,9 @@ #include #include -#include #include #include +#include #include #include #include @@ -108,7 +108,9 @@ void PreviewBridge::createFactory() } const auto offers = KPluginMetaData::findPlugins(s_pluginName); - auto item = std::find_if(offers.constBegin(), offers.constEnd(), [this](const auto &plugin) { return plugin.pluginId() == m_plugin; }); + auto item = std::find_if(offers.constBegin(), offers.constEnd(), [this](const auto &plugin) { + return plugin.pluginId() == m_plugin; + }); if (item != offers.constEnd()) { m_factory = KPluginFactory::loadFactory(*item).plugin; } @@ -135,7 +137,7 @@ Decoration *PreviewBridge::createDecoration(QObject *parent) if (!m_valid) { return nullptr; } - QVariantMap args({ {QStringLiteral("bridge"), QVariant::fromValue(this)} }); + QVariantMap args({{QStringLiteral("bridge"), QVariant::fromValue(this)}}); if (!m_theme.isNull()) { args.insert(QStringLiteral("theme"), m_theme); } @@ -155,7 +157,7 @@ void PreviewBridge::configure(QQuickItem *ctx) if (!m_valid) { return; } - //setup the UI + // setup the UI QDialog *dialog = new QDialog(); dialog->setAttribute(Qt::WA_DeleteOnClose); if (m_lastCreatedClient) { @@ -174,7 +176,7 @@ void PreviewBridge::configure(QQuickItem *ctx) return; } - auto save = [this,kcm] { + auto save = [this, kcm] { kcm->save(); if (m_lastCreatedSettings) { Q_EMIT m_lastCreatedSettings->decorationSettings()->reconfigured(); @@ -187,10 +189,7 @@ void PreviewBridge::configure(QQuickItem *ctx) }; connect(dialog, &QDialog::accepted, this, save); - QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok | - QDialogButtonBox::Cancel | - QDialogButtonBox::RestoreDefaults | - QDialogButtonBox::Reset, + QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults | QDialogButtonBox::Reset, dialog); QPushButton *reset = buttons->button(QDialogButtonBox::Reset); @@ -199,7 +198,7 @@ void PreviewBridge::configure(QQuickItem *ctx) connect(buttons, &QDialogButtonBox::accepted, dialog, &QDialog::accept); connect(buttons, &QDialogButtonBox::rejected, dialog, &QDialog::reject); connect(reset, &QPushButton::clicked, kcm, &KCModule::load); - auto changedSignal = static_cast(&KCModule::changed); + auto changedSignal = static_cast(&KCModule::changed); connect(kcm, changedSignal, reset, &QPushButton::setEnabled); connect(buttons->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, kcm, &KCModule::defaults); diff --git a/src/kcmkwin/kwindecoration/declarative-plugin/previewbridge.h b/src/kcmkwin/kwindecoration/declarative-plugin/previewbridge.h index 5e0dc9094f..1ad8e57995 100644 --- a/src/kcmkwin/kwindecoration/declarative-plugin/previewbridge.h +++ b/src/kcmkwin/kwindecoration/declarative-plugin/previewbridge.h @@ -6,8 +6,8 @@ #ifndef KDECOARTIONS_PREVIEW_BRIDGE_H #define KDECOARTIONS_PREVIEW_BRIDGE_H -#include #include +#include #include #include @@ -37,10 +37,12 @@ public: std::unique_ptr createClient(DecoratedClient *client, Decoration *decoration) override; std::unique_ptr settings(DecorationSettings *parent) override; - PreviewClient *lastCreatedClient() { + PreviewClient *lastCreatedClient() + { return m_lastCreatedClient; } - PreviewSettings *lastCreatedSettings() { + PreviewSettings *lastCreatedSettings() + { return m_lastCreatedSettings; } @@ -69,7 +71,7 @@ private: void setValid(bool valid); PreviewClient *m_lastCreatedClient; PreviewSettings *m_lastCreatedSettings; - QList m_previewItems; + QList m_previewItems; QString m_plugin; QString m_theme; QPointer m_factory; @@ -88,23 +90,29 @@ public: explicit BridgeItem(QObject *parent = nullptr); ~BridgeItem() override; - void setPlugin(const QString &plugin) { + void setPlugin(const QString &plugin) + { m_bridge->setPlugin(plugin); } - QString plugin() const { + QString plugin() const + { return m_bridge->plugin(); } - void setTheme(const QString &theme) { + void setTheme(const QString &theme) + { m_bridge->setTheme(theme); } - QString theme() const { + QString theme() const + { return m_bridge->theme(); } - bool isValid() const { + bool isValid() const + { return m_bridge->isValid(); } - PreviewBridge *bridge() const { + PreviewBridge *bridge() const + { return m_bridge; } @@ -115,7 +123,6 @@ Q_SIGNALS: private: PreviewBridge *m_bridge; - }; } diff --git a/src/kcmkwin/kwindecoration/declarative-plugin/previewbutton.cpp b/src/kcmkwin/kwindecoration/declarative-plugin/previewbutton.cpp index 1f76207b37..dfe20df04b 100644 --- a/src/kcmkwin/kwindecoration/declarative-plugin/previewbutton.cpp +++ b/src/kcmkwin/kwindecoration/declarative-plugin/previewbutton.cpp @@ -18,7 +18,7 @@ namespace KDecoration2 namespace Preview { -PreviewButtonItem::PreviewButtonItem(QQuickItem* parent) +PreviewButtonItem::PreviewButtonItem(QQuickItem *parent) : QQuickPaintedItem(parent) { } @@ -118,7 +118,7 @@ void PreviewButtonItem::paint(QPainter *painter) if (!m_button) { return; } - QRect size { 0, 0, (int)width(), (int)height() }; + QRect size{0, 0, (int)width(), (int)height()}; m_button->paint(painter, size); painter->setCompositionMode(QPainter::CompositionMode_SourceAtop); painter->fillRect(size, m_color); diff --git a/src/kcmkwin/kwindecoration/declarative-plugin/previewbutton.h b/src/kcmkwin/kwindecoration/declarative-plugin/previewbutton.h index 85d0a4d691..a0337b5826 100644 --- a/src/kcmkwin/kwindecoration/declarative-plugin/previewbutton.h +++ b/src/kcmkwin/kwindecoration/declarative-plugin/previewbutton.h @@ -6,10 +6,10 @@ #ifndef KDECOARTIONS_PREVIEW_BUTTON_ITEM_H #define KDECOARTIONS_PREVIEW_BUTTON_ITEM_H -#include +#include #include #include -#include +#include namespace KDecoration2 { @@ -44,7 +44,10 @@ public: void setType(KDecoration2::DecorationButtonType type); void setType(int type); - const QColor &color() const { return m_color; } + const QColor &color() const + { + return m_color; + } void setColor(const QColor &color); Q_SIGNALS: @@ -64,7 +67,6 @@ private: KDecoration2::Decoration *m_decoration = nullptr; KDecoration2::DecorationButton *m_button = nullptr; KDecoration2::DecorationButtonType m_type = KDecoration2::DecorationButtonType::Custom; - }; } // Preview diff --git a/src/kcmkwin/kwindecoration/declarative-plugin/previewclient.cpp b/src/kcmkwin/kwindecoration/declarative-plugin/previewclient.cpp index 1a3e4b8913..1e92a3bf61 100644 --- a/src/kcmkwin/kwindecoration/declarative-plugin/previewclient.cpp +++ b/src/kcmkwin/kwindecoration/declarative-plugin/previewclient.cpp @@ -4,11 +4,11 @@ SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL */ #include "previewclient.h" -#include #include +#include -#include #include +#include #include #include @@ -45,57 +45,49 @@ PreviewClient::PreviewClient(DecoratedClient *c, Decoration *decoration) , m_bordersRightEdge(false) , m_bordersBottomEdge(false) { - connect(this, &PreviewClient::captionChanged, c, &DecoratedClient::captionChanged); - connect(this, &PreviewClient::activeChanged, c, &DecoratedClient::activeChanged); - connect(this, &PreviewClient::closeableChanged, c, &DecoratedClient::closeableChanged); - connect(this, &PreviewClient::keepAboveChanged, c, &DecoratedClient::keepAboveChanged); - connect(this, &PreviewClient::keepBelowChanged, c, &DecoratedClient::keepBelowChanged); - connect(this, &PreviewClient::maximizableChanged, c, &DecoratedClient::maximizeableChanged); - connect(this, &PreviewClient::maximizedChanged, c, &DecoratedClient::maximizedChanged); - connect(this, &PreviewClient::maximizedVerticallyChanged, c, &DecoratedClient::maximizedVerticallyChanged); + connect(this, &PreviewClient::captionChanged, c, &DecoratedClient::captionChanged); + connect(this, &PreviewClient::activeChanged, c, &DecoratedClient::activeChanged); + connect(this, &PreviewClient::closeableChanged, c, &DecoratedClient::closeableChanged); + connect(this, &PreviewClient::keepAboveChanged, c, &DecoratedClient::keepAboveChanged); + connect(this, &PreviewClient::keepBelowChanged, c, &DecoratedClient::keepBelowChanged); + connect(this, &PreviewClient::maximizableChanged, c, &DecoratedClient::maximizeableChanged); + connect(this, &PreviewClient::maximizedChanged, c, &DecoratedClient::maximizedChanged); + connect(this, &PreviewClient::maximizedVerticallyChanged, c, &DecoratedClient::maximizedVerticallyChanged); connect(this, &PreviewClient::maximizedHorizontallyChanged, c, &DecoratedClient::maximizedHorizontallyChanged); - connect(this, &PreviewClient::minimizableChanged, c, &DecoratedClient::minimizeableChanged); - connect(this, &PreviewClient::movableChanged, c, &DecoratedClient::moveableChanged); - connect(this, &PreviewClient::onAllDesktopsChanged, c, &DecoratedClient::onAllDesktopsChanged); - connect(this, &PreviewClient::resizableChanged, c, &DecoratedClient::resizeableChanged); - connect(this, &PreviewClient::shadeableChanged, c, &DecoratedClient::shadeableChanged); - connect(this, &PreviewClient::shadedChanged, c, &DecoratedClient::shadedChanged); - connect(this, &PreviewClient::providesContextHelpChanged, c, &DecoratedClient::providesContextHelpChanged); - connect(this, &PreviewClient::onAllDesktopsChanged, c, &DecoratedClient::onAllDesktopsChanged); - connect(this, &PreviewClient::widthChanged, c, &DecoratedClient::widthChanged); - connect(this, &PreviewClient::heightChanged, c, &DecoratedClient::heightChanged); - connect(this, &PreviewClient::iconChanged, c, &DecoratedClient::iconChanged); - connect(this, &PreviewClient::paletteChanged, c, &DecoratedClient::paletteChanged); - connect(this, &PreviewClient::maximizedVerticallyChanged, this, - [this]() { - Q_EMIT maximizedChanged(isMaximized()); - } - ); - connect(this, &PreviewClient::maximizedHorizontallyChanged, this, - [this]() { - Q_EMIT maximizedChanged(isMaximized()); - } - ); - connect(this, &PreviewClient::iconNameChanged, this, - [this]() { - m_icon = QIcon::fromTheme(m_iconName); - Q_EMIT iconChanged(m_icon); - } - ); - connect(this, &PreviewClient::desktopChanged, this, - [this]() { - Q_EMIT onAllDesktopsChanged(isOnAllDesktops()); - } - ); + connect(this, &PreviewClient::minimizableChanged, c, &DecoratedClient::minimizeableChanged); + connect(this, &PreviewClient::movableChanged, c, &DecoratedClient::moveableChanged); + connect(this, &PreviewClient::onAllDesktopsChanged, c, &DecoratedClient::onAllDesktopsChanged); + connect(this, &PreviewClient::resizableChanged, c, &DecoratedClient::resizeableChanged); + connect(this, &PreviewClient::shadeableChanged, c, &DecoratedClient::shadeableChanged); + connect(this, &PreviewClient::shadedChanged, c, &DecoratedClient::shadedChanged); + connect(this, &PreviewClient::providesContextHelpChanged, c, &DecoratedClient::providesContextHelpChanged); + connect(this, &PreviewClient::onAllDesktopsChanged, c, &DecoratedClient::onAllDesktopsChanged); + connect(this, &PreviewClient::widthChanged, c, &DecoratedClient::widthChanged); + connect(this, &PreviewClient::heightChanged, c, &DecoratedClient::heightChanged); + connect(this, &PreviewClient::iconChanged, c, &DecoratedClient::iconChanged); + connect(this, &PreviewClient::paletteChanged, c, &DecoratedClient::paletteChanged); + connect(this, &PreviewClient::maximizedVerticallyChanged, this, [this]() { + Q_EMIT maximizedChanged(isMaximized()); + }); + connect(this, &PreviewClient::maximizedHorizontallyChanged, this, [this]() { + Q_EMIT maximizedChanged(isMaximized()); + }); + connect(this, &PreviewClient::iconNameChanged, this, [this]() { + m_icon = QIcon::fromTheme(m_iconName); + Q_EMIT iconChanged(m_icon); + }); + connect(this, &PreviewClient::desktopChanged, this, [this]() { + Q_EMIT onAllDesktopsChanged(isOnAllDesktops()); + }); connect(&m_palette, &KWin::Decoration::DecorationPalette::changed, this, [this]() { Q_EMIT paletteChanged(m_palette.palette()); }); auto emitEdgesChanged = [this, c]() { Q_EMIT c->adjacentScreenEdgesChanged(adjacentScreenEdges()); }; - connect(this, &PreviewClient::bordersTopEdgeChanged, this, emitEdgesChanged); - connect(this, &PreviewClient::bordersLeftEdgeChanged, this, emitEdgesChanged); - connect(this, &PreviewClient::bordersRightEdgeChanged, this, emitEdgesChanged); + connect(this, &PreviewClient::bordersTopEdgeChanged, this, emitEdgesChanged); + connect(this, &PreviewClient::bordersLeftEdgeChanged, this, emitEdgesChanged); + connect(this, &PreviewClient::bordersRightEdgeChanged, this, emitEdgesChanged); connect(this, &PreviewClient::bordersBottomEdgeChanged, this, emitEdgesChanged); auto emitSizeChanged = [c]() { Q_EMIT c->sizeChanged(c->size()); @@ -418,15 +410,15 @@ void PreviewClient::requestToggleShade() setShaded(!isShaded()); } -#define SETTER(type, name, variable) \ -void PreviewClient::name(type variable) \ -{ \ - if (m_##variable == variable) { \ - return; \ - } \ - m_##variable = variable; \ - Q_EMIT variable##Changed(m_##variable); \ -} +#define SETTER(type, name, variable) \ + void PreviewClient::name(type variable) \ + { \ + if (m_##variable == variable) { \ + return; \ + } \ + m_##variable = variable; \ + Q_EMIT variable##Changed(m_##variable); \ + } #define SETTER2(name, variable) SETTER(bool, name, variable) diff --git a/src/kcmkwin/kwindecoration/declarative-plugin/previewclient.h b/src/kcmkwin/kwindecoration/declarative-plugin/previewclient.h index fbd88a32f4..5ffca89e3b 100644 --- a/src/kcmkwin/kwindecoration/declarative-plugin/previewclient.h +++ b/src/kcmkwin/kwindecoration/declarative-plugin/previewclient.h @@ -44,9 +44,9 @@ class PreviewClient : public QObject, public ApplicationMenuEnabledDecoratedClie 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 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); @@ -156,7 +156,7 @@ Q_SIGNALS: void desktopChanged(int); void widthChanged(int); void heightChanged(int); - void paletteChanged(const QPalette&); + void paletteChanged(const QPalette &); void bordersTopEdgeChanged(bool); void bordersLeftEdgeChanged(bool); void bordersRightEdgeChanged(bool); diff --git a/src/kcmkwin/kwindecoration/declarative-plugin/previewitem.cpp b/src/kcmkwin/kwindecoration/declarative-plugin/previewitem.cpp index 4a39231dce..f3d44f6ef9 100644 --- a/src/kcmkwin/kwindecoration/declarative-plugin/previewitem.cpp +++ b/src/kcmkwin/kwindecoration/declarative-plugin/previewitem.cpp @@ -5,12 +5,12 @@ */ #include "previewitem.h" #include "previewbridge.h" -#include "previewsettings.h" #include "previewclient.h" +#include "previewsettings.h" +#include #include #include #include -#include #include #include #include @@ -43,7 +43,7 @@ PreviewItem::PreviewItem(QQuickItem *parent) PreviewItem::~PreviewItem() { m_decoration->deleteLater(); - if (m_bridge){ + if (m_bridge) { m_bridge->unregisterPreviewItem(this); } } @@ -85,7 +85,9 @@ void PreviewItem::setDecoration(Decoration *deco) connect(m_decoration, &Decoration::bordersChanged, this, &PreviewItem::syncSize); connect(m_decoration, &Decoration::shadowChanged, this, &PreviewItem::syncSize); connect(m_decoration, &Decoration::shadowChanged, this, &PreviewItem::shadowChanged); - connect(m_decoration, &Decoration::damaged, this, [this]() { update(); }); + connect(m_decoration, &Decoration::damaged, this, [this]() { + update(); + }); Q_EMIT decorationChanged(m_decoration); } @@ -109,30 +111,30 @@ void PreviewItem::paint(QPainter *painter) if (!m_decoration) { return; } - int paddingLeft = 0; - int paddingTop = 0; - int paddingRight = 0; + int paddingLeft = 0; + int paddingTop = 0; + int paddingRight = 0; int paddingBottom = 0; paintShadow(painter, paddingLeft, paddingRight, paddingTop, paddingBottom); m_decoration->paint(painter, QRect(0, 0, width(), height())); if (m_drawBackground) { painter->fillRect(m_decoration->borderLeft(), m_decoration->borderTop(), - width() - m_decoration->borderLeft() - m_decoration->borderRight() - paddingLeft - paddingRight, - height() - m_decoration->borderTop() - m_decoration->borderBottom() - paddingTop - paddingBottom, - m_windowColor); + width() - m_decoration->borderLeft() - m_decoration->borderRight() - paddingLeft - paddingRight, + height() - m_decoration->borderTop() - m_decoration->borderBottom() - paddingTop - paddingBottom, + m_windowColor); } } void PreviewItem::paintShadow(QPainter *painter, int &paddingLeft, int &paddingRight, int &paddingTop, int &paddingBottom) { - const auto &shadow = ((const Decoration*)(m_decoration))->shadow(); + const auto &shadow = ((const Decoration *)(m_decoration))->shadow(); if (!shadow) { return; } - paddingLeft = shadow->paddingLeft(); - paddingTop = shadow->paddingTop(); - paddingRight = shadow->paddingRight(); + paddingLeft = shadow->paddingLeft(); + paddingTop = shadow->paddingTop(); + paddingRight = shadow->paddingRight(); paddingBottom = shadow->paddingBottom(); const QImage shadowPixmap = shadow->shadow(); @@ -211,8 +213,8 @@ void PreviewItem::paintShadow(QPainter *painter, int &paddingLeft, int &paddingR QRect(QPoint(0, 0), topLeftTarget.size())); painter->drawImage(topRightTarget, shadowPixmap, - QRect(QPoint(shadowRect.width() - topRightTarget.width(), 0), - topRightTarget.size())); + QRect(QPoint(shadowRect.width() - topRightTarget.width(), 0), + topRightTarget.size())); painter->drawImage(bottomRightTarget, shadowPixmap, QRect(QPoint(shadowRect.width() - bottomRightTarget.width(), @@ -257,10 +259,10 @@ void PreviewItem::paintShadow(QPainter *painter, int &paddingLeft, int &paddingR } if (drawLeft) { - QRect leftTarget(topLeftTarget.x(), - topLeftTarget.y() + topLeftTarget.height(), - topLeftTarget.width(), - bottomLeftTarget.y() - topLeftTarget.y() - topLeftTarget.height()); + QRect leftTarget(topLeftTarget.x(), + topLeftTarget.y() + topLeftTarget.height(), + topLeftTarget.width(), + bottomLeftTarget.y() - topLeftTarget.y() - topLeftTarget.height()); QRect leftSource(shadow->leftGeometry()); leftSource.setWidth(leftTarget.width()); leftSource.moveLeft(shadowRect.left()); diff --git a/src/kcmkwin/kwindecoration/declarative-plugin/previewitem.h b/src/kcmkwin/kwindecoration/declarative-plugin/previewitem.h index 8774b8365b..9058ce15c6 100644 --- a/src/kcmkwin/kwindecoration/declarative-plugin/previewitem.h +++ b/src/kcmkwin/kwindecoration/declarative-plugin/previewitem.h @@ -6,8 +6,8 @@ #ifndef KDECOARTIONS_PREVIEW_ITEM_H #define KDECOARTIONS_PREVIEW_ITEM_H -#include #include +#include namespace KDecoration2 { diff --git a/src/kcmkwin/kwindecoration/declarative-plugin/previewsettings.cpp b/src/kcmkwin/kwindecoration/declarative-plugin/previewsettings.cpp index cae329d1ec..5fe51db1d6 100644 --- a/src/kcmkwin/kwindecoration/declarative-plugin/previewsettings.cpp +++ b/src/kcmkwin/kwindecoration/declarative-plugin/previewsettings.cpp @@ -4,8 +4,8 @@ SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL */ #include "previewsettings.h" -#include "previewbridge.h" #include "buttonsmodel.h" +#include "previewbridge.h" #include @@ -43,7 +43,7 @@ int BorderSizesModel::rowCount(const QModelIndex &parent) const return m_borders.count(); } -QHash< int, QByteArray > BorderSizesModel::roleNames() const +QHash BorderSizesModel::roleNames() const { QHash roles; roles.insert(Qt::DisplayRole, QByteArrayLiteral("display")); @@ -56,29 +56,26 @@ PreviewSettings::PreviewSettings(DecorationSettings *parent) , m_alphaChannelSupported(true) , m_onAllDesktopsAvailable(true) , m_closeOnDoubleClick(false) - , m_leftButtons(new ButtonsModel(QVector({ - DecorationButtonType::Menu, - DecorationButtonType::ApplicationMenu, - DecorationButtonType::OnAllDesktops - }), this)) - , m_rightButtons(new ButtonsModel(QVector({ - DecorationButtonType::ContextHelp, - DecorationButtonType::Minimize, - DecorationButtonType::Maximize, - DecorationButtonType::Close - }), this)) - , m_availableButtons(new ButtonsModel(QVector({ - DecorationButtonType::Menu, - DecorationButtonType::ApplicationMenu, - DecorationButtonType::OnAllDesktops, - DecorationButtonType::Minimize, - DecorationButtonType::Maximize, - DecorationButtonType::Close, - DecorationButtonType::ContextHelp, - DecorationButtonType::Shade, - DecorationButtonType::KeepBelow, - DecorationButtonType::KeepAbove - }), this)) + , m_leftButtons(new ButtonsModel(QVector({DecorationButtonType::Menu, + DecorationButtonType::ApplicationMenu, + DecorationButtonType::OnAllDesktops}), + this)) + , m_rightButtons(new ButtonsModel(QVector({DecorationButtonType::ContextHelp, + DecorationButtonType::Minimize, + DecorationButtonType::Maximize, + DecorationButtonType::Close}), + this)) + , m_availableButtons(new ButtonsModel(QVector({DecorationButtonType::Menu, + DecorationButtonType::ApplicationMenu, + DecorationButtonType::OnAllDesktops, + DecorationButtonType::Minimize, + DecorationButtonType::Maximize, + DecorationButtonType::Close, + DecorationButtonType::ContextHelp, + DecorationButtonType::Shade, + DecorationButtonType::KeepBelow, + DecorationButtonType::KeepAbove}), + this)) , m_borderSizes(new BorderSizesModel(this)) , m_borderSize(int(BorderSize::Normal)) , m_font(QFontDatabase::systemFont(QFontDatabase::TitleFont)) @@ -93,11 +90,11 @@ PreviewSettings::PreviewSettings(DecorationSettings *parent) auto updateRight = [this, parent]() { Q_EMIT parent->decorationButtonsRightChanged(decorationButtonsRight()); }; - connect(m_leftButtons, &QAbstractItemModel::rowsRemoved, this, updateLeft); - connect(m_leftButtons, &QAbstractItemModel::rowsMoved, this, updateLeft); - connect(m_leftButtons, &QAbstractItemModel::rowsInserted, this, updateLeft); - connect(m_rightButtons, &QAbstractItemModel::rowsRemoved, this, updateRight); - connect(m_rightButtons, &QAbstractItemModel::rowsMoved, this, updateRight); + connect(m_leftButtons, &QAbstractItemModel::rowsRemoved, this, updateLeft); + connect(m_leftButtons, &QAbstractItemModel::rowsMoved, this, updateLeft); + connect(m_leftButtons, &QAbstractItemModel::rowsInserted, this, updateLeft); + connect(m_rightButtons, &QAbstractItemModel::rowsRemoved, this, updateRight); + connect(m_rightButtons, &QAbstractItemModel::rowsMoved, this, updateRight); connect(m_rightButtons, &QAbstractItemModel::rowsInserted, this, updateRight); } @@ -155,12 +152,12 @@ void PreviewSettings::setCloseOnDoubleClickOnMenu(bool enabled) Q_EMIT closeOnDoubleClickOnMenuChanged(enabled); } -QVector< DecorationButtonType > PreviewSettings::decorationButtonsLeft() const +QVector PreviewSettings::decorationButtonsLeft() const { return m_leftButtons->buttons(); } -QVector< DecorationButtonType > PreviewSettings::decorationButtonsRight() const +QVector PreviewSettings::decorationButtonsRight() const { return m_rightButtons->buttons(); } diff --git a/src/kcmkwin/kwindecoration/declarative-plugin/previewsettings.h b/src/kcmkwin/kwindecoration/declarative-plugin/previewsettings.h index 301477d28b..a42ee749a3 100644 --- a/src/kcmkwin/kwindecoration/declarative-plugin/previewsettings.h +++ b/src/kcmkwin/kwindecoration/declarative-plugin/previewsettings.h @@ -6,10 +6,10 @@ #ifndef KDECOARTIONS_PREVIEW_SETTINGS_H #define KDECOARTIONS_PREVIEW_SETTINGS_H -#include #include -#include +#include #include +#include namespace KDecoration2 { @@ -25,21 +25,20 @@ class BorderSizesModel : public QAbstractListModel public: explicit BorderSizesModel(QObject *parent = nullptr); ~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; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + QHash 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 - }); + 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 @@ -59,7 +58,8 @@ public: ~PreviewSettings() override; bool isAlphaChannelSupported() const override; bool isOnAllDesktopsAvailable() const override; - bool isCloseOnDoubleClickOnMenu() const override { + bool isCloseOnDoubleClickOnMenu() const override + { return m_closeOnDoubleClick; } BorderSize borderSize() const override; @@ -71,22 +71,25 @@ public: QAbstractItemModel *leftButtonsModel() const; QAbstractItemModel *rightButtonsModel() const; QAbstractItemModel *availableButtonsModel() const; - QAbstractItemModel *borderSizesModel() const { + QAbstractItemModel *borderSizesModel() const + { return m_borderSizes; } - QVector< DecorationButtonType > decorationButtonsLeft() const override; - QVector< DecorationButtonType > decorationButtonsRight() const override; + QVector decorationButtonsLeft() const override; + QVector decorationButtonsRight() const override; Q_INVOKABLE void addButtonToLeft(int row); Q_INVOKABLE void addButtonToRight(int row); - int borderSizesIndex() const { + int borderSizesIndex() const + { return m_borderSize; } void setBorderSizesIndex(int index); - QFont font() const override { + QFont font() const override + { return m_font; } void setFont(const QFont &font); @@ -125,7 +128,8 @@ public: QSharedPointer settings() const; DecorationSettings *settingsPointer() const; - int borderSizesIndex() const { + int borderSizesIndex() const + { return m_borderSize; } void setBorderSizesIndex(int index); diff --git a/src/kcmkwin/kwindecoration/decorationmodel.cpp b/src/kcmkwin/kwindecoration/decorationmodel.cpp index d7ec832151..ef35cb024d 100644 --- a/src/kcmkwin/kwindecoration/decorationmodel.cpp +++ b/src/kcmkwin/kwindecoration/decorationmodel.cpp @@ -57,15 +57,13 @@ QVariant DecorationsModel::data(const QModelIndex &index, int role) const return QVariant(); } -QHash< int, QByteArray > DecorationsModel::roleNames() const +QHash DecorationsModel::roleNames() const { - QHash roles({ - {Qt::DisplayRole, QByteArrayLiteral("display")}, - {PluginNameRole, QByteArrayLiteral("plugin")}, - {ThemeNameRole, QByteArrayLiteral("theme")}, - {ConfigurationRole, QByteArrayLiteral("configureable")}, - {RecommendedBorderSizeRole, QByteArrayLiteral("recommendedbordersize")} - }); + QHash roles({{Qt::DisplayRole, QByteArrayLiteral("display")}, + {PluginNameRole, QByteArrayLiteral("plugin")}, + {ThemeNameRole, QByteArrayLiteral("theme")}, + {ConfigurationRole, QByteArrayLiteral("configureable")}, + {RecommendedBorderSizeRole, QByteArrayLiteral("recommendedbordersize")}}); return roles; } diff --git a/src/kcmkwin/kwindecoration/decorationmodel.h b/src/kcmkwin/kwindecoration/decorationmodel.h index 203fedcf10..fdc53ec1af 100644 --- a/src/kcmkwin/kwindecoration/decorationmodel.h +++ b/src/kcmkwin/kwindecoration/decorationmodel.h @@ -34,11 +34,12 @@ public: 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; + QHash roleNames() const override; QModelIndex findDecoration(const QString &pluginName, const QString &themeName = QString()) const; - QStringList knsProviders() const { + QStringList knsProviders() const + { return m_knsProviders; } diff --git a/src/kcmkwin/kwindecoration/kcm.cpp b/src/kcmkwin/kwindecoration/kcm.cpp index cf03c15fca..c1cbab4118 100644 --- a/src/kcmkwin/kwindecoration/kcm.cpp +++ b/src/kcmkwin/kwindecoration/kcm.cpp @@ -4,17 +4,18 @@ SPDX-License-Identifier: LGPL-2.0-only */ - #include "kcm.h" -#include "decorationmodel.h" -#include "declarative-plugin/buttonsmodel.h" + #include +#include "declarative-plugin/buttonsmodel.h" +#include "decorationmodel.h" + #include #include #include -#include #include +#include #include #include @@ -26,11 +27,10 @@ #include "kwindecorationdata.h" #include "kwindecorationsettings.h" -K_PLUGIN_FACTORY_WITH_JSON(KCMKWinDecorationFactory, "kwindecoration.json", registerPlugin();registerPlugin();) +K_PLUGIN_FACTORY_WITH_JSON(KCMKWinDecorationFactory, "kwindecoration.json", registerPlugin(); registerPlugin();) Q_DECLARE_METATYPE(KDecoration2::BorderSize) - namespace { const KDecoration2::BorderSize s_defaultRecommendedBorderSize = KDecoration2::BorderSize::Normal; @@ -70,7 +70,7 @@ KCMKWinDecoration::KCMKWinDecoration(QObject *parent, const QVariantList &argume connect(this, &KCMKWinDecoration::borderSizeChanged, this, &KCMKWinDecoration::borderIndexChanged); connect(this, &KCMKWinDecoration::themeChanged, this, &KCMKWinDecoration::borderIndexChanged); - connect(this, &KCMKWinDecoration::themeChanged, this, [=](){ + connect(this, &KCMKWinDecoration::themeChanged, this, [=]() { if (m_data->settings()->borderSizeAuto()) { setBorderSize(recommendedBorderSize()); } @@ -91,7 +91,7 @@ KCMKWinDecoration::KCMKWinDecoration(QObject *parent, const QVariantList &argume // Update the themes when the color scheme or a theme's settings change QDBusConnection::sessionBus() .connect(QString(), QStringLiteral("/KWin"), QStringLiteral("org.kde.KWin"), QStringLiteral("reloadConfig"), - this, SLOT(reloadKWinSettings())); + this, SLOT(reloadKWinSettings())); QMetaObject::invokeMethod(m_themesModel, &KDecoration2::Configuration::DecorationsModel::init, Qt::QueuedConnection); } @@ -180,8 +180,7 @@ QStringList KCMKWinDecoration::borderSizesModel() const // Use index 0 for borderSizeAuto == true // The rest of indexes get offset by 1 QStringList model = Utils::getBorderSizeNames().values(); - model.insert(0, i18nc("%1 is the name of a border size", - "Theme's default (%1)", model.at(recommendedBorderSize()))); + model.insert(0, i18nc("%1 is the name of a border size", "Theme's default (%1)", model.at(recommendedBorderSize()))); return model; } diff --git a/src/kcmkwin/kwindecoration/kcm.h b/src/kcmkwin/kwindecoration/kcm.h index 2995685705..047fdee794 100644 --- a/src/kcmkwin/kwindecoration/kcm.h +++ b/src/kcmkwin/kwindecoration/kcm.h @@ -11,7 +11,6 @@ #include - class QAbstractItemModel; class QSortFilterProxyModel; class QQuickItem; diff --git a/src/kcmkwin/kwindecoration/kwin-applywindowdecoration.cpp b/src/kcmkwin/kwindecoration/kwin-applywindowdecoration.cpp index ace08563fd..3f5ca76c87 100644 --- a/src/kcmkwin/kwindecoration/kwin-applywindowdecoration.cpp +++ b/src/kcmkwin/kwindecoration/kwin-applywindowdecoration.cpp @@ -10,11 +10,11 @@ #include -#include #include -#include -#include +#include #include +#include +#include #include #include @@ -79,7 +79,7 @@ int main(int argc, char **argv) } else if (themeResolved) { int index{-1}; QStringList availableThemes; - for (int i = 0 ; i < model->rowCount(); ++i) { + for (int i = 0; i < model->rowCount(); ++i) { const QString themeName = model->data(model->index(i), KDecoration2::Configuration::DecorationsModel::ThemeNameRole).toString(); if (requestedTheme == themeName) { index = i; @@ -93,11 +93,12 @@ int main(int argc, char **argv) if (settings->save()) { // Send a signal to all kwin instances QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KWin"), - QStringLiteral("org.kde.KWin"), - QStringLiteral("reloadConfig")); + QStringLiteral("org.kde.KWin"), + QStringLiteral("reloadConfig")); QDBusConnection::sessionBus().send(message); ts << i18n("Successfully applied the cursor theme %1 to your current Plasma session", - model->data(model->index(index), KDecoration2::Configuration::DecorationsModel::ThemeNameRole).toString()) << Qt::endl; + model->data(model->index(index), KDecoration2::Configuration::DecorationsModel::ThemeNameRole).toString()) + << Qt::endl; } else { ts << i18n("Failed to save your theme settings - the reason is unknown, but this is an unrecoverable error. You may find that simply trying again will work."); exitCode = -1; @@ -109,7 +110,7 @@ int main(int argc, char **argv) } } else if (parser->isSet(QStringLiteral("list-themes"))) { ts << i18n("You have the following KWin window decoration themes on your system:") << Qt::endl; - for (int i = 0 ; i < model->rowCount(); ++i) { + for (int i = 0; i < model->rowCount(); ++i) { const QString displayName = model->data(model->index(i), Qt::DisplayRole).toString(); const QString themeName = model->data(model->index(i), KDecoration2::Configuration::DecorationsModel::ThemeNameRole).toString(); if (settings->theme() == themeName) { @@ -121,7 +122,9 @@ int main(int argc, char **argv) } else { parser->showHelp(); } - QTimer::singleShot(0, &app, [&app,&exitCode](){ app.exit(exitCode); }); + QTimer::singleShot(0, &app, [&app, &exitCode]() { + app.exit(exitCode); + }); return app.exec(); } diff --git a/src/kcmkwin/kwindecoration/utils.cpp b/src/kcmkwin/kwindecoration/utils.cpp index 05dd79f7e2..ca00796d66 100644 --- a/src/kcmkwin/kwindecoration/utils.cpp +++ b/src/kcmkwin/kwindecoration/utils.cpp @@ -11,44 +11,40 @@ namespace { -const QMap s_borderSizes { - { QStringLiteral("None"), KDecoration2::BorderSize::None }, - { QStringLiteral("NoSides"), KDecoration2::BorderSize::NoSides }, - { QStringLiteral("Tiny"), KDecoration2::BorderSize::Tiny }, - { QStringLiteral("Normal"), KDecoration2::BorderSize::Normal }, - { QStringLiteral("Large"), KDecoration2::BorderSize::Large }, - { QStringLiteral("VeryLarge"), KDecoration2::BorderSize::VeryLarge }, - { QStringLiteral("Huge"), KDecoration2::BorderSize::Huge }, - { QStringLiteral("VeryHuge"), KDecoration2::BorderSize::VeryHuge }, - { QStringLiteral("Oversized"), KDecoration2::BorderSize::Oversized } -}; -const QMap s_borderSizeNames { - { KDecoration2::BorderSize::None, i18n("No Borders") }, - { KDecoration2::BorderSize::NoSides, i18n("No Side Borders") }, - { KDecoration2::BorderSize::Tiny, i18n("Tiny") }, - { KDecoration2::BorderSize::Normal, i18n("Normal") }, - { KDecoration2::BorderSize::Large, i18n("Large") }, - { KDecoration2::BorderSize::VeryLarge, i18n("Very Large") }, - { KDecoration2::BorderSize::Huge, i18n("Huge") }, - { KDecoration2::BorderSize::VeryHuge, i18n("Very Huge") }, - { KDecoration2::BorderSize::Oversized, i18n("Oversized") } -}; +const QMap s_borderSizes{ + {QStringLiteral("None"), KDecoration2::BorderSize::None}, + {QStringLiteral("NoSides"), KDecoration2::BorderSize::NoSides}, + {QStringLiteral("Tiny"), KDecoration2::BorderSize::Tiny}, + {QStringLiteral("Normal"), KDecoration2::BorderSize::Normal}, + {QStringLiteral("Large"), KDecoration2::BorderSize::Large}, + {QStringLiteral("VeryLarge"), KDecoration2::BorderSize::VeryLarge}, + {QStringLiteral("Huge"), KDecoration2::BorderSize::Huge}, + {QStringLiteral("VeryHuge"), KDecoration2::BorderSize::VeryHuge}, + {QStringLiteral("Oversized"), KDecoration2::BorderSize::Oversized}}; +const QMap s_borderSizeNames{ + {KDecoration2::BorderSize::None, i18n("No Borders")}, + {KDecoration2::BorderSize::NoSides, i18n("No Side Borders")}, + {KDecoration2::BorderSize::Tiny, i18n("Tiny")}, + {KDecoration2::BorderSize::Normal, i18n("Normal")}, + {KDecoration2::BorderSize::Large, i18n("Large")}, + {KDecoration2::BorderSize::VeryLarge, i18n("Very Large")}, + {KDecoration2::BorderSize::Huge, i18n("Huge")}, + {KDecoration2::BorderSize::VeryHuge, i18n("Very Huge")}, + {KDecoration2::BorderSize::Oversized, i18n("Oversized")}}; -const QHash s_buttonNames { - {KDecoration2::DecorationButtonType::Menu, QChar('M') }, - {KDecoration2::DecorationButtonType::ApplicationMenu, QChar('N') }, - {KDecoration2::DecorationButtonType::OnAllDesktops, QChar('S') }, - {KDecoration2::DecorationButtonType::ContextHelp, QChar('H') }, - {KDecoration2::DecorationButtonType::Minimize, QChar('I') }, - {KDecoration2::DecorationButtonType::Maximize, QChar('A') }, - {KDecoration2::DecorationButtonType::Close, QChar('X') }, - {KDecoration2::DecorationButtonType::KeepAbove, QChar('F') }, - {KDecoration2::DecorationButtonType::KeepBelow, QChar('B') }, - {KDecoration2::DecorationButtonType::Shade, QChar('L') } -}; +const QHash s_buttonNames{ + {KDecoration2::DecorationButtonType::Menu, QChar('M')}, + {KDecoration2::DecorationButtonType::ApplicationMenu, QChar('N')}, + {KDecoration2::DecorationButtonType::OnAllDesktops, QChar('S')}, + {KDecoration2::DecorationButtonType::ContextHelp, QChar('H')}, + {KDecoration2::DecorationButtonType::Minimize, QChar('I')}, + {KDecoration2::DecorationButtonType::Maximize, QChar('A')}, + {KDecoration2::DecorationButtonType::Close, QChar('X')}, + {KDecoration2::DecorationButtonType::KeepAbove, QChar('F')}, + {KDecoration2::DecorationButtonType::KeepBelow, QChar('B')}, + {KDecoration2::DecorationButtonType::Shade, QChar('L')}}; } - namespace Utils { diff --git a/src/kcmkwin/kwindecoration/utils.h b/src/kcmkwin/kwindecoration/utils.h index de467ad669..2a1dbca69a 100644 --- a/src/kcmkwin/kwindecoration/utils.h +++ b/src/kcmkwin/kwindecoration/utils.h @@ -11,7 +11,6 @@ #include - using DecorationButtonsList = QVector; namespace Utils diff --git a/src/kcmkwin/kwindesktop/animationsmodel.cpp b/src/kcmkwin/kwindesktop/animationsmodel.cpp index 7359664693..bea78b875a 100644 --- a/src/kcmkwin/kwindesktop/animationsmodel.cpp +++ b/src/kcmkwin/kwindesktop/animationsmodel.cpp @@ -17,26 +17,22 @@ namespace KWin AnimationsModel::AnimationsModel(QObject *parent) : EffectsModel(parent) { - connect(this, &EffectsModel::loaded, this, - [this] { - setAnimationEnabled(modelAnimationEnabled()); - setAnimationIndex(modelAnimationIndex()); - loadDefaults(); + connect(this, &EffectsModel::loaded, this, [this]() { + setAnimationEnabled(modelAnimationEnabled()); + setAnimationIndex(modelAnimationIndex()); + loadDefaults(); + }); + connect(this, &AnimationsModel::animationIndexChanged, this, [this]() { + const QModelIndex index_ = index(m_animationIndex, 0); + if (!index_.isValid()) { + return; } - ); - connect(this, &AnimationsModel::animationIndexChanged, this, - [this] { - const QModelIndex index_ = index(m_animationIndex, 0); - if (!index_.isValid()) { - return; - } - const bool configurable = index_.data(ConfigurableRole).toBool(); - if (configurable != m_currentConfigurable) { - m_currentConfigurable = configurable; - Q_EMIT currentConfigurableChanged(); - } + const bool configurable = index_.data(ConfigurableRole).toBool(); + if (configurable != m_currentConfigurable) { + m_currentConfigurable = configurable; + Q_EMIT currentConfigurableChanged(); } - ); + }); } bool AnimationsModel::animationEnabled() const @@ -166,8 +162,7 @@ bool AnimationsModel::needsSave() const const QModelIndex index_ = index(i, 0); const bool enabledConfig = kwinConfig.readEntry( index_.data(ServiceNameRole).toString() + QLatin1String("Enabled"), - index_.data(EnabledByDefaultRole).toBool() - ); + index_.data(EnabledByDefaultRole).toBool()); const bool enabled = (m_animationEnabled && i == m_animationIndex); if (enabled != enabledConfig) { diff --git a/src/kcmkwin/kwindesktop/desktopsmodel.cpp b/src/kcmkwin/kwindesktop/desktopsmodel.cpp index 491c7ebdeb..cf147a7981 100644 --- a/src/kcmkwin/kwindesktop/desktopsmodel.cpp +++ b/src/kcmkwin/kwindesktop/desktopsmodel.cpp @@ -42,47 +42,47 @@ DesktopsModel::DesktopsModel(QObject *parent) qDBusRegisterMetaType(); m_serviceWatcher = new QDBusServiceWatcher(s_serviceName, - QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange); + QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange); QObject::connect(m_serviceWatcher, &QDBusServiceWatcher::serviceRegistered, - this, [this]() { reset(); }); + this, [this]() { + reset(); + }); QObject::connect(m_serviceWatcher, &QDBusServiceWatcher::serviceUnregistered, - this, [this]() { - QDBusConnection::sessionBus().disconnect( - s_serviceName, - s_virtDesktopsPath, - s_virtualDesktopsInterface, - QStringLiteral("desktopCreated"), - this, - SLOT(desktopCreated(QString,KWin::DBusDesktopDataStruct))); + this, [this]() { + QDBusConnection::sessionBus().disconnect( + s_serviceName, + s_virtDesktopsPath, + s_virtualDesktopsInterface, + QStringLiteral("desktopCreated"), + this, + SLOT(desktopCreated(QString, KWin::DBusDesktopDataStruct))); - QDBusConnection::sessionBus().disconnect( - s_serviceName, - s_virtDesktopsPath, - s_virtualDesktopsInterface, - QStringLiteral("desktopRemoved"), - this, - SLOT(desktopRemoved(QString))); + QDBusConnection::sessionBus().disconnect( + s_serviceName, + s_virtDesktopsPath, + s_virtualDesktopsInterface, + QStringLiteral("desktopRemoved"), + this, + SLOT(desktopRemoved(QString))); - QDBusConnection::sessionBus().disconnect( - s_serviceName, - s_virtDesktopsPath, - s_virtualDesktopsInterface, - QStringLiteral("desktopDataChanged"), - this, - SLOT(desktopDataChanged(QString,KWin::DBusDesktopDataStruct))); + QDBusConnection::sessionBus().disconnect( + s_serviceName, + s_virtDesktopsPath, + s_virtualDesktopsInterface, + QStringLiteral("desktopDataChanged"), + this, + SLOT(desktopDataChanged(QString, KWin::DBusDesktopDataStruct))); - - QDBusConnection::sessionBus().disconnect( - s_serviceName, - s_virtDesktopsPath, - s_virtualDesktopsInterface, - QStringLiteral("rowsChanged"), - this, - SLOT(desktopRowsChanged(uint))); - } - ); + QDBusConnection::sessionBus().disconnect( + s_serviceName, + s_virtDesktopsPath, + s_virtualDesktopsInterface, + QStringLiteral("rowsChanged"), + this, + SLOT(desktopRowsChanged(uint))); + }); reset(); } @@ -349,7 +349,7 @@ void DesktopsModel::syncWithServer() QStringLiteral("Set")); call.setArguments({s_virtualDesktopsInterface, - QStringLiteral("rows"), QVariant::fromValue(QDBusVariant(QVariant((uint)m_rows)))}); + QStringLiteral("rows"), QVariant::fromValue(QDBusVariant(QVariant((uint)m_rows)))}); ++m_pendingCalls; QDBusPendingCall pending = QDBusConnection::sessionBus().asyncCall(call); @@ -420,12 +420,11 @@ void DesktopsModel::getAllAndConnect(const QDBusMessage &msg) const QVariantMap &data = qdbus_cast(msg.arguments().at(0).value()); const KWin::DBusDesktopDataVector &desktops = qdbus_cast( - data.value(QStringLiteral("desktops")).value() - ); + data.value(QStringLiteral("desktops")).value()); const int newServerSideRows = data.value(QStringLiteral("rows")).toUInt(); QStringList newServerSideDesktops; - QHash newServerSideNames; + QHash newServerSideNames; for (const KWin::DBusDesktopDataStruct &d : desktops) { newServerSideDesktops.append(d.id); @@ -473,7 +472,7 @@ void DesktopsModel::getAllAndConnect(const QDBusMessage &msg) s_virtualDesktopsInterface, QStringLiteral("desktopCreated"), this, - SLOT(desktopCreated(QString,KWin::DBusDesktopDataStruct))); + SLOT(desktopCreated(QString, KWin::DBusDesktopDataStruct))); if (!connected) { handleConnectionError(); @@ -501,7 +500,7 @@ void DesktopsModel::getAllAndConnect(const QDBusMessage &msg) s_virtualDesktopsInterface, QStringLiteral("desktopDataChanged"), this, - SLOT(desktopDataChanged(QString,KWin::DBusDesktopDataStruct))); + SLOT(desktopDataChanged(QString, KWin::DBusDesktopDataStruct))); if (!connected) { handleConnectionError(); diff --git a/src/kcmkwin/kwindesktop/desktopsmodel.h b/src/kcmkwin/kwindesktop/desktopsmodel.h index 623baefcd0..bd761fcbad 100644 --- a/src/kcmkwin/kwindesktop/desktopsmodel.h +++ b/src/kcmkwin/kwindesktop/desktopsmodel.h @@ -16,7 +16,6 @@ class QDBusArgument; class QDBusMessage; class QDBusServiceWatcher; - namespace KWin { @@ -115,10 +114,10 @@ private: bool m_userModified; bool m_serverModified; QStringList m_serverSideDesktops; - QHash m_serverSideNames; + QHash m_serverSideNames; int m_serverSideRows; QStringList m_desktops; - QHash m_names; + QHash m_names; int m_rows; int m_pendingCalls = 0; }; diff --git a/src/kcmkwin/kwindesktop/virtualdesktops.cpp b/src/kcmkwin/kwindesktop/virtualdesktops.cpp index 8d76d7559f..1858dd90e4 100644 --- a/src/kcmkwin/kwindesktop/virtualdesktops.cpp +++ b/src/kcmkwin/kwindesktop/virtualdesktops.cpp @@ -8,8 +8,8 @@ #include "virtualdesktops.h" #include "animationsmodel.h" #include "desktopsmodel.h" -#include "virtualdesktopssettings.h" #include "virtualdesktopsdata.h" +#include "virtualdesktopssettings.h" #include #include @@ -30,8 +30,8 @@ VirtualDesktops::VirtualDesktops(QObject *parent, const QVariantList &args) , m_data(new VirtualDesktopsData(this)) { KAboutData *about = new KAboutData(QStringLiteral("kcm_kwin_virtualdesktops"), - i18n("Virtual Desktops"), - QStringLiteral("2.0"), QString(), KAboutLicense::GPL); + i18n("Virtual Desktops"), + QStringLiteral("2.0"), QString(), KAboutLicense::GPL); setAboutData(about); qmlRegisterAnonymousType("org.kde.kwin.kcm.desktop", 0); @@ -39,11 +39,11 @@ VirtualDesktops::VirtualDesktops(QObject *parent, const QVariantList &args) setButtons(Apply | Default); QObject::connect(m_data->desktopsModel(), &KWin::DesktopsModel::userModifiedChanged, - this, &VirtualDesktops::settingsChanged); + this, &VirtualDesktops::settingsChanged); connect(m_data->animationsModel(), &AnimationsModel::animationEnabledChanged, - this, &VirtualDesktops::settingsChanged); + this, &VirtualDesktops::settingsChanged); connect(m_data->animationsModel(), &AnimationsModel::animationIndexChanged, - this, &VirtualDesktops::settingsChanged); + this, &VirtualDesktops::settingsChanged); } VirtualDesktops::~VirtualDesktops() @@ -81,7 +81,7 @@ void VirtualDesktops::save() m_data->animationsModel()->save(); QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KWin"), - QStringLiteral("org.kde.KWin"), QStringLiteral("reloadConfig")); + QStringLiteral("org.kde.KWin"), QStringLiteral("reloadConfig")); QDBusConnection::sessionBus().send(message); } @@ -115,25 +115,25 @@ void VirtualDesktops::showAboutAnimation() return; } - const QString name = index.data(AnimationsModel::NameRole).toString(); + const QString name = index.data(AnimationsModel::NameRole).toString(); const QString comment = index.data(AnimationsModel::DescriptionRole).toString(); - const QString author = index.data(AnimationsModel::AuthorNameRole).toString(); - const QString email = index.data(AnimationsModel::AuthorEmailRole).toString(); + const QString author = index.data(AnimationsModel::AuthorNameRole).toString(); + const QString email = index.data(AnimationsModel::AuthorEmailRole).toString(); const QString website = index.data(AnimationsModel::WebsiteRole).toString(); const QString version = index.data(AnimationsModel::VersionRole).toString(); const QString license = index.data(AnimationsModel::LicenseRole).toString(); - const QString icon = index.data(AnimationsModel::IconNameRole).toString(); + const QString icon = index.data(AnimationsModel::IconNameRole).toString(); const KAboutLicense::LicenseKey licenseType = KAboutLicense::byKeyword(license).key(); KAboutData aboutData( - name, // Plugin name - name, // Display name - version, // Version - comment, // Short description - licenseType, // License - QString(), // Copyright statement - QString(), // Other text + name, // Plugin name + name, // Display name + version, // Version + comment, // Short description + licenseType, // License + QString(), // Copyright statement + QString(), // Other text website.toLatin1() // Home page ); aboutData.setProgramLogo(icon); @@ -164,5 +164,5 @@ bool VirtualDesktops::isSaveNeeded() const } -#include "virtualdesktops.moc" #include "moc_virtualdesktops.cpp" +#include "virtualdesktops.moc" diff --git a/src/kcmkwin/kwindesktop/virtualdesktops.h b/src/kcmkwin/kwindesktop/virtualdesktops.h index 479c0ea80e..e70d593290 100644 --- a/src/kcmkwin/kwindesktop/virtualdesktops.h +++ b/src/kcmkwin/kwindesktop/virtualdesktops.h @@ -23,7 +23,7 @@ class VirtualDesktops : public KQuickAddons::ManagedConfigModule { Q_OBJECT - Q_PROPERTY(QAbstractItemModel* desktopsModel READ desktopsModel CONSTANT) + Q_PROPERTY(QAbstractItemModel *desktopsModel READ desktopsModel CONSTANT) Q_PROPERTY(QAbstractItemModel *animationsModel READ animationsModel CONSTANT) Q_PROPERTY(VirtualDesktopsSettings *virtualDesktopsSettings READ virtualDesktopsSettings CONSTANT) diff --git a/src/kcmkwin/kwindesktop/virtualdesktopsdata.cpp b/src/kcmkwin/kwindesktop/virtualdesktopsdata.cpp index 10d990f7ae..d07368771e 100644 --- a/src/kcmkwin/kwindesktop/virtualdesktopsdata.cpp +++ b/src/kcmkwin/kwindesktop/virtualdesktopsdata.cpp @@ -6,8 +6,8 @@ #include "virtualdesktopsdata.h" -#include "desktopsmodel.h" #include "animationsmodel.h" +#include "desktopsmodel.h" #include "virtualdesktopssettings.h" namespace KWin diff --git a/src/kcmkwin/kwineffects/effectsfilterproxymodel.cpp b/src/kcmkwin/kwineffects/effectsfilterproxymodel.cpp index 1bd85279cb..745915262d 100644 --- a/src/kcmkwin/kwineffects/effectsfilterproxymodel.cpp +++ b/src/kcmkwin/kwineffects/effectsfilterproxymodel.cpp @@ -67,9 +67,7 @@ bool EffectsFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex const QModelIndex idx = sourceModel()->index(sourceRow, 0, sourceParent); if (!m_query.isEmpty()) { - const bool matches = idx.data(EffectsModel::NameRole).toString().contains(m_query, Qt::CaseInsensitive) || - idx.data(EffectsModel::DescriptionRole).toString().contains(m_query, Qt::CaseInsensitive) || - idx.data(EffectsModel::CategoryRole).toString().contains(m_query, Qt::CaseInsensitive); + const bool matches = idx.data(EffectsModel::NameRole).toString().contains(m_query, Qt::CaseInsensitive) || idx.data(EffectsModel::DescriptionRole).toString().contains(m_query, Qt::CaseInsensitive) || idx.data(EffectsModel::CategoryRole).toString().contains(m_query, Qt::CaseInsensitive); if (!matches) { return false; } diff --git a/src/kcmkwin/kwineffects/kcm.cpp b/src/kcmkwin/kwineffects/kcm.cpp index d814b0d1e2..a2164791d0 100644 --- a/src/kcmkwin/kwineffects/kcm.cpp +++ b/src/kcmkwin/kwineffects/kcm.cpp @@ -5,9 +5,9 @@ */ #include "kcm.h" +#include "desktopeffectsdata.h" #include "effectsfilterproxymodel.h" #include "effectsmodel.h" -#include "desktopeffectsdata.h" #include #include @@ -35,8 +35,7 @@ DesktopEffectsKCM::DesktopEffectsKCM(QObject *parent, const QVariantList &args) i18n("Desktop Effects"), QStringLiteral("2.0"), QString(), - KAboutLicense::GPL - ); + KAboutLicense::GPL); about->addAuthor(i18n("Vlad Zahorodnii"), QString(), QStringLiteral("vlad.zahorodnii@kde.org")); setAboutData(about); diff --git a/src/kcmkwin/kwinoptions/main.cpp b/src/kcmkwin/kwinoptions/main.cpp index 2beb632f31..11fd1365ad 100644 --- a/src/kcmkwin/kwinoptions/main.cpp +++ b/src/kcmkwin/kwinoptions/main.cpp @@ -7,21 +7,21 @@ #include "main.h" #include -//Added by qt3to4: +// Added by qt3to4: #include #include #include -#include -#include #include +#include +#include +#include "kwinoptions_kdeglobals_settings.h" +#include "kwinoptions_settings.h" +#include "kwinoptionsdata.h" #include "mouse.h" #include "windows.h" -#include "kwinoptions_settings.h" -#include "kwinoptions_kdeglobals_settings.h" -#include "kwinoptionsdata.h" K_PLUGIN_FACTORY(KWinOptionsFactory, registerPlugin();) @@ -29,7 +29,7 @@ class KFocusConfigStandalone : public KFocusConfig { Q_OBJECT public: - KFocusConfigStandalone(QWidget* parent, const QVariantList &) + KFocusConfigStandalone(QWidget *parent, const QVariantList &) : KFocusConfig(true, nullptr, parent) { initialize(new KWinOptionsSettings(this)); @@ -40,7 +40,7 @@ class KMovingConfigStandalone : public KMovingConfig { Q_OBJECT public: - KMovingConfigStandalone(QWidget* parent, const QVariantList &) + KMovingConfigStandalone(QWidget *parent, const QVariantList &) : KMovingConfig(true, nullptr, parent) { initialize(new KWinOptionsSettings(this)); @@ -51,7 +51,7 @@ class KAdvancedConfigStandalone : public KAdvancedConfig { Q_OBJECT public: - KAdvancedConfigStandalone(QWidget* parent, const QVariantList &) + KAdvancedConfigStandalone(QWidget *parent, const QVariantList &) : KAdvancedConfig(true, nullptr, nullptr, parent) { initialize(new KWinOptionsSettings(this), new KWinOptionsKDEGlobalsSettings(this)); @@ -143,7 +143,6 @@ void KWinOptions::save() QDBusConnection::sessionBus().send(message); } - void KWinOptions::defaults() { KCModule::defaults(); @@ -188,7 +187,6 @@ void KWinOptions::updateUnmanagedState() unmanagedWidgetDefaultState(isDefault); } - KActionsOptions::KActionsOptions(QWidget *parent, const QVariantList &) : KCModule(parent) { diff --git a/src/kcmkwin/kwinoptions/main.h b/src/kcmkwin/kwinoptions/main.h index 7233a1402d..21e6f7e9a6 100644 --- a/src/kcmkwin/kwinoptions/main.h +++ b/src/kcmkwin/kwinoptions/main.h @@ -9,7 +9,6 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #ifndef __MAIN_H__ #define __MAIN_H__ @@ -29,7 +28,6 @@ class KWinOptions : public KCModule Q_OBJECT public: - KWinOptions(QWidget *parent, const QVariantList &args); void load() override; @@ -41,8 +39,7 @@ protected Q_SLOTS: void updateUnmanagedState(); private: - - QTabWidget *tab; + QTabWidget *tab; KFocusConfig *mFocus; KTitleBarActionsConfig *mTitleBarActions; @@ -58,7 +55,6 @@ class KActionsOptions : public KCModule Q_OBJECT public: - KActionsOptions(QWidget *parent, const QVariantList &args); void load() override; @@ -70,8 +66,7 @@ protected Q_SLOTS: void moduleChanged(bool state); private: - - QTabWidget *tab; + QTabWidget *tab; KTitleBarActionsConfig *mTitleBarActions; KWindowActionsConfig *mWindowActions; diff --git a/src/kcmkwin/kwinoptions/mouse.cpp b/src/kcmkwin/kwinoptions/mouse.cpp index 6a124b571d..01daeecd45 100644 --- a/src/kcmkwin/kwinoptions/mouse.cpp +++ b/src/kcmkwin/kwinoptions/mouse.cpp @@ -27,7 +27,8 @@ KWinActionsConfigForm::KWinActionsConfigForm(QWidget *parent) } KTitleBarActionsConfig::KTitleBarActionsConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent) - : KCModule(parent), standAlone(_standAlone) + : KCModule(parent) + , standAlone(_standAlone) , m_ui(new KWinMouseConfigForm(this)) { if (settings) { @@ -79,7 +80,8 @@ bool KTitleBarActionsConfig::isSaveNeeded() const } KWindowActionsConfig::KWindowActionsConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent) - : KCModule(parent), standAlone(_standAlone) + : KCModule(parent) + , standAlone(_standAlone) , m_ui(new KWinActionsConfigForm(this)) { if (settings) { diff --git a/src/kcmkwin/kwinoptions/mouse.h b/src/kcmkwin/kwinoptions/mouse.h index 577104b6ea..0d5809610a 100644 --- a/src/kcmkwin/kwinoptions/mouse.h +++ b/src/kcmkwin/kwinoptions/mouse.h @@ -12,8 +12,8 @@ class KConfig; -#include #include +#include #include "ui_actions.h" #include "ui_mouse.h" @@ -25,7 +25,7 @@ class KWinMouseConfigForm : public QWidget, public Ui::KWinMouseConfigForm Q_OBJECT public: - explicit KWinMouseConfigForm(QWidget* parent); + explicit KWinMouseConfigForm(QWidget *parent); }; class KWinActionsConfigForm : public QWidget, public Ui::KWinActionsConfigForm @@ -33,7 +33,7 @@ class KWinActionsConfigForm : public QWidget, public Ui::KWinActionsConfigForm Q_OBJECT public: - explicit KWinActionsConfigForm(QWidget* parent); + explicit KWinActionsConfigForm(QWidget *parent); }; class KTitleBarActionsConfig : public KCModule @@ -41,7 +41,6 @@ class KTitleBarActionsConfig : public KCModule Q_OBJECT public: - KTitleBarActionsConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent); void save() override; @@ -66,7 +65,6 @@ class KWindowActionsConfig : public KCModule Q_OBJECT public: - KWindowActionsConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent); void save() override; @@ -86,4 +84,3 @@ private: }; #endif - diff --git a/src/kcmkwin/kwinoptions/windows.cpp b/src/kcmkwin/kwinoptions/windows.cpp index e169e88036..4c835b0cf5 100644 --- a/src/kcmkwin/kwinoptions/windows.cpp +++ b/src/kcmkwin/kwinoptions/windows.cpp @@ -9,47 +9,48 @@ #include #include -#include -#include -#include #include -#include #include +#include +#include +#include #include +#include #include #include #include #include -#include "windows.h" #include "kwinoptions_settings.h" +#include "windows.h" #include -#include "kwinoptions_settings.h" #include "kwinoptions_kdeglobals_settings.h" +#include "kwinoptions_settings.h" #include -#define CLICK_TO_FOCUS 0 -#define CLICK_TO_FOCUS_MOUSE_PRECEDENT 1 -#define FOCUS_FOLLOWS_MOUSE 2 -#define FOCUS_FOLLOWS_MOUSE_PRECEDENT 3 -#define FOCUS_UNDER_MOUSE 4 -#define FOCUS_STRICTLY_UNDER_MOUSE 5 +#define CLICK_TO_FOCUS 0 +#define CLICK_TO_FOCUS_MOUSE_PRECEDENT 1 +#define FOCUS_FOLLOWS_MOUSE 2 +#define FOCUS_FOLLOWS_MOUSE_PRECEDENT 3 +#define FOCUS_UNDER_MOUSE 4 +#define FOCUS_STRICTLY_UNDER_MOUSE 5 namespace { constexpr int defaultFocusPolicyIndex = CLICK_TO_FOCUS; } -KWinFocusConfigForm::KWinFocusConfigForm(QWidget* parent) +KWinFocusConfigForm::KWinFocusConfigForm(QWidget *parent) : QWidget(parent) { setupUi(parent); } -KFocusConfig::KFocusConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget * parent) - : KCModule(parent), standAlone(_standAlone) +KFocusConfig::KFocusConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent) + : KCModule(parent) + , standAlone(_standAlone) , m_ui(new KWinFocusConfigForm(this)) { if (settings) { @@ -221,14 +222,15 @@ bool KFocusConfig::isSaveNeeded() const return managedWidgetChangeState() || m_unmanagedChangeState; } -KWinAdvancedConfigForm::KWinAdvancedConfigForm(QWidget* parent) +KWinAdvancedConfigForm::KWinAdvancedConfigForm(QWidget *parent) : QWidget(parent) { setupUi(parent); } KAdvancedConfig::KAdvancedConfig(bool _standAlone, KWinOptionsSettings *settings, KWinOptionsKDEGlobalsSettings *globalSettings, QWidget *parent) - : KCModule(parent), standAlone(_standAlone) + : KCModule(parent) + , standAlone(_standAlone) , m_ui(new KWinAdvancedConfigForm(this)) { if (settings && globalSettings) { @@ -276,7 +278,6 @@ void KAdvancedConfig::save(void) QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); QDBusConnection::sessionBus().send(message); - } } @@ -290,14 +291,15 @@ bool KAdvancedConfig::isSaveNeeded() const return managedWidgetChangeState(); } -KWinMovingConfigForm::KWinMovingConfigForm(QWidget* parent) +KWinMovingConfigForm::KWinMovingConfigForm(QWidget *parent) : QWidget(parent) { setupUi(parent); } KMovingConfig::KMovingConfig(bool _standAlone, KWinOptionsSettings *settings, QWidget *parent) - : KCModule(parent), standAlone(_standAlone) + : KCModule(parent) + , standAlone(_standAlone) , m_ui(new KWinMovingConfigForm(this)) { if (settings) { diff --git a/src/kcmkwin/kwinoptions/windows.h b/src/kcmkwin/kwinoptions/windows.h index a39716aeb4..a5ac6d90dd 100644 --- a/src/kcmkwin/kwinoptions/windows.h +++ b/src/kcmkwin/kwinoptions/windows.h @@ -36,7 +36,7 @@ class KWinFocusConfigForm : public QWidget, public Ui::KWinFocusConfigForm Q_OBJECT public: - explicit KWinFocusConfigForm(QWidget* parent); + explicit KWinFocusConfigForm(QWidget *parent); }; class KWinMovingConfigForm : public QWidget, public Ui::KWinMovingConfigForm @@ -44,7 +44,7 @@ class KWinMovingConfigForm : public QWidget, public Ui::KWinMovingConfigForm Q_OBJECT public: - explicit KWinMovingConfigForm(QWidget* parent); + explicit KWinMovingConfigForm(QWidget *parent); }; class KWinAdvancedConfigForm : public QWidget, public Ui::KWinAdvancedConfigForm @@ -52,7 +52,7 @@ class KWinAdvancedConfigForm : public QWidget, public Ui::KWinAdvancedConfigForm Q_OBJECT public: - explicit KWinAdvancedConfigForm(QWidget* parent); + explicit KWinAdvancedConfigForm(QWidget *parent); }; class KFocusConfig : public KCModule @@ -78,7 +78,7 @@ private Q_SLOTS: void updateDefaultIndicator(); private: - bool standAlone; + bool standAlone; bool m_unmanagedChangeState = false; bool m_unmanagedDefaultState = true; @@ -103,7 +103,7 @@ protected: private: KWinOptionsSettings *m_settings; - bool standAlone; + bool standAlone; KWinMovingConfigForm *m_ui; }; @@ -123,8 +123,7 @@ protected: void showEvent(QShowEvent *ev) override; private: - - bool standAlone; + bool standAlone; KWinAdvancedConfigForm *m_ui; KWinOptionsSettings *m_settings; }; diff --git a/src/kcmkwin/kwinrules/kcmrules.cpp b/src/kcmkwin/kwinrules/kcmrules.cpp index 4f5fa8b364..50c1989115 100644 --- a/src/kcmkwin/kwinrules/kcmrules.cpp +++ b/src/kcmkwin/kwinrules/kcmrules.cpp @@ -16,7 +16,6 @@ #include #include - namespace KWin { @@ -47,14 +46,14 @@ KCMKWinRules::KCMKWinRules(QObject *parent, const QVariantList &arguments) } parseArguments(argList); - connect(m_rulesModel, &RulesModel::descriptionChanged, this, [this]{ + connect(m_rulesModel, &RulesModel::descriptionChanged, this, [this] { if (m_editIndex.isValid()) { m_ruleBookModel->setDescriptionAt(m_editIndex.row(), m_rulesModel->description()); } - } ); - connect(m_rulesModel, &RulesModel::dataChanged, this, [this]{ + }); + connect(m_rulesModel, &RulesModel::dataChanged, this, [this] { Q_EMIT m_ruleBookModel->dataChanged(m_editIndex, m_editIndex, {}); - } ); + }); connect(m_ruleBookModel, &RuleBookModel::dataChanged, this, &KCMKWinRules::updateNeedsSave); } @@ -167,7 +166,6 @@ int KCMKWinRules::editIndex() const return m_editIndex.row(); } - void KCMKWinRules::setRuleDescription(int index, const QString &description) { if (index < 0 || index >= m_ruleBookModel->rowCount()) { @@ -183,7 +181,6 @@ void KCMKWinRules::setRuleDescription(int index, const QString &description) updateNeedsSave(); } - void KCMKWinRules::editRule(int index) { if (index < 0 || index >= m_ruleBookModel->rowCount()) { @@ -225,8 +222,8 @@ void KCMKWinRules::moveRule(int sourceIndex, int destIndex) { const int lastIndex = m_ruleBookModel->rowCount() - 1; if (sourceIndex == destIndex - || (sourceIndex < 0 || sourceIndex > lastIndex) - || (destIndex < 0 || destIndex > lastIndex)) { + || (sourceIndex < 0 || sourceIndex > lastIndex) + || (destIndex < 0 || destIndex > lastIndex)) { return; } diff --git a/src/kcmkwin/kwinrules/kcmrules.h b/src/kcmkwin/kwinrules/kcmrules.h index 06aba842c6..cd48f6f1d5 100644 --- a/src/kcmkwin/kwinrules/kcmrules.h +++ b/src/kcmkwin/kwinrules/kcmrules.h @@ -11,7 +11,6 @@ #include - namespace KWin { class RuleSettings; @@ -58,7 +57,7 @@ private: private: RuleBookModel *m_ruleBookModel; - RulesModel* m_rulesModel; + RulesModel *m_rulesModel; QPersistentModelIndex m_editIndex; diff --git a/src/kcmkwin/kwinrules/kwinsrc.cpp b/src/kcmkwin/kwinrules/kwinsrc.cpp index 166a891d96..5682161534 100644 --- a/src/kcmkwin/kwinrules/kwinsrc.cpp +++ b/src/kcmkwin/kwinrules/kwinsrc.cpp @@ -18,7 +18,7 @@ Qt::KeyboardModifiers KWin::InputRedirection::keyboardModifiers() const return Qt::NoModifier; } -void KWin::InputRedirection::warpPointer(const QPointF&) +void KWin::InputRedirection::warpPointer(const QPointF &) { } diff --git a/src/kcmkwin/kwinrules/main.cpp b/src/kcmkwin/kwinrules/main.cpp index 36760b7e75..68bf51af5b 100644 --- a/src/kcmkwin/kwinrules/main.cpp +++ b/src/kcmkwin/kwinrules/main.cpp @@ -15,7 +15,7 @@ #include #include -int main(int argc, char* argv[]) +int main(int argc, char *argv[]) { QApplication app(argc, argv); diff --git a/src/kcmkwin/kwinrules/optionsmodel.cpp b/src/kcmkwin/kwinrules/optionsmodel.cpp index 7d4fdeef76..78f9da7012 100644 --- a/src/kcmkwin/kwinrules/optionsmodel.cpp +++ b/src/kcmkwin/kwinrules/optionsmodel.cpp @@ -8,18 +8,17 @@ #include - namespace KWin { QHash OptionsModel::roleNames() const { return { - {Qt::DisplayRole, QByteArrayLiteral("display")}, + {Qt::DisplayRole, QByteArrayLiteral("display")}, {Qt::DecorationRole, QByteArrayLiteral("decoration")}, - {Qt::ToolTipRole, QByteArrayLiteral("tooltip")}, - {Qt::UserRole, QByteArrayLiteral("value")}, - {Qt::UserRole + 1, QByteArrayLiteral("iconName")}, + {Qt::ToolTipRole, QByteArrayLiteral("tooltip")}, + {Qt::UserRole, QByteArrayLiteral("value")}, + {Qt::UserRole + 1, QByteArrayLiteral("iconName")}, }; } @@ -40,16 +39,16 @@ QVariant OptionsModel::data(const QModelIndex &index, int role) const const Data data = m_data.at(index.row()); switch (role) { - case Qt::DisplayRole: - return data.text; - case Qt::UserRole: - return data.value; - case Qt::DecorationRole: - return data.icon; - case Qt::UserRole + 1: - return data.icon.name(); - case Qt::ToolTipRole: - return data.description; + case Qt::DisplayRole: + return data.text; + case Qt::UserRole: + return data.value; + case Qt::DecorationRole: + return data.icon; + case Qt::UserRole + 1: + return data.icon.name(); + case Qt::ToolTipRole: + return data.description; } return QVariant(); } @@ -104,13 +103,13 @@ void OptionsModel::resetValue() Q_EMIT selectedIndexChanged(m_index); } -void OptionsModel::updateModelData(const QList &data) { +void OptionsModel::updateModelData(const QList &data) +{ beginResetModel(); m_data = data; endResetModel(); } - RulePolicy::Type RulePolicy::type() const { return m_type; @@ -119,7 +118,7 @@ RulePolicy::Type RulePolicy::type() const int RulePolicy::value() const { if (m_type == RulePolicy::NoPolicy) { - return Rules::Apply; // To simplify external checks when rule has no policy + return Rules::Apply; // To simplify external checks when rule has no policy } return OptionsModel::value().toInt(); } @@ -127,13 +126,13 @@ int RulePolicy::value() const QString RulePolicy::policyKey(const QString &key) const { switch (m_type) { - case NoPolicy: - return QString(); - case StringMatch: - return QStringLiteral("%1match").arg(key); - case SetRule: - case ForceRule: - return QStringLiteral("%1rule").arg(key); + case NoPolicy: + return QString(); + case StringMatch: + return QStringLiteral("%1match").arg(key); + case SetRule: + case ForceRule: + return QStringLiteral("%1rule").arg(key); } return QString(); @@ -141,43 +140,41 @@ QString RulePolicy::policyKey(const QString &key) const QList RulePolicy::policyOptions(RulePolicy::Type type) { - static const auto stringMatchOptions = QList { + static const auto stringMatchOptions = QList{ {Rules::UnimportantMatch, i18n("Unimportant")}, - {Rules::ExactMatch, i18n("Exact Match")}, - {Rules::SubstringMatch, i18n("Substring Match")}, - {Rules::RegExpMatch, i18n("Regular Expression")} - }; + {Rules::ExactMatch, i18n("Exact Match")}, + {Rules::SubstringMatch, i18n("Substring Match")}, + {Rules::RegExpMatch, i18n("Regular Expression")}}; - static const auto setRuleOptions = QList { + static const auto setRuleOptions = QList{ {Rules::Apply, - i18n("Apply Initially"), - i18n("The window property will be only set to the given value after the window is created." - "\nNo further changes will be affected.")}, + i18n("Apply Initially"), + i18n("The window property will be only set to the given value after the window is created." + "\nNo further changes will be affected.")}, {Rules::ApplyNow, - i18n("Apply Now"), - i18n("The window property will be set to the given value immediately and will not be affected later" - "\n(this action will be deleted afterwards).")}, + i18n("Apply Now"), + i18n("The window property will be set to the given value immediately and will not be affected later" + "\n(this action will be deleted afterwards).")}, {Rules::Remember, - i18n("Remember"), - i18n("The value of the window property will be remembered and, every time the window" - " is created, the last remembered value will be applied.")}, + i18n("Remember"), + i18n("The value of the window property will be remembered and, every time the window" + " is created, the last remembered value will be applied.")}, {Rules::DontAffect, - i18n("Do Not Affect"), - i18n("The window property will not be affected and therefore the default handling for it will be used." - "\nSpecifying this will block more generic window settings from taking effect.")}, + i18n("Do Not Affect"), + i18n("The window property will not be affected and therefore the default handling for it will be used." + "\nSpecifying this will block more generic window settings from taking effect.")}, {Rules::Force, - i18n("Force"), - i18n("The window property will be always forced to the given value.")}, + i18n("Force"), + i18n("The window property will be always forced to the given value.")}, {Rules::ForceTemporarily, - i18n("Force Temporarily"), - i18n("The window property will be forced to the given value until it is hidden" - "\n(this action will be deleted after the window is hidden).")} - }; + i18n("Force Temporarily"), + i18n("The window property will be forced to the given value until it is hidden" + "\n(this action will be deleted after the window is hidden).")}}; - static auto forceRuleOptions = QList { - setRuleOptions.at(4), // Rules::Force - setRuleOptions.at(5), // Rules::ForceTemporarily - setRuleOptions.at(3), // Rules::DontAffect + static auto forceRuleOptions = QList{ + setRuleOptions.at(4), // Rules::Force + setRuleOptions.at(5), // Rules::ForceTemporarily + setRuleOptions.at(3), // Rules::DontAffect }; switch (type) { @@ -193,4 +190,4 @@ QList RulePolicy::policyOptions(RulePolicy::Type type) return {}; } -} //namespace +} // namespace diff --git a/src/kcmkwin/kwinrules/optionsmodel.h b/src/kcmkwin/kwinrules/optionsmodel.h index d23a5cf958..ffc5897826 100644 --- a/src/kcmkwin/kwinrules/optionsmodel.h +++ b/src/kcmkwin/kwinrules/optionsmodel.h @@ -13,8 +13,8 @@ #include #include - -namespace KWin { +namespace KWin +{ class OptionsModel : public QAbstractListModel { @@ -22,18 +22,21 @@ class OptionsModel : public QAbstractListModel Q_PROPERTY(int selectedIndex READ selectedIndex NOTIFY selectedIndexChanged) public: - struct Data { + struct Data + { Data(const QVariant &value, const QString &text, const QIcon &icon = {}, const QString &description = {}) : value(value) , text(text) , icon(icon) , description(description) - {} + { + } Data(const QVariant &value, const QString &text, const QString &description) : value(value) , text(text) , description(description) - {} + { + } QVariant value; QString text; @@ -42,8 +45,14 @@ public: }; public: - OptionsModel() : QAbstractListModel(), m_data(), m_index(0) {}; - OptionsModel(const QList &data) : QAbstractListModel(), m_data(data), m_index(0) {}; + OptionsModel() + : QAbstractListModel() + , m_data() + , m_index(0){}; + OptionsModel(const QList &data) + : QAbstractListModel() + , m_data(data) + , m_index(0){}; int rowCount(const QModelIndex &parent = QModelIndex()) const override; QHash roleNames() const override; @@ -82,8 +91,7 @@ public: public: RulePolicy(Type type) : OptionsModel(policyOptions(type)) - , m_type(type) - {}; + , m_type(type){}; Type type() const; int value() const; @@ -96,6 +104,6 @@ private: Type m_type; }; -} //namespace +} // namespace -#endif //KWIN_OPTIONS_MODEL_H +#endif // KWIN_OPTIONS_MODEL_H diff --git a/src/kcmkwin/kwinrules/rulebookmodel.cpp b/src/kcmkwin/kwinrules/rulebookmodel.cpp index 1a05aaac72..26dc070683 100644 --- a/src/kcmkwin/kwinrules/rulebookmodel.cpp +++ b/src/kcmkwin/kwinrules/rulebookmodel.cpp @@ -110,7 +110,7 @@ bool RuleBookModel::removeRows(int row, int count, const QModelIndex &parent) bool RuleBookModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) { - if (sourceParent != destinationParent || sourceParent != QModelIndex()){ + if (sourceParent != destinationParent || sourceParent != QModelIndex()) { return false; } @@ -130,7 +130,6 @@ bool RuleBookModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int return true; } - QString RuleBookModel::descriptionAt(int row) const { Q_ASSERT(row >= 0 && row < rowCount()); diff --git a/src/kcmkwin/kwinrules/rulebookmodel.h b/src/kcmkwin/kwinrules/rulebookmodel.h index 4cff917934..3e8e064043 100644 --- a/src/kcmkwin/kwinrules/rulebookmodel.h +++ b/src/kcmkwin/kwinrules/rulebookmodel.h @@ -11,7 +11,6 @@ #include - namespace KWin { diff --git a/src/kcmkwin/kwinrules/ruleitem.cpp b/src/kcmkwin/kwinrules/ruleitem.cpp index 46830c5f73..e3aa61e9d1 100644 --- a/src/kcmkwin/kwinrules/ruleitem.cpp +++ b/src/kcmkwin/kwinrules/ruleitem.cpp @@ -6,7 +6,6 @@ #include "ruleitem.h" - namespace KWin { @@ -190,39 +189,38 @@ QString RuleItem::policyKey() const QVariant RuleItem::typedValue(const QVariant &value) const { switch (type()) { - case Undefined: - case Option: - return value; - case Boolean: - return value.toBool(); - case Integer: - case Percentage: - return value.toInt(); - case NetTypes: { - const uint typesMask = value.toUInt() & optionsMask(); // filter by the allowed mask in the model - if (typesMask == 0 || typesMask == optionsMask()) { // if no types or all of them are selected - return 0U - 1; // return an all active mask (NET:AllTypesMask) - } - return typesMask; + case Undefined: + case Option: + return value; + case Boolean: + return value.toBool(); + case Integer: + case Percentage: + return value.toInt(); + case NetTypes: { + const uint typesMask = value.toUInt() & optionsMask(); // filter by the allowed mask in the model + if (typesMask == 0 || typesMask == optionsMask()) { // if no types or all of them are selected + return 0U - 1; // return an all active mask (NET:AllTypesMask) } - case Point: { - const QPoint point = value.toPoint(); - return (point == invalidPoint) ? QPoint(0, 0) : point; + return typesMask; + } + case Point: { + const QPoint point = value.toPoint(); + return (point == invalidPoint) ? QPoint(0, 0) : point; + } + case Size: + return value.toSize(); + case String: + if (value.type() == QVariant::StringList && !value.toStringList().isEmpty()) { + return value.toStringList().at(0).trimmed(); } - case Size: - return value.toSize(); - case String: - if (value.type() == QVariant::StringList && !value.toStringList().isEmpty()) { - return value.toStringList().at(0).trimmed(); - } - return value.toString().trimmed(); - case Shortcut: - return value.toString(); - case OptionList: - return value.toStringList(); + return value.toString().trimmed(); + case Shortcut: + return value.toString(); + case OptionList: + return value.toStringList(); } return value; } -} //namespace - +} // namespace diff --git a/src/kcmkwin/kwinrules/ruleitem.h b/src/kcmkwin/kwinrules/ruleitem.h index fa5fcdfd23..137d2f380a 100644 --- a/src/kcmkwin/kwinrules/ruleitem.h +++ b/src/kcmkwin/kwinrules/ruleitem.h @@ -12,7 +12,6 @@ #include #include - namespace KWin { @@ -37,25 +36,24 @@ public: Q_ENUM(Type) enum Flags { - NoFlags = 0, - AlwaysEnabled = 1u << 0, - StartEnabled = 1u << 1, - AffectsWarning = 1u << 2, + NoFlags = 0, + AlwaysEnabled = 1u << 0, + StartEnabled = 1u << 1, + AffectsWarning = 1u << 2, AffectsDescription = 1u << 3, - SuggestionOnly = 1u << 4, - AllFlags = 0b11111 + SuggestionOnly = 1u << 4, + AllFlags = 0b11111 }; public: - RuleItem() {}; + RuleItem(){}; RuleItem(const QString &key, const RulePolicy::Type policyType, const Type type, const QString &name, const QString §ion, const QIcon &icon = QIcon::fromTheme("window"), - const QString &description = QString("") - ); + const QString &description = QString("")); ~RuleItem(); QString key() const; @@ -69,7 +67,7 @@ public: void setEnabled(bool enabled); bool hasFlag(RuleItem::Flags flag) const; - void setFlag(RuleItem::Flags flag, bool active=true); + void setFlag(RuleItem::Flags flag, bool active = true); Type type() const; QVariant value() const; @@ -82,8 +80,8 @@ public: uint optionsMask() const; RulePolicy::Type policyType() const; - int policy() const; // int belongs to anonymous enum in Rules:: - void setPolicy(int policy); // int belongs to anonymous enum in Rules:: + int policy() const; // int belongs to anonymous enum in Rules:: + void setPolicy(int policy); // int belongs to anonymous enum in Rules:: QVariant policyModel() const; QString policyKey() const; @@ -111,6 +109,6 @@ private: uint m_optionsMask; }; -} //namespace +} // namespace -#endif //KWIN_RULEITEM_H +#endif // KWIN_RULEITEM_H diff --git a/src/kcmkwin/kwinrules/rulesmodel.cpp b/src/kcmkwin/kwinrules/rulesmodel.cpp index 82e7256142..e85d6f8d4b 100644 --- a/src/kcmkwin/kwinrules/rulesmodel.cpp +++ b/src/kcmkwin/kwinrules/rulesmodel.cpp @@ -20,7 +20,6 @@ #include #include - namespace KWin { @@ -30,7 +29,7 @@ RulesModel::RulesModel(QObject *parent) qmlRegisterUncreatableType("org.kde.kcms.kwinrules", 1, 0, "RuleItem", QStringLiteral("Do not create objects of type RuleItem")); qmlRegisterUncreatableType("org.kde.kcms.kwinrules", 1, 0, "RulesModel", - QStringLiteral("Do not create objects of type RulesModel")); + QStringLiteral("Do not create objects of type RulesModel")); qDBusRegisterMetaType(); qDBusRegisterMetaType(); @@ -42,23 +41,23 @@ RulesModel::~RulesModel() { } -QHash< int, QByteArray > RulesModel::roleNames() const +QHash RulesModel::roleNames() const { return { - {KeyRole, QByteArrayLiteral("key")}, - {NameRole, QByteArrayLiteral("name")}, - {IconRole, QByteArrayLiteral("icon")}, - {IconNameRole, QByteArrayLiteral("iconName")}, - {SectionRole, QByteArrayLiteral("section")}, - {DescriptionRole, QByteArrayLiteral("description")}, - {EnabledRole, QByteArrayLiteral("enabled")}, - {SelectableRole, QByteArrayLiteral("selectable")}, - {ValueRole, QByteArrayLiteral("value")}, - {TypeRole, QByteArrayLiteral("type")}, - {PolicyRole, QByteArrayLiteral("policy")}, - {PolicyModelRole, QByteArrayLiteral("policyModel")}, - {OptionsModelRole, QByteArrayLiteral("options")}, - {OptionsMaskRole, QByteArrayLiteral("optionsMask")}, + {KeyRole, QByteArrayLiteral("key")}, + {NameRole, QByteArrayLiteral("name")}, + {IconRole, QByteArrayLiteral("icon")}, + {IconNameRole, QByteArrayLiteral("iconName")}, + {SectionRole, QByteArrayLiteral("section")}, + {DescriptionRole, QByteArrayLiteral("description")}, + {EnabledRole, QByteArrayLiteral("enabled")}, + {SelectableRole, QByteArrayLiteral("selectable")}, + {ValueRole, QByteArrayLiteral("value")}, + {TypeRole, QByteArrayLiteral("type")}, + {PolicyRole, QByteArrayLiteral("policy")}, + {PolicyModelRole, QByteArrayLiteral("policyModel")}, + {OptionsModelRole, QByteArrayLiteral("options")}, + {OptionsMaskRole, QByteArrayLiteral("optionsMask")}, {SuggestedValueRole, QByteArrayLiteral("suggested")}, }; } @@ -167,7 +166,7 @@ bool RulesModel::setData(const QModelIndex &index, const QVariant &value, int ro return true; } -QModelIndex RulesModel::indexOf(const QString& key) const +QModelIndex RulesModel::indexOf(const QString &key) const { const QModelIndexList indexes = match(index(0), RulesModel::KeyRole, key, 1, Qt::MatchFixedString); if (indexes.isEmpty()) { @@ -184,13 +183,12 @@ RuleItem *RulesModel::addRule(RuleItem *rule) return rule; } -bool RulesModel::hasRule(const QString& key) const +bool RulesModel::hasRule(const QString &key) const { return m_rules.contains(key); } - -RuleItem *RulesModel::ruleItem(const QString& key) const +RuleItem *RulesModel::ruleItem(const QString &key) const { return m_rules.value(key); } @@ -256,11 +254,11 @@ QStringList RulesModel::warningMessages() const bool RulesModel::wmclassWarning() const { const bool no_wmclass = !m_rules["wmclass"]->isEnabled() - || m_rules["wmclass"]->policy() == Rules::UnimportantMatch; + || m_rules["wmclass"]->policy() == Rules::UnimportantMatch; const bool alltypes = !m_rules["types"]->isEnabled() - || (m_rules["types"]->value() == 0) - || (m_rules["types"]->value() == NET::AllTypesMask) - || ((m_rules["types"]->value().toInt() | (1 << NET::Override)) == 0x3FF); + || (m_rules["types"]->value() == 0) + || (m_rules["types"]->value() == NET::AllTypesMask) + || ((m_rules["types"]->value().toInt() | (1 << NET::Override)) == 0x3FF); return (no_wmclass && alltypes); } @@ -268,19 +266,19 @@ bool RulesModel::wmclassWarning() const bool RulesModel::geometryWarning() const { const bool ignoregeometry = m_rules["ignoregeometry"]->isEnabled() - && m_rules["ignoregeometry"]->policy() == Rules::Force - && m_rules["ignoregeometry"]->value() == true; + && m_rules["ignoregeometry"]->policy() == Rules::Force + && m_rules["ignoregeometry"]->value() == true; const bool initialPos = m_rules["position"]->isEnabled() - && (m_rules["position"]->policy() == Rules::Apply - || m_rules["position"]->policy() == Rules::Remember); + && (m_rules["position"]->policy() == Rules::Apply + || m_rules["position"]->policy() == Rules::Remember); const bool initialSize = m_rules["size"]->isEnabled() - && (m_rules["size"]->policy() == Rules::Apply - || m_rules["size"]->policy() == Rules::Remember); + && (m_rules["size"]->policy() == Rules::Apply + || m_rules["size"]->policy() == Rules::Remember); const bool initialPlacement = m_rules["placement"]->isEnabled() - && m_rules["placement"]->policy() == Rules::Force; + && m_rules["placement"]->policy() == Rules::Force; return (!ignoregeometry && (initialPos || initialSize || initialPlacement)); } @@ -356,7 +354,7 @@ void RulesModel::populateRuleList() qDeleteAll(m_ruleList); m_ruleList.clear(); - //Rule description + // Rule description auto description = addRule(new RuleItem(QLatin1String("description"), RulePolicy::NoPolicy, RuleItem::String, i18n("Description"), i18n("Window matching"), @@ -412,9 +410,9 @@ void RulesModel::populateRuleList() // Size & Position auto position = addRule(new RuleItem(QLatin1String("position"), - RulePolicy::SetRule, RuleItem::Point, - i18n("Position"), i18n("Size & Position"), - QIcon::fromTheme("transform-move"))); + RulePolicy::SetRule, RuleItem::Point, + i18n("Position"), i18n("Size & Position"), + QIcon::fromTheme("transform-move"))); position->setFlag(RuleItem::AffectsWarning); auto size = addRule(new RuleItem(QLatin1String("size"), @@ -450,8 +448,9 @@ void RulesModel::populateRuleList() addRule(desktops); desktops->setOptionsData(virtualDesktopsModelData()); - connect(this, &RulesModel::virtualDesktopsUpdated, - this, [this] { m_rules["desktops"]->setOptionsData(virtualDesktopsModelData()); }); + connect(this, &RulesModel::virtualDesktopsUpdated, this, [this]() { + m_rules["desktops"]->setOptionsData(virtualDesktopsModelData()); + }); updateVirtualDesktops(); @@ -465,11 +464,12 @@ void RulesModel::populateRuleList() activity->setOptionsData(activitiesModelData()); // Activites consumer may update the available activities later - connect(m_activities, &KActivities::Consumer::activitiesChanged, - this, [this] { m_rules["activity"]->setOptionsData(activitiesModelData()); }); - connect(m_activities, &KActivities::Consumer::serviceStatusChanged, - this, [this] { m_rules["activity"]->setOptionsData(activitiesModelData()); }); - + connect(m_activities, &KActivities::Consumer::activitiesChanged, this, [this]() { + m_rules["activity"]->setOptionsData(activitiesModelData()); + }); + connect(m_activities, &KActivities::Consumer::serviceStatusChanged, this, [this]() { + m_rules["activity"]->setOptionsData(activitiesModelData()); + }); #endif addRule(new RuleItem(QLatin1String("screen"), @@ -650,27 +650,26 @@ void RulesModel::populateRuleList() QIcon::fromTheme("composite-track-on"))); } - const QHash RulesModel::x11PropertyHash() { - static const auto propertyToRule = QHash { - { "caption", "title" }, - { "role", "windowrole" }, - { "clientMachine", "clientmachine" }, - { "maximizeHorizontal", "maximizehoriz" }, - { "maximizeVertical", "maximizevert" }, - { "minimized", "minimize" }, - { "shaded", "shade" }, - { "fullscreen", "fullscreen" }, - { "keepAbove", "above" }, - { "keepBelow", "below" }, - { "noBorder", "noborder" }, - { "skipTaskbar", "skiptaskbar" }, - { "skipPager", "skippager" }, - { "skipSwitcher", "skipswitcher" }, - { "type", "type" }, - { "desktopFile", "desktopfile" }, - { "desktops", "desktops" }, + static const auto propertyToRule = QHash{ + {"caption", "title"}, + {"role", "windowrole"}, + {"clientMachine", "clientmachine"}, + {"maximizeHorizontal", "maximizehoriz"}, + {"maximizeVertical", "maximizevert"}, + {"minimized", "minimize"}, + {"shaded", "shade"}, + {"fullscreen", "fullscreen"}, + {"keepAbove", "above"}, + {"keepBelow", "below"}, + {"noBorder", "noborder"}, + {"skipTaskbar", "skiptaskbar"}, + {"skipPager", "skippager"}, + {"skipSwitcher", "skipswitcher"}, + {"type", "type"}, + {"desktopFile", "desktopfile"}, + {"desktops", "desktops"}, }; return propertyToRule; }; @@ -701,7 +700,7 @@ void RulesModel::setSuggestedProperties(const QVariantMap &info) #if KWIN_BUILD_ACTIVITIES const QStringList activities = info.value("activities").toStringList(); - m_rules["activity"]->setSuggestedValue(activities.isEmpty() ? QStringList{ Activities::nullUuid() } + m_rules["activity"]->setSuggestedValue(activities.isEmpty() ? QStringList{Activities::nullUuid()} : activities); #endif @@ -716,43 +715,39 @@ void RulesModel::setSuggestedProperties(const QVariantMap &info) m_rules[ruleKey]->setSuggestedValue(info.value(property)); } - Q_EMIT dataChanged(index(0), index(rowCount()-1), {RulesModel::SuggestedValueRole}); + Q_EMIT dataChanged(index(0), index(rowCount() - 1), {RulesModel::SuggestedValueRole}); } - QList RulesModel::windowTypesModelData() const { - static const auto modelData = QList { - //TODO: Find/create better icons - { NET::Normal, i18n("Normal Window") , QIcon::fromTheme("window") }, - { NET::Dialog, i18n("Dialog Window") , QIcon::fromTheme("window-duplicate") }, - { NET::Utility, i18n("Utility Window") , QIcon::fromTheme("dialog-object-properties") }, - { NET::Dock, i18n("Dock (panel)") , QIcon::fromTheme("list-remove") }, - { NET::Toolbar, i18n("Toolbar") , QIcon::fromTheme("tools") }, - { NET::Menu, i18n("Torn-Off Menu") , QIcon::fromTheme("overflow-menu-left") }, - { NET::Splash, i18n("Splash Screen") , QIcon::fromTheme("embosstool") }, - { NET::Desktop, i18n("Desktop") , QIcon::fromTheme("desktop") }, + static const auto modelData = QList{ + // TODO: Find/create better icons + {NET::Normal, i18n("Normal Window"), QIcon::fromTheme("window")}, + {NET::Dialog, i18n("Dialog Window"), QIcon::fromTheme("window-duplicate")}, + {NET::Utility, i18n("Utility Window"), QIcon::fromTheme("dialog-object-properties")}, + {NET::Dock, i18n("Dock (panel)"), QIcon::fromTheme("list-remove")}, + {NET::Toolbar, i18n("Toolbar"), QIcon::fromTheme("tools")}, + {NET::Menu, i18n("Torn-Off Menu"), QIcon::fromTheme("overflow-menu-left")}, + {NET::Splash, i18n("Splash Screen"), QIcon::fromTheme("embosstool")}, + {NET::Desktop, i18n("Desktop"), QIcon::fromTheme("desktop")}, // { NET::Override, i18n("Unmanaged Window") }, deprecated - { NET::TopMenu, i18n("Standalone Menubar"), QIcon::fromTheme("application-menu") }, - { NET::OnScreenDisplay, i18n("On Screen Display"), QIcon::fromTheme("osd-duplicate") } - }; + {NET::TopMenu, i18n("Standalone Menubar"), QIcon::fromTheme("application-menu")}, + {NET::OnScreenDisplay, i18n("On Screen Display"), QIcon::fromTheme("osd-duplicate")}}; return modelData; } QList RulesModel::virtualDesktopsModelData() const { - QList modelData = { {QString(), i18n("All Desktops"), QIcon::fromTheme("window-pin")} }; + QList modelData = {{QString(), i18n("All Desktops"), QIcon::fromTheme("window-pin")}}; for (const DBusDesktopDataStruct &desktop : m_virtualDesktops) { modelData << OptionsModel::Data{ desktop.id, QString::number(desktop.position + 1).rightJustified(2) + QStringLiteral(": ") + desktop.name, - QIcon::fromTheme("virtual-desktops") - }; + QIcon::fromTheme("virtual-desktops")}; } return modelData; } - QList RulesModel::activitiesModelData() const { #if KWIN_BUILD_ACTIVITIES @@ -761,14 +756,13 @@ QList RulesModel::activitiesModelData() const modelData << OptionsModel::Data{ Activities::nullUuid(), i18n("All Activities"), - QIcon::fromTheme("activities") - }; + QIcon::fromTheme("activities")}; const auto activities = m_activities->activities(KActivities::Info::Running); if (m_activities->serviceStatus() == KActivities::Consumer::Running) { for (const QString &activityId : activities) { const KActivities::Info info(activityId); - modelData << OptionsModel::Data{ activityId, info.name(), QIcon::fromTheme(info.icon()) }; + modelData << OptionsModel::Data{activityId, info.name(), QIcon::fromTheme(info.icon())}; } } @@ -780,30 +774,28 @@ QList RulesModel::activitiesModelData() const QList RulesModel::placementModelData() const { - static const auto modelData = QList { - { Placement::Default, i18n("Default") }, - { Placement::NoPlacement, i18n("No Placement") }, - { Placement::Smart, i18n("Minimal Overlapping") }, - { Placement::Maximizing, i18n("Maximized") }, - { Placement::Cascade, i18n("Cascaded") }, - { Placement::Centered, i18n("Centered") }, - { Placement::Random, i18n("Random") }, - { Placement::ZeroCornered, i18n("In Top-Left Corner") }, - { Placement::UnderMouse, i18n("Under Mouse") }, - { Placement::OnMainWindow, i18n("On Main Window") } - }; + static const auto modelData = QList{ + {Placement::Default, i18n("Default")}, + {Placement::NoPlacement, i18n("No Placement")}, + {Placement::Smart, i18n("Minimal Overlapping")}, + {Placement::Maximizing, i18n("Maximized")}, + {Placement::Cascade, i18n("Cascaded")}, + {Placement::Centered, i18n("Centered")}, + {Placement::Random, i18n("Random")}, + {Placement::ZeroCornered, i18n("In Top-Left Corner")}, + {Placement::UnderMouse, i18n("Under Mouse")}, + {Placement::OnMainWindow, i18n("On Main Window")}}; return modelData; } QList RulesModel::focusModelData() const { - static const auto modelData = QList { - { 0, i18n("None") }, - { 1, i18n("Low") }, - { 2, i18n("Normal") }, - { 3, i18n("High") }, - { 4, i18n("Extreme") } - }; + static const auto modelData = QList{ + {0, i18n("None")}, + {1, i18n("Low")}, + {2, i18n("Normal")}, + {3, i18n("High")}, + {4, i18n("Extreme")}}; return modelData; } @@ -820,8 +812,7 @@ QList RulesModel::colorSchemesModelData() const modelData << OptionsModel::Data{ QFileInfo(index.data(Qt::UserRole).toString()).baseName(), index.data(Qt::DisplayRole).toString(), - index.data(Qt::DecorationRole).value() - }; + index.data(Qt::DecorationRole).value()}; } return modelData; @@ -842,21 +833,19 @@ void RulesModel::selectX11Window() QDBusPendingReply async = QDBusConnection::sessionBus().asyncCall(message); QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(async, this); - connect(callWatcher, &QDBusPendingCallWatcher::finished, this, - [this](QDBusPendingCallWatcher *self) { - QDBusPendingReply reply = *self; - self->deleteLater(); - if (!reply.isValid()) { - if (reply.error().name() == QLatin1String("org.kde.KWin.Error.InvalidWindow")) { - Q_EMIT showErrorMessage(i18n("Could not detect window properties. The window is not managed by KWin.")); - } - return; - } - const QVariantMap windowInfo = reply.value(); - setSuggestedProperties(windowInfo); - Q_EMIT showSuggestions(); + connect(callWatcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *self) { + QDBusPendingReply reply = *self; + self->deleteLater(); + if (!reply.isValid()) { + if (reply.error().name() == QLatin1String("org.kde.KWin.Error.InvalidWindow")) { + Q_EMIT showErrorMessage(i18n("Could not detect window properties. The window is not managed by KWin.")); } - ); + return; + } + const QVariantMap windowInfo = reply.value(); + setSuggestedProperties(windowInfo); + Q_EMIT showSuggestions(); + }); } void RulesModel::updateVirtualDesktops() @@ -867,24 +856,20 @@ void RulesModel::updateVirtualDesktops() QStringLiteral("Get")); message.setArguments(QVariantList{ QStringLiteral("org.kde.KWin.VirtualDesktopManager"), - QStringLiteral("desktops") - }); + QStringLiteral("desktops")}); QDBusPendingReply async = QDBusConnection::sessionBus().asyncCall(message); QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(async, this); - connect(callWatcher, &QDBusPendingCallWatcher::finished, this, - [this](QDBusPendingCallWatcher *self) { - QDBusPendingReply reply = *self; - self->deleteLater(); - if (!reply.isValid()) { - return; - } - m_virtualDesktops = qdbus_cast(reply.value()); - Q_EMIT virtualDesktopsUpdated(); - } - ); + connect(callWatcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *self) { + QDBusPendingReply reply = *self; + self->deleteLater(); + if (!reply.isValid()) { + return; + } + m_virtualDesktops = qdbus_cast(reply.value()); + Q_EMIT virtualDesktopsUpdated(); + }); } - -} //namespace +} // namespace diff --git a/src/kcmkwin/kwinrules/rulesmodel.h b/src/kcmkwin/kwinrules/rulesmodel.h index 156a7b07c5..1878fc57f6 100644 --- a/src/kcmkwin/kwinrules/rulesmodel.h +++ b/src/kcmkwin/kwinrules/rulesmodel.h @@ -13,14 +13,13 @@ #include #include -#include #include +#include #if KWIN_BUILD_ACTIVITIES #include #endif - namespace KWin { @@ -58,7 +57,7 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const override; QHash roleNames() const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - bool setData(const QModelIndex & index, const QVariant & value, int role) override; + bool setData(const QModelIndex &index, const QVariant &value, int role) override; QModelIndex indexOf(const QString &key) const; bool hasRule(const QString &key) const; diff --git a/src/kcmkwin/kwinscreenedges/kwinscreenedge.cpp b/src/kcmkwin/kwinscreenedges/kwinscreenedge.cpp index d4d269eee7..a4fda24326 100644 --- a/src/kcmkwin/kwinscreenedges/kwinscreenedge.cpp +++ b/src/kcmkwin/kwinscreenedges/kwinscreenedge.cpp @@ -139,7 +139,7 @@ void KWinScreenEdge::setDefaults() int KWinScreenEdge::electricBorderToMonitorEdge(ElectricBorder border) { - switch(border) { + switch (border) { case ElectricTop: return Monitor::Top; case ElectricTopRight: @@ -203,10 +203,10 @@ void KWinScreenEdge::onChanged() void KWinScreenEdge::createConnection() { - connect(monitor(), - &Monitor::changed, - this, - &KWinScreenEdge::onChanged); + connect(monitor(), + &Monitor::changed, + this, + &KWinScreenEdge::onChanged); } bool KWinScreenEdge::isSaveNeeded() const diff --git a/src/kcmkwin/kwinscreenedges/main.cpp b/src/kcmkwin/kwinscreenedges/main.cpp index 8753e7554e..bd48b33e0b 100644 --- a/src/kcmkwin/kwinscreenedges/main.cpp +++ b/src/kcmkwin/kwinscreenedges/main.cpp @@ -15,16 +15,16 @@ #include #include #include -#include #include #include -#include +#include #include +#include #include "kwinscreenedgeconfigform.h" #include "kwinscreenedgedata.h" -#include "kwinscreenedgesettings.h" #include "kwinscreenedgescriptsettings.h" +#include "kwinscreenedgesettings.h" K_PLUGIN_FACTORY(KWinScreenEdgesConfigFactory, registerPlugin(); registerPlugin();) @@ -87,8 +87,8 @@ void KWinScreenEdgesConfig::save() QDBusConnection::sessionBus().send(message); // and reconfigure the effects OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), - QStringLiteral("/Effects"), - QDBusConnection::sessionBus()); + QStringLiteral("/Effects"), + QDBusConnection::sessionBus()); interface.reconfigureEffect(QStringLiteral("overview")); interface.reconfigureEffect(QStringLiteral("presentwindows")); interface.reconfigureEffect(QStringLiteral("desktopgrid")); @@ -139,7 +139,7 @@ void KWinScreenEdgesConfig::monitorInit() const auto scripts = KPackage::PackageLoader::self()->listPackages(QStringLiteral("KWin/Script"), scriptFolder); KConfigGroup config(m_config, "Plugins"); - for (const KPluginMetaData &script: scripts) { + for (const KPluginMetaData &script : scripts) { if (script.value(QStringLiteral("X-KWin-Border-Activate")) != QLatin1String("true")) { continue; } diff --git a/src/kcmkwin/kwinscreenedges/main.h b/src/kcmkwin/kwinscreenedges/main.h index 94b312dc11..b0f1629972 100644 --- a/src/kcmkwin/kwinscreenedges/main.h +++ b/src/kcmkwin/kwinscreenedges/main.h @@ -43,8 +43,8 @@ protected: private: KWinScreenEdgesConfigForm *m_form; KSharedConfigPtr m_config; - QStringList m_scripts; //list of script IDs ordered in the list they are presented in the menu - QHash m_scriptSettings; + QStringList m_scripts; // list of script IDs ordered in the list they are presented in the menu + QHash m_scriptSettings; KWinScreenEdgeData *m_data; enum EffectActions { diff --git a/src/kcmkwin/kwinscreenedges/monitor.cpp b/src/kcmkwin/kwinscreenedges/monitor.cpp index 3f64908318..4ae6872f93 100644 --- a/src/kcmkwin/kwinscreenedges/monitor.cpp +++ b/src/kcmkwin/kwinscreenedges/monitor.cpp @@ -15,9 +15,9 @@ #include #include -#include #include #include +#include #include #include #include @@ -50,15 +50,15 @@ static QScreen *screenFromWidget(const QWidget *widget) return QGuiApplication::primaryScreen(); } -Monitor::Monitor(QWidget* parent) +Monitor::Monitor(QWidget *parent) : ScreenPreviewWidget(parent) { QRect avail = screenFromWidget(this)->geometry(); setRatio((qreal)avail.width() / (qreal)avail.height()); for (int i = 0; - i < 8; - ++i) - popups[ i ] = new QMenu(this); + i < 8; + ++i) + popups[i] = new QMenu(this); scene = new QGraphicsScene(this); view = new QGraphicsView(scene, this); view->setBackgroundBrush(Qt::black); @@ -67,12 +67,12 @@ Monitor::Monitor(QWidget* parent) view->setFocusPolicy(Qt::NoFocus); view->setFrameShape(QFrame::NoFrame); for (int i = 0; - i < 8; - ++i) { - items[ i ] = new Corner(this); - scene->addItem(items[ i ]); - hidden[ i ] = false; - grp[ i ] = new QActionGroup(this); + i < 8; + ++i) { + items[i] = new Corner(this); + scene->addItem(items[i]); + hidden[i] = false; + grp[i] = new QActionGroup(this); } checkSize(); } @@ -80,17 +80,17 @@ Monitor::Monitor(QWidget* parent) void Monitor::clear() { for (int i = 0; - i < 8; - ++i) { - popups[ i ]->clear(); + i < 8; + ++i) { + popups[i]->clear(); setEdge(i, false); setEdgeHidden(i, false); - delete grp[ i ]; - grp[ i ] = new QActionGroup(this); + delete grp[i]; + grp[i] = new QActionGroup(this); } } -void Monitor::resizeEvent(QResizeEvent* e) +void Monitor::resizeEvent(QResizeEvent *e) { ScreenPreviewWidget::resizeEvent(e); checkSize(); @@ -99,32 +99,32 @@ void Monitor::resizeEvent(QResizeEvent* e) void Monitor::checkSize() { QRect contentsRect = previewRect(); - //int w = 151; - //int h = 115; + // int w = 151; + // int h = 115; view->setGeometry(contentsRect); scene->setSceneRect(QRect(QPoint(0, 0), contentsRect.size())); int x2 = (contentsRect.width() - 20) / 2; int x3 = contentsRect.width() - 20; int y2 = (contentsRect.height() - 20) / 2; int y3 = contentsRect.height() - 20; - items[ 0 ]->setRect(0, y2, 20, 20); - items[ 1 ]->setRect(x3, y2, 20, 20); - items[ 2 ]->setRect(x2, 0, 20, 20); - items[ 3 ]->setRect(x2, y3, 20, 20); - items[ 4 ]->setRect(0, 0, 20, 20); - items[ 5 ]->setRect(x3, 0, 20, 20); - items[ 6 ]->setRect(0, y3, 20, 20); - items[ 7 ]->setRect(x3, y3, 20, 20); + items[0]->setRect(0, y2, 20, 20); + items[1]->setRect(x3, y2, 20, 20); + items[2]->setRect(x2, 0, 20, 20); + items[3]->setRect(x2, y3, 20, 20); + items[4]->setRect(0, 0, 20, 20); + items[5]->setRect(x3, 0, 20, 20); + items[6]->setRect(0, y3, 20, 20); + items[7]->setRect(x3, y3, 20, 20); } void Monitor::setEdge(int edge, bool set) { - items[ edge ]->setActive(set); + items[edge]->setActive(set); } bool Monitor::edge(int edge) const { - return items[ edge ]->brush() == Qt::green; + return items[edge]->brush() == Qt::green; } void Monitor::setEdgeEnabled(int edge, bool enabled) @@ -136,55 +136,55 @@ void Monitor::setEdgeEnabled(int edge, bool enabled) void Monitor::setEdgeHidden(int edge, bool set) { - hidden[ edge ] = set; + hidden[edge] = set; if (set) - items[ edge ]->hide(); + items[edge]->hide(); else - items[ edge ]->show(); + items[edge]->show(); } bool Monitor::edgeHidden(int edge) const { - return hidden[ edge ]; + return hidden[edge]; } -void Monitor::addEdgeItem(int edge, const QString& item) +void Monitor::addEdgeItem(int edge, const QString &item) { - QAction* act = popups[ edge ]->addAction(item); + QAction *act = popups[edge]->addAction(item); act->setCheckable(true); - popup_actions[ edge ].append(act); - grp[ edge ]->addAction(act); - if (popup_actions[ edge ].count() == 1) { + popup_actions[edge].append(act); + grp[edge]->addAction(act); + if (popup_actions[edge].count() == 1) { act->setChecked(true); - items[ edge ]->setToolTip(item); + items[edge]->setToolTip(item); } - setEdge(edge, !popup_actions[ edge ][ 0 ]->isChecked()); + setEdge(edge, !popup_actions[edge][0]->isChecked()); } void Monitor::setEdgeItemEnabled(int edge, int index, bool enabled) { - popup_actions[ edge ][ index ]->setEnabled(enabled); + popup_actions[edge][index]->setEnabled(enabled); } bool Monitor::edgeItemEnabled(int edge, int index) const { - return popup_actions[ edge ][ index ]->isEnabled(); + return popup_actions[edge][index]->isEnabled(); } void Monitor::selectEdgeItem(int edge, int index) { - popup_actions[ edge ][ index ]->setChecked(true); - setEdge(edge, !popup_actions[ edge ][ 0 ]->isChecked()); - QString actionText = popup_actions[ edge ][ index ]->text(); + popup_actions[edge][index]->setChecked(true); + setEdge(edge, !popup_actions[edge][0]->isChecked()); + QString actionText = popup_actions[edge][index]->text(); // remove accelerators added by KAcceleratorManager actionText = KLocalizedString::removeAcceleratorMarker(actionText); - items[ edge ]->setToolTip(actionText); + items[edge]->setToolTip(actionText); } int Monitor::selectedEdgeItem(int edge) const { const auto actions = popup_actions[edge]; - for (QAction * act : actions) { + for (QAction *act : actions) { if (act->isChecked()) { return actions.indexOf(act); } @@ -192,18 +192,18 @@ int Monitor::selectedEdgeItem(int edge) const Q_UNREACHABLE(); } -void Monitor::popup(Corner* c, QPoint pos) +void Monitor::popup(Corner *c, QPoint pos) { for (int i = 0; - i < 8; - ++i) { - if (items[ i ] == c) { - if (popup_actions[ i ].count() == 0) + i < 8; + ++i) { + if (items[i] == c) { + if (popup_actions[i].count() == 0) return; - if (QAction* a = popups[ i ]->exec(pos)) { - selectEdgeItem(i, popup_actions[ i ].indexOf(a)); + if (QAction *a = popups[i]->exec(pos)) { + selectEdgeItem(i, popup_actions[i].indexOf(a)); Q_EMIT changed(); - Q_EMIT edgeSelectionChanged(i, popup_actions[ i ].indexOf(a)); + Q_EMIT edgeSelectionChanged(i, popup_actions[i].indexOf(a)); c->setToolTip(KLocalizedString::removeAcceleratorMarker(a->text())); } return; @@ -212,13 +212,13 @@ void Monitor::popup(Corner* c, QPoint pos) Q_UNREACHABLE(); } -void Monitor::flip(Corner* c, QPoint pos) +void Monitor::flip(Corner *c, QPoint pos) { for (int i = 0; - i < 8; - ++i) { - if (items[ i ] == c) { - if (popup_actions[ i ].count() == 0) + i < 8; + ++i) { + if (items[i] == c) { + if (popup_actions[i].count() == 0) setEdge(i, !edge(i)); else popup(c, pos); @@ -228,10 +228,10 @@ void Monitor::flip(Corner* c, QPoint pos) Q_UNREACHABLE(); } -Monitor::Corner::Corner(Monitor* m) - : monitor(m), - m_active(false), - m_hover(false) +Monitor::Corner::Corner(Monitor *m) + : monitor(m) + , m_active(false) + , m_hover(false) { button = new Plasma::FrameSvg(); button->setImagePath("widgets/button"); @@ -243,17 +243,17 @@ Monitor::Corner::~Corner() delete button; } -void Monitor::Corner::contextMenuEvent(QGraphicsSceneContextMenuEvent* e) +void Monitor::Corner::contextMenuEvent(QGraphicsSceneContextMenuEvent *e) { monitor->popup(this, e->screenPos()); } -void Monitor::Corner::mousePressEvent(QGraphicsSceneMouseEvent* e) +void Monitor::Corner::mousePressEvent(QGraphicsSceneMouseEvent *e) { monitor->flip(this, e->screenPos()); } -void Monitor::Corner::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) +void Monitor::Corner::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option) Q_UNUSED(widget) @@ -288,14 +288,14 @@ void Monitor::Corner::paint(QPainter* painter, const QStyleOptionGraphicsItem* o } } -void Monitor::Corner::hoverEnterEvent(QGraphicsSceneHoverEvent * e) +void Monitor::Corner::hoverEnterEvent(QGraphicsSceneHoverEvent *e) { Q_UNUSED(e); m_hover = true; update(); } -void Monitor::Corner::hoverLeaveEvent(QGraphicsSceneHoverEvent * e) +void Monitor::Corner::hoverLeaveEvent(QGraphicsSceneHoverEvent *e) { Q_UNUSED(e); m_hover = false; @@ -313,4 +313,3 @@ bool Monitor::Corner::active() const return m_active; } } // namespace - diff --git a/src/kcmkwin/kwinscreenedges/monitor.h b/src/kcmkwin/kwinscreenedges/monitor.h index a62334a89b..cdebc585f9 100644 --- a/src/kcmkwin/kwinscreenedges/monitor.h +++ b/src/kcmkwin/kwinscreenedges/monitor.h @@ -35,14 +35,14 @@ class Monitor { Q_OBJECT public: - explicit Monitor(QWidget* parent); + explicit Monitor(QWidget *parent); void setEdge(int edge, bool set); bool edge(int edge) const; void setEdgeEnabled(int edge, bool enabled); void setEdgeHidden(int edge, bool set); bool edgeHidden(int edge) const; void clear(); - void addEdgeItem(int edge, const QString& item); + 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); @@ -62,38 +62,42 @@ public: Q_SIGNALS: void changed(); void edgeSelectionChanged(int edge, int index); + protected: - void resizeEvent(QResizeEvent* e) override; + void resizeEvent(QResizeEvent *e) override; + private: class Corner; - void popup(Corner* c, QPoint pos); - void flip(Corner* c, QPoint pos); + 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 ]; + QGraphicsView *view; + QGraphicsScene *scene; + Corner *items[8]; + bool hidden[8]; + QMenu *popups[8]; + QVector popup_actions[8]; + QActionGroup *grp[8]; }; class Monitor::Corner : public QGraphicsRectItem { public: - Corner(Monitor* m); + Corner(Monitor *m); ~Corner() override; void setActive(bool active); bool active() const; + protected: - 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 = nullptr) override; + 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 = nullptr) override; + private: - Monitor* monitor; + Monitor *monitor; Plasma::FrameSvg *button; bool m_active; bool m_hover; diff --git a/src/kcmkwin/kwinscreenedges/screenpreviewwidget.cpp b/src/kcmkwin/kwinscreenedges/screenpreviewwidget.cpp index 19bfada7c9..675b0624e4 100644 --- a/src/kcmkwin/kwinscreenedges/screenpreviewwidget.cpp +++ b/src/kcmkwin/kwinscreenedges/screenpreviewwidget.cpp @@ -6,9 +6,9 @@ #include "screenpreviewwidget.h" -#include #include #include +#include #include #include @@ -16,19 +16,20 @@ #include #include - class ScreenPreviewWidgetPrivate { public: ScreenPreviewWidgetPrivate(ScreenPreviewWidget *screen) - : q(screen), - ratio(1) - {} + : q(screen) + , ratio(1) + { + } ~ScreenPreviewWidgetPrivate() - {} + { + } - void updateRect(const QRectF& rect) + void updateRect(const QRectF &rect) { q->update(rect.toRect()); } @@ -36,16 +37,16 @@ public: void updateScreenGraphics() { int bottomElements = screenGraphics->elementSize("base").height() + screenGraphics->marginSize(Plasma::Types::BottomMargin); - QRect bounds(QPoint(0,0), QSize(q->size().width(), q->height() - bottomElements)); + QRect bounds(QPoint(0, 0), QSize(q->size().width(), q->height() - bottomElements)); - QSize monitorSize(q->size().width(), q->size().width()/ratio); + QSize monitorSize(q->size().width(), q->size().width() / ratio); monitorSize.scale(bounds.size(), Qt::KeepAspectRatio); if (monitorSize.isEmpty()) { return; } - monitorRect = QRect(QPoint(0,0), monitorSize); + monitorRect = QRect(QPoint(0, 0), monitorSize); monitorRect.moveCenter(bounds.center()); screenGraphics->resizeFrame(monitorRect.size()); @@ -63,8 +64,8 @@ public: }; ScreenPreviewWidget::ScreenPreviewWidget(QWidget *parent) - : QWidget(parent), - d(new ScreenPreviewWidgetPrivate(this)) + : QWidget(parent) + , d(new ScreenPreviewWidgetPrivate(this)) { d->screenGraphics = new Plasma::FrameSvg(this); d->screenGraphics->setImagePath("widgets/monitor"); @@ -73,7 +74,7 @@ ScreenPreviewWidget::ScreenPreviewWidget(QWidget *parent) ScreenPreviewWidget::~ScreenPreviewWidget() { - delete d; + delete d; } void ScreenPreviewWidget::setPreview(const QPixmap &preview) @@ -118,7 +119,7 @@ void ScreenPreviewWidget::paintEvent(QPaintEvent *event) } QPainter painter(this); - QPoint standPosition(d->monitorRect.center().x() - d->screenGraphics->elementSize("base").width()/2, d->previewRect.bottom()); + QPoint standPosition(d->monitorRect.center().x() - d->screenGraphics->elementSize("base").width() / 2, d->previewRect.bottom()); d->screenGraphics->paint(&painter, QRect(standPosition, d->screenGraphics->elementSize("base")), "base"); d->screenGraphics->paintFrame(&painter, d->monitorRect.topLeft()); @@ -142,7 +143,7 @@ void ScreenPreviewWidget::dropEvent(QDropEvent *e) if (!uris.isEmpty()) { // TODO: Download remote file if (uris.first().isLocalFile()) - Q_EMIT imageDropped(uris.first().path()); + Q_EMIT imageDropped(uris.first().path()); } } diff --git a/src/kcmkwin/kwinscreenedges/screenpreviewwidget.h b/src/kcmkwin/kwinscreenedges/screenpreviewwidget.h index a8ae965fc8..f13fb3fd45 100644 --- a/src/kcmkwin/kwinscreenedges/screenpreviewwidget.h +++ b/src/kcmkwin/kwinscreenedges/screenpreviewwidget.h @@ -37,8 +37,7 @@ Q_SIGNALS: private: ScreenPreviewWidgetPrivate *const d; - Q_PRIVATE_SLOT(d, void updateRect(const QRectF& rect)) + Q_PRIVATE_SLOT(d, void updateRect(const QRectF &rect)) }; - #endif diff --git a/src/kcmkwin/kwinscreenedges/touch.cpp b/src/kcmkwin/kwinscreenedges/touch.cpp index 22ac1404da..c1288dc634 100644 --- a/src/kcmkwin/kwinscreenedges/touch.cpp +++ b/src/kcmkwin/kwinscreenedges/touch.cpp @@ -15,16 +15,16 @@ #include #include #include -#include #include #include -#include +#include #include +#include -#include "kwintouchscreenedgeconfigform.h" #include "kwintouchscreendata.h" -#include "kwintouchscreensettings.h" +#include "kwintouchscreenedgeconfigform.h" #include "kwintouchscreenscriptsettings.h" +#include "kwintouchscreensettings.h" K_PLUGIN_FACTORY(KWinScreenEdgesConfigFactory, registerPlugin(); registerPlugin();) @@ -37,7 +37,7 @@ KWinScreenEdgesConfig::KWinScreenEdgesConfig(QWidget *parent, const QVariantList , m_config(KSharedConfig::openConfig("kwinrc")) , m_data(new KWinTouchScreenData(this)) { - QVBoxLayout* layout = new QVBoxLayout(this); + QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(m_form); monitorInit(); @@ -80,8 +80,8 @@ void KWinScreenEdgesConfig::save() QDBusConnection::sessionBus().send(message); // and reconfigure the effects OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), - QStringLiteral("/Effects"), - QDBusConnection::sessionBus()); + QStringLiteral("/Effects"), + QDBusConnection::sessionBus()); interface.reconfigureEffect(QStringLiteral("overview")); interface.reconfigureEffect(QStringLiteral("presentwindows")); interface.reconfigureEffect(QStringLiteral("desktopgrid")); @@ -96,7 +96,7 @@ void KWinScreenEdgesConfig::defaults() KCModule::defaults(); } -void KWinScreenEdgesConfig::showEvent(QShowEvent* e) +void KWinScreenEdgesConfig::showEvent(QShowEvent *e) { KCModule::showEvent(e); @@ -137,7 +137,7 @@ void KWinScreenEdgesConfig::monitorInit() const auto scripts = KPackage::PackageLoader::self()->listPackages(QStringLiteral("KWin/Script"), scriptFolder); KConfigGroup config(m_config, "Plugins"); - for (const KPluginMetaData &script: scripts) { + for (const KPluginMetaData &script : scripts) { if (script.value(QStringLiteral("X-KWin-Border-Activate")) != QLatin1String("true")) { continue; } @@ -182,7 +182,7 @@ void KWinScreenEdgesConfig::monitorLoadSettings() m_form->monitorChangeEdge(m_data->settings()->touchBorderActivateOverview(), Overview); // Scripts - for (int i=0; i < m_scripts.size(); i++) { + for (int i = 0; i < m_scripts.size(); i++) { int index = EffectCount + i; m_form->monitorChangeEdge(m_scriptSettings[m_scripts[i]]->touchBorderActivate(), index); } diff --git a/src/kcmkwin/kwinscreenedges/touch.h b/src/kcmkwin/kwinscreenedges/touch.h index 862d5b3acc..edf7ecf28d 100644 --- a/src/kcmkwin/kwinscreenedges/touch.h +++ b/src/kcmkwin/kwinscreenedges/touch.h @@ -43,8 +43,8 @@ protected: private: KWinTouchScreenEdgeConfigForm *m_form; KSharedConfigPtr m_config; - QStringList m_scripts; //list of script IDs ordered in the list they are presented in the menu - QHash m_scriptSettings; + QStringList m_scripts; // list of script IDs ordered in the list they are presented in the menu + QHash m_scriptSettings; KWinTouchScreenData *m_data; enum EffectActions { diff --git a/src/kcmkwin/kwinscripts/kwinscriptsdata.cpp b/src/kcmkwin/kwinscripts/kwinscriptsdata.cpp index 1bd3ac25a5..83cf527f6b 100644 --- a/src/kcmkwin/kwinscripts/kwinscriptsdata.cpp +++ b/src/kcmkwin/kwinscripts/kwinscriptsdata.cpp @@ -20,7 +20,7 @@ KWinScriptsData::KWinScriptsData(QObject *parent, const QVariantList &args) QVector KWinScriptsData::pluginMetaDataList() const { - auto filter = [](const KPluginMetaData &md) { + auto filter = [](const KPluginMetaData &md) { return md.isValid() && !md.rawData().value("X-KWin-Exclude-Listing").toBool(); }; diff --git a/src/kcmkwin/kwinscripts/main.cpp b/src/kcmkwin/kwinscripts/main.cpp index 8526184ecc..4185df5852 100644 --- a/src/kcmkwin/kwinscripts/main.cpp +++ b/src/kcmkwin/kwinscripts/main.cpp @@ -6,12 +6,11 @@ #include -#include "module.h" #include "kwinscriptsdata.h" +#include "module.h" K_PLUGIN_FACTORY(KcmKWinScriptsFactory, registerPlugin(); - registerPlugin(); - ) + registerPlugin();) #include "main.moc" diff --git a/src/kcmkwin/kwinscripts/module.cpp b/src/kcmkwin/kwinscripts/module.cpp index ebfe69b6f3..95971532e1 100644 --- a/src/kcmkwin/kwinscripts/module.cpp +++ b/src/kcmkwin/kwinscripts/module.cpp @@ -4,37 +4,36 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "module.h" + +#include "config-kwin.h" + +#include "kwinscriptsdata.h" #include "ui_module.h" -#include -#include -#include #include #include #include +#include +#include +#include #include #include #include #include #include +#include #include #include #include #include -#include - -#include "kwinscriptsdata.h" -#include "config-kwin.h" - -Module::Module(QWidget *parent, const QVariantList &args) : - KCModule(parent, args), - ui(new Ui::Module), - m_kwinConfig(KSharedConfig::openConfig("kwinrc")), - m_kwinScriptsData(new KWinScriptsData(this)) +Module::Module(QWidget *parent, const QVariantList &args) + : KCModule(parent, args) + , ui(new Ui::Module) + , m_kwinConfig(KSharedConfig::openConfig("kwinrc")) + , m_kwinScriptsData(new KWinScriptsData(this)) { KAboutData *about = new KAboutData("kwin-scripts", i18n("KWin Scripts"), diff --git a/src/kcmkwin/kwintabbox/kwintabboxconfigform.cpp b/src/kcmkwin/kwintabbox/kwintabboxconfigform.cpp index e1e86207ed..e69f3e32dc 100644 --- a/src/kcmkwin/kwintabbox/kwintabboxconfigform.cpp +++ b/src/kcmkwin/kwintabbox/kwintabboxconfigform.cpp @@ -17,7 +17,6 @@ #include #include - namespace KWin { diff --git a/src/kcmkwin/kwintabbox/kwintabboxconfigform.h b/src/kcmkwin/kwintabbox/kwintabboxconfigform.h index f798749a84..a5f4ec8a91 100644 --- a/src/kcmkwin/kwintabbox/kwintabboxconfigform.h +++ b/src/kcmkwin/kwintabbox/kwintabboxconfigform.h @@ -11,8 +11,8 @@ #ifndef __KWINTABBOXCONFIGFORM_H__ #define __KWINTABBOXCONFIGFORM_H__ -#include #include +#include #include "tabboxconfig.h" @@ -32,15 +32,12 @@ class KWinTabBoxConfigForm : public QWidget Q_OBJECT public: - enum class TabboxType - { + enum class TabboxType { Main, Alternative, }; - - enum EffectComboRole - { + enum EffectComboRole { LayoutPath = Qt::UserRole + 1, AddonEffect, // i.e not builtin effects }; diff --git a/src/kcmkwin/kwintabbox/kwintabboxdata.cpp b/src/kcmkwin/kwintabbox/kwintabboxdata.cpp index 74f96922e3..cc4f3ac2cb 100644 --- a/src/kcmkwin/kwintabbox/kwintabboxdata.cpp +++ b/src/kcmkwin/kwintabbox/kwintabboxdata.cpp @@ -9,9 +9,9 @@ #include "kwintabboxdata.h" -#include "kwintabboxsettings.h" -#include "kwinswitcheffectsettings.h" #include "kwinpluginssettings.h" +#include "kwinswitcheffectsettings.h" +#include "kwintabboxsettings.h" namespace KWin { diff --git a/src/kcmkwin/kwintabbox/layoutpreview.cpp b/src/kcmkwin/kwintabbox/layoutpreview.cpp index 1f752565ee..59779770de 100644 --- a/src/kcmkwin/kwintabbox/layoutpreview.cpp +++ b/src/kcmkwin/kwintabbox/layoutpreview.cpp @@ -9,16 +9,16 @@ // own #include "layoutpreview.h" -#include -#include -#include -#include -#include -#include +#include #include #include #include -#include +#include +#include +#include +#include +#include +#include namespace KWin { @@ -41,30 +41,30 @@ LayoutPreview::LayoutPreview(const QString &path, bool showDesktopThumbnail, QOb qDebug() << component->errorString(); } QObject *item = component->create(); - auto findSwitcher = [item]() -> SwitcherItem* { + auto findSwitcher = [item]() -> SwitcherItem * { if (!item) { return nullptr; } - if (SwitcherItem *i = qobject_cast(item)) { + if (SwitcherItem *i = qobject_cast(item)) { return i; - } else if (QQuickWindow *w = qobject_cast(item)) { - return w->contentItem()->findChild(); + } else if (QQuickWindow *w = qobject_cast(item)) { + return w->contentItem()->findChild(); } - return item->findChild(); + return item->findChild(); }; if (SwitcherItem *switcher = findSwitcher()) { m_item = switcher; static_cast(switcher->model())->showDesktopThumbnail(showDesktopThumbnail); switcher->setVisible(true); } - auto findWindow = [item]() -> QQuickWindow* { + auto findWindow = [item]() -> QQuickWindow * { if (!item) { return nullptr; } - if (QQuickWindow *w = qobject_cast(item)) { + if (QQuickWindow *w = qobject_cast(item)) { return w; } - return item->findChild(); + return item->findChild(); }; if (QQuickWindow *w = findWindow()) { w->setKeyboardGrabEnabled(true); @@ -80,11 +80,8 @@ LayoutPreview::~LayoutPreview() bool LayoutPreview::eventFilter(QObject *object, QEvent *event) { if (event->type() == QEvent::KeyPress) { - QKeyEvent *keyEvent = static_cast(event); - if (keyEvent->key() == Qt::Key_Escape || - keyEvent->key() == Qt::Key_Return || - keyEvent->key() == Qt::Key_Enter || - keyEvent->key() == Qt::Key_Space) { + QKeyEvent *keyEvent = static_cast(event); + if (keyEvent->key() == Qt::Key_Escape || keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Space) { object->deleteLater(); deleteLater(); } @@ -95,8 +92,8 @@ bool LayoutPreview::eventFilter(QObject *object, QEvent *event) m_item->decrementIndex(); } } else if (event->type() == QEvent::MouseButtonPress) { - if (QWindow *w = qobject_cast(object)) { - if (!w->geometry().contains(static_cast(event)->globalPos())) { + if (QWindow *w = qobject_cast(object)) { + if (!w->geometry().contains(static_cast(event)->globalPos())) { object->deleteLater(); deleteLater(); } @@ -105,8 +102,8 @@ bool LayoutPreview::eventFilter(QObject *object, QEvent *event) return QObject::eventFilter(object, event); } -ExampleClientModel::ExampleClientModel (QObject* parent) - : QAbstractListModel (parent) +ExampleClientModel::ExampleClientModel(QObject *parent) + : QAbstractListModel(parent) { init(); } @@ -118,22 +115,22 @@ ExampleClientModel::~ExampleClientModel() void ExampleClientModel::init() { if (const auto s = KApplicationTrader::preferredService(QStringLiteral("inode/directory"))) { - m_thumbnails << ThumbnailInfo{ WindowThumbnailItem::Dolphin, s->name(), s->icon() }; + m_thumbnails << ThumbnailInfo{WindowThumbnailItem::Dolphin, s->name(), s->icon()}; } if (const auto s = KApplicationTrader::preferredService(QStringLiteral("text/html"))) { - m_thumbnails << ThumbnailInfo{ WindowThumbnailItem::Konqueror, s->name(), s->icon() }; + m_thumbnails << ThumbnailInfo{WindowThumbnailItem::Konqueror, s->name(), s->icon()}; } if (const auto s = KApplicationTrader::preferredService(QStringLiteral("message/rfc822"))) { - m_thumbnails << ThumbnailInfo{ WindowThumbnailItem::KMail, s->name(), s->icon() }; + m_thumbnails << ThumbnailInfo{WindowThumbnailItem::KMail, s->name(), s->icon()}; } if (const auto s = KService::serviceByDesktopName(QStringLiteral("kdesystemsettings"))) { - m_thumbnails << ThumbnailInfo{ WindowThumbnailItem::Systemsettings, s->name(), s->icon() }; + m_thumbnails << ThumbnailInfo{WindowThumbnailItem::Systemsettings, s->name(), s->icon()}; } } void ExampleClientModel::showDesktopThumbnail(bool showDesktop) { - const ThumbnailInfo desktopThumbnail = ThumbnailInfo { WindowThumbnailItem::Desktop, i18n("Show Desktop"), QStringLiteral("desktop") }; + const ThumbnailInfo desktopThumbnail = ThumbnailInfo{WindowThumbnailItem::Desktop, i18n("Show Desktop"), QStringLiteral("desktop")}; const int desktopIndex = m_thumbnails.indexOf(desktopThumbnail); if (showDesktop == (desktopIndex >= 0)) { return; @@ -192,11 +189,11 @@ int ExampleClientModel::rowCount(const QModelIndex &parent) const QHash ExampleClientModel::roleNames() const { return { - { CaptionRole, QByteArrayLiteral("caption") }, - { MinimizedRole, QByteArrayLiteral("minimized") }, - { DesktopNameRole, QByteArrayLiteral("desktopName") }, - { IconRole, QByteArrayLiteral("icon") }, - { WindowIdRole, QByteArrayLiteral("windowId") }, + {CaptionRole, QByteArrayLiteral("caption")}, + {MinimizedRole, QByteArrayLiteral("minimized")}, + {DesktopNameRole, QByteArrayLiteral("desktopName")}, + {IconRole, QByteArrayLiteral("icon")}, + {WindowIdRole, QByteArrayLiteral("windowId")}, }; } @@ -250,13 +247,12 @@ void SwitcherItem::incrementIndex() void SwitcherItem::decrementIndex() { - int index = m_currentIndex -1; + int index = m_currentIndex - 1; if (index < 0) { - index = m_model->rowCount() -1; + index = m_model->rowCount() - 1; } setCurrentIndex(index); } } // namespace KWin } // namespace TabBox - diff --git a/src/kcmkwin/kwintabbox/layoutpreview.h b/src/kcmkwin/kwintabbox/layoutpreview.h index ccd534bf5d..3b617d2d4b 100644 --- a/src/kcmkwin/kwintabbox/layoutpreview.h +++ b/src/kcmkwin/kwintabbox/layoutpreview.h @@ -31,6 +31,7 @@ public: ~LayoutPreview() override; bool eventFilter(QObject *object, QEvent *event) override; + private: SwitcherItem *m_item; }; @@ -58,12 +59,14 @@ public: void showDesktopThumbnail(bool showDesktop); private: - struct ThumbnailInfo { + struct ThumbnailInfo + { WindowThumbnailItem::Thumbnail wId; QString caption; QString icon; - bool operator==(const ThumbnailInfo &other) const { + bool operator==(const ThumbnailInfo &other) const + { return wId == other.wId; } }; @@ -72,7 +75,6 @@ private: QList m_thumbnails; }; - class SwitcherItem : public QObject { Q_OBJECT diff --git a/src/kcmkwin/kwintabbox/main.cpp b/src/kcmkwin/kwintabbox/main.cpp index 220f718fb1..a42bdb7960 100644 --- a/src/kcmkwin/kwintabbox/main.cpp +++ b/src/kcmkwin/kwintabbox/main.cpp @@ -11,34 +11,34 @@ #include // Qt -#include #include #include #include -#include -#include -#include -#include -#include #include +#include +#include #include +#include +#include +#include +#include // KDE #include +#include #include #include -#include // Plasma #include #include // own +#include "kwinpluginssettings.h" +#include "kwinswitcheffectsettings.h" #include "kwintabboxconfigform.h" -#include "layoutpreview.h" #include "kwintabboxdata.h" #include "kwintabboxsettings.h" -#include "kwinswitcheffectsettings.h" -#include "kwinpluginssettings.h" +#include "layoutpreview.h" K_PLUGIN_FACTORY(KWinTabBoxConfigFactory, registerPlugin(); registerPlugin();) @@ -47,36 +47,36 @@ namespace KWin using namespace TabBox; -KWinTabBoxConfig::KWinTabBoxConfig(QWidget* parent, const QVariantList& args) +KWinTabBoxConfig::KWinTabBoxConfig(QWidget *parent, const QVariantList &args) : KCModule(parent, args) , m_config(KSharedConfig::openConfig("kwinrc")) , m_data(new KWinTabboxData(this)) { - QTabWidget* tabWidget = new QTabWidget(this); + QTabWidget *tabWidget = new QTabWidget(this); m_primaryTabBoxUi = new KWinTabBoxConfigForm(KWinTabBoxConfigForm::TabboxType::Main, tabWidget); m_alternativeTabBoxUi = new KWinTabBoxConfigForm(KWinTabBoxConfigForm::TabboxType::Alternative, tabWidget); tabWidget->addTab(m_primaryTabBoxUi, i18n("Main")); tabWidget->addTab(m_alternativeTabBoxUi, i18n("Alternative")); KNSWidgets::Button *ghnsButton = new KNSWidgets::Button(i18n("Get New Task Switchers..."), QStringLiteral("kwinswitcher.knsrc"), this); - connect(ghnsButton, &KNSWidgets::Button::dialogFinished, this, [this] (auto changedEntries) { + connect(ghnsButton, &KNSWidgets::Button::dialogFinished, this, [this](auto changedEntries) { if (!changedEntries.isEmpty()) { initLayoutLists(); } }); - QHBoxLayout* buttonBar = new QHBoxLayout(); - QSpacerItem* buttonBarSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + QHBoxLayout *buttonBar = new QHBoxLayout(); + QSpacerItem *buttonBarSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); buttonBar->addItem(buttonBarSpacer); buttonBar->addWidget(ghnsButton); - QVBoxLayout* layout = new QVBoxLayout(this); - KTitleWidget* infoLabel = new KTitleWidget(tabWidget); + QVBoxLayout *layout = new QVBoxLayout(this); + KTitleWidget *infoLabel = new KTitleWidget(tabWidget); infoLabel->setText(i18n("Focus policy settings limit the functionality of navigating through windows."), KTitleWidget::InfoMessage); infoLabel->setIcon(KTitleWidget::InfoMessage, KTitleWidget::ImageLeft); - layout->addWidget(infoLabel,0); - layout->addWidget(tabWidget,1); + layout->addWidget(infoLabel, 0); + layout->addWidget(tabWidget, 1); layout->addLayout(buttonBar); setLayout(layout); @@ -154,14 +154,14 @@ void KWinTabBoxConfig::initLayoutLists() if (offer.value("X-Plasma-API") != "declarativeappletscript") { continue; } - //we don't have a proper servicetype + // we don't have a proper servicetype if (offer.value("X-KWin-Exclude-Listing") == QStringLiteral("true")) { continue; } const QString scriptName = offer.value("X-Plasma-MainScript"); const QString scriptFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("kwin/tabbox/") + pluginName + QLatin1String("/contents/") - + scriptName); + + scriptName); if (scriptFile.isNull()) { continue; } @@ -171,9 +171,8 @@ void KWinTabBoxConfig::initLayoutLists() layoutPaths << scriptFile; } - - KWinTabBoxConfigForm *ui[2] = { m_primaryTabBoxUi, m_alternativeTabBoxUi }; - for (int i=0; i<2; ++i) { + KWinTabBoxConfigForm *ui[2] = {m_primaryTabBoxUi, m_alternativeTabBoxUi}; + for (int i = 0; i < 2; ++i) { QStandardItemModel *model = new QStandardItemModel; for (int j = 0; j < layoutNames.count(); ++j) { @@ -289,7 +288,7 @@ void KWinTabBoxConfig::load() m_data->tabBoxAlternativeConfig()->load(); updateUiFromConfig(m_primaryTabBoxUi, m_data->tabBoxConfig()); - updateUiFromConfig(m_alternativeTabBoxUi , m_data->tabBoxAlternativeConfig()); + updateUiFromConfig(m_alternativeTabBoxUi, m_data->tabBoxAlternativeConfig()); m_data->pluginsConfig()->load(); diff --git a/src/kcmkwin/kwintabbox/main.h b/src/kcmkwin/kwintabbox/main.h index 0099c052ca..d124a29afa 100644 --- a/src/kcmkwin/kwintabbox/main.h +++ b/src/kcmkwin/kwintabbox/main.h @@ -11,9 +11,9 @@ #ifndef __MAIN_H__ #define __MAIN_H__ +#include "tabboxconfig.h" #include #include -#include "tabboxconfig.h" namespace KWin { @@ -24,13 +24,12 @@ class KWinTabboxData; class TabBoxSettings; } - class KWinTabBoxConfig : public KCModule { Q_OBJECT public: - explicit KWinTabBoxConfig(QWidget* parent, const QVariantList& args); + explicit KWinTabBoxConfig(QWidget *parent, const QVariantList &args); ~KWinTabBoxConfig() override; public Q_SLOTS: diff --git a/src/kcmkwin/kwintabbox/thumbnailitem.cpp b/src/kcmkwin/kwintabbox/thumbnailitem.cpp index b04397e543..aaac922ca4 100644 --- a/src/kcmkwin/kwintabbox/thumbnailitem.cpp +++ b/src/kcmkwin/kwintabbox/thumbnailitem.cpp @@ -9,9 +9,9 @@ #include "thumbnailitem.h" // Qt -#include #include #include +#include namespace KWin { @@ -27,38 +27,36 @@ BrightnessSaturationShader::BrightnessSaturationShader() const char *BrightnessSaturationShader::vertexShader() const { - return - "attribute highp vec4 vertex; \n" - "attribute highp vec2 texCoord; \n" - "uniform highp mat4 u_matrix; \n" - "varying highp vec2 v_coord; \n" - "void main() { \n" - " v_coord = texCoord; \n" - " gl_Position = u_matrix * vertex; \n" - "}"; + return "attribute highp vec4 vertex; \n" + "attribute highp vec2 texCoord; \n" + "uniform highp mat4 u_matrix; \n" + "varying highp vec2 v_coord; \n" + "void main() { \n" + " v_coord = texCoord; \n" + " gl_Position = u_matrix * vertex; \n" + "}"; } const char *BrightnessSaturationShader::fragmentShader() const { - return - "uniform sampler2D qt_Texture; \n" - "uniform lowp float u_opacity; \n" - "uniform highp float u_saturation; \n" - "uniform highp float u_brightness; \n" - "varying highp vec2 v_coord; \n" - "void main() { \n" - " lowp vec4 tex = texture2D(qt_Texture, v_coord); \n" - " if (u_saturation != 1.0) { \n" - " tex.rgb = mix(vec3(dot( vec3( 0.30, 0.59, 0.11 ), tex.rgb )), tex.rgb, u_saturation); \n" - " } \n" - " tex.rgb = tex.rgb * u_brightness; \n" - " gl_FragColor = tex * u_opacity; \n" - "}"; + return "uniform sampler2D qt_Texture; \n" + "uniform lowp float u_opacity; \n" + "uniform highp float u_saturation; \n" + "uniform highp float u_brightness; \n" + "varying highp vec2 v_coord; \n" + "void main() { \n" + " lowp vec4 tex = texture2D(qt_Texture, v_coord); \n" + " if (u_saturation != 1.0) { \n" + " tex.rgb = mix(vec3(dot( vec3( 0.30, 0.59, 0.11 ), tex.rgb )), tex.rgb, u_saturation); \n" + " } \n" + " tex.rgb = tex.rgb * u_brightness; \n" + " gl_FragColor = tex * u_opacity; \n" + "}"; } -const char* const *BrightnessSaturationShader::attributeNames() const +const char *const *BrightnessSaturationShader::attributeNames() const { - static char const *const names[] = { "vertex", "texCoord", nullptr }; + static char const *const names[] = {"vertex", "texCoord", nullptr}; return names; } @@ -87,13 +85,13 @@ void BrightnessSaturationShader::updateState(const QSGMaterialShader::RenderStat void BrightnessSaturationShader::initialize() { QSGMaterialShader::initialize(); - m_id_matrix = program()->uniformLocation("u_matrix"); - m_id_opacity = program()->uniformLocation("u_opacity"); + m_id_matrix = program()->uniformLocation("u_matrix"); + m_id_opacity = program()->uniformLocation("u_opacity"); m_id_saturation = program()->uniformLocation("u_saturation"); m_id_brightness = program()->uniformLocation("u_brightness"); } -WindowThumbnailItem::WindowThumbnailItem(QQuickItem* parent) +WindowThumbnailItem::WindowThumbnailItem(QQuickItem *parent) : QQuickItem(parent) , m_wId(0) , m_image() @@ -163,7 +161,7 @@ void WindowThumbnailItem::findImage() QSGNode *WindowThumbnailItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) { Q_UNUSED(updatePaintNodeData) - QSGGeometryNode *node = static_cast(oldNode); + QSGGeometryNode *node = static_cast(oldNode); if (!node) { node = new QSGGeometryNode(); auto *material = new BrightnessSaturationMaterial; @@ -173,10 +171,10 @@ QSGNode *WindowThumbnailItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeD QSGGeometry *geometry = new QSGGeometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4); node->setGeometry(geometry); } - auto *material = static_cast(node->material()); + auto *material = static_cast(node->material()); const QSize size(material->texture()->textureSize().scaled(boundingRect().size().toSize(), Qt::KeepAspectRatio)); - const qreal x = boundingRect().x() + (boundingRect().width() - size.width())/2; - const qreal y = boundingRect().y() + (boundingRect().height() - size.height())/2; + const qreal x = boundingRect().x() + (boundingRect().width() - size.width()) / 2; + const qreal y = boundingRect().y() + (boundingRect().height() - size.height()) / 2; QSGGeometry::updateTexturedRectGeometry(node->geometry(), QRectF(QPointF(x, y), size), QRectF(0.0, 0.0, 1.0, 1.0)); material->brightness = m_brightness; material->saturation = m_saturation; diff --git a/src/kcmkwin/kwintabbox/thumbnailitem.h b/src/kcmkwin/kwintabbox/thumbnailitem.h index c4ec458599..bc20ad308d 100644 --- a/src/kcmkwin/kwintabbox/thumbnailitem.h +++ b/src/kcmkwin/kwintabbox/thumbnailitem.h @@ -21,11 +21,12 @@ class BrightnessSaturationShader : public QSGMaterialShader { public: BrightnessSaturationShader(); - 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; + 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; @@ -36,10 +37,12 @@ private: class BrightnessSaturationMaterial : public QSGTextureMaterial { public: - QSGMaterialShader* createShader() const override { + QSGMaterialShader *createShader() const override + { return new BrightnessSaturationShader; } - QSGMaterialType *type() const override { + QSGMaterialType *type() const override + { static QSGMaterialType type; return &type; } @@ -59,10 +62,12 @@ public: explicit WindowThumbnailItem(QQuickItem *parent = nullptr); ~WindowThumbnailItem() override; - qulonglong wId() const { + qulonglong wId() const + { return m_wId; } - QQuickItem *clipTo() const { + QQuickItem *clipTo() const + { return m_clipToItem; } qreal brightness() const; @@ -88,6 +93,7 @@ Q_SIGNALS: void brightnessChanged(); void saturationChanged(); void sourceSizeChanged(); + private: void findImage(); qulonglong m_wId; diff --git a/src/kcmkwin/kwinvirtualkeyboard/kcmvirtualkeyboard.h b/src/kcmkwin/kwinvirtualkeyboard/kcmvirtualkeyboard.h index 755f56bcb0..5c5270a5f6 100644 --- a/src/kcmkwin/kwinvirtualkeyboard/kcmvirtualkeyboard.h +++ b/src/kcmkwin/kwinvirtualkeyboard/kcmvirtualkeyboard.h @@ -18,7 +18,9 @@ class VirtualKeyboardsModel : public QAbstractListModel { Q_OBJECT public: - enum Roles { DesktopFileNameRole = Qt::UserRole + 1 }; + enum Roles { + DesktopFileNameRole = Qt::UserRole + 1, + }; Q_ENUM(Roles); VirtualKeyboardsModel(QObject *parent = nullptr); diff --git a/src/keyboard_input.cpp b/src/keyboard_input.cpp index a735c2187a..56a3b12a6e 100644 --- a/src/keyboard_input.cpp +++ b/src/keyboard_input.cpp @@ -6,8 +6,10 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include #include "keyboard_input.h" + +#include + #include "abstract_client.h" #include "input_event.h" #include "input_event_spy.h" @@ -23,7 +25,7 @@ #include #include #include -//screenlocker +// screenlocker #if KWIN_BUILD_SCREENLOCKER #include #endif @@ -127,22 +129,24 @@ void KeyboardInputRedirection::init() KeyboardRepeat *keyRepeatSpy = new KeyboardRepeat(m_xkb.data()); connect(keyRepeatSpy, &KeyboardRepeat::keyRepeat, this, - std::bind(&KeyboardInputRedirection::processKey, this, std::placeholders::_1, InputRedirection::KeyboardKeyAutoRepeat, std::placeholders::_2, nullptr)); + std::bind(&KeyboardInputRedirection::processKey, this, std::placeholders::_1, InputRedirection::KeyboardKeyAutoRepeat, std::placeholders::_2, nullptr)); m_input->installInputEventSpy(keyRepeatSpy); - connect(workspace(), &QObject::destroyed, this, [this] { m_inited = false; }); - connect(waylandServer(), &QObject::destroyed, this, [this] { m_inited = false; }); - connect(workspace(), &Workspace::clientActivated, this, - [this] { - disconnect(m_activeClientSurfaceChangedConnection); - if (auto c = workspace()->activeClient()) { - m_activeClientSurfaceChangedConnection = connect(c, &Toplevel::surfaceChanged, this, &KeyboardInputRedirection::update); - } else { - m_activeClientSurfaceChangedConnection = QMetaObject::Connection(); - } - update(); + connect(workspace(), &QObject::destroyed, this, [this] { + m_inited = false; + }); + connect(waylandServer(), &QObject::destroyed, this, [this] { + m_inited = false; + }); + connect(workspace(), &Workspace::clientActivated, this, [this] { + disconnect(m_activeClientSurfaceChangedConnection); + if (auto c = workspace()->activeClient()) { + m_activeClientSurfaceChangedConnection = connect(c, &Toplevel::surfaceChanged, this, &KeyboardInputRedirection::update); + } else { + m_activeClientSurfaceChangedConnection = QMetaObject::Connection(); } - ); + update(); + }); #if KWIN_BUILD_SCREENLOCKER if (waylandServer()->hasScreenLockerIntegration()) { connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, &KeyboardInputRedirection::update); diff --git a/src/keyboard_input.h b/src/keyboard_input.h index 2bf03bd5e5..6ed36f3d18 100644 --- a/src/keyboard_input.h +++ b/src/keyboard_input.h @@ -13,8 +13,8 @@ #include "xkb.h" #include -#include #include +#include #include @@ -63,13 +63,16 @@ public: */ void processKeymapChange(int fd, uint32_t size); - Xkb *xkb() const { + Xkb *xkb() const + { return m_xkb.data(); } - Qt::KeyboardModifiers modifiers() const { + Qt::KeyboardModifiers modifiers() const + { return m_xkb->modifiers(); } - Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const { + Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const + { return m_xkb->modifiersRelevantForGlobalShortcuts(); } diff --git a/src/keyboard_layout.cpp b/src/keyboard_layout.cpp index bd22d46499..1786b450c3 100644 --- a/src/keyboard_layout.cpp +++ b/src/keyboard_layout.cpp @@ -7,9 +7,9 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "keyboard_layout.h" -#include "keyboard_layout_switching.h" -#include "keyboard_input.h" #include "input_event.h" +#include "keyboard_input.h" +#include "keyboard_layout_switching.h" #include "main.h" #include "platform.h" @@ -18,8 +18,8 @@ #include #include #include -#include #include +#include namespace KWin { @@ -131,9 +131,9 @@ void KeyboardLayout::loadShortcuts() m_layoutShortcuts.clear(); const QString componentName = QStringLiteral("KDE Keyboard Layout Switcher"); const quint32 count = m_xkb->numberOfLayouts(); - for (uint i = 0; i < count ; ++i) { + for (uint i = 0; i < count; ++i) { // layout name is translated in the action name in keyboard kcm! - const QString action = QStringLiteral("Switch keyboard layout to %1").arg( translatedLayout(m_xkb->layoutName(i)) ); + const QString action = QStringLiteral("Switch keyboard layout to %1").arg(translatedLayout(m_xkb->layoutName(i))); const auto shortcuts = KGlobalAccel::self()->globalShortcut(componentName, action); if (shortcuts.isEmpty()) { continue; @@ -211,7 +211,7 @@ void KeyboardLayoutDBusInterface::switchToPreviousLayout() bool KeyboardLayoutDBusInterface::setLayout(uint index) { const quint32 previousLayout = m_xkb->currentLayout(); - if ( !m_xkb->switchToLayout(index) ) { + if (!m_xkb->switchToLayout(index)) { return false; } m_keyboardLayout->checkLayoutChange(previousLayout); @@ -232,7 +232,7 @@ QVector KeyboardLayoutDBusInterface::g const int layoutsSize = m_xkb->numberOfLayouts(); const int displayNamesSize = displayNames.size(); for (int i = 0; i < layoutsSize; ++i) { - ret.append( {m_xkb->layoutShortName(i), i < displayNamesSize ? displayNames.at(i) : QString(), translatedLayout(m_xkb->layoutName(i))} ); + ret.append({m_xkb->layoutShortName(i), i < displayNamesSize ? displayNames.at(i) : QString(), translatedLayout(m_xkb->layoutName(i))}); } return ret; } diff --git a/src/keyboard_layout.h b/src/keyboard_layout.h index 5aa81acd10..644c84f266 100644 --- a/src/keyboard_layout.h +++ b/src/keyboard_layout.h @@ -13,8 +13,8 @@ #include #include -#include #include +#include typedef uint32_t xkb_layout_index_t; class QAction; @@ -60,7 +60,7 @@ private: Xkb *m_xkb; xkb_layout_index_t m_layout = 0; KConfigGroup m_configGroup; - QVector m_layoutShortcuts; + QVector m_layoutShortcuts; KeyboardLayoutDBusInterface *m_dbusInterface = nullptr; KeyboardLayoutSwitching::Policy *m_policy = nullptr; }; @@ -74,12 +74,12 @@ public: explicit KeyboardLayoutDBusInterface(Xkb *xkb, const KConfigGroup &configGroup, KeyboardLayout *parent); ~KeyboardLayoutDBusInterface() override; - struct LayoutNames - { - QString shortName; - QString displayName; - QString longName; - }; + struct LayoutNames + { + QString shortName; + QString displayName; + QString longName; + }; public Q_SLOTS: void switchToNextLayout(); diff --git a/src/keyboard_layout_switching.cpp b/src/keyboard_layout_switching.cpp index b0b509ed7d..95a75b2d7b 100644 --- a/src/keyboard_layout_switching.cpp +++ b/src/keyboard_layout_switching.cpp @@ -7,9 +7,9 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "keyboard_layout_switching.h" -#include "keyboard_layout.h" #include "abstract_client.h" #include "deleted.h" +#include "keyboard_layout.h" #include "virtualdesktops.h" #include "workspace.h" #include "xkb.h" @@ -78,24 +78,20 @@ const QString GlobalPolicy::defaultLayoutEntryKey() const GlobalPolicy::GlobalPolicy(Xkb *xkb, KeyboardLayout *_layout, const KConfigGroup &config) : Policy(xkb, _layout, config) { - connect(workspace()->sessionManager(), &SessionManager::prepareSessionSaveRequested, this, - [this, xkb] (const QString &name) { - Q_UNUSED(name) - clearLayouts(); - if (const uint layout = xkb->currentLayout()) { - m_config.writeEntry(defaultLayoutEntryKey(), layout); - } + connect(workspace()->sessionManager(), &SessionManager::prepareSessionSaveRequested, this, [this, xkb](const QString &name) { + Q_UNUSED(name) + clearLayouts(); + if (const uint layout = xkb->currentLayout()) { + m_config.writeEntry(defaultLayoutEntryKey(), layout); } - ); + }); - connect(workspace()->sessionManager(), &SessionManager::loadSessionRequested, this, - [this, xkb] (const QString &name) { - Q_UNUSED(name) - if (xkb->numberOfLayouts() > 1) { - setLayout(m_config.readEntry(defaultLayoutEntryKey(), 0)); - } + connect(workspace()->sessionManager(), &SessionManager::loadSessionRequested, this, [this, xkb](const QString &name) { + Q_UNUSED(name) + if (xkb->numberOfLayouts() > 1) { + setLayout(m_config.readEntry(defaultLayoutEntryKey(), 0)); } - ); + }); } GlobalPolicy::~GlobalPolicy() = default; @@ -104,47 +100,39 @@ VirtualDesktopPolicy::VirtualDesktopPolicy(Xkb *xkb, KeyboardLayout *layout, con : Policy(xkb, layout, config) { connect(VirtualDesktopManager::self(), &VirtualDesktopManager::currentChanged, - this, &VirtualDesktopPolicy::desktopChanged); + this, &VirtualDesktopPolicy::desktopChanged); - connect(workspace()->sessionManager(), &SessionManager::prepareSessionSaveRequested, this, - [this] (const QString &name) { - Q_UNUSED(name) - clearLayouts(); + connect(workspace()->sessionManager(), &SessionManager::prepareSessionSaveRequested, this, [this](const QString &name) { + Q_UNUSED(name) + clearLayouts(); - for (auto i = m_layouts.constBegin(); i != m_layouts.constEnd(); ++i) { - if (const uint layout = *i) { - m_config.writeEntry( - defaultLayoutEntryKey() % - QLatin1String( QByteArray::number(i.key()->x11DesktopNumber()) ), - layout); - } + for (auto i = m_layouts.constBegin(); i != m_layouts.constEnd(); ++i) { + if (const uint layout = *i) { + m_config.writeEntry( + defaultLayoutEntryKey() % QLatin1String(QByteArray::number(i.key()->x11DesktopNumber())), + layout); } } - ); + }); - connect(workspace()->sessionManager(), &SessionManager::loadSessionRequested, this, - [this, xkb] (const QString &name) { - Q_UNUSED(name) - if (xkb->numberOfLayouts() > 1) { - const auto &desktops = VirtualDesktopManager::self()->desktops(); - for (KWin::VirtualDesktop* const desktop : desktops) { - const uint layout = m_config.readEntry( - defaultLayoutEntryKey() % - QLatin1String( QByteArray::number(desktop->x11DesktopNumber()) ), - 0u); - if (layout) { - m_layouts.insert(desktop, layout); - connect(desktop, &VirtualDesktop::aboutToBeDestroyed, this, - [this, desktop] { - m_layouts.remove(desktop); - } - ); - } + connect(workspace()->sessionManager(), &SessionManager::loadSessionRequested, this, [this, xkb](const QString &name) { + Q_UNUSED(name) + if (xkb->numberOfLayouts() > 1) { + const auto &desktops = VirtualDesktopManager::self()->desktops(); + for (KWin::VirtualDesktop *const desktop : desktops) { + const uint layout = m_config.readEntry( + defaultLayoutEntryKey() % QLatin1String(QByteArray::number(desktop->x11DesktopNumber())), + 0u); + if (layout) { + m_layouts.insert(desktop, layout); + connect(desktop, &VirtualDesktop::aboutToBeDestroyed, this, [this, desktop]() { + m_layouts.remove(desktop); + }); } - desktopChanged(); } + desktopChanged(); } - ); + }); } VirtualDesktopPolicy::~VirtualDesktopPolicy() = default; @@ -154,8 +142,9 @@ void VirtualDesktopPolicy::clearCache() m_layouts.clear(); } -namespace { -template +namespace +{ +template quint32 getLayout(const T &layouts, const U &reference) { auto it = layouts.constFind(reference); @@ -185,11 +174,9 @@ void VirtualDesktopPolicy::layoutChanged(uint index) auto it = m_layouts.find(d); if (it == m_layouts.end()) { m_layouts.insert(d, index); - connect(d, &VirtualDesktop::aboutToBeDestroyed, this, - [this, d] { - m_layouts.remove(d); - } - ); + connect(d, &VirtualDesktop::aboutToBeDestroyed, this, [this, d]() { + m_layouts.remove(d); + }); } else { if (it.value() == index) { return; @@ -198,21 +185,19 @@ void VirtualDesktopPolicy::layoutChanged(uint index) } } -WindowPolicy::WindowPolicy(KWin::Xkb* xkb, KWin::KeyboardLayout* layout) +WindowPolicy::WindowPolicy(KWin::Xkb *xkb, KWin::KeyboardLayout *layout) : Policy(xkb, layout) { - connect(workspace(), &Workspace::clientActivated, this, - [this] (AbstractClient *c) { - if (!c) { - return; - } - // ignore some special types - if (c->isDesktop() || c->isDock()) { - return; - } - setLayout(getLayout(m_layouts, c)); + connect(workspace(), &Workspace::clientActivated, this, [this](AbstractClient *c) { + if (!c) { + return; } - ); + // ignore some special types + if (c->isDesktop() || c->isDock()) { + return; + } + setLayout(getLayout(m_layouts, c)); + }); } WindowPolicy::~WindowPolicy() @@ -238,11 +223,9 @@ void WindowPolicy::layoutChanged(uint index) auto it = m_layouts.find(c); if (it == m_layouts.end()) { m_layouts.insert(c, index); - connect(c, &AbstractClient::windowClosed, this, - [this, c] { - m_layouts.remove(c); - } - ); + connect(c, &AbstractClient::windowClosed, this, [this, c]() { + m_layouts.remove(c); + }); } else { if (it.value() == index) { return; @@ -251,44 +234,40 @@ void WindowPolicy::layoutChanged(uint index) } } -ApplicationPolicy::ApplicationPolicy(KWin::Xkb* xkb, KWin::KeyboardLayout* layout, const KConfigGroup &config) +ApplicationPolicy::ApplicationPolicy(KWin::Xkb *xkb, KWin::KeyboardLayout *layout, const KConfigGroup &config) : Policy(xkb, layout, config) { connect(workspace(), &Workspace::clientActivated, this, &ApplicationPolicy::clientActivated); - connect(workspace()->sessionManager(), &SessionManager::prepareSessionSaveRequested, this, - [this] (const QString &name) { - Q_UNUSED(name) - clearLayouts(); + connect(workspace()->sessionManager(), &SessionManager::prepareSessionSaveRequested, this, [this](const QString &name) { + Q_UNUSED(name) + clearLayouts(); - for (auto i = m_layouts.constBegin(); i != m_layouts.constEnd(); ++i) { - if (const uint layout = *i) { - const QByteArray desktopFileName = i.key()->desktopFileName(); - if (!desktopFileName.isEmpty()) { - m_config.writeEntry( - defaultLayoutEntryKey() % QLatin1String(desktopFileName), - layout); - } + for (auto i = m_layouts.constBegin(); i != m_layouts.constEnd(); ++i) { + if (const uint layout = *i) { + const QByteArray desktopFileName = i.key()->desktopFileName(); + if (!desktopFileName.isEmpty()) { + m_config.writeEntry( + defaultLayoutEntryKey() % QLatin1String(desktopFileName), + layout); } } } - ); + }); - connect(workspace()->sessionManager(), &SessionManager::loadSessionRequested, this, - [this, xkb] (const QString &name) { - Q_UNUSED(name) - if (xkb->numberOfLayouts() > 1) { - const QString keyPrefix = defaultLayoutEntryKey(); - const QStringList keyList = m_config.keyList().filter(keyPrefix); - for (const QString& key : keyList) { - m_layoutsRestored.insert( - QStringView(key).mid(keyPrefix.size()).toLatin1(), - m_config.readEntry(key, 0)); - } + connect(workspace()->sessionManager(), &SessionManager::loadSessionRequested, this, [this, xkb](const QString &name) { + Q_UNUSED(name) + if (xkb->numberOfLayouts() > 1) { + const QString keyPrefix = defaultLayoutEntryKey(); + const QStringList keyList = m_config.keyList().filter(keyPrefix); + for (const QString &key : keyList) { + m_layoutsRestored.insert( + QStringView(key).mid(keyPrefix.size()).toLatin1(), + m_config.readEntry(key, 0)); } - m_layoutsRestored.squeeze(); } - ); + m_layoutsRestored.squeeze(); + }); } ApplicationPolicy::~ApplicationPolicy() @@ -305,7 +284,7 @@ void ApplicationPolicy::clientActivated(AbstractClient *c) return; } auto it = m_layouts.constFind(c); - if(it != m_layouts.constEnd()) { + if (it != m_layouts.constEnd()) { setLayout(it.value()); return; }; @@ -317,7 +296,7 @@ void ApplicationPolicy::clientActivated(AbstractClient *c) return; } } - setLayout( m_layoutsRestored.take(c->desktopFileName()) ); + setLayout(m_layoutsRestored.take(c->desktopFileName())); if (const uint index = m_xkb->currentLayout()) { layoutChanged(index); } @@ -342,11 +321,9 @@ void ApplicationPolicy::layoutChanged(uint index) auto it = m_layouts.find(c); if (it == m_layouts.end()) { m_layouts.insert(c, index); - connect(c, &AbstractClient::windowClosed, this, - [this, c] { - m_layouts.remove(c); - } - ); + connect(c, &AbstractClient::windowClosed, this, [this, c]() { + m_layouts.remove(c); + }); } else { if (it.value() == index) { return; diff --git a/src/keyboard_layout_switching.h b/src/keyboard_layout_switching.h index 95051cfdea..fdafb73d95 100644 --- a/src/keyboard_layout_switching.h +++ b/src/keyboard_layout_switching.h @@ -9,9 +9,9 @@ #ifndef KWIN_KEYBOARD_LAYOUT_SWITCHING_H #define KWIN_KEYBOARD_LAYOUT_SWITCHING_H -#include -#include #include +#include +#include namespace KWin { @@ -59,13 +59,19 @@ public: explicit GlobalPolicy(Xkb *xkb, KeyboardLayout *layout, const KConfigGroup &config); ~GlobalPolicy() override; - QString name() const override { + QString name() const override + { return QStringLiteral("Global"); } protected: - void clearCache() override {} - void layoutChanged(uint index) override {Q_UNUSED(index)} + void clearCache() override + { + } + void layoutChanged(uint index) override + { + Q_UNUSED(index) + } private: const QString defaultLayoutEntryKey() const override; @@ -78,7 +84,8 @@ public: explicit VirtualDesktopPolicy(Xkb *xkb, KeyboardLayout *layout, const KConfigGroup &config); ~VirtualDesktopPolicy() override; - QString name() const override { + QString name() const override + { return QStringLiteral("Desktop"); } @@ -98,7 +105,8 @@ public: explicit WindowPolicy(Xkb *xkb, KeyboardLayout *layout); ~WindowPolicy() override; - QString name() const override { + QString name() const override + { return QStringLiteral("Window"); } @@ -107,7 +115,7 @@ protected: void layoutChanged(uint index) override; private: - QHash m_layouts; + QHash m_layouts; }; class ApplicationPolicy : public Policy @@ -117,7 +125,8 @@ public: explicit ApplicationPolicy(Xkb *xkb, KeyboardLayout *layout, const KConfigGroup &config); ~ApplicationPolicy() override; - QString name() const override { + QString name() const override + { return QStringLiteral("WinClass"); } @@ -127,7 +136,7 @@ protected: private: void clientActivated(AbstractClient *c); - QHash m_layouts; + QHash m_layouts; QHash m_layoutsRestored; }; diff --git a/src/keyboard_repeat.cpp b/src/keyboard_repeat.cpp index cc946b624e..154a9565c5 100644 --- a/src/keyboard_repeat.cpp +++ b/src/keyboard_repeat.cpp @@ -7,8 +7,8 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "keyboard_repeat.h" -#include "keyboard_input.h" #include "input_event.h" +#include "keyboard_input.h" #include "wayland_server.h" #include diff --git a/src/keyboard_repeat.h b/src/keyboard_repeat.h index faad0de252..4028292954 100644 --- a/src/keyboard_repeat.h +++ b/src/keyboard_repeat.h @@ -39,7 +39,6 @@ private: quint32 m_key = 0; }; - } #endif diff --git a/src/killwindow.cpp b/src/killwindow.cpp index 2aab9dfc81..4d5613bdad 100644 --- a/src/killwindow.cpp +++ b/src/killwindow.cpp @@ -11,8 +11,8 @@ #include "killwindow.h" #include "abstract_client.h" #include "main.h" -#include "platform.h" #include "osd.h" +#include "platform.h" #include "unmanaged.h" #include @@ -33,18 +33,18 @@ void KillWindow::start() OSD::show(i18n("Select window to force close with left click or enter.\nEscape or right click to cancel."), QStringLiteral("window-close")); kwinApp()->platform()->startInteractiveWindowSelection( - [] (KWin::Toplevel *t) { + [](KWin::Toplevel *t) { OSD::hide(); if (!t) { return; } - if (AbstractClient *c = qobject_cast(t)) { + if (AbstractClient *c = qobject_cast(t)) { c->killWindow(); - } else if (Unmanaged *u = qobject_cast(t)) { + } else if (Unmanaged *u = qobject_cast(t)) { xcb_kill_client(kwinApp()->x11Connection(), u->window()); } - }, QByteArrayLiteral("pirate") - ); + }, + QByteArrayLiteral("pirate")); } } // namespace diff --git a/src/killwindow.h b/src/killwindow.h index 7da1a94f22..c9d5339204 100644 --- a/src/killwindow.h +++ b/src/killwindow.h @@ -18,7 +18,6 @@ namespace KWin class KillWindow { public: - KillWindow(); ~KillWindow(); diff --git a/src/kwineglutils_p.h b/src/kwineglutils_p.h index 4b6f464b1d..d73fc6ecfd 100644 --- a/src/kwineglutils_p.h +++ b/src/kwineglutils_p.h @@ -8,27 +8,42 @@ */ #pragma once -#include #include +#include static QString getEglErrorString(EGLint errorCode) { - switch(errorCode) { - case EGL_SUCCESS: return QStringLiteral("EGL_SUCCESS"); - case EGL_NOT_INITIALIZED: return QStringLiteral("EGL_NOT_INITIALIZED"); - case EGL_BAD_ACCESS: return QStringLiteral("EGL_BAD_ACCESS"); - case EGL_BAD_ALLOC: return QStringLiteral("EGL_BAD_ALLOC"); - case EGL_BAD_ATTRIBUTE: return QStringLiteral("EGL_BAD_ATTRIBUTE"); - case EGL_BAD_CONTEXT: return QStringLiteral("EGL_BAD_CONTEXT"); - case EGL_BAD_CONFIG: return QStringLiteral("EGL_BAD_CONFIG"); - case EGL_BAD_CURRENT_SURFACE: return QStringLiteral("EGL_BAD_CURRENT_SURFACE"); - case EGL_BAD_DISPLAY: return QStringLiteral("EGL_BAD_DISPLAY"); - case EGL_BAD_SURFACE: return QStringLiteral("EGL_BAD_SURFACE"); - case EGL_BAD_MATCH: return QStringLiteral("EGL_BAD_MATCH"); - case EGL_BAD_PARAMETER: return QStringLiteral("EGL_BAD_PARAMETER"); - case EGL_BAD_NATIVE_PIXMAP: return QStringLiteral("EGL_BAD_NATIVE_PIXMAP"); - case EGL_BAD_NATIVE_WINDOW: return QStringLiteral("EGL_BAD_NATIVE_WINDOW"); - case EGL_CONTEXT_LOST: return QStringLiteral("EGL_CONTEXT_LOST"); + switch (errorCode) { + case EGL_SUCCESS: + return QStringLiteral("EGL_SUCCESS"); + case EGL_NOT_INITIALIZED: + return QStringLiteral("EGL_NOT_INITIALIZED"); + case EGL_BAD_ACCESS: + return QStringLiteral("EGL_BAD_ACCESS"); + case EGL_BAD_ALLOC: + return QStringLiteral("EGL_BAD_ALLOC"); + case EGL_BAD_ATTRIBUTE: + return QStringLiteral("EGL_BAD_ATTRIBUTE"); + case EGL_BAD_CONTEXT: + return QStringLiteral("EGL_BAD_CONTEXT"); + case EGL_BAD_CONFIG: + return QStringLiteral("EGL_BAD_CONFIG"); + case EGL_BAD_CURRENT_SURFACE: + return QStringLiteral("EGL_BAD_CURRENT_SURFACE"); + case EGL_BAD_DISPLAY: + return QStringLiteral("EGL_BAD_DISPLAY"); + case EGL_BAD_SURFACE: + return QStringLiteral("EGL_BAD_SURFACE"); + case EGL_BAD_MATCH: + return QStringLiteral("EGL_BAD_MATCH"); + case EGL_BAD_PARAMETER: + return QStringLiteral("EGL_BAD_PARAMETER"); + case EGL_BAD_NATIVE_PIXMAP: + return QStringLiteral("EGL_BAD_NATIVE_PIXMAP"); + case EGL_BAD_NATIVE_WINDOW: + return QStringLiteral("EGL_BAD_NATIVE_WINDOW"); + case EGL_CONTEXT_LOST: + return QStringLiteral("EGL_CONTEXT_LOST"); default: return QString::number(errorCode, 16); } diff --git a/src/layers.cpp b/src/layers.cpp index 9824656874..d5c15a2107 100644 --- a/src/layers.cpp +++ b/src/layers.cpp @@ -64,23 +64,23 @@ */ -#include "utils/common.h" -#include "x11client.h" -#include "focuschain.h" -#include "netinfo.h" -#include "workspace.h" -#include "tabbox.h" -#include "group.h" -#include "rules.h" -#include "screens.h" -#include "unmanaged.h" +#include "composite.h" #include "deleted.h" #include "effects.h" -#include "composite.h" -#include "screenedge.h" -#include "wayland_server.h" +#include "focuschain.h" +#include "group.h" #include "internal_client.h" +#include "netinfo.h" +#include "rules.h" +#include "screenedge.h" +#include "screens.h" +#include "tabbox.h" +#include "unmanaged.h" +#include "utils/common.h" #include "virtualdesktops.h" +#include "wayland_server.h" +#include "workspace.h" +#include "x11client.h" #include @@ -159,7 +159,7 @@ void Workspace::propagateClients(bool propagate_new_clients) newWindowStack << manual_overlays; - newWindowStack.reserve(newWindowStack.size() + 2*stacking_order.size()); // *2 for inputWindow + newWindowStack.reserve(newWindowStack.size() + 2 * stacking_order.size()); // *2 for inputWindow for (int i = stacking_order.size() - 1; i >= 0; --i) { X11Client *client = qobject_cast(stacking_order.at(i)); @@ -191,17 +191,17 @@ void Workspace::propagateClients(bool propagate_new_clients) int pos = 0; xcb_window_t *cl(nullptr); if (propagate_new_clients) { - cl = new xcb_window_t[ manual_overlays.count() + m_x11Clients.count()]; + cl = new xcb_window_t[manual_overlays.count() + m_x11Clients.count()]; for (const auto win : qAsConst(manual_overlays)) { cl[pos++] = win; } for (auto it = m_x11Clients.constBegin(); it != m_x11Clients.constEnd(); ++it) cl[pos++] = (*it)->window(); rootInfo()->setClientList(cl, pos); - delete [] cl; + delete[] cl; } - cl = new xcb_window_t[ manual_overlays.count() + stacking_order.count()]; + cl = new xcb_window_t[manual_overlays.count() + stacking_order.count()]; pos = 0; for (auto it = stacking_order.constBegin(); it != stacking_order.constEnd(); ++it) { X11Client *client = qobject_cast(*it); @@ -213,7 +213,7 @@ void Workspace::propagateClients(bool propagate_new_clients) cl[pos++] = win; } rootInfo()->setClientListStacking(cl, pos); - delete [] cl; + delete[] cl; } /** @@ -224,16 +224,14 @@ void Workspace::propagateClients(bool propagate_new_clients) // TODO misleading name for this method, too many slightly different ways to use it AbstractClient *Workspace::topClientOnDesktop(VirtualDesktop *desktop, AbstractOutput *output, bool unconstrained, bool only_normal) const { -// TODO Q_ASSERT( block_stacking_updates == 0 ); + // TODO Q_ASSERT( block_stacking_updates == 0 ); QList list; if (!unconstrained) list = stacking_order; else list = unconstrained_stacking_order; - for (int i = list.size() - 1; - i >= 0; - --i) { - AbstractClient *c = qobject_cast(list.at(i)); + for (int i = list.size() - 1; i >= 0; --i) { + AbstractClient *c = qobject_cast(list.at(i)); if (!c) { continue; } @@ -251,17 +249,17 @@ AbstractClient *Workspace::topClientOnDesktop(VirtualDesktop *desktop, AbstractO AbstractClient *Workspace::findDesktop(bool topmost, VirtualDesktop *desktop) const { -// TODO Q_ASSERT( block_stacking_updates == 0 ); + // TODO Q_ASSERT( block_stacking_updates == 0 ); if (topmost) { for (int i = stacking_order.size() - 1; i >= 0; i--) { - AbstractClient *c = qobject_cast(stacking_order.at(i)); + AbstractClient *c = qobject_cast(stacking_order.at(i)); if (c && c->isOnDesktop(desktop) && c->isDesktop() && c->isShown()) { return c; } } } else { // bottom-most for (Toplevel *c : qAsConst(stacking_order)) { - AbstractClient *client = qobject_cast(c); + AbstractClient *client = qobject_cast(c); if (client && c->isOnDesktop(desktop) && c->isDesktop() && client->isShown()) { return client; } @@ -277,8 +275,8 @@ void Workspace::raiseOrLowerClient(AbstractClient *c) } const AbstractClient *topmost = - topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop(), - options->isSeparateScreenFocus() ? c->output() : nullptr); + topClientOnDesktop(VirtualDesktopManager::self()->currentDesktop(), + options->isSeparateScreenFocus() ? c->output() : nullptr); if (c == topmost) lowerClient(c); @@ -286,8 +284,7 @@ void Workspace::raiseOrLowerClient(AbstractClient *c) raiseClient(c); } - -void Workspace::lowerClient(AbstractClient* c, bool nogroup) +void Workspace::lowerClient(AbstractClient *c, bool nogroup) { if (!c) return; @@ -304,16 +301,14 @@ void Workspace::lowerClient(AbstractClient* c, bool nogroup) if (auto group = c->group()) { wins = ensureStackingOrder(group->members()); } - for (int i = wins.size() - 1; - i >= 0; - --i) { - if (wins[ i ] != c) - lowerClient(wins[ i ], true); + for (int i = wins.size() - 1; i >= 0; --i) { + if (wins[i] != c) + lowerClient(wins[i], true); } } } -void Workspace::lowerClientWithinApplication(AbstractClient* c) +void Workspace::lowerClientWithinApplication(AbstractClient *c) { if (!c) return; @@ -325,10 +320,8 @@ void Workspace::lowerClientWithinApplication(AbstractClient* c) unconstrained_stacking_order.removeAll(c); bool lowered = false; // first try to put it below the bottom-most window of the application - for (auto it = unconstrained_stacking_order.begin(); - it != unconstrained_stacking_order.end(); - ++it) { - AbstractClient *client = qobject_cast(*it); + for (auto it = unconstrained_stacking_order.begin(); it != unconstrained_stacking_order.end(); ++it) { + AbstractClient *client = qobject_cast(*it); if (!client) { continue; } @@ -343,7 +336,7 @@ void Workspace::lowerClientWithinApplication(AbstractClient* c) // ignore mainwindows } -void Workspace::raiseClient(AbstractClient* c, bool nogroup) +void Workspace::raiseClient(AbstractClient *c, bool nogroup) { if (!c) return; @@ -353,7 +346,7 @@ void Workspace::raiseClient(AbstractClient* c, bool nogroup) StackingUpdatesBlocker blocker(this); if (!nogroup && c->isTransient()) { - QList transients; + QList transients; AbstractClient *transient_parent = c; while ((transient_parent = transient_parent->transientFor())) transients << transient_parent; @@ -366,7 +359,7 @@ void Workspace::raiseClient(AbstractClient* c, bool nogroup) unconstrained_stacking_order.append(c); } -void Workspace::raiseClientWithinApplication(AbstractClient* c) +void Workspace::raiseClientWithinApplication(AbstractClient *c) { if (!c) return; @@ -377,16 +370,16 @@ void Workspace::raiseClientWithinApplication(AbstractClient* c) // ignore mainwindows // first try to put it above the top-most window of the application - for (int i = unconstrained_stacking_order.size() - 1; i > -1 ; --i) { - AbstractClient *other = qobject_cast(unconstrained_stacking_order.at(i)); + for (int i = unconstrained_stacking_order.size() - 1; i > -1; --i) { + AbstractClient *other = qobject_cast(unconstrained_stacking_order.at(i)); if (!other) { continue; } - if (other == c) // don't lower it just because it asked to be raised + if (other == c) // don't lower it just because it asked to be raised return; if (AbstractClient::belongToSameApplication(other, c)) { unconstrained_stacking_order.removeAll(c); - unconstrained_stacking_order.insert(unconstrained_stacking_order.indexOf(other) + 1, c); // insert after the found one + unconstrained_stacking_order.insert(unconstrained_stacking_order.indexOf(other) + 1, c); // insert after the found one break; } } @@ -419,13 +412,13 @@ void Workspace::lowerClientRequest(KWin::AbstractClient *c) lowerClientWithinApplication(c); } -void Workspace::restack(AbstractClient* c, AbstractClient* under, bool force) +void Workspace::restack(AbstractClient *c, AbstractClient *under, bool force) { Q_ASSERT(unconstrained_stacking_order.contains(under)); if (!force && !AbstractClient::belongToSameApplication(under, c)) { - // put in the stacking order below _all_ windows belonging to the active application + // put in the stacking order below _all_ windows belonging to the active application for (int i = 0; i < unconstrained_stacking_order.size(); ++i) { - AbstractClient *other = qobject_cast(unconstrained_stacking_order.at(i)); + AbstractClient *other = qobject_cast(unconstrained_stacking_order.at(i)); if (other && other->layer() == c->layer() && AbstractClient::belongToSameApplication(under, other)) { under = (c == other) ? nullptr : other; break; @@ -442,7 +435,7 @@ void Workspace::restack(AbstractClient* c, AbstractClient* under, bool force) updateStackingOrder(); } -void Workspace::restackClientUnderActive(AbstractClient* c) +void Workspace::restackClientUnderActive(AbstractClient *c) { if (!active_client || active_client == c || active_client->layer() != c->layer()) { raiseClient(c); @@ -457,9 +450,7 @@ void Workspace::restoreSessionStackingOrder(X11Client *c) return; StackingUpdatesBlocker blocker(this); unconstrained_stacking_order.removeAll(c); - for (auto it = unconstrained_stacking_order.begin(); // from bottom - it != unconstrained_stacking_order.end(); - ++it) { + for (auto it = unconstrained_stacking_order.begin(); it != unconstrained_stacking_order.end(); ++it) { X11Client *current = qobject_cast(*it); if (!current) { continue; @@ -575,25 +566,24 @@ void Workspace::blockStackingUpdates(bool block) if (--block_stacking_updates == 0) { updateStackingOrder(blocked_propagating_new_clients); if (effects) - static_cast(effects)->checkInputWindowStacking(); + static_cast(effects)->checkInputWindowStacking(); } } -namespace { -template -QList ensureStackingOrderInList(const QList &stackingOrder, const QList &list) +namespace +{ +template +QList ensureStackingOrderInList(const QList &stackingOrder, const QList &list) { static_assert(std::is_base_of::value, - "U must be derived from T"); -// TODO Q_ASSERT( block_stacking_updates == 0 ); + "U must be derived from T"); + // TODO Q_ASSERT( block_stacking_updates == 0 ); if (list.count() < 2) return list; // TODO is this worth optimizing? - QList result = list; - for (auto it = stackingOrder.begin(); - it != stackingOrder.end(); - ++it) { - T *c = qobject_cast(*it); + QList result = list; + for (auto it = stackingOrder.begin(); it != stackingOrder.end(); ++it) { + T *c = qobject_cast(*it); if (!c) { continue; } @@ -610,7 +600,7 @@ QList Workspace::ensureStackingOrder(const QList &list return ensureStackingOrderInList(stacking_order, list); } -QList Workspace::ensureStackingOrder(const QList &list) const +QList Workspace::ensureStackingOrder(const QList &list) const { return ensureStackingOrderInList(stacking_order, list); } @@ -619,7 +609,7 @@ QList Workspace::ensureStackingOrder(const QList Workspace::xStackingOrder() const { if (m_xStackingDirty) { - const_cast(this)->updateXStackingOrder(); + const_cast(this)->updateXStackingOrder(); } return x_stacking; } @@ -634,9 +624,7 @@ void Workspace::updateXStackingOrder() xcb_window_t *windows = tree->children(); const auto count = tree->data()->children_len; int foundUnmanagedCount = m_unmanaged.count(); - for (unsigned int i = 0; - i < count; - ++i) { + for (unsigned int i = 0; i < count; ++i) { for (auto it = m_unmanaged.constBegin(); it != m_unmanaged.constEnd(); ++it) { Unmanaged *u = *it; if (u->window() == windows[i]) { @@ -668,7 +656,7 @@ void X11Client::restackWindow(xcb_window_t above, int detail, NET::RequestSource return; } auto it = workspace()->stackingOrder().constBegin(), - end = workspace()->stackingOrder().constEnd(); + end = workspace()->stackingOrder().constEnd(); while (it != end) { if (*it == this) { detail = XCB_STACK_MODE_ABOVE; @@ -679,14 +667,12 @@ void X11Client::restackWindow(xcb_window_t above, int detail, NET::RequestSource } ++it; } - } - else if (detail == XCB_STACK_MODE_TOP_IF) { + } else if (detail == XCB_STACK_MODE_TOP_IF) { other = workspace()->findClient(Predicate::WindowMatch, above); if (other && other->frameGeometry().intersects(frameGeometry())) workspace()->raiseClientRequest(this, src, timestamp); return; - } - else if (detail == XCB_STACK_MODE_BOTTOM_IF) { + } else if (detail == XCB_STACK_MODE_BOTTOM_IF) { other = workspace()->findClient(Predicate::WindowMatch, above); if (other && other->frameGeometry().intersects(frameGeometry())) workspace()->lowerClientRequest(this, src, timestamp); @@ -698,7 +684,7 @@ void X11Client::restackWindow(xcb_window_t above, int detail, NET::RequestSource if (other && detail == XCB_STACK_MODE_ABOVE) { auto it = workspace()->stackingOrder().constEnd(), - begin = workspace()->stackingOrder().constBegin(); + begin = workspace()->stackingOrder().constBegin(); while (--it != begin) { if (*it == other) { // the other one is top on stack @@ -708,8 +694,7 @@ void X11Client::restackWindow(xcb_window_t above, int detail, NET::RequestSource } X11Client *c = qobject_cast(*it); - if (!c || !( (*it)->isNormalWindow() && c->isShown() && - (*it)->isOnCurrentDesktop() && (*it)->isOnCurrentActivity() && (*it)->isOnOutput(output()) )) + if (!c || !((*it)->isNormalWindow() && c->isShown() && (*it)->isOnCurrentDesktop() && (*it)->isOnCurrentActivity() && (*it)->isOnOutput(output()))) continue; // irrelevant clients if (*(it - 1) == other) diff --git a/src/layershellv1client.cpp b/src/layershellv1client.cpp index e58d6d37ca..a9c0c3c422 100644 --- a/src/layershellv1client.cpp +++ b/src/layershellv1client.cpp @@ -6,8 +6,8 @@ #include "layershellv1client.h" #include "abstract_output.h" -#include "layershellv1integration.h" #include "deleted.h" +#include "layershellv1integration.h" #include "wayland_server.h" #include "workspace.h" @@ -22,16 +22,16 @@ namespace KWin static NET::WindowType scopeToType(const QString &scope) { - static const QHash scopeToType { - { QStringLiteral("desktop"), NET::Desktop }, - { QStringLiteral("dock"), NET::Dock }, - { QStringLiteral("crititical-notification"), NET::CriticalNotification }, - { QStringLiteral("notification"), NET::Notification }, - { QStringLiteral("tooltip"), NET::Tooltip }, - { QStringLiteral("on-screen-display"), NET::OnScreenDisplay }, - { QStringLiteral("dialog"), NET::Dialog }, - { QStringLiteral("splash"), NET::Splash }, - { QStringLiteral("utility"), NET::Utility }, + static const QHash scopeToType{ + {QStringLiteral("desktop"), NET::Desktop}, + {QStringLiteral("dock"), NET::Dock}, + {QStringLiteral("crititical-notification"), NET::CriticalNotification}, + {QStringLiteral("notification"), NET::Notification}, + {QStringLiteral("tooltip"), NET::Tooltip}, + {QStringLiteral("on-screen-display"), NET::OnScreenDisplay}, + {QStringLiteral("dialog"), NET::Dialog}, + {QStringLiteral("splash"), NET::Splash}, + {QStringLiteral("utility"), NET::Utility}, }; return scopeToType.value(scope.toLower(), NET::Normal); } diff --git a/src/libkwineffects/anidata.cpp b/src/libkwineffects/anidata.cpp index 0b006ce591..5dac272500 100644 --- a/src/libkwineffects/anidata.cpp +++ b/src/libkwineffects/anidata.cpp @@ -58,13 +58,13 @@ PreviousWindowPixmapLock::~PreviousWindowPixmapLock() } AniData::AniData() - : attribute(AnimationEffect::Opacity) - , customCurve(0) // Linear - , meta(0) - , startTime(0) - , waitAtSource(false) - , keepAlive(true) - , lastPresentTime(std::chrono::milliseconds::zero()) + : attribute(AnimationEffect::Opacity) + , customCurve(0) // Linear + , meta(0) + , startTime(0) + , waitAtSource(false) + , keepAlive(true) + , lastPresentTime(std::chrono::milliseconds::zero()) { } @@ -72,16 +72,16 @@ AniData::AniData(AnimationEffect::Attribute a, int meta_, const FPx2 &to_, int delay, const FPx2 &from_, bool waitAtSource_, FullScreenEffectLockPtr fullScreenEffectLock_, bool keepAlive, PreviousWindowPixmapLockPtr previousWindowPixmapLock_) - : attribute(a) - , from(from_) - , to(to_) - , meta(meta_) - , startTime(AnimationEffect::clock() + delay) - , fullScreenEffectLock(std::move(fullScreenEffectLock_)) - , waitAtSource(waitAtSource_) - , keepAlive(keepAlive) - , previousWindowPixmapLock(std::move(previousWindowPixmapLock_)) - , lastPresentTime(std::chrono::milliseconds::zero()) + : attribute(a) + , from(from_) + , to(to_) + , meta(meta_) + , startTime(AnimationEffect::clock() + delay) + , fullScreenEffectLock(std::move(fullScreenEffectLock_)) + , waitAtSource(waitAtSource_) + , keepAlive(keepAlive) + , previousWindowPixmapLock(std::move(previousWindowPixmapLock_)) + , lastPresentTime(std::chrono::milliseconds::zero()) { } @@ -101,27 +101,37 @@ bool AniData::isActive() const static QString attributeString(KWin::AnimationEffect::Attribute attribute) { switch (attribute) { - case KWin::AnimationEffect::Opacity: return QStringLiteral("Opacity"); - case KWin::AnimationEffect::Brightness: return QStringLiteral("Brightness"); - case KWin::AnimationEffect::Saturation: return QStringLiteral("Saturation"); - case KWin::AnimationEffect::Scale: return QStringLiteral("Scale"); - case KWin::AnimationEffect::Translation: return QStringLiteral("Translation"); - case KWin::AnimationEffect::Rotation: return QStringLiteral("Rotation"); - case KWin::AnimationEffect::Position: return QStringLiteral("Position"); - case KWin::AnimationEffect::Size: return QStringLiteral("Size"); - case KWin::AnimationEffect::Clip: return QStringLiteral("Clip"); - default: return QStringLiteral(" "); + case KWin::AnimationEffect::Opacity: + return QStringLiteral("Opacity"); + case KWin::AnimationEffect::Brightness: + return QStringLiteral("Brightness"); + case KWin::AnimationEffect::Saturation: + return QStringLiteral("Saturation"); + case KWin::AnimationEffect::Scale: + return QStringLiteral("Scale"); + case KWin::AnimationEffect::Translation: + return QStringLiteral("Translation"); + case KWin::AnimationEffect::Rotation: + return QStringLiteral("Rotation"); + case KWin::AnimationEffect::Position: + return QStringLiteral("Position"); + case KWin::AnimationEffect::Size: + return QStringLiteral("Size"); + case KWin::AnimationEffect::Clip: + return QStringLiteral("Clip"); + default: + return QStringLiteral(" "); } } QString AniData::debugInfo() const { - return QLatin1String("Animation: ") + attributeString(attribute) + - QLatin1String("\n From: ") + from.toString() + - QLatin1String("\n To: ") + to.toString() + - QLatin1String("\n Started: ") + QString::number(AnimationEffect::clock() - startTime) + QLatin1String("ms ago\n") + - QLatin1String( " Duration: ") + QString::number(timeLine.duration().count()) + QLatin1String("ms\n") + - QLatin1String( " Passed: ") + QString::number(timeLine.elapsed().count()) + QLatin1String("ms\n"); + return (QLatin1String("Animation: ") + attributeString(attribute) + + QLatin1String("\n From: ") + from.toString() + + QLatin1String("\n To: ") + to.toString() + + QLatin1String("\n Started: ") + QString::number(AnimationEffect::clock() - startTime) + QLatin1String("ms ago\n") + + QLatin1String(" Duration: ") + QString::number(timeLine.duration().count()) + QLatin1String("ms\n") + + QLatin1String(" Passed: ") + QString::number(timeLine.elapsed().count()) + QLatin1String("ms\n")); } } // namespace KWin diff --git a/src/libkwineffects/anidata_p.h b/src/libkwineffects/anidata_p.h index ed26e9a40b..2044bab777 100644 --- a/src/libkwineffects/anidata_p.h +++ b/src/libkwineffects/anidata_p.h @@ -15,7 +15,8 @@ #include -namespace KWin { +namespace KWin +{ /** * Wraps effects->setActiveFullScreenEffect for the duration of it's lifespan @@ -25,6 +26,7 @@ class FullScreenEffectLock public: FullScreenEffectLock(Effect *effect); ~FullScreenEffectLock(); + private: Q_DISABLE_COPY(FullScreenEffectLock) }; @@ -60,17 +62,19 @@ private: }; typedef QSharedPointer PreviousWindowPixmapLockPtr; -class KWINEFFECTS_EXPORT AniData { +class KWINEFFECTS_EXPORT AniData +{ public: AniData(); AniData(AnimationEffect::Attribute a, int meta, const FPx2 &to, int delay, const FPx2 &from, bool waitAtSource, - FullScreenEffectLockPtr =FullScreenEffectLockPtr(), + FullScreenEffectLockPtr = FullScreenEffectLockPtr(), bool keepAlive = true, PreviousWindowPixmapLockPtr previousWindowPixmapLock = {}); bool isActive() const; - inline bool isOneDimensional() const { + inline bool isOneDimensional() const + { return from[0] == from[1] && to[0] == to[1]; } diff --git a/src/libkwineffects/kwinanimationeffect.cpp b/src/libkwineffects/kwinanimationeffect.cpp index a6ac3a46a4..fc63df5137 100644 --- a/src/libkwineffects/kwinanimationeffect.cpp +++ b/src/libkwineffects/kwinanimationeffect.cpp @@ -13,8 +13,8 @@ #include #include -#include #include +#include namespace KWin { @@ -27,7 +27,8 @@ QDebug operator<<(QDebug dbg, const KWin::FPx2 &fpx2) QElapsedTimer AnimationEffect::s_clock; -class AnimationEffectPrivate { +class AnimationEffectPrivate +{ public: AnimationEffectPrivate() { @@ -43,7 +44,8 @@ public: quint64 AnimationEffectPrivate::m_animCounter = 0; -AnimationEffect::AnimationEffect() : d_ptr(new AnimationEffectPrivate()) +AnimationEffect::AnimationEffect() + : d_ptr(new AnimationEffectPrivate()) { Q_D(AnimationEffect); if (!s_clock.isValid()) @@ -78,15 +80,14 @@ bool AnimationEffect::isActive() const return !d->m_animations.isEmpty() && !effects->isScreenLocked(); } - -#define RELATIVE_XY(_FIELD_) const bool relative[2] = { static_cast(metaData(Relative##_FIELD_##X, meta)), \ - static_cast(metaData(Relative##_FIELD_##Y, meta)) } +#define RELATIVE_XY(_FIELD_) const bool relative[2] = {static_cast(metaData(Relative##_FIELD_##X, meta)), \ + static_cast(metaData(Relative##_FIELD_##Y, meta))} void AnimationEffect::validate(Attribute a, uint &meta, FPx2 *from, FPx2 *to, const EffectWindow *w) const { if (a < NonFloatBase) { if (a == Scale) { - QRect area = effects->clientArea(ScreenArea , w); + QRect area = effects->clientArea(ScreenArea, w); if (from && from->isValid()) { RELATIVE_XY(Source); from->set(relative[0] ? (*from)[0] * area.width() / w->width() : (*from)[0], @@ -95,35 +96,34 @@ void AnimationEffect::validate(Attribute a, uint &meta, FPx2 *from, FPx2 *to, co if (to && to->isValid()) { RELATIVE_XY(Target); to->set(relative[0] ? (*to)[0] * area.width() / w->width() : (*to)[0], - relative[1] ? (*to)[1] * area.height() / w->height() : (*to)[1] ); + relative[1] ? (*to)[1] * area.height() / w->height() : (*to)[1]); } } else if (a == Rotation) { if (from && !from->isValid()) { setMetaData(SourceAnchor, metaData(TargetAnchor, meta), meta); - from->set(0.0,0.0); + from->set(0.0, 0.0); } if (to && !to->isValid()) { setMetaData(TargetAnchor, metaData(SourceAnchor, meta), meta); - to->set(0.0,0.0); + to->set(0.0, 0.0); } } if (from && !from->isValid()) - from->set(1.0,1.0); + from->set(1.0, 1.0); if (to && !to->isValid()) - to->set(1.0,1.0); - + to->set(1.0, 1.0); } else if (a == Position) { - QRect area = effects->clientArea(ScreenArea , w); + QRect area = effects->clientArea(ScreenArea, w); QPoint pt = w->frameGeometry().bottomRight(); // cannot be < 0 ;-) if (from) { if (from->isValid()) { RELATIVE_XY(Source); from->set(relative[0] ? area.x() + (*from)[0] * area.width() : (*from)[0], - relative[1] ? area.y() + (*from)[1] * area.height() : (*from)[1]); + relative[1] ? area.y() + (*from)[1] * area.height() : (*from)[1]); } else { from->set(pt.x(), pt.y()); - setMetaData(SourceAnchor, AnimationEffect::Bottom|AnimationEffect::Right, meta); + setMetaData(SourceAnchor, AnimationEffect::Bottom | AnimationEffect::Right, meta); } } @@ -134,13 +134,12 @@ void AnimationEffect::validate(Attribute a, uint &meta, FPx2 *from, FPx2 *to, co relative[1] ? area.y() + (*to)[1] * area.height() : (*to)[1]); } else { to->set(pt.x(), pt.y()); - setMetaData( TargetAnchor, AnimationEffect::Bottom|AnimationEffect::Right, meta ); + setMetaData(TargetAnchor, AnimationEffect::Bottom | AnimationEffect::Right, meta); } } - } else if (a == Size) { - QRect area = effects->clientArea(ScreenArea , w); + QRect area = effects->clientArea(ScreenArea, w); if (from) { if (from->isValid()) { RELATIVE_XY(Source); @@ -185,11 +184,11 @@ void AnimationEffect::validate(Attribute a, uint &meta, FPx2 *from, FPx2 *to, co } else if (a == Clip) { if (from && !from->isValid()) { - from->set(1.0,1.0); + from->set(1.0, 1.0); setMetaData(SourceAnchor, metaData(TargetAnchor, meta), meta); } if (to && !to->isValid()) { - to->set(1.0,1.0); + to->set(1.0, 1.0); setMetaData(TargetAnchor, metaData(SourceAnchor, meta), meta); } @@ -203,7 +202,7 @@ void AnimationEffect::validate(Attribute a, uint &meta, FPx2 *from, FPx2 *to, co } } -quint64 AnimationEffect::p_animate( EffectWindow *w, Attribute a, uint meta, int ms, FPx2 to, const QEasingCurve &curve, int delay, FPx2 from, bool keepAtTarget, bool fullScreenEffect, bool keepAlive) +quint64 AnimationEffect::p_animate(EffectWindow *w, Attribute a, uint meta, int ms, FPx2 to, const QEasingCurve &curve, int delay, FPx2 from, bool keepAtTarget, bool fullScreenEffect, bool keepAlive) { const bool waitAtSource = from.isValid(); validate(a, meta, &from, &to, w); @@ -235,16 +234,16 @@ quint64 AnimationEffect::p_animate( EffectWindow *w, Attribute a, uint meta, int } it->first.append(AniData( - a, // Attribute - meta, // Metadata - to, // Target - delay, // Delay - from, // Source - waitAtSource, // Whether the animation should be kept at source - fullscreen, // Full screen effect lock - keepAlive, // Keep alive flag - previousPixmap // Previous window pixmap lock - )); + a, // Attribute + meta, // Metadata + to, // Target + delay, // Delay + from, // Source + waitAtSource, // Whether the animation should be kept at source + fullscreen, // Full screen effect lock + keepAlive, // Keep alive flag + previousPixmap // Previous window pixmap lock + )); const quint64 ret_id = ++d->m_animCounter; AniData &animation = it->first.last(); @@ -270,8 +269,7 @@ quint64 AnimationEffect::p_animate( EffectWindow *w, Attribute a, uint meta, int const QSize &s = effects->virtualScreenSize(); if (waitAtSource) w->addLayerRepaint(0, 0, s.width(), s.height()); - } - else { + } else { triggerRepaint(); } return ret_id; @@ -283,9 +281,11 @@ bool AnimationEffect::retarget(quint64 animationId, FPx2 newTarget, int newRemai if (animationId == d->m_justEndedAnimation) return false; // this is just ending, do not try to retarget it for (AniMap::iterator entry = d->m_animations.begin(), - mapEnd = d->m_animations.end(); entry != mapEnd; ++entry) { + mapEnd = d->m_animations.end(); + entry != mapEnd; ++entry) { for (QList::iterator anim = entry->first.begin(), - animEnd = entry->first.end(); anim != animEnd; ++anim) { + animEnd = entry->first.end(); + anim != animEnd; ++anim) { if (anim->id == animationId) { anim->from.set(interpolated(*anim, 0), interpolated(*anim, 1)); validate(anim->attribute, anim->meta, nullptr, &newTarget, entry.key()); @@ -312,10 +312,9 @@ bool AnimationEffect::redirect(quint64 animationId, Direction direction, Termina for (auto entryIt = d->m_animations.begin(); entryIt != d->m_animations.end(); ++entryIt) { auto animIt = std::find_if(entryIt->first.begin(), entryIt->first.end(), - [animationId] (AniData &anim) { - return anim.id == animationId; - } - ); + [animationId](AniData &anim) { + return anim.id == animationId; + }); if (animIt == entryIt->first.end()) { continue; } @@ -348,10 +347,9 @@ bool AnimationEffect::complete(quint64 animationId) for (auto entryIt = d->m_animations.begin(); entryIt != d->m_animations.end(); ++entryIt) { auto animIt = std::find_if(entryIt->first.begin(), entryIt->first.end(), - [animationId] (AniData &anim) { - return anim.id == animationId; - } - ); + [animationId](AniData &anim) { + return anim.id == animationId; + }); if (animIt == entryIt->first.end()) { continue; } @@ -386,7 +384,7 @@ bool AnimationEffect::cancel(quint64 animationId) return false; } -void AnimationEffect::prePaintScreen( ScreenPrePaintData& data, std::chrono::milliseconds presentTime ) +void AnimationEffect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) { Q_D(AnimationEffect); if (d->m_animations.isEmpty()) { @@ -408,22 +406,24 @@ void AnimationEffect::prePaintScreen( ScreenPrePaintData& data, std::chrono::mil effects->prePaintScreen(data, presentTime); } -static int xCoord(const QRect &r, int flag) { +static int xCoord(const QRect &r, int flag) +{ if (flag & AnimationEffect::Left) return r.x(); else if (flag & AnimationEffect::Right) return r.right(); else - return r.x() + r.width()/2; + return r.x() + r.width() / 2; } -static int yCoord(const QRect &r, int flag) { +static int yCoord(const QRect &r, int flag) +{ if (flag & AnimationEffect::Top) return r.y(); else if (flag & AnimationEffect::Bottom) return r.bottom(); else - return r.y() + r.height()/2; + return r.y() + r.height() / 2; } QRect AnimationEffect::clipRect(const QRect &geo, const AniData &anim) const @@ -436,14 +436,14 @@ QRect AnimationEffect::clipRect(const QRect &geo, const AniData &anim) const if (anim.from[1] < 1.0 || anim.to[1] < 1.0) { clip.setHeight(clip.height() * ratio[1]); } - const QRect center = geo.adjusted(clip.width()/2, clip.height()/2, - -(clip.width()+1)/2, -(clip.height()+1)/2 ); - const int x[2] = { xCoord(center, metaData(SourceAnchor, anim.meta)), - xCoord(center, metaData(TargetAnchor, anim.meta)) }; - const int y[2] = { yCoord(center, metaData(SourceAnchor, anim.meta)), - yCoord(center, metaData(TargetAnchor, anim.meta)) }; - const QPoint d(x[0] + ratio[0]*(x[1]-x[0]), y[0] + ratio[1]*(y[1]-y[0])); - clip.moveTopLeft(QPoint(d.x() - clip.width()/2, d.y() - clip.height()/2)); + const QRect center = geo.adjusted(clip.width() / 2, clip.height() / 2, + -(clip.width() + 1) / 2, -(clip.height() + 1) / 2); + const int x[2] = {xCoord(center, metaData(SourceAnchor, anim.meta)), + xCoord(center, metaData(TargetAnchor, anim.meta))}; + const int y[2] = {yCoord(center, metaData(SourceAnchor, anim.meta)), + yCoord(center, metaData(TargetAnchor, anim.meta))}; + const QPoint d(x[0] + ratio[0] * (x[1] - x[0]), y[0] + ratio[1] * (y[1] - y[0])); + clip.moveTopLeft(QPoint(d.x() - clip.width() / 2, d.y() - clip.height() / 2)); return clip; } @@ -453,12 +453,11 @@ void AnimationEffect::disconnectGeometryChanges() this, &AnimationEffect::_windowExpandedGeometryChanged); } - -void AnimationEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime ) +void AnimationEffect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) { Q_D(AnimationEffect); - AniMap::const_iterator entry = d->m_animations.constFind( w ); - if ( entry != d->m_animations.constEnd() ) { + AniMap::const_iterator entry = d->m_animations.constFind(w); + if (entry != d->m_animations.constEnd()) { bool isUsed = false; bool paintDeleted = false; for (QList::const_iterator anim = entry->first.constBegin(); anim != entry->first.constEnd(); ++anim) { @@ -474,15 +473,15 @@ void AnimationEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, paintDeleted |= anim->keepAlive; } - if ( isUsed ) { - if ( w->isMinimized() ) - w->enablePainting( EffectWindow::PAINT_DISABLED_BY_MINIMIZE ); - else if ( w->isDeleted() && paintDeleted ) - w->enablePainting( EffectWindow::PAINT_DISABLED_BY_DELETE ); - else if ( !w->isOnCurrentDesktop() ) - w->enablePainting( EffectWindow::PAINT_DISABLED_BY_DESKTOP ); -// if( !w->isPaintingEnabled() && !effects->activeFullScreenEffect() ) -// effects->addLayerRepaint(w->expandedGeometry()); + if (isUsed) { + if (w->isMinimized()) + w->enablePainting(EffectWindow::PAINT_DISABLED_BY_MINIMIZE); + else if (w->isDeleted() && paintDeleted) + w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DELETE); + else if (!w->isOnCurrentDesktop()) + w->enablePainting(EffectWindow::PAINT_DISABLED_BY_DESKTOP); + // if( !w->isPaintingEnabled() && !effects->activeFullScreenEffect() ) + // effects->addLayerRepaint(w->expandedGeometry()); } } effects->prePaintWindow(w, data, presentTime); @@ -490,46 +489,48 @@ void AnimationEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, static inline float geometryCompensation(int flags, float v) { - if (flags & (AnimationEffect::Left|AnimationEffect::Top)) + if (flags & (AnimationEffect::Left | AnimationEffect::Top)) return 0.0; // no compensation required - if (flags & (AnimationEffect::Right|AnimationEffect::Bottom)) + if (flags & (AnimationEffect::Right | AnimationEffect::Bottom)) return 1.0 - v; // full compensation return 0.5 * (1.0 - v); // half compensation } -void AnimationEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) +void AnimationEffect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) { Q_D(AnimationEffect); - AniMap::const_iterator entry = d->m_animations.constFind( w ); - if ( entry != d->m_animations.constEnd() ) { - for ( QList::const_iterator anim = entry->first.constBegin(); anim != entry->first.constEnd(); ++anim ) { + AniMap::const_iterator entry = d->m_animations.constFind(w); + if (entry != d->m_animations.constEnd()) { + for (QList::const_iterator anim = entry->first.constBegin(); anim != entry->first.constEnd(); ++anim) { if (anim->startTime > clock() && !anim->waitAtSource) continue; switch (anim->attribute) { case Opacity: - data.multiplyOpacity(interpolated(*anim)); break; + data.multiplyOpacity(interpolated(*anim)); + break; case Brightness: - data.multiplyBrightness(interpolated(*anim)); break; + data.multiplyBrightness(interpolated(*anim)); + break; case Saturation: - data.multiplySaturation(interpolated(*anim)); break; + data.multiplySaturation(interpolated(*anim)); + break; case Scale: { const QSize sz = w->frameGeometry().size(); float f1(1.0), f2(0.0); if (anim->from[0] >= 0.0 && anim->to[0] >= 0.0) { // scale x f1 = interpolated(*anim, 0); - f2 = geometryCompensation( anim->meta & AnimationEffect::Horizontal, f1 ); + f2 = geometryCompensation(anim->meta & AnimationEffect::Horizontal, f1); data.translate(f2 * sz.width()); data.setXScale(data.xScale() * f1); } if (anim->from[1] >= 0.0 && anim->to[1] >= 0.0) { // scale y if (!anim->isOneDimensional()) { f1 = interpolated(*anim, 1); - f2 = geometryCompensation( anim->meta & AnimationEffect::Vertical, f1 ); - } - else if ( ((anim->meta & AnimationEffect::Vertical)>>1) != (anim->meta & AnimationEffect::Horizontal) ) - f2 = geometryCompensation( anim->meta & AnimationEffect::Vertical, f1 ); + f2 = geometryCompensation(anim->meta & AnimationEffect::Vertical, f1); + } else if (((anim->meta & AnimationEffect::Vertical) >> 1) != (anim->meta & AnimationEffect::Horizontal)) + f2 = geometryCompensation(anim->meta & AnimationEffect::Vertical, f1); data.translate(0.0, f2 * sz.height()); data.setYScale(data.yScale() * f1); } @@ -546,13 +547,13 @@ void AnimationEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi const QSize sz = w->frameGeometry().size(); float f; if (anim->from[0] >= 0.0 && anim->to[0] >= 0.0) { // resize x - f = dest[0]/sz.width(); - data.translate(geometryCompensation( anim->meta & AnimationEffect::Horizontal, f ) * sz.width()); + f = dest[0] / sz.width(); + data.translate(geometryCompensation(anim->meta & AnimationEffect::Horizontal, f) * sz.width()); data.setXScale(data.xScale() * f); } if (anim->from[1] >= 0.0 && anim->to[1] >= 0.0) { // resize y - f = dest[1]/sz.height(); - data.translate(0.0, geometryCompensation( anim->meta & AnimationEffect::Vertical, f ) * sz.height()); + f = dest[1] / sz.height(); + data.translate(0.0, geometryCompensation(anim->meta & AnimationEffect::Vertical, f) * sz.height()); data.setYScale(data.yScale() * f); } break; @@ -560,33 +561,33 @@ void AnimationEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi case Position: { const QRect geo = w->frameGeometry(); const float prgrs = progress(*anim); - if ( anim->from[0] >= 0.0 && anim->to[0] >= 0.0 ) { + if (anim->from[0] >= 0.0 && anim->to[0] >= 0.0) { float dest = interpolated(*anim, 0); - const int x[2] = { xCoord(geo, metaData(SourceAnchor, anim->meta)), - xCoord(geo, metaData(TargetAnchor, anim->meta)) }; - data.translate(dest - (x[0] + prgrs*(x[1] - x[0]))); + const int x[2] = {xCoord(geo, metaData(SourceAnchor, anim->meta)), + xCoord(geo, metaData(TargetAnchor, anim->meta))}; + data.translate(dest - (x[0] + prgrs * (x[1] - x[0]))); } - if ( anim->from[1] >= 0.0 && anim->to[1] >= 0.0 ) { + if (anim->from[1] >= 0.0 && anim->to[1] >= 0.0) { float dest = interpolated(*anim, 1); - const int y[2] = { yCoord(geo, metaData(SourceAnchor, anim->meta)), - yCoord(geo, metaData(TargetAnchor, anim->meta)) }; - data.translate(0.0, dest - (y[0] + prgrs*(y[1] - y[0]))); + const int y[2] = {yCoord(geo, metaData(SourceAnchor, anim->meta)), + yCoord(geo, metaData(TargetAnchor, anim->meta))}; + data.translate(0.0, dest - (y[0] + prgrs * (y[1] - y[0]))); } break; } case Rotation: { data.setRotationAxis((Qt::Axis)metaData(Axis, anim->meta)); const float prgrs = progress(*anim); - data.setRotationAngle(anim->from[0] + prgrs*(anim->to[0] - anim->from[0])); + data.setRotationAngle(anim->from[0] + prgrs * (anim->to[0] - anim->from[0])); const QRect geo = w->rect(); - const uint sAnchor = metaData(SourceAnchor, anim->meta), - tAnchor = metaData(TargetAnchor, anim->meta); + const uint sAnchor = metaData(SourceAnchor, anim->meta), + tAnchor = metaData(TargetAnchor, anim->meta); QPointF pt(xCoord(geo, sAnchor), yCoord(geo, sAnchor)); if (tAnchor != sAnchor) { QPointF pt2(xCoord(geo, tAnchor), yCoord(geo, tAnchor)); - pt += static_cast(prgrs)*(pt2 - pt); + pt += static_cast(prgrs) * (pt2 - pt); } data.setRotationOrigin(QVector3D(pt)); break; @@ -602,7 +603,7 @@ void AnimationEffect::paintWindow( EffectWindow* w, int mask, QRegion region, Wi } } } - effects->paintWindow( w, mask, region, data ); + effects->paintWindow(w, mask, region, data); } void AnimationEffect::postPaintScreen() @@ -648,7 +649,7 @@ void AnimationEffect::postPaintScreen() entry = d->m_animations.erase(entry); } else { if (invalidateLayerRect) { - *const_cast(&(entry->second)) = QRect(); // invalidate + *const_cast(&(entry->second)) = QRect(); // invalidate } ++entry; } @@ -680,17 +681,16 @@ void AnimationEffect::postPaintScreen() effects->postPaintScreen(); } -float AnimationEffect::interpolated( const AniData &a, int i ) const +float AnimationEffect::interpolated(const AniData &a, int i) const { return a.from[i] + a.timeLine.value() * (a.to[i] - a.from[i]); } -float AnimationEffect::progress( const AniData &a ) const +float AnimationEffect::progress(const AniData &a) const { return a.startTime < clock() ? a.timeLine.value() : 0.0; } - // TODO - get this out of the header - the functionpointer usage of QEasingCurve somehow sucks ;-) // qreal AnimationEffect::qecGaussian(qreal progress) // exp(-5*(2*x-1)^2) // { @@ -699,33 +699,33 @@ float AnimationEffect::progress( const AniData &a ) const // return qExp(progress); // } -int AnimationEffect::metaData( MetaType type, uint meta ) -{ - switch (type) { - case SourceAnchor: - return ((meta>>5) & 0x1f); - case TargetAnchor: - return (meta& 0x1f); - case RelativeSourceX: - case RelativeSourceY: - case RelativeTargetX: - case RelativeTargetY: { - const int shift = 10 + type - RelativeSourceX; - return ((meta>>shift) & 1); - } - case Axis: - return ((meta>>10) & 3); - default: - return 0; - } -} - -void AnimationEffect::setMetaData( MetaType type, uint value, uint &meta ) +int AnimationEffect::metaData(MetaType type, uint meta) { switch (type) { case SourceAnchor: - meta &= ~(0x1f<<5); - meta |= ((value & 0x1f)<<5); + return ((meta >> 5) & 0x1f); + case TargetAnchor: + return (meta & 0x1f); + case RelativeSourceX: + case RelativeSourceY: + case RelativeTargetX: + case RelativeTargetY: { + const int shift = 10 + type - RelativeSourceX; + return ((meta >> shift) & 1); + } + case Axis: + return ((meta >> 10) & 3); + default: + return 0; + } +} + +void AnimationEffect::setMetaData(MetaType type, uint value, uint &meta) +{ + switch (type) { + case SourceAnchor: + meta &= ~(0x1f << 5); + meta |= ((value & 0x1f) << 5); break; case TargetAnchor: meta &= ~(0x1f); @@ -737,14 +737,14 @@ void AnimationEffect::setMetaData( MetaType type, uint value, uint &meta ) case RelativeTargetY: { const int shift = 10 + type - RelativeSourceX; if (value) - meta |= (1<m_animations.constBegin(), mapEnd = d->m_animations.constEnd(); entry != mapEnd; ++entry) - *const_cast(&(entry->second)) = QRect(); + *const_cast(&(entry->second)) = QRect(); updateLayerRepaints(); if (d->m_needSceneRepaint) { effects->addRepaintFull(); @@ -769,19 +769,19 @@ void AnimationEffect::triggerRepaint() static float fixOvershoot(float f, const AniData &d, short int dir, float s = 1.1) { - switch(d.timeLine.easingCurve().type()) { - case QEasingCurve::InOutElastic: - case QEasingCurve::InOutBack: - return f * s; - case QEasingCurve::InElastic: - case QEasingCurve::OutInElastic: - case QEasingCurve::OutBack: - return (dir&2) ? f * s : f; - case QEasingCurve::OutElastic: - case QEasingCurve::InBack: - return (dir&1) ? f * s : f; - default: - return f; + switch (d.timeLine.easingCurve().type()) { + case QEasingCurve::InOutElastic: + case QEasingCurve::InOutBack: + return f * s; + case QEasingCurve::InElastic: + case QEasingCurve::OutInElastic: + case QEasingCurve::OutBack: + return (dir & 2) ? f * s : f; + case QEasingCurve::OutElastic: + case QEasingCurve::InBack: + return (dir & 1) ? f * s : f; + default: + return f; } } @@ -796,98 +796,98 @@ void AnimationEffect::updateLayerRepaints() float t[2] = {0.0, 0.0}; bool createRegion = false; QList rects; - QRect *layerRect = const_cast(&(entry->second)); + QRect *layerRect = const_cast(&(entry->second)); for (QList::const_iterator anim = entry->first.constBegin(), animEnd = entry->first.constEnd(); anim != animEnd; ++anim) { if (anim->startTime > clock()) continue; switch (anim->attribute) { - case Opacity: - case Brightness: - case Saturation: - case CrossFadePrevious: - createRegion = true; - break; - case Rotation: - createRegion = false; - *layerRect = QRect(QPoint(0, 0), effects->virtualScreenSize()); - goto region_creation; // sic! no need to do anything else - case Generic: - d->m_needSceneRepaint = true; // we don't know whether this will change visual stacking order - return; // sic! no need to do anything else - case Translation: - case Position: { - createRegion = true; - QRect r(entry.key()->frameGeometry()); - int x[2] = {0,0}; - int y[2] = {0,0}; - if (anim->attribute == Translation) { - x[0] = anim->from[0]; - x[1] = anim->to[0]; - y[0] = anim->from[1]; - y[1] = anim->to[1]; - } else { - if ( anim->from[0] >= 0.0 && anim->to[0] >= 0.0 ) { - x[0] = anim->from[0] - xCoord(r, metaData(SourceAnchor, anim->meta)); - x[1] = anim->to[0] - xCoord(r, metaData(TargetAnchor, anim->meta)); - } - if ( anim->from[1] >= 0.0 && anim->to[1] >= 0.0 ) { - y[0] = anim->from[1] - yCoord(r, metaData(SourceAnchor, anim->meta)); - y[1] = anim->to[1] - yCoord(r, metaData(TargetAnchor, anim->meta)); - } + case Opacity: + case Brightness: + case Saturation: + case CrossFadePrevious: + createRegion = true; + break; + case Rotation: + createRegion = false; + *layerRect = QRect(QPoint(0, 0), effects->virtualScreenSize()); + goto region_creation; // sic! no need to do anything else + case Generic: + d->m_needSceneRepaint = true; // we don't know whether this will change visual stacking order + return; // sic! no need to do anything else + case Translation: + case Position: { + createRegion = true; + QRect r(entry.key()->frameGeometry()); + int x[2] = {0, 0}; + int y[2] = {0, 0}; + if (anim->attribute == Translation) { + x[0] = anim->from[0]; + x[1] = anim->to[0]; + y[0] = anim->from[1]; + y[1] = anim->to[1]; + } else { + if (anim->from[0] >= 0.0 && anim->to[0] >= 0.0) { + x[0] = anim->from[0] - xCoord(r, metaData(SourceAnchor, anim->meta)); + x[1] = anim->to[0] - xCoord(r, metaData(TargetAnchor, anim->meta)); + } + if (anim->from[1] >= 0.0 && anim->to[1] >= 0.0) { + y[0] = anim->from[1] - yCoord(r, metaData(SourceAnchor, anim->meta)); + y[1] = anim->to[1] - yCoord(r, metaData(TargetAnchor, anim->meta)); } - r = entry.key()->expandedGeometry(); - rects << r.translated(x[0], y[0]) << r.translated(x[1], y[1]); - break; } - case Clip: - createRegion = true; - break; - case Size: - case Scale: { - createRegion = true; - const QSize sz = entry.key()->frameGeometry().size(); - float fx = qMax(fixOvershoot(anim->from[0], *anim, 1), fixOvershoot(anim->to[0], *anim, 2)); -// float fx = qMax(interpolated(*anim,0), anim->to[0]); - if (fx >= 0.0) { - if (anim->attribute == Size) - fx /= sz.width(); - f[0] *= fx; - t[0] += geometryCompensation( anim->meta & AnimationEffect::Horizontal, fx ) * sz.width(); - } -// float fy = qMax(interpolated(*anim,1), anim->to[1]); - float fy = qMax(fixOvershoot(anim->from[1], *anim, 1), fixOvershoot(anim->to[1], *anim, 2)); - if (fy >= 0.0) { - if (anim->attribute == Size) - fy /= sz.height(); - if (!anim->isOneDimensional()) { - f[1] *= fy; - t[1] += geometryCompensation( anim->meta & AnimationEffect::Vertical, fy ) * sz.height(); - } else if ( ((anim->meta & AnimationEffect::Vertical)>>1) != (anim->meta & AnimationEffect::Horizontal) ) { - f[1] *= fx; - t[1] += geometryCompensation( anim->meta & AnimationEffect::Vertical, fx ) * sz.height(); - } - } - break; + r = entry.key()->expandedGeometry(); + rects << r.translated(x[0], y[0]) << r.translated(x[1], y[1]); + break; + } + case Clip: + createRegion = true; + break; + case Size: + case Scale: { + createRegion = true; + const QSize sz = entry.key()->frameGeometry().size(); + float fx = qMax(fixOvershoot(anim->from[0], *anim, 1), fixOvershoot(anim->to[0], *anim, 2)); + // float fx = qMax(interpolated(*anim,0), anim->to[0]); + if (fx >= 0.0) { + if (anim->attribute == Size) + fx /= sz.width(); + f[0] *= fx; + t[0] += geometryCompensation(anim->meta & AnimationEffect::Horizontal, fx) * sz.width(); } + // float fy = qMax(interpolated(*anim,1), anim->to[1]); + float fy = qMax(fixOvershoot(anim->from[1], *anim, 1), fixOvershoot(anim->to[1], *anim, 2)); + if (fy >= 0.0) { + if (anim->attribute == Size) + fy /= sz.height(); + if (!anim->isOneDimensional()) { + f[1] *= fy; + t[1] += geometryCompensation(anim->meta & AnimationEffect::Vertical, fy) * sz.height(); + } else if (((anim->meta & AnimationEffect::Vertical) >> 1) != (anim->meta & AnimationEffect::Horizontal)) { + f[1] *= fx; + t[1] += geometryCompensation(anim->meta & AnimationEffect::Vertical, fx) * sz.height(); + } + } + break; + } } } -region_creation: + region_creation: if (createRegion) { const QRect geo = entry.key()->expandedGeometry(); if (rects.isEmpty()) rects << geo; QList::const_iterator r, rEnd = rects.constEnd(); - for ( r = rects.constBegin(); r != rEnd; ++r) { // transform - const_cast(&(*r))->setSize(QSize(qRound(r->width()*f[0]), qRound(r->height()*f[1]))); - const_cast(&(*r))->translate(t[0], t[1]); // "const_cast" - don't do that at home, kids ;-) + for (r = rects.constBegin(); r != rEnd; ++r) { // transform + const_cast(&(*r))->setSize(QSize(qRound(r->width() * f[0]), qRound(r->height() * f[1]))); + const_cast(&(*r))->translate(t[0], t[1]); // "const_cast" - don't do that at home, kids ;-) } QRect rect = rects.at(0); if (rects.count() > 1) { - for ( r = rects.constBegin() + 1; r != rEnd; ++r) // unite + for (r = rects.constBegin() + 1; r != rEnd; ++r) // unite rect |= *r; - const int dx = 110*(rect.width() - geo.width())/100 + 1 - rect.width() + geo.width(); - const int dy = 110*(rect.height() - geo.height())/100 + 1 - rect.height() + geo.height(); - rect.adjust(-dx,-dy,dx,dy); // fix pot. overshoot + const int dx = 110 * (rect.width() - geo.width()) / 100 + 1 - rect.width() + geo.width(); + const int dy = 110 * (rect.height() - geo.height()) / 100 + 1 - rect.height() + geo.height(); + rect.adjust(-dx, -dy, dx, dy); // fix pot. overshoot } *layerRect = rect; } @@ -899,14 +899,14 @@ void AnimationEffect::_windowExpandedGeometryChanged(KWin::EffectWindow *w) Q_D(AnimationEffect); AniMap::const_iterator entry = d->m_animations.constFind(w); if (entry != d->m_animations.constEnd()) { - *const_cast(&(entry->second)) = QRect(); + *const_cast(&(entry->second)) = QRect(); updateLayerRepaints(); if (!entry->second.isNull()) // actually got updated, ie. is in use - ensure it get's a repaint w->addLayerRepaint(entry->second); } } -void AnimationEffect::_windowClosed( EffectWindow* w ) +void AnimationEffect::_windowClosed(EffectWindow *w) { Q_D(AnimationEffect); @@ -919,8 +919,8 @@ void AnimationEffect::_windowClosed( EffectWindow* w ) QList &animations = (*it).first; for (auto animationIt = animations.begin(); - animationIt != animations.end(); - ++animationIt) { + animationIt != animations.end(); + ++animationIt) { if (!(*animationIt).keepAlive) { continue; } @@ -933,14 +933,13 @@ void AnimationEffect::_windowClosed( EffectWindow* w ) } } -void AnimationEffect::_windowDeleted( EffectWindow* w ) +void AnimationEffect::_windowDeleted(EffectWindow *w) { Q_D(AnimationEffect); - d->m_animations.remove( w ); + d->m_animations.remove(w); } - -QString AnimationEffect::debug(const QString &/*parameter*/) const +QString AnimationEffect::debug(const QString & /*parameter*/) const { Q_D(const AnimationEffect); QString dbg; diff --git a/src/libkwineffects/kwinanimationeffect.h b/src/libkwineffects/kwinanimationeffect.h index b93743b8bb..b5ac38cec6 100644 --- a/src/libkwineffects/kwinanimationeffect.h +++ b/src/libkwineffects/kwinanimationeffect.h @@ -20,20 +20,69 @@ namespace KWin { -class KWINEFFECTS_EXPORT FPx2 { +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 { + 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]); @@ -43,35 +92,81 @@ public: } inline FPx2 &operator=(const FPx2 &other) - { f[0] = other.f[0]; f[1] = other.f[1]; valid = other.valid; return *this; } + { + 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; } + { + 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; } + { + f[0] -= other[0]; + f[1] -= other[1]; + return *this; + } inline FPx2 &operator*=(float fl) - { f[0] *= fl; f[1] *= fl; return *this; } + { + f[0] *= fl; + f[1] *= fl; + return *this; + } inline FPx2 &operator/=(float fl) - { f[0] /= fl; f[1] /= fl; return *this; } + { + 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]; } + { + 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]; } + { + 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] ); } + { + 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] ); } + { + 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 ); } + { + 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 ); } + { + return FPx2(f[0] * fl, f[1] * fl); + } friend inline const FPx2 operator-(const FPx2 &f) - { return FPx2( -f[0], -f[1] ); } + { + return FPx2(-f[0], -f[1]); + } friend inline const FPx2 operator/(const FPx2 &f, float fl) - { return FPx2( f[0] / fl, f[1] / 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; } + 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]; @@ -100,19 +195,38 @@ 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 }; + 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, + 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 }; + enum MetaType { SourceAnchor, + TargetAnchor, + RelativeSourceX, + RelativeSourceY, + RelativeTargetX, + RelativeTargetY, + Axis }; Q_ENUM(MetaType) /** @@ -135,7 +249,7 @@ public: /** * Don't terminate the animation when it reaches source or target position. */ - DontTerminate = 0x00, + 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 @@ -184,7 +298,7 @@ public: * @returns Stored metadata. * @since 4.8 */ - static int metaData(MetaType type, uint meta ); + static int metaData(MetaType type, uint meta); /** * Sets metadata. @@ -194,13 +308,13 @@ public: * @param meta Where the metadata will be stored. * @since 4.8 */ - static void setMetaData(MetaType type, uint value, uint &meta ); + static void setMetaData(MetaType type, uint value, uint &meta); // Reimplemented from KWin::Effect. QString debug(const QString ¶meter) const override; - void prePaintScreen( ScreenPrePaintData& data, std::chrono::milliseconds presentTime ) override; - void prePaintWindow( EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime ) override; - void paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) override; + void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) override; + void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) override; + void paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) override; void postPaintScreen() override; /** @@ -210,15 +324,16 @@ public: */ static qreal qecGaussian(qreal progress) { - progress = 2*progress - 1; - progress *= -5*progress; + progress = 2 * progress - 1; + progress *= -5 * progress; return qExp(progress); } /** * @since 4.8 */ - static inline qint64 clock() { + static inline qint64 clock() + { return s_clock.elapsed(); } @@ -247,8 +362,10 @@ protected: * @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, const FPx2 &to, const QEasingCurve &curve = QEasingCurve(), int delay = 0, const FPx2 &from = FPx2(), bool fullScreen = false, bool keepAlive = true) - { return p_animate(w, a, meta, ms, to, curve, delay, from, false, fullScreen, keepAlive); } + quint64 animate(EffectWindow *w, Attribute a, uint meta, int ms, const FPx2 &to, const QEasingCurve &curve = QEasingCurve(), int delay = 0, const 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. @@ -277,8 +394,10 @@ protected: * @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, const FPx2 &to, const QEasingCurve &curve = QEasingCurve(), int delay = 0, const FPx2 &from = FPx2(), bool fullScreen = false, bool keepAlive = true) - { return p_animate(w, a, meta, ms, to, curve, delay, from, true, fullScreen, keepAlive); } + quint64 set(EffectWindow *w, Attribute a, uint meta, int ms, const FPx2 &to, const QEasingCurve &curve = QEasingCurve(), int delay = 0, const 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. @@ -333,7 +452,11 @@ protected: * @since 4.8 */ virtual void animationEnded(EffectWindow *w, Attribute a, uint meta) - {Q_UNUSED(w); Q_UNUSED(a); Q_UNUSED(meta);} + { + Q_UNUSED(w); + Q_UNUSED(a); + Q_UNUSED(meta); + } /** * Cancels a running animation. @@ -361,13 +484,18 @@ protected: * @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);} + 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; + typedef QMap, QRect>> AniMap; /** * @internal @@ -376,9 +504,9 @@ protected: private: quint64 p_animate(EffectWindow *w, Attribute a, uint meta, int ms, FPx2 to, const QEasingCurve &curve, int delay, FPx2 from, bool keepAtTarget, bool fullScreenEffect, bool keepAlive); - QRect clipRect(const QRect &windowRect, const AniData&) const; - float interpolated( const AniData&, int i = 0 ) const; - float progress( const AniData& ) const; + QRect clipRect(const QRect &windowRect, const AniData &) 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; @@ -386,13 +514,13 @@ private: private Q_SLOTS: void init(); void triggerRepaint(); - void _windowClosed( KWin::EffectWindow* w ); - void _windowDeleted( KWin::EffectWindow* w ); + void _windowClosed(KWin::EffectWindow *w); + void _windowDeleted(KWin::EffectWindow *w); void _windowExpandedGeometryChanged(KWin::EffectWindow *w); private: static QElapsedTimer s_clock; - AnimationEffectPrivate * const d_ptr; + AnimationEffectPrivate *const d_ptr; Q_DECLARE_PRIVATE(AnimationEffect) Q_DISABLE_COPY(AnimationEffect) }; diff --git a/src/libkwineffects/kwindeformeffect.cpp b/src/libkwineffects/kwindeformeffect.cpp index 1303f668ec..32a7ed2895 100644 --- a/src/libkwineffects/kwindeformeffect.cpp +++ b/src/libkwineffects/kwindeformeffect.cpp @@ -128,8 +128,8 @@ void DeformEffectPrivate::paint(EffectWindow *window, GLTexture *texture, const const int verticesPerQuad = indexedQuads ? 4 : 6; const GLVertexAttrib attribs[] = { - { VA_Position, 2, GL_FLOAT, offsetof(GLVertex2D, position) }, - { VA_TexCoord, 2, GL_FLOAT, offsetof(GLVertex2D, texcoord) }, + {VA_Position, 2, GL_FLOAT, offsetof(GLVertex2D, position)}, + {VA_TexCoord, 2, GL_FLOAT, offsetof(GLVertex2D, texcoord)}, }; GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); @@ -163,7 +163,7 @@ void DeformEffectPrivate::paint(EffectWindow *window, GLTexture *texture, const vbo->unbindArrays(); } -void DeformEffect::drawWindow(EffectWindow *window, int mask, const QRegion& region, WindowPaintData &data) +void DeformEffect::drawWindow(EffectWindow *window, int mask, const QRegion ®ion, WindowPaintData &data) { DeformOffscreenData *offscreenData = d->windows.value(window); if (!offscreenData) { @@ -206,9 +206,9 @@ void DeformEffect::handleWindowDeleted(EffectWindow *window) void DeformEffect::setupConnections() { d->windowDamagedConnection = - connect(effects, &EffectsHandler::windowDamaged, this, &DeformEffect::handleWindowDamaged); + connect(effects, &EffectsHandler::windowDamaged, this, &DeformEffect::handleWindowDamaged); d->windowDeletedConnection = - connect(effects, &EffectsHandler::windowDeleted, this, &DeformEffect::handleWindowDeleted); + connect(effects, &EffectsHandler::windowDeleted, this, &DeformEffect::handleWindowDeleted); } void DeformEffect::destroyConnections() diff --git a/src/libkwineffects/kwindeformeffect.h b/src/libkwineffects/kwindeformeffect.h index 5615d8184e..a228668e0a 100644 --- a/src/libkwineffects/kwindeformeffect.h +++ b/src/libkwineffects/kwindeformeffect.h @@ -38,7 +38,7 @@ public: static bool supported(); private: - void drawWindow(EffectWindow *window, int mask, const QRegion& region, WindowPaintData &data) override; + void drawWindow(EffectWindow *window, int mask, const QRegion ®ion, WindowPaintData &data) override; protected: /** diff --git a/src/libkwineffects/kwineffects.cpp b/src/libkwineffects/kwineffects.cpp index 5f4922156f..f549edd936 100644 --- a/src/libkwineffects/kwineffects.cpp +++ b/src/libkwineffects/kwineffects.cpp @@ -13,23 +13,22 @@ #include "config-kwin.h" -#include -#include -#include #include +#include #include #include -#include +#include +#include #include +#include -#include #include +#include #if defined(__SSE2__) -# include +#include #endif - namespace KWin { @@ -45,13 +44,15 @@ void WindowPrePaintData::setTransformed() mask |= Effect::PAINT_WINDOW_TRANSFORMED; } -class PaintDataPrivate { +class PaintDataPrivate +{ public: PaintDataPrivate() - : scale(1., 1., 1.) + : scale(1., 1., 1.) , rotationAxis(0, 0, 1.) , rotationAngle(0.) - {} + { + } QVector3D scale; QVector3D translation; @@ -205,7 +206,8 @@ void PaintData::setRotationOrigin(const QVector3D &origin) d->rotationOrigin = origin; } -class WindowPaintDataPrivate { +class WindowPaintDataPrivate +{ public: qreal opacity; qreal saturation; @@ -222,7 +224,7 @@ WindowPaintData::WindowPaintData(EffectWindow *w) { } -WindowPaintData::WindowPaintData(EffectWindow* w, const QMatrix4x4 &screenProjectionMatrix) +WindowPaintData::WindowPaintData(EffectWindow *w, const QMatrix4x4 &screenProjectionMatrix) : PaintData() , shader(nullptr) , d(new WindowPaintDataPrivate()) @@ -534,16 +536,16 @@ void Effect::reconfigure(ReconfigureFlags) { } -void* Effect::proxy() +void *Effect::proxy() { return nullptr; } -void Effect::windowInputMouseEvent(QEvent*) +void Effect::windowInputMouseEvent(QEvent *) { } -void Effect::grabbedKeyboardEvent(QKeyEvent*) +void Effect::grabbedKeyboardEvent(QKeyEvent *) { } @@ -552,12 +554,12 @@ bool Effect::borderActivated(ElectricBorder) return false; } -void Effect::prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) +void Effect::prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) { effects->prePaintScreen(data, presentTime); } -void Effect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) +void Effect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) { effects->paintScreen(mask, region, data); } @@ -567,22 +569,22 @@ void Effect::postPaintScreen() effects->postPaintScreen(); } -void Effect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime) +void Effect::prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) { effects->prePaintWindow(w, data, presentTime); } -void Effect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data) +void Effect::paintWindow(EffectWindow *w, int mask, QRegion region, WindowPaintData &data) { effects->paintWindow(w, mask, region, data); } -void Effect::postPaintWindow(EffectWindow* w) +void Effect::postPaintWindow(EffectWindow *w) { effects->postPaintWindow(w); } -void Effect::paintEffectFrame(KWin::EffectFrame* frame, const QRegion ®ion, double opacity, double frameOpacity) +void Effect::paintEffectFrame(KWin::EffectFrame *frame, const QRegion ®ion, double opacity, double frameOpacity) { effects->paintEffectFrame(frame, region, opacity, frameOpacity); } @@ -602,13 +604,13 @@ QString Effect::debug(const QString &) const return QString(); } -void Effect::drawWindow(EffectWindow* w, int mask, const QRegion ®ion, WindowPaintData& data) +void Effect::drawWindow(EffectWindow *w, int mask, const QRegion ®ion, WindowPaintData &data) { effects->drawWindow(w, mask, region, data); } -void Effect::setPositionTransformations(WindowPaintData& data, QRect& region, EffectWindow* w, - const QRect& r, Qt::AspectRatioMode aspect) +void Effect::setPositionTransformations(WindowPaintData &data, QRect ®ion, EffectWindow *w, + const QRect &r, Qt::AspectRatioMode aspect) { QSize size = w->size(); size.scale(r.size(), aspect); @@ -628,7 +630,7 @@ QPoint Effect::cursorPos() return effects->cursorPos(); } -double Effect::animationTime(const KConfigGroup& cfg, const QString& key, int defaultTime) +double Effect::animationTime(const KConfigGroup &cfg, const QString &key, int defaultTime) { int time = cfg.readEntry(key, 0); return time != 0 ? time : qMax(defaultTime * effects->animationTimeFactor(), 1.); @@ -801,7 +803,7 @@ QRegion EffectsHandler::mapToRenderTarget(const QRegion ®ion) const return result; } -EffectsHandler* effects = nullptr; +EffectsHandler *effects = nullptr; EffectScreen::EffectScreen(QObject *parent) : QObject(parent) @@ -884,8 +886,8 @@ bool EffectWindow::hasDecoration() const bool EffectWindow::isVisible() const { return !isMinimized() - && isOnCurrentDesktop() - && isOnCurrentActivity(); + && isOnCurrentDesktop() + && isOnCurrentActivity(); } //**************************************** @@ -905,19 +907,19 @@ WindowQuad WindowQuad::makeSubQuad(double x1, double y1, double x2, double y2) c Q_ASSERT(x1 < x2 && y1 < y2 && x1 >= left() && x2 <= right() && y1 >= top() && y2 <= bottom()); WindowQuad ret(*this); // vertices are clockwise starting from topleft - ret.verts[ 0 ].px = x1; - ret.verts[ 3 ].px = x1; - ret.verts[ 1 ].px = x2; - ret.verts[ 2 ].px = x2; - ret.verts[ 0 ].py = y1; - ret.verts[ 1 ].py = y1; - ret.verts[ 2 ].py = y2; - ret.verts[ 3 ].py = y2; + ret.verts[0].px = x1; + ret.verts[3].px = x1; + ret.verts[1].px = x2; + ret.verts[2].px = x2; + ret.verts[0].py = y1; + ret.verts[1].py = y1; + ret.verts[2].py = y2; + ret.verts[3].py = y2; const double xOrigin = left(); const double yOrigin = top(); - const double widthReciprocal = 1 / (right() - xOrigin); + const double widthReciprocal = 1 / (right() - xOrigin); const double heightReciprocal = 1 / (bottom() - yOrigin); for (int i = 0; i < 4; ++i) { @@ -925,12 +927,8 @@ WindowQuad WindowQuad::makeSubQuad(double x1, double y1, double x2, double y2) c const double w2 = (ret.verts[i].py - yOrigin) * heightReciprocal; // Use bilinear interpolation to compute the texture coords. - ret.verts[i].tx = (1 - w1) * (1 - w2) * verts[0].tx + - w1 * (1 - w2) * verts[1].tx + - w1 * w2 * verts[2].tx + (1 - w1) * w2 * verts[3].tx; - ret.verts[i].ty = (1 - w1) * (1 - w2) * verts[0].ty + - w1 * (1 - w2) * verts[1].ty + - w1 * w2 * verts[2].ty + (1 - w1) * w2 * verts[3].ty; + ret.verts[i].tx = (1 - w1) * (1 - w2) * verts[0].tx + w1 * (1 - w2) * verts[1].tx + w1 * w2 * verts[2].tx + (1 - w1) * w2 * verts[3].tx; + ret.verts[i].ty = (1 - w1) * (1 - w2) * verts[0].ty + w1 * (1 - w2) * verts[1].ty + w1 * w2 * verts[2].ty + (1 - w1) * w2 * verts[3].ty; } return ret; @@ -944,15 +942,13 @@ WindowQuadList WindowQuadList::splitAtX(double x) const { WindowQuadList ret; ret.reserve(count()); - for (const WindowQuad & quad : *this) { + for (const WindowQuad &quad : *this) { bool wholeleft = true; bool wholeright = true; - for (int i = 0; - i < 4; - ++i) { - if (quad[ i ].x() < x) + for (int i = 0; i < 4; ++i) { + if (quad[i].x() < x) wholeright = false; - if (quad[ i ].x() > x) + if (quad[i].x() > x) wholeleft = false; } if (wholeleft || wholeright) { // is whole in one split part @@ -973,15 +969,13 @@ WindowQuadList WindowQuadList::splitAtY(double y) const { WindowQuadList ret; ret.reserve(count()); - for (const WindowQuad & quad : *this) { + for (const WindowQuad &quad : *this) { bool wholetop = true; bool wholebottom = true; - for (int i = 0; - i < 4; - ++i) { - if (quad[ i ].y() < y) + for (int i = 0; i < 4; ++i) { + if (quad[i].y() < y) wholebottom = false; - if (quad[ i ].y() > y) + if (quad[i].y() > y) wholetop = false; } if (wholetop || wholebottom) { // is whole in one split part @@ -1004,24 +998,24 @@ WindowQuadList WindowQuadList::makeGrid(int maxQuadSize) const return *this; // Find the bounding rectangle - double left = first().left(); - double right = first().right(); - double top = first().top(); + double left = first().left(); + double right = first().right(); + double top = first().top(); double bottom = first().bottom(); for (const WindowQuad &quad : qAsConst(*this)) { - left = qMin(left, quad.left()); - right = qMax(right, quad.right()); - top = qMin(top, quad.top()); + left = qMin(left, quad.left()); + right = qMax(right, quad.right()); + top = qMin(top, quad.top()); bottom = qMax(bottom, quad.bottom()); } WindowQuadList ret; for (const WindowQuad &quad : qAsConst(*this)) { - const double quadLeft = quad.left(); - const double quadRight = quad.right(); - const double quadTop = quad.top(); + const double quadLeft = quad.left(); + const double quadRight = quad.right(); + const double quadTop = quad.top(); const double quadBottom = quad.bottom(); // sanity check, see BUG 390953 @@ -1032,7 +1026,7 @@ WindowQuadList WindowQuadList::makeGrid(int maxQuadSize) const // Compute the top-left corner of the first intersecting grid cell const double xBegin = left + qFloor((quadLeft - left) / maxQuadSize) * maxQuadSize; - const double yBegin = top + qFloor((quadTop - top) / maxQuadSize) * maxQuadSize; + const double yBegin = top + qFloor((quadTop - top) / maxQuadSize) * maxQuadSize; // Loop over all intersecting cells and add sub-quads for (double y = yBegin; y < quadBottom; y += maxQuadSize) { @@ -1057,15 +1051,15 @@ WindowQuadList WindowQuadList::makeRegularGrid(int xSubdivisions, int ySubdivisi return *this; // Find the bounding rectangle - double left = first().left(); - double right = first().right(); - double top = first().top(); + double left = first().left(); + double right = first().right(); + double top = first().top(); double bottom = first().bottom(); for (const WindowQuad &quad : *this) { - left = qMin(left, quad.left()); - right = qMax(right, quad.right()); - top = qMin(top, quad.top()); + left = qMin(left, quad.left()); + right = qMax(right, quad.right()); + top = qMin(top, quad.top()); bottom = qMax(bottom, quad.bottom()); } @@ -1075,9 +1069,9 @@ WindowQuadList WindowQuadList::makeRegularGrid(int xSubdivisions, int ySubdivisi WindowQuadList ret; for (const WindowQuad &quad : *this) { - const double quadLeft = quad.left(); - const double quadRight = quad.right(); - const double quadTop = quad.top(); + const double quadLeft = quad.left(); + const double quadRight = quad.right(); + const double quadTop = quad.top(); const double quadBottom = quad.bottom(); // sanity check, see BUG 390953 @@ -1088,7 +1082,7 @@ WindowQuadList WindowQuadList::makeRegularGrid(int xSubdivisions, int ySubdivisi // Compute the top-left corner of the first intersecting grid cell const double xBegin = left + qFloor((quadLeft - left) / xIncrement) * xIncrement; - const double yBegin = top + qFloor((quadTop - top) / yIncrement) * yIncrement; + const double yBegin = top + qFloor((quadTop - top) / yIncrement) * yIncrement; // Loop over all intersecting cells and add sub-quads for (double y = yBegin; y < quadBottom; y += yIncrement) { @@ -1108,11 +1102,11 @@ WindowQuadList WindowQuadList::makeRegularGrid(int xSubdivisions, int ySubdivisi } #ifndef GL_TRIANGLES -# define GL_TRIANGLES 0x0004 +#define GL_TRIANGLES 0x0004 #endif #ifndef GL_QUADS -# define GL_QUADS 0x0007 +#define GL_QUADS 0x0007 #endif void WindowQuadList::makeInterleavedArrays(unsigned int type, GLVertex2D *vertices, const QMatrix4x4 &textureMatrix) const @@ -1126,8 +1120,7 @@ void WindowQuadList::makeInterleavedArrays(unsigned int type, GLVertex2D *vertic Q_ASSERT(type == GL_QUADS || type == GL_TRIANGLES); - switch (type) - { + switch (type) { case GL_QUADS: #if defined(__SSE2__) if (!(intptr_t(vertex) & 0xf)) { @@ -1241,8 +1234,8 @@ void WindowQuadList::makeArrays(float **vertices, float **texcoords, const QSize float *vpos = *vertices; float *tpos = *texcoords; - // Note: The positions in a WindowQuad are stored in clockwise order - const int index[] = { 1, 0, 3, 3, 2, 1 }; + // Note: The positions in a WindowQuad are stored in clockwise order + const int index[] = {1, 0, 3, 3, 2, 1}; for (const WindowQuad &quad : *this) { for (int j = 0; j < 6; j++) { @@ -1298,7 +1291,7 @@ Motion2D::~Motion2D() ***************************************************************/ WindowMotionManager::WindowMotionManager(bool useGlobalAnimationModifier) - : m_useGlobalAnimationModifier(useGlobalAnimationModifier) + : m_useGlobalAnimationModifier(useGlobalAnimationModifier) { // TODO: Allow developer to modify motion attributes @@ -1321,7 +1314,7 @@ void WindowMotionManager::manage(EffectWindow *w) smoothness = effects->animationTimeFactor() * 4.0; } - WindowMotion &motion = m_managedWindows[ w ]; + WindowMotion &motion = m_managedWindows[w]; motion.translation.setStrength(strength); motion.translation.setSmoothness(smoothness); motion.scale.setStrength(strength * 1.33); @@ -1348,7 +1341,7 @@ void WindowMotionManager::calculate(int time) if (!effects->animationTimeFactor()) { // Just skip it completely if the user wants no animation m_movingWindowsSet.clear(); - QHash::iterator it = m_managedWindows.begin(); + QHash::iterator it = m_managedWindows.begin(); for (; it != m_managedWindows.end(); ++it) { WindowMotion *motion = &it.value(); motion->translation.finish(); @@ -1356,7 +1349,7 @@ void WindowMotionManager::calculate(int time) } } - QHash::iterator it = m_managedWindows.begin(); + QHash::iterator it = m_managedWindows.begin(); for (; it != m_managedWindows.end(); ++it) { WindowMotion *motion = &it.value(); int stopped = 0; @@ -1372,8 +1365,8 @@ void WindowMotionManager::calculate(int time) trans->calculate(time); const short fx = trans->target().x() <= trans->startValue().x() ? -1 : 1; const short fy = trans->target().y() <= trans->startValue().y() ? -1 : 1; - if (trans->distance().x()*fx/0.5 < 1.0 && trans->velocity().x()*fx/0.2 < 1.0 && - trans->distance().y()*fy/0.5 < 1.0 && trans->velocity().y()*fy/0.2 < 1.0) { + if (trans->distance().x() * fx / 0.5 < 1.0 && trans->velocity().x() * fx / 0.2 < 1.0 + && trans->distance().y() * fy / 0.5 < 1.0 && trans->velocity().y() * fy / 0.2 < 1.0) { // Hide tiny oscillations motion->translation.finish(); ++stopped; @@ -1388,8 +1381,8 @@ void WindowMotionManager::calculate(int time) scale->calculate(time); const short fx = scale->target().x() < 1.0 ? -1 : 1; const short fy = scale->target().y() < 1.0 ? -1 : 1; - if (scale->distance().x()*fx/0.001 < 1.0 && scale->velocity().x()*fx/0.05 < 1.0 && - scale->distance().y()*fy/0.001 < 1.0 && scale->velocity().y()*fy/0.05 < 1.0) { + if (scale->distance().x() * fx / 0.001 < 1.0 && scale->velocity().x() * fx / 0.05 < 1.0 + && scale->distance().y() * fy / 0.001 < 1.0 && scale->velocity().y() * fy / 0.05 < 1.0) { // Hide tiny oscillations motion->scale.finish(); ++stopped; @@ -1404,7 +1397,7 @@ void WindowMotionManager::calculate(int time) void WindowMotionManager::reset() { - QHash::iterator it = m_managedWindows.begin(); + QHash::iterator it = m_managedWindows.begin(); for (; it != m_managedWindows.end(); ++it) { WindowMotion *motion = &it.value(); EffectWindow *window = it.key(); @@ -1417,7 +1410,7 @@ void WindowMotionManager::reset() void WindowMotionManager::reset(EffectWindow *w) { - QHash::iterator it = m_managedWindows.find(w); + QHash::iterator it = m_managedWindows.find(w); if (it == m_managedWindows.end()) return; @@ -1430,7 +1423,7 @@ void WindowMotionManager::reset(EffectWindow *w) void WindowMotionManager::apply(EffectWindow *w, WindowPaintData &data) { - QHash::iterator it = m_managedWindows.find(w); + QHash::iterator it = m_managedWindows.find(w); if (it == m_managedWindows.end()) return; @@ -1442,7 +1435,7 @@ void WindowMotionManager::apply(EffectWindow *w, WindowPaintData &data) void WindowMotionManager::moveWindow(EffectWindow *w, QPoint target, double scale, double yScale) { - QHash::iterator it = m_managedWindows.find(w); + QHash::iterator it = m_managedWindows.find(w); Q_ASSERT(it != m_managedWindows.end()); // Notify the effect author that they did something wrong WindowMotion *motion = &it.value(); @@ -1462,7 +1455,7 @@ void WindowMotionManager::moveWindow(EffectWindow *w, QPoint target, double scal QRectF WindowMotionManager::transformedGeometry(EffectWindow *w) const { - QHash::const_iterator it = m_managedWindows.constFind(w); + QHash::const_iterator it = m_managedWindows.constFind(w); if (it == m_managedWindows.end()) return w->frameGeometry(); @@ -1479,7 +1472,7 @@ QRectF WindowMotionManager::transformedGeometry(EffectWindow *w) const void WindowMotionManager::setTransformedGeometry(EffectWindow *w, const QRectF &geometry) { - QHash::iterator it = m_managedWindows.find(w); + QHash::iterator it = m_managedWindows.find(w); if (it == m_managedWindows.end()) return; WindowMotion *motion = &it.value(); @@ -1489,7 +1482,7 @@ void WindowMotionManager::setTransformedGeometry(EffectWindow *w, const QRectF & QRectF WindowMotionManager::targetGeometry(EffectWindow *w) const { - QHash::const_iterator it = m_managedWindows.constFind(w); + QHash::const_iterator it = m_managedWindows.constFind(w); if (it == m_managedWindows.end()) return w->frameGeometry(); @@ -1504,11 +1497,11 @@ QRectF WindowMotionManager::targetGeometry(EffectWindow *w) const return geometry; } -EffectWindow* WindowMotionManager::windowAtPoint(QPoint point, bool useStackingOrder) const +EffectWindow *WindowMotionManager::windowAtPoint(QPoint point, bool useStackingOrder) const { Q_UNUSED(useStackingOrder); // TODO: Stacking order uses EffectsHandler::stackingOrder() then filters by m_managedWindows - QHash< EffectWindow*, WindowMotion >::ConstIterator it = m_managedWindows.constBegin(); + QHash::ConstIterator it = m_managedWindows.constBegin(); while (it != m_managedWindows.constEnd()) { if (transformedGeometry(it.key()).contains(point)) return it.key(); @@ -1689,7 +1682,7 @@ void TimeLine::setDirection(TimeLine::Direction direction) d->direction = direction; if (d->elapsed > std::chrono::milliseconds::zero() - || d->sourceRedirectMode == RedirectMode::Strict) { + || d->sourceRedirectMode == RedirectMode::Strict) { d->elapsed = d->duration - d->elapsed; } @@ -1767,5 +1760,5 @@ TimeLine &TimeLine::operator=(const TimeLine &other) } // namespace -#include "moc_kwinglobals.cpp" #include "moc_kwineffects.cpp" +#include "moc_kwinglobals.cpp" diff --git a/src/libkwineffects/kwineffects.h b/src/libkwineffects/kwineffects.h index 42cc05e806..401987ce88 100644 --- a/src/libkwineffects/kwineffects.h +++ b/src/libkwineffects/kwineffects.h @@ -20,18 +20,18 @@ #include #include #include -#include #include #include +#include #include #include -#include -#include -#include #include -#include +#include +#include #include +#include +#include #include #include @@ -54,13 +54,15 @@ class QTabletEvent; */ Q_DECLARE_LOGGING_CATEGORY(KWINEFFECTS) -namespace KDecoration2 { +namespace KDecoration2 +{ class Decoration; } -namespace KWaylandServer { - class SurfaceInterface; - class Display; +namespace KWaylandServer +{ +class SurfaceInterface; +class Display; } namespace KWin @@ -84,9 +86,8 @@ class WindowPaintData; class ScreenPrePaintData; class ScreenPaintData; -typedef QPair< QString, Effect* > EffectPair; -typedef QList< KWin::EffectWindow* > EffectWindowList; - +typedef QPair EffectPair; +typedef QList EffectWindowList; /** @defgroup kwineffects KWin effects library * KWin effects library contains necessary classes for creating new KWin @@ -177,11 +178,11 @@ X-KDE-Library=kwin4_effect_cooleffect * @{ */ -#define KWIN_EFFECT_API_MAKE_VERSION( major, minor ) (( major ) << 8 | ( minor )) +#define KWIN_EFFECT_API_MAKE_VERSION(major, minor) ((major) << 8 | (minor)) #define KWIN_EFFECT_API_VERSION_MAJOR 0 #define KWIN_EFFECT_API_VERSION_MINOR 233 #define KWIN_EFFECT_API_VERSION KWIN_EFFECT_API_MAKE_VERSION( \ - KWIN_EFFECT_API_VERSION_MAJOR, KWIN_EFFECT_API_VERSION_MINOR ) + KWIN_EFFECT_API_VERSION_MAJOR, KWIN_EFFECT_API_VERSION_MINOR) /** * EffectWindow::setData() and EffectWindow::data() global roles. @@ -214,8 +215,7 @@ enum EffectFrameStyle { /** * Infinite region (i.e. a special region type saying that everything needs to be painted). */ -KWINEFFECTS_EXPORT inline -QRect infiniteRegion() +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); @@ -296,25 +296,25 @@ public: /** * Window (or at least part of it) will be painted opaque. */ - PAINT_WINDOW_OPAQUE = 1 << 0, + PAINT_WINDOW_OPAQUE = 1 << 0, /** * Window (or at least part of it) will be painted translucent. */ - PAINT_WINDOW_TRANSLUCENT = 1 << 1, + PAINT_WINDOW_TRANSLUCENT = 1 << 1, /** * Window will be painted with transformed geometry. */ - PAINT_WINDOW_TRANSFORMED = 1 << 2, + 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, + 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, + PAINT_SCREEN_TRANSFORMED = 1 << 4, /** * At least one window will be painted with transformed geometry. * Forces the entire screen to be painted. @@ -378,7 +378,7 @@ public: /** * Called when another effect requests the proxy for this effect. */ - virtual void* proxy(); + virtual void *proxy(); /** * Called before starting to paint the screen. @@ -406,7 +406,7 @@ public: * In OpenGL based compositing, the frameworks ensures that the context is current * when this method is invoked. */ - virtual void paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data); + virtual void paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data); /** * Called after all the painting has been finished. * In this method you can: @@ -444,7 +444,7 @@ public: * 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); + 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: @@ -454,7 +454,7 @@ public: * In OpenGL based compositing, the frameworks ensures that the context is current * when this method is invoked. */ - virtual void postPaintWindow(EffectWindow* w); + virtual void postPaintWindow(EffectWindow *w); /** * This method is called directly before painting an @ref EffectFrame. @@ -469,7 +469,7 @@ public: * In OpenGL based compositing, the frameworks ensures that the context is current * when this method is invoked. */ - virtual void paintEffectFrame(EffectFrame* frame, const QRegion ®ion, double opacity, double frameOpacity); + virtual void paintEffectFrame(EffectFrame *frame, const QRegion ®ion, double opacity, double frameOpacity); /** * Called on Transparent resizes. @@ -498,10 +498,10 @@ public: * In OpenGL based compositing, the frameworks ensures that the context is current * when this method is invoked. */ - virtual void drawWindow(EffectWindow* w, int mask, const QRegion ®ion, WindowPaintData& data); + virtual void drawWindow(EffectWindow *w, int mask, const QRegion ®ion, WindowPaintData &data); - virtual void windowInputMouseEvent(QEvent* e); - virtual void grabbedKeyboardEvent(QKeyEvent* e); + virtual void windowInputMouseEvent(QEvent *e); + virtual void grabbedKeyboardEvent(QKeyEvent *e); /** * Overwrite this method to indicate whether your effect will be doing something in @@ -547,7 +547,6 @@ public: */ virtual int requestedEffectChainPosition() const; - /** * A touch point was pressed. * @@ -678,7 +677,7 @@ public: * @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); + 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. @@ -688,21 +687,22 @@ public: * @overload Use this variant if animation time is provided through a KConfigXT generated class * having a property called "duration". */ - template + 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) { + 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); + static void setPositionTransformations(WindowPaintData &data, QRect ®ion, EffectWindow *w, + const QRect &r, Qt::AspectRatioMode aspect); /** * overwrite this method to return false if your effect does not need to be drawn over opaque fullscreen windows @@ -721,11 +721,10 @@ protected: * This method will perform the instance on the class. * @since 5.9 */ - template + template void initConfig(); }; - /** * Prefer the KWIN_EFFECT_FACTORY macros. */ @@ -784,36 +783,38 @@ public: * @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(className, jsonFile, supported, enabled ) \ - class KWIN_PLUGIN_FACTORY_NAME : public KWin::EffectPluginFactory \ - { \ - Q_OBJECT \ - Q_PLUGIN_METADATA(IID EffectPluginFactory_iid FILE jsonFile) \ - Q_INTERFACES(KPluginFactory) \ - public: \ - explicit KWIN_PLUGIN_FACTORY_NAME() {} \ - ~KWIN_PLUGIN_FACTORY_NAME() {} \ - bool isSupported() const override { \ - supported \ - } \ - bool enabledByDefault() const override { \ - enabled \ - } \ - KWin::Effect *createEffect() const override { \ - return new className(); \ - } \ +#define KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED(className, jsonFile, supported, enabled) \ + class KWIN_PLUGIN_FACTORY_NAME : public KWin::EffectPluginFactory \ + { \ + Q_OBJECT \ + Q_PLUGIN_METADATA(IID EffectPluginFactory_iid FILE jsonFile) \ + Q_INTERFACES(KPluginFactory) \ + public: \ + explicit KWIN_PLUGIN_FACTORY_NAME() \ + { \ + } \ + ~KWIN_PLUGIN_FACTORY_NAME() \ + { \ + } \ + bool isSupported() const override \ + { \ + supported \ + } \ + bool enabledByDefault() const override{ \ + enabled} KWin::Effect *createEffect() const override \ + { \ + return new className(); \ + } \ }; -#define KWIN_EFFECT_FACTORY_ENABLED(className, jsonFile, enabled ) \ - KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED(className, jsonFile, return true;, enabled ) - -#define KWIN_EFFECT_FACTORY_SUPPORTED(className, jsonFile, supported ) \ - KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED(className, jsonFile, supported, return true; ) - -#define KWIN_EFFECT_FACTORY(className, jsonFile ) \ - KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED(className, jsonFile, return true;, return true; ) +#define KWIN_EFFECT_FACTORY_ENABLED(className, jsonFile, enabled) \ + KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED(className, jsonFile, return true;, enabled) +#define KWIN_EFFECT_FACTORY_SUPPORTED(className, jsonFile, supported) \ + KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED(className, jsonFile, supported, return true;) +#define KWIN_EFFECT_FACTORY(className, jsonFile) \ + KWIN_EFFECT_FACTORY_SUPPORTED_ENABLED(className, jsonFile, return true;, return true;) /** * @short Manager class that handles all the effects. @@ -870,20 +871,21 @@ class KWINEFFECTS_EXPORT EffectsHandler : public QObject Q_PROPERTY(KWin::EffectWindow *inputPanel READ inputPanel NOTIFY inputPanelChanged) friend class Effect; + public: - using TouchBorderCallback = std::function; + using TouchBorderCallback = std::function; explicit EffectsHandler(CompositingType type); ~EffectsHandler() override; // for use by effects - virtual void prePaintScreen(ScreenPrePaintData& data, std::chrono::milliseconds presentTime) = 0; - virtual void paintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) = 0; + virtual void prePaintScreen(ScreenPrePaintData &data, std::chrono::milliseconds presentTime) = 0; + virtual void paintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) = 0; virtual void postPaintScreen() = 0; - virtual void prePaintWindow(EffectWindow* w, WindowPrePaintData& data, std::chrono::milliseconds presentTime) = 0; - virtual void paintWindow(EffectWindow* w, int mask, const QRegion ®ion, WindowPaintData& data) = 0; - virtual void postPaintWindow(EffectWindow* w) = 0; - virtual void paintEffectFrame(EffectFrame* frame, const QRegion ®ion, double opacity, double frameOpacity) = 0; - virtual void drawWindow(EffectWindow* w, int mask, const QRegion ®ion, WindowPaintData& data) = 0; + virtual void prePaintWindow(EffectWindow *w, WindowPrePaintData &data, std::chrono::milliseconds presentTime) = 0; + virtual void paintWindow(EffectWindow *w, int mask, const QRegion ®ion, WindowPaintData &data) = 0; + virtual void postPaintWindow(EffectWindow *w) = 0; + virtual void paintEffectFrame(EffectFrame *frame, const QRegion ®ion, double opacity, double frameOpacity) = 0; + virtual void drawWindow(EffectWindow *w, int mask, const QRegion ®ion, WindowPaintData &data) = 0; virtual QVariant kwinOption(KWinOption kwopt) = 0; /** * Sets the cursor while the mouse is intercepted. @@ -892,7 +894,7 @@ public: */ virtual void defineCursor(Qt::CursorShape shape) = 0; virtual QPoint cursorPos() const = 0; - virtual bool grabKeyboard(Effect* effect) = 0; + virtual bool grabKeyboard(Effect *effect) = 0; virtual void ungrabKeyboard() = 0; /** * Ensures that all mouse events are sent to the @p effect. @@ -949,16 +951,16 @@ public: */ virtual void registerTouchpadSwipeShortcut(SwipeDirection direction, uint fingerCount, QAction *action) = 0; - virtual void registerRealtimeTouchpadSwipeShortcut(SwipeDirection dir, uint fingerCount, QAction* onUp, std::function progressCallback) = 0; + virtual void registerRealtimeTouchpadSwipeShortcut(SwipeDirection dir, uint fingerCount, QAction *onUp, std::function progressCallback) = 0; - virtual void registerRealtimeTouchpadPinchShortcut(PinchDirection dir, uint fingerCount, QAction* onUp, std::function progressCallback) = 0; + virtual void registerRealtimeTouchpadPinchShortcut(PinchDirection dir, uint fingerCount, QAction *onUp, std::function progressCallback) = 0; virtual void registerTouchpadPinchShortcut(PinchDirection direction, uint fingerCount, 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; + virtual void *getProxy(QString name) = 0; // Mouse polling virtual void startMousePolling() = 0; @@ -1009,15 +1011,15 @@ public: 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; + 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; + Q_SCRIPTABLE virtual void windowToDesktop(KWin::EffectWindow *w, int desktop) = 0; /** * Moves a window to the given desktops @@ -1026,9 +1028,9 @@ public: * * @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 windowToDesktops(KWin::EffectWindow *w, const QVector &desktopIds) = 0; - Q_SCRIPTABLE virtual void windowToScreen(KWin::EffectWindow* w, EffectScreen *screen) = 0; + Q_SCRIPTABLE virtual void windowToScreen(KWin::EffectWindow *w, EffectScreen *screen) = 0; virtual void setShowingDesktop(bool showing) = 0; // Activities @@ -1111,8 +1113,8 @@ public: virtual EffectScreen *activeScreen() const = 0; // Xinerama virtual QRect clientArea(clientAreaOption, const EffectScreen *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; + 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 @@ -1141,8 +1143,8 @@ public: */ virtual double animationTimeFactor() const = 0; - Q_SCRIPTABLE virtual KWin::EffectWindow* findWindow(WId id) const = 0; - Q_SCRIPTABLE virtual KWin::EffectWindow* findWindow(KWaylandServer::SurfaceInterface *surf) const = 0; + Q_SCRIPTABLE virtual KWin::EffectWindow *findWindow(WId id) const = 0; + Q_SCRIPTABLE virtual KWin::EffectWindow *findWindow(KWaylandServer::SurfaceInterface *surf) const = 0; /** * Finds the EffectWindow for the internal window @p w. * If there is no such window @c null is returned. @@ -1162,20 +1164,20 @@ public: 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; + Q_SCRIPTABLE virtual void setElevatedWindow(KWin::EffectWindow *w, bool set) = 0; - virtual void setTabBoxWindow(EffectWindow*) = 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 QList currentTabBoxDesktopList() const = 0; virtual int currentTabBoxDesktop() const = 0; - virtual EffectWindow* currentTabBoxWindow() const = 0; + virtual EffectWindow *currentTabBoxWindow() const = 0; - virtual void setActiveFullScreenEffect(Effect* e) = 0; - virtual Effect* activeFullScreenEffect() const = 0; + virtual void setActiveFullScreenEffect(Effect *e) = 0; + virtual Effect *activeFullScreenEffect() const = 0; /** * Schedules the entire workspace to be repainted next time. @@ -1183,8 +1185,8 @@ public: * 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(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; @@ -1257,8 +1259,8 @@ public: * 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; + 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. @@ -1358,7 +1360,7 @@ public: * @param callback The function to invoke once the interactive window selection ends * @since 5.9 */ - virtual void startInteractiveWindowSelection(std::function callback) = 0; + virtual void startInteractiveWindowSelection(std::function callback) = 0; /** * Starts an interactive position selection process. @@ -1508,11 +1510,11 @@ Q_SIGNALS: */ 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 - */ + * 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 desktop showing ("dashboard") state changed @@ -1706,10 +1708,10 @@ Q_SIGNALS: * @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 + 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. @@ -1723,9 +1725,9 @@ Q_SIGNALS: * @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); + 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 @@ -1742,7 +1744,7 @@ Q_SIGNALS: * @param atom The property * @since 4.7 */ - void propertyNotify(KWin::EffectWindow* w, long atom); + void propertyNotify(KWin::EffectWindow *w, long atom); /** * This signal is emitted when the global @@ -1928,8 +1930,8 @@ Q_SIGNALS: void inputPanelChanged(); protected: - QVector< EffectPair > loaded_effects; - //QHash< QString, EffectFactory* > effect_factories; + QVector loaded_effects; + // QHash< QString, EffectFactory* > effect_factories; CompositingType compositing_type; }; @@ -1961,7 +1963,6 @@ public: */ virtual QRect geometry() const = 0; - enum class Transform { Normal, Rotated90, @@ -2310,17 +2311,17 @@ public: /** Flags explaining why painting should be disabled */ enum { /** Window will not be painted */ - PAINT_DISABLED = 1 << 0, + PAINT_DISABLED = 1 << 0, /** Window will not be painted because it is deleted */ - PAINT_DISABLED_BY_DELETE = 1 << 1, + PAINT_DISABLED_BY_DELETE = 1 << 1, /** Window will not be painted because of which desktop it's on */ - PAINT_DISABLED_BY_DESKTOP = 1 << 2, + PAINT_DISABLED_BY_DESKTOP = 1 << 2, /** Window will not be painted because it is minimized */ - PAINT_DISABLED_BY_MINIMIZE = 1 << 3, + PAINT_DISABLED_BY_MINIMIZE = 1 << 3, /** Deprecated, tab groups have been removed: 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 + PAINT_DISABLED_BY_ACTIVITY = 1 << 5 }; explicit EffectWindow(QObject *parent = nullptr); @@ -2442,7 +2443,7 @@ public: virtual QIcon icon() const = 0; virtual QString windowClass() const = 0; virtual QString windowRole() const = 0; - virtual const EffectWindowGroup* group() const = 0; + virtual const EffectWindowGroup *group() const = 0; /** * Returns whether the window is a desktop background window (the one with wallpaper). @@ -2557,8 +2558,8 @@ public: virtual bool keepBelow() const = 0; virtual bool isModal() const = 0; - Q_SCRIPTABLE virtual KWin::EffectWindow* findModal() = 0; - Q_SCRIPTABLE virtual KWin::EffectWindow* transientFor() = 0; + Q_SCRIPTABLE virtual KWin::EffectWindow *findModal() = 0; + Q_SCRIPTABLE virtual KWin::EffectWindow *transientFor() = 0; Q_SCRIPTABLE virtual KWin::EffectWindowList mainWindows() const = 0; /** @@ -2690,7 +2691,6 @@ public: virtual EffectWindowList members() const = 0; }; - struct GLVertex2D { QVector2D position; @@ -2703,7 +2703,6 @@ struct GLVertex3D QVector2D texcoord; }; - /** * @short Vertex class * @@ -2717,10 +2716,22 @@ public: 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 x() const + { + return px; + } + double y() const + { + return py; + } + double u() const + { + return tx; + } + double v() const + { + return ty; + } void move(double x, double y); void setX(double x); void setY(double y); @@ -2743,15 +2754,16 @@ class KWINEFFECTS_EXPORT WindowQuad public: WindowQuad(); WindowQuad makeSubQuad(double x1, double y1, double x2, double y2) const; - WindowVertex& operator[](int index); - const WindowVertex& operator[](int index) const; + WindowVertex &operator[](int index); + const WindowVertex &operator[](int index) const; double left() const; double right() const; double top() const; double bottom() const; + private: friend class WindowQuadList; - WindowVertex verts[ 4 ]; + WindowVertex verts[4]; }; class KWINEFFECTS_EXPORT WindowQuadList @@ -2763,7 +2775,7 @@ public: WindowQuadList makeGrid(int maxquadsize) const; WindowQuadList makeRegularGrid(int xSubdivisions, int ySubdivisions) const; void makeInterleavedArrays(unsigned int type, GLVertex2D *vertices, const QMatrix4x4 &matrix) const; - void makeArrays(float** vertices, float** texcoords, const QSizeF &size, bool yInverted) const; + void makeArrays(float **vertices, float **texcoords, const QSizeF &size, bool yInverted) const; }; class KWINEFFECTS_EXPORT WindowPrePaintData @@ -2948,14 +2960,14 @@ protected: PaintData(const PaintData &other); private: - PaintDataPrivate * const d; + PaintDataPrivate *const d; }; class KWINEFFECTS_EXPORT WindowPaintData : public PaintData { public: - explicit WindowPaintData(EffectWindow* w); - explicit WindowPaintData(EffectWindow* w, const QMatrix4x4 &screenProjectionMatrix); + explicit WindowPaintData(EffectWindow *w); + explicit WindowPaintData(EffectWindow *w, const QMatrix4x4 &screenProjectionMatrix); WindowPaintData(const WindowPaintData &other); ~WindowPaintData() override; /** @@ -2963,42 +2975,42 @@ public: * Multiplies all three components by the given factor. * @since 4.10 */ - WindowPaintData& operator*=(qreal scale); + 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); + 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); + 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); + 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); + 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); + 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); + WindowPaintData &operator+=(const QVector3D &translation); /** * Window opacity, in range 0 = transparent to 1 = fully opaque * @see setOpacity @@ -3143,10 +3155,10 @@ public: /** * Shader to be used for rendering, if any. */ - GLShader* shader; + GLShader *shader; private: - WindowPaintDataPrivate * const d; + WindowPaintDataPrivate *const d; }; class KWINEFFECTS_EXPORT ScreenPaintData : public PaintData @@ -3161,43 +3173,43 @@ public: * Multiplies all three components by the given factor. * @since 4.10 */ - ScreenPaintData& operator*=(qreal scale); + 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); + 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); + 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); + 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); + 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); + 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); + ScreenPaintData &operator+=(const QVector3D &translation); + ScreenPaintData &operator=(const ScreenPaintData &rhs); /** * The projection matrix used by the scene for the current rendering pass. @@ -3227,7 +3239,7 @@ public: /** * @internal */ -template +template class KWINEFFECTS_EXPORT Motion { public: @@ -3245,46 +3257,58 @@ public: Motion(const Motion &other); ~Motion(); - inline T value() const { + inline T value() const + { return m_value; } - inline void setValue(const T value) { + inline void setValue(const T value) + { m_value = value; } - inline T target() const { + inline T target() const + { return m_target; } - inline void setTarget(const T target) { + inline void setTarget(const T target) + { m_start = m_value; m_target = target; } - inline T velocity() const { + inline T velocity() const + { return m_velocity; } - inline void setVelocity(const T velocity) { + inline void setVelocity(const T velocity) + { m_velocity = velocity; } - inline double strength() const { + inline double strength() const + { return m_strength; } - inline void setStrength(const double strength) { + inline void setStrength(const double strength) + { m_strength = strength; } - inline double smoothness() const { + inline double smoothness() const + { return m_smoothness; } - inline void setSmoothness(const double smoothness) { + inline void setSmoothness(const double smoothness) + { m_smoothness = smoothness; } - inline T startValue() { + inline T startValue() + { return m_start; } /** * The distance between the current position and the target. */ - inline T distance() const { + inline T distance() const + { return m_target - m_value; } @@ -3366,7 +3390,8 @@ public: /** * Register a list of windows for managing. */ - inline void manage(const EffectWindowList &list) { + inline void manage(const EffectWindowList &list) + { for (int i = 0; i < list.size(); i++) manage(list.at(i)); } @@ -3420,7 +3445,8 @@ public: * Ask the manager to move the window to the target rectangle. * Automatically determines scale. */ - inline void moveWindow(EffectWindow *w, QRect target) { + 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())); @@ -3448,26 +3474,29 @@ public: * order as it's what the user sees, but it is slightly * slower to process. */ - EffectWindow* windowAtPoint(QPoint point, bool useStackingOrder = true) const; + EffectWindow *windowAtPoint(QPoint point, bool useStackingOrder = true) const; /** * Return a list of all currently registered windows. */ - inline EffectWindowList managedWindows() const { + 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 { + 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 { + inline bool managingWindows() const + { return !m_managedWindows.empty(); } /** @@ -3475,26 +3504,29 @@ public: * or not. Can be used to see if an effect should be * processed and displayed or not. */ - inline bool areWindowsMoving() const { + 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 { + inline bool isWindowMoving(EffectWindow *w) const + { return m_movingWindowsSet.contains(w); } private: bool m_useGlobalAnimationModifier; - struct WindowMotion { + struct WindowMotion + { // TODO: Rotation, etc? Motion2D translation; // Absolute position Motion2D scale; // xScale and yScale }; - QHash m_managedWindows; - QSet m_movingWindowsSet; + QHash m_managedWindows; + QSet m_movingWindowsSet; }; /** @@ -3522,43 +3554,43 @@ public: */ virtual void render(const QRegion ®ion = infiniteRegion(), double opacity = 1.0, double frameOpacity = 1.0) = 0; - virtual void setPosition(const QPoint& point) = 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 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; + 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; + 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; + virtual void setSelection(const QRect &selection) = 0; /** * @param shader The GLShader for rendering. */ - virtual void setShader(GLShader* shader) = 0; + virtual void setShader(GLShader *shader) = 0; /** * @returns The GLShader used for rendering or null if none. */ - virtual GLShader* shader() const = 0; + virtual GLShader *shader() const = 0; /** * @returns The style of this EffectFrame. @@ -3620,7 +3652,7 @@ protected: void setScreenProjectionMatrix(const QMatrix4x4 &projection); private: - EffectFramePrivate* const d; + EffectFramePrivate *const d; }; /** @@ -3883,46 +3915,48 @@ private: /** * Pointer to the global EffectsHandler object. */ -extern KWINEFFECTS_EXPORT EffectsHandler* effects; +extern KWINEFFECTS_EXPORT EffectsHandler *effects; /*************************************************************** WindowVertex ***************************************************************/ -inline -WindowVertex::WindowVertex() - : px(0), py(0), tx(0), ty(0) +inline WindowVertex::WindowVertex() + : px(0) + , py(0) + , tx(0) + , ty(0) { } -inline -WindowVertex::WindowVertex(double _x, double _y, double _tx, double _ty) - : px(_x), py(_y), tx(_tx), ty(_ty) +inline WindowVertex::WindowVertex(double _x, double _y, double _tx, double _ty) + : px(_x) + , py(_y) + , tx(_tx) + , ty(_ty) { } - -inline -WindowVertex::WindowVertex(const QPointF &position, const QPointF &texturePosition) - : px(position.x()), py(position.y()), tx(texturePosition.x()), ty(texturePosition.y()) +inline WindowVertex::WindowVertex(const QPointF &position, const QPointF &texturePosition) + : px(position.x()) + , py(position.y()) + , tx(texturePosition.x()) + , ty(texturePosition.y()) { } -inline -void WindowVertex::move(double x, double y) +inline void WindowVertex::move(double x, double y) { px = x; py = y; } -inline -void WindowVertex::setX(double x) +inline void WindowVertex::setX(double x) { px = x; } -inline -void WindowVertex::setY(double y) +inline void WindowVertex::setY(double y) { py = y; } @@ -3931,84 +3965,77 @@ void WindowVertex::setY(double y) WindowQuad ***************************************************************/ -inline -WindowQuad::WindowQuad() +inline WindowQuad::WindowQuad() { } -inline -WindowVertex& WindowQuad::operator[](int index) +inline WindowVertex &WindowQuad::operator[](int index) { Q_ASSERT(index >= 0 && index < 4); - return verts[ index ]; + return verts[index]; } -inline -const WindowVertex& WindowQuad::operator[](int index) const +inline const WindowVertex &WindowQuad::operator[](int index) const { Q_ASSERT(index >= 0 && index < 4); - return verts[ index ]; + return verts[index]; } -inline -double WindowQuad::left() const +inline double WindowQuad::left() const { - return qMin(verts[ 0 ].px, qMin(verts[ 1 ].px, qMin(verts[ 2 ].px, verts[ 3 ].px))); + return qMin(verts[0].px, qMin(verts[1].px, qMin(verts[2].px, verts[3].px))); } -inline -double WindowQuad::right() const +inline double WindowQuad::right() const { - return qMax(verts[ 0 ].px, qMax(verts[ 1 ].px, qMax(verts[ 2 ].px, verts[ 3 ].px))); + return qMax(verts[0].px, qMax(verts[1].px, qMax(verts[2].px, verts[3].px))); } -inline -double WindowQuad::top() const +inline double WindowQuad::top() const { - return qMin(verts[ 0 ].py, qMin(verts[ 1 ].py, qMin(verts[ 2 ].py, verts[ 3 ].py))); + return qMin(verts[0].py, qMin(verts[1].py, qMin(verts[2].py, verts[3].py))); } -inline -double WindowQuad::bottom() const +inline double WindowQuad::bottom() const { - return qMax(verts[ 0 ].py, qMax(verts[ 1 ].py, qMax(verts[ 2 ].py, verts[ 3 ].py))); + return qMax(verts[0].py, qMax(verts[1].py, qMax(verts[2].py, verts[3].py))); } /*************************************************************** Motion ***************************************************************/ -template +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) + : m_value(initial) + , m_start(initial) + , m_target(initial) + , m_velocity() + , m_strength(strength) + , m_smoothness(smoothness) { } -template +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()) + : 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 +template Motion::~Motion() { } -template +template void Motion::calculate(const int msec) { - if (m_value == m_target && m_velocity == T()) // At target and not moving + if (m_value == m_target && m_velocity == T()) // At target and not moving return; // Poor man's time independent calculation @@ -4021,7 +4048,7 @@ void Motion::calculate(const int msec) } } -template +template void Motion::finish() { m_value = m_target; @@ -4031,20 +4058,20 @@ void Motion::finish() /*************************************************************** Effect ***************************************************************/ -template +template int Effect::animationTime(int defaultDuration) { return animationTime(T::duration() != 0 ? T::duration() : defaultDuration); } -template +template void Effect::initConfig() { T::instance(effects->config()); } } // namespace -Q_DECLARE_METATYPE(KWin::EffectWindow*) +Q_DECLARE_METATYPE(KWin::EffectWindow *) Q_DECLARE_METATYPE(KWin::EffectWindowList) Q_DECLARE_METATYPE(KWin::TimeLine) Q_DECLARE_METATYPE(KWin::TimeLine::Direction) diff --git a/src/libkwineffects/kwineglimagetexture.h b/src/libkwineffects/kwineglimagetexture.h index 2367c117f8..5f00005acb 100644 --- a/src/libkwineffects/kwineglimagetexture.h +++ b/src/libkwineffects/kwineglimagetexture.h @@ -9,8 +9,8 @@ #pragma once -#include #include +#include typedef void *EGLImageKHR; typedef void *EGLDisplay; @@ -31,4 +31,3 @@ private: }; } - diff --git a/src/libkwineffects/kwinglobals.h b/src/libkwineffects/kwinglobals.h index 178bef0fe6..3569790bbb 100644 --- a/src/libkwineffects/kwinglobals.h +++ b/src/libkwineffects/kwinglobals.h @@ -27,19 +27,19 @@ namespace KWin { KWIN_EXPORT Q_NAMESPACE -enum CompositingType { - NoCompositing = 0, - /** - * Used as a flag whether OpenGL based compositing is used. - * The flag is or-ed to the enum values of the specific OpenGL types. - * The actual Compositors use the or @c OpenGLCompositing - * flags. If you need to know whether OpenGL is used, either and the flag or - * use EffectsHandler::isOpenGLCompositing(). - */ - OpenGLCompositing = 1, - /* XRenderCompositing = 1<<1, */ - QPainterCompositing = 1<< 2, -}; + enum CompositingType { + NoCompositing = 0, + /** + * Used as a flag whether OpenGL based compositing is used. + * The flag is or-ed to the enum values of the specific OpenGL types. + * The actual Compositors use the or @c OpenGLCompositing + * flags. If you need to know whether OpenGL is used, either and the flag or + * use EffectsHandler::isOpenGLCompositing(). + */ + OpenGLCompositing = 1, + /* XRenderCompositing = 1<<1, */ + QPainterCompositing = 1 << 2, + }; enum OpenGLPlatformInterface { NoOpenGLPlatformInterface = 0, @@ -48,15 +48,15 @@ enum OpenGLPlatformInterface { }; enum clientAreaOption { - PlacementArea, // geometry where a window will be initially placed after being mapped - MovementArea, // ??? window movement snapping area? ignore struts - MaximizeArea, // geometry to which a window will be maximized - MaximizeFullArea, // like MaximizeArea, but ignore struts - used e.g. for topmenu - FullScreenArea, // area for fullscreen windows + PlacementArea, // geometry where a window will be initially placed after being mapped + MovementArea, // ??? window movement snapping area? ignore struts + MaximizeArea, // geometry to which a window will be maximized + MaximizeFullArea, // like MaximizeArea, but ignore struts - used e.g. for topmenu + FullScreenArea, // area for fullscreen windows // these below don't depend on xinerama settings - WorkArea, // whole workarea (all screens together) - FullArea, // whole area (all screens together), ignore struts - ScreenArea, // one whole screen, ignore struts + WorkArea, // whole workarea (all screens together) + FullArea, // whole area (all screens together), ignore struts + ScreenArea, // one whole screen, ignore struts }; enum ElectricBorder { @@ -78,10 +78,10 @@ Q_ENUM_NS(ElectricBorder) // such as "only when moving windows" desktop switching that the current global action // system doesn't support. enum ElectricBorderAction { - ElectricActionNone, // No special action, not set, desktop switch or an effect - ElectricActionShowDesktop, // Show desktop or restore - ElectricActionLockScreen, // Lock screen - ElectricActionKRunner, // Open KRunner + ElectricActionNone, // No special action, not set, desktop switch or an effect + ElectricActionShowDesktop, // Show desktop or restore + ElectricActionLockScreen, // Lock screen + ElectricActionKRunner, // Open KRunner ElectricActionActivityManager, // Activity Manager ElectricActionApplicationLauncher, // Application Launcher ELECTRIC_ACTION_COUNT, @@ -91,12 +91,12 @@ enum ElectricBorderAction { // or window were viewed. // DesktopListMode lists them in the order created. enum TabBoxMode { - TabBoxDesktopMode, // Focus chain of desktops - TabBoxDesktopListMode, // Static desktop order - TabBoxWindowsMode, // Primary window switching mode - TabBoxWindowsAlternativeMode, // Secondary window switching mode - TabBoxCurrentAppWindowsMode, // Same as primary window switching mode but only for windows of current application - TabBoxCurrentAppWindowsAlternativeMode, // Same as secondary switching mode but only for windows of current application + TabBoxDesktopMode, // Focus chain of desktops + TabBoxDesktopListMode, // Static desktop order + TabBoxWindowsMode, // Primary window switching mode + TabBoxWindowsAlternativeMode, // Secondary window switching mode + TabBoxCurrentAppWindowsMode, // Same as primary window switching mode but only for windows of current application + TabBoxCurrentAppWindowsAlternativeMode, // Same as secondary switching mode but only for windows of current application }; enum KWinOption { @@ -166,20 +166,17 @@ enum class Gravity { BottomRight, }; -inline -KWIN_EXPORT xcb_connection_t *connection() +inline KWIN_EXPORT xcb_connection_t *connection() { - return reinterpret_cast(qApp->property("x11Connection").value()); + return reinterpret_cast(qApp->property("x11Connection").value()); } -inline -KWIN_EXPORT xcb_window_t rootWindow() +inline KWIN_EXPORT xcb_window_t rootWindow() { return qApp->property("x11RootWindow").value(); } -inline -KWIN_EXPORT xcb_timestamp_t xTime() +inline KWIN_EXPORT xcb_timestamp_t xTime() { return qApp->property("x11Time").value(); } @@ -188,7 +185,8 @@ KWIN_EXPORT xcb_timestamp_t xTime() * Short wrapper for a cursor image provided by the Platform. * @since 5.9 */ -class PlatformCursorImage { +class PlatformCursorImage +{ public: explicit PlatformCursorImage() : m_image() @@ -202,13 +200,16 @@ public: } virtual ~PlatformCursorImage() = default; - bool isNull() const { + bool isNull() const + { return m_image.isNull(); } - QImage image() const { + QImage image() const + { return m_image; } - QPoint hotSpot() const { + QPoint hotSpot() const + { return m_hotSpot; } @@ -222,24 +223,29 @@ private: Q_DECLARE_METATYPE(std::chrono::nanoseconds) #define KWIN_SINGLETON_VARIABLE(ClassName, variableName) \ -public: \ - static ClassName *create(QObject *parent = nullptr);\ - static ClassName *self() { return variableName; }\ -protected: \ - explicit ClassName(QObject *parent = nullptr); \ -private: \ +public: \ + static ClassName *create(QObject *parent = nullptr); \ + static ClassName *self() \ + { \ + return variableName; \ + } \ + \ +protected: \ + explicit ClassName(QObject *parent = nullptr); \ + \ +private: \ static ClassName *variableName; #define KWIN_SINGLETON(ClassName) KWIN_SINGLETON_VARIABLE(ClassName, s_self) #define KWIN_SINGLETON_FACTORY_VARIABLE_FACTORED(ClassName, FactoredClassName, variableName) \ -ClassName *ClassName::variableName = nullptr; \ -ClassName *ClassName::create(QObject *parent) \ -{ \ - Q_ASSERT(!variableName); \ - variableName = new FactoredClassName(parent); \ - return variableName; \ -} + ClassName *ClassName::variableName = nullptr; \ + ClassName *ClassName::create(QObject *parent) \ + { \ + Q_ASSERT(!variableName); \ + variableName = new FactoredClassName(parent); \ + return variableName; \ + } #define KWIN_SINGLETON_FACTORY_VARIABLE(ClassName, variableName) KWIN_SINGLETON_FACTORY_VARIABLE_FACTORED(ClassName, ClassName, variableName) #define KWIN_SINGLETON_FACTORY_FACTORED(ClassName, FactoredClassName) KWIN_SINGLETON_FACTORY_VARIABLE_FACTORED(ClassName, FactoredClassName, s_self) #define KWIN_SINGLETON_FACTORY(ClassName) KWIN_SINGLETON_FACTORY_VARIABLE(ClassName, s_self) diff --git a/src/libkwineffects/kwinglplatform.cpp b/src/libkwineffects/kwinglplatform.cpp index 858d7b1d40..b5c27e4273 100644 --- a/src/libkwineffects/kwinglplatform.cpp +++ b/src/libkwineffects/kwinglplatform.cpp @@ -13,16 +13,16 @@ #include "kwinglutils_funcs.h" #include -#include -#include #include #include +#include +#include #include -#include #include #include +#include namespace KWin { @@ -41,7 +41,7 @@ static qint64 parseVersionString(const QByteArray &version) while (end < version.length() && (version[end] == '.' || QChar::fromLatin1(version[end]).isDigit())) end++; - const QByteArray result = version.mid(start, end-start); + const QByteArray result = version.mid(start, end - start); const QList tokens = result.split('.'); const qint64 major = tokens.at(0).toInt(); const qint64 minor = tokens.count() > 1 ? tokens.at(1).toInt() : 0; @@ -63,8 +63,8 @@ static qint64 getXServerVersion() if (vendorName.contains("X.Org")) { const int release = setup->release_number; major = (release / 10000000); - minor = (release / 100000) % 100; - patch = (release / 1000) % 100; + minor = (release / 100000) % 100; + patch = (release / 1000) % 100; } } @@ -97,128 +97,128 @@ static ChipClass detectRadeonClass(const QByteArray &chipset) if (chipset.isEmpty()) return UnknownRadeon; - if (chipset.contains("R100") || - chipset.contains("RV100") || - chipset.contains("RS100")) + if (chipset.contains("R100") + || chipset.contains("RV100") + || chipset.contains("RS100")) return R100; - if (chipset.contains("RV200") || - chipset.contains("RS200") || - chipset.contains("R200") || - chipset.contains("RV250") || - chipset.contains("RS300") || - chipset.contains("RV280")) + if (chipset.contains("RV200") + || chipset.contains("RS200") + || chipset.contains("R200") + || chipset.contains("RV250") + || chipset.contains("RS300") + || chipset.contains("RV280")) return R200; - if (chipset.contains("R300") || - chipset.contains("R350") || - chipset.contains("R360") || - chipset.contains("RV350") || - chipset.contains("RV370") || - chipset.contains("RV380")) + if (chipset.contains("R300") + || chipset.contains("R350") + || chipset.contains("R360") + || chipset.contains("RV350") + || chipset.contains("RV370") + || chipset.contains("RV380")) return R300; - if (chipset.contains("R420") || - chipset.contains("R423") || - chipset.contains("R430") || - chipset.contains("R480") || - chipset.contains("R481") || - chipset.contains("RV410") || - chipset.contains("RS400") || - chipset.contains("RC410") || - chipset.contains("RS480") || - chipset.contains("RS482") || - chipset.contains("RS600") || - chipset.contains("RS690") || - chipset.contains("RS740")) + if (chipset.contains("R420") + || chipset.contains("R423") + || chipset.contains("R430") + || chipset.contains("R480") + || chipset.contains("R481") + || chipset.contains("RV410") + || chipset.contains("RS400") + || chipset.contains("RC410") + || chipset.contains("RS480") + || chipset.contains("RS482") + || chipset.contains("RS600") + || chipset.contains("RS690") + || chipset.contains("RS740")) return R400; - if (chipset.contains("RV515") || - chipset.contains("R520") || - chipset.contains("RV530") || - chipset.contains("R580") || - chipset.contains("RV560") || - chipset.contains("RV570")) + if (chipset.contains("RV515") + || chipset.contains("R520") + || chipset.contains("RV530") + || chipset.contains("R580") + || chipset.contains("RV560") + || chipset.contains("RV570")) return R500; - if (chipset.contains("R600") || - chipset.contains("RV610") || - chipset.contains("RV630") || - chipset.contains("RV670") || - chipset.contains("RV620") || - chipset.contains("RV635") || - chipset.contains("RS780") || - chipset.contains("RS880")) + if (chipset.contains("R600") + || chipset.contains("RV610") + || chipset.contains("RV630") + || chipset.contains("RV670") + || chipset.contains("RV620") + || chipset.contains("RV635") + || chipset.contains("RS780") + || chipset.contains("RS880")) return R600; - if (chipset.contains("R700") || - chipset.contains("RV770") || - chipset.contains("RV730") || - chipset.contains("RV710") || - chipset.contains("RV740")) + if (chipset.contains("R700") + || chipset.contains("RV770") + || chipset.contains("RV730") + || chipset.contains("RV710") + || chipset.contains("RV740")) return R700; - if (chipset.contains("EVERGREEN") || // Not an actual chipset, but returned by R600G in 7.9 - chipset.contains("CEDAR") || - chipset.contains("REDWOOD") || - chipset.contains("JUNIPER") || - chipset.contains("CYPRESS") || - chipset.contains("HEMLOCK") || - chipset.contains("PALM")) + if (chipset.contains("EVERGREEN") // Not an actual chipset, but returned by R600G in 7.9 + || chipset.contains("CEDAR") + || chipset.contains("REDWOOD") + || chipset.contains("JUNIPER") + || chipset.contains("CYPRESS") + || chipset.contains("HEMLOCK") + || chipset.contains("PALM")) return Evergreen; - if (chipset.contains("SUMO") || - chipset.contains("SUMO2") || - chipset.contains("BARTS") || - chipset.contains("TURKS") || - chipset.contains("CAICOS") || - chipset.contains("CAYMAN")) + if (chipset.contains("SUMO") + || chipset.contains("SUMO2") + || chipset.contains("BARTS") + || chipset.contains("TURKS") + || chipset.contains("CAICOS") + || chipset.contains("CAYMAN")) return NorthernIslands; - if (chipset.contains("TAHITI") || - chipset.contains("PITCAIRN") || - chipset.contains("VERDE") || - chipset.contains("OLAND") || - chipset.contains("HAINAN")) { + if (chipset.contains("TAHITI") + || chipset.contains("PITCAIRN") + || chipset.contains("VERDE") + || chipset.contains("OLAND") + || chipset.contains("HAINAN")) { return SouthernIslands; } - if (chipset.contains("BONAIRE") || - chipset.contains("KAVERI") || - chipset.contains("KABINI") || - chipset.contains("HAWAII") || - chipset.contains("MULLINS")) { + if (chipset.contains("BONAIRE") + || chipset.contains("KAVERI") + || chipset.contains("KABINI") + || chipset.contains("HAWAII") + || chipset.contains("MULLINS")) { return SeaIslands; } - if (chipset.contains("TONGA") || - chipset.contains("TOPAZ") || - chipset.contains("FIJI") || - chipset.contains("CARRIZO") || - chipset.contains("STONEY")) { + if (chipset.contains("TONGA") + || chipset.contains("TOPAZ") + || chipset.contains("FIJI") + || chipset.contains("CARRIZO") + || chipset.contains("STONEY")) { return VolcanicIslands; } - if (chipset.contains("POLARIS10") || - chipset.contains("POLARIS11") || - chipset.contains("POLARIS12") || - chipset.contains("VEGAM")) { + if (chipset.contains("POLARIS10") + || chipset.contains("POLARIS11") + || chipset.contains("POLARIS12") + || chipset.contains("VEGAM")) { return ArcticIslands; } - if (chipset.contains("VEGA10") || - chipset.contains("VEGA12") || - chipset.contains("VEGA20") || - chipset.contains("RAVEN") || - chipset.contains("RAVEN2") || - chipset.contains("RENOIR") || - chipset.contains("ARCTURUS")) { + if (chipset.contains("VEGA10") + || chipset.contains("VEGA12") + || chipset.contains("VEGA20") + || chipset.contains("RAVEN") + || chipset.contains("RAVEN2") + || chipset.contains("RENOIR") + || chipset.contains("ARCTURUS")) { return Vega; } - if (chipset.contains("NAVI10") || - chipset.contains("NAVI12") || - chipset.contains("NAVI14")) { + if (chipset.contains("NAVI10") + || chipset.contains("NAVI12") + || chipset.contains("NAVI14")) { return Navi; } @@ -226,19 +226,19 @@ static ChipClass detectRadeonClass(const QByteArray &chipset) QString name = extract(chipset16, QStringLiteral("HD [0-9]{4}")); // HD followed by a space and 4 digits if (!name.isEmpty()) { const int id = QStringView(name).right(4).toInt(); - if (id == 6250 || id == 6310) // Palm + if (id == 6250 || id == 6310) // Palm return Evergreen; if (id >= 6000 && id < 7000) - return NorthernIslands; // HD 6xxx + return NorthernIslands; // HD 6xxx if (id >= 5000 && id < 6000) - return Evergreen; // HD 5xxx + return Evergreen; // HD 5xxx if (id >= 4000 && id < 5000) - return R700; // HD 4xxx + return R700; // HD 4xxx - if (id >= 2000 && id < 4000) // HD 2xxx/3xxx + if (id >= 2000 && id < 4000) // HD 2xxx/3xxx return R600; return UnknownRadeon; @@ -292,7 +292,7 @@ static ChipClass detectNVidiaClass(const QString &chipset) if (!name.isEmpty()) { const int id = QStringView(chipset).mid(2, -1).toInt(nullptr, 16); // Strip the 'NV' from the id - switch(id & 0xf0) { + switch (id & 0xf0) { case 0x00: case 0x10: return NV10; @@ -325,11 +325,11 @@ static ChipClass detectNVidiaClass(const QString &chipset) return NV20; if (chipset.contains(QLatin1String("GeForce4"))) { - if (chipset.contains(QLatin1String("MX 420")) || - chipset.contains(QLatin1String("MX 440")) || // including MX 440SE - chipset.contains(QLatin1String("MX 460")) || - chipset.contains(QLatin1String("MX 4000")) || - chipset.contains(QLatin1String("PCX 4300"))) + if (chipset.contains(QLatin1String("MX 420")) + || chipset.contains(QLatin1String("MX 440")) // including MX 440SE + || chipset.contains(QLatin1String("MX 460")) + || chipset.contains(QLatin1String("MX 4000")) + || chipset.contains(QLatin1String("PCX 4300"))) return NV10; return NV20; @@ -381,37 +381,37 @@ static ChipClass detectIntelClass(const QByteArray &chipset) { // see mesa repository: src/mesa/drivers/dri/intel/intel_context.c // GL 1.3, DX8? SM ? - if (chipset.contains("845G") || - chipset.contains("830M") || - chipset.contains("852GM/855GM") || - chipset.contains("865G")) + if (chipset.contains("845G") + || chipset.contains("830M") + || chipset.contains("852GM/855GM") + || chipset.contains("865G")) return I8XX; // GL 1.4, DX 9.0, SM 2.0 - if (chipset.contains("915G") || - chipset.contains("E7221G") || - chipset.contains("915GM") || - chipset.contains("945G") || // DX 9.0c - chipset.contains("945GM") || - chipset.contains("945GME") || - chipset.contains("Q33") || // GL1.5 - chipset.contains("Q35") || - chipset.contains("G33") || - chipset.contains("965Q") || // GMA 3000, but apparently considered gen 4 by the driver - chipset.contains("946GZ") || // GMA 3000, but apparently considered gen 4 by the driver - chipset.contains("IGD")) + if (chipset.contains("915G") + || chipset.contains("E7221G") + || chipset.contains("915GM") + || chipset.contains("945G") // DX 9.0c + || chipset.contains("945GM") + || chipset.contains("945GME") + || chipset.contains("Q33") // GL1.5 + || chipset.contains("Q35") + || chipset.contains("G33") + || chipset.contains("965Q") // GMA 3000, but apparently considered gen 4 by the driver + || chipset.contains("946GZ") // GMA 3000, but apparently considered gen 4 by the driver + || chipset.contains("IGD")) return I915; // GL 2.0, DX 9.0c, SM 3.0 - if (chipset.contains("965G") || - chipset.contains("G45/G43") || // SM 4.0 - chipset.contains("965GM") || // GL 2.1 - chipset.contains("965GME/GLE") || - chipset.contains("GM45") || - chipset.contains("Q45/Q43") || - chipset.contains("G41") || - chipset.contains("B43") || - chipset.contains("Ironlake")) + if (chipset.contains("965G") + || chipset.contains("G45/G43") // SM 4.0 + || chipset.contains("965GM") // GL 2.1 + || chipset.contains("965GME/GLE") + || chipset.contains("GM45") + || chipset.contains("Q45/Q43") + || chipset.contains("G41") + || chipset.contains("B43") + || chipset.contains("Ironlake")) return I965; // GL 3.1, CL 1.1, DX 10.1 @@ -502,17 +502,13 @@ static ChipClass detectQualcommClass(const QByteArray &chipClass) static ChipClass detectPanfrostClass(const QByteArray &chipClass) { - if (chipClass.contains("T720") || - chipClass.contains("T760")) + if (chipClass.contains("T720") || chipClass.contains("T760")) return MaliT7XX; - if (chipClass.contains("T820") || - chipClass.contains("T860")) + if (chipClass.contains("T820") || chipClass.contains("T860")) return MaliT8XX; - if (chipClass.contains("G31") || - chipClass.contains("G52") || - chipClass.contains("G72")) + if (chipClass.contains("G31") || chipClass.contains("G52") || chipClass.contains("G72")) return MaliGXX; return UnknownPanfrost; @@ -541,7 +537,7 @@ QString GLPlatform::driverToString(Driver driver) } QByteArray GLPlatform::driverToString8(Driver driver) { - switch(driver) { + switch (driver) { case Driver_R100: return QByteArrayLiteral("Radeon"); case Driver_R200: @@ -592,7 +588,7 @@ QString GLPlatform::chipClassToString(ChipClass chipClass) } QByteArray GLPlatform::chipClassToString8(ChipClass chipClass) { - switch(chipClass) { + switch (chipClass) { case R100: return QByteArrayLiteral("R100"); case R200: @@ -699,33 +695,29 @@ QByteArray GLPlatform::chipClassToString8(ChipClass chipClass) } } - - // ------- - - GLPlatform::GLPlatform() - : m_driver(Driver_Unknown), - m_chipClass(UnknownChipClass), - m_recommendedCompositor(QPainterCompositing), - m_glVersion(0), - m_glslVersion(0), - m_mesaVersion(0), - m_driverVersion(0), - m_galliumVersion(0), - m_serverVersion(0), - m_kernelVersion(0), - m_looseBinding(false), - m_supportsGLSL(false), - m_limitedGLSL(false), - m_textureNPOT(false), - m_limitedNPOT(false), - m_packInvert(false), - m_virtualMachine(false), - m_preferBufferSubData(false), - m_platformInterface(NoOpenGLPlatformInterface), - m_gles(false) + : m_driver(Driver_Unknown) + , m_chipClass(UnknownChipClass) + , m_recommendedCompositor(QPainterCompositing) + , m_glVersion(0) + , m_glslVersion(0) + , m_mesaVersion(0) + , m_driverVersion(0) + , m_galliumVersion(0) + , m_serverVersion(0) + , m_kernelVersion(0) + , m_looseBinding(false) + , m_supportsGLSL(false) + , m_limitedGLSL(false) + , m_textureNPOT(false) + , m_limitedNPOT(false) + , m_packInvert(false) + , m_virtualMachine(false) + , m_preferBufferSubData(false) + , m_platformInterface(NoOpenGLPlatformInterface) + , m_gles(false) { } @@ -737,9 +729,9 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface) { m_platformInterface = platformInterface; - m_vendor = (const char*)glGetString(GL_VENDOR); - m_renderer = (const char*)glGetString(GL_RENDERER); - m_version = (const char*)glGetString(GL_VERSION); + m_vendor = (const char *)glGetString(GL_VENDOR); + m_renderer = (const char *)glGetString(GL_RENDERER); + m_version = (const char *)glGetString(GL_VERSION); // Parse the OpenGL version const QList versionTokens = m_version.split(' '); @@ -761,11 +753,11 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface) glGetIntegerv(GL_NUM_EXTENSIONS, &count); for (int i = 0; i < count; i++) { - const char *name = (const char *) glGetStringi(GL_EXTENSIONS, i); + const char *name = (const char *)glGetStringi(GL_EXTENSIONS, i); m_extensions.insert(name); } } else { - const QByteArray extensions = (const char *) glGetString(GL_EXTENSIONS); + const QByteArray extensions = (const char *)glGetString(GL_EXTENSIONS); QList extensionsList = extensions.split(' '); m_extensions = {extensionsList.constBegin(), extensionsList.constEnd()}; } @@ -781,9 +773,9 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface) m_supportsGLSL = true; m_textureNPOT = true; } else { - m_supportsGLSL = m_extensions.contains("GL_ARB_shader_objects") && - m_extensions.contains("GL_ARB_fragment_shader") && - m_extensions.contains("GL_ARB_vertex_shader"); + m_supportsGLSL = (m_extensions.contains("GL_ARB_shader_objects") + && m_extensions.contains("GL_ARB_fragment_shader") + && m_extensions.contains("GL_ARB_vertex_shader")); m_textureNPOT = m_extensions.contains("GL_ARB_texture_non_power_of_two"); } @@ -796,7 +788,7 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface) if (m_supportsGLSL) { // Parse the GLSL version - m_glsl_version = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION); + m_glsl_version = (const char *)glGetString(GL_SHADING_LANGUAGE_VERSION); m_glslVersion = parseVersionString(m_glsl_version); } @@ -804,7 +796,6 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface) m_preferBufferSubData = false; m_packInvert = m_extensions.contains("GL_MESA_pack_invert"); - // Mesa classic drivers // ==================================================== @@ -882,7 +873,7 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface) else if (m_renderer.contains("Panfrost")) { m_driver = Driver_Panfrost; m_chipClass = detectPanfrostClass(m_renderer); - } + } else if (m_renderer == "Software Rasterizer") { m_driver = Driver_Swrast; @@ -908,10 +899,8 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface) if (m_renderer.contains("Gallium")) { // Sample renderer string: Gallium 0.4 on AMD RV740 m_galliumVersion = parseVersionString(tokens.at(1)); - m_chipset = (tokens.at(3) == "AMD" || tokens.at(3) == "ATI") ? - tokens.at(4) : tokens.at(3); - } - else { + m_chipset = (tokens.at(3) == "AMD" || tokens.at(3) == "ATI") ? tokens.at(4) : tokens.at(3); + } else { // The renderer string does not contain "Gallium" anymore. m_chipset = tokens.at(0); // We don't know the actual version anymore, but it's at least 0.4. @@ -925,61 +914,13 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface) } // R600G - else if (m_vendor == "X.Org" && - (m_renderer.contains("R6") || - m_renderer.contains("R7") || - m_renderer.contains("RV6") || - m_renderer.contains("RV7") || - m_renderer.contains("RS780") || - m_renderer.contains("RS880") || - m_renderer.contains("CEDAR") || - m_renderer.contains("REDWOOD") || - m_renderer.contains("JUNIPER") || - m_renderer.contains("CYPRESS") || - m_renderer.contains("HEMLOCK") || - m_renderer.contains("PALM") || - m_renderer.contains("EVERGREEN") || - m_renderer.contains("SUMO") || - m_renderer.contains("SUMO2") || - m_renderer.contains("BARTS") || - m_renderer.contains("TURKS") || - m_renderer.contains("CAICOS") || - m_renderer.contains("CAYMAN"))) { + else if (m_vendor == "X.Org" && (m_renderer.contains("R6") || m_renderer.contains("R7") || m_renderer.contains("RV6") || m_renderer.contains("RV7") || m_renderer.contains("RS780") || m_renderer.contains("RS880") || m_renderer.contains("CEDAR") || m_renderer.contains("REDWOOD") || m_renderer.contains("JUNIPER") || m_renderer.contains("CYPRESS") || m_renderer.contains("HEMLOCK") || m_renderer.contains("PALM") || m_renderer.contains("EVERGREEN") || m_renderer.contains("SUMO") || m_renderer.contains("SUMO2") || m_renderer.contains("BARTS") || m_renderer.contains("TURKS") || m_renderer.contains("CAICOS") || m_renderer.contains("CAYMAN"))) { m_chipClass = detectRadeonClass(m_chipset); m_driver = Driver_R600G; } // RadeonSI - else if ((m_vendor == "X.Org" || m_vendor == "AMD") && - (m_renderer.contains("TAHITI") || - m_renderer.contains("PITCAIRN") || - m_renderer.contains("VERDE") || - m_renderer.contains("OLAND") || - m_renderer.contains("HAINAN") || - m_renderer.contains("BONAIRE") || - m_renderer.contains("KAVERI") || - m_renderer.contains("KABINI") || - m_renderer.contains("HAWAII") || - m_renderer.contains("MULLINS") || - m_renderer.contains("TOPAZ") || - m_renderer.contains("TONGA") || - m_renderer.contains("FIJI") || - m_renderer.contains("CARRIZO") || - m_renderer.contains("STONEY") || - m_renderer.contains("POLARIS10") || - m_renderer.contains("POLARIS11") || - m_renderer.contains("POLARIS12") || - m_renderer.contains("VEGAM") || - m_renderer.contains("VEGA10") || - m_renderer.contains("VEGA12") || - m_renderer.contains("VEGA20") || - m_renderer.contains("RAVEN") || - m_renderer.contains("RAVEN2") || - m_renderer.contains("RENOIR") || - m_renderer.contains("ARCTURUS") || - m_renderer.contains("NAVI10") || - m_renderer.contains("NAVI12") || - m_renderer.contains("NAVI14"))) { + else if ((m_vendor == "X.Org" || m_vendor == "AMD") && (m_renderer.contains("TAHITI") || m_renderer.contains("PITCAIRN") || m_renderer.contains("VERDE") || m_renderer.contains("OLAND") || m_renderer.contains("HAINAN") || m_renderer.contains("BONAIRE") || m_renderer.contains("KAVERI") || m_renderer.contains("KABINI") || m_renderer.contains("HAWAII") || m_renderer.contains("MULLINS") || m_renderer.contains("TOPAZ") || m_renderer.contains("TONGA") || m_renderer.contains("FIJI") || m_renderer.contains("CARRIZO") || m_renderer.contains("STONEY") || m_renderer.contains("POLARIS10") || m_renderer.contains("POLARIS11") || m_renderer.contains("POLARIS12") || m_renderer.contains("VEGAM") || m_renderer.contains("VEGA10") || m_renderer.contains("VEGA12") || m_renderer.contains("VEGA20") || m_renderer.contains("RAVEN") || m_renderer.contains("RAVEN2") || m_renderer.contains("RENOIR") || m_renderer.contains("ARCTURUS") || m_renderer.contains("NAVI10") || m_renderer.contains("NAVI12") || m_renderer.contains("NAVI14"))) { m_chipClass = detectRadeonClass(m_renderer); m_driver = Driver_RadeonSI; } @@ -1041,8 +982,7 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface) m_recommendedCompositor = OpenGLCompositing; } - if (driver() == Driver_R600G || - (driver() == Driver_R600C && m_renderer.contains("DRI2"))) { + if (driver() == Driver_R600G || (driver() == Driver_R600C && m_renderer.contains("DRI2"))) { m_looseBinding = true; } } @@ -1151,9 +1091,9 @@ static void print(const QByteArray &label, const QByteArray &setting) void GLPlatform::printResults() const { - print(QByteArrayLiteral("OpenGL vendor string:"), m_vendor); + print(QByteArrayLiteral("OpenGL vendor string:"), m_vendor); print(QByteArrayLiteral("OpenGL renderer string:"), m_renderer); - print(QByteArrayLiteral("OpenGL version string:"), m_version); + print(QByteArrayLiteral("OpenGL version string:"), m_version); if (m_supportsGLSL) print(QByteArrayLiteral("OpenGL shading language version string:"), m_glsl_version); @@ -1171,8 +1111,8 @@ void GLPlatform::printResults() const if (isMesaDriver()) print(QByteArrayLiteral("Mesa version:"), versionToString8(mesaVersion())); - //if (galliumVersion() > 0) - // print("Gallium version:", versionToString(m_galliumVersion)); + // if (galliumVersion() > 0) + // print("Gallium version:", versionToString(m_galliumVersion)); if (serverVersion() > 0) print(QByteArrayLiteral("X server version:"), versionToString8(m_serverVersion)); if (kernelVersion() > 0) @@ -1186,7 +1126,7 @@ void GLPlatform::printResults() const bool GLPlatform::supports(GLFeature feature) const { - switch(feature) { + switch (feature) { case LooseBinding: return m_looseBinding; @@ -1370,4 +1310,3 @@ void GLPlatform::cleanup() } } // namespace KWin - diff --git a/src/libkwineffects/kwinglplatform.h b/src/libkwineffects/kwinglplatform.h index f799eea83f..34aed63cbf 100644 --- a/src/libkwineffects/kwinglplatform.h +++ b/src/libkwineffects/kwinglplatform.h @@ -10,8 +10,8 @@ #ifndef KWIN_GLPLATFORM_H #define KWIN_GLPLATFORM_H -#include #include +#include #include #include @@ -80,7 +80,7 @@ enum GLFeature { }; enum Driver { - Driver_R100, // Technically "Radeon" + Driver_R100, // Technically "Radeon" Driver_R200, Driver_R300C, Driver_R300G, @@ -173,7 +173,6 @@ enum ChipClass { }; // clang-format on - class KWINGLUTILS_EXPORT GLPlatform { public: @@ -314,7 +313,7 @@ public: **/ bool isVirgl() const; - /** + /** * @returns @c true if the "GPU" is a Panfrost Mali GPU * @since 5.21.5 **/ @@ -444,16 +443,16 @@ private: qint64 m_galliumVersion; qint64 m_serverVersion; qint64 m_kernelVersion; - bool m_looseBinding: 1; - bool m_supportsGLSL: 1; - bool m_limitedGLSL: 1; - bool m_textureNPOT: 1; - bool m_limitedNPOT: 1; - bool m_packInvert: 1; - bool m_virtualMachine: 1; - bool m_preferBufferSubData: 1; + bool m_looseBinding : 1; + bool m_supportsGLSL : 1; + bool m_limitedGLSL : 1; + bool m_textureNPOT : 1; + bool m_limitedNPOT : 1; + bool m_packInvert : 1; + bool m_virtualMachine : 1; + bool m_preferBufferSubData : 1; OpenGLPlatformInterface m_platformInterface; - bool m_gles: 1; + bool m_gles : 1; static GLPlatform *s_platform; }; @@ -468,4 +467,3 @@ inline GLPlatform *GLPlatform::instance() } // namespace KWin #endif // KWIN_GLPLATFORM_H - diff --git a/src/libkwineffects/kwingltexture.cpp b/src/libkwineffects/kwingltexture.cpp index 8a44af34bf..ac874f5b42 100644 --- a/src/libkwineffects/kwingltexture.cpp +++ b/src/libkwineffects/kwingltexture.cpp @@ -12,13 +12,13 @@ #include "kwinconfig.h" // KWIN_HAVE_OPENGL #include "kwineffects.h" #include "kwinglplatform.h" -#include "kwinglutils_funcs.h" #include "kwinglutils.h" +#include "kwinglutils_funcs.h" #include "kwingltexture_p.h" -#include #include +#include #include #include #include @@ -44,41 +44,42 @@ uint GLTexturePrivate::s_fbo = 0; // // Note: Blending is set up to expect premultiplied data, so the non-premultiplied // Format_ARGB32 must be converted to Format_ARGB32_Premultiplied ahead of time. -struct { +struct +{ GLenum internalFormat; GLenum format; GLenum type; } static const formatTable[] = { - { 0, 0, 0 }, // QImage::Format_Invalid - { 0, 0, 0 }, // QImage::Format_Mono - { 0, 0, 0 }, // QImage::Format_MonoLSB - { 0, 0, 0 }, // QImage::Format_Indexed8 - { GL_RGB8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV }, // QImage::Format_RGB32 - { 0, 0, 0 }, // QImage::Format_ARGB32 - { GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV }, // QImage::Format_ARGB32_Premultiplied - { GL_RGB8, GL_BGR, GL_UNSIGNED_SHORT_5_6_5_REV }, // QImage::Format_RGB16 - { 0, 0, 0 }, // QImage::Format_ARGB8565_Premultiplied - { 0, 0, 0 }, // QImage::Format_RGB666 - { 0, 0, 0 }, // QImage::Format_ARGB6666_Premultiplied - { GL_RGB5, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV }, // QImage::Format_RGB555 - { 0, 0, 0 }, // QImage::Format_ARGB8555_Premultiplied - { GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE }, // QImage::Format_RGB888 - { GL_RGB4, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV }, // QImage::Format_RGB444 - { GL_RGBA4, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV }, // QImage::Format_ARGB4444_Premultiplied - { GL_RGB8, GL_RGBA, GL_UNSIGNED_BYTE }, // QImage::Format_RGBX8888 - { 0, 0, 0 }, // QImage::Format_RGBA8888 - { GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE }, // QImage::Format_RGBA8888_Premultiplied - { GL_RGB10, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV }, // QImage::Format_BGR30 - { GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV }, // QImage::Format_A2BGR30_Premultiplied - { GL_RGB10, GL_BGRA, GL_UNSIGNED_INT_2_10_10_10_REV }, // QImage::Format_RGB30 - { GL_RGB10_A2, GL_BGRA, GL_UNSIGNED_INT_2_10_10_10_REV }, // QImage::Format_A2RGB30_Premultiplied - { GL_R8, GL_RED, GL_UNSIGNED_BYTE }, // QImage::Format_Alpha8 - { GL_R8, GL_RED, GL_UNSIGNED_BYTE }, // QImage::Format_Grayscale8 - { GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT }, // QImage::Format_RGBX64 - { 0, 0, 0 }, // QImage::Format_RGBA64 - { GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT }, // QImage::Format_RGBA64_Premultiplied - { GL_R16, GL_RED, GL_UNSIGNED_SHORT }, // QImage::Format_Grayscale16 - { 0, 0, 0 }, // QImage::Format_BGR888 + {0, 0, 0}, // QImage::Format_Invalid + {0, 0, 0}, // QImage::Format_Mono + {0, 0, 0}, // QImage::Format_MonoLSB + {0, 0, 0}, // QImage::Format_Indexed8 + {GL_RGB8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV}, // QImage::Format_RGB32 + {0, 0, 0}, // QImage::Format_ARGB32 + {GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV}, // QImage::Format_ARGB32_Premultiplied + {GL_RGB8, GL_BGR, GL_UNSIGNED_SHORT_5_6_5_REV}, // QImage::Format_RGB16 + {0, 0, 0}, // QImage::Format_ARGB8565_Premultiplied + {0, 0, 0}, // QImage::Format_RGB666 + {0, 0, 0}, // QImage::Format_ARGB6666_Premultiplied + {GL_RGB5, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV}, // QImage::Format_RGB555 + {0, 0, 0}, // QImage::Format_ARGB8555_Premultiplied + {GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE}, // QImage::Format_RGB888 + {GL_RGB4, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV}, // QImage::Format_RGB444 + {GL_RGBA4, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV}, // QImage::Format_ARGB4444_Premultiplied + {GL_RGB8, GL_RGBA, GL_UNSIGNED_BYTE}, // QImage::Format_RGBX8888 + {0, 0, 0}, // QImage::Format_RGBA8888 + {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE}, // QImage::Format_RGBA8888_Premultiplied + {GL_RGB10, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV}, // QImage::Format_BGR30 + {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV}, // QImage::Format_A2BGR30_Premultiplied + {GL_RGB10, GL_BGRA, GL_UNSIGNED_INT_2_10_10_10_REV}, // QImage::Format_RGB30 + {GL_RGB10_A2, GL_BGRA, GL_UNSIGNED_INT_2_10_10_10_REV}, // QImage::Format_A2RGB30_Premultiplied + {GL_R8, GL_RED, GL_UNSIGNED_BYTE}, // QImage::Format_Alpha8 + {GL_R8, GL_RED, GL_UNSIGNED_BYTE}, // QImage::Format_Grayscale8 + {GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT}, // QImage::Format_RGBX64 + {0, 0, 0}, // QImage::Format_RGBA64 + {GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT}, // QImage::Format_RGBA64_Premultiplied + {GL_R16, GL_RED, GL_UNSIGNED_SHORT}, // QImage::Format_Grayscale16 + {0, 0, 0}, // QImage::Format_BGR888 }; GLTexture::GLTexture(GLenum target) @@ -88,17 +89,17 @@ GLTexture::GLTexture(GLenum target) d->m_target = target; } -GLTexture::GLTexture(GLTexturePrivate& dd) +GLTexture::GLTexture(GLTexturePrivate &dd) : d_ptr(&dd) { } -GLTexture::GLTexture(const GLTexture& tex) +GLTexture::GLTexture(const GLTexture &tex) : d_ptr(tex.d_ptr) { } -GLTexture::GLTexture(const QImage& image, GLenum target) +GLTexture::GLTexture(const QImage &image, GLenum target) : d_ptr(new GLTexturePrivate()) { Q_D(GLTexture); @@ -178,18 +179,18 @@ GLTexture::GLTexture(const QImage& image, GLenum target) setFilter(GL_LINEAR); } -GLTexture::GLTexture(const QPixmap& pixmap, GLenum target) +GLTexture::GLTexture(const QPixmap &pixmap, GLenum target) : GLTexture(pixmap.toImage(), target) { } -GLTexture::GLTexture(const QString& fileName) - : GLTexture(QImage(fileName)) +GLTexture::GLTexture(const QString &fileName) + : GLTexture(QImage(fileName)) { } GLTexture::GLTexture(GLenum internalFormat, int width, int height, int levels, bool needsMutability) - : d_ptr(new GLTexturePrivate()) + : d_ptr(new GLTexturePrivate()) { Q_D(GLTexture); @@ -269,29 +270,29 @@ bool GLTexture::create() return d->m_texture != GL_NONE; } -GLTexture& GLTexture::operator = (const GLTexture& tex) +GLTexture &GLTexture::operator=(const GLTexture &tex) { d_ptr = tex.d_ptr; return *this; } GLTexturePrivate::GLTexturePrivate() - : m_texture(0) - , m_target(0) - , m_internalFormat(0) - , m_filter(GL_NEAREST) - , m_wrapMode(GL_REPEAT) - , m_yInverted(false) - , m_canUseMipmaps(false) - , m_markedDirty(false) - , m_filterChanged(true) - , m_wrapModeChanged(false) - , m_immutable(false) - , m_foreign(false) - , m_mipLevels(1) - , m_unnormalizeActive(0) - , m_normalizeActive(0) - , m_vbo(nullptr) + : m_texture(0) + , m_target(0) + , m_internalFormat(0) + , m_filter(GL_NEAREST) + , m_wrapMode(GL_REPEAT) + , m_yInverted(false) + , m_canUseMipmaps(false) + , m_markedDirty(false) + , m_filterChanged(true) + , m_wrapModeChanged(false) + , m_immutable(false) + , m_foreign(false) + , m_mipLevels(1) + , m_unnormalizeActive(0) + , m_normalizeActive(0) + , m_vbo(nullptr) { } @@ -306,8 +307,7 @@ GLTexturePrivate::~GLTexturePrivate() void GLTexturePrivate::initStatic() { if (!GLPlatform::instance()->isGLES()) { - s_supportsFramebufferObjects = hasGLVersion(3, 0) || - hasGLExtension("GL_ARB_framebuffer_object") || hasGLExtension(QByteArrayLiteral("GL_EXT_framebuffer_object")); + s_supportsFramebufferObjects = hasGLVersion(3, 0) || hasGLExtension("GL_ARB_framebuffer_object") || hasGLExtension(QByteArrayLiteral("GL_EXT_framebuffer_object")); s_supportsTextureStorage = hasGLVersion(4, 2) || hasGLExtension(QByteArrayLiteral("GL_ARB_texture_storage")); s_supportsTextureSwizzle = hasGLVersion(3, 3) || hasGLExtension(QByteArrayLiteral("GL_ARB_texture_swizzle")); // see https://www.opengl.org/registry/specs/ARB/texture_rg.txt @@ -325,8 +325,7 @@ void GLTexturePrivate::initStatic() // QImage::Format_ARGB32_Premultiplied is a packed-pixel format, so it's only // equivalent to GL_BGRA/GL_UNSIGNED_BYTE on little-endian systems. - s_supportsARGB32 = QSysInfo::ByteOrder == QSysInfo::LittleEndian && - hasGLExtension(QByteArrayLiteral("GL_EXT_texture_format_BGRA8888")); + s_supportsARGB32 = QSysInfo::ByteOrder == QSysInfo::LittleEndian && hasGLExtension(QByteArrayLiteral("GL_EXT_texture_format_BGRA8888")); s_supportsUnpack = hasGLExtension(QByteArrayLiteral("GL_EXT_unpack_subimage")); } @@ -511,7 +510,7 @@ void GLTexture::render(const QRect &rect) render(infiniteRegion(), rect, false); } -void GLTexture::render(const QRegion ®ion, const QRect& rect, bool hardwareClipping) +void GLTexture::render(const QRegion ®ion, const QRect &rect, bool hardwareClipping) { Q_D(GLTexture); if (rect.isEmpty()) @@ -524,23 +523,21 @@ void GLTexture::render(const QRegion ®ion, const QRect& rect, bool hardwareCl d->m_vbo = new GLVertexBuffer(KWin::GLVertexBuffer::Static); } - const float verts[ 4 * 2 ] = { + const float verts[4 * 2] = { // NOTICE: r.x/y could be replaced by "0", but that would make it unreadable... static_cast(r.x()), static_cast(r.y()), static_cast(r.x()), static_cast(r.y() + rect.height()), static_cast(r.x() + rect.width()), static_cast(r.y()), - static_cast(r.x() + rect.width()), static_cast(r.y() + rect.height()) - }; + static_cast(r.x() + rect.width()), static_cast(r.y() + rect.height())}; const float texWidth = (target() == GL_TEXTURE_RECTANGLE_ARB) ? width() : 1.0f; const float texHeight = (target() == GL_TEXTURE_RECTANGLE_ARB) ? height() : 1.0f; - const float texcoords[ 4 * 2 ] = { + const float texcoords[4 * 2] = { 0.0f, d->m_yInverted ? 0.0f : texHeight, // y needs to be swapped (normalized coords) 0.0f, d->m_yInverted ? texHeight : 0.0f, texWidth, d->m_yInverted ? 0.0f : texHeight, - texWidth, d->m_yInverted ? texHeight : 0.0f - }; + texWidth, d->m_yInverted ? texHeight : 0.0f}; d->m_vbo->setData(4, 2, verts, texcoords); } @@ -575,8 +572,7 @@ void GLTexture::clear() { Q_D(GLTexture); Q_ASSERT(!d->m_foreign); - if (!GLTexturePrivate::s_fbo && GLRenderTarget::supported() && - GLPlatform::instance()->driver() != Driver_Catalyst) // fail. -> bug #323065 + if (!GLTexturePrivate::s_fbo && GLRenderTarget::supported() && GLPlatform::instance()->driver() != Driver_Catalyst) // fail. -> bug #323065 glGenFramebuffers(1, &GLTexturePrivate::s_fbo); if (GLTexturePrivate::s_fbo) { @@ -591,9 +587,9 @@ void GLTexture::clear() if (GLTexturePrivate::s_fbo != previousFramebuffer) glBindFramebuffer(GL_FRAMEBUFFER, previousFramebuffer); } else { - if (const int size = width()*height()) { + if (const int size = width() * height()) { uint32_t *buffer = new uint32_t[size]; - memset(buffer, 0, size*sizeof(uint32_t)); + memset(buffer, 0, size * sizeof(uint32_t)); bind(); if (!GLPlatform::instance()->isGLES()) { glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width(), height(), @@ -629,7 +625,7 @@ void GLTexture::setWrapMode(GLenum mode) Q_D(GLTexture); if (mode != d->m_wrapMode) { d->m_wrapMode = mode; - d->m_wrapModeChanged=true; + d->m_wrapModeChanged = true; } } @@ -684,8 +680,8 @@ void GLTexture::setSwizzle(GLenum red, GLenum green, GLenum blue, GLenum alpha) Q_D(GLTexture); if (!GLPlatform::instance()->isGLES()) { - const GLuint swizzle[] = { red, green, blue, alpha }; - glTexParameteriv(d->m_target, GL_TEXTURE_SWIZZLE_RGBA, (const GLint *) swizzle); + const GLuint swizzle[] = {red, green, blue, alpha}; + glTexParameteriv(d->m_target, GL_TEXTURE_SWIZZLE_RGBA, (const GLint *)swizzle); } else { glTexParameteri(d->m_target, GL_TEXTURE_SWIZZLE_R, red); glTexParameteri(d->m_target, GL_TEXTURE_SWIZZLE_G, green); diff --git a/src/libkwineffects/kwingltexture.h b/src/libkwineffects/kwingltexture.h index b346369b01..2dd0527ed1 100644 --- a/src/libkwineffects/kwingltexture.h +++ b/src/libkwineffects/kwingltexture.h @@ -13,11 +13,11 @@ #include -#include -#include -#include #include #include +#include +#include +#include #include @@ -42,10 +42,10 @@ class KWINGLUTILS_EXPORT GLTexture { public: explicit GLTexture(GLenum target); - GLTexture(const GLTexture& tex); - explicit GLTexture(const QImage& image, GLenum target = GL_TEXTURE_2D); - explicit GLTexture(const QPixmap& pixmap, GLenum target = GL_TEXTURE_2D); - explicit GLTexture(const QString& fileName); + GLTexture(const GLTexture &tex); + explicit GLTexture(const QImage &image, GLenum target = GL_TEXTURE_2D); + explicit GLTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D); + explicit GLTexture(const QString &fileName); GLTexture(GLenum internalFormat, int width, int height, int levels = 1, bool needsMutability = false); explicit GLTexture(GLenum internalFormat, const QSize &size, int levels = 1, bool needsMutability = false); @@ -64,7 +64,7 @@ public: explicit GLTexture(GLuint textureId, GLenum internalFormat, const QSize &size, int levels = 1); virtual ~GLTexture(); - GLTexture & operator = (const GLTexture& tex); + GLTexture &operator=(const GLTexture &tex); bool isNull() const; QSize size() const; @@ -99,12 +99,12 @@ public: */ QMatrix4x4 matrix(TextureCoordinateType type) const; - void update(const QImage& image, const QPoint &offset = QPoint(0, 0), const QRect &src = QRect()); + void update(const QImage &image, const QPoint &offset = QPoint(0, 0), const QRect &src = QRect()); virtual void discard(); void bind(); void unbind(); void render(const QRect &rect); - void render(const QRegion ®ion, const QRect& rect, bool hardwareClipping = false); + void render(const QRegion ®ion, const QRect &rect, bool hardwareClipping = false); GLuint texture() const; GLenum target() const; @@ -149,7 +149,7 @@ public: protected: QExplicitlySharedDataPointer d_ptr; - GLTexture(GLTexturePrivate& dd); + GLTexture(GLTexturePrivate &dd); private: Q_DECLARE_PRIVATE(GLTexture) diff --git a/src/libkwineffects/kwingltexture_p.h b/src/libkwineffects/kwingltexture_p.h index 1f5c285db5..2546b18d16 100644 --- a/src/libkwineffects/kwingltexture_p.h +++ b/src/libkwineffects/kwingltexture_p.h @@ -16,10 +16,10 @@ #include "kwinglutils.h" #include -#include -#include #include #include +#include +#include #include namespace KWin @@ -57,7 +57,7 @@ public: int m_unnormalizeActive; // 0 - no, otherwise refcount int m_normalizeActive; // 0 - no, otherwise refcount - GLVertexBuffer* m_vbo; + GLVertexBuffer *m_vbo; QSize m_cachedSize; static void initStatic(); @@ -70,6 +70,7 @@ public: static bool s_supportsTextureFormatRG; static bool s_supportsTexture16Bit; static GLuint s_fbo; + private: friend void KWin::cleanupGL(); static void cleanup(); diff --git a/src/libkwineffects/kwinglutils.cpp b/src/libkwineffects/kwinglutils.cpp index 3024e19f5a..62095dc2b3 100644 --- a/src/libkwineffects/kwinglutils.cpp +++ b/src/libkwineffects/kwinglutils.cpp @@ -17,15 +17,15 @@ #include "kwinglplatform.h" #include "logging_p.h" -#include -#include -#include #include +#include +#include +#include +#include +#include #include #include #include -#include -#include #include #include @@ -34,11 +34,11 @@ #define DEBUG_GLRENDERTARGET 0 #ifdef __GNUC__ -# define likely(x) __builtin_expect(!!(x), 1) -# define unlikely(x) __builtin_expect(!!(x), 0) +#define likely(x) __builtin_expect(!!(x), 1) +#define unlikely(x) __builtin_expect(!!(x), 0) #else -# define likely(x) (x) -# define unlikely(x) (x) +#define likely(x) (x) +#define unlikely(x) (x) #endif namespace KWin @@ -47,7 +47,6 @@ namespace KWin // List of all supported GL extensions static QList glExtensions; - // Functions static void initDebugOutput() @@ -130,7 +129,7 @@ static void initDebugOutput() GL_DEBUG_SEVERITY_LOW, message.length(), message.constData()); } -void initGL(const std::function &resolveFunction) +void initGL(const std::function &resolveFunction) { // Get list of supported OpenGL extensions if (hasGLVersion(3, 0)) { @@ -138,11 +137,11 @@ void initGL(const std::function &resolveFunction) glGetIntegerv(GL_NUM_EXTENSIONS, &count); for (int i = 0; i < count; i++) { - const QByteArray name = (const char *) glGetStringi(GL_EXTENSIONS, i); + const QByteArray name = (const char *)glGetStringi(GL_EXTENSIONS, i); glExtensions << name; } } else - glExtensions = QByteArray((const char*)glGetString(GL_EXTENSIONS)).split(' '); + glExtensions = QByteArray((const char *)glGetString(GL_EXTENSIONS)).split(' '); // handle OpenGL extensions functions glResolveFunctions(resolveFunction); @@ -182,19 +181,27 @@ QList openGLExtensions() static QString formatGLError(GLenum err) { - switch(err) { - case GL_NO_ERROR: return QStringLiteral("GL_NO_ERROR"); - case GL_INVALID_ENUM: return QStringLiteral("GL_INVALID_ENUM"); - case GL_INVALID_VALUE: return QStringLiteral("GL_INVALID_VALUE"); - case GL_INVALID_OPERATION: return QStringLiteral("GL_INVALID_OPERATION"); - case GL_STACK_OVERFLOW: return QStringLiteral("GL_STACK_OVERFLOW"); - case GL_STACK_UNDERFLOW: return QStringLiteral("GL_STACK_UNDERFLOW"); - case GL_OUT_OF_MEMORY: return QStringLiteral("GL_OUT_OF_MEMORY"); - default: return QLatin1String("0x") + QString::number(err, 16); + switch (err) { + case GL_NO_ERROR: + return QStringLiteral("GL_NO_ERROR"); + case GL_INVALID_ENUM: + return QStringLiteral("GL_INVALID_ENUM"); + case GL_INVALID_VALUE: + return QStringLiteral("GL_INVALID_VALUE"); + case GL_INVALID_OPERATION: + return QStringLiteral("GL_INVALID_OPERATION"); + case GL_STACK_OVERFLOW: + return QStringLiteral("GL_STACK_OVERFLOW"); + case GL_STACK_UNDERFLOW: + return QStringLiteral("GL_STACK_UNDERFLOW"); + case GL_OUT_OF_MEMORY: + return QStringLiteral("GL_OUT_OF_MEMORY"); + default: + return QLatin1String("0x") + QString::number(err, 16); } } -bool checkGLError(const char* txt) +bool checkGLError(const char *txt) { GLenum err = glGetError(); if (err == GL_CONTEXT_LOST) { @@ -226,7 +233,7 @@ GLShader::GLShader(unsigned int flags) mProgram = glCreateProgram(); } -GLShader::GLShader(const QString& vertexfile, const QString& fragmentfile, unsigned int flags) +GLShader::GLShader(const QString &vertexfile, const QString &fragmentfile, unsigned int flags) : mValid(false) , mLocationsResolved(false) , mExplicitLinking(flags & ExplicitLinking) @@ -280,7 +287,9 @@ bool GLShader::link() glGetProgramiv(mProgram, GL_LINK_STATUS, &status); if (status == 0) { - qCCritical(LIBKWINGLUTILS) << "Failed to link shader:" << "\n" << log; + qCCritical(LIBKWINGLUTILS) << "Failed to link shader:" + << "\n" + << log; mValid = false; } else if (length > 0) { qCDebug(LIBKWINGLUTILS) << "Shader link log:" << log; @@ -310,7 +319,7 @@ bool GLShader::compile(GLuint program, GLenum shaderType, const QByteArray &sour GLuint shader = glCreateShader(shaderType); QByteArray preparedSource = prepareSource(shaderType, source); - const char* src = preparedSource.constData(); + const char *src = preparedSource.constData(); glShaderSource(shader, 1, &src, nullptr); // Compile the shader @@ -329,7 +338,9 @@ bool GLShader::compile(GLuint program, GLenum shaderType, const QByteArray &sour if (status == 0) { const char *typeName = (shaderType == GL_VERTEX_SHADER ? "vertex" : "fragment"); - qCCritical(LIBKWINGLUTILS) << "Failed to compile" << typeName << "shader:" << "\n" << log; + qCCritical(LIBKWINGLUTILS) << "Failed to compile" << typeName << "shader:" + << "\n" + << log; } else if (length > 0) qCDebug(LIBKWINGLUTILS) << "Shader compile log:" << log; @@ -344,8 +355,8 @@ bool GLShader::load(const QByteArray &vertexSource, const QByteArray &fragmentSo { // Make sure shaders are actually supported if (!(GLPlatform::instance()->supports(GLSL) && - // we lack shader branching for Texture2DRectangle everywhere - and it's probably not worth it - GLPlatform::instance()->supports(TextureNPOT))) { + // we lack shader branching for Texture2DRectangle everywhere - and it's probably not worth it + GLPlatform::instance()->supports(TextureNPOT))) { qCCritical(LIBKWINGLUTILS) << "Shaders are not supported"; return false; } @@ -401,18 +412,18 @@ void GLShader::resolveLocations() if (mLocationsResolved) return; - mMatrixLocation[TextureMatrix] = uniformLocation("textureMatrix"); - mMatrixLocation[ProjectionMatrix] = uniformLocation("projection"); - mMatrixLocation[ModelViewMatrix] = uniformLocation("modelview"); - mMatrixLocation[ModelViewProjectionMatrix] = uniformLocation("modelViewProjectionMatrix"); - mMatrixLocation[WindowTransformation] = uniformLocation("windowTransformation"); - mMatrixLocation[ScreenTransformation] = uniformLocation("screenTransformation"); + mMatrixLocation[TextureMatrix] = uniformLocation("textureMatrix"); + mMatrixLocation[ProjectionMatrix] = uniformLocation("projection"); + mMatrixLocation[ModelViewMatrix] = uniformLocation("modelview"); + mMatrixLocation[ModelViewProjectionMatrix] = uniformLocation("modelViewProjectionMatrix"); + mMatrixLocation[WindowTransformation] = uniformLocation("windowTransformation"); + mMatrixLocation[ScreenTransformation] = uniformLocation("screenTransformation"); mVec2Location[Offset] = uniformLocation("offset"); mVec4Location[ModulationConstant] = uniformLocation("modulation"); - mFloatLocation[Saturation] = uniformLocation("saturation"); + mFloatLocation[Saturation] = uniformLocation("saturation"); mColorLocation[Color] = uniformLocation("geometryColor"); @@ -479,31 +490,31 @@ bool GLShader::setUniform(const char *name, int value) return setUniform(location, value); } -bool GLShader::setUniform(const char *name, const QVector2D& value) +bool GLShader::setUniform(const char *name, const QVector2D &value) { const int location = uniformLocation(name); return setUniform(location, value); } -bool GLShader::setUniform(const char *name, const QVector3D& value) +bool GLShader::setUniform(const char *name, const QVector3D &value) { const int location = uniformLocation(name); return setUniform(location, value); } -bool GLShader::setUniform(const char *name, const QVector4D& value) +bool GLShader::setUniform(const char *name, const QVector4D &value) { const int location = uniformLocation(name); return setUniform(location, value); } -bool GLShader::setUniform(const char *name, const QMatrix4x4& value) +bool GLShader::setUniform(const char *name, const QMatrix4x4 &value) { const int location = uniformLocation(name); return setUniform(location, value); } -bool GLShader::setUniform(const char *name, const QColor& color) +bool GLShader::setUniform(const char *name, const QColor &color) { const int location = uniformLocation(name); return setUniform(location, color); @@ -528,7 +539,7 @@ bool GLShader::setUniform(int location, int value) bool GLShader::setUniform(int location, const QVector2D &value) { if (location >= 0) { - glUniform2fv(location, 1, (const GLfloat*)&value); + glUniform2fv(location, 1, (const GLfloat *)&value); } return (location >= 0); } @@ -536,7 +547,7 @@ bool GLShader::setUniform(int location, const QVector2D &value) bool GLShader::setUniform(int location, const QVector3D &value) { if (location >= 0) { - glUniform3fv(location, 1, (const GLfloat*)&value); + glUniform3fv(location, 1, (const GLfloat *)&value); } return (location >= 0); } @@ -544,7 +555,7 @@ bool GLShader::setUniform(int location, const QVector3D &value) bool GLShader::setUniform(int location, const QVector4D &value) { if (location >= 0) { - glUniform4fv(location, 1, (const GLfloat*)&value); + glUniform4fv(location, 1, (const GLfloat *)&value); } return (location >= 0); } @@ -565,13 +576,13 @@ bool GLShader::setUniform(int location, const QColor &color) return (location >= 0); } -int GLShader::attributeLocation(const char* name) +int GLShader::attributeLocation(const char *name) { int location = glGetAttribLocation(mProgram, name); return location; } -bool GLShader::setAttribute(const char* name, float value) +bool GLShader::setAttribute(const char *name, float value) { int location = attributeLocation(name); if (location >= 0) { @@ -580,14 +591,14 @@ bool GLShader::setAttribute(const char* name, float value) return (location >= 0); } -QMatrix4x4 GLShader::getUniformMatrix4x4(const char* name) +QMatrix4x4 GLShader::getUniformMatrix4x4(const char *name) { int location = uniformLocation(name); if (location >= 0) { GLfloat m[16]; glGetnUniformfv(mProgram, location, sizeof(m), m); - QMatrix4x4 matrix(m[0], m[4], m[8], m[12], - m[1], m[5], m[9], m[13], + QMatrix4x4 matrix(m[0], m[4], m[8], m[12], + m[1], m[5], m[9], m[13], m[2], m[6], m[10], m[14], m[3], m[7], m[11], m[15]); matrix.optimize(); @@ -635,22 +646,22 @@ QByteArray ShaderManager::generateVertexSource(ShaderTraits traits) const QByteArray source; QTextStream stream(&source); - GLPlatform * const gl = GLPlatform::instance(); + GLPlatform *const gl = GLPlatform::instance(); QByteArray attribute, varying; if (!gl->isGLES()) { const bool glsl_140 = gl->glslVersion() >= kVersionNumber(1, 40); - attribute = glsl_140 ? QByteArrayLiteral("in") : QByteArrayLiteral("attribute"); - varying = glsl_140 ? QByteArrayLiteral("out") : QByteArrayLiteral("varying"); + attribute = glsl_140 ? QByteArrayLiteral("in") : QByteArrayLiteral("attribute"); + varying = glsl_140 ? QByteArrayLiteral("out") : QByteArrayLiteral("varying"); if (glsl_140) stream << "#version 140\n\n"; } else { const bool glsl_es_300 = gl->glslVersion() >= kVersionNumber(3, 0); - attribute = glsl_es_300 ? QByteArrayLiteral("in") : QByteArrayLiteral("attribute"); - varying = glsl_es_300 ? QByteArrayLiteral("out") : QByteArrayLiteral("varying"); + attribute = glsl_es_300 ? QByteArrayLiteral("in") : QByteArrayLiteral("attribute"); + varying = glsl_es_300 ? QByteArrayLiteral("out") : QByteArrayLiteral("varying"); if (glsl_es_300) stream << "#version 300 es\n\n"; @@ -681,7 +692,7 @@ QByteArray ShaderManager::generateFragmentSource(ShaderTraits traits) const QByteArray source; QTextStream stream(&source); - GLPlatform * const gl = GLPlatform::instance(); + GLPlatform *const gl = GLPlatform::instance(); QByteArray varying, output, textureLookup; if (!gl->isGLES()) { @@ -690,9 +701,9 @@ QByteArray ShaderManager::generateFragmentSource(ShaderTraits traits) const if (glsl_140) stream << "#version 140\n\n"; - varying = glsl_140 ? QByteArrayLiteral("in") : QByteArrayLiteral("varying"); - textureLookup = glsl_140 ? QByteArrayLiteral("texture") : QByteArrayLiteral("texture2D"); - output = glsl_140 ? QByteArrayLiteral("fragColor") : QByteArrayLiteral("gl_FragColor"); + varying = glsl_140 ? QByteArrayLiteral("in") : QByteArrayLiteral("varying"); + textureLookup = glsl_140 ? QByteArrayLiteral("texture") : QByteArrayLiteral("texture2D"); + output = glsl_140 ? QByteArrayLiteral("fragColor") : QByteArrayLiteral("gl_FragColor"); } else { const bool glsl_es_300 = GLPlatform::instance()->glslVersion() >= kVersionNumber(3, 0); @@ -704,9 +715,9 @@ QByteArray ShaderManager::generateFragmentSource(ShaderTraits traits) const // "The fragment language has no default precision qualifier for floating point types." stream << "precision highp float;\n\n"; - varying = glsl_es_300 ? QByteArrayLiteral("in") : QByteArrayLiteral("varying"); - textureLookup = glsl_es_300 ? QByteArrayLiteral("texture") : QByteArrayLiteral("texture2D"); - output = glsl_es_300 ? QByteArrayLiteral("fragColor") : QByteArrayLiteral("gl_FragColor"); + varying = glsl_es_300 ? QByteArrayLiteral("in") : QByteArrayLiteral("varying"); + textureLookup = glsl_es_300 ? QByteArrayLiteral("texture") : QByteArrayLiteral("texture2D"); + output = glsl_es_300 ? QByteArrayLiteral("fragColor") : QByteArrayLiteral("gl_FragColor"); } if (traits & ShaderTrait::MapTexture) { @@ -717,7 +728,8 @@ QByteArray ShaderManager::generateFragmentSource(ShaderTraits traits) const if (traits & ShaderTrait::AdjustSaturation) stream << "uniform float saturation;\n"; - stream << "\n" << varying << " vec2 texcoord0;\n"; + stream << "\n" + << varying << " vec2 texcoord0;\n"; } else if (traits & ShaderTrait::UniformColor) stream << "uniform vec4 geometryColor;\n"; @@ -755,7 +767,7 @@ GLShader *ShaderManager::generateShader(ShaderTraits traits) GLShader *ShaderManager::generateCustomShader(ShaderTraits traits, const QByteArray &vertexSource, const QByteArray &fragmentSource) { - const QByteArray vertex = vertexSource.isEmpty() ? generateVertexSource(traits) : vertexSource; + const QByteArray vertex = vertexSource.isEmpty() ? generateVertexSource(traits) : vertexSource; const QByteArray fragment = fragmentSource.isEmpty() ? generateFragmentSource(traits) : fragmentSource; #if 0 @@ -860,7 +872,6 @@ GLShader *ShaderManager::pushShader(ShaderTraits traits) return shader; } - void ShaderManager::pushShader(GLShader *shader) { // only bind shader if it is not already bound @@ -892,7 +903,7 @@ void ShaderManager::bindFragDataLocations(GLShader *shader) void ShaderManager::bindAttributeLocations(GLShader *shader) const { - shader->bindAttributeLocation("vertex", VA_Position); + shader->bindAttributeLocation("vertex", VA_Position); shader->bindAttributeLocation("texCoord", VA_TexCoord); } @@ -909,7 +920,7 @@ GLShader *ShaderManager::loadShaderFromCode(const QByteArray &vertexSource, cons /*** GLRenderTarget ***/ bool GLRenderTarget::sSupported = false; bool GLRenderTarget::s_blitSupported = false; -QStack GLRenderTarget::s_renderTargets = QStack(); +QStack GLRenderTarget::s_renderTargets = QStack(); void GLRenderTarget::initStatic() { @@ -917,13 +928,9 @@ void GLRenderTarget::initStatic() sSupported = true; s_blitSupported = hasGLVersion(3, 0); } else { - sSupported = hasGLVersion(3, 0) || - hasGLExtension(QByteArrayLiteral("GL_ARB_framebuffer_object")) || - hasGLExtension(QByteArrayLiteral("GL_EXT_framebuffer_object")); + sSupported = hasGLVersion(3, 0) || hasGLExtension(QByteArrayLiteral("GL_ARB_framebuffer_object")) || hasGLExtension(QByteArrayLiteral("GL_EXT_framebuffer_object")); - s_blitSupported = hasGLVersion(3, 0) || - hasGLExtension(QByteArrayLiteral("GL_ARB_framebuffer_object")) || - hasGLExtension(QByteArrayLiteral("GL_EXT_framebuffer_blit")); + s_blitSupported = hasGLVersion(3, 0) || hasGLExtension(QByteArrayLiteral("GL_ARB_framebuffer_object")) || hasGLExtension(QByteArrayLiteral("GL_EXT_framebuffer_blit")); } } @@ -944,21 +951,21 @@ GLRenderTarget *GLRenderTarget::currentRenderTarget() return s_renderTargets.isEmpty() ? nullptr : s_renderTargets.top(); } -void GLRenderTarget::pushRenderTarget(GLRenderTarget* target) +void GLRenderTarget::pushRenderTarget(GLRenderTarget *target) { target->bind(); s_renderTargets.push(target); } -void GLRenderTarget::pushRenderTargets(QStack targets) +void GLRenderTarget::pushRenderTargets(QStack targets) { targets.top()->bind(); s_renderTargets.append(targets); } -GLRenderTarget* GLRenderTarget::popRenderTarget() +GLRenderTarget *GLRenderTarget::popRenderTarget() { - GLRenderTarget* ret = s_renderTargets.pop(); + GLRenderTarget *ret = s_renderTargets.pop(); if (!s_renderTargets.isEmpty()) { s_renderTargets.top()->bind(); } @@ -1011,7 +1018,7 @@ bool GLRenderTarget::bind() static QString formatFramebufferStatus(GLenum status) { - switch(status) { + switch (status) { case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: // An attachment is the wrong type / is invalid / has 0 width or height return QStringLiteral("GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"); @@ -1135,180 +1142,179 @@ void GLRenderTarget::blitFromFramebuffer(const QRect &source, const QRect &desti // ------------------------------------------------------------------ static const uint16_t indices[] = { - 1, 0, 3, 3, 2, 1, 5, 4, 7, 7, 6, 5, 9, 8, 11, 11, 10, 9, - 13, 12, 15, 15, 14, 13, 17, 16, 19, 19, 18, 17, 21, 20, 23, 23, 22, 21, - 25, 24, 27, 27, 26, 25, 29, 28, 31, 31, 30, 29, 33, 32, 35, 35, 34, 33, - 37, 36, 39, 39, 38, 37, 41, 40, 43, 43, 42, 41, 45, 44, 47, 47, 46, 45, - 49, 48, 51, 51, 50, 49, 53, 52, 55, 55, 54, 53, 57, 56, 59, 59, 58, 57, - 61, 60, 63, 63, 62, 61, 65, 64, 67, 67, 66, 65, 69, 68, 71, 71, 70, 69, - 73, 72, 75, 75, 74, 73, 77, 76, 79, 79, 78, 77, 81, 80, 83, 83, 82, 81, - 85, 84, 87, 87, 86, 85, 89, 88, 91, 91, 90, 89, 93, 92, 95, 95, 94, 93, - 97, 96, 99, 99, 98, 97, 101, 100, 103, 103, 102, 101, 105, 104, 107, 107, 106, 105, - 109, 108, 111, 111, 110, 109, 113, 112, 115, 115, 114, 113, 117, 116, 119, 119, 118, 117, - 121, 120, 123, 123, 122, 121, 125, 124, 127, 127, 126, 125, 129, 128, 131, 131, 130, 129, - 133, 132, 135, 135, 134, 133, 137, 136, 139, 139, 138, 137, 141, 140, 143, 143, 142, 141, - 145, 144, 147, 147, 146, 145, 149, 148, 151, 151, 150, 149, 153, 152, 155, 155, 154, 153, - 157, 156, 159, 159, 158, 157, 161, 160, 163, 163, 162, 161, 165, 164, 167, 167, 166, 165, - 169, 168, 171, 171, 170, 169, 173, 172, 175, 175, 174, 173, 177, 176, 179, 179, 178, 177, - 181, 180, 183, 183, 182, 181, 185, 184, 187, 187, 186, 185, 189, 188, 191, 191, 190, 189, - 193, 192, 195, 195, 194, 193, 197, 196, 199, 199, 198, 197, 201, 200, 203, 203, 202, 201, - 205, 204, 207, 207, 206, 205, 209, 208, 211, 211, 210, 209, 213, 212, 215, 215, 214, 213, - 217, 216, 219, 219, 218, 217, 221, 220, 223, 223, 222, 221, 225, 224, 227, 227, 226, 225, - 229, 228, 231, 231, 230, 229, 233, 232, 235, 235, 234, 233, 237, 236, 239, 239, 238, 237, - 241, 240, 243, 243, 242, 241, 245, 244, 247, 247, 246, 245, 249, 248, 251, 251, 250, 249, - 253, 252, 255, 255, 254, 253, 257, 256, 259, 259, 258, 257, 261, 260, 263, 263, 262, 261, - 265, 264, 267, 267, 266, 265, 269, 268, 271, 271, 270, 269, 273, 272, 275, 275, 274, 273, - 277, 276, 279, 279, 278, 277, 281, 280, 283, 283, 282, 281, 285, 284, 287, 287, 286, 285, - 289, 288, 291, 291, 290, 289, 293, 292, 295, 295, 294, 293, 297, 296, 299, 299, 298, 297, - 301, 300, 303, 303, 302, 301, 305, 304, 307, 307, 306, 305, 309, 308, 311, 311, 310, 309, - 313, 312, 315, 315, 314, 313, 317, 316, 319, 319, 318, 317, 321, 320, 323, 323, 322, 321, - 325, 324, 327, 327, 326, 325, 329, 328, 331, 331, 330, 329, 333, 332, 335, 335, 334, 333, - 337, 336, 339, 339, 338, 337, 341, 340, 343, 343, 342, 341, 345, 344, 347, 347, 346, 345, - 349, 348, 351, 351, 350, 349, 353, 352, 355, 355, 354, 353, 357, 356, 359, 359, 358, 357, - 361, 360, 363, 363, 362, 361, 365, 364, 367, 367, 366, 365, 369, 368, 371, 371, 370, 369, - 373, 372, 375, 375, 374, 373, 377, 376, 379, 379, 378, 377, 381, 380, 383, 383, 382, 381, - 385, 384, 387, 387, 386, 385, 389, 388, 391, 391, 390, 389, 393, 392, 395, 395, 394, 393, - 397, 396, 399, 399, 398, 397, 401, 400, 403, 403, 402, 401, 405, 404, 407, 407, 406, 405, - 409, 408, 411, 411, 410, 409, 413, 412, 415, 415, 414, 413, 417, 416, 419, 419, 418, 417, - 421, 420, 423, 423, 422, 421, 425, 424, 427, 427, 426, 425, 429, 428, 431, 431, 430, 429, - 433, 432, 435, 435, 434, 433, 437, 436, 439, 439, 438, 437, 441, 440, 443, 443, 442, 441, - 445, 444, 447, 447, 446, 445, 449, 448, 451, 451, 450, 449, 453, 452, 455, 455, 454, 453, - 457, 456, 459, 459, 458, 457, 461, 460, 463, 463, 462, 461, 465, 464, 467, 467, 466, 465, - 469, 468, 471, 471, 470, 469, 473, 472, 475, 475, 474, 473, 477, 476, 479, 479, 478, 477, - 481, 480, 483, 483, 482, 481, 485, 484, 487, 487, 486, 485, 489, 488, 491, 491, 490, 489, - 493, 492, 495, 495, 494, 493, 497, 496, 499, 499, 498, 497, 501, 500, 503, 503, 502, 501, - 505, 504, 507, 507, 506, 505, 509, 508, 511, 511, 510, 509, 513, 512, 515, 515, 514, 513, - 517, 516, 519, 519, 518, 517, 521, 520, 523, 523, 522, 521, 525, 524, 527, 527, 526, 525, - 529, 528, 531, 531, 530, 529, 533, 532, 535, 535, 534, 533, 537, 536, 539, 539, 538, 537, - 541, 540, 543, 543, 542, 541, 545, 544, 547, 547, 546, 545, 549, 548, 551, 551, 550, 549, - 553, 552, 555, 555, 554, 553, 557, 556, 559, 559, 558, 557, 561, 560, 563, 563, 562, 561, - 565, 564, 567, 567, 566, 565, 569, 568, 571, 571, 570, 569, 573, 572, 575, 575, 574, 573, - 577, 576, 579, 579, 578, 577, 581, 580, 583, 583, 582, 581, 585, 584, 587, 587, 586, 585, - 589, 588, 591, 591, 590, 589, 593, 592, 595, 595, 594, 593, 597, 596, 599, 599, 598, 597, - 601, 600, 603, 603, 602, 601, 605, 604, 607, 607, 606, 605, 609, 608, 611, 611, 610, 609, - 613, 612, 615, 615, 614, 613, 617, 616, 619, 619, 618, 617, 621, 620, 623, 623, 622, 621, - 625, 624, 627, 627, 626, 625, 629, 628, 631, 631, 630, 629, 633, 632, 635, 635, 634, 633, - 637, 636, 639, 639, 638, 637, 641, 640, 643, 643, 642, 641, 645, 644, 647, 647, 646, 645, - 649, 648, 651, 651, 650, 649, 653, 652, 655, 655, 654, 653, 657, 656, 659, 659, 658, 657, - 661, 660, 663, 663, 662, 661, 665, 664, 667, 667, 666, 665, 669, 668, 671, 671, 670, 669, - 673, 672, 675, 675, 674, 673, 677, 676, 679, 679, 678, 677, 681, 680, 683, 683, 682, 681, - 685, 684, 687, 687, 686, 685, 689, 688, 691, 691, 690, 689, 693, 692, 695, 695, 694, 693, - 697, 696, 699, 699, 698, 697, 701, 700, 703, 703, 702, 701, 705, 704, 707, 707, 706, 705, - 709, 708, 711, 711, 710, 709, 713, 712, 715, 715, 714, 713, 717, 716, 719, 719, 718, 717, - 721, 720, 723, 723, 722, 721, 725, 724, 727, 727, 726, 725, 729, 728, 731, 731, 730, 729, - 733, 732, 735, 735, 734, 733, 737, 736, 739, 739, 738, 737, 741, 740, 743, 743, 742, 741, - 745, 744, 747, 747, 746, 745, 749, 748, 751, 751, 750, 749, 753, 752, 755, 755, 754, 753, - 757, 756, 759, 759, 758, 757, 761, 760, 763, 763, 762, 761, 765, 764, 767, 767, 766, 765, - 769, 768, 771, 771, 770, 769, 773, 772, 775, 775, 774, 773, 777, 776, 779, 779, 778, 777, - 781, 780, 783, 783, 782, 781, 785, 784, 787, 787, 786, 785, 789, 788, 791, 791, 790, 789, - 793, 792, 795, 795, 794, 793, 797, 796, 799, 799, 798, 797, 801, 800, 803, 803, 802, 801, - 805, 804, 807, 807, 806, 805, 809, 808, 811, 811, 810, 809, 813, 812, 815, 815, 814, 813, - 817, 816, 819, 819, 818, 817, 821, 820, 823, 823, 822, 821, 825, 824, 827, 827, 826, 825, - 829, 828, 831, 831, 830, 829, 833, 832, 835, 835, 834, 833, 837, 836, 839, 839, 838, 837, - 841, 840, 843, 843, 842, 841, 845, 844, 847, 847, 846, 845, 849, 848, 851, 851, 850, 849, - 853, 852, 855, 855, 854, 853, 857, 856, 859, 859, 858, 857, 861, 860, 863, 863, 862, 861, - 865, 864, 867, 867, 866, 865, 869, 868, 871, 871, 870, 869, 873, 872, 875, 875, 874, 873, - 877, 876, 879, 879, 878, 877, 881, 880, 883, 883, 882, 881, 885, 884, 887, 887, 886, 885, - 889, 888, 891, 891, 890, 889, 893, 892, 895, 895, 894, 893, 897, 896, 899, 899, 898, 897, - 901, 900, 903, 903, 902, 901, 905, 904, 907, 907, 906, 905, 909, 908, 911, 911, 910, 909, - 913, 912, 915, 915, 914, 913, 917, 916, 919, 919, 918, 917, 921, 920, 923, 923, 922, 921, - 925, 924, 927, 927, 926, 925, 929, 928, 931, 931, 930, 929, 933, 932, 935, 935, 934, 933, - 937, 936, 939, 939, 938, 937, 941, 940, 943, 943, 942, 941, 945, 944, 947, 947, 946, 945, - 949, 948, 951, 951, 950, 949, 953, 952, 955, 955, 954, 953, 957, 956, 959, 959, 958, 957, - 961, 960, 963, 963, 962, 961, 965, 964, 967, 967, 966, 965, 969, 968, 971, 971, 970, 969, - 973, 972, 975, 975, 974, 973, 977, 976, 979, 979, 978, 977, 981, 980, 983, 983, 982, 981, - 985, 984, 987, 987, 986, 985, 989, 988, 991, 991, 990, 989, 993, 992, 995, 995, 994, 993, - 997, 996, 999, 999, 998, 997, 1001, 1000, 1003, 1003, 1002, 1001, 1005, 1004, 1007, 1007, 1006, 1005, - 1009, 1008, 1011, 1011, 1010, 1009, 1013, 1012, 1015, 1015, 1014, 1013, 1017, 1016, 1019, 1019, 1018, 1017, - 1021, 1020, 1023, 1023, 1022, 1021, 1025, 1024, 1027, 1027, 1026, 1025, 1029, 1028, 1031, 1031, 1030, 1029, - 1033, 1032, 1035, 1035, 1034, 1033, 1037, 1036, 1039, 1039, 1038, 1037, 1041, 1040, 1043, 1043, 1042, 1041, - 1045, 1044, 1047, 1047, 1046, 1045, 1049, 1048, 1051, 1051, 1050, 1049, 1053, 1052, 1055, 1055, 1054, 1053, - 1057, 1056, 1059, 1059, 1058, 1057, 1061, 1060, 1063, 1063, 1062, 1061, 1065, 1064, 1067, 1067, 1066, 1065, - 1069, 1068, 1071, 1071, 1070, 1069, 1073, 1072, 1075, 1075, 1074, 1073, 1077, 1076, 1079, 1079, 1078, 1077, - 1081, 1080, 1083, 1083, 1082, 1081, 1085, 1084, 1087, 1087, 1086, 1085, 1089, 1088, 1091, 1091, 1090, 1089, - 1093, 1092, 1095, 1095, 1094, 1093, 1097, 1096, 1099, 1099, 1098, 1097, 1101, 1100, 1103, 1103, 1102, 1101, - 1105, 1104, 1107, 1107, 1106, 1105, 1109, 1108, 1111, 1111, 1110, 1109, 1113, 1112, 1115, 1115, 1114, 1113, - 1117, 1116, 1119, 1119, 1118, 1117, 1121, 1120, 1123, 1123, 1122, 1121, 1125, 1124, 1127, 1127, 1126, 1125, - 1129, 1128, 1131, 1131, 1130, 1129, 1133, 1132, 1135, 1135, 1134, 1133, 1137, 1136, 1139, 1139, 1138, 1137, - 1141, 1140, 1143, 1143, 1142, 1141, 1145, 1144, 1147, 1147, 1146, 1145, 1149, 1148, 1151, 1151, 1150, 1149, - 1153, 1152, 1155, 1155, 1154, 1153, 1157, 1156, 1159, 1159, 1158, 1157, 1161, 1160, 1163, 1163, 1162, 1161, - 1165, 1164, 1167, 1167, 1166, 1165, 1169, 1168, 1171, 1171, 1170, 1169, 1173, 1172, 1175, 1175, 1174, 1173, - 1177, 1176, 1179, 1179, 1178, 1177, 1181, 1180, 1183, 1183, 1182, 1181, 1185, 1184, 1187, 1187, 1186, 1185, - 1189, 1188, 1191, 1191, 1190, 1189, 1193, 1192, 1195, 1195, 1194, 1193, 1197, 1196, 1199, 1199, 1198, 1197, - 1201, 1200, 1203, 1203, 1202, 1201, 1205, 1204, 1207, 1207, 1206, 1205, 1209, 1208, 1211, 1211, 1210, 1209, - 1213, 1212, 1215, 1215, 1214, 1213, 1217, 1216, 1219, 1219, 1218, 1217, 1221, 1220, 1223, 1223, 1222, 1221, - 1225, 1224, 1227, 1227, 1226, 1225, 1229, 1228, 1231, 1231, 1230, 1229, 1233, 1232, 1235, 1235, 1234, 1233, - 1237, 1236, 1239, 1239, 1238, 1237, 1241, 1240, 1243, 1243, 1242, 1241, 1245, 1244, 1247, 1247, 1246, 1245, - 1249, 1248, 1251, 1251, 1250, 1249, 1253, 1252, 1255, 1255, 1254, 1253, 1257, 1256, 1259, 1259, 1258, 1257, - 1261, 1260, 1263, 1263, 1262, 1261, 1265, 1264, 1267, 1267, 1266, 1265, 1269, 1268, 1271, 1271, 1270, 1269, - 1273, 1272, 1275, 1275, 1274, 1273, 1277, 1276, 1279, 1279, 1278, 1277, 1281, 1280, 1283, 1283, 1282, 1281, - 1285, 1284, 1287, 1287, 1286, 1285, 1289, 1288, 1291, 1291, 1290, 1289, 1293, 1292, 1295, 1295, 1294, 1293, - 1297, 1296, 1299, 1299, 1298, 1297, 1301, 1300, 1303, 1303, 1302, 1301, 1305, 1304, 1307, 1307, 1306, 1305, - 1309, 1308, 1311, 1311, 1310, 1309, 1313, 1312, 1315, 1315, 1314, 1313, 1317, 1316, 1319, 1319, 1318, 1317, - 1321, 1320, 1323, 1323, 1322, 1321, 1325, 1324, 1327, 1327, 1326, 1325, 1329, 1328, 1331, 1331, 1330, 1329, - 1333, 1332, 1335, 1335, 1334, 1333, 1337, 1336, 1339, 1339, 1338, 1337, 1341, 1340, 1343, 1343, 1342, 1341, - 1345, 1344, 1347, 1347, 1346, 1345, 1349, 1348, 1351, 1351, 1350, 1349, 1353, 1352, 1355, 1355, 1354, 1353, - 1357, 1356, 1359, 1359, 1358, 1357, 1361, 1360, 1363, 1363, 1362, 1361, 1365, 1364, 1367, 1367, 1366, 1365, - 1369, 1368, 1371, 1371, 1370, 1369, 1373, 1372, 1375, 1375, 1374, 1373, 1377, 1376, 1379, 1379, 1378, 1377, - 1381, 1380, 1383, 1383, 1382, 1381, 1385, 1384, 1387, 1387, 1386, 1385, 1389, 1388, 1391, 1391, 1390, 1389, - 1393, 1392, 1395, 1395, 1394, 1393, 1397, 1396, 1399, 1399, 1398, 1397, 1401, 1400, 1403, 1403, 1402, 1401, - 1405, 1404, 1407, 1407, 1406, 1405, 1409, 1408, 1411, 1411, 1410, 1409, 1413, 1412, 1415, 1415, 1414, 1413, - 1417, 1416, 1419, 1419, 1418, 1417, 1421, 1420, 1423, 1423, 1422, 1421, 1425, 1424, 1427, 1427, 1426, 1425, - 1429, 1428, 1431, 1431, 1430, 1429, 1433, 1432, 1435, 1435, 1434, 1433, 1437, 1436, 1439, 1439, 1438, 1437, - 1441, 1440, 1443, 1443, 1442, 1441, 1445, 1444, 1447, 1447, 1446, 1445, 1449, 1448, 1451, 1451, 1450, 1449, - 1453, 1452, 1455, 1455, 1454, 1453, 1457, 1456, 1459, 1459, 1458, 1457, 1461, 1460, 1463, 1463, 1462, 1461, - 1465, 1464, 1467, 1467, 1466, 1465, 1469, 1468, 1471, 1471, 1470, 1469, 1473, 1472, 1475, 1475, 1474, 1473, - 1477, 1476, 1479, 1479, 1478, 1477, 1481, 1480, 1483, 1483, 1482, 1481, 1485, 1484, 1487, 1487, 1486, 1485, - 1489, 1488, 1491, 1491, 1490, 1489, 1493, 1492, 1495, 1495, 1494, 1493, 1497, 1496, 1499, 1499, 1498, 1497, - 1501, 1500, 1503, 1503, 1502, 1501, 1505, 1504, 1507, 1507, 1506, 1505, 1509, 1508, 1511, 1511, 1510, 1509, - 1513, 1512, 1515, 1515, 1514, 1513, 1517, 1516, 1519, 1519, 1518, 1517, 1521, 1520, 1523, 1523, 1522, 1521, - 1525, 1524, 1527, 1527, 1526, 1525, 1529, 1528, 1531, 1531, 1530, 1529, 1533, 1532, 1535, 1535, 1534, 1533, - 1537, 1536, 1539, 1539, 1538, 1537, 1541, 1540, 1543, 1543, 1542, 1541, 1545, 1544, 1547, 1547, 1546, 1545, - 1549, 1548, 1551, 1551, 1550, 1549, 1553, 1552, 1555, 1555, 1554, 1553, 1557, 1556, 1559, 1559, 1558, 1557, - 1561, 1560, 1563, 1563, 1562, 1561, 1565, 1564, 1567, 1567, 1566, 1565, 1569, 1568, 1571, 1571, 1570, 1569, - 1573, 1572, 1575, 1575, 1574, 1573, 1577, 1576, 1579, 1579, 1578, 1577, 1581, 1580, 1583, 1583, 1582, 1581, - 1585, 1584, 1587, 1587, 1586, 1585, 1589, 1588, 1591, 1591, 1590, 1589, 1593, 1592, 1595, 1595, 1594, 1593, - 1597, 1596, 1599, 1599, 1598, 1597, 1601, 1600, 1603, 1603, 1602, 1601, 1605, 1604, 1607, 1607, 1606, 1605, - 1609, 1608, 1611, 1611, 1610, 1609, 1613, 1612, 1615, 1615, 1614, 1613, 1617, 1616, 1619, 1619, 1618, 1617, - 1621, 1620, 1623, 1623, 1622, 1621, 1625, 1624, 1627, 1627, 1626, 1625, 1629, 1628, 1631, 1631, 1630, 1629, - 1633, 1632, 1635, 1635, 1634, 1633, 1637, 1636, 1639, 1639, 1638, 1637, 1641, 1640, 1643, 1643, 1642, 1641, - 1645, 1644, 1647, 1647, 1646, 1645, 1649, 1648, 1651, 1651, 1650, 1649, 1653, 1652, 1655, 1655, 1654, 1653, - 1657, 1656, 1659, 1659, 1658, 1657, 1661, 1660, 1663, 1663, 1662, 1661, 1665, 1664, 1667, 1667, 1666, 1665, - 1669, 1668, 1671, 1671, 1670, 1669, 1673, 1672, 1675, 1675, 1674, 1673, 1677, 1676, 1679, 1679, 1678, 1677, - 1681, 1680, 1683, 1683, 1682, 1681, 1685, 1684, 1687, 1687, 1686, 1685, 1689, 1688, 1691, 1691, 1690, 1689, - 1693, 1692, 1695, 1695, 1694, 1693, 1697, 1696, 1699, 1699, 1698, 1697, 1701, 1700, 1703, 1703, 1702, 1701, - 1705, 1704, 1707, 1707, 1706, 1705, 1709, 1708, 1711, 1711, 1710, 1709, 1713, 1712, 1715, 1715, 1714, 1713, - 1717, 1716, 1719, 1719, 1718, 1717, 1721, 1720, 1723, 1723, 1722, 1721, 1725, 1724, 1727, 1727, 1726, 1725, - 1729, 1728, 1731, 1731, 1730, 1729, 1733, 1732, 1735, 1735, 1734, 1733, 1737, 1736, 1739, 1739, 1738, 1737, - 1741, 1740, 1743, 1743, 1742, 1741, 1745, 1744, 1747, 1747, 1746, 1745, 1749, 1748, 1751, 1751, 1750, 1749, - 1753, 1752, 1755, 1755, 1754, 1753, 1757, 1756, 1759, 1759, 1758, 1757, 1761, 1760, 1763, 1763, 1762, 1761, - 1765, 1764, 1767, 1767, 1766, 1765, 1769, 1768, 1771, 1771, 1770, 1769, 1773, 1772, 1775, 1775, 1774, 1773, - 1777, 1776, 1779, 1779, 1778, 1777, 1781, 1780, 1783, 1783, 1782, 1781, 1785, 1784, 1787, 1787, 1786, 1785, - 1789, 1788, 1791, 1791, 1790, 1789, 1793, 1792, 1795, 1795, 1794, 1793, 1797, 1796, 1799, 1799, 1798, 1797, - 1801, 1800, 1803, 1803, 1802, 1801, 1805, 1804, 1807, 1807, 1806, 1805, 1809, 1808, 1811, 1811, 1810, 1809, - 1813, 1812, 1815, 1815, 1814, 1813, 1817, 1816, 1819, 1819, 1818, 1817, 1821, 1820, 1823, 1823, 1822, 1821, - 1825, 1824, 1827, 1827, 1826, 1825, 1829, 1828, 1831, 1831, 1830, 1829, 1833, 1832, 1835, 1835, 1834, 1833, - 1837, 1836, 1839, 1839, 1838, 1837, 1841, 1840, 1843, 1843, 1842, 1841, 1845, 1844, 1847, 1847, 1846, 1845, - 1849, 1848, 1851, 1851, 1850, 1849, 1853, 1852, 1855, 1855, 1854, 1853, 1857, 1856, 1859, 1859, 1858, 1857, - 1861, 1860, 1863, 1863, 1862, 1861, 1865, 1864, 1867, 1867, 1866, 1865, 1869, 1868, 1871, 1871, 1870, 1869, - 1873, 1872, 1875, 1875, 1874, 1873, 1877, 1876, 1879, 1879, 1878, 1877, 1881, 1880, 1883, 1883, 1882, 1881, - 1885, 1884, 1887, 1887, 1886, 1885, 1889, 1888, 1891, 1891, 1890, 1889, 1893, 1892, 1895, 1895, 1894, 1893, - 1897, 1896, 1899, 1899, 1898, 1897, 1901, 1900, 1903, 1903, 1902, 1901, 1905, 1904, 1907, 1907, 1906, 1905, - 1909, 1908, 1911, 1911, 1910, 1909, 1913, 1912, 1915, 1915, 1914, 1913, 1917, 1916, 1919, 1919, 1918, 1917, - 1921, 1920, 1923, 1923, 1922, 1921, 1925, 1924, 1927, 1927, 1926, 1925, 1929, 1928, 1931, 1931, 1930, 1929, - 1933, 1932, 1935, 1935, 1934, 1933, 1937, 1936, 1939, 1939, 1938, 1937, 1941, 1940, 1943, 1943, 1942, 1941, - 1945, 1944, 1947, 1947, 1946, 1945, 1949, 1948, 1951, 1951, 1950, 1949, 1953, 1952, 1955, 1955, 1954, 1953, - 1957, 1956, 1959, 1959, 1958, 1957, 1961, 1960, 1963, 1963, 1962, 1961, 1965, 1964, 1967, 1967, 1966, 1965, - 1969, 1968, 1971, 1971, 1970, 1969, 1973, 1972, 1975, 1975, 1974, 1973, 1977, 1976, 1979, 1979, 1978, 1977, - 1981, 1980, 1983, 1983, 1982, 1981, 1985, 1984, 1987, 1987, 1986, 1985, 1989, 1988, 1991, 1991, 1990, 1989, - 1993, 1992, 1995, 1995, 1994, 1993, 1997, 1996, 1999, 1999, 1998, 1997, 2001, 2000, 2003, 2003, 2002, 2001, - 2005, 2004, 2007, 2007, 2006, 2005, 2009, 2008, 2011, 2011, 2010, 2009, 2013, 2012, 2015, 2015, 2014, 2013, - 2017, 2016, 2019, 2019, 2018, 2017, 2021, 2020, 2023, 2023, 2022, 2021, 2025, 2024, 2027, 2027, 2026, 2025, - 2029, 2028, 2031, 2031, 2030, 2029, 2033, 2032, 2035, 2035, 2034, 2033, 2037, 2036, 2039, 2039, 2038, 2037, - 2041, 2040, 2043, 2043, 2042, 2041, 2045, 2044, 2047, 2047, 2046, 2045 -}; + 1, 0, 3, 3, 2, 1, 5, 4, 7, 7, 6, 5, 9, 8, 11, 11, 10, 9, + 13, 12, 15, 15, 14, 13, 17, 16, 19, 19, 18, 17, 21, 20, 23, 23, 22, 21, + 25, 24, 27, 27, 26, 25, 29, 28, 31, 31, 30, 29, 33, 32, 35, 35, 34, 33, + 37, 36, 39, 39, 38, 37, 41, 40, 43, 43, 42, 41, 45, 44, 47, 47, 46, 45, + 49, 48, 51, 51, 50, 49, 53, 52, 55, 55, 54, 53, 57, 56, 59, 59, 58, 57, + 61, 60, 63, 63, 62, 61, 65, 64, 67, 67, 66, 65, 69, 68, 71, 71, 70, 69, + 73, 72, 75, 75, 74, 73, 77, 76, 79, 79, 78, 77, 81, 80, 83, 83, 82, 81, + 85, 84, 87, 87, 86, 85, 89, 88, 91, 91, 90, 89, 93, 92, 95, 95, 94, 93, + 97, 96, 99, 99, 98, 97, 101, 100, 103, 103, 102, 101, 105, 104, 107, 107, 106, 105, + 109, 108, 111, 111, 110, 109, 113, 112, 115, 115, 114, 113, 117, 116, 119, 119, 118, 117, + 121, 120, 123, 123, 122, 121, 125, 124, 127, 127, 126, 125, 129, 128, 131, 131, 130, 129, + 133, 132, 135, 135, 134, 133, 137, 136, 139, 139, 138, 137, 141, 140, 143, 143, 142, 141, + 145, 144, 147, 147, 146, 145, 149, 148, 151, 151, 150, 149, 153, 152, 155, 155, 154, 153, + 157, 156, 159, 159, 158, 157, 161, 160, 163, 163, 162, 161, 165, 164, 167, 167, 166, 165, + 169, 168, 171, 171, 170, 169, 173, 172, 175, 175, 174, 173, 177, 176, 179, 179, 178, 177, + 181, 180, 183, 183, 182, 181, 185, 184, 187, 187, 186, 185, 189, 188, 191, 191, 190, 189, + 193, 192, 195, 195, 194, 193, 197, 196, 199, 199, 198, 197, 201, 200, 203, 203, 202, 201, + 205, 204, 207, 207, 206, 205, 209, 208, 211, 211, 210, 209, 213, 212, 215, 215, 214, 213, + 217, 216, 219, 219, 218, 217, 221, 220, 223, 223, 222, 221, 225, 224, 227, 227, 226, 225, + 229, 228, 231, 231, 230, 229, 233, 232, 235, 235, 234, 233, 237, 236, 239, 239, 238, 237, + 241, 240, 243, 243, 242, 241, 245, 244, 247, 247, 246, 245, 249, 248, 251, 251, 250, 249, + 253, 252, 255, 255, 254, 253, 257, 256, 259, 259, 258, 257, 261, 260, 263, 263, 262, 261, + 265, 264, 267, 267, 266, 265, 269, 268, 271, 271, 270, 269, 273, 272, 275, 275, 274, 273, + 277, 276, 279, 279, 278, 277, 281, 280, 283, 283, 282, 281, 285, 284, 287, 287, 286, 285, + 289, 288, 291, 291, 290, 289, 293, 292, 295, 295, 294, 293, 297, 296, 299, 299, 298, 297, + 301, 300, 303, 303, 302, 301, 305, 304, 307, 307, 306, 305, 309, 308, 311, 311, 310, 309, + 313, 312, 315, 315, 314, 313, 317, 316, 319, 319, 318, 317, 321, 320, 323, 323, 322, 321, + 325, 324, 327, 327, 326, 325, 329, 328, 331, 331, 330, 329, 333, 332, 335, 335, 334, 333, + 337, 336, 339, 339, 338, 337, 341, 340, 343, 343, 342, 341, 345, 344, 347, 347, 346, 345, + 349, 348, 351, 351, 350, 349, 353, 352, 355, 355, 354, 353, 357, 356, 359, 359, 358, 357, + 361, 360, 363, 363, 362, 361, 365, 364, 367, 367, 366, 365, 369, 368, 371, 371, 370, 369, + 373, 372, 375, 375, 374, 373, 377, 376, 379, 379, 378, 377, 381, 380, 383, 383, 382, 381, + 385, 384, 387, 387, 386, 385, 389, 388, 391, 391, 390, 389, 393, 392, 395, 395, 394, 393, + 397, 396, 399, 399, 398, 397, 401, 400, 403, 403, 402, 401, 405, 404, 407, 407, 406, 405, + 409, 408, 411, 411, 410, 409, 413, 412, 415, 415, 414, 413, 417, 416, 419, 419, 418, 417, + 421, 420, 423, 423, 422, 421, 425, 424, 427, 427, 426, 425, 429, 428, 431, 431, 430, 429, + 433, 432, 435, 435, 434, 433, 437, 436, 439, 439, 438, 437, 441, 440, 443, 443, 442, 441, + 445, 444, 447, 447, 446, 445, 449, 448, 451, 451, 450, 449, 453, 452, 455, 455, 454, 453, + 457, 456, 459, 459, 458, 457, 461, 460, 463, 463, 462, 461, 465, 464, 467, 467, 466, 465, + 469, 468, 471, 471, 470, 469, 473, 472, 475, 475, 474, 473, 477, 476, 479, 479, 478, 477, + 481, 480, 483, 483, 482, 481, 485, 484, 487, 487, 486, 485, 489, 488, 491, 491, 490, 489, + 493, 492, 495, 495, 494, 493, 497, 496, 499, 499, 498, 497, 501, 500, 503, 503, 502, 501, + 505, 504, 507, 507, 506, 505, 509, 508, 511, 511, 510, 509, 513, 512, 515, 515, 514, 513, + 517, 516, 519, 519, 518, 517, 521, 520, 523, 523, 522, 521, 525, 524, 527, 527, 526, 525, + 529, 528, 531, 531, 530, 529, 533, 532, 535, 535, 534, 533, 537, 536, 539, 539, 538, 537, + 541, 540, 543, 543, 542, 541, 545, 544, 547, 547, 546, 545, 549, 548, 551, 551, 550, 549, + 553, 552, 555, 555, 554, 553, 557, 556, 559, 559, 558, 557, 561, 560, 563, 563, 562, 561, + 565, 564, 567, 567, 566, 565, 569, 568, 571, 571, 570, 569, 573, 572, 575, 575, 574, 573, + 577, 576, 579, 579, 578, 577, 581, 580, 583, 583, 582, 581, 585, 584, 587, 587, 586, 585, + 589, 588, 591, 591, 590, 589, 593, 592, 595, 595, 594, 593, 597, 596, 599, 599, 598, 597, + 601, 600, 603, 603, 602, 601, 605, 604, 607, 607, 606, 605, 609, 608, 611, 611, 610, 609, + 613, 612, 615, 615, 614, 613, 617, 616, 619, 619, 618, 617, 621, 620, 623, 623, 622, 621, + 625, 624, 627, 627, 626, 625, 629, 628, 631, 631, 630, 629, 633, 632, 635, 635, 634, 633, + 637, 636, 639, 639, 638, 637, 641, 640, 643, 643, 642, 641, 645, 644, 647, 647, 646, 645, + 649, 648, 651, 651, 650, 649, 653, 652, 655, 655, 654, 653, 657, 656, 659, 659, 658, 657, + 661, 660, 663, 663, 662, 661, 665, 664, 667, 667, 666, 665, 669, 668, 671, 671, 670, 669, + 673, 672, 675, 675, 674, 673, 677, 676, 679, 679, 678, 677, 681, 680, 683, 683, 682, 681, + 685, 684, 687, 687, 686, 685, 689, 688, 691, 691, 690, 689, 693, 692, 695, 695, 694, 693, + 697, 696, 699, 699, 698, 697, 701, 700, 703, 703, 702, 701, 705, 704, 707, 707, 706, 705, + 709, 708, 711, 711, 710, 709, 713, 712, 715, 715, 714, 713, 717, 716, 719, 719, 718, 717, + 721, 720, 723, 723, 722, 721, 725, 724, 727, 727, 726, 725, 729, 728, 731, 731, 730, 729, + 733, 732, 735, 735, 734, 733, 737, 736, 739, 739, 738, 737, 741, 740, 743, 743, 742, 741, + 745, 744, 747, 747, 746, 745, 749, 748, 751, 751, 750, 749, 753, 752, 755, 755, 754, 753, + 757, 756, 759, 759, 758, 757, 761, 760, 763, 763, 762, 761, 765, 764, 767, 767, 766, 765, + 769, 768, 771, 771, 770, 769, 773, 772, 775, 775, 774, 773, 777, 776, 779, 779, 778, 777, + 781, 780, 783, 783, 782, 781, 785, 784, 787, 787, 786, 785, 789, 788, 791, 791, 790, 789, + 793, 792, 795, 795, 794, 793, 797, 796, 799, 799, 798, 797, 801, 800, 803, 803, 802, 801, + 805, 804, 807, 807, 806, 805, 809, 808, 811, 811, 810, 809, 813, 812, 815, 815, 814, 813, + 817, 816, 819, 819, 818, 817, 821, 820, 823, 823, 822, 821, 825, 824, 827, 827, 826, 825, + 829, 828, 831, 831, 830, 829, 833, 832, 835, 835, 834, 833, 837, 836, 839, 839, 838, 837, + 841, 840, 843, 843, 842, 841, 845, 844, 847, 847, 846, 845, 849, 848, 851, 851, 850, 849, + 853, 852, 855, 855, 854, 853, 857, 856, 859, 859, 858, 857, 861, 860, 863, 863, 862, 861, + 865, 864, 867, 867, 866, 865, 869, 868, 871, 871, 870, 869, 873, 872, 875, 875, 874, 873, + 877, 876, 879, 879, 878, 877, 881, 880, 883, 883, 882, 881, 885, 884, 887, 887, 886, 885, + 889, 888, 891, 891, 890, 889, 893, 892, 895, 895, 894, 893, 897, 896, 899, 899, 898, 897, + 901, 900, 903, 903, 902, 901, 905, 904, 907, 907, 906, 905, 909, 908, 911, 911, 910, 909, + 913, 912, 915, 915, 914, 913, 917, 916, 919, 919, 918, 917, 921, 920, 923, 923, 922, 921, + 925, 924, 927, 927, 926, 925, 929, 928, 931, 931, 930, 929, 933, 932, 935, 935, 934, 933, + 937, 936, 939, 939, 938, 937, 941, 940, 943, 943, 942, 941, 945, 944, 947, 947, 946, 945, + 949, 948, 951, 951, 950, 949, 953, 952, 955, 955, 954, 953, 957, 956, 959, 959, 958, 957, + 961, 960, 963, 963, 962, 961, 965, 964, 967, 967, 966, 965, 969, 968, 971, 971, 970, 969, + 973, 972, 975, 975, 974, 973, 977, 976, 979, 979, 978, 977, 981, 980, 983, 983, 982, 981, + 985, 984, 987, 987, 986, 985, 989, 988, 991, 991, 990, 989, 993, 992, 995, 995, 994, 993, + 997, 996, 999, 999, 998, 997, 1001, 1000, 1003, 1003, 1002, 1001, 1005, 1004, 1007, 1007, 1006, 1005, + 1009, 1008, 1011, 1011, 1010, 1009, 1013, 1012, 1015, 1015, 1014, 1013, 1017, 1016, 1019, 1019, 1018, 1017, + 1021, 1020, 1023, 1023, 1022, 1021, 1025, 1024, 1027, 1027, 1026, 1025, 1029, 1028, 1031, 1031, 1030, 1029, + 1033, 1032, 1035, 1035, 1034, 1033, 1037, 1036, 1039, 1039, 1038, 1037, 1041, 1040, 1043, 1043, 1042, 1041, + 1045, 1044, 1047, 1047, 1046, 1045, 1049, 1048, 1051, 1051, 1050, 1049, 1053, 1052, 1055, 1055, 1054, 1053, + 1057, 1056, 1059, 1059, 1058, 1057, 1061, 1060, 1063, 1063, 1062, 1061, 1065, 1064, 1067, 1067, 1066, 1065, + 1069, 1068, 1071, 1071, 1070, 1069, 1073, 1072, 1075, 1075, 1074, 1073, 1077, 1076, 1079, 1079, 1078, 1077, + 1081, 1080, 1083, 1083, 1082, 1081, 1085, 1084, 1087, 1087, 1086, 1085, 1089, 1088, 1091, 1091, 1090, 1089, + 1093, 1092, 1095, 1095, 1094, 1093, 1097, 1096, 1099, 1099, 1098, 1097, 1101, 1100, 1103, 1103, 1102, 1101, + 1105, 1104, 1107, 1107, 1106, 1105, 1109, 1108, 1111, 1111, 1110, 1109, 1113, 1112, 1115, 1115, 1114, 1113, + 1117, 1116, 1119, 1119, 1118, 1117, 1121, 1120, 1123, 1123, 1122, 1121, 1125, 1124, 1127, 1127, 1126, 1125, + 1129, 1128, 1131, 1131, 1130, 1129, 1133, 1132, 1135, 1135, 1134, 1133, 1137, 1136, 1139, 1139, 1138, 1137, + 1141, 1140, 1143, 1143, 1142, 1141, 1145, 1144, 1147, 1147, 1146, 1145, 1149, 1148, 1151, 1151, 1150, 1149, + 1153, 1152, 1155, 1155, 1154, 1153, 1157, 1156, 1159, 1159, 1158, 1157, 1161, 1160, 1163, 1163, 1162, 1161, + 1165, 1164, 1167, 1167, 1166, 1165, 1169, 1168, 1171, 1171, 1170, 1169, 1173, 1172, 1175, 1175, 1174, 1173, + 1177, 1176, 1179, 1179, 1178, 1177, 1181, 1180, 1183, 1183, 1182, 1181, 1185, 1184, 1187, 1187, 1186, 1185, + 1189, 1188, 1191, 1191, 1190, 1189, 1193, 1192, 1195, 1195, 1194, 1193, 1197, 1196, 1199, 1199, 1198, 1197, + 1201, 1200, 1203, 1203, 1202, 1201, 1205, 1204, 1207, 1207, 1206, 1205, 1209, 1208, 1211, 1211, 1210, 1209, + 1213, 1212, 1215, 1215, 1214, 1213, 1217, 1216, 1219, 1219, 1218, 1217, 1221, 1220, 1223, 1223, 1222, 1221, + 1225, 1224, 1227, 1227, 1226, 1225, 1229, 1228, 1231, 1231, 1230, 1229, 1233, 1232, 1235, 1235, 1234, 1233, + 1237, 1236, 1239, 1239, 1238, 1237, 1241, 1240, 1243, 1243, 1242, 1241, 1245, 1244, 1247, 1247, 1246, 1245, + 1249, 1248, 1251, 1251, 1250, 1249, 1253, 1252, 1255, 1255, 1254, 1253, 1257, 1256, 1259, 1259, 1258, 1257, + 1261, 1260, 1263, 1263, 1262, 1261, 1265, 1264, 1267, 1267, 1266, 1265, 1269, 1268, 1271, 1271, 1270, 1269, + 1273, 1272, 1275, 1275, 1274, 1273, 1277, 1276, 1279, 1279, 1278, 1277, 1281, 1280, 1283, 1283, 1282, 1281, + 1285, 1284, 1287, 1287, 1286, 1285, 1289, 1288, 1291, 1291, 1290, 1289, 1293, 1292, 1295, 1295, 1294, 1293, + 1297, 1296, 1299, 1299, 1298, 1297, 1301, 1300, 1303, 1303, 1302, 1301, 1305, 1304, 1307, 1307, 1306, 1305, + 1309, 1308, 1311, 1311, 1310, 1309, 1313, 1312, 1315, 1315, 1314, 1313, 1317, 1316, 1319, 1319, 1318, 1317, + 1321, 1320, 1323, 1323, 1322, 1321, 1325, 1324, 1327, 1327, 1326, 1325, 1329, 1328, 1331, 1331, 1330, 1329, + 1333, 1332, 1335, 1335, 1334, 1333, 1337, 1336, 1339, 1339, 1338, 1337, 1341, 1340, 1343, 1343, 1342, 1341, + 1345, 1344, 1347, 1347, 1346, 1345, 1349, 1348, 1351, 1351, 1350, 1349, 1353, 1352, 1355, 1355, 1354, 1353, + 1357, 1356, 1359, 1359, 1358, 1357, 1361, 1360, 1363, 1363, 1362, 1361, 1365, 1364, 1367, 1367, 1366, 1365, + 1369, 1368, 1371, 1371, 1370, 1369, 1373, 1372, 1375, 1375, 1374, 1373, 1377, 1376, 1379, 1379, 1378, 1377, + 1381, 1380, 1383, 1383, 1382, 1381, 1385, 1384, 1387, 1387, 1386, 1385, 1389, 1388, 1391, 1391, 1390, 1389, + 1393, 1392, 1395, 1395, 1394, 1393, 1397, 1396, 1399, 1399, 1398, 1397, 1401, 1400, 1403, 1403, 1402, 1401, + 1405, 1404, 1407, 1407, 1406, 1405, 1409, 1408, 1411, 1411, 1410, 1409, 1413, 1412, 1415, 1415, 1414, 1413, + 1417, 1416, 1419, 1419, 1418, 1417, 1421, 1420, 1423, 1423, 1422, 1421, 1425, 1424, 1427, 1427, 1426, 1425, + 1429, 1428, 1431, 1431, 1430, 1429, 1433, 1432, 1435, 1435, 1434, 1433, 1437, 1436, 1439, 1439, 1438, 1437, + 1441, 1440, 1443, 1443, 1442, 1441, 1445, 1444, 1447, 1447, 1446, 1445, 1449, 1448, 1451, 1451, 1450, 1449, + 1453, 1452, 1455, 1455, 1454, 1453, 1457, 1456, 1459, 1459, 1458, 1457, 1461, 1460, 1463, 1463, 1462, 1461, + 1465, 1464, 1467, 1467, 1466, 1465, 1469, 1468, 1471, 1471, 1470, 1469, 1473, 1472, 1475, 1475, 1474, 1473, + 1477, 1476, 1479, 1479, 1478, 1477, 1481, 1480, 1483, 1483, 1482, 1481, 1485, 1484, 1487, 1487, 1486, 1485, + 1489, 1488, 1491, 1491, 1490, 1489, 1493, 1492, 1495, 1495, 1494, 1493, 1497, 1496, 1499, 1499, 1498, 1497, + 1501, 1500, 1503, 1503, 1502, 1501, 1505, 1504, 1507, 1507, 1506, 1505, 1509, 1508, 1511, 1511, 1510, 1509, + 1513, 1512, 1515, 1515, 1514, 1513, 1517, 1516, 1519, 1519, 1518, 1517, 1521, 1520, 1523, 1523, 1522, 1521, + 1525, 1524, 1527, 1527, 1526, 1525, 1529, 1528, 1531, 1531, 1530, 1529, 1533, 1532, 1535, 1535, 1534, 1533, + 1537, 1536, 1539, 1539, 1538, 1537, 1541, 1540, 1543, 1543, 1542, 1541, 1545, 1544, 1547, 1547, 1546, 1545, + 1549, 1548, 1551, 1551, 1550, 1549, 1553, 1552, 1555, 1555, 1554, 1553, 1557, 1556, 1559, 1559, 1558, 1557, + 1561, 1560, 1563, 1563, 1562, 1561, 1565, 1564, 1567, 1567, 1566, 1565, 1569, 1568, 1571, 1571, 1570, 1569, + 1573, 1572, 1575, 1575, 1574, 1573, 1577, 1576, 1579, 1579, 1578, 1577, 1581, 1580, 1583, 1583, 1582, 1581, + 1585, 1584, 1587, 1587, 1586, 1585, 1589, 1588, 1591, 1591, 1590, 1589, 1593, 1592, 1595, 1595, 1594, 1593, + 1597, 1596, 1599, 1599, 1598, 1597, 1601, 1600, 1603, 1603, 1602, 1601, 1605, 1604, 1607, 1607, 1606, 1605, + 1609, 1608, 1611, 1611, 1610, 1609, 1613, 1612, 1615, 1615, 1614, 1613, 1617, 1616, 1619, 1619, 1618, 1617, + 1621, 1620, 1623, 1623, 1622, 1621, 1625, 1624, 1627, 1627, 1626, 1625, 1629, 1628, 1631, 1631, 1630, 1629, + 1633, 1632, 1635, 1635, 1634, 1633, 1637, 1636, 1639, 1639, 1638, 1637, 1641, 1640, 1643, 1643, 1642, 1641, + 1645, 1644, 1647, 1647, 1646, 1645, 1649, 1648, 1651, 1651, 1650, 1649, 1653, 1652, 1655, 1655, 1654, 1653, + 1657, 1656, 1659, 1659, 1658, 1657, 1661, 1660, 1663, 1663, 1662, 1661, 1665, 1664, 1667, 1667, 1666, 1665, + 1669, 1668, 1671, 1671, 1670, 1669, 1673, 1672, 1675, 1675, 1674, 1673, 1677, 1676, 1679, 1679, 1678, 1677, + 1681, 1680, 1683, 1683, 1682, 1681, 1685, 1684, 1687, 1687, 1686, 1685, 1689, 1688, 1691, 1691, 1690, 1689, + 1693, 1692, 1695, 1695, 1694, 1693, 1697, 1696, 1699, 1699, 1698, 1697, 1701, 1700, 1703, 1703, 1702, 1701, + 1705, 1704, 1707, 1707, 1706, 1705, 1709, 1708, 1711, 1711, 1710, 1709, 1713, 1712, 1715, 1715, 1714, 1713, + 1717, 1716, 1719, 1719, 1718, 1717, 1721, 1720, 1723, 1723, 1722, 1721, 1725, 1724, 1727, 1727, 1726, 1725, + 1729, 1728, 1731, 1731, 1730, 1729, 1733, 1732, 1735, 1735, 1734, 1733, 1737, 1736, 1739, 1739, 1738, 1737, + 1741, 1740, 1743, 1743, 1742, 1741, 1745, 1744, 1747, 1747, 1746, 1745, 1749, 1748, 1751, 1751, 1750, 1749, + 1753, 1752, 1755, 1755, 1754, 1753, 1757, 1756, 1759, 1759, 1758, 1757, 1761, 1760, 1763, 1763, 1762, 1761, + 1765, 1764, 1767, 1767, 1766, 1765, 1769, 1768, 1771, 1771, 1770, 1769, 1773, 1772, 1775, 1775, 1774, 1773, + 1777, 1776, 1779, 1779, 1778, 1777, 1781, 1780, 1783, 1783, 1782, 1781, 1785, 1784, 1787, 1787, 1786, 1785, + 1789, 1788, 1791, 1791, 1790, 1789, 1793, 1792, 1795, 1795, 1794, 1793, 1797, 1796, 1799, 1799, 1798, 1797, + 1801, 1800, 1803, 1803, 1802, 1801, 1805, 1804, 1807, 1807, 1806, 1805, 1809, 1808, 1811, 1811, 1810, 1809, + 1813, 1812, 1815, 1815, 1814, 1813, 1817, 1816, 1819, 1819, 1818, 1817, 1821, 1820, 1823, 1823, 1822, 1821, + 1825, 1824, 1827, 1827, 1826, 1825, 1829, 1828, 1831, 1831, 1830, 1829, 1833, 1832, 1835, 1835, 1834, 1833, + 1837, 1836, 1839, 1839, 1838, 1837, 1841, 1840, 1843, 1843, 1842, 1841, 1845, 1844, 1847, 1847, 1846, 1845, + 1849, 1848, 1851, 1851, 1850, 1849, 1853, 1852, 1855, 1855, 1854, 1853, 1857, 1856, 1859, 1859, 1858, 1857, + 1861, 1860, 1863, 1863, 1862, 1861, 1865, 1864, 1867, 1867, 1866, 1865, 1869, 1868, 1871, 1871, 1870, 1869, + 1873, 1872, 1875, 1875, 1874, 1873, 1877, 1876, 1879, 1879, 1878, 1877, 1881, 1880, 1883, 1883, 1882, 1881, + 1885, 1884, 1887, 1887, 1886, 1885, 1889, 1888, 1891, 1891, 1890, 1889, 1893, 1892, 1895, 1895, 1894, 1893, + 1897, 1896, 1899, 1899, 1898, 1897, 1901, 1900, 1903, 1903, 1902, 1901, 1905, 1904, 1907, 1907, 1906, 1905, + 1909, 1908, 1911, 1911, 1910, 1909, 1913, 1912, 1915, 1915, 1914, 1913, 1917, 1916, 1919, 1919, 1918, 1917, + 1921, 1920, 1923, 1923, 1922, 1921, 1925, 1924, 1927, 1927, 1926, 1925, 1929, 1928, 1931, 1931, 1930, 1929, + 1933, 1932, 1935, 1935, 1934, 1933, 1937, 1936, 1939, 1939, 1938, 1937, 1941, 1940, 1943, 1943, 1942, 1941, + 1945, 1944, 1947, 1947, 1946, 1945, 1949, 1948, 1951, 1951, 1950, 1949, 1953, 1952, 1955, 1955, 1954, 1953, + 1957, 1956, 1959, 1959, 1958, 1957, 1961, 1960, 1963, 1963, 1962, 1961, 1965, 1964, 1967, 1967, 1966, 1965, + 1969, 1968, 1971, 1971, 1970, 1969, 1973, 1972, 1975, 1975, 1974, 1973, 1977, 1976, 1979, 1979, 1978, 1977, + 1981, 1980, 1983, 1983, 1982, 1981, 1985, 1984, 1987, 1987, 1986, 1985, 1989, 1988, 1991, 1991, 1990, 1989, + 1993, 1992, 1995, 1995, 1994, 1993, 1997, 1996, 1999, 1999, 1998, 1997, 2001, 2000, 2003, 2003, 2002, 2001, + 2005, 2004, 2007, 2007, 2006, 2005, 2009, 2008, 2011, 2011, 2010, 2009, 2013, 2012, 2015, 2015, 2014, 2013, + 2017, 2016, 2019, 2019, 2018, 2017, 2021, 2020, 2023, 2023, 2022, 2021, 2025, 2024, 2027, 2027, 2026, 2025, + 2029, 2028, 2031, 2031, 2030, 2029, 2033, 2032, 2035, 2035, 2034, 2033, 2037, 2036, 2039, 2039, 2038, 2037, + 2041, 2040, 2043, 2043, 2042, 2041, 2045, 2044, 2047, 2047, 2046, 2045}; -template +template T align(T value, int bytes) { return (value + bytes - 1) & ~T(bytes - 1); @@ -1369,9 +1375,9 @@ void IndexBuffer::accommodate(int count) // Map the new object and fill in the uninitialized section const GLbitfield access = GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_INVALIDATE_RANGE_BIT; - uint16_t *map = (uint16_t *) glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, m_size, size - m_size, access); + uint16_t *map = (uint16_t *)glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, m_size, size - m_size, access); - const uint16_t index[] = { 1, 0, 3, 3, 2, 1 }; + const uint16_t index[] = {1, 0, 3, 3, 2, 1}; for (int i = m_count; i < count; i++) { for (int j = 0; j < 6; j++) *(map++) = i * 4 + index[j]; @@ -1388,62 +1394,88 @@ void IndexBuffer::bind() glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_buffer); } - - // ------------------------------------------------------------------ - class BitRef { public: - BitRef(uint32_t &bitfield, int bit) : m_bitfield(bitfield), m_mask(1 << bit) {} + BitRef(uint32_t &bitfield, int bit) + : m_bitfield(bitfield) + , m_mask(1 << bit) + { + } - void operator = (bool val) { + void operator=(bool val) + { if (val) m_bitfield |= m_mask; else m_bitfield &= ~m_mask; } - operator bool () const { return m_bitfield & m_mask; } + operator bool() const + { + return m_bitfield & m_mask; + } private: uint32_t &m_bitfield; int const m_mask; }; - // ------------------------------------------------------------------ - class Bitfield { public: - Bitfield() : m_bitfield(0) {} - Bitfield(uint32_t bits) : m_bitfield(bits) {} + Bitfield() + : m_bitfield(0) + { + } + Bitfield(uint32_t bits) + : m_bitfield(bits) + { + } - void set(int i) { m_bitfield |= (1 << i); } - void clear(int i) { m_bitfield &= ~(1 << i); } + void set(int i) + { + m_bitfield |= (1 << i); + } + void clear(int i) + { + m_bitfield &= ~(1 << i); + } - BitRef operator [] (int i) { return BitRef(m_bitfield, i); } - operator uint32_t () const { return m_bitfield; } + BitRef operator[](int i) + { + return BitRef(m_bitfield, i); + } + operator uint32_t() const + { + return m_bitfield; + } private: uint32_t m_bitfield; }; - // ------------------------------------------------------------------ - class BitfieldIterator { public: - BitfieldIterator(uint32_t bitfield) : m_bitfield(bitfield) {} + BitfieldIterator(uint32_t bitfield) + : m_bitfield(bitfield) + { + } - bool hasNext() const { return m_bitfield != 0; } + bool hasNext() const + { + return m_bitfield != 0; + } - int next() { + int next() + { const int bit = ffs(m_bitfield) - 1; m_bitfield ^= (1 << bit); return bit; @@ -1453,12 +1485,8 @@ private: uint32_t m_bitfield; }; - - // ------------------------------------------------------------------ - - struct VertexAttrib { int size; @@ -1466,11 +1494,8 @@ struct VertexAttrib int offset; }; - // ------------------------------------------------------------------ - - struct BufferFence { GLsync sync; @@ -1484,7 +1509,6 @@ struct BufferFence } }; - static void deleteAll(std::deque &fences) { for (const BufferFence &fence : fences) @@ -1493,26 +1517,25 @@ static void deleteAll(std::deque &fences) fences.clear(); } - - // ------------------------------------------------------------------ - - -template +template struct FrameSizesArray { public: - FrameSizesArray() { + FrameSizesArray() + { m_array.fill(0); } - void push(size_t size) { + void push(size_t size) + { m_array[m_index] = size; m_index = (m_index + 1) % Count; } - size_t average() const { + size_t average() const + { size_t sum = 0; for (size_t size : m_array) sum += size; @@ -1524,8 +1547,6 @@ private: int m_index = 0; }; - - //********************************* // GLVertexBufferPrivate //********************************* @@ -1547,7 +1568,7 @@ public: { glGenBuffers(1, &buffer); - switch(usageHint) { + switch (usageHint) { case GLVertexBuffer::Dynamic: usage = GL_DYNAMIC_DRAW; break; @@ -1560,7 +1581,8 @@ public: } } - ~GLVertexBufferPrivate() { + ~GLVertexBufferPrivate() + { deleteAll(fences); if (buffer != 0) { @@ -1617,12 +1639,11 @@ void GLVertexBufferPrivate::interleaveArrays(float *dst, int dim, int count) { if (!texcoords) { - memcpy((void *) dst, vertices, dim * sizeof(float) * count); + memcpy((void *)dst, vertices, dim * sizeof(float) * count); return; } - switch (dim) - { + switch (dim) { case 2: for (int i = 0; i < count; i++) { *(dst++) = *(vertices++); @@ -1666,7 +1687,7 @@ void GLVertexBufferPrivate::bindArrays() while (it.hasNext()) { const int index = it.next(); glVertexAttribPointer(index, attrib[index].size, attrib[index].type, GL_FALSE, stride, - (const GLvoid *) (baseAddress + attrib[index].offset)); + (const GLvoid *)(baseAddress + attrib[index].offset)); glEnableVertexAttribArray(index); } } @@ -1701,7 +1722,7 @@ void GLVertexBufferPrivate::reallocatePersistentBuffer(size_t size) glBindBuffer(GL_ARRAY_BUFFER, buffer); glBufferStorage(GL_ARRAY_BUFFER, bufferSize, nullptr, storage | access); - map = (uint8_t *) glMapBufferRange(GL_ARRAY_BUFFER, 0, bufferSize, access); + map = (uint8_t *)glMapBufferRange(GL_ARRAY_BUFFER, 0, bufferSize, access); nextOffset = 0; bufferEnd = bufferSize; @@ -1798,7 +1819,6 @@ GLvoid *GLVertexBufferPrivate::mapNextFreeRange(size_t size) return glMapBufferRange(GL_ARRAY_BUFFER, nextOffset, size, access); } - //********************************* // GLVertexBuffer //********************************* @@ -1820,21 +1840,20 @@ void GLVertexBuffer::setData(const void *data, size_t size) unmap(); } -void GLVertexBuffer::setData(int vertexCount, int dim, const float* vertices, const float* texcoords) +void GLVertexBuffer::setData(int vertexCount, int dim, const float *vertices, const float *texcoords) { const GLVertexAttrib layout[] = { - { VA_Position, dim, GL_FLOAT, 0 }, - { VA_TexCoord, 2, GL_FLOAT, int(dim * sizeof(float)) } - }; + {VA_Position, dim, GL_FLOAT, 0}, + {VA_TexCoord, 2, GL_FLOAT, int(dim * sizeof(float))}}; - int stride = (texcoords ? dim + 2 : dim) * sizeof(float); - int attribCount = texcoords ? 2 : 1; + int stride = (texcoords ? dim + 2 : dim) * sizeof(float); + int attribCount = texcoords ? 2 : 1; setAttribLayout(layout, attribCount, stride); setVertexCount(vertexCount); GLvoid *ptr = map(vertexCount * stride); - d->interleaveArrays((float *) ptr, dim, vertices, texcoords, vertexCount); + d->interleaveArrays((float *)ptr, dim, vertices, texcoords, vertexCount); unmap(); } @@ -1851,7 +1870,7 @@ GLvoid *GLVertexBuffer::map(size_t size) bool preferBufferSubData = GLPlatform::instance()->preferBufferSubData(); if (GLVertexBufferPrivate::hasMapBufferRange && !preferBufferSubData) - return (GLvoid *) d->mapNextFreeRange(size); + return (GLvoid *)d->mapNextFreeRange(size); // If we can't map the buffer we allocate local memory to hold the // buffer data and return a pointer to it. The data will be submitted @@ -1859,7 +1878,7 @@ GLvoid *GLVertexBuffer::map(size_t size) if (size_t(d->dataStore.size()) < size) d->dataStore.resize(size); - return (GLvoid *) d->dataStore.data(); + return (GLvoid *)d->dataStore.data(); } void GLVertexBuffer::unmap() @@ -1898,7 +1917,6 @@ void GLVertexBuffer::unmap() // Free the local memory buffer if it's unlikely to be used again if (d->usage == GL_STATIC_DRAW) d->dataStore = QByteArray(); - } d->mappedSize = 0; @@ -1920,8 +1938,8 @@ void GLVertexBuffer::setAttribLayout(const GLVertexAttrib *attribs, int count, i Q_ASSERT(index >= 0 && index < VertexAttributeCount); Q_ASSERT(!d->enabledArrays[index]); - d->attrib[index].size = attribs[i].size; - d->attrib[index].type = attribs[i].type; + d->attrib[index].size = attribs[i].size; + d->attrib[index].type = attribs[i].type; d->attrib[index].offset = attribs[i].relativeOffset; d->enabledArrays[index] = true; @@ -1935,7 +1953,7 @@ void GLVertexBuffer::render(GLenum primitiveMode) render(infiniteRegion(), primitiveMode, false); } -void GLVertexBuffer::render(const QRegion& region, GLenum primitiveMode, bool hardwareClipping) +void GLVertexBuffer::render(const QRegion ®ion, GLenum primitiveMode, bool hardwareClipping) { d->bindArrays(); draw(region, primitiveMode, 0, d->vertexCount, hardwareClipping); @@ -2010,7 +2028,7 @@ void GLVertexBuffer::setUseColor(bool enable) d->useColor = enable; } -void GLVertexBuffer::setColor(const QColor& color, bool enable) +void GLVertexBuffer::setColor(const QColor &color, bool enable) { d->useColor = enable; d->color = QVector4D(color.redF(), color.greenF(), color.blueF(), color.alphaF()); @@ -2018,9 +2036,9 @@ void GLVertexBuffer::setColor(const QColor& color, bool enable) void GLVertexBuffer::reset() { - d->useColor = false; - d->color = QVector4D(0, 0, 0, 1); - d->vertexCount = 0; + d->useColor = false; + d->color = QVector4D(0, 0, 0, 1); + d->vertexCount = 0; } void GLVertexBuffer::endOfFrame() @@ -2072,8 +2090,8 @@ void GLVertexBuffer::beginFrame() void GLVertexBuffer::initStatic() { if (GLPlatform::instance()->isGLES()) { - bool haveBaseVertex = hasGLExtension(QByteArrayLiteral("GL_OES_draw_elements_base_vertex")); - bool haveCopyBuffer = hasGLVersion(3, 0); + bool haveBaseVertex = hasGLExtension(QByteArrayLiteral("GL_OES_draw_elements_base_vertex")); + bool haveCopyBuffer = hasGLVersion(3, 0); bool haveMapBufferRange = hasGLExtension(QByteArrayLiteral("GL_EXT_map_buffer_range")); GLVertexBufferPrivate::hasMapBufferRange = haveMapBufferRange; @@ -2081,8 +2099,8 @@ void GLVertexBuffer::initStatic() GLVertexBufferPrivate::haveBufferStorage = hasGLExtension("GL_EXT_buffer_storage"); GLVertexBufferPrivate::haveSyncFences = hasGLVersion(3, 0); } else { - bool haveBaseVertex = hasGLVersion(3, 2) || hasGLExtension(QByteArrayLiteral("GL_ARB_draw_elements_base_vertex")); - bool haveCopyBuffer = hasGLVersion(3, 1) || hasGLExtension(QByteArrayLiteral("GL_ARB_copy_buffer")); + bool haveBaseVertex = hasGLVersion(3, 2) || hasGLExtension(QByteArrayLiteral("GL_ARB_draw_elements_base_vertex")); + bool haveCopyBuffer = hasGLVersion(3, 1) || hasGLExtension(QByteArrayLiteral("GL_ARB_copy_buffer")); bool haveMapBufferRange = hasGLVersion(3, 0) || hasGLExtension(QByteArrayLiteral("GL_ARB_map_buffer_range")); GLVertexBufferPrivate::hasMapBufferRange = haveMapBufferRange; diff --git a/src/libkwineffects/kwinglutils.h b/src/libkwineffects/kwinglutils.h index 65ef298f50..c346364244 100644 --- a/src/libkwineffects/kwinglutils.h +++ b/src/libkwineffects/kwinglutils.h @@ -12,9 +12,9 @@ #define KWIN_GLUTILS_H // kwin -#include -#include "kwinglutils_funcs.h" #include "kwingltexture.h" +#include "kwinglutils_funcs.h" +#include // Qt #include @@ -28,8 +28,8 @@ class QVector3D; class QVector4D; class QMatrix4x4; -template< class K, class V > class QHash; - +template +class QHash; namespace KWin { @@ -41,17 +41,16 @@ class GLVertexBufferPrivate; // well as checking for GL version and extensions // Note that GL context has to be created by the time this function is called typedef void (*resolveFuncPtr)(); -void KWINGLUTILS_EXPORT initGL(const std::function &resolveFunction); +void KWINGLUTILS_EXPORT initGL(const std::function &resolveFunction); // Cleans up all resources hold by the GL Context void KWINGLUTILS_EXPORT cleanupGL(); - bool KWINGLUTILS_EXPORT hasGLVersion(int major, int minor, int release = 0); // use for both OpenGL and GLX extensions bool KWINGLUTILS_EXPORT hasGLExtension(const QByteArray &extension); // detect OpenGL error (add to various places in code to pinpoint the place) -bool KWINGLUTILS_EXPORT checkGLError(const char* txt); +bool KWINGLUTILS_EXPORT checkGLError(const char *txt); QList KWINGLUTILS_EXPORT openGLExtensions(); @@ -59,14 +58,15 @@ class KWINGLUTILS_EXPORT GLShader { public: enum Flags { - NoFlags = 0, + NoFlags = 0, ExplicitLinking = (1 << 0) }; GLShader(const QString &vertexfile, const QString &fragmentfile, unsigned int flags = NoFlags); ~GLShader(); - bool isValid() const { + bool isValid() const + { return mValid; } @@ -75,15 +75,15 @@ public: bool link(); - int uniformLocation(const char* name); + int uniformLocation(const char *name); - bool setUniform(const char* name, float value); - bool setUniform(const char* name, int value); - bool setUniform(const char* name, const QVector2D& value); - bool setUniform(const char* name, const QVector3D& value); - bool setUniform(const char* name, const QVector4D& value); - bool setUniform(const char* name, const QMatrix4x4& value); - bool setUniform(const char* name, const QColor& color); + bool setUniform(const char *name, float value); + bool setUniform(const char *name, int value); + bool setUniform(const char *name, const QVector2D &value); + bool setUniform(const char *name, const QVector3D &value); + bool setUniform(const char *name, const QVector4D &value); + bool setUniform(const char *name, const QMatrix4x4 &value); + bool setUniform(const char *name, const QColor &color); bool setUniform(int location, float value); bool setUniform(int location, int value); @@ -93,13 +93,13 @@ public: bool setUniform(int location, const QMatrix4x4 &value); bool setUniform(int location, const QColor &value); - int attributeLocation(const char* name); - bool setAttribute(const char* name, float value); + int attributeLocation(const char *name); + bool setAttribute(const char *name, float value); /** * @return The value of the uniform as a matrix * @since 4.7 */ - QMatrix4x4 getUniformMatrix4x4(const char* name); + QMatrix4x4 getUniformMatrix4x4(const char *name); enum MatrixUniform { TextureMatrix = 0, @@ -127,7 +127,7 @@ public: }; enum IntUniform { - AlphaToOne, ///< @deprecated no longer used + AlphaToOne, ///< @deprecated no longer used IntUniformCount }; @@ -137,16 +137,16 @@ public: }; bool setUniform(MatrixUniform uniform, const QMatrix4x4 &matrix); - bool setUniform(Vec2Uniform uniform, const QVector2D &value); - bool setUniform(Vec4Uniform uniform, const QVector4D &value); - bool setUniform(FloatUniform uniform, float value); - bool setUniform(IntUniform uniform, int value); - bool setUniform(ColorUniform uniform, const QVector4D &value); - bool setUniform(ColorUniform uniform, const QColor &value); + bool setUniform(Vec2Uniform uniform, const QVector2D &value); + bool setUniform(Vec4Uniform uniform, const QVector4D &value); + bool setUniform(FloatUniform uniform, float value); + bool setUniform(IntUniform uniform, int value); + bool setUniform(ColorUniform uniform, const QVector4D &value); + bool setUniform(ColorUniform uniform, const QColor &value); protected: GLShader(unsigned int flags = NoFlags); - bool loadFromFiles(const QString& vertexfile, const QString& fragmentfile); + bool loadFromFiles(const QString &vertexfile, const QString &fragmentfile); bool load(const QByteArray &vertexSource, const QByteArray &fragmentSource); const QByteArray prepareSource(GLenum shaderType, const QByteArray &sourceCode) const; bool compile(GLuint program, GLenum shaderType, const QByteArray &sourceCode) const; @@ -156,9 +156,9 @@ protected: private: unsigned int mProgram; - bool mValid:1; - bool mLocationsResolved:1; - bool mExplicitLinking:1; + bool mValid : 1; + bool mLocationsResolved : 1; + bool mExplicitLinking : 1; int mMatrixLocation[MatrixCount]; int mVec2Location[Vec2UniformCount]; int mVec4Location[Vec4UniformCount]; @@ -169,17 +169,15 @@ private: friend class ShaderManager; }; - enum class ShaderTrait { - MapTexture = (1 << 0), - UniformColor = (1 << 1), - Modulate = (1 << 2), + MapTexture = (1 << 0), + UniformColor = (1 << 1), + Modulate = (1 << 2), AdjustSaturation = (1 << 3), }; Q_DECLARE_FLAGS(ShaderTraits, ShaderTrait) - /** * @short Manager for Shaders. * @@ -303,7 +301,7 @@ private: QByteArray generateFragmentSource(ShaderTraits traits) const; GLShader *generateShader(ShaderTraits traits); - QStack m_boundShaders; + QStack m_boundShaders; QHash m_shaderHash; static ShaderManager *s_shaderManager; }; @@ -353,28 +351,24 @@ private: GLShader *m_shader; }; -inline -ShaderBinder::ShaderBinder(GLShader *shader) +inline ShaderBinder::ShaderBinder(GLShader *shader) : m_shader(shader) { ShaderManager::instance()->pushShader(shader); } -inline -ShaderBinder::ShaderBinder(ShaderTraits traits) +inline ShaderBinder::ShaderBinder(ShaderTraits traits) : m_shader(nullptr) { m_shader = ShaderManager::instance()->pushShader(traits); } -inline -ShaderBinder::~ShaderBinder() +inline ShaderBinder::~ShaderBinder() { ShaderManager::instance()->popShader(); } -inline -GLShader* ShaderBinder::shader() +inline GLShader *ShaderBinder::shader() { return m_shader; } @@ -414,21 +408,25 @@ public: /** * Returns the framebuffer object handle to this render target object. */ - GLuint handle() const { + GLuint handle() const + { return mFramebuffer; } /** * Returns the size of the color attachment to this render target object. */ - QSize size() const { + QSize size() const + { return mSize; } - bool valid() const { + bool valid() const + { return mValid; } static void initStatic(); - static bool supported() { + static bool supported() + { return sSupported; } @@ -442,7 +440,7 @@ public: * @param targets The stack of GLRenderTargets * @since 5.13 */ - static void pushRenderTargets(QStack targets); + static void pushRenderTargets(QStack targets); static void pushRenderTarget(GLRenderTarget *target); static GLRenderTarget *popRenderTarget(); @@ -480,7 +478,7 @@ private: static void cleanup(); static bool sSupported; static bool s_blitSupported; - static QStack s_renderTargets; + static QStack s_renderTargets; GLuint mFramebuffer = 0; QSize mSize; @@ -503,10 +501,10 @@ enum VertexAttributeType { */ struct GLVertexAttrib { - int index; /** The attribute index */ - int size; /** The number of components [1..4] */ - GLenum type; /** The type (e.g. GL_FLOAT) */ - int relativeOffset; /** The relative offset of the attribute */ + int index; /** The attribute index */ + int size; /** The number of components [1..4] */ + GLenum type; /** The type (e.g. GL_FLOAT) */ + int relativeOffset; /** The relative offset of the attribute */ }; /** @@ -582,7 +580,7 @@ public: * @param texcoords The texture coordinates for each vertex. * Size must equal 2 * @a numberVertices. */ - void setData(int numberVertices, int dim, const float* vertices, const float* texcoords); + void setData(int numberVertices, int dim, const float *vertices, const float *texcoords); /** * Maps an unused range of the data store into the client's address space. @@ -640,7 +638,7 @@ public: * Same as above restricting painting to @a region if @a hardwareClipping is true. * It's within the caller's responsibility to enable GL_SCISSOR_TEST. */ - void render(const QRegion& region, GLenum primitiveMode, bool hardwareClipping = false); + void render(const QRegion ®ion, GLenum primitiveMode, bool hardwareClipping = false); /** * Sets the color the geometry will be rendered with. * For legacy rendering glColor is used before rendering the geometry. @@ -651,7 +649,7 @@ public: * @see isUseColor * @since 4.7 */ - void setColor(const QColor& color, bool enableColor = true); + void setColor(const QColor &color, bool enableColor = true); /** * @return @c true if geometry will be painted with a color, @c false otherwise * @see setUseColor @@ -712,7 +710,7 @@ public: static GLVertexBuffer *streamingBuffer(); private: - GLVertexBufferPrivate* const d; + GLVertexBufferPrivate *const d; }; } // namespace diff --git a/src/libkwineffects/kwinglutils_funcs.cpp b/src/libkwineffects/kwinglutils_funcs.cpp index 4bee3f3a29..96ae0ca06a 100644 --- a/src/libkwineffects/kwinglutils_funcs.cpp +++ b/src/libkwineffects/kwinglutils_funcs.cpp @@ -7,14 +7,13 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include "kwinglutils.h" #include "kwinglplatform.h" - +#include "kwinglutils.h" // Resolves given function, using getProcAddress // Useful when functionality is defined in an extension with a different name -#define GL_RESOLVE_WITH_EXT( function, symbolName ) \ - function = (function ## _func)resolveFunction( #symbolName ); +#define GL_RESOLVE_WITH_EXT(function, symbolName) \ + function = (function##_func)resolveFunction(#symbolName); namespace KWin { @@ -26,10 +25,10 @@ static void GetnUniformfv(GLuint program, GLint location, GLsizei bufSize, GLflo // GL_ARB_robustness / GL_EXT_robustness glGetGraphicsResetStatus_func glGetGraphicsResetStatus; -glReadnPixels_func glReadnPixels; -glGetnUniformfv_func glGetnUniformfv; +glReadnPixels_func glReadnPixels; +glGetnUniformfv_func glGetnUniformfv; -void glResolveFunctions(const std::function &resolveFunction) +void glResolveFunctions(const std::function &resolveFunction) { const bool haveArbRobustness = hasGLExtension(QByteArrayLiteral("GL_ARB_robustness")); const bool haveExtRobustness = hasGLExtension(QByteArrayLiteral("GL_EXT_robustness")); @@ -56,17 +55,17 @@ void glResolveFunctions(const std::function &resolv if (robustContext && haveArbRobustness) { // See https://www.opengl.org/registry/specs/ARB/robustness.txt GL_RESOLVE_WITH_EXT(glGetGraphicsResetStatus, glGetGraphicsResetStatusARB); - GL_RESOLVE_WITH_EXT(glReadnPixels, glReadnPixelsARB); - GL_RESOLVE_WITH_EXT(glGetnUniformfv, glGetnUniformfvARB); + GL_RESOLVE_WITH_EXT(glReadnPixels, glReadnPixelsARB); + GL_RESOLVE_WITH_EXT(glGetnUniformfv, glGetnUniformfvARB); } else if (robustContext && haveExtRobustness) { // See https://www.khronos.org/registry/gles/extensions/EXT/EXT_robustness.txt - glGetGraphicsResetStatus = (glGetGraphicsResetStatus_func) resolveFunction("glGetGraphicsResetStatusEXT"); - glReadnPixels = (glReadnPixels_func) resolveFunction("glReadnPixelsEXT"); - glGetnUniformfv = (glGetnUniformfv_func) resolveFunction("glGetnUniformfvEXT"); + glGetGraphicsResetStatus = (glGetGraphicsResetStatus_func)resolveFunction("glGetGraphicsResetStatusEXT"); + glReadnPixels = (glReadnPixels_func)resolveFunction("glReadnPixelsEXT"); + glGetnUniformfv = (glGetnUniformfv_func)resolveFunction("glGetnUniformfvEXT"); } else { glGetGraphicsResetStatus = KWin::GetGraphicsResetStatus; - glReadnPixels = KWin::ReadnPixels; - glGetnUniformfv = KWin::GetnUniformfv; + glReadnPixels = KWin::ReadnPixels; + glGetnUniformfv = KWin::GetnUniformfv; } } diff --git a/src/libkwineffects/kwinglutils_funcs.h b/src/libkwineffects/kwinglutils_funcs.h index aaa6a11e73..d855d45ed3 100644 --- a/src/libkwineffects/kwinglutils_funcs.h +++ b/src/libkwineffects/kwinglutils_funcs.h @@ -32,7 +32,7 @@ namespace KWin { typedef void (*resolveFuncPtr)(); -void KWINGLUTILS_EXPORT glResolveFunctions(const std::function &resolveFunction); +void KWINGLUTILS_EXPORT glResolveFunctions(const std::function &resolveFunction); // GL_ARB_robustness / GL_EXT_robustness using glGetGraphicsResetStatus_func = GLenum (*)(); @@ -41,8 +41,8 @@ using glReadnPixels_func = void (*)(GLint x, GLint y, GLsizei width, GLsizei hei using glGetnUniformfv_func = void (*)(GLuint program, GLint location, GLsizei bufSize, GLfloat *params); extern KWINGLUTILS_EXPORT glGetGraphicsResetStatus_func glGetGraphicsResetStatus; -extern KWINGLUTILS_EXPORT glReadnPixels_func glReadnPixels; -extern KWINGLUTILS_EXPORT glGetnUniformfv_func glGetnUniformfv; +extern KWINGLUTILS_EXPORT glReadnPixels_func glReadnPixels; +extern KWINGLUTILS_EXPORT glGetnUniformfv_func glGetnUniformfv; } // namespace diff --git a/src/libkwineffects/kwinoffscreenquickview.cpp b/src/libkwineffects/kwinoffscreenquickview.cpp index 1480e6f86e..cdcadb14a9 100644 --- a/src/libkwineffects/kwinoffscreenquickview.cpp +++ b/src/libkwineffects/kwinoffscreenquickview.cpp @@ -14,13 +14,12 @@ #include "sharedqmlengine.h" #include +#include +#include #include #include -#include -#include -#include -#include #include +#include #include #include @@ -89,7 +88,7 @@ public: void releaseResources(); - void updateTouchState(Qt::TouchPointState state, qint32 id, const QPointF& pos); + void updateTouchState(Qt::TouchPointState state, qint32 id, const QPointF &pos); }; class Q_DECL_HIDDEN OffscreenQuickScene::Private @@ -98,7 +97,6 @@ public: Private() : qmlEngine(SharedQmlEngine::engine()) { - } SharedQmlEngine::Ptr qmlEngine; @@ -170,7 +168,9 @@ OffscreenQuickView::OffscreenQuickView(QObject *parent, QWindow *renderWindow, E } } - auto updateSize = [this]() { contentItem()->setSize(d->m_view->size()); }; + auto updateSize = [this]() { + contentItem()->setSize(d->m_view->size()); + }; updateSize(); connect(d->m_view, &QWindow::widthChanged, this, updateSize); connect(d->m_view, &QWindow::heightChanged, this, updateSize); @@ -297,8 +297,7 @@ void OffscreenQuickView::forwardMouseEvent(QEvent *e) switch (e->type()) { case QEvent::MouseMove: case QEvent::MouseButtonPress: - case QEvent::MouseButtonRelease: - { + case QEvent::MouseButtonRelease: { QMouseEvent *me = static_cast(e); const QPoint widgetPos = d->m_view->mapFromGlobal(me->pos()); QMouseEvent cloneEvent(me->type(), widgetPos, me->pos(), me->button(), me->buttons(), me->modifiers()); @@ -321,8 +320,7 @@ void OffscreenQuickView::forwardMouseEvent(QEvent *e) } case QEvent::HoverEnter: case QEvent::HoverLeave: - case QEvent::HoverMove: - { + case QEvent::HoverMove: { QHoverEvent *he = static_cast(e); const QPointF widgetPos = d->m_view->mapFromGlobal(he->pos()); const QPointF oldWidgetPos = d->m_view->mapFromGlobal(he->oldPos()); @@ -331,8 +329,7 @@ void OffscreenQuickView::forwardMouseEvent(QEvent *e) e->setAccepted(cloneEvent.isAccepted()); return; } - case QEvent::Wheel: - { + case QEvent::Wheel: { QWheelEvent *we = static_cast(e); const QPointF widgetPos = d->m_view->mapFromGlobal(we->position().toPoint()); QWheelEvent cloneEvent(widgetPos, we->globalPosition(), we->pixelDelta(), we->angleDelta(), we->buttons(), @@ -429,7 +426,7 @@ void OffscreenQuickView::setVisible(bool visible) } d->m_visible = visible; - if (visible){ + if (visible) { Q_EMIT d->m_renderControl->renderRequested(); } else { // deferred to not change GL context @@ -507,16 +504,17 @@ void OffscreenQuickView::Private::updateTouchState(Qt::TouchPointState state, qi // points to Stationary so we only have one touch point with a different // state. touchPoints.erase(std::remove_if(touchPoints.begin(), touchPoints.end(), [](QTouchEvent::TouchPoint &point) { - if (point.state() == Qt::TouchPointReleased) { - return true; - } + if (point.state() == Qt::TouchPointReleased) { + return true; + } #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - point.setState(Qt::TouchPointStationary); + point.setState(Qt::TouchPointStationary); #else - static_cast(point).setState(QEventPoint::Stationary); + static_cast(point).setState(QEventPoint::Stationary); #endif - return false; - }), touchPoints.end()); + return false; + }), + touchPoints.end()); // QtQuick Pointer Handlers incorrectly consider a touch point with ID 0 // to be an invalid touch point. This has been fixed in Qt 6 but could not @@ -532,63 +530,60 @@ void OffscreenQuickView::Private::updateTouchState(Qt::TouchPointState state, qi switch (state) { case Qt::TouchPointPressed: { - if (changed != touchPoints.end()) { - return; - } + if (changed != touchPoints.end()) { + return; + } #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QTouchEvent::TouchPoint point; - point.setState(Qt::TouchPointPressed); + QTouchEvent::TouchPoint point; + point.setState(Qt::TouchPointPressed); #else - QMutableEventPoint point; - point.setState(QEventPoint::Pressed); + QMutableEventPoint point; + point.setState(QEventPoint::Pressed); #endif - point.setId(id + idOffset); - point.setScreenPos(pos); - point.setScenePos(m_view->mapFromGlobal(pos.toPoint())); - point.setPos(m_view->mapFromGlobal(pos.toPoint())); + point.setId(id + idOffset); + point.setScreenPos(pos); + point.setScenePos(m_view->mapFromGlobal(pos.toPoint())); + point.setPos(m_view->mapFromGlobal(pos.toPoint())); - touchPoints.append(point); - } - break; + touchPoints.append(point); + } break; case Qt::TouchPointMoved: { - if (changed == touchPoints.end()) { - return; - } + if (changed == touchPoints.end()) { + return; + } #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - auto &point = *changed; - point.setLastPos(point.pos()); - point.setLastScenePos(point.scenePos()); - point.setLastScreenPos(point.screenPos()); - point.setState(Qt::TouchPointMoved); + auto &point = *changed; + point.setLastPos(point.pos()); + point.setLastScenePos(point.scenePos()); + point.setLastScreenPos(point.screenPos()); + point.setState(Qt::TouchPointMoved); #else - auto &point = static_cast(*changed); - point.setGlobalLastPosition(point.globalPosition()); - point.setState(QEventPoint::Updated); + auto &point = static_cast(*changed); + point.setGlobalLastPosition(point.globalPosition()); + point.setState(QEventPoint::Updated); #endif - point.setScenePos(m_view->mapFromGlobal(pos.toPoint())); - point.setPos(m_view->mapFromGlobal(pos.toPoint())); - point.setScreenPos(pos); - } - break; + point.setScenePos(m_view->mapFromGlobal(pos.toPoint())); + point.setPos(m_view->mapFromGlobal(pos.toPoint())); + point.setScreenPos(pos); + } break; case Qt::TouchPointReleased: { - if (changed == touchPoints.end()) { - return; - } + if (changed == touchPoints.end()) { + return; + } #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - auto &point = *changed; - point.setLastPos(point.pos()); - point.setLastScreenPos(point.screenPos()); - point.setState(Qt::TouchPointReleased); + auto &point = *changed; + point.setLastPos(point.pos()); + point.setLastScreenPos(point.screenPos()); + point.setState(Qt::TouchPointReleased); #else - auto &point = static_cast(*changed); - point.setGlobalLastPosition(point.globalPosition()); - point.setState(QEventPoint::Released); + auto &point = static_cast(*changed); + point.setGlobalLastPosition(point.globalPosition()); + point.setState(QEventPoint::Released); #endif - } - break; + } break; default: break; } @@ -655,7 +650,9 @@ void OffscreenQuickScene::setSource(const QUrl &source) item->setParentItem(contentItem()); - auto updateSize = [item, this]() { item->setSize(contentItem()->size()); }; + auto updateSize = [item, this]() { + item->setSize(contentItem()->size()); + }; updateSize(); connect(contentItem(), &QQuickItem::widthChanged, item, updateSize); connect(contentItem(), &QQuickItem::heightChanged, item, updateSize); diff --git a/src/libkwineffects/kwinoffscreenquickview.h b/src/libkwineffects/kwinoffscreenquickview.h index 85cdfaff6e..ed42d9234e 100644 --- a/src/libkwineffects/kwinoffscreenquickview.h +++ b/src/libkwineffects/kwinoffscreenquickview.h @@ -10,8 +10,8 @@ #pragma once #include -#include #include +#include #include diff --git a/src/libkwineffects/kwinquickeffect.cpp b/src/libkwineffects/kwinquickeffect.cpp index 4b1c579b39..fc7b374cb1 100644 --- a/src/libkwineffects/kwinquickeffect.cpp +++ b/src/libkwineffects/kwinquickeffect.cpp @@ -8,8 +8,8 @@ #include "sharedqmlengine.h" -#include #include +#include #include namespace KWin @@ -18,7 +18,10 @@ namespace KWin class QuickSceneEffectPrivate { public: - static QuickSceneEffectPrivate *get(QuickSceneEffect *effect) { return effect->d.data(); } + static QuickSceneEffectPrivate *get(QuickSceneEffect *effect) + { + return effect->d.data(); + } SharedQmlEngine::Ptr qmlEngine; QScopedPointer qmlComponent; @@ -56,7 +59,9 @@ void QuickSceneView::setRootItem(QQuickItem *item) m_rootItem.reset(item); m_rootItem->setParentItem(contentItem()); - auto updateSize = [this]() { m_rootItem->setSize(contentItem()->size()); }; + auto updateSize = [this]() { + m_rootItem->setSize(contentItem()->size()); + }; updateSize(); connect(contentItem(), &QQuickItem::widthChanged, m_rootItem.data(), updateSize); connect(contentItem(), &QQuickItem::heightChanged, m_rootItem.data(), updateSize); diff --git a/src/libkwineffects/kwinquickeffect.h b/src/libkwineffects/kwinquickeffect.h index 8e3be51952..6a827f962c 100644 --- a/src/libkwineffects/kwinquickeffect.h +++ b/src/libkwineffects/kwinquickeffect.h @@ -6,8 +6,8 @@ #pragma once -#include "kwinoffscreenquickview.h" #include "kwineffects.h" +#include "kwinoffscreenquickview.h" namespace KWin { diff --git a/src/libkwineffects/kwinxrenderutils.cpp b/src/libkwineffects/kwinxrenderutils.cpp index 1ee6f411af..a930605e86 100644 --- a/src/libkwineffects/kwinxrenderutils.cpp +++ b/src/libkwineffects/kwinxrenderutils.cpp @@ -11,9 +11,9 @@ #include "logging_p.h" #include -#include -#include #include +#include +#include namespace KWin { @@ -48,9 +48,9 @@ xcb_render_color_t preMultiply(const QColor &c, float opacity) G = c.green(), B = c.blue(); color.alpha = (A | A << 8); - color.red = (R | R << 8) * color.alpha / 0x10000; + color.red = (R | R << 8) * color.alpha / 0x10000; color.green = (G | G << 8) * color.alpha / 0x10000; - color.blue = (B | B << 8) * color.alpha / 0x10000; + color.blue = (B | B << 8) * color.alpha / 0x10000; return color; } @@ -99,8 +99,8 @@ static xcb_render_picture_t createPicture(xcb_pixmap_t pix, int depth) return XCB_RENDER_PICTURE_NONE; } for (xcb_render_pictforminfo_iterator_t it = xcb_render_query_pict_formats_formats_iterator(formats); - it.rem; - xcb_render_pictforminfo_next(&it)) { + it.rem; + xcb_render_pictforminfo_next(&it)) { if (it.data->depth == depth) { s_renderFormats.insert(depth, it.data->id); break; @@ -175,7 +175,7 @@ XFixesRegion::~XFixesRegion() } static xcb_render_picture_t s_offscreenTarget = XCB_RENDER_PICTURE_NONE; -static QStack s_scene_offscreenTargetStack; +static QStack s_scene_offscreenTargetStack; static int s_renderOffscreen = 0; void scene_setXRenderOffscreenTarget(xcb_render_picture_t pix) @@ -228,10 +228,11 @@ namespace XRenderUtils struct PictFormatData { - PictFormatData() { + PictFormatData() + { // Fetch the render pict formats reply = xcb_render_query_pict_formats_reply(s_connection, - xcb_render_query_pict_formats_unchecked(s_connection), nullptr); + xcb_render_query_pict_formats_unchecked(s_connection), nullptr); // Init the visual ID -> format ID hash table for (auto screens = xcb_render_query_pict_formats_screens_iterator(reply); screens.rem; xcb_render_pictscreen_next(&screens)) { @@ -254,7 +255,8 @@ struct PictFormatData } } - ~PictFormatData() { + ~PictFormatData() + { free(reply); } diff --git a/src/libkwineffects/kwinxrenderutils.h b/src/libkwineffects/kwinxrenderutils.h index 61d377d3bc..a4b888ac03 100644 --- a/src/libkwineffects/kwinxrenderutils.h +++ b/src/libkwineffects/kwinxrenderutils.h @@ -40,6 +40,7 @@ public: explicit XRenderPictureData(xcb_render_picture_t pic = XCB_RENDER_PICTURE_NONE); ~XRenderPictureData(); xcb_render_picture_t value(); + private: xcb_render_picture_t picture; Q_DISABLE_COPY(XRenderPictureData) @@ -59,9 +60,10 @@ public: explicit XRenderPicture(const QImage &img); XRenderPicture(xcb_pixmap_t pix, int depth); operator xcb_render_picture_t(); + private: void fromImage(const QImage &img); - QExplicitlySharedDataPointer< XRenderPictureData > d; + QExplicitlySharedDataPointer d; }; class KWINXRENDERUTILS_EXPORT XFixesRegion @@ -71,36 +73,32 @@ public: virtual ~XFixesRegion(); operator xcb_xfixes_region_t(); + private: xcb_xfixes_region_t m_region; }; -inline -XRenderPictureData::XRenderPictureData(xcb_render_picture_t pic) +inline XRenderPictureData::XRenderPictureData(xcb_render_picture_t pic) : picture(pic) { } -inline -xcb_render_picture_t XRenderPictureData::value() +inline xcb_render_picture_t XRenderPictureData::value() { return picture; } -inline -XRenderPicture::XRenderPicture(xcb_render_picture_t pic) +inline XRenderPicture::XRenderPicture(xcb_render_picture_t pic) : d(new XRenderPictureData(pic)) { } -inline -XRenderPicture::operator xcb_render_picture_t() +inline XRenderPicture::operator xcb_render_picture_t() { return d->value(); } -inline -XFixesRegion::operator xcb_xfixes_region_t() +inline XFixesRegion::operator xcb_xfixes_region_t() { return m_region; } diff --git a/src/libkwineffects/logging_p.h b/src/libkwineffects/logging_p.h index 4f82a8b9d5..d2a0665a6f 100644 --- a/src/libkwineffects/logging_p.h +++ b/src/libkwineffects/logging_p.h @@ -9,8 +9,8 @@ #ifndef KWIN_KWINEFFECTS_LOGGING_P_H #define KWIN_KWINEFFECTS_LOGGING_P_H -#include #include +#include Q_DECLARE_LOGGING_CATEGORY(LIBKWINEFFECTS) Q_DECLARE_LOGGING_CATEGORY(LIBKWINGLUTILS) diff --git a/src/main.cpp b/src/main.cpp index 8826b3f0ef..cb02761d89 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,12 +7,12 @@ SPDX-License-Identifier: GPL-2.0-or-later */ +#include "main.h" #include -#include "main.h" -// kwin -#include "platform.h" + #include "atoms.h" +#include "platform.h" #if KWIN_BUILD_CMS #include "colormanager.h" #endif @@ -39,12 +39,12 @@ #include #include // Qt -#include #include +#include #include #include #include -#include +#include #ifdef __has_include() #include @@ -62,9 +62,9 @@ Q_DECLARE_METATYPE(KSharedConfigPtr) namespace KWin { -Options* options; +Options *options; -Atoms* atoms; +Atoms *atoms; int screen_number = -1; bool is_multihead = false; @@ -100,7 +100,7 @@ Application::Application(Application::OperationMode mode, int &argc, char **argv , m_operationMode(mode) { qRegisterMetaType("Options::WindowOperation"); - qRegisterMetaType(); + qRegisterMetaType(); qRegisterMetaType("KWaylandServer::SurfaceInterface *"); qRegisterMetaType(); qRegisterMetaType(); @@ -141,7 +141,7 @@ void Application::start() } if (!m_config->isImmutable() && m_configLock) { // TODO: This shouldn't be necessary - //config->setReadOnly( true ); + // config->setReadOnly( true ); m_config->reparseConfiguration(); } if (!m_kxkbConfig) { @@ -194,21 +194,21 @@ bool Application::wasCrash() void Application::createAboutData() { - KAboutData aboutData(QStringLiteral(KWIN_NAME), // The program name used internally - i18n("KWin"), // A displayable program name string + KAboutData aboutData(QStringLiteral(KWIN_NAME), // The program name used internally + i18n("KWin"), // A displayable program name string QStringLiteral(KWIN_VERSION_STRING), // The program version string - i18n("KDE window manager"), // Short description of what the app does - KAboutLicense::GPL, // The license this code is released under - i18n("(c) 1999-2019, The KDE Developers")); // Copyright Statement + i18n("KDE window manager"), // Short description of what the app does + KAboutLicense::GPL, // The license this code is released under + i18n("(c) 1999-2019, The KDE Developers")); // Copyright Statement aboutData.addAuthor(i18n("Matthias Ettrich"), QString(), QStringLiteral("ettrich@kde.org")); aboutData.addAuthor(i18n("Cristian Tibirna"), QString(), QStringLiteral("tibirna@kde.org")); - aboutData.addAuthor(i18n("Daniel M. Duley"), QString(), QStringLiteral("mosfet@kde.org")); - aboutData.addAuthor(i18n("LuboÅ¡ Luňák"), QString(), QStringLiteral("l.lunak@kde.org")); - aboutData.addAuthor(i18n("Martin Flöser"), QString(), QStringLiteral("mgraesslin@kde.org")); - aboutData.addAuthor(i18n("David Edmundson"), QStringLiteral("Maintainer"), QStringLiteral("davidedmundson@kde.org")); - aboutData.addAuthor(i18n("Roman Gilg"), QStringLiteral("Maintainer"), QStringLiteral("subdiff@gmail.com")); - aboutData.addAuthor(i18n("Vlad Zahorodnii"), QStringLiteral("Maintainer"), QStringLiteral("vlad.zahorodnii@kde.org")); + aboutData.addAuthor(i18n("Daniel M. Duley"), QString(), QStringLiteral("mosfet@kde.org")); + aboutData.addAuthor(i18n("LuboÅ¡ Luňák"), QString(), QStringLiteral("l.lunak@kde.org")); + aboutData.addAuthor(i18n("Martin Flöser"), QString(), QStringLiteral("mgraesslin@kde.org")); + aboutData.addAuthor(i18n("David Edmundson"), QStringLiteral("Maintainer"), QStringLiteral("davidedmundson@kde.org")); + aboutData.addAuthor(i18n("Roman Gilg"), QStringLiteral("Maintainer"), QStringLiteral("subdiff@gmail.com")); + aboutData.addAuthor(i18n("Vlad Zahorodnii"), QStringLiteral("Maintainer"), QStringLiteral("vlad.zahorodnii@kde.org")); KAboutData::setApplicationData(aboutData); } @@ -252,7 +252,7 @@ void Application::setupMalloc() // otherside if the threshold is too low, free() starts to permanently ask the kernel // about shrinking the heap. const int pagesize = sysconf(_SC_PAGESIZE); - mallopt(M_TRIM_THRESHOLD, 5*pagesize); + mallopt(M_TRIM_THRESHOLD, 5 * pagesize); #endif // M_TRIM_THRESHOLD } @@ -271,7 +271,7 @@ void Application::createWorkspace() // critical startup section where x errors cause kwin to abort. // create workspace. - (void) new Workspace(); + (void)new Workspace(); Q_EMIT workspaceCreated(); } @@ -397,34 +397,32 @@ void Application::unregisterEventFilter(X11EventFilter *filter) bool Application::dispatchEvent(xcb_generic_event_t *event) { - static const QVector s_xcbEerrors({ - QByteArrayLiteral("Success"), - QByteArrayLiteral("BadRequest"), - QByteArrayLiteral("BadValue"), - QByteArrayLiteral("BadWindow"), - QByteArrayLiteral("BadPixmap"), - QByteArrayLiteral("BadAtom"), - QByteArrayLiteral("BadCursor"), - QByteArrayLiteral("BadFont"), - QByteArrayLiteral("BadMatch"), - QByteArrayLiteral("BadDrawable"), - QByteArrayLiteral("BadAccess"), - QByteArrayLiteral("BadAlloc"), - QByteArrayLiteral("BadColor"), - QByteArrayLiteral("BadGC"), - QByteArrayLiteral("BadIDChoice"), - QByteArrayLiteral("BadName"), - QByteArrayLiteral("BadLength"), - QByteArrayLiteral("BadImplementation"), - QByteArrayLiteral("Unknown") - }); + static const QVector s_xcbEerrors({QByteArrayLiteral("Success"), + QByteArrayLiteral("BadRequest"), + QByteArrayLiteral("BadValue"), + QByteArrayLiteral("BadWindow"), + QByteArrayLiteral("BadPixmap"), + QByteArrayLiteral("BadAtom"), + QByteArrayLiteral("BadCursor"), + QByteArrayLiteral("BadFont"), + QByteArrayLiteral("BadMatch"), + QByteArrayLiteral("BadDrawable"), + QByteArrayLiteral("BadAccess"), + QByteArrayLiteral("BadAlloc"), + QByteArrayLiteral("BadColor"), + QByteArrayLiteral("BadGC"), + QByteArrayLiteral("BadIDChoice"), + QByteArrayLiteral("BadName"), + QByteArrayLiteral("BadLength"), + QByteArrayLiteral("BadImplementation"), + QByteArrayLiteral("Unknown")}); kwinApp()->updateX11Time(event); const uint8_t x11EventType = event->response_type & ~0x80; if (!x11EventType) { // let's check whether it's an error from one of the extensions KWin uses - xcb_generic_error_t *error = reinterpret_cast(event); + xcb_generic_error_t *error = reinterpret_cast(event); const QVector extensions = Xcb::Extensions::self()->extensions(); for (const auto &extension : extensions) { if (error->major_code == extension.majorOpcode) { @@ -441,11 +439,11 @@ bool Application::dispatchEvent(xcb_generic_event_t *event) errorName = QByteArrayLiteral("Unknown"); } qCWarning(KWIN_CORE, "XCB error: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d (%s)", - int(error->error_code), errorName.constData(), - int(error->sequence), int(error->resource_id), - int(error->major_code), extension.name.constData(), - int(error->minor_code), - extension.opCodes.size() > error->minor_code ? extension.opCodes.at(error->minor_code).constData() : "Unknown"); + int(error->error_code), errorName.constData(), + int(error->sequence), int(error->resource_id), + int(error->major_code), extension.name.constData(), + int(error->minor_code), + extension.opCodes.size() > error->minor_code ? extension.opCodes.at(error->minor_code).constData() : "Unknown"); return true; } } @@ -495,21 +493,21 @@ void Application::updateX11Time(xcb_generic_event_t *event) { xcb_timestamp_t time = XCB_TIME_CURRENT_TIME; const uint8_t eventType = event->response_type & ~0x80; - switch(eventType) { + switch (eventType) { case XCB_KEY_PRESS: case XCB_KEY_RELEASE: - time = reinterpret_cast(event)->time; + time = reinterpret_cast(event)->time; break; case XCB_BUTTON_PRESS: case XCB_BUTTON_RELEASE: - time = reinterpret_cast(event)->time; + time = reinterpret_cast(event)->time; break; case XCB_MOTION_NOTIFY: - time = reinterpret_cast(event)->time; + time = reinterpret_cast(event)->time; break; case XCB_ENTER_NOTIFY: case XCB_LEAVE_NOTIFY: - time = reinterpret_cast(event)->time; + time = reinterpret_cast(event)->time; break; case XCB_FOCUS_IN: case XCB_FOCUS_OUT: @@ -533,16 +531,16 @@ void Application::updateX11Time(xcb_generic_event_t *event) // no timestamp return; case XCB_PROPERTY_NOTIFY: - time = reinterpret_cast(event)->time; + time = reinterpret_cast(event)->time; break; case XCB_SELECTION_CLEAR: - time = reinterpret_cast(event)->time; + time = reinterpret_cast(event)->time; break; case XCB_SELECTION_REQUEST: - time = reinterpret_cast(event)->time; + time = reinterpret_cast(event)->time; break; case XCB_SELECTION_NOTIFY: - time = reinterpret_cast(event)->time; + time = reinterpret_cast(event)->time; break; case XCB_COLORMAP_NOTIFY: case XCB_CLIENT_MESSAGE: @@ -554,10 +552,10 @@ void Application::updateX11Time(xcb_generic_event_t *event) // extension handling if (Xcb::Extensions::self()) { if (eventType == Xcb::Extensions::self()->shapeNotifyEvent()) { - time = reinterpret_cast(event)->server_time; + time = reinterpret_cast(event)->server_time; } if (eventType == Xcb::Extensions::self()->damageNotifyEvent()) { - time = reinterpret_cast(event)->timestamp; + time = reinterpret_cast(event)->timestamp; } } break; @@ -606,4 +604,3 @@ ApplicationWaylandAbstract::~ApplicationWaylandAbstract() } } // namespace - diff --git a/src/main.h b/src/main.h index 8d5f234a81..341c028af1 100644 --- a/src/main.h +++ b/src/main.h @@ -11,13 +11,13 @@ #ifndef MAIN_H #define MAIN_H -#include #include +#include #include // Qt -#include #include +#include #include class KPluginMetaData; @@ -52,7 +52,7 @@ private: X11EventFilter *m_filter; }; -class KWIN_EXPORT Application : public QApplication +class KWIN_EXPORT Application : public QApplication { Q_OBJECT Q_PROPERTY(quint32 x11Time READ x11Time WRITE setX11Time) @@ -86,17 +86,21 @@ public: void setConfigLock(bool lock); - KSharedConfigPtr config() const { + KSharedConfigPtr config() const + { return m_config; } - void setConfig(KSharedConfigPtr config) { + void setConfig(KSharedConfigPtr config) + { m_config = std::move(config); } - KSharedConfigPtr kxkbConfig() const { + KSharedConfigPtr kxkbConfig() const + { return m_kxkbConfig; } - void setKxkbConfig(KSharedConfigPtr config) { + void setKxkbConfig(KSharedConfigPtr config) + { m_kxkbConfig = std::move(config); } @@ -118,14 +122,16 @@ public: void unregisterEventFilter(X11EventFilter *filter); bool dispatchEvent(xcb_generic_event_t *event); - xcb_timestamp_t x11Time() const { + xcb_timestamp_t x11Time() const + { return m_x11Time; } enum class TimestampUpdate { OnlyIfLarger, Always }; - void setX11Time(xcb_timestamp_t timestamp, TimestampUpdate force = TimestampUpdate::OnlyIfLarger) { + void setX11Time(xcb_timestamp_t timestamp, TimestampUpdate force = TimestampUpdate::OnlyIfLarger) + { if ((timestamp > m_x11Time || force == TimestampUpdate::Always) && timestamp != 0) { m_x11Time = timestamp; } @@ -163,36 +169,42 @@ public: /** * @returns the X11 root window. */ - xcb_window_t x11RootWindow() const { + xcb_window_t x11RootWindow() const + { return m_rootWindow; } /** * @returns the X11 xcb connection */ - xcb_connection_t *x11Connection() const { + xcb_connection_t *x11Connection() const + { return m_connection; } /** * @returns the X11 default screen */ - xcb_screen_t *x11DefaultScreen() const { + xcb_screen_t *x11DefaultScreen() const + { return m_defaultScreen; } /** * Returns @c true if we're in the middle of destroying the X11 connection. */ - bool isClosingX11Connection() const { + bool isClosingX11Connection() const + { return m_isClosingX11Connection; } #if KWIN_BUILD_ACTIVITIES - bool usesKActivities() const { + bool usesKActivities() const + { return m_useKActivities; } - void setUseKActivities(bool use) { + void setUseKActivities(bool use) + { m_useKActivities = use; } #endif @@ -200,11 +212,13 @@ public: virtual QProcessEnvironment processStartupEnvironment() const; void initPlatform(const KPluginMetaData &plugin); - Platform *platform() const { + Platform *platform() const + { return m_platform; } - bool isTerminating() const { + bool isTerminating() const + { return m_terminating; } @@ -245,30 +259,35 @@ protected: * 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) { + 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) { + void setX11Connection(xcb_connection_t *c) + { m_connection = c; } /** * Inheriting classes should use this method to set the default screen * before accessing any X11 specific code pathes. */ - void setX11DefaultScreen(xcb_screen_t *screen) { + void setX11DefaultScreen(xcb_screen_t *screen) + { m_defaultScreen = screen; } void destroyAtoms(); void destroyPlatform(); - void setTerminating() { + void setTerminating() + { m_terminating = true; } - void setClosingX11Connection(bool set) { + void setClosingX11Connection(bool set) + { m_isClosingX11Connection = set; } @@ -297,7 +316,7 @@ private: inline static Application *kwinApp() { - return static_cast(QCoreApplication::instance()); + return static_cast(QCoreApplication::instance()); } namespace Xwl @@ -310,17 +329,20 @@ class KWIN_EXPORT ApplicationWaylandAbstract : public Application Q_OBJECT public: ~ApplicationWaylandAbstract() override = 0; + protected: friend class Xwl::Xwayland; ApplicationWaylandAbstract(OperationMode mode, int &argc, char **argv); - virtual void setProcessStartupEnvironment(const QProcessEnvironment &environment) { + virtual void setProcessStartupEnvironment(const QProcessEnvironment &environment) + { Q_UNUSED(environment); } - virtual void startSession() {} + virtual void startSession() + { + } }; - } // namespace #endif diff --git a/src/main_wayland.cpp b/src/main_wayland.cpp index d4da4be81e..51e14584c4 100644 --- a/src/main_wayland.cpp +++ b/src/main_wayland.cpp @@ -7,16 +7,16 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "main_wayland.h" -#include "composite.h" -#include "inputmethod.h" -#include "workspace.h" -#include -// kwin -#include "platform.h" -#include "effects.h" -#include "tabletmodemanager.h" +#include + +#include "composite.h" +#include "effects.h" +#include "inputmethod.h" +#include "platform.h" +#include "tabletmodemanager.h" #include "wayland_server.h" +#include "workspace.h" #include "xwl/xwayland.h" #include "xwl/xwaylandlauncher.h" @@ -32,13 +32,13 @@ #include // Qt -#include #include +#include +#include #include #include -#include #include -#include +#include #if HAVE_LIBCAP #include @@ -46,8 +46,8 @@ #include -#include #include +#include Q_IMPORT_PLUGIN(KWinIntegrationPlugin) Q_IMPORT_PLUGIN(KGlobalAccelImpl) @@ -73,13 +73,13 @@ void disableDrKonqi() // that would enable drkonqi Q_CONSTRUCTOR_FUNCTION(disableDrKonqi) -enum class RealTimeFlags -{ +enum class RealTimeFlags { DontReset, ResetOnFork }; -namespace { +namespace +{ void gainRealTime(RealTimeFlags flags = RealTimeFlags::DontReset) { #if HAVE_SCHED_RESET_ON_FORK @@ -115,7 +115,7 @@ ApplicationWayland::~ApplicationWayland() // need to unload all effects prior to destroying X connection as they might do X calls if (effects) { - static_cast(effects)->unloadAllEffects(); + static_cast(effects)->unloadAllEffects(); } delete m_xwayland; m_xwayland = nullptr; @@ -222,7 +222,7 @@ void ApplicationWayland::startSession() QProcess *p = new QProcess(this); p->setProcessChannelMode(QProcess::ForwardedErrorChannel); p->setProcessEnvironment(processStartupEnvironment()); - connect(p, qOverload(&QProcess::finished), this, [p] (int code, QProcess::ExitStatus status) { + connect(p, qOverload(&QProcess::finished), this, [p](int code, QProcess::ExitStatus status) { p->deleteLater(); if (status == QProcess::CrashExit) { qWarning() << "Session process has crashed"; @@ -246,7 +246,7 @@ void ApplicationWayland::startSession() } // start the applications passed to us as command line arguments if (!m_applicationsToStart.isEmpty()) { - for (const QString &application: qAsConst(m_applicationsToStart)) { + for (const QString &application : qAsConst(m_applicationsToStart)) { QStringList arguments = KShell::splitArgs(application); if (arguments.isEmpty()) { qWarning("Failed to launch application: %s is an invalid command", @@ -290,7 +290,7 @@ void dropNiceCapability() if (!caps) { return; } - cap_value_t capList[] = { CAP_SYS_NICE }; + cap_value_t capList[] = {CAP_SYS_NICE}; if (cap_set_flag(caps, CAP_PERMITTED, 1, capList, CAP_CLEAR) == -1) { cap_free(caps); return; @@ -306,7 +306,7 @@ void dropNiceCapability() } // namespace -int main(int argc, char * argv[]) +int main(int argc, char *argv[]) { KWin::Application::setupMalloc(); KWin::Application::setupLocalizedString(); @@ -337,12 +337,11 @@ int main(int argc, char * argv[]) KWin::Application::createAboutData(); const auto availablePlugins = KPluginMetaData::findPlugins(QStringLiteral("org.kde.kwin.waylandbackends")); - auto hasPlugin = [&availablePlugins] (const QString &name) { + auto hasPlugin = [&availablePlugins](const QString &name) { return std::any_of(availablePlugins.begin(), availablePlugins.end(), - [name] (const KPluginMetaData &plugin) { - return plugin.pluginId() == name; - } - ); + [name](const KPluginMetaData &plugin) { + return plugin.pluginId() == name; + }); }; const bool hasSizeOption = hasPlugin(KWin::s_x11Plugin) || hasPlugin(KWin::s_virtualPlugin); const bool hasOutputCountOption = hasPlugin(KWin::s_x11Plugin); @@ -373,33 +372,33 @@ int main(int argc, char * argv[]) heightOption.setDefaultValue(QString::number(768)); QCommandLineOption scaleOption(QStringLiteral("scale"), - i18n("The scale for windowed mode. Default value is 1."), - QStringLiteral("scale")); + i18n("The scale for windowed mode. Default value is 1."), + QStringLiteral("scale")); scaleOption.setDefaultValue(QString::number(1)); QCommandLineOption outputCountOption(QStringLiteral("output-count"), - i18n("The number of windows to open as outputs in windowed mode. Default value is 1"), - QStringLiteral("count")); + i18n("The number of windows to open as outputs in windowed mode. Default value is 1"), + QStringLiteral("count")); outputCountOption.setDefaultValue(QString::number(1)); QCommandLineOption waylandSocketFdOption(QStringLiteral("wayland-fd"), - i18n("Wayland socket to use for incoming connections. This can be combined with --socket to name the socket"), - QStringLiteral("wayland-fd")); + i18n("Wayland socket to use for incoming connections. This can be combined with --socket to name the socket"), + QStringLiteral("wayland-fd")); QCommandLineOption xwaylandListenFdOption(QStringLiteral("xwayland-fd"), - i18n("XWayland socket to use for Xwayland's incoming connections. This can be set multiple times"), - QStringLiteral("xwayland-fds")); + i18n("XWayland socket to use for Xwayland's incoming connections. This can be set multiple times"), + QStringLiteral("xwayland-fds")); QCommandLineOption xwaylandDisplayOption(QStringLiteral("xwayland-display"), i18n("Name of the xwayland display that has been pre-set up"), "xwayland-display"); QCommandLineOption xwaylandXAuthorityOption(QStringLiteral("xwayland-xauthority"), - i18n("Name of the xauthority file "), - "xwayland-xauthority"); + i18n("Name of the xauthority file "), + "xwayland-xauthority"); QCommandLineOption replaceOption(QStringLiteral("replace"), - i18n("Exits this instance so it can be restarted by kwin_wayland_wrapper.")); + i18n("Exits this instance so it can be restarted by kwin_wayland_wrapper.")); QCommandLineParser parser; a.setupCommandLine(&parser); @@ -439,7 +438,7 @@ int main(int argc, char * argv[]) parser.addOption(inputMethodOption); QCommandLineOption listBackendsOption(QStringLiteral("list-backends"), - i18n("List all available backends and quit.")); + i18n("List all available backends and quit.")); parser.addOption(listBackendsOption); #if KWIN_BUILD_SCREENLOCKER @@ -482,12 +481,12 @@ int main(int argc, char * argv[]) if (parser.isSet(replaceOption)) { QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.KWin"), QStringLiteral("/KWin"), - QStringLiteral("org.kde.KWin"), QStringLiteral("replace")); + QStringLiteral("org.kde.KWin"), QStringLiteral("replace")); QDBusConnection::sessionBus().call(msg, QDBus::NoBlock); return 0; } if (parser.isSet(listBackendsOption)) { - for (const auto &plugin: availablePlugins) { + for (const auto &plugin : availablePlugins) { std::cout << std::setw(40) << std::left << qPrintable(plugin.name()) << qPrintable(plugin.description()) << std::endl; } return 0; @@ -555,10 +554,9 @@ int main(int argc, char * argv[]) } auto pluginIt = std::find_if(availablePlugins.begin(), availablePlugins.end(), - [&pluginName] (const KPluginMetaData &plugin) { - return plugin.pluginId() == pluginName; - } - ); + [&pluginName](const KPluginMetaData &plugin) { + return plugin.pluginId() == pluginName; + }); if (pluginIt == availablePlugins.end()) { std::cerr << "FATAL ERROR: could not find a backend" << std::endl; return 1; @@ -579,12 +577,11 @@ int main(int argc, char * argv[]) flags |= KWin::WaylandServer::InitializationFlag::NoGlobalShortcuts; } - const QString socketName = parser.value(waylandSocketOption); if (parser.isSet(waylandSocketFdOption)) { bool ok; int fd = parser.value(waylandSocketFdOption).toInt(&ok); - if (ok ) { + if (ok) { // make sure we don't leak this FD to children fcntl(fd, F_SETFD, O_CLOEXEC); server->display()->addSocketFileDescriptor(fd, socketName); @@ -631,10 +628,10 @@ int main(int argc, char * argv[]) if (parser.isSet(xwaylandListenFdOption)) { const QStringList fdStrings = parser.values(xwaylandListenFdOption); - for (const QString &fdString: fdStrings){ + for (const QString &fdString : fdStrings) { bool ok; int fd = fdString.toInt(&ok); - if (ok ) { + if (ok) { // make sure we don't leak this FD to children fcntl(fd, F_SETFD, O_CLOEXEC); a.addXwaylandSocketFileDescriptor(fd); diff --git a/src/main_wayland.h b/src/main_wayland.h index c559abedb6..1fa5210be9 100644 --- a/src/main_wayland.h +++ b/src/main_wayland.h @@ -27,32 +27,41 @@ public: ApplicationWayland(int &argc, char **argv); ~ApplicationWayland() override; - void setStartXwayland(bool start) { + void setStartXwayland(bool start) + { m_startXWayland = start; } - void addXwaylandSocketFileDescriptor(int fd) { + void addXwaylandSocketFileDescriptor(int fd) + { m_xwaylandListenFds << fd; } - void setXwaylandDisplay(const QString &display) { + void setXwaylandDisplay(const QString &display) + { m_xwaylandDisplay = display; } - void setXwaylandXauthority(const QString &xauthority) { - m_xwaylandXauthority= xauthority; + void setXwaylandXauthority(const QString &xauthority) + { + m_xwaylandXauthority = xauthority; } - void setApplicationsToStart(const QStringList &applications) { + void setApplicationsToStart(const QStringList &applications) + { m_applicationsToStart = applications; } - void setInputMethodServerToStart(const QString &inputMethodServer) { + void setInputMethodServerToStart(const QString &inputMethodServer) + { m_inputMethodServerToStart = inputMethodServer; } - void setProcessStartupEnvironment(const QProcessEnvironment &environment) override { + void setProcessStartupEnvironment(const QProcessEnvironment &environment) override + { m_environment = environment; } - void setSessionArgument(const QString &session) { + void setSessionArgument(const QString &session) + { m_sessionArgument = session; } - QProcessEnvironment processStartupEnvironment() const override { + QProcessEnvironment processStartupEnvironment() const override + { return m_environment; } diff --git a/src/main_x11.cpp b/src/main_x11.cpp index 6024abf2f5..449c479884 100644 --- a/src/main_x11.cpp +++ b/src/main_x11.cpp @@ -14,8 +14,8 @@ #include "platform.h" #include "sm.h" -#include "workspace.h" #include "utils/xcbutils.h" +#include "workspace.h" #include #include @@ -23,7 +23,6 @@ #include #include -#include #include #include #include @@ -33,6 +32,7 @@ #include #include #include +#include #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #include #else @@ -58,14 +58,14 @@ class AlternativeWMDialog : public QDialog { public: AlternativeWMDialog() - : QDialog() { - QWidget* mainWidget = new QWidget(this); - QVBoxLayout* layout = new QVBoxLayout(mainWidget); - QString text = i18n( - "KWin is unstable.\n" - "It seems to have crashed several times in a row.\n" - "You can select another window manager to run:"); - QLabel* textLabel = new QLabel(text, mainWidget); + : QDialog() + { + QWidget *mainWidget = new QWidget(this); + QVBoxLayout *layout = new QVBoxLayout(mainWidget); + QString text = i18n("KWin is unstable.\n" + "It seems to have crashed several times in a row.\n" + "You can select another window manager to run:"); + QLabel *textLabel = new QLabel(text, mainWidget); layout->addWidget(textLabel); wmList = new QComboBox(mainWidget); wmList->setEditable(true); @@ -87,17 +87,19 @@ public: raise(); } - void addWM(const QString& wm) { + void addWM(const QString &wm) + { // TODO: Check if WM is installed if (!QStandardPaths::findExecutable(wm).isEmpty()) wmList->addItem(wm); } - QString selectedWM() const { + QString selectedWM() const + { return wmList->currentText(); } private: - QComboBox* wmList; + QComboBox *wmList; }; class KWinSelectionOwner : public KSelectionOwner @@ -110,9 +112,10 @@ public: } private: - bool genericReply(xcb_atom_t target_P, xcb_atom_t property_P, xcb_window_t requestor_P) override { + bool genericReply(xcb_atom_t target_P, xcb_atom_t property_P, xcb_window_t requestor_P) override + { if (target_P == xa_version) { - int32_t version[] = { 2, 0 }; + int32_t version[] = {2, 0}; xcb_change_property(kwinApp()->x11Connection(), XCB_PROP_MODE_REPLACE, requestor_P, property_P, XCB_ATOM_INTEGER, 32, 2, version); } else @@ -120,15 +123,17 @@ private: return true; } - void replyTargets(xcb_atom_t property_P, xcb_window_t requestor_P) override { + void replyTargets(xcb_atom_t property_P, xcb_window_t requestor_P) override + { KSelectionOwner::replyTargets(property_P, requestor_P); - xcb_atom_t atoms[ 1 ] = { xa_version }; + xcb_atom_t atoms[1] = {xa_version}; // PropModeAppend ! xcb_change_property(kwinApp()->x11Connection(), XCB_PROP_MODE_APPEND, requestor_P, property_P, XCB_ATOM_ATOM, 32, 1, atoms); } - void getAtoms() override { + void getAtoms() override + { KSelectionOwner::getAtoms(); if (xa_version == XCB_ATOM_NONE) { const QByteArray name(QByteArrayLiteral("VERSION")); @@ -142,7 +147,8 @@ private: } } - xcb_atom_t make_selection_atom(int screen_P) { + xcb_atom_t make_selection_atom(int screen_P) + { if (screen_P < 0) screen_P = QX11Info::appScreen(); QByteArray screen(QByteArrayLiteral("WM_S")); @@ -178,7 +184,7 @@ ApplicationX11::~ApplicationX11() setTerminating(); destroyCompositor(); destroyWorkspace(); - if (!owner.isNull() && owner->ownerWindow() != XCB_WINDOW_NONE) // If there was no --replace (no new WM) + if (!owner.isNull() && owner->ownerWindow() != XCB_WINDOW_NONE) // If there was no --replace (no new WM) Xcb::setInputFocus(XCB_INPUT_FOCUS_POINTER_ROOT); } @@ -198,12 +204,11 @@ void ApplicationX11::lostSelection() quit(); } - static xcb_screen_t *findXcbScreen(xcb_connection_t *connection, int screen) { for (xcb_screen_iterator_t it = xcb_setup_roots_iterator(xcb_get_setup(connection)); - it.rem; - --screen, xcb_screen_next(&it)) { + it.rem; + --screen, xcb_screen_next(&it)) { if (screen == 0) { return it.data; } @@ -221,12 +226,12 @@ void ApplicationX11::performStartup() setX11DefaultScreen(findXcbScreen(x11Connection(), x11ScreenNumber())); owner.reset(new KWinSelectionOwner(Application::x11ScreenNumber())); - connect(owner.data(), &KSelectionOwner::failedToClaimOwnership, []{ + connect(owner.data(), &KSelectionOwner::failedToClaimOwnership, [] { fputs(i18n("kwin: unable to claim manager selection, another wm running? (try using --replace)\n").toLocal8Bit().constData(), stderr); ::exit(1); }); connect(owner.data(), &KSelectionOwner::lostOwnership, this, &ApplicationX11::lostSelection); - connect(owner.data(), &KSelectionOwner::claimedOwnership, this, [this]{ + connect(owner.data(), &KSelectionOwner::claimedOwnership, this, [this] { installNativeX11EventFilter(); // first load options - done internally by a different thread createOptions(); @@ -266,7 +271,7 @@ void ApplicationX11::performStartup() createAtoms(); } -bool ApplicationX11::notify(QObject* o, QEvent* e) +bool ApplicationX11::notify(QObject *o, QEvent *e) { if (e->spontaneous() && Workspace::self()->workspaceEvent(e)) return true; @@ -313,9 +318,9 @@ void ApplicationX11::notifyKSplash() { // Tell KSplash that KWin has started QDBusMessage ksplashProgressMessage = QDBusMessage::createMethodCall(QStringLiteral("org.kde.KSplash"), - QStringLiteral("/KSplash"), - QStringLiteral("org.kde.KSplash"), - QStringLiteral("setStage")); + QStringLiteral("/KSplash"), + QStringLiteral("org.kde.KSplash"), + QStringLiteral("setStage")); ksplashProgressMessage.setArguments(QList() << QStringLiteral("wm")); QDBusConnection::sessionBus().asyncCall(ksplashProgressMessage); } @@ -335,7 +340,7 @@ void ApplicationX11::crashHandler(int signal) } // namespace -int main(int argc, char * argv[]) +int main(int argc, char *argv[]) { KWin::Application::setupMalloc(); KWin::Application::setupLocalizedString(); @@ -367,7 +372,7 @@ int main(int argc, char * argv[]) QByteArray display_name = qgetenv("DISPLAY"); if ((pos = display_name.lastIndexOf('.')) != -1) - display_name.remove(pos, 10); // 10 is enough to be sure we removed ".s" + display_name.remove(pos, 10); // 10 is enough to be sure we removed ".s" for (int i = 0; i < number_of_screens; i++) { // If execution doesn't pass by here, then kwin @@ -388,8 +393,8 @@ int main(int argc, char * argv[]) // In the next statement, display_name shouldn't contain a screen // number. If it had it, it was removed at the "pos" check const QString envir = QStringLiteral("DISPLAY=%1.%2") - .arg(display_name.data()) - .arg(KWin::Application::x11ScreenNumber()); + .arg(display_name.data()) + .arg(KWin::Application::x11ScreenNumber()); if (putenv(strdup(envir.toLatin1().constData()))) { fprintf(stderr, "%s: WARNING: unable to set DISPLAY environment variable\n", argv[0]); @@ -439,7 +444,7 @@ int main(int argc, char * argv[]) parser.addOption(replaceOption); #if KWIN_BUILD_ACTIVITIES QCommandLineOption noActivitiesOption(QStringLiteral("no-kactivities"), - i18n("Disable KActivities integration.")); + i18n("Disable KActivities integration.")); parser.addOption(noActivitiesOption); #endif diff --git a/src/modifier_only_shortcuts.cpp b/src/modifier_only_shortcuts.cpp index 6a44f57cfb..1820ffcdff 100644 --- a/src/modifier_only_shortcuts.cpp +++ b/src/modifier_only_shortcuts.cpp @@ -6,8 +6,10 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include #include "modifier_only_shortcuts.h" + +#include + #include "input_event.h" #include "options.h" #if KWIN_BUILD_SCREENLOCKER @@ -46,17 +48,14 @@ void ModifierOnlyShortcuts::keyEvent(KeyEvent *event) #if KWIN_BUILD_SCREENLOCKER !ScreenLockerWatcher::self()->isLocked() && #endif - m_pressedButtons == Qt::NoButton && - m_cachedMods == Qt::NoModifier) { + m_pressedButtons == Qt::NoButton && m_cachedMods == Qt::NoModifier) { m_modifier = Qt::KeyboardModifier(int(event->modifiersRelevantForGlobalShortcuts())); } else { m_modifier = Qt::NoModifier; } } else if (!m_pressedKeys.isEmpty()) { m_pressedKeys.remove(event->nativeScanCode()); - if (m_pressedKeys.isEmpty() && - event->modifiersRelevantForGlobalShortcuts() == Qt::NoModifier && - workspace() && !workspace()->globalShortcutsDisabled()) { + if (m_pressedKeys.isEmpty() && event->modifiersRelevantForGlobalShortcuts() == Qt::NoModifier && workspace() && !workspace()->globalShortcutsDisabled()) { if (m_modifier != Qt::NoModifier) { const auto list = options->modifierOnlyDBusShortcut(m_modifier); if (list.size() >= 4) { diff --git a/src/modifier_only_shortcuts.h b/src/modifier_only_shortcuts.h index ef0bbfc15b..ae3b2ee277 100644 --- a/src/modifier_only_shortcuts.h +++ b/src/modifier_only_shortcuts.h @@ -29,7 +29,8 @@ public: void pointerEvent(MouseEvent *event) override; void wheelEvent(WheelEvent *event) override; - void reset() { + void reset() + { m_modifier = Qt::NoModifier; } diff --git a/src/moving_client_x11_filter.cpp b/src/moving_client_x11_filter.cpp index 79bf8df196..2b8306c686 100644 --- a/src/moving_client_x11_filter.cpp +++ b/src/moving_client_x11_filter.cpp @@ -7,8 +7,8 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "moving_client_x11_filter.h" -#include "x11client.h" #include "workspace.h" +#include "x11client.h" #include #include @@ -26,7 +26,7 @@ bool MovingClientX11Filter::event(xcb_generic_event_t *event) if (!client) { return false; } - auto testWindow = [client, event] (xcb_window_t window) { + auto testWindow = [client, event](xcb_window_t window) { return client->moveResizeGrabWindow() == window && client->windowEvent(event); }; @@ -34,16 +34,16 @@ bool MovingClientX11Filter::event(xcb_generic_event_t *event) switch (eventType) { case XCB_KEY_PRESS: { int keyQt; - xcb_key_press_event_t *keyEvent = reinterpret_cast(event); + xcb_key_press_event_t *keyEvent = reinterpret_cast(event); KKeyServer::xcbKeyPressEventToQt(keyEvent, &keyQt); client->keyPressEvent(keyQt, keyEvent->time); return true; } case XCB_BUTTON_PRESS: case XCB_BUTTON_RELEASE: - return testWindow(reinterpret_cast(event)->event); + return testWindow(reinterpret_cast(event)->event); case XCB_MOTION_NOTIFY: - return testWindow(reinterpret_cast(event)->event); + return testWindow(reinterpret_cast(event)->event); } return false; } diff --git a/src/moving_client_x11_filter.h b/src/moving_client_x11_filter.h index 356e399e44..b5c6cc8b1c 100644 --- a/src/moving_client_x11_filter.h +++ b/src/moving_client_x11_filter.h @@ -24,4 +24,3 @@ public: } #endif - diff --git a/src/netinfo.cpp b/src/netinfo.cpp index b3cc7009a6..e8655e3b9a 100644 --- a/src/netinfo.cpp +++ b/src/netinfo.cpp @@ -11,10 +11,10 @@ // own #include "netinfo.h" // kwin -#include "x11client.h" #include "rootinfo_filter.h" #include "virtualdesktops.h" #include "workspace.h" +#include "x11client.h" // Qt #include @@ -32,88 +32,88 @@ RootInfo *RootInfo::create() xcb_create_window(kwinApp()->x11Connection(), XCB_COPY_FROM_PARENT, supportWindow, kwinApp()->x11RootWindow(), 0, 0, 1, 1, 0, XCB_COPY_FROM_PARENT, XCB_COPY_FROM_PARENT, XCB_CW_OVERRIDE_REDIRECT, values); - const uint32_t lowerValues[] = { XCB_STACK_MODE_BELOW }; // See usage in layers.cpp + const uint32_t lowerValues[] = {XCB_STACK_MODE_BELOW}; // See usage in layers.cpp // we need to do the lower window with a roundtrip, otherwise NETRootInfo is not functioning ScopedCPointer error(xcb_request_check(kwinApp()->x11Connection(), - xcb_configure_window_checked(kwinApp()->x11Connection(), supportWindow, XCB_CONFIG_WINDOW_STACK_MODE, lowerValues))); + xcb_configure_window_checked(kwinApp()->x11Connection(), supportWindow, XCB_CONFIG_WINDOW_STACK_MODE, lowerValues))); if (!error.isNull()) { qCDebug(KWIN_CORE) << "Error occurred while lowering support window: " << error->error_code; } - const NET::Properties properties = NET::Supported | - NET::SupportingWMCheck | - NET::ClientList | - NET::ClientListStacking | - NET::DesktopGeometry | - NET::NumberOfDesktops | - NET::CurrentDesktop | - NET::ActiveWindow | - NET::WorkArea | - NET::CloseWindow | - NET::DesktopNames | - NET::WMName | - NET::WMVisibleName | - NET::WMDesktop | - NET::WMWindowType | - NET::WMState | - NET::WMStrut | - NET::WMIconGeometry | - NET::WMIcon | - NET::WMPid | - NET::WMMoveResize | - NET::WMFrameExtents | - NET::WMPing; - const NET::WindowTypes types = NET::NormalMask | - NET::DesktopMask | - NET::DockMask | - NET::ToolbarMask | - NET::MenuMask | - NET::DialogMask | - NET::OverrideMask | - NET::UtilityMask | - NET::SplashMask; // No compositing window types here unless we support them also as managed window types - const NET::States states = NET::Modal | - //NET::Sticky | // Large desktops not supported (and probably never will be) - NET::MaxVert | - NET::MaxHoriz | - NET::Shaded | - NET::SkipTaskbar | - NET::KeepAbove | - //NET::StaysOnTop | // The same like KeepAbove - NET::SkipPager | - NET::Hidden | - NET::FullScreen | - NET::KeepBelow | - NET::DemandsAttention | - NET::SkipSwitcher | - NET::Focused; - NET::Properties2 properties2 = NET::WM2UserTime | - NET::WM2StartupId | - NET::WM2AllowedActions | - NET::WM2RestackWindow | - NET::WM2MoveResizeWindow | - NET::WM2ExtendedStrut | - NET::WM2KDETemporaryRules | - NET::WM2ShowingDesktop | - NET::WM2DesktopLayout | - NET::WM2FullPlacement | - NET::WM2FullscreenMonitors | - NET::WM2KDEShadow | - NET::WM2OpaqueRegion | - NET::WM2GTKFrameExtents; + const NET::Properties properties = NET::Supported + | NET::SupportingWMCheck + | NET::ClientList + | NET::ClientListStacking + | NET::DesktopGeometry + | NET::NumberOfDesktops + | NET::CurrentDesktop + | NET::ActiveWindow + | NET::WorkArea + | NET::CloseWindow + | NET::DesktopNames + | NET::WMName + | NET::WMVisibleName + | NET::WMDesktop + | NET::WMWindowType + | NET::WMState + | NET::WMStrut + | NET::WMIconGeometry + | NET::WMIcon + | NET::WMPid + | NET::WMMoveResize + | NET::WMFrameExtents + | NET::WMPing; + const NET::WindowTypes types = NET::NormalMask + | NET::DesktopMask + | NET::DockMask + | NET::ToolbarMask + | NET::MenuMask + | NET::DialogMask + | NET::OverrideMask + | NET::UtilityMask + | NET::SplashMask; // No compositing window types here unless we support them also as managed window types + const NET::States states = NET::Modal + // | NET::Sticky // Large desktops not supported (and probably never will be) + | NET::MaxVert + | NET::MaxHoriz + | NET::Shaded + | NET::SkipTaskbar + | NET::KeepAbove + // | NET::StaysOnTop // The same like KeepAbove + | NET::SkipPager + | NET::Hidden + | NET::FullScreen + | NET::KeepBelow + | NET::DemandsAttention + | NET::SkipSwitcher + | NET::Focused; + NET::Properties2 properties2 = NET::WM2UserTime + | NET::WM2StartupId + | NET::WM2AllowedActions + | NET::WM2RestackWindow + | NET::WM2MoveResizeWindow + | NET::WM2ExtendedStrut + | NET::WM2KDETemporaryRules + | NET::WM2ShowingDesktop + | NET::WM2DesktopLayout + | NET::WM2FullPlacement + | NET::WM2FullscreenMonitors + | NET::WM2KDEShadow + | NET::WM2OpaqueRegion + | NET::WM2GTKFrameExtents; #if KWIN_BUILD_ACTIVITIES - properties2 |= NET::WM2Activities; + properties2 |= NET::WM2Activities; #endif - const NET::Actions actions = NET::ActionMove | - NET::ActionResize | - NET::ActionMinimize | - NET::ActionShade | - //NET::ActionStick | // Sticky state is not supported - NET::ActionMaxVert | - NET::ActionMaxHoriz | - NET::ActionFullScreen | - NET::ActionChangeDesktop | - NET::ActionClose; + const NET::Actions actions = NET::ActionMove + | NET::ActionResize + | NET::ActionMinimize + | NET::ActionShade + // | NET::ActionStick // Sticky state is not supported + | NET::ActionMaxVert + | NET::ActionMaxHoriz + | NET::ActionFullScreen + | NET::ActionChangeDesktop + | NET::ActionClose; s_self = new RootInfo(supportWindow, "KWin", properties, types, states, properties2, actions, screen_number); return s_self; @@ -157,7 +157,7 @@ void RootInfo::changeActiveWindow(xcb_window_t w, NET::RequestSource src, xcb_ti if (src != NET::FromApplication && src != FromTool) src = NET::FromTool; if (src == NET::FromTool) - workspace->activateClient(c, true); // force + workspace->activateClient(c, true); // force else if (c == workspace->mostRecentlyActivatedClient()) { return; // WORKAROUND? With > 1 plasma activities, we cause this ourselves. bug #240673 } else { // NET::FromApplication @@ -166,9 +166,9 @@ void RootInfo::changeActiveWindow(xcb_window_t w, NET::RequestSource src, xcb_ti workspace->activateClient(c); // if activation of the requestor's window would be allowed, allow activation too else if (active_window != XCB_WINDOW_NONE - && (c2 = workspace->findClient(Predicate::WindowMatch, active_window)) != nullptr - && workspace->allowClientActivation(c2, - timestampCompare(timestamp, c2->userTime() > 0 ? timestamp : c2->userTime()), false, true)) { + && (c2 = workspace->findClient(Predicate::WindowMatch, active_window)) != nullptr + && workspace->allowClientActivation(c2, + timestampCompare(timestamp, c2->userTime() > 0 ? timestamp : c2->userTime()), false, true)) { workspace->activateClient(c); } else c->demandAttention(); @@ -237,7 +237,8 @@ void RootInfo::setActiveClient(AbstractClient *client) WinInfo::WinInfo(X11Client *c, xcb_window_t window, xcb_window_t rwin, NET::Properties properties, NET::Properties2 properties2) - : NETWinInfo(kwinApp()->x11Connection(), window, rwin, properties, properties2, NET::WindowManager), m_client(c) + : NETWinInfo(kwinApp()->x11Connection(), window, rwin, properties, properties2, NET::WindowManager) + , m_client(c) { } diff --git a/src/netinfo.h b/src/netinfo.h index a3ef6241c8..9722ba842f 100644 --- a/src/netinfo.h +++ b/src/netinfo.h @@ -14,8 +14,8 @@ #include -#include #include +#include namespace KWin { @@ -47,7 +47,7 @@ protected: void changeShowingDesktop(bool showing) override; private: - RootInfo(xcb_window_t w, const char* name, NET::Properties properties, NET::WindowTypes types, + 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(); diff --git a/src/onscreennotification.cpp b/src/onscreennotification.cpp index 1b0d94662c..ac3197a73e 100644 --- a/src/onscreennotification.cpp +++ b/src/onscreennotification.cpp @@ -4,20 +4,21 @@ SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL */ - #include "onscreennotification.h" + +#include + #include "input.h" #include "input_event.h" #include "input_event_spy.h" -#include #include -#include -#include #include #include #include #include +#include +#include #include @@ -32,6 +33,7 @@ public: explicit OnScreenNotificationInputEventSpy(OnScreenNotification *parent); void pointerEvent(MouseEvent *event) override; + private: OnScreenNotification *m_parent; }; @@ -50,29 +52,26 @@ void OnScreenNotificationInputEventSpy::pointerEvent(MouseEvent *event) m_parent->setContainsPointer(m_parent->geometry().contains(event->globalPos())); } - OnScreenNotification::OnScreenNotification(QObject *parent) : QObject(parent) , m_timer(new QTimer(this)) { m_timer->setSingleShot(true); connect(m_timer, &QTimer::timeout, this, std::bind(&OnScreenNotification::setVisible, this, false)); - connect(this, &OnScreenNotification::visibleChanged, this, - [this] { - if (m_visible) { - show(); - } else { - m_timer->stop(); - m_spy.reset(); - m_containsPointer = false; - } + connect(this, &OnScreenNotification::visibleChanged, this, [this]() { + if (m_visible) { + show(); + } else { + m_timer->stop(); + m_spy.reset(); + m_containsPointer = false; } - ); + }); } OnScreenNotification::~OnScreenNotification() { - if (QQuickWindow *w = qobject_cast(m_mainItem.data())) { + if (QQuickWindow *w = qobject_cast(m_mainItem.data())) { w->hide(); w->destroy(); } @@ -174,7 +173,7 @@ void OnScreenNotification::ensureQmlComponent() } m_qmlComponent.reset(new QQmlComponent(m_qmlEngine)); const QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation, - m_config->group(QStringLiteral("OnScreenNotification")).readEntry("QmlPath", QStringLiteral(KWIN_NAME "/onscreennotification/plasma/main.qml"))); + m_config->group(QStringLiteral("OnScreenNotification")).readEntry("QmlPath", QStringLiteral(KWIN_NAME "/onscreennotification/plasma/main.qml"))); if (fileName.isEmpty()) { return; } @@ -189,7 +188,7 @@ void OnScreenNotification::ensureQmlComponent() void OnScreenNotification::createInputSpy() { Q_ASSERT(m_spy.isNull()); - if (auto w = qobject_cast(m_mainItem.data())) { + if (auto w = qobject_cast(m_mainItem.data())) { m_spy.reset(new OnScreenNotificationInputEventSpy(this)); input()->installInputEventSpy(m_spy.data()); if (!m_animation) { @@ -204,7 +203,7 @@ void OnScreenNotification::createInputSpy() QRect OnScreenNotification::geometry() const { - if (QQuickWindow *w = qobject_cast(m_mainItem.data())) { + if (QQuickWindow *w = qobject_cast(m_mainItem.data())) { return w->geometry(); } return QRect(); @@ -225,7 +224,7 @@ void OnScreenNotification::setContainsPointer(bool contains) void OnScreenNotification::setSkipCloseAnimation(bool skip) { - if (QQuickWindow *w = qobject_cast(m_mainItem.data())) { + if (QQuickWindow *w = qobject_cast(m_mainItem.data())) { w->setProperty("KWIN_SKIP_CLOSE_ANIMATION", skip); } } diff --git a/src/onscreennotification.h b/src/onscreennotification.h index 6c5d853842..4839a2ac73 100644 --- a/src/onscreennotification.h +++ b/src/onscreennotification.h @@ -18,7 +18,8 @@ class QQmlContext; class QQmlComponent; class QQmlEngine; -namespace KWin { +namespace KWin +{ class OnScreenNotificationInputEventSpy; diff --git a/src/options.cpp b/src/options.cpp index 32ff6af472..dfbf3ce8e6 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -8,11 +8,12 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "options.h" + #include "config-kwin.h" -#include "utils/common.h" + #include "platform.h" +#include "utils/common.h" #ifndef KCMRULES @@ -20,10 +21,10 @@ #include "screens.h" #include "settings.h" -#include #include +#include -#endif //KCMRULES +#endif // KCMRULES namespace KWin { @@ -594,7 +595,6 @@ void Options::setMoveMinimizedWindowsToEndOfTabBoxFocusChain(bool value) return; } m_MoveMinimizedWindowsToEndOfTabBoxFocusChain = value; - } void Options::setGlPreferBufferSwap(char glPreferBufferSwap) @@ -693,9 +693,8 @@ void Options::updateSettings() // and not kstyle tooltips and vise-versa, we don't read the // "EffectNoTooltip" setting from kdeglobals. - -// QToolTip::setGloballyEnabled( d->show_tooltips ); -// KDE4 this probably needs to be done manually in clients + // QToolTip::setGloballyEnabled( d->show_tooltips ); + // KDE4 this probably needs to be done manually in clients // Driver-specific config detection reloadCompositingSettings(); @@ -748,10 +747,7 @@ void Options::loadConfig() if (config.hasKey("Alt")) { m_modifierOnlyShortcuts.insert(Qt::AltModifier, config.readEntry("Alt", QStringList())); } - m_modifierOnlyShortcuts.insert(Qt::MetaModifier, config.readEntry("Meta", QStringList{QStringLiteral("org.kde.plasmashell"), - QStringLiteral("/PlasmaShell"), - QStringLiteral("org.kde.PlasmaShell"), - QStringLiteral("activateLauncherMenu")})); + m_modifierOnlyShortcuts.insert(Qt::MetaModifier, config.readEntry("Meta", QStringList{QStringLiteral("org.kde.plasmashell"), QStringLiteral("/PlasmaShell"), QStringLiteral("org.kde.PlasmaShell"), QStringLiteral("activateLauncherMenu")})); } void Options::syncFromKcfgc() @@ -794,7 +790,7 @@ void Options::syncFromKcfgc() setRenderTimeEstimator(m_settings->renderTimeEstimator()); } -bool Options::loadCompositingConfig (bool force) +bool Options::loadCompositingConfig(bool force) { KConfigGroup config(m_settings->config(), "Compositing"); @@ -807,7 +803,7 @@ bool Options::loadCompositingConfig (bool force) compositingMode = OpenGLCompositing; if (const char *c = getenv("KWIN_COMPOSE")) { - switch(c[0]) { + switch (c[0]) { case 'O': qCDebug(KWIN_CORE) << "Compositing forced to OpenGL mode by environment variable"; compositingMode = OpenGLCompositing; @@ -937,41 +933,68 @@ Options::WindowOperation Options::windowOperation(const QString &name, bool rest Options::MouseCommand Options::mouseCommand(const QString &name, bool restricted) { QString lowerName = name.toLower(); - if (lowerName == QStringLiteral("raise")) return MouseRaise; - if (lowerName == QStringLiteral("lower")) return MouseLower; - if (lowerName == QStringLiteral("operations menu")) return MouseOperationsMenu; - if (lowerName == QStringLiteral("toggle raise and lower")) return MouseToggleRaiseAndLower; - if (lowerName == QStringLiteral("activate and raise")) return MouseActivateAndRaise; - if (lowerName == QStringLiteral("activate and lower")) return MouseActivateAndLower; - if (lowerName == QStringLiteral("activate")) return MouseActivate; - if (lowerName == QStringLiteral("activate, raise and pass click")) return MouseActivateRaiseAndPassClick; - if (lowerName == QStringLiteral("activate and pass click")) return MouseActivateAndPassClick; - if (lowerName == QStringLiteral("scroll")) return MouseNothing; - if (lowerName == QStringLiteral("activate and scroll")) return MouseActivateAndPassClick; - if (lowerName == QStringLiteral("activate, raise and scroll")) return MouseActivateRaiseAndPassClick; + if (lowerName == QStringLiteral("raise")) + return MouseRaise; + if (lowerName == QStringLiteral("lower")) + return MouseLower; + if (lowerName == QStringLiteral("operations menu")) + return MouseOperationsMenu; + if (lowerName == QStringLiteral("toggle raise and lower")) + return MouseToggleRaiseAndLower; + if (lowerName == QStringLiteral("activate and raise")) + return MouseActivateAndRaise; + if (lowerName == QStringLiteral("activate and lower")) + return MouseActivateAndLower; + if (lowerName == QStringLiteral("activate")) + return MouseActivate; + if (lowerName == QStringLiteral("activate, raise and pass click")) + return MouseActivateRaiseAndPassClick; + if (lowerName == QStringLiteral("activate and pass click")) + return MouseActivateAndPassClick; + if (lowerName == QStringLiteral("scroll")) + return MouseNothing; + if (lowerName == QStringLiteral("activate and scroll")) + return MouseActivateAndPassClick; + if (lowerName == QStringLiteral("activate, raise and scroll")) + return MouseActivateRaiseAndPassClick; if (lowerName == QStringLiteral("activate, raise and move")) return restricted ? MouseActivateRaiseAndMove : MouseActivateRaiseAndUnrestrictedMove; - if (lowerName == QStringLiteral("move")) return restricted ? MouseMove : MouseUnrestrictedMove; - if (lowerName == QStringLiteral("resize")) return restricted ? MouseResize : MouseUnrestrictedResize; - if (lowerName == QStringLiteral("shade")) return MouseShade; - if (lowerName == QStringLiteral("minimize")) return MouseMinimize; - if (lowerName == QStringLiteral("close")) return MouseClose; - if (lowerName == QStringLiteral("increase opacity")) return MouseOpacityMore; - if (lowerName == QStringLiteral("decrease opacity")) return MouseOpacityLess; - if (lowerName == QStringLiteral("nothing")) return MouseNothing; + if (lowerName == QStringLiteral("move")) + return restricted ? MouseMove : MouseUnrestrictedMove; + if (lowerName == QStringLiteral("resize")) + return restricted ? MouseResize : MouseUnrestrictedResize; + if (lowerName == QStringLiteral("shade")) + return MouseShade; + if (lowerName == QStringLiteral("minimize")) + return MouseMinimize; + if (lowerName == QStringLiteral("close")) + return MouseClose; + if (lowerName == QStringLiteral("increase opacity")) + return MouseOpacityMore; + if (lowerName == QStringLiteral("decrease opacity")) + return MouseOpacityLess; + if (lowerName == QStringLiteral("nothing")) + return MouseNothing; return MouseNothing; } Options::MouseWheelCommand Options::mouseWheelCommand(const QString &name) { QString lowerName = name.toLower(); - if (lowerName == QStringLiteral("raise/lower")) return MouseWheelRaiseLower; - if (lowerName == QStringLiteral("shade/unshade")) return MouseWheelShadeUnshade; - if (lowerName == QStringLiteral("maximize/restore")) return MouseWheelMaximizeRestore; - if (lowerName == QStringLiteral("above/below")) return MouseWheelAboveBelow; - if (lowerName == QStringLiteral("previous/next desktop")) return MouseWheelPreviousNextDesktop; - if (lowerName == QStringLiteral("change opacity")) return MouseWheelChangeOpacity; - if (lowerName == QStringLiteral("nothing")) return MouseWheelNothing; + if (lowerName == QStringLiteral("raise/lower")) + return MouseWheelRaiseLower; + if (lowerName == QStringLiteral("shade/unshade")) + return MouseWheelShadeUnshade; + if (lowerName == QStringLiteral("maximize/restore")) + return MouseWheelMaximizeRestore; + if (lowerName == QStringLiteral("above/below")) + return MouseWheelAboveBelow; + if (lowerName == QStringLiteral("previous/next desktop")) + return MouseWheelPreviousNextDesktop; + if (lowerName == QStringLiteral("change opacity")) + return MouseWheelChangeOpacity; + if (lowerName == QStringLiteral("nothing")) + return MouseWheelNothing; return MouseWheelNothing; } @@ -982,7 +1005,7 @@ bool Options::condensedTitle() const Options::MouseCommand Options::wheelToMouseCommand(MouseWheelCommand com, int delta) const { - switch(com) { + switch (com) { case MouseWheelRaiseLower: return delta > 0 ? MouseRaise : MouseLower; case MouseWheelShadeUnshade: @@ -1003,7 +1026,7 @@ Options::MouseCommand Options::wheelToMouseCommand(MouseWheelCommand com, int de double Options::animationTimeFactor() const { - #ifndef KCMRULES +#ifndef KCMRULES return m_settings->animationDurationFactor(); #else return 0; @@ -1012,9 +1035,8 @@ double Options::animationTimeFactor() const Options::WindowOperation Options::operationMaxButtonClick(Qt::MouseButtons button) const { - return button == Qt::RightButton ? opMaxButtonRightClick : - button == Qt::MiddleButton ? opMaxButtonMiddleClick : - opMaxButtonLeftClick; + return button == Qt::RightButton ? opMaxButtonRightClick : button == Qt::MiddleButton ? opMaxButtonMiddleClick + : opMaxButtonLeftClick; } QStringList Options::modifierOnlyDBusShortcut(Qt::KeyboardModifier mod) const diff --git a/src/options.h b/src/options.h index 6b5676bd83..638dc3c124 100644 --- a/src/options.h +++ b/src/options.h @@ -195,7 +195,6 @@ class KWIN_EXPORT Options : public QObject Q_PROPERTY(LatencyPolicy latencyPolicy READ latencyPolicy WRITE setLatencyPolicy NOTIFY latencyPolicyChanged) Q_PROPERTY(RenderTimeEstimator renderTimeEstimator READ renderTimeEstimator WRITE setRenderTimeEstimator NOTIFY renderTimeEstimatorChanged) public: - explicit Options(QObject *parent = nullptr); ~Options() override; @@ -238,17 +237,21 @@ public: }; Q_ENUM(FocusPolicy) - FocusPolicy focusPolicy() const { + FocusPolicy focusPolicy() const + { return m_focusPolicy; } - bool isNextFocusPrefersMouse() const { + bool isNextFocusPrefersMouse() const + { return m_nextFocusPrefersMouse; } - XwaylandCrashPolicy xwaylandCrashPolicy() const { + XwaylandCrashPolicy xwaylandCrashPolicy() const + { return m_xwaylandCrashPolicy; } - int xwaylandMaxCrashCount() const { + int xwaylandMaxCrashCount() const + { return m_xwaylandMaxCrashCount; } @@ -256,97 +259,111 @@ public: * Whether clicking on a window raises it in FocusFollowsMouse * mode or not. */ - bool isClickRaise() const { + bool isClickRaise() const + { return m_clickRaise; } /** * Whether autoraise is enabled FocusFollowsMouse mode or not. */ - bool isAutoRaise() const { + bool isAutoRaise() const + { return m_autoRaise; } /** * Autoraise interval */ - int autoRaiseInterval() const { + int autoRaiseInterval() const + { return m_autoRaiseInterval; } /** * Delayed focus interval. */ - int delayFocusInterval() const { + int delayFocusInterval() const + { return m_delayFocusInterval; } /** * Whether shade hover is enabled or not. */ - bool isShadeHover() const { + bool isShadeHover() const + { return m_shadeHover; } /** * Shade hover interval. */ - int shadeHoverInterval() { + int shadeHoverInterval() + { return m_shadeHoverInterval; } /** * Whether to see Xinerama screens separately for focus (in Alt+Tab, when activating next client) */ - bool isSeparateScreenFocus() const { + bool isSeparateScreenFocus() const + { return m_separateScreenFocus; } - bool activeMouseScreen() const { + bool activeMouseScreen() const + { return m_activeMouseScreen; } - Placement::Policy placement() const { + Placement::Policy placement() const + { return m_placement; } - bool focusPolicyIsReasonable() { + bool focusPolicyIsReasonable() + { return m_focusPolicy == ClickToFocus || m_focusPolicy == FocusFollowsMouse; } /** * The size of the zone that triggers snapping on desktop borders. */ - int borderSnapZone() const { + int borderSnapZone() const + { return m_borderSnapZone; } /** * The size of the zone that triggers snapping with other windows. */ - int windowSnapZone() const { + int windowSnapZone() const + { return m_windowSnapZone; } /** * The size of the zone that triggers snapping on the screen center. */ - int centerSnapZone() const { + int centerSnapZone() const + { return m_centerSnapZone; } - /** * Snap only when windows will overlap. */ - bool isSnapOnlyWhenOverlapping() const { + 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 { + bool isRollOverDesktops() const + { return m_rollOverDesktops; } @@ -355,7 +372,8 @@ public: * * @see allowClientActivation */ - int focusStealingPreventionLevel() const { + int focusStealingPreventionLevel() const + { return m_focusStealingPreventionLevel; } @@ -386,99 +404,139 @@ public: }; Q_ENUM(WindowOperation) - WindowOperation operationTitlebarDblClick() const { + WindowOperation operationTitlebarDblClick() const + { return OpTitlebarDblClick; } - WindowOperation operationMaxButtonLeftClick() const { + WindowOperation operationMaxButtonLeftClick() const + { return opMaxButtonLeftClick; } - WindowOperation operationMaxButtonRightClick() const { + WindowOperation operationMaxButtonRightClick() const + { return opMaxButtonRightClick; } - WindowOperation operationMaxButtonMiddleClick() const { + 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, + 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, MouseNothing }; Q_ENUM(MouseCommand) enum MouseWheelCommand { - MouseWheelRaiseLower, MouseWheelShadeUnshade, MouseWheelMaximizeRestore, - MouseWheelAboveBelow, MouseWheelPreviousNextDesktop, + MouseWheelRaiseLower, + MouseWheelShadeUnshade, + MouseWheelMaximizeRestore, + MouseWheelAboveBelow, + MouseWheelPreviousNextDesktop, MouseWheelChangeOpacity, MouseWheelNothing }; Q_ENUM(MouseWheelCommand) - MouseCommand operationTitlebarMouseWheel(int delta) const { + MouseCommand operationTitlebarMouseWheel(int delta) const + { return wheelToMouseCommand(CmdTitlebarWheel, delta); } - MouseCommand operationWindowMouseWheel(int delta) const { + MouseCommand operationWindowMouseWheel(int delta) const + { return wheelToMouseCommand(CmdAllWheel, delta); } - MouseCommand commandActiveTitlebar1() const { + MouseCommand commandActiveTitlebar1() const + { return CmdActiveTitlebar1; } - MouseCommand commandActiveTitlebar2() const { + MouseCommand commandActiveTitlebar2() const + { return CmdActiveTitlebar2; } - MouseCommand commandActiveTitlebar3() const { + MouseCommand commandActiveTitlebar3() const + { return CmdActiveTitlebar3; } - MouseCommand commandInactiveTitlebar1() const { + MouseCommand commandInactiveTitlebar1() const + { return CmdInactiveTitlebar1; } - MouseCommand commandInactiveTitlebar2() const { + MouseCommand commandInactiveTitlebar2() const + { return CmdInactiveTitlebar2; } - MouseCommand commandInactiveTitlebar3() const { + MouseCommand commandInactiveTitlebar3() const + { return CmdInactiveTitlebar3; } - MouseCommand commandWindow1() const { + MouseCommand commandWindow1() const + { return CmdWindow1; } - MouseCommand commandWindow2() const { + MouseCommand commandWindow2() const + { return CmdWindow2; } - MouseCommand commandWindow3() const { + MouseCommand commandWindow3() const + { return CmdWindow3; } - MouseCommand commandWindowWheel() const { + MouseCommand commandWindowWheel() const + { return CmdWindowWheel; } - MouseCommand commandAll1() const { + MouseCommand commandAll1() const + { return CmdAll1; } - MouseCommand commandAll2() const { + MouseCommand commandAll2() const + { return CmdAll2; } - MouseCommand commandAll3() const { + MouseCommand commandAll3() const + { return CmdAll3; } - MouseWheelCommand commandAllWheel() const { + MouseWheelCommand commandAllWheel() const + { return CmdAllWheel; } - uint keyCmdAllModKey() const { + uint keyCmdAllModKey() const + { return CmdAllModKey; } - Qt::KeyboardModifier commandAllModifier() const { + Qt::KeyboardModifier commandAllModifier() const + { switch (CmdAllModKey) { case Qt::Key_Alt: return Qt::AltModifier; @@ -502,38 +560,44 @@ public: * @returns true if a window gets maximized when it reaches top screen edge * while being moved. */ - bool electricBorderMaximize() const { + 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 { + 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 { + float electricBorderCornerRatio() const + { return electric_border_corner_ratio; } - bool borderlessMaximizedWindows() const { + bool borderlessMaximizedWindows() const + { return borderless_maximized_windows; } /** * Timeout before non-responding application will be killed after attempt to close. */ - int killPingTimeout() const { + int killPingTimeout() const + { return m_killPingTimeout; } /** * Whether to hide utility windows for inactive applications. */ - bool isHideUtilityWindowsForInactive() const { + bool isHideUtilityWindowsForInactive() const + { return m_hideUtilityWindowsForInactive; } @@ -545,35 +609,42 @@ public: //---------------------- // Compositing settings void reloadCompositingSettings(bool force = false); - CompositingType compositingMode() const { + CompositingType compositingMode() const + { return m_compositingMode; } - void setCompositingMode(CompositingType mode) { + void setCompositingMode(CompositingType mode) + { m_compositingMode = mode; } // Separate to mode so the user can toggle bool isUseCompositing() const; // General preferences - HiddenPreviews hiddenPreviews() const { + HiddenPreviews hiddenPreviews() const + { return m_hiddenPreviews; } // OpenGL // 1 = yes, // 2 = try trilinear when transformed; else 1, // -1 = auto - int glSmoothScale() const { + int glSmoothScale() const + { return m_glSmoothScale; } // Settings that should be auto-detected - bool isGlStrictBinding() const { + bool isGlStrictBinding() const + { return m_glStrictBinding; } - bool isGlStrictBindingFollowsDriver() const { + bool isGlStrictBindingFollowsDriver() const + { return m_glStrictBindingFollowsDriver; } - OpenGLPlatformInterface glPlatformInterface() const { + OpenGLPlatformInterface glPlatformInterface() const + { return m_glPlatformInterface; } @@ -584,7 +655,8 @@ public: AutoSwapStrategy = 'a', }; Q_ENUM(GlSwapStrategy) - GlSwapStrategy glPreferBufferSwap() const { + GlSwapStrategy glPreferBufferSwap() const + { return m_glPreferBufferSwap; } @@ -593,7 +665,8 @@ public: return m_windowsBlockCompositing; } - bool moveMinimizedWindowsToEndOfTabBoxFocusChain() const { + bool moveMinimizedWindowsToEndOfTabBoxFocusChain() const + { return m_MoveMinimizedWindowsToEndOfTabBoxFocusChain; } @@ -660,100 +733,132 @@ public: void setRenderTimeEstimator(RenderTimeEstimator estimator); // default values - static WindowOperation defaultOperationTitlebarDblClick() { + static WindowOperation defaultOperationTitlebarDblClick() + { return MaximizeOp; } - static WindowOperation defaultOperationMaxButtonLeftClick() { + static WindowOperation defaultOperationMaxButtonLeftClick() + { return MaximizeOp; } - static WindowOperation defaultOperationMaxButtonRightClick() { + static WindowOperation defaultOperationMaxButtonRightClick() + { return HMaximizeOp; } - static WindowOperation defaultOperationMaxButtonMiddleClick() { + static WindowOperation defaultOperationMaxButtonMiddleClick() + { return VMaximizeOp; } - static MouseCommand defaultCommandActiveTitlebar1() { + static MouseCommand defaultCommandActiveTitlebar1() + { return MouseRaise; } - static MouseCommand defaultCommandActiveTitlebar2() { + static MouseCommand defaultCommandActiveTitlebar2() + { return MouseNothing; } - static MouseCommand defaultCommandActiveTitlebar3() { + static MouseCommand defaultCommandActiveTitlebar3() + { return MouseOperationsMenu; } - static MouseCommand defaultCommandInactiveTitlebar1() { + static MouseCommand defaultCommandInactiveTitlebar1() + { return MouseActivateAndRaise; } - static MouseCommand defaultCommandInactiveTitlebar2() { + static MouseCommand defaultCommandInactiveTitlebar2() + { return MouseNothing; } - static MouseCommand defaultCommandInactiveTitlebar3() { + static MouseCommand defaultCommandInactiveTitlebar3() + { return MouseOperationsMenu; } - static MouseCommand defaultCommandWindow1() { + static MouseCommand defaultCommandWindow1() + { return MouseActivateRaiseAndPassClick; } - static MouseCommand defaultCommandWindow2() { + static MouseCommand defaultCommandWindow2() + { return MouseActivateAndPassClick; } - static MouseCommand defaultCommandWindow3() { + static MouseCommand defaultCommandWindow3() + { return MouseActivateAndPassClick; } - static MouseCommand defaultCommandWindowWheel() { + static MouseCommand defaultCommandWindowWheel() + { return MouseNothing; } - static MouseCommand defaultCommandAll1() { + static MouseCommand defaultCommandAll1() + { return MouseUnrestrictedMove; } - static MouseCommand defaultCommandAll2() { + static MouseCommand defaultCommandAll2() + { return MouseToggleRaiseAndLower; } - static MouseCommand defaultCommandAll3() { + static MouseCommand defaultCommandAll3() + { return MouseUnrestrictedResize; } - static MouseWheelCommand defaultCommandTitlebarWheel() { + static MouseWheelCommand defaultCommandTitlebarWheel() + { return MouseWheelNothing; } - static MouseWheelCommand defaultCommandAllWheel() { + static MouseWheelCommand defaultCommandAllWheel() + { return MouseWheelNothing; } - static uint defaultKeyCmdAllModKey() { + static uint defaultKeyCmdAllModKey() + { return Qt::Key_Alt; } - static CompositingType defaultCompositingMode() { + static CompositingType defaultCompositingMode() + { return OpenGLCompositing; } - static bool defaultUseCompositing() { + static bool defaultUseCompositing() + { return true; } - static HiddenPreviews defaultHiddenPreviews() { + static HiddenPreviews defaultHiddenPreviews() + { return HiddenPreviewsShown; } - static int defaultGlSmoothScale() { + static int defaultGlSmoothScale() + { return 2; } - static bool defaultGlStrictBinding() { + static bool defaultGlStrictBinding() + { return true; } - static bool defaultGlStrictBindingFollowsDriver() { + static bool defaultGlStrictBindingFollowsDriver() + { return true; } - static GlSwapStrategy defaultGlPreferBufferSwap() { + static GlSwapStrategy defaultGlPreferBufferSwap() + { return AutoSwapStrategy; } - static OpenGLPlatformInterface defaultGlPlatformInterface() { + static OpenGLPlatformInterface defaultGlPlatformInterface() + { return kwinApp()->shouldUseWaylandForCompositing() ? EglPlatformInterface : GlxPlatformInterface; } - static XwaylandCrashPolicy defaultXwaylandCrashPolicy() { + static XwaylandCrashPolicy defaultXwaylandCrashPolicy() + { return XwaylandCrashPolicy::Restart; } - static int defaultXwaylandMaxCrashCount() { + static int defaultXwaylandMaxCrashCount() + { return 3; } - static LatencyPolicy defaultLatencyPolicy() { + static LatencyPolicy defaultLatencyPolicy() + { return LatencyMedium; } - static RenderTimeEstimator defaultRenderTimeEstimator() { + static RenderTimeEstimator defaultRenderTimeEstimator() + { return RenderTimeEstimatorMaximum; } /** @@ -904,7 +1009,7 @@ private: MouseCommand wheelToMouseCommand(MouseWheelCommand com, int delta) const; }; -extern KWIN_EXPORT Options* options; +extern KWIN_EXPORT Options *options; } // namespace diff --git a/src/osd.cpp b/src/osd.cpp index 518b30cdb4..01d8331c95 100644 --- a/src/osd.cpp +++ b/src/osd.cpp @@ -5,10 +5,10 @@ */ #include "osd.h" -#include "onscreennotification.h" #include "main.h" -#include "workspace.h" +#include "onscreennotification.h" #include "scripting/scripting.h" +#include "workspace.h" #include diff --git a/src/outline.cpp b/src/outline.cpp index f9ce0bacfa..92b620faf7 100644 --- a/src/outline.cpp +++ b/src/outline.cpp @@ -25,7 +25,8 @@ #include #include -namespace KWin { +namespace KWin +{ KWIN_SINGLETON_FACTORY(Outline) @@ -67,7 +68,7 @@ void Outline::hide() m_visual->hide(); } -void Outline::show(const QRect& outlineGeometry) +void Outline::show(const QRect &outlineGeometry) { show(outlineGeometry, QRect()); } @@ -79,7 +80,7 @@ void Outline::show(const QRect &outlineGeometry, const QRect &visualParentGeomet show(); } -void Outline::setGeometry(const QRect& outlineGeometry) +void Outline::setGeometry(const QRect &outlineGeometry) { if (m_outlineGeometry == outlineGeometry) { return; @@ -143,7 +144,7 @@ CompositedOutlineVisual::~CompositedOutlineVisual() void CompositedOutlineVisual::hide() { - if (QQuickWindow *w = qobject_cast(m_mainItem.data())) { + if (QQuickWindow *w = qobject_cast(m_mainItem.data())) { w->hide(); w->destroy(); } @@ -158,7 +159,7 @@ void CompositedOutlineVisual::show() if (m_qmlComponent.isNull()) { m_qmlComponent.reset(new QQmlComponent(Scripting::self()->qmlEngine())); const QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation, - kwinApp()->config()->group(QStringLiteral("Outline")).readEntry("QmlPath", QStringLiteral(KWIN_NAME "/outline/plasma/outline.qml"))); + kwinApp()->config()->group(QStringLiteral("Outline")).readEntry("QmlPath", QStringLiteral(KWIN_NAME "/outline/plasma/outline.qml"))); if (fileName.isEmpty()) { qCDebug(KWIN_CORE) << "Could not locate outline.qml"; return; diff --git a/src/outline.h b/src/outline.h index f3117bbad9..0a909ef2e7 100644 --- a/src/outline.h +++ b/src/outline.h @@ -9,16 +9,17 @@ #ifndef KWIN_OUTLINE_H #define KWIN_OUTLINE_H -#include -#include #include +#include +#include #include class QQmlContext; class QQmlComponent; -namespace KWin { +namespace KWin +{ class OutlineVisual; /** @@ -32,7 +33,8 @@ class OutlineVisual; * @author Arthur Arlt * @since 4.7 */ -class Outline : public QObject { +class Outline : public QObject +{ Q_OBJECT Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged) Q_PROPERTY(QRect visualParentGeometry READ visualParentGeometry NOTIFY visualParentGeometryChanged) @@ -122,9 +124,11 @@ public: virtual ~OutlineVisual(); virtual void show() = 0; virtual void hide() = 0; + protected: Outline *outline(); const Outline *outline() const; + private: Outline *m_outline; }; @@ -136,44 +140,39 @@ public: ~CompositedOutlineVisual() override; void show() override; void hide() override; + private: QScopedPointer m_qmlContext; QScopedPointer m_qmlComponent; QScopedPointer m_mainItem; }; -inline -bool Outline::isActive() const +inline bool Outline::isActive() const { return m_active; } -inline -const QRect &Outline::geometry() const +inline const QRect &Outline::geometry() const { return m_outlineGeometry; } -inline -const QRect &Outline::visualParentGeometry() const +inline const QRect &Outline::visualParentGeometry() const { return m_visualParentGeometry; } -inline -Outline *OutlineVisual::outline() +inline Outline *OutlineVisual::outline() { return m_outline; } -inline -const Outline *OutlineVisual::outline() const +inline const Outline *OutlineVisual::outline() const { return m_outline; } -inline -Outline *outline() +inline Outline *outline() { return Outline::self(); } diff --git a/src/overlaywindow.cpp b/src/overlaywindow.cpp index 094ab51bdc..795a77d7f4 100644 --- a/src/overlaywindow.cpp +++ b/src/overlaywindow.cpp @@ -9,7 +9,8 @@ #include "overlaywindow.h" -namespace KWin { +namespace KWin +{ OverlayWindow::OverlayWindow() { } diff --git a/src/overlaywindow.h b/src/overlaywindow.h index 4b0c4d6717..bb9b00b6ac 100644 --- a/src/overlaywindow.h +++ b/src/overlaywindow.h @@ -16,8 +16,10 @@ #include -namespace KWin { -class KWIN_EXPORT OverlayWindow { +namespace KWin +{ +class KWIN_EXPORT OverlayWindow +{ public: virtual ~OverlayWindow(); /// Creates XComposite overlay window, call initOverlay() afterwards @@ -26,16 +28,17 @@ public: virtual void setup(xcb_window_t window) = 0; virtual void show() = 0; virtual void hide() = 0; // hides and resets overlay window - virtual void setShape(const QRegion& reg) = 0; + virtual void setShape(const QRegion ®) = 0; virtual void resize(const QSize &size) = 0; /// Destroys XComposite overlay window virtual void destroy() = 0; virtual xcb_window_t window() const = 0; virtual bool isVisible() const = 0; virtual void setVisibility(bool visible) = 0; + protected: OverlayWindow(); }; } // namespace -#endif //KWIN_OVERLAYWINDOW_H +#endif // KWIN_OVERLAYWINDOW_H diff --git a/src/placement.cpp b/src/placement.cpp index 5b0fd493c2..4cb29a6434 100644 --- a/src/placement.cpp +++ b/src/placement.cpp @@ -12,13 +12,13 @@ #include "placement.h" #ifndef KCMRULES -#include "workspace.h" -#include "x11client.h" #include "cursor.h" #include "options.h" #include "rules.h" #include "screens.h" #include "virtualdesktops.h" +#include "workspace.h" +#include "x11client.h" #endif #include @@ -31,7 +31,7 @@ namespace KWin KWIN_SINGLETON_FACTORY(Placement) -Placement::Placement(QObject*) +Placement::Placement(QObject *) { reinitCascading(0); } @@ -57,7 +57,7 @@ void Placement::place(AbstractClient *c, const QRect &area) else if (c->isDialog()) placeDialog(c, area, options->placement()); else if (c->isSplash()) - placeOnMainWindow(c, area); // on mainwindow, if any, otherwise centered + placeOnMainWindow(c, area); // on mainwindow, if any, otherwise centered else if (c->isOnScreenDisplay() || c->isNotification() || c->isCriticalNotification()) placeOnScreenDisplay(c, area); else if (c->isTransient() && c->hasTransientPlacementHint()) @@ -105,11 +105,11 @@ void Placement::place(AbstractClient *c, const QRect &area, Policy policy, Polic /** * Place the client \a c according to a simply "random" placement algorithm. */ -void Placement::placeAtRandom(AbstractClient* c, const QRect& area, Policy /*next*/) +void Placement::placeAtRandom(AbstractClient *c, const QRect &area, Policy /*next*/) { Q_ASSERT(area.isValid()); - const int step = 24; + const int step = 24; static int px = step; static int py = 2 * step; int tx, ty; @@ -168,7 +168,7 @@ static inline bool isIrrelevant(const AbstractClient *client, const AbstractClie /** * Place the client \a c according to a really smart placement algorithm :-) */ -void Placement::placeSmart(AbstractClient* c, const QRect& area, Policy /*next*/) +void Placement::placeSmart(AbstractClient *c, const QRect &area, Policy /*next*/) { Q_ASSERT(area.isValid()); @@ -191,46 +191,52 @@ void Placement::placeSmart(AbstractClient* c, const QRect& area, Policy /*next*/ int possible; int desktop = c->desktop() == 0 || c->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : c->desktop(); - int cxl, cxr, cyt, cyb; //temp coords - int xl, xr, yt, yb; //temp coords - int basket; //temp holder + int cxl, cxr, cyt, cyb; // temp coords + int xl, xr, yt, yb; // temp coords + int basket; // temp holder // get the maximum allowed windows space int x = area.left(); int y = area.top(); - x_optimal = x; y_optimal = y; + x_optimal = x; + y_optimal = y; - //client gabarit + // client gabarit int ch = c->height() - 1; - int cw = c->width() - 1; + int cw = c->width() - 1; - bool first_pass = true; //CT lame flag. Don't like it. What else would do? + bool first_pass = true; // CT lame flag. Don't like it. What else would do? - //loop over possible positions + // loop over possible positions do { - //test if enough room in x and y directions + // test if enough room in x and y directions if (y + ch > area.bottom() && ch < area.height()) { overlap = h_wrong; // this throws the algorithm to an exit } else if (x + cw > area.right()) { overlap = w_wrong; } else { - overlap = none; //initialize + overlap = none; // initialize - cxl = x; cxr = x + cw; - cyt = y; cyb = y + ch; - for (auto l = workspace()->stackingOrder().constBegin(); l != workspace()->stackingOrder().constEnd() ; ++l) { - AbstractClient *client = qobject_cast(*l); + cxl = x; + cxr = x + cw; + cyt = y; + cyb = y + ch; + for (auto l = workspace()->stackingOrder().constBegin(); l != workspace()->stackingOrder().constEnd(); ++l) { + AbstractClient *client = qobject_cast(*l); if (isIrrelevant(client, c, desktop)) { continue; } - xl = client->x(); yt = client->y(); - xr = xl + client->width(); yb = yt + client->height(); + xl = client->x(); + yt = client->y(); + xr = xl + client->width(); + yb = yt + client->height(); - //if windows overlap, calc the overall overlapping - if ((cxl < xr) && (cxr > xl) && - (cyt < yb) && (cyb > yt)) { - xl = qMax(cxl, xl); xr = qMin(cxr, xr); - yt = qMax(cyt, yt); yb = qMin(cyb, yb); + // if windows overlap, calc the overall overlapping + if ((cxl < xr) && (cxr > xl) && (cyt < yb) && (cyb > yt)) { + xl = qMax(cxl, xl); + xr = qMin(cxr, xr); + yt = qMax(cyt, yt); + yb = qMin(cyb, yb); if (client->keepAbove()) overlap += 16 * (xr - xl) * (yb - yt); else if (client->keepBelow() && !client->isDock()) // ignore KeepBelow windows @@ -241,7 +247,7 @@ void Placement::placeSmart(AbstractClient* c, const QRect& area, Policy /*next*/ } } - //CT first time we get no overlap we stop. + // CT first time we get no overlap we stop. if (overlap == none) { x_optimal = x; y_optimal = y; @@ -252,7 +258,7 @@ void Placement::placeSmart(AbstractClient* c, const QRect& area, Policy /*next*/ first_pass = false; min_overlap = overlap; } - //CT save the best position and the minimum overlap up to now + // CT save the best position and the minimum overlap up to now else if (overlap >= none && overlap < min_overlap) { min_overlap = overlap; x_optimal = x; @@ -263,26 +269,31 @@ void Placement::placeSmart(AbstractClient* c, const QRect& area, Policy /*next*/ if (overlap > none) { possible = area.right(); - if (possible - cw > x) possible -= cw; + if (possible - cw > x) + possible -= cw; // compare to the position of each client on the same desk - for (auto l = workspace()->stackingOrder().constBegin(); l != workspace()->stackingOrder().constEnd() ; ++l) { - AbstractClient *client = qobject_cast(*l); + for (auto l = workspace()->stackingOrder().constBegin(); l != workspace()->stackingOrder().constEnd(); ++l) { + AbstractClient *client = qobject_cast(*l); if (isIrrelevant(client, c, desktop)) { continue; } - xl = client->x(); yt = client->y(); - xr = xl + client->width(); yb = yt + client->height(); + xl = client->x(); + yt = client->y(); + xr = xl + client->width(); + yb = yt + client->height(); // if not enough room above or under the current tested client // determine the first non-overlapped x position if ((y < yb) && (yt < ch + y)) { - if ((xr > x) && (possible > xr)) possible = xr; + if ((xr > x) && (possible > xr)) + possible = xr; basket = xl - cw; - if ((basket > x) && (possible > basket)) possible = basket; + if ((basket > x) && (possible > basket)) + possible = basket; } } x = possible; @@ -293,24 +304,29 @@ void Placement::placeSmart(AbstractClient* c, const QRect& area, Policy /*next*/ x = area.left(); possible = area.bottom(); - if (possible - ch > y) possible -= ch; + if (possible - ch > y) + possible -= ch; - //test the position of each window on the desk - for (auto l = workspace()->stackingOrder().constBegin(); l != workspace()->stackingOrder().constEnd() ; ++l) { - AbstractClient *client = qobject_cast(*l); + // test the position of each window on the desk + for (auto l = workspace()->stackingOrder().constBegin(); l != workspace()->stackingOrder().constEnd(); ++l) { + AbstractClient *client = qobject_cast(*l); if (isIrrelevant(client, c, desktop)) { continue; } - xl = client->x(); yt = client->y(); - xr = xl + client->width(); yb = yt + client->height(); + xl = client->x(); + yt = client->y(); + xr = xl + client->width(); + yb = yt + client->height(); // if not enough room to the left or right of the current tested client // determine the first non-overlapped y position - if ((yb > y) && (possible > yb)) possible = yb; + if ((yb > y) && (possible > yb)) + possible = yb; basket = yt - ch; - if ((basket > y) && (possible > basket)) possible = basket; + if ((basket > y) && (possible > basket)) + possible = basket; } y = possible; } @@ -322,7 +338,6 @@ void Placement::placeSmart(AbstractClient* c, const QRect& area, Policy /*next*/ // place the window c->move(QPoint(x_optimal, y_optimal)); - } void Placement::reinitCascading(int desktop) @@ -346,7 +361,7 @@ void Placement::reinitCascading(int desktop) QPoint Workspace::cascadeOffset(const AbstractClient *c) const { QRect area = clientArea(PlacementArea, c, c->frameGeometry().center()); - return QPoint(area.width()/48, area.height()/48); + return QPoint(area.width() / 48, area.height() / 48); } /** @@ -365,7 +380,7 @@ void Placement::placeCascaded(AbstractClient *c, const QRect &area, Policy nextP // work coords int xp, yp; - //CT how do I get from the 'Client' class the size that NW squarish "handle" + // CT how do I get from the 'Client' class the size that NW squarish "handle" const QPoint delta = workspace()->cascadeOffset(c); const int dn = c->desktop() == 0 || c->isOnAllDesktops() ? (VirtualDesktopManager::self()->current() - 1) : (c->desktop() - 1); @@ -381,27 +396,28 @@ void Placement::placeCascaded(AbstractClient *c, const QRect &area, Policy nextP if (nextPlacement == Unknown) nextPlacement = Smart; - //initialize if needed + // initialize if needed if (cci[dn].pos.x() < 0 || cci[dn].pos.x() < X || cci[dn].pos.y() < Y) { cci[dn].pos = QPoint(X, Y); cci[dn].col = cci[dn].row = 0; } - xp = cci[dn].pos.x(); yp = cci[dn].pos.y(); - //here to touch in case people vote for resize on placement - if ((yp + ch) > H) yp = Y; + // here to touch in case people vote for resize on placement + if ((yp + ch) > H) + yp = Y; if ((xp + cw) > W) { if (!yp) { place(c, area, nextPlacement); return; - } else xp = X; + } else + xp = X; } - //if this isn't the first window + // if this isn't the first window if (cci[dn].pos.x() != X && cci[dn].pos.y() != Y) { /* The following statements cause an internal compiler error with * egcs-2.91.66 on SuSE Linux 6.3. The equivalent forms compile fine. @@ -436,7 +452,7 @@ void Placement::placeCascaded(AbstractClient *c, const QRect &area, Policy nextP /** * Place windows centered, on top of all others */ -void Placement::placeCentered(AbstractClient* c, const QRect& area, Policy /*next*/) +void Placement::placeCentered(AbstractClient *c, const QRect &area, Policy /*next*/) { Q_ASSERT(area.isValid()); @@ -454,7 +470,7 @@ void Placement::placeCentered(AbstractClient* c, const QRect& area, Policy /*nex /** * Place windows in the (0,0) corner, on top of all others */ -void Placement::placeZeroCornered(AbstractClient* c, const QRect& area, Policy /*next*/) +void Placement::placeZeroCornered(AbstractClient *c, const QRect &area, Policy /*next*/) { Q_ASSERT(area.isValid()); @@ -464,10 +480,10 @@ void Placement::placeZeroCornered(AbstractClient* c, const QRect& area, Policy / void Placement::placeUtility(AbstractClient *c, const QRect &area, Policy /*next*/) { -// TODO kwin should try to place utility windows next to their mainwindow, -// preferably at the right edge, and going down if there are more of them -// if there's not enough place outside the mainwindow, it should prefer -// top-right corner + // TODO kwin should try to place utility windows next to their mainwindow, + // preferably at the right edge, and going down if there are more of them + // if there's not enough place outside the mainwindow, it should prefer + // top-right corner // use the default placement for now place(c, area, Default); } @@ -477,7 +493,7 @@ void Placement::placeOnScreenDisplay(AbstractClient *c, const QRect &area) Q_ASSERT(area.isValid()); // place at lower area of the screen - const int x = area.left() + (area.width() - c->width()) / 2; + const int x = area.left() + (area.width() - c->width()) / 2; const int y = area.top() + 2 * area.height() / 3 - c->height() / 2; c->move(QPoint(x, y)); @@ -486,7 +502,7 @@ void Placement::placeOnScreenDisplay(AbstractClient *c, const QRect &area) void Placement::placeTransient(AbstractClient *c) { const auto parent = c->transientFor(); - const QRect screen = Workspace::self()->clientArea(parent->isFullScreen() ? FullScreenArea : PlacementArea, parent); + const QRect screen = Workspace::self()->clientArea(parent->isFullScreen() ? FullScreenArea : PlacementArea, parent); c->moveResize(c->transientPlacement(screen)); // Potentially a client could set no constraint adjustments @@ -512,7 +528,7 @@ void Placement::placeUnderMouse(AbstractClient *c, const QRect &area, Policy /*n QRect geom = c->frameGeometry(); geom.moveCenter(Cursors::self()->mouse()->pos()); c->move(geom.topLeft()); - c->keepInArea(area); // make sure it's kept inside workarea + c->keepInArea(area); // make sure it's kept inside workarea } void Placement::placeOnMainWindow(AbstractClient *c, const QRect &area, Policy nextPlacement) @@ -521,15 +537,13 @@ void Placement::placeOnMainWindow(AbstractClient *c, const QRect &area, Policy n if (nextPlacement == Unknown) nextPlacement = Centered; - if (nextPlacement == Maximizing) // maximize if needed + if (nextPlacement == Maximizing) // maximize if needed placeMaximizing(c, area, NoPlacement); auto mainwindows = c->mainClients(); - AbstractClient* place_on = nullptr; - AbstractClient* place_on2 = nullptr; + AbstractClient *place_on = nullptr; + AbstractClient *place_on2 = nullptr; int mains_count = 0; - for (auto it = mainwindows.constBegin(); - it != mainwindows.constEnd(); - ++it) { + for (auto it = mainwindows.constBegin(); it != mainwindows.constEnd(); ++it) { if (mainwindows.count() > 1 && (*it)->isSpecialWindow()) continue; // don't consider toolbars etc when placing ++mains_count; @@ -566,7 +580,7 @@ void Placement::placeOnMainWindow(AbstractClient *c, const QRect &area, Policy n c->move(geom.topLeft()); // get area again, because the mainwindow may be on different xinerama screen const QRect placementArea = workspace()->clientArea(PlacementArea, c); - c->keepInArea(placementArea); // make sure it's kept inside workarea + c->keepInArea(placementArea); // make sure it's kept inside workarea } void Placement::placeMaximizing(AbstractClient *c, const QRect &area, Policy nextPlacement) @@ -595,12 +609,8 @@ void Placement::cascadeDesktop() reinitCascading(desktop); const auto stackingOrder = ws->stackingOrder(); for (Toplevel *toplevel : stackingOrder) { - auto client = qobject_cast(toplevel); - if (!client || - (!client->isOnCurrentDesktop()) || - (client->isMinimized()) || - (client->isOnAllDesktops()) || - (!client->isMovable())) + auto client = qobject_cast(toplevel); + if (!client || (!client->isOnCurrentDesktop()) || (client->isMinimized()) || (client->isOnAllDesktops()) || (!client->isMovable())) continue; const QRect placementArea = workspace()->clientArea(PlacementArea, client); placeCascaded(client, placementArea); @@ -612,10 +622,7 @@ void Placement::unclutterDesktop() const auto &clients = Workspace::self()->allClientList(); for (int i = clients.size() - 1; i >= 0; i--) { auto client = clients.at(i); - if ((!client->isOnCurrentDesktop()) || - (client->isMinimized()) || - (client->isOnAllDesktops()) || - (!client->isMovable())) + if ((!client->isOnCurrentDesktop()) || (client->isMinimized()) || (client->isOnAllDesktops()) || (!client->isMovable())) continue; const QRect placementArea = workspace()->clientArea(PlacementArea, client); placeSmart(client, placementArea); @@ -624,17 +631,15 @@ void Placement::unclutterDesktop() #endif -const char* Placement::policyToString(Policy policy) +const char *Placement::policyToString(Policy policy) { - const char* const policies[] = { + const char *const policies[] = { "NoPlacement", "Default", "XXX should never see", "Random", "Smart", "Cascade", "Centered", - "ZeroCornered", "UnderMouse", "OnMainWindow", "Maximizing" - }; - Q_ASSERT(policy < int(sizeof(policies) / sizeof(policies[ 0 ]))); - return policies[ policy ]; + "ZeroCornered", "UnderMouse", "OnMainWindow", "Maximizing"}; + Q_ASSERT(policy < int(sizeof(policies) / sizeof(policies[0]))); + return policies[policy]; } - #ifndef KCMRULES // ******************** @@ -723,7 +728,9 @@ void AbstractClient::growHorizontal() // TODO this may be wrong? if (workspace()->clientArea(MovementArea, this, - QPoint((x() + newright) / 2, moveResizeGeometry().center().y())).right() >= newright) + QPoint((x() + newright) / 2, moveResizeGeometry().center().y())) + .right() + >= newright) geom.setRight(newright); } geom.setSize(constrainFrameSize(geom.size(), SizeModeFixedW)); @@ -771,7 +778,9 @@ void AbstractClient::growVertical() // check that it hasn't grown outside of the area, due to size increments if (workspace()->clientArea(MovementArea, this, - QPoint(moveResizeGeometry().center().x(), (y() + newbottom) / 2)).bottom() >= newbottom) + QPoint(moveResizeGeometry().center().x(), (y() + newbottom) / 2)) + .bottom() + >= newbottom) geom.setBottom(newbottom); } geom.setSize(constrainFrameSize(geom.size(), SizeModeFixedH)); @@ -779,7 +788,6 @@ void AbstractClient::growVertical() moveResize(geom); } - void Workspace::slotWindowShrinkVertical() { if (active_client) @@ -815,9 +823,8 @@ void Workspace::quickTileWindow(QuickTileMode mode) m_lastTilingMode = mode; } else { if ( - ( (m_lastTilingMode == FLAG(Left) || m_lastTilingMode == FLAG(Right)) && (mode == FLAG(Top) || mode == FLAG(Bottom)) ) - || - ( (m_lastTilingMode == FLAG(Top) || m_lastTilingMode == FLAG(Bottom)) && (mode == FLAG(Left) || mode == FLAG(Right)) ) + ((m_lastTilingMode == FLAG(Left) || m_lastTilingMode == FLAG(Right)) && (mode == FLAG(Top) || mode == FLAG(Bottom))) + || ((m_lastTilingMode == FLAG(Top) || m_lastTilingMode == FLAG(Bottom)) && (mode == FLAG(Left) || mode == FLAG(Right))) #undef FLAG ) { mode |= m_lastTilingMode; @@ -834,7 +841,8 @@ int Workspace::packPositionLeft(const AbstractClient *client, int oldX, bool lef if (oldX <= newX) { // try another Xinerama screen newX = clientArea(MaximizeArea, client, - QPoint(client->frameGeometry().left() - 1, client->frameGeometry().center().y())).left(); + QPoint(client->frameGeometry().left() - 1, client->frameGeometry().center().y())) + .left(); } if (oldX <= newX) { return oldX; @@ -846,8 +854,8 @@ int Workspace::packPositionLeft(const AbstractClient *client, int oldX, bool lef } const int x = leftEdge ? (*it)->frameGeometry().right() + 1 : (*it)->frameGeometry().left() - 1; if (x > newX && x < oldX - && !(client->frameGeometry().top() > (*it)->frameGeometry().bottom() // they overlap in Y direction - || client->frameGeometry().bottom() < (*it)->frameGeometry().top())) { + && !(client->frameGeometry().top() > (*it)->frameGeometry().bottom() // they overlap in Y direction + || client->frameGeometry().bottom() < (*it)->frameGeometry().top())) { newX = x; } } @@ -860,7 +868,8 @@ int Workspace::packPositionRight(const AbstractClient *client, int oldX, bool ri if (oldX >= newX) { // try another Xinerama screen newX = clientArea(MaximizeArea, client, - QPoint(client->frameGeometry().right() + 1, client->frameGeometry().center().y())).right(); + QPoint(client->frameGeometry().right() + 1, client->frameGeometry().center().y())) + .right(); } if (oldX >= newX) { return oldX; @@ -872,8 +881,8 @@ int Workspace::packPositionRight(const AbstractClient *client, int oldX, bool ri } const int x = rightEdge ? (*it)->frameGeometry().left() - 1 : (*it)->frameGeometry().right() + 1; if (x < newX && x > oldX - && !(client->frameGeometry().top() > (*it)->frameGeometry().bottom() - || client->frameGeometry().bottom() < (*it)->frameGeometry().top())) { + && !(client->frameGeometry().top() > (*it)->frameGeometry().bottom() + || client->frameGeometry().bottom() < (*it)->frameGeometry().top())) { newX = x; } } @@ -886,7 +895,8 @@ int Workspace::packPositionUp(const AbstractClient *client, int oldY, bool topEd if (oldY <= newY) { // try another Xinerama screen newY = clientArea(MaximizeArea, client, - QPoint(client->frameGeometry().center().x(), client->frameGeometry().top() - 1)).top(); + QPoint(client->frameGeometry().center().x(), client->frameGeometry().top() - 1)) + .top(); } if (oldY <= newY) { return oldY; @@ -898,8 +908,8 @@ int Workspace::packPositionUp(const AbstractClient *client, int oldY, bool topEd } const int y = topEdge ? (*it)->frameGeometry().bottom() + 1 : (*it)->frameGeometry().top() - 1; if (y > newY && y < oldY - && !(client->frameGeometry().left() > (*it)->frameGeometry().right() // they overlap in X direction - || client->frameGeometry().right() < (*it)->frameGeometry().left())) { + && !(client->frameGeometry().left() > (*it)->frameGeometry().right() // they overlap in X direction + || client->frameGeometry().right() < (*it)->frameGeometry().left())) { newY = y; } } @@ -912,7 +922,8 @@ int Workspace::packPositionDown(const AbstractClient *client, int oldY, bool bot if (oldY >= newY) { // try another Xinerama screen newY = clientArea(MaximizeArea, client, - QPoint(client->frameGeometry().center().x(), client->frameGeometry().bottom() + 1)).bottom(); + QPoint(client->frameGeometry().center().x(), client->frameGeometry().bottom() + 1)) + .bottom(); } if (oldY >= newY) { return oldY; @@ -924,8 +935,8 @@ int Workspace::packPositionDown(const AbstractClient *client, int oldY, bool bot } const int y = bottomEdge ? (*it)->frameGeometry().top() - 1 : (*it)->frameGeometry().bottom() + 1; if (y < newY && y > oldY - && !(client->frameGeometry().left() > (*it)->frameGeometry().right() - || client->frameGeometry().right() < (*it)->frameGeometry().left())) { + && !(client->frameGeometry().left() > (*it)->frameGeometry().right() + || client->frameGeometry().right() < (*it)->frameGeometry().left())) { newY = y; } } diff --git a/src/placement.h b/src/placement.h index 59072492da..908b3ab565 100644 --- a/src/placement.h +++ b/src/placement.h @@ -14,9 +14,9 @@ // KWin #include // Qt +#include #include #include -#include class QObject; @@ -51,9 +51,9 @@ public: }; void place(AbstractClient *c, const QRect &area); - void placeSmart(AbstractClient* c, const QRect& area, Policy next = Unknown); + void placeSmart(AbstractClient *c, const QRect &area, Policy next = Unknown); - void placeCentered(AbstractClient* c, const QRect& area, Policy next = Unknown); + void placeCentered(AbstractClient *c, const QRect &area, Policy next = Unknown); void reinitCascading(int desktop); @@ -66,7 +66,7 @@ public: */ void unclutterDesktop(); - static const char* policyToString(Policy policy); + static const char *policyToString(Policy policy); private: void place(AbstractClient *c, const QRect &area, Policy policy, Policy nextPlacement = Unknown); @@ -74,16 +74,17 @@ private: void placeOnMainWindow(AbstractClient *c, const QRect &area, Policy next = Unknown); void placeTransient(AbstractClient *c); - void placeAtRandom(AbstractClient* c, const QRect& area, Policy next = Unknown); - void placeCascaded(AbstractClient* c, const QRect& area, Policy next = Unknown); - void placeMaximizing(AbstractClient* c, const QRect& area, Policy next = Unknown); - void placeZeroCornered(AbstractClient* c, const QRect& area, Policy next = Unknown); - void placeDialog(AbstractClient* c, const QRect& area, Policy next = Unknown); - void placeUtility(AbstractClient* c, const QRect& area, Policy next = Unknown); - void placeOnScreenDisplay(AbstractClient* c, const QRect& area); + void placeAtRandom(AbstractClient *c, const QRect &area, Policy next = Unknown); + void placeCascaded(AbstractClient *c, const QRect &area, Policy next = Unknown); + void placeMaximizing(AbstractClient *c, const QRect &area, Policy next = Unknown); + void placeZeroCornered(AbstractClient *c, const QRect &area, Policy next = Unknown); + void placeDialog(AbstractClient *c, const QRect &area, Policy next = Unknown); + void placeUtility(AbstractClient *c, const QRect &area, Policy next = Unknown); + void placeOnScreenDisplay(AbstractClient *c, const QRect &area); - //CT needed for cascading+ - struct DesktopCascadingInfo { + // CT needed for cascading+ + struct DesktopCascadingInfo + { QPoint pos; int col; int row; diff --git a/src/platform.cpp b/src/platform.cpp index 6e0a575cb0..782b1d1c66 100644 --- a/src/platform.cpp +++ b/src/platform.cpp @@ -6,27 +6,29 @@ SPDX-License-Identifier: GPL-2.0-or-later */ + #include "platform.h" -#include "abstract_output.h" #include + +#include "abstract_output.h" #include "composite.h" #include "cursor.h" #include "effects.h" #include "keyboard_input.h" -#include -#include "overlaywindow.h" #include "outline.h" +#include "overlaywindow.h" #include "pointer_input.h" #include "scene.h" -#include "screens.h" #include "screenedge.h" +#include "screens.h" #include "touch_input.h" #include "wayland_server.h" #include "waylandoutputconfig.h" +#include -#include #include +#include #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #include @@ -43,12 +45,12 @@ Platform::Platform(QObject *parent) : QObject(parent) , m_eglDisplay(EGL_NO_DISPLAY) { - connect(this, &Platform::outputDisabled, this, [this] (AbstractOutput *output) { + connect(this, &Platform::outputDisabled, this, [this](AbstractOutput *output) { if (m_primaryOutput == output) { setPrimaryOutput(enabledOutputs().value(0, nullptr)); } }); - connect(this, &Platform::outputEnabled, this, [this] (AbstractOutput *output) { + connect(this, &Platform::outputEnabled, this, [this](AbstractOutput *output) { if (!m_primaryOutput) { setPrimaryOutput(output); } @@ -61,7 +63,7 @@ Platform::~Platform() PlatformCursorImage Platform::cursorImage() const { - Cursor* cursor = Cursors::self()->currentCursor(); + Cursor *cursor = Cursors::self()->currentCursor(); return PlatformCursorImage(cursor->image(), cursor->hotspot()); } @@ -102,7 +104,7 @@ void Platform::requestOutputsChange(KWaylandServer::OutputConfigurationV2Interfa const auto changes = config->changes(); for (auto it = changes.begin(); it != changes.end(); it++) { const KWaylandServer::OutputChangeSetV2 *changeset = it.value(); - auto output = qobject_cast(findOutput(it.key()->uuid())); + auto output = qobject_cast(findOutput(it.key()->uuid())); if (!output) { qCWarning(KWIN_CORE) << "Could NOT find output matching " << it.key()->uuid(); continue; @@ -120,8 +122,8 @@ void Platform::requestOutputsChange(KWaylandServer::OutputConfigurationV2Interfa } const auto allOutputs = outputs(); - bool allDisabled = !std::any_of(allOutputs.begin(), allOutputs.end(), [&cfg](const auto &output){ - auto o = qobject_cast(output); + bool allDisabled = !std::any_of(allOutputs.begin(), allOutputs.end(), [&cfg](const auto &output) { + auto o = qobject_cast(output); if (!o) { qCWarning(KWIN_CORE) << "Platform::requestOutputsChange should only be called for Wayland platforms!"; return false; @@ -156,20 +158,20 @@ void Platform::requestOutputsChange(KWaylandServer::OutputConfigurationV2Interfa bool Platform::applyOutputChanges(const WaylandOutputConfig &config) { const auto availableOutputs = outputs(); - QVector toBeEnabledOutputs; - QVector toBeDisabledOutputs; + QVector toBeEnabledOutputs; + QVector toBeDisabledOutputs; for (const auto &output : availableOutputs) { - if (config.constChangeSet(qobject_cast(output))->enabled) { + if (config.constChangeSet(qobject_cast(output))->enabled) { toBeEnabledOutputs << output; } else { toBeDisabledOutputs << output; } } for (const auto &output : toBeEnabledOutputs) { - static_cast(output)->applyChanges(config); + static_cast(output)->applyChanges(config); } for (const auto &output : toBeDisabledOutputs) { - static_cast(output)->applyChanges(config); + static_cast(output)->applyChanges(config); } return true; } @@ -183,9 +185,9 @@ AbstractOutput *Platform::findOutput(const QUuid &uuid) const { const auto outs = outputs(); auto it = std::find_if(outs.constBegin(), outs.constEnd(), - [uuid](AbstractOutput *output) { - return output->uuid() == uuid; } - ); + [uuid](AbstractOutput *output) { + return output->uuid() == uuid; + }); if (it != outs.constEnd()) { return *it; } @@ -238,7 +240,7 @@ void Platform::keyboardKeyReleased(quint32 key, quint32 time) if (!input()) { return; } - input()->keyboard()->processKey(key, InputRedirection::KeyboardKeyReleased, time); + input()->keyboard()->processKey(key, InputRedirection::KeyboardKeyReleased, time); } void Platform::keyboardModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group) @@ -491,7 +493,7 @@ void Platform::createOpenGLSafePoint(OpenGLSafePoint safePoint) Q_UNUSED(safePoint) } -void Platform::startInteractiveWindowSelection(std::function callback, const QByteArray &cursorName) +void Platform::startInteractiveWindowSelection(std::function callback, const QByteArray &cursorName) { if (!input()) { callback(nullptr); @@ -550,7 +552,7 @@ void Platform::updateXTime() OutlineVisual *Platform::createOutline(Outline *outline) { if (Compositor::compositing()) { - return new CompositedOutlineVisual(outline); + return new CompositedOutlineVisual(outline); } return nullptr; } @@ -558,7 +560,7 @@ OutlineVisual *Platform::createOutline(Outline *outline) void Platform::invertScreen() { if (effects) { - if (Effect *inverter = static_cast(effects)->provides(Effect::ScreenInversion)) { + if (Effect *inverter = static_cast(effects)->provides(Effect::ScreenInversion)) { qCDebug(KWIN_CORE) << "inverting screen using Effect plugin"; QMetaObject::invokeMethod(inverter, "toggleScreenInversion", Qt::DirectConnection); } diff --git a/src/platform.h b/src/platform.h index 3fcc1ed65e..1c1db88071 100644 --- a/src/platform.h +++ b/src/platform.h @@ -8,10 +8,10 @@ */ #ifndef KWIN_PLATFORM_H #define KWIN_PLATFORM_H +#include "input.h" +#include #include #include -#include -#include "input.h" #include #include @@ -20,7 +20,8 @@ class QAction; -namespace KWaylandServer { +namespace KWaylandServer +{ class OutputConfigurationV2Interface; } @@ -43,12 +44,13 @@ class Session; class Toplevel; class WaylandOutputConfig; -class KWIN_EXPORT Outputs : public QVector +class KWIN_EXPORT Outputs : public QVector { public: Outputs(){}; - template - Outputs(const QVector &other) { + template + Outputs(const QVector &other) + { resize(other.size()); std::copy(other.constBegin(), other.constEnd(), begin()); } @@ -65,7 +67,8 @@ public: virtual InputBackend *createInputBackend(); virtual OpenGLBackend *createOpenGLBackend(); virtual QPainterBackend *createQPainterBackend(); - virtual DmaBufTexture *createDmaBufTexture(const QSize &size) { + virtual DmaBufTexture *createDmaBufTexture(const QSize &size) + { Q_UNUSED(size); return nullptr; } @@ -184,7 +187,7 @@ public: * @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()); + virtual void startInteractiveWindowSelection(std::function callback, const QByteArray &cursorName = QByteArray()); /** * Starts an interactive position selection process. @@ -229,28 +232,36 @@ public: */ virtual PlatformCursorImage cursorImage() const; - bool isReady() const { + bool isReady() const + { return m_ready; } - void setInitialWindowSize(const QSize &size) { + void setInitialWindowSize(const QSize &size) + { m_initialWindowSize = size; } - void setDeviceIdentifier(const QByteArray &identifier) { + void setDeviceIdentifier(const QByteArray &identifier) + { m_deviceIdentifier = identifier; } - bool supportsPointerWarping() const { + bool supportsPointerWarping() const + { return m_pointerWarping; } - int initialOutputCount() const { + int initialOutputCount() const + { return m_initialOutputCount; } - void setInitialOutputCount(int count) { + void setInitialOutputCount(int count) + { m_initialOutputCount = count; } - qreal initialOutputScale() const { + qreal initialOutputScale() const + { return m_initialOutputScale; } - void setInitialOutputScale(qreal scale) { + void setInitialOutputScale(qreal scale) + { m_initialOutputScale = scale; } @@ -293,16 +304,19 @@ public: * Whether gamma control is supported by the backend. * @since 5.12 */ - bool supportsGammaControl() const { + bool supportsGammaControl() const + { return m_supportsGammaControl; } // outputs with connections (org_kde_kwin_outputdevice) - virtual Outputs outputs() const { + virtual Outputs outputs() const + { return Outputs(); } // actively compositing outputs (wl_output) - virtual Outputs enabledOutputs() const { + virtual Outputs enabledOutputs() const + { return Outputs(); } AbstractOutput *findOutput(int screenId) const; @@ -344,7 +358,8 @@ public: /** * @returns the primary output amomg the enabled outputs */ - AbstractOutput *primaryOutput() const { + AbstractOutput *primaryOutput() const + { return m_primaryOutput; } @@ -363,9 +378,9 @@ public Q_SLOTS: 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); + InputRedirection::PointerAxisSource source = InputRedirection::PointerAxisSourceUnknown); void pointerAxisVertical(qreal delta, quint32 time, qint32 discreteDelta = 0, - InputRedirection::PointerAxisSource source = InputRedirection::PointerAxisSourceUnknown); + 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); @@ -386,7 +401,7 @@ public Q_SLOTS: void processPinchGestureEnd(quint32 time); void processPinchGestureCancelled(quint32 time); - virtual void sceneInitialized() {}; + virtual void sceneInitialized(){}; Q_SIGNALS: void screensQueried(); @@ -420,23 +435,28 @@ protected: explicit Platform(QObject *parent = nullptr); void repaint(const QRect &rect); void setReady(bool ready); - QSize initialWindowSize() const { + QSize initialWindowSize() const + { return m_initialWindowSize; } - QByteArray deviceIdentifier() const { + QByteArray deviceIdentifier() const + { return m_deviceIdentifier; } - void setSupportsPointerWarping(bool set) { + void setSupportsPointerWarping(bool set) + { m_pointerWarping = set; } - void setSupportsGammaControl(bool set) { + void setSupportsGammaControl(bool set) + { m_supportsGammaControl = set; } /** * Whether the backend is supposed to change the configuration of outputs. */ - void supportsOutputChanges() { + void supportsOutputChanges() + { m_supportsOutputChanges = true; } diff --git a/src/platformsupport/scenes/opengl/abstract_egl_backend.cpp b/src/platformsupport/scenes/opengl/abstract_egl_backend.cpp index e5fa3eaa4f..b98f2dc8d8 100644 --- a/src/platformsupport/scenes/opengl/abstract_egl_backend.cpp +++ b/src/platformsupport/scenes/opengl/abstract_egl_backend.cpp @@ -7,13 +7,13 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "abstract_egl_backend.h" -#include "egl_dmabuf.h" +#include "abstract_wayland_output.h" #include "composite.h" +#include "egl_dmabuf.h" #include "options.h" #include "platform.h" #include "utils/egl_context_attribute_builder.h" #include "wayland_server.h" -#include "abstract_wayland_output.h" #include // kwin libs #include @@ -135,7 +135,7 @@ bool AbstractEglBackend::initEglAPI() } typedef void (*eglFuncPtr)(); -static eglFuncPtr getProcAddress(const char* name) +static eglFuncPtr getProcAddress(const char *name) { return eglGetProcAddress(name); } @@ -199,12 +199,12 @@ void AbstractEglBackend::initWayland() void AbstractEglBackend::initClientExtensions() { // Get the list of client extensions - const char* clientExtensionsCString = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); + const char *clientExtensionsCString = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); const QByteArray clientExtensionsString = QByteArray::fromRawData(clientExtensionsCString, qstrlen(clientExtensionsCString)); if (clientExtensionsString.isEmpty()) { // If eglQueryString() returned NULL, the implementation doesn't support // EGL_EXT_client_extensions. Expect an EGL_BAD_DISPLAY error. - (void) eglGetError(); + (void)eglGetError(); } m_clientExtensions = clientExtensionsString.split(' '); @@ -351,7 +351,8 @@ EGLContext AbstractEglBackend::createContextInternal(EGLContext sharedContext) return ctx; } -void AbstractEglBackend::setEglDisplay(const EGLDisplay &display) { +void AbstractEglBackend::setEglDisplay(const EGLDisplay &display) +{ m_display = display; kwinApp()->platform()->setSceneEglDisplay(display); } diff --git a/src/platformsupport/scenes/opengl/abstract_egl_backend.h b/src/platformsupport/scenes/opengl/abstract_egl_backend.h index df3f49cf76..2a5ac47a56 100644 --- a/src/platformsupport/scenes/opengl/abstract_egl_backend.h +++ b/src/platformsupport/scenes/opengl/abstract_egl_backend.h @@ -19,9 +19,9 @@ struct wl_resource; namespace KWin { -typedef GLboolean(*eglBindWaylandDisplayWL_func)(EGLDisplay dpy, wl_display *display); -typedef GLboolean(*eglUnbindWaylandDisplayWL_func)(EGLDisplay dpy, wl_display *display); -typedef GLboolean(*eglQueryWaylandBufferWL_func)(EGLDisplay dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value); +typedef GLboolean (*eglBindWaylandDisplayWL_func)(EGLDisplay dpy, wl_display *display); +typedef GLboolean (*eglUnbindWaylandDisplayWL_func)(EGLDisplay dpy, wl_display *display); +typedef GLboolean (*eglQueryWaylandBufferWL_func)(EGLDisplay dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value); struct AbstractEglBackendFunctions { @@ -41,19 +41,24 @@ public: bool makeCurrent() override; void doneCurrent() override; - const AbstractEglBackendFunctions *functions() const { + const AbstractEglBackendFunctions *functions() const + { return &m_functions; } - EGLDisplay eglDisplay() const { + EGLDisplay eglDisplay() const + { return m_display; } - EGLContext context() const { + EGLContext context() const + { return m_context; } - EGLSurface surface() const { + EGLSurface surface() const + { return m_surface; } - EGLConfig config() const { + EGLConfig config() const + { return m_config; } @@ -96,7 +101,7 @@ private: QList m_clientExtensions; const dev_t m_deviceId; - static AbstractEglBackend * s_primaryBackend; + static AbstractEglBackend *s_primaryBackend; }; } diff --git a/src/platformsupport/scenes/opengl/basiceglsurfacetexture_wayland.cpp b/src/platformsupport/scenes/opengl/basiceglsurfacetexture_wayland.cpp index 380b38475f..12023dc137 100644 --- a/src/platformsupport/scenes/opengl/basiceglsurfacetexture_wayland.cpp +++ b/src/platformsupport/scenes/opengl/basiceglsurfacetexture_wayland.cpp @@ -202,8 +202,7 @@ EGLImageKHR BasicEGLSurfaceTextureWayland::attach(KWaylandServer::DrmClientBuffe const EGLint attribs[] = { EGL_WAYLAND_PLANE_WL, 0, - EGL_NONE - }; + EGL_NONE}; EGLImageKHR image = eglCreateImageKHR(backend()->eglDisplay(), EGL_NO_CONTEXT, EGL_WAYLAND_BUFFER_WL, static_cast(buffer->resource()), attribs); diff --git a/src/platformsupport/scenes/opengl/egl_dmabuf.cpp b/src/platformsupport/scenes/opengl/egl_dmabuf.cpp index c155194ad0..cddb1a0416 100644 --- a/src/platformsupport/scenes/opengl/egl_dmabuf.cpp +++ b/src/platformsupport/scenes/opengl/egl_dmabuf.cpp @@ -20,8 +20,8 @@ namespace KWin { -typedef EGLBoolean (*eglQueryDmaBufFormatsEXT_func) (EGLDisplay dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats); -typedef EGLBoolean (*eglQueryDmaBufModifiersEXT_func) (EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR *modifiers, EGLBoolean *external_only, EGLint *num_modifiers); +typedef EGLBoolean (*eglQueryDmaBufFormatsEXT_func)(EGLDisplay dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats); +typedef EGLBoolean (*eglQueryDmaBufModifiersEXT_func)(EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR *modifiers, EGLBoolean *external_only, EGLint *num_modifiers); eglQueryDmaBufFormatsEXT_func eglQueryDmaBufFormatsEXT = nullptr; eglQueryDmaBufModifiersEXT_func eglQueryDmaBufModifiersEXT = nullptr; @@ -43,85 +43,52 @@ struct YuvFormat }; YuvFormat yuvFormats[] = { - { - DRM_FORMAT_YUYV, - 1, 2, - EGL_TEXTURE_Y_XUXV_WL, - { - { - 1, 1, - DRM_FORMAT_GR88, - 0 - }, - { - 2, 1, - DRM_FORMAT_ARGB8888, - 0 - } - } - }, - { - DRM_FORMAT_NV12, - 2, 2, - EGL_TEXTURE_Y_UV_WL, - { - { - 1, 1, - DRM_FORMAT_R8, - 0 - }, - { - 2, 2, - DRM_FORMAT_GR88, - 1 - } - } - }, - { - DRM_FORMAT_YUV420, - 3, 3, - EGL_TEXTURE_Y_U_V_WL, - { - { - 1, 1, - DRM_FORMAT_R8, - 0 - }, - { - 2, 2, - DRM_FORMAT_R8, - 1 - }, - { - 2, 2, - DRM_FORMAT_R8, - 2 - } - } - }, - { - DRM_FORMAT_YUV444, - 3, 3, - EGL_TEXTURE_Y_U_V_WL, - { - { - 1, 1, - DRM_FORMAT_R8, - 0 - }, - { - 1, 1, - DRM_FORMAT_R8, - 1 - }, - { - 1, 1, - DRM_FORMAT_R8, - 2 - } - } - } -}; + {DRM_FORMAT_YUYV, + 1, + 2, + EGL_TEXTURE_Y_XUXV_WL, + {{1, 1, + DRM_FORMAT_GR88, + 0}, + {2, 1, + DRM_FORMAT_ARGB8888, + 0}}}, + {DRM_FORMAT_NV12, + 2, + 2, + EGL_TEXTURE_Y_UV_WL, + {{1, 1, + DRM_FORMAT_R8, + 0}, + {2, 2, + DRM_FORMAT_GR88, + 1}}}, + {DRM_FORMAT_YUV420, + 3, + 3, + EGL_TEXTURE_Y_U_V_WL, + {{1, 1, + DRM_FORMAT_R8, + 0}, + {2, 2, + DRM_FORMAT_R8, + 1}, + {2, 2, + DRM_FORMAT_R8, + 2}}}, + {DRM_FORMAT_YUV444, + 3, + 3, + EGL_TEXTURE_Y_U_V_WL, + {{1, 1, + DRM_FORMAT_R8, + 0}, + {1, 1, + DRM_FORMAT_R8, + 1}, + {1, 1, + DRM_FORMAT_R8, + 2}}}}; EglDmabufBuffer::EglDmabufBuffer(EGLImage image, const QVector &planes, @@ -135,7 +102,6 @@ EglDmabufBuffer::EglDmabufBuffer(EGLImage image, addImage(image); } - EglDmabufBuffer::EglDmabufBuffer(const QVector &planes, uint32_t format, const QSize &size, @@ -174,60 +140,59 @@ EGLImage EglDmabuf::createImage(const QVector attribs; - attribs << EGL_WIDTH << size.width() - << EGL_HEIGHT << size.height() - << EGL_LINUX_DRM_FOURCC_EXT << EGLint(format) + attribs << EGL_WIDTH << size.width() + << EGL_HEIGHT << size.height() + << EGL_LINUX_DRM_FOURCC_EXT << EGLint(format) - << EGL_DMA_BUF_PLANE0_FD_EXT << planes[0].fd - << EGL_DMA_BUF_PLANE0_OFFSET_EXT << EGLint(planes[0].offset) - << EGL_DMA_BUF_PLANE0_PITCH_EXT << EGLint(planes[0].stride); + << EGL_DMA_BUF_PLANE0_FD_EXT << planes[0].fd + << EGL_DMA_BUF_PLANE0_OFFSET_EXT << EGLint(planes[0].offset) + << EGL_DMA_BUF_PLANE0_PITCH_EXT << EGLint(planes[0].stride); if (hasModifiers) { attribs - << EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT << EGLint(planes[0].modifier & 0xffffffff) - << EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT << EGLint(planes[0].modifier >> 32); + << EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT << EGLint(planes[0].modifier & 0xffffffff) + << EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT << EGLint(planes[0].modifier >> 32); } if (planes.count() > 1) { attribs - << EGL_DMA_BUF_PLANE1_FD_EXT << planes[1].fd - << EGL_DMA_BUF_PLANE1_OFFSET_EXT << EGLint(planes[1].offset) - << EGL_DMA_BUF_PLANE1_PITCH_EXT << EGLint(planes[1].stride); + << EGL_DMA_BUF_PLANE1_FD_EXT << planes[1].fd + << EGL_DMA_BUF_PLANE1_OFFSET_EXT << EGLint(planes[1].offset) + << EGL_DMA_BUF_PLANE1_PITCH_EXT << EGLint(planes[1].stride); if (hasModifiers) { attribs - << EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT << EGLint(planes[1].modifier & 0xffffffff) - << EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT << EGLint(planes[1].modifier >> 32); + << EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT << EGLint(planes[1].modifier & 0xffffffff) + << EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT << EGLint(planes[1].modifier >> 32); } } if (planes.count() > 2) { attribs - << EGL_DMA_BUF_PLANE2_FD_EXT << planes[2].fd - << EGL_DMA_BUF_PLANE2_OFFSET_EXT << EGLint(planes[2].offset) - << EGL_DMA_BUF_PLANE2_PITCH_EXT << EGLint(planes[2].stride); + << EGL_DMA_BUF_PLANE2_FD_EXT << planes[2].fd + << EGL_DMA_BUF_PLANE2_OFFSET_EXT << EGLint(planes[2].offset) + << EGL_DMA_BUF_PLANE2_PITCH_EXT << EGLint(planes[2].stride); if (hasModifiers) { attribs - << EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT << EGLint(planes[2].modifier & 0xffffffff) - << EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT << EGLint(planes[2].modifier >> 32); + << EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT << EGLint(planes[2].modifier & 0xffffffff) + << EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT << EGLint(planes[2].modifier >> 32); } } if (eglQueryDmaBufModifiersEXT != nullptr && planes.count() > 3) { attribs - << EGL_DMA_BUF_PLANE3_FD_EXT << planes[3].fd - << EGL_DMA_BUF_PLANE3_OFFSET_EXT << EGLint(planes[3].offset) - << EGL_DMA_BUF_PLANE3_PITCH_EXT << EGLint(planes[3].stride); + << EGL_DMA_BUF_PLANE3_FD_EXT << planes[3].fd + << EGL_DMA_BUF_PLANE3_OFFSET_EXT << EGLint(planes[3].offset) + << EGL_DMA_BUF_PLANE3_PITCH_EXT << EGLint(planes[3].stride); if (hasModifiers) { attribs - << EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT << EGLint(planes[3].modifier & 0xffffffff) - << EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT << EGLint(planes[3].modifier >> 32); + << EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT << EGLint(planes[3].modifier & 0xffffffff) + << EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT << EGLint(planes[3].modifier >> 32); } } @@ -261,8 +226,8 @@ KWaylandServer::LinuxDmaBufV1ClientBuffer *EglDmabuf::importBuffer(const QVector // TODO: to enable this we must be able to store multiple textures per window pixmap // and when on window draw do yuv to rgb transformation per shader (see Weston) -// // not a single image, try yuv import -// return yuvImport(planes, format, size, flags); + // // not a single image, try yuv import + // return yuvImport(planes, format, size, flags); return nullptr; } @@ -294,8 +259,7 @@ KWaylandServer::LinuxDmaBufV1ClientBuffer *EglDmabuf::yuvImport(const QVectorhasExtension(QByteArrayLiteral("EGL_EXT_image_dma_buf_import"))) { return nullptr; } if (backend->hasExtension(QByteArrayLiteral("EGL_EXT_image_dma_buf_import_modifiers"))) { - eglQueryDmaBufFormatsEXT = (eglQueryDmaBufFormatsEXT_func) eglGetProcAddress("eglQueryDmaBufFormatsEXT"); - eglQueryDmaBufModifiersEXT = (eglQueryDmaBufModifiersEXT_func) eglGetProcAddress("eglQueryDmaBufModifiersEXT"); + eglQueryDmaBufFormatsEXT = (eglQueryDmaBufFormatsEXT_func)eglGetProcAddress("eglQueryDmaBufFormatsEXT"); + eglQueryDmaBufModifiersEXT = (eglQueryDmaBufModifiersEXT_func)eglGetProcAddress("eglQueryDmaBufModifiersEXT"); } if (eglQueryDmaBufFormatsEXT == nullptr) { @@ -335,7 +299,7 @@ EglDmabuf::EglDmabuf(AbstractEglBackend *backend) { auto prevBuffersSet = waylandServer()->linuxDmabufBuffers(); for (auto *buffer : prevBuffersSet) { - auto *buf = static_cast(buffer); + auto *buf = static_cast(buffer); buf->setInterfaceImplementation(this); buf->addImage(createImage(buf->planes(), buf->format(), buf->size())); } @@ -346,7 +310,7 @@ EglDmabuf::~EglDmabuf() { auto curBuffers = waylandServer()->linuxDmabufBuffers(); for (auto *buffer : curBuffers) { - auto *buf = static_cast(buffer); + auto *buf = static_cast(buffer); buf->removeImages(); } } @@ -377,8 +341,7 @@ const uint32_t s_multiPlaneFormats[] = { DRM_FORMAT_YUV422, DRM_FORMAT_YVU422, DRM_FORMAT_YUV444, - DRM_FORMAT_YVU444 -}; + DRM_FORMAT_YVU444}; void filterFormatsWithMultiplePlanes(QVector &formats) { @@ -398,7 +361,7 @@ void filterFormatsWithMultiplePlanes(QVector &formats) static int bpcForFormat(uint32_t format) { - switch(format) { + switch (format) { case DRM_FORMAT_XRGB8888: case DRM_FORMAT_XBGR8888: case DRM_FORMAT_RGBX8888: @@ -436,7 +399,7 @@ void EglDmabuf::setSupportedFormatsAndModifiers() } QVector formats(count); - if (!eglQueryDmaBufFormatsEXT(eglDisplay, count, (EGLint *) formats.data(), &count)) { + if (!eglQueryDmaBufFormatsEXT(eglDisplay, count, (EGLint *)formats.data(), &count)) { qCCritical(KWIN_OPENGL) << "eglQueryDmaBufFormatsEXT with count" << count << "failed!" << getEglErrorString(); return; } diff --git a/src/platformsupport/scenes/opengl/egl_dmabuf.h b/src/platformsupport/scenes/opengl/egl_dmabuf.h index 25e27e3c85..fb63e18a1d 100644 --- a/src/platformsupport/scenes/opengl/egl_dmabuf.h +++ b/src/platformsupport/scenes/opengl/egl_dmabuf.h @@ -46,7 +46,10 @@ public: void addImage(EGLImage image); void removeImages(); - QVector images() const { return m_images; } + QVector images() const + { + return m_images; + } private: QVector m_images; @@ -57,7 +60,7 @@ private: class EglDmabuf : public LinuxDmaBufV1RendererInterface { public: - static EglDmabuf* factory(AbstractEglBackend *backend); + static EglDmabuf *factory(AbstractEglBackend *backend); explicit EglDmabuf(AbstractEglBackend *backend); ~EglDmabuf() override; @@ -67,7 +70,8 @@ public: const QSize &size, quint32 flags) override; - QVector tranches() const { + QVector tranches() const + { return m_tranches; } diff --git a/src/platformsupport/scenes/opengl/kwineglext.h b/src/platformsupport/scenes/opengl/kwineglext.h index cae312a008..7656c95ea0 100644 --- a/src/platformsupport/scenes/opengl/kwineglext.h +++ b/src/platformsupport/scenes/opengl/kwineglext.h @@ -14,52 +14,52 @@ #include #ifndef EGL_WL_bind_wayland_display -#define EGL_WAYLAND_BUFFER_WL 0x31D5 -#define EGL_WAYLAND_PLANE_WL 0x31D6 -#define EGL_TEXTURE_Y_U_V_WL 0x31D7 -#define EGL_TEXTURE_Y_UV_WL 0x31D8 -#define EGL_TEXTURE_Y_XUXV_WL 0x31D9 -#define EGL_TEXTURE_EXTERNAL_WL 0x31DA -#define EGL_WAYLAND_Y_INVERTED_WL 0x31DB +#define EGL_WAYLAND_BUFFER_WL 0x31D5 +#define EGL_WAYLAND_PLANE_WL 0x31D6 +#define EGL_TEXTURE_Y_U_V_WL 0x31D7 +#define EGL_TEXTURE_Y_UV_WL 0x31D8 +#define EGL_TEXTURE_Y_XUXV_WL 0x31D9 +#define EGL_TEXTURE_EXTERNAL_WL 0x31DA +#define EGL_WAYLAND_Y_INVERTED_WL 0x31DB #endif // EGL_WL_bind_wayland_display #ifndef EGL_EXT_image_dma_buf_import -#define EGL_LINUX_DMA_BUF_EXT 0x3270 -#define EGL_LINUX_DRM_FOURCC_EXT 0x3271 -#define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272 -#define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273 -#define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274 -#define EGL_DMA_BUF_PLANE1_FD_EXT 0x3275 -#define EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276 -#define EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277 -#define EGL_DMA_BUF_PLANE2_FD_EXT 0x3278 -#define EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279 -#define EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A -#define EGL_YUV_COLOR_SPACE_HINT_EXT 0x327B -#define EGL_SAMPLE_RANGE_HINT_EXT 0x327C +#define EGL_LINUX_DMA_BUF_EXT 0x3270 +#define EGL_LINUX_DRM_FOURCC_EXT 0x3271 +#define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272 +#define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273 +#define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274 +#define EGL_DMA_BUF_PLANE1_FD_EXT 0x3275 +#define EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276 +#define EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277 +#define EGL_DMA_BUF_PLANE2_FD_EXT 0x3278 +#define EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279 +#define EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A +#define EGL_YUV_COLOR_SPACE_HINT_EXT 0x327B +#define EGL_SAMPLE_RANGE_HINT_EXT 0x327C #define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D -#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E -#define EGL_ITU_REC601_EXT 0x327F -#define EGL_ITU_REC709_EXT 0x3280 -#define EGL_ITU_REC2020_EXT 0x3281 -#define EGL_YUV_FULL_RANGE_EXT 0x3282 -#define EGL_YUV_NARROW_RANGE_EXT 0x3283 -#define EGL_YUV_CHROMA_SITING_0_EXT 0x3284 -#define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285 +#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E +#define EGL_ITU_REC601_EXT 0x327F +#define EGL_ITU_REC709_EXT 0x3280 +#define EGL_ITU_REC2020_EXT 0x3281 +#define EGL_YUV_FULL_RANGE_EXT 0x3282 +#define EGL_YUV_NARROW_RANGE_EXT 0x3283 +#define EGL_YUV_CHROMA_SITING_0_EXT 0x3284 +#define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285 #endif // EGL_EXT_image_dma_buf_import #ifndef EGL_EXT_image_dma_buf_import_modifiers -#define EGL_DMA_BUF_PLANE3_FD_EXT 0x3440 -#define EGL_DMA_BUF_PLANE3_OFFSET_EXT 0x3441 -#define EGL_DMA_BUF_PLANE3_PITCH_EXT 0x3442 -#define EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT 0x3443 -#define EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT 0x3444 -#define EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT 0x3445 -#define EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT 0x3446 -#define EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT 0x3447 -#define EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT 0x3448 -#define EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT 0x3449 -#define EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT 0x344A +#define EGL_DMA_BUF_PLANE3_FD_EXT 0x3440 +#define EGL_DMA_BUF_PLANE3_OFFSET_EXT 0x3441 +#define EGL_DMA_BUF_PLANE3_PITCH_EXT 0x3442 +#define EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT 0x3443 +#define EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT 0x3444 +#define EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT 0x3445 +#define EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT 0x3446 +#define EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT 0x3447 +#define EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT 0x3448 +#define EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT 0x3449 +#define EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT 0x344A #endif // EGL_EXT_image_dma_buf_import_modifiers #endif // KWINEGLEXT_H diff --git a/src/platformsupport/scenes/opengl/openglbackend.cpp b/src/platformsupport/scenes/opengl/openglbackend.cpp index 0f064fd1b8..37b07250c4 100644 --- a/src/platformsupport/scenes/opengl/openglbackend.cpp +++ b/src/platformsupport/scenes/opengl/openglbackend.cpp @@ -56,7 +56,7 @@ void OpenGLBackend::copyPixels(const QRegion ®ion) } } -QSharedPointer OpenGLBackend::textureForOutput(AbstractOutput* output) const +QSharedPointer OpenGLBackend::textureForOutput(AbstractOutput *output) const { Q_UNUSED(output) return {}; diff --git a/src/platformsupport/scenes/opengl/openglbackend.h b/src/platformsupport/scenes/opengl/openglbackend.h index bbccee9ffc..c2c9e6693a 100644 --- a/src/platformsupport/scenes/opengl/openglbackend.h +++ b/src/platformsupport/scenes/opengl/openglbackend.h @@ -66,7 +66,8 @@ public: * * @return bool @c true if the creation of the Backend failed, @c false otherwise. */ - bool isFailed() const { + bool isFailed() const + { return m_failed; } /** @@ -77,11 +78,13 @@ public: * * @return bool @c true if the GL context is direct, @c false if indirect */ - bool isDirectRendering() const { + bool isDirectRendering() const + { return m_directRendering; } - bool supportsBufferAge() const { + bool supportsBufferAge() const + { return m_haveBufferAge; } @@ -104,14 +107,16 @@ public: * * Not the OpenGL (ES) extension! */ - QList extensions() const { + QList extensions() const + { return m_extensions; } /** * @returns whether the backend specific extensions contains @p extension. */ - bool hasExtension(const QByteArray &extension) const { + bool hasExtension(const QByteArray &extension) const + { return m_extensions.contains(extension); } @@ -141,11 +146,13 @@ protected: * * @param direct @c true if the OpenGL context is direct, @c false if indirect */ - void setIsDirectRendering(bool direct) { + void setIsDirectRendering(bool direct) + { m_directRendering = direct; } - void setSupportsBufferAge(bool value) { + void setSupportsBufferAge(bool value) + { m_haveBufferAge = value; } @@ -169,7 +176,8 @@ protected: * * These are the EGL/GLX extensions, not the OpenGL extensions */ - void setExtensions(const QList &extensions) { + void setExtensions(const QList &extensions) + { m_extensions = extensions; } diff --git a/src/platformsupport/scenes/qpainter/qpainterbackend.h b/src/platformsupport/scenes/qpainter/qpainterbackend.h index 8173efea0c..d041f63198 100644 --- a/src/platformsupport/scenes/qpainter/qpainterbackend.h +++ b/src/platformsupport/scenes/qpainter/qpainterbackend.h @@ -44,7 +44,8 @@ public: * * @return bool @c true if the creation of the Backend failed, @c false otherwise. */ - bool isFailed() const { + bool isFailed() const + { return m_failed; } virtual QImage *bufferForScreen(AbstractOutput *output) = 0; diff --git a/src/platformsupport/vsyncconvenience/softwarevsyncmonitor.cpp b/src/platformsupport/vsyncconvenience/softwarevsyncmonitor.cpp index 7c7b196061..5f00dd7d02 100644 --- a/src/platformsupport/vsyncconvenience/softwarevsyncmonitor.cpp +++ b/src/platformsupport/vsyncconvenience/softwarevsyncmonitor.cpp @@ -37,7 +37,7 @@ void SoftwareVsyncMonitor::handleSyntheticVsync() Q_EMIT vblankOccurred(m_vblankTimestamp); } -template +template T alignTimestamp(const T ×tamp, const T &alignment) { return timestamp + ((alignment - (timestamp % alignment)) % alignment); diff --git a/src/plugins/colord-integration/colorddevice.cpp b/src/plugins/colord-integration/colorddevice.cpp index fb174b5fac..dfd16d5142 100644 --- a/src/plugins/colord-integration/colorddevice.cpp +++ b/src/plugins/colord-integration/colorddevice.cpp @@ -8,8 +8,8 @@ #include "abstract_output.h" #include "colordevice.h" #include "colordlogging.h" -#include "colormanager.h" #include "colordprofileinterface.h" +#include "colormanager.h" namespace KWin { diff --git a/src/plugins/colord-integration/colordintegration.cpp b/src/plugins/colord-integration/colordintegration.cpp index 2d1f37e3dc..cf437ba584 100644 --- a/src/plugins/colord-integration/colordintegration.cpp +++ b/src/plugins/colord-integration/colordintegration.cpp @@ -24,8 +24,7 @@ ColordIntegration::ColordIntegration(QObject *parent) auto watcher = new QDBusServiceWatcher(QStringLiteral("org.freedesktop.ColorManager"), QDBusConnection::systemBus(), - QDBusServiceWatcher::WatchForRegistration | - QDBusServiceWatcher::WatchForUnregistration, this); + QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration, this); connect(watcher, &QDBusServiceWatcher::serviceRegistered, this, &ColordIntegration::initialize); connect(watcher, &QDBusServiceWatcher::serviceUnregistered, this, &ColordIntegration::teardown); @@ -97,7 +96,7 @@ void ColordIntegration::handleOutputAdded(AbstractOutput *output) } QDBusPendingReply reply = - m_colordInterface->CreateDevice(output->name(), QStringLiteral("temp"), properties); + m_colordInterface->CreateDevice(output->name(), QStringLiteral("temp"), properties); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, device, watcher]() { diff --git a/src/plugins/colord-integration/main.cpp b/src/plugins/colord-integration/main.cpp index df723b71b9..edf3b8fa2d 100644 --- a/src/plugins/colord-integration/main.cpp +++ b/src/plugins/colord-integration/main.cpp @@ -4,8 +4,8 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ -#include "colordintegration.h" #include "main.h" +#include "colordintegration.h" #include diff --git a/src/plugins/idletime/poller.cpp b/src/plugins/idletime/poller.cpp index 7680ba703a..7d9142fea3 100644 --- a/src/plugins/idletime/poller.cpp +++ b/src/plugins/idletime/poller.cpp @@ -11,9 +11,8 @@ #include #include "wayland_server.h" -#include #include - +#include namespace KWin { @@ -60,7 +59,7 @@ void KWinIdleTimePoller::addTimeout(int newTimeout) auto timer = new QTimer(); timer->setInterval(newTimeout); timer->setSingleShot(true); - timer->callOnTimeout(this, [newTimeout, this](){ + timer->callOnTimeout(this, [newTimeout, this]() { m_idling = true; Q_EMIT timeoutReached(newTimeout); }); @@ -122,7 +121,7 @@ void KWinIdleTimePoller::stopCatchingIdleEvents() void KWinIdleTimePoller::simulateUserActivity() { if (waylandServer()->idle()->isInhibited()) { - return ; + return; } processActivity(); waylandServer()->simulateUserActivity(); @@ -133,7 +132,7 @@ void KWinIdleTimePoller::removeTimeout(int nextTimeout) delete m_timeouts.take(nextTimeout); } -QList< int > KWinIdleTimePoller::timeouts() const +QList KWinIdleTimePoller::timeouts() const { return m_timeouts.keys(); } diff --git a/src/plugins/kdecorations/aurorae/src/aurorae.cpp b/src/plugins/kdecorations/aurorae/src/aurorae.cpp index e18273afb0..74c98ce40a 100644 --- a/src/plugins/kdecorations/aurorae/src/aurorae.cpp +++ b/src/plugins/kdecorations/aurorae/src/aurorae.cpp @@ -3,10 +3,11 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "aurorae.h" -#include "auroraetheme.h" + #include "config-kwin.h" + +#include "auroraetheme.h" #include "kwinoffscreenquickview.h" // qml imports #include "decorationoptions.h" @@ -15,18 +16,18 @@ #include #include // KDE +#include #include #include -#include #include #include #include +#include #include #include -#include // Qt -#include #include +#include #include #include #include @@ -34,12 +35,12 @@ #include #include #include -#include -#include -#include #include #include #include +#include +#include +#include #include #include #include @@ -49,9 +50,7 @@ K_PLUGIN_FACTORY_WITH_JSON(AuroraeDecoFactory, "aurorae.json", registerPlugin(); registerPlugin(); - registerPlugin(); - ) - + registerPlugin();) namespace Aurorae { @@ -63,18 +62,20 @@ public: void unref(); QQmlComponent *component(const QString &theme); QQmlContext *rootContext(); - QQmlComponent *svgComponent() { + QQmlComponent *svgComponent() + { return m_svgComponent.data(); } static Helper &instance(); + private: Helper() = default; void init(); QQmlComponent *loadComponent(const QString &themeName); int m_refCount = 0; QScopedPointer m_engine; - QHash m_components; + QHash m_components; QScopedPointer m_svgComponent; }; @@ -157,10 +158,9 @@ QQmlComponent *Helper::loadComponent(const QString &themeName) const QString internalname = themeName.toLower(); const auto offers = KPackage::PackageLoader::self()->findPackages(QStringLiteral("KWin/Decoration"), s_qmlPackageFolder, - [internalname] (const KPluginMetaData &data) { - return data.pluginId().compare(internalname, Qt::CaseInsensitive) == 0; - } - ); + [internalname](const KPluginMetaData &data) { + return data.pluginId().compare(internalname, Qt::CaseInsensitive) == 0; + }); if (offers.isEmpty()) { qCCritical(AURORAE) << "Couldn't find QML Decoration " << themeName; // TODO: what to do in error case? @@ -288,18 +288,19 @@ void Decoration::init() const KSharedConfigPtr conf = KSharedConfig::openConfig(QStringLiteral("auroraerc")); const KConfigGroup themeGroup(conf, m_themeName.mid(16)); theme->setButtonSize((KDecoration2::BorderSize)(themeGroup.readEntry("ButtonSize", - int(KDecoration2::BorderSize::Normal) - s_indexMapper) + s_indexMapper)); + int(KDecoration2::BorderSize::Normal) - s_indexMapper) + + s_indexMapper)); }; connect(this, &Decoration::configChanged, theme, readButtonSize); readButtonSize(); -// m_theme->setTabDragMimeType(tabDragMimeType()); + // m_theme->setTabDragMimeType(tabDragMimeType()); m_qmlContext->setContextProperty(QStringLiteral("auroraeTheme"), theme); } - m_item = qobject_cast< QQuickItem* >(component->create(m_qmlContext)); + m_item = qobject_cast(component->create(m_qmlContext)); if (!m_item) { if (component->isError()) { const auto errors = component->errors(); - for (const auto &error: errors) { + for (const auto &error : errors) { qCWarning(AURORAE) << error; } } @@ -310,12 +311,14 @@ void Decoration::init() QVariant visualParent = property("visualParent"); if (visualParent.isValid()) { - m_item->setParentItem(visualParent.value()); - visualParent.value()->setProperty("drawBackground", false); + m_item->setParentItem(visualParent.value()); + visualParent.value()->setProperty("drawBackground", false); } else { m_view = new KWin::OffscreenQuickView(this, KWin::OffscreenQuickView::ExportMode::Image); m_item->setParentItem(m_view->contentItem()); - auto updateSize = [this]() { m_item->setSize(m_view->contentItem()->size()); }; + auto updateSize = [this]() { + m_item->setSize(m_view->contentItem()->size()); + }; updateSize(); connect(m_view->contentItem(), &QQuickItem::widthChanged, m_item, updateSize); connect(m_view->contentItem(), &QQuickItem::heightChanged, m_item, updateSize); @@ -326,7 +329,6 @@ void Decoration::init() setupBorders(m_item); - // TODO: Is there a more efficient way to react to border changes? auto trackBorders = [this](KWin::Borders *borders) { if (!borders) { @@ -386,10 +388,10 @@ QVariant Decoration::readConfig(const QString &key, const QVariant &defaultValue void Decoration::setupBorders(QQuickItem *item) { - m_borders = item->findChild(QStringLiteral("borders")); - m_maximizedBorders = item->findChild(QStringLiteral("maximizedBorders")); - m_extendedBorders = item->findChild(QStringLiteral("extendedBorders")); - m_padding = item->findChild(QStringLiteral("padding")); + m_borders = item->findChild(QStringLiteral("borders")); + m_maximizedBorders = item->findChild(QStringLiteral("maximizedBorders")); + m_extendedBorders = item->findChild(QStringLiteral("extendedBorders")); + m_padding = item->findChild(QStringLiteral("padding")); } void Decoration::updateBorders() @@ -429,9 +431,7 @@ void Decoration::updateShadow() } bool updateShadow = false; const auto oldShadow = shadow(); - if (m_padding && - (m_padding->left() > 0 || m_padding->top() > 0 || m_padding->right() > 0 || m_padding->bottom() > 0) && - !clientPointer()->isMaximized()) { + if (m_padding && (m_padding->left() > 0 || m_padding->top() > 0 || m_padding->right() > 0 || m_padding->bottom() > 0) && !clientPointer()->isMaximized()) { if (oldShadow.isNull()) { updateShadow = true; } else { @@ -448,9 +448,9 @@ void Decoration::updateShadow() img.fill(Qt::transparent); QPainter p(&img); // top - p.drawImage(0, 0, m_buffer, 0, 0, imageSize.width() * dpr, m_padding->top() * dpr); + p.drawImage(0, 0, m_buffer, 0, 0, imageSize.width() * dpr, m_padding->top() * dpr); // left - p.drawImage(0, m_padding->top(), m_buffer, 0, m_padding->top() * dpr, m_padding->left() * dpr, (imageSize.height() - m_padding->top()) * dpr); + p.drawImage(0, m_padding->top(), m_buffer, 0, m_padding->top() * dpr, m_padding->left() * dpr, (imageSize.height() - m_padding->top()) * dpr); // bottom p.drawImage(m_padding->left(), imageSize.height() - m_padding->bottom(), m_buffer, m_padding->left() * dpr, (imageSize.height() - m_padding->bottom()) * dpr, @@ -458,7 +458,7 @@ void Decoration::updateShadow() // right p.drawImage(imageSize.width() - m_padding->right(), m_padding->top(), m_buffer, (imageSize.width() - m_padding->right()) * dpr, m_padding->top() * dpr, - m_padding->right() * dpr, (imageSize.height() - m_padding->top() - m_padding->bottom()) * dpr); + m_padding->right() * dpr, (imageSize.height() - m_padding->top() - m_padding->bottom()) * dpr); if (!updateShadow) { updateShadow = (oldShadow->shadow() != img); } @@ -491,7 +491,7 @@ void Decoration::hoverEnterEvent(QHoverEvent *event) void Decoration::hoverLeaveEvent(QHoverEvent *event) { if (m_view) { - m_view->forwardMouseEvent(event); + m_view->forwardMouseEvent(event); } KDecoration2::Decoration::hoverLeaveEvent(event); } @@ -565,7 +565,7 @@ void Decoration::updateExtendedBorders() extBottom = qMax(m_extendedBorders->bottom(), extSize); } - } else if (settings()->borderSize() == KDecoration2::BorderSize::NoSides && !clientPointer()->isMaximizedHorizontally() ) { + } else if (settings()->borderSize() == KDecoration2::BorderSize::NoSides && !clientPointer()->isMaximizedHorizontally()) { extLeft = qMax(m_extendedBorders->left(), extSize); extRight = qMax(m_extendedBorders->right(), extSize); } @@ -592,7 +592,7 @@ void Decoration::updateBlur() // moving mask by 1,1 because mask size has already been adjusted to be smaller than the frame. // Since the svg will have antialiasing and the mask not, there will be artifacts at the corners, // if they go under the svg they're less evident. - QPoint maskOffset(-m_padding->left()+1, -m_padding->top()+1); + QPoint maskOffset(-m_padding->left() + 1, -m_padding->top() + 1); mask.translate(maskOffset); } } @@ -608,9 +608,7 @@ void Decoration::updateBuffer() return; } m_contentRect = QRect(QPoint(0, 0), m_view->contentItem()->size().toSize()); - if (m_padding && - (m_padding->left() > 0 || m_padding->top() > 0 || m_padding->right() > 0 || m_padding->bottom() > 0) && - !clientPointer()->isMaximized()) { + if (m_padding && (m_padding->left() > 0 || m_padding->top() > 0 || m_padding->right() > 0 || m_padding->bottom() > 0) && !clientPointer()->isMaximized()) { m_contentRect = m_contentRect.adjusted(m_padding->left(), m_padding->top(), -m_padding->right(), -m_padding->bottom()); } updateShadow(); @@ -661,11 +659,11 @@ void ThemeProvider::findAllSvgThemes() } } for (const QString &dir : themeDirectories) { - for (const QString & file : QDir(dir).entryList(QStringList() << QStringLiteral("metadata.desktop"))) { + for (const QString &file : QDir(dir).entryList(QStringList() << QStringLiteral("metadata.desktop"))) { themes.append(dir + '/' + file); } } - for (const QString & theme : themes) { + for (const QString &theme : themes) { int themeSepIndex = theme.lastIndexOf('/', -1); QString themeRoot = theme.left(themeSepIndex); int themeNameSepIndex = themeRoot.lastIndexOf('/', -1); @@ -762,7 +760,7 @@ void ConfigurationModule::initQml() KLocalizedTranslator *translator = new KLocalizedTranslator(this); QCoreApplication::instance()->installTranslator(translator); const KDesktopFile metaData(QStandardPaths::locate(QStandardPaths::GenericDataLocation, - QStringLiteral("kwin/decorations/%1/metadata.desktop").arg(m_theme))); + QStringLiteral("kwin/decorations/%1/metadata.desktop").arg(m_theme))); const QString translationDomain = metaData.desktopGroup().readEntry("X-KWin-Config-TranslationDomain", QString()); if (!translationDomain.isEmpty()) { translator->setTranslationDomain(translationDomain); diff --git a/src/plugins/kdecorations/aurorae/src/aurorae.h b/src/plugins/kdecorations/aurorae/src/aurorae.h index 46c5a5ffd9..4980c13cbf 100644 --- a/src/plugins/kdecorations/aurorae/src/aurorae.h +++ b/src/plugins/kdecorations/aurorae/src/aurorae.h @@ -33,7 +33,7 @@ namespace Aurorae class Decoration : public KDecoration2::Decoration { Q_OBJECT - Q_PROPERTY(KDecoration2::DecoratedClient* client READ clientPointer CONSTANT) + Q_PROPERTY(KDecoration2::DecoratedClient *client READ clientPointer CONSTANT) public: explicit Decoration(QObject *parent = nullptr, const QVariantList &args = QVariantList()); ~Decoration() override; @@ -70,7 +70,7 @@ private: bool m_supportsMask{false}; - QRect m_contentRect; //the geometry of the part of the buffer that is not a shadow when buffer was created. + QRect m_contentRect; // the geometry of the part of the buffer that is not a shadow when buffer was created. QQuickItem *m_item = nullptr; QQmlContext *m_qmlContext = nullptr; KWin::Borders *m_borders; diff --git a/src/plugins/kdecorations/aurorae/src/colorhelper.cpp b/src/plugins/kdecorations/aurorae/src/colorhelper.cpp index 88e6d33a0c..e57d98c17f 100644 --- a/src/plugins/kdecorations/aurorae/src/colorhelper.cpp +++ b/src/plugins/kdecorations/aurorae/src/colorhelper.cpp @@ -49,4 +49,3 @@ QColor ColorHelper::foreground(bool active, ColorHelper::ForegroundRole role) co KColorScheme kcs(active ? QPalette::Active : QPalette::Inactive, KColorScheme::Button); return kcs.foreground(static_cast(role)).color(); } - diff --git a/src/plugins/kdecorations/aurorae/src/colorhelper.h b/src/plugins/kdecorations/aurorae/src/colorhelper.h index 1a16989e4a..f8ef3d3352 100644 --- a/src/plugins/kdecorations/aurorae/src/colorhelper.h +++ b/src/plugins/kdecorations/aurorae/src/colorhelper.h @@ -6,8 +6,8 @@ #ifndef COLOR_HELPER_H #define COLOR_HELPER_H -#include #include +#include /** * @short Helper to manipulate colors. @@ -193,8 +193,8 @@ public: * 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); + 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. @@ -211,7 +211,7 @@ public: * * @see KColorUtils::shade */ - Q_INVOKABLE QColor multiplyAlpha(const QColor& color, qreal alpha); + 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. diff --git a/src/plugins/kdecorations/aurorae/src/decorationoptions.cpp b/src/plugins/kdecorations/aurorae/src/decorationoptions.cpp index ba4fde8c80..cc4a0f2084 100644 --- a/src/plugins/kdecorations/aurorae/src/decorationoptions.cpp +++ b/src/plugins/kdecorations/aurorae/src/decorationoptions.cpp @@ -4,9 +4,9 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "decorationoptions.h" +#include #include #include -#include #include #include #include @@ -28,21 +28,20 @@ void ColorSettings::init(const QPalette &pal) { m_palette = pal; KConfigGroup wmConfig(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), QStringLiteral("WM")); - m_activeFrameColor = wmConfig.readEntry("frame", pal.color(QPalette::Active, QPalette::Window)); - m_inactiveFrameColor = wmConfig.readEntry("inactiveFrame", m_activeFrameColor); - m_activeTitleBarColor = wmConfig.readEntry("activeBackground", pal.color(QPalette::Active, QPalette::Highlight)); + m_activeFrameColor = wmConfig.readEntry("frame", pal.color(QPalette::Active, QPalette::Window)); + m_inactiveFrameColor = wmConfig.readEntry("inactiveFrame", m_activeFrameColor); + m_activeTitleBarColor = wmConfig.readEntry("activeBackground", pal.color(QPalette::Active, QPalette::Highlight)); m_inactiveTitleBarColor = wmConfig.readEntry("inactiveBackground", m_inactiveFrameColor); m_activeTitleBarBlendColor = wmConfig.readEntry("activeBlend", m_activeTitleBarColor.darker(110)); m_inactiveTitleBarBlendColor = wmConfig.readEntry("inactiveBlend", m_inactiveTitleBarColor.darker(110)); - m_activeFontColor = wmConfig.readEntry("activeForeground", pal.color(QPalette::Active, QPalette::HighlightedText)); - m_inactiveFontColor = wmConfig.readEntry("inactiveForeground", m_activeFontColor.darker()); + m_activeFontColor = wmConfig.readEntry("activeForeground", pal.color(QPalette::Active, QPalette::HighlightedText)); + m_inactiveFontColor = wmConfig.readEntry("inactiveForeground", m_activeFontColor.darker()); m_activeButtonColor = wmConfig.readEntry("activeTitleBtnBg", m_activeFrameColor.lighter(130)); m_inactiveButtonColor = wmConfig.readEntry("inactiveTitleBtnBg", m_inactiveFrameColor.lighter(130)); m_activeHandle = wmConfig.readEntry("handle", m_activeFrameColor); m_inactiveHandle = wmConfig.readEntry("inactiveHandle", m_activeHandle); } - DecorationOptions::DecorationOptions(QObject *parent) : QObject(parent) , m_active(true) @@ -165,12 +164,10 @@ void DecorationOptions::setDecoration(KDecoration2::Decoration *decoration) } m_decoration = decoration; connect(m_decoration->client().toStrongRef().data(), &KDecoration2::DecoratedClient::activeChanged, this, &DecorationOptions::slotActiveChanged); - m_paletteConnection = connect(m_decoration->client().toStrongRef().data(), &KDecoration2::DecoratedClient::paletteChanged, this, - [this] (const QPalette &pal) { - m_colors.update(pal); - Q_EMIT colorsChanged(); - } - ); + m_paletteConnection = connect(m_decoration->client().toStrongRef().data(), &KDecoration2::DecoratedClient::paletteChanged, this, [this](const QPalette &pal) { + m_colors.update(pal); + Q_EMIT colorsChanged(); + }); auto s = m_decoration->settings(); connect(s.data(), &KDecoration2::DecorationSettings::fontChanged, this, &DecorationOptions::fontChanged); connect(s.data(), &KDecoration2::DecorationSettings::decorationButtonsLeftChanged, this, &DecorationOptions::titleButtonsChanged); @@ -209,15 +206,15 @@ Borders::~Borders() { } -#define SETTER( methodName, name ) \ -void Borders::methodName(int name) \ -{ \ - if (m_##name == name) { \ - return; \ - } \ - m_##name = name; \ - Q_EMIT name##Changed(); \ -} +#define SETTER(methodName, name) \ + void Borders::methodName(int name) \ + { \ + if (m_##name == name) { \ + return; \ + } \ + m_##name = name; \ + Q_EMIT name##Changed(); \ + } SETTER(setLeft, left) SETTER(setRight, right) @@ -255,4 +252,3 @@ Borders::operator QMargins() const } } // namespace - diff --git a/src/plugins/kdecorations/aurorae/src/decorationoptions.h b/src/plugins/kdecorations/aurorae/src/decorationoptions.h index de6dd713d3..d312a7a100 100644 --- a/src/plugins/kdecorations/aurorae/src/decorationoptions.h +++ b/src/plugins/kdecorations/aurorae/src/decorationoptions.h @@ -8,9 +8,9 @@ #include -#include #include #include +#include #include namespace KWin @@ -24,54 +24,71 @@ public: void update(const QPalette &pal); - const QColor &titleBarColor(bool active) const { + const QColor &titleBarColor(bool active) const + { return active ? m_activeTitleBarColor : m_inactiveTitleBarColor; } - const QColor &activeTitleBarColor() const { + const QColor &activeTitleBarColor() const + { return m_activeTitleBarColor; } - const QColor &inactiveTitleBarColor() const { + const QColor &inactiveTitleBarColor() const + { return m_inactiveTitleBarColor; } - const QColor &activeTitleBarBlendColor() const { + const QColor &activeTitleBarBlendColor() const + { return m_activeTitleBarBlendColor; } - const QColor &inactiveTitleBarBlendColor() const { + const QColor &inactiveTitleBarBlendColor() const + { return m_inactiveTitleBarBlendColor; } - const QColor &frame(bool active) const { + const QColor &frame(bool active) const + { return active ? m_activeFrameColor : m_inactiveFrameColor; } - const QColor &activeFrame() const { + const QColor &activeFrame() const + { return m_activeFrameColor; } - const QColor &inactiveFrame() const { + const QColor &inactiveFrame() const + { return m_inactiveFrameColor; } - const QColor &font(bool active) const { + const QColor &font(bool active) const + { return active ? m_activeFontColor : m_inactiveFontColor; } - const QColor &activeFont() const { + const QColor &activeFont() const + { return m_activeFontColor; } - const QColor &inactiveFont() const { + const QColor &inactiveFont() const + { return m_inactiveFontColor; } - const QColor &activeButtonColor() const { + const QColor &activeButtonColor() const + { return m_activeButtonColor; } - const QColor &inactiveButtonColor() const { + const QColor &inactiveButtonColor() const + { return m_inactiveButtonColor; } - const QColor &activeHandle() const { + const QColor &activeHandle() const + { return m_activeHandle; } - const QColor &inactiveHandle() const { + const QColor &inactiveHandle() const + { return m_inactiveHandle; } - const QPalette &palette() const { + const QPalette &palette() const + { return m_palette; } + private: void init(const QPalette &pal); QColor m_activeTitleBarColor; @@ -163,15 +180,15 @@ class DecorationOptions : public QObject 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 + 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 + BorderHuge, ///< Huge borders + BorderVeryHuge, ///< Very huge borders + BorderOversized ///< Oversized borders }; Q_ENUM(BorderSize) /** @@ -290,11 +307,11 @@ private: int m_bottom; }; -#define GETTER( name ) \ -inline int Borders::name() const \ -{ \ - return m_##name;\ -}\ +#define GETTER(name) \ + inline int Borders::name() const \ + { \ + return m_##name; \ + } GETTER(left) GETTER(right) diff --git a/src/plugins/kdecorations/aurorae/src/decorationplugin.cpp b/src/plugins/kdecorations/aurorae/src/decorationplugin.cpp index a5110e434d..75f14c4235 100644 --- a/src/plugins/kdecorations/aurorae/src/decorationplugin.cpp +++ b/src/plugins/kdecorations/aurorae/src/decorationplugin.cpp @@ -15,4 +15,3 @@ void DecorationPlugin::registerTypes(const char *uri) qmlRegisterType(uri, 0, 1, "DecorationOptions"); qmlRegisterType(uri, 0, 1, "Borders"); } - diff --git a/src/plugins/kdecorations/aurorae/src/lib/auroraetheme.cpp b/src/plugins/kdecorations/aurorae/src/lib/auroraetheme.cpp index fbe82affb5..756cce645d 100644 --- a/src/plugins/kdecorations/aurorae/src/lib/auroraetheme.cpp +++ b/src/plugins/kdecorations/aurorae/src/lib/auroraetheme.cpp @@ -18,11 +18,12 @@ Q_LOGGING_CATEGORY(AURORAE, "aurorae", QtWarningMsg) -namespace Aurorae { +namespace Aurorae +{ /************************************************ -* AuroraeThemePrivate -************************************************/ + * AuroraeThemePrivate + ************************************************/ class AuroraeThemePrivate { public: @@ -31,7 +32,7 @@ public: void initButtonFrame(AuroraeButtonType type); QString themeName; Aurorae::ThemeConfig themeConfig; - QHash< AuroraeButtonType, QString > pathes; + QHash pathes; bool activeCompositing; KDecoration2::BorderSize borderSize; KDecoration2::BorderSize buttonSize; @@ -40,7 +41,7 @@ public: }; AuroraeThemePrivate::AuroraeThemePrivate() - :activeCompositing(true) + : activeCompositing(true) , borderSize(KDecoration2::BorderSize::Normal) , buttonSize(KDecoration2::BorderSize::Normal) { @@ -60,16 +61,16 @@ void AuroraeThemePrivate::initButtonFrame(AuroraeButtonType type) path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, file); } if (!path.isEmpty()) { - pathes[ type ] = path; + pathes[type] = path; } else { qCDebug(AURORAE) << "No button for: " << AuroraeTheme::mapButtonToName(type); } } /************************************************ -* AuroraeTheme -************************************************/ -AuroraeTheme::AuroraeTheme(QObject* parent) + * AuroraeTheme + ************************************************/ +AuroraeTheme::AuroraeTheme(QObject *parent) : QObject(parent) , d(new AuroraeThemePrivate) { @@ -134,7 +135,7 @@ bool AuroraeTheme::hasButton(AuroraeButtonType button) const QLatin1String AuroraeTheme::mapButtonToName(AuroraeButtonType type) { - switch(type) { + switch (type) { case MinimizeButton: return QLatin1String("minimize"); case MaximizeButton: @@ -167,11 +168,10 @@ const QString &AuroraeTheme::themeName() const return d->themeName; } -void AuroraeTheme::borders(int& left, int& top, int& right, int& bottom, bool maximized) const +void AuroraeTheme::borders(int &left, int &top, int &right, int &bottom, bool maximized) const { const qreal titleHeight = qMax((qreal)d->themeConfig.titleHeight(), - d->themeConfig.buttonHeight()*buttonSizeFactor() + - d->themeConfig.buttonMarginTop()); + d->themeConfig.buttonHeight() * buttonSizeFactor() + d->themeConfig.buttonMarginTop()); if (maximized) { const qreal title = titleHeight + d->themeConfig.titleEdgeTopMaximized() + d->themeConfig.titleEdgeBottomMaximized(); switch ((DecorationPosition)d->themeConfig.decorationPosition()) { @@ -249,16 +249,16 @@ void AuroraeTheme::borders(int& left, int& top, int& right, int& bottom, bool ma const qreal title = titleHeight + d->themeConfig.titleEdgeTop() + d->themeConfig.titleEdgeBottom(); switch ((DecorationPosition)d->themeConfig.decorationPosition()) { case DecorationTop: - top = title; + top = title; break; case DecorationBottom: - bottom = title; + bottom = title; break; case DecorationLeft: - left = title; + left = title; break; case DecorationRight: - right = title; + right = title; break; default: left = right = bottom = top = 0; @@ -331,19 +331,19 @@ int AuroraeTheme::topBorderMaximized() const return top; } -void AuroraeTheme::padding(int& left, int& top, int& right, int& bottom) const +void AuroraeTheme::padding(int &left, int &top, int &right, int &bottom) const { - left = d->themeConfig.paddingLeft(); - top = d->themeConfig.paddingTop(); - right = d->themeConfig.paddingRight(); + left = d->themeConfig.paddingLeft(); + top = d->themeConfig.paddingTop(); + right = d->themeConfig.paddingRight(); bottom = d->themeConfig.paddingBottom(); } -#define THEME_CONFIG( prototype ) \ -int AuroraeTheme::prototype ( ) const \ -{ \ - return d->themeConfig.prototype( ); \ -} +#define THEME_CONFIG(prototype) \ + int AuroraeTheme::prototype() const \ + { \ + return d->themeConfig.prototype(); \ + } THEME_CONFIG(paddingBottom) THEME_CONFIG(paddingLeft) @@ -377,11 +377,11 @@ THEME_CONFIG(titleHeight) #undef THEME_CONFIG -#define THEME_CONFIG_TYPE( rettype, prototype ) \ -rettype AuroraeTheme::prototype ( ) const \ -{\ - return d->themeConfig.prototype(); \ -} +#define THEME_CONFIG_TYPE(rettype, prototype) \ + rettype AuroraeTheme::prototype() const \ + { \ + return d->themeConfig.prototype(); \ + } THEME_CONFIG_TYPE(QColor, activeTextColor) THEME_CONFIG_TYPE(QColor, inactiveTextColor) @@ -395,15 +395,15 @@ QString AuroraeTheme::decorationPath() const return d->decorationPath; } -#define BUTTON_PATH( prototype, buttonType ) \ -QString AuroraeTheme::prototype ( ) const \ -{ \ - if (hasButton( buttonType )) { \ - return d->pathes[ buttonType ]; \ - } else { \ - return QString(); \ - } \ -}\ +#define BUTTON_PATH(prototype, buttonType) \ + QString AuroraeTheme::prototype() const \ + { \ + if (hasButton(buttonType)) { \ + return d->pathes[buttonType]; \ + } else { \ + return QString(); \ + } \ + } BUTTON_PATH(minimizeButtonPath, MinimizeButton) BUTTON_PATH(maximizeButtonPath, MaximizeButton) @@ -420,14 +420,14 @@ BUTTON_PATH(helpButtonPath, HelpButton) void AuroraeTheme::titleEdges(int &left, int &top, int &right, int &bottom, bool maximized) const { if (maximized) { - left = d->themeConfig.titleEdgeLeftMaximized(); - top = d->themeConfig.titleEdgeTopMaximized(); - right = d->themeConfig.titleEdgeRightMaximized(); + left = d->themeConfig.titleEdgeLeftMaximized(); + top = d->themeConfig.titleEdgeTopMaximized(); + right = d->themeConfig.titleEdgeRightMaximized(); bottom = d->themeConfig.titleEdgeBottomMaximized(); } else { - left = d->themeConfig.titleEdgeLeft(); - top = d->themeConfig.titleEdgeTop(); - right = d->themeConfig.titleEdgeRight(); + left = d->themeConfig.titleEdgeLeft(); + top = d->themeConfig.titleEdgeTop(); + right = d->themeConfig.titleEdgeRight(); bottom = d->themeConfig.titleEdgeBottom(); } } diff --git a/src/plugins/kdecorations/aurorae/src/lib/auroraetheme.h b/src/plugins/kdecorations/aurorae/src/lib/auroraetheme.h index 74500c589c..5043997c2b 100644 --- a/src/plugins/kdecorations/aurorae/src/lib/auroraetheme.h +++ b/src/plugins/kdecorations/aurorae/src/lib/auroraetheme.h @@ -21,7 +21,8 @@ Q_DECLARE_LOGGING_CATEGORY(AURORAE) class KConfig; -namespace Aurorae { +namespace Aurorae +{ class AuroraeThemePrivate; class ThemeConfig; @@ -103,7 +104,7 @@ class /*LIBAURORAE_EXPORT*/ AuroraeTheme : public QObject Q_PROPERTY(Qt::Alignment horizontalAlignment READ alignment NOTIFY themeChanged) Q_PROPERTY(Qt::Alignment verticalAlignment READ verticalAlignment NOTIFY themeChanged) public: - explicit AuroraeTheme(QObject* parent = nullptr); + explicit AuroraeTheme(QObject *parent = nullptr); ~AuroraeTheme() override; // TODO: KSharedConfigPtr void loadTheme(const QString &name, const KConfig &config); @@ -209,7 +210,7 @@ private: */ void padding(int &left, int &top, int &right, int &bottom) const; - AuroraeThemePrivate* const d; + AuroraeThemePrivate *const d; }; } // namespace diff --git a/src/plugins/kdecorations/aurorae/src/lib/themeconfig.cpp b/src/plugins/kdecorations/aurorae/src/lib/themeconfig.cpp index c95fd02a0e..565ae4ae33 100644 --- a/src/plugins/kdecorations/aurorae/src/lib/themeconfig.cpp +++ b/src/plugins/kdecorations/aurorae/src/lib/themeconfig.cpp @@ -93,21 +93,17 @@ void ThemeConfig::load(const KConfig &conf) QString alignment = (general.readEntry("TitleAlignment", "Left")).toLower(); if (alignment == QStringLiteral("left")) { m_alignment = Qt::AlignLeft; - } - else if (alignment == QStringLiteral("center")) { + } else if (alignment == QStringLiteral("center")) { m_alignment = Qt::AlignHCenter; - } - else { + } else { m_alignment = Qt::AlignRight; } alignment = (general.readEntry("TitleVerticalAlignment", "Center")).toLower(); if (alignment == QStringLiteral("top")) { m_verticalAlignment = Qt::AlignTop; - } - else if (alignment == QStringLiteral("center")) { + } else if (alignment == QStringLiteral("center")) { m_verticalAlignment = Qt::AlignVCenter; - } - else { + } else { m_verticalAlignment = Qt::AlignBottom; } m_animationTime = general.readEntry("Animation", defaultAnimationTime()); @@ -187,4 +183,4 @@ QColor ThemeConfig::inactiveTextColor(bool useTabs, bool focused) const } } -} //namespace +} // namespace diff --git a/src/plugins/kdecorations/aurorae/src/lib/themeconfig.h b/src/plugins/kdecorations/aurorae/src/lib/themeconfig.h index c68edc3dbf..4a742d71a3 100644 --- a/src/plugins/kdecorations/aurorae/src/lib/themeconfig.h +++ b/src/plugins/kdecorations/aurorae/src/lib/themeconfig.h @@ -8,8 +8,8 @@ // This class encapsulates all theme config values // it's a separate class as it's needed by both deco and config dialog -#include #include +#include class KConfig; @@ -20,315 +20,413 @@ class ThemeConfig public: ThemeConfig(); void load(const KConfig &conf); - ~ThemeConfig() {}; + ~ThemeConfig(){}; // active window QColor activeTextColor(bool useTabs = false, bool focused = true) const; // inactive window QColor inactiveTextColor(bool useTabs = false, bool focused = true) const; - QColor activeTextShadowColor() const { + QColor activeTextShadowColor() const + { return m_activeTextShadowColor; } - QColor inactiveTextShadowColor() const { + QColor inactiveTextShadowColor() const + { return m_inactiveTextShadowColor; } - int textShadowOffsetX() const { + int textShadowOffsetX() const + { return m_textShadowOffsetX; } - int textShadowOffsetY() const { + int textShadowOffsetY() const + { return m_textShadowOffsetY; } - bool useTextShadow() const { + bool useTextShadow() const + { return m_useTextShadow; } - bool haloActive() const { + bool haloActive() const + { return m_haloActive; } - bool haloInactive() const { + bool haloInactive() const + { return m_haloInactive; } // Alignment - Qt::Alignment alignment() const { + Qt::Alignment alignment() const + { return m_alignment; }; - Qt::Alignment verticalAlignment() const { + Qt::Alignment verticalAlignment() const + { return m_verticalAlignment; } - int animationTime() const { + int animationTime() const + { return m_animationTime; } // Borders - int borderLeft() const { + int borderLeft() const + { return m_borderLeft; } - int borderRight() const { + int borderRight() const + { return m_borderRight; } - int borderBottom() const { + int borderBottom() const + { return m_borderBottom; } - int borderTop() const { + int borderTop() const + { return m_borderTop; } - int titleEdgeTop() const { + int titleEdgeTop() const + { return m_titleEdgeTop; } - int titleEdgeBottom() const { + int titleEdgeBottom() const + { return m_titleEdgeBottom; } - int titleEdgeLeft() const { + int titleEdgeLeft() const + { return m_titleEdgeLeft; } - int titleEdgeRight() const { + int titleEdgeRight() const + { return m_titleEdgeRight; } - int titleEdgeTopMaximized() const { + int titleEdgeTopMaximized() const + { return m_titleEdgeTopMaximized; } - int titleEdgeBottomMaximized() const { + int titleEdgeBottomMaximized() const + { return m_titleEdgeBottomMaximized; } - int titleEdgeLeftMaximized() const { + int titleEdgeLeftMaximized() const + { return m_titleEdgeLeftMaximized; } - int titleEdgeRightMaximized() const { + int titleEdgeRightMaximized() const + { return m_titleEdgeRightMaximized; } - int titleBorderLeft() const { + int titleBorderLeft() const + { return m_titleBorderLeft; } - int titleBorderRight() const { + int titleBorderRight() const + { return m_titleBorderRight; } - int titleHeight() const { + int titleHeight() const + { return m_titleHeight; } - int buttonWidth() const { + int buttonWidth() const + { return m_buttonWidth; } - int buttonWidthMinimize() const { + int buttonWidthMinimize() const + { return m_buttonWidthMinimize; } - int buttonWidthMaximizeRestore() const { + int buttonWidthMaximizeRestore() const + { return m_buttonWidthMaximizeRestore; } - int buttonWidthClose() const { + int buttonWidthClose() const + { return m_buttonWidthClose; } - int buttonWidthAllDesktops() const { + int buttonWidthAllDesktops() const + { return m_buttonWidthAllDesktops; } - int buttonWidthKeepAbove() const { + int buttonWidthKeepAbove() const + { return m_buttonWidthKeepAbove; } - int buttonWidthKeepBelow() const { + int buttonWidthKeepBelow() const + { return m_buttonWidthKeepBelow; } - int buttonWidthShade() const { + int buttonWidthShade() const + { return m_buttonWidthShade; } - int buttonWidthHelp() const { + int buttonWidthHelp() const + { return m_buttonWidthHelp; } - int buttonWidthMenu() const { + int buttonWidthMenu() const + { return m_buttonWidthMenu; } - int buttonWidthAppMenu() const { + int buttonWidthAppMenu() const + { return m_buttonWidthAppMenu; } - int buttonHeight() const { + int buttonHeight() const + { return m_buttonHeight; } - int buttonSpacing() const { + int buttonSpacing() const + { return m_buttonSpacing; } - int buttonMarginTop() const { + int buttonMarginTop() const + { return m_buttonMarginTop; } - int explicitButtonSpacer() const { + int explicitButtonSpacer() const + { return m_explicitButtonSpacer; } - int paddingLeft() const { + int paddingLeft() const + { return m_paddingLeft; } - int paddingRight() const { + int paddingRight() const + { return m_paddingRight; } - int paddingTop() const { + int paddingTop() const + { return m_paddingTop; } - int paddingBottom() const { + int paddingBottom() const + { return m_paddingBottom; } - bool shadow() const { + bool shadow() const + { return m_shadow; } - int decorationPosition() const { + int decorationPosition() const + { return m_decorationPosition; } - static QColor defaultActiveTextColor() { + static QColor defaultActiveTextColor() + { return QColor(Qt::black); } - static QColor defaultActiveFocusedTextColor() { + static QColor defaultActiveFocusedTextColor() + { return QColor(Qt::black); } - static QColor defaultActiveUnfocusedTextColor() { + static QColor defaultActiveUnfocusedTextColor() + { return QColor(Qt::black); } - static QColor defaultInactiveTextColor() { + static QColor defaultInactiveTextColor() + { return QColor(Qt::black); } - static QColor defaultInactiveFocusedTextColor() { + static QColor defaultInactiveFocusedTextColor() + { return QColor(Qt::black); } - static QColor defaultInactiveUnfocusedTextColor() { + static QColor defaultInactiveUnfocusedTextColor() + { return QColor(Qt::black); } - static QColor defaultActiveTextShadowColor() { + static QColor defaultActiveTextShadowColor() + { return QColor(Qt::white); } - static QColor defaultInactiveTextShadowColor() { + static QColor defaultInactiveTextShadowColor() + { return QColor(Qt::white); } - static int defaultTextShadowOffsetX() { + static int defaultTextShadowOffsetX() + { return 0; } - static int defaultTextShadowOffsetY() { + static int defaultTextShadowOffsetY() + { return 0; } - static bool defaultUseTextShadow() { + static bool defaultUseTextShadow() + { return false; } - static bool defaultHaloActive() { + static bool defaultHaloActive() + { return false; } - static bool defaultHaloInactive() { + static bool defaultHaloInactive() + { return false; } - static Qt::Alignment defaultAlignment() { + static Qt::Alignment defaultAlignment() + { return Qt::AlignLeft; } - static Qt::Alignment defaultVerticalAlignment() { + static Qt::Alignment defaultVerticalAlignment() + { return Qt::AlignVCenter; } // borders - static int defaultBorderLeft() { + static int defaultBorderLeft() + { return 5; } - static int defaultBorderRight() { + static int defaultBorderRight() + { return 5; } - static int defaultBorderBottom() { + static int defaultBorderBottom() + { return 5; } - static int defaultBorderTop() { + static int defaultBorderTop() + { return 0; } // title - static int defaultTitleEdgeTop() { + static int defaultTitleEdgeTop() + { return 5; } - static int defaultTitleEdgeBottom() { + static int defaultTitleEdgeBottom() + { return 5; } - static int defaultTitleEdgeLeft() { + static int defaultTitleEdgeLeft() + { return 5; } - static int defaultTitleEdgeRight() { + static int defaultTitleEdgeRight() + { return 5; } - static int defaultTitleEdgeTopMaximized() { + static int defaultTitleEdgeTopMaximized() + { return 0; } - static int defaultTitleEdgeBottomMaximized() { + static int defaultTitleEdgeBottomMaximized() + { return 0; } - static int defaultTitleEdgeLeftMaximized() { + static int defaultTitleEdgeLeftMaximized() + { return 0; } - static int defaultTitleEdgeRightMaximized() { + static int defaultTitleEdgeRightMaximized() + { return 0; } - static int defaultTitleBorderLeft() { + static int defaultTitleBorderLeft() + { return 5; } - static int defaultTitleBorderRight() { + static int defaultTitleBorderRight() + { return 5; } - static int defaultTitleHeight() { + static int defaultTitleHeight() + { return 20; } // buttons - static int defaultButtonWidth() { + static int defaultButtonWidth() + { return 20; } - static int defaultButtonWidthMinimize() { + static int defaultButtonWidthMinimize() + { return defaultButtonWidth(); } - static int defaultButtonWidthMaximizeRestore() { + static int defaultButtonWidthMaximizeRestore() + { return defaultButtonWidth(); } - static int defaultButtonWidthClose() { + static int defaultButtonWidthClose() + { return defaultButtonWidth(); } - static int defaultButtonWidthAllDesktops() { + static int defaultButtonWidthAllDesktops() + { return defaultButtonWidth(); } - static int defaultButtonWidthKeepAbove() { + static int defaultButtonWidthKeepAbove() + { return defaultButtonWidth(); } - static int defaultButtonWidthKeepBelow() { + static int defaultButtonWidthKeepBelow() + { return defaultButtonWidth(); } - static int defaultButtonWidthShade() { + static int defaultButtonWidthShade() + { return defaultButtonWidth(); } - static int defaultButtonWidthHelp() { + static int defaultButtonWidthHelp() + { return defaultButtonWidth(); } - static int defaultButtonWidthMenu() { + static int defaultButtonWidthMenu() + { return defaultButtonWidth(); } - static int defaultButtonWidthAppMenu() { + static int defaultButtonWidthAppMenu() + { return defaultButtonWidthMenu(); } - static int defaultButtonHeight() { + static int defaultButtonHeight() + { return 20; } - static int defaultButtonSpacing() { + static int defaultButtonSpacing() + { return 5; } - static int defaultButtonMarginTop() { + static int defaultButtonMarginTop() + { return 0; } - static int defaultExplicitButtonSpacer() { + static int defaultExplicitButtonSpacer() + { return 10; } // padding - static int defaultPaddingLeft() { + static int defaultPaddingLeft() + { return 0; } - static int defaultPaddingRight() { + static int defaultPaddingRight() + { return 0; } - static int defaultPaddingTop() { + static int defaultPaddingTop() + { return 0; } - static int defaultPaddingBottom() { + static int defaultPaddingBottom() + { return 0; } - static int defaultAnimationTime() { + static int defaultAnimationTime() + { return 0; } - static bool defaultShadow() { + static bool defaultShadow() + { return true; } - static int defaultDecorationPosition() { + static int defaultDecorationPosition() + { return 0; } diff --git a/src/plugins/kdecorations/aurorae/themes/plastik/code/plastikbutton.cpp b/src/plugins/kdecorations/aurorae/themes/plastik/code/plastikbutton.cpp index 56c21bd2df..121bc08d4d 100644 --- a/src/plugins/kdecorations/aurorae/themes/plastik/code/plastikbutton.cpp +++ b/src/plugins/kdecorations/aurorae/themes/plastik/code/plastikbutton.cpp @@ -103,7 +103,7 @@ QPixmap PlastikButtonProvider::requestPixmap(const QString &id, QSize *size, con QPixmap PlastikButtonProvider::icon(ButtonIcon icon, int size, bool active, bool shadow) { Q_UNUSED(active); - if (size%2 == 0) + if (size % 2 == 0) --size; QPixmap image(size, size); @@ -134,249 +134,234 @@ QPixmap PlastikButtonProvider::icon(ButtonIcon icon, int size, bool active, bool lwArrow = 2; } - switch(icon) { - case CloseIcon: - { - int lineWidth = 1; - if (r.width() > 16) { - lineWidth = 3; - } else if (r.width() > 4) { - lineWidth = 2; - } - - drawObject(p, DiagonalLine, r.x(), r.y(), r.width(), lineWidth); - drawObject(p, CrossDiagonalLine, r.x(), r.bottom(), r.width(), lineWidth); - - break; + switch (icon) { + case CloseIcon: { + int lineWidth = 1; + if (r.width() > 16) { + lineWidth = 3; + } else if (r.width() > 4) { + lineWidth = 2; } - case MaxIcon: - { - int lineWidth2 = 1; // frame - if (r.width() > 16) { - lineWidth2 = 2; - } else if (r.width() > 4) { - lineWidth2 = 1; - } + drawObject(p, DiagonalLine, r.x(), r.y(), r.width(), lineWidth); + drawObject(p, CrossDiagonalLine, r.x(), r.bottom(), r.width(), lineWidth); - drawObject(p, HorizontalLine, r.x(), r.top(), r.width(), lwTitleBar); - drawObject(p, HorizontalLine, r.x(), r.bottom()-(lineWidth2-1), r.width(), lineWidth2); - drawObject(p, VerticalLine, r.x(), r.top(), r.height(), lineWidth2); - drawObject(p, VerticalLine, r.right()-(lineWidth2-1), r.top(), r.height(), lineWidth2); + break; + } - break; + case MaxIcon: { + int lineWidth2 = 1; // frame + if (r.width() > 16) { + lineWidth2 = 2; + } else if (r.width() > 4) { + lineWidth2 = 1; } - case MaxRestoreIcon: - { - int lineWidth2 = 1; // frame - if (r.width() > 16) { - lineWidth2 = 2; - } else if (r.width() > 4) { - lineWidth2 = 1; - } + drawObject(p, HorizontalLine, r.x(), r.top(), r.width(), lwTitleBar); + drawObject(p, HorizontalLine, r.x(), r.bottom() - (lineWidth2 - 1), r.width(), lineWidth2); + drawObject(p, VerticalLine, r.x(), r.top(), r.height(), lineWidth2); + drawObject(p, VerticalLine, r.right() - (lineWidth2 - 1), r.top(), r.height(), lineWidth2); - int margin1, margin2; - margin1 = margin2 = lineWidth2*2; - if (r.width() < 8) - margin1 = 1; + break; + } - // background window - drawObject(p, HorizontalLine, r.x()+margin1, r.top(), r.width()-margin1, lineWidth2); - drawObject(p, HorizontalLine, r.right()-margin2, r.bottom()-(lineWidth2-1)-margin1, margin2, lineWidth2); - drawObject(p, VerticalLine, r.x()+margin1, r.top(), margin2, lineWidth2); - drawObject(p, VerticalLine, r.right()-(lineWidth2-1), r.top(), r.height()-margin1, lineWidth2); - - // foreground window - drawObject(p, HorizontalLine, r.x(), r.top()+margin2, r.width()-margin2, lwTitleBar); - drawObject(p, HorizontalLine, r.x(), r.bottom()-(lineWidth2-1), r.width()-margin2, lineWidth2); - drawObject(p, VerticalLine, r.x(), r.top()+margin2, r.height(), lineWidth2); - drawObject(p, VerticalLine, r.right()-(lineWidth2-1)-margin2, r.top()+margin2, r.height(), lineWidth2); - - break; + case MaxRestoreIcon: { + int lineWidth2 = 1; // frame + if (r.width() > 16) { + lineWidth2 = 2; + } else if (r.width() > 4) { + lineWidth2 = 1; } - case MinIcon: - { - drawObject(p, HorizontalLine, r.x(), r.bottom()-(lwTitleBar-1), r.width(), lwTitleBar); + int margin1, margin2; + margin1 = margin2 = lineWidth2 * 2; + if (r.width() < 8) + margin1 = 1; - break; - } + // background window + drawObject(p, HorizontalLine, r.x() + margin1, r.top(), r.width() - margin1, lineWidth2); + drawObject(p, HorizontalLine, r.right() - margin2, r.bottom() - (lineWidth2 - 1) - margin1, margin2, lineWidth2); + drawObject(p, VerticalLine, r.x() + margin1, r.top(), margin2, lineWidth2); + drawObject(p, VerticalLine, r.right() - (lineWidth2 - 1), r.top(), r.height() - margin1, lineWidth2); - case HelpIcon: - { - int center = r.x()+r.width()/2 -1; - int side = r.width()/4; + // foreground window + drawObject(p, HorizontalLine, r.x(), r.top() + margin2, r.width() - margin2, lwTitleBar); + drawObject(p, HorizontalLine, r.x(), r.bottom() - (lineWidth2 - 1), r.width() - margin2, lineWidth2); + drawObject(p, VerticalLine, r.x(), r.top() + margin2, r.height(), lineWidth2); + drawObject(p, VerticalLine, r.right() - (lineWidth2 - 1) - margin2, r.top() + margin2, r.height(), lineWidth2); - // paint a question mark... code is quite messy, to be cleaned up later...! :o + break; + } - if (r.width() > 16) { - int lineWidth = 3; + case MinIcon: { + drawObject(p, HorizontalLine, r.x(), r.bottom() - (lwTitleBar - 1), r.width(), lwTitleBar); - // top bar - drawObject(p, HorizontalLine, center-side+3, r.y(), 2*side-3-1, lineWidth); - // top bar rounding - drawObject(p, CrossDiagonalLine, center-side-1, r.y()+5, 6, lineWidth); - drawObject(p, DiagonalLine, center+side-3, r.y(), 5, lineWidth); - // right bar - drawObject(p, VerticalLine, center+side+2-lineWidth, r.y()+3, r.height()-(2*lineWidth+side+2+1), lineWidth); - // bottom bar - drawObject(p, CrossDiagonalLine, center, r.bottom()-2*lineWidth, side+2, lineWidth); - drawObject(p, HorizontalLine, center, r.bottom()-3*lineWidth+2, lineWidth, lineWidth); - // the dot - drawObject(p, HorizontalLine, center, r.bottom()-(lineWidth-1), lineWidth, lineWidth); - } else if (r.width() > 8) { - int lineWidth = 2; + break; + } - // top bar - drawObject(p, HorizontalLine, center-(side-1), r.y(), 2*side-1, lineWidth); - // top bar rounding - if (r.width() > 9) { - drawObject(p, CrossDiagonalLine, center-side-1, r.y()+3, 3, lineWidth); - } else { - drawObject(p, CrossDiagonalLine, center-side-1, r.y()+2, 3, lineWidth); - } - drawObject(p, DiagonalLine, center+side-1, r.y(), 3, lineWidth); - // right bar - drawObject(p, VerticalLine, center+side+2-lineWidth, r.y()+2, r.height()-(2*lineWidth+side+1), lineWidth); - // bottom bar - drawObject(p, CrossDiagonalLine, center, r.bottom()-2*lineWidth+1, side+2, lineWidth); - // the dot - drawObject(p, HorizontalLine, center, r.bottom()-(lineWidth-1), lineWidth, lineWidth); + case HelpIcon: { + int center = r.x() + r.width() / 2 - 1; + int side = r.width() / 4; + + // paint a question mark... code is quite messy, to be cleaned up later...! :o + + if (r.width() > 16) { + int lineWidth = 3; + + // top bar + drawObject(p, HorizontalLine, center - side + 3, r.y(), 2 * side - 3 - 1, lineWidth); + // top bar rounding + drawObject(p, CrossDiagonalLine, center - side - 1, r.y() + 5, 6, lineWidth); + drawObject(p, DiagonalLine, center + side - 3, r.y(), 5, lineWidth); + // right bar + drawObject(p, VerticalLine, center + side + 2 - lineWidth, r.y() + 3, r.height() - (2 * lineWidth + side + 2 + 1), lineWidth); + // bottom bar + drawObject(p, CrossDiagonalLine, center, r.bottom() - 2 * lineWidth, side + 2, lineWidth); + drawObject(p, HorizontalLine, center, r.bottom() - 3 * lineWidth + 2, lineWidth, lineWidth); + // the dot + drawObject(p, HorizontalLine, center, r.bottom() - (lineWidth - 1), lineWidth, lineWidth); + } else if (r.width() > 8) { + int lineWidth = 2; + + // top bar + drawObject(p, HorizontalLine, center - (side - 1), r.y(), 2 * side - 1, lineWidth); + // top bar rounding + if (r.width() > 9) { + drawObject(p, CrossDiagonalLine, center - side - 1, r.y() + 3, 3, lineWidth); } else { - int lineWidth = 1; - - // top bar - drawObject(p, HorizontalLine, center-(side-1), r.y(), 2*side, lineWidth); - // top bar rounding - drawObject(p, CrossDiagonalLine, center-side-1, r.y()+1, 2, lineWidth); - // right bar - drawObject(p, VerticalLine, center+side+1, r.y(), r.height()-(side+2+1), lineWidth); - // bottom bar - drawObject(p, CrossDiagonalLine, center, r.bottom()-2, side+2, lineWidth); - // the dot - drawObject(p, HorizontalLine, center, r.bottom(), 1, 1); + drawObject(p, CrossDiagonalLine, center - side - 1, r.y() + 2, 3, lineWidth); } + drawObject(p, DiagonalLine, center + side - 1, r.y(), 3, lineWidth); + // right bar + drawObject(p, VerticalLine, center + side + 2 - lineWidth, r.y() + 2, r.height() - (2 * lineWidth + side + 1), lineWidth); + // bottom bar + drawObject(p, CrossDiagonalLine, center, r.bottom() - 2 * lineWidth + 1, side + 2, lineWidth); + // the dot + drawObject(p, HorizontalLine, center, r.bottom() - (lineWidth - 1), lineWidth, lineWidth); + } else { + int lineWidth = 1; - break; + // top bar + drawObject(p, HorizontalLine, center - (side - 1), r.y(), 2 * side, lineWidth); + // top bar rounding + drawObject(p, CrossDiagonalLine, center - side - 1, r.y() + 1, 2, lineWidth); + // right bar + drawObject(p, VerticalLine, center + side + 1, r.y(), r.height() - (side + 2 + 1), lineWidth); + // bottom bar + drawObject(p, CrossDiagonalLine, center, r.bottom() - 2, side + 2, lineWidth); + // the dot + drawObject(p, HorizontalLine, center, r.bottom(), 1, 1); } - case NotOnAllDesktopsIcon: - { - int lwMark = r.width()-lwTitleBar*2-2; - if (lwMark < 1) - lwMark = 3; + break; + } - drawObject(p, HorizontalLine, r.x()+(r.width()-lwMark)/2, r.y()+(r.height()-lwMark)/2, lwMark, lwMark); + case NotOnAllDesktopsIcon: { + int lwMark = r.width() - lwTitleBar * 2 - 2; + if (lwMark < 1) + lwMark = 3; - // Fall through to OnAllDesktopsIcon intended! - Q_FALLTHROUGH(); - } - case OnAllDesktopsIcon: - { - // horizontal bars - drawObject(p, HorizontalLine, r.x()+lwTitleBar, r.y(), r.width()-2*lwTitleBar, lwTitleBar); - drawObject(p, HorizontalLine, r.x()+lwTitleBar, r.bottom()-(lwTitleBar-1), r.width()-2*lwTitleBar, lwTitleBar); - // vertical bars - drawObject(p, VerticalLine, r.x(), r.y()+lwTitleBar, r.height()-2*lwTitleBar, lwTitleBar); - drawObject(p, VerticalLine, r.right()-(lwTitleBar-1), r.y()+lwTitleBar, r.height()-2*lwTitleBar, lwTitleBar); + drawObject(p, HorizontalLine, r.x() + (r.width() - lwMark) / 2, r.y() + (r.height() - lwMark) / 2, lwMark, lwMark); + // Fall through to OnAllDesktopsIcon intended! + Q_FALLTHROUGH(); + } + case OnAllDesktopsIcon: { + // horizontal bars + drawObject(p, HorizontalLine, r.x() + lwTitleBar, r.y(), r.width() - 2 * lwTitleBar, lwTitleBar); + drawObject(p, HorizontalLine, r.x() + lwTitleBar, r.bottom() - (lwTitleBar - 1), r.width() - 2 * lwTitleBar, lwTitleBar); + // vertical bars + drawObject(p, VerticalLine, r.x(), r.y() + lwTitleBar, r.height() - 2 * lwTitleBar, lwTitleBar); + drawObject(p, VerticalLine, r.right() - (lwTitleBar - 1), r.y() + lwTitleBar, r.height() - 2 * lwTitleBar, lwTitleBar); - break; + break; + } + + case NoKeepAboveIcon: { + int center = r.x() + r.width() / 2; + + // arrow + drawObject(p, CrossDiagonalLine, r.x(), center + 2 * lwArrow, center - r.x(), lwArrow); + drawObject(p, DiagonalLine, r.x() + center, r.y() + 1 + 2 * lwArrow, center - r.x(), lwArrow); + if (lwArrow > 1) + drawObject(p, HorizontalLine, center - (lwArrow - 2), r.y() + 2 * lwArrow, (lwArrow - 2) * 2, lwArrow); + + // Fall through to KeepAboveIcon intended! + Q_FALLTHROUGH(); + } + case KeepAboveIcon: { + int center = r.x() + r.width() / 2; + + // arrow + drawObject(p, CrossDiagonalLine, r.x(), center, center - r.x(), lwArrow); + drawObject(p, DiagonalLine, r.x() + center, r.y() + 1, center - r.x(), lwArrow); + if (lwArrow > 1) + drawObject(p, HorizontalLine, center - (lwArrow - 2), r.y(), (lwArrow - 2) * 2, lwArrow); + + break; + } + + case NoKeepBelowIcon: { + int center = r.x() + r.width() / 2; + + // arrow + drawObject(p, DiagonalLine, r.x(), center - 2 * lwArrow, center - r.x(), lwArrow); + drawObject(p, CrossDiagonalLine, r.x() + center, r.bottom() - 1 - 2 * lwArrow, center - r.x(), lwArrow); + if (lwArrow > 1) + drawObject(p, HorizontalLine, center - (lwArrow - 2), r.bottom() - (lwArrow - 1) - 2 * lwArrow, (lwArrow - 2) * 2, lwArrow); + + // Fall through to KeepBelowIcon intended! + Q_FALLTHROUGH(); + } + case KeepBelowIcon: { + int center = r.x() + r.width() / 2; + + // arrow + drawObject(p, DiagonalLine, r.x(), center, center - r.x(), lwArrow); + drawObject(p, CrossDiagonalLine, r.x() + center, r.bottom() - 1, center - r.x(), lwArrow); + if (lwArrow > 1) + drawObject(p, HorizontalLine, center - (lwArrow - 2), r.bottom() - (lwArrow - 1), (lwArrow - 2) * 2, lwArrow); + + break; + } + + case ShadeIcon: { + drawObject(p, HorizontalLine, r.x(), r.y(), r.width(), lwTitleBar); + + break; + } + + case UnShadeIcon: { + int lw1 = 1; + int lw2 = 1; + if (r.width() > 16) { + lw1 = 4; + lw2 = 2; + } else if (r.width() > 7) { + lw1 = 2; + lw2 = 1; } - case NoKeepAboveIcon: - { - int center = r.x()+r.width()/2; + int h = qMax((r.width() / 2), (lw1 + 2 * lw2)); - // arrow - drawObject(p, CrossDiagonalLine, r.x(), center+2*lwArrow, center-r.x(), lwArrow); - drawObject(p, DiagonalLine, r.x()+center, r.y()+1+2*lwArrow, center-r.x(), lwArrow); - if (lwArrow>1) - drawObject(p, HorizontalLine, center-(lwArrow-2), r.y()+2*lwArrow, (lwArrow-2)*2, lwArrow); + // horizontal bars + drawObject(p, HorizontalLine, r.x(), r.y(), r.width(), lw1); + drawObject(p, HorizontalLine, r.x(), r.x() + h - (lw2 - 1), r.width(), lw2); + // vertical bars + drawObject(p, VerticalLine, r.x(), r.y(), h, lw2); + drawObject(p, VerticalLine, r.right() - (lw2 - 1), r.y(), h, lw2); - // Fall through to KeepAboveIcon intended! - Q_FALLTHROUGH(); - } - case KeepAboveIcon: - { - int center = r.x()+r.width()/2; + break; + } + case AppMenuIcon: { + drawObject(p, HorizontalLine, r.x(), r.top() + (lwTitleBar - 1), r.width(), lwTitleBar); + drawObject(p, HorizontalLine, r.x(), r.center().y(), r.width(), lwTitleBar); + drawObject(p, HorizontalLine, r.x(), r.bottom() - (lwTitleBar - 1), r.width(), lwTitleBar); + break; + } - // arrow - drawObject(p, CrossDiagonalLine, r.x(), center, center-r.x(), lwArrow); - drawObject(p, DiagonalLine, r.x()+center, r.y()+1, center-r.x(), lwArrow); - if (lwArrow>1) - drawObject(p, HorizontalLine, center-(lwArrow-2), r.y(), (lwArrow-2)*2, lwArrow); - - break; - } - - case NoKeepBelowIcon: - { - int center = r.x()+r.width()/2; - - // arrow - drawObject(p, DiagonalLine, r.x(), center-2*lwArrow, center-r.x(), lwArrow); - drawObject(p, CrossDiagonalLine, r.x()+center, r.bottom()-1-2*lwArrow, center-r.x(), lwArrow); - if (lwArrow>1) - drawObject(p, HorizontalLine, center-(lwArrow-2), r.bottom()-(lwArrow-1)-2*lwArrow, (lwArrow-2)*2, lwArrow); - - // Fall through to KeepBelowIcon intended! - Q_FALLTHROUGH(); - } - case KeepBelowIcon: - { - int center = r.x()+r.width()/2; - - // arrow - drawObject(p, DiagonalLine, r.x(), center, center-r.x(), lwArrow); - drawObject(p, CrossDiagonalLine, r.x()+center, r.bottom()-1, center-r.x(), lwArrow); - if (lwArrow>1) - drawObject(p, HorizontalLine, center-(lwArrow-2), r.bottom()-(lwArrow-1), (lwArrow-2)*2, lwArrow); - - break; - } - - case ShadeIcon: - { - drawObject(p, HorizontalLine, r.x(), r.y(), r.width(), lwTitleBar); - - break; - } - - case UnShadeIcon: - { - int lw1 = 1; - int lw2 = 1; - if (r.width() > 16) { - lw1 = 4; - lw2 = 2; - } else if (r.width() > 7) { - lw1 = 2; - lw2 = 1; - } - - int h = qMax( (r.width()/2), (lw1+2*lw2) ); - - // horizontal bars - drawObject(p, HorizontalLine, r.x(), r.y(), r.width(), lw1); - drawObject(p, HorizontalLine, r.x(), r.x()+h-(lw2-1), r.width(), lw2); - // vertical bars - drawObject(p, VerticalLine, r.x(), r.y(), h, lw2); - drawObject(p, VerticalLine, r.right()-(lw2-1), r.y(), h, lw2); - - break; - } - case AppMenuIcon: - { - drawObject(p, HorizontalLine, r.x(), r.top()+(lwTitleBar-1), r.width(), lwTitleBar); - drawObject(p, HorizontalLine, r.x(), r.center().y(), r.width(), lwTitleBar); - drawObject(p, HorizontalLine, r.x(), r.bottom()-(lwTitleBar-1), r.width(), lwTitleBar); - break; - } - - default: - break; + default: + break; } p.end(); @@ -386,73 +371,73 @@ QPixmap PlastikButtonProvider::icon(ButtonIcon icon, int size, bool active, bool void PlastikButtonProvider::drawObject(QPainter &p, Object object, int x, int y, int length, int lineWidth) { - switch(object) { - case DiagonalLine: - if (lineWidth <= 1) { - for (int i = 0; i < length; ++i) { - p.drawPoint(x+i,y+i); - } - } else if (lineWidth <= 2) { - for (int i = 0; i < length; ++i) { - p.drawPoint(x+i,y+i); - } - for (int i = 0; i < (length-1); ++i) { - p.drawPoint(x+1+i,y+i); - p.drawPoint(x+i,y+1+i); - } - } else { - for (int i = 1; i < (length-1); ++i) { - p.drawPoint(x+i,y+i); - } - for (int i = 0; i < (length-1); ++i) { - p.drawPoint(x+1+i,y+i); - p.drawPoint(x+i,y+1+i); - } - for (int i = 0; i < (length-2); ++i) { - p.drawPoint(x+2+i,y+i); - p.drawPoint(x+i,y+2+i); - } + switch (object) { + case DiagonalLine: + if (lineWidth <= 1) { + for (int i = 0; i < length; ++i) { + p.drawPoint(x + i, y + i); } - break; - case CrossDiagonalLine: - if (lineWidth <= 1) { - for (int i = 0; i < length; ++i) { - p.drawPoint(x+i,y-i); - } - } else if (lineWidth <= 2) { - for (int i = 0; i < length; ++i) { - p.drawPoint(x+i,y-i); - } - for (int i = 0; i < (length-1); ++i) { - p.drawPoint(x+1+i,y-i); - p.drawPoint(x+i,y-1-i); - } - } else { - for (int i = 1; i < (length-1); ++i) { - p.drawPoint(x+i,y-i); - } - for (int i = 0; i < (length-1); ++i) { - p.drawPoint(x+1+i,y-i); - p.drawPoint(x+i,y-1-i); - } - for (int i = 0; i < (length-2); ++i) { - p.drawPoint(x+2+i,y-i); - p.drawPoint(x+i,y-2-i); - } + } else if (lineWidth <= 2) { + for (int i = 0; i < length; ++i) { + p.drawPoint(x + i, y + i); } - break; - case HorizontalLine: - for (int i = 0; i < lineWidth; ++i) { - p.drawLine(x,y+i, x+length-1, y+i); + for (int i = 0; i < (length - 1); ++i) { + p.drawPoint(x + 1 + i, y + i); + p.drawPoint(x + i, y + 1 + i); } - break; - case VerticalLine: - for (int i = 0; i < lineWidth; ++i) { - p.drawLine(x+i,y, x+i, y+length-1); + } else { + for (int i = 1; i < (length - 1); ++i) { + p.drawPoint(x + i, y + i); } - break; - default: - break; + for (int i = 0; i < (length - 1); ++i) { + p.drawPoint(x + 1 + i, y + i); + p.drawPoint(x + i, y + 1 + i); + } + for (int i = 0; i < (length - 2); ++i) { + p.drawPoint(x + 2 + i, y + i); + p.drawPoint(x + i, y + 2 + i); + } + } + break; + case CrossDiagonalLine: + if (lineWidth <= 1) { + for (int i = 0; i < length; ++i) { + p.drawPoint(x + i, y - i); + } + } else if (lineWidth <= 2) { + for (int i = 0; i < length; ++i) { + p.drawPoint(x + i, y - i); + } + for (int i = 0; i < (length - 1); ++i) { + p.drawPoint(x + 1 + i, y - i); + p.drawPoint(x + i, y - 1 - i); + } + } else { + for (int i = 1; i < (length - 1); ++i) { + p.drawPoint(x + i, y - i); + } + for (int i = 0; i < (length - 1); ++i) { + p.drawPoint(x + 1 + i, y - i); + p.drawPoint(x + i, y - 1 - i); + } + for (int i = 0; i < (length - 2); ++i) { + p.drawPoint(x + 2 + i, y - i); + p.drawPoint(x + i, y - 2 - i); + } + } + break; + case HorizontalLine: + for (int i = 0; i < lineWidth; ++i) { + p.drawLine(x, y + i, x + length - 1, y + i); + } + break; + case VerticalLine: + for (int i = 0; i < lineWidth; ++i) { + p.drawLine(x + i, y, x + i, y + length - 1); + } + break; + default: + break; } } diff --git a/src/plugins/kglobalaccel/kglobalaccel_plugin.cpp b/src/plugins/kglobalaccel/kglobalaccel_plugin.cpp index 17a5ec92f4..074801f03c 100644 --- a/src/plugins/kglobalaccel/kglobalaccel_plugin.cpp +++ b/src/plugins/kglobalaccel/kglobalaccel_plugin.cpp @@ -36,7 +36,9 @@ void KGlobalAccelImpl::setEnabled(bool enabled) qFatal("This plugin is intended to be used with KWin and this is not KWin, exiting now"); } else { if (!m_inputDestroyedConnection) { - m_inputDestroyedConnection = connect(s_input, &QObject::destroyed, this, [this] { m_shuttingDown = true; }); + m_inputDestroyedConnection = connect(s_input, &QObject::destroyed, this, [this] { + m_shuttingDown = true; + }); } } s_input->registerGlobalAccel(enabled ? this : nullptr); diff --git a/src/plugins/kpackage/aurorae/aurorae.cpp b/src/plugins/kpackage/aurorae/aurorae.cpp index cfe5812fe8..997ca364c0 100644 --- a/src/plugins/kpackage/aurorae/aurorae.cpp +++ b/src/plugins/kpackage/aurorae/aurorae.cpp @@ -14,38 +14,38 @@ void AuroraePackage::initPackage(KPackage::Package *package) package->setDefaultPackageRoot(QStringLiteral("aurorae/themes/")); package->addFileDefinition("decoration", QStringLiteral("decoration.svgz"), - i18n("Window Decoration")); + i18n("Window Decoration")); package->setRequired("decoration", true); package->addFileDefinition("close", QStringLiteral("close.svgz"), - i18n("Close Button")); + i18n("Close Button")); package->addFileDefinition("minimize", QStringLiteral("minimize.svgz"), - i18n("Minimize Button")); + i18n("Minimize Button")); package->addFileDefinition("maximize", QStringLiteral("maximize.svgz"), - i18n("Maximize Button")); + i18n("Maximize Button")); package->addFileDefinition("restore", QStringLiteral("restore.svgz"), - i18n("Restore Button")); + i18n("Restore Button")); package->addFileDefinition("alldesktops", QStringLiteral("alldesktops.svgz"), - i18n("Sticky Button")); + i18n("Sticky Button")); package->addFileDefinition("keepabove", QStringLiteral("keepabove.svgz"), - i18n("Keepabove Button")); + i18n("Keepabove Button")); package->addFileDefinition("keepbelow", QStringLiteral("keepbelow.svgz"), - i18n("Keepbelow Button")); + i18n("Keepbelow Button")); package->addFileDefinition("shade", QStringLiteral("shade.svgz"), - i18n("Shade Button")); + i18n("Shade Button")); package->addFileDefinition("help", QStringLiteral("help.svgz"), - i18n("Help Button")); + i18n("Help Button")); package->addFileDefinition("configrc", QStringLiteral("configrc"), - i18n("Configuration file")); + i18n("Configuration file")); QStringList mimetypes; mimetypes << QStringLiteral("image/svg+xml-compressed"); @@ -69,4 +69,3 @@ void AuroraePackage::pathChanged(KPackage::Package *package) K_PLUGIN_CLASS_WITH_JSON(AuroraePackage, "kwin-packagestructure-aurorae.json") #include "aurorae.moc" - diff --git a/src/plugins/kpackage/aurorae/aurorae.h b/src/plugins/kpackage/aurorae/aurorae.h index e5c1b1c418..8acbc3b7f7 100644 --- a/src/plugins/kpackage/aurorae/aurorae.h +++ b/src/plugins/kpackage/aurorae/aurorae.h @@ -12,7 +12,9 @@ class AuroraePackage : public KPackage::PackageStructure { public: - AuroraePackage(QObject*, const QVariantList &) {} + AuroraePackage(QObject *, const QVariantList &) + { + } void initPackage(KPackage::Package *package) override; void pathChanged(KPackage::Package *package) override; }; diff --git a/src/plugins/kpackage/decoration/decoration.cpp b/src/plugins/kpackage/decoration/decoration.cpp index 2862c7db89..f646e02f3e 100644 --- a/src/plugins/kpackage/decoration/decoration.cpp +++ b/src/plugins/kpackage/decoration/decoration.cpp @@ -46,4 +46,3 @@ void DecorationPackage::pathChanged(KPackage::Package *package) K_PLUGIN_CLASS_WITH_JSON(DecorationPackage, "kwin-packagestructure-decoration.json") #include "decoration.moc" - diff --git a/src/plugins/kpackage/decoration/decoration.h b/src/plugins/kpackage/decoration/decoration.h index f91e1759f0..0901d872ed 100644 --- a/src/plugins/kpackage/decoration/decoration.h +++ b/src/plugins/kpackage/decoration/decoration.h @@ -12,7 +12,9 @@ class DecorationPackage : public KPackage::PackageStructure { public: - DecorationPackage(QObject*, const QVariantList &) {} + DecorationPackage(QObject *, const QVariantList &) + { + } void initPackage(KPackage::Package *package) override; void pathChanged(KPackage::Package *package) override; }; diff --git a/src/plugins/kpackage/scripts/scripts.cpp b/src/plugins/kpackage/scripts/scripts.cpp index 7b5324dcd2..2e4a602a99 100644 --- a/src/plugins/kpackage/scripts/scripts.cpp +++ b/src/plugins/kpackage/scripts/scripts.cpp @@ -46,4 +46,3 @@ void ScriptsPackage::pathChanged(KPackage::Package *package) K_PLUGIN_CLASS_WITH_JSON(ScriptsPackage, "kwin-packagestructure-scripts.json") #include "scripts.moc" - diff --git a/src/plugins/kpackage/scripts/scripts.h b/src/plugins/kpackage/scripts/scripts.h index 661a3e8e46..2fafda0bb7 100644 --- a/src/plugins/kpackage/scripts/scripts.h +++ b/src/plugins/kpackage/scripts/scripts.h @@ -12,7 +12,9 @@ class ScriptsPackage : public KPackage::PackageStructure { public: - ScriptsPackage(QObject*, const QVariantList &) {} + ScriptsPackage(QObject *, const QVariantList &) + { + } void initPackage(KPackage::Package *package) override; void pathChanged(KPackage::Package *package) override; }; diff --git a/src/plugins/kpackage/windowswitcher/windowswitcher.cpp b/src/plugins/kpackage/windowswitcher/windowswitcher.cpp index 298beb73ec..4cf03c4942 100644 --- a/src/plugins/kpackage/windowswitcher/windowswitcher.cpp +++ b/src/plugins/kpackage/windowswitcher/windowswitcher.cpp @@ -46,4 +46,3 @@ void SwitcherPackage::pathChanged(KPackage::Package *package) K_PLUGIN_CLASS_WITH_JSON(SwitcherPackage, "kwin-packagestructure-windowswitcher.json") #include "windowswitcher.moc" - diff --git a/src/plugins/kpackage/windowswitcher/windowswitcher.h b/src/plugins/kpackage/windowswitcher/windowswitcher.h index 0f9f56814d..db033caac1 100644 --- a/src/plugins/kpackage/windowswitcher/windowswitcher.h +++ b/src/plugins/kpackage/windowswitcher/windowswitcher.h @@ -12,7 +12,9 @@ class SwitcherPackage : public KPackage::PackageStructure { public: - SwitcherPackage(QObject*, const QVariantList &) {} + SwitcherPackage(QObject *, const QVariantList &) + { + } void initPackage(KPackage::Package *package) override; void pathChanged(KPackage::Package *package) override; }; diff --git a/src/plugins/krunner-integration/dbusutils_p.h b/src/plugins/krunner-integration/dbusutils_p.h index 94845ff734..a14e59c89a 100644 --- a/src/plugins/krunner-integration/dbusutils_p.h +++ b/src/plugins/krunner-integration/dbusutils_p.h @@ -10,15 +10,15 @@ #pragma once +#include +#include #include #include -#include #include -#include struct RemoteMatch { - //sssuda{sv} + // sssuda{sv} QString id; QString text; QString iconName; @@ -40,7 +40,7 @@ typedef QList RemoteActions; struct RemoteImage { - //iiibiiay (matching notification spec image-data attribute) + // iiibiiay (matching notification spec image-data attribute) int width = 0; int height = 0; int rowStride = 0; @@ -50,7 +50,8 @@ struct RemoteImage QByteArray data; }; -inline QDBusArgument &operator<< (QDBusArgument &argument, const RemoteMatch &match) { +inline QDBusArgument &operator<<(QDBusArgument &argument, const RemoteMatch &match) +{ argument.beginStructure(); argument << match.id; argument << match.text; @@ -62,7 +63,8 @@ inline QDBusArgument &operator<< (QDBusArgument &argument, const RemoteMatch &ma return argument; } -inline const QDBusArgument &operator>>(const QDBusArgument &argument, RemoteMatch &match) { +inline const QDBusArgument &operator>>(const QDBusArgument &argument, RemoteMatch &match) +{ argument.beginStructure(); argument >> match.id; argument >> match.text; @@ -77,7 +79,7 @@ inline const QDBusArgument &operator>>(const QDBusArgument &argument, RemoteMatc return argument; } -inline QDBusArgument &operator<< (QDBusArgument &argument, const RemoteAction &action) +inline QDBusArgument &operator<<(QDBusArgument &argument, const RemoteAction &action) { argument.beginStructure(); argument << action.id; @@ -87,7 +89,8 @@ inline QDBusArgument &operator<< (QDBusArgument &argument, const RemoteAction &a return argument; } -inline const QDBusArgument &operator>>(const QDBusArgument &argument, RemoteAction &action) { +inline const QDBusArgument &operator>>(const QDBusArgument &argument, RemoteAction &action) +{ argument.beginStructure(); argument >> action.id; argument >> action.text; @@ -96,7 +99,8 @@ inline const QDBusArgument &operator>>(const QDBusArgument &argument, RemoteActi return argument; } -inline QDBusArgument &operator<< (QDBusArgument &argument, const RemoteImage &image) { +inline QDBusArgument &operator<<(QDBusArgument &argument, const RemoteImage &image) +{ argument.beginStructure(); argument << image.width; argument << image.height; @@ -109,7 +113,8 @@ inline QDBusArgument &operator<< (QDBusArgument &argument, const RemoteImage &im return argument; } -inline const QDBusArgument &operator>>(const QDBusArgument &argument, RemoteImage &image) { +inline const QDBusArgument &operator>>(const QDBusArgument &argument, RemoteImage &image) +{ argument.beginStructure(); argument >> image.width; argument >> image.height; diff --git a/src/plugins/krunner-integration/main.cpp b/src/plugins/krunner-integration/main.cpp index f8ac11fe77..b3ed27da34 100644 --- a/src/plugins/krunner-integration/main.cpp +++ b/src/plugins/krunner-integration/main.cpp @@ -4,8 +4,8 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include "windowsrunnerinterface.h" #include "main.h" +#include "windowsrunnerinterface.h" #include diff --git a/src/plugins/krunner-integration/windowsrunnerinterface.cpp b/src/plugins/krunner-integration/windowsrunnerinterface.cpp index 4c954eca01..1107967c3e 100644 --- a/src/plugins/krunner-integration/windowsrunnerinterface.cpp +++ b/src/plugins/krunner-integration/windowsrunnerinterface.cpp @@ -17,7 +17,6 @@ #include "krunner1adaptor.h" #include - namespace KWin { WindowsRunner::WindowsRunner(QObject *parent) @@ -49,7 +48,7 @@ void WindowsRunner::initialize() RemoteActions WindowsRunner::Actions() { RemoteActions actions; - return actions; + return actions; } RemoteMatches WindowsRunner::Match(const QString &searchTerm) @@ -58,55 +57,55 @@ RemoteMatches WindowsRunner::Match(const QString &searchTerm) auto term = searchTerm; WindowsRunnerAction action = ActivateAction; - if (term.endsWith(i18nc("Note this is a KRunner keyword", "activate") , Qt::CaseInsensitive)) { + if (term.endsWith(i18nc("Note this is a KRunner keyword", "activate"), Qt::CaseInsensitive)) { action = ActivateAction; term = term.left(term.lastIndexOf(i18nc("Note this is a KRunner keyword", "activate")) - 1); - } else if (term.endsWith(i18nc("Note this is a KRunner keyword", "close") , Qt::CaseInsensitive)) { + } else if (term.endsWith(i18nc("Note this is a KRunner keyword", "close"), Qt::CaseInsensitive)) { action = CloseAction; term = term.left(term.lastIndexOf(i18nc("Note this is a KRunner keyword", "close")) - 1); - } else if (term.endsWith(i18nc("Note this is a KRunner keyword", "min") , Qt::CaseInsensitive)) { + } else if (term.endsWith(i18nc("Note this is a KRunner keyword", "min"), Qt::CaseInsensitive)) { action = MinimizeAction; term = term.left(term.lastIndexOf(i18nc("Note this is a KRunner keyword", "min")) - 1); - } else if (term.endsWith(i18nc("Note this is a KRunner keyword", "minimize") , Qt::CaseInsensitive)) { + } else if (term.endsWith(i18nc("Note this is a KRunner keyword", "minimize"), Qt::CaseInsensitive)) { action = MinimizeAction; term = term.left(term.lastIndexOf(i18nc("Note this is a KRunner keyword", "minimize")) - 1); - } else if (term.endsWith(i18nc("Note this is a KRunner keyword", "max") , Qt::CaseInsensitive)) { + } else if (term.endsWith(i18nc("Note this is a KRunner keyword", "max"), Qt::CaseInsensitive)) { action = MaximizeAction; term = term.left(term.lastIndexOf(i18nc("Note this is a KRunner keyword", "max")) - 1); - } else if (term.endsWith(i18nc("Note this is a KRunner keyword", "maximize") , Qt::CaseInsensitive)) { + } else if (term.endsWith(i18nc("Note this is a KRunner keyword", "maximize"), Qt::CaseInsensitive)) { action = MaximizeAction; term = term.left(term.lastIndexOf(i18nc("Note this is a KRunner keyword", "maximize")) - 1); - } else if (term.endsWith(i18nc("Note this is a KRunner keyword", "fullscreen") , Qt::CaseInsensitive)) { + } else if (term.endsWith(i18nc("Note this is a KRunner keyword", "fullscreen"), Qt::CaseInsensitive)) { action = FullscreenAction; term = term.left(term.lastIndexOf(i18nc("Note this is a KRunner keyword", "fullscreen")) - 1); - } else if (term.endsWith(i18nc("Note this is a KRunner keyword", "shade") , Qt::CaseInsensitive)) { + } else if (term.endsWith(i18nc("Note this is a KRunner keyword", "shade"), Qt::CaseInsensitive)) { action = ShadeAction; term = term.left(term.lastIndexOf(i18nc("Note this is a KRunner keyword", "shade")) - 1); - } else if (term.endsWith(i18nc("Note this is a KRunner keyword", "keep above") , Qt::CaseInsensitive)) { + } else if (term.endsWith(i18nc("Note this is a KRunner keyword", "keep above"), Qt::CaseInsensitive)) { action = KeepAboveAction; term = term.left(term.lastIndexOf(i18nc("Note this is a KRunner keyword", "keep above")) - 1); - } else if (term.endsWith(i18nc("Note this is a KRunner keyword", "keep below") , Qt::CaseInsensitive)) { + } else if (term.endsWith(i18nc("Note this is a KRunner keyword", "keep below"), Qt::CaseInsensitive)) { action = KeepBelowAction; term = term.left(term.lastIndexOf(i18nc("Note this is a KRunner keyword", "keep below")) - 1); } // keyword match: when term starts with "window" we list all windows // the list can be restricted to windows matching a given name, class, role or desktop - if (term.startsWith(i18nc("Note this is a KRunner keyword", "window") , Qt::CaseInsensitive)) { + if (term.startsWith(i18nc("Note this is a KRunner keyword", "window"), Qt::CaseInsensitive)) { const QStringList keywords = term.split(QLatin1Char(' ')); QString windowName; QString windowAppName; VirtualDesktop *targetDesktop = nullptr; QVariant desktopId; - for (const QString& keyword : keywords) { + for (const QString &keyword : keywords) { if (keyword.endsWith(QLatin1Char('='))) { continue; } - if (keyword.startsWith(i18nc("Note this is a KRunner keyword", "name") + QStringLiteral("=") , Qt::CaseInsensitive)) { + if (keyword.startsWith(i18nc("Note this is a KRunner keyword", "name") + QStringLiteral("="), Qt::CaseInsensitive)) { windowName = keyword.split(QStringLiteral("="))[1]; - } else if (keyword.startsWith(i18nc("Note this is a KRunner keyword", "appname") + QStringLiteral("=") , Qt::CaseInsensitive)) { + } else if (keyword.startsWith(i18nc("Note this is a KRunner keyword", "appname") + QStringLiteral("="), Qt::CaseInsensitive)) { windowAppName = keyword.split(QStringLiteral("="))[1]; - } else if (keyword.startsWith(i18nc("Note this is a KRunner keyword", "desktop") + QStringLiteral("=") , Qt::CaseInsensitive)) { + } else if (keyword.startsWith(i18nc("Note this is a KRunner keyword", "desktop") + QStringLiteral("="), Qt::CaseInsensitive)) { desktopId = keyword.split(QStringLiteral("="))[1]; for (const auto desktop : VirtualDesktopManager::self()->desktops()) { if (desktop->name().contains(desktopId.toString(), Qt::CaseInsensitive) || desktop->x11DesktopNumber() == desktopId.toUInt()) { @@ -140,13 +139,13 @@ RemoteMatches WindowsRunner::Match(const QString &searchTerm) // check for windows when no keywords were used // check the name and app name for containing the query without the keyword if (windowName.isEmpty() && windowAppName.isEmpty() && !targetDesktop) { - const QString& test = term.mid(keywords[0].length() + 1); + const QString &test = term.mid(keywords[0].length() + 1); if (!name.contains(test, Qt::CaseInsensitive) && !appName.contains(test, Qt::CaseInsensitive)) { continue; } } // blacklisted everything else: we have a match - if (actionSupported(client, action)){ + if (actionSupported(client, action)) { matches << windowsMatch(client, action); } } @@ -159,7 +158,7 @@ RemoteMatches WindowsRunner::Match(const QString &searchTerm) bool desktopAdded = false; // check for desktop keyword - if (term.startsWith(i18nc("Note this is a KRunner keyword", "desktop") , Qt::CaseInsensitive)) { + if (term.startsWith(i18nc("Note this is a KRunner keyword", "desktop"), Qt::CaseInsensitive)) { const QStringList parts = term.split(QLatin1Char(' ')); if (parts.size() == 1) { // only keyword - list all desktops @@ -201,7 +200,6 @@ RemoteMatches WindowsRunner::Match(const QString &searchTerm) } } - return matches; } @@ -220,7 +218,6 @@ void WindowsRunner::Run(const QString &id, const QString &actionId) return; } - const auto uuid = QUuid::fromString(objectId); const auto client = workspace()->findAbstractClient(uuid); switch (action) { @@ -290,7 +287,7 @@ RemoteMatch WindowsRunner::windowsMatch(const AbstractClient *client, const Wind // When there is no icon name, send a pixmap along instead if (match.iconName.isEmpty()) { - QImage convertedImage = client->icon().pixmap(QSize(16,16)).toImage().convertToFormat(QImage::Format_RGBA8888); + QImage convertedImage = client->icon().pixmap(QSize(16, 16)).toImage().convertToFormat(QImage::Format_RGBA8888); RemoteImage remoteImage{ convertedImage.width(), convertedImage.height(), @@ -298,8 +295,7 @@ RemoteMatch WindowsRunner::windowsMatch(const AbstractClient *client, const Wind true, // hasAlpha 8, // bitsPerSample 4, // channels - QByteArray(reinterpret_cast(convertedImage.constBits()), convertedImage.sizeInBytes()) - }; + QByteArray(reinterpret_cast(convertedImage.constBits()), convertedImage.sizeInBytes())}; properties.insert(QStringLiteral("icon-data"), QVariant::fromValue(remoteImage)); } diff --git a/src/plugins/krunner-integration/windowsrunnerinterface.h b/src/plugins/krunner-integration/windowsrunnerinterface.h index 2386c4dc60..6dbe8ab126 100644 --- a/src/plugins/krunner-integration/windowsrunnerinterface.h +++ b/src/plugins/krunner-integration/windowsrunnerinterface.h @@ -13,16 +13,16 @@ #pragma once -#include "plugin.h" #include "dbusutils_p.h" +#include "plugin.h" #include -#include +#include #include #include +#include #include -#include namespace KWin { @@ -57,8 +57,8 @@ private: }; void initialize(); - RemoteMatch desktopMatch(const VirtualDesktop *desktop, const WindowsRunnerAction action = ActivateDesktopAction, qreal relevance = 1.0) const; - RemoteMatch windowsMatch(const AbstractClient *client, const WindowsRunnerAction action = ActivateAction, qreal relevance = 1.0, Plasma::QueryMatch::Type type = Plasma::QueryMatch::ExactMatch) const; + RemoteMatch desktopMatch(const VirtualDesktop *desktop, const WindowsRunnerAction action = ActivateDesktopAction, qreal relevance = 1.0) const; + RemoteMatch windowsMatch(const AbstractClient *client, const WindowsRunnerAction action = ActivateAction, qreal relevance = 1.0, Plasma::QueryMatch::Type type = Plasma::QueryMatch::ExactMatch) const; bool actionSupported(const AbstractClient *client, const WindowsRunnerAction action) const; }; } diff --git a/src/plugins/nightcolor/clockskewnotifierengine_linux.cpp b/src/plugins/nightcolor/clockskewnotifierengine_linux.cpp index af23c595a3..c51464ec89 100644 --- a/src/plugins/nightcolor/clockskewnotifierengine_linux.cpp +++ b/src/plugins/nightcolor/clockskewnotifierengine_linux.cpp @@ -8,10 +8,10 @@ #include +#include #include #include #include -#include #ifndef TFD_TIMER_CANCEL_ON_SET // only available in newer glib #define TFD_TIMER_CANCEL_ON_SET (1 << 1) diff --git a/src/plugins/nightcolor/constants.h b/src/plugins/nightcolor/constants.h index e5102b82e3..685a755479 100644 --- a/src/plugins/nightcolor/constants.h +++ b/src/plugins/nightcolor/constants.h @@ -16,7 +16,7 @@ static const int MSC_DAY = 86400000; static const int MIN_TEMPERATURE = 1000; static const int NEUTRAL_TEMPERATURE = 6500; static const int DEFAULT_NIGHT_TEMPERATURE = 4500; -static const int FALLBACK_SLOW_UPDATE_TIME = 1800000; /* 30 minutes */ +static const int FALLBACK_SLOW_UPDATE_TIME = 1800000; /* 30 minutes */ } diff --git a/src/plugins/nightcolor/nightcolordbusinterface.cpp b/src/plugins/nightcolor/nightcolordbusinterface.cpp index 189fc05dbd..6fc5101e59 100644 --- a/src/plugins/nightcolor/nightcolordbusinterface.cpp +++ b/src/plugins/nightcolor/nightcolordbusinterface.cpp @@ -8,12 +8,13 @@ */ #include "nightcolordbusinterface.h" -#include "nightcolormanager.h" #include "colorcorrectadaptor.h" +#include "nightcolormanager.h" #include -namespace KWin { +namespace KWin +{ NightColorDBusInterface::NightColorDBusInterface(NightColorManager *parent) : QObject(parent) @@ -32,8 +33,7 @@ NightColorDBusInterface::NightColorDBusInterface(NightColorManager *parent) QDBusMessage message = QDBusMessage::createSignal( QStringLiteral("/ColorCorrect"), QStringLiteral("org.freedesktop.DBus.Properties"), - QStringLiteral("PropertiesChanged") - ); + QStringLiteral("PropertiesChanged")); message.setArguments({ QStringLiteral("org.kde.kwin.ColorCorrect"), @@ -51,8 +51,7 @@ NightColorDBusInterface::NightColorDBusInterface(NightColorManager *parent) QDBusMessage message = QDBusMessage::createSignal( QStringLiteral("/ColorCorrect"), QStringLiteral("org.freedesktop.DBus.Properties"), - QStringLiteral("PropertiesChanged") - ); + QStringLiteral("PropertiesChanged")); message.setArguments({ QStringLiteral("org.kde.kwin.ColorCorrect"), @@ -70,8 +69,7 @@ NightColorDBusInterface::NightColorDBusInterface(NightColorManager *parent) QDBusMessage message = QDBusMessage::createSignal( QStringLiteral("/ColorCorrect"), QStringLiteral("org.freedesktop.DBus.Properties"), - QStringLiteral("PropertiesChanged") - ); + QStringLiteral("PropertiesChanged")); message.setArguments({ QStringLiteral("org.kde.kwin.ColorCorrect"), @@ -89,8 +87,7 @@ NightColorDBusInterface::NightColorDBusInterface(NightColorManager *parent) QDBusMessage message = QDBusMessage::createSignal( QStringLiteral("/ColorCorrect"), QStringLiteral("org.freedesktop.DBus.Properties"), - QStringLiteral("PropertiesChanged") - ); + QStringLiteral("PropertiesChanged")); message.setArguments({ QStringLiteral("org.kde.kwin.ColorCorrect"), @@ -108,8 +105,7 @@ NightColorDBusInterface::NightColorDBusInterface(NightColorManager *parent) QDBusMessage message = QDBusMessage::createSignal( QStringLiteral("/ColorCorrect"), QStringLiteral("org.freedesktop.DBus.Properties"), - QStringLiteral("PropertiesChanged") - ); + QStringLiteral("PropertiesChanged")); message.setArguments({ QStringLiteral("org.kde.kwin.ColorCorrect"), @@ -127,8 +123,7 @@ NightColorDBusInterface::NightColorDBusInterface(NightColorManager *parent) QDBusMessage message = QDBusMessage::createSignal( QStringLiteral("/ColorCorrect"), QStringLiteral("org.freedesktop.DBus.Properties"), - QStringLiteral("PropertiesChanged") - ); + QStringLiteral("PropertiesChanged")); message.setArguments({ QStringLiteral("org.kde.kwin.ColorCorrect"), @@ -147,8 +142,7 @@ NightColorDBusInterface::NightColorDBusInterface(NightColorManager *parent) QDBusMessage message = QDBusMessage::createSignal( QStringLiteral("/ColorCorrect"), QStringLiteral("org.freedesktop.DBus.Properties"), - QStringLiteral("PropertiesChanged") - ); + QStringLiteral("PropertiesChanged")); message.setArguments({ QStringLiteral("org.kde.kwin.ColorCorrect"), @@ -167,8 +161,7 @@ NightColorDBusInterface::NightColorDBusInterface(NightColorManager *parent) QDBusMessage message = QDBusMessage::createSignal( QStringLiteral("/ColorCorrect"), QStringLiteral("org.freedesktop.DBus.Properties"), - QStringLiteral("PropertiesChanged") - ); + QStringLiteral("PropertiesChanged")); message.setArguments({ QStringLiteral("org.kde.kwin.ColorCorrect"), diff --git a/src/plugins/nightcolor/nightcolormanager.cpp b/src/plugins/nightcolor/nightcolormanager.cpp index 90cc6c4ed4..fb51c1ab59 100644 --- a/src/plugins/nightcolor/nightcolormanager.cpp +++ b/src/plugins/nightcolor/nightcolormanager.cpp @@ -27,7 +27,8 @@ #include #include -namespace KWin { +namespace KWin +{ static const int QUICK_ADJUST_DURATION = 2000; static const int TEMPERATURE_STEP = 50; @@ -67,7 +68,7 @@ NightColorManager::NightColorManager(QObject *parent) QStringLiteral("/org/kde/osdService"), QStringLiteral("org.kde.osdService"), QStringLiteral("showText")); - message.setArguments({ iconName, text }); + message.setArguments({iconName, text}); QDBusConnection::sessionBus().asyncCall(message); }); @@ -305,8 +306,8 @@ void NightColorManager::readConfig() int diffME = mrB.msecsTo(evB); if (diffME <= 0) { // morning not strictly before evening - use defaults - mrB = QTime(6,0); - evB = QTime(18,0); + mrB = QTime(6, 0); + evB = QTime(18, 0); diffME = mrB.msecsTo(evB); } int diffMin = qMin(diffME, MSC_DAY - diffME); @@ -314,8 +315,8 @@ void NightColorManager::readConfig() int trTime = s->transitionTime() * 1000 * 60; if (trTime < 0 || diffMin <= trTime) { // transition time too long - use defaults - mrB = QTime(6,0); - evB = QTime(18,0); + mrB = QTime(6, 0); + evB = QTime(18, 0); trTime = FALLBACK_SLOW_UPDATE_TIME; } m_morning = mrB; @@ -448,9 +449,13 @@ void NightColorManager::resetSlowUpdateTimer() m_slowUpdateTimer = new QTimer(this); m_slowUpdateTimer->setSingleShot(false); if (isDay) { - connect(m_slowUpdateTimer, &QTimer::timeout, this, [this]() {slowUpdate(m_dayTargetTemp);}); + connect(m_slowUpdateTimer, &QTimer::timeout, this, [this]() { + slowUpdate(m_dayTargetTemp); + }); } else { - connect(m_slowUpdateTimer, &QTimer::timeout, this, [this]() {slowUpdate(m_nightTargetTemp);}); + connect(m_slowUpdateTimer, &QTimer::timeout, this, [this]() { + slowUpdate(m_nightTargetTemp); + }); } // calculate interval such as temperature is changed by TEMPERATURE_STEP K per timer timeout @@ -581,16 +586,16 @@ DateTimes NightColorManager::getSunTimings(const QDateTime &dateTime, double lat const bool endDefined = !dateTimes.second.isNull(); if (!beginDefined || !endDefined) { if (beginDefined) { - dateTimes.second = dateTimes.first.addMSecs( FALLBACK_SLOW_UPDATE_TIME ); + dateTimes.second = dateTimes.first.addMSecs(FALLBACK_SLOW_UPDATE_TIME); } else if (endDefined) { - dateTimes.first = dateTimes.second.addMSecs( - FALLBACK_SLOW_UPDATE_TIME ); + dateTimes.first = dateTimes.second.addMSecs(-FALLBACK_SLOW_UPDATE_TIME); } else { // Just use default values for morning and evening, but the user // will probably deactivate Night Color anyway if he is living // in a region without clear sun rise and set. const QTime referenceTime = morning ? QTime(6, 0) : QTime(18, 0); dateTimes.first = QDateTime(dateTime.date(), referenceTime); - dateTimes.second = dateTimes.first.addMSecs( FALLBACK_SLOW_UPDATE_TIME ); + dateTimes.second = dateTimes.first.addMSecs(FALLBACK_SLOW_UPDATE_TIME); } } return dateTimes; @@ -598,11 +603,9 @@ DateTimes NightColorManager::getSunTimings(const QDateTime &dateTime, double lat bool NightColorManager::checkAutomaticSunTimings() const { - if (m_prev.first.isValid() && m_prev.second.isValid() && - m_next.first.isValid() && m_next.second.isValid()) { + if (m_prev.first.isValid() && m_prev.second.isValid() && m_next.first.isValid() && m_next.second.isValid()) { const QDateTime todayNow = QDateTime::currentDateTime(); - return m_prev.first <= todayNow && todayNow < m_next.first && - m_prev.first.msecsTo(m_next.first) < MSC_DAY * 23./24; + return m_prev.first <= todayNow && todayNow < m_next.first && m_prev.first.msecsTo(m_next.first) < MSC_DAY * 23. / 24; } return false; } @@ -619,7 +622,7 @@ int NightColorManager::currentTargetTemp() const } if (m_mode == NightColorMode::Constant) { - return m_nightTargetTemp; + return m_nightTargetTemp; } const QDateTime todayNow = QDateTime::currentDateTime(); diff --git a/src/plugins/nightcolor/nightcolormanager.h b/src/plugins/nightcolor/nightcolormanager.h index 8efeecbc93..ff6998c213 100644 --- a/src/plugins/nightcolor/nightcolormanager.h +++ b/src/plugins/nightcolor/nightcolormanager.h @@ -12,9 +12,9 @@ #include "constants.h" #include "plugin.h" +#include #include #include -#include #include @@ -26,8 +26,8 @@ namespace KWin class ClockSkewNotifier; class NightColorDBusInterface; -typedef QPair DateTimes; -typedef QPair Times; +typedef QPair DateTimes; +typedef QPair Times; /** * This enum type is used to specify operation mode of the night color manager. @@ -272,8 +272,8 @@ private: DateTimes m_next = DateTimes(); // manual times from config - QTime m_morning = QTime(6,0); - QTime m_evening = QTime(18,0); + QTime m_morning = QTime(6, 0); + QTime m_evening = QTime(18, 0); int m_trTime = 30; // saved in minutes > 1 // auto location provided by work space diff --git a/src/plugins/nightcolor/suncalc.cpp b/src/plugins/nightcolor/suncalc.cpp index 6d32e481a4..61a52dd1af 100644 --- a/src/plugins/nightcolor/suncalc.cpp +++ b/src/plugins/nightcolor/suncalc.cpp @@ -13,12 +13,13 @@ #include #include -namespace KWin { +namespace KWin +{ -#define TWILIGHT_NAUT -12.0 -#define TWILIGHT_CIVIL -6.0 -#define SUN_RISE_SET -0.833 -#define SUN_HIGH 2.0 +#define TWILIGHT_NAUT -12.0 +#define TWILIGHT_CIVIL -6.0 +#define SUN_RISE_SET -0.833 +#define SUN_HIGH 2.0 static QTime convertToLocalTime(const QDateTime &when, const QTime &utcTime) { @@ -36,13 +37,13 @@ QPair calculateSunTimings(const QDateTime &dateTime, doubl const double rad = M_PI / 180.; const double earthObliquity = 23.4397; // epsilon - const double lat = latitude; // phi - const double lng = -longitude; // lw + const double lat = latitude; // phi + const double lng = -longitude; // lw // times const QDateTime utcDateTime = dateTime.toUTC(); - const double juPrompt = utcDateTime.date().toJulianDay(); // J - const double ju2000 = 2451545.; // J2000 + const double juPrompt = utcDateTime.date().toJulianDay(); // J + const double ju2000 = 2451545.; // J2000 // geometry auto mod360 = [](double number) -> double { @@ -90,7 +91,7 @@ QPair calculateSunTimings(const QDateTime &dateTime, doubl const double decl = declination(date); const double ret0 = (sin(angle) - sin(lat) * sin(decl)) / (cos(lat) * cos(decl)); - double ret = mod360(acos( ret0 )); + double ret = mod360(acos(ret0)); if (180. < ret) { ret = ret - 360.; } @@ -102,11 +103,11 @@ QPair calculateSunTimings(const QDateTime &dateTime, doubl */ // transit is at noon - auto getTransit = [&](const double date) -> double { // Jtransit - const double juMeanSolTime = juPrompt - ju2000 - 0.0009 - lng / 360.; // n_x = J - J_2000 - J_0 - l_w / 360° + auto getTransit = [&](const double date) -> double { // Jtransit + const double juMeanSolTime = juPrompt - ju2000 - 0.0009 - lng / 360.; // n_x = J - J_2000 - J_0 - l_w / 360° const double juTrEstimate = date + qRound64(juMeanSolTime) - juMeanSolTime; // J_x = J + n - n_x - const double anom = anomaly(juTrEstimate); // M - const double eclLngM = ecliptLngMean(anom); // L_sun + const double anom = anomaly(juTrEstimate); // M + const double eclLngM = ecliptLngMean(anom); // L_sun return juTrEstimate + 0.0053 * sin(anom) - 0.0068 * sin(2 * eclLngM); }; @@ -155,7 +156,7 @@ QPair calculateSunTimings(const QDateTime &dateTime, doubl dateTimeEnd = QDateTime(dateTime.date(), localTime); } - return { dateTimeBegin, dateTimeEnd }; + return {dateTimeBegin, dateTimeEnd}; } } diff --git a/src/plugins/nightcolor/suncalc.h b/src/plugins/nightcolor/suncalc.h index 45c8c4c604..5d58f5fddd 100644 --- a/src/plugins/nightcolor/suncalc.h +++ b/src/plugins/nightcolor/suncalc.h @@ -10,8 +10,8 @@ #define KWIN_SUNCALCULATOR_H #include -#include #include +#include namespace KWin { diff --git a/src/plugins/qpa/eglhelpers.cpp b/src/plugins/qpa/eglhelpers.cpp index 2b24e966e5..e32c2763c2 100644 --- a/src/plugins/qpa/eglhelpers.cpp +++ b/src/plugins/qpa/eglhelpers.cpp @@ -41,7 +41,7 @@ EGLConfig configFromFormat(EGLDisplay display, const QSurfaceFormat &surfaceForm const EGLint renderableType = isOpenGLES() ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_BIT; // Not setting samples as QtQuick doesn't need it. - const QVector attributes { + const QVector attributes{ EGL_SURFACE_TYPE, surfaceType, EGL_RED_SIZE, redSize, EGL_GREEN_SIZE, greenSize, @@ -50,8 +50,7 @@ EGLConfig configFromFormat(EGLDisplay display, const QSurfaceFormat &surfaceForm EGL_DEPTH_SIZE, depthSize, EGL_STENCIL_SIZE, stencilSize, EGL_RENDERABLE_TYPE, renderableType, - EGL_NONE - }; + EGL_NONE}; EGLint configCount; if (!eglChooseConfig(display, attributes.data(), nullptr, 0, &configCount)) { @@ -80,10 +79,7 @@ EGLConfig configFromFormat(EGLDisplay display, const QSurfaceFormat &surfaceForm eglGetConfigAttrib(display, config, EGL_BLUE_SIZE, &blueConfig); eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE, &alphaConfig); - if ((redSize == 0 || redSize == redConfig) && - (greenSize == 0 || greenSize == greenConfig) && - (blueSize == 0 || blueSize == blueConfig) && - (alphaSize == 0 || alphaSize == alphaConfig)) { + if ((redSize == 0 || redSize == redConfig) && (greenSize == 0 || greenSize == greenConfig) && (blueSize == 0 || blueSize == blueConfig) && (alphaSize == 0 || alphaSize == alphaConfig)) { return config; } } diff --git a/src/plugins/qpa/integration.h b/src/plugins/qpa/integration.h index c333e6bf59..34511eb610 100644 --- a/src/plugins/qpa/integration.h +++ b/src/plugins/qpa/integration.h @@ -12,9 +12,9 @@ #include -#include -#include #include +#include +#include namespace KWin { diff --git a/src/plugins/qpa/offscreensurface.cpp b/src/plugins/qpa/offscreensurface.cpp index a44bda56dc..2c354b5efa 100644 --- a/src/plugins/qpa/offscreensurface.cpp +++ b/src/plugins/qpa/offscreensurface.cpp @@ -33,8 +33,7 @@ OffscreenSurface::OffscreenSurface(QOffscreenSurface *surface) const EGLint attributes[] = { EGL_WIDTH, size.width(), EGL_HEIGHT, size.height(), - EGL_NONE - }; + EGL_NONE}; m_surface = eglCreatePbufferSurface(m_eglDisplay, config, attributes); if (m_surface == EGL_NO_SURFACE) { diff --git a/src/plugins/screencast/eglnativefence.cpp b/src/plugins/screencast/eglnativefence.cpp index c10afc3e5c..a2e096511e 100644 --- a/src/plugins/screencast/eglnativefence.cpp +++ b/src/plugins/screencast/eglnativefence.cpp @@ -12,8 +12,8 @@ namespace KWin { #ifndef EGL_ANDROID_native_fence_sync -#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144 -#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1 +#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144 +#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1 #endif // EGL_ANDROID_native_fence_sync EGLNativeFence::EGLNativeFence(EGLDisplay display) diff --git a/src/plugins/screencast/main.cpp b/src/plugins/screencast/main.cpp index 99fdd702be..16c405d769 100644 --- a/src/plugins/screencast/main.cpp +++ b/src/plugins/screencast/main.cpp @@ -4,8 +4,8 @@ SPDX-License-Identifier: LGPL-2.0-or-later */ -#include "screencastmanager.h" #include "main.h" +#include "screencastmanager.h" #include diff --git a/src/plugins/screencast/pipewirecore.cpp b/src/plugins/screencast/pipewirecore.cpp index 269c2d99b6..90e95cab29 100644 --- a/src/plugins/screencast/pipewirecore.cpp +++ b/src/plugins/screencast/pipewirecore.cpp @@ -43,13 +43,13 @@ PipeWireCore::~PipeWireCore() } } -void PipeWireCore::onCoreError(void* data, uint32_t id, int seq, int res, const char* message) +void PipeWireCore::onCoreError(void *data, uint32_t id, int seq, int res, const char *message) { Q_UNUSED(seq) qCWarning(KWIN_SCREENCAST) << "PipeWire remote error: " << message; if (id == PW_ID_CORE && res == -EPIPE) { - PipeWireCore *pw = static_cast(data); + PipeWireCore *pw = static_cast(data); Q_EMIT pw->pipewireFailed(QString::fromUtf8(message)); } } @@ -66,11 +66,10 @@ bool PipeWireCore::init() QSocketNotifier *notifier = new QSocketNotifier(pw_loop_get_fd(pwMainLoop), QSocketNotifier::Read, this); connect(notifier, &QSocketNotifier::activated, this, [this] { - int result = pw_loop_iterate (pwMainLoop, 0); - if (result < 0) - qCWarning(KWIN_SCREENCAST) << "pipewire_loop_iterate failed: " << result; - } - ); + int result = pw_loop_iterate(pwMainLoop, 0); + if (result < 0) + qCWarning(KWIN_SCREENCAST) << "pipewire_loop_iterate failed: " << result; + }); pwContext = pw_context_new(pwMainLoop, nullptr, 0); if (!pwContext) { @@ -96,7 +95,7 @@ bool PipeWireCore::init() return true; } -QSharedPointer< PipeWireCore > PipeWireCore::self() +QSharedPointer PipeWireCore::self() { static QWeakPointer global; QSharedPointer ret; diff --git a/src/plugins/screencast/regionscreencastsource.cpp b/src/plugins/screencast/regionscreencastsource.cpp index f7a9417e1e..92e962442e 100644 --- a/src/plugins/screencast/regionscreencastsource.cpp +++ b/src/plugins/screencast/regionscreencastsource.cpp @@ -10,9 +10,9 @@ #include #include #include -#include #include #include +#include #include diff --git a/src/plugins/screencast/regionscreencastsource.h b/src/plugins/screencast/regionscreencastsource.h index 5b0bfe5424..6b73dd0808 100644 --- a/src/plugins/screencast/regionscreencastsource.h +++ b/src/plugins/screencast/regionscreencastsource.h @@ -30,7 +30,8 @@ public: void render(QImage *image) override; std::chrono::nanoseconds clock() const override; - QRect region() const { + QRect region() const + { return m_region; } void updateOutput(AbstractWaylandOutput *output); diff --git a/src/plugins/screencast/screencastmanager.cpp b/src/plugins/screencast/screencastmanager.cpp index 44a4f08eae..6b8eb9a55e 100644 --- a/src/plugins/screencast/screencastmanager.cpp +++ b/src/plugins/screencast/screencastmanager.cpp @@ -14,10 +14,10 @@ #include "effects.h" #include "kwingltexture.h" #include "outputscreencastsource.h" -#include "regionscreencastsource.h" -#include "screencaststream.h" #include "platform.h" +#include "regionscreencastsource.h" #include "scene.h" +#include "screencaststream.h" #include "wayland_server.h" #include "windowscreencastsource.h" #include "workspace.h" @@ -56,7 +56,8 @@ public: } private: - void startFeeding() { + void startFeeding() + { connect(Compositor::self()->scene(), &Scene::frameRendered, this, &WindowStream::bufferToStream); connect(m_toplevel, &Toplevel::damaged, this, &WindowStream::includeDamage); @@ -64,16 +65,19 @@ private: m_toplevel->addRepaintFull(); } - void stopFeeding() { + void stopFeeding() + { disconnect(Compositor::self()->scene(), &Scene::frameRendered, this, &WindowStream::bufferToStream); } - void includeDamage(Toplevel *toplevel, const QRegion &damage) { + void includeDamage(Toplevel *toplevel, const QRegion &damage) + { Q_ASSERT(m_toplevel == toplevel); m_damagedRegion |= damage; } - void bufferToStream () { + void bufferToStream() + { if (!m_damagedRegion.isEmpty()) { recordFrame(m_damagedRegion); m_damagedRegion = {}; @@ -129,7 +133,7 @@ void ScreencastManager::streamOutput(KWaylandServer::ScreencastStreamV1Interface auto stream = new ScreenCastStream(new OutputScreenCastSource(streamOutput), this); stream->setObjectName(streamOutput->name()); stream->setCursorMode(mode, streamOutput->scale(), streamOutput->geometry()); - auto bufferToStream = [streamOutput, stream] (const QRegion &damagedRegion) { + auto bufferToStream = [streamOutput, stream](const QRegion &damagedRegion) { if (damagedRegion.isEmpty()) { return; } @@ -169,7 +173,7 @@ void ScreencastManager::streamRegion(KWaylandServer::ScreencastStreamV1Interface for (auto output : allOutputs) { AbstractWaylandOutput *streamOutput = qobject_cast(output); if (streamOutput->geometry().intersects(geometry)) { - auto bufferToStream = [streamOutput, stream, source] (const QRegion &damagedRegion) { + auto bufferToStream = [streamOutput, stream, source](const QRegion &damagedRegion) { if (damagedRegion.isEmpty()) { return; } @@ -193,7 +197,7 @@ void ScreencastManager::integrateStreams(KWaylandServer::ScreencastStreamV1Inter waylandStream->sendClosed(); stream->deleteLater(); }); - connect(stream, &ScreenCastStream::streamReady, stream, [waylandStream] (uint nodeid) { + connect(stream, &ScreenCastStream::streamReady, stream, [waylandStream](uint nodeid) { waylandStream->sendCreated(nodeid); }); if (!stream->init()) { diff --git a/src/plugins/screencast/screencastmanager.h b/src/plugins/screencast/screencastmanager.h index cab329eebd..cc1c97f58b 100644 --- a/src/plugins/screencast/screencastmanager.h +++ b/src/plugins/screencast/screencastmanager.h @@ -37,9 +37,9 @@ private: double scale, KWaylandServer::ScreencastV1Interface::CursorMode mode); void streamRegion(KWaylandServer::ScreencastStreamV1Interface *stream, - const QRect &geometry, - qreal scale, - KWaylandServer::ScreencastV1Interface::CursorMode mode); + const QRect &geometry, + qreal scale, + KWaylandServer::ScreencastV1Interface::CursorMode mode); void integrateStreams(KWaylandServer::ScreencastStreamV1Interface *waylandStream, ScreenCastStream *stream); diff --git a/src/plugins/screencast/screencaststream.cpp b/src/plugins/screencast/screencaststream.cpp index e90103cad1..07d2d2d1f3 100644 --- a/src/plugins/screencast/screencaststream.cpp +++ b/src/plugins/screencast/screencaststream.cpp @@ -7,8 +7,8 @@ */ #include "screencaststream.h" -#include "cursor.h" #include "composite.h" +#include "cursor.h" #include "dmabuftexture.h" #include "eglnativefence.h" #include "kwineffects.h" @@ -41,8 +41,8 @@ namespace KWin void ScreenCastStream::onStreamStateChanged(void *data, pw_stream_state old, pw_stream_state state, const char *error_message) { - ScreenCastStream *pw = static_cast(data); - qCDebug(KWIN_SCREENCAST) << "state changed"<< pw_stream_state_as_string(old) << " -> " << pw_stream_state_as_string(state) << error_message; + ScreenCastStream *pw = static_cast(data); + qCDebug(KWIN_SCREENCAST) << "state changed" << pw_stream_state_as_string(old) << " -> " << pw_stream_state_as_string(state) << error_message; switch (state) { case PW_STREAM_STATE_ERROR: @@ -67,54 +67,50 @@ void ScreenCastStream::onStreamStateChanged(void *data, pw_stream_state old, pw_ } } -#define CURSOR_BPP 4 -#define CURSOR_META_SIZE(w,h) (sizeof(struct spa_meta_cursor) + \ - sizeof(struct spa_meta_bitmap) + w * h * CURSOR_BPP) +#define CURSOR_BPP 4 +#define CURSOR_META_SIZE(w, h) (sizeof(struct spa_meta_cursor) + sizeof(struct spa_meta_bitmap) + w * h * CURSOR_BPP) static const int videoDamageRegionCount = 16; void ScreenCastStream::newStreamParams() { const int bpp = videoFormat.format == SPA_VIDEO_FORMAT_RGB || videoFormat.format == SPA_VIDEO_FORMAT_BGR ? 3 : 4; - auto stride = SPA_ROUND_UP_N (m_resolution.width() * bpp, 4); + auto stride = SPA_ROUND_UP_N(m_resolution.width() * bpp, 4); uint8_t paramsBuffer[1024]; - spa_pod_builder pod_builder = SPA_POD_BUILDER_INIT (paramsBuffer, sizeof (paramsBuffer)); + spa_pod_builder pod_builder = SPA_POD_BUILDER_INIT(paramsBuffer, sizeof(paramsBuffer)); int buffertypes; if (m_hasModifier) { - buffertypes = (1<(data); - spa_format_video_raw_parse (format, &pw->videoFormat); + spa_format_video_raw_parse(format, &pw->videoFormat); // TODO[explicit_modifiers]: check if modifier list or single modifier, // make test allocation, fixate format, ... // depends on how flexible kwin will become in that regard. @@ -149,13 +145,13 @@ void ScreenCastStream::onStreamAddBuffer(void *data, pw_buffer *buffer) dmabuf.reset(kwinApp()->platform()->createDmaBufTexture(stream->m_resolution)); if (dmabuf) { - spa_data->type = SPA_DATA_DmaBuf; - spa_data->fd = dmabuf->fd(); - spa_data->data = nullptr; - spa_data->maxsize = dmabuf->stride() * stream->m_resolution.height(); + spa_data->type = SPA_DATA_DmaBuf; + spa_data->fd = dmabuf->fd(); + spa_data->data = nullptr; + spa_data->maxsize = dmabuf->stride() * stream->m_resolution.height(); - stream->m_dmabufDataForPwBuffer.insert(buffer, dmabuf); -#ifdef F_SEAL_SEAL //Disable memfd on systems that don't have it, like BSD < 12 + stream->m_dmabufDataForPwBuffer.insert(buffer, dmabuf); +#ifdef F_SEAL_SEAL // Disable memfd on systems that don't have it, like BSD < 12 } else { if (!(spa_data[0].type & (1 << SPA_DATA_MemFd))) { qCCritical(KWIN_SCREENCAST) << "memfd: Client doesn't support memfd buffer data type"; @@ -163,7 +159,7 @@ void ScreenCastStream::onStreamAddBuffer(void *data, pw_buffer *buffer) } const int bytesPerPixel = stream->m_source->hasAlphaChannel() ? 4 : 3; - const int stride = SPA_ROUND_UP_N (stream->m_resolution.width() * bytesPerPixel, 4); + const int stride = SPA_ROUND_UP_N(stream->m_resolution.width() * bytesPerPixel, 4); spa_data->maxsize = stride * stream->m_resolution.height(); spa_data->type = SPA_DATA_MemFd; spa_data->fd = memfd_create("kwin-screencast-memfd", MFD_CLOEXEC | MFD_ALLOW_SEALING); @@ -173,7 +169,7 @@ void ScreenCastStream::onStreamAddBuffer(void *data, pw_buffer *buffer) } spa_data->mapoffset = 0; - if (ftruncate (spa_data->fd, spa_data->maxsize) < 0) { + if (ftruncate(spa_data->fd, spa_data->maxsize) < 0) { qCCritical(KWIN_SCREENCAST) << "memfd: Can't truncate to" << spa_data->maxsize; return; } @@ -204,8 +200,8 @@ void ScreenCastStream::onStreamRemoveBuffer(void *data, pw_buffer *buffer) struct spa_buffer *spa_buffer = buffer->buffer; struct spa_data *spa_data = spa_buffer->datas; if (spa_data && spa_data->type == SPA_DATA_MemFd) { - munmap (spa_data->data, spa_data->maxsize); - close (spa_data->fd); + munmap(spa_data->data, spa_data->maxsize); + close(spa_data->fd); } } @@ -283,18 +279,18 @@ bool ScreenCastStream::createStream() const spa_pod *params[2]; int n_params; - auto canCreateDmaBuf = [this] () -> bool { + auto canCreateDmaBuf = [this]() -> bool { return !QSharedPointer(kwinApp()->platform()->createDmaBufTexture(m_resolution)).isNull(); }; const auto format = m_source->hasAlphaChannel() ? SPA_VIDEO_FORMAT_BGRA : SPA_VIDEO_FORMAT_BGR; if (canCreateDmaBuf()) { - params[0] = buildFormat(&podBuilder, SPA_VIDEO_FORMAT_BGRA, &resolution, &defaultFramerate, &minFramerate, &maxFramerate, &modifier, 1); - params[1] = buildFormat(&podBuilder, format, &resolution, &defaultFramerate, &minFramerate, &maxFramerate, nullptr, 0); - n_params = 2; + params[0] = buildFormat(&podBuilder, SPA_VIDEO_FORMAT_BGRA, &resolution, &defaultFramerate, &minFramerate, &maxFramerate, &modifier, 1); + params[1] = buildFormat(&podBuilder, format, &resolution, &defaultFramerate, &minFramerate, &maxFramerate, nullptr, 0); + n_params = 2; } else { - params[0] = buildFormat(&podBuilder, format, &resolution, &defaultFramerate, &minFramerate, &maxFramerate, nullptr, 0); - n_params = 1; + params[0] = buildFormat(&podBuilder, format, &resolution, &defaultFramerate, &minFramerate, &maxFramerate, nullptr, 0); + n_params = 1; } pw_stream_add_listener(pwStream, &streamListener, &pwStreamEvents, this); @@ -365,7 +361,7 @@ void ScreenCastStream::recordFrame(const QRegion &damagedRegion) struct spa_buffer *spa_buffer = buffer->buffer; struct spa_data *spa_data = spa_buffer->datas; - uint8_t *data = (uint8_t *) spa_data->data; + uint8_t *data = (uint8_t *)spa_data->data; if (!data && spa_buffer->datas->type != SPA_DATA_DmaBuf) { qCWarning(KWIN_SCREENCAST) << "Failed to record frame: invalid buffer data"; pw_stream_queue_buffer(pwStream, buffer); @@ -377,7 +373,7 @@ void ScreenCastStream::recordFrame(const QRegion &damagedRegion) if (data || spa_data[0].type == SPA_DATA_MemFd) { const bool hasAlpha = m_source->hasAlphaChannel(); const int bpp = data && !hasAlpha ? 3 : 4; - const uint stride = SPA_ROUND_UP_N (size.width() * bpp, 4); + const uint stride = SPA_ROUND_UP_N(size.width() * bpp, 4); QImage dest(data, size.width(), size.height(), stride, hasAlpha ? QImage::Format_RGBA8888_Premultiplied : QImage::Format_RGB888); if (dest.sizeInBytes() > spa_data->maxsize) { @@ -439,11 +435,11 @@ void ScreenCastStream::recordFrame(const QRegion &damagedRegion) if (m_cursor.mode == KWaylandServer::ScreencastV1Interface::Metadata) { sendCursorData(Cursors::self()->currentCursor(), - (spa_meta_cursor *) spa_buffer_find_meta_data (spa_buffer, SPA_META_Cursor, sizeof (spa_meta_cursor))); + (spa_meta_cursor *)spa_buffer_find_meta_data(spa_buffer, SPA_META_Cursor, sizeof(spa_meta_cursor))); } if (spa_meta *vdMeta = spa_buffer_find_meta(spa_buffer, SPA_META_VideoDamage)) { - struct spa_meta_region *r = (spa_meta_region *) spa_meta_first(vdMeta); + struct spa_meta_region *r = (spa_meta_region *)spa_meta_first(vdMeta); // If there's too many rectangles, we just send the bounding rect if (damagedRegion.rectCount() > videoDamageRegionCount - 1) { @@ -466,7 +462,7 @@ void ScreenCastStream::recordFrame(const QRegion &damagedRegion) } } - spa_meta_header *spaHeader = (spa_meta_header *) spa_buffer_find_meta_data(spa_buffer, SPA_META_Header, sizeof(spaHeader)); + spa_meta_header *spaHeader = (spa_meta_header *)spa_buffer_find_meta_data(spa_buffer, SPA_META_Header, sizeof(spaHeader)); if (spaHeader) { spaHeader->flags = 0; spaHeader->dts_offset = 0; @@ -508,7 +504,7 @@ void ScreenCastStream::recordCursor() struct spa_buffer *spa_buffer = m_pendingBuffer->buffer; spa_buffer->datas[0].chunk->size = 0; sendCursorData(Cursors::self()->currentCursor(), - (spa_meta_cursor *) spa_buffer_find_meta_data (spa_buffer, SPA_META_Cursor, sizeof (spa_meta_cursor))); + (spa_meta_cursor *)spa_buffer_find_meta_data(spa_buffer, SPA_META_Cursor, sizeof(spa_meta_cursor))); enqueue(); } @@ -555,8 +551,8 @@ void ScreenCastStream::enqueue() } spa_pod *ScreenCastStream::buildFormat(struct spa_pod_builder *b, enum spa_video_format format, struct spa_rectangle *resolution, - struct spa_fraction *defaultFramerate, struct spa_fraction *minFramerate, struct spa_fraction *maxFramerate, - uint64_t *modifiers, int modifierCount) + struct spa_fraction *defaultFramerate, struct spa_fraction *minFramerate, struct spa_fraction *maxFramerate, + uint64_t *modifiers, int modifierCount) { struct spa_pod_frame f[2]; int i, c; @@ -597,12 +593,12 @@ spa_pod *ScreenCastStream::buildFormat(struct spa_pod_builder *b, enum spa_video /* maximal framerate */ spa_pod_builder_add(b, SPA_FORMAT_VIDEO_maxFramerate, - SPA_POD_CHOICE_RANGE_Fraction( - SPA_POD_Fraction(maxFramerate), - SPA_POD_Fraction(minFramerate), - SPA_POD_Fraction(maxFramerate)), - 0); - return (spa_pod*)spa_pod_builder_pop(b, &f[0]); + SPA_POD_CHOICE_RANGE_Fraction( + SPA_POD_Fraction(maxFramerate), + SPA_POD_Fraction(minFramerate), + SPA_POD_Fraction(maxFramerate)), + 0); + return (spa_pod *)spa_pod_builder_pop(b, &f[0]); } QRect ScreenCastStream::cursorGeometry(Cursor *cursor) const @@ -636,18 +632,18 @@ void ScreenCastStream::sendCursorData(Cursor *cursor, spa_meta_cursor *spa_meta_ } m_cursor.lastKey = image.cacheKey(); - spa_meta_cursor->bitmap_offset = sizeof (struct spa_meta_cursor); + spa_meta_cursor->bitmap_offset = sizeof(struct spa_meta_cursor); - struct spa_meta_bitmap *spa_meta_bitmap = SPA_MEMBER (spa_meta_cursor, - spa_meta_cursor->bitmap_offset, - struct spa_meta_bitmap); + struct spa_meta_bitmap *spa_meta_bitmap = SPA_MEMBER(spa_meta_cursor, + spa_meta_cursor->bitmap_offset, + struct spa_meta_bitmap); spa_meta_bitmap->format = SPA_VIDEO_FORMAT_RGBA; spa_meta_bitmap->offset = sizeof(struct spa_meta_bitmap); spa_meta_bitmap->size.width = std::min(m_cursor.bitmapSize.width(), image.width()); spa_meta_bitmap->size.height = std::min(m_cursor.bitmapSize.height(), image.height()); spa_meta_bitmap->stride = spa_meta_bitmap->size.width * 4; - uint8_t *bitmap_data = SPA_MEMBER (spa_meta_bitmap, spa_meta_bitmap->offset, uint8_t); + uint8_t *bitmap_data = SPA_MEMBER(spa_meta_bitmap, spa_meta_bitmap->offset, uint8_t); QImage dest(bitmap_data, spa_meta_bitmap->size.width, spa_meta_bitmap->size.height, diff --git a/src/plugins/screencast/screencaststream.h b/src/plugins/screencast/screencaststream.h index 19dc747890..84b4c90517 100644 --- a/src/plugins/screencast/screencaststream.h +++ b/src/plugins/screencast/screencaststream.h @@ -9,6 +9,7 @@ #pragma once #include "config-kwin.h" + #include "kwinglobals.h" #include @@ -46,7 +47,8 @@ public: bool init(); uint framerate(); uint nodeId(); - QString error() const { + QString error() const + { return m_error; } @@ -61,7 +63,7 @@ public: void setCursorMode(KWaylandServer::ScreencastV1Interface::CursorMode mode, qreal scale, const QRect &viewport); public Q_SLOTS: - void recordCursor(); + void recordCursor(); Q_SIGNALS: void streamReady(quint32 nodeId); @@ -81,7 +83,7 @@ private: void newStreamParams(); void tryEnqueue(pw_buffer *buffer); void enqueue(); - spa_pod* buildFormat(struct spa_pod_builder *b, enum spa_video_format format, struct spa_rectangle *resolution, + spa_pod *buildFormat(struct spa_pod_builder *b, enum spa_video_format format, struct spa_rectangle *resolution, struct spa_fraction *defaultFramerate, struct spa_fraction *minFramerate, struct spa_fraction *maxFramerate, uint64_t *modifiers, int modifier_count); @@ -100,7 +102,8 @@ private: bool m_hasModifier = false; QString m_error; - struct { + struct + { KWaylandServer::ScreencastV1Interface::CursorMode mode = KWaylandServer::ScreencastV1Interface::Hidden; const QSize bitmapSize = QSize(256, 256); qreal scale = 1; diff --git a/src/plugins/screencast/screencastutils.h b/src/plugins/screencast/screencastutils.h index 8b1a9a6756..583e00baed 100644 --- a/src/plugins/screencast/screencastutils.h +++ b/src/plugins/screencast/screencastutils.h @@ -37,7 +37,7 @@ static void grabTexture(GLTexture *texture, QImage *image) texture->bind(); if (GLPlatform::instance()->isGLES()) { - glReadPixels(0, 0, image->width(), image->height(), image->hasAlphaChannel() ? GL_BGRA : GL_BGR, GL_UNSIGNED_BYTE, (GLvoid*)image->bits()); + glReadPixels(0, 0, image->width(), image->height(), image->hasAlphaChannel() ? GL_BGRA : GL_BGR, GL_UNSIGNED_BYTE, (GLvoid *)image->bits()); } else if (GLPlatform::instance()->glVersion() >= kVersionNumber(4, 5)) { glGetTextureImage(texture->texture(), 0, image->hasAlphaChannel() ? GL_BGRA : GL_BGR, GL_UNSIGNED_BYTE, image->sizeInBytes(), image->bits()); } else { diff --git a/src/plugins/windowsystem/windoweffects.cpp b/src/plugins/windowsystem/windoweffects.cpp index 60690cae36..e153c031b1 100644 --- a/src/plugins/windowsystem/windoweffects.cpp +++ b/src/plugins/windowsystem/windoweffects.cpp @@ -16,20 +16,23 @@ namespace KWin { WindowEffects::WindowEffects() - : QObject(), - KWindowEffectsPrivate() + : QObject() + , KWindowEffectsPrivate() { } WindowEffects::~WindowEffects() -{} +{ +} namespace { QWindow *findWindow(WId win) { const auto windows = qApp->allWindows(); - auto it = std::find_if(windows.begin(), windows.end(), [win] (QWindow *w) { return w->winId() == win; }); + auto it = std::find_if(windows.begin(), windows.end(), [win](QWindow *w) { + return w->winId() == win; + }); if (it == windows.end()) { return nullptr; } @@ -42,7 +45,7 @@ bool WindowEffects::isEffectAvailable(KWindowEffects::Effect effect) if (!effects) { return false; } - auto e = static_cast(effects); + auto e = static_cast(effects); switch (effect) { case KWindowEffects::BackgroundContrast: return e->isEffectLoaded(QStringLiteral("contrast")); diff --git a/src/plugins/windowsystem/windoweffects.h b/src/plugins/windowsystem/windoweffects.h index 1637eaa75b..bb2c60c202 100644 --- a/src/plugins/windowsystem/windoweffects.h +++ b/src/plugins/windowsystem/windoweffects.h @@ -5,8 +5,8 @@ */ #pragma once #include -#include #include +#include namespace KWin { diff --git a/src/plugins/windowsystem/windowsystem.cpp b/src/plugins/windowsystem/windowsystem.cpp index faea561561..9f36a68faf 100644 --- a/src/plugins/windowsystem/windowsystem.cpp +++ b/src/plugins/windowsystem/windowsystem.cpp @@ -247,7 +247,9 @@ void WindowSystem::setState(WId win, NET::States state) void WindowSystem::setType(WId win, NET::WindowType windowType) { const auto windows = qApp->allWindows(); - auto it = std::find_if(windows.begin(), windows.end(), [win] (QWindow *w) { return w->winId() == win; }); + auto it = std::find_if(windows.begin(), windows.end(), [win](QWindow *w) { + return w->winId() == win; + }); if (it == windows.end()) { return; } @@ -267,7 +269,7 @@ bool WindowSystem::showingDesktop() return false; } -QList< WId > WindowSystem::stackingOrder() +QList WindowSystem::stackingOrder() { // KWin should not use KWindowSystem for stacking order return {}; @@ -293,12 +295,12 @@ int WindowSystem::viewportWindowToDesktop(const QRect &r) return 0; } -QList< WId > WindowSystem::windows() +QList WindowSystem::windows() { return {}; } -QRect WindowSystem::workArea(const QList< WId > &excludes, int desktop) +QRect WindowSystem::workArea(const QList &excludes, int desktop) { Q_UNUSED(excludes) Q_UNUSED(desktop) diff --git a/src/pointer_input.cpp b/src/pointer_input.cpp index 5eb30e9d2f..8b4b3d428c 100644 --- a/src/pointer_input.cpp +++ b/src/pointer_input.cpp @@ -8,28 +8,30 @@ SPDX-License-Identifier: GPL-2.0-or-later */ -#include #include "pointer_input.h" + +#include + #include "abstract_output.h" -#include "platform.h" -#include "x11client.h" +#include "decorations/decoratedclient.h" #include "effects.h" #include "input_event.h" #include "input_event_spy.h" #include "osd.h" +#include "platform.h" #include "screens.h" #include "wayland_server.h" #include "workspace.h" -#include "decorations/decoratedclient.h" +#include "x11client.h" // KDecoration #include // KWayland -#include #include #include #include #include #include +#include #include // screenlocker #if KWIN_BUILD_SCREENLOCKER @@ -39,8 +41,8 @@ #include #include -#include #include +#include #include @@ -48,25 +50,25 @@ namespace KWin { static const QHash s_buttonToQtMouseButton = { - { BTN_LEFT , Qt::LeftButton }, - { BTN_MIDDLE , Qt::MiddleButton }, - { BTN_RIGHT , Qt::RightButton }, + {BTN_LEFT, Qt::LeftButton}, + {BTN_MIDDLE, Qt::MiddleButton}, + {BTN_RIGHT, Qt::RightButton}, // in QtWayland mapped like that - { BTN_SIDE , Qt::ExtraButton1 }, + {BTN_SIDE, Qt::ExtraButton1}, // in QtWayland mapped like that - { BTN_EXTRA , Qt::ExtraButton2 }, - { BTN_BACK , Qt::BackButton }, - { BTN_FORWARD , Qt::ForwardButton }, - { BTN_TASK , Qt::TaskButton }, + {BTN_EXTRA, Qt::ExtraButton2}, + {BTN_BACK, Qt::BackButton}, + {BTN_FORWARD, Qt::ForwardButton}, + {BTN_TASK, Qt::TaskButton}, // mapped like that in QtWayland - { 0x118 , Qt::ExtraButton6 }, - { 0x119 , Qt::ExtraButton7 }, - { 0x11a , Qt::ExtraButton8 }, - { 0x11b , Qt::ExtraButton9 }, - { 0x11c , Qt::ExtraButton10 }, - { 0x11d , Qt::ExtraButton11 }, - { 0x11e , Qt::ExtraButton12 }, - { 0x11f , Qt::ExtraButton13 }, + {0x118, Qt::ExtraButton6}, + {0x119, Qt::ExtraButton7}, + {0x11a, Qt::ExtraButton8}, + {0x11b, Qt::ExtraButton9}, + {0x11c, Qt::ExtraButton10}, + {0x11d, Qt::ExtraButton11}, + {0x11e, Qt::ExtraButton12}, + {0x11f, Qt::ExtraButton13}, }; uint32_t qtMouseButtonToButton(Qt::MouseButton button) @@ -100,11 +102,10 @@ static QPointF confineToBoundingBox(const QPointF &pos, const QRectF &boundingBo { return QPointF( qBound(boundingBox.left(), pos.x(), boundingBox.right() - 1.0), - qBound(boundingBox.top(), pos.y(), boundingBox.bottom() - 1.0) - ); + qBound(boundingBox.top(), pos.y(), boundingBox.bottom() - 1.0)); } -PointerInputRedirection::PointerInputRedirection(InputRedirection* parent) +PointerInputRedirection::PointerInputRedirection(InputRedirection *parent) : InputDeviceHandler(parent) , m_cursor(nullptr) { @@ -145,28 +146,28 @@ void PointerInputRedirection::init() connect(screens(), &Screens::changed, this, &PointerInputRedirection::updateAfterScreenChange); #if KWIN_BUILD_SCREENLOCKER if (waylandServer()->hasScreenLockerIntegration()) { - connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, - [this] { - if (waylandServer()->seat()->hasPointer()) { - waylandServer()->seat()->cancelPointerPinchGesture(); - waylandServer()->seat()->cancelPointerSwipeGesture(); - } - update(); + connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, [this]() { + if (waylandServer()->seat()->hasPointer()) { + waylandServer()->seat()->cancelPointerPinchGesture(); + waylandServer()->seat()->cancelPointerSwipeGesture(); } - ); + update(); + }); } #endif - connect(workspace(), &QObject::destroyed, this, [this] { setInited(false); }); - connect(waylandServer(), &QObject::destroyed, this, [this] { setInited(false); }); - connect(waylandServer()->seat(), &KWaylandServer::SeatInterface::dragEnded, this, - [this] { - // need to force a focused pointer change - setFocus(nullptr); - update(); - } - ); + connect(workspace(), &QObject::destroyed, this, [this] { + setInited(false); + }); + connect(waylandServer(), &QObject::destroyed, this, [this] { + setInited(false); + }); + connect(waylandServer()->seat(), &KWaylandServer::SeatInterface::dragEnded, this, [this]() { + // need to force a focused pointer change + setFocus(nullptr); + update(); + }); // connect the move resize of all window - auto setupMoveResizeConnection = [this] (AbstractClient *c) { + auto setupMoveResizeConnection = [this](AbstractClient *c) { connect(c, &AbstractClient::clientStartUserMovedResized, this, &PointerInputRedirection::updateOnStartMoveResize); connect(c, &AbstractClient::clientFinishUserMovedResized, this, &PointerInputRedirection::update); }; @@ -196,7 +197,7 @@ void PointerInputRedirection::updateToReset() setDecoration(nullptr); } if (focus()) { - if (AbstractClient *c = qobject_cast(focus())) { + if (AbstractClient *c = qobject_cast(focus())) { c->pointerLeaveEvent(); } disconnect(m_focusGeometryConnection); @@ -215,7 +216,8 @@ public: { s_counter++; } - ~PositionUpdateBlocker() { + ~PositionUpdateBlocker() + { s_counter--; if (s_counter == 0) { if (!s_scheduledPositions.isEmpty()) { @@ -225,17 +227,20 @@ public: } } - static bool isPositionBlocked() { + static bool isPositionBlocked() + { return s_counter > 0; } - static void schedulePosition(const QPointF &pos, const QSizeF &delta, const QSizeF &deltaNonAccelerated, uint32_t time, quint64 timeUsec) { + static void schedulePosition(const QPointF &pos, const QSizeF &delta, const QSizeF &deltaNonAccelerated, uint32_t time, quint64 timeUsec) + { s_scheduledPositions.append({pos, delta, deltaNonAccelerated, time, timeUsec}); } private: static int s_counter; - struct ScheduledPosition { + struct ScheduledPosition + { QPointF pos; QSizeF delta; QSizeF deltaNonAccelerated; @@ -321,7 +326,7 @@ void PointerInputRedirection::processButton(uint32_t button, InputRedirection::P } void PointerInputRedirection::processAxis(InputRedirection::PointerAxis axis, qreal delta, qint32 discreteDelta, - InputRedirection::PointerAxisSource source, uint32_t time, InputDevice *device) + InputRedirection::PointerAxisSource source, uint32_t time, InputDevice *device) { input()->setLastInputHandler(this); update(); @@ -329,8 +334,8 @@ void PointerInputRedirection::processAxis(InputRedirection::PointerAxis axis, qr Q_EMIT input()->pointerAxisChanged(axis, delta); WheelEvent wheelEvent(m_pos, delta, discreteDelta, - (axis == InputRedirection::PointerAxisHorizontal) ? Qt::Horizontal : Qt::Vertical, - m_qtButtons, input()->keyboardModifiers(), source, time, device); + (axis == InputRedirection::PointerAxisHorizontal) ? Qt::Horizontal : Qt::Vertical, + m_qtButtons, input()->keyboardModifiers(), source, time, device); wheelEvent.setModifiersRelevantForGlobalShortcuts(input()->modifiersRelevantForGlobalShortcuts()); input()->processSpies(std::bind(&InputEventSpy::wheelEvent, std::placeholders::_1, &wheelEvent)); @@ -532,22 +537,19 @@ void PointerInputRedirection::cleanupDecoration(Decoration::DecoratedClientImpl QCoreApplication::instance()->sendEvent(now->decoration(), &event); now->client()->processDecorationMove(pos.toPoint(), m_pos.toPoint()); - m_decorationGeometryConnection = connect(decoration()->client(), &AbstractClient::frameGeometryChanged, this, - [this] { + m_decorationGeometryConnection = connect( + decoration()->client(), &AbstractClient::frameGeometryChanged, this, [this]() { // ensure maximize button gets the leave event when maximizing/restore a window, see BUG 385140 const auto oldDeco = decoration(); update(); - if (oldDeco && - oldDeco == decoration() && - !decoration()->client()->isInteractiveMove() && - !decoration()->client()->isInteractiveResize() && - !areButtonsPressed()) { + if (oldDeco && oldDeco == decoration() && !decoration()->client()->isInteractiveMove() && !decoration()->client()->isInteractiveResize() && !areButtonsPressed()) { // position of window did not change, we need to send HoverMotion manually const QPointF p = m_pos - decoration()->client()->pos(); QHoverEvent event(QEvent::HoverMove, p, p); QCoreApplication::instance()->sendEvent(decoration()->decoration(), &event); } - }, Qt::QueuedConnection); + }, + Qt::QueuedConnection); // if our decoration gets destroyed whilst it has focus, we pass focus on to the same client m_decorationDestroyedConnection = connect(now, &QObject::destroyed, this, &PointerInputRedirection::update, Qt::QueuedConnection); @@ -555,7 +557,7 @@ void PointerInputRedirection::cleanupDecoration(Decoration::DecoratedClientImpl void PointerInputRedirection::focusUpdate(Toplevel *focusOld, Toplevel *focusNow) { - if (AbstractClient *ac = qobject_cast(focusOld)) { + if (AbstractClient *ac = qobject_cast(focusOld)) { ac->pointerLeaveEvent(); breakPointerConstraints(ac->surface()); disconnectPointerConstraintsConnection(); @@ -563,7 +565,7 @@ void PointerInputRedirection::focusUpdate(Toplevel *focusOld, Toplevel *focusNow disconnect(m_focusGeometryConnection); m_focusGeometryConnection = QMetaObject::Connection(); - if (AbstractClient *ac = qobject_cast(focusNow)) { + if (AbstractClient *ac = qobject_cast(focusNow)) { ac->pointerEnterEvent(m_pos.toPoint()); } @@ -575,24 +577,22 @@ void PointerInputRedirection::focusUpdate(Toplevel *focusOld, Toplevel *focusNow seat->notifyPointerEnter(focusNow->surface(), m_pos, focusNow->inputTransformation()); - m_focusGeometryConnection = connect(focusNow, &Toplevel::inputTransformationChanged, this, - [this] { - // TODO: why no assert possible? - if (!focus()) { - return; - } - // TODO: can we check on the client instead? - if (workspace()->moveResizeClient()) { - // don't update while moving - return; - } - auto seat = waylandServer()->seat(); - if (focus()->surface() != seat->focusedPointerSurface()) { - return; - } - seat->setFocusedPointerSurfaceTransformation(focus()->inputTransformation()); + m_focusGeometryConnection = connect(focusNow, &Toplevel::inputTransformationChanged, this, [this]() { + // TODO: why no assert possible? + if (!focus()) { + return; } - ); + // TODO: can we check on the client instead? + if (workspace()->moveResizeClient()) { + // don't update while moving + return; + } + auto seat = waylandServer()->seat(); + if (focus()->surface() != seat->focusedPointerSurface()) { + return; + } + seat->setFocusedPointerSurfaceTransformation(focus()->inputTransformation()); + }); m_constraintsConnection = connect(focusNow->surface(), &KWaylandServer::SurfaceInterface::pointerConstraintsChanged, this, &PointerInputRedirection::updatePointerConstraints); @@ -640,7 +640,7 @@ void PointerInputRedirection::disconnectPointerConstraintsConnection() m_constraintsActivatedConnection = QMetaObject::Connection(); } -template +template static QRegion getConstraintRegion(Toplevel *t, T *constraint) { const QRegion windowShape = t->inputShape(); @@ -687,28 +687,26 @@ void PointerInputRedirection::updatePointerConstraints() if (canConstrain && r.contains(m_pos.toPoint())) { cf->setConfined(true); m_confined = true; - m_confinedPointerRegionConnection = connect(cf, &KWaylandServer::ConfinedPointerV1Interface::regionChanged, this, - [this] { - if (!focus()) { - return; - } - const auto s = focus()->surface(); - if (!s) { - return; - } - const auto cf = s->confinedPointer(); - if (!getConstraintRegion(focus(), cf).contains(m_pos.toPoint())) { - // pointer no longer in confined region, break the confinement - cf->setConfined(false); - m_confined = false; - } else { - if (!cf->isConfined()) { - cf->setConfined(true); - m_confined = true; - } + m_confinedPointerRegionConnection = connect(cf, &KWaylandServer::ConfinedPointerV1Interface::regionChanged, this, [this]() { + if (!focus()) { + return; + } + const auto s = focus()->surface(); + if (!s) { + return; + } + const auto cf = s->confinedPointer(); + if (!getConstraintRegion(focus(), cf).contains(m_pos.toPoint())) { + // pointer no longer in confined region, break the confinement + cf->setConfined(false); + m_confined = false; + } else { + if (!cf->isConfined()) { + cf->setConfined(true); + m_confined = true; } } - ); + }); return; } } else { @@ -723,7 +721,7 @@ void PointerInputRedirection::updatePointerConstraints() lock->setLocked(false); m_locked = false; disconnectLockedPointerAboutToBeUnboundConnection(); - if (! (hint.x() < 0 || hint.y() < 0) && focus()) { + if (!(hint.x() < 0 || hint.y() < 0) && focus()) { processMotionAbsolute(focus()->mapFromLocal(hint), waylandServer()->seat()->timestamp()); } } @@ -736,21 +734,18 @@ void PointerInputRedirection::updatePointerConstraints() // The client might cancel pointer locking from its side by unbinding the LockedPointerInterface. // In this case the cached cursor position hint must be fetched before the resource goes away - m_lockedPointerAboutToBeUnboundConnection = connect(lock, &KWaylandServer::LockedPointerV1Interface::aboutToBeDestroyed, this, - [this, lock]() { - const auto hint = lock->cursorPositionHint(); - if (hint.x() < 0 || hint.y() < 0 || !focus()) { - return; - } - auto globalHint = focus()->mapFromLocal(hint); - - // When the resource finally goes away, reposition the cursor according to the hint - connect(lock, &KWaylandServer::LockedPointerV1Interface::destroyed, this, - [this, globalHint]() { - processMotionAbsolute(globalHint, waylandServer()->seat()->timestamp()); - }); + m_lockedPointerAboutToBeUnboundConnection = connect(lock, &KWaylandServer::LockedPointerV1Interface::aboutToBeDestroyed, this, [this, lock]() { + const auto hint = lock->cursorPositionHint(); + if (hint.x() < 0 || hint.y() < 0 || !focus()) { + return; } - ); + auto globalHint = focus()->mapFromLocal(hint); + + // When the resource finally goes away, reposition the cursor according to the hint + connect(lock, &KWaylandServer::LockedPointerV1Interface::destroyed, this, [this, globalHint]() { + processMotionAbsolute(globalHint, waylandServer()->seat()->timestamp()); + }); + }); // TODO: connect to region change - is it needed at all? If the pointer is locked it's always in the region } } else { @@ -946,12 +941,10 @@ CursorImage::CursorImage(PointerInputRedirection *parent) connect(waylandServer()->seat(), &KWaylandServer::SeatInterface::hasPointerChanged, this, &CursorImage::handlePointerChanged); connect(waylandServer()->seat(), &KWaylandServer::SeatInterface::dragStarted, this, &CursorImage::updateDrag); - connect(waylandServer()->seat(), &KWaylandServer::SeatInterface::dragEnded, this, - [this] { - disconnect(m_drag.connection); - reevaluteSource(); - } - ); + connect(waylandServer()->seat(), &KWaylandServer::SeatInterface::dragEnded, this, [this]() { + disconnect(m_drag.connection); + reevaluteSource(); + }); #if KWIN_BUILD_SCREENLOCKER if (waylandServer()->hasScreenLockerIntegration()) { connect(ScreenLocker::KSldApp::self(), &ScreenLocker::KSldApp::lockStateChanged, this, &CursorImage::reevaluteSource); @@ -959,7 +952,7 @@ CursorImage::CursorImage(PointerInputRedirection *parent) #endif connect(m_pointer, &PointerInputRedirection::decorationChanged, this, &CursorImage::updateDecoration); // connect the move resize of all window - auto setupMoveResizeConnection = [this] (AbstractClient *c) { + auto setupMoveResizeConnection = [this](AbstractClient *c) { connect(c, &AbstractClient::moveResizedChanged, this, &CursorImage::updateMoveResize); connect(c, &AbstractClient::moveResizeCursorChanged, this, &CursorImage::updateMoveResize); }; @@ -989,8 +982,8 @@ void CursorImage::markAsRendered(std::chrono::milliseconds timestamp) } } if (m_currentSource != CursorSource::LockScreen - && m_currentSource != CursorSource::PointerSurface - && m_currentSource != CursorSource::DragAndDrop) { + && m_currentSource != CursorSource::PointerSurface + && m_currentSource != CursorSource::DragAndDrop) { return; } auto p = waylandServer()->seat()->pointer(); @@ -1339,7 +1332,7 @@ void CursorImage::reevaluteSource() setSource(CursorSource::WindowSelector); return; } - if (effects && static_cast(effects)->isMouseInterception()) { + if (effects && static_cast(effects)->isMouseInterception()) { setSource(CursorSource::EffectsOverride); return; } @@ -1449,7 +1442,7 @@ void InputRedirectionCursor::slotPosChanged(const QPointF &pos) const QPoint oldPos = currentPos(); updatePos(pos.toPoint()); Q_EMIT mouseChanged(pos.toPoint(), oldPos, m_currentButtons, m_currentButtons, - input()->keyboardModifiers(), input()->keyboardModifiers()); + input()->keyboardModifiers(), input()->keyboardModifiers()); } void InputRedirectionCursor::slotModifiersChanged(Qt::KeyboardModifiers mods, Qt::KeyboardModifiers oldMods) diff --git a/src/pointer_input.h b/src/pointer_input.h index 558273e126..5b7c53f578 100644 --- a/src/pointer_input.h +++ b/src/pointer_input.h @@ -11,14 +11,14 @@ #ifndef KWIN_POINTER_INPUT_H #define KWIN_POINTER_INPUT_H -#include "input.h" #include "cursor.h" +#include "input.h" #include "xcursortheme.h" #include #include -#include #include +#include class QWindow; @@ -55,10 +55,12 @@ public: bool supportsWarping() const; void warp(const QPointF &pos); - QPointF pos() const { + QPointF pos() const + { return m_pos; } - Qt::MouseButtons buttons() const { + Qt::MouseButtons buttons() const + { return m_qtButtons; } bool areButtonsPressed() const; @@ -73,7 +75,8 @@ public: void setEnableConstraints(bool set); - bool isConstrained() const { + bool isConstrained() const + { return m_confined || m_locked; } @@ -180,7 +183,8 @@ class WaylandCursorImage : public QObject public: explicit WaylandCursorImage(QObject *parent = nullptr); - struct Image { + struct Image + { QImage image; QPoint hotspot; }; @@ -255,11 +259,13 @@ private: WaylandCursorImage::Image m_fallbackCursor; WaylandCursorImage::Image m_moveResizeCursor; WaylandCursorImage::Image m_windowSelectionCursor; - struct { + struct + { WaylandCursorImage::Image cursor; QMetaObject::Connection connection; } m_drag; - struct { + struct + { QMetaObject::Connection connection; WaylandCursorImage::Image cursor; } m_serverCursor; @@ -276,6 +282,7 @@ class InputRedirectionCursor : public KWin::Cursor public: explicit InputRedirectionCursor(QObject *parent); ~InputRedirectionCursor() override; + protected: void doSetPos() override; void doStartCursorTracking() override; @@ -284,6 +291,7 @@ private Q_SLOTS: void slotPosChanged(const QPointF &pos); void slotPointerButtonChanged(); void slotModifiersChanged(Qt::KeyboardModifiers mods, Qt::KeyboardModifiers oldMods); + private: Qt::MouseButtons m_currentButtons; }; diff --git a/src/popup_input_filter.cpp b/src/popup_input_filter.cpp index 3bfbcdb061..8a34fd0f31 100644 --- a/src/popup_input_filter.cpp +++ b/src/popup_input_filter.cpp @@ -48,8 +48,8 @@ bool PopupInputFilter::pointerEvent(QMouseEvent *event, quint32 nativeButton) return false; } if (event->type() == QMouseEvent::MouseButtonPress) { - auto pointerFocus = qobject_cast(input()->findToplevel(event->globalPos())); - if (!pointerFocus || !AbstractClient::belongToSameApplication(pointerFocus, qobject_cast(m_popupClients.constLast()))) { + auto pointerFocus = qobject_cast(input()->findToplevel(event->globalPos())); + if (!pointerFocus || !AbstractClient::belongToSameApplication(pointerFocus, qobject_cast(m_popupClients.constLast()))) { // a press on a window (or no window) not belonging to the popup window cancelPopups(); // filter out this press @@ -96,8 +96,8 @@ bool PopupInputFilter::touchDown(qint32 id, const QPointF &pos, quint32 time) if (m_popupClients.isEmpty()) { return false; } - auto pointerFocus = qobject_cast(input()->findToplevel(pos.toPoint())); - if (!pointerFocus || !AbstractClient::belongToSameApplication(pointerFocus, qobject_cast(m_popupClients.constLast()))) { + auto pointerFocus = qobject_cast(input()->findToplevel(pos.toPoint())); + if (!pointerFocus || !AbstractClient::belongToSameApplication(pointerFocus, qobject_cast(m_popupClients.constLast()))) { // a touch on a window (or no window) not belonging to the popup window cancelPopups(); // filter out this touch diff --git a/src/popup_input_filter.h b/src/popup_input_filter.h index 7356ee595a..cf5fcf34b5 100644 --- a/src/popup_input_filter.h +++ b/src/popup_input_filter.h @@ -24,13 +24,14 @@ public: bool pointerEvent(QMouseEvent *event, quint32 nativeButton) override; bool keyEvent(QKeyEvent *event) override; bool touchDown(qint32 id, const QPointF &pos, quint32 time) override; + private: void handleClientAdded(Toplevel *client); void handleClientRemoved(Toplevel *client); void disconnectClient(Toplevel *client); void cancelPopups(); - QVector m_popupClients; + QVector m_popupClients; }; } diff --git a/src/renderloop.cpp b/src/renderloop.cpp index 90cbbf1057..2f00393fa5 100644 --- a/src/renderloop.cpp +++ b/src/renderloop.cpp @@ -13,7 +13,7 @@ namespace KWin { -template +template T alignTimestamp(const T ×tamp, const T &alignment) { return timestamp + ((alignment - (timestamp % alignment)) % alignment); @@ -28,7 +28,9 @@ RenderLoopPrivate::RenderLoopPrivate(RenderLoop *q) : q(q) { compositeTimer.setSingleShot(true); - QObject::connect(&compositeTimer, &QTimer::timeout, q, [this]() { dispatch(); }); + QObject::connect(&compositeTimer, &QTimer::timeout, q, [this]() { + dispatch(); + }); } void RenderLoopPrivate::scheduleRepaint() @@ -48,7 +50,7 @@ void RenderLoopPrivate::scheduleRepaint() nextPresentationTimestamp = lastPresentationTimestamp + vblankInterval; if (nextPresentationTimestamp < currentTime && presentMode == SyncMode::Fixed) { nextPresentationTimestamp = lastPresentationTimestamp - + alignTimestamp(currentTime - lastPresentationTimestamp, vblankInterval); + + alignTimestamp(currentTime - lastPresentationTimestamp, vblankInterval); } // Estimate when it's a good time to perform the next compositing cycle. diff --git a/src/renderloop_p.h b/src/renderloop_p.h index 224885bc0b..7975dbc93e 100644 --- a/src/renderloop_p.h +++ b/src/renderloop_p.h @@ -6,8 +6,8 @@ #pragma once -#include "renderloop.h" #include "renderjournal.h" +#include "renderloop.h" #include diff --git a/src/rules.cpp b/src/rules.cpp index 38bcd04ba2..fd593b776b 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -9,27 +9,27 @@ #include "rules.h" -#include #include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include #ifndef KCMRULES -#include "x11client.h" #include "client_machine.h" #include "main.h" #include "platform.h" #include "screens.h" #include "virtualdesktops.h" #include "workspace.h" +#include "x11client.h" #endif -#include "rulesettings.h" #include "rulebooksettings.h" +#include "rulesettings.h" namespace KWin { @@ -81,7 +81,7 @@ Rules::Rules() { } -Rules::Rules(const QString& str, bool temporary) +Rules::Rules(const QString &str, bool temporary) : temporary_state(temporary ? 2 : 0) { QTemporaryFile file; @@ -98,7 +98,7 @@ Rules::Rules(const QString& str, bool temporary) } #define READ_MATCH_STRING(var, func) \ - var = settings->var() func; \ + var = settings->var() func; \ var##match = static_cast(settings->var##match()) #define READ_SET_RULE(var) \ @@ -106,10 +106,9 @@ Rules::Rules(const QString& str, bool temporary) var##rule = static_cast(settings->var##rule()) #define READ_FORCE_RULE(var, func) \ - var = func(settings->var()); \ + var = func(settings->var()); \ var##rule = convertForceRule(settings->var##rule()) - Rules::Rules(const RuleSettings *settings) : temporary_state(0) { @@ -125,22 +124,22 @@ void Rules::readFromSettings(const RuleSettings *settings) READ_MATCH_STRING(wmclass, .toLower().toLatin1()); wmclasscomplete = settings->wmclasscomplete(); READ_MATCH_STRING(windowrole, .toLower().toLatin1()); - READ_MATCH_STRING(title,); + READ_MATCH_STRING(title, ); READ_MATCH_STRING(clientmachine, .toLower().toLatin1()); types = NET::WindowTypeMask(settings->types()); - READ_FORCE_RULE(placement,); + READ_FORCE_RULE(placement, ); READ_SET_RULE(position); READ_SET_RULE(size); if (size.isEmpty() && sizerule != static_cast(Remember)) sizerule = UnusedSetRule; - READ_FORCE_RULE(minsize,); + READ_FORCE_RULE(minsize, ); if (!minsize.isValid()) minsize = QSize(1, 1); - READ_FORCE_RULE(maxsize,); + READ_FORCE_RULE(maxsize, ); if (maxsize.isEmpty()) maxsize = QSize(32767, 32767); - READ_FORCE_RULE(opacityactive,); - READ_FORCE_RULE(opacityinactive,); + READ_FORCE_RULE(opacityactive, ); + READ_FORCE_RULE(opacityinactive, ); READ_SET_RULE(ignoregeometry); READ_SET_RULE(desktops); READ_SET_RULE(screen); @@ -164,17 +163,17 @@ void Rules::readFromSettings(const RuleSettings *settings) if (decocolor.isEmpty()) decocolorrule = UnusedForceRule; - READ_FORCE_RULE(blockcompositing,); - READ_FORCE_RULE(fsplevel,); - READ_FORCE_RULE(fpplevel,); - READ_FORCE_RULE(acceptfocus,); - READ_FORCE_RULE(closeable,); - READ_FORCE_RULE(autogroup,); - READ_FORCE_RULE(autogroupfg,); - READ_FORCE_RULE(autogroupid,); - READ_FORCE_RULE(strictgeometry,); + READ_FORCE_RULE(blockcompositing, ); + READ_FORCE_RULE(fsplevel, ); + READ_FORCE_RULE(fpplevel, ); + READ_FORCE_RULE(acceptfocus, ); + READ_FORCE_RULE(closeable, ); + READ_FORCE_RULE(autogroup, ); + READ_FORCE_RULE(autogroupfg, ); + READ_FORCE_RULE(autogroupid, ); + READ_FORCE_RULE(strictgeometry, ); READ_SET_RULE(shortcut); - READ_FORCE_RULE(disableglobalshortcuts,); + READ_FORCE_RULE(disableglobalshortcuts, ); READ_SET_RULE(desktopfile); } @@ -184,24 +183,21 @@ void Rules::readFromSettings(const RuleSettings *settings) #undef READ_FORCE_RULE2 #define WRITE_MATCH_STRING(var, capital, force) \ - settings->set##capital##match(var##match); \ - if (!var.isEmpty() || force) \ - { \ - settings->set##capital(var); \ + settings->set##capital##match(var##match); \ + if (!var.isEmpty() || force) { \ + settings->set##capital(var); \ } -#define WRITE_SET_RULE(var, capital, func) \ +#define WRITE_SET_RULE(var, capital, func) \ settings->set##capital##rule(var##rule); \ - if (var##rule != UnusedSetRule) \ - { \ - settings->set##capital(func(var)); \ + if (var##rule != UnusedSetRule) { \ + settings->set##capital(func(var)); \ } #define WRITE_FORCE_RULE(var, capital, func) \ settings->set##capital##rule(var##rule); \ - if ( var##rule != UnusedForceRule ) \ - { \ - settings->set##capital(func(var)); \ + if (var##rule != UnusedForceRule) { \ + settings->set##capital(func(var)); \ } void Rules::write(RuleSettings *settings) const @@ -214,29 +210,29 @@ void Rules::write(RuleSettings *settings) const WRITE_MATCH_STRING(title, Title, false); WRITE_MATCH_STRING(clientmachine, Clientmachine, false); settings->setTypes(types); - WRITE_FORCE_RULE(placement, Placement,); - WRITE_SET_RULE(position, Position,); - WRITE_SET_RULE(size, Size,); - WRITE_FORCE_RULE(minsize, Minsize,); - WRITE_FORCE_RULE(maxsize, Maxsize,); - WRITE_FORCE_RULE(opacityactive, Opacityactive,); - WRITE_FORCE_RULE(opacityinactive, Opacityinactive,); - WRITE_SET_RULE(ignoregeometry, Ignoregeometry,); - WRITE_SET_RULE(desktops, Desktops,); - WRITE_SET_RULE(screen, Screen,); - WRITE_SET_RULE(activity, Activity,); - WRITE_FORCE_RULE(type, Type,); - WRITE_SET_RULE(maximizevert, Maximizevert,); - WRITE_SET_RULE(maximizehoriz, Maximizehoriz,); - WRITE_SET_RULE(minimize, Minimize,); - WRITE_SET_RULE(shade, Shade,); - WRITE_SET_RULE(skiptaskbar, Skiptaskbar,); - WRITE_SET_RULE(skippager, Skippager,); - WRITE_SET_RULE(skipswitcher, Skipswitcher,); - WRITE_SET_RULE(above, Above,); - WRITE_SET_RULE(below, Below,); - WRITE_SET_RULE(fullscreen, Fullscreen,); - WRITE_SET_RULE(noborder, Noborder,); + WRITE_FORCE_RULE(placement, Placement, ); + WRITE_SET_RULE(position, Position, ); + WRITE_SET_RULE(size, Size, ); + WRITE_FORCE_RULE(minsize, Minsize, ); + WRITE_FORCE_RULE(maxsize, Maxsize, ); + WRITE_FORCE_RULE(opacityactive, Opacityactive, ); + WRITE_FORCE_RULE(opacityinactive, Opacityinactive, ); + WRITE_SET_RULE(ignoregeometry, Ignoregeometry, ); + WRITE_SET_RULE(desktops, Desktops, ); + WRITE_SET_RULE(screen, Screen, ); + WRITE_SET_RULE(activity, Activity, ); + WRITE_FORCE_RULE(type, Type, ); + WRITE_SET_RULE(maximizevert, Maximizevert, ); + WRITE_SET_RULE(maximizehoriz, Maximizehoriz, ); + WRITE_SET_RULE(minimize, Minimize, ); + WRITE_SET_RULE(shade, Shade, ); + WRITE_SET_RULE(skiptaskbar, Skiptaskbar, ); + WRITE_SET_RULE(skippager, Skippager, ); + WRITE_SET_RULE(skipswitcher, Skipswitcher, ); + WRITE_SET_RULE(above, Above, ); + WRITE_SET_RULE(below, Below, ); + WRITE_SET_RULE(fullscreen, Fullscreen, ); + WRITE_SET_RULE(noborder, Noborder, ); auto colorToString = [](const QString &value) -> QString { if (value.endsWith(QLatin1String(".colors"))) { return QFileInfo(value).baseName(); @@ -245,18 +241,18 @@ void Rules::write(RuleSettings *settings) const } }; WRITE_FORCE_RULE(decocolor, Decocolor, colorToString); - WRITE_FORCE_RULE(blockcompositing, Blockcompositing,); - WRITE_FORCE_RULE(fsplevel, Fsplevel,); - WRITE_FORCE_RULE(fpplevel, Fpplevel,); - WRITE_FORCE_RULE(acceptfocus, Acceptfocus,); - WRITE_FORCE_RULE(closeable, Closeable,); - WRITE_FORCE_RULE(autogroup, Autogroup,); - WRITE_FORCE_RULE(autogroupfg, Autogroupfg,); - WRITE_FORCE_RULE(autogroupid, Autogroupid,); - WRITE_FORCE_RULE(strictgeometry, Strictgeometry,); - WRITE_SET_RULE(shortcut, Shortcut,); - WRITE_FORCE_RULE(disableglobalshortcuts, Disableglobalshortcuts,); - WRITE_SET_RULE(desktopfile, Desktopfile,); + WRITE_FORCE_RULE(blockcompositing, Blockcompositing, ); + WRITE_FORCE_RULE(fsplevel, Fsplevel, ); + WRITE_FORCE_RULE(fpplevel, Fpplevel, ); + WRITE_FORCE_RULE(acceptfocus, Acceptfocus, ); + WRITE_FORCE_RULE(closeable, Closeable, ); + WRITE_FORCE_RULE(autogroup, Autogroup, ); + WRITE_FORCE_RULE(autogroupfg, Autogroupfg, ); + WRITE_FORCE_RULE(autogroupid, Autogroupid, ); + WRITE_FORCE_RULE(strictgeometry, Strictgeometry, ); + WRITE_SET_RULE(shortcut, Shortcut, ); + WRITE_FORCE_RULE(disableglobalshortcuts, Disableglobalshortcuts, ); + WRITE_SET_RULE(desktopfile, Desktopfile, ); } #undef WRITE_MATCH_STRING @@ -266,42 +262,42 @@ void Rules::write(RuleSettings *settings) const // returns true if it doesn't affect anything bool Rules::isEmpty() const { - return(placementrule == UnusedForceRule - && positionrule == UnusedSetRule - && sizerule == UnusedSetRule - && minsizerule == UnusedForceRule - && maxsizerule == UnusedForceRule - && opacityactiverule == UnusedForceRule - && opacityinactiverule == UnusedForceRule - && ignoregeometryrule == UnusedSetRule - && desktopsrule == UnusedSetRule - && screenrule == UnusedSetRule - && activityrule == UnusedSetRule - && typerule == UnusedForceRule - && maximizevertrule == UnusedSetRule - && maximizehorizrule == UnusedSetRule - && minimizerule == UnusedSetRule - && shaderule == UnusedSetRule - && skiptaskbarrule == UnusedSetRule - && skippagerrule == UnusedSetRule - && skipswitcherrule == UnusedSetRule - && aboverule == UnusedSetRule - && belowrule == UnusedSetRule - && fullscreenrule == UnusedSetRule - && noborderrule == UnusedSetRule - && decocolorrule == UnusedForceRule - && blockcompositingrule == UnusedForceRule - && fsplevelrule == UnusedForceRule - && fpplevelrule == UnusedForceRule - && acceptfocusrule == UnusedForceRule - && closeablerule == UnusedForceRule - && autogrouprule == UnusedForceRule - && autogroupfgrule == UnusedForceRule - && autogroupidrule == UnusedForceRule - && strictgeometryrule == UnusedForceRule - && shortcutrule == UnusedSetRule - && disableglobalshortcutsrule == UnusedForceRule - && desktopfilerule == UnusedSetRule); + return (placementrule == UnusedForceRule + && positionrule == UnusedSetRule + && sizerule == UnusedSetRule + && minsizerule == UnusedForceRule + && maxsizerule == UnusedForceRule + && opacityactiverule == UnusedForceRule + && opacityinactiverule == UnusedForceRule + && ignoregeometryrule == UnusedSetRule + && desktopsrule == UnusedSetRule + && screenrule == UnusedSetRule + && activityrule == UnusedSetRule + && typerule == UnusedForceRule + && maximizevertrule == UnusedSetRule + && maximizehorizrule == UnusedSetRule + && minimizerule == UnusedSetRule + && shaderule == UnusedSetRule + && skiptaskbarrule == UnusedSetRule + && skippagerrule == UnusedSetRule + && skipswitcherrule == UnusedSetRule + && aboverule == UnusedSetRule + && belowrule == UnusedSetRule + && fullscreenrule == UnusedSetRule + && noborderrule == UnusedSetRule + && decocolorrule == UnusedForceRule + && blockcompositingrule == UnusedForceRule + && fsplevelrule == UnusedForceRule + && fpplevelrule == UnusedForceRule + && acceptfocusrule == UnusedForceRule + && closeablerule == UnusedForceRule + && autogrouprule == UnusedForceRule + && autogroupfgrule == UnusedForceRule + && autogroupidrule == UnusedForceRule + && strictgeometryrule == UnusedForceRule + && shortcutrule == UnusedSetRule + && disableglobalshortcutsrule == UnusedForceRule + && desktopfilerule == UnusedSetRule); } Rules::ForceRule Rules::convertForceRule(int v) @@ -332,12 +328,13 @@ bool Rules::matchType(NET::WindowType match_type) const return true; } -bool Rules::matchWMClass(const QByteArray& match_class, const QByteArray& match_name) const +bool Rules::matchWMClass(const QByteArray &match_class, const QByteArray &match_name) const { if (wmclassmatch != UnimportantMatch) { // TODO optimize? QByteArray cwmclass = wmclasscomplete - ? match_name + ' ' + match_class : match_class; + ? match_name + ' ' + match_class + : match_class; if (wmclassmatch == RegExpMatch && !QRegularExpression(QString::fromUtf8(wmclass)).match(QString::fromUtf8(cwmclass)).hasMatch()) return false; if (wmclassmatch == ExactMatch && wmclass != cwmclass) @@ -348,7 +345,7 @@ bool Rules::matchWMClass(const QByteArray& match_class, const QByteArray& match_ return true; } -bool Rules::matchRole(const QByteArray& match_role) const +bool Rules::matchRole(const QByteArray &match_role) const { if (windowrolematch != UnimportantMatch) { if (windowrolematch == RegExpMatch && !QRegularExpression(QString::fromUtf8(windowrole)).match(QString::fromUtf8(match_role)).hasMatch()) @@ -361,7 +358,7 @@ bool Rules::matchRole(const QByteArray& match_role) const return true; } -bool Rules::matchTitle(const QString& match_title) const +bool Rules::matchTitle(const QString &match_title) const { if (titlematch != UnimportantMatch) { if (titlematch == RegExpMatch && !QRegularExpression(title).match(match_title).hasMatch()) @@ -374,28 +371,28 @@ bool Rules::matchTitle(const QString& match_title) const return true; } -bool Rules::matchClientMachine(const QByteArray& match_machine, bool local) const +bool Rules::matchClientMachine(const QByteArray &match_machine, bool local) const { if (clientmachinematch != UnimportantMatch) { // if it's localhost, check also "localhost" before checking hostname if (match_machine != "localhost" && local - && matchClientMachine("localhost", true)) + && matchClientMachine("localhost", true)) return true; if (clientmachinematch == RegExpMatch - && !QRegularExpression(QString::fromUtf8(clientmachine)).match(QString::fromUtf8(match_machine)).hasMatch()) + && !QRegularExpression(QString::fromUtf8(clientmachine)).match(QString::fromUtf8(match_machine)).hasMatch()) return false; if (clientmachinematch == ExactMatch - && clientmachine != match_machine) + && clientmachine != match_machine) return false; if (clientmachinematch == SubstringMatch - && !match_machine.contains(clientmachine)) + && !match_machine.contains(clientmachine)) return false; } return true; } #ifndef KCMRULES -bool Rules::match(const AbstractClient* c) const +bool Rules::match(const AbstractClient *c) const { if (!matchType(c->windowType(true))) return false; @@ -409,7 +406,7 @@ bool Rules::match(const AbstractClient* c) const QObject::connect(c, &AbstractClient::captionChanged, c, &AbstractClient::evaluateWindowRules, // QueuedConnection, because title may change before // the client is ready (could segfault!) - static_cast(Qt::QueuedConnection|Qt::UniqueConnection)); + static_cast(Qt::QueuedConnection | Qt::UniqueConnection)); if (!matchTitle(c->captionNormal())) return false; return true; @@ -417,11 +414,11 @@ bool Rules::match(const AbstractClient* c) const #define NOW_REMEMBER(_T_, _V_) ((selection & _T_) && (_V_##rule == (SetRule)Remember)) -bool Rules::update(AbstractClient* c, int selection) +bool Rules::update(AbstractClient *c, int selection) { // TODO check this setting is for this client ? bool updated = false; - if NOW_REMEMBER(Position, position) { + if NOW_REMEMBER (Position, position) { if (!c->isFullScreen()) { QPoint new_pos = position; // don't use the position in the direction which is maximized @@ -433,7 +430,7 @@ bool Rules::update(AbstractClient* c, int selection) position = new_pos; } } - if NOW_REMEMBER(Size, size) { + if NOW_REMEMBER (Size, size) { if (!c->isFullScreen()) { QSize new_size = size; // don't use the position in the direction which is maximized @@ -445,63 +442,63 @@ bool Rules::update(AbstractClient* c, int selection) size = new_size; } } - if NOW_REMEMBER(Desktops, desktops) { + if NOW_REMEMBER (Desktops, desktops) { updated = updated || desktops != c->desktopIds(); desktops = c->desktopIds(); } - if NOW_REMEMBER(Screen, screen) { + if NOW_REMEMBER (Screen, screen) { updated = updated || screen != c->screen(); screen = c->screen(); } - if NOW_REMEMBER(Activity, activity) { + if NOW_REMEMBER (Activity, activity) { updated = updated || activity != c->activities(); activity = c->activities(); } - if NOW_REMEMBER(MaximizeVert, maximizevert) { + if NOW_REMEMBER (MaximizeVert, maximizevert) { updated = updated || maximizevert != bool(c->maximizeMode() & MaximizeVertical); maximizevert = c->maximizeMode() & MaximizeVertical; } - if NOW_REMEMBER(MaximizeHoriz, maximizehoriz) { + if NOW_REMEMBER (MaximizeHoriz, maximizehoriz) { updated = updated || maximizehoriz != bool(c->maximizeMode() & MaximizeHorizontal); maximizehoriz = c->maximizeMode() & MaximizeHorizontal; } - if NOW_REMEMBER(Minimize, minimize) { + if NOW_REMEMBER (Minimize, minimize) { updated = updated || minimize != c->isMinimized(); minimize = c->isMinimized(); } - if NOW_REMEMBER(Shade, shade) { + if NOW_REMEMBER (Shade, shade) { updated = updated || (shade != (c->shadeMode() != ShadeNone)); shade = c->shadeMode() != ShadeNone; } - if NOW_REMEMBER(SkipTaskbar, skiptaskbar) { + if NOW_REMEMBER (SkipTaskbar, skiptaskbar) { updated = updated || skiptaskbar != c->skipTaskbar(); skiptaskbar = c->skipTaskbar(); } - if NOW_REMEMBER(SkipPager, skippager) { + if NOW_REMEMBER (SkipPager, skippager) { updated = updated || skippager != c->skipPager(); skippager = c->skipPager(); } - if NOW_REMEMBER(SkipSwitcher, skipswitcher) { + if NOW_REMEMBER (SkipSwitcher, skipswitcher) { updated = updated || skipswitcher != c->skipSwitcher(); skipswitcher = c->skipSwitcher(); } - if NOW_REMEMBER(Above, above) { + if NOW_REMEMBER (Above, above) { updated = updated || above != c->keepAbove(); above = c->keepAbove(); } - if NOW_REMEMBER(Below, below) { + if NOW_REMEMBER (Below, below) { updated = updated || below != c->keepBelow(); below = c->keepBelow(); } - if NOW_REMEMBER(Fullscreen, fullscreen) { + if NOW_REMEMBER (Fullscreen, fullscreen) { updated = updated || fullscreen != c->isFullScreen(); fullscreen = c->isFullScreen(); } - if NOW_REMEMBER(NoBorder, noborder) { + if NOW_REMEMBER (NoBorder, noborder) { updated = updated || noborder != c->noBorder(); noborder = c->noBorder(); } - if NOW_REMEMBER(DesktopFile, desktopfile) { + if NOW_REMEMBER (DesktopFile, desktopfile) { updated = updated || desktopfile != c->desktopFileName(); desktopfile = c->desktopFileName(); } @@ -510,25 +507,25 @@ bool Rules::update(AbstractClient* c, int selection) #undef NOW_REMEMBER -#define APPLY_RULE( var, name, type ) \ - bool Rules::apply##name( type& arg, bool init ) const \ - { \ - if ( checkSetRule( var##rule, init )) \ - arg = this->var; \ - return checkSetStop( var##rule ); \ +#define APPLY_RULE(var, name, type) \ + bool Rules::apply##name(type &arg, bool init) const \ + { \ + if (checkSetRule(var##rule, init)) \ + arg = this->var; \ + return checkSetStop(var##rule); \ } -#define APPLY_FORCE_RULE( var, name, type ) \ - bool Rules::apply##name( type& arg ) const \ - { \ - if ( checkForceRule( var##rule )) \ - arg = this->var; \ - return checkForceStop( var##rule ); \ +#define APPLY_FORCE_RULE(var, name, type) \ + bool Rules::apply##name(type &arg) const \ + { \ + if (checkForceRule(var##rule)) \ + arg = this->var; \ + return checkForceStop(var##rule); \ } APPLY_FORCE_RULE(placement, Placement, Placement::Policy) -bool Rules::applyGeometry(QRect& rect, bool init) const +bool Rules::applyGeometry(QRect &rect, bool init) const { QPoint p = rect.topLeft(); QSize s = rect.size(); @@ -544,14 +541,14 @@ bool Rules::applyGeometry(QRect& rect, bool init) const return ret; } -bool Rules::applyPosition(QPoint& pos, bool init) const +bool Rules::applyPosition(QPoint &pos, bool init) const { if (this->position != invalidPoint && checkSetRule(positionrule, init)) pos = this->position; return checkSetStop(positionrule); } -bool Rules::applySize(QSize& s, bool init) const +bool Rules::applySize(QSize &s, bool init) const { if (this->size.isValid() && checkSetRule(sizerule, init)) s = this->size; @@ -581,23 +578,23 @@ bool Rules::applyDesktops(QVector &vds, bool init) const return checkSetStop(desktopsrule); } -bool Rules::applyMaximizeHoriz(MaximizeMode& mode, bool init) const +bool Rules::applyMaximizeHoriz(MaximizeMode &mode, bool init) const { if (checkSetRule(maximizehorizrule, init)) - mode = static_cast< MaximizeMode >((maximizehoriz ? MaximizeHorizontal : 0) | (mode & MaximizeVertical)); + mode = static_cast((maximizehoriz ? MaximizeHorizontal : 0) | (mode & MaximizeVertical)); return checkSetStop(maximizehorizrule); } -bool Rules::applyMaximizeVert(MaximizeMode& mode, bool init) const +bool Rules::applyMaximizeVert(MaximizeMode &mode, bool init) const { if (checkSetRule(maximizevertrule, init)) - mode = static_cast< MaximizeMode >((maximizevert ? MaximizeVertical : 0) | (mode & MaximizeHorizontal)); + mode = static_cast((maximizevert ? MaximizeVertical : 0) | (mode & MaximizeHorizontal)); return checkSetStop(maximizevertrule); } APPLY_RULE(minimize, Minimize, bool) -bool Rules::applyShade(ShadeMode& sh, bool init) const +bool Rules::applyShade(ShadeMode &sh, bool init) const { if (checkSetRule(shaderule, init)) { if (!this->shade) @@ -629,7 +626,6 @@ APPLY_RULE(shortcut, Shortcut, QString) APPLY_FORCE_RULE(disableglobalshortcuts, DisableGlobalShortcuts, bool) APPLY_RULE(desktopfile, DesktopFile, QString) - #undef APPLY_RULE #undef APPLY_FORCE_RULE @@ -640,7 +636,7 @@ bool Rules::isTemporary() const bool Rules::discardTemporary(bool force) { - if (temporary_state == 0) // not temporary + if (temporary_state == 0) // not temporary return false; if (force || --temporary_state == 0) { // too old delete this; @@ -649,20 +645,20 @@ bool Rules::discardTemporary(bool force) return false; } -#define DISCARD_USED_SET_RULE( var ) \ - do { \ - if ( var##rule == ( SetRule ) ApplyNow || ( withdrawn && var##rule == ( SetRule ) ForceTemporarily )) { \ - var##rule = UnusedSetRule; \ - changed = true; \ - } \ - } while ( false ) -#define DISCARD_USED_FORCE_RULE( var ) \ - do { \ - if ( withdrawn && var##rule == ( ForceRule ) ForceTemporarily ) { \ - var##rule = UnusedForceRule; \ - changed = true; \ - } \ - } while ( false ) +#define DISCARD_USED_SET_RULE(var) \ + do { \ + if (var##rule == (SetRule)ApplyNow || (withdrawn && var##rule == (SetRule)ForceTemporarily)) { \ + var##rule = UnusedSetRule; \ + changed = true; \ + } \ + } while (false) +#define DISCARD_USED_FORCE_RULE(var) \ + do { \ + if (withdrawn && var##rule == (ForceRule)ForceTemporarily) { \ + var##rule = UnusedForceRule; \ + changed = true; \ + } \ + } while (false) bool Rules::discardUsed(bool withdrawn) { @@ -711,18 +707,17 @@ bool Rules::discardUsed(bool withdrawn) #endif -QDebug& operator<<(QDebug& stream, const Rules* r) +QDebug &operator<<(QDebug &stream, const Rules *r) { - return stream << "[" << r->description << ":" << r->wmclass << "]" ; + return stream << "[" << r->description << ":" << r->wmclass << "]"; } #ifndef KCMRULES void WindowRules::discardTemporary() { - QVector< Rules* >::Iterator it2 = rules.begin(); - for (QVector< Rules* >::Iterator it = rules.begin(); - it != rules.end(); - ) { + QVector::Iterator it2 = rules.begin(); + for (QVector::Iterator it = rules.begin(); + it != rules.end();) { if ((*it)->discardTemporary(true)) ++it; else { @@ -732,48 +727,46 @@ void WindowRules::discardTemporary() rules.erase(it2, rules.end()); } -void WindowRules::update(AbstractClient* c, int selection) +void WindowRules::update(AbstractClient *c, int selection) { bool updated = false; - for (QVector< Rules* >::ConstIterator it = rules.constBegin(); - it != rules.constEnd(); - ++it) - if ((*it)->update(c, selection)) // no short-circuiting here + for (QVector::ConstIterator it = rules.constBegin(); + it != rules.constEnd(); + ++it) + if ((*it)->update(c, selection)) // no short-circuiting here updated = true; if (updated) RuleBook::self()->requestDiskStorage(); } -#define CHECK_RULE( rule, type ) \ - type WindowRules::check##rule( type arg, bool init ) const \ - { \ - if ( rules.count() == 0 ) \ - return arg; \ - type ret = arg; \ - for ( QVector< Rules* >::ConstIterator it = rules.constBegin(); \ - it != rules.constEnd(); \ - ++it ) \ - { \ - if ( (*it)->apply##rule( ret, init )) \ - break; \ - } \ - return ret; \ +#define CHECK_RULE(rule, type) \ + type WindowRules::check##rule(type arg, bool init) const \ + { \ + if (rules.count() == 0) \ + return arg; \ + type ret = arg; \ + for (QVector::ConstIterator it = rules.constBegin(); \ + it != rules.constEnd(); \ + ++it) { \ + if ((*it)->apply##rule(ret, init)) \ + break; \ + } \ + return ret; \ } -#define CHECK_FORCE_RULE( rule, type ) \ - type WindowRules::check##rule( type arg ) const \ - { \ - if ( rules.count() == 0 ) \ - return arg; \ - type ret = arg; \ - for ( QVector< Rules* >::ConstIterator it = rules.begin(); \ - it != rules.end(); \ - ++it ) \ - { \ - if ( (*it)->apply##rule( ret )) \ - break; \ - } \ - return ret; \ +#define CHECK_FORCE_RULE(rule, type) \ + type WindowRules::check##rule(type arg) const \ + { \ + if (rules.count() == 0) \ + return arg; \ + type ret = arg; \ + for (QVector::ConstIterator it = rules.begin(); \ + it != rules.end(); \ + ++it) { \ + if ((*it)->apply##rule(ret)) \ + break; \ + } \ + return ret; \ } CHECK_FORCE_RULE(Placement, Placement::Policy) @@ -801,7 +794,7 @@ MaximizeMode WindowRules::checkMaximize(MaximizeMode mode, bool init) const { bool vert = checkMaximizeVert(mode, init) & MaximizeVertical; bool horiz = checkMaximizeHoriz(mode, init) & MaximizeHorizontal; - return static_cast< MaximizeMode >((vert ? MaximizeVertical : 0) | (horiz ? MaximizeHorizontal : 0)); + return static_cast((vert ? MaximizeVertical : 0) | (horiz ? MaximizeHorizontal : 0)); } AbstractOutput *WindowRules::checkOutput(AbstractOutput *output, bool init) const @@ -891,7 +884,7 @@ void AbstractClient::applyWindowRules() // FSP // AcceptFocus : if (workspace()->mostRecentlyActivatedClient() == this - && !client_rules->checkAcceptFocus(true)) + && !client_rules->checkAcceptFocus(true)) workspace()->activateNextClient(this); // Autogrouping : Only checked on window manage // AutogroupInForeground : Only checked on window manage @@ -909,7 +902,7 @@ void AbstractClient::applyWindowRules() void X11Client::updateWindowRules(Rules::Types selection) { - if (!isManaged()) // not fully setup yet + if (!isManaged()) // not fully setup yet return; AbstractClient::updateWindowRules(selection); } @@ -971,18 +964,17 @@ void RuleBook::deleteAll() m_rules.clear(); } -WindowRules RuleBook::find(const AbstractClient* c, bool ignore_temporary) +WindowRules RuleBook::find(const AbstractClient *c, bool ignore_temporary) { - QVector< Rules* > ret; - for (QList< Rules* >::Iterator it = m_rules.begin(); - it != m_rules.end(); - ) { + QVector ret; + for (QList::Iterator it = m_rules.begin(); + it != m_rules.end();) { if (ignore_temporary && (*it)->isTemporary()) { ++it; continue; } if ((*it)->match(c)) { - Rules* rule = *it; + Rules *rule = *it; qCDebug(KWIN_CORE) << "Rule found:" << rule << ":" << c; if (rule->isTemporary()) it = m_rules.erase(it); @@ -996,7 +988,7 @@ WindowRules RuleBook::find(const AbstractClient* c, bool ignore_temporary) return WindowRules(ret); } -void RuleBook::edit(AbstractClient* c, bool whole_app) +void RuleBook::edit(AbstractClient *c, bool whole_app) { save(); QStringList args; @@ -1049,16 +1041,16 @@ void RuleBook::save() settings.save(); } -void RuleBook::temporaryRulesMessage(const QString& message) +void RuleBook::temporaryRulesMessage(const QString &message) { bool was_temporary = false; - for (QList< Rules* >::ConstIterator it = m_rules.constBegin(); - it != m_rules.constEnd(); - ++it) + for (QList::ConstIterator it = m_rules.constBegin(); + it != m_rules.constEnd(); + ++it) if ((*it)->isTemporary()) was_temporary = true; - Rules* rule = new Rules(message, true); - m_rules.prepend(rule); // highest priority first + Rules *rule = new Rules(message, true); + m_rules.prepend(rule); // highest priority first if (!was_temporary) QTimer::singleShot(60000, this, &RuleBook::cleanupTemporaryRules); } @@ -1066,9 +1058,8 @@ void RuleBook::temporaryRulesMessage(const QString& message) void RuleBook::cleanupTemporaryRules() { bool has_temporary = false; - for (QList< Rules* >::Iterator it = m_rules.begin(); - it != m_rules.end(); - ) { + for (QList::Iterator it = m_rules.begin(); + it != m_rules.end();) { if ((*it)->discardTemporary(false)) { // deletes (*it) it = m_rules.erase(it); } else { @@ -1081,19 +1072,18 @@ void RuleBook::cleanupTemporaryRules() QTimer::singleShot(60000, this, &RuleBook::cleanupTemporaryRules); } -void RuleBook::discardUsed(AbstractClient* c, bool withdrawn) +void RuleBook::discardUsed(AbstractClient *c, bool withdrawn) { bool updated = false; - for (QList< Rules* >::Iterator it = m_rules.begin(); - it != m_rules.end(); - ) { + for (QList::Iterator it = m_rules.begin(); + it != m_rules.end();) { if (c->rules()->contains(*it)) { if ((*it)->discardUsed(withdrawn)) { updated = true; } if ((*it)->isEmpty()) { c->removeRule(*it); - Rules* r = *it; + Rules *r = *it; it = m_rules.erase(it); delete r; continue; diff --git a/src/rules.h b/src/rules.h index 6bb71b08d3..dbea8e4c1f 100644 --- a/src/rules.h +++ b/src/rules.h @@ -10,13 +10,12 @@ #ifndef KWIN_RULES_H #define KWIN_RULES_H - -#include #include #include +#include -#include "placement.h" #include "options.h" +#include "placement.h" #include "utils/common.h" class QDebug; @@ -37,12 +36,12 @@ class VirtualDesktop; class WindowRules { public: - explicit WindowRules(const QVector< Rules* >& rules); + explicit WindowRules(const QVector &rules); WindowRules(); - void update(AbstractClient*, int selection); + void update(AbstractClient *, int selection); void discardTemporary(); - bool contains(const Rules* rule) const; - void remove(Rules* rule); + 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 @@ -80,10 +79,11 @@ public: 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; + QVector rules; }; #endif @@ -92,25 +92,39 @@ class Rules { public: Rules(); - explicit Rules(const RuleSettings*); - Rules(const QString&, bool temporary); + explicit Rules(const RuleSettings *); + Rules(const QString &, bool temporary); enum Type { - Position = 1<<0, Size = 1<<1, Desktops = 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 + Position = 1 << 0, + Size = 1 << 1, + Desktops = 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 + 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 { @@ -123,65 +137,66 @@ public: }; enum SetRule { UnusedSetRule = Unused, - SetRuleDummy = 256 // so that it's at least short int + SetRuleDummy = 256 // so that it's at least short int }; enum ForceRule { UnusedForceRule = Unused, - ForceRuleDummy = 256 // so that it's at least short int + ForceRuleDummy = 256 // so that it's at least short int }; - void write(RuleSettings*) const; + void write(RuleSettings *) const; bool isEmpty() const; #ifndef KCMRULES bool discardUsed(bool withdrawn); - bool match(const AbstractClient* c) const; - bool update(AbstractClient*, int selection); + 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; + 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 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 applyDesktops(QVector &desktops, bool init) const; - bool applyScreen(int& desktop, bool init) const; - bool applyActivity(QStringList& 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 applyScreen(int &desktop, bool init) const; + bool applyActivity(QStringList &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 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; + 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; #ifdef KCMRULES private: #endif @@ -278,7 +293,7 @@ private: ForceRule disableglobalshortcutsrule; QString desktopfile; SetRule desktopfilerule; - friend QDebug& operator<<(QDebug& stream, const Rules*); + friend QDebug &operator<<(QDebug &stream, const Rules *); }; #ifndef KCMRULES @@ -287,20 +302,21 @@ class KWIN_EXPORT RuleBook : public QObject Q_OBJECT public: ~RuleBook() override; - WindowRules find(const AbstractClient*, bool); - void discardUsed(AbstractClient* c, bool withdraw); + 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 edit(AbstractClient *c, bool whole_app); void requestDiskStorage(); - void setConfig(const KSharedConfig::Ptr &config) { + void setConfig(const KSharedConfig::Ptr &config) + { m_config = config; } private Q_SLOTS: - void temporaryRulesMessage(const QString&); + void temporaryRulesMessage(const QString &); void cleanupTemporaryRules(); void save(); @@ -310,74 +326,65 @@ private: void cleanupX11(); QTimer *m_updateTimer; bool m_updatesDisabled; - QList m_rules; + QList m_rules; QScopedPointer m_temporaryRulesMessages; KSharedConfig::Ptr m_config; KWIN_SINGLETON(RuleBook) }; -inline -bool RuleBook::areUpdatesDisabled() const +inline bool RuleBook::areUpdatesDisabled() const { return m_updatesDisabled; } -inline -bool Rules::checkSetRule(SetRule rule, bool init) +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) + 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) +inline bool Rules::checkForceRule(ForceRule rule) { - return rule == (ForceRule)Force || rule == (ForceRule) ForceTemporarily; + return rule == (ForceRule)Force || rule == (ForceRule)ForceTemporarily; } -inline -bool Rules::checkSetStop(SetRule rule) +inline bool Rules::checkSetStop(SetRule rule) { return rule != UnusedSetRule; } -inline -bool Rules::checkForceStop(ForceRule rule) +inline bool Rules::checkForceStop(ForceRule rule) { return rule != UnusedForceRule; } -inline -WindowRules::WindowRules(const QVector< Rules* >& r) +inline WindowRules::WindowRules(const QVector &r) : rules(r) { } -inline -WindowRules::WindowRules() +inline WindowRules::WindowRules() { } -inline -bool WindowRules::contains(const Rules* rule) const +inline bool WindowRules::contains(const Rules *rule) const { return rules.contains(const_cast(rule)); } -inline -void WindowRules::remove(Rules* rule) +inline void WindowRules::remove(Rules *rule) { rules.removeOne(rule); } #endif -QDebug& operator<<(QDebug& stream, const Rules*); +QDebug &operator<<(QDebug &stream, const Rules *); } // namespace diff --git a/src/scene.cpp b/src/scene.cpp index a56bd93043..d5ed0d566d 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -68,13 +68,13 @@ #include #include -#include "x11client.h" +#include "composite.h" #include "deleted.h" #include "effects.h" #include "renderloop.h" #include "shadow.h" #include "wayland_server.h" -#include "composite.h" +#include "x11client.h" #include #include @@ -229,12 +229,12 @@ SurfaceItem *Scene::scanoutCandidate() const return nullptr; } SurfaceItem *candidate = nullptr; - if (!static_cast(effects)->blocksDirectScanout()) { - for (int i = stacking_order.count() - 1; i >=0; i--) { + if (!static_cast(effects)->blocksDirectScanout()) { + for (int i = stacking_order.count() - 1; i >= 0; i--) { Window *window = stacking_order[i]; Toplevel *toplevel = window->window(); if (toplevel->isOnOutput(painted_screen) && window->isVisible() && toplevel->opacity() > 0) { - AbstractClient *c = dynamic_cast(toplevel); + AbstractClient *c = dynamic_cast(toplevel); if (!c || !c->isFullScreen() || c->opacity() != 1.0) { break; } @@ -279,7 +279,7 @@ void Scene::prePaint(AbstractOutput *output) const RenderLoop *renderLoop = painted_screen->renderLoop(); const std::chrono::milliseconds presentTime = - std::chrono::duration_cast(renderLoop->nextPresentationTimestamp()); + std::chrono::duration_cast(renderLoop->nextPresentationTimestamp()); if (Q_UNLIKELY(presentTime < m_expectedPresentTimestamp)) { qCDebug(KWIN_CORE, @@ -420,7 +420,7 @@ void Scene::postPaint() if (waylandServer()) { const std::chrono::milliseconds frameTime = - std::chrono::duration_cast(painted_screen->renderLoop()->lastPresentationTimestamp()); + std::chrono::duration_cast(painted_screen->renderLoop()->lastPresentationTimestamp()); for (Window *window : std::as_const(m_windows)) { Toplevel *toplevel = window->window(); @@ -442,23 +442,23 @@ static QMatrix4x4 createProjectionMatrix(const QRect &rect) // and an aspect ratio of 1.0. QMatrix4x4 ret; ret.setToIdentity(); - const float fovY = std::tan(qDegreesToRadians(60.0f) / 2); - const float aspect = 1.0f; - const float zNear = 0.1f; - const float zFar = 100.0f; + const float fovY = std::tan(qDegreesToRadians(60.0f) / 2); + const float aspect = 1.0f; + const float zNear = 0.1f; + const float zFar = 100.0f; - const float yMax = zNear * fovY; - const float yMin = -yMax; - const float xMin = yMin * aspect; - const float xMax = yMax * aspect; + const float yMax = zNear * fovY; + const float yMin = -yMax; + const float xMin = yMin * aspect; + const float xMax = yMax * aspect; ret.frustum(xMin, xMax, yMin, yMax, zNear, zFar); const float scaleFactor = 1.1 * fovY / yMax; ret.translate(xMin * scaleFactor, yMax * scaleFactor, -1.1); - ret.scale( (xMax - xMin) * scaleFactor / rect.width(), - -(yMax - yMin) * scaleFactor / rect.height(), - 0.001); + ret.scale((xMax - xMin) * scaleFactor / rect.width(), + -(yMax - yMin) * scaleFactor / rect.height(), + 0.001); ret.translate(-rect.x(), -rect.y()); return ret; } @@ -511,7 +511,7 @@ void Scene::paintScreen(const QRegion ®ion) } // the function that'll be eventually called by paintScreen() above -void Scene::finalPaintScreen(int mask, const QRegion ®ion, ScreenPaintData& data) +void Scene::finalPaintScreen(int mask, const QRegion ®ion, ScreenPaintData &data) { m_paintScreenCount++; if (mask & (PAINT_SCREEN_TRANSFORMED | PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS)) { @@ -570,7 +570,7 @@ void Scene::addToplevel(Toplevel *c) { Q_ASSERT(!m_windows.contains(c)); Scene::Window *w = createWindow(c); - m_windows[ c ] = w; + m_windows[c] = w; connect(c, &Toplevel::windowClosed, this, &Scene::windowClosed); @@ -621,7 +621,7 @@ void Scene::createStackingOrder() windows.removeAll(win); } if (waylandServer() && waylandServer()->isScreenLocked()) { - if(!win->isLockScreen() && !win->isInputMethod()) { + if (!win->isLockScreen() && !win->isInputMethod()) { windows.removeAll(win); } } @@ -630,7 +630,7 @@ void Scene::createStackingOrder() // TODO: cache the stacking_order in case it has not changed for (Toplevel *c : std::as_const(windows)) { Q_ASSERT(m_windows.contains(c)); - stacking_order.append(m_windows[ c ]); + stacking_order.append(m_windows[c]); } } @@ -641,7 +641,7 @@ void Scene::clearStackingOrder() void Scene::paintWindow(Window *w, int mask, const QRegion ®ion) { - if (region.isEmpty()) // completely clipped + if (region.isEmpty()) // completely clipped return; WindowPaintData data(w->window()->effectWindow(), screenProjectionMatrix()); @@ -650,17 +650,17 @@ void Scene::paintWindow(Window *w, int mask, const QRegion ®ion) void Scene::paintDesktop(int desktop, int mask, const QRegion ®ion, ScreenPaintData &data) { - static_cast(effects)->paintDesktop(desktop, mask, region, data); + static_cast(effects)->paintDesktop(desktop, mask, region, data); } // the function that'll be eventually called by paintWindow() above -void Scene::finalPaintWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data) +void Scene::finalPaintWindow(EffectWindowImpl *w, int mask, const QRegion ®ion, WindowPaintData &data) { effects->drawWindow(w, mask, region, data); } // will be eventually called from drawWindow() -void Scene::finalDrawWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data) +void Scene::finalDrawWindow(EffectWindowImpl *w, int mask, const QRegion ®ion, WindowPaintData &data) { if (waylandServer() && waylandServer()->isScreenLocked() && !w->window()->isLockScreen() && !w->window()->isInputMethod()) { return; @@ -801,7 +801,7 @@ bool Scene::Window::isVisible() const return false; if (!toplevel->isOnCurrentActivity()) return false; - if (AbstractClient *c = dynamic_cast(toplevel)) + if (AbstractClient *c = dynamic_cast(toplevel)) return c->isShown(); return true; // Unmanaged is always visible } @@ -821,8 +821,8 @@ void Scene::Window::resetPaintingEnabled() disable_painting = 0; if (toplevel->isDeleted()) disable_painting |= PAINT_DISABLED_BY_DELETE; - if (static_cast(effects)->isDesktopRendering()) { - if (!toplevel->isOnDesktop(static_cast(effects)->currentRenderedDesktop())) { + if (static_cast(effects)->isDesktopRendering()) { + if (!toplevel->isOnDesktop(static_cast(effects)->currentRenderedDesktop())) { disable_painting |= PAINT_DISABLED_BY_DESKTOP; } } else { @@ -831,7 +831,7 @@ void Scene::Window::resetPaintingEnabled() } if (!toplevel->isOnCurrentActivity()) disable_painting |= PAINT_DISABLED_BY_ACTIVITY; - if (AbstractClient *c = dynamic_cast(toplevel)) { + if (AbstractClient *c = dynamic_cast(toplevel)) { if (c->isMinimized()) disable_painting |= PAINT_DISABLED_BY_MINIMIZE; if (c->isHiddenInternal()) { @@ -873,7 +873,7 @@ void Scene::Window::updateWindowPosition() //**************************************** // Scene::EffectFrame //**************************************** -Scene::EffectFrame::EffectFrame(EffectFrameImpl* frame) +Scene::EffectFrame::EffectFrame(EffectFrameImpl *frame) : m_effectFrame(frame) { } diff --git a/src/scene.h b/src/scene.h index da61edc611..4812f5e9d9 100644 --- a/src/scene.h +++ b/src/scene.h @@ -10,10 +10,10 @@ #ifndef KWIN_SCENE_H #define KWIN_SCENE_H +#include "kwineffects.h" #include "renderlayerdelegate.h" #include "toplevel.h" #include "utils/common.h" -#include "kwineffects.h" #include #include @@ -137,16 +137,16 @@ public: // Flags controlling how painting is done. enum { // Window (or at least part of it) will be painted opaque. - PAINT_WINDOW_OPAQUE = 1 << 0, + PAINT_WINDOW_OPAQUE = 1 << 0, // Window (or at least part of it) will be painted translucent. - PAINT_WINDOW_TRANSLUCENT = 1 << 1, + PAINT_WINDOW_TRANSLUCENT = 1 << 1, // Window will be painted with transformed geometry. - PAINT_WINDOW_TRANSFORMED = 1 << 2, + 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, + PAINT_SCREEN_REGION = 1 << 3, // Whole screen will be painted with transformed geometry. - PAINT_SCREEN_TRANSFORMED = 1 << 4, + 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 @@ -194,7 +194,8 @@ public: */ virtual QVector openGLPlatformInterfaceExtensions() const; - virtual QSharedPointer textureForOutput(AbstractOutput *output) const { + virtual QSharedPointer textureForOutput(AbstractOutput *output) const + { Q_UNUSED(output); return {}; } @@ -218,7 +219,8 @@ Q_SIGNALS: public Q_SLOTS: // a window has been closed - void windowClosed(KWin::Toplevel* c, KWin::Deleted* deleted); + void windowClosed(KWin::Toplevel *c, KWin::Deleted *deleted); + protected: virtual Window *createWindow(Toplevel *toplevel) = 0; void createStackingOrder(); @@ -227,7 +229,7 @@ protected: void paintScreen(const QRegion ®ion); friend class EffectsHandlerImpl; // called after all effects had their paintScreen() called - void finalPaintScreen(int mask, const QRegion ®ion, ScreenPaintData& data); + void finalPaintScreen(int mask, const QRegion ®ion, ScreenPaintData &data); // shared implementation of painting the screen in the generic // (unoptimized) way void preparePaintGenericScreen(); @@ -238,23 +240,25 @@ protected: // paint the background (not the desktop background - the whole background) virtual void paintBackground(const QRegion ®ion) = 0; // called after all effects had their paintWindow() called - void finalPaintWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data); + void finalPaintWindow(EffectWindowImpl *w, int mask, const QRegion ®ion, WindowPaintData &data); // shared implementation, starts painting the window - virtual void paintWindow(Window* w, int mask, const QRegion ®ion); + virtual void paintWindow(Window *w, int mask, const QRegion ®ion); // called after all effects had their drawWindow() called - virtual void finalDrawWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data); + virtual void finalDrawWindow(EffectWindowImpl *w, int mask, const QRegion ®ion, WindowPaintData &data); virtual void paintOffscreenQuickView(OffscreenQuickView *w) = 0; // saved data for 2nd pass of optimized screen painting - struct Phase2Data { + struct Phase2Data + { Window *window = nullptr; QRegion region; QRegion opaque; int mask = 0; }; - struct PaintContext { + struct PaintContext + { QRegion damage; int mask = 0; QVector phase2Data; @@ -264,11 +268,12 @@ protected: AbstractOutput *painted_screen = nullptr; // windows in their stacking order - QVector< Window* > stacking_order; + QVector stacking_order; + private: std::chrono::milliseconds m_expectedPresentTimestamp = std::chrono::milliseconds::zero(); QList m_delegates; - QHash< Toplevel*, Window* > m_windows; + QHash m_windows; QRect m_geometry; QMatrix4x4 m_renderTargetProjectionMatrix; QRect m_renderTargetRect; @@ -298,22 +303,22 @@ public: QRect rect() const; // access to the internal window class // TODO eventually get rid of this - Toplevel* window() const; + 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, + PAINT_DISABLED = 1 << 0, // Window will not be painted because it is deleted - PAINT_DISABLED_BY_DELETE = 1 << 1, + PAINT_DISABLED_BY_DELETE = 1 << 1, // Window will not be painted because of which desktop it's on - PAINT_DISABLED_BY_DESKTOP = 1 << 2, + PAINT_DISABLED_BY_DESKTOP = 1 << 2, // Window will not be painted because it is minimized - PAINT_DISABLED_BY_MINIMIZE = 1 << 3, + PAINT_DISABLED_BY_MINIMIZE = 1 << 3, // Window will not be painted because it's not on the current activity - PAINT_DISABLED_BY_ACTIVITY = 1 << 5 + PAINT_DISABLED_BY_ACTIVITY = 1 << 5 }; void enablePainting(int reason); void disablePainting(int reason); @@ -330,7 +335,8 @@ public: ShadowItem *shadowItem() const; protected: - Toplevel* toplevel; + Toplevel *toplevel; + private: void referencePreviousPixmap_helper(SurfaceItem *item); void unreferencePreviousPixmap_helper(SurfaceItem *item); @@ -345,7 +351,7 @@ private: class Scene::EffectFrame { public: - EffectFrame(EffectFrameImpl* frame); + EffectFrame(EffectFrameImpl *frame); virtual ~EffectFrame(); virtual void render(const QRegion ®ion, double opacity, double frameOpacity) = 0; virtual void free() = 0; @@ -356,59 +362,50 @@ public: virtual void crossFadeText() = 0; protected: - EffectFrameImpl* m_effectFrame; + EffectFrameImpl *m_effectFrame; }; -inline -int Scene::Window::x() const +inline int Scene::Window::x() const { return toplevel->x(); } -inline -int Scene::Window::y() const +inline int Scene::Window::y() const { return toplevel->y(); } -inline -int Scene::Window::width() const +inline int Scene::Window::width() const { return toplevel->width(); } -inline -int Scene::Window::height() const +inline int Scene::Window::height() const { return toplevel->height(); } -inline -QRect Scene::Window::geometry() const +inline QRect Scene::Window::geometry() const { return toplevel->frameGeometry(); } -inline -QSize Scene::Window::size() const +inline QSize Scene::Window::size() const { return toplevel->size(); } -inline -QPoint Scene::Window::pos() const +inline QPoint Scene::Window::pos() const { return toplevel->pos(); } -inline -QRect Scene::Window::rect() const +inline QRect Scene::Window::rect() const { return toplevel->rect(); } -inline -Toplevel* Scene::Window::window() const +inline Toplevel *Scene::Window::window() const { return toplevel; } diff --git a/src/scenes/opengl/lanczosfilter.cpp b/src/scenes/opengl/lanczosfilter.cpp index 2158d6f60c..2f909f35b2 100644 --- a/src/scenes/opengl/lanczosfilter.cpp +++ b/src/scenes/opengl/lanczosfilter.cpp @@ -13,8 +13,8 @@ #include "options.h" #include "workspace.h" -#include #include +#include #include @@ -76,15 +76,14 @@ void LanczosFilter::init() m_shader.reset(ShaderManager::instance()->generateShaderFromFile(ShaderTrait::MapTexture, QString(), QStringLiteral(":/scenes/opengl/shaders/lanczos.frag"))); if (m_shader->isValid()) { ShaderBinder binder(m_shader.data()); - m_uKernel = m_shader->uniformLocation("kernel"); - m_uOffsets = m_shader->uniformLocation("offsets"); + m_uKernel = m_shader->uniformLocation("kernel"); + m_uOffsets = m_shader->uniformLocation("offsets"); } else { qCDebug(KWIN_OPENGL) << "Shader is not valid"; m_shader.reset(); } } - void LanczosFilter::updateOffscreenSurfaces() { const QSize &s = m_scene->geometry().size(); @@ -154,12 +153,11 @@ void LanczosFilter::createOffsets(int count, float width, Qt::Orientation direct { m_offsets.fill(QVector2D()); for (int i = 0; i < count; i++) { - m_offsets[i] = (direction == Qt::Horizontal) ? - QVector2D(i / width, 0) : QVector2D(0, i / width); + m_offsets[i] = (direction == Qt::Horizontal) ? QVector2D(i / width, 0) : QVector2D(0, i / width); } } -void LanczosFilter::performPaint(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data) +void LanczosFilter::performPaint(EffectWindowImpl *w, int mask, QRegion region, WindowPaintData &data) { if (data.xScale() < 0.9 || data.yScale() < 0.9) { if (!m_inited) @@ -179,7 +177,7 @@ void LanczosFilter::performPaint(EffectWindowImpl* w, int mask, QRegion region, int tw = width * data.xScale(); int th = height * data.yScale(); const QRect textureRect(tx, ty, tw, th); - const bool hardwareClipping = !(QRegion(textureRect)-region).isEmpty(); + const bool hardwareClipping = !(QRegion(textureRect) - region).isEmpty(); int sw = width; int sh = height; @@ -189,7 +187,7 @@ void LanczosFilter::performPaint(EffectWindowImpl* w, int mask, QRegion region, scissor = m_scene->mapToRenderTarget(region); } - GLTexture *cachedTexture = static_cast< GLTexture*>(w->data(LanczosCacheRole).value()); + GLTexture *cachedTexture = static_cast(w->data(LanczosCacheRole).value()); if (cachedTexture) { if (cachedTexture->width() == tw && cachedTexture->height() == th) { cachedTexture->bind(); @@ -242,7 +240,7 @@ void LanczosFilter::performPaint(EffectWindowImpl* w, int mask, QRegion region, GLRenderTarget::pushRenderTarget(m_offscreenTarget); QMatrix4x4 modelViewProjectionMatrix; - modelViewProjectionMatrix.ortho(0, m_offscreenTex->width(), m_offscreenTex->height(), 0 , 0, 65535); + modelViewProjectionMatrix.ortho(0, m_offscreenTex->width(), m_offscreenTex->height(), 0, 0, 65535); thumbData.setProjectionMatrix(modelViewProjectionMatrix); glClearColor(0.0, 0.0, 0.0, 0.0); @@ -274,12 +272,18 @@ void LanczosFilter::performPaint(EffectWindowImpl* w, int mask, QRegion region, verts.reserve(12); texCoords.reserve(12); - texCoords << 1.0 << 0.0; verts << tw << 0.0; // Top right - texCoords << 0.0 << 0.0; verts << 0.0 << 0.0; // Top left - texCoords << 0.0 << 1.0; verts << 0.0 << sh; // Bottom left - texCoords << 0.0 << 1.0; verts << 0.0 << sh; // Bottom left - texCoords << 1.0 << 1.0; verts << tw << sh; // Bottom right - texCoords << 1.0 << 0.0; verts << tw << 0.0; // Top right + texCoords << 1.0 << 0.0; + verts << tw << 0.0; // Top right + texCoords << 0.0 << 0.0; + verts << 0.0 << 0.0; // Top left + texCoords << 0.0 << 1.0; + verts << 0.0 << sh; // Bottom left + texCoords << 0.0 << 1.0; + verts << 0.0 << sh; // Bottom left + texCoords << 1.0 << 1.0; + verts << tw << sh; // Bottom right + texCoords << 1.0 << 0.0; + verts << tw << 0.0; // Top right GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); vbo->reset(); vbo->setData(6, 2, verts.constData(), texCoords.constData()); @@ -309,12 +313,12 @@ void LanczosFilter::performPaint(EffectWindowImpl* w, int mask, QRegion region, verts.clear(); - verts << tw << 0.0; // Top right + verts << tw << 0.0; // Top right verts << 0.0 << 0.0; // Top left - verts << 0.0 << th; // Bottom left - verts << 0.0 << th; // Bottom left - verts << tw << th; // Bottom right - verts << tw << 0.0; // Top right + verts << 0.0 << th; // Bottom left + verts << 0.0 << th; // Bottom left + verts << tw << th; // Bottom right + verts << tw << 0.0; // Top right vbo->setData(6, 2, verts.constData(), texCoords.constData()); vbo->render(GL_TRIANGLES); @@ -358,7 +362,7 @@ void LanczosFilter::performPaint(EffectWindowImpl* w, int mask, QRegion region, } cache->unbind(); - w->setData(LanczosCacheRole, QVariant::fromValue(static_cast(cache))); + w->setData(LanczosCacheRole, QVariant::fromValue(static_cast(cache))); connect(effects, &EffectsHandler::windowDamaged, this, &LanczosFilter::safeDiscardCacheTexture, @@ -399,7 +403,7 @@ void LanczosFilter::discardCacheTexture(EffectWindow *w) { QVariant cachedTextureVariant = w->data(LanczosCacheRole); if (cachedTextureVariant.isValid()) { - delete static_cast< GLTexture*>(cachedTextureVariant.value()); + delete static_cast(cachedTextureVariant.value()); w->setData(LanczosCacheRole, QVariant()); } } @@ -409,16 +413,15 @@ void LanczosFilter::safeDiscardCacheTexture(EffectWindow *w) QVariant cachedTextureVariant = w->data(LanczosCacheRole); if (cachedTextureVariant.isValid()) { m_scene->makeOpenGLContextCurrent(); - delete static_cast< GLTexture*>(cachedTextureVariant.value()); + delete static_cast(cachedTextureVariant.value()); w->setData(LanczosCacheRole, QVariant()); } } void LanczosFilter::setUniforms() { - glUniform2fv(m_uOffsets, m_offsets.size(), (const GLfloat*)m_offsets.data()); - glUniform4fv(m_uKernel, m_kernel.size(), (const GLfloat*)m_kernel.data()); + glUniform2fv(m_uOffsets, m_offsets.size(), (const GLfloat *)m_offsets.data()); + glUniform4fv(m_uKernel, m_kernel.size(), (const GLfloat *)m_kernel.data()); } } // namespace - diff --git a/src/scenes/opengl/lanczosfilter.h b/src/scenes/opengl/lanczosfilter.h index 7cc66c2fb4..14ac4f913a 100644 --- a/src/scenes/opengl/lanczosfilter.h +++ b/src/scenes/opengl/lanczosfilter.h @@ -11,11 +11,11 @@ #ifndef KWIN_LANCZOSFILTER_P_H #define KWIN_LANCZOSFILTER_P_H -#include #include -#include +#include #include #include +#include #include namespace KWin @@ -36,10 +36,11 @@ class LanczosFilter : public QObject public: explicit LanczosFilter(Scene *parent); ~LanczosFilter() override; - void performPaint(EffectWindowImpl* w, int mask, QRegion region, WindowPaintData& data); + void performPaint(EffectWindowImpl *w, int mask, QRegion region, WindowPaintData &data); protected: - void timerEvent(QTimerEvent*) override; + void timerEvent(QTimerEvent *) override; + private: void init(); void updateOffscreenSurfaces(); diff --git a/src/scenes/opengl/scene_opengl.cpp b/src/scenes/opengl/scene_opengl.cpp index 1c3a1a5ab9..3f4cb4b51f 100644 --- a/src/scenes/opengl/scene_opengl.cpp +++ b/src/scenes/opengl/scene_opengl.cpp @@ -20,30 +20,30 @@ #include #include -#include "utils/common.h" #include "abstract_client.h" +#include "abstract_output.h" #include "composite.h" +#include "cursor.h" +#include "decorations/decoratedclient.h" #include "effects.h" #include "lanczosfilter.h" #include "main.h" #include "overlaywindow.h" #include "renderloop.h" -#include "cursor.h" -#include "decorations/decoratedclient.h" #include "shadowitem.h" #include "surfaceitem.h" +#include "utils/common.h" #include "windowitem.h" -#include "abstract_output.h" #include #include #include +#include #include #include #include #include -#include #include namespace KWin @@ -232,7 +232,7 @@ QVector SceneOpenGL::openGLPlatformInterfaceExtensions() const return m_backend->extensions().toVector(); } -QSharedPointer SceneOpenGL::textureForOutput(AbstractOutput* output) const +QSharedPointer SceneOpenGL::textureForOutput(AbstractOutput *output) const { return m_backend->textureForOutput(output); } @@ -290,7 +290,7 @@ void SceneOpenGL::paintGenericScreen(int mask, const ScreenPaintData &data) Scene::paintGenericScreen(mask, data); } -void SceneOpenGL::doPaintBackground(const QVector< float >& vertices) +void SceneOpenGL::doPaintBackground(const QVector &vertices) { GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); vbo->reset(); @@ -308,7 +308,7 @@ Scene::Window *SceneOpenGL::createWindow(Toplevel *t) return new OpenGLWindow(t, this); } -void SceneOpenGL::finalDrawWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data) +void SceneOpenGL::finalDrawWindow(EffectWindowImpl *w, int mask, const QRegion ®ion, WindowPaintData &data) { if (waylandServer() && waylandServer()->isScreenLocked() && !w->window()->isLockScreen() && !w->window()->isInputMethod()) { return; @@ -316,7 +316,7 @@ void SceneOpenGL::finalDrawWindow(EffectWindowImpl* w, int mask, const QRegion & performPaintWindow(w, mask, region, data); } -void SceneOpenGL::performPaintWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data) +void SceneOpenGL::performPaintWindow(EffectWindowImpl *w, int mask, const QRegion ®ion, WindowPaintData &data) { if (mask & PAINT_WINDOW_LANCZOS) { if (!m_lanczosFilter) { @@ -363,7 +363,7 @@ static GLTexture *bindSurfaceTexture(SurfaceItem *surfaceItem) { SurfacePixmap *surfacePixmap = surfaceItem->pixmap(); auto platformSurfaceTexture = - static_cast(surfacePixmap->texture()); + static_cast(surfacePixmap->texture()); if (surfacePixmap->isDiscarded()) { return platformSurfaceTexture->texture(); } @@ -550,7 +550,7 @@ void OpenGLWindow::performPaint(int mask, const QRegion ®ion, const WindowPai return; } - RenderContext renderContext { + RenderContext renderContext{ .clip = region, .paintData = data, .hardwareClipping = region != infiniteRegion() && ((mask & Scene::PAINT_WINDOW_TRANSFORMED) || (mask & Scene::PAINT_SCREEN_TRANSFORMED)), @@ -594,15 +594,15 @@ void OpenGLWindow::performPaint(int mask, const QRegion ®ion, const WindowPai } const GLVertexAttrib attribs[] = { - { VA_Position, 2, GL_FLOAT, offsetof(GLVertex2D, position) }, - { VA_TexCoord, 2, GL_FLOAT, offsetof(GLVertex2D, texcoord) }, + {VA_Position, 2, GL_FLOAT, offsetof(GLVertex2D, position)}, + {VA_TexCoord, 2, GL_FLOAT, offsetof(GLVertex2D, texcoord)}, }; GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); vbo->reset(); vbo->setAttribLayout(attribs, 2, sizeof(GLVertex2D)); - GLVertex2D *map = (GLVertex2D *) vbo->map(size); + GLVertex2D *map = (GLVertex2D *)vbo->map(size); for (int i = 0, v = 0; i < renderContext.renderNodes.count(); i++) { RenderNode &renderNode = renderContext.renderNodes[i]; @@ -672,10 +672,10 @@ void OpenGLWindow::performPaint(int mask, const QRegion ®ion, const WindowPai // SceneOpenGL::EffectFrame //**************************************** -GLTexture* SceneOpenGL::EffectFrame::m_unstyledTexture = nullptr; -QPixmap* SceneOpenGL::EffectFrame::m_unstyledPixmap = nullptr; +GLTexture *SceneOpenGL::EffectFrame::m_unstyledTexture = nullptr; +QPixmap *SceneOpenGL::EffectFrame::m_unstyledPixmap = nullptr; -SceneOpenGL::EffectFrame::EffectFrame(EffectFrameImpl* frame, SceneOpenGL *scene) +SceneOpenGL::EffectFrame::EffectFrame(EffectFrameImpl *frame, SceneOpenGL *scene) : Scene::EffectFrame(frame) , m_texture(nullptr) , m_textTexture(nullptr) @@ -763,7 +763,7 @@ void SceneOpenGL::EffectFrame::render(const QRegion &_region, double opacity, do Q_UNUSED(_region); // TODO: Old region doesn't seem to work with OpenGL - GLShader* shader = m_effectFrame->shader(); + GLShader *shader = m_effectFrame->shader(); if (!shader) { shader = ShaderManager::instance()->pushShader(ShaderTrait::MapTexture | ShaderTrait::Modulate); } else if (shader) { @@ -906,7 +906,7 @@ void SceneOpenGL::EffectFrame::render(const QRegion &_region, double opacity, do m_unstyledVBO->render(GL_TRIANGLES); m_unstyledTexture->unbind(); } else if (m_effectFrame->style() == EffectFrameStyled) { - if (!m_texture) // Lazy creation + if (!m_texture) // Lazy creation updateTexture(); if (shader) { @@ -915,7 +915,7 @@ void SceneOpenGL::EffectFrame::render(const QRegion &_region, double opacity, do } m_texture->bind(); qreal left, top, right, bottom; - m_effectFrame->frame().getMargins(left, top, right, bottom); // m_geometry is the inner geometry + m_effectFrame->frame().getMargins(left, top, right, bottom); // m_geometry is the inner geometry const QRect rect = m_effectFrame->geometry().adjusted(-left, -top, right, bottom); QMatrix4x4 mvp(projection); @@ -924,7 +924,6 @@ void SceneOpenGL::EffectFrame::render(const QRegion &_region, double opacity, do m_texture->render(rect); m_texture->unbind(); - } if (!m_effectFrame->selection().isNull()) { if (!m_selectionTexture) { // Lazy creation @@ -1009,7 +1008,7 @@ void SceneOpenGL::EffectFrame::render(const QRegion &_region, double opacity, do shader->setUniform(GLShader::ModulationConstant, constant); } } - if (!m_textTexture) // Lazy creation + if (!m_textTexture) // Lazy creation updateTextTexture(); if (m_textTexture) { @@ -1104,7 +1103,7 @@ class DecorationShadowTextureCache { public: ~DecorationShadowTextureCache(); - DecorationShadowTextureCache(const DecorationShadowTextureCache&) = delete; + DecorationShadowTextureCache(const DecorationShadowTextureCache &) = delete; static DecorationShadowTextureCache &instance(); void unregister(SceneOpenGLShadow *shadow); @@ -1112,11 +1111,12 @@ public: private: DecorationShadowTextureCache() = default; - struct Data { + struct Data + { QSharedPointer texture; - QVector shadows; + QVector shadows; }; - QHash m_cache; + QHash m_cache; }; DecorationShadowTextureCache &DecorationShadowTextureCache::instance() @@ -1206,12 +1206,8 @@ bool SceneOpenGLShadow::prepareBackend() const QSize topLeft(shadowPixmap(ShadowElementTopLeft).size()); const QSize bottomRight(shadowPixmap(ShadowElementBottomRight).size()); - const int width = std::max({topLeft.width(), left.width(), bottomLeft.width()}) + - std::max(top.width(), bottom.width()) + - std::max({topRight.width(), right.width(), bottomRight.width()}); - const int height = std::max({topLeft.height(), top.height(), topRight.height()}) + - std::max(left.height(), right.height()) + - std::max({bottomLeft.height(), bottom.height(), bottomRight.height()}); + const int width = std::max({topLeft.width(), left.width(), bottomLeft.width()}) + std::max(top.width(), bottom.width()) + std::max({topRight.width(), right.width(), bottomRight.width()}); + const int height = std::max({topLeft.height(), top.height(), topRight.height()}) + std::max(left.height(), right.height()) + std::max({bottomLeft.height(), bottom.height(), bottomRight.height()}); if (width == 0 || height == 0) { return false; @@ -1245,8 +1241,8 @@ bool SceneOpenGLShadow::prepareBackend() bool alphaOnly = true; for (ptrdiff_t y = 0; alphaOnly && y < image.height(); y++) { - const uint32_t * const src = reinterpret_cast(image.scanLine(y)); - uint8_t * const dst = reinterpret_cast(alphaImage.scanLine(y)); + const uint32_t *const src = reinterpret_cast(image.scanLine(y)); + uint8_t *const dst = reinterpret_cast(alphaImage.scanLine(y)); for (ptrdiff_t x = 0; x < image.width(); x++) { if (src[x] & 0x00ffffff) @@ -1426,7 +1422,7 @@ void SceneOpenGLDecorationRenderer::renderPart(const QRect &rect, const QRect &p } const QMargins SceneOpenGLDecorationRenderer::texturePadForPart( - const QRect &rect, const QRect &partRect) + const QRect &rect, const QRect &partRect) { QMargins result = QMargins(0, 0, 0, 0); if (rect.top() == partRect.top()) { @@ -1457,8 +1453,7 @@ void SceneOpenGLDecorationRenderer::resizeTexture() size.rwidth() = qMax(qMax(top.width(), bottom.width()), qMax(left.height(), right.height())); - size.rheight() = top.height() + bottom.height() + - left.width() + right.width(); + size.rheight() = top.height() + bottom.height() + left.width() + right.width(); size *= effectiveDevicePixelRatio(); size.rheight() += 4 * (2 * TexturePad); diff --git a/src/scenes/opengl/scene_opengl.h b/src/scenes/opengl/scene_opengl.h index 736d699a78..52b47a080d 100644 --- a/src/scenes/opengl/scene_opengl.h +++ b/src/scenes/opengl/scene_opengl.h @@ -45,14 +45,18 @@ public: SurfaceTexture *createSurfaceTextureX11(SurfacePixmapX11 *pixmap) override; SurfaceTexture *createSurfaceTextureWayland(SurfacePixmapWayland *pixmap) override; - OpenGLBackend *backend() const { + OpenGLBackend *backend() const + { return m_backend; } QVector openGLPlatformInterfaceExtensions() const override; QSharedPointer textureForOutput(AbstractOutput *output) const override; - QMatrix4x4 screenProjectionMatrix() const override { return m_screenProjectionMatrix; } + QMatrix4x4 screenProjectionMatrix() const override + { + return m_screenProjectionMatrix; + } static SceneOpenGL *createScene(OpenGLBackend *backend, QObject *parent); static bool supported(OpenGLBackend *backend); @@ -66,11 +70,11 @@ protected: void paintSimpleScreen(int mask, const QRegion ®ion) override; void paintGenericScreen(int mask, const ScreenPaintData &data) override; Scene::Window *createWindow(Toplevel *t) override; - void finalDrawWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data) override; + void finalDrawWindow(EffectWindowImpl *w, int mask, const QRegion ®ion, WindowPaintData &data) override; private: - void doPaintBackground(const QVector< float >& vertices); - void performPaintWindow(EffectWindowImpl* w, int mask, const QRegion ®ion, WindowPaintData& data); + void doPaintBackground(const QVector &vertices); + void performPaintWindow(EffectWindowImpl *w, int mask, const QRegion ®ion, WindowPaintData &data); bool init_ok = true; OpenGLBackend *m_backend; @@ -124,7 +128,7 @@ class SceneOpenGL::EffectFrame : public Scene::EffectFrame { public: - EffectFrame(EffectFrameImpl* frame, SceneOpenGL *scene); + EffectFrame(EffectFrameImpl *frame, SceneOpenGL *scene); ~EffectFrame() override; void free() override; @@ -153,8 +157,8 @@ private: 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 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 }; @@ -171,11 +175,14 @@ public: explicit SceneOpenGLShadow(Toplevel *toplevel); ~SceneOpenGLShadow() override; - GLTexture *shadowTexture() { + GLTexture *shadowTexture() + { return m_texture.data(); } + protected: bool prepareBackend() override; + private: QSharedPointer m_texture; }; @@ -196,10 +203,12 @@ public: void render(const QRegion ®ion) override; - GLTexture *texture() { + GLTexture *texture() + { return m_texture.data(); } - GLTexture *texture() const { + GLTexture *texture() const + { return m_texture.data(); } diff --git a/src/scenes/qpainter/scene_qpainter.cpp b/src/scenes/qpainter/scene_qpainter.cpp index cc27081514..25bbeaf417 100644 --- a/src/scenes/qpainter/scene_qpainter.cpp +++ b/src/scenes/qpainter/scene_qpainter.cpp @@ -10,25 +10,25 @@ #include "qpaintersurfacetexture.h" // KWin #include "abstract_client.h" +#include "abstract_output.h" #include "composite.h" #include "cursor.h" #include "decorations/decoratedclient.h" #include "deleted.h" #include "effects.h" #include "main.h" +#include "platform.h" #include "renderloop.h" #include "screens.h" #include "surfaceitem.h" #include "toplevel.h" -#include "platform.h" #include "windowitem.h" -#include "abstract_output.h" #include // Qt +#include #include #include -#include #include @@ -226,7 +226,7 @@ void SceneQPainter::Window::renderSurfaceItem(QPainter *painter, SurfaceItem *su } QPainterSurfaceTexture *platformSurfaceTexture = - static_cast(surfaceTexture->texture()); + static_cast(surfaceTexture->texture()); if (!platformSurfaceTexture->isValid()) { platformSurfaceTexture->create(); } else { @@ -298,7 +298,6 @@ void QPainterEffectFrame::render(const QRegion ®ion, double opacity, double f } QPainter *painter = m_scene->scenePainter(); - // Render the actual frame if (m_effectFrame->style() == EffectFrameUnstyled) { painter->save(); @@ -311,7 +310,7 @@ void QPainterEffectFrame::render(const QRegion ®ion, double opacity, double f painter->restore(); } else if (m_effectFrame->style() == EffectFrameStyled) { qreal left, top, right, bottom; - m_effectFrame->frame().getMargins(left, top, right, bottom); // m_geometry is the inner geometry + m_effectFrame->frame().getMargins(left, top, right, bottom); // m_geometry is the inner geometry QRect geom = m_effectFrame->geometry().adjusted(-left, -top, right, bottom); painter->drawPixmap(geom, m_effectFrame->frame().framePixmap()); } @@ -359,7 +358,7 @@ void QPainterEffectFrame::render(const QRegion ®ion, double opacity, double f //**************************************** // QPainterShadow //**************************************** -SceneQPainterShadow::SceneQPainterShadow(Toplevel* toplevel) +SceneQPainterShadow::SceneQPainterShadow(Toplevel *toplevel) : Shadow(toplevel) { } @@ -433,9 +432,7 @@ void SceneQPainterDecorationRenderer::resizeImages() auto checkAndCreate = [this](int index, const QSize &size) { auto dpr = effectiveDevicePixelRatio(); - if (m_images[index].size() != size * dpr || - m_images[index].devicePixelRatio() != dpr) - { + if (m_images[index].size() != size * dpr || m_images[index].devicePixelRatio() != dpr) { m_images[index] = QImage(size * dpr, QImage::Format_ARGB32_Premultiplied); m_images[index].setDevicePixelRatio(dpr); m_images[index].fill(Qt::transparent); diff --git a/src/scenes/qpainter/scene_qpainter.h b/src/scenes/qpainter/scene_qpainter.h index 997c79201d..8b7ce541c8 100644 --- a/src/scenes/qpainter/scene_qpainter.h +++ b/src/scenes/qpainter/scene_qpainter.h @@ -15,7 +15,8 @@ #include "scene.h" #include "shadow.h" -namespace KWin { +namespace KWin +{ class KWIN_EXPORT SceneQPainter : public Scene { @@ -32,14 +33,16 @@ public: SurfaceTexture *createSurfaceTextureInternal(SurfacePixmapInternal *pixmap) override; SurfaceTexture *createSurfaceTextureWayland(SurfacePixmapWayland *pixmap) override; - bool animationsSupported() const override { + bool animationsSupported() const override + { return false; } QPainter *scenePainter() const override; QImage *qpainterRenderBuffer(AbstractOutput *output) const override; - QPainterBackend *backend() const { + QPainterBackend *backend() const + { return m_backend; } @@ -65,6 +68,7 @@ public: Window(SceneQPainter *scene, Toplevel *c); ~Window() override; void performPaint(int mask, const QRegion ®ion, const WindowPaintData &data) override; + private: void renderSurfaceItem(QPainter *painter, SurfaceItem *surfaceItem) const; void renderDecorationItem(QPainter *painter, DecorationItem *decorationItem) const; @@ -77,13 +81,26 @@ class QPainterEffectFrame : public Scene::EffectFrame public: QPainterEffectFrame(EffectFrameImpl *frame, SceneQPainter *scene); ~QPainterEffectFrame() override; - void crossFadeIcon() override {} - void crossFadeText() override {} - void free() override {} - void freeIconFrame() override {} - void freeTextFrame() override {} - void freeSelection() override {} + void crossFadeIcon() override + { + } + void crossFadeText() override + { + } + void free() override + { + } + void freeIconFrame() override + { + } + void freeTextFrame() override + { + } + void freeSelection() override + { + } void render(const QRegion ®ion, double opacity, double frameOpacity) override; + private: SceneQPainter *m_scene; }; @@ -91,7 +108,7 @@ private: class SceneQPainterShadow : public Shadow { public: - SceneQPainterShadow(Toplevel* toplevel); + SceneQPainterShadow(Toplevel *toplevel); ~SceneQPainterShadow() override; protected: @@ -120,8 +137,7 @@ private: QImage m_images[int(DecorationPart::Count)]; }; -inline -QPainter* SceneQPainter::scenePainter() const +inline QPainter *SceneQPainter::scenePainter() const { return m_painter.data(); } diff --git a/src/screenedge.cpp b/src/screenedge.cpp index 3e9e43598a..cb8a4dc5ec 100644 --- a/src/screenedge.cpp +++ b/src/screenedge.cpp @@ -18,18 +18,18 @@ #include "screenedge.h" -// KWin #include + #include "abstract_output.h" +#include "cursor.h" #include "effects.h" #include "gestures.h" -#include -#include "cursor.h" #include "main.h" #include "platform.h" #include "utils/common.h" -#include #include "virtualdesktops.h" +#include +#include // DBus generated #if KWIN_BUILD_SCREENLOCKER #include "screenlocker_interface.h" @@ -39,15 +39,16 @@ // Qt #include #include -#include -#include -#include -#include #include #include +#include +#include +#include +#include #include -namespace KWin { +namespace KWin +{ // Mouse should not move more than this many pixels static const int DISTANCE_RESET = 30; @@ -61,10 +62,12 @@ static const int MINIMUM_DELTA = 44; TouchCallback::TouchCallback(QAction *touchUpAction, TouchCallback::CallbackFunction progressCallback) : m_touchUpAction(touchUpAction) , m_progressCallback(progressCallback) -{} +{ +} TouchCallback::~TouchCallback() -{} +{ +} QAction *TouchCallback::touchUpAction() const { @@ -99,8 +102,8 @@ Edge::Edge(ScreenEdges *parent) { m_gesture->setMinimumFingerCount(1); m_gesture->setMaximumFingerCount(1); - connect(m_gesture, &Gesture::triggered, this, - [this] { + connect( + m_gesture, &Gesture::triggered, this, [this]() { stopApproaching(); if (m_client) { m_client->showOnScreenEdge(); @@ -109,43 +112,36 @@ Edge::Edge(ScreenEdges *parent) } handleTouchAction(); handleTouchCallback(); - }, Qt::QueuedConnection - ); + }, + Qt::QueuedConnection); connect(m_gesture, &SwipeGesture::started, this, &Edge::startApproaching); connect(m_gesture, &SwipeGesture::cancelled, this, &Edge::stopApproaching); - connect(m_gesture, &SwipeGesture::cancelled, this, [this] () { - if (!m_touchCallbacks.isEmpty() && m_touchCallbacks.constFirst().hasProgressCallback()) { - handleTouchCallback(); + connect(m_gesture, &SwipeGesture::cancelled, this, [this]() { + if (!m_touchCallbacks.isEmpty() && m_touchCallbacks.constFirst().hasProgressCallback()) { + handleTouchCallback(); + } + }); + connect(m_gesture, &SwipeGesture::progress, this, [this](qreal progress) { + int factor = progress * 256.0f; + if (m_lastApproachingFactor != factor) { + m_lastApproachingFactor = factor; + Q_EMIT approaching(border(), m_lastApproachingFactor / 256.0f, m_approachGeometry); + } + }); + connect(m_gesture, &SwipeGesture::deltaProgress, this, [this](const QSizeF &progressDelta) { + if (!m_touchCallbacks.isEmpty()) { + m_touchCallbacks.constFirst().progressCallback(border(), progressDelta, m_output); + } + }); + connect(this, &Edge::activatesForTouchGestureChanged, this, [this]() { + if (isReserved()) { + if (activatesForTouchGesture()) { + m_edges->gestureRecognizer()->registerSwipeGesture(m_gesture); + } else { + m_edges->gestureRecognizer()->unregisterSwipeGesture(m_gesture); } } - ); - connect(m_gesture, &SwipeGesture::progress, this, - [this] (qreal progress) { - int factor = progress * 256.0f; - if (m_lastApproachingFactor != factor) { - m_lastApproachingFactor = factor; - Q_EMIT approaching(border(), m_lastApproachingFactor/256.0f, m_approachGeometry); - } - } - ); - connect(m_gesture, &SwipeGesture::deltaProgress, this, - [this] (const QSizeF &progressDelta) { - if (!m_touchCallbacks.isEmpty()) { - m_touchCallbacks.constFirst().progressCallback(border(), progressDelta, m_output); - } - } - ); - connect(this, &Edge::activatesForTouchGestureChanged, this, - [this] { - if (isReserved()) { - if (activatesForTouchGesture()) { - m_edges->gestureRecognizer()->registerSwipeGesture (m_gesture); - } else { - m_edges->gestureRecognizer()->unregisterSwipeGesture (m_gesture); - } - } - } - ); + }); } Edge::~Edge() @@ -170,7 +166,10 @@ void Edge::reserve(QObject *object, const char *slot) void Edge::reserveTouchCallBack(QAction *action, TouchCallback::CallbackFunction callback) { - if (auto itr = std::find_if(m_touchCallbacks.constBegin(), m_touchCallbacks.constEnd(), [action] (const TouchCallback &c) { return c.touchUpAction() == action; }); itr != m_touchCallbacks.constEnd()) { + if (auto itr = std::find_if(m_touchCallbacks.constBegin(), m_touchCallbacks.constEnd(), [action](const TouchCallback &c) { + return c.touchUpAction() == action; + }); + itr != m_touchCallbacks.constEnd()) { return; } reserveTouchCallBack(TouchCallback(action, callback)); @@ -178,21 +177,24 @@ void Edge::reserveTouchCallBack(QAction *action, TouchCallback::CallbackFunction void Edge::reserveTouchCallBack(const TouchCallback &callback) { - if (auto itr = std::find_if(m_touchCallbacks.constBegin(), m_touchCallbacks.constEnd(), [callback] (const TouchCallback &c) { return c.touchUpAction() == callback.touchUpAction(); }); itr != m_touchCallbacks.constEnd()) { + if (auto itr = std::find_if(m_touchCallbacks.constBegin(), m_touchCallbacks.constEnd(), [callback](const TouchCallback &c) { + return c.touchUpAction() == callback.touchUpAction(); + }); + itr != m_touchCallbacks.constEnd()) { return; } - connect(callback.touchUpAction(), &QAction::destroyed, this, - [this, callback] { - unreserveTouchCallBack(callback.touchUpAction()); - } - ); + connect(callback.touchUpAction(), &QAction::destroyed, this, [this, callback]() { + unreserveTouchCallBack(callback.touchUpAction()); + }); m_touchCallbacks << callback; reserve(); } void Edge::unreserveTouchCallBack(QAction *action) { - auto it = std::find_if(m_touchCallbacks.begin(), m_touchCallbacks.end(), [action] (const TouchCallback &c) { return c.touchUpAction() == action; }); + auto it = std::find_if(m_touchCallbacks.begin(), m_touchCallbacks.end(), [action](const TouchCallback &c) { + return c.touchUpAction() == action; + }); if (it != m_touchCallbacks.end()) { m_touchCallbacks.erase(it); unreserve(); @@ -274,13 +276,13 @@ bool Edge::triggersFor(const QPoint &cursorPos) const if (isLeft() && cursorPos.x() != m_geometry.x()) { return false; } - if (isRight() && cursorPos.x() != (m_geometry.x() + m_geometry.width() -1)) { + if (isRight() && cursorPos.x() != (m_geometry.x() + m_geometry.width() - 1)) { return false; } if (isTop() && cursorPos.y() != m_geometry.y()) { return false; } - if (isBottom() && cursorPos.y() != (m_geometry.y() + m_geometry.height() -1)) { + if (isBottom() && cursorPos.y() != (m_geometry.y() + m_geometry.height() - 1)) { return false; } return true; @@ -341,8 +343,7 @@ bool Edge::canActivate(const QPoint &cursorPos, const QDateTime &triggerTime) void Edge::handle(const QPoint &cursorPos) { AbstractClient *movingClient = Workspace::self()->moveResizeClient(); - if ((edges()->isDesktopSwitchingMovingClients() && movingClient && !movingClient->isInteractiveResize()) || - (edges()->isDesktopSwitching() && isScreenEdge())) { + if ((edges()->isDesktopSwitchingMovingClients() && movingClient && !movingClient->isInteractiveResize()) || (edges()->isDesktopSwitching() && isScreenEdge())) { // always switch desktops in case: // moving a Client and option for switch on client move is enabled // or switch on screen edge is enabled @@ -398,9 +399,7 @@ bool Edge::handleAction(ElectricBorderAction action) QDBusMessage::createMethodCall(QStringLiteral("org.kde.krunner"), QStringLiteral("/App"), QStringLiteral("org.kde.krunner.App"), - QStringLiteral("display") - ) - ); + QStringLiteral("display"))); return true; } case ElectricActionActivityManager: { // open activity manager @@ -408,9 +407,7 @@ bool Edge::handleAction(ElectricBorderAction action) QDBusMessage::createMethodCall(QStringLiteral("org.kde.plasmashell"), QStringLiteral("/PlasmaShell"), QStringLiteral("org.kde.PlasmaShell"), - QStringLiteral("toggleActivityManager") - ) - ); + QStringLiteral("toggleActivityManager"))); return true; } case ElectricActionApplicationLauncher: { @@ -418,9 +415,7 @@ bool Edge::handleAction(ElectricBorderAction action) QDBusMessage::createMethodCall(QStringLiteral("org.kde.plasmashell"), QStringLiteral("/PlasmaShell"), QStringLiteral("org.kde.PlasmaShell"), - QStringLiteral("activateLauncherMenu") - ) - ); + QStringLiteral("activateLauncherMenu"))); return true; } default: @@ -434,8 +429,8 @@ bool Edge::handleByCallback() return false; } for (QHash::iterator it = m_callBacks.begin(); - it != m_callBacks.end(); - ++it) { + it != m_callBacks.end(); + ++it) { bool retVal = false; QMetaObject::invokeMethod(it.key(), it.value().constData(), Q_RETURN_ARG(bool, retVal), Q_ARG(ElectricBorder, m_border)); if (retVal) { @@ -497,14 +492,11 @@ void Edge::switchDesktop(const QPoint &cursorPos) m_pushBackBlocked = true; Cursors::self()->mouse()->setPos(pos); QSharedPointer me(new QMetaObject::Connection); - *me = QObject::connect(QCoreApplication::eventDispatcher(), - &QAbstractEventDispatcher::aboutToBlock, this, - [this, me](){ + *me = QObject::connect(QCoreApplication::eventDispatcher(), &QAbstractEventDispatcher::aboutToBlock, this, [this, me]() { QObject::disconnect(*me); - const_cast*>(&me)->reset(nullptr); + const_cast *>(&me)->reset(nullptr); m_pushBackBlocked = false; - } - ); + }); } } @@ -612,7 +604,7 @@ void Edge::doGeometryUpdate() void Edge::activate() { if (activatesForTouchGesture()) { - m_edges->gestureRecognizer()->registerSwipeGesture (m_gesture); + m_edges->gestureRecognizer()->registerSwipeGesture(m_gesture); } doActivate(); } @@ -623,7 +615,7 @@ void Edge::doActivate() void Edge::deactivate() { - m_edges->gestureRecognizer()->unregisterSwipeGesture (m_gesture); + m_edges->gestureRecognizer()->unregisterSwipeGesture(m_gesture); doDeactivate(); } @@ -671,28 +663,28 @@ void Edge::updateApproaching(const QPoint &point) }; switch (border()) { case ElectricTopLeft: - factor = (cornerDistance(approachGeometry().topLeft())<<8) / edgeDistance; + factor = (cornerDistance(approachGeometry().topLeft()) << 8) / edgeDistance; break; case ElectricTopRight: - factor = (cornerDistance(approachGeometry().topRight())<<8) / edgeDistance; + factor = (cornerDistance(approachGeometry().topRight()) << 8) / edgeDistance; break; case ElectricBottomRight: - factor = (cornerDistance(approachGeometry().bottomRight())<<8) / edgeDistance; + factor = (cornerDistance(approachGeometry().bottomRight()) << 8) / edgeDistance; break; case ElectricBottomLeft: - factor = (cornerDistance(approachGeometry().bottomLeft())<<8) / edgeDistance; + factor = (cornerDistance(approachGeometry().bottomLeft()) << 8) / edgeDistance; break; case ElectricTop: - factor = (qAbs(point.y() - approachGeometry().y())<<8) / edgeDistance; + factor = (qAbs(point.y() - approachGeometry().y()) << 8) / edgeDistance; break; case ElectricRight: - factor = (qAbs(point.x() - approachGeometry().right())<<8) / edgeDistance; + factor = (qAbs(point.x() - approachGeometry().right()) << 8) / edgeDistance; break; case ElectricBottom: - factor = (qAbs(point.y() - approachGeometry().bottom())<<8) / edgeDistance; + factor = (qAbs(point.y() - approachGeometry().bottom()) << 8) / edgeDistance; break; case ElectricLeft: - factor = (qAbs(point.x() - approachGeometry().x())<<8) / edgeDistance; + factor = (qAbs(point.x() - approachGeometry().x()) << 8) / edgeDistance; break; default: break; @@ -700,7 +692,7 @@ void Edge::updateApproaching(const QPoint &point) factor = 256 - factor; if (m_lastApproachingFactor != factor) { m_lastApproachingFactor = factor; - Q_EMIT approaching(border(), m_lastApproachingFactor/256.0f, m_approachGeometry); + Q_EMIT approaching(border(), m_lastApproachingFactor / 256.0f, m_approachGeometry); } } else { stopApproaching(); @@ -738,7 +730,8 @@ void Edge::setBorder(ElectricBorder border) } } -void Edge::setTouchAction(ElectricBorderAction action) { +void Edge::setTouchAction(ElectricBorderAction action) +{ const bool wasTouch = activatesForTouchGesture(); m_touchAction = action; if (wasTouch != activatesForTouchGesture()) { @@ -813,7 +806,7 @@ void ScreenEdges::init() updateLayout(); recreateEdges(); } -static ElectricBorderAction electricBorderAction(const QString& name) +static ElectricBorderAction electricBorderAction(const QString &name) { QString lowerName = name.toLower(); if (lowerName == QStringLiteral("showdesktop")) { @@ -854,21 +847,21 @@ void ScreenEdges::reconfigure() m_cursorPushBackDistance = QSize(pushBack, pushBack); KConfigGroup borderConfig = m_config->group("ElectricBorders"); - setActionForBorder(ElectricTopLeft, &m_actionTopLeft, + setActionForBorder(ElectricTopLeft, &m_actionTopLeft, electricBorderAction(borderConfig.readEntry("TopLeft", "None"))); - setActionForBorder(ElectricTop, &m_actionTop, + setActionForBorder(ElectricTop, &m_actionTop, electricBorderAction(borderConfig.readEntry("Top", "None"))); - setActionForBorder(ElectricTopRight, &m_actionTopRight, + setActionForBorder(ElectricTopRight, &m_actionTopRight, electricBorderAction(borderConfig.readEntry("TopRight", "None"))); - setActionForBorder(ElectricRight, &m_actionRight, + setActionForBorder(ElectricRight, &m_actionRight, electricBorderAction(borderConfig.readEntry("Right", "None"))); setActionForBorder(ElectricBottomRight, &m_actionBottomRight, electricBorderAction(borderConfig.readEntry("BottomRight", "None"))); - setActionForBorder(ElectricBottom, &m_actionBottom, + setActionForBorder(ElectricBottom, &m_actionBottom, electricBorderAction(borderConfig.readEntry("Bottom", "None"))); - setActionForBorder(ElectricBottomLeft, &m_actionBottomLeft, + setActionForBorder(ElectricBottomLeft, &m_actionBottomLeft, electricBorderAction(borderConfig.readEntry("BottomLeft", "None"))); - setActionForBorder(ElectricLeft, &m_actionLeft, + setActionForBorder(ElectricLeft, &m_actionLeft, electricBorderAction(borderConfig.readEntry("Left", "None"))); borderConfig = m_config->group("TouchEdges"); @@ -1078,7 +1071,7 @@ static bool isBottomScreen(const QRect &screen, const QRect &fullArea) void ScreenEdges::recreateEdges() { - QList oldEdges(m_edges); + QList oldEdges(m_edges); m_edges.clear(); const QRect fullArea = workspace()->geometry(); QRegion processedRegion; @@ -1110,8 +1103,8 @@ void ScreenEdges::recreateEdges() for (auto it = m_edges.begin(); it != m_edges.end(); ++it) { Edge *edge = *it; for (auto oldIt = oldEdges.constBegin(); - oldIt != oldEdges.constEnd(); - ++oldIt) { + oldIt != oldEdges.constEnd(); + ++oldIt) { Edge *oldEdge = *oldIt; if (oldEdge->client()) { // show the client again and don't recreate the edge @@ -1123,8 +1116,8 @@ void ScreenEdges::recreateEdges() } const QHash &callbacks = oldEdge->callBacks(); for (QHash::const_iterator callback = callbacks.begin(); - callback != callbacks.end(); - ++callback) { + callback != callbacks.end(); + ++callback) { edge->reserve(callback.key(), callback.value().constData()); } const auto touchCallBacks = oldEdge->touchCallBacks(); @@ -1420,7 +1413,7 @@ void ScreenEdges::createEdgeForClient(AbstractClient *client, ElectricBorder bor } } -void ScreenEdges::deleteEdgeForClient(AbstractClient* c) +void ScreenEdges::deleteEdgeForClient(AbstractClient *c) { auto it = m_edges.begin(); while (it != m_edges.end()) { @@ -1563,12 +1556,12 @@ void ScreenEdges::ensureOnTop() Xcb::restackWindowsWithRaise(windows()); } -QVector< xcb_window_t > ScreenEdges::windows() const +QVector ScreenEdges::windows() const { QVector wins; for (auto it = m_edges.constBegin(); - it != m_edges.constEnd(); - ++it) { + it != m_edges.constEnd(); + ++it) { Edge *edge = *it; xcb_window_t w = edge->window(); if (w != XCB_WINDOW_NONE) { @@ -1583,4 +1576,4 @@ QVector< xcb_window_t > ScreenEdges::windows() const return wins; } -} //namespace +} // namespace diff --git a/src/screenedge.h b/src/screenedge.h index 8f78a42d2e..40927ac542 100644 --- a/src/screenedge.h +++ b/src/screenedge.h @@ -23,15 +23,16 @@ // KDE includes #include // Qt -#include -#include #include +#include #include +#include class QAction; class QMouseEvent; -namespace KWin { +namespace KWin +{ class AbstractClient; class AbstractOutput; @@ -42,7 +43,7 @@ class SwipeGesture; class TouchCallback { public: - using CallbackFunction = std::function; + using CallbackFunction = std::function; explicit TouchCallback(QAction *touchUpAction, TouchCallback::CallbackFunction progressCallback); ~TouchCallback(); @@ -116,6 +117,7 @@ public Q_SLOTS: Q_SIGNALS: void approaching(ElectricBorder border, qreal factor, const QRect &geometry); void activatesForTouchGestureChanged(); + protected: ScreenEdges *edges(); const ScreenEdges *edges() const; @@ -126,16 +128,19 @@ protected: 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() { + bool handlePointerAction() + { return handleAction(m_action); } - bool handleTouchAction() { + bool handleTouchAction() + { return handleAction(m_touchAction); } bool handleByCallback(); @@ -143,7 +148,8 @@ private: void switchDesktop(const QPoint &cursorPos); void pushCursorBack(const QPoint &cursorPos); void reserveTouchCallBack(const TouchCallback &callback); - QVector touchCallBacks() const { + QVector touchCallBacks() const + { return m_touchCallbacks; } ScreenEdges *m_edges; @@ -244,7 +250,7 @@ public: * @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); + 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" */ @@ -330,7 +336,7 @@ public: * Returns a QVector of all existing screen edge windows * @return all existing screen edge windows in a QVector */ - QVector< xcb_window_t > windows() const; + QVector windows() const; bool isDesktopSwitching() const; bool isDesktopSwitchingMovingClients() const; @@ -352,7 +358,8 @@ public: ElectricBorderAction actionBottomLeft() const; ElectricBorderAction actionLeft() const; - GestureRecognizer *gestureRecognizer() const { + GestureRecognizer *gestureRecognizer() const + { return m_gestureRecognizer; } @@ -406,7 +413,7 @@ private: int m_timeThreshold; int m_reactivateThreshold; Qt::Orientations m_virtualDesktopLayout; - QList m_edges; + QList m_edges; KSharedConfig::Ptr m_config; ElectricBorderAction m_actionTopLeft; ElectricBorderAction m_actionTop; @@ -498,7 +505,7 @@ inline ElectricBorder Edge::border() const return m_border; } -inline const QHash< QObject *, QByteArray > &Edge::callBacks() const +inline const QHash &Edge::callBacks() const { return m_callBacks; } @@ -526,7 +533,8 @@ inline void ScreenEdges::setConfig(KSharedConfig::Ptr config) m_config = config; } -inline int ScreenEdges::cornerOffset() const { +inline int ScreenEdges::cornerOffset() const +{ return m_cornerOffset; } @@ -585,11 +593,11 @@ inline void ScreenEdges::setTimeThreshold(int threshold) m_timeThreshold = threshold; } -#define ACTION( name ) \ -inline ElectricBorderAction ScreenEdges::name() const \ -{ \ - return m_##name; \ -} +#define ACTION(name) \ + inline ElectricBorderAction ScreenEdges::name() const \ + { \ + return m_##name; \ + } ACTION(actionTopLeft) ACTION(actionTop) diff --git a/src/screenlockerwatcher.cpp b/src/screenlockerwatcher.cpp index 7932631ab7..42fd71d69f 100644 --- a/src/screenlockerwatcher.cpp +++ b/src/screenlockerwatcher.cpp @@ -10,8 +10,8 @@ #include "wayland_server.h" // dbus generated -#include "screenlocker_interface.h" #include "kscreenlocker_interface.h" +#include "screenlocker_interface.h" namespace KWin { diff --git a/src/screenlockerwatcher.h b/src/screenlockerwatcher.h index 158253a5a4..7b8da1685d 100644 --- a/src/screenlockerwatcher.h +++ b/src/screenlockerwatcher.h @@ -26,7 +26,8 @@ class KWIN_EXPORT ScreenLockerWatcher : public QObject Q_OBJECT public: ~ScreenLockerWatcher() override; - bool isLocked() const { + bool isLocked() const + { return m_locked; } Q_SIGNALS: @@ -36,6 +37,7 @@ private Q_SLOTS: void setLocked(bool activated); void activeQueried(QDBusPendingCallWatcher *watcher); void serviceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner); + private: void initialize(); void queryActive(); diff --git a/src/screens.cpp b/src/screens.cpp index 548547d32a..60e4d142b1 100644 --- a/src/screens.cpp +++ b/src/screens.cpp @@ -7,14 +7,16 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "screens.h" -#include + +#include + #include "abstract_output.h" #include "cursor.h" -#include "utils/common.h" -#include "settings.h" -#include -#include #include "platform.h" +#include "settings.h" +#include "utils/common.h" +#include +#include namespace KWin { diff --git a/src/screens.h b/src/screens.h index 8fbff0d19c..cb990331af 100644 --- a/src/screens.h +++ b/src/screens.h @@ -113,26 +113,22 @@ private: KWIN_SINGLETON(Screens) }; -inline -int Screens::count() const +inline int Screens::count() const { return m_count; } -inline -QSize Screens::size() const +inline QSize Screens::size() const { return m_boundingSize; } -inline -QRect Screens::geometry() const +inline QRect Screens::geometry() const { - return QRect(QPoint(0,0), size()); + return QRect(QPoint(0, 0), size()); } -inline -Screens *screens() +inline Screens *screens() { return Screens::self(); } diff --git a/src/scripting/dbuscall.cpp b/src/scripting/dbuscall.cpp index d540a2656a..20f5d58cf2 100644 --- a/src/scripting/dbuscall.cpp +++ b/src/scripting/dbuscall.cpp @@ -13,7 +13,8 @@ #include #include -namespace KWin { +namespace KWin +{ DBusCall::DBusCall(QObject *parent) : QObject(parent) diff --git a/src/scripting/dbuscall.h b/src/scripting/dbuscall.h index 0c48e207b3..c0ba1e56d8 100644 --- a/src/scripting/dbuscall.h +++ b/src/scripting/dbuscall.h @@ -71,7 +71,7 @@ class DBusCall : public QObject 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 = nullptr); + explicit DBusCall(QObject *parent = nullptr); ~DBusCall() override; const QString &service() const; @@ -107,21 +107,21 @@ private: 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; \ - Q_EMIT name##Changed(); \ -} +#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; \ + Q_EMIT name##Changed(); \ + } #define WRAPPER(name, upperName) \ -GENERIC_WRAPPER(const QString&, name, upperName) + GENERIC_WRAPPER(const QString &, name, upperName) WRAPPER(interface, Interface) WRAPPER(method, Method) diff --git a/src/scripting/genericscriptedconfig.cpp b/src/scripting/genericscriptedconfig.cpp index 9b23154577..e2af3e74eb 100644 --- a/src/scripting/genericscriptedconfig.cpp +++ b/src/scripting/genericscriptedconfig.cpp @@ -6,24 +6,27 @@ SPDX-License-Identifier: GPL-2.0-or-later */ - #include "genericscriptedconfig.h" + #include "config-kwin.h" + #include + #include #define TRANSLATION_DOMAIN "kwin_scripting" +#include #include #include #include -#include #include #include +#include #include #include -#include -namespace KWin { +namespace KWin +{ QObject *GenericScriptedConfigFactory::create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &args, const QString &keyword) { @@ -63,22 +66,12 @@ GenericScriptedConfig::~GenericScriptedConfig() void GenericScriptedConfig::createUi() { - QVBoxLayout* layout = new QVBoxLayout(this); + QVBoxLayout *layout = new QVBoxLayout(this); const QString kconfigXTFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, - QLatin1String(KWIN_NAME) + - QLatin1Char('/') + - typeName() + - QLatin1Char('/') + - m_packageName + - QLatin1String("/contents/config/main.xml")); + QLatin1String(KWIN_NAME) + QLatin1Char('/') + typeName() + QLatin1Char('/') + m_packageName + QLatin1String("/contents/config/main.xml")); const QString uiPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, - QLatin1String(KWIN_NAME) + - QLatin1Char('/') + - typeName() + - QLatin1Char('/') + - m_packageName + - QLatin1String("/contents/ui/config.ui")); + QLatin1String(KWIN_NAME) + QLatin1Char('/') + typeName() + QLatin1Char('/') + m_packageName + QLatin1String("/contents/ui/config.ui")); if (kconfigXTFile.isEmpty() || uiPath.isEmpty()) { layout->addWidget(new QLabel(i18nc("Error message", "Plugin does not provide configuration file in expected location"))); return; @@ -174,5 +167,4 @@ void ScriptingConfig::reload() // TODO: what to call } - } // namespace diff --git a/src/scripting/genericscriptedconfig.h b/src/scripting/genericscriptedconfig.h index 30038adeb0..1572aec000 100644 --- a/src/scripting/genericscriptedconfig.h +++ b/src/scripting/genericscriptedconfig.h @@ -11,8 +11,8 @@ #define KWIN_GENERICSCRIPTEDCONFIG_H #include -#include #include +#include class KLocalizedTranslator; @@ -22,7 +22,7 @@ namespace KWin class GenericScriptedConfigFactory : public KPluginFactory { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.kde.KPluginFactory" FILE "genericscriptedconfig.json" ) + Q_PLUGIN_METADATA(IID "org.kde.KPluginFactory" FILE "genericscriptedconfig.json") Q_INTERFACES(KPluginFactory) protected: @@ -58,6 +58,7 @@ class ScriptedEffectConfig : public GenericScriptedConfig public: ScriptedEffectConfig(const QString &keyword, QWidget *parent, const QVariantList &args); ~ScriptedEffectConfig() override; + protected: QString typeName() const override; KConfigGroup configGroup() override; @@ -77,8 +78,7 @@ protected: void reload() override; }; -inline -const QString &GenericScriptedConfig::packageName() const +inline const QString &GenericScriptedConfig::packageName() const { return m_packageName; } diff --git a/src/scripting/screenedgeitem.cpp b/src/scripting/screenedgeitem.cpp index b24ab61489..a2a2032f77 100644 --- a/src/scripting/screenedgeitem.cpp +++ b/src/scripting/screenedgeitem.cpp @@ -7,7 +7,9 @@ SPDX-License-Identifier: GPL-2.0-or-later */ #include "screenedgeitem.h" + #include + #include "screenedge.h" #include @@ -15,7 +17,7 @@ namespace KWin { -ScreenEdgeItem::ScreenEdgeItem(QObject* parent) +ScreenEdgeItem::ScreenEdgeItem(QObject *parent) : QObject(parent) , m_enabled(true) , m_edge(NoEdge) diff --git a/src/scripting/screenedgeitem.h b/src/scripting/screenedgeitem.h index 1856c7c26e..08dbf676e7 100644 --- a/src/scripting/screenedgeitem.h +++ b/src/scripting/screenedgeitem.h @@ -73,7 +73,8 @@ public: ~ScreenEdgeItem() override; bool isEnabled() const; Edge edge() const; - Mode mode() const { + Mode mode() const + { return m_mode; } @@ -91,6 +92,7 @@ Q_SIGNALS: private Q_SLOTS: bool borderActivated(ElectricBorder edge); + private: void enableEdge(); void disableEdge(); diff --git a/src/scripting/scriptedeffect.cpp b/src/scripting/scriptedeffect.cpp index c26819f035..2bbdbd25dd 100644 --- a/src/scripting/scriptedeffect.cpp +++ b/src/scripting/scriptedeffect.cpp @@ -9,18 +9,18 @@ */ #include "scriptedeffect.h" +#include "scripting_logging.h" #include "scriptingutils.h" #include "workspace_wrapper.h" -#include "scripting_logging.h" #include "input.h" #include "screenedge.h" #include "workspace.h" // KDE #include -#include #include #include +#include // Qt #include #include @@ -32,14 +32,15 @@ Q_DECLARE_METATYPE(KSharedConfigPtr) namespace KWin { -struct AnimationSettings { +struct AnimationSettings +{ enum { - Type = 1<<0, - Curve = 1<<1, - Delay = 1<<2, - Duration = 1<<3, - FullScreen = 1<<4, - KeepAlive = 1<<5 + Type = 1 << 0, + Curve = 1 << 1, + Delay = 1 << 2, + Duration = 1 << 3, + FullScreen = 1 << 4, + KeepAlive = 1 << 5 }; AnimationEffect::Attribute type; QEasingCurve::Type curve; @@ -150,7 +151,7 @@ ScriptedEffect *ScriptedEffect::create(const KPluginMetaData &effect) return ScriptedEffect::create(name, scriptFile, effect.value(QStringLiteral("X-KDE-Ordering")).toInt()); } -ScriptedEffect *ScriptedEffect::create(const QString& effectName, const QString& pathToScript, int chainPosition) +ScriptedEffect *ScriptedEffect::create(const QString &effectName, const QString &pathToScript, int chainPosition) { ScriptedEffect *effect = new ScriptedEffect(); if (!effect->init(effectName, pathToScript)) { @@ -175,7 +176,7 @@ ScriptedEffect::ScriptedEffect() { Q_ASSERT(effects); connect(effects, &EffectsHandler::activeFullScreenEffectChanged, this, [this]() { - Effect* fullScreenEffect = effects->activeFullScreenEffect(); + Effect *fullScreenEffect = effects->activeFullScreenEffect(); if (fullScreenEffect == m_activeFullScreenEffect) { return; } @@ -240,7 +241,7 @@ bool ScriptedEffect::init(const QString &effectName, const QString &pathToScript globalObject.setProperty(QStringLiteral("QEasingCurve"), m_engine->newQMetaObject(&QEasingCurve::staticMetaObject)); - static const QStringList globalProperties { + static const QStringList globalProperties{ QStringLiteral("animationTime"), QStringLiteral("displayWidth"), QStringLiteral("displayHeight"), @@ -348,18 +349,17 @@ QJSValue ScriptedEffect::animate_helper(const QJSValue &object, AnimationType an s.metaData = 0; typedef QMap MetaTypeMap; - static MetaTypeMap metaTypes({ - {AnimationEffect::SourceAnchor, QStringLiteral("sourceAnchor")}, - {AnimationEffect::TargetAnchor, QStringLiteral("targetAnchor")}, - {AnimationEffect::RelativeSourceX, QStringLiteral("relativeSourceX")}, - {AnimationEffect::RelativeSourceY, QStringLiteral("relativeSourceY")}, - {AnimationEffect::RelativeTargetX, QStringLiteral("relativeTargetX")}, - {AnimationEffect::RelativeTargetY, QStringLiteral("relativeTargetY")}, - {AnimationEffect::Axis, QStringLiteral("axis")} - }); + static MetaTypeMap metaTypes({{AnimationEffect::SourceAnchor, QStringLiteral("sourceAnchor")}, + {AnimationEffect::TargetAnchor, QStringLiteral("targetAnchor")}, + {AnimationEffect::RelativeSourceX, QStringLiteral("relativeSourceX")}, + {AnimationEffect::RelativeSourceY, QStringLiteral("relativeSourceY")}, + {AnimationEffect::RelativeTargetX, QStringLiteral("relativeTargetX")}, + {AnimationEffect::RelativeTargetY, QStringLiteral("relativeTargetY")}, + {AnimationEffect::Axis, QStringLiteral("axis")}}); for (auto it = metaTypes.constBegin(), - end = metaTypes.constEnd(); it != end; ++it) { + end = metaTypes.constEnd(); + it != end; ++it) { QJSValue metaVal = value.property(*it); if (metaVal.isNumber()) { AnimationEffect::setMetaData(it.key(), metaVal.toInt(), s.metaData); @@ -509,9 +509,9 @@ bool ScriptedEffect::cancel(const QList &animationIds) return ret; } -bool ScriptedEffect::isGrabbed(EffectWindow* w, ScriptedEffect::DataRole grabRole) +bool ScriptedEffect::isGrabbed(EffectWindow *w, ScriptedEffect::DataRole grabRole) { - void *e = w->data(static_cast(grabRole)).value(); + void *e = w->data(static_cast(grabRole)).value(); if (e) { return e != this; } else { @@ -637,7 +637,7 @@ bool ScriptedEffect::unregisterScreenEdge(int edge) { auto it = screenEdgeCallbacks().find(edge); if (it == screenEdgeCallbacks().end()) { - //not previously registered + // not previously registered return false; } ScreenEdges::self()->unreserve(static_cast(edge), this); diff --git a/src/scripting/scriptedeffect.h b/src/scripting/scriptedeffect.h index 9f03cc0e8e..5225c1867a 100644 --- a/src/scripting/scriptedeffect.h +++ b/src/scripting/scriptedeffect.h @@ -56,11 +56,13 @@ public: enum EasingCurve { GaussianCurve = 128 }; - const QString &scriptFile() const { + const QString &scriptFile() const + { return m_scriptFile; } void reconfigure(ReconfigureFlags flags) override; - int requestedEffectChainPosition() const override { + int requestedEffectChainPosition() const override + { return m_chainPosition; } QString activeConfig() const; @@ -146,7 +148,8 @@ public: Q_SCRIPTABLE bool cancel(quint64 animationId); Q_SCRIPTABLE bool cancel(const QList &animationIds); - QHash &screenEdgeCallbacks() { + QHash &screenEdgeCallbacks() + { return m_screenEdgeCallbacks; } @@ -184,7 +187,7 @@ private: QHash m_screenEdgeCallbacks; KConfigLoader *m_config; int m_chainPosition; - QHash m_touchScreenEdgeCallbacks; + QHash m_touchScreenEdgeCallbacks; Effect *m_activeFullScreenEffect = nullptr; }; diff --git a/src/scripting/scripting.cpp b/src/scripting/scripting.cpp index cc0550478f..154d1e845b 100644 --- a/src/scripting/scripting.cpp +++ b/src/scripting/scripting.cpp @@ -13,11 +13,11 @@ // own #include "dbuscall.h" #include "desktopbackgrounditem.h" -#include "scriptingutils.h" -#include "workspace_wrapper.h" #include "screenedgeitem.h" #include "scripting_logging.h" +#include "scriptingutils.h" #include "thumbnailitem.h" +#include "workspace_wrapper.h" #include "v2/clientmodel.h" #include "v3/clientmodel.h" @@ -38,14 +38,14 @@ #include #include #include -#include -#include #include #include #include #include -#include #include +#include +#include +#include #include "scriptadaptor.h" @@ -103,7 +103,7 @@ KWin::ScriptTimer::ScriptTimer(QObject *parent) { } -KWin::Script::Script(int id, QString scriptName, QString pluginName, QObject* parent) +KWin::Script::Script(int id, QString scriptName, QString pluginName, QObject *parent) : AbstractScript(id, scriptName, pluginName, parent) , m_engine(new QJSEngine(this)) , m_starting(false) @@ -159,7 +159,7 @@ QByteArray KWin::Script::loadScriptFromFile(const QString &fileName) void KWin::Script::slotScriptLoadedFromFile() { - QFutureWatcher *watcher = dynamic_cast< QFutureWatcher< QByteArray>* >(sender()); + QFutureWatcher *watcher = dynamic_cast *>(sender()); if (!watcher) { // not invoked from a QFutureWatcher return; @@ -201,7 +201,7 @@ void KWin::Script::slotScriptLoadedFromFile() QJSValue self = m_engine->newQObject(this); QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); - static const QStringList globalProperties { + static const QStringList globalProperties{ QStringLiteral("readConfig"), QStringLiteral("callDBus"), @@ -352,11 +352,11 @@ bool KWin::Script::registerShortcut(const QString &objectName, const QString &te action->setText(text); const QKeySequence shortcut = keySequence; - KGlobalAccel::self()->setShortcut(action, { shortcut }); + KGlobalAccel::self()->setShortcut(action, {shortcut}); input()->registerShortcut(shortcut, action); connect(action, &QAction::triggered, this, [this, action, callback]() { - QJSValue(callback).call({ m_engine->toScriptValue(action) }); + QJSValue(callback).call({m_engine->toScriptValue(action)}); }); return true; @@ -441,7 +441,7 @@ QList KWin::Script::actionsForUserActionMenu(KWin::AbstractClient *cl actions.reserve(m_userActionsMenuCallbacks.count()); for (QJSValue callback : qAsConst(m_userActionsMenuCallbacks)) { - const QJSValue result = callback.call({ m_engine->toScriptValue(client) }); + const QJSValue result = callback.call({m_engine->toScriptValue(client)}); if (result.isError()) { continue; } @@ -499,7 +499,7 @@ QAction *KWin::Script::createAction(const QString &title, const QJSValue &item, action->setChecked(checked); connect(action, &QAction::triggered, this, [this, action, callback]() { - QJSValue(callback).call({ m_engine->toScriptValue(action) }); + QJSValue(callback).call({m_engine->toScriptValue(action)}); }); return action; @@ -530,7 +530,7 @@ QAction *KWin::Script::createMenu(const QString &title, const QJSValue &items, Q return menu->menuAction(); } -KWin::DeclarativeScript::DeclarativeScript(int id, QString scriptName, QString pluginName, QObject* parent) +KWin::DeclarativeScript::DeclarativeScript(int id, QString scriptName, QString pluginName, QObject *parent) : AbstractScript(id, scriptName, pluginName, parent) , m_context(new QQmlContext(Scripting::self()->declarativeScriptSharedContext(), this)) , m_component(new QQmlComponent(Scripting::self()->qmlEngine(), this)) @@ -586,14 +586,16 @@ QVariant KWin::JSEngineGlobalMethodsWrapper::readConfig(const QString &key, QVar void KWin::JSEngineGlobalMethodsWrapper::registerWindow(QQuickWindow *window) { QPointer guard = window; - connect(window, &QWindow::visibilityChanged, this, [guard](QWindow::Visibility visibility) { - if (guard && visibility == QWindow::Hidden) { - guard->destroy(); - } - }, Qt::QueuedConnection); + connect( + window, &QWindow::visibilityChanged, this, [guard](QWindow::Visibility visibility) { + if (guard && visibility == QWindow::Hidden) { + guard->destroy(); + } + }, + Qt::QueuedConnection); } -bool KWin::JSEngineGlobalMethodsWrapper::registerShortcut(const QString &name, const QString &text, const QKeySequence& keys, QJSValue function) +bool KWin::JSEngineGlobalMethodsWrapper::registerShortcut(const QString &name, const QString &text, const QKeySequence &keys, QJSValue function) { if (!function.isCallable()) { qCDebug(KWIN_SCRIPTING) << "Fourth and final argument must be a javascript function"; @@ -695,8 +697,8 @@ void KWin::Scripting::start() #else LoadScriptList scriptsToLoad = queryScriptsToLoad(); for (LoadScriptList::const_iterator it = scriptsToLoad.constBegin(); - it != scriptsToLoad.constEnd(); - ++it) { + it != scriptsToLoad.constEnd(); + ++it) { if (it->first) { loadScript(it->second.first, it->second.second); } else { @@ -717,13 +719,13 @@ LoadScriptList KWin::Scripting::queryScriptsToLoad() } else { s_started = true; } - QMap pluginStates = KConfigGroup(_config, "Plugins").entryMap(); + QMap pluginStates = KConfigGroup(_config, "Plugins").entryMap(); const QString scriptFolder = QStringLiteral(KWIN_NAME "/scripts/"); const auto offers = KPackage::PackageLoader::self()->listPackages(QStringLiteral("KWin/Script"), scriptFolder); LoadScriptList scriptsToLoad; - for (const KPluginMetaData &service: offers) { + for (const KPluginMetaData &service : offers) { const QString value = pluginStates.value(service.pluginId() + QLatin1String("Enabled"), QString()); const bool enabled = value.isNull() ? service.isEnabledByDefault() : QVariant(value).toBool(); const bool javaScript = service.value(QStringLiteral("X-Plasma-API")) == QLatin1String("javascript"); @@ -753,7 +755,7 @@ LoadScriptList KWin::Scripting::queryScriptsToLoad() void KWin::Scripting::slotScriptsQueried() { - QFutureWatcher *watcher = dynamic_cast< QFutureWatcher* >(sender()); + QFutureWatcher *watcher = dynamic_cast *>(sender()); if (!watcher) { // slot invoked not from a FutureWatcher return; @@ -761,8 +763,8 @@ void KWin::Scripting::slotScriptsQueried() LoadScriptList scriptsToLoad = watcher->result(); for (LoadScriptList::const_iterator it = scriptsToLoad.constBegin(); - it != scriptsToLoad.constEnd(); - ++it) { + it != scriptsToLoad.constEnd(); + ++it) { if (it->first) { loadScript(it->second.first, it->second.second); } else { @@ -813,10 +815,10 @@ void KWin::Scripting::runScripts() void KWin::Scripting::scriptDestroyed(QObject *object) { QMutexLocker locker(m_scriptsLock.data()); - scripts.removeAll(static_cast(object)); + scripts.removeAll(static_cast(object)); } -int KWin::Scripting::loadScript(const QString &filePath, const QString& pluginName) +int KWin::Scripting::loadScript(const QString &filePath, const QString &pluginName) { QMutexLocker locker(m_scriptsLock.data()); if (isScriptLoaded(pluginName)) { @@ -829,7 +831,7 @@ int KWin::Scripting::loadScript(const QString &filePath, const QString& pluginNa return id; } -int KWin::Scripting::loadDeclarativeScript(const QString& filePath, const QString& pluginName) +int KWin::Scripting::loadDeclarativeScript(const QString &filePath, const QString &pluginName) { QMutexLocker locker(m_scriptsLock.data()); if (isScriptLoaded(pluginName)) { @@ -848,9 +850,9 @@ KWin::Scripting::~Scripting() s_self = nullptr; } -QList< QAction * > KWin::Scripting::actionsForUserActionMenu(KWin::AbstractClient *c, QMenu *parent) +QList KWin::Scripting::actionsForUserActionMenu(KWin::AbstractClient *c, QMenu *parent) { - QList actions; + QList actions; for (AbstractScript *s : qAsConst(scripts)) { // TODO: Allow declarative scripts to add their own user actions. if (Script *script = qobject_cast