コード例 #1
0
ファイル: gs-manager.c プロジェクト: bk2204/mate-screensaver
static void
gs_manager_create_windows (GSManager *manager)
{
	GdkDisplay  *display;
	int          n_screens;
	int          i;

	g_return_if_fail (manager != NULL);
	g_return_if_fail (GS_IS_MANAGER (manager));

	g_assert (manager->priv->windows == NULL);

	display = gdk_display_get_default ();
	n_screens = gdk_display_get_n_screens (display);

	for (i = 0; i < n_screens; i++)
	{
		g_signal_connect (gdk_display_get_screen (display, i),
		                  "monitors-changed",
		                  G_CALLBACK (on_screen_monitors_changed),
		                  manager);

		gs_manager_create_windows_for_screen (manager, gdk_display_get_screen (display, i));
	}
}
コード例 #2
0
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;
}
コード例 #3
0
ファイル: ui.c プロジェクト: fatman2021/marco
MetaImageWindow*
meta_image_window_new (Display *xdisplay,
                       int      screen_number,
                       int      max_width,
                       int      max_height)
{
  MetaImageWindow *iw;
  GdkDisplay *gdisplay;
  GdkScreen *gscreen;

  iw = g_new (MetaImageWindow, 1);
  iw->window = gtk_window_new (GTK_WINDOW_POPUP);

  gdisplay = gdk_x11_lookup_xdisplay (xdisplay);
  gscreen = gdk_display_get_screen (gdisplay, screen_number);

  gtk_window_set_screen (GTK_WINDOW (iw->window), gscreen);

  gtk_widget_realize (iw->window);
  iw->pixmap = gdk_pixmap_new (gtk_widget_get_window (iw->window),
                               max_width, max_height,
                               -1);

  gtk_widget_set_size_request (iw->window, 1, 1);
  gtk_widget_set_double_buffered (iw->window, FALSE);
  gtk_widget_set_app_paintable (iw->window, TRUE);

  return iw;
}
コード例 #4
0
ファイル: nemo-application.c プロジェクト: Cobinja/nemo
static void
init_desktop (NemoApplication *self)
{
	GdkScreen *screen;
	screen = gdk_display_get_screen (gdk_display_get_default (), 0);
	/* Initialize the desktop link monitor singleton */
	nemo_desktop_link_monitor_get ();

	if (!self->priv->no_desktop &&
	    !g_settings_get_boolean (nemo_desktop_preferences,
				     NEMO_PREFERENCES_SHOW_DESKTOP)) {
		self->priv->no_desktop = TRUE;
	}

	if (!self->priv->no_desktop) {
		nemo_application_open_desktop (self);
	}

	/* Monitor the preference to show or hide the desktop */
	g_signal_connect_swapped (nemo_desktop_preferences, "changed::" NEMO_PREFERENCES_SHOW_DESKTOP,
				  G_CALLBACK (desktop_changed_callback),
				  self);

	g_signal_connect (screen, "monitors-changed",
				  G_CALLBACK (monitors_changed_callback),
				  self);
}
コード例 #5
0
ファイル: mmkeys.c プロジェクト: BackupTheBerlios/sonata-svn
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);
		}
	}
}
コード例 #6
0
ファイル: changedisplay.c プロジェクト: Aridna/gtk2
/* Fills in the screen list based on the current display
 */
