Example #1
0
/**
 * gdk_pixbuf_render_pixmap_and_mask_for_colormap:
 * @pixbuf: A pixbuf.
 * @colormap: A #GdkColormap
 * @pixmap_return: Location to store a pointer to the created pixmap,
 *   or %NULL if the pixmap is not needed.
 * @mask_return: Location to store a pointer to the created mask,
 *   or %NULL if the mask is not needed.
 * @alpha_threshold: Threshold value for opacity values.
 *
 * Creates a pixmap and a mask bitmap which are returned in the @pixmap_return
 * and @mask_return arguments, respectively, and renders a pixbuf and its
 * corresponding tresholded alpha mask to them.  This is merely a convenience
 * function; applications that need to render pixbufs with dither offsets or to
 * given drawables should use gdk_draw_pixbuf(), and gdk_pixbuf_render_threshold_alpha().
 *
 * The pixmap that is created uses the #GdkColormap specified by @colormap.
 * This colormap must match the colormap of the window where the pixmap
 * will eventually be used or an error will result.
 *
 * If the pixbuf does not have an alpha channel, then *@mask_return will be set
 * to %NULL.
 **/
void
gdk_pixbuf_render_pixmap_and_mask_for_colormap (GdkPixbuf   *pixbuf,
						GdkColormap *colormap,
						GdkPixmap  **pixmap_return,
						GdkBitmap  **mask_return,
						int          alpha_threshold)
{
  GdkScreen *screen;

  g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
  g_return_if_fail (GDK_IS_COLORMAP (colormap));

  screen = gdk_colormap_get_screen (colormap);
  
  if (pixmap_return)
    {
      GdkGC *gc;
      *pixmap_return = gdk_pixmap_new (gdk_screen_get_root_window (screen),
				       gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf),
				       gdk_colormap_get_visual (colormap)->depth);

      gdk_drawable_set_colormap (GDK_DRAWABLE (*pixmap_return), colormap);
      gc = _gdk_drawable_get_scratch_gc (*pixmap_return, FALSE);

      /* If the pixbuf has an alpha channel, using gdk_pixbuf_draw would give
       * random pixel values in the area that are within the mask, but semi-
       * transparent. So we treat the pixbuf like a pixbuf without alpha channel;
       * see bug #487865.
       */
      if (gdk_pixbuf_get_has_alpha (pixbuf))
        gdk_draw_rgb_32_image (*pixmap_return, gc,
                               0, 0,
                               gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf),
                               GDK_RGB_DITHER_NORMAL,
                               gdk_pixbuf_get_pixels (pixbuf), gdk_pixbuf_get_rowstride (pixbuf));
      else
        gdk_draw_pixbuf (*pixmap_return, gc, pixbuf, 
                         0, 0, 0, 0,
                         gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf),
                         GDK_RGB_DITHER_NORMAL,
                         0, 0);
    }
  
  if (mask_return)
    {
      if (gdk_pixbuf_get_has_alpha (pixbuf))
	{
	  *mask_return = gdk_pixmap_new (gdk_screen_get_root_window (screen),
					 gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), 1);

	  gdk_pixbuf_render_threshold_alpha (pixbuf, *mask_return,
					     0, 0, 0, 0,
					     gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf),
					     alpha_threshold);
	}
      else
	*mask_return = NULL;
    }
}
Example #2
0
gint 
gtksharp_get_gdk_net_current_desktop (void)
{
	GdkAtom actual_property_type;
	int actual_format;
	int actual_length;
	long *data = NULL;
	gint current_desktop;

	if (!gdk_property_get (
			gdk_screen_get_root_window (gdk_screen_get_default ()),
			gdk_atom_intern ("_NET_CURRENT_DESKTOP", FALSE),
			gdk_atom_intern ("CARDINAL", FALSE),
			0,
			G_MAXLONG,
			FALSE,
			&actual_property_type,
			&actual_format,
			&actual_length,
			(guchar **) &data)) {
		gchar *actual_property_type_name;
		g_critical ("Unable to get _NET_CURRENT_DESKTOP");
		actual_property_type_name = gdk_atom_name (actual_property_type);
		if (actual_property_type_name) {
			g_message ("actual_property_type: %s", actual_property_type_name);
			g_free (actual_property_type_name);
		}
		return -1;
	}

	current_desktop = (gint) data[0];
	g_free (data);

	return current_desktop;
}
static void
run_dialog (GdkDisplay *display, GdkScreen  *screen, guint32 timestamp)
{
	Atom action_atom;
	Atom atom;
	Window root;
	XClientMessageEvent ev;
	
	if (!display)
		display = gdk_display_get_default ();
	if (!screen)
		screen = gdk_display_get_default_screen (display);
	root = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (screen));
	
	action_atom = gdk_x11_get_xatom_by_name_for_display (display, "_MATE_PANEL_ACTION");
	atom = gdk_x11_get_xatom_by_name_for_display (display, "_MATE_PANEL_ACTION_RUN_DIALOG");
	
	ev.type = ClientMessage;
	ev.window = root;
	ev.message_type = action_atom;
	ev.format = 32;
	ev.data.l[0] = atom;
	ev.data.l[1] = timestamp;
	
	gdk_error_trap_push ();
	
	XSendEvent (gdk_x11_display_get_xdisplay (display),
			root, False, StructureNotifyMask, (XEvent*) &ev);
	
	gdk_flush ();
	gdk_error_trap_pop ();
}
Example #4
0
static void
mmkeys_init (MmKeys *object)
{
	int keycodes[N_KEYCODES];
	GdkDisplay *display;
	GdkScreen *screen;
	GdkWindow *root;
	guint i, j;

	display = gdk_display_get_default ();

	keycodes[0] = XKeysymToKeycode (GDK_DISPLAY (), XF86XK_AudioPrev);
	keycodes[1] = XKeysymToKeycode (GDK_DISPLAY (), XF86XK_AudioNext);
	keycodes[2] = XKeysymToKeycode (GDK_DISPLAY (), XF86XK_AudioPlay);
	keycodes[3] = XKeysymToKeycode (GDK_DISPLAY (), XF86XK_AudioPause);
	keycodes[4] = XKeysymToKeycode (GDK_DISPLAY (), XF86XK_AudioStop);

	for (i = 0; i < gdk_display_get_n_screens (display); i++) {
		screen = gdk_display_get_screen (display, i);

		if (screen != NULL) {
			root = gdk_screen_get_root_window (screen);

			for (j = 0; j < N_KEYCODES; j++) {
				if (keycodes[j] > 0)
					grab_mmkey (keycodes[j], root);
			}

			gdk_window_add_filter (root, filter_mmkeys, object);
		}
	}
}
Example #5
0
static void tray_widget_realize(GtkWidget *widget)
{
	struct _tray_widget_icon *widget_icon = TRAY_WIDGET_ICON(widget);

	if (GTK_WIDGET_CLASS(parent_class)->realize)
		GTK_WIDGET_CLASS(parent_class)->realize(widget);

	tray_widget_make_transparent(widget, NULL);

	int screen_number = gdk_screen_get_number(gtk_widget_get_screen(widget));
	Display *display = GDK_DISPLAY_XDISPLAY(gtk_widget_get_display(widget));

	char *buffer = g_strdup_printf("_NET_SYSTEM_TRAY_S%d", screen_number);

	widget_icon->selection_atom		= XInternAtom(display, buffer, False);
	widget_icon->manager_atom		= XInternAtom(display, "MANAGER", False);
	widget_icon->system_tray_opcode_atom	= XInternAtom(display, "_NET_SYSTEM_TRAY_OPCODE", False);
	widget_icon->orientation_atom		= XInternAtom(display, "_NET_SYSTEM_TRAY_ORIENTATION", False);

	free(buffer);

	tray_widget_update_manager_window(widget_icon, FALSE);
	tray_widget_send_dock_request(widget_icon);

	GdkWindow *root_window = gdk_screen_get_root_window(gtk_widget_get_screen(widget));
	gdk_window_add_filter(root_window, tray_widget_filter, widget_icon);
}
cmsHPROFILE *
f_screen_get_profile (GdkScreen *screen)
{
	Display *dpy;
	Atom icc_atom, type;
	int format;
	gulong nitems;
	gulong bytes_after;
	guchar *str;
	int result;
	cmsHPROFILE *profile;
	
	dpy = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen));
	icc_atom = gdk_x11_get_xatom_by_name_for_display (gdk_screen_get_display (screen), "_ICC_PROFILE");
	
	result = XGetWindowProperty (dpy, GDK_WINDOW_XID (gdk_screen_get_root_window (screen)),
				     icc_atom, 0, G_MAXLONG,
				     False, XA_CARDINAL, &type, &format, &nitems,
				     &bytes_after, (guchar **)&str);
	/* TODO: handle bytes_after != 0 */
	
	if (nitems) {
		profile = cmsOpenProfileFromMem(str, nitems);
		XFree (str);
		return profile;
	} else
		return NULL;
}
Example #7
0
void
panel_force_quit (GdkScreen *screen,
		  guint      time)
{
	GdkGrabStatus  status;
	GdkCursor     *cross;
	GtkWidget     *popup;
	GdkWindow     *root;

	popup = display_popup_window (screen);

	root = gdk_screen_get_root_window (screen);

	gdk_window_add_filter (root, (GdkFilterFunc) popup_filter, popup);

	cross = gdk_cursor_new (GDK_CROSS);
	status = gdk_pointer_grab (root, FALSE, GDK_BUTTON_PRESS_MASK,
				   NULL, cross, time);
	gdk_cursor_unref (cross);
	if (status != GDK_GRAB_SUCCESS) {
		g_warning ("Pointer grab failed\n");
		remove_popup (popup);
		return;
	}

	status = gdk_keyboard_grab (root, FALSE, time);
	if (status != GDK_GRAB_SUCCESS) {
		g_warning ("Keyboard grab failed\n");
		remove_popup (popup);
		return;
	}

	gdk_flush ();
}
Example #8
0
static void
get_menu_pos (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data)
{
	charpick_data *curr_data = data;
	GtkRequisition  reqmenu;
	gint tempx, tempy, width, height;
	gint screen_width, screen_height;

	gtk_widget_get_preferred_size (GTK_WIDGET (menu), NULL, &reqmenu);
	gdk_window_get_origin (GDK_WINDOW (gtk_widget_get_window(curr_data->applet)), &tempx, &tempy);
	gdk_window_get_geometry (GDK_WINDOW (gtk_widget_get_window(curr_data->applet)), NULL, NULL,
				 &width, &height
				 );
     			      
	switch (mate_panel_applet_get_orient (MATE_PANEL_APPLET (curr_data->applet))) {
	case MATE_PANEL_APPLET_ORIENT_DOWN:
		tempy += height;
		break;
	case MATE_PANEL_APPLET_ORIENT_UP:
		tempy -= reqmenu.height;
		break;
	case MATE_PANEL_APPLET_ORIENT_LEFT:
		tempx -= reqmenu.width;
		break;
	case MATE_PANEL_APPLET_ORIENT_RIGHT:
		tempx += width;
		break;
	}

	gdk_window_get_geometry (gdk_screen_get_root_window (gdk_screen_get_default()),
				 NULL, NULL, &screen_width, &screen_height);

	*x = CLAMP (tempx, 0, MAX (0, screen_width - reqmenu.width));
	*y = CLAMP (tempy, 0, MAX (0, screen_height - reqmenu.height));
}
Example #9
0
static void
gdk_wmspec_change_state (gboolean add,
			 GdkWindow *window,
			 GdkAtom state1,
			 GdkAtom state2)
{
  GdkDisplay *display = 
    gdk_screen_get_display (gdk_drawable_get_screen (GDK_DRAWABLE (window)));
  XEvent xev;
  
#define _NET_WM_STATE_REMOVE        0    /* remove/unset property */
#define _NET_WM_STATE_ADD           1    /* add/set property */
#define _NET_WM_STATE_TOGGLE        2    /* toggle property  */  
  
  xev.xclient.type = ClientMessage;
  xev.xclient.serial = 0;
  xev.xclient.send_event = True;
  xev.xclient.window = GDK_WINDOW_XID (window);
  xev.xclient.message_type = 
    gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE");
  xev.xclient.format = 32;
  xev.xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
  xev.xclient.data.l[1] = gdk_x11_atom_to_xatom_for_display (display, state1);
  xev.xclient.data.l[2] = gdk_x11_atom_to_xatom_for_display (display, state2);
  
  XSendEvent (GDK_WINDOW_XDISPLAY (window),
	      GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (gdk_drawable_get_screen (GDK_DRAWABLE (window)))),
	      False, SubstructureRedirectMask | SubstructureNotifyMask,
	      &xev);
}
Example #10
0
void
_gdk_x11_xsettings_init (GdkX11Screen *x11_screen)
{
  gdk_window_add_filter (gdk_screen_get_root_window (GDK_SCREEN (x11_screen)), gdk_xsettings_root_window_filter, x11_screen);

  check_manager_window (x11_screen, FALSE);
}
Example #11
0
void
gdk_property_change (GdkWindow    *window,
		     GdkAtom       property,
		     GdkAtom       type,
		     gint          format,
		     GdkPropMode   mode,
		     const guchar *data,
		     gint          nelements)
{
  GdkDisplay *display;
  Window xwindow;
  Atom xproperty;
  Atom xtype;

  g_return_if_fail (!window || GDK_IS_WINDOW (window));

  if (!window)
    {
      GdkScreen *screen;
      
      screen = gdk_screen_get_default ();
      window = gdk_screen_get_root_window (screen);
      
      GDK_NOTE (MULTIHEAD, g_message ("gdk_property_change(): window is NULL\n"));
    }


  if (GDK_WINDOW_DESTROYED (window))
    return;

  display = gdk_drawable_get_display (window);
  
  xproperty = gdk_x11_atom_to_xatom_for_display (display, property);
  xtype = gdk_x11_atom_to_xatom_for_display (display, type);
  xwindow = GDK_WINDOW_XID (window);

  if (xtype == XA_ATOM ||
      xtype == gdk_x11_get_xatom_by_name_for_display (display, "ATOM_PAIR"))
    {
      /*
       * data is an array of GdkAtom, we need to convert it
       * to an array of X Atoms
       */
      gint i;
      GdkAtom *atoms = (GdkAtom*) data;
      Atom *xatoms;

      xatoms = g_new (Atom, nelements);
      for (i = 0; i < nelements; i++)
	xatoms[i] = gdk_x11_atom_to_xatom_for_display (display, atoms[i]);

      XChangeProperty (GDK_DISPLAY_XDISPLAY (display), xwindow,
		       xproperty, xtype,
		       format, mode, (guchar *)xatoms, nelements);
      g_free (xatoms);
    }
  else
    XChangeProperty (GDK_DISPLAY_XDISPLAY (display), xwindow, xproperty, 
		     xtype, format, mode, (guchar *)data, nelements);
}
Example #12
0
/* on_screen_changed */
static void _on_screen_changed(GtkWidget * widget, GdkScreen * previous,
                               gpointer data)
{
    Close * close = data;
    GdkWindow * window;
    GdkEventMask events;

#ifdef DEBUG
    fprintf(stderr, "DEBUG: %s()\n", __func__);
#endif
    close->screen = gtk_widget_get_screen(widget);
    close->display = gdk_screen_get_display(close->screen);
    close->root = gdk_screen_get_root_window(close->screen);
    close->panel = ((window = gtk_widget_get_parent_window(widget)) != NULL)
                   ? GDK_WINDOW_XID(window) : None;
    events = gdk_window_get_events(close->root);
    gdk_window_set_events(close->root, events
                          | GDK_PROPERTY_CHANGE_MASK);
    gdk_window_add_filter(close->root, _on_filter, close);
    close->atom_active = gdk_x11_get_xatom_by_name_for_display(
                             close->display, "_NET_ACTIVE_WINDOW");
    close->atom_close = gdk_x11_get_xatom_by_name_for_display(
                            close->display, "_NET_CLOSE_WINDOW");
    _close_do(close);
}
Example #13
0
/********************************************************************\
 * gnc_restore_window_size                                          *
 *   restores the position and size of the given window, if these   *
 *   these parameters have been saved earlier. Does nothing if no   *
 *   saved values are found.                                        *
 *                                                                  *
 * Args: group - the preferences group to look in for saved coords  *
 *       window - the window for which the coords are to be         *
 *                restored                                          *
 * Returns: nothing                                                 *
 \*******************************************************************/
