1. 22 Sep, 2020 1 commit
    • Aleix Pol Gonzalez's avatar
      Centralize WindowPixmap buffer updating code · 61e655f7
      Aleix Pol Gonzalez authored
      Uses a setter and clear method pattern rather than having the code
      repeated.
      Instead of keeping a QPointer, now we are a QObject and we get notified
      about destruction intention directly, so we can clear the pointer when
      necessary.
      61e655f7
  2. 09 Sep, 2020 1 commit
    • Vlad Zahorodnii's avatar
      Properly handle opaque regions for CSD X11 windows · 2b241d30
      Vlad Zahorodnii authored
      Currently, we don't compute the clip region properly for some client-
      side decorated applications, for example gedit, due to mixing several
      separate coordinate spaces.
      
      This change ensures that the window pixmap shape and the opaque region
      are in the same coordinate space - the window pixmap coordinate.
      
      In order to simplify mapping regions from the window pixmap coordinates
      to the global screen coordinates, a new helper method was introduced in
      the WindowPixmap class - mapToGlobal().
      2b241d30
  3. 19 Aug, 2020 1 commit
    • Aleix Pol Gonzalez's avatar
      Implement EGL_KHR_partial_update and EGL_EXT_swap_buffers_with_damage · eeeac049
      Aleix Pol Gonzalez authored
      Summary:
      Notify the driver about the parts of the screen that will be repainted.
      In some cases this can be benefitial. This is especially useful on lima
      and panfrost devices (e.g. pinephone, pinebook, pinebook pro).
      
      Test Plan:
      Tested on a pinebook pro with a late mesa version.
      Basically I implemented it, then it didn't work and I fixed it.
      Maybe next step we want to look into our damage algorithm.
      eeeac049
  4. 07 Aug, 2020 2 commits
    • Vlad Zahorodnii's avatar
      Prettify license headers · 4ce853e8
      Vlad Zahorodnii authored
      4ce853e8
    • Vlad Zahorodnii's avatar
      Switch to SPDX license markers · 1fb9f6f1
      Vlad Zahorodnii authored
      The main advantage of SPDX license identifiers over the traditional
      license headers is that it's more difficult to overlook inappropriate
      licenses for kwin, for example GPL 3. We also don't have to copy a
      lot of boilerplate text.
      
      In order to create this change, I ran licensedigger -r -c from the
      toplevel source directory.
      1fb9f6f1
  5. 23 Jul, 2020 1 commit
  6. 10 Jun, 2020 3 commits
    • Vlad Zahorodnii's avatar
      [scene] Setup scene window connections with correct receiver object · c890996a
      Vlad Zahorodnii authored
      We need a couple of connections to ensure that the window pixmap, the
      window quad cache, and the window shape get discarded when the geometry
      of the toplevel has been changed. Currently, those connections are
      created with the receiver object being the scene. The problem is that
      the associated wayland surface may outlive the toplevel and we don't
      cleanup the connections after the scene window has been destroyed.
      
      The fact that the connections don't get destroyed can lead to accessing
      dangling pointers, which may result in a crash.
      
      In order to ensure that the connections are broken automatically when
      the scene window is destroyed, we need to ensure that the received
      object is the scene window. That way, the connections will be destroyed
      automatically.
      c890996a
    • Vlad Zahorodnii's avatar
      [scene] Rename a scene window method · 430b63d1
      Vlad Zahorodnii authored
      This change renames invalidateQuadsCache() to discardQuads() because the
      latter name is shorter and it aligns with pre-existing method names.
      430b63d1
    • Vlad Zahorodnii's avatar
      [scene] Make the scene window a qobject · cb4dc0ff
      Vlad Zahorodnii authored
      Since the scene window is not a QObject, we cannot connect toplevel's
      signals directly to the scene window's slots.
      cb4dc0ff
  7. 03 Jun, 2020 1 commit
    • Vlad Zahorodnii's avatar
      [scene] Introduce helpers for mapping between different coordinate spaces · 9e797cf9
      Vlad Zahorodnii authored
      We currently deal with three distinct coordinate spaces - the window
      pixmap coordinate space, the window coordinate space, and the buffer
      pixel coordinate space.
      
      This change introduces a couple of helper methods to make it easier
      to map points from the window pixmap space to the other two spaces.
      
      The main motivation behind the new helpers is to break the direct
      relationship between the surface-local coordinates and buffer pixel
      coordinates for wayland surfaces.
      9e797cf9
  8. 02 Jun, 2020 1 commit
  9. 04 May, 2020 3 commits
    • Vlad Zahorodnii's avatar
      [scene] Generate window quads for sub-surfaces · f2c8981f
      Vlad Zahorodnii authored
      No window quads are generated for sub-surfaces right now. This leads to
      issues with effects that operate on window quads, e.g. magic lamp and
      wobbly windows. Furthermore, the OpenGL scene needs window quads to
      properly clip windows during the rendering process.
      
      The best way to render sub-surfaces would be with a little help from a
      scene graph. Contrary to GNOME, KDE hasn't developed any scene graph
      implementation that we could use in kwin. As a short term solution, this
      change adjusts the scene to generate window quads.
      
      Window quads are generated as we traverse the current window pixmap tree
      in the depth-first search manner. In order to match a list of quads with
      a particular WindowPixmap, we assign an id to each quad.
      
      BUG: 387313
      FIXED-IN: 5.19.0
      
      Differential Revision: https://phabricator.kde.org/D29131
      f2c8981f
    • Vlad Zahorodnii's avatar
      [scene] Release previous pixmap when a raster buffer is attached · 2d88fd0e
      Vlad Zahorodnii authored
      We need to release the previous window pixmap if the new pixmap is
      valid. However, it's currently the case only when the client has
      attached either an fbo buffer or a wl_buffer. If an internal client
      has attached a raster buffer, the previous window pixmap won't be
      released.
      
      In order to ensure that we're going to release the previous window
      pixmaps no matter what type of buffer has been attached, this change
      refactors WindowPixmap to use isValid() to verify that the new
      window pixmap is valid.
      
      Differential Revision: https://phabricator.kde.org/D29131
      2d88fd0e
    • Vlad Zahorodnii's avatar
      [scene] Build window pixmap trees before starting rendering · e4b598ca
      Vlad Zahorodnii authored
      In order to generate window quads for sub-surfaces, we need a valid
      window pixmap tree. The problem is that the window pixmap tree is
      created too late in the rendering process. This change adjusts the
      scene so it creates window pixmap trees before buildQuads().
      
      Differential Revision: https://phabricator.kde.org/D29131
      e4b598ca
  10. 30 Apr, 2020 1 commit
  11. 20 Apr, 2020 1 commit
    • Méven Car's avatar
      Wayland: Allow to take single screen screenshots using scale factor without loss · 66898e7f
      Méven Car authored
      Summary:
      The screenshot made on screens with scale factor were downscaled by their scale factor making them blurry.
      It prevents taking screenshots of missing Hidpi related bugs showing the issues under Wayland.
      
      This fix the case of a single screenshot, but not the rest:
      Multiscreen screenshot downscales the screen using scale factor.
      Spectacle rectangular selection screenshot is broken as soon as some scale factor different than 1 is used on any screen.
      
      Test Plan:
      Under Wayland with a scale factor on a screen, take a screenshot using spectacle.
      The output image is not downscaled and has the same size as the screen resolution.
      
      No other change to any other screenshot mode, or under X.
      
      Reviewers: davidedmundson, #kwin
      
      Reviewed By: davidedmundson, #kwin
      
      Subscribers: kwin
      
      Tags: #kwin
      
      Differential Revision: https://phabricator.kde.org/D29010
      66898e7f
  12. 14 Mar, 2020 1 commit
  13. 03 Feb, 2020 1 commit
    • Vlad Zahorodnii's avatar
      [x11] Fix visual artifacts during interactive resize · 56d5f3a4
      Vlad Zahorodnii authored
      Summary:
      When a window is being interactively resized, its contents may jump. The
      reason why that happens is because KWin renders partially resized client
      window. Composite extension spec says that a window will get a new pixmap
      each time it is resized or mapped. This applies to the frame window, but
      not to the client window itself. If the client window is resized,
      off-screen storage for the frame window won't be reallocated. Therefore,
      KWin may render partially resized client window if the client doesn't
      attempt to be in sync with our rendering loop. Currently, the only way
      to do that is to use extended frame counters, which are not supported by
      KWin.
      
      So, in order to fix visual artifacts during interactive resize, we need
      somehow forcefully re-allocate off-screen storage for the frame window.
      Unfortunately, Composite extension doesn't provide any request to do
      that, so the only option we have is to resize the frame window.
      
      BUG: 415839
      FIXED-IN: 5.18....
      56d5f3a4
  14. 16 Jan, 2020 3 commits
  15. 12 Dec, 2019 1 commit
    • Roman Gilg's avatar
      Add hasSwapEvent getter · a55dee3b
      Roman Gilg authored
      Summary:
      Add a small getter to query information internally if the backend supports
      swap events. Defaults to true as it is the default in the GBM Wayland backend.
      
      Test Plan: i915
      
      Reviewers: #kwin
      
      Subscribers: kwin
      
      Tags: #kwin
      
      Maniphest Tasks: T11071
      
      Differential Revision: https://phabricator.kde.org/D25298
      a55dee3b
  16. 02 Dec, 2019 2 commits
    • Vlad Zahorodnii's avatar
      Revert the fix for the texture bleeding issue · 6e000314
      Vlad Zahorodnii authored
      This reverts commit 9151bb7b.
      This reverts commit ac4dce1c.
      This reverts commit 754b72d1.
      
      In order to make the fix work, we need to redirect the client window
      instead of the frame window. However, we cannot to do that because
      Xwayland expects the toplevel window(in our case, the frame window)
      to be redirected.
      
      Another solution to the texture bleeding issue must be found.
      
      CCBUG: 257566
      CCBUG: 360549
      6e000314
    • Vlad Zahorodnii's avatar
      [x11] Name client pixmap instead of frame pixmap · 754b72d1
      Vlad Zahorodnii authored
      Summary:
      Since KDE 4.2 - 4.3 times, KWin doesn't paint window decorations on real
      X11 windows, except when compositing is turned off. This leaves us with
      a problem. The actual client contents is inside a larger texture with no
      useful pixel data around it. This and decoration texture bleeding are
      the main factors that contribute to 1px gap between the server-side
      decoration and client contents with effects such as wobbly windows, and
      zoom.
      
      Another problem with naming frame pixmap instead of client pixmap is
      that it doesn't quite go along with wayland. It only makes more difficult
      to abstract window quad generation in the scene.
      
      Since we don't actually need the frame window when compositing is on,
      there is nothing that holds us from redirecting client windows instead
      of frame windows. This will help us to fix the texture bleeding issue
      and also help us with the ongoing redesign of the scene.
      
      Test Plan: X11 clients are still composited.
      
      Reviewers: #kwin, davidedmundson
      
      Reviewed By: #kwin, davidedmundson
      
      Subscribers: davidedmundson, kwin
      
      Tags: #kwin
      
      Differential Revision: https://phabricator.kde.org/D25610
      754b72d1
  17. 27 Nov, 2019 2 commits
    • Vlad Zahorodnii's avatar
      Drop some custom list typedefs · 9d4a3259
      Vlad Zahorodnii authored
      Summary:
      Qt has its own thing where a type might also have corresponding list
      alias, e.g. QObject and QObjectList, QWidget and QWidgetList. I don't
      know why Qt does that, maybe for some historical reasons, but what
      matters is that we copy this pattern here in KWin. While this pattern
      might be useful with some long list types, for example
      
          QList<QWeakPointer<TabBoxClient>> TabBoxClientList
      
      in general, it causes more harm than good. For example, we've got two
      new client types, do we need corresponding list typedefs for them? If
      no, why do we have ClientList and so on?
      
      Another problem with these typedefs is that you need to include utils.h
      header in order to use them. A better way to handle such things is to
      just forward declare a client class (if that's possible) and use it
      directly with QList or QVector. This way translation units don't get
      "bloated" with utils.h stuff for no apparent reason.
      
      So, in order to make code more consistent and easier to follow, this
      change d...
      9d4a3259
    • Vlad Zahorodnii's avatar
      Adjust scene for client-side decorated clients · fb2d4c11
      Vlad Zahorodnii authored
      Summary:
      Currently our Scene is quite naive about geometry. It assumes that the
      window frame wraps the attached buffer/client. While this is true for X11
      clients, such geometry model is not suitable for client-side decorated
      clients, in our case for xdg-shell clients that set window geometry
      other than the bounding rectangle of the main surface.
      
      In general, the proposed solution doesn't make any concrete assumptions
      about the order between frame and buffer geometry, however we may still
      need to reconsider the design of Scene once it starts to generate quads
      for sub-surfaces.
      
      Reviewers: #kwin, davidedmundson
      
      Reviewed By: #kwin, davidedmundson
      
      Subscribers: davidedmundson, romangg, kwin
      
      Tags: #kwin
      
      Maniphest Tasks: T10867
      
      Differential Revision: https://phabricator.kde.org/D24462
      fb2d4c11
  18. 14 Nov, 2019 2 commits
    • Roman Gilg's avatar
      [platforms/x11] Never block on retrace, always present after paint · 8d137290
      Roman Gilg authored
      Summary:
      Compositing in X11 was done time shifted, meaning that we paint first, then
      wait one vblank interval length and present on prepareRenderingFrame the
      previous paint result. This is supposed to make sure we don't miss the vblank
      and in case of block till retrace be able to continue issuing commands and
      only shortly before next vblank present.
      
      This is counter-intuitiv, not how we do it on Wayland or even on MESA with X.
      The reason seems to be that the GLX backend was in the beginning written
      against Nvidia proprietary driver which needed this but nowadays even this
      driver defaults to non-blocking behavior on buffer swap.
      
      Therefore remove this legacy anomaly fully and directly present after paint.
      We then wait one refresh cycle and in the future can optimize this by delaying
      the paint and present till shortly before vsync.
      
      Test Plan: kwin_x11 tested on i915 and Nvidia proprietary driver.
      
      Reviewers: #kwin
      
      Subscribers: zzag, alexeymin, kwin
      
      Tags: #kwin
      
      Maniphest Tasks: T11071
      
      Differential Revision: https://phabricator.kde.org/D23514
      8d137290
    • Roman Gilg's avatar
      Remove vsync detection and configurability · b3a19f9e
      Roman Gilg authored
      Summary:
      Selecting not to vsync does not make sense for an X11 compositor. In the end
      we want clients to be able to present async if they want to but the compositor
      is supposed to send swaps with vsync to the XServer in order to not generate
      tearing artifacts.
      
      There was also a detection logic which did some questionable things in case
      vsync was not available. I don't think this is necessary at all since we can
      just always run a timer to present with or without vsync.
      
      Test Plan: kwin_x11 tested on i915.
      
      Reviewers: #kwin, zzag
      
      Subscribers: zzag, kwin
      
      Tags: #kwin
      
      Maniphest Tasks: T11071
      
      Differential Revision: https://phabricator.kde.org/D23511
      b3a19f9e
  19. 02 Oct, 2019 1 commit
    • Vlad Zahorodnii's avatar
      Rename geometry property to frameGeometry · 7d4471eb
      Vlad Zahorodnii authored
      Summary:
      In order to properly implement xdg_surface.set_window_geometry we need
      two kinds of geometry - frame and buffer. The frame geometry specifies
      visible bounds of the client on the screen, excluding client-side drop
      shadows. The buffer geometry specifies rectangle on the screen that the
      attached buffer or x11 pixmap occupies on the screen.
      
      This change renames the geometry property to frameGeometry in order to
      reflect the new meaning assigned to it as well to make it easier to
      differentiate between frame geometry and buffer geometry in the future.
      
      Reviewers: #kwin
      
      Subscribers: kwin
      
      Tags: #kwin
      
      Differential Revision: https://phabricator.kde.org/D24334
      7d4471eb
  20. 27 Sep, 2019 1 commit
    • David Edmundson's avatar
      [libkwineffects] Introduce API to easily show a QtQuick scene in an effect · 40b0296d
      David Edmundson authored
      Summary:
      EffectQuickView/Scene is a convenient class to render a QtQuick
      scenegraph into an effect.
      
      Current methods (such as present windows) involve creating an underlying
      platform window which is expensive, causes a headache to filter out
      again in the rest of the code, and only works as an overlay.
      
      The new class exposes things more natively to an effect where we don't
      mess with real windows, we can perform the painting anywhere in the view
      and we don't have issues with hiding/closing.
      
      QtQuick has both software and hardware accelerated modes, and kwin also
      has 3 render backends. Every combination is supported.
      
      * When used in OpenGL mode for both, we render into an FBO export the
      texture ID then it's up to the effect to render that into a scene.
      
      * When using software QtQuick rendering we blit into an image, upload
      that into a KWinGLTexture which serves as an abstraction layer and
      render that into the scene.
      
      * When using GL for QtQuick and XRender/QPainter in kwin everything is
      rendered into the internal FBO, blit and exported as an image.
      
      * When using software rendering for both an image gets passed directly.
      
      Mouse and keyboard events can be forwarded, only if the effect
      intercepts them.
      
      The class is meant to be generic enough that we can remove all the
      QtQuick code from Aurorae.
      
      The intention is also to replace EffectFrameImpl using this backend and
      we can kill all of the EffectFrame code throughout the scenes.
      
      The close button in present windows will also be ported to this,
      simplifiying that code base.
      
      Classes that handle the rendering and handling QML are intentionally
      split so that in the future we can have a declarative effects API create
      overlays from within the same context. Similar to how one can
      instantiate windows from a typical QML scene.
      
      Notes:
      I don't like how I pass the kwin GL context from the backends into the
      effect, but I need something that works with the library separation. It
      also currently has wayland problem if I create a QOpenGLContext before
      the QPA is set up with a scene - but I don't have anything better?
      
      I know for the EffectFrame we need an API to push things through the
      effects stack to handle blur/invert etc. Will deal with that when we
      port the EffectFrame.
      
      Test Plan: Used in an effect
      
      Reviewers: #kwin, zzag
      
      Reviewed By: #kwin, zzag
      
      Subscribers: zzag, kwin
      
      Tags: #kwin
      
      Differential Revision: https://phabricator.kde.org/D24215
      40b0296d
  21. 23 Sep, 2019 1 commit
    • Vlad Zahorodnii's avatar
      Port QPA away from Wayland · bebe8120
      Vlad Zahorodnii authored
      Summary:
      So far wayland was used by internal clients to submit raster buffers
      and position themselves on the screen. While we didn't have issues with
      submitting raster buffers, there were some problems with positioning
      task switchers. Mostly, because we had effectively two paths that may
      alter geometry.
      
      A better approach to deal with internal clients is to let our QPA use
      kwin core api directly. This way we can eliminate unnecessary roundtrips
      as well make geometry handling much easier and comprehensible.
      
      The last missing piece is shadows. Both Plasma::Dialog and Breeze widget
      style use platform-specific APIs to set and unset shadows. We need to
      add shadows API to KWindowSystem. Even though some internal clients lack
      drop-shadows at the moment, I don't consider it to be a blocker. We can
      add shadows back later on.
      
      CCBUG: 386304
      
      Reviewers: #kwin, davidedmundson, romangg
      
      Reviewed By: #kwin, romangg
      
      Subscribers: romangg, kwin
      
      Tags: #kwin
      
      Maniphest Tasks: T9600
      
      Differential Revision: https://phabricator.kde.org/D22810
      bebe8120
  22. 14 Sep, 2019 1 commit
  23. 07 Aug, 2019 1 commit
    • Roman Gilg's avatar
      Split Compositor class in Wayland and X11 child classes · 1db84a2b
      Roman Gilg authored
      Summary:
      This patch is a first take at splitting up of the Compositor class into
      Wayland and X11 child classes.
      
      In this first patch we mostly deal with setup and teardown procedures.
      A future goal is to further differentiate the compositing part itself too.
      
      Test Plan: Manually X from VT and Wayland nested. Autotests pass.
      
      Reviewers: #kwin
      
      Subscribers: sbergeron, anthonyfieroni, zzag, kwin
      
      Tags: #kwin
      
      Maniphest Tasks: T11071
      
      Differential Revision: https://phabricator.kde.org/D22195
      1db84a2b
  24. 29 Jul, 2019 1 commit
    • Vlad Zahorodnii's avatar
      Use more traditional doxygen style · 684b4b63
      Vlad Zahorodnii authored
      Summary:
      So far we were following a bit unique and rare doxygen comment style:
      
          /**
           * Contents of the comment.
           **/
      
      Doxygen comments with this style look balanced and neat, but many people
      that contribute to KWin don't follow this style. Instead, they prefer
      more traditional doxygen comment style, i.e.
      
          /**
           * Contents of the comment.
           */
      
      Reviewing such changes has been a bit frustrating for me (so selfish!)
      and for other contributors.
      
      This change switches doxygen comment style in KWin to a more traditional
      style. The main reason for doing this is to make code review process easier
      for new contributors as well us.
      
      Reviewers: #kwin, davidedmundson
      
      Reviewed By: #kwin, davidedmundson
      
      Subscribers: kwin
      
      Tags: #kwin
      
      Differential Revision: https://phabricator.kde.org/D22812
      684b4b63
  25. 22 Jul, 2019 1 commit
    • Vlad Zahorodnii's avatar
      Run clang-tidy with modernize-use-override check · 8af2fa73
      Vlad Zahorodnii authored
      Summary:
      Currently code base of kwin can be viewed as two pieces. One is very
      ancient, and the other one is more modern, which uses new C++ features.
      
      The main problem with the ancient code is that it was written before
      C++11 era. So, no override or final keywords, lambdas, etc.
      
      Quite recently, KDE compiler settings were changed to show a warning if
      a virtual method has missing override keyword. As you might have already
      guessed, this fired back at us because of that ancient code. We had
      about 500 new compiler warnings.
      
      A "solution" was proposed to that problem - disable -Wno-suggest-override
      and the other similar warning for clang. It's hard to call a solution
      because those warnings are disabled not only for the old code, but also
      for new. This is not what we want!
      
      The main argument for not actually fixing the problem was that git
      history will be screwed as well because of human factor. While good git
      history is a very important thing, we should not go ...
      8af2fa73
  26. 14 Feb, 2019 1 commit
    • Vlad Zahorodnii's avatar
      Add addToplevel and removeToplevel to Scene · d1679351
      Vlad Zahorodnii authored
      Summary:
      Code that destroys all scene windows when finishing compositing is not
      readable. E.g. can you tell what this piece of code is doing without
      looking into the source code of Scene::windowClosed?
      
          foreach (Client * c, Workspace::self()->clientList())
              m_scene->windowClosed(c, NULL);
      
      This change intoduces removeToplevel(as well its counterpart) method to
      the Scene class. The name of the new method much better describes what
      we're doing.
      
      Reviewers: #kwin, davidedmundson
      
      Reviewed By: #kwin, davidedmundson
      
      Subscribers: kwin
      
      Tags: #kwin
      
      Differential Revision: https://phabricator.kde.org/D18210
      d1679351
  27. 12 Feb, 2019 1 commit
    • Vlad Zahorodnii's avatar
      Overhaul doxygen comments · 7b20e1f6
      Vlad Zahorodnii authored
      Summary:
      We have a mix of different doxygen comment styles, e.g.
      
          /*!
            Foo bar.
           */
      
          /**
           * Foo bar.
           */
      
          /** Foo bar.
           */
      
          /**
           * Foo bar.
           */
      
          /**
           * Foo bar.
           **/
      
      To make the code more consistent, this change updates the style of all
      doxygen comments to the last one.
      
      Test Plan: Compiles.
      
      Reviewers: #kwin, davidedmundson
      
      Reviewed By: #kwin, davidedmundson
      
      Subscribers: kwin
      
      Tags: #kwin
      
      Differential Revision: https://phabricator.kde.org/D18683
      7b20e1f6
  28. 12 Jan, 2019 2 commits
  29. 11 Jan, 2019 1 commit