Exemplo n.º 1
0
static GdkColormap *
gdk_gl_config_setup_colormap (GdkScreen             *screen,
                              PIXELFORMATDESCRIPTOR *pfd,
                              gboolean               is_rgba)
{
  GDK_GL_NOTE_FUNC_PRIVATE ();

  if (is_rgba)
    {
      /*
       * For RGBA mode.
       */

      /* System default colormap. */

      GDK_GL_NOTE (MISC, g_message (" -- Colormap: system default"));

      return g_object_ref (G_OBJECT (gdk_screen_get_system_colormap (screen)));
    }
  else
    {
      /*
       * For color index mode.
       */

      /* New private colormap. */

      GDK_GL_NOTE (MISC, g_message (" -- Colormap: new allocated writable"));

      return gdk_colormap_new (gdk_screen_get_system_visual (screen), TRUE);
    }

  /* not reached */
  return NULL;
}
Exemplo n.º 2
0
static void
msd_osd_window_real_realize (GtkWidget *widget)
{
        GdkScreen *screen;
        GdkVisual *visual;
        cairo_region_t *region;

        screen = gtk_widget_get_screen (widget);
        visual = gdk_screen_get_rgba_visual (screen);

        if (visual == NULL) {
                visual = gdk_screen_get_system_visual (screen);
        }

        gtk_widget_set_visual (widget, visual);

        if (GTK_WIDGET_CLASS (msd_osd_window_parent_class)->realize) {
                GTK_WIDGET_CLASS (msd_osd_window_parent_class)->realize (widget);
        }

        /* make the whole window ignore events */
        region = cairo_region_create ();
        gtk_widget_input_shape_combine_region (widget, region);
        cairo_region_destroy (region);
}
Exemplo n.º 3
0
gboolean
xfwmPixmapRenderGdkPixbuf (xfwmPixmap * pm, GdkPixbuf *pixbuf)
{
    GdkPixbuf *src;
    GdkPixmap *destw;
    GdkVisual *gvisual;
    GdkColormap *cmap;
    gint width, height;
    gint dest_x, dest_y;

    g_return_val_if_fail (pm != NULL, FALSE);
    g_return_val_if_fail (pm->pixmap != None, FALSE);
    g_return_val_if_fail (pm->mask != None, FALSE);

    destw = gdk_xid_table_lookup (pm->pixmap);
    if (destw)
    {
        g_object_ref (G_OBJECT (destw));
    }
    else
    {
        destw = gdk_pixmap_foreign_new (pm->pixmap);
    }

    if (!destw)
    {
        g_warning ("Cannot get pixmap");
        return FALSE;
    }

    gvisual = gdk_screen_get_system_visual (pm->screen_info->gscr);
    cmap = gdk_x11_colormap_foreign_new (gvisual, pm->screen_info->cmap);

    if (!cmap)
    {
        g_warning ("Cannot create colormap");
        g_object_unref (destw);
        return FALSE;
    }

    width = MIN (gdk_pixbuf_get_width (pixbuf), pm->width);
    height = MIN (gdk_pixbuf_get_height (pixbuf), pm->height);

    /* Add 1 for rounding */
    dest_x = (pm->width - width + 1) / 2;
    dest_y = (pm->height - height + 1) / 2;

    src = gdk_pixbuf_get_from_drawable(NULL, GDK_DRAWABLE (destw), cmap,
                                       dest_x, dest_y, 0, 0, width, height);
    gdk_pixbuf_composite (pixbuf, src, 0, 0, width, height,
                          0, 0, 1.0, 1.0, GDK_INTERP_NEAREST, 0xFF);
    gdk_draw_pixbuf (GDK_DRAWABLE (destw), NULL, src, 0, 0, dest_x, dest_y,
                     width, height, GDK_RGB_DITHER_NONE, 0, 0);

    g_object_unref (cmap);
    g_object_unref (src);
    g_object_unref (destw);

    return TRUE;
}
static void
create_window (CsdLocatePointerData *data,
               GdkScreen            *screen)
{
  GdkVisual *visual;
  GdkWindowAttr attributes;
  gint attributes_mask;

  visual = gdk_screen_get_rgba_visual (screen);

  if (visual == NULL)
    visual = gdk_screen_get_system_visual (screen);

  attributes_mask = GDK_WA_X | GDK_WA_Y;

  if (visual != NULL)
    attributes_mask = attributes_mask | GDK_WA_VISUAL;

  attributes.window_type = GDK_WINDOW_TEMP;
  attributes.wclass = GDK_INPUT_OUTPUT;
  attributes.visual = visual;
  attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK;
  attributes.width = 1;
  attributes.height = 1;

  data->window = gdk_window_new (gdk_screen_get_root_window (screen),
                                 &attributes,
                                 attributes_mask);

  gdk_window_set_user_data (data->window, data->widget);
}
Exemplo n.º 5
0
decor_frame_t *
decor_frame_new (const gchar *type)
{
    GdkScreen     *gdkscreen = gdk_screen_get_default ();
    GdkVisual     *visual;
    decor_frame_t *frame = malloc (sizeof (decor_frame_t));

    if (!frame)
    {
        g_critical ("Couldn't allocate frame!");
        return NULL;
    }

    frame->type = strdup (type);
    frame->refcount = 0;
    frame->titlebar_height = 17;
    frame->max_titlebar_height = 17;
    frame->border_shadow_active = NULL;
    frame->border_shadow_inactive = NULL;
    frame->border_no_shadow = NULL;
    frame->max_border_no_shadow = NULL;
    frame->max_border_shadow_active = NULL;
    frame->max_border_shadow_inactive = NULL;
    frame->titlebar_font = NULL;

    frame->style_window_rgba = gtk_window_new (GTK_WINDOW_POPUP);

    visual = gdk_screen_get_rgba_visual (gdkscreen);
    if (visual)
        gtk_widget_set_visual (frame->style_window_rgba, visual);

    gtk_widget_realize (frame->style_window_rgba);

    gtk_widget_set_size_request (frame->style_window_rgba, 0, 0);
    gtk_window_move (GTK_WINDOW (frame->style_window_rgba), -100, -100);

    frame->pango_context = gtk_widget_create_pango_context (frame->style_window_rgba);

    g_signal_connect_data (frame->style_window_rgba, "style-updated",
                           G_CALLBACK (style_updated),
                           (gpointer) frame->pango_context, 0, 0);

    frame->style_window_rgb = gtk_window_new (GTK_WINDOW_POPUP);

    visual = gdk_screen_get_system_visual (gdkscreen);
    if (visual)
        gtk_widget_set_visual (frame->style_window_rgb, visual);

    gtk_widget_realize (frame->style_window_rgb);

    gtk_widget_set_size_request (frame->style_window_rgb, 0, 0);
    gtk_window_move (GTK_WINDOW (frame->style_window_rgb), -100, -100);

    g_signal_connect_data (frame->style_window_rgb, "style-updated",
                           G_CALLBACK (style_updated),
                           (gpointer) frame->pango_context, 0, 0);

    return frame;
}
Exemplo n.º 6
0
NS_IMETHODIMP 
nsScreenGtk :: GetPixelDepth(int32_t *aPixelDepth)
{
  GdkVisual * visual = gdk_screen_get_system_visual(gdk_screen_get_default());
  *aPixelDepth = gdk_visual_get_depth(visual);

  return NS_OK;

} // GetPixelDepth
Exemplo n.º 7
0
static inline int displayDepth()
{
#if PLATFORM(GTK)
    return gdk_visual_get_depth(gdk_screen_get_system_visual(gdk_screen_get_default()));
#elif PLATFORM(EFL) && defined(HAVE_ECORE_X)
    return ecore_x_default_depth_get(x11HostDisplay(), ecore_x_default_screen_get());
#else
    return 0;
#endif
}
Exemplo n.º 8
0
static inline int displayDepth()
{
#if PLATFORM(QT)
    return XDefaultDepth(NetscapePlugin::x11HostDisplay(), x11Screen());
#elif PLATFORM(GTK)
    return gdk_visual_get_depth(gdk_screen_get_system_visual(gdk_screen_get_default()));
#else
    return 0;
#endif
}
Exemplo n.º 9
0
/* This function queries the _XROOTPMAP_ID property from the root window
 * to determine the current root window background pixmap and returns a
 * surface to draw directly to it.
 * If _XROOTPMAP_ID is not set, then NULL returned.
 */
