summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberts Muktupāvels <alberts.muktupavels@gmail.com>2017-01-08 18:52:19 +0200
committerAlberts Muktupāvels <alberts.muktupavels@gmail.com>2017-01-08 18:52:19 +0200
commitb245f1a02ddffc8e956165a477ab0d62e3f84c4d (patch)
tree43ee0aa3fa066aaf8dd25953115a90daaf0a74ce
parent63b8a7d2cb2eef4ced74118abeab742518275bd7 (diff)
downloadmetacity-b245f1a02ddffc8e956165a477ab0d62e3f84c4d.tar.gz
display: always have a valid compositor
-rw-r--r--src/compositor/compositor.c44
-rw-r--r--src/core/display.c26
-rw-r--r--src/include/compositor.h31
3 files changed, 61 insertions, 40 deletions
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index a63f30ef..bbb9bb1d 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -1,31 +1,45 @@
-/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
-
/*
* Copyright (C) 2008 Iain Holmes
+ * Copyright (C) 2017 Alberts Muktupāvels
*
- * 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 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.
+ * 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, see <http://www.gnu.org/licenses/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <config.h>
+#include "config.h"
+
+#include "compositor-none.h"
#include "compositor-private.h"
#include "compositor-xrender.h"
MetaCompositor *
-meta_compositor_new (MetaDisplay *display)
+meta_compositor_new (MetaCompositorType type,
+ MetaDisplay *display)
{
- /* At some point we would have a way to select between backends */
- return meta_compositor_xrender_new (display);
+ switch (type)
+ {
+ case META_COMPOSITOR_TYPE_NONE:
+ return meta_compositor_none_new (display);
+
+ case META_COMPOSITOR_TYPE_XRENDER:
+ return meta_compositor_xrender_new (display);
+
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ return NULL;
}
void
diff --git a/src/core/display.c b/src/core/display.c
index dd6bcd70..bc981d96 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -244,14 +244,13 @@ sn_error_trap_pop (SnDisplay *sn_display,
#endif
static void
-enable_compositor (MetaDisplay *display,
- gboolean composite_windows)
+enable_compositor (MetaCompositorType type,
+ MetaDisplay *display,
+ gboolean composite_windows)
{
- if (!display->compositor)
- display->compositor = meta_compositor_new (display);
+ g_assert (display->compositor == NULL);
- if (!display->compositor)
- return;
+ display->compositor = meta_compositor_new (type, display);
meta_compositor_manage_screen (display->compositor, display->screen);
@@ -262,8 +261,7 @@ enable_compositor (MetaDisplay *display,
static void
disable_compositor (MetaDisplay *display)
{
- if (!display->compositor)
- return;
+ g_return_if_fail (display->compositor != NULL);
meta_compositor_unmanage_screen (display->compositor, display->screen);
@@ -663,7 +661,9 @@ meta_display_open (void)
faster with the call to meta_screen_manage_all_windows further down
the code */
if (meta_prefs_get_compositing_manager ())
- enable_compositor (the_display, FALSE);
+ enable_compositor (META_COMPOSITOR_TYPE_XRENDER, the_display, FALSE);
+ else
+ enable_compositor (META_COMPOSITOR_TYPE_NONE, the_display, FALSE);
meta_display_grab (the_display);
@@ -5062,12 +5062,12 @@ prefs_changed_callback (MetaPreference pref,
}
else if (pref == META_PREF_COMPOSITING_MANAGER)
{
- gboolean cm = meta_prefs_get_compositing_manager ();
+ disable_compositor (display);
- if (cm)
- enable_compositor (display, TRUE);
+ if (meta_prefs_get_compositing_manager ())
+ enable_compositor (META_COMPOSITOR_TYPE_XRENDER, display, TRUE);
else
- disable_compositor (display);
+ enable_compositor (META_COMPOSITOR_TYPE_NONE, display, TRUE);
}
else if (pref == META_PREF_ATTACH_MODAL_DIALOGS)
{
diff --git a/src/include/compositor.h b/src/include/compositor.h
index ad4411bc..1d1938a4 100644
--- a/src/include/compositor.h
+++ b/src/include/compositor.h
@@ -1,20 +1,19 @@
-/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
-
/*
* Copyright (C) 2008 Iain Holmes
+ * Copyright (C) 2017 Alberts Muktupāvels
*
- * 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 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.
+ * 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, see <http://www.gnu.org/licenses/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef META_COMPOSITOR_H
@@ -26,7 +25,15 @@
#include "types.h"
#include "boxes.h"
-MetaCompositor *meta_compositor_new (MetaDisplay *display);
+typedef enum
+{
+ META_COMPOSITOR_TYPE_NONE,
+ META_COMPOSITOR_TYPE_XRENDER
+} MetaCompositorType;
+
+MetaCompositor *meta_compositor_new (MetaCompositorType type,
+ MetaDisplay *display);
+
void meta_compositor_destroy (MetaCompositor *compositor);
void meta_compositor_manage_screen (MetaCompositor *compositor,