int Frame::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QFrame::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: press_top_mid((*reinterpret_cast< QMouseEvent*(*)>(_a[1]))); break; case 1: move_top_mid((*reinterpret_cast< QMouseEvent*(*)>(_a[1]))); break; case 2: press_bottom_left((*reinterpret_cast< QMouseEvent*(*)>(_a[1]))); break; case 3: move_bottom_left((*reinterpret_cast< QMouseEvent*(*)>(_a[1]))); break; case 4: press_bottom_right((*reinterpret_cast< QMouseEvent*(*)>(_a[1]))); break; case 5: move_bottom_right((*reinterpret_cast< QMouseEvent*(*)>(_a[1]))); break; case 6: press_bottom_mid((*reinterpret_cast< QMouseEvent*(*)>(_a[1]))); break; case 7: move_bottom_mid((*reinterpret_cast< QMouseEvent*(*)>(_a[1]))); break; case 8: press_right((*reinterpret_cast< QMouseEvent*(*)>(_a[1]))); break; case 9: move_right((*reinterpret_cast< QMouseEvent*(*)>(_a[1]))); break; case 10: press_left((*reinterpret_cast< QMouseEvent*(*)>(_a[1]))); break; case 11: move_left((*reinterpret_cast< QMouseEvent*(*)>(_a[1]))); break; case 12: destroy_it(); break; case 13: maximize_it(); break; case 14: iconify_it(); break; case 15: dragEnterEvent((*reinterpret_cast< QDragEnterEvent*(*)>(_a[1]))); break; case 16: dragMoveEvent((*reinterpret_cast< QDragMoveEvent*(*)>(_a[1]))); break; case 17: dropEvent((*reinterpret_cast< QDropEvent*(*)>(_a[1]))); break; default: ; } _id -= 18; } return _id; }
void Frame::init() { maximized = false; set_state(1); state = "WithdrawnState"; shaped = false; XSelectInput(QX11Info::display(), winId(), KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | KeymapStateMask | ButtonMotionMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask | VisibilityChangeMask | ExposureMask | StructureNotifyMask | SubstructureRedirectMask | SubstructureNotifyMask); XSetWindowAttributes at; at.event_mask = ColormapChangeMask|PropertyChangeMask; XChangeWindowAttributes(QX11Info::display(), c_win, CWEventMask, &at); XGrabServer(QX11Info::display()); // get the client geometry get_client_geometry(); // get the client hints get_wm_hints(); // get the client normal hints get_wm_normal_hints(); // get the client prot get_wm_protocols(); // get the client icon to show on header get_icon(); // get the client name get_wm_name(); // set the frame geometry set_frame_geometry(); // set the window modality set_window_modality(); shaped = query_shape(); if (shaped) reshape(); XSetWindowBorderWidth(QX11Info::display(), c_win, 0); //client XSetWindowBorderWidth(QX11Info::display(), winId(), 0); //frame // *** THE MOST IMPORTANT FUNCTION *** // reparent client with frame XReparentWindow(QX11Info::display(), c_win, winId(), lateral_bdr_width, top_bdr_height); qDebug() << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"; qDebug() << "Reparent Client:" << c_win << "with Frame:" << winId() << "- Name:" << cl_name(); qDebug() << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"; XAddToSaveSet(QX11Info::display(), c_win); // move and resize client XMoveResizeWindow(QX11Info::display(), c_win, lateral_bdr_width, top_bdr_height+3, client_w, client_h); //if the frame is too large, maximize it if (frame_w >= QApplication::desktop()->width()-20 || frame_h >= QApplication::desktop()->height()-40) { maximize_it(); } else // normal size { // move the frame in desktop center and resize move((QApplication::desktop()->width()/2)-(frame_w/2), (QApplication::desktop()->height()/2)-(frame_h/2)); resize(frame_w, frame_h); } qDebug() << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"; qDebug() << "Frame_x:" << frame_x << "Frame_y:" << frame_y << "Frame_w:" << frame_w << "Frame_h:" << frame_h; qDebug() << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << "\n"; if (frame_type != "Splash") // Splash frame have no header and no border { // create frame borders/header create_borders(); // set the header pixmap set_inactive(); splash = false; } else { qDebug() << "Frame:" << winId() << "Name:" << wm_name << "is Splash type"; splash = true; } // send _NET_ACTIVE_WINDOW property Atom _net_active_window = XInternAtom(QX11Info::display(), "_NET_ACTIVE_WINDOW", False); XClientMessageEvent xev; xev.type = ClientMessage; xev.window = c_win; xev.message_type = _net_active_window; xev.format = 32; xev.data.l[0] = 1; // from application xev.data.l[1] = CurrentTime; xev.data.l[2] = 0; XSendEvent(QX11Info::display(), QApplication::desktop()->winId(), False, StructureNotifyMask, (XEvent *)&xev); // map client XMapWindow(QX11Info::display(), c_win); XSync(QX11Info::display(), false); XUngrabServer(QX11Info::display()); // show frame show(); }
void Frame::create_borders() { layout = new QGridLayout(this); // 3x3 grid for window borders layout->setMargin(0); layout->setSpacing(0); setLayout(layout); // center frame where client apps is shown c_bdr = new Border(this); layout->addWidget(c_bdr, 1, 1); // top left border (icon) tl_bdr = new Border(this); tl_bdr->setToolTip(tr("Minimize(L)/Maximize(R)")); tl_bdr->setFixedSize(top_bdr_height, top_bdr_height); tl_bdr->setPixmap(minmax_pix); tl_bdr->setScaledContents(true); tl_bdr->setAlignment(Qt::AlignCenter); layout->addWidget(tl_bdr, 0, 0); // top right border (icon) tr_bdr = new Border(this); tr_bdr->setToolTip(tr("Close")); tr_bdr->setFixedSize(top_bdr_height, top_bdr_height); tr_bdr->setPixmap(close_pix); tr_bdr->setScaledContents(true); tr_bdr->setAlignment(Qt::AlignCenter); layout->addWidget(tr_bdr, 0, 2); // top mid header border (header frame) tm_bdr = new Header(cl_icon(), cl_name(), this); tm_bdr->set_pixmap(QPixmap(header_active_pix), QPixmap(header_inactive_pix), title_color); tm_bdr->setFixedHeight(top_bdr_height); layout->addWidget(tm_bdr, 0, 1); // bottom mid border bm_bdr = new Border(this); bm_bdr->setFixedHeight(bottom_bdr_height); bm_bdr->setCursor(Qt::SizeVerCursor); layout->addWidget(bm_bdr, 2, 1); // bottom left border bl_bdr = new Border(this); bl_bdr->setFixedSize(top_bdr_height, bottom_bdr_height); bl_bdr->setCursor(Qt::SizeBDiagCursor); layout->addWidget(bl_bdr, 2, 0); // bottom right border br_bdr = new Border(this); br_bdr->setFixedSize(top_bdr_height, bottom_bdr_height); br_bdr->setCursor(Qt::SizeFDiagCursor); layout->addWidget(br_bdr, 2, 2); // left border l_bdr = new Border(this); l_bdr->setCursor(Qt::SizeHorCursor); layout->addWidget(l_bdr, 1, 0); // right border r_bdr = new Border(this); r_bdr->setCursor(Qt::SizeHorCursor); layout->addWidget(r_bdr, 1, 2); if (frame_type == "Dialog") // no Max/Min on Dialog frames { tl_bdr->setEnabled(false); } // top left (icon) connect(tl_bdr, SIGNAL(mouse_left_press()), this, SLOT(iconify_it())); connect(tl_bdr, SIGNAL(mouse_right_press()), this, SLOT(maximize_it())); // top right (icon) connect(tr_bdr, SIGNAL(mouse_left_press()), this, SLOT(destroy_it())); // top mid (title bar) connect(tm_bdr, SIGNAL(mouse_double_click()), this, SLOT(iconify_it())); connect(tm_bdr, SIGNAL(mouse_left_press(QMouseEvent *)), this, SLOT(press_top_mid(QMouseEvent *))); connect(tm_bdr, SIGNAL(mouse_right_press()), this, SLOT(maximize_it())); connect(tm_bdr, SIGNAL(mouse_move(QMouseEvent *)), this, SLOT(move_top_mid(QMouseEvent *))); // bottom left connect(bl_bdr, SIGNAL(mouse_left_press(QMouseEvent *)), this, SLOT(press_bottom_left(QMouseEvent *))); connect(bl_bdr, SIGNAL(mouse_move(QMouseEvent *)), this, SLOT(move_bottom_left(QMouseEvent *))); // bottom right connect(br_bdr, SIGNAL(mouse_left_press(QMouseEvent *)), this, SLOT(press_bottom_right(QMouseEvent *))); connect(br_bdr, SIGNAL(mouse_move(QMouseEvent *)), this, SLOT(move_bottom_right(QMouseEvent *))); // bottom mid connect(bm_bdr, SIGNAL(mouse_left_press(QMouseEvent *)), this, SLOT(press_bottom_mid(QMouseEvent *))); connect(bm_bdr, SIGNAL(mouse_move(QMouseEvent *)), this, SLOT(move_bottom_mid(QMouseEvent *))); // left connect(l_bdr, SIGNAL(mouse_left_press(QMouseEvent *)), this, SLOT(press_left(QMouseEvent *))); connect(l_bdr, SIGNAL(mouse_move(QMouseEvent *)), this, SLOT(move_left(QMouseEvent *))); // right connect(r_bdr, SIGNAL(mouse_left_press(QMouseEvent *)), this, SLOT(press_right(QMouseEvent *))); connect(r_bdr, SIGNAL(mouse_move(QMouseEvent *)), this, SLOT(move_right(QMouseEvent *))); }