void clientmessage(XEvent *e) { XClientMessageEvent *ev = &e->xclient; Client *c; if (ev->message_type == atom[CloseWindow]) { if ((c = getclient(ev->window, clients, ClientWindow))) killclient(c); } else if (ev->message_type == atom[ActiveWindow]) { if ((c = getclient(ev->window, clients, ClientWindow))) { c->isicon = False; focus(c); arrange(curmonitor()); } } else if (ev->message_type == atom[CurDesk]) { view(tags[ev->data.l[0]]); } else if (ev->message_type == atom[WindowState]) { if ((c = getclient(ev->window, clients, ClientWindow))) { ewmh_process_state_atom(c, (Atom) ev->data.l[1], ev->data.l[0]); if (ev->data.l[2]) ewmh_process_state_atom(c, (Atom) ev->data.l[2], ev->data.l[0]); } } else if (ev->message_type == atom[WMChangeState]) { if ((c = getclient(ev->window, clients, ClientWindow))) { if (ev->data.l[0] == IconicState) { focus(c); iconify(NULL); } } } }
void xwindow::create_wborder(void) { lbdr = NULL; ubdr = NULL; layout = new QVBoxLayout(this); Q_CHECK_PTR(layout); layout->setMargin(0); if(pflags & WindowManager::SmallFrame) { midmove = new wframe(this); Q_CHECK_PTR(midmove); midmove->setFixedHeight(defaults::lowerborderheight); layout->addWidget(midmove); connect(midmove, SIGNAL(left_press(QMouseEvent *)), SLOT(press_move(QMouseEvent *))); connect(midmove, SIGNAL(left_release(QMouseEvent *)), SLOT(release_move(QMouseEvent *))); connect(midmove, SIGNAL(right_press()), SLOT(s_maximize())); connect(midmove, SIGNAL(mid_press()), SLOT(show_info())); connect(midmove, SIGNAL(mouse_move(QMouseEvent *)), SLOT(move_move(QMouseEvent *))); } else { ubdr = new uborder((transfor == None), this); Q_CHECK_PTR(ubdr); layout->addWidget(ubdr); midmove = ubdr->midframe; if(transfor == None) { connect(ubdr->leftframe, SIGNAL(right_press()), SLOT(t_maximize())); connect(ubdr->leftframe, SIGNAL(mid_press()), SLOT(toggle_tiled())); connect(ubdr->leftframe, SIGNAL(left_press()), SLOT(iconify())); } connect(ubdr->rightframe, SIGNAL(press()), SLOT(wdestroy())); connect(midmove, SIGNAL(right_press()), SLOT(s_maximize())); connect(midmove, SIGNAL(left_press(QMouseEvent *)), SLOT(press_move(QMouseEvent *))); connect(midmove, SIGNAL(left_release(QMouseEvent *)), SLOT(release_move(QMouseEvent *))); connect(midmove, SIGNAL(mid_press()), SLOT(show_info())); connect(midmove, SIGNAL(mouse_move(QMouseEvent *)), SLOT(move_move(QMouseEvent *))); } layout->addStretch(); if(! (pflags & WindowManager::NoResize)) { lbdr = new lborder(this); Q_CHECK_PTR(lbdr); layout->addWidget(lbdr); connect(lbdr->leftframe, SIGNAL(press(QMouseEvent *)), SLOT(press_leftresize(QMouseEvent *))); connect(lbdr->leftframe, SIGNAL(release(QMouseEvent *)), SLOT(release_leftresize(QMouseEvent *))); connect(lbdr->leftframe, SIGNAL(mouse_move(QMouseEvent *)), SLOT(move_leftresize(QMouseEvent *))); connect(lbdr->rightframe, SIGNAL(press(QMouseEvent *)), SLOT(press_rightresize(QMouseEvent *))); connect(lbdr->rightframe, SIGNAL(release(QMouseEvent *)), SLOT(release_rightresize(QMouseEvent *))); connect(lbdr->rightframe, SIGNAL(mouse_move(QMouseEvent *)), SLOT(move_rightresize(QMouseEvent *))); connect(lbdr->midframe, SIGNAL(press(QMouseEvent *)), SLOT(press_midresize(QMouseEvent *))); connect(lbdr->midframe, SIGNAL(release(QMouseEvent *)), SLOT(release_midresize(QMouseEvent *))); connect(lbdr->midframe, SIGNAL(mouse_move(QMouseEvent *)), SLOT(move_midresize(QMouseEvent *))); }
void Client::setDblMinimizeClick(bool active) { dblClickMinimize = active; disconnect(titlebar, SIGNAL(tMouseDblClick()), 0, 0); if (dblClickMinimize) { connect(titlebar, SIGNAL(tMouseDblClick()), SLOT(iconify())); } }
void Task::activateRaiseOrIconify() { if ( !isActive() || isIconified() ) { activate(); } else if ( !isOnTop() ) { raise(); } else { iconify(); } }
bool QWidget::qt_invoke( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->slotOffset() ) { case 0: setEnabled((bool)static_QUType_bool.get(_o+1)); break; case 1: setDisabled((bool)static_QUType_bool.get(_o+1)); break; case 2: setCaption((const QString&)static_QUType_QString.get(_o+1)); break; case 3: setIcon((const QPixmap&)*((const QPixmap*)static_QUType_ptr.get(_o+1))); break; case 4: setIconText((const QString&)static_QUType_QString.get(_o+1)); break; case 5: setMouseTracking((bool)static_QUType_bool.get(_o+1)); break; case 6: setFocus(); break; case 7: clearFocus(); break; case 8: setUpdatesEnabled((bool)static_QUType_bool.get(_o+1)); break; case 9: update(); break; case 10: update((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3),(int)static_QUType_int.get(_o+4)); break; case 11: update((const QRect&)*((const QRect*)static_QUType_ptr.get(_o+1))); break; case 12: repaint(); break; case 13: repaint((bool)static_QUType_bool.get(_o+1)); break; case 14: repaint((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3),(int)static_QUType_int.get(_o+4)); break; case 15: repaint((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3),(int)static_QUType_int.get(_o+4),(bool)static_QUType_bool.get(_o+5)); break; case 16: repaint((const QRect&)*((const QRect*)static_QUType_ptr.get(_o+1))); break; case 17: repaint((const QRect&)*((const QRect*)static_QUType_ptr.get(_o+1)),(bool)static_QUType_bool.get(_o+2)); break; case 18: repaint((const QRegion&)*((const QRegion*)static_QUType_ptr.get(_o+1))); break; case 19: repaint((const QRegion&)*((const QRegion*)static_QUType_ptr.get(_o+1)),(bool)static_QUType_bool.get(_o+2)); break; case 20: show(); break; case 21: hide(); break; case 22: setShown((bool)static_QUType_bool.get(_o+1)); break; case 23: setHidden((bool)static_QUType_bool.get(_o+1)); break; case 24: iconify(); break; case 25: showMinimized(); break; case 26: showMaximized(); break; case 27: showFullScreen(); break; case 28: showNormal(); break; case 29: polish(); break; case 30: constPolish(); break; case 31: static_QUType_bool.set(_o,close()); break; case 32: raise(); break; case 33: lower(); break; case 34: stackUnder((QWidget*)static_QUType_ptr.get(_o+1)); break; case 35: move((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 36: move((const QPoint&)*((const QPoint*)static_QUType_ptr.get(_o+1))); break; case 37: resize((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 38: resize((const QSize&)*((const QSize*)static_QUType_ptr.get(_o+1))); break; case 39: setGeometry((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3),(int)static_QUType_int.get(_o+4)); break; case 40: setGeometry((const QRect&)*((const QRect*)static_QUType_ptr.get(_o+1))); break; case 41: adjustSize(); break; case 42: focusProxyDestroyed(); break; default: return QObject::qt_invoke( _id, _o ); } return TRUE; }
void Client::createDecor() { qDebug() << "CREATE DECORATIONS FOR ROLE " << windowRole; if (windowRole == Atoms::Splash) { titlebar = NULL; return; } layout = new QGridLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); // center frame where client apps is shown Border *center = new Border(this); layout->addWidget(center, 1, 1); titlebar = new Titlebar(this->icon(16), clientName, windowRole); layout->addWidget(titlebar, 0, 0, 1, -1); // Window buttons actions if (windowRole != Atoms::Dialog) { connect(qobject_cast <WinButton *>(titlebar->minBtn), SIGNAL(wMouseLeftPress()), SLOT(iconify())); connect(qobject_cast <WinButton *>(titlebar->maxBtn), SIGNAL(wMouseLeftPress()), SLOT(maximize())); connect(qobject_cast <WinButton *>(titlebar->closeBtn), SIGNAL(wMouseLeftPress()), SLOT(destroyClient())); } bottombar = new GenericBar(); layout->addWidget(bottombar, 2, 0, 1, -1); // Titlebar actions connect(titlebar, SIGNAL(tMouseLeftPress(QMouseEvent *)), SLOT(titlebarMousePress(QMouseEvent *))); connect(titlebar, SIGNAL(tMouseMove(QMouseEvent *)), SLOT(titlebarMove(QMouseEvent *))); if (dblClickMinimize) { connect(titlebar, SIGNAL(tMouseDblClick()), SLOT(iconify())); } // Bottombar actions connect(bottombar, SIGNAL(tMouseLeftPress(QMouseEvent *)), SLOT(bottombarMousePress(QMouseEvent *))); connect(bottombar, SIGNAL(tMouseMove(QMouseEvent *)), SLOT(bottombarMove(QMouseEvent *))); connect(bottombar, SIGNAL(tMouseRelease()), SLOT(bottombarMouseRelease())); setLayout(layout); }
void Manager::createTitle() { leftButtonList_.clear(); rightButtonList_.clear(); TQString buttons; if (options()->customButtonPositions()) buttons = options()->titleButtonsLeft() + "|" + options()->titleButtonsRight(); else buttons = "XSH|IA"; TQPtrList<Button> *buttonList = &leftButtonList_; for (unsigned int i = 0; i < buttons.length(); ++i) { Button * tb = NULL; switch (buttons[i].latin1()) { case 'S': // Sticky tb = new StickyButton(widget()); connect(this, TQT_SIGNAL(stickyChanged(bool)), tb, TQT_SLOT(setOn(bool))); connect(tb, TQT_SIGNAL(toggleSticky()), this, TQT_SLOT(slotToggleSticky())); emit(stickyChanged(isOnAllDesktops())); break; case 'H': // Help if (providesContextHelp()) { tb = new HelpButton(widget()); connect(tb, TQT_SIGNAL(help()), this, TQT_SLOT(showContextHelp())); } break; case 'I': // Minimize if (isMinimizable()) { tb = new IconifyButton(widget()); connect(tb, TQT_SIGNAL(iconify()), this, TQT_SLOT(minimize())); } break; case 'A': // Maximize if (isMaximizable()) { tb = new MaximiseButton(widget()); connect(tb, TQT_SIGNAL(maximizeClicked(ButtonState)), this, TQT_SLOT(slotMaximizeClicked(ButtonState))); connect(this, TQT_SIGNAL(maximizeChanged(bool)), tb, TQT_SLOT(setOn(bool))); emit(maximizeChanged(maximizeMode() == MaximizeFull)); } break; case 'F': // Above tb = new AboveButton(widget()); connect(tb, TQT_SIGNAL(above()), this, TQT_SLOT(slotAbove())); break; case 'B': // Lower tb = new LowerButton(widget()); connect(tb, TQT_SIGNAL(lower()), this, TQT_SLOT(slotLower())); break; case 'X': // Close if (isCloseable()) { tb = new CloseButton(widget()); connect(tb, TQT_SIGNAL(closeWindow()), this, TQT_SLOT(closeWindow())); } break; case '|': buttonList = &rightButtonList_; break; } if (tb != NULL) { connect(this, TQT_SIGNAL(activeChanged(bool)), tb, TQT_SLOT(setActive(bool))); buttonList->append(tb); } }
xwindow::xwindow(Window w, QWidget *parent) : QWidget(parent) { dt = QApplication::desktop(); maxstate = 0; mrb = NULL; clientid = w; actpal = TRUE; urgpal = FALSE; cmapwins = NULL; sstate = FALSE; tstate = FALSE; trsize = FALSE; ncmaps = 0; withdrawnstate = unmapped = TRUE; // get ClassHint get_classhint(); clientname = res_class; // get flags for WM_COMMAND char **argv; int argc; if(XGetCommand(QX11Info::display(), w, &argv, &argc) && argc) { int ncm=0; while(1) { command += argv[ncm]; if(argc > ++ncm) command += ' '; else break; } if(clientname.isEmpty() && ! command.isEmpty()) { char *base; if((base = strrchr(argv[0], '/')) == NULL) base = argv[0]; else base++; clientname = base; } XFreeStringList(argv); } clientname = clientname.simplified(); pflags = get_clientflags(); if(pflags & WindowManager::SmallFrame) { uborderh = defaults::lowerborderheight; borderh = 2*uborderh; } else { uborderh = defaults::windowbuttonsize; borderh = defaults::windowbuttonsize+defaults::lowerborderheight; } // check for nonrectangular window shaped = (WindowManager::servershapes)?(query_shape()):(FALSE); if(pflags & WindowManager::NoResize) borderh -= defaults::lowerborderheight; // save window geometry Window root; uint bwidth,depth; XGetGeometry(QX11Info::display(), w, &root, &pos_x, &pos_y, &init_w, &init_h, &bwidth, &depth); base_w = init_w; base_h = init_h; init_h += borderh; // reparent XSetWindowBorderWidth(QX11Info::display(), w, 0); XSetWindowBorderWidth(QX11Info::display(), winId(), 0); XReparentWindow(QX11Info::display(), w, winId(), 0, uborderh); XAddToSaveSet(QX11Info::display(), w); // get TransientForHint transfor = None; XGetTransientForHint(QX11Info::display(), w, &transfor); // set Font setFont(defaults::borderfont); // get colormap and check for WM_COLORMAP_WINDOWS property get_colormaps(); // get WM_CLIENT_MACHINE XTextProperty prop; if(XGetWMClientMachine(QX11Info::display(), w, &prop) && prop.nitems && prop.format == 8) { clientfqdn = (char *)prop.value; if(defaults::showclientmachines) { int pos = clientfqdn.indexOf('.'); if(pos == -1) clientmachine = clientfqdn; else clientmachine = clientfqdn.left(pos); } } // get WMHints get_wmhints(); // get WMNormalhints get_wmnormalhints(); int cw = init_w; int ch = init_h; getsize(&cw, &ch); // window position if(wmnflags & USPosition) { if(wmnflags & PWinGravity && (wingrav == SouthWestGravity || wingrav == SouthEastGravity)) pos_y -= uborderh; } // a transient window with program specified position looks like a dialog box, // otherwise use autoplacement else if(! defaults::start_restart && (transfor == None || ! (wmnflags & PPosition))) { if(WindowManager::next_x+cw > dt->width()) { pos_x = 0; if(cw < dt->width()) WindowManager::next_x = 2*defaults::windowbuttonsize; } else { pos_x = WindowManager::next_x; WindowManager::next_x += 2*defaults::windowbuttonsize; } int sy,ey; if(defaults::toolbar_top) { sy = defaults::tb_height; ey = dt->height(); } else { sy = 0; ey = dt->height()-defaults::tb_height; } if(WindowManager::next_y+ch > ey) { pos_y = sy; if(ch < dt->height()) WindowManager::next_y = sy+2*defaults::windowbuttonsize; } else { pos_y = WindowManager::next_y; WindowManager::next_y += 2*defaults::windowbuttonsize; } } // move and resize XResizeWindow(QX11Info::display(), clientid, cw, ch-borderh); if(pos_y < 0) pos_y = 0; setGeometry(pos_x, pos_y, cw, ch); // overwrite Qt-defaults because we need SubstructureNotifyMask XSelectInput(QX11Info::display(), winId(), KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | KeymapStateMask | ButtonMotionMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask | ExposureMask | StructureNotifyMask | SubstructureRedirectMask | SubstructureNotifyMask); XSetWindowAttributes attr; attr.event_mask = ColormapChangeMask|PropertyChangeMask; XChangeWindowAttributes(QX11Info::display(), w, CWEventMask, &attr); // get WM protocols getwmprotocols(); // create window borders create_wborder(); // add client to lookup tables WindowManager::cwindows.insert(w, this); WindowManager::pwindows.insert(winId(), this); // get WM_NAME and set window title get_wmname(); if(shaped) reshape(); // init autofocus timer focustimer = new QTimer(this); Q_CHECK_PTR(focustimer); focustimer->setSingleShot(TRUE); connect(focustimer, SIGNAL(timeout()), SLOT(raise())); tfocustimer = new QTimer(this); // used for tiled mode Q_CHECK_PTR(tfocustimer); tfocustimer->setSingleShot(TRUE); connect(tfocustimer, SIGNAL(timeout()), SLOT(tile_maximize())); WindowManager::send_configurenotify(this); if(! urgent && ! defaults::starturgent) { setinactive(); } else { seturgent(); } if(defaults::start_restart) // restore original state { int clstate = get_clientstate(); if(clstate == IconicState) { iconify(); } else if(clstate == WithdrawnState) { withdraw(); } else map(); } else map(); #ifdef DEBUGMSG logmsg << "class xwindow constructed (WId:" << winId() << ")\n"; #endif }