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(); }
void Client::withdraw(Boolean changeState) { // fprintf(stderr,"withdrawing\n"); m_border->unmap(); gravitate(True); XReparentWindow(display(), m_window, root(), m_x, m_y); gravitate(False); if (changeState) { XRemoveFromSaveSet(display(), m_window); setState(WithdrawnState); } ignoreBadWindowErrors = True; XSync(display(), False); ignoreBadWindowErrors = False; }
void Client::unreparent() { XWindowChanges wc; if (!isWithdrawn()) { gravitate(True); XReparentWindow(display(), m_window, root(), m_x, m_y); } wc.border_width = m_bw; XConfigureWindow(display(), m_window, CWBorderWidth, &wc); XSync(display(), True); }
void smooth_pan() { if (ZOOM) { if ( (offset+.108) > -0.143f ) { gravitate(3.36303857f - 13.177629f*(0-(offset+.108)), 2.50690389f*powf(.216129672,-(offset+.108))); } else if ( (offset+.108) <= -0.143f ) { gravitate(16.777777f+111.11111f*(offset+.108), 1.0f); if (X_Cam < -7.0f) X_Cam = -7.0f; } } else { gravitate(0.0f, 0.0f); } usleep(1); return; }
Client::~Client() { // if ( ignore_unmap ) // throw ( "Client withdrawing directly!" ); // ## db more ws->setState( window, WithdrawnState ); gravitate( REMOVE_GRAVITY ); ws->setBorderWidth( window, 1 ); ws->removeFromSaveSet( window ); ws->reparentToRoot( window, x, y); ws->destroy( close_button ); ws->destroy( iconize_button ); ws->destroy( titlebar ); ws->destroy( frame ); if (size) ws->xFree(size); }
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 ); } } }
/** * CCoin::update() * @date Modified May 3, 2006 */ void CCoin::update() { // gold money doesn't gravitate if (m_unValue != GOLD_VALUE) { if (!gravitate()) return; } // spin the coin rotateActorY(CTimer::getInstance().getFrameTime()*0.75f); if(!m_oTimeSpan.tick()) { CActor::update(); return; } // kill the coin if it's lifespan elapses CObjectManager::getInstance().removeObject((CObject*)this); }
void Client::handleConfigureRequest(XConfigureRequestEvent *event) { XWindowChanges wc; if (event->value_mask & CWStackMode) { if (attached()) { if (!isFocused()) { requestsFocus_ = true; } if (monitor()->focused() != attached()) { attached()->setRequestsFocus(true); } } event->value_mask &= ~CWStackMode; } event->value_mask &= ~CWSibling; if (!frame() #ifdef SLOT_SUPPORT || (mode_ == SLOT) #endif ) { // floating client gravitate(true); if (event->value_mask & CWX) { setX(event->x); } if (event->value_mask & CWY) { setY(event->y); } if (event->value_mask & CWWidth) { setWidth(event->width); } if (event->value_mask & CWHeight) { setHeight(event->height); } if (event->value_mask & CWBorderWidth) { clientBorderWidth_ = event->border_width; } ostringstream oss; oss << "configure request: x=" << x() << ", y=" << y() << ", w=" << width() << ", h=" << height(); LOGDEBUG(oss.str()); gravitate(false); // applied patch by Dr. J. Pfefferl if (hasFrame_) { if((event->value_mask & CWWidth)) { setWidth(width() + 2 * borderWidth_); } if((event->value_mask & CWHeight)) { setHeight(height() + titleBarHeight_ + 2 * borderWidth_ + (titleBarHeight_ ? 1 : 0)); } if((event->value_mask & CWX)) { setX(x() - borderWidth_); } if((event->value_mask & CWY)) { setY(y() - titleBarHeight_ - borderWidth_); } wc.x = x(); wc.y = y(); wc.width = width(); wc.height = height(); wc.border_width = 1; // event->border_width wc.sibling = None; wc.stack_mode = event->detail; XCORE->configureWindow(frameWindow(), event->value_mask, &wc); fitClientArea(); sendConfiguration(); } else { // save current dimensions to client area clientAreaRect_.copy(this); } } #ifdef SLOT_SUPPORT if (mode_ == SLOT) { monitor()->slot()->manage(); } else #endif // SLOT_SUPPORT { // If client is attached to a frame, the clientAreaRect_ has // the size of the frames client area. wc.x = clientAreaRect_.x(); wc.y = clientAreaRect_.y(); wc.width = clientAreaRect_.width(); wc.height = clientAreaRect_.height(); wc.border_width = 0; wc.sibling = None; event->value_mask |= CWBorderWidth; XCORE->configureWindow(clientWindow_, event->value_mask, &wc); illuminate(); } }
void Client::manage(Boolean mapped) { Boolean shouldHide, reshape; XWMHints *hints; Display *d = display(); long mSize; int state; XSelectInput(d, m_window, ColormapChangeMask | EnterWindowMask | PropertyChangeMask | FocusChangeMask); m_iconName = getProperty(XA_WM_ICON_NAME); m_name = getProperty(XA_WM_NAME); setLabel(); getColormaps(); getProtocols(); getTransient(); hints = XGetWMHints(d, m_window); if (!getState(&state)) { state = hints ? hints->initial_state : NormalState; } shouldHide = (state == IconicState); if (hints) XFree(hints); if (XGetWMNormalHints(d, m_window, &m_sizeHints, &mSize) == 0 || m_sizeHints.flags == 0) { m_sizeHints.flags = PSize; } m_fixedSize = False; // if ((m_sizeHints.flags & (USSize | PSize))) m_fixedSize = True; if ((m_sizeHints.flags & (PMinSize | PMaxSize)) == (PMinSize | PMaxSize) && (m_sizeHints.min_width == m_sizeHints.max_width && m_sizeHints.min_height == m_sizeHints.max_height)) m_fixedSize = True; reshape = !mapped; if (m_fixedSize) { if ((m_sizeHints.flags & USPosition)) reshape = False; if ((m_sizeHints.flags & PPosition) && shouldHide) reshape = False; if ((m_transient != None)) reshape = False; } if ((m_sizeHints.flags & PBaseSize)) { m_minWidth = m_sizeHints.base_width; m_minHeight = m_sizeHints.base_height; } else if ((m_sizeHints.flags & PMinSize)) { m_minWidth = m_sizeHints.min_width; m_minHeight = m_sizeHints.min_height; } else { m_minWidth = m_minHeight = 50; } // act gravitate(False); // zeros are iffy, should be calling some Manager method int dw = DisplayWidth(display(), 0), dh = DisplayHeight(display(), 0); if (m_w < m_minWidth) { m_w = m_minWidth; m_fixedSize = False; reshape = True; } if (m_h < m_minHeight) { m_h = m_minHeight; m_fixedSize = False; reshape = True; } if (m_w > dw - 8) m_w = dw - 8; if (m_h > dh - 8) m_h = dh - 8; if (m_x > dw - m_border->xIndent()) { m_x = dw - m_border->xIndent(); } if (m_y > dh - m_border->yIndent()) { m_y = dh - m_border->yIndent(); } if (m_x < m_border->xIndent()) m_x = m_border->xIndent(); if (m_y < m_border->yIndent()) m_y = m_border->yIndent(); m_border->configure(m_x, m_y, m_w, m_h, 0L, Above); if (mapped) m_reparenting = True; if (reshape && !m_fixedSize) XResizeWindow(d, m_window, m_w, m_h); XSetWindowBorderWidth(d, m_window, 0); m_border->reparent(); // (support for shaped windows absent) XAddToSaveSet(d, m_window); m_managed = True; if (shouldHide) hide(); else { XMapWindow(d, m_window); m_border->map(); setState(NormalState); if (CONFIG_CLICK_TO_FOCUS || (m_transient != None && activeClient() && activeClient()->m_window == m_transient)) { activate(); mapRaised(); } else { deactivate(); } } if (activeClient() && !isActive()) { activeClient()->installColormap(); } if (CONFIG_AUTO_RAISE) { m_windowManager->stopConsideringFocus(); focusIfAppropriate(False); } }
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 ); }
void make_new_client(Window w) { Client *c, *p; XWindowAttributes attr; long dummy; XWMHints *hints; XSizeHints* shints; XGrabServer(dpy); XSetErrorHandler(ignore_xerror); hints = XGetWMHints(dpy, w); shints = XAllocSizeHints(); XGetWMNormalHints(dpy, w, shints, &dummy); c = (Client *)calloc(1, sizeof(Client)); c->next = head_client; head_client = c; c->window = w; c->name = null_str; /* try these here instead */ c->size = shints; XClassHint* hint = XAllocClassHint(); XGetClassHint(dpy, w, hint); if (hint->res_class) { c->name = hint->res_class; if (hint->res_name) XFree(hint->res_name); } XFree(hint); XGetWindowAttributes(dpy, c->window, &attr); c->x = attr.x; c->y = attr.y; c->width = attr.width; c->height = attr.height; c->border = opt_bw; c->oldw = c->oldh = 0; c->vdesk = vdesk; c->index = 0; if (!(attr.map_state == IsViewable)) { init_position(c); if (hints && hints->flags & StateHint) set_wm_state(c, hints->initial_state); } if (hints) XFree(hints); /* client is initialised */ gravitate(c); reparent(c); XGrabButton(dpy, AnyButton, Mod1Mask, c->parent, False, ButtonMask, GrabModeSync, GrabModeAsync, None, None); XGrabButton(dpy, AnyButton, 0, c->parent, False, ButtonPressMask, GrabModeSync, GrabModeAsync, None, None); XMapWindow(dpy, c->window); XMapRaised(dpy, c->parent); set_wm_state(c, NormalState); XSync(dpy, False); XSetErrorHandler(handle_xerror); XUngrabServer(dpy); throwUnmaps = 0; again: for (p = c->next; p; p = p->next) { if (c->index == p->index && !strcmp(c->name, p->name)) { c->index++; goto again; } } }