From a4a102726e0a2e419ef7976c59cf9f9244eab7c7 Mon Sep 17 00:00:00 2001 From: Tomas Frydrych Date: Wed, 29 Oct 2008 09:01:50 +0000 Subject: [PATCH] Removed tridy-grid and scratch plugin --- src/Makefile.am | 2 - src/compositor/mutter/plugins/Makefile.am | 7 +- src/compositor/mutter/plugins/scratch.c | 1215 --------------------- src/compositor/mutter/tidy/tidy-grid.c | 1000 ----------------- src/compositor/mutter/tidy/tidy-grid.h | 99 -- 5 files changed, 1 insertion(+), 2322 deletions(-) delete mode 100644 src/compositor/mutter/plugins/scratch.c delete mode 100644 src/compositor/mutter/tidy/tidy-grid.c delete mode 100644 src/compositor/mutter/tidy/tidy-grid.h diff --git a/src/Makefile.am b/src/Makefile.am index 3a1667827..6db534d87 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -112,8 +112,6 @@ metacity_SOURCES += \ compositor/mutter/mutter-plugin-manager.h \ compositor/mutter/tidy/tidy-texture-frame.c \ compositor/mutter/tidy/tidy-texture-frame.h \ - compositor/mutter/tidy/tidy-grid.c \ - compositor/mutter/tidy/tidy-grid.h \ include/mutter-plugin.h endif diff --git a/src/compositor/mutter/plugins/Makefile.am b/src/compositor/mutter/plugins/Makefile.am index 94b607e5a..1a6082c3e 100644 --- a/src/compositor/mutter/plugins/Makefile.am +++ b/src/compositor/mutter/plugins/Makefile.am @@ -10,12 +10,7 @@ default_la_SOURCES = default.c default_la_LDFLAGS = -module -avoid-version -no-undefined default_la_LIBADD = @CLUTTER_LIBS@ -scratch_la_CFLAGS = -fPIC -scratch_la_SOURCES = scratch.c -scratch_la_LDFLAGS = -module -avoid-version -no-undefined -scratch_la_LIBADD = @CLUTTER_LIBS@ - -pkglib_LTLIBRARIES = default.la scratch.la +pkglib_LTLIBRARIES = default.la # post-install hook to remove the .la and .a files we are not interested in # (There is no way to stop libtool generating static libs locally, and we diff --git a/src/compositor/mutter/plugins/scratch.c b/src/compositor/mutter/plugins/scratch.c deleted file mode 100644 index dd6135785..000000000 --- a/src/compositor/mutter/plugins/scratch.c +++ /dev/null @@ -1,1215 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ - -/* - * Copyright (c) 2008 Intel Corp. - * - * Author: Tomas Frydrych - * - * 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. - */ - -#define MUTTER_BUILDING_PLUGIN 1 -#include "mutter-plugin.h" - -#include -#define _(x) dgettext (GETTEXT_PACKAGE, x) -#define N_(x) x - -#include -#include -#include -#include - -#include "../tidy/tidy-grid.h" - -/* For debugging only */ -#include "../../../core/window-private.h" -#include "compositor-mutter.h" - -#define DESTROY_TIMEOUT 250 -#define MINIMIZE_TIMEOUT 250 -#define MAXIMIZE_TIMEOUT 250 -#define MAP_TIMEOUT 250 -#define SWITCH_TIMEOUT 500 -#define PANEL_SLIDE_TIMEOUT 250; \ - -#define PANEL_SLIDE_THRESHOLD 2 -#define PANEL_HEIGHT 40 -#define ACTOR_DATA_KEY "MCCP-scratch-actor-data" - -#define SWITCHER_CELL_WIDTH 200 -#define SWITCHER_CELL_HEIGHT 200 - -static GQuark actor_data_quark = 0; - -typedef struct PluginPrivate PluginPrivate; -typedef struct ActorPrivate ActorPrivate; - -static gboolean do_init (const char *params); -static void minimize (MutterWindow *actor); -static void map (MutterWindow *actor); -static void destroy (MutterWindow *actor); -static void maximize (MutterWindow *actor, - gint x, gint y, gint width, gint height); -static void unmaximize (MutterWindow *actor, - gint x, gint y, gint width, gint height); -static void switch_workspace (const GList **actors, gint from, gint to, - MetaMotionDirection direction); -static void kill_effect (MutterWindow *actor, gulong event); -static gboolean xevent_filter (XEvent *xev); -static gboolean reload (const char *params); - -/* - * Create the plugin struct; function pointers initialized in - * g_module_check_init(). - */ -MUTTER_DECLARE_PLUGIN (); - -/* - * Plugin private data that we store in the .plugin_private member. - */ -struct PluginPrivate -{ - ClutterEffectTemplate *destroy_effect; - ClutterEffectTemplate *minimize_effect; - ClutterEffectTemplate *maximize_effect; - ClutterEffectTemplate *map_effect; - ClutterEffectTemplate *switch_workspace_effect; - ClutterEffectTemplate *switch_workspace_arrow_effect; - ClutterEffectTemplate *panel_slide_effect; - - /* Valid only when switch_workspace effect is in progress */ - ClutterTimeline *tml_switch_workspace1; - ClutterTimeline *tml_switch_workspace2; - GList **actors; - ClutterActor *desktop1; - ClutterActor *desktop2; - - ClutterActor *d_overlay ; /* arrow indicator */ - ClutterActor *panel; - - ClutterActor *switcher; - - gboolean debug_mode : 1; - gboolean panel_out : 1; - gboolean panel_out_in_progress : 1; - gboolean panel_back_in_progress : 1; -}; - -/* - * Per actor private data we attach to each actor. - */ -struct ActorPrivate -{ - ClutterActor *orig_parent; - gint orig_x; - gint orig_y; - - ClutterTimeline *tml_minimize; - ClutterTimeline *tml_maximize; - ClutterTimeline *tml_destroy; - ClutterTimeline *tml_map; - - gboolean is_minimized : 1; - gboolean is_maximized : 1; -}; - -/* - * Actor private data accessor - */ -static void -free_actor_private (gpointer data) -{ - if (G_LIKELY (data != NULL)) - g_slice_free (ActorPrivate, data); -} - -static ActorPrivate * -get_actor_private (MutterWindow *actor) -{ - ActorPrivate *priv = g_object_get_qdata (G_OBJECT (actor), actor_data_quark); - - if (G_UNLIKELY (actor_data_quark == 0)) - actor_data_quark = g_quark_from_static_string (ACTOR_DATA_KEY); - - if (G_UNLIKELY (!priv)) - { - priv = g_slice_new0 (ActorPrivate); - - g_object_set_qdata_full (G_OBJECT (actor), - actor_data_quark, priv, - free_actor_private); - } - - return priv; -} - -static void -on_switch_workspace_effect_complete (ClutterActor *group, gpointer data) -{ - MutterPlugin *plugin = mutter_get_plugin (); - PluginPrivate *ppriv = plugin->plugin_private; - GList *l = *((GList**)data); - MutterWindow *actor_for_cb = l->data; - - while (l) - { - ClutterActor *a = l->data; - MutterWindow *mcw = MUTTER_WINDOW (a); - ActorPrivate *priv = get_actor_private (mcw); - - if (priv->orig_parent) - { - clutter_actor_reparent (a, priv->orig_parent); - priv->orig_parent = NULL; - } - - l = l->next; - } - - clutter_actor_destroy (ppriv->desktop1); - clutter_actor_destroy (ppriv->desktop2); - clutter_actor_destroy (ppriv->d_overlay); - - ppriv->actors = NULL; - ppriv->tml_switch_workspace1 = NULL; - ppriv->tml_switch_workspace2 = NULL; - ppriv->desktop1 = NULL; - ppriv->desktop2 = NULL; - - mutter_plugin_effect_completed (plugin, actor_for_cb, - MUTTER_PLUGIN_SWITCH_WORKSPACE); -} - -static void -switch_workspace (const GList **actors, gint from, gint to, - MetaMotionDirection direction) -{ - MutterPlugin *plugin = mutter_get_plugin (); - PluginPrivate *ppriv = plugin->plugin_private; - GList *l; - gint n_workspaces; - ClutterActor *group1 = clutter_group_new (); - ClutterActor *group2 = clutter_group_new (); - ClutterActor *group3 = clutter_group_new (); - ClutterActor *stage, *label, *rect, *window_layer, *overlay_layer; - gint to_x, to_y, from_x = 0, from_y = 0; - ClutterColor white = { 0xff, 0xff, 0xff, 0xff }; - ClutterColor black = { 0x33, 0x33, 0x33, 0xff }; - gint screen_width; - gint screen_height; - - stage = mutter_plugin_get_stage (plugin); - - mutter_plugin_query_screen_size (plugin, &screen_width, &screen_height); - - window_layer = mutter_plugin_get_window_group (plugin); - overlay_layer = mutter_plugin_get_overlay_group (plugin); - - clutter_container_add_actor (CLUTTER_CONTAINER (window_layer), group1); - clutter_container_add_actor (CLUTTER_CONTAINER (window_layer), group2); - clutter_container_add_actor (CLUTTER_CONTAINER (overlay_layer), group3); - - if (from == to) - { - clutter_actor_destroy (group3); - clutter_actor_destroy (group2); - clutter_actor_destroy (group1); - - mutter_plugin_effect_completed (plugin, NULL, - MUTTER_PLUGIN_SWITCH_WORKSPACE); - return; - } - - n_workspaces = g_list_length (plugin->work_areas); - - l = g_list_last (*((GList**) actors)); - - while (l) - { - MutterWindow *mcw = l->data; - ActorPrivate *priv = get_actor_private (mcw); - ClutterActor *a = CLUTTER_ACTOR (mcw); - gint workspace; - - workspace = mutter_window_get_workspace (mcw); - - if (workspace == to || workspace == from) - { - gint x, y; - guint w, h; - - clutter_actor_get_position (a, &x, &y); - clutter_actor_get_size (a, &w, &h); - - priv->orig_parent = clutter_actor_get_parent (a); - - clutter_actor_reparent (a, workspace == to ? group2 : group1); - clutter_actor_show_all (a); - clutter_actor_raise_top (a); - } - else if (workspace < 0) - { - /* Sticky window */ - priv->orig_parent = NULL; - } - else - { - /* Window on some other desktop */ - clutter_actor_hide (a); - priv->orig_parent = NULL; - } - - l = l->prev; - } - - /* Make arrow indicator */ - rect = clutter_rectangle_new (); - clutter_rectangle_set_color (CLUTTER_RECTANGLE (rect), &white); - clutter_container_add_actor (CLUTTER_CONTAINER (group3), rect); - - label = clutter_label_new (); - clutter_label_set_font_name (CLUTTER_LABEL (label), "Sans Bold 148"); - clutter_label_set_color (CLUTTER_LABEL (label), &black); - clutter_container_add_actor (CLUTTER_CONTAINER (group3), label); - - clutter_actor_set_size (rect, - clutter_actor_get_width (label), - clutter_actor_get_height (label)); - - ppriv->actors = (GList **)actors; - ppriv->desktop1 = group1; - ppriv->desktop2 = group2; - ppriv->d_overlay = group3; - - switch (direction) - { - case META_MOTION_UP: - clutter_label_set_text (CLUTTER_LABEL (label), "\342\206\221"); - - to_x = 0; - to_y = -screen_height; - break; - - case META_MOTION_DOWN: - clutter_label_set_text (CLUTTER_LABEL (label), "\342\206\223"); - - to_x = 0; - to_y = -screen_height; - break; - - case META_MOTION_LEFT: - clutter_label_set_text (CLUTTER_LABEL (label), "\342\206\220"); - - to_x = -screen_width * -1; - to_y = 0; - break; - - case META_MOTION_RIGHT: - clutter_label_set_text (CLUTTER_LABEL (label), "\342\206\222"); - - to_x = -screen_width; - to_y = 0; - break; - - default: - break; - } - - /* dest group offscreen and on top */ - clutter_actor_set_position (group2, to_x, to_y); /* *-1 for simpler */ - clutter_actor_raise_top (group2); - - /* center arrow */ - clutter_actor_set_position - (group3, - (screen_width - clutter_actor_get_width (group3)) / 2, - (screen_height - clutter_actor_get_height (group3)) / 2); - - - /* workspace were going too */ - ppriv->tml_switch_workspace2 = - clutter_effect_move (ppriv->switch_workspace_effect, group2, - 0, 0, - on_switch_workspace_effect_complete, - - actors); - /* coming from */ - ppriv->tml_switch_workspace1 = - clutter_effect_move (ppriv->switch_workspace_effect, group1, - to_x, to_y, - NULL, NULL); - - /* arrow */ - clutter_effect_fade (ppriv->switch_workspace_arrow_effect, group3, - 0, - NULL, NULL); - - -} - -/* - * Minimize effect completion callback; this function restores actor state, and - * calls the manager callback function. - */ -static void -on_minimize_effect_complete (ClutterActor *actor, gpointer data) -{ - /* - * Must reverse the effect of the effect; must hide it first to ensure - * that the restoration will not be visible. - */ - MutterPlugin *plugin = mutter_get_plugin (); - ActorPrivate *apriv; - MutterWindow *mcw = MUTTER_WINDOW (actor); - - apriv = get_actor_private (MUTTER_WINDOW (actor)); - apriv->tml_minimize = NULL; - - clutter_actor_hide (actor); - - clutter_actor_set_scale (actor, 1.0, 1.0); - clutter_actor_move_anchor_point_from_gravity (actor, - CLUTTER_GRAVITY_NORTH_WEST); - - /* Now notify the manager that we are done with this effect */ - mutter_plugin_effect_completed (plugin, mcw, - MUTTER_PLUGIN_MINIMIZE); -} - -/* - * Simple minimize handler: it applies a scale effect (which must be reversed on - * completion). - */ -static void -minimize (MutterWindow *mcw) - -{ - MutterPlugin *plugin = mutter_get_plugin (); - PluginPrivate *priv = plugin->plugin_private; - MetaCompWindowType type; - ClutterActor *actor = CLUTTER_ACTOR (mcw); - - type = mutter_window_get_window_type (mcw); - - if (type == META_COMP_WINDOW_NORMAL) - { - ActorPrivate *apriv = get_actor_private (mcw); - - apriv->is_minimized = TRUE; - - clutter_actor_move_anchor_point_from_gravity (actor, - CLUTTER_GRAVITY_CENTER); - - apriv->tml_minimize = clutter_effect_scale (priv->minimize_effect, - actor, - 0.0, - 0.0, - (ClutterEffectCompleteFunc) - on_minimize_effect_complete, - NULL); - } - else - mutter_plugin_effect_completed (plugin, mcw, MUTTER_PLUGIN_MINIMIZE); -} - -/* - * Minimize effect completion callback; this function restores actor state, and - * calls the manager callback function. - */ -static void -on_maximize_effect_complete (ClutterActor *actor, gpointer data) -{ - /* - * Must reverse the effect of the effect. - */ - MutterPlugin *plugin = mutter_get_plugin (); - MutterWindow *mcw = MUTTER_WINDOW (actor); - ActorPrivate *apriv = get_actor_private (mcw); - - apriv->tml_maximize = NULL; - - clutter_actor_set_scale (actor, 1.0, 1.0); - clutter_actor_move_anchor_point_from_gravity (actor, - CLUTTER_GRAVITY_NORTH_WEST); - - /* Now notify the manager that we are done with this effect */ - mutter_plugin_effect_completed (plugin, mcw, MUTTER_PLUGIN_MAXIMIZE); -} - -/* - * The Nature of Maximize operation is such that it is difficult to do a visual - * effect that would work well. Scaling, the obvious effect, does not work that - * well, because at the end of the effect we end up with window content bigger - * and differently laid out than in the real window; this is a proof concept. - * - * (Something like a sound would be more appropriate.) - */ -static void -maximize (MutterWindow *mcw, - gint end_x, gint end_y, gint end_width, gint end_height) -{ - MutterPlugin *plugin = mutter_get_plugin (); - PluginPrivate *priv = plugin->plugin_private; - MetaCompWindowType type; - ClutterActor *actor = CLUTTER_ACTOR (mcw); - - gdouble scale_x = 1.0; - gdouble scale_y = 1.0; - gint anchor_x = 0; - gint anchor_y = 0; - - type = mutter_window_get_window_type (mcw); - - if (type == META_COMP_WINDOW_NORMAL) - { - ActorPrivate *apriv = get_actor_private (mcw); - guint width, height; - gint x, y; - - apriv->is_maximized = TRUE; - - clutter_actor_get_size (actor, &width, &height); - clutter_actor_get_position (actor, &x, &y); - - /* - * Work out the scale and anchor point so that the window is expanding - * smoothly into the target size. - */ - scale_x = (gdouble)end_width / (gdouble) width; - scale_y = (gdouble)end_height / (gdouble) height; - - anchor_x = (gdouble)(x - end_x)*(gdouble)width / - ((gdouble)(end_width - width)); - anchor_y = (gdouble)(y - end_y)*(gdouble)height / - ((gdouble)(end_height - height)); - - clutter_actor_move_anchor_point (actor, anchor_x, anchor_y); - - apriv->tml_maximize = clutter_effect_scale (priv->maximize_effect, - actor, - scale_x, - scale_y, - (ClutterEffectCompleteFunc) - on_maximize_effect_complete, - NULL); - - return; - } - - mutter_plugin_effect_completed (plugin, mcw, MUTTER_PLUGIN_MAXIMIZE); -} - -/* - * See comments on the maximize() function. - * - * (Just a skeleton code.) - */ -static void -unmaximize (MutterWindow *mcw, - gint end_x, gint end_y, gint end_width, gint end_height) -{ - MutterPlugin *plugin = mutter_get_plugin (); - MetaCompWindowType type; - - type = mutter_window_get_window_type (mcw); - - if (type == META_COMP_WINDOW_NORMAL) - { - ActorPrivate *apriv = get_actor_private (mcw); - - apriv->is_maximized = FALSE; - } - - /* Do this conditionally, if the effect requires completion callback. */ - mutter_plugin_effect_completed (plugin, mcw, MUTTER_PLUGIN_UNMAXIMIZE); -} - -static void -on_map_effect_complete (ClutterActor *actor, gpointer data) -{ - /* - * Must reverse the effect of the effect. - */ - MutterPlugin *plugin = mutter_get_plugin (); - MutterWindow *mcw = MUTTER_WINDOW (actor); - ActorPrivate *apriv = get_actor_private (mcw); - - apriv->tml_map = NULL; - - clutter_actor_move_anchor_point_from_gravity (actor, - CLUTTER_GRAVITY_NORTH_WEST); - - /* Now notify the manager that we are done with this effect */ - mutter_plugin_effect_completed (plugin, mcw, MUTTER_PLUGIN_MAP); -} - -/* - * Simple map handler: it applies a scale effect which must be reversed on - * completion). - */ -static void -map (MutterWindow *mcw) -{ - MutterPlugin *plugin = mutter_get_plugin (); - PluginPrivate *priv = plugin->plugin_private; - MetaCompWindowType type; - ClutterActor *actor = CLUTTER_ACTOR (mcw); - - type = mutter_window_get_window_type (mcw); - - if (type == META_COMP_WINDOW_NORMAL) - { - ActorPrivate *apriv = get_actor_private (mcw); - - clutter_actor_move_anchor_point_from_gravity (actor, - CLUTTER_GRAVITY_CENTER); - - clutter_actor_set_scale (actor, 0.0, 0.0); - clutter_actor_show (actor); - - apriv->tml_map = clutter_effect_scale (priv->map_effect, - actor, - 1.0, - 1.0, - (ClutterEffectCompleteFunc) - on_map_effect_complete, - NULL); - - apriv->is_minimized = FALSE; - - } - else - mutter_plugin_effect_completed (plugin, mcw, MUTTER_PLUGIN_MAP); -} - -/* - * Destroy effect completion callback; this is a simple effect that requires no - * further action than notifying the manager that the effect is completed. - */ -static void -on_destroy_effect_complete (ClutterActor *actor, gpointer data) -{ - MutterPlugin *plugin = mutter_get_plugin (); - MutterWindow *mcw = MUTTER_WINDOW (actor); - ActorPrivate *apriv = get_actor_private (mcw); - - apriv->tml_destroy = NULL; - - mutter_plugin_effect_completed (plugin, mcw, MUTTER_PLUGIN_DESTROY); -} - -/* - * Simple TV-out like effect. - */ -static void -destroy (MutterWindow *mcw) -{ - MutterPlugin *plugin = mutter_get_plugin (); - PluginPrivate *priv = plugin->plugin_private; - MetaCompWindowType type; - ClutterActor *actor = CLUTTER_ACTOR (mcw); - - type = mutter_window_get_window_type (mcw); - - if (type == META_COMP_WINDOW_NORMAL) - { - ActorPrivate *apriv = get_actor_private (mcw); - - clutter_actor_move_anchor_point_from_gravity (actor, - CLUTTER_GRAVITY_CENTER); - - apriv->tml_destroy = clutter_effect_scale (priv->destroy_effect, - actor, - 1.0, - 0.0, - (ClutterEffectCompleteFunc) - on_destroy_effect_complete, - NULL); - } - else - mutter_plugin_effect_completed (plugin, mcw, MUTTER_PLUGIN_DESTROY); -} - -/* - * Use this function to disable stage input - * - * Used by the completion callback for the panel in/out effects - */ -static void -disable_stage (MutterPlugin *plugin) -{ - gint screen_width, screen_height; - - mutter_plugin_query_screen_size (plugin, &screen_width, &screen_height); - mutter_plugin_set_stage_input_area (plugin, 0, 0, screen_width, 1); -} - -static void -on_panel_effect_complete (ClutterActor *panel, gpointer data) -{ - gboolean reactive = GPOINTER_TO_INT (data); - MutterPlugin *plugin = mutter_get_plugin (); - PluginPrivate *priv = plugin->plugin_private; - - if (reactive) - { - priv->panel_out_in_progress = FALSE; - mutter_plugin_set_stage_reactive (plugin, reactive); - } - else - { - priv->panel_back_in_progress = FALSE; - disable_stage (plugin); - } -} - -static gboolean -xevent_filter (XEvent *xev) -{ - MutterPlugin *plugin = mutter_get_plugin (); - ClutterActor *stage; - - stage = mutter_plugin_get_stage (plugin); - - clutter_x11_handle_event (xev); - - return FALSE; -} - -static void -kill_effect (MutterWindow *mcw, gulong event) -{ - MutterPlugin *plugin = mutter_get_plugin (); - ActorPrivate *apriv; - ClutterActor *actor = CLUTTER_ACTOR (mcw); - - if (event & MUTTER_PLUGIN_SWITCH_WORKSPACE) - { - PluginPrivate *ppriv = plugin->plugin_private; - - if (ppriv->tml_switch_workspace1) - { - clutter_timeline_stop (ppriv->tml_switch_workspace1); - clutter_timeline_stop (ppriv->tml_switch_workspace2); - on_switch_workspace_effect_complete (ppriv->desktop1, ppriv->actors); - } - - if (!(event & ~MUTTER_PLUGIN_SWITCH_WORKSPACE)) - { - /* Workspace switch only, nothing more to do */ - return; - } - } - - apriv = get_actor_private (mcw); - - if ((event & MUTTER_PLUGIN_MINIMIZE) && apriv->tml_minimize) - { - clutter_timeline_stop (apriv->tml_minimize); - on_minimize_effect_complete (actor, NULL); - } - - if ((event & MUTTER_PLUGIN_MAXIMIZE) && apriv->tml_maximize) - { - clutter_timeline_stop (apriv->tml_maximize); - on_maximize_effect_complete (actor, NULL); - } - - if ((event & MUTTER_PLUGIN_MAP) && apriv->tml_map) - { - clutter_timeline_stop (apriv->tml_map); - on_map_effect_complete (actor, NULL); - } - - if ((event & MUTTER_PLUGIN_DESTROY) && apriv->tml_destroy) - { - clutter_timeline_stop (apriv->tml_destroy); - on_destroy_effect_complete (actor, NULL); - } -} - - -const gchar * g_module_check_init (GModule *module); -const gchar * -g_module_check_init (GModule *module) -{ - MutterPlugin *plugin = mutter_get_plugin (); - - /* Human readable name (for use in UI) */ - plugin->name = "Experimental effects", - - /* Plugin load time initialiser */ - plugin->do_init = do_init; - - /* Effect handlers */ - plugin->minimize = minimize; - plugin->destroy = destroy; - plugin->map = map; - plugin->maximize = maximize; - plugin->unmaximize = unmaximize; - plugin->switch_workspace = switch_workspace; - plugin->kill_effect = kill_effect; - plugin->xevent_filter = xevent_filter; - - /* The reload handler */ - plugin->reload = reload; - - return NULL; -} - -static void switcher_clone_weak_notify (gpointer data, GObject *object); - -static void -switcher_origin_weak_notify (gpointer data, GObject *object) -{ - ClutterActor *clone = data; - - /* - * The original MutterWindow destroyed; remove the weak reference the - * we added to the clone referencing the original window, then - * destroy the clone. - */ - g_object_weak_unref (G_OBJECT (clone), switcher_clone_weak_notify, object); - clutter_actor_destroy (clone); -} - -static void -switcher_clone_weak_notify (gpointer data, GObject *object) -{ - ClutterActor *origin = data; - - /* - * Clone destroyed -- this function gets only called whent the clone - * is destroyed while the original MutterWindow still exists, so remove - * the weak reference we added on the origin for sake of the clone. - */ - g_object_weak_unref (G_OBJECT (origin), switcher_origin_weak_notify, object); -} - -static gboolean -switcher_clone_input_cb (ClutterActor *clone, - ClutterEvent *event, - gpointer data) -{ - MutterWindow *mw = data; - MetaWindow *window; - MetaWorkspace *workspace; - - printf ("Actor %p (%s) clicked\n", - clone, clutter_actor_get_name (clone)); - - window = mutter_window_get_meta_window (mw); - workspace = meta_window_get_workspace (window); - - meta_workspace_activate_with_focus (workspace, window, event->any.time); - - return FALSE; -} - -/* - * This is a simple example of how a switcher might access the windows. - * - * Note that we use ClutterCloneTexture hooked up to the texture *inside* - * MutterWindow (with FBO support, we could clone the entire MutterWindow, - * although for the switcher purposes that is probably not what is wanted - * anyway). - */ -static void -hide_switcher (void) -{ - MutterPlugin *plugin = mutter_get_plugin (); - PluginPrivate *priv = plugin->plugin_private; - - if (!priv->switcher) - return; - - clutter_actor_destroy (priv->switcher); - priv->switcher = NULL; -} - -static void -show_switcher (void) -{ - MutterPlugin *plugin = mutter_get_plugin (); - PluginPrivate *priv = plugin->plugin_private; - ClutterActor *overlay; - GList *l; - ClutterActor *switcher; - TidyGrid *grid; - guint panel_height; - gint panel_y; - gint screen_width, screen_height; - - mutter_plugin_query_screen_size (plugin, &screen_width, &screen_height); - - switcher = tidy_grid_new (); - - grid = TIDY_GRID (switcher); - - tidy_grid_set_homogenous_rows (grid, TRUE); - tidy_grid_set_homogenous_columns (grid, TRUE); - tidy_grid_set_column_major (grid, FALSE); - tidy_grid_set_row_gap (grid, CLUTTER_UNITS_FROM_INT (10)); - tidy_grid_set_column_gap (grid, CLUTTER_UNITS_FROM_INT (10)); - - l = mutter_plugin_get_windows (plugin); - while (l) - { - MutterWindow *mw = l->data; - MetaCompWindowType type = mutter_window_get_window_type (mw); - ClutterActor *a = CLUTTER_ACTOR (mw); - ClutterActor *texture; - ClutterActor *clone; - guint w, h; - gdouble s_x, s_y, s; - - /* - * Only show regular windows. - */ - if (mutter_window_is_override_redirect (mw) || - type != META_COMP_WINDOW_NORMAL) - { - l = l->next; - continue; - } - -#if 0 - printf ("Adding %p:%s\n", - mw, - mutter_window_get_meta_window (mw) ? - mutter_window_get_meta_window (mw)->desc : "unknown"); -#endif - - texture = mutter_window_get_texture (mw); - clone = clutter_clone_texture_new (CLUTTER_TEXTURE (texture)); - - clutter_actor_set_name (clone, mutter_window_get_meta_window (mw)->desc); - g_signal_connect (clone, - "button-press-event", - G_CALLBACK (switcher_clone_input_cb), mw); - - g_object_weak_ref (G_OBJECT (mw), switcher_origin_weak_notify, clone); - g_object_weak_ref (G_OBJECT (clone), switcher_clone_weak_notify, mw); - - /* - * Scale clone to fit the predefined size of the grid cell - */ - clutter_actor_get_size (a, &w, &h); - s_x = (gdouble) SWITCHER_CELL_WIDTH / (gdouble) w; - s_y = (gdouble) SWITCHER_CELL_HEIGHT / (gdouble) h; - - s = s_x < s_y ? s_x : s_y; - - if (s_x < s_y) - clutter_actor_set_size (clone, - (guint)((gdouble)w * s_x), - (guint)((gdouble)h * s_x)); - else - clutter_actor_set_size (clone, - (guint)((gdouble)w * s_y), - (guint)((gdouble)h * s_y)); - - clutter_actor_set_reactive (clone, TRUE); - - clutter_container_add_actor (CLUTTER_CONTAINER (grid), clone); - l = l->next; - } - - if (priv->switcher) - hide_switcher (); - - priv->switcher = switcher; - - panel_height = clutter_actor_get_height (priv->panel); - panel_y = clutter_actor_get_y (priv->panel); - - clutter_actor_set_position (switcher, 10, panel_height + panel_y); - - overlay = mutter_plugin_get_overlay_group (plugin); - clutter_container_add_actor (CLUTTER_CONTAINER (overlay), switcher); - - clutter_actor_set_width (grid, screen_width); -} - -static void -toggle_switcher () -{ - MutterPlugin *plugin = mutter_get_plugin (); - PluginPrivate *priv = plugin->plugin_private; - - if (priv->switcher) - hide_switcher (); - else - show_switcher (); -} - -static gboolean -stage_input_cb (ClutterActor *stage, ClutterEvent *event, gpointer data) -{ - gboolean capture = GPOINTER_TO_INT (data); - - if ((capture && event->type == CLUTTER_MOTION) || - (!capture && event->type == CLUTTER_BUTTON_PRESS)) - { - gint event_y; - MutterPlugin *plugin = mutter_get_plugin (); - PluginPrivate *priv = plugin->plugin_private; - - if (event->type == CLUTTER_MOTION) - event_y = ((ClutterMotionEvent*)event)->y; - else - event_y = ((ClutterButtonEvent*)event)->y; - - if (priv->panel_out_in_progress || priv->panel_back_in_progress) - return FALSE; - - if (priv->panel_out && - (event->type == CLUTTER_BUTTON_PRESS || !priv->switcher)) - { - guint height = clutter_actor_get_height (priv->panel); - gint x = clutter_actor_get_x (priv->panel); - - if (event_y > (gint)height) - { - priv->panel_back_in_progress = TRUE; - - clutter_effect_move (priv->panel_slide_effect, - priv->panel, x, -height, - on_panel_effect_complete, - GINT_TO_POINTER (FALSE)); - priv->panel_out = FALSE; - } - } - else if (event_y < PANEL_SLIDE_THRESHOLD) - { - gint x = clutter_actor_get_x (priv->panel); - - priv->panel_out_in_progress = TRUE; - clutter_effect_move (priv->panel_slide_effect, - priv->panel, x, 0, - on_panel_effect_complete, - GINT_TO_POINTER (TRUE)); - - priv->panel_out = TRUE; - } - } - else if (event->type == CLUTTER_KEY_RELEASE) - { - ClutterKeyEvent *kev = (ClutterKeyEvent *) event; - - g_print ("*** key press event (key:%c) ***\n", - clutter_key_event_symbol (kev)); - - } - - if (!capture && (event->type == CLUTTER_BUTTON_PRESS)) - { - toggle_switcher (); - } - - return FALSE; -} - -static ClutterActor * -make_panel (gint width) -{ - ClutterActor *panel; - ClutterActor *background; - ClutterColor clr = {0x44, 0x44, 0x44, 0x7f}; - - panel = clutter_group_new (); - - /* FIME -- size and color */ - background = clutter_rectangle_new_with_color (&clr); - clutter_container_add_actor (CLUTTER_CONTAINER (panel), background); - clutter_actor_set_size (background, width, PANEL_HEIGHT); - - return panel; -} - -/* - * Core of the plugin init function, called for initial initialization and - * by the reload() function. Returns TRUE on success. - */ -static gboolean -do_init (const char *params) -{ - MutterPlugin *plugin = mutter_get_plugin (); - - PluginPrivate *priv = g_new0 (PluginPrivate, 1); - guint destroy_timeout = DESTROY_TIMEOUT; - guint minimize_timeout = MINIMIZE_TIMEOUT; - guint maximize_timeout = MAXIMIZE_TIMEOUT; - guint map_timeout = MAP_TIMEOUT; - guint switch_timeout = SWITCH_TIMEOUT; - guint panel_slide_timeout = PANEL_SLIDE_TIMEOUT; - const gchar *name; - ClutterActor *overlay; - ClutterActor *panel; - gint screen_width, screen_height; - - plugin->plugin_private = priv; - - name = plugin->name; - plugin->name = _(name); - - mutter_plugin_query_screen_size (plugin, &screen_width, &screen_height); - - if (params) - { - if (strstr (params, "debug")) - { - g_debug ("%s: Entering debug mode.", - plugin->name); - - priv->debug_mode = TRUE; - - /* - * Double the effect duration to make them easier to observe. - */ - destroy_timeout *= 2; - minimize_timeout *= 2; - maximize_timeout *= 2; - map_timeout *= 2; - switch_timeout *= 2; - } - } - - priv->destroy_effect - = clutter_effect_template_new (clutter_timeline_new_for_duration ( - destroy_timeout), - CLUTTER_ALPHA_SINE_INC); - - - priv->minimize_effect - = clutter_effect_template_new (clutter_timeline_new_for_duration ( - minimize_timeout), - CLUTTER_ALPHA_SINE_INC); - - priv->maximize_effect - = clutter_effect_template_new (clutter_timeline_new_for_duration ( - maximize_timeout), - CLUTTER_ALPHA_SINE_INC); - - priv->map_effect - = clutter_effect_template_new (clutter_timeline_new_for_duration ( - map_timeout), - CLUTTER_ALPHA_SINE_INC); - - priv->switch_workspace_effect - = clutter_effect_template_new (clutter_timeline_new_for_duration ( - switch_timeout), - CLUTTER_ALPHA_SINE_INC); - - /* better syncing as multiple groups run off this */ - clutter_effect_template_set_timeline_clone (priv->switch_workspace_effect, - TRUE); - - priv->switch_workspace_arrow_effect - = clutter_effect_template_new (clutter_timeline_new_for_duration ( - switch_timeout*4), - CLUTTER_ALPHA_SINE_INC); - - overlay = mutter_plugin_get_overlay_group (plugin); - - panel = priv->panel = make_panel (screen_width); - clutter_container_add_actor (CLUTTER_CONTAINER (overlay), panel); - - priv->panel_slide_effect - = clutter_effect_template_new (clutter_timeline_new_for_duration ( - panel_slide_timeout), - CLUTTER_ALPHA_SINE_INC); - - clutter_actor_set_position (panel, 0, - -clutter_actor_get_height (panel)); - - /* - * Set up the stage even processing - */ - disable_stage (plugin); - - /* - * Hook to the captured signal, so we get to see all events before our - * children and do not interfere with their event processing. - */ - g_signal_connect (mutter_plugin_get_stage (plugin), - "captured-event", G_CALLBACK (stage_input_cb), - GINT_TO_POINTER (TRUE)); - - g_signal_connect (mutter_plugin_get_stage (plugin), - "button-press-event", G_CALLBACK (stage_input_cb), - GINT_TO_POINTER (FALSE)); - - mutter_plugin_set_stage_input_area (plugin, 0, 0, screen_width, 1); - - clutter_set_motion_events_enabled (TRUE); - - return TRUE; -} - -static void -free_plugin_private (PluginPrivate *priv) -{ - if (!priv) - return; - - g_object_unref (priv->destroy_effect); - g_object_unref (priv->minimize_effect); - g_object_unref (priv->maximize_effect); - g_object_unref (priv->switch_workspace_effect); - g_object_unref (priv->switch_workspace_arrow_effect); - - g_free (priv); - - mutter_get_plugin()->plugin_private = NULL; -} - -/* - * Called by the plugin manager when we stuff like the command line parameters - * changed. - */ -static gboolean -reload (const char *params) -{ - MutterPlugin *plugin = mutter_get_plugin (); - PluginPrivate *priv = plugin->plugin_private; - - if (do_init (params)) - { - /* Success; free the old private struct */ - free_plugin_private (priv); - return TRUE; - } - else - { - /* Fail -- fall back to the old private. */ - plugin->plugin_private = priv; - } - - return FALSE; -} - -/* - * GModule unload function -- do any cleanup required. - */ -G_MODULE_EXPORT void g_module_unload (GModule *module); -G_MODULE_EXPORT void g_module_unload (GModule *module) -{ - PluginPrivate *priv = mutter_get_plugin()->plugin_private; - - free_plugin_private (priv); -} diff --git a/src/compositor/mutter/tidy/tidy-grid.c b/src/compositor/mutter/tidy/tidy-grid.c deleted file mode 100644 index c5d788a5f..000000000 --- a/src/compositor/mutter/tidy/tidy-grid.c +++ /dev/null @@ -1,1000 +0,0 @@ -/* tidy-grid.h: Reflowing grid layout container for clutter. - * - * Copyright (C) 2008 Intel Corporation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Written by: Øyvind Kolås - */ - -/* TODO: - * - * - Better names for properties. - * - Caching layouted positions? (perhaps needed for huge collections) - * - More comments / overall concept on how the layouting is done. - * - Allow more layout directions than just row major / column major. - */ - -#include -#include -#include - -#include "tidy-grid.h" - -typedef struct _TidyGridActorData TidyGridActorData; - -static void tidy_grid_dispose (GObject *object); -static void tidy_grid_finalize (GObject *object); - -static void tidy_grid_finalize (GObject *object); - -static void tidy_grid_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void tidy_grid_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -static void clutter_container_iface_init (ClutterContainerIface *iface); - -static void tidy_grid_real_add (ClutterContainer *container, - ClutterActor *actor); -static void tidy_grid_real_remove (ClutterContainer *container, - ClutterActor *actor); -static void tidy_grid_real_foreach (ClutterContainer *container, - ClutterCallback callback, - gpointer user_data); -static void tidy_grid_real_raise (ClutterContainer *container, - ClutterActor *actor, - ClutterActor *sibling); -static void tidy_grid_real_lower (ClutterContainer *container, - ClutterActor *actor, - ClutterActor *sibling); -static void -tidy_grid_real_sort_depth_order (ClutterContainer *container); - -static void -tidy_grid_free_actor_data (gpointer data); - -static void tidy_grid_paint (ClutterActor *actor); - -static void tidy_grid_pick (ClutterActor *actor, - const ClutterColor *color); - -static void -tidy_grid_get_preferred_width (ClutterActor *self, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p); - -static void -tidy_grid_get_preferred_height (ClutterActor *self, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p); - -static void tidy_grid_allocate (ClutterActor *self, - const ClutterActorBox *box, - gboolean absolute_origin_changed); - -G_DEFINE_TYPE_WITH_CODE (TidyGrid, tidy_grid, - CLUTTER_TYPE_ACTOR, - G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_CONTAINER, - clutter_container_iface_init)); - -#define TIDY_GRID_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TIDY_TYPE_GRID, \ - TidyGridPrivate)) - -struct _TidyGridPrivate -{ - ClutterUnit for_height, for_width; - ClutterUnit pref_width, pref_height; - ClutterUnit alloc_width, alloc_height; - - gboolean absolute_origin_changed; - GHashTable *hash_table; - GList *list; - - gboolean homogenous_rows; - gboolean homogenous_columns; - gboolean end_align; - ClutterUnit column_gap, row_gap; - gdouble valign, halign; - - gboolean column_major; - - gboolean first_of_batch; - ClutterUnit a_current_sum, a_wrap; - ClutterUnit max_extent_a; - ClutterUnit max_extent_b; -}; - -enum -{ - PROP_0, - PROP_HOMOGENOUS_ROWS, - PROP_HOMOGENOUS_COLUMNS, - PROP_ROW_GAP, - PROP_COLUMN_GAP, - PROP_VALIGN, - PROP_HALIGN, - PROP_END_ALIGN, - PROP_COLUMN_MAJOR, -}; - -struct _TidyGridActorData -{ - gboolean xpos_set, ypos_set; - ClutterUnit xpos, ypos; - ClutterUnit pref_width, pref_height; -}; - -static void -tidy_grid_class_init (TidyGridClass *klass) -{ - GObjectClass *gobject_class = (GObjectClass *) klass; - ClutterActorClass *actor_class = (ClutterActorClass *) klass; - - gobject_class->dispose = tidy_grid_dispose; - gobject_class->finalize = tidy_grid_finalize; - - gobject_class->set_property = tidy_grid_set_property; - gobject_class->get_property = tidy_grid_get_property; - - actor_class->paint = tidy_grid_paint; - actor_class->pick = tidy_grid_pick; - actor_class->get_preferred_width = tidy_grid_get_preferred_width; - actor_class->get_preferred_height = tidy_grid_get_preferred_height; - actor_class->allocate = tidy_grid_allocate; - - g_type_class_add_private (klass, sizeof (TidyGridPrivate)); - - - g_object_class_install_property - (gobject_class, - PROP_ROW_GAP, - clutter_param_spec_unit ("row-gap", - "Row gap", - "gap between rows in the layout", - 0, CLUTTER_MAXUNIT, - 0, - G_PARAM_READWRITE|G_PARAM_CONSTRUCT)); - - g_object_class_install_property - (gobject_class, - PROP_COLUMN_GAP, - clutter_param_spec_unit ("column-gap", - "Column gap", - "gap between columns in the layout", - 0, CLUTTER_MAXUNIT, - 0, - G_PARAM_READWRITE|G_PARAM_CONSTRUCT)); - - - g_object_class_install_property - (gobject_class, - PROP_HOMOGENOUS_ROWS, - g_param_spec_boolean ("homogenous-rows", - "homogenous rows", - "Should all rows have the same height?", - FALSE, - G_PARAM_READWRITE|G_PARAM_CONSTRUCT)); - - g_object_class_install_property - (gobject_class, - PROP_HOMOGENOUS_COLUMNS, - g_param_spec_boolean ("homogenous-columns", - "homogenous columns", - "Should all columns have the same height?", - FALSE, - G_PARAM_READWRITE|G_PARAM_CONSTRUCT)); - - g_object_class_install_property - (gobject_class, - PROP_COLUMN_MAJOR, - g_param_spec_boolean ("column-major", - "column-major", - "Do a column filling first instead of row filling first", - FALSE, - G_PARAM_READWRITE|G_PARAM_CONSTRUCT)); - - g_object_class_install_property - (gobject_class, - PROP_END_ALIGN, - g_param_spec_boolean ("end-align", - "end-align", - "Right/bottom aligned rows/columns", - FALSE, - G_PARAM_READWRITE|G_PARAM_CONSTRUCT)); - - g_object_class_install_property - (gobject_class, - PROP_VALIGN, - g_param_spec_double ("valign", - "Vertical align", - "Vertical alignment of items within cells", - 0.0, 1.0, 0.0, - G_PARAM_READWRITE|G_PARAM_CONSTRUCT)); - - g_object_class_install_property - (gobject_class, - PROP_HALIGN, - g_param_spec_double ("halign", - "Horizontal align", - "Horizontal alignment of items within cells", - 0.0, 1.0, 0.0, - G_PARAM_READWRITE|G_PARAM_CONSTRUCT)); - -} - -static void -clutter_container_iface_init (ClutterContainerIface *iface) -{ - iface->add = tidy_grid_real_add; - iface->remove = tidy_grid_real_remove; - iface->foreach = tidy_grid_real_foreach; - iface->raise = tidy_grid_real_raise; - iface->lower = tidy_grid_real_lower; - iface->sort_depth_order = tidy_grid_real_sort_depth_order; -} - -static void -tidy_grid_init (TidyGrid *self) -{ - TidyGridPrivate *priv; - - self->priv = priv = TIDY_GRID_GET_PRIVATE (self); - - priv->hash_table - = g_hash_table_new_full (g_direct_hash, - g_direct_equal, - /*g_object_unref*/NULL, - tidy_grid_free_actor_data); -} - -static void -tidy_grid_dispose (GObject *object) -{ - TidyGrid *self = (TidyGrid *) object; - TidyGridPrivate *priv; - - priv = self->priv; - - /* Destroy all of the children. This will cause them to be removed - from the container and unparented */ - clutter_container_foreach (CLUTTER_CONTAINER (object), - (ClutterCallback) clutter_actor_destroy, - NULL); - - G_OBJECT_CLASS (tidy_grid_parent_class)->dispose (object); -} - -static void -tidy_grid_finalize (GObject *object) -{ - TidyGrid *self = (TidyGrid *) object; - TidyGridPrivate *priv = self->priv; - - g_hash_table_destroy (priv->hash_table); - - G_OBJECT_CLASS (tidy_grid_parent_class)->finalize (object); -} - - -void -tidy_grid_set_end_align (TidyGrid *self, - gboolean value) -{ - TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self); - priv->end_align = value; - clutter_actor_queue_relayout (CLUTTER_ACTOR (self)); -} - -gboolean -tidy_grid_get_end_align (TidyGrid *self) -{ - TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self); - return priv->end_align; -} - -void -tidy_grid_set_homogenous_rows (TidyGrid *self, - gboolean value) -{ - TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self); - priv->homogenous_rows = value; - clutter_actor_queue_relayout (CLUTTER_ACTOR (self)); -} - -gboolean -tidy_grid_get_homogenous_rows (TidyGrid *self) -{ - TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self); - return priv->homogenous_rows; -} - - -void -tidy_grid_set_homogenous_columns (TidyGrid *self, - gboolean value) -{ - TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self); - priv->homogenous_columns = value; - clutter_actor_queue_relayout (CLUTTER_ACTOR (self)); -} - - -gboolean -tidy_grid_get_homogenous_columns (TidyGrid *self) -{ - TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self); - return priv->homogenous_columns; -} - - -void -tidy_grid_set_column_major (TidyGrid *self, - gboolean value) -{ - TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self); - priv->column_major = value; - clutter_actor_queue_relayout (CLUTTER_ACTOR (self)); -} - -gboolean -tidy_grid_get_column_major (TidyGrid *self) -{ - TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self); - return priv->column_major; -} - -void -tidy_grid_set_column_gap (TidyGrid *self, - ClutterUnit value) -{ - TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self); - priv->column_gap = value; - clutter_actor_queue_relayout (CLUTTER_ACTOR (self)); -} - -ClutterUnit -tidy_grid_get_column_gap (TidyGrid *self) -{ - TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self); - return priv->column_gap; -} - - - -void -tidy_grid_set_row_gap (TidyGrid *self, - ClutterUnit value) -{ - TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self); - priv->row_gap = value; - clutter_actor_queue_relayout (CLUTTER_ACTOR (self)); -} - -ClutterUnit -tidy_grid_get_row_gap (TidyGrid *self) -{ - TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self); - return priv->row_gap; -} - - -void -tidy_grid_set_valign (TidyGrid *self, - gdouble value) -{ - TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self); - priv->valign = value; - clutter_actor_queue_relayout (CLUTTER_ACTOR (self)); -} - -gdouble -tidy_grid_get_valign (TidyGrid *self) -{ - TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self); - return priv->valign; -} - - - -void -tidy_grid_set_halign (TidyGrid *self, - gdouble value) - -{ - TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self); - priv->halign = value; - clutter_actor_queue_relayout (CLUTTER_ACTOR (self)); -} - -gdouble -tidy_grid_get_halign (TidyGrid *self) -{ - TidyGridPrivate *priv = TIDY_GRID_GET_PRIVATE (self); - return priv->halign; -} - - -static void -tidy_grid_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - TidyGrid *grid = TIDY_GRID (object); - - TidyGridPrivate *priv; - - priv = TIDY_GRID_GET_PRIVATE (object); - - switch (prop_id) - { - case PROP_END_ALIGN: - tidy_grid_set_end_align (grid, g_value_get_boolean (value)); - break; - case PROP_HOMOGENOUS_ROWS: - tidy_grid_set_homogenous_rows (grid, g_value_get_boolean (value)); - break; - case PROP_HOMOGENOUS_COLUMNS: - tidy_grid_set_homogenous_columns (grid, g_value_get_boolean (value)); - break; - case PROP_COLUMN_MAJOR: - tidy_grid_set_column_major (grid, g_value_get_boolean (value)); - break; - case PROP_COLUMN_GAP: - tidy_grid_set_column_gap (grid, clutter_value_get_unit (value)); - break; - case PROP_ROW_GAP: - tidy_grid_set_row_gap (grid, clutter_value_get_unit (value)); - break; - case PROP_VALIGN: - tidy_grid_set_valign (grid, g_value_get_double (value)); - break; - case PROP_HALIGN: - tidy_grid_set_halign (grid, g_value_get_double (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -tidy_grid_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - TidyGrid *grid = TIDY_GRID (object); - - TidyGridPrivate *priv; - - priv = TIDY_GRID_GET_PRIVATE (object); - - switch (prop_id) - { - case PROP_HOMOGENOUS_ROWS: - g_value_set_boolean (value, tidy_grid_get_homogenous_rows (grid)); - break; - case PROP_HOMOGENOUS_COLUMNS: - g_value_set_boolean (value, tidy_grid_get_homogenous_columns (grid)); - break; - case PROP_END_ALIGN: - g_value_set_boolean (value, tidy_grid_get_end_align (grid)); - break; - case PROP_COLUMN_MAJOR: - g_value_set_boolean (value, tidy_grid_get_column_major (grid)); - break; - case PROP_COLUMN_GAP: - clutter_value_set_unit (value, tidy_grid_get_column_gap (grid)); - break; - case PROP_ROW_GAP: - clutter_value_set_unit (value, tidy_grid_get_row_gap (grid)); - break; - case PROP_VALIGN: - g_value_set_double (value, tidy_grid_get_valign (grid)); - break; - case PROP_HALIGN: - g_value_set_double (value, tidy_grid_get_halign (grid)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - - -static void -tidy_grid_free_actor_data (gpointer data) -{ - g_slice_free (TidyGridActorData, data); -} - -ClutterActor * -tidy_grid_new (void) -{ - ClutterActor *self = g_object_new (TIDY_TYPE_GRID, NULL); - - return self; -} - -static void -tidy_grid_real_add (ClutterContainer *container, - ClutterActor *actor) -{ - TidyGridPrivate *priv; - TidyGridActorData *data; - - g_return_if_fail (TIDY_IS_GRID (container)); - - g_object_ref (actor); - - priv = TIDY_GRID (container)->priv; - - clutter_actor_set_parent (actor, CLUTTER_ACTOR (container)); - - data = g_slice_alloc0 (sizeof (TidyGridActorData)); - - priv->list = g_list_append (priv->list, actor); - g_hash_table_insert (priv->hash_table, actor, data); - - clutter_actor_queue_relayout (CLUTTER_ACTOR (container)); - - g_object_unref (actor); -} - -static void -tidy_grid_real_remove (ClutterContainer *container, - ClutterActor *actor) -{ - TidyGrid *layout = TIDY_GRID (container); - TidyGridPrivate *priv = layout->priv; - - g_object_ref (actor); - - if (g_hash_table_remove (priv->hash_table, actor)) - { - clutter_actor_unparent (actor); - - clutter_actor_queue_relayout (CLUTTER_ACTOR (layout)); - - g_signal_emit_by_name (container, "actor-removed", actor); - - if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR (layout))) - clutter_actor_queue_redraw (CLUTTER_ACTOR (layout)); - } - priv->list = g_list_remove (priv->list, actor); - - g_object_unref (actor); -} - -static void -tidy_grid_real_foreach (ClutterContainer *container, - ClutterCallback callback, - gpointer user_data) -{ - TidyGrid *layout = TIDY_GRID (container); - TidyGridPrivate *priv = layout->priv; - - g_list_foreach (priv->list, (GFunc) callback, user_data); -} - -static void -tidy_grid_real_raise (ClutterContainer *container, - ClutterActor *actor, - ClutterActor *sibling) -{ - /* STUB */ -} - -static void -tidy_grid_real_lower (ClutterContainer *container, - ClutterActor *actor, - ClutterActor *sibling) -{ - /* STUB */ -} - -static void -tidy_grid_real_sort_depth_order (ClutterContainer *container) -{ - /* STUB */ -} - -static void -tidy_grid_paint (ClutterActor *actor) -{ - TidyGrid *layout = (TidyGrid *) actor; - TidyGridPrivate *priv = layout->priv; - GList *child_item; - - for (child_item = priv->list; - child_item != NULL; - child_item = child_item->next) - { - ClutterActor *child = child_item->data; - - g_assert (child != NULL); - - if (CLUTTER_ACTOR_IS_VISIBLE (child)) - clutter_actor_paint (child); - } - -} - -static void -tidy_grid_pick (ClutterActor *actor, - const ClutterColor *color) -{ - /* Chain up so we get a bounding box pained (if we are reactive) */ - CLUTTER_ACTOR_CLASS (tidy_grid_parent_class)->pick (actor, color); - - /* Just forward to the paint call which in turn will trigger - * the child actors also getting 'picked'. - */ - if (CLUTTER_ACTOR_IS_VISIBLE (actor)) - tidy_grid_paint (actor); -} - -static void -tidy_grid_get_preferred_width (ClutterActor *self, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p) -{ - TidyGrid *layout = (TidyGrid *) self; - TidyGridPrivate *priv = layout->priv; - ClutterUnit natural_width; - - natural_width = CLUTTER_UNITS_FROM_INT (200); - if (min_width_p) - *min_width_p = natural_width; - if (natural_width_p) - *natural_width_p = natural_width; - - priv->pref_width = natural_width; -} - -static void -tidy_grid_get_preferred_height (ClutterActor *self, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p) -{ - TidyGrid *layout = (TidyGrid *) self; - TidyGridPrivate *priv = layout->priv; - ClutterUnit natural_height; - - natural_height = CLUTTER_UNITS_FROM_INT (200); - - priv->for_width = for_width; - priv->pref_height = natural_height; - - if (min_height_p) - *min_height_p = natural_height; - if (natural_height_p) - *natural_height_p = natural_height; -} - -static ClutterUnit -compute_row_height (GList *siblings, - ClutterUnit best_yet, - ClutterUnit current_a, - TidyGridPrivate *priv) -{ - GList *l; - - gboolean homogenous_a; - gboolean homogenous_b; - ClutterUnit gap; - - if (priv->column_major) - { - homogenous_b = priv->homogenous_columns; - homogenous_a = priv->homogenous_rows; - gap = priv->row_gap; - } - else - { - homogenous_a = priv->homogenous_columns; - homogenous_b = priv->homogenous_rows; - gap = priv->column_gap; - } - - for (l = siblings; l != NULL; l = l->next) - { - ClutterActor *child = l->data; - ClutterUnit natural_width, natural_height; - - /* each child will get as much space as they require */ - clutter_actor_get_preferred_size (CLUTTER_ACTOR (child), - NULL, NULL, - &natural_width, &natural_height); - - if (priv->column_major) - { - ClutterUnit temp = natural_height; - natural_height = natural_width; - natural_width = temp; - } - - /* if the primary axis is homogenous, each additional item is the same - * width */ - if (homogenous_a) - natural_width = priv->max_extent_a; - - if (natural_height > best_yet) - best_yet = natural_height; - - /* if the child is overflowing, we wrap to next line */ - if (current_a + natural_width + gap > priv->a_wrap) - { - return best_yet; - } - current_a += natural_width + gap; - } - return best_yet; -} - - - - -static ClutterUnit -compute_row_start (GList *siblings, - ClutterUnit start_x, - TidyGridPrivate *priv) -{ - ClutterUnit current_a = start_x; - GList *l; - - gboolean homogenous_a; - gboolean homogenous_b; - ClutterUnit gap; - - if (priv->column_major) - { - homogenous_b = priv->homogenous_columns; - homogenous_a = priv->homogenous_rows; - gap = priv->row_gap; - } - else - { - homogenous_a = priv->homogenous_columns; - homogenous_b = priv->homogenous_rows; - gap = priv->column_gap; - } - - for (l = siblings; l != NULL; l = l->next) - { - ClutterActor *child = l->data; - ClutterUnit natural_width, natural_height; - - /* each child will get as much space as they require */ - clutter_actor_get_preferred_size (CLUTTER_ACTOR (child), - NULL, NULL, - &natural_width, &natural_height); - - - if (priv->column_major) - natural_width = natural_height; - - /* if the primary axis is homogenous, each additional item is the same width */ - if (homogenous_a) - natural_width = priv->max_extent_a; - - /* if the child is overflowing, we wrap to next line */ - if (current_a + natural_width + gap > priv->a_wrap) - { - if (current_a == start_x) - return start_x; - return (priv->a_wrap - current_a); - } - current_a += natural_width + gap; - } - return (priv->a_wrap - current_a); -} - -static void -tidy_grid_allocate (ClutterActor *self, - const ClutterActorBox *box, - gboolean absolute_origin_changed) -{ - TidyGrid *layout = (TidyGrid *) self; - TidyGridPrivate *priv = layout->priv; - - ClutterUnit current_a; - ClutterUnit current_b; - ClutterUnit next_b; - ClutterUnit agap; - ClutterUnit bgap; - - gboolean homogenous_a; - gboolean homogenous_b; - gdouble aalign; - gdouble balign; - - current_a = current_b = next_b = 0; - - GList *iter; - - /* chain up to set actor->allocation */ - CLUTTER_ACTOR_CLASS (tidy_grid_parent_class) - ->allocate (self, box, absolute_origin_changed); - - priv->alloc_width = box->x2 - box->x1; - priv->alloc_height = box->y2 - box->y1; - priv->absolute_origin_changed = absolute_origin_changed; - - /* Make sure we have calculated the preferred size */ - /* what does this do? */ - clutter_actor_get_preferred_size (self, NULL, NULL, NULL, NULL); - - - if (priv->column_major) - { - priv->a_wrap = priv->alloc_height; - homogenous_b = priv->homogenous_columns; - homogenous_a = priv->homogenous_rows; - aalign = priv->valign; - balign = priv->halign; - agap = priv->row_gap; - bgap = priv->column_gap; - } - else - { - priv->a_wrap = priv->alloc_width; - homogenous_a = priv->homogenous_columns; - homogenous_b = priv->homogenous_rows; - aalign = priv->halign; - balign = priv->valign; - agap = priv->column_gap; - bgap = priv->row_gap; - } - - priv->max_extent_a = 0; - priv->max_extent_b = 0; - - priv->first_of_batch = TRUE; - - if (homogenous_a || - homogenous_b) - { - for (iter = priv->list; iter; iter = iter->next) - { - ClutterActor *child = iter->data; - ClutterUnit natural_width; - ClutterUnit natural_height; - - /* each child will get as much space as they require */ - clutter_actor_get_preferred_size (CLUTTER_ACTOR (child), - NULL, NULL, - &natural_width, &natural_height); - if (natural_width > priv->max_extent_a) - priv->max_extent_a = natural_width; - if (natural_height > priv->max_extent_b) - priv->max_extent_b = natural_width; - } - } - - if (priv->column_major) - { - ClutterUnit temp = priv->max_extent_a; - priv->max_extent_a = priv->max_extent_b; - priv->max_extent_b = temp; - } - - for (iter = priv->list; iter; iter=iter->next) - { - ClutterActor *child = iter->data; - ClutterUnit natural_a; - ClutterUnit natural_b; - - /* each child will get as much space as they require */ - clutter_actor_get_preferred_size (CLUTTER_ACTOR (child), - NULL, NULL, - &natural_a, &natural_b); - - if (priv->column_major) /* swap axes around if column is major */ - { - ClutterUnit temp = natural_a; - natural_a = natural_b; - natural_b = temp; - } - - /* if the child is overflowing, we wrap to next line */ - if (current_a + natural_a > priv->a_wrap || - (homogenous_a && current_a + priv->max_extent_a > priv->a_wrap)) - { - current_b = next_b + bgap; - current_a = 0; - next_b = current_b + bgap; - priv->first_of_batch = TRUE; - } - - if (priv->end_align && - priv->first_of_batch) - { - current_a = compute_row_start (iter, current_a, priv); - priv->first_of_batch = FALSE; - } - - if (next_b-current_b < natural_b) - next_b = current_b + natural_b; - - { - ClutterUnit row_height; - ClutterActorBox child_box; - - if (homogenous_b) - { - row_height = priv->max_extent_b; - } - else - { - row_height = compute_row_height (iter, next_b-current_b, - current_a, priv); - } - - if (homogenous_a) - { - child_box.x1 = current_a + (priv->max_extent_a-natural_a) * aalign; - child_box.x2 = child_box.x1 + natural_a; - - } - else - { - child_box.x1 = current_a; - child_box.x2 = child_box.x1 + natural_a; - } - - child_box.y1 = current_b + (row_height-natural_b) * balign; - child_box.y2 = child_box.y1 + natural_b; - - - if (priv->column_major) - { - ClutterUnit temp = child_box.x1; - child_box.x1 = child_box.y1; - child_box.y1 = temp; - - temp = child_box.x2; - child_box.x2 = child_box.y2; - child_box.y2 = temp; - } - - /* update the allocation */ - clutter_actor_allocate (CLUTTER_ACTOR (child), - &child_box, - absolute_origin_changed); - - if (homogenous_a) - { - current_a += priv->max_extent_a + agap; - } - else - { - current_a += natural_a + agap; - } - } - } -} diff --git a/src/compositor/mutter/tidy/tidy-grid.h b/src/compositor/mutter/tidy/tidy-grid.h deleted file mode 100644 index 374baeba2..000000000 --- a/src/compositor/mutter/tidy/tidy-grid.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Clutter. - * - * An OpenGL based 'interactive canvas' library. - * - * Authored By Matthew Allum - * - * Copyright (C) 2008 OpenedHand - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __TIDY_GRID_H__ -#define __TIDY_GRID_H__ - -#include - -G_BEGIN_DECLS - -#define TIDY_TYPE_GRID (tidy_grid_get_type()) -#define TIDY_GRID(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - TIDY_TYPE_GRID, \ - TidyGrid)) -#define TIDY_GRID_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - TIDY_TYPE_GRID, \ - TidyGridClass)) -#define TIDY_IS_GRID(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - TIDY_TYPE_GRID)) -#define TIDY_IS_GRID_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - TIDY_TYPE_GRID)) -#define TIDY_GRID_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - TIDY_TYPE_GRID, \ - TidyGridClass)) - -typedef struct _TidyGrid TidyGrid; -typedef struct _TidyGridClass TidyGridClass; -typedef struct _TidyGridPrivate TidyGridPrivate; - -struct _TidyGridClass -{ - ClutterActorClass parent_class; -}; - -struct _TidyGrid -{ - ClutterActor parent; - - TidyGridPrivate *priv; -}; - -GType tidy_grid_get_type (void) G_GNUC_CONST; - -ClutterActor *tidy_grid_new (void); -void tidy_grid_set_end_align (TidyGrid *self, - gboolean value); -gboolean tidy_grid_get_end_align (TidyGrid *self); -void tidy_grid_set_homogenous_rows (TidyGrid *self, - gboolean value); -gboolean tidy_grid_get_homogenous_rows (TidyGrid *self); -void tidy_grid_set_homogenous_columns (TidyGrid *self, - gboolean value); -gboolean tidy_grid_get_homogenous_columns (TidyGrid *self); -void tidy_grid_set_column_major (TidyGrid *self, - gboolean value); -gboolean tidy_grid_get_column_major (TidyGrid *self); -void tidy_grid_set_row_gap (TidyGrid *self, - ClutterUnit value); -ClutterUnit tidy_grid_get_row_gap (TidyGrid *self); -void tidy_grid_set_column_gap (TidyGrid *self, - ClutterUnit value); -ClutterUnit tidy_grid_get_column_gap (TidyGrid *self); -void tidy_grid_set_valign (TidyGrid *self, - gdouble value); -gdouble tidy_grid_get_valign (TidyGrid *self); -void tidy_grid_set_halign (TidyGrid *self, - gdouble value); -gdouble tidy_grid_get_halign (TidyGrid *self); - -G_END_DECLS - -#endif /* __TIDY_GRID_H__ */