~ubuntu-branches/ubuntu/quantal/openmotif/quantal

« back to all changes in this revision

Viewing changes to demos/programs/workspace/client_win.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Bauer
  • Date: 2010-06-23 12:12:31 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100623121231-u89gxdp51sg9wjj2
Tags: 2.3.0-1
* New Maintainer (Closes: #379258) 
* Acknowledge NMU changes
* New upstream release (Closes: #494375)
* Get rid of security patches as they are already part of new upstream
  release (00-xpmvuln.openmotif.patch, 342092-CVE-2005-3964.patch)
* Bump Standards to 3.8.4
* Added {misc:Depends} to make the package lintian cleaner
* Fix weak-library-dev-dependency by adding ${binary:Version}) for the
  -dev Package of openmotif
* Let package depend on autotools-dev to use newer autotools-helper-files
* Work around an autoconf-bug (Gentoo-Bug #1475)
* Added Client-side anti-aliased fonts support via XFT
* Added UTF-8 and UTF8_STRING atom support
* Ability to show text and pixmaps in Label, LabelGadget and all
  derived widgets
* Support of PNG/JPEG image formats in the same way as XPM is supported
* Increase FILE_OFFSET_BITS to 64 to show files >2GB in file-selector
  Idea taken from Magne Oestlyngen (Closes: #288537)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 *  @OPENGROUP_COPYRIGHT@
 
3
 *  COPYRIGHT NOTICE
 
4
 *  Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
 
5
 *  Copyright (c) 1996, 1997, 1998, 1999, 2000 The Open Group
 
6
 *  ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
 
7
 *  the full copyright text.
 
8
 *  
 
9
 *  This software is subject to an open license. It may only be
 
10
 *  used on, with or for operating systems which are themselves open
 
11
 *  source systems. You must contact The Open Group for a license
 
12
 *  allowing distribution and sublicensing of this software on, with,
 
13
 *  or for operating systems which are not Open Source programs.
 
14
 *  
 
15
 *  See http://www.opengroup.org/openmotif/license for full
 
16
 *  details of the license agreement. Any use, reproduction, or
 
17
 *  distribution of the program constitutes recipient's acceptance of
 
18
 *  this agreement.
 
19
 *  
 
20
 *  EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
 
21
 *  PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 
22
 *  KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
 
23
 *  WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
 
24
 *  OR FITNESS FOR A PARTICULAR PURPOSE
 
25
 *  
 
26
 *  EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
 
27
 *  NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT,
 
28
 *  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
29
 *  DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED
 
30
 *  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
31
 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 
32
 *  ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
 
33
 *  EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
 
34
 *  POSSIBILITY OF SUCH DAMAGES.
 
35
*/ 
 
36
/* 
 
37
 * HISTORY
 
38
*/ 
 
39
#ifdef REV_INFO
 
40
#ifndef lint
 
41
static char rcsid[] = "$XConsortium: client_win.c /main/5 1995/07/14 09:47:48 drk $"
 
42
#endif
 
43
#endif
 
44
/* $XConsortium: client_win.c /main/5 1995/07/14 09:47:48 drk $ */
 
45
/*
 
46
 * Edit history
 
47
 * 01/04/92 aja - return the property
 
48
 */
 
49
 
 
50
/* 
 
51
 * Copyright 1989 by the Massachusetts Institute of Technology
 
52
 *
 
53
 * Permission to use, copy, modify, and distribute this software and its
 
54
 * documentation for any purpose and without fee is hereby granted, provided 
 
55
 * that the above copyright notice appear in all copies and that both that 
 
56
 * copyright notice and this permission notice appear in supporting 
 
57
 * documentation, and that the name of M.I.T. not be used in advertising
 
58
 * or publicity pertaining to distribution of the software without specific, 
 
59
 * written prior permission. M.I.T. makes no representations about the 
 
60
 * suitability of this software for any purpose.  It is provided "as is"
 
61
 * without express or implied warranty.
 
62
 *
 
63
 */
 
64
 
 
65
#include <stdio.h>
 
66
#include <X11/Xlib.h>
 
67
#include <X11/Xatom.h>
 
68
 
 
69
static Window TryChildren();
 
70
 
 
71
/* Find a window with WM_STATE, else return win itself, as per ICCCM */
 
72
static Atom WM_STATE = None;
 
73
 
 
74
Window IsClientWindow(dpy, win, retdata)
 
75
        Display *dpy;
 
76
        Window win;
 
77
        unsigned int **retdata;
 
78
{
 
79
        Atom type = None;
 
80
        int format;
 
81
        unsigned long nitems, after;
 
82
        unsigned int    *data;
 
83
        Window inf;
 
84
        /* WM_STATE        *data */
 
85
 
 
86
        *retdata = NULL;
 
87
 
 
88
        if(WM_STATE == None) {
 
89
                WM_STATE = XInternAtom(dpy, "WM_STATE", True);
 
90
        }
 
91
        if (!WM_STATE) return win;
 
92
 
 
93
        XGetWindowProperty(dpy, win, WM_STATE, 0, 2, False, AnyPropertyType,
 
94
                       &type, &format, &nitems, &after, (unsigned char **)&data);
 
95
        if (type) {
 
96
                *retdata = data;
 
97
                return win;
 
98
        }
 
99
        inf = TryChildren(dpy, win, WM_STATE, retdata);
 
100
        if (!inf)
 
101
                inf = win;
 
102
        return inf;
 
103
}
 
104
 
 
105
static Window TryChildren (dpy, win, WM_STATE, retdata)
 
106
        Display *dpy;
 
107
        Window win;
 
108
        Atom WM_STATE;
 
109
        unsigned int **retdata;
 
110
{
 
111
        Window root, parent;
 
112
        Window *children;
 
113
        unsigned int nchildren;
 
114
        unsigned int i;
 
115
        Atom type = None;
 
116
        int format;
 
117
        unsigned long nitems, after;
 
118
        unsigned int *data;
 
119
        Window inf = 0;
 
120
 
 
121
        if (!XQueryTree(dpy, win, &root, &parent, &children, &nchildren))
 
122
                return 0;
 
123
        for (i = 0; !inf && (i < nchildren); i++) {
 
124
                XGetWindowProperty(dpy, children[i], WM_STATE, 0, 2, False,
 
125
                        AnyPropertyType, &type, &format, &nitems,
 
126
                        &after, (unsigned char **)&data);
 
127
                if (type) {
 
128
                        inf = children[i];
 
129
                        *retdata = data;
 
130
                }
 
131
        }
 
132
        for (i = 0; !inf && (i < nchildren); i++)
 
133
                inf = TryChildren(dpy, children[i], WM_STATE, retdata);
 
134
        if (children) XFree((char *)children);
 
135
        return inf;
 
136
}