summaryrefslogtreecommitdiff
authorsandman <sandman>2002-07-28 00:44:43 (UTC)
committer sandman <sandman>2002-07-28 00:44:43 (UTC)
commit72081cbfef03a69ed6f9ca7826854b6cf10dc2fe (patch) (unidiff)
tree43e67bdc7cbb972f431b3912e2f068df3d2c97bf
parent4baf36396739502c5471950e29f18954cca4517b (diff)
downloadopie-72081cbfef03a69ed6f9ca7826854b6cf10dc2fe.zip
opie-72081cbfef03a69ed6f9ca7826854b6cf10dc2fe.tar.gz
opie-72081cbfef03a69ed6f9ca7826854b6cf10dc2fe.tar.bz2
Workaround for a weird Qt/E bug, resulting in qpe hanging if clipboard
applet is loaded and qpe is terminated via shutdown applet.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/applets/clipboardapplet/clipboard.cpp15
-rw-r--r--core/applets/clipboardapplet/clipboard.h4
-rw-r--r--core/launcher/desktop.cpp6
3 files changed, 22 insertions, 3 deletions
diff --git a/core/applets/clipboardapplet/clipboard.cpp b/core/applets/clipboardapplet/clipboard.cpp
index 5848d0f..4fbdf6f 100644
--- a/core/applets/clipboardapplet/clipboard.cpp
+++ b/core/applets/clipboardapplet/clipboard.cpp
@@ -77,112 +77,121 @@ static const char * paste_xpm[] = {
77 "bc #FAF6F3", 77 "bc #FAF6F3",
78 "cc #AEAEAE", 78 "cc #AEAEAE",
79 "dc #C29A6A", 79 "dc #C29A6A",
80 "ec #FEFEFE", 80 "ec #FEFEFE",
81 "fc #B6B6B6", 81 "fc #B6B6B6",
82 "gc #7E7E7E", 82 "gc #7E7E7E",
83 "hc #FAF2E6", 83 "hc #FAF2E6",
84 "ic #8E8E8E", 84 "ic #8E8E8E",
85 "jc #C6BCAE", 85 "jc #C6BCAE",
86 "kc #DEDEDE", 86 "kc #DEDEDE",
87 "lc #BEBEBE", 87 "lc #BEBEBE",
88 "mc #464646", 88 "mc #464646",
89 "nc #BEAE92", 89 "nc #BEAE92",
90 "oc #262626", 90 "oc #262626",
91 "pc #F2E2CE", 91 "pc #F2E2CE",
92 "qc #C2A175", 92 "qc #C2A175",
93 "rc #CACACA", 93 "rc #CACACA",
94 "sc #969696", 94 "sc #969696",
95 "tc #8A8A8A", 95 "tc #8A8A8A",
96 "uc #828282", 96 "uc #828282",
97 "vc #6A6A6A", 97 "vc #6A6A6A",
98 "wc #BEB6AE", 98 "wc #BEB6AE",
99 "xc #E2E0E0", 99 "xc #E2E0E0",
100 "yc #7A7A7A", 100 "yc #7A7A7A",
101" *{>; ", 101" *{>; ",
102" }}}@e:!;}}} ", 102" }}}@e:!;}}} ",
103"<x8=&:#@+;ll, ", 103"<x8=&:#@+;ll, ",
104"}k/=;;3}337|o ", 104"}k/=;;3}337|o ",
105"<k's24444m45o ", 105"<k's24444m45o ",
106"}8'ss4xkkk]}a ", 106"}8'ss4xkkk]}a ",
107"<1s224keee|b4 ", 107"<1s224keee|b4 ",
108"}r2itmkeee]]44", 108"}r2itmkeee]]44",
109"<9iitmkeeehkw.", 109"<9iitmkeeehkw.",
110"<lt-u4keeb)pn.", 110"<lt-u4keeb)pn.",
111"<fu-umkebhp(0.", 111"<fu-umkebhp(0.",
112"<cugg4kbh)_(q.", 112"<cugg4kbh)_(q.",
113"<cyyymk))p(%q.", 113"<cyyymk))p(%q.",
114",5vvv4k)p_%[q.", 114",5vvv4k)p_%[q.",
115" ...$mljnn0qd.", 115" ...$mljnn0qd.",
116" 4.......,"}; 116" 4.......,"};
117 117
118 118
119ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) 119ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name )
120{ 120{
121 setFixedWidth ( 14 ); 121 setFixedWidth ( 14 );
122 setFixedHeight ( 18 ); 122 setFixedHeight ( 18 );
123 m_clipboardPixmap = QPixmap ( paste_xpm ); 123 m_clipboardPixmap = QPixmap ( paste_xpm );
124 124
125 QTimer *timer = new QTimer ( this ); 125 m_timer = new QTimer ( this );
126 126
127 connect ( QApplication::clipboard ( ), SIGNAL( dataChanged ( )), this, SLOT( newData ( ))); 127 connect ( QApplication::clipboard ( ), SIGNAL( dataChanged ( )), this, SLOT( newData ( )));
128 connect ( timer, SIGNAL( timeout ( )), this, SLOT( newData ( ))); 128 connect ( m_timer, SIGNAL( timeout ( )), this, SLOT( newData ( )));
129 connect ( qApp, SIGNAL( aboutToQuit ( )), this, SLOT( shutdown ( )));
129 130
130 timer-> start ( 1000 ); 131 m_timer-> start ( 1500 );
131 132
132 m_menu = 0; 133 m_menu = 0;
133 m_dirty = true; 134 m_dirty = true;
134 m_lasttext = QString::null; 135 m_lasttext = QString::null;
135} 136}
136 137
137ClipboardApplet::~ClipboardApplet ( ) 138ClipboardApplet::~ClipboardApplet ( )
138{ 139{
139} 140}
140 141
142void ClipboardApplet::shutdown ( )
143{
144 // the timer has to be stopped, or Qt/E will hang on quit()
145 // see launcher/desktop.cpp
146
147 m_timer-> stop ( );
148}
149
141void ClipboardApplet::mousePressEvent ( QMouseEvent *) 150void ClipboardApplet::mousePressEvent ( QMouseEvent *)
142{ 151{
143 if ( m_dirty ) { 152 if ( m_dirty ) {
144 delete m_menu; 153 delete m_menu;
145 154
146 m_menu = new QPopupMenu ( this ); 155 m_menu = new QPopupMenu ( this );
147 m_menu-> setCheckable ( true ); 156 m_menu-> setCheckable ( true );
148 157
149 if ( m_history. count ( )) { 158 if ( m_history. count ( )) {
150 for ( unsigned int i = 0; i < m_history. count ( ); i++ ) { 159 for ( unsigned int i = 0; i < m_history. count ( ); i++ ) {
151 QString str = m_history [i]; 160 QString str = m_history [i];
152 161
153 if ( str. length ( ) > 20 ) 162 if ( str. length ( ) > 20 )
154 str = str. left ( 20 ) + "..."; 163 str = str. left ( 20 ) + "...";
155 164
156 m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i ); 165 m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i );
157 m_menu-> setItemChecked ( i, false ); 166 m_menu-> setItemChecked ( i, false );
158 } 167 }
159 m_menu-> setItemChecked ( m_history. count ( ) - 1, true ); 168 m_menu-> setItemChecked ( m_history. count ( ) - 1, true );
160 m_menu-> insertSeparator ( ); 169 m_menu-> insertSeparator ( );
161 } 170 }
162 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "cut" )), tr( "Cut" ), 100 ); 171 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "cut" )), tr( "Cut" ), 100 );
163 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "copy" )), tr( "Copy" ), 101 ); 172 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "copy" )), tr( "Copy" ), 101 );
164 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "paste" )), tr( "Paste" ), 102 ); 173 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "paste" )), tr( "Paste" ), 102 );
165 174
166 connect ( m_menu, SIGNAL( activated ( int )), this, SLOT( action ( int ))); 175 connect ( m_menu, SIGNAL( activated ( int )), this, SLOT( action ( int )));
167 176
168 m_dirty = false; 177 m_dirty = false;
169 } 178 }
170 QPoint p = mapToGlobal ( QPoint ( 0, 0 )); 179 QPoint p = mapToGlobal ( QPoint ( 0, 0 ));
171 QSize s = m_menu-> sizeHint ( ); 180 QSize s = m_menu-> sizeHint ( );
172 181
173 m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( ))); 182 m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( )));
174} 183}
175 184
176void ClipboardApplet::action(int id) 185void ClipboardApplet::action(int id)
177{ 186{
178 ushort unicode = 0; 187 ushort unicode = 0;
179 int scan = 0; 188 int scan = 0;
180 189
181 switch ( id ) { 190 switch ( id ) {
182 case 100: 191 case 100:
183 unicode = 'X' - '@'; 192 unicode = 'X' - '@';
184 scan = Key_X; // Cut 193 scan = Key_X; // Cut
185 break; 194 break;
186 case 101: 195 case 101:
187 unicode = 'C' - '@'; 196 unicode = 'C' - '@';
188 scan = Key_C; // Copy 197 scan = Key_C; // Copy
diff --git a/core/applets/clipboardapplet/clipboard.h b/core/applets/clipboardapplet/clipboard.h
index 84743d9..ec87d39 100644
--- a/core/applets/clipboardapplet/clipboard.h
+++ b/core/applets/clipboardapplet/clipboard.h
@@ -1,53 +1,57 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef __CLIPBOARD_APPLET_H__ 20#ifndef __CLIPBOARD_APPLET_H__
21#define __CLIPBOARD_APPLET_H__ 21#define __CLIPBOARD_APPLET_H__
22 22
23#include <qwidget.h> 23#include <qwidget.h>
24#include <qpixmap.h> 24#include <qpixmap.h>
25#include <qstringlist.h> 25#include <qstringlist.h>
26 26
27class QTimer;
28
27class ClipboardApplet : public QWidget 29class ClipboardApplet : public QWidget
28{ 30{
29 Q_OBJECT 31 Q_OBJECT
30public: 32public:
31 ClipboardApplet ( QWidget *parent = 0, const char *name=0 ); 33 ClipboardApplet ( QWidget *parent = 0, const char *name=0 );
32 ~ClipboardApplet ( ); 34 ~ClipboardApplet ( );
33 35
34protected: 36protected:
35 void mousePressEvent ( QMouseEvent *); 37 void mousePressEvent ( QMouseEvent *);
36 void paintEvent ( QPaintEvent* ); 38 void paintEvent ( QPaintEvent* );
37 39
38private slots: 40private slots:
39 void action ( int ); 41 void action ( int );
40 void newData ( ); 42 void newData ( );
43 void shutdown ( );
41 44
42private: 45private:
43 QPopupMenu * m_menu; 46 QPopupMenu * m_menu;
44 QStringList m_history; 47 QStringList m_history;
45 bool m_dirty; 48 bool m_dirty;
46 QString m_lasttext; 49 QString m_lasttext;
50 QTimer * m_timer;
47 51
48 QPixmap m_clipboardPixmap; 52 QPixmap m_clipboardPixmap;
49}; 53};
50 54
51 55
52#endif // __CLIPBOARD_APPLET_H__ 56#endif // __CLIPBOARD_APPLET_H__
53 57
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index e58b08c..f90da1a 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -641,96 +641,102 @@ void Desktop::toggleSymbolInput()
641 tb->toggleSymbolInput(); 641 tb->toggleSymbolInput();
642} 642}
643 643
644void Desktop::toggleNumLockState() 644void Desktop::toggleNumLockState()
645{ 645{
646 tb->toggleNumLockState(); 646 tb->toggleNumLockState();
647} 647}
648 648
649void Desktop::toggleCapsLockState() 649void Desktop::toggleCapsLockState()
650{ 650{
651 tb->toggleCapsLockState(); 651 tb->toggleCapsLockState();
652} 652}
653 653
654void Desktop::styleChange( QStyle &s ) 654void Desktop::styleChange( QStyle &s )
655{ 655{
656 QWidget::styleChange( s ); 656 QWidget::styleChange( s );
657 int displayw = qApp->desktop()->width(); 657 int displayw = qApp->desktop()->width();
658 int displayh = qApp->desktop()->height(); 658 int displayh = qApp->desktop()->height();
659 659
660 QSize sz = tb->sizeHint(); 660 QSize sz = tb->sizeHint();
661 661
662 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 662 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
663} 663}
664 664
665void DesktopApplication::shutdown() 665void DesktopApplication::shutdown()
666{ 666{
667 if ( type() != GuiServer ) 667 if ( type() != GuiServer )
668 return; 668 return;
669 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 669 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
670 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), 670 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)),
671 this, SLOT(shutdown(ShutdownImpl::Type)) ); 671 this, SLOT(shutdown(ShutdownImpl::Type)) );
672 sd->showMaximized(); 672 sd->showMaximized();
673} 673}
674 674
675void DesktopApplication::shutdown( ShutdownImpl::Type t ) 675void DesktopApplication::shutdown( ShutdownImpl::Type t )
676{ 676{
677 switch ( t ) { 677 switch ( t ) {
678 case ShutdownImpl::ShutdownSystem: 678 case ShutdownImpl::ShutdownSystem:
679 execlp("shutdown", "shutdown", "-h", "now", (void*)0); 679 execlp("shutdown", "shutdown", "-h", "now", (void*)0);
680 break; 680 break;
681 case ShutdownImpl::RebootSystem: 681 case ShutdownImpl::RebootSystem:
682 execlp("shutdown", "shutdown", "-r", "now", (void*)0); 682 execlp("shutdown", "shutdown", "-r", "now", (void*)0);
683 break; 683 break;
684 case ShutdownImpl::RestartDesktop: 684 case ShutdownImpl::RestartDesktop:
685 restart(); 685 restart();
686 break; 686 break;
687 case ShutdownImpl::TerminateDesktop: 687 case ShutdownImpl::TerminateDesktop:
688 prepareForTermination(FALSE); 688 prepareForTermination(FALSE);
689
690 // This is a workaround for a Qt bug
691 // clipboard applet has to stop its poll timer, or Qt/E
692 // will hang on quit() right before it emits aboutToQuit()
693 emit aboutToQuit ( );
694
689 quit(); 695 quit();
690 break; 696 break;
691 } 697 }
692} 698}
693 699
694void DesktopApplication::restart() 700void DesktopApplication::restart()
695{ 701{
696 prepareForTermination(TRUE); 702 prepareForTermination(TRUE);
697 703
698#ifdef Q_WS_QWS 704#ifdef Q_WS_QWS
699 for ( int fd = 3; fd < 100; fd++ ) 705 for ( int fd = 3; fd < 100; fd++ )
700 close( fd ); 706 close( fd );
701#if defined(QT_DEMO_SINGLE_FLOPPY) 707#if defined(QT_DEMO_SINGLE_FLOPPY)
702 execl( "/sbin/init", "qpe", 0 ); 708 execl( "/sbin/init", "qpe", 0 );
703#elif defined(QT_QWS_CASSIOPEIA) 709#elif defined(QT_QWS_CASSIOPEIA)
704 execl( "/bin/sh", "sh", 0 ); 710 execl( "/bin/sh", "sh", 0 );
705#else 711#else
706 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); 712 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 );
707#endif 713#endif
708 exit(1); 714 exit(1);
709#endif 715#endif
710} 716}
711 717
712void Desktop::startTransferServer() 718void Desktop::startTransferServer()
713{ 719{
714 // start qcop bridge server 720 // start qcop bridge server
715 qcopBridge = new QCopBridge( 4243 ); 721 qcopBridge = new QCopBridge( 4243 );
716 if ( !qcopBridge->ok() ) { 722 if ( !qcopBridge->ok() ) {
717 delete qcopBridge; 723 delete qcopBridge;
718 qcopBridge = 0; 724 qcopBridge = 0;
719 } 725 }
720 // start transfer server 726 // start transfer server
721 transferServer = new TransferServer( 4242 ); 727 transferServer = new TransferServer( 4242 );
722 if ( !transferServer->ok() ) { 728 if ( !transferServer->ok() ) {
723 delete transferServer; 729 delete transferServer;
724 transferServer = 0; 730 transferServer = 0;
725 } 731 }
726 if ( !transferServer || !qcopBridge ) 732 if ( !transferServer || !qcopBridge )
727 startTimer( 2000 ); 733 startTimer( 2000 );
728} 734}
729 735
730void Desktop::timerEvent( QTimerEvent *e ) 736void Desktop::timerEvent( QTimerEvent *e )
731{ 737{
732 killTimer( e->timerId() ); 738 killTimer( e->timerId() );
733 startTransferServer(); 739 startTransferServer();
734} 740}
735 741
736void Desktop::terminateServers() 742void Desktop::terminateServers()