2 *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
4 *Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 *"Software"), to deal in the Software without restriction, including
7 *without limitation the rights to use, copy, modify, merge, publish,
8 *distribute, sublicense, and/or sell copies of the Software, and to
9 *permit persons to whom the Software is furnished to do so, subject to
10 *the following conditions:
12 *The above copyright notice and this permission notice shall be
13 *included in all copies or substantial portions of the Software.
15 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
19 *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20 *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *Except as contained in this notice, the name of the XFree86 Project
24 *shall not be used in advertising or otherwise to promote the sale, use
25 *or other dealings in this Software without prior written authorization
26 *from the XFree86 Project.
28 * Authors: Earle F. Philhower, III
31 #ifdef HAVE_XWIN_CONFIG_H
32 #include <xwin-config.h>
34 #include <X11/Xatom.h>
35 #include "propertyst.h"
36 #include "windowstr.h"
37 #include "winmultiwindowclass.h"
44 DEFINE_ATOM_HELPER(AtmWmWindowRole
, "WM_WINDOW_ROLE")
48 winMultiWindowGetClassHint (WindowPtr pWin
, char **res_name
, char **res_class
)
51 struct _Property
*prop
;
52 int len_name
, len_class
;
54 if (!pWin
|| !res_name
|| !res_class
)
56 ErrorF ("winMultiWindowGetClassHint - pWin, res_name, or res_class was "
61 pwin
= (struct _Window
*) pWin
;
64 prop
= (struct _Property
*) pwin
->optional
->userProps
;
68 *res_name
= *res_class
= NULL
;
72 if (prop
->propertyName
== XA_WM_CLASS
73 && prop
->type
== XA_STRING
77 len_name
= strlen ((char *) prop
->data
);
79 (*res_name
) = malloc (len_name
+ 1);
83 ErrorF ("winMultiWindowGetClassHint - *res_name was NULL\n");
87 /* Add one to len_name to allow copying of trailing 0 */
88 strncpy ((*res_name
), prop
->data
, len_name
+ 1);
90 if (len_name
== prop
->size
)
93 len_class
= strlen (((char *)prop
->data
) + 1 + len_name
);
95 (*res_class
) = malloc (len_class
+ 1);
99 ErrorF ("winMultiWindowGetClassHint - *res_class was NULL\n");
101 /* Free the previously allocated res_name */
106 strcpy ((*res_class
), ((char *)prop
->data
) + 1 + len_name
);
119 winMultiWindowGetWMHints (WindowPtr pWin
, WinXWMHints
*hints
)
121 struct _Window
*pwin
;
122 struct _Property
*prop
;
126 ErrorF ("winMultiWindowGetWMHints - pWin or hints was NULL\n");
130 pwin
= (struct _Window
*) pWin
;
133 prop
= (struct _Property
*) pwin
->optional
->userProps
;
137 memset (hints
, 0, sizeof (WinXWMHints
));
141 if (prop
->propertyName
== XA_WM_HINTS
144 memcpy (hints
, prop
->data
, sizeof (WinXWMHints
));
156 winMultiWindowGetWindowRole (WindowPtr pWin
, char **res_role
)
158 struct _Window
*pwin
;
159 struct _Property
*prop
;
162 if (!pWin
|| !res_role
)
165 pwin
= (struct _Window
*) pWin
;
168 prop
= (struct _Property
*) pwin
->optional
->userProps
;
175 if (prop
->propertyName
== AtmWmWindowRole ()
176 && prop
->type
== XA_STRING
180 len_role
= prop
->size
;
182 (*res_role
) = malloc (len_role
+ 1);
186 ErrorF ("winMultiWindowGetWindowRole - *res_role was NULL\n");
190 strncpy ((*res_role
), prop
->data
, len_role
);
191 (*res_role
)[len_role
] = 0;
204 winMultiWindowGetWMNormalHints (WindowPtr pWin
, WinXSizeHints
*hints
)
206 struct _Window
*pwin
;
207 struct _Property
*prop
;
211 ErrorF ("winMultiWindowGetWMNormalHints - pWin or hints was NULL\n");
215 pwin
= (struct _Window
*) pWin
;
218 prop
= (struct _Property
*) pwin
->optional
->userProps
;
222 memset (hints
, 0, sizeof (WinXSizeHints
));
226 if (prop
->propertyName
== XA_WM_NORMAL_HINTS
229 memcpy (hints
, prop
->data
, sizeof (WinXSizeHints
));
240 winMultiWindowGetTransientFor (WindowPtr pWin
, WindowPtr
*ppDaddy
)
242 struct _Window
*pwin
;
243 struct _Property
*prop
;
247 ErrorF ("winMultiWindowGetTransientFor - pWin was NULL\n");
251 pwin
= (struct _Window
*) pWin
;
254 prop
= (struct _Property
*) pwin
->optional
->userProps
;
263 if (prop
->propertyName
== XA_WM_TRANSIENT_FOR
)
266 memcpy (*ppDaddy
, prop
->data
, sizeof (WindowPtr
));
277 winMultiWindowGetWMName (WindowPtr pWin
, char **wmName
)
279 struct _Window
*pwin
;
280 struct _Property
*prop
;
283 if (!pWin
|| !wmName
)
285 ErrorF ("winMultiWindowGetClassHint - pWin, res_name, or res_class was "
290 pwin
= (struct _Window
*) pWin
;
293 prop
= (struct _Property
*) pwin
->optional
->userProps
;
301 if (prop
->propertyName
== XA_WM_NAME
302 && prop
->type
== XA_STRING
305 len_name
= prop
->size
;
307 (*wmName
) = malloc (len_name
+ 1);
311 ErrorF ("winMultiWindowGetWMName - *wmName was NULL\n");
315 strncpy ((*wmName
), prop
->data
, len_name
);
316 (*wmName
)[len_name
] = 0;