Пример #1
0
static void
on_switch_workspace_effect_complete (ClutterTimeline *timeline, gpointer data)
{
  MetaPlugin               *plugin  = META_PLUGIN (data);
  MetaDefaultPluginPrivate *priv = META_DEFAULT_PLUGIN (plugin)->priv;
  MetaScreen *screen = meta_plugin_get_screen (plugin);
  GList *l = meta_get_window_actors (screen);

  while (l)
    {
      ClutterActor *a = l->data;
      MetaWindowActor *window_actor = META_WINDOW_ACTOR (a);
      ActorPrivate *apriv = get_actor_private (window_actor);

      if (apriv->orig_parent)
        {
          clutter_actor_reparent (a, apriv->orig_parent);
          apriv->orig_parent = NULL;
        }

      l = l->next;
    }

  clutter_actor_destroy (priv->desktop1);
  clutter_actor_destroy (priv->desktop2);

  priv->tml_switch_workspace1 = NULL;
  priv->tml_switch_workspace2 = NULL;
  priv->desktop1 = NULL;
  priv->desktop2 = NULL;

  meta_plugin_switch_workspace_completed (plugin);
}
Пример #2
0
static void
meta_default_plugin_dispose (GObject *object)
{
  MetaDefaultPluginPrivate *priv = META_DEFAULT_PLUGIN (object)->priv;
  g_object_unref(priv->settings);
  G_OBJECT_CLASS (meta_default_plugin_parent_class)->dispose (object);
}
Пример #3
0
static const MetaPluginInfo *
plugin_info (MetaPlugin *plugin)
{
  MetaDefaultPluginPrivate *priv = META_DEFAULT_PLUGIN (plugin)->priv;

  return &priv->info;
}
Пример #4
0
static void
kill_switch_workspace (MetaPlugin     *plugin)
{
  MetaDefaultPluginPrivate *priv = META_DEFAULT_PLUGIN (plugin)->priv;

  if (priv->tml_switch_workspace1)
    {
      clutter_timeline_stop (priv->tml_switch_workspace1);
      clutter_timeline_stop (priv->tml_switch_workspace2);
      g_signal_emit_by_name (priv->tml_switch_workspace1, "completed", NULL);
    }
}
Пример #5
0
static void
start (MetaPlugin *plugin)
{
  MetaDefaultPlugin *self = META_DEFAULT_PLUGIN (plugin);
  MetaScreen *screen = meta_plugin_get_screen (plugin);

  self->priv->background_group = meta_background_group_new ();
  clutter_actor_insert_child_below (meta_get_window_group_for_screen (screen),
                                    self->priv->background_group, NULL);

  g_signal_connect (screen, "monitors-changed",
                    G_CALLBACK (on_monitors_changed), plugin);
  on_monitors_changed (screen, plugin);

  clutter_actor_show (meta_get_stage_for_screen (screen));
}
Пример #6
0
static void
on_monitors_changed (MetaScreen *screen,
                     MetaPlugin *plugin)
{
  MetaDefaultPlugin *self = META_DEFAULT_PLUGIN (plugin);
  int i, n;
  GRand *rand = g_rand_new_with_seed (123456);

  clutter_actor_destroy_all_children (self->priv->background_group);

  n = meta_screen_get_n_monitors (screen);
  for (i = 0; i < n; i++)
    {
      MetaRectangle rect;
      ClutterActor *background_actor;
      MetaBackground *background;
      ClutterColor color;

      meta_screen_get_monitor_geometry (screen, i, &rect);

      background_actor = meta_background_actor_new (screen, i);

      clutter_actor_set_position (background_actor, rect.x, rect.y);
      clutter_actor_set_size (background_actor, rect.width, rect.height);

      /* Don't use rand() here, mesa calls srand() internally when
         parsing the driconf XML, but it's nice if the colors are
         reproducible.
      */
      clutter_color_init (&color,
                          g_rand_int_range (rand, 0, 255),
                          g_rand_int_range (rand, 0, 255),
                          g_rand_int_range (rand, 0, 255),
                          255);

      background = meta_background_new (screen);
      meta_background_set_color (background, &color);
      meta_background_actor_set_background (META_BACKGROUND_ACTOR (background_actor), background);
      g_object_unref (background);

      clutter_actor_add_child (self->priv->background_group, background_actor);
    }

  g_rand_free (rand);
}
Пример #7
0
static void
switch_workspace (MetaPlugin *plugin,
                  gint from, gint to,
                  MetaMotionDirection direction)
{
  MetaScreen *screen;
  MetaDefaultPluginPrivate *priv = META_DEFAULT_PLUGIN (plugin)->priv;
  GList        *l;
  ClutterActor *workspace0  = clutter_group_new ();
  ClutterActor *workspace1  = clutter_group_new ();
  ClutterActor *stage;
  int           screen_width, screen_height;
  ClutterAnimation *animation;

  screen = meta_plugin_get_screen (plugin);
  stage = meta_get_stage_for_screen (screen);

  meta_screen_get_size (screen,
                        &screen_width,
                        &screen_height);

  clutter_actor_set_anchor_point (workspace1,
                                  screen_width,
                                  screen_height);
  clutter_actor_set_position (workspace1,
                              screen_width,
                              screen_height);

  clutter_actor_set_scale (workspace1, 0.0, 0.0);

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), workspace1);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), workspace0);

  if (from == to)
    {
      meta_plugin_switch_workspace_completed (plugin);
      return;
    }

  l = g_list_last (meta_get_window_actors (screen));

  while (l)
    {
      MetaWindowActor *window_actor = l->data;
      MetaWindow *window = meta_window_actor_get_meta_window (window_actor);
      MetaWorkspace   *workspace;
      ActorPrivate    *apriv	    = get_actor_private (window_actor);
      ClutterActor    *actor	    = CLUTTER_ACTOR (window_actor);
      gint             win_workspace;

      workspace = meta_window_get_workspace (window);
      win_workspace = meta_workspace_index (workspace);

      if (win_workspace == to || win_workspace == from)
        {
          apriv->orig_parent = clutter_actor_get_parent (actor);

          clutter_actor_reparent (actor,
				  win_workspace == to ? workspace1 : workspace0);
          clutter_actor_show_all (actor);
          clutter_actor_raise_top (actor);
        }
      else if (win_workspace < 0)
        {
          /* Sticky window */
          apriv->orig_parent = NULL;
        }
      else
        {
          /* Window on some other desktop */
          clutter_actor_hide (actor);
          apriv->orig_parent = NULL;
        }

      l = l->prev;
    }

  priv->desktop1 = workspace0;
  priv->desktop2 = workspace1;

  animation = clutter_actor_animate (workspace0, CLUTTER_EASE_IN_SINE,
                                     SWITCH_TIMEOUT,
                                     "scale-x", 1.0,
                                     "scale-y", 1.0,
                                     NULL);
  priv->tml_switch_workspace1 = clutter_animation_get_timeline (animation);
  g_signal_connect (priv->tml_switch_workspace1,
                    "completed",
                    G_CALLBACK (on_switch_workspace_effect_complete),
                    plugin);

  animation = clutter_actor_animate (workspace1, CLUTTER_EASE_IN_SINE,
                                     SWITCH_TIMEOUT,
                                     "scale-x", 0.0,
                                     "scale-y", 0.0,
                                     NULL);
  priv->tml_switch_workspace2 = clutter_animation_get_timeline (animation);
}
Пример #8
0
static void
on_monitors_changed (MetaScreen *screen,
                     MetaPlugin *plugin)
{
  MetaDefaultPlugin *self = META_DEFAULT_PLUGIN (plugin);
  __attribute__ ((unused)) ClutterAnimation *animation;
  int i, n;
  gchar *wallpaper = NULL;
  GFile *wallpaper_file = NULL;
  gchar *filename = NULL;
  GDesktopBackgroundStyle style;
  GDesktopBackgroundShading  shading_direction;
  ClutterColor primary_color;
  ClutterColor secondary_color;
  gboolean random_colour = FALSE;

  clutter_actor_destroy_all_children (self->priv->background_group);

  wallpaper = g_settings_get_string (self->priv->settings, PICTURE_URI_KEY);
  /* We don't currently support slideshows */
  if (!wallpaper || g_str_has_suffix(wallpaper, ".xml"))
    random_colour = TRUE;
  else {
    gchar *color_str;

    /* Shading direction*/
    shading_direction = g_settings_get_enum (self->priv->settings, COLOR_SHADING_TYPE_KEY);

    /* Primary color */
    color_str = g_settings_get_string (self->priv->settings, PRIMARY_COLOR_KEY);
    if (color_str)
    {
      clutter_color_from_string (&primary_color, color_str);
      g_free (color_str);
      color_str = NULL;
    }
      
    /* Secondary color */
    color_str = g_settings_get_string (self->priv->settings, SECONDARY_COLOR_KEY);
    if (color_str)
    {
      clutter_color_from_string (&secondary_color, color_str);
      g_free (color_str);
      color_str = NULL;
    }

    /* Picture options: "none", "wallpaper", "centered", "scaled", "stretched", "zoom", "spanned" */
    style = g_settings_get_enum (self->priv->settings, BACKGROUND_STYLE_KEY);

    wallpaper_file = g_file_new_for_uri(wallpaper);
    filename = g_file_get_path(wallpaper_file);
  }

  n = meta_screen_get_n_monitors (screen);

  for (i = 0; i < n; i++)
    {
      MetaBackground *content;
      MetaRectangle rect;
      ClutterActor *background;

      background = meta_background_actor_new ();

      content = meta_background_new (screen, 
                                     i, 
                                     META_BACKGROUND_EFFECTS_NONE);
      // Don't use rand() here, mesa calls srand() internally when
      // parsing the driconf XML, but it's nice if the colors are
      // reproducible.
      if (random_colour)
      {
        clutter_color_init (&primary_color,
          g_random_int () % 255,
          g_random_int () % 255,
          g_random_int () % 255,
          255);

        meta_background_load_color (content, &primary_color);
      } else {
        if (style == G_DESKTOP_BACKGROUND_STYLE_NONE ||
            g_str_has_suffix (filename, GNOME_COLOR_HACK))
        {
          if (shading_direction == G_DESKTOP_BACKGROUND_SHADING_SOLID)
            meta_background_load_color (content, &primary_color);
          else
            meta_background_load_gradient (content,
                                           shading_direction,
                                           &primary_color,
                                           &secondary_color);
        } else {
          /* Set the background */
          meta_background_load_file_async (content,
                                           filename,
                                           style,
                                           NULL, /*TODO use cancellable*/
                                           background_load_file_cb,
                                           self);
        }
      }

      clutter_actor_set_content (background, CLUTTER_CONTENT (content));
      g_object_unref (content);

      meta_screen_get_monitor_geometry (screen, i, &rect);

      clutter_actor_set_position (background, rect.x, rect.y);
      clutter_actor_set_size (background, rect.width, rect.height);
      clutter_actor_add_child (self->priv->background_group, background);
      clutter_actor_set_scale (background, 0.0, 0.0);
      clutter_actor_show (background);
      clutter_actor_set_pivot_point (background, 0.5, 0.5);

      /* Ease in the background using a scale effect */
      animation = clutter_actor_animate (background, CLUTTER_EASE_IN_SINE,
                                         BACKGROUND_TIMEOUT,
                                         "scale-x", 1.0,
                                         "scale-y", 1.0,
                                         NULL);
    }
    if (wallpaper_file)
      g_object_unref(wallpaper_file);
    g_free(wallpaper);
    g_free(filename);
}
Пример #9
0
static void
on_monitors_changed (MetaScreen *screen,
                     MetaPlugin *plugin)
{
  MetaDefaultPlugin *self = META_DEFAULT_PLUGIN (plugin);
  __attribute__ ((unused)) ClutterAnimation *animation;
  int i, n;
  gchar *wallpaper = NULL;
  GFile *wallpaper_file = NULL;
  gchar *filename = NULL;
  gboolean random_colour = FALSE;

  clutter_actor_destroy_all_children (self->priv->background_group);

  wallpaper = g_settings_get_string(self->priv->settings, PICTURE_KEY);
  if (!wallpaper)
      random_colour = TRUE;
  else {
      wallpaper_file = g_file_new_for_uri(wallpaper);
      filename = g_file_get_path(wallpaper_file);
  }
      

  n = meta_screen_get_n_monitors (screen);
  for (i = 0; i < n; i++)
    {
      MetaRectangle rect;
      ClutterActor *background;
      ClutterColor color;

      meta_screen_get_monitor_geometry (screen, i, &rect);

      /* Don't use rand() here, mesa calls srand() internally when
         parsing the driconf XML, but it's nice if the colors are
         reproducible.
      */
      if (random_colour) {
            background = meta_background_actor_new ();
            clutter_color_init (&color,
                          g_random_int () % 255,
                          g_random_int () % 255,
                          g_random_int () % 255,
                          255);
            clutter_actor_set_background_color (background, &color);
      } else {
            /* Set the background */
            background = clutter_texture_new_from_file(filename, NULL);
      }

      clutter_actor_set_position (background, rect.x, rect.y);
      clutter_actor_set_size (background, rect.width, rect.height);
      clutter_actor_add_child (self->priv->background_group, background);
      clutter_actor_set_scale (background, 0.0, 0.0);
      clutter_actor_show (background);
      clutter_actor_move_anchor_point_from_gravity (background,
                                                    CLUTTER_GRAVITY_CENTER);
      /* Ease in the background using a scale effect */
      animation = clutter_actor_animate (background, CLUTTER_EASE_IN_SINE,
                                         BACKGROUND_TIMEOUT,
                                         "scale-x", 1.0,
                                         "scale-y", 1.0,
                                         NULL);
    }
    if (wallpaper_file)
      g_object_unref(wallpaper_file);
    g_free(wallpaper);
    g_free(filename);
}