static cairo_surface_t *
get_root_pixmap_id_surface (GdkDisplay *display)
{
	GdkScreen       *screen;
	Display         *xdisplay;
	Visual          *xvisual;
	Window           xroot;
	Atom             type;
	int              format, result;
	unsigned long    nitems, bytes_after;
	unsigned char   *data;
	cairo_surface_t *surface = NULL;

	g_return_val_if_fail (display != NULL, NULL);

	screen   = gdk_display_get_default_screen (display);
	xdisplay = GDK_DISPLAY_XDISPLAY (display);
	xvisual  = GDK_VISUAL_XVISUAL (gdk_screen_get_system_visual (screen));
	xroot    = RootWindow (xdisplay, GDK_SCREEN_XNUMBER (screen));

	result = XGetWindowProperty (xdisplay, xroot,
				     gdk_x11_get_xatom_by_name ("_XROOTPMAP_ID"),
				     0L, 1L, False, XA_PIXMAP,
				     &type, &format, &nitems, &bytes_after,
				     &data);

	if (result != Success || type != XA_PIXMAP ||
	    format != 32 || nitems != 1) {
		XFree (data);
		data = NULL;
	}

	if (data != NULL) {
		Pixmap pixmap = *(Pixmap *) data;
		Window root_ret;
		int x_ret, y_ret;
		unsigned int w_ret, h_ret, bw_ret, depth_ret;

		gdk_x11_display_error_trap_push (display);
		if (XGetGeometry (xdisplay, pixmap, &root_ret,
		                  &x_ret, &y_ret, &w_ret, &h_ret,
		                  &bw_ret, &depth_ret))
		{
			surface = cairo_xlib_surface_create (xdisplay,
			                                     pixmap, xvisual,
			                                     w_ret, h_ret);
		}

		gdk_x11_display_error_trap_pop_ignored (display);
		XFree (data);
	}

	gdk_display_flush (display);
	return surface;
}
Exemplo n.º 10
0
/**
 * xfce_workspace_set_workspace_num:
 * @workspace: An #XfceWorkspace.
 * @GdkScreen: screen the workspace is on.
 *
 * Updates the backdrops to correctly display the right settings since GTK/GDK
 * uses monitor numbers rather than names.
 **/
