summaryrefslogtreecommitdiff
path: root/core/applets/vtapplet/vt.cpp
Unidiff
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
@@ -71,49 +71,57 @@ QIconSet VTApplet::icon ( ) const
71 QImage img = Resource::loadImage ( "terminal" ); 71 QImage img = Resource::loadImage ( "terminal" );
72 72
73 if ( !img. isNull ( )) 73 if ( !img. isNull ( ))
74 pix. convertFromImage ( img. smoothScale ( 14, 14 )); 74 pix. convertFromImage ( img. smoothScale ( 14, 14 ));
75 return pix; 75 return pix;
76} 76}
77 77
78QPopupMenu *VTApplet::popup ( QWidget* parent ) const 78QPopupMenu *VTApplet::popup ( QWidget* parent ) const
79{ 79{
80 odebug << "VTApplet::popup" << oendl; 80 odebug << "VTApplet::popup" << oendl;
81 81
82 struct vt_stat vtstat; 82 struct vt_stat vtstat;
83#ifdef QT_QWS_DEVFS
84 int fd = ::open( "/dev/vc/0", O_RDWR );
85#else
83 int fd = ::open( "/dev/tty0", O_RDWR ); 86 int fd = ::open( "/dev/tty0", O_RDWR );
87#endif
84 if ( fd == -1 ) return 0; 88 if ( fd == -1 ) return 0;
85 if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0; 89 if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0;
86 90
87 m_subMenu = new QPopupMenu( parent ); 91 m_subMenu = new QPopupMenu( parent );
88 m_subMenu->setCheckable( true ); 92 m_subMenu->setCheckable( true );
89 for ( int i = 1; i < 10; ++i ) 93 for ( int i = 1; i < 10; ++i )
90 { 94 {
91 int id = m_subMenu->insertItem( QString::number( i ), 500+i ); 95 int id = m_subMenu->insertItem( QString::number( i ), 500+i );
92 m_subMenu->setItemChecked( id, id-500 == vtstat.v_active ); 96 m_subMenu->setItemChecked( id, id-500 == vtstat.v_active );
93 } 97 }
94 ::close( fd ); 98 ::close( fd );
95 99
96 connect( m_subMenu, SIGNAL( activated(int) ), this, SLOT( changeVT(int) ) ); 100 connect( m_subMenu, SIGNAL( activated(int) ), this, SLOT( changeVT(int) ) );
97 connect( m_subMenu, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) ); 101 connect( m_subMenu, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) );
98 102
99 return m_subMenu; 103 return m_subMenu;
100} 104}
101 105
102 106
103void VTApplet::changeVT( int index ) 107void VTApplet::changeVT( int index )
104{ 108{
105 //odebug << "VTApplet::changeVT( " << index-500 << " )" << oendl; 109 //odebug << "VTApplet::changeVT( " << index-500 << " )" << oendl;
106 110
111#ifdef QT_QWS_DEVFS
112 int fd = ::open("/dev/vc/0", O_RDWR);
113#else
107 int fd = ::open("/dev/tty0", O_RDWR); 114 int fd = ::open("/dev/tty0", O_RDWR);
115#endif
108 if ( fd == -1 ) return; 116 if ( fd == -1 ) return;
109 ioctl( fd, VT_ACTIVATE, index-500 ); 117 ioctl( fd, VT_ACTIVATE, index-500 );
110} 118}
111 119
112 120
113void VTApplet::updateMenu() 121void VTApplet::updateMenu()
114{ 122{
115 //odebug << "VTApplet::updateMenu()" << oendl; 123 //odebug << "VTApplet::updateMenu()" << oendl;
116 124
117 int fd = ::open( "/dev/console", O_RDONLY ); 125 int fd = ::open( "/dev/console", O_RDONLY );
118 if ( fd == -1 ) return; 126 if ( fd == -1 ) return;
119 127