home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gwm18a.zip / wob.h < prev    next >
C/C++ Source or Header  |  1995-07-03  |  7KB  |  235 lines

  1. /* Copyright 1989 GROUPE BULL -- See license conditions in file COPYRIGHT
  2.  * Copyright 1989 Massachusetts Institute of Technology
  3.  */
  4. /********************************************\
  5. *                          *
  6. *     The GWM Window Object Abstraction    *
  7. *                          *
  8. \********************************************/
  9.  
  10. #ifndef WOB_h
  11. #ifndef INCLUDE_WOOL_H
  12. #include "wool.h"
  13. #endif /* INCLUDE_WOOL_H */
  14. #ifndef WL_NUMBER_H
  15. #include "wl_number.h"
  16. #endif
  17. #ifndef INCLUDE_PIXMAP_H
  18. #include "wl_pixmap.h"
  19. #endif
  20. #define WOB_h
  21.  
  22. typedef PtrToFunc WOB_METHOD;
  23. typedef WOB_METHOD *Methods;
  24.  
  25. /*
  26.  * A wob is an object maintained in a list of all wobs.
  27.  * It is able to open (be created) or destroyed, but its XWindow, the hook
  28.  * will govern its visibility and attributes
  29.  * Its behaviour is given via a finite state machine, fsm.
  30.  */
  31.  
  32. #define WobMacro  Methods type; \
  33.                   int valid; \
  34.           int status;   \
  35.           Window hook;  \
  36.           struct _Wob *parent; \
  37.           struct _Box    box; \
  38.           int curstate; \
  39.               Card32 input_mask; \
  40.           WOOL_OBJECT bordertile; \
  41.           WOOL_OBJECT menu; \
  42.           WOOL_OBJECT fsm; \
  43.           WOOL_OBJECT cursor; \
  44.           WOOL_OBJECT tile; \
  45.           WOOL_OBJECT property;
  46.  
  47.  
  48. #define WobMAGIC 456789
  49. #ifndef USE_STANDARD_MALLOC
  50. #define WobIsValid(w) (((Wob)(w))->valid == WobMAGIC)
  51. #endif
  52.  
  53. /*
  54.  * WobMacro define fields common to all objects
  55.  */
  56.  
  57. #define NOFLAGS            0
  58. #define ClientWindowStatus    (1L << 1)
  59. #define IconStatus        (1L << 2)
  60. #define RootStatus        (1L << 3)
  61. #define MenuStatus        (1L << 4)
  62. #define TopLevelXWindowStatus    (1L << 5)
  63. #define TargetWindowStatus      ClientWindowStatus|IconStatus \
  64.                 |RootStatus
  65.  
  66. typedef struct _Box {        /* the box is there for ANY wob */
  67.     int             x, y;
  68.     unsigned int    width, height;
  69.     unsigned int    borderwidth;
  70.     long            borderpixel;
  71.     long            background;
  72.     Pixmap          shape;
  73. }               *Box;
  74.  
  75. typedef struct _Wob {    /* any wob matches this one */
  76.     WobMacro
  77. }               *Wob;
  78.  
  79. typedef struct _Plug {
  80.     WobMacro
  81.     unsigned int graphic_mask;
  82.     WOOL_OBJECT    graphic;    /* what to draw on the background */
  83. }               *Plug;
  84.  
  85. typedef struct _Bar {
  86.     WobMacro
  87.     short            min_width, max_width;
  88.     short            plug_separator;
  89.     short           elength, ewidth;
  90.     short           shaped;
  91.     short         direction;
  92.     short             nplugs;
  93.     Wob             plugs[1];
  94. }               *Bar;
  95.  
  96. typedef struct _Meter {
  97.     WobMacro
  98.     long    foreground;
  99.     long         font;
  100.     short        horizontal_margin;
  101.     short        vertical_margin;
  102. }               *Meter;
  103.  
  104. typedef struct _CWCachedProperties {     /* common to window & icon */
  105.     WOOL_OBJECT    clientclass;        
  106.     WOOL_OBJECT clientname;
  107.     WOOL_OBJECT machinename;
  108.     WOOL_OBJECT windowname;
  109.     WOOL_OBJECT iconname;
  110.     XWMHints    wm_hints;
  111.     XSizeHints  normal_hints;
  112.     WOOL_OBJECT    transient_for;        /* raw X11 hint */
  113.     WOOL_OBJECT client_group;        /* the logical GWM group */
  114.     int        wm_state;        /* last updated state */
  115.     struct _ClientWindow *user_icon;    /* user-managed icon */
  116.     int        colormap_windows_size;    /* list of sub-windows that must */
  117.     Window     *colormap_windows;    /* have colormap installed */
  118.     int        colormap_windows_index;    /* current selected one */
  119.                     /* standard ICCC protocols */
  120.     unsigned    wm_take_focus : 1;
  121.     unsigned    wm_save_yourself : 1;
  122.     unsigned    wm_delete_window : 1;
  123.     unsigned    new_normal_hints : 1;
  124. }             *CWCachedProperties;    
  125.  
  126. typedef struct _ClientWindow {
  127.     WobMacro
  128.     struct _GWMScreenContext *screen;    /* on which screen is it? */
  129.     Window     client;              /* the inner window */
  130.     Wob        client_wob;        /* if client is made by GWM */
  131.     struct _ClientWindow *window;    /* the client in normal state */
  132.     struct _ClientWindow *icon;        /* the client when iconified */
  133.     struct _ClientWindow *previous;    /* doubly linked list of windows */
  134.     struct _ClientWindow *next;
  135.     short        inner_x, inner_y;    /* dims */
  136.     unsigned short inner_width, inner_height;
  137.     short               inner_borderwidth;
  138.     short               old_inner_borderwidth;
  139.     Bar        titlebar;        /* the 4 bars */
  140.     Bar        leftbar;
  141.     Bar        rightbar;
  142.     Bar        basebar;
  143.     WOOL_OBJECT opening;        /* NULL after first map */
  144.     WOOL_OBJECT closing;        /* evaluated on destruction */
  145.     WOOL_OBJECT grabs;            /* on whole frame */
  146.     WOOL_OBJECT icon_plug;        /* for icons only */
  147.     WOOL_OBJECT icon_description;    /* wool code to build the icon */
  148.     CWCachedProperties cached_props;    /* X properties cached in common */
  149.     Colormap    colormap;        /* colormap for main window */
  150.     unsigned    mapped : 1;        /* flag if window is mapped */
  151.     unsigned    client_shaped : 1;     /* is client non-rectangular? */
  152.     unsigned    map_on_raise : 1;    /* should we de-iconify when raised? */
  153.     unsigned    ignore_take_focus : 1;    /* ignore the WM_TAKE_FOCUS protocol */
  154.  
  155. }               *ClientWindow;
  156.  
  157. typedef struct _Menu {
  158.     WobMacro
  159.     struct _GWMScreenContext *screen;    /* on which screen is it? */
  160.     short        min_width, max_width;
  161.     short        bar_separator;
  162.     short        direction;
  163.     short        nbars;
  164.     Bar        bars[1];
  165. }               *Menu;
  166.  
  167. #define MENU_unmapped    0
  168. #define MENU_placed    1
  169. #define MENU_popped    2
  170.  
  171. /* screen description */
  172.  
  173. typedef struct _GWMScreenContext {    /* All screen-dependent data */
  174.     int            screen;        /* screen number */
  175.     Screen       *x_screen;        /* X structure */
  176.     Window          root;        /* root window */
  177.     ClientWindow    rootWob;        /* and its associated wob */
  178.     int            WindowCount;    /* number of managed windows */
  179.     Window          GwmWindow;            /* window used to set properties on */
  180.     struct {
  181.             long Back;    /* Background */
  182.             long Fore;    /* Foreground */
  183.             long Border;    /* BorderPixel of windows */
  184.             long GridColor;    /* Context -> pixel.GridColor */
  185.             long InvertColor; /* for wob-invert */
  186.     }            pixel;        /* screen-dependent colors */
  187.     struct {
  188.                 GC Work;
  189.                 GC Tile;
  190.                 GC Set;
  191.                 GC Draw;
  192.                 GC Invert;
  193.                 GC Back;
  194.                 GC Bitmap;
  195.     }             gc;            /* the GC for the screen */
  196.     int            width, height, depth;    /* dims in pixels */
  197.     int            widthMM, heightMM;        /* dims in millimeters */
  198.     ClientWindow    InstalledColormapCW;    /* window of inst. colormap */
  199.     Pixmap        DefaultBitmap;
  200.     struct {
  201.             Window window;        /* meter X window */
  202.             short  x,y;
  203.             unsigned short width, height;
  204.             unsigned short borderwidth;
  205.             long borderpixel;
  206.             short anchor_x, anchor_y; /* gravity and anchor */
  207.             short gravity;
  208.             GC  gc;
  209.             int  font;        /* meter appearance */
  210.             char *string;
  211.             short string_length;
  212.             short string_x, string_y;
  213.             long background;    
  214.             long foreground;
  215.             short  horizontal_margin;
  216.             short  vertical_margin;
  217.     }            meter;
  218. }               *GWMScreenContext;
  219.  
  220. /*
  221.  * methods generic to wobs
  222.  */
  223.  
  224. extern int WobEval(), WobPrint(), WobRelease(), WobExecute(), WobSet(),
  225.        WobGetCValue(), WobOpen(), WobClose(), WobEventHandler(), 
  226.        WobActionRoutine(), WobGetDimensions();
  227.  
  228. extern WOB_METHOD       ClientWindowClass[],
  229.             MenuClass[],
  230.             BarClass[],
  231.             PlugClass[],
  232.             ScreenClass[];
  233.      
  234. #endif /* WOB_h */
  235.