void
xfce_workspace_monitors_changed(XfceWorkspace *workspace,
                                GdkScreen *gscreen)
{
    guint i;
    guint n_monitors;
    GdkVisual *vis = NULL;

    TRACE("entering");

    vis = gdk_screen_get_rgba_visual(gscreen);
    if(vis == NULL)
        vis = gdk_screen_get_system_visual(gscreen);

    if(workspace->priv->nbackdrops > 0 &&
       xfce_workspace_get_xinerama_stretch(workspace)) {
        /* When spanning screens we only need one backdrop */
        n_monitors = 1;
    } else {
        n_monitors = gdk_screen_get_n_monitors(gscreen);
    }

    /* Remove all backdrops so that the correct monitor is added/removed and
     * things stay in the correct order */
    xfce_workspace_remove_backdrops(workspace);

    /* Allocate space for the backdrops and their color properties so they
     * can correctly be removed */
    workspace->priv->backdrops = g_realloc(workspace->priv->backdrops,
                                           sizeof(XfceBackdrop *) * n_monitors);
    workspace->priv->first_color_id = g_realloc(workspace->priv->first_color_id,
                                                sizeof(gulong) * n_monitors);
    workspace->priv->second_color_id = g_realloc(workspace->priv->second_color_id,
                                                 sizeof(gulong) * n_monitors);

    for(i = 0; i < n_monitors; ++i) {
        DBG("Adding workspace %d backdrop %d", workspace->priv->workspace_num, i);

        workspace->priv->backdrops[i] = xfce_backdrop_new(vis);
        xfce_workspace_connect_backdrop_settings(workspace,
                                               workspace->priv->backdrops[i],
                                               i);
        g_signal_connect(G_OBJECT(workspace->priv->backdrops[i]),
                         "changed",
                         G_CALLBACK(backdrop_changed_cb), workspace);
        g_signal_connect(G_OBJECT(workspace->priv->backdrops[i]),
                         "cycle",
                         G_CALLBACK(backdrop_cycle_cb),
                         workspace);
        g_signal_connect(G_OBJECT(workspace->priv->backdrops[i]),
                         "ready",
                         G_CALLBACK(backdrop_changed_cb), workspace);
    }
    workspace->priv->nbackdrops = n_monitors;
}
Exemplo n.º 11
0
static void set_colormap(GtkWidget *window)
{
  /*Set RGBA visual*/
  GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (window));
  GdkVisual *visual = gdk_screen_get_rgba_visual (screen);

  if (visual == NULL)
    visual = gdk_screen_get_system_visual (screen);

  gtk_widget_set_visual (window, visual);
}
Exemplo n.º 12
0
static GdkVisual* getVisual(Widget* widget)
{
    GtkWidget* container = widget ? GTK_WIDGET(widget->root()->hostWindow()->platformPageClient()) : 0;
    if (!container) {
        GdkScreen* screen = gdk_screen_get_default();
        return screen ? gdk_screen_get_system_visual(screen) : 0;
    }

    if (!gtk_widget_get_realized(container))
        container = getToplevel(container);
    return container ? gdk_window_get_visual(gtk_widget_get_window(container)) : 0;
}
Exemplo n.º 13
0
void eric_window_screen_changed( GtkWidget *widget, GdkScreen *old_screen, gpointer userdata )
{
    GdkVisual *visual;
	
	GdkScreen* screen=gtk_widget_get_screen(widget);
	if(!screen) return;

	visual = gdk_screen_get_rgba_visual(screen);
	if(visual==NULL) visual=gdk_screen_get_system_visual(screen);

	gtk_widget_set_visual(widget,visual);
}
void
screen_changed_handler (GtkWidget* window,
			GdkScreen* old_screen,
			gpointer   data)
{                       
	GdkScreen* screen = gtk_widget_get_screen (GTK_WIDGET (window));
	GdkVisual* visual = gdk_screen_get_rgba_visual (screen);
      
	if (!visual)
		visual = gdk_screen_get_system_visual (screen);

	gtk_widget_set_visual (GTK_WIDGET (window), visual);
}
Exemplo n.º 15
0
static void
na_tray_manager_set_visual_property (NaTrayManager *manager)
{
#ifdef GDK_WINDOWING_X11
  GdkWindow  *window;
  GdkDisplay *display;
  Visual     *xvisual;
  Atom        visual_atom;
  gulong      data[1];

  g_return_if_fail (manager->invisible != NULL);
  window = gtk_widget_get_window (manager->invisible);
  g_return_if_fail (window != NULL);

  /* The visual property is a hint to the tray icons as to what visual they
   * should use for their windows. If the X server has RGBA colormaps, then
   * we tell the tray icons to use a RGBA colormap and we'll composite the
   * icon onto its parents with real transparency. Otherwise, we just tell
   * the icon to use our colormap, and we'll do some hacks with parent
   * relative backgrounds to simulate transparency.
   */

  display = gtk_widget_get_display (manager->invisible);
  visual_atom = gdk_x11_get_xatom_by_name_for_display (display,
						       "_NET_SYSTEM_TRAY_VISUAL");

  if (gdk_screen_get_rgba_visual (manager->screen) != NULL &&
      gdk_display_supports_composite (display))
    {
      xvisual = GDK_VISUAL_XVISUAL (gdk_screen_get_rgba_visual (manager->screen));
    }
  else
    {
      /* We actually want the visual of the tray where the icons will
       * be embedded. In almost all cases, this will be the same as the visual
       * of the screen.
       */
      xvisual = GDK_VISUAL_XVISUAL (gdk_screen_get_system_visual (manager->screen));
    }

  data[0] = XVisualIDFromVisual (xvisual);

  XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
                   GDK_WINDOW_XID (window),
                   visual_atom,
                   XA_VISUALID, 32,
                   PropModeReplace,
                   (guchar *) &data, 1);