static void
fill_screens (ChangeDisplayInfo *info)
{
  gtk_list_store_clear (GTK_LIST_STORE (info->screen_model));

  if (info->current_display)
    {
      gint n_screens = gdk_display_get_n_screens (info->current_display);
      gint i;

      for (i = 0; i < n_screens; i++)
	{
	  GdkScreen *screen = gdk_display_get_screen (info->current_display, i);
	  GtkTreeIter iter;

	  gtk_list_store_append (GTK_LIST_STORE (info->screen_model), &iter);
	  gtk_list_store_set (GTK_LIST_STORE (info->screen_model), &iter,
			      SCREEN_COLUMN_NUMBER, i,
			      SCREEN_COLUMN_SCREEN, screen,
			      -1);

	  if (i == 0)
	    gtk_tree_selection_select_iter (info->screen_selection, &iter);
	}
    }
}
コード例 #7
0
ファイル: resizepopup.c プロジェクト: CSRedRat/mutter
static void
ensure_size_window (MetaResizePopup *popup)
{
  GdkVisual *visual;
  GdkScreen *screen;

  if (popup->size_window)
    return;

  popup->size_window = gtk_window_new (GTK_WINDOW_POPUP);
  screen = gdk_display_get_screen (gdk_x11_lookup_xdisplay (popup->display),
                                   popup->screen_number);
  visual = gdk_screen_get_rgba_visual (screen);

  gtk_window_set_screen (GTK_WINDOW (popup->size_window), screen);
  if (visual != NULL)
    gtk_widget_set_visual (popup->size_window, visual);

  gtk_window_set_type_hint (GTK_WINDOW (popup->size_window),
                            GDK_WINDOW_TYPE_HINT_TOOLTIP);
  gtk_window_set_resizable (GTK_WINDOW (popup->size_window), FALSE);

  gtk_widget_set_app_paintable (popup->size_window, TRUE);
  gtk_style_context_add_class (gtk_widget_get_style_context (popup->size_window),
                               GTK_STYLE_CLASS_TOOLTIP);
  g_signal_connect (popup->size_window, "draw",
                    G_CALLBACK (size_window_draw), popup);

  popup->size_label = gtk_label_new ("");
  g_object_set (popup->size_label, "margin", 6, NULL);

  gtk_container_add (GTK_CONTAINER (popup->size_window), popup->size_label);

  gtk_widget_show (popup->size_label);
}
コード例 #8
0
ファイル: gs-manager.c プロジェクト: cavalier38/light-locker
static void
gs_manager_destroy_windows (GSManager *manager)
{
        GdkDisplay  *display;
        GSList      *l;
        int          n_screens;
        int          i;

        g_return_if_fail (manager != NULL);
        g_return_if_fail (GS_IS_MANAGER (manager));

        if (manager->priv->windows == NULL) {
                return;
        }

        display = gdk_display_get_default ();

        n_screens = gdk_display_get_n_screens (display);

        for (i = 0; i < n_screens; i++) {
                g_signal_handlers_disconnect_by_func (gdk_display_get_screen (display, i),
                                                      on_screen_monitors_changed,
                                                      manager);
        }

        for (l = manager->priv->windows; l; l = l->next) {
                gs_window_destroy (l->data);
        }
        g_slist_free (manager->priv->windows);
        manager->priv->windows = NULL;
}
コード例 #9
0
void
meta_fixed_tip_show (Display *xdisplay, int screen_number,
                     int root_x, int root_y,
                     const char *markup_text)
{
  int w, h;
  
  if (tip == NULL)
    {      
      tip = gtk_window_new (GTK_WINDOW_POPUP);
      gtk_window_set_type_hint (GTK_WINDOW(tip), GDK_WINDOW_TYPE_HINT_TOOLTIP);

      {
        GdkScreen *gdk_screen;
	GdkRectangle monitor;
	gint mon_num;

        gdk_screen = gdk_display_get_screen (gdk_display_get_default (),
                                             screen_number);
        gtk_window_set_screen (GTK_WINDOW (tip),
                               gdk_screen);
	mon_num = gdk_screen_get_monitor_at_point (gdk_screen, root_x, root_y);
	gdk_screen_get_monitor_geometry (gdk_screen, mon_num, &monitor);
	screen_right_edge = monitor.x + monitor.width;
	screen_bottom_edge = monitor.y + monitor.height;
      }
      
      gtk_widget_set_app_paintable (tip, TRUE);
      gtk_window_set_resizable (GTK_WINDOW (tip), FALSE);
      gtk_widget_set_name (tip, "gtk-tooltips");
      gtk_container_set_border_width (GTK_CONTAINER (tip), 4);

      g_signal_connect_swapped (tip, "expose_event",
				 G_CALLBACK (expose_handler), NULL);

      label = gtk_label_new (NULL);
      gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
      gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
      gtk_widget_show (label);
      
      gtk_container_add (GTK_CONTAINER (tip), label);

      g_signal_connect (tip, "destroy",
			G_CALLBACK (gtk_widget_destroyed), &tip);
    }

  gtk_label_set_markup (GTK_LABEL (label), markup_text);
  
  gtk_window_get_size (GTK_WINDOW (tip), &w, &h);

  if (meta_ui_get_direction() == META_UI_DIRECTION_RTL)
      root_x = MAX(0, root_x - w);

  if ((root_x + w) > screen_right_edge)
    root_x -= (root_x + w) - screen_right_edge;
  
  gtk_window_move (GTK_WINDOW (tip), root_x, root_y);

  gtk_widget_show (tip);
}
コード例 #10
0
static CORBA_char *
impl_MateComponent_Control_getWindowId (PortableServer_Servant servant,
				 const CORBA_char      *cookie,
				 CORBA_Environment     *ev)
{
	guint32        x11_id;
	MateComponentControl *control = MATECOMPONENT_CONTROL (
		matecomponent_object_from_servant (servant));
	GdkScreen *gdkscreen;
	int        screen_num;

	if (!control->priv->plug)
		create_plug (control);

	g_assert (control->priv->plug != NULL);

	screen_num = parse_cookie (cookie);
	if (screen_num != -1)
		gdkscreen = gdk_display_get_screen (
				gdk_display_get_default (), screen_num);
	else
		gdkscreen = gdk_screen_get_default ();

	gtk_window_set_screen (GTK_WINDOW (control->priv->plug), gdkscreen);

	gtk_widget_show (control->priv->plug);

	x11_id = gtk_plug_get_id (GTK_PLUG (control->priv->plug));
		
	dbgprintf ("plug id %u\n", x11_id);

	return matecomponent_control_window_id_from_x11 (x11_id);
}
コード例 #11
0
EggTrayIcon *egg_tray_icon_new_for_xscreen (Screen *xscreen, const char *name)
{
  GdkDisplay *display;
  GdkScreen *screen;

  display = gdk_x11_lookup_xdisplay (DisplayOfScreen (xscreen));
  screen = gdk_display_get_screen (display, XScreenNumberOfScreen (xscreen));

  return egg_tray_icon_new_for_screen (screen, name);
}
コード例 #12
0
ファイル: gimpsessioninfo.c プロジェクト: WilfR/Gimp-Matting
void
gimp_session_info_restore (GimpSessionInfo   *info,
                           GimpDialogFactory *factory)
{
  GtkWidget            *dialog  = NULL;
  GdkDisplay           *display = NULL;
  GdkScreen            *screen  = NULL;
  GimpRestoreDocksData *data    = NULL;

  g_return_if_fail (GIMP_IS_SESSION_INFO (info));
  g_return_if_fail (GIMP_IS_DIALOG_FACTORY (factory));

  g_object_ref (info);

  display = gdk_display_get_default ();

  if (info->p->screen != DEFAULT_SCREEN)
    screen = gdk_display_get_screen (display, info->p->screen);

  if (! screen)
    screen = gdk_display_get_default_screen (display);

  info->p->open   = FALSE;
  info->p->screen = DEFAULT_SCREEN;

  if (info->p->factory_entry &&
      info->p->factory_entry->restore_func)
    {
      dialog = info->p->factory_entry->restore_func (factory,
                                                     screen,
                                                     info);
    }

  if (GIMP_IS_SESSION_MANAGED (dialog) && info->p->aux_info)
    gimp_session_managed_set_aux_info (GIMP_SESSION_MANAGED (dialog),
                                       info->p->aux_info);

  /* In single-window mode, gimp_session_managed_set_aux_info()
   * will set the size of the dock areas at the sides. If we don't
   * wait for those areas to get their size-allocation, we can't
   * properly restore the docks inside them, so do that in an idle
   * callback.
   */

  /* Objects are unreffed again in the callback */
  data = g_slice_new0 (GimpRestoreDocksData);
  data->info    = g_object_ref (info);
  data->factory = g_object_ref (factory);
  data->screen  = g_object_ref (screen);
  data->dialog  = g_object_ref (dialog);

  g_idle_add ((GSourceFunc) gimp_session_info_restore_docks, data);

  g_object_unref (info);
}
コード例 #13
0
ファイル: gdk_Display.cpp プロジェクト: Klaim/falcon
/*#
    @method get_screen GdkDisplay
    @brief Returns a screen object for one of the screens of the display.
    @param screen_num the screen number
    @return the GdkScreen object
 */
