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

📄 gdkdisplay-x11.c

📁 linux下电话本所依赖的一些图形库
💻 C
📖 第 1 页 / 共 3 页
字号:
/* GDK - The GIMP Drawing Kit * gdkdisplay-x11.c *  * Copyright 2001 Sun Microsystems Inc. * Copyright (C) 2004 Nokia Corporation * * Erwann Chenede <erwann.chenede@sun.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */#include <config.h>#include <stdlib.h>#include <string.h>#include <errno.h>#include <unistd.h>#include <glib.h>#include "gdkx.h"#include "gdkdisplay.h"#include "gdkdisplay-x11.h"#include "gdkscreen.h"#include "gdkscreen-x11.h"#include "gdkinternals.h"#include "gdkinputprivate.h"#include "xsettings-client.h"#include "gdkalias.h"#include <X11/Xatom.h>#ifdef HAVE_XKB#include <X11/XKBlib.h>#endif#ifdef HAVE_XFIXES#include <X11/extensions/Xfixes.h>#endifstatic void                 gdk_display_x11_class_init         (GdkDisplayX11Class *class);static void                 gdk_display_x11_dispose            (GObject            *object);static void                 gdk_display_x11_finalize           (GObject            *object);#ifdef HAVE_X11R6static void gdk_internal_connection_watch (Display  *display,					   XPointer  arg,					   gint      fd,					   gboolean  opening,					   XPointer *watch_data);#endif /* HAVE_X11R6 */static gpointer parent_class = NULL;/* Note that we never *directly* use WM_LOCALE_NAME, WM_PROTOCOLS, * but including them here has the side-effect of getting them * into the internal Xlib cache */static const char *const precache_atoms[] = {  "UTF8_STRING",  "WM_CLIENT_LEADER",  "WM_DELETE_WINDOW",  "WM_LOCALE_NAME",  "WM_PROTOCOLS",  "WM_TAKE_FOCUS",  "_NET_WM_DESKTOP",  "_NET_WM_ICON",  "_NET_WM_ICON_NAME",  "_NET_WM_NAME",  "_NET_WM_PID",  "_NET_WM_PING",  "_NET_WM_STATE",  "_NET_WM_STATE_STICKY",  "_NET_WM_STATE_MAXIMIZED_VERT",  "_NET_WM_STATE_MAXIMIZED_HORZ",  "_NET_WM_STATE_FULLSCREEN",  "_NET_WM_SYNC_REQUEST",  "_NET_WM_SYNC_REQUEST_COUNTER",  "_NET_WM_WINDOW_TYPE",  "_NET_WM_WINDOW_TYPE_NORMAL",  "_NET_WM_USER_TIME",  "_NET_VIRTUAL_ROOTS"};GType_gdk_display_x11_get_type (void){  static GType object_type = 0;  if (!object_type)    {      static const GTypeInfo object_info =	{	  sizeof (GdkDisplayX11Class),	  (GBaseInitFunc) NULL,	  (GBaseFinalizeFunc) NULL,	  (GClassInitFunc) gdk_display_x11_class_init,	  NULL,			/* class_finalize */	  NULL,			/* class_data */	  sizeof (GdkDisplayX11),	  0,			/* n_preallocs */	  (GInstanceInitFunc) NULL,	};            object_type = g_type_register_static (GDK_TYPE_DISPLAY,					    "GdkDisplayX11",					    &object_info, 0);    }    return object_type;}static voidgdk_display_x11_class_init (GdkDisplayX11Class * class){  GObjectClass *object_class = G_OBJECT_CLASS (class);    object_class->dispose = gdk_display_x11_dispose;  object_class->finalize = gdk_display_x11_finalize;    parent_class = g_type_class_peek_parent (class);}/** * gdk_display_open: * @display_name: the name of the display to open * @returns: a #GdkDisplay, or %NULL if the display *  could not be opened. * * Opens a display. * * Since: 2.2 */GdkDisplay *gdk_display_open (const gchar *display_name){  Display *xdisplay;  GdkDisplay *display;  GdkDisplayX11 *display_x11;  GdkWindowAttr attr;  gint argc;  gchar *argv[1];  const char *sm_client_id;    XClassHint *class_hint;  gulong pid;  gint i;#ifdef HAVE_XFIXES  gint ignore;#endif  xdisplay = XOpenDisplay (display_name);  if (!xdisplay)    return NULL;    display = g_object_new (GDK_TYPE_DISPLAY_X11, NULL);  display_x11 = GDK_DISPLAY_X11 (display);  display_x11->use_xshm = TRUE;  display_x11->xdisplay = xdisplay;#ifdef HAVE_X11R6    /* Set up handlers for Xlib internal connections */  XAddConnectionWatch (xdisplay, gdk_internal_connection_watch, NULL);#endif /* HAVE_X11R6 */    /* initialize the display's screens */   display_x11->screens = g_new (GdkScreen *, ScreenCount (display_x11->xdisplay));  for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)    display_x11->screens[i] = _gdk_x11_screen_new (display, i);  /* We need to initialize events after we have the screen   * structures in places   */  for (i = 0; i < ScreenCount (display_x11->xdisplay); i++)    _gdk_x11_events_init_screen (display_x11->screens[i]);    /*set the default screen */  display_x11->default_screen = display_x11->screens[DefaultScreen (display_x11->xdisplay)];  attr.window_type = GDK_WINDOW_TOPLEVEL;  attr.wclass = GDK_INPUT_OUTPUT;  attr.x = 10;  attr.y = 10;  attr.width = 10;  attr.height = 10;  attr.event_mask = 0;  display_x11->leader_gdk_window = gdk_window_new (GDK_SCREEN_X11 (display_x11->default_screen)->root_window, 						   &attr, GDK_WA_X | GDK_WA_Y);  (_gdk_x11_window_get_toplevel (display_x11->leader_gdk_window))->is_leader = TRUE;  display_x11->leader_window = GDK_WINDOW_XID (display_x11->leader_gdk_window);  display_x11->leader_window_title_set = FALSE;  display_x11->have_render = GDK_UNKNOWN;  display_x11->have_render_with_trapezoids = GDK_UNKNOWN;#ifdef HAVE_XFIXES  if (XFixesQueryExtension (display_x11->xdisplay, 			    &display_x11->xfixes_event_base, 			    &ignore))    {      display_x11->have_xfixes = TRUE;      gdk_x11_register_standard_event_type (display,					    display_x11->xfixes_event_base, 					    XFixesNumberEvents);    }  else#endif  display_x11->have_xfixes = FALSE;  if (_gdk_synchronize)    XSynchronize (display_x11->xdisplay, True);    _gdk_x11_precache_atoms (display, precache_atoms, G_N_ELEMENTS (precache_atoms));  class_hint = XAllocClassHint();  class_hint->res_name = g_get_prgname ();    class_hint->res_class = (char *)gdk_get_program_class ();  /* XmbSetWMProperties sets the RESOURCE_NAME environment variable   * from argv[0], so we just synthesize an argument array here.   */  argc = 1;  argv[0] = g_get_prgname ();    XmbSetWMProperties (display_x11->xdisplay,		      display_x11->leader_window,		      NULL, NULL, argv, argc, NULL, NULL,		      class_hint);  XFree (class_hint);  sm_client_id = _gdk_get_sm_client_id ();  if (sm_client_id)    _gdk_windowing_display_set_sm_client_id (display, sm_client_id);  pid = getpid ();  XChangeProperty (display_x11->xdisplay,		   display_x11->leader_window,		   gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_PID"),		   XA_CARDINAL, 32, PropModeReplace, (guchar *) & pid, 1);  /* We don't yet know a valid time. */  display_x11->user_time = 0;  #ifdef HAVE_XKB  {    gint xkb_major = XkbMajorVersion;    gint xkb_minor = XkbMinorVersion;    if (XkbLibraryVersion (&xkb_major, &xkb_minor))      {        xkb_major = XkbMajorVersion;        xkb_minor = XkbMinorVersion;	            if (XkbQueryExtension (display_x11->xdisplay, 			       NULL, &display_x11->xkb_event_type, NULL,                               &xkb_major, &xkb_minor))          {	    Bool detectable_autorepeat_supported;	    	    display_x11->use_xkb = TRUE;            XkbSelectEvents (display_x11->xdisplay,                             XkbUseCoreKbd,                             XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbStateNotifyMask,                             XkbNewKeyboardNotifyMask | XkbMapNotifyMask | XkbStateNotifyMask);	    XkbSetDetectableAutoRepeat (display_x11->xdisplay,					True,					&detectable_autorepeat_supported);	    GDK_NOTE (MISC, g_message ("Detectable autorepeat %s.",				       detectable_autorepeat_supported ? 				       "supported" : "not supported"));	    	    display_x11->have_xkb_autorepeat = detectable_autorepeat_supported;          }      }  }#endif  display_x11->use_sync = FALSE;#ifdef HAVE_XSYNC  {    int major, minor;    int error_base, event_base;        if (XSyncQueryExtension (display_x11->xdisplay,			     &event_base, &error_base) &&        XSyncInitialize (display_x11->xdisplay,                         &major, &minor))      display_x11->use_sync = TRUE;  }#endif    _gdk_windowing_image_init (display);  _gdk_events_init (display);  _gdk_input_init (display);  _gdk_dnd_init (display);  g_signal_emit_by_name (gdk_display_manager_get(),			 "display_opened", display);  return display;}#ifdef HAVE_X11R6/* * XLib internal connection handling */typedef struct _GdkInternalConnection GdkInternalConnection;struct _GdkInternalConnection{  gint	         fd;  GSource	*source;  Display	*display;};static gbooleanprocess_internal_connection (GIOChannel  *gioc,			     GIOCondition cond,			     gpointer     data){  GdkInternalConnection *connection = (GdkInternalConnection *)data;  GDK_THREADS_ENTER ();  XProcessInternalConnection ((Display*)connection->display, connection->fd);  GDK_THREADS_LEAVE ();  return TRUE;}static GdkInternalConnection *gdk_add_connection_handler (Display *display,			    guint    fd){  GIOChannel *io_channel;  GdkInternalConnection *connection;  connection = g_new (GdkInternalConnection, 1);  connection->fd = fd;  connection->display = display;    io_channel = g_io_channel_unix_new (fd);    connection->source = g_io_create_watch (io_channel, G_IO_IN);  g_source_set_callback (connection->source,			 (GSourceFunc)process_internal_connection, connection, NULL);  g_source_attach (connection->source, NULL);    g_io_channel_unref (io_channel);    return connection;}static voidgdk_remove_connection_handler (GdkInternalConnection *connection){  g_source_destroy (connection->source);  g_free (connection);}static voidgdk_internal_connection_watch (Display  *display,			       XPointer  arg,			       gint      fd,			       gboolean  opening,			       XPointer *watch_data){  if (opening)    *watch_data = (XPointer)gdk_add_connection_handler (display, fd);  else    gdk_remove_connection_handler ((GdkInternalConnection *)*watch_data);}#endif /* HAVE_X11R6 *//** * gdk_display_get_name:

⌨️ 快捷键说明

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