Back to index

indicator-appmenu  12.10.0
gdk-get-func.c
Go to the documentation of this file.
00001 /* GDK - The GIMP Drawing Kit
00002  * Copyright (C) 1995-2007 Peter Mattis, Spencer Kimball,
00003  * Josh MacDonald, Ryan Lortie
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the
00017  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018  * Boston, MA 02111-1307, USA.
00019  */
00020 
00021 /*
00022  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
00023  * file for a list of people on the GTK+ Team.  See the ChangeLog
00024  * files for a list of changes.  These files are distributed with
00025  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
00026  */
00027 
00028 #include "config.h"
00029 
00030 #include <X11/Xlib.h>
00031 #include <X11/Xutil.h>
00032 #include <X11/Xatom.h>
00033 /*
00034 #ifdef HAVE_XKB
00035 #include <X11/XKBlib.h>
00036 #endif
00037 
00038 #include <netinet/in.h>
00039 #include <unistd.h>
00040 */
00041 #include <gdk/gdk.h>
00042 #include <gdk/gdkx.h>
00043 
00044 #include "MwmUtil.h"
00045 /*
00046 #include "gdkwindowimpl.h"
00047 #include "gdkasync.h"
00048 #include "gdkinputprivate.h"
00049 #include "gdkdisplay-x11.h"
00050 #include "gdkprivate-x11.h"
00051 #include "gdkregion.h"
00052 #include "gdkinternals.h"
00053 #include "gdkwindow-x11.h"
00054 #include "gdkalias.h"
00055 
00056 #include <stdlib.h>
00057 #include <stdio.h>
00058 #include <string.h>
00059 
00060 
00061 #include <X11/extensions/shape.h>
00062 
00063 #ifdef HAVE_XCOMPOSITE
00064 #include <X11/extensions/Xcomposite.h>
00065 #endif
00066 
00067 #ifdef HAVE_XFIXES
00068 #include <X11/extensions/Xfixes.h>
00069 #endif
00070 
00071 #ifdef HAVE_XDAMAGE
00072 #include <X11/extensions/Xdamage.h>
00073 #endif
00074 */
00075 
00076 #define WINDOW_IS_TOPLEVEL_OR_FOREIGN(window) \
00077   (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD &&   \
00078      GDK_WINDOW_TYPE (window) != GDK_WINDOW_OFFSCREEN)
00079 
00080 static MotifWmHints *
00081 gdk_xid_get_mwm_hints (Window window)
00082 {
00083   GdkDisplay *display;
00084   Atom hints_atom = None;
00085   guchar *data = NULL;
00086   Atom type;
00087   gint format;
00088   gulong nitems;
00089   gulong bytes_after;
00090   int ret = 0;
00091   
00092   display = gdk_display_get_default ();
00093   
00094   hints_atom = gdk_x11_get_xatom_by_name_for_display (display, _XA_MOTIF_WM_HINTS);
00095 
00096   gdk_error_trap_push ();
00097   XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), window,
00098                     hints_atom, 0, sizeof (MotifWmHints)/sizeof (long),
00099                     False, AnyPropertyType, &type, &format, &nitems,
00100                     &bytes_after, &data);
00101   gdk_flush ();
00102   if ((ret = gdk_error_trap_pop ()))
00103     {
00104       g_warning ("%s: Unable to get hints for %u: Error Code: %d", G_STRFUNC, (guint32)window, ret);
00105       return NULL;
00106     }
00107 
00108   if (type == None)
00109     return NULL;
00110   
00111   return (MotifWmHints *)data;
00112 }
00113 
00122 gboolean
00123 egg_xid_get_functions (Window window,
00124                        GdkWMFunction *functions)
00125 {
00126   MotifWmHints *hints;
00127   gboolean result = FALSE;
00128 
00129   hints = gdk_xid_get_mwm_hints (window);
00130   
00131   if (hints)
00132     {
00133       if (hints->flags & MWM_HINTS_FUNCTIONS)
00134         {
00135           if (functions)
00136             *functions = hints->functions;
00137           result = TRUE;
00138         }
00139       
00140       XFree (hints);
00141     }
00142 
00143   return result;
00144 }