FALCON_FUNC Display::get_screen( VMARG )
{
    Item* i_n = vm->param( 0 );
#ifndef NO_PARAMETER_CHECK
    if ( !i_n || !i_n->isInteger() )
        throw_inv_params( "I" );
#endif
    vm->retval( new Gdk::Screen( vm->findWKI( "GdkScreen" )->asClass(),
                                 gdk_display_get_screen( GET_DISPLAY( vm->self() ),
                                                         i_n->asInteger() ) ) );
}
コード例 #14
0
ファイル: na-gtk-utils.c プロジェクト: nmbooker/caja-actions
/**
 * na_gtk_utils_restore_position_window:
 * @toplevel: the #GtkWindow window.
 * @wsp_name: the string which handles the window size and position in user preferences.
 *
 * Position the specified window on the screen.
 *
 * A window position is stored as a list of integers "x,y,width,height".
 */
void
na_gtk_utils_restore_window_position( GtkWindow *toplevel, const gchar *wsp_name )
{
	static const gchar *thisfn = "na_gtk_utils_restore_window_position";
	GList *list;
	gint x=0, y=0, width=0, height=0;
	GdkDisplay *display;
	GdkScreen *screen;
	gint screen_width, screen_height;

	g_return_if_fail( GTK_IS_WINDOW( toplevel ));
	g_return_if_fail( wsp_name && strlen( wsp_name ));

	g_debug( "%s: toplevel=%p (%s), wsp_name=%s",
			thisfn, ( void * ) toplevel, G_OBJECT_TYPE_NAME( toplevel ), wsp_name );

	list = na_settings_get_uint_list( wsp_name, NULL, NULL );

	if( list ){
		int_list_to_position( list, &x, &y, &width, &height );
		g_debug( "%s: wsp_name=%s, x=%d, y=%d, width=%d, height=%d", thisfn, wsp_name, x, y, width, height );
		free_int_list( list );
	}

	x = MAX( 1, x );
	y = MAX( 1, y );
	width = MAX( 1, width );
	height = MAX( 1, height );

	display = gdk_display_get_default();
	screen = gdk_display_get_screen( display, 0 );
	screen_width = gdk_screen_get_width( screen );
	screen_height = gdk_screen_get_height( screen );

	/* very dirty hack based on the assumption that Mate 2.x has a bottom
	 * and a top panel bars, while Mate 3.x only has one.
	 * Don't know how to get usable height of screen, and don't bother today.
	 */
	screen_height -= DEFAULT_HEIGHT;
#if ! GTK_CHECK_VERSION( 3, 0, 0 )
	screen_height -= DEFAULT_HEIGHT;
#endif

	width = MIN( width, screen_width-x );
	height = MIN( height, screen_height-y );

	g_debug( "%s: wsp_name=%s, screen=(%d,%d), x=%d, y=%d, width=%d, height=%d",
			thisfn, wsp_name, screen_width, screen_height, x, y, width, height );

	gtk_window_move( toplevel, x, y );
	gtk_window_resize( toplevel, width, height );
}
コード例 #15
0
ファイル: ui.c プロジェクト: darkxst/mtest
void
meta_ui_theme_get_frame_borders (MetaUI *ui,
                                 MetaFrameType      type,
                                 MetaFrameFlags     flags,
                                 MetaFrameBorders  *borders)
{
  int text_height;
  GtkStyleContext *style = NULL;
  PangoContext *context;
  const PangoFontDescription *font_desc;
  PangoFontDescription *free_font_desc = NULL;

  if (meta_ui_have_a_theme ())
    {
      context = gtk_widget_get_pango_context (GTK_WIDGET (ui->frames));
      font_desc = meta_prefs_get_titlebar_font ();

      if (!font_desc)
        {
          GdkDisplay *display = gdk_x11_lookup_xdisplay (ui->xdisplay);
          GdkScreen *screen = gdk_display_get_screen (display, XScreenNumberOfScreen (ui->xscreen));
          GtkWidgetPath *widget_path;

          style = gtk_style_context_new ();
          gtk_style_context_set_screen (style, screen);
          widget_path = gtk_widget_path_new ();
          gtk_widget_path_append_type (widget_path, GTK_TYPE_WINDOW);
          gtk_style_context_set_path (style, widget_path);
          gtk_widget_path_free (widget_path);

          gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, "font", &free_font_desc, NULL);
          font_desc = (const PangoFontDescription *) free_font_desc;
        }

      text_height = meta_pango_font_desc_get_text_height (font_desc, context);

      meta_theme_get_frame_borders (meta_theme_get_current (),
                                    type, text_height, flags,
                                    borders);

      if (free_font_desc)
        pango_font_description_free (free_font_desc);
    }
  else
    {
      meta_frame_borders_clear (borders);
    }

  if (style != NULL)
    g_object_unref (style);
}
コード例 #16
0
ファイル: mt-main.c プロジェクト: Kristishka/mousetweaks
static void
mt_main_set_cursor (MTClosure *mt, GdkCursorType type)
{
    GdkScreen *screen;
    GdkCursor *cursor;
    gint i;

    cursor = gdk_cursor_new (type);
    for (i = 0; i < mt->n_screens; ++i) {
	screen = gdk_display_get_screen (gdk_display_get_default (), i);
	gdk_window_set_cursor (gdk_screen_get_root_window (screen), cursor);
    }
    gdk_cursor_unref (cursor);
}
コード例 #17
0
ファイル: grab.c プロジェクト: Pitxyoki/audacious-plugins
void release_filter()
{
    GdkDisplay *display;
    int screen;

    display = gdk_display_get_default();

    for (screen = 0; screen<gdk_display_get_n_screens(display); screen++)
    {
        gdk_window_remove_filter(gdk_screen_get_root_window(gdk_display_get_screen(display, screen)),
                    gdk_filter,
                    NULL);
    }
}
コード例 #18
0
static gboolean install_keygrab(const char *accelerator, struct keygrab_data *data)
{
        GdkDisplay *display = gdk_display_get_default();
        int i;
        int xerr;

        g_return_val_if_fail(accelerator, FALSE);
        g_return_val_if_fail(data, FALSE);

        gtk_accelerator_parse(accelerator,
                              &data->keyval,
                              &data->modifiers);
        if(data->keyval==0) {
                fprintf(stderr,
                        "error: invalid accelerator: '%s'\n",
                        accelerator);
                return FALSE;
        }

        gdk_error_trap_push();

        data->keycode=XKeysymToKeycode(GDK_DISPLAY(), data->keyval);
        for (i = 0; i < gdk_display_get_n_screens (display); i++) {
                GdkScreen *screen;
                GdkWindow *root;

                screen = gdk_display_get_screen (display, i);
                if (!screen) {
                        continue;
                }
                root = gdk_screen_get_root_window (screen);
                XGrabKey(GDK_DISPLAY(),
                         data->keycode,
                         data->modifiers,
                         GDK_WINDOW_XID(root),
                         True,
                         GrabModeAsync,
                         GrabModeAsync);
        }
        gdk_flush();
        xerr=gdk_error_trap_pop();
        if(xerr!=0) {
                return FALSE;
        }

        printf("ocha: Type %s to open the seach window.\n",
               accelerator);
        return TRUE;
}
コード例 #19
0
ファイル: gdkmireventsource.c プロジェクト: csoriano89/gtk-1
static void
send_event (GdkWindow *window, GdkDevice *device, GdkEvent *event)
{
  GdkDisplay *display;
  GList *node;

  gdk_event_set_device (event, device);
  gdk_event_set_source_device (event, device);
  gdk_event_set_screen (event, gdk_display_get_screen (gdk_window_get_display (window), 0));
  event->any.window = g_object_ref (window);

  display = gdk_window_get_display (window);
  node = _gdk_event_queue_append (display, event);
  _gdk_windowing_got_event (display, node, event, _gdk_display_get_next_serial (display));
}
コード例 #20
0
ファイル: eggtrayicon.c プロジェクト: czxxjtu/wxPython-1
EggTrayIcon *
egg_tray_icon_new_for_xscreen (Screen *xscreen, const char *name)
{
  EggTrayIcon *icon;
  char buffer[256];
  GdkWindow *root_window;
  GdkDisplay *display;
  GdkScreen *screen;
  
  g_return_val_if_fail (xscreen != NULL, NULL);
  
  icon = g_object_new (EGG_TYPE_TRAY_ICON, NULL);
  gtk_window_set_title (GTK_WINDOW (icon), name);

  display = gdk_x11_lookup_xdisplay (DisplayOfScreen (xscreen));
  screen = gdk_display_get_screen (display, XScreenNumberOfScreen (xscreen));
  
  gtk_plug_construct_for_display (GTK_PLUG (icon),
				  display, 0);

  gtk_window_set_screen (GTK_WINDOW (icon), screen);	 
  
  gtk_widget_realize (GTK_WIDGET (icon));

  /* Now see if there's a manager window around */
  g_snprintf (buffer, sizeof (buffer),
	      "_NET_SYSTEM_TRAY_S%d",
	      XScreenNumberOfScreen (xscreen));
  
  icon->selection_atom = XInternAtom (DisplayOfScreen (xscreen),
				      buffer, False);
  
  icon->manager_atom = XInternAtom (DisplayOfScreen (xscreen),
				    "MANAGER", False);
  
  icon->system_tray_opcode_atom = XInternAtom (DisplayOfScreen (xscreen),
					       "_NET_SYSTEM_TRAY_OPCODE", False);

  egg_tray_icon_update_manager_window (icon);

  root_window = gdk_screen_get_root_window (gtk_widget_get_screen (GTK_WIDGET (icon)));
  
  /* Add a root window filter so that we get changes on MANAGER */
  gdk_window_add_filter (root_window,
			 egg_tray_icon_manager_filter, icon);
		      
  return icon;
}
コード例 #21
0
void
hildon_desktop_ms_reinit (HildonDesktopMultiscreen *dms)
{
  GdkDisplay *display;
  GList *toplevels, *l;
  gint new_screens;
  gint i;

  if (dms->monitors)
    g_free (dms->monitors);

  if (dms->geometries)
  {
    gint i;

    for (i = 0; i < dms->screens; i++)
      g_free (dms->geometries[i]);

    g_free (dms->geometries);
  }

  display = gdk_display_get_default ();
	/* Don't use the screens variable since in the future, we might
	 * want to call this function when a screen appears/disappears. */
#ifndef ONE_SCREEN_MONITOR
  new_screens = gdk_display_get_n_screens (display);
#else
  new_screens = 1;
#endif
  for (i = 0; i < new_screens; i++)
  {
    GdkScreen *screen;

    screen = gdk_display_get_screen (display, i);
    g_signal_handlers_disconnect_by_func (screen,
				          hildon_desktop_ms_reinit,
					  dms);
  }

  hildon_desktop_ms_init (dms);

  toplevels = gtk_window_list_toplevels ();

  for (l = toplevels; l; l = l->next)
    gtk_widget_queue_resize (l->data);

  g_list_free (toplevels);
}
コード例 #22
0
// Look for an existing Colormap that known to be associated with visual.
static Colormap
LookupColormapForVisual(const Screen* screen, const Visual* visual)
{
    // common case
    if (visual == DefaultVisualOfScreen(screen))
        return DefaultColormapOfScreen(screen);

#ifdef MOZ_WIDGET_GTK2
    // I wish there were a gdk_x11_display_lookup_screen.
    Display* dpy = DisplayOfScreen(screen);
    GdkDisplay* gdkDpy = gdk_x11_lookup_xdisplay(dpy);
    if (gdkDpy) {
        gint screen_num = 0;
        for (int s = 0; s < ScreenCount(dpy); ++s) {
            if (ScreenOfDisplay(dpy, s) == screen) {
                screen_num = s;
                break;
            }
        }
        GdkScreen* gdkScreen = gdk_display_get_screen(gdkDpy, screen_num);

        GdkColormap* gdkColormap = NULL;
        if (visual ==
            GDK_VISUAL_XVISUAL(gdk_screen_get_rgb_visual(gdkScreen))) {
            // widget/src/gtk2/mozcontainer.c uses gdk_rgb_get_colormap()
            // which is inherited by child widgets, so this is the visual
            // expected when drawing directly to widget surfaces or surfaces
            // created using cairo_surface_create_similar with
            // CAIRO_CONTENT_COLOR.
            // gdk_screen_get_rgb_colormap is the generalization of
            // gdk_rgb_get_colormap for any screen.
            gdkColormap = gdk_screen_get_rgb_colormap(gdkScreen);
        }
        else if (visual ==
             GDK_VISUAL_XVISUAL(gdk_screen_get_rgba_visual(gdkScreen))) {
            // This is the visual expected on displays with the Composite
            // extension enabled when the surface has been created using
            // cairo_surface_create_similar with CAIRO_CONTENT_COLOR_ALPHA,
            // as happens with non-unit opacity.
            gdkColormap = gdk_screen_get_rgba_colormap(gdkScreen);
        }
        if (gdkColormap != NULL)
            return GDK_COLORMAP_XCOLORMAP(gdkColormap);
    }
#endif

    return None;
}
コード例 #23
0
ファイル: grab.c プロジェクト: Pitxyoki/audacious-plugins
gboolean setup_filter()
{
    GdkDisplay *display;
    int screen;

    display = gdk_display_get_default();

    for (screen = 0; screen<gdk_display_get_n_screens(display); screen++)
    {
        gdk_window_add_filter(gdk_screen_get_root_window(gdk_display_get_screen(display, screen)),
                    gdk_filter,
                    NULL);
    }

    return TRUE;
}
コード例 #24
0
XfsmSplashScreen*
xfsm_splash_screen_new (GdkDisplay  *display,
                        const gchar *engine)
{
  XfsmSplashScreen *splash;
  XfsmSplashRc     *splash_rc;
  GdkScreen        *screen;
  gchar             name[128];
  int               monitor;
  XfconfChannel    *channel;

  /* locate monitor with pointer */
  screen = xfce_gdk_screen_get_active (&monitor);

  if (G_UNLIKELY (screen == NULL) || (gdk_screen_get_display (screen) != display))
    {
      screen  = gdk_display_get_screen (display, 0);
      monitor = 0;
    }

  /* initialize the screen struct */
  splash = g_new0 (XfsmSplashScreen, 1);
  splash->engine.display = display;
  splash->engine.primary_screen = screen;
  splash->engine.primary_monitor = monitor;

  /* load and setup the engine */
  if (G_LIKELY (engine != NULL && *engine != '\0'))
    {
      xfsm_splash_screen_load (splash, engine);
      if (G_LIKELY (splash->engine.setup != NULL))
        {
          g_snprintf (name, sizeof(name), "/splash/engines/%s", engine);
          channel = xfconf_channel_new_with_property_base ("xfce4-session",
                                                           name);
          splash_rc = xfsm_splash_rc_new (channel);
          g_object_unref (channel);
          splash->engine.setup (&splash->engine, splash_rc);
          xfsm_splash_rc_free (splash_rc);

          gdk_flush ();
        }
    }

  return splash;
}
コード例 #25
0
static void 
hildon_desktop_ms_init (HildonDesktopMultiscreen *dms)
{
  GdkDisplay *display;
  gint i;

  display = gdk_display_get_default ();
#ifndef ONE_SCREEN_MONITOR
  dms->screens    = gdk_display_get_n_screens (display);
  dms->monitors   = g_new0 (gint, dms->screens);
  dms->geometries = g_new0 (GdkRectangle *, dms->screens);
#else
  dms->screens    = 1;
  dms->monitors   = g_new0(gint,1);
  dms->geometries = g_new0(GdkRectangle *,1);
#endif

#ifndef ONE_SCREEN_MONITOR
  for (i = 0; i < dms->screens; i++)
  {
    GdkScreen *screen;
    gint j;

    screen = gdk_display_get_screen (display, i);

    g_signal_connect_swapped (screen, "size-changed",
                              G_CALLBACK (hildon_desktop_ms_reinit), dms);

    dms->monitors   [i] = gdk_screen_get_n_monitors (screen);
    dms->geometries [i] = g_new0 (GdkRectangle, dms->monitors[i]);

    for (j = 0; j < dms->monitors[i]; j++)
       gdk_screen_get_monitor_geometry (screen, j, &(dms->geometries [i][j]));
  }
#else
  GdkScreen *screen = gdk_display_get_default_screen (display);

  g_signal_connect_swapped (screen, "size-changed",
                            G_CALLBACK (hildon_desktop_ms_reinit), dms);

  dms->monitors[0]   = 1;
  dms->geometries[0] = g_new0 (GdkRectangle,1);
  gdk_screen_get_monitor_geometry (screen, 1, &geometries [0][0]);
#endif
}
コード例 #26
0
ファイル: window-actions.c プロジェクト: Zandoch/gimp
static void
window_actions_display_closed (GdkDisplay      *display,
                               gboolean         is_error,
                               GimpActionGroup *group)
{
    const gchar *group_name;
    gint         n_screens;
    gint         i;

    group_name = gtk_action_group_get_name (GTK_ACTION_GROUP (group));

    n_screens = gdk_display_get_n_screens (display);

    for (i = 0; i < n_screens; i++)
    {
        GdkScreen *screen = gdk_display_get_screen (display, i);
        GtkAction *action;
        gchar     *screen_name;
        gchar     *action_name;

        screen_name = gdk_screen_make_display_name (screen);
        action_name = g_strdup_printf ("%s-move-to-screen-%s",
                                       group_name, screen_name);
        g_free (screen_name);

        action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
                                              action_name);

        if (action)
        {
            GSList *radio_group;

            radio_group = gtk_radio_action_get_group (GTK_RADIO_ACTION (action));
            if (radio_group->data == (gpointer) action)
                radio_group = radio_group->next;

            gtk_action_group_remove_action (GTK_ACTION_GROUP (group), action);

            g_object_set_data (G_OBJECT (group), "change-to-screen-radio-group",
                               radio_group);
        }

        g_free (action_name);
    }
}
コード例 #27
0
ファイル: wallpaper.c プロジェクト: 27Paolo/ubiquity
int main (int argc, char** argv) {
	GdkScreen *screen;
	int monitor;
	int i;
	GError *error = NULL;
	GdkPixbuf *background_pixbuf = NULL;
	GdkRectangle monitor_geometry;
	cairo_t *c;
	cairo_surface_t *surface;
	struct stat st;

	gtk_init (&argc, &argv);

	if (argc != 2 || stat(argv[1], &st) != 0) {
		g_error ("First parameter must be an existing background");
		return 1;
	}
	background_pixbuf = gdk_pixbuf_new_from_file (argv[1], &error);

	if (!background_pixbuf) {
		g_error ("Failed to load background: %s", error->message);
		return 1;
	}
	g_clear_error (&error);
	for (i = 0; i < gdk_display_get_n_screens (gdk_display_get_default ()); i++) {
		screen = gdk_display_get_screen (gdk_display_get_default (), i);
		surface = create_root_surface (screen);
		c = cairo_create (surface);
		for (monitor = 0; monitor < gdk_screen_get_n_monitors (screen); monitor++) {
			gdk_screen_get_monitor_geometry (screen, monitor, &monitor_geometry);
			GdkPixbuf *pixbuf = gdk_pixbuf_scale_simple (background_pixbuf,
				monitor_geometry.width, monitor_geometry.height,
				GDK_INTERP_BILINEAR);
			gdk_cairo_set_source_pixbuf (c, pixbuf, monitor_geometry.x, monitor_geometry.y);
			g_object_unref (pixbuf);
			cairo_paint (c);
		}
		cairo_destroy (c);
		gdk_flush ();
		XClearWindow (GDK_SCREEN_XDISPLAY (screen), RootWindow (GDK_SCREEN_XDISPLAY (screen), i));
	}
	gtk_main ();
	return 0;
}
コード例 #28
0
void
panel_multiscreen_reinit (void)
{
	GdkDisplay *display;
	GList      *toplevels, *l;
	int         new_screens;
	int         i;

	if (monitors)
		g_free (monitors);

	if (geometries) {
		int j;

		for (j = 0; j < screens; j++)
			g_free (geometries[j]);
		g_free (geometries);
	}

	display = gdk_display_get_default ();
	/* Don't use the screens variable since in the future, we might
	 * want to call this function when a screen appears/disappears. */
	new_screens = gdk_display_get_n_screens (display);

	for (i = 0; i < new_screens; i++) {
		GdkScreen *screen;

		screen = gdk_display_get_screen (display, i);
		g_signal_handlers_disconnect_by_func (screen,
						      panel_multiscreen_queue_reinit,
						      NULL);
	}

	initialized = FALSE;
	panel_multiscreen_init ();

	toplevels = gtk_window_list_toplevels ();

	for (l = toplevels; l; l = l->next)
		gtk_widget_queue_resize (l->data);

	g_list_free (toplevels);
}
コード例 #29
0
ファイル: teststatusicon.c プロジェクト: RavetcoFX/gnome-apps
int
main (int argc, char **argv)
{
  GdkDisplay *display;
  guint n_screens, i;

  gtk_init (&argc, &argv);

  display = gdk_display_get_default ();

  n_screens = gdk_display_get_n_screens (display);

  for (i = 0; i < n_screens; i++)
    {
      GtkStatusIcon *icon;

      icon = gtk_status_icon_new ();
      gtk_status_icon_set_screen (icon, gdk_display_get_screen (display, i));
      update_icons ();

      g_signal_connect (icon, "size-changed", G_CALLBACK (size_changed_cb), NULL);
      g_signal_connect (icon, "notify::embedded", G_CALLBACK (embedded_changed_cb), NULL);
      g_signal_connect (icon, "notify::orientation", G_CALLBACK (orientation_changed_cb), NULL);
      g_signal_connect (icon, "notify::screen", G_CALLBACK (screen_changed_cb), NULL);
      g_print ("icon size %d\n", gtk_status_icon_get_size (icon));

      g_signal_connect (icon, "activate",
                        G_CALLBACK (icon_activated), NULL);

      g_signal_connect (icon, "popup-menu",
                        G_CALLBACK (popup_menu), NULL);

      icons = g_slist_append (icons, icon);
 
      update_icons ();

      timeout = gdk_threads_add_timeout (2000, timeout_handler, icon);
    }

  gtk_main ();

  return 0;
}
コード例 #30
0
static void install_keygrab_filters(struct keygrab_data *data)
{
        GdkDisplay *display = gdk_display_get_default();
        int i;

        for (i = 0; i < gdk_display_get_n_screens (display); i++) {
                GdkScreen *screen;
                GdkWindow *root;

                screen = gdk_display_get_screen (display, i);
                if (!screen) {
                        continue;
                }
                root = gdk_screen_get_root_window (screen);
                gdk_window_add_filter(root,
                                      filter_keygrab,
                                      data/*userdata*/);
        }
}