#endif
}
Exemplo n.º 16
0
static cairo_surface_t *
create_root_surface (GdkScreen *screen)
{
    Atom prop_root, prop_esetroot;
    gint number, width, height;
    Display *display;
    Pixmap pixmap;
    cairo_surface_t *surface;

    number = gdk_screen_get_number (screen);
    width = gdk_screen_get_width (screen);
    height = gdk_screen_get_height (screen);

    /* Open a new connection so with Retain Permanent so the pixmap remains when the greeter quits */
    gdk_flush ();
    display = XOpenDisplay (gdk_display_get_name (gdk_screen_get_display (screen)));
    if (!display)
    {
        g_warning ("Failed to create root pixmap");
        return NULL;
    }
    XSetCloseDownMode (display, RetainPermanent);
    pixmap = XCreatePixmap (display, RootWindow (display, number), width, height, DefaultDepth (display, number));
    XCloseDisplay (display);

    /* Convert into a Cairo surface */
    surface = cairo_xlib_surface_create (GDK_SCREEN_XDISPLAY (screen),
                                         pixmap,
                                         GDK_VISUAL_XVISUAL (gdk_screen_get_system_visual (screen)),
                                         width, height);

    /* Use this pixmap for the background */
    XSetWindowBackgroundPixmap (GDK_SCREEN_XDISPLAY (screen),
                                RootWindow (GDK_SCREEN_XDISPLAY (screen), number),
                                cairo_xlib_surface_get_drawable (surface));



    /* Fix to make the code work when a compositor is running */
    Pixmap xpm = cairo_xlib_surface_get_drawable (surface);
    prop_root = XInternAtom(GDK_SCREEN_XDISPLAY (screen), "_XROOTPMAP_ID", False);
    prop_esetroot = XInternAtom(GDK_SCREEN_XDISPLAY (screen), "ESETROOT_PMAP_ID", False);

    XChangeProperty(GDK_SCREEN_XDISPLAY (screen), RootWindow (GDK_SCREEN_XDISPLAY (screen), number), prop_root, XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &xpm, 1);
    XChangeProperty(GDK_SCREEN_XDISPLAY (screen), RootWindow (GDK_SCREEN_XDISPLAY (screen), number), prop_esetroot, XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &xpm, 1);


    return surface;
}
Exemplo n.º 17
0
void
set_desktop_background(GdkWindow *window)
{
  Pixmap xpm = get_pixmap_prop(GDK_WINDOW_XWINDOW(window), "_XROOTPMAP_ID");

#ifdef HAVE_GTK3
  if (xpm != None)
    {
      GdkScreen *screen = gdk_window_get_screen(window);
      Window root_return;
      int x, y;
      unsigned int width, height, bw, depth_ret;
      cairo_surface_t *surface = NULL;

      gdk_error_trap_push();
      if (XGetGeometry(GDK_SCREEN_XDISPLAY(screen),
                       xpm,
                       &root_return,
                       &x, &y, &width, &height, &bw, &depth_ret))
        {
          surface = cairo_xlib_surface_create(GDK_SCREEN_XDISPLAY (screen),
                                              xpm,
                                              GDK_VISUAL_XVISUAL(gdk_screen_get_system_visual(screen)),
                                              width, height);
        }
      gdk_error_trap_pop_ignored ();

      cairo_pattern_t *pattern = cairo_pattern_create_for_surface(surface);
      gdk_window_set_background_pattern(window, pattern);

      cairo_surface_destroy(surface);
      // cairo_pattern_destroy      ???
    }
  else
    {
      GdkRGBA black = { 0.0, 0.0, 0.0, 1.0 };
      gdk_window_set_background_rgba(window, &black);
    }

#else
  if (xpm != None)
    {
      GDKPIXMAP *gpm = gdk_pixmap_foreign_new(xpm);
      gdk_window_set_back_pixmap (window, gpm, FALSE);
      g_object_unref (gpm);
    }
#endif
}
Exemplo n.º 18
0
void on_screen_changed(GtkWidget *widget,
		       GdkScreen *previous_screen,
		       gpointer   user_data)
{
  GromitData *data = (GromitData *) user_data;

  if(data->debug)
    g_printerr("DEBUG: got screen-changed event\n");

  GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET (widget));
  GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
  if (visual == NULL)
    visual = gdk_screen_get_system_visual (screen);

  gtk_widget_set_visual (widget, visual);
}
Exemplo n.º 19
0
void		ly_3lrc_desktop_create			()
{
	int lrc_desktop_visible=1;
	int lrc_desktop_fixed=0;
	if(!ly_reg_get("3lrc_desktop_state", "%d:%d", &lrc_desktop_visible, &lrc_desktop_fixed))
	{
		ly_reg_set("3lrc_desktop_state", "%d:%d", lrc_desktop_visible, lrc_desktop_fixed);
	}

	int w=1000;
	int h=50;
	int x=0;
	int y=0;
	ly_reg_get("3lrc_desktop_pos_and_size", "%d:%d:%d:%d", &x, &y, &w, &h);	
	ly_3lrc_desktop=gtk_window_new(GTK_WINDOW_POPUP);
	gtk_window_set_default_size(GTK_WINDOW(ly_3lrc_desktop),w,h);
	gtk_window_move(GTK_WINDOW(ly_3lrc_desktop),x,y);
	gtk_widget_set_app_paintable(ly_3lrc_desktop, TRUE);
	gtk_window_set_decorated(GTK_WINDOW(ly_3lrc_desktop), FALSE);
		
	GdkVisual *visual;
	GdkScreen *screen;
	screen = gtk_widget_get_screen(ly_3lrc_desktop);	
	visual = gdk_screen_get_rgba_visual (screen);
	if (visual == NULL)
		visual = gdk_screen_get_system_visual (screen);
	gtk_widget_set_visual (GTK_WIDGET (ly_3lrc_desktop), visual);

	gtk_widget_set_events(ly_3lrc_desktop,GDK_ALL_EVENTS_MASK);
		
	if(lrc_desktop_visible<=0)
		gtk_widget_hide(ly_3lrc_desktop);
	if(lrc_desktop_fixed>0)
		gtk_widget_set_sensitive(ly_3lrc_desktop,FALSE);
			
	gtk_widget_show_all(ly_3lrc_desktop);
	g_signal_connect(G_OBJECT(ly_3lrc_desktop), "draw", G_CALLBACK(ly_3lrc_desktop_on_expose_cb), NULL);
	g_signal_connect(G_OBJECT(ly_3lrc_desktop), "button_press_event", G_CALLBACK(ly_3lrc_desktop_on_drag_cb), NULL);
	g_signal_connect(G_OBJECT(ly_3lrc_desktop), "button_release_event", G_CALLBACK(ly_3lrc_desktop_on_drag_cb), NULL);
	g_signal_connect(G_OBJECT(ly_3lrc_desktop), "motion_notify_event", G_CALLBACK(ly_3lrc_desktop_on_drag_cb), NULL);
	g_signal_connect(G_OBJECT(ly_3lrc_desktop), "enter_notify_event", G_CALLBACK(ly_3lrc_desktop_on_drag_cb), NULL);
	g_signal_connect(G_OBJECT(ly_3lrc_desktop), "leave_notify_event", G_CALLBACK(ly_3lrc_desktop_on_drag_cb), NULL);

	ly_3lrc_desktop_timeout=g_timeout_add(100, ly_3lrc_desktop_on_update_cb, NULL);
}
Exemplo n.º 20
0
void screen_changed(GtkWidget *widget, GdkScreen *old_screen, gpointer userdata)
{
    /* To check if the display supports alpha channels, get the visual */
    GdkScreen *screen = gtk_widget_get_screen(widget);
    GdkVisual *visual = gdk_screen_get_rgba_visual(screen);

    if (!visual)
    {
        printf("Your screen does not support alpha channels!\n");
        visual = gdk_screen_get_system_visual(screen);
        supports_alpha = FALSE;
    }
    else
    {
        printf("Your screen supports alpha channels!\n");
        supports_alpha = TRUE;
    }

    gtk_widget_set_visual(widget, visual);
}
Exemplo n.º 21
0
static void ghtml_window_initialize(int width, int height, bool as_dialog, void *file) {

	ghtml_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

	GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (ghtml_window));
	GdkVisual *visual = gdk_screen_get_rgba_visual (screen);

	if (visual == NULL)
	visual = gdk_screen_get_system_visual (screen);

	gtk_widget_set_visual (ghtml_window, visual);

	g_signal_connect(ghtml_window, "destroy", G_CALLBACK(ghtml_window_destroy), NULL);

	void *ghtml_window_scrollable_content_area = gtk_scrolled_window_new(NULL, NULL);

	gtk_scrolled_window_set_policy(
		ghtml_window_scrollable_content_area, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC
	);

	if (ghtml_app_title) gtk_window_set_title(ghtml_window, ghtml_app_title);

	gtk_window_set_default_size(ghtml_window, width, height);

	ghtml_webview = WEBKIT_WEB_VIEW(webkit_web_view_new());

	gtk_container_add(ghtml_window, ghtml_window_scrollable_content_area);

	if (as_dialog) {
		gtk_window_set_type_hint((void*) ghtml_window, GDK_WINDOW_TYPE_HINT_DIALOG);
		GtkAccelGroup *gtk_accel = gtk_accel_group_new ();
		GClosure *closure;
		closure = g_cclosure_new (G_CALLBACK (ghtml_window_escaped), NULL, NULL);
		gtk_accel_group_connect (gtk_accel, gdk_keyval_from_name ("Escape"), 0, GTK_ACCEL_LOCKED, closure);
		gtk_window_add_accel_group (ghtml_window, gtk_accel);
	}

	ghtml_webview_initialize(ghtml_window_scrollable_content_area, file, true);

}
Exemplo n.º 22
0
DragIcon::DragIcon()
    : m_window(gtk_window_new(GTK_WINDOW_POPUP))
{
#ifdef GTK_API_VERSION_2
    g_signal_connect(m_window, "expose-event", G_CALLBACK(dragIconWindowDrawEventCallback), this);
#else
    g_signal_connect(m_window, "draw", G_CALLBACK(dragIconWindowDrawEventCallback), this);
#endif

    // This strategy originally comes from Chromium: src/chrome/browser/gtk/tab_contents_drag_source.cc
    GdkScreen* screen = gtk_widget_get_screen(m_window);
#ifdef GTK_API_VERSION_2
    GdkColormap* rgba = gdk_screen_get_rgba_colormap(screen);
    if (rgba)
        gtk_widget_set_colormap(m_window, rgba);
#else
    GdkVisual* visual = gdk_screen_get_rgba_visual(screen);
    if (!visual)
        visual = gdk_screen_get_system_visual(screen);
    gtk_widget_set_visual(m_window, visual);
#endif // GTK_API_VERSION_2
}
Exemplo n.º 23
0
/* On screen changed. */
G_MODULE_EXPORT void
on_screen_changed       (GtkWidget  *widget,
                         GdkScreen  *previous_screen,
                         gpointer    user_data)
{
  AnnotateData *data = (AnnotateData *) user_data;

  if (data->debug)
    {
      g_printerr ("DEBUG: Annotation window get screen-changed event\n");
    }

  GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (widget));
  GdkVisual *visual = gdk_screen_get_rgba_visual (screen);
  
  if (visual == NULL)
    {
      visual = gdk_screen_get_system_visual (screen);
    }

  gtk_widget_set_visual (widget, visual);
}
Exemplo n.º 24
0
/*************************************************************
  Get display color type of default visual
*************************************************************/
enum Display_color_type get_visual(void)
{
  GdkVisual *visual;
  GdkVisualType type;

