author | treke <treke> | 2003-12-08 06:52:35 (UTC) |
---|---|---|
committer | treke <treke> | 2003-12-08 06:52:35 (UTC) |
commit | 7b4e723545a645056156246d27b2c26c78d599f3 (patch) (unidiff) | |
tree | 8b349615fc1441a60bc418e10c53b1799db895e4 | |
parent | 3bbeef6702ef80b7506b5393cc51d1fd5b04559d (diff) | |
download | opie-7b4e723545a645056156246d27b2c26c78d599f3.zip opie-7b4e723545a645056156246d27b2c26c78d599f3.tar.gz opie-7b4e723545a645056156246d27b2c26c78d599f3.tar.bz2 |
Automatic rotation. This might break binary compatibility, so beware including
in BRANCH_1_0
-rw-r--r-- | core/applets/rotateapplet/rotate.cpp | 43 | ||||
-rw-r--r-- | core/applets/rotateapplet/rotate.h | 1 | ||||
-rw-r--r-- | libopie/odevice.cpp | 124 | ||||
-rw-r--r-- | libopie/odevice.h | 4 | ||||
-rw-r--r-- | qt/qt-2.3.7.patch/qte237-all.patch | 11 |
5 files changed, 163 insertions, 20 deletions
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp index ac6b259..0da2f0c 100644 --- a/core/applets/rotateapplet/rotate.cpp +++ b/core/applets/rotateapplet/rotate.cpp | |||
@@ -66,7 +66,9 @@ void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data | |||
66 | QDataStream stream( data, IO_ReadOnly ); | 66 | QDataStream stream( data, IO_ReadOnly ); |
67 | if ( msg == "flip()" ) { | 67 | if ( msg == "flip()" ) { |
68 | activated ( ); | 68 | activated ( ); |
69 | } | 69 | } else if ( msg == "rotateDefault()") { |
70 | rotateDefault(); | ||
71 | } | ||
70 | } | 72 | } |
71 | 73 | ||
72 | 74 | ||
@@ -111,6 +113,45 @@ QPopupMenu *RotateApplet::popup ( QWidget * ) const | |||
111 | return 0; | 113 | return 0; |
112 | } | 114 | } |
113 | 115 | ||
116 | void RotateApplet::rotateDefault ( ) | ||
117 | { | ||
118 | |||
119 | int rot = ODevice::inst()->rotation(); | ||
120 | |||
121 | switch (rot) { | ||
122 | case Rot0: | ||
123 | rot=0; | ||
124 | break; | ||
125 | case Rot90: | ||
126 | rot=90; | ||
127 | break; | ||
128 | case Rot180: | ||
129 | rot=180; | ||
130 | break; | ||
131 | case Rot270: | ||
132 | rot=270; | ||
133 | break; | ||
134 | default: | ||
135 | rot=0; | ||
136 | break; | ||
137 | } | ||
138 | Config cfg( "qpe" ); | ||
139 | cfg.setGroup( "Appearance" ); | ||
140 | |||
141 | bool rotateDisabled = cfg.readBoolEntry( "rotateEnabled",false ); | ||
142 | |||
143 | if (rotateDisabled == true) | ||
144 | return; | ||
145 | |||
146 | // hide inputs methods before rotation | ||
147 | QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); | ||
148 | |||
149 | QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); | ||
150 | env << rot; | ||
151 | |||
152 | m_flipped = false; | ||
153 | |||
154 | } | ||
114 | void RotateApplet::activated ( ) | 155 | void RotateApplet::activated ( ) |
115 | { | 156 | { |
116 | 157 | ||
diff --git a/core/applets/rotateapplet/rotate.h b/core/applets/rotateapplet/rotate.h index de2a707..572b82a 100644 --- a/core/applets/rotateapplet/rotate.h +++ b/core/applets/rotateapplet/rotate.h | |||
@@ -58,6 +58,7 @@ public: | |||
58 | */ | 58 | */ |
59 | virtual QPopupMenu *popup ( QWidget *parent ) const; | 59 | virtual QPopupMenu *popup ( QWidget *parent ) const; |
60 | virtual void activated ( ); | 60 | virtual void activated ( ); |
61 | virtual void rotateDefault ( ); | ||
61 | 62 | ||
62 | private slots: | 63 | private slots: |
63 | void channelReceived( const QCString &msg, const QByteArray & data ); | 64 | void channelReceived( const QCString &msg, const QByteArray & data ); |
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 9373ef9..5038cc9 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -141,6 +141,11 @@ public: | |||
141 | virtual bool setLedState ( OLed led, OLedState st ); | 141 | virtual bool setLedState ( OLed led, OLedState st ); |
142 | 142 | ||
143 | static bool isZaurus(); | 143 | static bool isZaurus(); |
144 | |||
145 | // Does this break BC? | ||
146 | virtual bool suspend ( ); | ||
147 | virtual Transformation rotation ( ) const; | ||
148 | virtual ODirection direction ( ) const; | ||
144 | 149 | ||
145 | protected: | 150 | protected: |
146 | virtual void buzzer ( int snd ); | 151 | virtual void buzzer ( int snd ); |
@@ -289,10 +294,10 @@ struct z_button z_buttons_c700 [] = { | |||
289 | "devicebuttons/z_menu", | 294 | "devicebuttons/z_menu", |
290 | "QPE/TaskBar", "toggleMenu()", | 295 | "QPE/TaskBar", "toggleMenu()", |
291 | "QPE/TaskBar", "toggleStartMenu()" }, | 296 | "QPE/TaskBar", "toggleStartMenu()" }, |
292 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), | 297 | { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), |
293 | "", | 298 | "", |
294 | "QPE/Rotation", "flip()", | 299 | "QPE/Rotation", "rotateDefault()", |
295 | "QPE/Rotation", "flip()" }, | 300 | "QPE/Rotation", "rotateDefault()" }, |
296 | }; | 301 | }; |
297 | 302 | ||
298 | struct s_button { | 303 | struct s_button { |
@@ -1632,20 +1637,8 @@ void Zaurus::init ( ) | |||
1632 | d-> m_rotation = Rot0; | 1637 | d-> m_rotation = Rot0; |
1633 | break; | 1638 | break; |
1634 | case Model_Zaurus_SLC7x0: | 1639 | case Model_Zaurus_SLC7x0: |
1635 | // Note: need to 1) set flipstate based on physical screen orientation | 1640 | d-> m_rotation = rotation(); |
1636 | // and 2) check to see if the user overrode the rotation direction | 1641 | d-> m_direction = direction(); |
1637 | // using appearance, and if so, remove that item from the Config to | ||
1638 | // ensure the rotate applet flips us back to the previous state. | ||
1639 | // treke said he has patches for detecting the phys. so where are they, treke? -mickeyl. | ||
1640 | if ( flipstate ) { | ||
1641 | // 480x640 | ||
1642 | d-> m_rotation = Rot0; | ||
1643 | d-> m_direction = CW; | ||
1644 | } else { | ||
1645 | // 640x480 | ||
1646 | d-> m_rotation = Rot270; | ||
1647 | d-> m_direction = CCW; | ||
1648 | } | ||
1649 | break; | 1642 | break; |
1650 | case Model_Zaurus_SLB600: | 1643 | case Model_Zaurus_SLB600: |
1651 | case Model_Zaurus_SL5500: | 1644 | case Model_Zaurus_SL5500: |
@@ -1746,6 +1739,8 @@ void Zaurus::initButtons ( ) | |||
1746 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1739 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1747 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 1740 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
1748 | 1741 | ||
1742 | #define SHARP_IOCTL_GET_ROTATION 0x413c | ||
1743 | |||
1749 | typedef struct sharp_led_status { | 1744 | typedef struct sharp_led_status { |
1750 | int which; /* select which LED status is wanted. */ | 1745 | int which; /* select which LED status is wanted. */ |
1751 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 1746 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
@@ -1979,6 +1974,101 @@ bool Zaurus::setDisplayBrightness ( int bright ) | |||
1979 | return res; | 1974 | return res; |
1980 | } | 1975 | } |
1981 | 1976 | ||
1977 | bool Zaurus::suspend ( ) | ||
1978 | { | ||
1979 | qDebug("ODevice::suspend"); | ||
1980 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | ||
1981 | return false; | ||
1982 | |||
1983 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | ||
1984 | return false; | ||
1985 | |||
1986 | bool res = false; | ||
1987 | |||
1988 | struct timeval tvs, tvn; | ||
1989 | ::gettimeofday ( &tvs, 0 ); | ||
1990 | |||
1991 | ::sync ( ); // flush fs caches | ||
1992 | res = ( ::system ( "apm --suspend" ) == 0 ); | ||
1993 | |||
1994 | // This is needed because the iPAQ apm implementation is asynchronous and we | ||
1995 | // can not be sure when exactly the device is really suspended | ||
1996 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | ||
1997 | |||
1998 | if ( res ) { | ||
1999 | do { // Yes, wait 15 seconds. This APM bug sucks big time. | ||
2000 | ::usleep ( 200 * 1000 ); | ||
2001 | ::gettimeofday ( &tvn, 0 ); | ||
2002 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); | ||
2003 | } | ||
2004 | |||
2005 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); | ||
2006 | return res; | ||
2007 | } | ||
2008 | |||
2009 | |||
2010 | Transformation Zaurus::rotation ( ) const | ||
2011 | { | ||
2012 | Transformation rot; | ||
2013 | int handle = 0; | ||
2014 | int retval = 0; | ||
2015 | |||
2016 | switch ( d-> m_model ) { | ||
2017 | case Model_Zaurus_SLC7x0: | ||
2018 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | ||
2019 | if (handle == -1) { | ||
2020 | return Rot270; | ||
2021 | } else { | ||
2022 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | ||
2023 | ::close (handle); | ||
2024 | |||
2025 | if (retval == 2 ) | ||
2026 | rot = Rot0; | ||
2027 | else | ||
2028 | rot = Rot270; | ||
2029 | } | ||
2030 | break; | ||
2031 | case Model_Zaurus_SLA300: | ||
2032 | case Model_Zaurus_SLB600: | ||
2033 | case Model_Zaurus_SL5500: | ||
2034 | case Model_Zaurus_SL5000: | ||
2035 | default: | ||
2036 | rot = d-> m_rotation; | ||
2037 | break; | ||
2038 | } | ||
2039 | |||
2040 | return rot; | ||
2041 | } | ||
2042 | ODirection Zaurus::direction ( ) const | ||
2043 | { | ||
2044 | ODirection dir; | ||
2045 | int handle = 0; | ||
2046 | int retval = 0; | ||
2047 | switch ( d-> m_model ) { | ||
2048 | case Model_Zaurus_SLC7x0: | ||
2049 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | ||
2050 | if (handle == -1) { | ||
2051 | dir = Rot270; | ||
2052 | } else { | ||
2053 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | ||
2054 | ::close (handle); | ||
2055 | if (retval == 2 ) | ||
2056 | dir = CCW; | ||
2057 | else | ||
2058 | dir = CW; | ||
2059 | } | ||
2060 | break; | ||
2061 | case Model_Zaurus_SLA300: | ||
2062 | case Model_Zaurus_SLB600: | ||
2063 | case Model_Zaurus_SL5500: | ||
2064 | case Model_Zaurus_SL5000: | ||
2065 | default: | ||
2066 | dir = d-> m_direction; | ||
2067 | break; | ||
2068 | } | ||
2069 | return dir; | ||
2070 | |||
2071 | } | ||
1982 | 2072 | ||
1983 | int Zaurus::displayBrightnessResolution ( ) const | 2073 | int Zaurus::displayBrightnessResolution ( ) const |
1984 | { | 2074 | { |
diff --git a/libopie/odevice.h b/libopie/odevice.h index 25910b5..8273761 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h | |||
@@ -187,8 +187,8 @@ public: | |||
187 | 187 | ||
188 | QString systemVersionString ( ) const; | 188 | QString systemVersionString ( ) const; |
189 | 189 | ||
190 | Transformation rotation ( ) const; | 190 | virtual Transformation rotation ( ) const; |
191 | ODirection direction ( ) const; | 191 | virtual ODirection direction ( ) const; |
192 | 192 | ||
193 | // system | 193 | // system |
194 | 194 | ||
diff --git a/qt/qt-2.3.7.patch/qte237-all.patch b/qt/qt-2.3.7.patch/qte237-all.patch index 233996a..e6cf0a4 100644 --- a/qt/qt-2.3.7.patch/qte237-all.patch +++ b/qt/qt-2.3.7.patch/qte237-all.patch | |||
@@ -408,3 +408,14 @@ diff -ru qt-2.3.5_fresh/src/widgets/qtoolbutton.cpp qt-2.3.5/src/widgets/qtoolbu | |||
408 | QPixmap pm = iconSet(TRUE).pixmap(QIconSet::Small, QIconSet::Normal); | 408 | QPixmap pm = iconSet(TRUE).pixmap(QIconSet::Small, QIconSet::Normal); |
409 | w = pm.width(); | 409 | w = pm.width(); |
410 | h = pm.height(); | 410 | h = pm.height(); |
411 | --- qt-2.3.7/src/kernel/qkeyboard_qws.cpp~c7xxrotate2003-07-16 18:20:25.000000000 -0700 | ||
412 | +++ qt-2.3.7/src/kernel/qkeyboard_qws.cpp2003-12-07 15:54:10.000000000 -0800 | ||
413 | @@ -238,7 +238,7 @@ | ||
414 | { Qt::Key_unknown,0xffff , 0xffff , 0xffff }, // 63 | ||
415 | { Qt::Key_unknown,0xffff , 0xffff , 0xffff }, // 64 | ||
416 | { Qt::Key_unknown,0xffff , 0xffff , 0xffff }, // 65 | ||
417 | - { Qt::Key_unknown,0xffff , 0xffff , 0xffff }, // 66 | ||
418 | + { Qt::Key_F14, 0xffff , 0xffff , 0xffff }, // 66 | ||
419 | { Qt::Key_Meta, 0xffff , 0xffff , 0xffff }, // 67 | ||
420 | { Qt::Key_unknown,0xffff , 0xffff , 0xffff }, // 68 | ||
421 | { Qt::Key_unknown,0xffff , 0xffff , 0xffff }, // 69 | ||