summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-09-22 12:06:07 (UTC)
committer mickeyl <mickeyl>2003-09-22 12:06:07 (UTC)
commitfd500184450e37c239e573adf1c12a6ff62b65f6 (patch) (unidiff)
tree2ce7fad7a9af7d17d1ab9495b1e32d353c5f08b0
parentbef84fa57fcb1ea5815ea55be7ac12b1a9df0c24 (diff)
downloadopie-fd500184450e37c239e573adf1c12a6ff62b65f6.zip
opie-fd500184450e37c239e573adf1c12a6ff62b65f6.tar.gz
opie-fd500184450e37c239e573adf1c12a6ff62b65f6.tar.bz2
FEATURE: vtapplet now indicates which virtual terminals are occupied
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/applets/vtapplet/vt.cpp39
-rw-r--r--core/applets/vtapplet/vt.h1
2 files changed, 30 insertions, 10 deletions
diff --git a/core/applets/vtapplet/vt.cpp b/core/applets/vtapplet/vt.cpp
index 6200447..4cc2d60 100644
--- a/core/applets/vtapplet/vt.cpp
+++ b/core/applets/vtapplet/vt.cpp
@@ -29,14 +29,6 @@
29 29
30#include "vt.h" 30#include "vt.h"
31 31
32class VTPopupMenu : public QPopupMenu
33{
34 public:
35 VTPopupMenu( QWidget * parent=0, const char * name=0 ) : QPopupMenu( parent, name ) {};
36
37 virtual void activated() { qDebug( "VTPopupMenu::activated()" ); }
38};
39
40VTApplet::VTApplet ( ) 32VTApplet::VTApplet ( )
41 : QObject ( 0, "VTApplet" ), ref ( 0 ) 33 : QObject ( 0, "VTApplet" ), ref ( 0 )
42{ 34{
@@ -92,7 +84,7 @@ QPopupMenu *VTApplet::popup ( QWidget* parent ) const
92 if ( fd == -1 ) return 0; 84 if ( fd == -1 ) return 0;
93 if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0; 85 if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0;
94 86
95 submenu = new VTPopupMenu( parent ); 87 submenu = new QPopupMenu( parent );
96 submenu->setCheckable( true ); 88 submenu->setCheckable( true );
97 for ( int i = 1; i < 10; ++i ) 89 for ( int i = 1; i < 10; ++i )
98 { 90 {
@@ -102,6 +94,7 @@ QPopupMenu *VTApplet::popup ( QWidget* parent ) const
102 ::close( fd ); 94 ::close( fd );
103 95
104 connect( submenu, SIGNAL( activated(int) ), this, SLOT( changeVT(int) ) ); 96 connect( submenu, SIGNAL( activated(int) ), this, SLOT( changeVT(int) ) );
97 connect( submenu, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) );
105 98
106 return submenu; 99 return submenu;
107} 100}
@@ -109,13 +102,39 @@ QPopupMenu *VTApplet::popup ( QWidget* parent ) const
109 102
110void VTApplet::changeVT( int index ) 103void VTApplet::changeVT( int index )
111{ 104{
112 qDebug( "VTApplet::changeVT( %d )", index-500 ); 105 //qDebug( "VTApplet::changeVT( %d )", index-500 );
106
113 int fd = ::open("/dev/tty0", O_RDWR); 107 int fd = ::open("/dev/tty0", O_RDWR);
114 if ( fd == -1 ) return; 108 if ( fd == -1 ) return;
115 ioctl( fd, VT_ACTIVATE, index-500 ); 109 ioctl( fd, VT_ACTIVATE, index-500 );
116} 110}
117 111
118 112
113void VTApplet::updateMenu()
114{
115 //qDebug( "VTApplet::updateMenu()" );
116
117 int fd = ::open( "/dev/console", O_RDONLY );
118 if ( fd == -1 ) return;
119
120 for ( int i = 1; i < 10; ++i )
121 {
122 int result = ioctl( fd, VT_DISALLOCATE, i );
123
124 /*
125 if ( result == -1 )
126 qDebug( "VT %d disallocated == free", i );
127 else
128 qDebug( "VT %d _not_ disallocated == busy", i );
129 */
130
131 submenu->setItemEnabled( 500+i, result == -1 );
132 }
133
134 ::close( fd );
135}
136
137
119void VTApplet::activated() 138void VTApplet::activated()
120{ 139{
121 qDebug( "VTApplet::activated()" ); 140 qDebug( "VTApplet::activated()" );
diff --git a/core/applets/vtapplet/vt.h b/core/applets/vtapplet/vt.h
index 2df9791..6bdb9e0 100644
--- a/core/applets/vtapplet/vt.h
+++ b/core/applets/vtapplet/vt.h
@@ -43,6 +43,7 @@ public:
43 43
44public slots: 44public slots:
45 virtual void changeVT( int index ); 45 virtual void changeVT( int index );
46 virtual void updateMenu();
46 47
47private: 48private:
48 ulong ref; 49 ulong ref;