summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
Unidiff
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 19e99f2..dcc1001 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -1954,337 +1954,337 @@ QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
1954 \value RightOnHold the stylus generates RightButton events 1954 \value RightOnHold the stylus generates RightButton events
1955 if the user uses the press-and-hold gesture. 1955 if the user uses the press-and-hold gesture.
1956 1956
1957 \sa setStylusOperation() stylusOperation() 1957 \sa setStylusOperation() stylusOperation()
1958*/ 1958*/
1959 1959
1960/*! 1960/*!
1961 Causes widget \a w to receive mouse events according to the stylus 1961 Causes widget \a w to receive mouse events according to the stylus
1962 \a mode. 1962 \a mode.
1963 1963
1964 \sa stylusOperation() StylusMode 1964 \sa stylusOperation() StylusMode
1965*/ 1965*/
1966void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) 1966void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode )
1967{ 1967{
1968 createDict(); 1968 createDict();
1969 if ( mode == LeftOnly ) { 1969 if ( mode == LeftOnly ) {
1970 stylusDict->remove 1970 stylusDict->remove
1971 ( w ); 1971 ( w );
1972 w->removeEventFilter( qApp ); 1972 w->removeEventFilter( qApp );
1973 } 1973 }
1974 else { 1974 else {
1975 stylusDict->insert( w, ( void* ) mode ); 1975 stylusDict->insert( w, ( void* ) mode );
1976 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); 1976 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
1977 w->installEventFilter( qApp ); 1977 w->installEventFilter( qApp );
1978 } 1978 }
1979} 1979}
1980 1980
1981 1981
1982/*! 1982/*!
1983 \reimp 1983 \reimp
1984*/ 1984*/
1985bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 1985bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1986{ 1986{
1987 if ( !o->isWidgetType() ) 1987 if ( !o->isWidgetType() )
1988 return FALSE; 1988 return FALSE;
1989 1989
1990 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 1990 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
1991 QMouseEvent * me = ( QMouseEvent* ) e; 1991 QMouseEvent * me = ( QMouseEvent* ) e;
1992 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 1992 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
1993 switch (mode) { 1993 switch (mode) {
1994 case RightOnHold: 1994 case RightOnHold:
1995 switch ( me->type() ) { 1995 switch ( me->type() ) {
1996 case QEvent::MouseButtonPress: 1996 case QEvent::MouseButtonPress:
1997 if ( me->button() == LeftButton ) { 1997 if ( me->button() == LeftButton ) {
1998 static long Pref = 500; // #### pref. 1998 static long Pref = 500; // #### pref.
1999 d->presswidget = (QWidget*)o; 1999 d->presswidget = (QWidget*)o;
2000 d->presspos = me->pos(); 2000 d->presspos = me->pos();
2001 d->rightpressed = FALSE; 2001 d->rightpressed = FALSE;
2002#ifdef OPIE_WITHROHFEEDBACK 2002#ifdef OPIE_WITHROHFEEDBACK
2003 if( ! d->RoH ) 2003 if( ! d->RoH )
2004 d->RoH = new Opie::Internal::RoHFeedback; 2004 d->RoH = new Opie::Internal::RoHFeedback;
2005 2005
2006 d->RoH->init( me->globalPos(), d->presswidget ); 2006 d->RoH->init( me->globalPos(), d->presswidget );
2007 Pref = d->RoH->delay(); 2007 Pref = d->RoH->delay();
2008 2008
2009#endif 2009#endif
2010 if (!d->presstimer ) 2010 if (!d->presstimer )
2011 d->presstimer = startTimer( Pref ); // #### pref. 2011 d->presstimer = startTimer( Pref ); // #### pref.
2012 2012
2013 } 2013 }
2014 break; 2014 break;
2015 case QEvent::MouseMove: 2015 case QEvent::MouseMove:
2016 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { 2016 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
2017 killTimer(d->presstimer); 2017 killTimer(d->presstimer);
2018#ifdef OPIE_WITHROHFEEDBACK 2018#ifdef OPIE_WITHROHFEEDBACK
2019 d->RoH->stop(); 2019 d->RoH->stop();
2020#endif 2020#endif
2021 d->presstimer = 0; 2021 d->presstimer = 0;
2022 } 2022 }
2023 break; 2023 break;
2024 case QEvent::MouseButtonRelease: 2024 case QEvent::MouseButtonRelease:
2025 if ( me->button() == LeftButton ) { 2025 if ( me->button() == LeftButton ) {
2026 if ( d->presstimer ) { 2026 if ( d->presstimer ) {
2027 killTimer(d->presstimer); 2027 killTimer(d->presstimer);
2028#ifdef OPIE_WITHROHFEEDBACK 2028#ifdef OPIE_WITHROHFEEDBACK
2029 d->RoH->stop( ); 2029 d->RoH->stop( );
2030#endif 2030#endif
2031 d->presstimer = 0; 2031 d->presstimer = 0;
2032 } 2032 }
2033 if ( d->rightpressed && d->presswidget ) { 2033 if ( d->rightpressed && d->presswidget ) {
2034 printf( "Send ButtonRelease\n" ); 2034 printf( "Send ButtonRelease\n" );
2035 // Right released 2035 // Right released
2036 postEvent( d->presswidget, 2036 postEvent( d->presswidget,
2037 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 2037 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
2038 RightButton, LeftButton + RightButton ) ); 2038 RightButton, LeftButton + RightButton ) );
2039 // Left released, off-widget 2039 // Left released, off-widget
2040 postEvent( d->presswidget, 2040 postEvent( d->presswidget,
2041 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), 2041 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
2042 LeftButton, LeftButton ) ); 2042 LeftButton, LeftButton ) );
2043 postEvent( d->presswidget, 2043 postEvent( d->presswidget,
2044 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), 2044 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
2045 LeftButton, LeftButton ) ); 2045 LeftButton, LeftButton ) );
2046 d->rightpressed = FALSE; 2046 d->rightpressed = FALSE;
2047 return TRUE; // don't send the real Left release 2047 return TRUE; // don't send the real Left release
2048 } 2048 }
2049 } 2049 }
2050 break; 2050 break;
2051 default: 2051 default:
2052 break; 2052 break;
2053 } 2053 }
2054 break; 2054 break;
2055 default: 2055 default:
2056 ; 2056 ;
2057 } 2057 }
2058 } 2058 }
2059 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 2059 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
2060 QKeyEvent *ke = (QKeyEvent *)e; 2060 QKeyEvent *ke = (QKeyEvent *)e;
2061 if ( ke->key() == Key_Enter ) { 2061 if ( ke->key() == Key_Enter ) {
2062 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 2062 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
2063 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 2063 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
2064 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 2064 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
2065 return TRUE; 2065 return TRUE;
2066 } 2066 }
2067 } 2067 }
2068 } 2068 }
2069 return FALSE; 2069 return FALSE;
2070} 2070}
2071 2071
2072/*! 2072/*!
2073 \reimp 2073 \reimp
2074*/ 2074*/
2075void QPEApplication::timerEvent( QTimerEvent *e ) 2075void QPEApplication::timerEvent( QTimerEvent *e )
2076{ 2076{
2077 if ( e->timerId() == d->presstimer && d->presswidget ) { 2077 if ( e->timerId() == d->presstimer && d->presswidget ) {
2078 2078
2079 // Right pressed 2079 // Right pressed
2080 postEvent( d->presswidget, 2080 postEvent( d->presswidget,
2081 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 2081 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
2082 RightButton, LeftButton ) ); 2082 RightButton, LeftButton ) );
2083 killTimer( d->presstimer ); 2083 killTimer( d->presstimer );
2084 d->presstimer = 0; 2084 d->presstimer = 0;
2085 d->rightpressed = TRUE; 2085 d->rightpressed = TRUE;
2086#ifdef OPIE_WITHROHFEEDBACK 2086#ifdef OPIE_WITHROHFEEDBACK
2087 d->RoH->stop(); 2087 d->RoH->stop();
2088#endif 2088#endif
2089 } 2089 }
2090} 2090}
2091 2091
2092void QPEApplication::removeSenderFromStylusDict() 2092void QPEApplication::removeSenderFromStylusDict()
2093{ 2093{
2094 stylusDict->remove 2094 stylusDict->remove
2095 ( ( void* ) sender() ); 2095 ( ( void* ) sender() );
2096 if ( d->presswidget == sender() ) 2096 if ( d->presswidget == sender() )
2097 d->presswidget = 0; 2097 d->presswidget = 0;
2098} 2098}
2099 2099
2100/*! 2100/*!
2101 \internal 2101 \internal
2102*/ 2102*/
2103bool QPEApplication::keyboardGrabbed() const 2103bool QPEApplication::keyboardGrabbed() const
2104{ 2104{
2105 return d->kbgrabbed; 2105 return d->kbgrabbed;
2106} 2106}
2107 2107
2108 2108
2109/*! 2109/*!
2110 Reverses the effect of grabKeyboard(). This is called automatically 2110 Reverses the effect of grabKeyboard(). This is called automatically
2111 on program exit. 2111 on program exit.
2112*/ 2112*/
2113void QPEApplication::ungrabKeyboard() 2113void QPEApplication::ungrabKeyboard()
2114{ 2114{
2115 ((QPEApplication *) qApp )-> d-> kbgrabbed = false; 2115 ((QPEApplication *) qApp )-> d-> kbgrabbed = false;
2116} 2116}
2117 2117
2118/*! 2118/*!
2119 Grabs the physical keyboard keys, e.g. the application's launching 2119 Grabs the physical keyboard keys, e.g. the application's launching
2120 keys. Instead of launching applications when these keys are pressed 2120 keys. Instead of launching applications when these keys are pressed
2121 the signals emitted are sent to this application instead. Some games 2121 the signals emitted are sent to this application instead. Some games
2122 programs take over the launch keys in this way to make interaction 2122 programs take over the launch keys in this way to make interaction
2123 easier. 2123 easier.
2124 2124
2125 \sa ungrabKeyboard() 2125 \sa ungrabKeyboard()
2126*/ 2126*/
2127void QPEApplication::grabKeyboard() 2127void QPEApplication::grabKeyboard()
2128{ 2128{
2129 ((QPEApplication *) qApp )-> d-> kbgrabbed = true; 2129 ((QPEApplication *) qApp )-> d-> kbgrabbed = true;
2130} 2130}
2131 2131
2132/*! 2132/*!
2133 \reimp 2133 \reimp
2134*/ 2134*/
2135int QPEApplication::exec() 2135int QPEApplication::exec()
2136{ 2136{
2137 d->qcopQok = true; 2137 d->qcopQok = true;
2138#ifndef QT_NO_COP 2138#ifndef QT_NO_COP
2139 d->sendQCopQ(); 2139 d->sendQCopQ();
2140 if ( !d->keep_running ) 2140 if ( !d->keep_running )
2141 processEvents(); // we may have received QCop messages in the meantime. 2141 processEvents(); // we may have received QCop messages in the meantime.
2142#endif 2142#endif
2143 2143
2144 if ( d->keep_running ) 2144 if ( d->keep_running )
2145 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 2145 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
2146 return QApplication::exec(); 2146 return QApplication::exec();
2147 2147
2148#ifndef QT_NO_COP 2148#ifndef QT_NO_COP
2149 2149
2150 { 2150 {
2151 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2151 QCopEnvelope e( "QPE/System", "closing(QString)" );
2152 e << d->appName; 2152 e << d->appName;
2153 } 2153 }
2154#endif 2154#endif
2155 processEvents(); 2155 processEvents();
2156 return 0; 2156 return 0;
2157} 2157}
2158 2158
2159/*! 2159/*!
2160 \internal 2160 \internal
2161 External request for application to quit. Quits if possible without 2161 External request for application to quit. Quits if possible without
2162 loosing state. 2162 loosing state.
2163*/ 2163*/
2164void QPEApplication::tryQuit() 2164void QPEApplication::tryQuit()
2165{ 2165{
2166 if ( activeModalWidget() ) 2166 if ( activeModalWidget() )
2167 return ; // Inside modal loop or konsole. Too hard to save state. 2167 return ; // Inside modal loop or konsole. Too hard to save state.
2168#ifndef QT_NO_COP 2168#ifndef QT_NO_COP
2169 2169
2170 { 2170 {
2171 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2171 QCopEnvelope e( "QPE/System", "closing(QString)" );
2172 e << d->appName; 2172 e << d->appName;
2173 } 2173 }
2174#endif 2174#endif
2175 if ( d->keep_running ) 2175 if ( d->keep_running )
2176 d->store_widget_rect(d->qpe_main_widget, d->appName); 2176 d->store_widget_rect(d->qpe_main_widget, d->appName);
2177 processEvents(); 2177 processEvents();
2178 2178
2179 quit(); 2179 quit();
2180} 2180}
2181 2181
2182 2182
2183/*! 2183/*!
2184 \internal 2184 \internal
2185 User initiated quit. Makes the window 'Go Away'. If preloaded this means 2185 User initiated quit. Makes the window 'Go Away'. If preloaded this means
2186 hiding the window. If not it means quitting the application. 2186 hiding the window. If not it means quitting the application.
2187 As this is user initiated we don't need to check state. 2187 As this is user initiated we don't need to check state.
2188*/ 2188*/
2189void QPEApplication::hideOrQuit() 2189void QPEApplication::hideOrQuit()
2190{ 2190{
2191 if ( d->keep_running ) 2191 if ( d->keep_running )
2192 d->store_widget_rect(d->qpe_main_widget, d->appName); 2192 d->store_widget_rect(d->qpe_main_widget, d->appName);
2193 processEvents(); 2193 processEvents();
2194 2194
2195 // If we are a preloaded application we don't actually quit, so emit 2195 // If we are a preloaded application we don't actually quit, so emit
2196 // a System message indicating we're quasi-closing. 2196 // a System message indicating we're quasi-closing.
2197 if ( d->preloaded && d->qpe_main_widget ) 2197 if ( d->preloaded && d->qpe_main_widget )
2198#ifndef QT_NO_COP 2198#ifndef QT_NO_COP
2199 2199
2200 { 2200 {
2201 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 2201 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
2202 e << d->appName; 2202 e << d->appName;
2203 d->qpe_main_widget->hide(); 2203 d->qpe_main_widget->hide();
2204 } 2204 }
2205#endif 2205#endif
2206 else 2206 else
2207 quit(); 2207 quit();
2208} 2208}
2209 2209
2210#if (__GNUC__ > 2 ) 2210#if (__GNUC__ > 2 ) && !defined(_OS_MACX_)
2211extern "C" void __cxa_pure_virtual(); 2211extern "C" void __cxa_pure_virtual();
2212 2212
2213void __cxa_pure_virtual() 2213void __cxa_pure_virtual()
2214{ 2214{
2215 fprintf( stderr, "Pure virtual called\n"); 2215 fprintf( stderr, "Pure virtual called\n");
2216 abort(); 2216 abort();
2217 2217
2218} 2218}
2219 2219
2220#endif 2220#endif
2221 2221
2222 2222
2223#if defined(OPIE_NEW_MALLOC) 2223#if defined(OPIE_NEW_MALLOC)
2224 2224
2225// The libraries with the skiff package (and possibly others) have 2225// The libraries with the skiff package (and possibly others) have
2226// completely useless implementations of builtin new and delete that 2226// completely useless implementations of builtin new and delete that
2227// use about 50% of your CPU. Here we revert to the simple libc 2227// use about 50% of your CPU. Here we revert to the simple libc
2228// functions. 2228// functions.
2229 2229
2230void* operator new[]( size_t size ) 2230void* operator new[]( size_t size )
2231{ 2231{
2232 return malloc( size ); 2232 return malloc( size );
2233} 2233}
2234 2234
2235void* operator new( size_t size ) 2235void* operator new( size_t size )
2236{ 2236{
2237 return malloc( size ); 2237 return malloc( size );
2238} 2238}
2239 2239
2240void operator delete[]( void* p ) 2240void operator delete[]( void* p )
2241{ 2241{
2242 if ( p ) 2242 if ( p )
2243 free( p ); 2243 free( p );
2244} 2244}
2245 2245
2246void operator delete[]( void* p, size_t /*size*/ ) 2246void operator delete[]( void* p, size_t /*size*/ )
2247{ 2247{
2248 if ( p ) 2248 if ( p )
2249 free( p ); 2249 free( p );
2250} 2250}
2251 2251
2252 2252
2253void operator delete( void* p ) 2253void operator delete( void* p )
2254{ 2254{
2255 if ( p ) 2255 if ( p )
2256 free( p ); 2256 free( p );
2257} 2257}
2258 2258
2259void operator delete( void* p, size_t /*size*/ ) 2259void operator delete( void* p, size_t /*size*/ )
2260{ 2260{
2261 if ( p ) 2261 if ( p )
2262 free( p ); 2262 free( p );
2263} 2263}
2264 2264
2265#endif 2265#endif
2266 2266
2267#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) 2267#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP)
2268#include <qwidgetlist.h> 2268#include <qwidgetlist.h>
2269#ifdef QWS 2269#ifdef QWS
2270#include <qgfx_qws.h> 2270#include <qgfx_qws.h>
2271extern QRect qt_maxWindowRect; 2271extern QRect qt_maxWindowRect;
2272void qt_setMaxWindowRect(const QRect& r ) 2272void qt_setMaxWindowRect(const QRect& r )
2273{ 2273{
2274 qt_maxWindowRect = qt_screen->mapFromDevice( r, 2274 qt_maxWindowRect = qt_screen->mapFromDevice( r,
2275 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); 2275 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) );
2276 // Re-resize any maximized windows 2276 // Re-resize any maximized windows
2277 QWidgetList* l = QApplication::topLevelWidgets(); 2277 QWidgetList* l = QApplication::topLevelWidgets();
2278 if ( l ) { 2278 if ( l ) {
2279 QWidget * w = l->first(); 2279 QWidget * w = l->first();
2280 while ( w ) { 2280 while ( w ) {
2281 if ( w->isVisible() && w->isMaximized() ) { 2281 if ( w->isVisible() && w->isMaximized() ) {
2282 w->showMaximized(); 2282 w->showMaximized();
2283 } 2283 }
2284 w = l->next(); 2284 w = l->next();
2285 } 2285 }
2286 delete l; 2286 delete l;
2287 } 2287 }
2288} 2288}
2289#endif 2289#endif
2290#endif 2290#endif