コード例 #1
0
ファイル: na-tray-child.c プロジェクト: gfunkmonk2/mate-panel
static void
na_tray_child_realize (GtkWidget *widget)
{
  NaTrayChild *child = NA_TRAY_CHILD (widget);
  GdkVisual *visual = gtk_widget_get_visual (widget);
  GdkWindow *window;

  GTK_WIDGET_CLASS (na_tray_child_parent_class)->realize (widget);

  window = gtk_widget_get_window (widget);

  if (child->has_alpha)
    {
      /* We have real transparency with an ARGB visual and the Composite
       * extension. */

      /* Set a transparent background */
      GdkColor transparent = { 0, 0, 0, 0 }; /* only pixel=0 matters */
      gdk_window_set_background (window, &transparent);
      gdk_window_set_composited (window, TRUE);

      child->parent_relative_bg = FALSE;
	}
	#if GTK_CHECK_VERSION(3, 0, 0)
		else if (visual == gdk_window_get_visual(gdk_window_get_parent(window)))
	#else
		else if (visual == gdk_drawable_get_visual(GDK_DRAWABLE(gdk_window_get_parent(window))))
	#endif
	{
      /* Otherwise, if the visual matches the visual of the parent window, we
       * can use a parent-relative background and fake transparency. */
      gdk_window_set_back_pixmap (window, NULL, TRUE);

      child->parent_relative_bg = TRUE;
    }
  else
    {
      /* Nothing to do; the icon will sit on top of an ugly gray box */
      child->parent_relative_bg = FALSE;
    }

  gdk_window_set_composited (window, child->composited);

  gtk_widget_set_app_paintable (GTK_WIDGET (child),
                                child->parent_relative_bg || child->has_alpha);

  /* Double-buffering will interfere with the parent-relative-background fake
   * transparency, since the double-buffer code doesn't know how to fill in the
   * background of the double-buffer correctly.
   */
  gtk_widget_set_double_buffered (GTK_WIDGET (child),
                                  child->parent_relative_bg);
}
コード例 #2
0
ファイル: na-tray-child.c プロジェクト: SESDE/SESDE
static void
na_tray_child_realize (GtkWidget *widget)
{
  NaTrayChild *child = NA_TRAY_CHILD (widget);
  GdkVisual *visual = gtk_widget_get_visual (widget);
  GdkWindow *window;

  GTK_WIDGET_CLASS (na_tray_child_parent_class)->realize (widget);

  window = gtk_widget_get_window (widget);

  if (child->has_alpha)
    {
      /* We have real transparency with an ARGB visual and the Composite
       * extension. */

      /* Set a transparent background */
      cairo_pattern_t *transparent = cairo_pattern_create_rgba (0, 0, 0, 0);
      gdk_window_set_background_pattern (window, transparent);
      gdk_window_set_composited (window, TRUE);
      cairo_pattern_destroy (transparent);

      child->parent_relative_bg = FALSE;
    }
  else if (visual == gdk_window_get_visual (gdk_window_get_parent (window)))
    {
      /* Otherwise, if the visual matches the visual of the parent window, we
       * can use a parent-relative background and fake transparency. */
      gdk_window_set_background_pattern (window, NULL);

      child->parent_relative_bg = TRUE;
    }
  else
    {
      /* Nothing to do; the icon will sit on top of an ugly gray box */
      child->parent_relative_bg = FALSE;
    }

  gdk_window_set_composited (window, child->composited);

  gtk_widget_set_app_paintable (GTK_WIDGET (child),
                                child->parent_relative_bg || child->has_alpha);

  /* Double-buffering will interfere with the parent-relative-background fake
   * transparency, since the double-buffer code doesn't know how to fill in the
   * background of the double-buffer correctly.
   */
  gtk_widget_set_double_buffered (GTK_WIDGET (child),
                                  child->parent_relative_bg);
}
コード例 #3
0
ファイル: tray.c プロジェクト: electricface/dde
void tray_icon_added (NaTrayManager *manager, Window child, GtkWidget* container)
{
    GdkWindow* wrapper = create_wrapper(gtk_widget_get_window(container), child);
    if (wrapper == NULL)
        return;
    GdkWindow* icon = get_icon_window(wrapper);
    g_assert(icon != NULL);

    gdk_window_reparent(wrapper, gtk_widget_get_window(container), 0, gdk_screen_height() - DOCK_HEIGHT);
    //add this mask so, gdk can handle GDK_SELECTION_CLEAR event to destroy this gdkwindow.
    gdk_window_set_events(icon, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_VISIBILITY_NOTIFY_MASK);
    gdk_window_add_filter(icon, (GdkFilterFunc)monitor_icon_event, wrapper);
    gdk_window_set_composited(wrapper, TRUE);

    gdk_window_show(wrapper);

    char *re_class = NULL;
    get_wmclass(icon, &re_class, NULL);
    if (g_strcmp0(re_class, DEEPIN_TRAY_ICON) == 0) {
        _deepin_tray = wrapper;
        _deepin_tray_width = CLAMP_WIDTH(gdk_window_get_width(icon));
        _update_deepin_try_position();
    } else if (g_strcmp0(re_class, FCITX_TRAY_ICON) == 0) {
        _fcitx_tray = wrapper;
        _fcitx_tray_width = CLAMP_WIDTH(gdk_window_get_width(icon));
        _update_fcitx_try_position();

    } else {
        int width = gdk_window_get_width(icon) * 1.0 / gdk_window_get_height(icon) * DEFAULT_HEIGHT;
        gdk_window_resize(icon, width, DEFAULT_HEIGHT);
        g_hash_table_insert(_icons, wrapper, GINT_TO_POINTER(CLAMP_WIDTH(width)));
    }
    g_free(re_class);
    _update_notify_area_width();
}
コード例 #4
0
ファイル: na-tray-child.c プロジェクト: RainCT/gnome-shell
/**
 * na_tray_child_set_composited;
 * @child: a #NaTrayChild
 * @composited: %TRUE if the child's window should be redirected
 *
 * Sets whether the #GdkWindow of the child should be set redirected
 * using gdk_window_set_composited(). By default this is based off of
 * na_tray_child_has_alpha(), but it may be useful to override it in
 * certain circumstances; for example, if the #NaTrayChild is added
 * to a parent window and that parent window is composited against the
 * background.
 */