  visual = gdk_screen_get_system_visual(gdk_screen_get_default());
  type = gdk_visual_get_visual_type(visual);

  if (type == GDK_VISUAL_STATIC_GRAY) { 
    /* StaticGray, use black and white */
    log_verbose("found B/W display.");
    return BW_DISPLAY;
  }

  if(type < GDK_VISUAL_STATIC_COLOR) {
    /* No color visual available at default depth */
    log_verbose("found grayscale(?) display.");
    return GRAYSCALE_DISPLAY;
  }

  log_verbose("color system booted ok.");

  return COLOR_DISPLAY;
}
Exemplo n.º 25
0
static GtkWidget*
create_new_window (GtkApplication *application,
                   GVariantDict   *options)
{
    dg_lmem gchar* command = NULL;
    dg_lmem gchar* title = NULL;
    gboolean opt_show_title;
    gboolean opt_update_title;
    gboolean opt_no_headerbar;

    g_object_get (dwt_settings_get_instance (),
                  "show-title", &opt_show_title,
                  "update-title", &opt_update_title,
                  "no-header-bar", &opt_no_headerbar,
                  "command", &command,
                  "title", &title,
                  NULL);

    const gchar *opt_command = command;
    const gchar *opt_title   = title;
    const gchar *opt_workdir = NULL;

    if (options) {
        gboolean opt_no_auto_title = FALSE;
        g_variant_dict_lookup (options, "title-on-maximize", "b", &opt_show_title);
        g_variant_dict_lookup (options, "no-header-bar", "b", &opt_no_headerbar);
        g_variant_dict_lookup (options, "no-auto-title", "b", &opt_no_auto_title);
        g_variant_dict_lookup (options, "workdir", "&s", &opt_workdir);
        g_variant_dict_lookup (options, "command", "&s", &opt_command);
        g_variant_dict_lookup (options, "title",   "&s", &opt_title);
        if (opt_no_auto_title)
            opt_update_title = FALSE;
    }
    if (!opt_workdir) opt_workdir = g_get_home_dir ();
    if (!opt_command) opt_command = guess_shell ();

    /*
     * Title either comes from the default value of the "title" setting,
     * or from the command line flag, but should never be NULL at this
     * point.
     */
    g_assert (opt_title);

    dg_lerr GError *gerror = NULL;
    gint command_argv_len = 0;
    gchar **command_argv = NULL;

    if (!g_shell_parse_argv (opt_command,
                             &command_argv_len,
                             &command_argv,
                             &gerror))
    {
        g_printerr ("%s: coult not parse command: %s\n",
                    __func__, gerror->message);
        return NULL;
    }

    GtkWidget *window = gtk_application_window_new (application);
    gtk_widget_set_visual (window,
                           gdk_screen_get_system_visual (gtk_widget_get_screen (window)));
    gtk_application_window_set_show_menubar (GTK_APPLICATION_WINDOW (window),
                                             FALSE);
    gtk_window_set_title (GTK_WINDOW (window), opt_title);
    gtk_window_set_hide_titlebar_when_maximized (GTK_WINDOW (window),
                                                 !opt_show_title);

    g_action_map_add_action_entries (G_ACTION_MAP (window), win_actions,
                                     G_N_ELEMENTS (win_actions), window);

    VteTerminal *vtterm = VTE_TERMINAL (vte_terminal_new ());
    configure_term_widget (vtterm, options);
    term_char_size_changed (vtterm,
                            vte_terminal_get_char_width (vtterm),
                            vte_terminal_get_char_height (vtterm),
                            window);

    g_signal_connect (G_OBJECT (window), "notify::has-toplevel-focus",
                      G_CALLBACK (window_has_toplevel_focus_notified),
                      vtterm);

    g_signal_connect (G_OBJECT (vtterm), "char-size-changed",
                      G_CALLBACK (term_char_size_changed), window);
    g_signal_connect (G_OBJECT (vtterm), "child-exited",
                      G_CALLBACK (term_child_exited), window);
    g_signal_connect (G_OBJECT (vtterm), "bell",
                      G_CALLBACK (term_beeped), window);
    g_signal_connect (G_OBJECT (vtterm), "button-release-event",
                      G_CALLBACK (term_mouse_button_released),
                      setup_popover (vtterm));

    /*
     * Propagate title changes to the window.
     */
    if (opt_update_title)
        g_object_bind_property (G_OBJECT (vtterm), "window-title",
                                G_OBJECT (window), "title",
                                G_BINDING_DEFAULT);

    if (!opt_no_headerbar)
        setup_header_bar (window, vtterm, opt_show_title);

    gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (vtterm));
    gtk_widget_set_receives_default (GTK_WIDGET (vtterm), TRUE);

    /* We need to realize and show the window for it to have a valid XID */
    gtk_widget_show_all (window);

    gchar **command_env = g_get_environ ();
