Remove MetaCompositor virtualization

Now that we only have one compositor, there's no reason to access the
compositor functions through a vtable. Remove the MetaCompositor virtualization
and make the clutter code implement the meta_compositor_* functions
directly.

Move the checks for the compositor being NULL from the vtable wrappers
to the calling code (most of them were already there, so just a few
needed to be added)

Note: the compositor is actually hard-coded on at the moment and the plan
  is to remove the non-composited code entirely, so the checks are
  added only to keep things neat: they have no practical effect.

http://bugzilla.gnome.org/show_bug.cgi?id=581813
This commit is contained in:
Owen W. Taylor 2009-06-25 16:17:27 -04:00
parent 0b8a57bcba
commit 3aff9726eb
7 changed files with 161 additions and 474 deletions

View File

@ -15,8 +15,6 @@ mutter_SOURCES= \
core/bell.h \
core/boxes.c \
include/boxes.h \
compositor/compositor.c \
compositor/compositor-private.h \
compositor/compositor-mutter.c \
compositor/mutter-module.c \
compositor/mutter-module.h \

View File

@ -17,7 +17,7 @@
#include "frame.h"
#include "errors.h"
#include "window.h"
#include "compositor-private.h"
#include "compositor.h"
#include "compositor-mutter.h"
#include "mutter-plugin-manager.h"
#include "tidy/tidy-texture-frame.h"
@ -119,7 +119,6 @@ composite_at_least_version (MetaDisplay *display, int maj, int min)
typedef struct _Mutter
{
MetaCompositor compositor;
MetaDisplay *display;
Atom atom_x_root_pixmap;
@ -1138,8 +1137,8 @@ mutter_window_effect_completed (MutterWindow *cw, gulong event)
}
static void
clutter_cmp_destroy (MetaCompositor *compositor)
void
meta_compositor_destroy (MetaCompositor *compositor)
{
}
@ -1845,8 +1844,8 @@ mutter_empty_stage_input_region (MetaScreen *screen)
mutter_set_stage_input_region (screen, region);
}
static void
clutter_cmp_manage_screen (MetaCompositor *compositor,
void
meta_compositor_manage_screen (MetaCompositor *compositor,
MetaScreen *screen)
{
MetaCompScreen *info;
@ -1968,14 +1967,14 @@ clutter_cmp_manage_screen (MetaCompositor *compositor,
clutter_actor_show (info->stage);
}
static void
clutter_cmp_unmanage_screen (MetaCompositor *compositor,
void
meta_compositor_unmanage_screen (MetaCompositor *compositor,
MetaScreen *screen)
{
}
static void
clutter_cmp_add_window (MetaCompositor *compositor,
void
meta_compositor_add_window (MetaCompositor *compositor,
MetaWindow *window)
{
MetaScreen *screen = meta_window_get_screen (window);
@ -1989,8 +1988,8 @@ clutter_cmp_add_window (MetaCompositor *compositor,
meta_error_trap_pop (display, FALSE);
}
static void
clutter_cmp_remove_window (MetaCompositor *compositor,
void
meta_compositor_remove_window (MetaCompositor *compositor,
MetaWindow *window)
{
MutterWindow *cw = NULL;
@ -2003,15 +2002,15 @@ clutter_cmp_remove_window (MetaCompositor *compositor,
destroy_win (cw);
}
static void
clutter_cmp_set_updates (MetaCompositor *compositor,
void
meta_compositor_set_updates (MetaCompositor *compositor,
MetaWindow *window,
gboolean update)
gboolean updates)
{
}
static gboolean
clutter_cmp_process_event (MetaCompositor *compositor,
gboolean
meta_compositor_process_event (MetaCompositor *compositor,
XEvent *event,
MetaWindow *window)
{
@ -2099,22 +2098,47 @@ clutter_cmp_process_event (MetaCompositor *compositor,
return FALSE;
}
static Pixmap
clutter_cmp_get_window_pixmap (MetaCompositor *compositor,
Pixmap
meta_compositor_get_window_pixmap (MetaCompositor *compositor,
MetaWindow *window)
{
return None;
}
static void
clutter_cmp_set_active_window (MetaCompositor *compositor,
void
meta_compositor_set_active_window (MetaCompositor *compositor,
MetaScreen *screen,
MetaWindow *window)
{
}
static void
clutter_cmp_map_window (MetaCompositor *compositor, MetaWindow *window)
/* These functions are unused at the moment */
void
meta_compositor_begin_move (MetaCompositor *compositor,
MetaWindow *window,
MetaRectangle *initial,
int grab_x,
int grab_y)
{
}
void
meta_compositor_update_move (MetaCompositor *compositor,
MetaWindow *window,
int x,
int y)
{
}
void
meta_compositor_end_move (MetaCompositor *compositor,
MetaWindow *window)
{
}
void
meta_compositor_map_window (MetaCompositor *compositor,
MetaWindow *window)
{
MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window));
DEBUG_TRACE ("clutter_cmp_map_window\n");
@ -2124,8 +2148,9 @@ clutter_cmp_map_window (MetaCompositor *compositor, MetaWindow *window)
map_win (cw);
}
static void
clutter_cmp_unmap_window (MetaCompositor *compositor, MetaWindow *window)
void
meta_compositor_unmap_window (MetaCompositor *compositor,
MetaWindow *window)
{
MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window));
DEBUG_TRACE ("clutter_cmp_unmap_window\n");
@ -2135,8 +2160,8 @@ clutter_cmp_unmap_window (MetaCompositor *compositor, MetaWindow *window)
unmap_win (cw);
}
static void
clutter_cmp_minimize_window (MetaCompositor *compositor,
void
meta_compositor_minimize_window (MetaCompositor *compositor,
MetaWindow *window,
MetaRectangle *window_rect,
MetaRectangle *icon_rect)
@ -2168,8 +2193,8 @@ clutter_cmp_minimize_window (MetaCompositor *compositor,
}
}
static void
clutter_cmp_unminimize_window (MetaCompositor *compositor,
void
meta_compositor_unminimize_window (MetaCompositor *compositor,
MetaWindow *window,
MetaRectangle *window_rect,
MetaRectangle *icon_rect)
@ -2209,10 +2234,10 @@ clutter_cmp_unminimize_window (MetaCompositor *compositor,
}
static void
clutter_cmp_maximize_window (MetaCompositor *compositor,
void
meta_compositor_maximize_window (MetaCompositor *compositor,
MetaWindow *window,
MetaRectangle *rect)
MetaRectangle *window_rect)
{
MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window));
MetaScreen *screen = meta_window_get_screen (window);
@ -2230,17 +2255,17 @@ clutter_cmp_maximize_window (MetaCompositor *compositor,
!mutter_plugin_manager_event_maximize (info->plugin_mgr,
cw,
MUTTER_PLUGIN_MAXIMIZE,
rect->x, rect->y,
rect->width, rect->height))
window_rect->x, window_rect->y,
window_rect->width, window_rect->height))
{
cw->priv->maximize_in_progress--;
}
}
static void
clutter_cmp_unmaximize_window (MetaCompositor *compositor,
void
meta_compositor_unmaximize_window (MetaCompositor *compositor,
MetaWindow *window,
MetaRectangle *rect)
MetaRectangle *window_rect)
{
MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window));
MetaScreen *screen = meta_window_get_screen (window);
@ -2258,15 +2283,15 @@ clutter_cmp_unmaximize_window (MetaCompositor *compositor,
!mutter_plugin_manager_event_maximize (info->plugin_mgr,
cw,
MUTTER_PLUGIN_UNMAXIMIZE,
rect->x, rect->y,
rect->width, rect->height))
window_rect->x, window_rect->y,
window_rect->width, window_rect->height))
{
cw->priv->unmaximize_in_progress--;
}
}
static void
clutter_cmp_update_workspace_geometry (MetaCompositor *compositor,
void
meta_compositor_update_workspace_geometry (MetaCompositor *compositor,
MetaWorkspace *workspace)
{
#if 0
@ -2288,8 +2313,8 @@ clutter_cmp_update_workspace_geometry (MetaCompositor *compositor,
#endif
}
static void
clutter_cmp_switch_workspace (MetaCompositor *compositor,
void
meta_compositor_switch_workspace (MetaCompositor *compositor,
MetaScreen *screen,
MetaWorkspace *from,
MetaWorkspace *to,
@ -2382,8 +2407,8 @@ sync_actor_stacking (GList *windows)
}
}
static void
clutter_cmp_sync_stack (MetaCompositor *compositor,
void
meta_compositor_sync_stack (MetaCompositor *compositor,
MetaScreen *screen,
GList *stack)
{
@ -2471,8 +2496,8 @@ clutter_cmp_sync_stack (MetaCompositor *compositor,
sync_actor_stacking (info->windows);
}
static void
clutter_cmp_set_window_hidden (MetaCompositor *compositor,
void
meta_compositor_set_window_hidden (MetaCompositor *compositor,
MetaScreen *screen,
MetaWindow *window,
gboolean hidden)
@ -2509,8 +2534,8 @@ clutter_cmp_set_window_hidden (MetaCompositor *compositor,
}
}
static void
clutter_cmp_sync_window_geometry (MetaCompositor *compositor,
void
meta_compositor_sync_window_geometry (MetaCompositor *compositor,
MetaWindow *window)
{
MutterWindow *cw = MUTTER_WINDOW (meta_window_get_compositor_private (window));
@ -2526,8 +2551,8 @@ clutter_cmp_sync_window_geometry (MetaCompositor *compositor,
sync_actor_position (cw);
}
static void
clutter_cmp_sync_screen_size (MetaCompositor *compositor,
void
meta_compositor_sync_screen_size (MetaCompositor *compositor,
MetaScreen *screen,
guint width,
guint height)
@ -2544,32 +2569,8 @@ clutter_cmp_sync_screen_size (MetaCompositor *compositor,
width, height);
}
static MetaCompositor comp_info = {
clutter_cmp_destroy,
clutter_cmp_manage_screen,
clutter_cmp_unmanage_screen,
clutter_cmp_add_window,
clutter_cmp_remove_window,
clutter_cmp_set_updates,
clutter_cmp_process_event,
clutter_cmp_get_window_pixmap,
clutter_cmp_set_active_window,
clutter_cmp_map_window,
clutter_cmp_unmap_window,
clutter_cmp_minimize_window,
clutter_cmp_unminimize_window,
clutter_cmp_maximize_window,
clutter_cmp_unmaximize_window,
clutter_cmp_update_workspace_geometry,
clutter_cmp_switch_workspace,
clutter_cmp_sync_stack,
clutter_cmp_set_window_hidden,
clutter_cmp_sync_window_geometry,
clutter_cmp_sync_screen_size
};
MetaCompositor *
mutter_new (MetaDisplay *display)
meta_compositor_new (MetaDisplay *display)
{
char *atom_names[] = {
"_XROOTPMAP_ID",
@ -2586,7 +2587,6 @@ mutter_new (MetaDisplay *display)
return NULL;
clc = g_new0 (Mutter, 1);
clc->compositor = comp_info;
compositor = (MetaCompositor *) clc;

View File

@ -1,90 +0,0 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2008 Iain Holmes
*
* 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.
*/
#ifndef META_COMPOSITOR_PRIVATE_H
#define META_COMPOSITOR_PRIVATE_H
#include "compositor.h"
struct _MetaCompositor
{
void (* destroy) (MetaCompositor *compositor);
void (*manage_screen) (MetaCompositor *compositor,
MetaScreen *screen);
void (*unmanage_screen) (MetaCompositor *compositor,
MetaScreen *screen);
void (*add_window) (MetaCompositor *compositor,
MetaWindow *window);
void (*remove_window) (MetaCompositor *compositor,
MetaWindow *window);
void (*set_updates) (MetaCompositor *compositor,
MetaWindow *window,
gboolean update);
gboolean (*process_event) (MetaCompositor *compositor,
XEvent *event,
MetaWindow *window);
Pixmap (*get_window_pixmap) (MetaCompositor *compositor,
MetaWindow *window);
void (*set_active_window) (MetaCompositor *compositor,
MetaScreen *screen,
MetaWindow *window);
void (*map_window) (MetaCompositor *compositor,
MetaWindow *window);
void (*unmap_window) (MetaCompositor *compositor,
MetaWindow *window);
void (*minimize_window) (MetaCompositor *compositor,
MetaWindow *window,
MetaRectangle *window_rect,
MetaRectangle *icon_rect);
void (*unminimize_window) (MetaCompositor *compositor,
MetaWindow *window,
MetaRectangle *window_rect,
MetaRectangle *icon_rect);
void (*maximize_window) (MetaCompositor *compositor,
MetaWindow *window,
MetaRectangle *window_rect);
void (*unmaximize_window) (MetaCompositor *compositor,
MetaWindow *window,
MetaRectangle *window_rect);
void (*update_workspace_geometry) (MetaCompositor *compositor,
MetaWorkspace *workspace);
void (*switch_workspace) (MetaCompositor *compositor,
MetaScreen *screen,
MetaWorkspace *from,
MetaWorkspace *to,
MetaMotionDirection direction);
void (*sync_stack) (MetaCompositor *compositor,
MetaScreen *screen,
GList *stack);
void (*set_window_hidden) (MetaCompositor *compositor,
MetaScreen *screen,
MetaWindow *window,
gboolean hidden);
void (*sync_window_geometry) (MetaCompositor *compositor,
MetaWindow *window);
void (*sync_screen_size) (MetaCompositor *compositor,
MetaScreen *screen,
guint width,
guint height);
};
#endif

View File

@ -1,240 +0,0 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2008 Iain Holmes
*
* 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>
#include "compositor-private.h"
#include "compositor-mutter.h"
#include "prefs.h"
MetaCompositor *
meta_compositor_new (MetaDisplay *display)
{
return mutter_new (display);
}
void
meta_compositor_destroy (MetaCompositor *compositor)
{
if (compositor && compositor->destroy)
compositor->destroy (compositor);
}
void
meta_compositor_add_window (MetaCompositor *compositor,
MetaWindow *window)
{
if (compositor && compositor->add_window)
compositor->add_window (compositor, window);
}
void
meta_compositor_remove_window (MetaCompositor *compositor,
MetaWindow *window)
{
if (compositor && compositor->remove_window)
compositor->remove_window (compositor, window);
}
void
meta_compositor_manage_screen (MetaCompositor *compositor,
MetaScreen *screen)
{
if (compositor && compositor->manage_screen)
compositor->manage_screen (compositor, screen);
}
void
meta_compositor_unmanage_screen (MetaCompositor *compositor,
MetaScreen *screen)
{
if (compositor && compositor->unmanage_screen)
compositor->unmanage_screen (compositor, screen);
}
void
meta_compositor_set_updates (MetaCompositor *compositor,
MetaWindow *window,
gboolean updates)
{
if (compositor && compositor->set_updates)
compositor->set_updates (compositor, window, updates);
}
gboolean
meta_compositor_process_event (MetaCompositor *compositor,
XEvent *event,
MetaWindow *window)
{
if (compositor && compositor->process_event)
return compositor->process_event (compositor, event, window);
else
return FALSE;
}
Pixmap
meta_compositor_get_window_pixmap (MetaCompositor *compositor,
MetaWindow *window)
{
if (compositor && compositor->get_window_pixmap)
return compositor->get_window_pixmap (compositor, window);
else
return None;
}
void
meta_compositor_set_active_window (MetaCompositor *compositor,
MetaScreen *screen,
MetaWindow *window)
{
if (compositor && compositor->set_active_window)
compositor->set_active_window (compositor, screen, window);
}
/* These functions are unused at the moment */
void meta_compositor_begin_move (MetaCompositor *compositor,
MetaWindow *window,
MetaRectangle *initial,
int grab_x,
int grab_y)
{
}
void meta_compositor_update_move (MetaCompositor *compositor,
MetaWindow *window,
int x,
int y)
{
}
void meta_compositor_end_move (MetaCompositor *compositor,
MetaWindow *window)
{
}
void
meta_compositor_map_window (MetaCompositor *compositor,
MetaWindow *window)
{
if (compositor && compositor->map_window)
compositor->map_window (compositor, window);
}
void
meta_compositor_unmap_window (MetaCompositor *compositor,
MetaWindow *window)
{
if (compositor && compositor->unmap_window)
compositor->unmap_window (compositor, window);
}
void
meta_compositor_minimize_window (MetaCompositor *compositor,
MetaWindow *window,
MetaRectangle *window_rect,
MetaRectangle *icon_rect)
{
if (compositor && compositor->minimize_window)
compositor->minimize_window (compositor, window, window_rect, icon_rect);
}
void
meta_compositor_unminimize_window (MetaCompositor *compositor,
MetaWindow *window,
MetaRectangle *window_rect,
MetaRectangle *icon_rect)
{
if (compositor && compositor->unminimize_window)
compositor->unminimize_window (compositor, window, window_rect, icon_rect);
}
void
meta_compositor_maximize_window (MetaCompositor *compositor,
MetaWindow *window,
MetaRectangle *window_rect)
{
if (compositor && compositor->maximize_window)
compositor->maximize_window (compositor, window, window_rect);
}
void
meta_compositor_unmaximize_window (MetaCompositor *compositor,
MetaWindow *window,
MetaRectangle *window_rect)
{
if (compositor && compositor->unmaximize_window)
compositor->unmaximize_window (compositor, window, window_rect);
}
void
meta_compositor_update_workspace_geometry (MetaCompositor *compositor,
MetaWorkspace *workspace)
{
if (compositor && compositor->update_workspace_geometry)
compositor->update_workspace_geometry (compositor, workspace);
}
void
meta_compositor_switch_workspace (MetaCompositor *compositor,
MetaScreen *screen,
MetaWorkspace *from,
MetaWorkspace *to,
MetaMotionDirection direction)
{
if (compositor && compositor->switch_workspace)
compositor->switch_workspace (compositor, screen, from, to, direction);
}
void
meta_compositor_sync_stack (MetaCompositor *compositor,
MetaScreen *screen,
GList *stack)
{
if (compositor && compositor->sync_stack)
compositor->sync_stack (compositor, screen, stack);
}
void
meta_compositor_set_window_hidden (MetaCompositor *compositor,
MetaScreen *screen,
MetaWindow *window,
gboolean hidden)
{
if (compositor && compositor->set_window_hidden)
compositor->set_window_hidden (compositor, screen, window, hidden);
}
void
meta_compositor_sync_window_geometry (MetaCompositor *compositor,
MetaWindow *window)
{
if (compositor && compositor->sync_window_geometry)
compositor->sync_window_geometry (compositor, window);
}
void
meta_compositor_sync_screen_size (MetaCompositor *compositor,
MetaScreen *screen,
guint width,
guint height)
{
if (compositor && compositor->sync_screen_size)
compositor->sync_screen_size (compositor, screen, width, height);
}

View File

@ -686,6 +686,7 @@ meta_stack_tracker_sync_stack (MetaStackTracker *tracker)
meta_windows = g_list_prepend (meta_windows, meta_window);
}
if (tracker->screen->display->compositor)
meta_compositor_sync_stack (tracker->screen->display->compositor,
tracker->screen,
meta_windows);

View File

@ -1274,6 +1274,7 @@ meta_window_unmanage (MetaWindow *window,
if (window->display->focus_window == window)
{
window->display->focus_window = NULL;
if (window->display->compositor)
meta_compositor_set_active_window (window->display->compositor,
window->screen, NULL);
}
@ -2550,6 +2551,7 @@ meta_window_show (MetaWindow *window)
meta_stack_freeze (window->screen->stack);
window->hidden = FALSE;
/* Inform the compositor that the window isn't hidden */
if (window->display->compositor)
meta_compositor_set_window_hidden (window->display->compositor,
window->screen,
window,
@ -2582,8 +2584,11 @@ meta_window_show (MetaWindow *window)
NULL, NULL);
}
else
{
if (window->display->compositor)
meta_compositor_map_window (window->display->compositor,
window);
}
window->was_minimized = FALSE;
}
@ -2659,12 +2664,14 @@ meta_window_hide (MetaWindow *window)
meta_stack_freeze (window->screen->stack);
window->hidden = TRUE;
/* Tell the compositor this window is now hidden */
if (window->display->compositor)
meta_compositor_set_window_hidden (window->display->compositor,
window->screen,
window,
window->hidden);
meta_stack_thaw (window->screen->stack);
if (window->display->compositor)
meta_compositor_unmap_window (window->display->compositor,
window);
@ -2672,6 +2679,7 @@ meta_window_hide (MetaWindow *window)
}
else
{
if (window->display->compositor)
meta_compositor_unmap_window (window->display->compositor,
window);
@ -4019,6 +4027,7 @@ meta_window_move_resize_internal (MetaWindow *window,
newx, newy, window->rect.width, window->rect.height,
window->user_rect.x, window->user_rect.y,
window->user_rect.width, window->user_rect.height);
if (window->display->compositor)
meta_compositor_sync_window_geometry (window->display->compositor,
window);
}
@ -4188,6 +4197,7 @@ meta_window_configure_notify (MetaWindow *window, XConfigureEvent *event)
if (!event->override_redirect && !event->send_event)
meta_warning ("Unhandled change of windows override redirect status\n");
if (window->display->compositor)
meta_compositor_sync_window_geometry (window->display->compositor, window);
}
@ -5817,6 +5827,7 @@ meta_window_notify_focus (MetaWindow *window,
"* Focus --> %s\n", window->desc);
window->display->focus_window = window;
window->has_focus = TRUE;
if (window->display->compositor)
meta_compositor_set_active_window (window->display->compositor,
window->screen, window);
@ -5906,6 +5917,7 @@ meta_window_notify_focus (MetaWindow *window,
if (window->frame)
meta_frame_queue_draw (window->frame);
if (window->display->compositor)
meta_compositor_set_active_window (window->display->compositor,
window->screen, NULL);

View File

@ -540,6 +540,9 @@ meta_workspace_activate_with_focus (MetaWorkspace *workspace,
gint num_workspaces, current_space, new_space;
MetaMotionDirection direction = 0;
if (!comp)
return;
current_space = meta_workspace_index (old);
new_space = meta_workspace_index (workspace);
@ -922,6 +925,7 @@ ensure_work_areas_validated (MetaWorkspace *workspace)
/* We're all done, YAAY! Record that everything has been validated. */
workspace->work_areas_invalid = FALSE;
{
/*
* Notify the compositor that the workspace geometry has changed.
*/
@ -929,7 +933,9 @@ ensure_work_areas_validated (MetaWorkspace *workspace)
MetaDisplay *display = meta_screen_get_display (screen);
MetaCompositor *comp = meta_display_get_compositor (display);
if (comp)
meta_compositor_update_workspace_geometry (comp, workspace);
}
}
/**