void
na_tray_child_set_composited (NaTrayChild *child,
			      gboolean     composited)
{
  g_return_if_fail (NA_IS_TRAY_CHILD (child));

  child->composited = composited;
  if (GTK_WIDGET_REALIZED (child))
    gdk_window_set_composited (GTK_WIDGET (child)->window, composited);
}
コード例 #5
0
ファイル: na-tray-child.c プロジェクト: SESDE/SESDE
/**
 * na_tray_child_set_composited;
 * @child: a #NaTrayChild
 * @composited: %TRUE if the child's window should be redirected
 *
 * Sets whether the #GdkWindow of the child should be set redirected
 * using gdk_window_set_composited(). By default this is based off of
 * na_tray_child_has_alpha(), but it may be useful to override it in
 * certain circumstances; for example, if the #NaTrayChild is added
 * to a parent window and that parent window is composited against the
 * background.
 */
void
na_tray_child_set_composited (NaTrayChild *child,
                              gboolean     composited)
{
  g_return_if_fail (NA_IS_TRAY_CHILD (child));

  if (child->composited == composited)
    return;

  child->composited = composited;
  if (gtk_widget_get_realized (GTK_WIDGET (child)))
    gdk_window_set_composited (gtk_widget_get_window (GTK_WIDGET (child)),
                               composited);
}
コード例 #6
0
BackgroundInfo* create_background_info(GtkWidget* container, GtkWidget* child)
{
    g_message("[%s]\n", __func__);
    BackgroundInfo* info = g_new0(BackgroundInfo, 1);
    g_mutex_init(&info->m);
    info->alpha = 1;
    info->container = container;

    if (child != NULL) {
        gtk_widget_realize (child);
        gdk_window_set_composited(gtk_widget_get_window(child), TRUE);
    }
    g_signal_connect(container, "draw",
                     G_CALLBACK(background_info_draw_callback), info);
    gtk_widget_realize (container);
    GdkRGBA color = {0,0,0,0};
    gdk_window_set_background_rgba(gtk_widget_get_window(container), &color);

    return info;
}
コード例 #7
0
ファイル: rbgdkwindow.c プロジェクト: geoffyoungs/ruby-gnome2
static VALUE
gdkwin_set_composited(VALUE self, VALUE composited)
{
    gdk_window_set_composited(_SELF(self), RVAL2CBOOL(composited));
    return self;
}