#ifdef GDK_WINDOWING_X11
    if (GDK_IS_X11_SCREEN (gtk_widget_get_screen (window))) {
        GdkWindow *gdk_window = gtk_widget_get_window (window);
        if (gdk_window) {
            gchar window_id[NDIGITS10(unsigned long)];
            snprintf (window_id,
                      sizeof (window_id),
                      "%lu",
                      GDK_WINDOW_XID (gdk_window));
            command_env = g_environ_setenv (command_env,
                                            "WINDOWID",
                                            window_id,
                                            TRUE);
        } else {
            g_printerr ("No window, cannot set $WINDOWID!\n");
        }
    }
Exemplo n.º 26
0
/**
 * gdk_visual_get_system:
 *
 * Get the system’s default visual for the default GDK screen.
 * This is the visual for the root window of the display.
 * The return value should not be freed.
 *
 * Returns: (transfer none): system visual
 */
GdkVisual*
gdk_visual_get_system (void)
{
  return gdk_screen_get_system_visual (gdk_screen_get_default());
}
Exemplo n.º 27
0
GtkWidget*
gtk_xtbin_new (GtkWidget *parent_widget, String *f)
{
  GtkXtBin *xtbin;
  gpointer user_data;
  GdkScreen *screen;
  GdkVisual* visual;
  Colormap colormap;
  GdkWindow* parent_window = gtk_widget_get_window(parent_widget);

  assert(parent_window != NULL);
  xtbin = g_object_new (GTK_TYPE_XTBIN, NULL);

  if (!xtbin)
    return (GtkWidget*)NULL;

  if (f)
    fallback = f;

  /* Initialize the Xt toolkit */
  xtbin->parent_window = parent_window;

  screen = gtk_widget_get_screen(parent_widget);
  visual = gdk_screen_get_system_visual(screen);
  colormap = XCreateColormap(GDK_DISPLAY_XDISPLAY(gdk_screen_get_display(screen)),
                             GDK_WINDOW_XWINDOW(gdk_screen_get_root_window(screen)),
                             GDK_VISUAL_XVISUAL(visual), AllocNone);

  xt_client_init(&(xtbin->xtclient), 
                 GDK_VISUAL_XVISUAL(visual),
                 colormap,
                 gdk_visual_get_depth(visual));

  if (!xtbin->xtclient.xtdisplay) {
    /* If XtOpenDisplay failed, we can't go any further.
     *  Bail out.
     */
#ifdef DEBUG_XTBIN
    printf("gtk_xtbin_init: XtOpenDisplay() returned NULL.\n");
#endif
    g_free (xtbin);
    return (GtkWidget *)NULL;
  }

  /* If this is the first running widget, hook this display into the
     mainloop */
  if (0 == num_widgets) {
    int           cnumber;
    /*
     * hook Xt event loop into the glib event loop.
     */

    /* the assumption is that gtk_init has already been called */
    GSource* gs = g_source_new(&xt_event_funcs, sizeof(GSource));
      if (!gs) {
       return NULL;
      }
    
    g_source_set_priority(gs, GDK_PRIORITY_EVENTS);
    g_source_set_can_recurse(gs, TRUE);
    tag = g_source_attach(gs, (GMainContext*)NULL);
#ifdef VMS
    cnumber = XConnectionNumber(xtdisplay);
#else
    cnumber = ConnectionNumber(xtdisplay);
#endif
    xt_event_poll_fd.fd = cnumber;
    xt_event_poll_fd.events = G_IO_IN; 
    xt_event_poll_fd.revents = 0;    /* hmm... is this correct? */

    g_main_context_add_poll ((GMainContext*)NULL, 
                             &xt_event_poll_fd, 
                             G_PRIORITY_LOW);
    /* add a timer so that we can poll and process Xt timers */
    xt_polling_timer_id =
      g_timeout_add(25,
                      (GSourceFunc)xt_event_polling_timer_callback,
                      xtdisplay);
  }

  /* Bump up our usage count */
  num_widgets++;

  /* Build the hierachy */
  xtbin->xtdisplay = xtbin->xtclient.xtdisplay;
  gtk_widget_set_parent_window(GTK_WIDGET(xtbin), parent_window);
  gdk_window_get_user_data(xtbin->parent_window, &user_data);
  if (user_data)
    gtk_container_add(GTK_CONTAINER(user_data), GTK_WIDGET(xtbin));

  return GTK_WIDGET (xtbin);
}
Exemplo n.º 28
0
GtkWidget *
na_tray_child_new (GdkScreen *screen,
                   Window     icon_window)
{
  XWindowAttributes window_attributes;
  Display *xdisplay;
  NaTrayChild *child;
  GdkVisual *visual;
  gboolean visual_has_alpha;
  GdkColormap *colormap;
  gboolean new_colormap;
  int red_prec, green_prec, blue_prec, depth;
  int result;

  g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
  g_return_val_if_fail (icon_window != None, NULL);

  xdisplay = GDK_SCREEN_XDISPLAY (screen);

  /* We need to determine the visual of the window we are embedding and create
   * the socket in the same visual.
   */

  gdk_error_trap_push ();
  result = XGetWindowAttributes (xdisplay, icon_window,
                                 &window_attributes);
  gdk_error_trap_pop ();

  if (!result) /* Window already gone */
    return NULL;

  visual = gdk_x11_screen_lookup_visual (screen,
                                         window_attributes.visual->visualid);
  if (!visual) /* Icon window is on another screen? */
    return NULL;

  new_colormap = FALSE;

  if (visual == gdk_screen_get_rgb_visual (screen))
    colormap = gdk_screen_get_rgb_colormap (screen);
  else if (visual == gdk_screen_get_rgba_visual (screen))
    colormap = gdk_screen_get_rgba_colormap (screen);
  else if (visual == gdk_screen_get_system_visual (screen))
    colormap = gdk_screen_get_system_colormap (screen);
  else
    {
      colormap = gdk_colormap_new (visual, FALSE);
      new_colormap = TRUE;
    }

  child = g_object_new (NA_TYPE_TRAY_CHILD, NULL);
  child->icon_window = icon_window;

  gtk_widget_set_colormap (GTK_WIDGET (child), colormap);

  /* We have alpha if the visual has something other than red, green,
   * and blue */
  gdk_visual_get_red_pixel_details (visual, NULL, NULL, &red_prec);
  gdk_visual_get_green_pixel_details (visual, NULL, NULL, &green_prec);
  gdk_visual_get_blue_pixel_details (visual, NULL, NULL, &blue_prec);
  depth = gdk_visual_get_depth (visual);

  visual_has_alpha = red_prec + blue_prec + green_prec < depth;
  child->has_alpha = (visual_has_alpha &&
                      gdk_display_supports_composite (gdk_screen_get_display (screen)));

  child->composited = child->has_alpha;

  if (new_colormap)
    g_object_unref (colormap);

  return GTK_WIDGET (child);
}
Exemplo n.º 29
0
static gboolean
xfwmPixmapDrawFromGdkPixbuf (xfwmPixmap * pm, GdkPixbuf *pixbuf)
{
    GdkPixmap *dest_pixmap;
    GdkPixmap *dest_bitmap;
    GdkVisual *gvisual;
    GdkColormap *cmap;
    gint width, height;
    gint dest_x, dest_y;
    gint alpha_threshold;

    g_return_val_if_fail (pm != NULL, FALSE);
    g_return_val_if_fail (pm->pixmap != None, FALSE);
    g_return_val_if_fail (pm->mask != None, FALSE);

    dest_pixmap = gdk_xid_table_lookup (pm->pixmap);
    if (dest_pixmap)
    {
        g_object_ref (G_OBJECT (dest_pixmap));
    }
    else
    {
        dest_pixmap = gdk_pixmap_foreign_new (pm->pixmap);
    }

    if (!dest_pixmap)
    {
        g_warning ("Cannot get pixmap");
        return FALSE;
    }

    dest_bitmap = gdk_xid_table_lookup (pm->mask);
    if (dest_bitmap)
    {
        g_object_ref (G_OBJECT (dest_bitmap));
    }
    else
    {
        dest_bitmap = gdk_pixmap_foreign_new (pm->mask);
    }

    if (!dest_bitmap)
    {
        g_warning ("Cannot get bitmap");
        g_object_unref (dest_pixmap);
        return FALSE;
    }

    gvisual = gdk_screen_get_system_visual (pm->screen_info->gscr);
    cmap = gdk_x11_colormap_foreign_new (gvisual, pm->screen_info->cmap);

    if (!cmap)
    {
        g_warning ("Cannot create colormap");
        g_object_unref (dest_pixmap);
        g_object_unref (dest_bitmap);
        return FALSE;
    }

    width = MIN (gdk_pixbuf_get_width (pixbuf), pm->width);
    height = MIN (gdk_pixbuf_get_height (pixbuf), pm->height);
    dest_x = (pm->width - width) / 2;
    dest_y = (pm->height - height) / 2;

    gdk_drawable_set_colormap (GDK_DRAWABLE (dest_pixmap), cmap);
    gdk_draw_pixbuf (GDK_DRAWABLE (dest_pixmap), NULL, pixbuf, 0, 0, dest_x, dest_y,
                     width, height, GDK_RGB_DITHER_NONE, 0, 0);

    alpha_threshold = (gdk_pixbuf_get_has_alpha (pixbuf) ? 0xFF : 0);
    gdk_pixbuf_render_threshold_alpha (pixbuf, dest_bitmap,
                                       0, 0, dest_x, dest_y,
                                       width, height, alpha_threshold);

    g_object_unref (cmap);
    g_object_unref (dest_pixmap);
    g_object_unref (dest_bitmap);

    return TRUE;
}
Exemplo n.º 30
0
static void
gth_media_viewer_page_real_activate (GthViewerPage *base,
				     GthBrowser    *browser)
{
	GthMediaViewerPage *self;
	gboolean            rtl;

	if (! gstreamer_init ())
		return;

	self = (GthMediaViewerPage*) base;

	self->priv->browser = browser;
	g_action_map_add_action_entries (G_ACTION_MAP (browser),
					 actions,
					 G_N_ELEMENTS (actions),
					 browser);
	self->priv->screenshot_button =
			gth_browser_add_header_bar_button (browser,
							   GTH_BROWSER_HEADER_SECTION_VIEWER_VIEW,
							   "camera-photo-symbolic",
							   _("Take a screenshot"),
							   "win.video-screenshot",
							   NULL);

	rtl = gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL;

	/* video area */

	self->priv->area = gtk_drawing_area_new ();

	/* do not use the rgba visual on the drawing area */
	{
	        GdkVisual *visual;
	        visual = gdk_screen_get_system_visual (gtk_widget_get_screen (GTK_WIDGET (self->priv->area)));
        	if (visual != NULL)
                	gtk_widget_set_visual (GTK_WIDGET (self->priv->area), visual);
	}

	gtk_widget_set_double_buffered (self->priv->area, FALSE);
	gtk_widget_add_events (self->priv->area, (gtk_widget_get_events (self->priv->area)
						  | GDK_EXPOSURE_MASK
						  | GDK_BUTTON_PRESS_MASK
						  | GDK_BUTTON_RELEASE_MASK
						  | GDK_POINTER_MOTION_MASK
						  | GDK_POINTER_MOTION_HINT_MASK
						  | GDK_BUTTON_MOTION_MASK
						  | GDK_SCROLL_MASK));
	gtk_widget_set_can_focus (self->priv->area, TRUE);
	gtk_widget_show (self->priv->area);

	g_signal_connect (G_OBJECT (self->priv->area),
			  "realize",
			  G_CALLBACK (video_area_realize_cb),
			  self);
	g_signal_connect (G_OBJECT (self->priv->area),
			  "unrealize",
			  G_CALLBACK (video_area_unrealize_cb),
			  self);
	g_signal_connect (G_OBJECT (self->priv->area),
			  "draw",
			  G_CALLBACK (video_area_draw_cb),
			  self);
	g_signal_connect (G_OBJECT (self->priv->area),
			  "button_press_event",
			  G_CALLBACK (video_area_button_press_cb),
			  self);
	g_signal_connect (G_OBJECT (self->priv->area),
			  "popup-menu",
			  G_CALLBACK (video_area_popup_menu_cb),
			  self);
	g_signal_connect (G_OBJECT (self->priv->area),
			  "scroll_event",
			  G_CALLBACK (video_area_scroll_event_cb),
			  self);
	g_signal_connect (G_OBJECT (self->priv->area),
			  "key_press_event",
			  G_CALLBACK (video_area_key_press_cb),
			  self);

	/* mediabar */

	self->priv->builder = _gtk_builder_new_from_file ("mediabar.ui", "gstreamer_tools");
	self->priv->mediabar = GET_WIDGET ("mediabar");
	gtk_widget_set_halign (self->priv->mediabar, GTK_ALIGN_FILL);
	gtk_widget_set_valign (self->priv->mediabar, GTK_ALIGN_END);

	gtk_image_set_from_icon_name (GTK_IMAGE (GET_WIDGET ("play_slower_image")),
				      rtl ? "media-seek-backward-rtl-symbolic" : "media-seek-backward-symbolic",
				      GTK_ICON_SIZE_MENU);
	gtk_image_set_from_icon_name (GTK_IMAGE (GET_WIDGET ("play_faster_image")),
				      rtl ? "media-seek-forward-rtl-symbolic" : "media-seek-forward-symbolic",
				      GTK_ICON_SIZE_MENU);

	g_signal_connect (GET_WIDGET ("volume_adjustment"),
			  "value-changed",
			  G_CALLBACK (volume_value_changed_cb),
			  self);
	g_signal_connect (GET_WIDGET ("position_adjustment"),
			  "value-changed",
			  G_CALLBACK (position_value_changed_cb),
			  self);
	g_signal_connect (GET_WIDGET ("play_button"),
			  "clicked",
			  G_CALLBACK (play_button_clicked_cb),
			  self);
	g_signal_connect (GET_WIDGET ("play_slower_button"),
			  "clicked",
			  G_CALLBACK (play_slower_button_clicked_cb),
			  self);
	g_signal_connect (GET_WIDGET ("play_faster_button"),
			  "clicked",
			  G_CALLBACK (play_faster_button_clicked_cb),
			  self);

	self->priv->mediabar_revealer = gtk_revealer_new ();
	gtk_revealer_set_transition_type (GTK_REVEALER (self->priv->mediabar_revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP);
	gtk_widget_set_halign (self->priv->mediabar_revealer, GTK_ALIGN_FILL);
	gtk_widget_set_valign (self->priv->mediabar_revealer, GTK_ALIGN_END);
	gtk_widget_show (self->priv->mediabar_revealer);
	gtk_container_add (GTK_CONTAINER (self->priv->mediabar_revealer), self->priv->mediabar);

	self->priv->area_box = gtk_overlay_new ();
	gtk_container_add (GTK_CONTAINER (self->priv->area_box), self->priv->area);
	gtk_overlay_add_overlay (GTK_OVERLAY (self->priv->area_box), self->priv->mediabar_revealer);
	gtk_widget_show (self->priv->area_box);
	gth_browser_set_viewer_widget (browser, self->priv->area_box);

	gtk_widget_realize (self->priv->area);
	gth_browser_register_viewer_control (self->priv->browser, self->priv->mediabar);

	gth_viewer_page_focus (GTH_VIEWER_PAGE (self));
}