Ejemplo n.º 1
0
QPixmap WindowGrabber::grabCurrent( bool includeDecorations )
{
    int x, y;
#ifdef Q_WS_X11
    Window root;
    uint w, h, border, depth;

    XGrabServer( QX11Info::display() );
    Window child = windowUnderCursor( includeDecorations );
    XGetGeometry( QX11Info::display(), child, &root, &x, &y, &w, &h, &border, &depth );

    Window parent;
    Window* children;
    unsigned int nchildren;

    if( XQueryTree( QX11Info::display(), child, &root, &parent,
                    &children, &nchildren ) != 0 ) {
        if( children != NULL ) {
            XFree( children );
        }

        int newx, newy;
        Window dummy;

        if( XTranslateCoordinates( QX11Info::display(), parent, QX11Info::appRootWindow(),
            x, y, &newx, &newy, &dummy )) {
            x = newx;
            y = newy;
        }
    }

    windowPosition = QPoint(x,y);
    QPixmap pm( grabWindow( child, x, y, w, h, border, &title, &windowClass ) );
    XUngrabServer( QX11Info::display() );
    return pm;
#elif defined(Q_WS_WIN)
    HWND hWindow;
    hWindow = windowUnderCursor(includeDecorations);
    Q_ASSERT(hWindow);

    HWND hParent;

// Now find the top-most window
    do {
      hParent = hWindow;
    } while( (hWindow = GetParent(hWindow)) != NULL );
    Q_ASSERT(hParent);

    RECT r;
    GetWindowRect(hParent, &r);

    x = r.left;
    y = r.top;

    windowPosition = QPoint(x,y);
    QPixmap pm( grabWindow( hParent, &title, &windowClass) );
    return pm;
#endif // Q_WS_X11
    return QPixmap();
}
Ejemplo n.º 2
0
WindowGrabber::WindowGrabber()
: QDialog( 0, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint ),
  current( -1 ), yPos( -1 )
{
    setWindowModality( Qt::WindowModal );
    int y,x;
    uint w, h;

#ifdef Q_WS_X11
    uint border, depth;
    Window root;
    XGrabServer( QX11Info::display() );
    Window child = windowUnderCursor();
    XGetGeometry( QX11Info::display(), child, &root, &x, &y, &w, &h, &border, &depth );
    XUngrabServer( QX11Info::display() );

    QPixmap pm( grabWindow( child, x, y, w, h, border, &title, &windowClass ) );
#elif defined(Q_WS_WIN)
    HWND child = windowUnderCursor();

    WINDOWINFO wi;
    GetWindowInfo( child, &wi);

    RECT r;
    GetWindowRect( child, &r);
    x = r.left;
    y = r.top;
    w = r.right - r.left;
    h = r.bottom - r.top;
    cxWindowBorder = wi.cxWindowBorders;
    cyWindowBorder = wi.cyWindowBorders;

    HDC childDC = GetDC(child);

    QPixmap pm( grabWindow( child, &title, &windowClass ) );
#endif // Q_WS_X11

    getWindowsRecursive( &windows, child );

    QPalette p = palette();
    p.setBrush( backgroundRole(), QBrush( pm ) );
    setPalette( p );
    setFixedSize( pm.size() );
    setMouseTracking( true );
    setGeometry( x, y, w, h );
    current = windowIndex( mapFromGlobal(QCursor::pos()) );
}
Ejemplo n.º 3
0
void TcpSockServer::incomingConnection(int socketDescriptor)
{
    qRegisterMetaType <Qlist>("Qlist");

   // qDebug() << QString("Client %1 Comming").arg(socketDescriptor);
    TcpConThread *thread = new TcpConThread(socketDescriptor, this);
//    connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
    connect(this,SIGNAL(sendKeySettingRequest(Device,RegOperation)),
            thread,SLOT(sendKeySettingRequest(Device,RegOperation)));
    connect(this,SIGNAL(grabWindow()),thread,SLOT(sendGrabWindowRequest()));
    connect(thread,SIGNAL(processData(Qlist)),
            this,SIGNAL(processData(Qlist)));
    thread->start();
}
Ejemplo n.º 4
0
QPixmap grabEntireScreen() {
    auto screen = qApp->screens().first();
    auto desktopWId = qApp->desktop()->winId();
    return screen->grabWindow(desktopWId);
}
Ejemplo n.º 5
0
KJS::Value Pixmap::call( KJS::ExecState *exec, KJS::Object &self, const KJS::List &args ) {

    if( !JSProxy::checkType( self, JSProxy::ValueProxy, "QPixmap") )
        return KJS::Value();

    JSValueProxy *op = JSProxy::toValueProxy( self.imp() );
    pix = op->toVariant().toPixmap();

    KJS::Value retValue = KJS::Value();
    switch ( mid ) {
    case Methodwidth:
        retValue = KJS::Number(width());
        break;
    case Methodheight:
        retValue = KJS::Number(height());
        break;
    case Methoddepth:
        retValue = KJS::Number(depth());
        break;
    case MethodisNull:
        retValue = KJS::Boolean(isNull());
        break;
    case Methodsize:
        retValue = convertToValue(exec, size());
        break;
    case Methodrect:
        retValue = convertToValue(exec, rect());
        break;
    case Methodresize:
    {
        if( args.size() == 2)
		resize(extractInt(exec, args, 0), extractInt(exec, args, 1));
	else if( args.size() == 1)
	    resize(extractQSize(exec, args, 0) );
	break;
    }
    case Methodfill:
        fill( extractQColor(exec, args, 0));
        break;
    case Methodmask:
    {
        retValue = convertToValue(exec, mask() );
        break;
    }
    case MethodsetMask:
    {
       setMask(extractQPixmap(exec, args, 0));
       break;
    }
    case MethodcreateHeuristicMask:
    {
       retValue = convertToValue(exec, createHeuristicMask(extractBool(exec, args, 0)));
       break;
    }
    case MethodgrabWindow:
    {
    	int winid = extractInt(exec, args,0);
	int x = extractInt(exec, args,1);
	int y = extractInt(exec, args,2);
	int w = extractInt(exec, args,3);
	int h = extractInt(exec, args,4);
    	grabWindow(winid,x,y,w,h);
	break;
    }
    default:
        kdWarning() << "Image has no method " << mid << endl;
        break;
    }

    op->setValue(pix);
    return retValue;
}