⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdkdisplay-x11.c

📁 linux下电话本所依赖的一些图形库
💻 C
📖 第 1 页 / 共 3 页
字号:
				      Window      xrootwin){  gint n_screens, i;  n_screens = gdk_display_get_n_screens (display);  for (i = 0; i < n_screens; i++)    {      GdkScreen *screen = gdk_display_get_screen (display, i);      if (GDK_SCREEN_XROOTWIN (screen) == xrootwin)	return screen;    }  return NULL;}/** * gdk_x11_display_get_xdisplay: * @display: a #GdkDisplay * @returns: an X display. * * Returns the X display of a #GdkDisplay. * * Since: 2.2 */Display *gdk_x11_display_get_xdisplay (GdkDisplay  *display){  return GDK_DISPLAY_X11 (display)->xdisplay;}void_gdk_windowing_set_default_display (GdkDisplay *display){  GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);  const gchar *startup_id;    if (display)    gdk_display = GDK_DISPLAY_XDISPLAY (display);  else    gdk_display = NULL;  g_free (display_x11->startup_notification_id);  display_x11->startup_notification_id = NULL;    startup_id = g_getenv ("DESKTOP_STARTUP_ID");  if (startup_id && *startup_id != '\0')    {      gchar *time_str;      if (!g_utf8_validate (startup_id, -1, NULL))	g_warning ("DESKTOP_STARTUP_ID contains invalid UTF-8");      else	display_x11->startup_notification_id = g_strdup (startup_id);      /* Find the launch time from the startup_id, if it's there.  Newer spec       * states that the startup_id is of the form <unique>_TIME<timestamp>       */      time_str = g_strrstr (startup_id, "_TIME");      if (time_str != NULL)        {	  gulong retval;          gchar *end;          errno = 0;          /* Skip past the "_TIME" part */          time_str += 5;          retval = strtoul (time_str, &end, 0);          if (end != time_str && errno == 0)            display_x11->user_time = retval;        }            /* Clear the environment variable so it won't be inherited by       * child processes and confuse things.         */      g_unsetenv ("DESKTOP_STARTUP_ID");      /* Set the startup id on the leader window so it       * applies to all windows we create on this display       */      XChangeProperty (display_x11->xdisplay,		       display_x11->leader_window,		       gdk_x11_get_xatom_by_name_for_display (display, "_NET_STARTUP_ID"),		       gdk_x11_get_xatom_by_name_for_display (display, "UTF8_STRING"), 8,		       PropModeReplace,		       startup_id, strlen (startup_id));    }}static char*escape_for_xmessage (const char *str){  GString *retval;  const char *p;    retval = g_string_new (NULL);  p = str;  while (*p)    {      switch (*p)        {        case ' ':        case '"':        case '\\':          g_string_append_c (retval, '\\');          break;        }      g_string_append_c (retval, *p);      ++p;    }  return g_string_free (retval, FALSE);}static voidbroadcast_xmessage   (GdkDisplay   *display,                      const char   *message_type,                      const char   *message_type_begin,                      const char   *message){  Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);  GdkScreen *screen = gdk_display_get_default_screen (display);  GdkWindow *root_window = gdk_screen_get_root_window (screen);  Window xroot_window = GDK_WINDOW_XID (root_window);    Atom type_atom;  Atom type_atom_begin;  Window xwindow;  {    XSetWindowAttributes attrs;    attrs.override_redirect = True;    attrs.event_mask = PropertyChangeMask | StructureNotifyMask;    xwindow =      XCreateWindow (xdisplay,                     xroot_window,                     -100, -100, 1, 1,                     0,                     CopyFromParent,                     CopyFromParent,                     (Visual *)CopyFromParent,                     CWOverrideRedirect | CWEventMask,                     &attrs);  }  type_atom = gdk_x11_get_xatom_by_name_for_display (display,                                                     message_type);  type_atom_begin = gdk_x11_get_xatom_by_name_for_display (display,                                                           message_type_begin);    {    XEvent xevent;    const char *src;    const char *src_end;    char *dest;    char *dest_end;        xevent.xclient.type = ClientMessage;    xevent.xclient.message_type = type_atom_begin;    xevent.xclient.display =xdisplay;    xevent.xclient.window = xwindow;    xevent.xclient.format = 8;    src = message;    src_end = message + strlen (message) + 1; /* +1 to include nul byte */        while (src != src_end)      {        dest = &xevent.xclient.data.b[0];        dest_end = dest + 20;                        while (dest != dest_end &&               src != src_end)          {            *dest = *src;            ++dest;            ++src;          }	while (dest != dest_end)	  {	    *dest = 0;	    ++dest;	  }                XSendEvent (xdisplay,                    xroot_window,                    False,                    PropertyChangeMask,                    &xevent);        xevent.xclient.message_type = type_atom;      }  }  XDestroyWindow (xdisplay, xwindow);  XFlush (xdisplay);}/** * gdk_notify_startup_complete: *  * Indicates to the GUI environment that the application has finished * loading. If the applications opens windows, this function is * normally called after opening the application's initial set of * windows. *  * GTK+ will call this function automatically after opening the first * #GtkWindow unless gtk_window_set_auto_startup_notification() is called  * to disable that feature. * * Since: 2.2 **/voidgdk_notify_startup_complete (void){  GdkDisplay *display;  GdkDisplayX11 *display_x11;  gchar *escaped_id;  gchar *message;  display = gdk_display_get_default ();  if (!display)    return;    display_x11 = GDK_DISPLAY_X11 (display);  if (display_x11->startup_notification_id == NULL)    return;  escaped_id = escape_for_xmessage (display_x11->startup_notification_id);  message = g_strdup_printf ("remove: ID=%s", escaped_id);  g_free (escaped_id);  broadcast_xmessage (display,		      "_NET_STARTUP_INFO",                      "_NET_STARTUP_INFO_BEGIN",                      message);  g_free (message);}/** * gdk_display_supports_selection_notification: * @display: a #GdkDisplay *  * Returns whether #GdkEventOwnerChange events will be  * sent when the owner of a selection changes. *  * Return value: whether #GdkEventOwnerChange events will  *               be sent. * * Since: 2.6 **/gboolean gdk_display_supports_selection_notification (GdkDisplay *display){  GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);  return display_x11->have_xfixes;}/** * gdk_display_request_selection_notification: * @display: a #GdkDisplay * @selection: the #GdkAtom naming the selection for which *             ownership change notification is requested *  * Request #GdkEventOwnerChange events for ownership changes * of the selection named by the given atom. *  * Return value: whether #GdkEventOwnerChange events will  *               be sent. * * Since: 2.6 **/gboolean gdk_display_request_selection_notification  (GdkDisplay *display,						      GdkAtom     selection){#ifdef HAVE_XFIXES  GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);  Atom atom;  if (display_x11->have_xfixes)    {      atom = gdk_x11_atom_to_xatom_for_display (display, 						selection);      XFixesSelectSelectionInput (display_x11->xdisplay, 				  display_x11->leader_window,				  atom,				  XFixesSetSelectionOwnerNotifyMask |				  XFixesSelectionWindowDestroyNotifyMask |				  XFixesSelectionClientCloseNotifyMask);      return TRUE;    }  else#endif    return FALSE;}/** * gdk_display_supports_clipboard_persistence * @display: a #GdkDisplay * * Returns whether the speicifed display supports clipboard * persistance; i.e. if it's possible to store the clipboard data after an * application has quit. On X11 this checks if a clipboard daemon is * running. * * Returns: %TRUE if the display supports clipboard persistance. * * Since: 2.6 */gbooleangdk_display_supports_clipboard_persistence (GdkDisplay *display){  /* It might make sense to cache this */  return XGetSelectionOwner (GDK_DISPLAY_X11 (display)->xdisplay,			     gdk_x11_get_xatom_by_name_for_display (display, "CLIPBOARD_MANAGER")) != None;}/** * gdk_display_store_clipboard * @display:          a #GdkDisplay * @clipboard_window: a #GdkWindow belonging to the clipboard owner * @time_:            a timestamp * @targets:	      an array of targets that should be saved, or %NULL  *                    if all available targets should be saved. * @n_targets:        length of the @targets array * * Issues a request to the clipboard manager to store the * clipboard data. On X11, this is a special program that works * according to the freedesktop clipboard specification, available at * <ulink url="http://www.freedesktop.org/Standards/clipboard-manager-spec"> * http://www.freedesktop.org/Standards/clipboard-manager-spec</ulink>. * * Since: 2.6 */voidgdk_display_store_clipboard (GdkDisplay *display,			     GdkWindow  *clipboard_window,			     guint32     time_,			     GdkAtom    *targets,			     gint        n_targets){  GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);  Atom clipboard_manager, save_targets;    clipboard_manager = gdk_x11_get_xatom_by_name_for_display (display, "CLIPBOARD_MANAGER");  save_targets = gdk_x11_get_xatom_by_name_for_display (display, "SAVE_TARGETS");  gdk_error_trap_push ();  if (XGetSelectionOwner (display_x11->xdisplay, clipboard_manager) != None)    {      Atom property_name = None;      Atom *xatoms;      int i;            if (n_targets > 0)	{	  property_name = gdk_x11_atom_to_xatom_for_display (display, _gdk_selection_property);	  xatoms = g_new (Atom, n_targets);	  for (i = 0; i < n_targets; i++)	    xatoms[i] = gdk_x11_atom_to_xatom_for_display (display, targets[i]);	  XChangeProperty (display_x11->xdisplay, GDK_WINDOW_XID (clipboard_window),			   property_name, XA_ATOM,			   32, PropModeReplace, (guchar *)xatoms, n_targets);	  g_free (xatoms);	}            XConvertSelection (display_x11->xdisplay,			 clipboard_manager, save_targets, property_name,			 GDK_WINDOW_XID (clipboard_window), time_);          }  gdk_error_trap_pop ();}guint32gdk_x11_display_get_user_time_libgtk_only (GdkDisplay *display){  return GDK_DISPLAY_X11 (display)->user_time;}#define __GDK_DISPLAY_X11_C__#include "gdkaliasdef.c"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -