Пример #1
0
static void maximise(struct WM_t *W, struct wmclient *C)
{
    msg("client_MAX: %s\n", C->name);
    C->fullscreen = 1;
    XSetWindowBorderWidth(W->XDisplay, C->win, 0);
    XMoveResizeWindow(W->XDisplay, C->win,
                      curr_head_x(W), curr_head_y(W),
                      curr_width(W), curr_height(W));

    set_net_wm_status(W, C);
}
Пример #2
0
/* Move and resize a window, saving the new dimensions. Negative sizes mean
 * maximise but still with a border */
void client_moveresize(struct WM_t *W, struct wmclient *C, int x, int y, int w, int h)
{
    /* We can't move fullscreen windows so set it to its original size */
    if (C->fullscreen)
    {
        C->fullscreen = 0;
        set_size_pos_border(W, C);
    }

    /* Make sure it's smaller than the screen */
    if (w > curr_width(W) || w < 0)
        w = curr_width(W) - 2 * W->prefs.bw;
    if (h > curr_height(W) || h < 0)
        h = curr_height(W) - 2 * W->prefs.bw;

    C->x = x;
    C->y = y;
    C->w = w;
    C->h = h;

    XMoveResizeWindow(W->XDisplay, C->win, x, y, w, h);
}
Пример #3
0
bool Altitude_Hold::ExecuteCycle() {
  int t = hal.scheduler->micros();
  float dt = (t - timestamp()) / 1000.0;
  set_timestamp(t);

  update_curr_height();
  float height_err = target_height() - curr_height();
  float height_correction = height_pid.get_pid(height_err, dt);
  float throttle = hover_throttle() + height_correction * THROTTLE_CORRECTION_SCALE;
  ++count;
  if(!(count % 50) && DEBUG) {
    hal.console->printf("Height Correction: %f, Throttle: %f, Err: %f\n", height_correction, throttle, height_err);
  }
  set_hover_throttle(throttle);

  flight_control()->execute(up_cntrl(), throttle, 0);
  return false;
}
Пример #4
0
void decide_new_window_size_pos(struct WM_t *W, struct wmclient *C)
{
    XWindowAttributes attr;
    XSizeHints hints;
    long user_hints;

    /* Get actual position/size of window */
    XGetWindowAttributes(W->XDisplay, C->win, &attr);

    C->min_w = C->min_h = 30;

    C->x = attr.x;
    C->y = attr.y;
    C->w = attr.width;
    C->h = attr.height;

    msg("Deciding new window size/pos: x = %d, y = %d, w = %d, h = %d\n", C->x, C->y, C->w, C->h);

    /* Get hints on size limits, but not the actual sizes. If a client
     * wants a window a certain size, they will just create it that size,
     * not put it as a 'hint'. */

    if (XGetWMNormalHints(W->XDisplay, C->win, &hints, &user_hints))
    {
        msg("Got hints!\n");
        if (hints.flags & PMinSize)
        {
            if (C->min_w < hints.min_width)
                C->min_w = hints.min_width;
            if (C->min_h < hints.min_height)
                C->min_h = hints.min_height;
        }

        /* If size hints are provided and are larger than
         * the minimum, use them instead */
        if (hints.flags & PBaseSize)
        {
            msg("base size %dx%d\n", hints.base_width, hints.base_height);
            if (hints.base_width > C->min_w)
                C->w = hints.base_width;
            if (hints.base_height > C->min_h)
                C->h = hints.base_height;
        }
        else if (hints.flags & PSize)
        {
            msg("PSize %dx%d\n", hints.width, hints.height);
            if (hints.width > C->min_w)
                C->w = hints.width;
            if (hints.height > C->min_h)
                C->h = hints.height;
        }
        if (hints.flags & PAspect)
            msg("HAS ASPECT!\n");
    }

    if (C->w < C->min_w)
        C->w = C->min_w;
    if (C->h < C->min_h)
        C->h = C->min_h;

    /* Don't let windows be larger than the root window */
    if (C->w > curr_width(W))
    {
        C->w = curr_width(W) - 2 * W->prefs.bw;
        C->x = curr_head_x(W);
    }

    if (C->h > curr_height(W))
    {
        C->h = curr_height(W) - 2 * W->prefs.bw;
        C->y = curr_head_y(W);
    }
}