home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.004 / xemacs-1 / xemacs-19.13 / src / EmacsShell.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-07  |  4.5 KB  |  168 lines

  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 the Free
  18. Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. /* Synched up with: Not in FSF. */
  21.  
  22. /* Written by Ben Wing, May, 1994. */
  23.  
  24. #include <config.h>
  25.  
  26. #include <stdio.h>
  27. #include <stdlib.h>
  28. #include <X11/StringDefs.h>
  29. #include "xintrinsicp.h"
  30. #include <X11/Shell.h>
  31. #include <X11/ShellP.h>
  32. #include <X11/Vendor.h>
  33. #include <X11/VendorP.h>
  34. #include "EmacsShell.h"
  35.  
  36. #if 0 /* Not currently used */
  37.  
  38. /* The root_geometry_manager() method in Shell.c is fucked up with regard
  39.    to the user-specified-position vs. program-specified-position and
  40.    user-specified-size vs. program-specified-size flag. (It always
  41.    sets program-specified whenever the program requests a change
  42.    in its size or position, even when this came from direct user
  43.    request.) So we provide external entry points to fix this after
  44.    the program requested a size or position change.  If it turns
  45.    out that the user-specified-position flag needs to be set at the
  46.    *same* time that the geometry change request is made, then we
  47.    will have to duplicate the entire root_geometry_manager() method;
  48.    but I don't think there are any WM's that require this. */
  49.  
  50. /* junk stolen from IntrinsicI.h */
  51.  
  52. extern void _XtAllocError(
  53. #if NeedFunctionPrototypes
  54.     String    /* alloc_type */
  55. #endif
  56. );
  57.  
  58. /* junk ungraciously copied from Shell.c */
  59.  
  60. static void ComputeWMSizeHints(w, hints)
  61.     WMShellWidget w;
  62.     XSizeHints *hints;
  63. {
  64.     long flags;
  65.     hints->flags = flags = w->wm.size_hints.flags;
  66. #define copy(field) hints->field = w->wm.size_hints.field
  67.     if (flags & (USPosition | PPosition)) {
  68.     copy(x);
  69.     copy(y);
  70.     }
  71.     if (flags & (USSize | PSize)) {
  72.     copy(width);
  73.     copy(height);
  74.     }
  75.     if (flags & PMinSize) {
  76.     copy(min_width);
  77.     copy(min_height);
  78.     }
  79.     if (flags & PMaxSize) {
  80.     copy(max_width);
  81.     copy(max_height);
  82.     }
  83.     if (flags & PResizeInc) {
  84.     copy(width_inc);
  85.     copy(height_inc);
  86.     }
  87.     if (flags & PAspect) {
  88.     copy(min_aspect.x);
  89.     copy(min_aspect.y);
  90.     copy(max_aspect.x);
  91.     copy(max_aspect.y);
  92.     }
  93. #undef copy
  94. #define copy(field) hints->field = w->wm.field
  95.     if (flags & PBaseSize) {
  96.     copy(base_width);
  97.     copy(base_height);
  98.     }
  99.     if (flags & PWinGravity)
  100.     copy(win_gravity);
  101. #undef copy
  102. }
  103.  
  104. static void _SetWMSizeHints(w)
  105.     WMShellWidget w;
  106. {
  107.     XSizeHints *size_hints = XAllocSizeHints();
  108.  
  109.     if (size_hints == NULL) _XtAllocError("XAllocSizeHints");
  110.     ComputeWMSizeHints(w, size_hints);
  111.     XSetWMNormalHints(XtDisplay((Widget)w), XtWindow((Widget)w), size_hints);
  112.     XFree((char*)size_hints);
  113. }
  114.  
  115. /* end of junk ungraciously copied from Shell.c */
  116.  
  117. #endif /* 0 */
  118. #if 0 /* Not currently used */
  119.  
  120. void
  121. EmacsShellSetSizeUserSpecified (Widget gw)
  122. {
  123.   WMShellWidget w = (WMShellWidget) gw;
  124.   w->wm.size_hints.flags |= USSize;
  125.   w->wm.size_hints.flags &= ~PSize;
  126.   if (!w->shell.override_redirect && XtIsRealized (gw))
  127.     _SetWMSizeHints (w);
  128. }
  129.  
  130. void
  131. EmacsShellSetPositionUserSpecified (Widget gw)
  132. {
  133.   WMShellWidget w = (WMShellWidget) gw;
  134.   w->wm.size_hints.flags |= USPosition;
  135.   w->wm.size_hints.flags &= ~PPosition;
  136.   if (!w->shell.override_redirect && XtIsRealized (gw))
  137.     _SetWMSizeHints (w);
  138. }
  139.  
  140. #endif /* 0 */
  141.  
  142. void
  143. EmacsShellSmashIconicHint (Widget shell, int iconic_p)
  144. {
  145.   /* See comment in xfns.c about this */
  146.   WMShellWidget wmshell;
  147.   int old, new;
  148.   if (! XtIsSubclass (shell, wmShellWidgetClass)) abort ();
  149.   wmshell = (WMShellWidget) shell;
  150.   old = (wmshell->wm.wm_hints.flags & StateHint
  151.      ? wmshell->wm.wm_hints.initial_state
  152.      : NormalState);
  153.   new = (iconic_p ? IconicState : NormalState);
  154.   wmshell->wm.wm_hints.flags |= StateHint;
  155.   wmshell->wm.wm_hints.initial_state = new;
  156. }
  157.  
  158. void
  159. EmacsShellUpdateSizeHints (Widget gw)
  160. {
  161.   if (XtIsSubclass (gw, topLevelEmacsShellWidgetClass))
  162.     TopLevelEmacsShellUpdateSizeHints (gw);
  163.   else if (XtIsSubclass (gw, transientEmacsShellWidgetClass))
  164.     TransientEmacsShellUpdateSizeHints (gw);
  165.   else
  166.     abort ();
  167. }
  168.