1 /* Emacs shell widget -- glue.
2 Copyright (C) 1994, 1995 Sun Microsystems, Inc.
4 This file is part of XEmacs.
6 XEmacs is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with XEmacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* Synched up with: Not in FSF. */
23 /* Written by Ben Wing, May, 1994. */
29 #include <X11/StringDefs.h>
30 #include "xintrinsicp.h"
31 #include <X11/Shell.h>
32 #include <X11/ShellP.h>
33 #include <X11/Vendor.h>
34 #include <X11/VendorP.h>
35 #include "EmacsShell.h"
36 #include "ExternalShell.h"
38 #if 0 /* Not currently used */
40 /* The root_geometry_manager() method in Shell.c is fucked up with regard
41 to the user-specified-position vs. program-specified-position and
42 user-specified-size vs. program-specified-size flag. (It always
43 sets program-specified whenever the program requests a change
44 in its size or position, even when this came from direct user
45 request.) So we provide external entry points to fix this after
46 the program requested a size or position change. If it turns
47 out that the user-specified-position flag needs to be set at the
48 *same* time that the geometry change request is made, then we
49 will have to duplicate the entire root_geometry_manager() method;
50 but I don't think there are any WM's that require this. */
52 /* junk stolen from IntrinsicI.h */
54 extern void _XtAllocError( String /* alloc_type */);
56 /* junk ungraciously copied from Shell.c */
58 static void ComputeWMSizeHints(w, hints)
63 hints->flags = flags = w->wm.size_hints.flags;
64 #define copy(field) hints->field = w->wm.size_hints.field
65 if (flags & (USPosition | PPosition)) {
69 if (flags & (USSize | PSize)) {
73 if (flags & PMinSize) {
77 if (flags & PMaxSize) {
81 if (flags & PResizeInc) {
85 if (flags & PAspect) {
92 #define copy(field) hints->field = w->wm.field
93 if (flags & PBaseSize) {
97 if (flags & PWinGravity)
102 static void _SetWMSizeHints(w)
105 XSizeHints *size_hints = XAllocSizeHints();
107 if (size_hints == NULL) _XtAllocError("XAllocSizeHints");
108 ComputeWMSizeHints(w, size_hints);
109 XSetWMNormalHints(XtDisplay((Widget)w), XtWindow((Widget)w), size_hints);
110 XFree((char*)size_hints);
113 /* end of junk ungraciously copied from Shell.c */
116 #if 0 /* Not currently used */
119 EmacsShellSetSizeUserSpecified (Widget gw)
121 WMShellWidget w = (WMShellWidget) gw;
122 w->wm.size_hints.flags |= USSize;
123 w->wm.size_hints.flags &= ~PSize;
124 if (!w->shell.override_redirect && XtIsRealized (gw))
129 EmacsShellSetPositionUserSpecified (Widget gw)
131 WMShellWidget w = (WMShellWidget) gw;
132 w->wm.size_hints.flags |= USPosition;
133 w->wm.size_hints.flags &= ~PPosition;
134 if (!w->shell.override_redirect && XtIsRealized (gw))
141 EmacsShellSmashIconicHint (Widget shell, int iconic_p)
143 /* See comment in xfns.c about this */
144 WMShellWidget wmshell;
146 if (! XtIsSubclass (shell, wmShellWidgetClass)) abort ();
147 wmshell = (WMShellWidget) shell;
148 old = (wmshell->wm.wm_hints.flags & StateHint
149 ? wmshell->wm.wm_hints.initial_state
151 new = (iconic_p ? IconicState : NormalState);
152 wmshell->wm.wm_hints.flags |= StateHint;
153 wmshell->wm.wm_hints.initial_state = new;
157 EmacsShellUpdateSizeHints (Widget gw)
159 if (XtIsSubclass (gw, topLevelEmacsShellWidgetClass))
160 TopLevelEmacsShellUpdateSizeHints (gw);
161 #ifdef EXTERNAL_WIDGET
162 else if (XtIsSubclass (gw, externalShellWidgetClass))
163 /* do what ??? Don't abort! */;
165 else if (XtIsSubclass (gw, transientEmacsShellWidgetClass))
166 TransientEmacsShellUpdateSizeHints (gw);