0
|
1 /* Emacs shell widget -- glue.
|
|
2 Copyright (C) 1994, 1995 Sun Microsystems, Inc.
|
|
3
|
|
4 This file is part of XEmacs.
|
|
5
|
|
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
|
|
9 later version.
|
|
10
|
|
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
|
|
14 for more details.
|
|
15
|
|
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. */
|
|
20
|
|
21 /* Synched up with: Not in FSF. */
|
|
22
|
|
23 /* Written by Ben Wing, May, 1994. */
|
|
24
|
|
25 #include <config.h>
|
|
26
|
|
27 #include <stdio.h>
|
|
28 #include <stdlib.h>
|
|
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"
|
|
37
|
|
38 #if 0 /* Not currently used */
|
|
39
|
|
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. */
|
|
51
|
|
52 /* junk stolen from IntrinsicI.h */
|
|
53
|
|
54 extern void _XtAllocError(
|
|
55 #if NeedFunctionPrototypes
|
|
56 String /* alloc_type */
|
|
57 #endif
|
|
58 );
|
|
59
|
|
60 /* junk ungraciously copied from Shell.c */
|
|
61
|
|
62 static void ComputeWMSizeHints(w, hints)
|
|
63 WMShellWidget w;
|
|
64 XSizeHints *hints;
|
|
65 {
|
|
66 long flags;
|
|
67 hints->flags = flags = w->wm.size_hints.flags;
|
|
68 #define copy(field) hints->field = w->wm.size_hints.field
|
|
69 if (flags & (USPosition | PPosition)) {
|
|
70 copy(x);
|
|
71 copy(y);
|
|
72 }
|
|
73 if (flags & (USSize | PSize)) {
|
|
74 copy(width);
|
|
75 copy(height);
|
|
76 }
|
|
77 if (flags & PMinSize) {
|
|
78 copy(min_width);
|
|
79 copy(min_height);
|
|
80 }
|
|
81 if (flags & PMaxSize) {
|
|
82 copy(max_width);
|
|
83 copy(max_height);
|
|
84 }
|
|
85 if (flags & PResizeInc) {
|
|
86 copy(width_inc);
|
|
87 copy(height_inc);
|
|
88 }
|
|
89 if (flags & PAspect) {
|
|
90 copy(min_aspect.x);
|
|
91 copy(min_aspect.y);
|
|
92 copy(max_aspect.x);
|
|
93 copy(max_aspect.y);
|
|
94 }
|
|
95 #undef copy
|
|
96 #define copy(field) hints->field = w->wm.field
|
|
97 if (flags & PBaseSize) {
|
|
98 copy(base_width);
|
|
99 copy(base_height);
|
|
100 }
|
|
101 if (flags & PWinGravity)
|
|
102 copy(win_gravity);
|
|
103 #undef copy
|
|
104 }
|
|
105
|
|
106 static void _SetWMSizeHints(w)
|
|
107 WMShellWidget w;
|
|
108 {
|
|
109 XSizeHints *size_hints = XAllocSizeHints();
|
|
110
|
|
111 if (size_hints == NULL) _XtAllocError("XAllocSizeHints");
|
|
112 ComputeWMSizeHints(w, size_hints);
|
|
113 XSetWMNormalHints(XtDisplay((Widget)w), XtWindow((Widget)w), size_hints);
|
|
114 XFree((char*)size_hints);
|
|
115 }
|
|
116
|
|
117 /* end of junk ungraciously copied from Shell.c */
|
|
118
|
|
119 #endif /* 0 */
|
|
120 #if 0 /* Not currently used */
|
|
121
|
|
122 void
|
|
123 EmacsShellSetSizeUserSpecified (Widget gw)
|
|
124 {
|
|
125 WMShellWidget w = (WMShellWidget) gw;
|
|
126 w->wm.size_hints.flags |= USSize;
|
|
127 w->wm.size_hints.flags &= ~PSize;
|
|
128 if (!w->shell.override_redirect && XtIsRealized (gw))
|
|
129 _SetWMSizeHints (w);
|
|
130 }
|
|
131
|
|
132 void
|
|
133 EmacsShellSetPositionUserSpecified (Widget gw)
|
|
134 {
|
|
135 WMShellWidget w = (WMShellWidget) gw;
|
|
136 w->wm.size_hints.flags |= USPosition;
|
|
137 w->wm.size_hints.flags &= ~PPosition;
|
|
138 if (!w->shell.override_redirect && XtIsRealized (gw))
|
|
139 _SetWMSizeHints (w);
|
|
140 }
|
|
141
|
|
142 #endif /* 0 */
|
|
143
|
|
144 void
|
|
145 EmacsShellSmashIconicHint (Widget shell, int iconic_p)
|
|
146 {
|
|
147 /* See comment in xfns.c about this */
|
|
148 WMShellWidget wmshell;
|
|
149 int old, new;
|
|
150 if (! XtIsSubclass (shell, wmShellWidgetClass)) abort ();
|
|
151 wmshell = (WMShellWidget) shell;
|
|
152 old = (wmshell->wm.wm_hints.flags & StateHint
|
|
153 ? wmshell->wm.wm_hints.initial_state
|
|
154 : NormalState);
|
|
155 new = (iconic_p ? IconicState : NormalState);
|
|
156 wmshell->wm.wm_hints.flags |= StateHint;
|
|
157 wmshell->wm.wm_hints.initial_state = new;
|
|
158 }
|
|
159
|
|
160 void
|
|
161 EmacsShellUpdateSizeHints (Widget gw)
|
|
162 {
|
|
163 if (XtIsSubclass (gw, topLevelEmacsShellWidgetClass))
|
|
164 TopLevelEmacsShellUpdateSizeHints (gw);
|
|
165 #ifdef EXTERNAL_WIDGET
|
|
166 else if (XtIsSubclass (gw, externalShellWidgetClass))
|
|
167 /* do what ??? Don't abort! */;
|
|
168 #endif
|
|
169 else if (XtIsSubclass (gw, transientEmacsShellWidgetClass))
|
|
170 TransientEmacsShellUpdateSizeHints (gw);
|
|
171 else
|
|
172 abort ();
|
|
173 }
|