[PATCH] Config-level selection of "Windowed" vs "PDA" environment
Paul Sokolovsky <[email protected]> Fri, 12 Jan 2007 23:16:13 +0200
| Newsgroups | gmane.comp.handhelds.opie.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello opie-devel, What made me do this patch is the desire to get rid of build-time per-machine configuration (essentially, via #defines and #ifdef) of core OPIE lib, which leads to production of machine-dependent packages, and thus leads to additional hardships with QA, code coverage, etc. So, libqpe-opie has a define "OPIE_NO_WINDOWED", which works like that: 1. If it's not defined, there's a standard "desktop-type" windowing environment, where you usually can change size of any window, dialogs are initially opened with their natural size, and (additionally) [main] windows sizes and positions are preserved, and when app owning them reopened, last size used is shown. 2. When it is defined, it behaves in common "PDA" manner, where windows are maximized by default (not that OPIE is nice and allows to de-maximize them), and window positions are not preserved. 3. For windowed mode, screen size should be not less than 350 pixels wide, otherwise it hardcodes to PDA mode. Well, the issue is that some PDA (especially VGA) may set this #define, other not, all leading to machine-dependent packages which stuffs the feeds and have other issues like above. As the changes to the code are minimal, I instead converted it to do run-time configuration, based on the qpe.conf. I also removed adhoc limitation of 350 pixels. The default setting is "PDA mode", as OPIE's device base is mostly PDAs (and most PDAs in OE, for example, select non-windowed mode). But it will now become easily usable on tablets, and well, even QVGA device users may easily have multiple windows on their palmtops ;-). Patch attached. It actually bears marks of my searching for write config option name, I chose between "SaveWindowsPos" and "AllowWindowed", and chose the second one after all. So, please review it, and let's see if it's useful enough (I hope ;-) ) and if there're better names to use. -- Best regards, Paul mailto:[email protected] _______________________________________________ http://opie.handhelds.org/cgi-bin/moin.cgi/DeveloperWikiIndex Opie-devel mailing list [email protected] https://handhelds.org/mailman/listinfo/opie-devel
save-windows-pos-dynamic.patch
(application/octet-stream, 3.1 KB)
? 1.diff
? library/1.diff
Index: library/qpeapplication.cpp
===================================================================
RCS file: /cvs/opie/library/qpeapplication.cpp,v
retrieving revision 1.115
diff -u -r1.115 qpeapplication.cpp
--- library/qpeapplication.cpp 27 Sep 2005 21:04:59 -0000 1.115
+++ library/qpeapplication.cpp 11 Jan 2007 06:12:50 -0000
@@ -101,6 +101,7 @@
static bool useBigPixmaps = 0;
+static bool saveWindowsPos = 0;
class HackWidget : public QWidget
{
@@ -129,6 +130,7 @@
fontSize = cfg.readNumEntry( "FontSize", 10 );
smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 );
bigIconSize = cfg.readNumEntry( "BigIconSize", 32 );
+ saveWindowsPos = cfg.readBoolEntry( "AllowWindowed", false );
#ifdef OPIE_WITHROHFEEDBACK
RoH = 0;
#endif
@@ -250,7 +252,8 @@
static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s)
{
-#ifndef OPIE_NO_WINDOWED
+ if (!saveWindowsPos)
+ return FALSE;
maximized = TRUE;
// 350 is the trigger in qwsdefaultdecoration for providing a resize button
if ( qApp->desktop()->width() <= 350 )
@@ -272,8 +275,6 @@
return TRUE;
}
-#endif
- return FALSE;
}
@@ -322,7 +323,8 @@
{
if( !w )
return;
-#ifndef OPIE_NO_WINDOWED
+ if (!saveWindowsPos)
+ return;
// 350 is the trigger in qwsdefaultdecoration for providing a resize button
if ( qApp->desktop()->width() <= 350 )
return;
@@ -343,7 +345,6 @@
QString s;
s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() );
cfg.writeEntry( app, s );
-#endif
}
static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
@@ -2207,6 +2208,11 @@
quit();
}
+bool QPEApplication::isSaveWindowsPos()
+{
+ return saveWindowsPos;
+}
+
#if (__GNUC__ > 2 ) && !defined(_OS_MACX_)
extern "C" void __cxa_pure_virtual();
Index: library/qpeapplication.h
===================================================================
RCS file: /cvs/opie/library/qpeapplication.h,v
retrieving revision 1.35
diff -u -r1.35 qpeapplication.h
--- library/qpeapplication.h 4 Oct 2005 19:38:19 -0000 1.35
+++ library/qpeapplication.h 11 Jan 2007 06:12:50 -0000
@@ -137,6 +137,8 @@
int exec();
+ static bool isSaveWindowsPos();
+
signals:
void clientMoused();
void timeChanged();
Index: library/widget_showing.cpp
===================================================================
RCS file: /cvs/opie/library/widget_showing.cpp,v
retrieving revision 1.4
diff -u -r1.4 widget_showing.cpp
--- library/widget_showing.cpp 19 Apr 2005 13:27:29 -0000 1.4
+++ library/widget_showing.cpp 11 Jan 2007 06:12:50 -0000
@@ -52,13 +52,8 @@
return;
}
-#ifdef OPIE_NO_WINDOWED
- Q_UNUSED( nomax )
- if ( TRUE ) {
-#else
- if ( !nomax
- && ( qApp->desktop()->width() <= 320 ) ){
-#endif
+ if ( !isSaveWindowsPos() || (!nomax
+ && ( qApp->desktop()->width() <= 30 )) ){
wg->showMaximized();
} else {
#ifdef Q_WS_QWS