home *** CD-ROM | disk | FTP | other *** search
/ PC Shareware 1999 March / PCShareware-3-99.iso / IMPLE / DJGPP.RAR / DJGPP2 / XLIB-SR0.ZIP / SRC / XLIBEMU / RECONFW.C < prev    next >
C/C++ Source or Header  |  1994-02-20  |  6KB  |  225 lines

  1. /* $Id: reconfw.c 1.2 1994/02/20 19:53:38 ulrich Exp $ */
  2. /*
  3.  * X library function XConfigureWindow.
  4.  */
  5. #include "Xlibemu.h"
  6.  
  7. int
  8. XConfigureWindow (Display*        dpy,
  9.           Window        w,
  10.           unsigned int        value_mask,
  11.           XWindowChanges*    values)         
  12. {
  13.   int mapped;
  14.   int i, x, y, width, height, border_width;
  15.   XEvent xe;
  16.   Window sibling, window;
  17.  
  18.   if (0 == _WCheckWindow (dpy, w, X_ConfigureWindow))
  19.     return 0;
  20.   i = ConnectionNumber(dpy);
  21.  
  22.   if (w->override_redirect == False
  23.       && w->parent != None
  24.       && 0 != (w->parent->event_mask & SubstructureRedirectMask)
  25.       && 0 == (w->parent->event_masks[i] & SubstructureRedirectMask)) {
  26.     xe.xconfigurerequest.type = ConfigureRequest;
  27.     xe.xconfigurerequest.send_event = False;
  28.     xe.xconfigurerequest.parent = w->parent;
  29.     xe.xconfigurerequest.window = w;
  30.     xe.xconfigurerequest.x = (value_mask & CWX) ? values->x : w->x;
  31.     xe.xconfigurerequest.y = (value_mask & CWY) ? values->y : w->y;
  32.     xe.xconfigurerequest.width = (value_mask & CWWidth) ? values->width : w->width;
  33.     xe.xconfigurerequest.height = (value_mask & CWHeight) ? values->height : w->height;
  34.     xe.xconfigurerequest.border_width = 
  35.       (value_mask & CWBorderWidth) ? values->border_width : w->border_width;
  36.     xe.xconfigurerequest.above = (value_mask & CWSibling) ? Above : None;
  37.     xe.xconfigurerequest.detail = (value_mask & CWStackMode) ? values->stack_mode : 0;
  38.     xe.xconfigurerequest.value_mask = value_mask;
  39.     if (_WRedirectEvent (dpy, &xe))
  40.       return 0;
  41.   }
  42.   /*
  43.    * Note: Xlib manual says override-redirect flag has no effect on
  44.    * ResizeRedirectMask.
  45.    */
  46.   if (0 != (w->event_mask & ResizeRedirectMask)
  47.       && 0 == (w->event_masks[i] & ResizeRedirectMask)
  48.       && 0 != (value_mask & (CWWidth | CWHeight))) {
  49.     xe.xresizerequest.type = ResizeRequest;
  50.     xe.xresizerequest.send_event = False;
  51.     xe.xresizerequest.window = w;
  52.     xe.xresizerequest.width =
  53.       (value_mask & CWWidth) ? values->width : w->width;
  54.     xe.xresizerequest.height =
  55.       (value_mask & CWHeight) ? values->height : w->height;
  56.     _WRedirectEvent (dpy, &xe);
  57.     /*
  58.      * Note: Xlib manual says: Use current width and height.
  59.      */
  60.     value_mask &= ~(CWWidth & CWHeight);
  61.   }
  62.  
  63.   mapped = w->mapped;
  64.  
  65.   /* Initiailize defaults */
  66.   x = w->x;
  67.   y = w->y;
  68.   width = w->width;
  69.   height = w->height;
  70.   border_width = w->border_width;
  71.  
  72.   /* Check values */
  73.   if (value_mask & CWX) {
  74.     if (x != values->x)
  75.       x = values->x;
  76.     else
  77.       value_mask &= ~CWX;
  78.   }
  79.   if (value_mask & CWY) {
  80.     if (y != values->y)
  81.       y = values->y;
  82.     else
  83.       value_mask &= ~CWY;
  84.   }
  85.   if (value_mask & CWWidth) {
  86.     if (width != values->width)
  87.       width = values->width;
  88.     else
  89.       value_mask &= ~CWWidth;
  90.   }
  91.   if (value_mask & CWHeight) {
  92.     if (height != values->height)
  93.       height = values->height;
  94.     else
  95.       value_mask &= ~CWHeight;
  96.   }
  97.   if (value_mask & CWBorderWidth) {
  98.     if (border_width != values->border_width)
  99.       border_width = values->border_width;
  100.     else
  101.       value_mask &= ~CWBorderWidth;
  102.   }
  103.  
  104.   if (value_mask & (CWX | CWY | CWWidth | CWHeight | CWBorderWidth)) {
  105.     if (w->mapped) _WUnmapWindow (dpy, w);
  106.     w->x = x;
  107.     w->y = y;
  108.     w->width = width;
  109.     w->height = height;
  110.     w->border_width = border_width;
  111.     _WNewWindowContext (w);
  112.   }
  113.  
  114.   if (value_mask & CWStackMode) {
  115.  
  116.     if (w->mapped) _WUnmapWindow (dpy, w);
  117.  
  118.     if (value_mask & CWSibling) {
  119.       sibling = values->sibling;
  120.       if (sibling->parent == w->parent) {
  121.     switch (values->stack_mode) {
  122.     case Above:
  123.       _WTreeDelete (w);
  124.       _WTreeInsertAbove (sibling, w);
  125.       break;
  126.     case Below:
  127.       _WTreeDelete (w);
  128.       _WTreeInsertBelow (sibling, w);
  129.       break;
  130.     case TopIf:
  131.       for (window = w;
  132.            window != None;
  133.            window = window->upper_sibling) {
  134.         if (window == sibling
  135.         && EXTENTCHECK(&sibling->border_port, &w->window_port)) {
  136.           _WTreeDelete (w);
  137.           _WTreeInsertAbove (sibling, w);
  138.         }
  139.       }        
  140.       break;
  141.     case BottomIf:
  142.       for (window = w;
  143.            window != None;
  144.            window = window->lower_sibling) {
  145.         if (window == sibling
  146.         && EXTENTCHECK(&sibling->border_port, &w->window_port)) {
  147.           _WTreeDelete (w);
  148.           _WTreeInsertBelow (sibling, w);
  149.         }
  150.       }        
  151.       break;
  152.     case Opposite:
  153.       break;
  154.     }
  155.       }
  156.     }
  157.     else {
  158.       switch (values->stack_mode) {
  159.       case Above:
  160.     XRaiseWindow (dpy, w);
  161.     break;
  162.       case Below:
  163.     XLowerWindow (dpy, w);
  164.     break;
  165.       case TopIf:
  166.     for (sibling = w->upper_sibling;
  167.          sibling != None;
  168.          sibling = sibling->upper_sibling) {
  169.       if (EXTENTCHECK (&w->window_port, &sibling->border_port)) {
  170.         XRaiseWindow (dpy, w);
  171.         break;
  172.       }
  173.     }
  174.     break;
  175.       case BottomIf:
  176.     for (sibling = w->lower_sibling;
  177.          sibling != None;
  178.          sibling = sibling->upper_sibling) {
  179.       if (EXTENTCHECK (&w->border_port, &sibling->window_port)) {
  180.         XLowerWindow (dpy, w);
  181.         break;
  182.       }
  183.     }
  184.     break;
  185.       case Opposite:
  186.     break;
  187.       }
  188.     }
  189.   }
  190.  
  191.   if (w->event_mask & StructureNotifyMask) {
  192.     xe.xconfigure.type = ConfigureNotify;
  193.     xe.xconfigure.send_event = 0;
  194.     xe.xconfigure.display = dpy;
  195.     xe.xconfigure.event = w;
  196.     xe.xconfigure.window = w;
  197.     xe.xconfigure.x = w->x;
  198.     xe.xconfigure.y = w->y;
  199.     xe.xconfigure.width = w->width;
  200.     xe.xconfigure.height = w->height;
  201.     xe.xconfigure.border_width = w->border_width;
  202.     xe.xconfigure.above = w->lower_sibling;
  203.     xe.xconfigure.override_redirect = w->override_redirect;
  204.     _WDispatchEvent (&xe);
  205.   }
  206.   if (w->parent != None &&
  207.       w->parent->event_mask & SubstructureNotifyMask) {
  208.     xe.xconfigure.type = ConfigureNotify;
  209.     xe.xconfigure.send_event = 0;
  210.     xe.xconfigure.display = dpy;
  211.     xe.xconfigure.event = w->parent;
  212.     xe.xconfigure.window = w;
  213.     xe.xconfigure.x = w->x;
  214.     xe.xconfigure.y = w->y;
  215.     xe.xconfigure.width = w->width;
  216.     xe.xconfigure.height = w->height;
  217.     xe.xconfigure.border_width = w->border_width;
  218.     xe.xconfigure.above = w->lower_sibling;
  219.     xe.xconfigure.override_redirect = w->override_redirect;
  220.     _WDispatchEvent (&xe);
  221.   }
  222.   if (mapped != 0 && w->mapped == 0) _WMapWindow (dpy, w);
  223.   return 0;
  224. }
  225.