Beispiel #1
0
/**
 * shell_global_get_primary_monitor:
 * @global: the #ShellGlobal
 *
 * Gets the bounding box of the primary monitor (the one that the
 * panel is on).
 *
 * Return value: the bounding box of the primary monitor
 */
GdkRectangle *
shell_global_get_primary_monitor (ShellGlobal  *global)
{
  GdkScreen *screen = gdk_screen_get_default ();
  GdkRectangle rect;
  gint i, primary = 0;
  gchar *output_name = NULL;
  gint num_monitors = gdk_screen_get_n_monitors (screen);

  for (i = 0; i < num_monitors; i++)
    {
      /* Prefer the laptop's internal screen if present */
      output_name = gdk_screen_get_monitor_plug_name (screen, i);
      if (output_name)
        {
          gboolean is_lvds = g_ascii_strncasecmp (output_name, "LVDS", 4) == 0;
          g_free (output_name);
          if (is_lvds)
            {
              primary = i;
              break;
            }
        }
    }

  gdk_screen_get_monitor_geometry (screen, primary, &rect);

  return g_boxed_copy (GDK_TYPE_RECTANGLE, &rect);
}
const std::string UScreen::GetMonitorName(int output_number = 0) const
{
  if (output_number < 0 || output_number >= gdk_screen_get_n_monitors(screen_))
  {
    LOG_WARN(logger) << "UScreen::GetMonitorName: Invalid monitor number" << output_number;
    return "";
  }

  glib::String output_name(gdk_screen_get_monitor_plug_name(screen_, output_number));
  if (!output_name)
  {
    LOG_WARN(logger) << "UScreen::GetMonitorName: Failed to get monitor name for monitor" << output_number;
    return "";
  }

  return output_name.Str();
}
Beispiel #3
0
static void
xfce_workspace_change_backdrop(XfceWorkspace *workspace,
                               XfceBackdrop *backdrop,
                               const gchar *backdrop_file)
{
    XfconfChannel *channel = workspace->priv->channel;
    char buf[1024];
    gchar *monitor_name = NULL;
    guint i, monitor_num;

    g_return_if_fail(workspace->priv->nbackdrops > 0);

    TRACE("entering");

    /* Find out which monitor we're on */
    for(i = 0; i < workspace->priv->nbackdrops; ++i) {
        if(backdrop == workspace->priv->backdrops[i]) {
            monitor_num = i;
            break;
        }
    }

    monitor_name = gdk_screen_get_monitor_plug_name(workspace->priv->gscreen,
                                                    monitor_num);

    /* Get the backdrop's image property */
    if(monitor_name == NULL) {
        g_snprintf(buf, sizeof(buf), "%smonitor%d/workspace%d/last-image",
                   workspace->priv->property_prefix, monitor_num, workspace->priv->workspace_num);
    } else {
        g_snprintf(buf, sizeof(buf), "%smonitor%s/workspace%d/last-image",
                   workspace->priv->property_prefix, monitor_name, workspace->priv->workspace_num);

        g_free(monitor_name);
    }

    /* Update the property so that xfdesktop won't show the same image every
     * time it starts up when the user wants it to cycle different images */
    xfconf_channel_set_string(channel, buf, backdrop_file);
}
Beispiel #4
0
static void
xfce_workspace_connect_backdrop_settings(XfceWorkspace *workspace,
                                         XfceBackdrop *backdrop,
                                         guint monitor)
{
    XfconfChannel *channel = workspace->priv->channel;
    char buf[1024];
    gint pp_len;
    gchar *monitor_name = NULL;

    TRACE("entering");

    monitor_name = gdk_screen_get_monitor_plug_name(workspace->priv->gscreen, monitor);

    if(monitor_name == NULL) {
        g_snprintf(buf, sizeof(buf), "%smonitor%d/workspace%d/",
                   workspace->priv->property_prefix, monitor, workspace->priv->workspace_num);
    } else {
        g_snprintf(buf, sizeof(buf), "%smonitor%s/workspace%d/",
                   workspace->priv->property_prefix, monitor_name, workspace->priv->workspace_num);
    }
    pp_len = strlen(buf);

    DBG("prefix string: %s", buf);

    g_strlcat(buf, "color-style", sizeof(buf));
    xfconf_g_property_bind(channel, buf, XFCE_TYPE_BACKDROP_COLOR_STYLE,
                           G_OBJECT(backdrop), "color-style");

    buf[pp_len] = 0;
    g_strlcat(buf, "color1", sizeof(buf));
    workspace->priv->first_color_id[monitor] = xfconf_g_property_bind_gdkcolor(channel, buf,
                                                            G_OBJECT(backdrop), "first-color");

    buf[pp_len] = 0;
    g_strlcat(buf, "color2", sizeof(buf));
    workspace->priv->second_color_id[monitor] = xfconf_g_property_bind_gdkcolor(channel, buf,
                                                            G_OBJECT(backdrop), "second-color");

    buf[pp_len] = 0;
    g_strlcat(buf, "image-style", sizeof(buf));
    xfconf_g_property_bind(channel, buf, XFCE_TYPE_BACKDROP_IMAGE_STYLE,
                           G_OBJECT(backdrop), "image-style");

    buf[pp_len] = 0;
    g_strlcat(buf, "backdrop-cycle-enable", sizeof(buf));
    xfconf_g_property_bind(channel, buf, G_TYPE_BOOLEAN,
                           G_OBJECT(backdrop), "backdrop-cycle-enable");

    buf[pp_len] = 0;
    g_strlcat(buf, "backdrop-cycle-period", sizeof(buf));
    xfconf_g_property_bind(channel, buf, XFCE_TYPE_BACKDROP_CYCLE_PERIOD,
                           G_OBJECT(backdrop), "backdrop-cycle-period");

    buf[pp_len] = 0;
    g_strlcat(buf, "backdrop-cycle-timer", sizeof(buf));
    xfconf_g_property_bind(channel, buf, G_TYPE_UINT,
                           G_OBJECT(backdrop), "backdrop-cycle-timer");

    buf[pp_len] = 0;
    g_strlcat(buf, "backdrop-cycle-random-order", sizeof(buf));
    xfconf_g_property_bind(channel, buf, G_TYPE_BOOLEAN,
                           G_OBJECT(backdrop), "backdrop-cycle-random-order");

    buf[pp_len] = 0;
    g_strlcat(buf, "last-image", sizeof(buf));
    xfconf_g_property_bind(channel, buf, G_TYPE_STRING,
                           G_OBJECT(backdrop), "image-filename");

    /* If we didn't get a filename try to load one from a previous version */
    if(xfce_backdrop_get_image_filename(backdrop) == NULL)
        xfce_workspace_migrate_backdrop_image(workspace, backdrop, monitor);

    /* If we didn't get a proper color style, attempt to get the old one */
    if(xfce_backdrop_get_color_style(backdrop) == XFCE_BACKDROP_COLOR_INVALID)
        xfce_workspace_migrate_backdrop_color_style(workspace, backdrop, monitor);

    /* Same for image style, this also deals with 'Auto' */
    if(xfce_backdrop_get_image_style(backdrop) == XFCE_BACKDROP_IMAGE_INVALID)
        xfce_workspace_migrate_backdrop_image_style(workspace, backdrop, monitor);

    /* determine if the backdrop will be required to keep a ref of it's pixbuf
     * when it generates one */
    xfce_backdrop_set_cache_pixbuf(backdrop, workspace->priv->cache_pixbufs);

    g_free(monitor_name);
}