void
gnc_restore_window_size(const char *group, GtkWindow *window)
{
    gint wpos[2], wsize[2];
    GVariant *geometry;

    ENTER("");

    g_return_if_fail(group != NULL);
    g_return_if_fail(window != NULL);

    if (!gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_SAVE_GEOMETRY))
        return;

    geometry = gnc_prefs_get_value (group, GNC_PREF_LAST_GEOMETRY);
    if (g_variant_is_of_type (geometry, (const GVariantType *) "(iiii)") )
    {
        gint screen_width;
        gint screen_height;
#if GTK_CHECK_VERSION(3,22,0)
        GdkWindow *win = gdk_screen_get_root_window (gtk_window_get_screen (window));
        GdkMonitor *mon = gdk_display_get_monitor_at_window (gtk_widget_get_display (GTK_WIDGET(window)), win);
        GdkRectangle monitor_size;

        gdk_monitor_get_geometry (mon, &monitor_size);

        screen_width = monitor_size.width;
        screen_height = monitor_size.height;
#else
        screen_width = gdk_screen_width(); //default screen
        screen_height = gdk_screen_height(); //default screen
#endif
        g_variant_get (geometry, "(iiii)",
                       &wpos[0],  &wpos[1],
                       &wsize[0], &wsize[1]);
        DEBUG("geometry from preferences - wpos[0]: %d, wpos[1]: %d, wsize[0]: %d, wsize[1]: %d",
              wpos[0],  wpos[1], wsize[0], wsize[1]);

        /* (-1, -1) means no geometry was saved (default preferences value) */
        if ((wpos[0] != -1) && (wpos[1] != -1))
        {
            /* Keep the window on screen if possible */
            if (screen_width != 0)
                wpos[0] = wpos[0] % screen_width;
            if (screen_height != 0)
                wpos[1] = wpos[1] % screen_height;
            DEBUG("geometry after screen adaption - wpos[0]: %d, wpos[1]: %d, wsize[0]: %d, wsize[1]: %d",
                  wpos[0],  wpos[1], wsize[0], wsize[1]);

            gtk_window_move(window, wpos[0], wpos[1]);
        }

        /* Don't attempt to restore invalid sizes */
        if ((wsize[0] > 0) && (wsize[1] > 0))
            gtk_window_resize(window, wsize[0], wsize[1]);
    }
    g_variant_unref (geometry);

    LEAVE("");
}
Example #14
0
void
gdk_property_delete (GdkWindow *window,
		     GdkAtom    property)
{
  g_return_if_fail (!window || GDK_IS_WINDOW (window));

  if (!window)
    {
      GdkScreen *screen = gdk_screen_get_default ();
      window = gdk_screen_get_root_window (screen);
      
      GDK_NOTE (MULTIHEAD, 
		g_message ("gdk_property_delete(): window is NULL\n"));
    }

  if (GDK_WINDOW_DESTROYED (window))
    return;

  gi_atom_id_t aid;
  GdkDisplay *display = GDK_DISPLAY_OBJECT(_gdk_display);

  aid = gdk_x11_atom_to_xatom_for_display (display, property);

  gi_delete_property ( GDK_DRAWABLE_GIX_ID (window), aid);
}
Example #15
0
guint 
gtksharp_get_gdk_net_active_window (void)
{
	GdkAtom actual_property_type;
	int actual_format;
	int actual_length;
	long *data = NULL;
	guint windowID = 0;

	if (!gdk_property_get (
			gdk_screen_get_root_window (gdk_screen_get_default ()),
			gdk_atom_intern ("_NET_ACTIVE_WINDOW", FALSE),		
			gdk_atom_intern ("WINDOW", FALSE),			
			0,							
			G_MAXLONG,						
			FALSE,							
			&actual_property_type,					
			&actual_format,						
			&actual_length,						
			(guchar **) &data)) {					
		gchar *actualPropertyTypeName;
		g_critical ("Unable to get _NET_ACTIVE_WINDOW");
		actualPropertyTypeName = gdk_atom_name (actual_property_type);
		if (actualPropertyTypeName) {
			g_message ("actual_property_type: %s", actualPropertyTypeName);
			g_free(actualPropertyTypeName);
		}
		return -1;
	}

	windowID = (gint) data [0];
	g_free (data);

	return windowID;
}
static void
move_locate_pointer_window (GsdLocatePointerData *data,
			    GdkScreen            *screen)
{
  gint cursor_x, cursor_y;
  GdkBitmap *mask;
  GdkColor col;
  GdkGC *gc;

  gdk_window_get_pointer (gdk_screen_get_root_window (screen), &cursor_x, &cursor_y, NULL);

  gdk_window_move_resize (data->window,
                          cursor_x - WINDOW_SIZE / 2,
                          cursor_y - WINDOW_SIZE / 2,
                          WINDOW_SIZE, WINDOW_SIZE);

  col.pixel = 0;
  mask = gdk_pixmap_new (data->window, WINDOW_SIZE, WINDOW_SIZE, 1);

  gc = gdk_gc_new (mask);
  gdk_gc_set_foreground (gc, &col);
  gdk_draw_rectangle (mask, gc, TRUE, 0, 0, WINDOW_SIZE, WINDOW_SIZE);

  /* allow events to happen through the window */
  gdk_window_input_shape_combine_mask (data->window, mask, 0, 0);

  g_object_unref (mask);
  g_object_unref (gc);
}
Example #17
0
void Ctrl::GetWorkArea(Array<Rect>& rc)
{
	GuiLock __;
	GdkScreen *s = gdk_screen_get_default();
	int n = gdk_screen_get_n_monitors(s);
	rc.Clear();
	Vector<int> netwa;
	for(int i = 0; i < n; i++) {
		GdkRectangle rr;
		Rect r;
#if GTK_CHECK_VERSION (3, 3, 5) // U++ does not work with gtk3 yet, but be prepared
		gdk_screen_get_monitor_workarea(s, i, &rr);
		r = RectC(r.x, r.y, r.width, r.height);
#else
		gdk_screen_get_monitor_geometry (s, i, &rr);
		r = RectC(rr.x, rr.y, rr.width, rr.height);
	#ifdef GDK_WINDOWING_X11
		if(i == 0)
			netwa = GetPropertyInts(gdk_screen_get_root_window(gdk_screen_get_default()),
			                        "_NET_WORKAREA");
		if(netwa.GetCount())
			r = r & RectC(netwa[0], netwa[1], netwa[2], netwa[3]);
	#endif
#endif
		rc.Add(r);
	}
}
static void
move_locate_pointer_window (MsdLocatePointerData *data,
			    GdkScreen            *screen)
{
  gint cursor_x, cursor_y;
  GdkBitmap *mask;
  cairo_t *cr;

  gdk_window_get_pointer (gdk_screen_get_root_window (screen), &cursor_x, &cursor_y, NULL);

  gdk_window_move_resize (data->window,
                          cursor_x - WINDOW_SIZE / 2,
                          cursor_y - WINDOW_SIZE / 2,
                          WINDOW_SIZE, WINDOW_SIZE);

  mask = gdk_pixmap_new (data->window, WINDOW_SIZE, WINDOW_SIZE, 1);

  cr = gdk_cairo_create (mask);
  cairo_set_source_rgb (cr, 0., 0., 0.);
  cairo_rectangle (cr, 0., 0., WINDOW_SIZE, WINDOW_SIZE);
  cairo_fill (cr);
  cairo_destroy (cr);

  /* allow events to happen through the window */
  gdk_window_input_shape_combine_mask (data->window, mask, 0, 0);

  g_object_unref (mask);
}
Example #19
0
static void
desktop_cb (GSimpleAction *action,
            GVariant      *parameter,
            gpointer       callback_data)
{
  GdkScreen *screen;
  GdkWindow *root;
  GtkWidget *window;
  GtkWidget *label;
  GdkRGBA    desktop_color;

  screen = gdk_screen_get_default ();
  root = gdk_screen_get_root_window (screen);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  set_gtk_window_type (GTK_WINDOW (window), "_NET_WM_WINDOW_TYPE_DESKTOP");
  gtk_window_set_title (GTK_WINDOW (window), "Desktop");
  gtk_widget_set_size_request (window,
                               gdk_window_get_width (root),
                               gdk_window_get_height (root));
  gtk_window_move (GTK_WINDOW (window), 0, 0);

  desktop_color.red = 0.32;
  desktop_color.green = 0.46;
  desktop_color.blue = 0.65;
  desktop_color.alpha = 1.0;

  override_background_color (window, &desktop_color);

  label = focus_label (window);

  gtk_container_add (GTK_CONTAINER (window), label);

  gtk_widget_show_all (window);
}
Example #20
0
static void
egg_tray_icon_unrealize (GtkWidget *widget)
{
  EggTrayIcon *icon = EGG_TRAY_ICON (widget);
  GdkWindow *root_window;

  if (icon->manager_window != None)
    {
      GdkWindow *gdkwin;

#if GTK_CHECK_VERSION(2,1,0)
      gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (widget),
                                              icon->manager_window);
#else
      gdkwin = gdk_window_lookup (icon->manager_window);
#endif

      gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
    }

