void Client::drawOutline() { ws->painter()->rubberBand( x-1, y - titleHeight(), width+1, height + titleHeight() ); }
void Client::moveResize() { titlebar_width = width - 2*button_size; ws->moveResize( frame, x-1, y - titleHeight(), width + 2, height + titleHeight() + 1); ws->moveResize( close_button, width + 1 - button_size, 1, button_size, button_size); ws->moveResize( iconize_button, 1, 1, button_size, button_size); ws->moveResize( titlebar, button_size + 1, 1, titlebar_width, button_size); ws->moveResize( window, 1, titleHeight(), width, height); configure(); }
void Client::takeConfigureRequest( int x1, int y1, unsigned int width1, unsigned int height1, unsigned int valuemask, Window sibling, int stack_mode ) { gravitate( REMOVE_GRAVITY ); if (valuemask & CWX) x = x1; if (valuemask & CWY) y = y1; if (valuemask & CWWidth) width = width1; if (valuemask & CWHeight) height = height1; gravitate( APPLY_GRAVITY ); /* configure the frame */ ws->configure( frame, x, y - titleHeight(), width, height + titleHeight(), valuemask, sibling, stack_mode ); configure(); }
QSize CQDividedAreaWidget:: minimumSizeHint() const { int w = Constants::MIN_WIDTH; int h = titleHeight(); return QSize(w, h); }
QSize QDockWidgetLayout::sizeFromContent(const QSize &content, bool floating) const { QSize result = content; if (verticalTitleBar) { result.setHeight(qMax(result.height(), minimumTitleWidth())); result.setWidth(qMax(content.width(), 0)); } else { result.setHeight(qMax(result.height(), 0)); result.setWidth(qMax(content.width(), minimumTitleWidth())); } QDockWidget *w = qobject_cast<QDockWidget*>(parentWidget()); bool customTitleBar = item_list[TitleBar] != 0; bool nativeDeco = floating && !customTitleBar; #if defined(Q_WS_X11) || defined(Q_WS_QWS) nativeDeco = false; #endif int fw = floating && !nativeDeco ? w->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, 0) : 0; const int th = titleHeight(); if (!nativeDeco) { if (verticalTitleBar) result += QSize(th + 2*fw, 2*fw); else result += QSize(2*fw, th + 2*fw); } result.setHeight(qMin(result.height(), (int) QWIDGETSIZE_MAX)); result.setWidth(qMin(result.width(), (int) QWIDGETSIZE_MAX)); if (content.width() < 0) result.setWidth(-1); if (content.height() < 0) result.setHeight(-1); QSize min = w->minimumSize(); /* A floating dockwidget will automatically get its minimumSize set to the layout's minimum size + deco. We're *not* interested in this, we only take minimumSize() into account if the user set it herself. Otherwise we end up expanding the result of a calculation for a non-floating dock widget to a floating dock widget's minimum size + window decorations. */ uint explicitMin = 0; if (w->d_func()->extra != 0) explicitMin = w->d_func()->extra->explicitMinSize; if (!(explicitMin & Qt::Horizontal) || min.width() == 0) min.setWidth(-1); if (!(explicitMin & Qt::Vertical) || min.height() == 0) min.setHeight(-1); return result.boundedTo(w->maximumSize()).expandedTo(min); }
/* Window gravity is a mess to explain, but we don't need to do much * about it since we're using X borders. For NorthWest et al, the top * left corner of the window when there is no WM needs to match up * with the top left of our fram once we manage it, and likewise with * SouthWest and the bottom right (these are the only values I ever * use, but the others should be obvious.) Our titlebar is on the top * so we only have to adjust in the first case. */ void Client::gravitate( Client::GravityType type ) { int dy = 0; int gravity = (size->flags & PWinGravity) ? size->win_gravity : NorthWestGravity; switch (gravity) { case NorthWestGravity: case NorthEastGravity: case NorthGravity: dy = titleHeight(); break; case CenterGravity: dy = titleHeight()/2; break; } y += type * dy; }
QSize CQDividedAreaWidget:: sizeHint() const { int w = w_->sizeHint().width(); int h = w_->sizeHint().height(); h += titleHeight(); return QSize(w, h); }
void Client::initPosition() { int xmax = ws->displayWidth(); int ymax = ws->displayHeight();; if (size->flags & (USSize)) { if (size->width) width = size->width; if (size->height) height = size->height; } else { /* make sure it's big enough to click at */ if (width < 2 * titleHeight()) width = 2 * titleHeight(); if (height < titleHeight()) height = titleHeight(); } if (size->flags & USPosition) { x = size->x; y = size->y; } else { if (size->flags & PPosition) { x = size->x; y = size->y; } if (x < 0) x = 0; if (y < 0) y = 0; if (x > xmax) x = xmax - titleHeight(); if (y > ymax) y = ymax - titleHeight(); if (x == 0 && y == 0) { int mouse_x, mouse_y; ws->pointerPosition(&mouse_x, &mouse_y); if (width < xmax) x = int( (mouse_x < xmax ? (mouse_x / (float)xmax) : 1) * (xmax - width - 2 ) ); if (height + titleHeight() < ymax) y = int( (mouse_y < ymax ? (mouse_y / (float)ymax) : 1) * (ymax - height - titleHeight() - 2) ); y += titleHeight(); gravitate( REMOVE_GRAVITY ); } } }
void Client::redraw( bool act, bool force ) { bool cleared = false; if ( force || act != active ) { active = act; ws->painter()->setBorderBackground( frame, active, width + 2, height + titleHeight() + 1, titleHeight() ); ws->painter()->setTitlebarBackground( titlebar, active, titlebar_width, button_size); ws->painter()->setButtonBackground( close_button, Painter::CLOSE_BUTTON, active, false, button_size, button_size ); ws->painter()->setButtonBackground( iconize_button, Painter::ICONIZE_BUTTON, active, false, button_size, button_size ); cleared = true; } if (!trans && name().length()) { if ( !cleared ) ws->painter()->clear( titlebar ); ws->painter()->drawString( titlebar, active, ws->pad(), ws->painter()->fontAscent() + ws->pad(), name()); } ws->sync(); }
void AbstractBox::paintEvent(QPaintEvent *e) { Painter p(this); auto clip = e->rect(); auto paintTopRounded = clip.intersects(QRect(0, 0, width(), st::boxRadius)); auto paintBottomRounded = clip.intersects(QRect(0, height() - st::boxRadius, width(), st::boxRadius)); if (paintTopRounded || paintBottomRounded) { auto parts = RectPart::None | 0; if (paintTopRounded) parts |= RectPart::FullTop; if (paintBottomRounded) parts |= RectPart::FullBottom; App::roundRect(p, rect(), st::boxBg, BoxCorners, nullptr, parts); } auto other = e->region().intersected(QRect(0, st::boxRadius, width(), height() - 2 * st::boxRadius)); if (!other.isEmpty()) { for (auto rect : other.rects()) { p.fillRect(rect, st::boxBg); } } if (!_additionalTitle.isEmpty() && clip.intersects(QRect(0, 0, width(), titleHeight()))) { paintAdditionalTitle(p); } }
QSize QDockWidgetLayout::sizeFromContent(const QSize &content, bool floating) const { QSize result = content; if (verticalTitleBar) { result.setHeight(qMax(result.height(), minimumTitleWidth())); result.setWidth(qMax(content.width(), 0)); } else { result.setHeight(qMax(result.height(), 0)); result.setWidth(qMax(content.width(), minimumTitleWidth())); } QDockWidget *w = qobject_cast<QDockWidget*>(parentWidget()); const bool nativeDeco = nativeWindowDeco(floating); int fw = floating && !nativeDeco ? w->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, w) : 0; const int th = titleHeight(); if (!nativeDeco) { if (verticalTitleBar) result += QSize(th + 2*fw, 2*fw); else result += QSize(2*fw, th + 2*fw); } result.setHeight(qMin(result.height(), (int) QWIDGETSIZE_MAX)); result.setWidth(qMin(result.width(), (int) QWIDGETSIZE_MAX)); if (content.width() < 0) result.setWidth(-1); if (content.height() < 0) result.setHeight(-1); int left, top, right, bottom; w->getContentsMargins(&left, &top, &right, &bottom); //we need to substract the contents margin (it will be added by the caller) QSize min = w->minimumSize() - QSize(left + right, top + bottom); QSize max = w->maximumSize() - QSize(left + right, top + bottom); /* A floating dockwidget will automatically get its minimumSize set to the layout's minimum size + deco. We're *not* interested in this, we only take minimumSize() into account if the user set it herself. Otherwise we end up expanding the result of a calculation for a non-floating dock widget to a floating dock widget's minimum size + window decorations. */ uint explicitMin = 0; uint explicitMax = 0; if (w->d_func()->extra != 0) { explicitMin = w->d_func()->extra->explicitMinSize; explicitMax = w->d_func()->extra->explicitMaxSize; } if (!(explicitMin & Qt::Horizontal) || min.width() == 0) min.setWidth(-1); if (!(explicitMin & Qt::Vertical) || min.height() == 0) min.setHeight(-1); if (!(explicitMax & Qt::Horizontal)) max.setWidth(QWIDGETSIZE_MAX); if (!(explicitMax & Qt::Vertical)) max.setHeight(QWIDGETSIZE_MAX); return result.boundedTo(max).expandedTo(min); }
int AbstractBox::contentTop() const { return hasTitle() ? titleHeight() : (_noContentMargin ? 0 : st::boxTopMargin); }
void ewmh_set_strut(ScreenInfo *screen) { Client *c; EWMHStrut strut; unsigned long data[4]; /* FIXME: add parameter to MakeSane rather than this hack */ Edge backup; /* find largest reserved areas */ strut.left = 0; strut.right = 0; strut.top = 0; strut.bottom = 0; for (c = client_head(); c; c = c->next) { if (c->screen != screen) continue; if (c->strut.left > strut.left) strut.left = c->strut.left; if (c->strut.right > strut.right) strut.right = c->strut.right; if (c->strut.top > strut.top) strut.top = c->strut.top; if (c->strut.bottom > strut.bottom) strut.bottom = c->strut.bottom; } /* if the reservered aread have not changed then we're done */ if ( screen->strut.left == strut.left && screen->strut.right == strut.right && screen->strut.top == strut.top && screen->strut.bottom == strut.bottom) return; /* apply the new strut */ screen->strut.left = strut.left; screen->strut.right = strut.right; screen->strut.top = strut.top; screen->strut.bottom = strut.bottom; /* set the new workarea */ data[0] = strut.left; data[1] = strut.top; data[2] = screen->display_width - (strut.left + strut.right); data[3] = screen->display_height - (strut.top + strut.bottom); XChangeProperty(dpy, screen->root, ewmh_atom[_NET_WORKAREA], XA_CARDINAL, 32, PropModeReplace, (unsigned char*)data, 4); /* ensure no window fully occupy reserved areas */ for (c = client_head(); c; c = c->next) { int x = c->size.x; int y = c->size.y; if (c->wstate.fullscreen == True) continue; backup = interacting_edge; interacting_edge = ENone; Client_MakeSane(c, ENone, &x, &y, 0, 0); interacting_edge = backup; if (c->framed == True) { XMoveWindow(dpy, c->parent, c->size.x, c->size.y - titleHeight()); } else { XMoveWindow(dpy, c->parent, c->size.x, c->size.y); } sendConfigureNotify(c); } }
void Client::move() { ws->move( frame, x, y - titleHeight() ); configure(); }
Client::Client( WindowSystem* windowsystem, Window w, bool viewable, int wx, int wy, int wwidth, int wheight, long wcolormap ) : ws(windowsystem) { assert(ws); ws->transientForHint( w, &trans ); nm = ws->windowName( w ); window = w; ignore_unmap = 0; x = wx; y = wy; width = wwidth; height = wheight; cmap = wcolormap; size = ws->allocSizeHints(); active = false; awaiting_close = false; awaiting_iconize = false; long dummy; ws->windowNormalHints( window, size, &dummy ); if ( viewable ) { ignore_unmap++; } else { initPosition(); ws->setState(window, NormalState); // consolidate XWMHints *hints; if ((hints = ws->windowHints(w))) { if (hints->flags & StateHint) ws->setState(window, hints->initial_state); ws->xFree(hints); } } gravitate( APPLY_GRAVITY ); frame = ws->createFrame( x-1, y - titleHeight(), width + 2, // 1 pixel border, each side height + titleHeight() + 1 ); // 1 pixel border, top button_size = titleHeight() - 2; titlebar_width = width - 2*button_size; close_button = ws->createWindow( 0,0, button_size, button_size ); iconize_button = ws->createWindow( 0,0, button_size, button_size ); titlebar = ws->createWindow( 0,0, titlebar_width, button_size ); ws->addToSaveSet( window ); ws->selectInput( window, ColormapChangeMask|PropertyChangeMask); ws->grabButtons( window ); ws->setBorderWidth( window, 0); ws->resize( window, width, height); //db more needed? ws->reparent( close_button, frame, width + 1 - button_size, 1 ); ws->reparent( iconize_button, frame, 1, 1 ); ws->reparent( titlebar, frame, button_size + 1, 1 ); ws->reparent( window, frame, 1, titleHeight()); // for 1 pixel border configure(); // db more fix: initial iconized windows if ( viewable ) { if ( ws->getState(window) == IconicState ) { ignore_unmap++; ws->unmap( window ); } else { mapRaised(); } } else { if ( ws->getState(window) == NormalState ) { ws->map( window ); ws->map( close_button ); ws->map( iconize_button ); ws->map( titlebar ); ws->mapRaised( frame ); } } redraw( false, true ); }