summaryrefslogtreecommitdiff
path: root/core/applets/vtapplet/vt.cpp
authorschurig <schurig>2004-09-10 12:18:17 (UTC)
committer schurig <schurig>2004-09-10 12:18:17 (UTC)
commit9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521 (patch) (side-by-side diff)
tree53927c6a19c69d54bb3d0e092ac57180bcb60222 /core/applets/vtapplet/vt.cpp
parented70ec4945c7816ec6e899207ec8b99e20e10da5 (diff)
downloadopie-9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521.zip
opie-9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521.tar.gz
opie-9d0ccc1c5ca687bc017b2b515a9d3a47e98ce521.tar.bz2
added support for DEVFS
Diffstat (limited to 'core/applets/vtapplet/vt.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/applets/vtapplet/vt.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/core/applets/vtapplet/vt.cpp b/core/applets/vtapplet/vt.cpp
index aec63c3..7832ee0 100644
--- a/core/applets/vtapplet/vt.cpp
+++ b/core/applets/vtapplet/vt.cpp
@@ -59,73 +59,81 @@ QString VTApplet::tr( const char* s ) const
return qApp->translate( "VTApplet", s, 0 );
}
QString VTApplet::tr( const char* s, const char* p ) const
{
return qApp->translate( "VTApplet", s, p );
}
*/
QIconSet VTApplet::icon ( ) const
{
QPixmap pix;
QImage img = Resource::loadImage ( "terminal" );
if ( !img. isNull ( ))
pix. convertFromImage ( img. smoothScale ( 14, 14 ));
return pix;
}
QPopupMenu *VTApplet::popup ( QWidget* parent ) const
{
odebug << "VTApplet::popup" << oendl;
struct vt_stat vtstat;
+#ifdef QT_QWS_DEVFS
+ int fd = ::open( "/dev/vc/0", O_RDWR );
+#else
int fd = ::open( "/dev/tty0", O_RDWR );
+#endif
if ( fd == -1 ) return 0;
if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0;
m_subMenu = new QPopupMenu( parent );
m_subMenu->setCheckable( true );
for ( int i = 1; i < 10; ++i )
{
int id = m_subMenu->insertItem( QString::number( i ), 500+i );
m_subMenu->setItemChecked( id, id-500 == vtstat.v_active );
}
::close( fd );
connect( m_subMenu, SIGNAL( activated(int) ), this, SLOT( changeVT(int) ) );
connect( m_subMenu, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) );
return m_subMenu;
}
void VTApplet::changeVT( int index )
{
//odebug << "VTApplet::changeVT( " << index-500 << " )" << oendl;
+#ifdef QT_QWS_DEVFS
+ int fd = ::open("/dev/vc/0", O_RDWR);
+#else
int fd = ::open("/dev/tty0", O_RDWR);
+#endif
if ( fd == -1 ) return;
ioctl( fd, VT_ACTIVATE, index-500 );
}
void VTApplet::updateMenu()
{
//odebug << "VTApplet::updateMenu()" << oendl;
int fd = ::open( "/dev/console", O_RDONLY );
if ( fd == -1 ) return;
for ( int i = 1; i < 10; ++i )
{
int result = ioctl( fd, VT_DISALLOCATE, i );
/*
if ( result == -1 )
odebug << "VT " << i << " disallocated == free" << oendl;
else
odebug << "VT " << i << " _not_ disallocated == busy" << oendl;
*/
m_subMenu->setItemEnabled( 500+i, result == -1 );