#if GTK_CHECK_VERSION(2,1,0)
  root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget));
#else
  root_window = gdk_window_lookup (gdk_x11_get_default_root_xwindow ());
#endif

  gdk_window_remove_filter (root_window, egg_tray_icon_manager_filter, icon);

  if (GTK_WIDGET_CLASS (parent_class)->unrealize)
    (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
}
Example #21
0
static void
egg_tray_icon_unrealize (GtkWidget *widget)
{
#ifdef GDK_WINDOWING_X11
  EggTrayIcon *icon = EGG_TRAY_ICON (widget);
  GdkWindow *root_window;

  if (icon->manager_window != None)
    {
      GdkWindow *gdkwin;

      gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (widget),
                                              icon->manager_window);

      gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
    }

  root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget));

  gdk_window_remove_filter (root_window, egg_tray_icon_manager_filter, icon);

  if (GTK_WIDGET_CLASS (parent_class)->unrealize)
    (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
#endif
}
Example #22
0
static void
gimp_pick_button_pick (GdkScreen      *screen,
                       gint            x_root,
                       gint            y_root,
                       GimpPickButton *button)
{
  GdkWindow       *root_window = gdk_screen_get_root_window (screen);
  cairo_surface_t *image;
  cairo_t         *cr;
  guchar          *data;
  guchar           color[3];
  GimpRGB          rgb;

  image = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 1, 1);

  cr = cairo_create (image);

  gdk_cairo_set_source_window (cr, root_window, -x_root, -y_root);
  cairo_paint (cr);

  cairo_destroy (cr);

  data = cairo_image_surface_get_data (image);
  GIMP_CAIRO_RGB24_GET_PIXEL (data, color[0], color[1], color[2]);

  cairo_surface_destroy (image);

  gimp_rgba_set_uchar (&rgb, color[0], color[1], color[2], 1.0);

  g_signal_emit (button, pick_button_signals[COLOR_PICKED], 0, &rgb);
}
Example #23
0
static void
remove_popup (GtkWidget *popup)
{
	GdkWindow        *root;
#if GTK_CHECK_VERSION (3, 0, 0)
	GdkDisplay       *display;
	GdkDevice        *pointer;
	GdkDevice        *keyboard;
	GdkDeviceManager *device_manager;
#endif

	root = gdk_screen_get_root_window (
			gtk_window_get_screen (GTK_WINDOW (popup)));
	gdk_window_remove_filter (root, (GdkFilterFunc) popup_filter, popup);

	gtk_widget_destroy (popup);

#if GTK_CHECK_VERSION (3, 0, 0)
	display = gdk_window_get_display (root);
	device_manager = gdk_display_get_device_manager (display);
	pointer = gdk_device_manager_get_client_pointer (device_manager);
	keyboard = gdk_device_get_associated_device (pointer);

	gdk_device_ungrab (pointer, GDK_CURRENT_TIME);
	gdk_device_ungrab (keyboard, GDK_CURRENT_TIME);
#else
	gdk_pointer_ungrab (GDK_CURRENT_TIME);
	gdk_keyboard_ungrab (GDK_CURRENT_TIME);
#endif
}
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);
}
Example #25
0
/* title_on_screen_changed */
static void _title_on_screen_changed(GtkWidget * widget, GdkScreen * previous,
		gpointer data)
{
	Title * title = data;
	GdkEventMask events;

#ifdef DEBUG
	fprintf(stderr, "DEBUG: %s()\n", __func__);
#endif
	if(title->root != NULL)
		gdk_window_remove_filter(title->root, _title_on_filter, title);
	title->screen = gtk_widget_get_screen(widget);
	title->display = gdk_screen_get_display(title->screen);
	title->root = gdk_screen_get_root_window(title->screen);
	events = gdk_window_get_events(title->root);
	gdk_window_set_events(title->root, events
			| GDK_PROPERTY_CHANGE_MASK);
	gdk_window_add_filter(title->root, _title_on_filter, title);
	title->atom_active = gdk_x11_get_xatom_by_name_for_display(
			title->display, "_NET_ACTIVE_WINDOW");
	title->atom_name = gdk_x11_get_xatom_by_name_for_display(
			title->display, "_NET_WM_NAME");
	title->atom_utf8_string = gdk_x11_get_xatom_by_name_for_display(
			title->display, "UTF8_STRING");
	title->atom_visible_name = gdk_x11_get_xatom_by_name_for_display(
			title->display, "_NET_WM_VISIBLE_NAME");
	_title_do(title);
}
static void
timeline_frame_cb (GsdTimeline *timeline,
		   gdouble      progress,
		   gpointer     user_data)
{
  GsdLocatePointerData *data = (GsdLocatePointerData *) user_data;
  GdkScreen *screen;
  gint cursor_x, cursor_y;

  if (gtk_widget_is_composited (data->widget))
    {
      gdk_window_invalidate_rect (data->window, NULL, FALSE);
      data->progress = progress;
    }
  else if (progress >= data->progress + CIRCLES_PROGRESS_INTERVAL)
    {
      /* only invalidate window each circle interval */
      update_shape (data);
      gdk_window_invalidate_rect (data->window, NULL, FALSE);
      data->progress += CIRCLES_PROGRESS_INTERVAL;
    }

  screen = gdk_drawable_get_screen (data->window);
  gdk_window_get_pointer (gdk_screen_get_root_window (screen),
			  &cursor_x, &cursor_y, NULL);
  gdk_window_move (data->window,
                   cursor_x - WINDOW_SIZE / 2,
                   cursor_y - WINDOW_SIZE / 2);
}
JNIEXPORT jobject JNICALL
Java_gnu_java_awt_peer_gtk_GdkScreenGraphicsDevice_nativeGetBounds
(JNIEnv *env, jobject obj)
{
	jclass rectangle_class;
	jmethodID rectangle_ctor;
	GdkScreen *screen;
	GdkWindow *window;
	int x, y, w, h;
	jobject instance;
    
	rectangle_class = (*env)->FindClass(env, "java/awt/Rectangle");
    
    rectangle_ctor = (*env)->GetMethodID 
    (env, rectangle_class, "<init>", "(IIII)V");

    screen = (GdkScreen *) NSA_GET_SCREEN_PTR(env, obj);

	gdk_threads_enter();
	
	window = gdk_screen_get_root_window(screen);
	
	gdk_window_get_geometry(window, &x, &y, &w, &h, NULL);

	gdk_threads_leave();
	
    instance = (*env)->NewObject(env,
								 rectangle_class,
								 rectangle_ctor,
								 x, y, w, h);
	
	return instance;
}
static void
create_window (GsdLocatePointerData *data,
	       GdkScreen            *screen)
{
  GdkColormap *colormap;
  GdkVisual *visual;
  GdkWindowAttr attributes;

  colormap = gdk_screen_get_rgba_colormap (screen);
  visual = gdk_screen_get_rgba_visual (screen);

  if (!colormap)
    {
      colormap = gdk_screen_get_rgb_colormap (screen);
      visual = gdk_screen_get_rgb_visual (screen);
    }

  attributes.window_type = GDK_WINDOW_TEMP;
  attributes.wclass = GDK_INPUT_OUTPUT;
  attributes.visual = visual;
  attributes.colormap = colormap;
  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,
				 GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP);

  gdk_window_set_user_data (data->window, data->widget);
}
static gboolean get_desktop_window (Window *window)
{
	Window *desktop_window;
	GdkWindow *root_window;
	GdkAtom type_returned;
	int format_returned;
	int length_returned;

	root_window = gdk_screen_get_root_window (
				gdk_screen_get_default ());

	if (gdk_property_get (root_window,
			      gdk_atom_intern ("CAJA_DESKTOP_WINDOW_ID", FALSE),
			      gdk_x11_xatom_to_atom (XA_WINDOW),
			      0, 4, FALSE,
			      &type_returned,
			      &format_returned,
			      &length_returned,
			      (guchar**) &desktop_window)) {
		*window = *desktop_window;
		g_free (desktop_window);
		return TRUE;
	}
	else {
		*window = 0;
		return FALSE;
	}
}
int XttHotkey::grab_key( int keysym, int modifier)
{
  GdkDisplay *display = gdk_display_get_default();
  int n_screens = gdk_display_get_n_screens( display);

  Display *dp = gdk_x11_display_get_xdisplay( display);
  int mode = GrabModeAsync;

  int keycode = XKeysymToKeycode( dp, keysym);
  if ( !keycode)
    return 0;

  gdk_error_trap_push();

  for ( int i = 0; i < n_screens; i++) {
    GdkWindow *root = gdk_screen_get_root_window( gdk_display_get_screen( display, i));
    Window w = gdk_x11_drawable_get_xid( root);

    XGrabKey( dp, keycode, modifier, w, True, mode, mode);
    XGrabKey( dp, keycode, modifier | LockMask, w, True, mode, mode);
    XGrabKey( dp, keycode, modifier | Mod2Mask, w, True, mode, mode);
    XGrabKey( dp, keycode, modifier | LockMask | Mod2Mask, w, True, mode, mode);
  }
  gdk_flush();
  gdk_error_trap_pop();
  return 1;
}