1. 02 Aug, 2022 3 commits
    • Dor Askayo's avatar
      wayland/dma-buf: Don't require modifiers support for scanout tranche · 91ac4044
      Dor Askayo authored and Robert Mader's avatar Robert Mader committed
      When building the list of formats to be sent as part of the scanout
      tranche, avoid requiring modifier support by the DRM driver for
      formats relying on implicit modifiers (DRM_FORMAT_MOD_INVALID).
      Specifically, the previous check required the DRM driver to have
      advertised some modifier support for the given format in its
      IN_FORMATS KMS plane property, regardless of modifier it was. If it
      hadn't, the format was left out of the list of formats to be sent
      in the scanout tranche.
      When no formats remained to be sent in the scanout tranche, the
      tranche simply wasn't sent.
      This resulted in the scanout tranche never being sent for GPUs where
      modifiers aren't supported. In those cases, no formats are advertised
      using the IN_FORMATS property, and thus the list of formats to be sent
      in the scanout tranche remained empty.
      Since Mesa doesn't use scanout-compatible buffers for native Wayland
      clients unless specifically requested to do so using the "scanout"
      tranche flag, it effectively means that direct scanout of native
      Wayland clients wasn't supported for GPUs without modifiers support.
      Sending a tranche with formats paired with the implicit modifier
      (DRM_FORMAT_MOD_INVALID) is both allowed by the protocol and is
      already done by default for GPUs with modifiers support, unless the
      experimental support for explicit modifiers is enabled in Mutter.
      So instead of requiring modifiers to be supported for each format
      being evaluated for the scanout tranche, when processing formats
      which rely on implicit modifiers, only check if the format in
      question is supported by the DRM driver for scanout on the primary
      Part-of: <!2510>
      (cherry picked from commit f037c9df)
    • Dor Askayo's avatar
      tests/screen-cast: Avoid undefined behavior with GSource · 501a2ffe
      Dor Askayo authored and Pablo Correa Gomez's avatar Pablo Correa Gomez committed
      Follow the existing convention in Mutter and avoid downcasting
      custom GSource structs.
      Part-of: <!2406>
      (cherry picked from commit 40edfbcb)
    • Dor Askayo's avatar
      screen-cast/src: Avoid undefined behavior with GSource · fdfee403
      Dor Askayo authored and Pablo Correa Gomez's avatar Pablo Correa Gomez committed
      Follow the existing convention in Mutter and avoid downcasting
      custom GSource structs.
      This fixes the following warning:
          ../src/backends/meta-screen-cast-stream-src.c:1301:20: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
           1301 |   g_clear_pointer ((GSource **) &priv->pipewire_source, g_source_destroy);
          /usr/include/glib-2.0/glib/glib-typeof.h:36:36: note: in definition of macro ‘glib_typeof’
             36 | #define glib_typeof(t) __typeof__ (t)
                |                                    ^
          ../src/backends/meta-screen-cast-stream-src.c:1301:3: note: in expansion of macro ‘g_clear_pointer’
           1301 |   g_clear_pointer ((GSource **) &priv->pipewire_source, g_source_destroy);
                |   ^~~~~~~~~~~~~~~
      Part-of: <!2406>
      (cherry picked from commit 61c9e344)
  2. 29 Jul, 2022 6 commits
  3. 26 Jul, 2022 2 commits
    • Carlos Garnacho's avatar
      clutter/actor: Handle repicks when actors become reactive · 5981e074
      Carlos Garnacho authored
      The notification list in the GNOME Shell calendar popup triggers some
      interesting interactions when closing a notification:
      - Close button is clicked
      - The notification animates to be hidden
      - The next notification ends up hovered as a result of the animation
      - The notification being hovered sets its close button as non-transparent
        and reactive
      - The pointer is now again over a close button
      At this point the reactiveness change should trigger a repick, so that
      the new notification's close button is picked, and future button presses
      are directed to it, but we do not handle this situation.
      To fix this, handle actors becoming reactive so that if the closest
      reactive parent has a pointer, it will be repicked again just in case
      the pointer is over the newly reactive actor.
      Closes: #2364
      (cherry-picked from commit 550b66d4)
      Part-of: <!2533>
    • Carlos Garnacho's avatar
      clutter/stage: Add function to maybe invalidate pointers on an actor · 787bd707
      Carlos Garnacho authored
      The function that currently invalidates pointers over an specific actor
      also asserts for the situations where this invalidation makes sense to
      happen (i.e. the actor became unmapped, or non-reactive).
      We want to have a function that is more forgiving, and that doesn't
      enforce any guarantees about the pointer focus actually changing.
      (cherry-picked from commit 6dabdec1)
      Part-of: <!2533>
  4. 20 Jul, 2022 3 commits
    • Robert Mader's avatar
      wayland/actor-surface: Consider clones in is_on_logical_monitor() · d96efc7b
      Robert Mader authored
      While the check for `clutter_actor_has_mapped_clones` clearly indicates
      an intention to take clones into account, the following code
      does not do so, likely because it predates the introduction of
      Switch to that newer API in order to take clones into account. This
      avoids unnecessary `wl_surface_send_enter()` and `wl_surface_send_leave()`
      events when entering the overview, reducing client work.
      This also avoids unnecessarily allocating a `cairo_region_t`.
      Part-of: <!2502>
      (cherry picked from commit 1a56a539)
    • Robert Mader's avatar
      window-actor/wayland: Skip unnecessary set_child_at_index() calls · fddc87a4
      Robert Mader authored
      `clutter_actor_set_child_at_index()` is far from a no-op, even if
      the current index is equal to the new one - presumably for good
      reasons. For the use-case here we want it to be a no-op though, so
      skip calling it if the index already matches.
      Part-of: <!2501>
      (cherry picked from commit 0f8f30c9)
    • Robert Mader's avatar
      wayland/subsurface: Move actor unparenting back to rebuild_surface_tree() · 842d1ffa
      Robert Mader authored
      Unparenting the surface actor when the subsurface object is destroyed
      has several issues:
       - subsurface actors can be unparented while a close animation is
         still ongoing, breaking the animation for e.g. Firefox.
       - adding and removing the actor to/from the parent is not handled in
         one place, making the code harder to follow.
       - if the destroyed subsurface had children of its own, they potentially
         stick around until a surface-tree rebuild. This makes the Firefox
         hamburger menu not close with the "compositor" backend.
      Move the unparenting back to
      `meta_window_actor_wayland_rebuild_surface_tree()` and instead just
      notify the parent of a state change, if it still exist. This will ensure
      a correct mapping between the subsurface node tree and the flat surface
      actor list. In case of the closing animation the parent will already be
      removed and the call is skipped.
      Part-of: <!2501>
      (cherry picked from commit 57881ba6)
  5. 14 Jul, 2022 1 commit
    • Pascal Nowack's avatar
      backends/screen-cast-stream-src: Set correct stride when using dmabufs · 32ee9357
      Pascal Nowack authored
      Currently, mutter hardcodes the stride of all recorded images in a
      screencast to width * 4.
      While this stride is valid for general memory buffers, it is not
      necessarily valid for dmabuf buffers, as the driver may need a specific
      alignment of the stride.
      This can currently result into import failures, e.g. when using the AMD
      To fix this issue, retrieve the actual dmabuf stride, when using dmabuf
      screencasts, and set it as the stride value in the PipeWire buffer.
      Fixes: #1913
      Fixes: gnome-remote-desktop#101
      Part-of: <!2514>
  6. 04 Jul, 2022 1 commit
  7. 01 Jul, 2022 1 commit
    • Jonas Ådahl's avatar
      output/kms: Replace common mode bandwidth check with clock check · 8e522111
      Jonas Ådahl authored
      The pixel clock determines how fast pixels can be processed. When adding
      non-native common modes, avoid adding modes that exceed the max pixel
      clock frequency of the native modes. Avoiding these avoids potential
      mode setting failures where the GPU can't handle the modeline since the
      configured pixel clock is too fast. This replaces the "bandwidth" check
      which used the number of pixels and refresh rate, which wasn't enough to
      avoid incompatible modes.
      Part-of: <!2492>
      (cherry picked from commit 43860110)
  8. 29 Jun, 2022 1 commit
    • Jonas Ådahl's avatar
      screen-cast/monitor: Always use clutter_stage_paint_to_framebuffer() · 9fba0fbb
      Jonas Ådahl authored and Pascal Nowack's avatar Pascal Nowack committed
      'screen-cast/monitor-src: Use clutter_stage_paint_to_buffer'
      (6c818cd8) made the non-dma-buf path use
      clutter_stage_paint_to_buffer() to avoid running into direct scanout
      issues. At a glance, the dma-buf paths didn't have the same issue since
      it explicitly handled dma-bufs by blitting them.
      What it also did was move the recording to an idle callback, to avoid
      paint reentry issues. A side effect of this, however, is that it also
      broke the dma-buf paths, as they rely on the back buffer existing, and
      the stage view direct scanout already being setup, which it isn't in an
      idle callback.
      Fix this by using the dma-buf variant of
      clutter_stage_paint_to_buffer(): clutter_stage_paint_to_framebuffer().
      This has some negative performance impact, but we can't use
      cogl_blit_framebuffer() when using an idle callback for recording.
      Potential performance improvements to make things work more as they did
      before is to enhance 'cogl_blit_framebuffer()' a bit, making it a vfunc
      that could be implemented by MetaOnscreenNative. A flag to say whether
      to look at the back or front buffer would let MetaOnscreenNative know
      whether to use the already committed-to-KMS buffer, or the current back
      Fixes: 6c818cd8
      Closes: #2282
      Part-of: <!2462>
  9. 16 Jun, 2022 1 commit
    • Michel Dänzer's avatar
      wayland/dma-buf: Free feedback in surface_feedback_surface_destroyed_cb · 57cf77b4
      Michel Dänzer authored and Jonas Ådahl's avatar Jonas Ådahl committed
      Fixes leak:
      ==14889== 2,168 (16 direct, 2,152 indirect) bytes in 1 blocks are definitely lost in loss record 15,308 of 15,584
      ==14889==    at 0x48445EF: calloc (vg_replace_malloc.c:1328)
      ==14889==    by 0x4BAC1D0: g_malloc0 (gmem.c:155)
      ==14889==    by 0x4AAFF60: meta_wayland_dma_buf_feedback_new (meta-wayland-dma-buf.c:298)
      ==14889==    by 0x4AAFFE0: meta_wayland_dma_buf_feedback_copy (meta-wayland-dma-buf.c:317)
      ==14889==    by 0x4AB16B6: ensure_surface_feedback (meta-wayland-dma-buf.c:1121)
      ==14889==    by 0x4AB1848: dma_buf_handle_get_surface_feedback (meta-wayland-dma-buf.c:1169)
      ==14889==    by 0x66F77E9: ??? (in /usr/lib/x86_64-linux-gnu/libffi.so.8.1.0)
      ==14889==    by 0x66F6922: ??? (in /usr/lib/x86_64-linux-gnu/libffi.so.8.1.0)
      ==14889==    by 0x5318750: ??? (in /usr/lib/x86_64-linux-gnu/libwayland-server.so.0.20.0)
      ==14889==    by 0x5313B99: ??? (in /usr/lib/x86_64-linux-gnu/libwayland-server.so.0.20.0)
      ==14889==    by 0x5316649: wl_event_loop_dispatch (in /usr/lib/x86_64-linux-gnu/libwayland-server.so.0.20.0)
      ==14889==    by 0x4AA7C19: wayland_event_source_dispatch (meta-wayland.c:110)
      Fixes: 64e6bedb ("wayland/dma-buf: Add support for scanout surface feedback")
      Part-of: <!2469>
      (cherry picked from commit 4af54225)
  10. 03 Jun, 2022 1 commit
    • Robert Mader's avatar
      wayland/surface: Swap 90 and 270 degree transforms · cd52c57b
      Robert Mader authored
      Our internal interpretation of output transforms is not in line with
      the Wayland spec. Wayland describes them as the transform that a
      compositor will apply to a surface to compensate for the rotation
      or mirroring of an output device - counter-clockwise.
      Mutter in turn interprets it the other way around. One could
      argue it does the same but clock-wise - or it interprets the transform
      from the viewpoint of the content, not the device.
      In either way, the difference is that 90 and 270 degree values are
      switched. Thus swap these accordingly when we translate from
      See: https://gitlab.freedesktop.org/wayland/weston/issues/99
      Part-of: <!1055>
      (cherry picked from commit 8d9bbe10)
  11. 01 Jun, 2022 10 commits
  12. 28 May, 2022 10 commits
    • Florian Müllner's avatar
      Bump version to 42.2 · 10cece87
      Florian Müllner authored
      Update NEWS.
    • Jonas Ådahl's avatar
      kms/crtc: Determine gamma support given the gamma length · 7ac22a56
      Jonas Ådahl authored and Florian Müllner's avatar Florian Müllner committed
      The property doesn't necessarily exist when using drivers that doesn't
      support atomic mode setting, and the way it worked will break night
      light and other gamma related features. This makes things use the gamma
      length; if it is higher than 0, it definitely supports it one way or the
      other, i.e. GAMMA_LUT with the atomic backend, and drmModeCrtcSetGamma()
      with the legacy/simple backend.
      Fixes: 364572b9
      Closes: #2287
      Part-of: <!2435>
      (cherry picked from commit a2ebd10f)
    • Jonas Ådahl's avatar
      kms/crtc: Always read the gamma state · ad279646
      Jonas Ådahl authored and Florian Müllner's avatar Florian Müllner committed
      It doesn't depend on whether the CRTC is active or not, so always read
      it. This is also useful to know whether a CRTC supports gamma, before it
      is being turned on, without relying on the existance of properties.
      Part-of: <!2435>
      (cherry picked from commit 9001fa97)
    • Florian Müllner's avatar
      x11/events: Do not handle enter/leave during grabs · 2bfd36b9
      Florian Müllner authored
      The COMPOSITOR_GRAB event route has effectively been replaced by
      ClutterGrabs, which are no longer covered by the existing check.
      So check for grabs as well to restore the old behavior.
      Part-of: <!2436>
      (cherry picked from commit d04a1977)
    • Florian Müllner's avatar
      display: Bypass focus window during grabs · a2f93e36
      Florian Müllner authored
      This is what the old COMPOSITOR_GRAB check effectively did (by
      returning the grab_window, which is only set during window grab
      Part-of: <!2436>
      (cherry picked from commit 75856043)
    • Carlos Garnacho's avatar
      core: Avoid focusing window in presence of Clutter grabs · 13336d72
      Carlos Garnacho authored and Florian Müllner's avatar Florian Müllner committed
      This is the same circumstance than the event_route not being NORMAL,
      since events may or may not eventually reach the window. It should not
      attempt to get focus out of the stage in that situation. This used
      to be covered by META_EVENT_ROUTE_COMPOSITOR_GRAB, but this is no longer
      set when ClutterGrab came in to replace it.
      Fixes: gnome-shell#4858
      Part-of: <!2433>
      (cherry picked from commit 50e89e37)
    • Sebastian Keller's avatar
      display: Properly store later ID when adding window to queue · db52c904
      Sebastian Keller authored and Florian Müllner's avatar Florian Müllner committed
      The code is already trying to avoid creating new laters when there
      already is one for the queue type, but this wasn't working because the
      ID of the later was never stored after creating a new one. This would
      then result in as many laters as meta_display_queue_window() was called
      and all of them would run the handler function, even if only the first
      one had a non-empty window queue.
      Similarly this was causing the later to not be removed if the window
      queue got empty after meta_display_unqueue_window().
      Part-of: <!2414>
      (cherry picked from commit bc9762ee)
    • Sebastian Keller's avatar
      window: Ensure window-visibility-updated is emitted when flushing queue · f998a917
      Sebastian Keller authored and Florian Müllner's avatar Florian Müllner committed
      Currently the signal is getting emitted accidentally, because even when
      removing a window from the queue, the later handler of that queue will
      still get run due to a bug. This bug is going to get fixed in the next
      commit, but some things might depend on the signal getting emitted when
      the visibility of a window has changed.
      This change affects the behavior in two ways. First the signal is now
      emitted immediately rather than from an idle. And second it now
      correctly includes the window in the should_show or should_hide list.
      Part-of: <!2414>
      (cherry picked from commit b289c8f0)
    • Sebastian Keller's avatar
      display: Add method to flush a single window from the queues · a28b9f86
      Sebastian Keller authored and Florian Müllner's avatar Florian Müllner committed
      This can be used when a state change needs to be applied immediately for
      a specific window and will be used in the next commit.
      Part-of: <!2414>
      (cherry picked from commit 2a3c964e)
    • Sebastian Keller's avatar
      compositor: Update topmost window actor after visibility changes · 25a34545
      Sebastian Keller authored and Florian Müllner's avatar Florian Müllner committed
      The compositor currently only updates the topmost window actor that is
      visible to it after stacking changes. The visibility of a window actor
      to the compositor however might only change via the display idle queue
      after the stacking changes. This could then lead to the topmost window
      actor being assumed to be NULL on Wayland after switching from an empty
      workspace or when opening the first window on an empty workspace. The
      result of this is direct scanout being disabled in these cases.
      To fix this also trigger the update when the visibility of windows
      Fixes: #2269
      Part-of: <!2413>
      (cherry picked from commit bb76d6fc)