mutter/src/compositor/compositor-private.h
Dor Askayo 2ead3874f5 compositor: Expose the MetaCompositorView in before_paint () vfunc
The idea is that the state of the MetaCompositorView shall be
up-to-date only in specific scenarios, thus allowing operations
performed on it to be queued and aggregated to be handled in the
right time, and only if they are still necessary.

For example, in a following commit, the top window actor in each
view will be planned (if needed) only once before painting a frame,
rendering the top window actor in the MetaCompositorView potentially
stale in all other times.

Similarly, if a MetaCompositorView is destroyed before the beginning
of the frame, a queued operation to update its top window actor can be
discarded.

As an interface segragation measure, and as part of an attempt to
avoid the use of g_return_if_fail () to check the validity of the
MetaCompositorView's state in multiple places (which is still prone to
human error), the interfaces through which a MetaCompositorView is
made available would only ones where it's state is gurenteed to be
up-to-date.

Specifically, this commit gurentees that the state of the
MetaCompositorView would be up-to-date during the before_paint () and
after_paint () vfuncs exposed to child classes of the MetaCompositor.

The frame_in_progress variable will be used in a following commit to
guarantee that the MetaCompositorView's state is not invalidated during
this time.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2526>
2022-08-01 21:05:04 +00:00

98 lines
3.5 KiB
C

/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
#ifndef META_COMPOSITOR_PRIVATE_H
#define META_COMPOSITOR_PRIVATE_H
#include <X11/extensions/Xfixes.h>
#include "clutter/clutter-mutter.h"
#include "clutter/clutter.h"
#include "compositor/meta-compositor-view.h"
#include "compositor/meta-plugin-manager.h"
#include "compositor/meta-window-actor-private.h"
#include "meta/compositor.h"
#include "meta/display.h"
/* Wait 2ms after vblank before starting to draw next frame */
#define META_SYNC_DELAY 2
typedef struct _MetaLaters MetaLaters;
struct _MetaCompositorClass
{
GObjectClass parent_class;
gboolean (* manage) (MetaCompositor *compositor,
GError **error);
void (* unmanage) (MetaCompositor *compositor);
void (* before_paint) (MetaCompositor *compositor,
MetaCompositorView *compositor_view);
void (* after_paint) (MetaCompositor *compositor,
MetaCompositorView *compositor_view);
void (* remove_window) (MetaCompositor *compositor,
MetaWindow *window);
int64_t (* monotonic_to_high_res_xserver_time) (MetaCompositor *compositor,
int64_t time_us);
void (* grab_begin) (MetaCompositor *compositor);
void (* grab_end) (MetaCompositor *compositor);
};
gboolean meta_compositor_do_manage (MetaCompositor *compositor,
GError **error);
void meta_compositor_remove_window_actor (MetaCompositor *compositor,
MetaWindowActor *window_actor);
void meta_switch_workspace_completed (MetaCompositor *compositor);
MetaPluginManager * meta_compositor_get_plugin_manager (MetaCompositor *compositor);
int64_t meta_compositor_monotonic_to_high_res_xserver_time (MetaCompositor *compositor,
int64_t monotonic_time_us);
void meta_compositor_flash_window (MetaCompositor *compositor,
MetaWindow *window);
MetaCloseDialog * meta_compositor_create_close_dialog (MetaCompositor *compositor,
MetaWindow *window);
MetaInhibitShortcutsDialog * meta_compositor_create_inhibit_shortcuts_dialog (MetaCompositor *compositor,
MetaWindow *window);
void meta_compositor_locate_pointer (MetaCompositor *compositor);
void meta_compositor_redirect_x11_windows (MetaCompositor *compositor);
gboolean meta_compositor_is_unredirect_inhibited (MetaCompositor *compositor);
MetaDisplay * meta_compositor_get_display (MetaCompositor *compositor);
MetaBackend * meta_compositor_get_backend (MetaCompositor *compositor);
MetaWindowActor * meta_compositor_get_top_window_actor (MetaCompositor *compositor);
ClutterStage * meta_compositor_get_stage (MetaCompositor *compositor);
gboolean meta_compositor_is_switching_workspace (MetaCompositor *compositor);
void meta_compositor_grab_begin (MetaCompositor *compositor);
void meta_compositor_grab_end (MetaCompositor *compositor);
/*
* This function takes a 64 bit time stamp from the monotonic clock, and clamps
* it to the scope of the X server clock, without losing the granularity.
*/
static inline int64_t
meta_translate_to_high_res_xserver_time (int64_t time_us)
{
int64_t us;
int64_t ms;
us = time_us % 1000;
ms = time_us / 1000;
return ms2us (ms & 0xffffffff) + us;
}
#endif /* META_COMPOSITOR_PRIVATE_H */