2019-08-14 17:25:54 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 Red Hat Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2021-02-13 06:48:31 -05:00
|
|
|
#include "backends/meta-dnd-private.h"
|
2019-08-14 17:25:54 -04:00
|
|
|
#include "compositor/meta-compositor-server.h"
|
2022-07-15 05:06:12 -04:00
|
|
|
#include "compositor/meta-compositor-view.h"
|
2021-02-13 06:48:31 -05:00
|
|
|
#include "core/display-private.h"
|
2019-08-14 17:25:54 -04:00
|
|
|
|
|
|
|
G_DEFINE_TYPE (MetaCompositorServer, meta_compositor_server, META_TYPE_COMPOSITOR)
|
|
|
|
|
2020-03-03 03:27:33 -05:00
|
|
|
static gboolean
|
|
|
|
meta_compositor_server_manage (MetaCompositor *compositor,
|
|
|
|
GError **error)
|
2019-08-14 17:25:54 -04:00
|
|
|
{
|
2020-03-03 03:27:33 -05:00
|
|
|
return TRUE;
|
2019-08-14 17:25:54 -04:00
|
|
|
}
|
|
|
|
|
compositor: Make sure _NET_WM_FRAME_DRAWN timestamp has the right scope
The timestamp sent with _NET_WM_FRAME_DRAWN should be in "high
resolution X server timestamps", meaning they should have the same scope
as the built in X11 32 bit unsigned integer timestamps, i.e. overflow at
the same time.
This was not done correctly when mutter had determined the X server used
the monotonic clock, where it'd just forward the monotonic clock,
confusing any client using _NET_WM_FRAME_DRAWN and friends.
Fix this by 1) splitting the timestamp conversiot into an X11 case and a
display server case, where the display server case simply clamps the
monotonic clock, as it is assumed Xwayland is always usign the monotonic
clock, and 2) if we're a X11 compositing manager, if the X server is
using the monotonic clock, apply the same semantics as the display
server case and always just clamp, or if not, calculate the offset every
10 seconds, and offset the monotonic clock timestamp with the calculated
X server timestamp offset.
This fixes an issue that would occur if mutter (or rather GNOME Shell)
would have been started before a X11 timestamp overflow, after the
overflow happened. In this case, GTK3 clients would get unclamped
timestamps, and get very confused, resulting in frames queued several
weeks into the future.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1494
2020-07-08 10:53:14 -04:00
|
|
|
static int64_t
|
|
|
|
meta_compositor_server_monotonic_to_high_res_xserver_time (MetaCompositor *compositor,
|
|
|
|
int64_t monotonic_time_us)
|
|
|
|
{
|
|
|
|
return meta_translate_to_high_res_xserver_time (monotonic_time_us);
|
|
|
|
}
|
|
|
|
|
2021-02-13 06:48:31 -05:00
|
|
|
static void
|
|
|
|
meta_compositor_server_grab_begin (MetaCompositor *compositor)
|
|
|
|
{
|
|
|
|
MetaDisplay *display;
|
|
|
|
|
|
|
|
display = meta_compositor_get_display (compositor);
|
|
|
|
meta_display_sync_wayland_input_focus (display);
|
|
|
|
meta_display_cancel_touch (display);
|
|
|
|
|
|
|
|
#ifdef HAVE_WAYLAND
|
|
|
|
meta_dnd_wayland_handle_begin_modal (compositor);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_compositor_server_grab_end (MetaCompositor *compositor)
|
|
|
|
{
|
|
|
|
MetaDisplay *display;
|
|
|
|
|
|
|
|
display = meta_compositor_get_display (compositor);
|
|
|
|
#ifdef HAVE_WAYLAND
|
|
|
|
meta_dnd_wayland_handle_end_modal (compositor);
|
|
|
|
#endif
|
|
|
|
meta_display_sync_wayland_input_focus (display);
|
|
|
|
}
|
|
|
|
|
2022-07-15 05:06:12 -04:00
|
|
|
static MetaCompositorView *
|
|
|
|
meta_compositor_server_create_view (MetaCompositor *compositor,
|
|
|
|
ClutterStageView *stage_view)
|
|
|
|
{
|
|
|
|
return meta_compositor_view_new (stage_view);
|
|
|
|
}
|
|
|
|
|
2019-08-19 04:24:17 -04:00
|
|
|
MetaCompositorServer *
|
2020-04-16 13:14:21 -04:00
|
|
|
meta_compositor_server_new (MetaDisplay *display,
|
|
|
|
MetaBackend *backend)
|
2019-08-19 04:24:17 -04:00
|
|
|
{
|
|
|
|
return g_object_new (META_TYPE_COMPOSITOR_SERVER,
|
|
|
|
"display", display,
|
2020-04-16 13:14:21 -04:00
|
|
|
"backend", backend,
|
2019-08-19 04:24:17 -04:00
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2019-08-14 17:25:54 -04:00
|
|
|
static void
|
|
|
|
meta_compositor_server_init (MetaCompositorServer *compositor_server)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_compositor_server_class_init (MetaCompositorServerClass *klass)
|
|
|
|
{
|
|
|
|
MetaCompositorClass *compositor_class = META_COMPOSITOR_CLASS (klass);
|
|
|
|
|
|
|
|
compositor_class->manage = meta_compositor_server_manage;
|
compositor: Make sure _NET_WM_FRAME_DRAWN timestamp has the right scope
The timestamp sent with _NET_WM_FRAME_DRAWN should be in "high
resolution X server timestamps", meaning they should have the same scope
as the built in X11 32 bit unsigned integer timestamps, i.e. overflow at
the same time.
This was not done correctly when mutter had determined the X server used
the monotonic clock, where it'd just forward the monotonic clock,
confusing any client using _NET_WM_FRAME_DRAWN and friends.
Fix this by 1) splitting the timestamp conversiot into an X11 case and a
display server case, where the display server case simply clamps the
monotonic clock, as it is assumed Xwayland is always usign the monotonic
clock, and 2) if we're a X11 compositing manager, if the X server is
using the monotonic clock, apply the same semantics as the display
server case and always just clamp, or if not, calculate the offset every
10 seconds, and offset the monotonic clock timestamp with the calculated
X server timestamp offset.
This fixes an issue that would occur if mutter (or rather GNOME Shell)
would have been started before a X11 timestamp overflow, after the
overflow happened. In this case, GTK3 clients would get unclamped
timestamps, and get very confused, resulting in frames queued several
weeks into the future.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1494
2020-07-08 10:53:14 -04:00
|
|
|
compositor_class->monotonic_to_high_res_xserver_time =
|
|
|
|
meta_compositor_server_monotonic_to_high_res_xserver_time;
|
2021-02-13 06:48:31 -05:00
|
|
|
compositor_class->grab_begin = meta_compositor_server_grab_begin;
|
|
|
|
compositor_class->grab_end = meta_compositor_server_grab_end;
|
2022-07-15 05:06:12 -04:00
|
|
|
compositor_class->create_view = meta_compositor_server_create_view;
|
2019-08-14 17:25:54 -04:00
|
|
|
}
|