Example #1
0
/** Process a configure request. */
void HandleConfigureRequest(const XConfigureRequestEvent *event)
{
   XWindowChanges wc;
   ClientNode *np;

   if(HandleDockConfigureRequest(event)) {
      return;
   }

   np = FindClientByWindow(event->window);
   if(np) {

      int deltax, deltay;
      char changed = 0;
      char resized = 0;

      GetGravityDelta(np, np->gravity, &deltax, &deltay);
      if((event->value_mask & CWWidth) && (event->width != np->width)) {
         switch(np->gravity) {
         case EastGravity:
         case NorthEastGravity:
         case SouthEastGravity:
            /* Right side should not move. */
            np->x -= event->width - np->width;
            break;
         case WestGravity:
         case NorthWestGravity:
         case SouthWestGravity:
            /* Left side should not move. */
            break;
         case CenterGravity:
            /* Center of the window should not move. */
            np->x -= (event->width - np->width) / 2;
            break;
         default:
            break;
         }
         np->width = event->width;
         changed = 1;
         resized = 1;
      }
      if((event->value_mask & CWHeight) && (event->height != np->height)) {
         switch(np->gravity) {
         case NorthGravity:
         case NorthEastGravity:
         case NorthWestGravity:
            /* Top should not move. */
            break;
         case SouthGravity:
         case SouthEastGravity:
         case SouthWestGravity:
            /* Bottom should not move. */
            np->y -= event->height - np->height;
            break;
         case CenterGravity:
            /* Center of the window should not move. */
            np->y -= (event->height - np->height) / 2;
            break;
         default:
            break;
         }
         np->height = event->height;
         changed = 1;
         resized = 1;
      }
      if((event->value_mask & CWX) && (event->x - deltax != np->x)) {
         np->x = event->x - deltax;
         changed = 1;
      }
      if((event->value_mask & CWY) && (event->y - deltay != np->y)) {
         np->y = event->y - deltay;
         changed = 1;
      }

      /* Update stacking. */
      if((event->value_mask & CWStackMode)) {
         Window above = None;
         if(event->value_mask & CWSibling) {
            above = event->above;
         }
         RestackClient(np, above, event->detail);
      }

      /* Return early if there's nothing to do. */
      if(!changed) {
         return;
      }

      if(np->controller) {
         (np->controller)(0);
      }
      if(np->state.maxFlags) {
         MaximizeClient(np, MAX_NONE);
      }

      if(np->state.border & BORDER_CONSTRAIN) {
         resized = 1;
      }
      if(resized) {
         ConstrainSize(np);
         ConstrainPosition(np);
         ResetBorder(np);
      } else {
         int north, south, east, west;
         GetBorderSize(&np->state, &north, &south, &east, &west);
         if(np->parent != None) {
            JXMoveWindow(display, np->parent, np->x - west, np->y - north);
         } else {
            JXMoveWindow(display, np->window, np->x, np->y);
         }
      }

      SendConfigureEvent(np);
      RequirePagerUpdate();

   } else {

      /* We don't know about this window, just let the configure through. */

      wc.stack_mode = event->detail;
      wc.sibling = event->above;
      wc.border_width = event->border_width;
      wc.x = event->x;
      wc.y = event->y;
      wc.width = event->width;
      wc.height = event->height;
      JXConfigureWindow(display, event->window, event->value_mask, &wc);

   }
}
Example #2
0
/** Process a configure request. */
void HandleConfigureRequest(const XConfigureRequestEvent *event) {

   XWindowChanges wc;
   ClientNode *np;
   int north, south, east, west;
   int changed;
   int handled;

   handled = HandleDockConfigureRequest(event);
   if(handled) {
      return;
   }

   np = FindClientByWindow(event->window);
   if(np && np->window == event->window) {

      /* We own this window, make sure it's not trying to do something bad. */
      changed = 0;
      if((event->value_mask & CWWidth) && (event->width != np->width)) {
         if(!(np->state.status & STAT_HMAX)) {
            np->width = event->width;
            changed = 1;
         }
      }
      if((event->value_mask & CWHeight) && (event->height != np->height)) {
         if(!(np->state.status & STAT_VMAX)) {
            np->height = event->height;
            changed = 1;
         }
      }
      if((event->value_mask & CWX) && (event->x != np->x)) {
         if(!(np->state.status & STAT_HMAX)) {
            np->x = event->x;
            changed = 1;
         }
      }
      if((event->value_mask & CWY) && (event->y != np->y)) {
         if(!(np->state.status & STAT_VMAX)) {
            np->y = event->y;
            changed = 1;
         }
      }

      if(!changed) {
         return;
      }

      if(np->controller) {
         (np->controller)(0);
      }

      GetBorderSize(np, &north, &south, &east, &west);

      ResetRoundedRectWindow(np->parent);

      wc.stack_mode = Above;
      wc.sibling = np->parent;
      wc.border_width = 0;

      ConstrainSize(np);

      wc.x = np->x;
      wc.y = np->y;
      wc.width = np->width + east + west;
      wc.height = np->height + north + south;
      JXConfigureWindow(display, np->parent, event->value_mask, &wc);

      wc.x = west;
      wc.y = north;
      wc.width = np->width;
      wc.height = np->height;
      JXConfigureWindow(display, np->window, event->value_mask, &wc);

   } else {

      /* We don't know about this window, just let the configure through. */

      wc.stack_mode = event->detail;
      wc.sibling = event->above;
      wc.border_width = event->border_width;
      wc.x = event->x;
      wc.y = event->y;
      wc.width = event->width > rootWidth ? rootWidth : event->width;
      wc.height = event->height > rootHeight ? rootHeight : event->height;
      JXConfigureWindow(display, event->window, event->value_mask, &wc);

   }

}