1 /****************************************************************************
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the tools applications of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
44 #include <QApplication>
55 void fn_quit_qvfb(int)
57 // pretend that we have quit normally
62 void usage( const char *app
)
64 printf( "Usage: %s [-width width] [-height height] [-depth depth] [-zoom zoom]"
65 "[-mmap] [-nocursor] [-qwsdisplay :id] [-x11display :id] [-skin skindirectory]\n"
66 "Supported depths: 1, 4, 8, 12, 15, 16, 18, 24, 32\n", app
);
68 int qvfb_protocol
= 0;
70 int runQVfb( int argc
, char *argv
[] )
72 Q_INIT_RESOURCE(qvfb
);
74 QApplication
app( argc
, argv
);
78 int depth
= -32; // default, but overridable by skin
79 bool depthSet
= false;
82 QVFb::DisplayType displayType
= QVFb::QWS
;
84 QString
displaySpec( ":0" );
87 for ( int i
= 1; i
< argc
; i
++ ){
88 QString arg
= argv
[i
];
89 if ( arg
== "-width" ) {
90 width
= atoi( argv
[++i
] );
91 } else if ( arg
== "-height" ) {
92 height
= atoi( argv
[++i
] );
93 } else if ( arg
== "-skin" ) {
95 } else if ( arg
== "-depth" ) {
96 depth
= atoi( argv
[++i
] );
98 } else if ( arg
== "-nocursor" ) {
100 } else if ( arg
== "-mmap" ) {
102 } else if ( arg
== "-zoom" ) {
103 zoom
= atof( argv
[++i
] );
104 } else if ( arg
== "-qwsdisplay" ) {
105 displaySpec
= argv
[++i
];
106 displayType
= QVFb::QWS
;
108 } else if ( arg
== "-x11display" ) {
109 displaySpec
= argv
[++i
];
110 displayType
= QVFb::X11
;
112 // Usually only the default X11 depth will work with Xnest,
113 // so override the default of 32 with the actual X11 depth.
115 depth
= -QX11Info::appDepth(); // default, but overridable by skin
118 printf( "Unknown parameter %s\n", arg
.toLatin1().constData() );
125 QRegExp
r( ":[0-9]+" );
126 int m
= r
.indexIn( displaySpec
, 0 );
127 int len
= r
.matchedLength();
129 displayId
= displaySpec
.mid( m
+1, len
-1 ).toInt();
131 QRegExp
rotRegExp( "Rot[0-9]+" );
132 m
= rotRegExp
.indexIn( displaySpec
, 0 );
133 len
= rotRegExp
.matchedLength();
135 rotation
= displaySpec
.mid( m
+3, len
-3 ).toInt();
138 signal(SIGINT
, fn_quit_qvfb
);
139 signal(SIGTERM
, fn_quit_qvfb
);
141 QVFb
mw( displayId
, width
, height
, depth
, rotation
, skin
, displayType
);
143 //app.setMainWidget( &mw );
144 mw
.enableCursor(cursor
);
152 int main( int argc
, char *argv
[] )
154 return QT_PREPEND_NAMESPACE(runQVfb
)(argc
, argv
);