summaryrefslogtreecommitdiff
path: root/core
authorsandman <sandman>2002-11-24 18:18:35 (UTC)
committer sandman <sandman>2002-11-24 18:18:35 (UTC)
commitee62e73ddc29a5015c4a3e569be90dbfce4652c6 (patch) (side-by-side diff)
tree634833e66836220371ce3b441a88f077de30b954 /core
parent5b029ef4b109d50ae41a3fd8bfae0b30864745f8 (diff)
downloadopie-ee62e73ddc29a5015c4a3e569be90dbfce4652c6.zip
opie-ee62e73ddc29a5015c4a3e569be90dbfce4652c6.tar.gz
opie-ee62e73ddc29a5015c4a3e569be90dbfce4652c6.tar.bz2
A small library that can be LD_PRELOADed to other applications by the
launcher to force these applications to use the Opie style/font/window­ decoration settings. Could also be used for other things in the future...
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/libpreload/config.in5
-rw-r--r--core/launcher/libpreload/libpreload.pro14
-rw-r--r--core/launcher/libpreload/preload.cpp91
3 files changed, 110 insertions, 0 deletions
diff --git a/core/launcher/libpreload/config.in b/core/launcher/libpreload/config.in
new file mode 100644
index 0000000..c3cfd6f
--- a/dev/null
+++ b/core/launcher/libpreload/config.in
@@ -0,0 +1,5 @@
+config LIBPRELOAD
+ boolean "Preload library"
+ default "y" if ! X11
+ default "n" if X11
+ depends on ! X11
diff --git a/core/launcher/libpreload/libpreload.pro b/core/launcher/libpreload/libpreload.pro
new file mode 100644
index 0000000..210cbdd
--- a/dev/null
+++ b/core/launcher/libpreload/libpreload.pro
@@ -0,0 +1,14 @@
+TEMPLATE = lib
+
+CONFIG = release warn_on
+
+SOURCES = preload.cpp
+
+HEADERS =
+
+INCLUDEPATH += $(QTDIR)/include
+
+DESTDIR = $(OPIEDIR)/lib
+TARGET = preload
+
+VERSION = 1.0.0
diff --git a/core/launcher/libpreload/preload.cpp b/core/launcher/libpreload/preload.cpp
new file mode 100644
index 0000000..a94ec65
--- a/dev/null
+++ b/core/launcher/libpreload/preload.cpp
@@ -0,0 +1,91 @@
+
+#define _GNU_SOURCE
+//#define private public
+//#define protected public
+
+#include <qwsdecoration_qws.h>
+#include <qcommonstyle.h>
+//#include <qpe/qpeapplication.h>
+
+class QStyle;
+class QApplication;
+class QFont;
+class QWSDecoration;
+
+#include <dlfcn.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+typedef void ( *qapp_setstyle_t ) ( QStyle * );
+typedef void ( *qapp_setdeco_t ) ( QApplication *, QWSDecoration * );
+typedef void ( *qapp_setfont_t ) ( QApplication *, const QFont &, bool, const char * );
+
+
+static bool *opie_block_style_p = 0;
+
+extern "C" {
+
+static void *resolve_symbol ( const char *sym )
+{
+ void *adr = ::dlsym ( RTLD_NEXT, sym );
+
+ if ( !adr )
+ ::fprintf ( stderr, "PANIC: Could not resolve symbol \"%s\"\n", sym );
+
+ return adr;
+}
+
+extern void setStyle__12QApplicationP6QStyle ( QStyle *style )
+{
+ static qapp_setstyle_t qsetstyle = 0;
+
+ if ( !qsetstyle )
+ qsetstyle = (qapp_setstyle_t) resolve_symbol ( "setStyle__12QApplicationP6QStyle" );
+
+ if ( !opie_block_style_p )
+ opie_block_style_p = (bool *) resolve_symbol ( "opie_block_style" );
+
+ if ( !qsetstyle || ( opie_block_style_p && *opie_block_style_p )) {
+ delete style;
+ return;
+ }
+ else
+ ( *qsetstyle ) ( style );
+}
+
+extern void setFont__12QApplicationRC5QFontbPCc ( QApplication *app, const QFont &fnt, bool informWidgets, const char * className )
+{
+ static qapp_setfont_t qsetfont = 0;
+
+ if ( !qsetfont )
+ qsetfont = (qapp_setfont_t) resolve_symbol ( "setFont__12QApplicationRC5QFontbPCc" );
+
+ if ( !opie_block_style_p )
+ opie_block_style_p = (bool *) resolve_symbol ( "opie_block_style" );
+
+ if ( qsetfont && !( opie_block_style_p && *opie_block_style_p ))
+ ( *qsetfont ) ( app, fnt, informWidgets, className );
+}
+
+
+extern void qwsSetDecoration__12QApplicationP13QWSDecoration ( QApplication *app, QWSDecoration *deco )
+{
+ static qapp_setdeco_t qsetdeco = 0;
+
+ if ( !qsetdeco )
+ qsetdeco = (qapp_setdeco_t) resolve_symbol ( "qwsSetDecoration__12QApplicationP13QWSDecoration" );
+
+ if ( !opie_block_style_p )
+ opie_block_style_p = (bool *) resolve_symbol ( "opie_block_style" );
+
+ if ( !qsetdeco || ( opie_block_style_p && *opie_block_style_p )) {
+ delete deco;
+ return;
+ }
+ else
+ ( *qsetdeco ) ( app, deco );
+}
+
+}