summaryrefslogtreecommitdiff
path: root/x11/libqpe-x11
authorzecke <zecke>2002-10-18 01:34:23 (UTC)
committer zecke <zecke>2002-10-18 01:34:23 (UTC)
commit0457c48c165abef8afa2ac73c8f66d20e289681a (patch) (side-by-side diff)
tree2c6baf363487d474df6ceeaf2ea17a351b38aa05 /x11/libqpe-x11
parente7e36afd3685c7fab146ebd0078d7f1a60f8c5e6 (diff)
downloadopie-0457c48c165abef8afa2ac73c8f66d20e289681a.zip
opie-0457c48c165abef8afa2ac73c8f66d20e289681a.tar.gz
opie-0457c48c165abef8afa2ac73c8f66d20e289681a.tar.bz2
Fix OCOPServer bugs... when removing clients
Implement the Opie side for the OK button now the awesome matchbox needs to get an update I was too excited about X11 so i did not do any PIM work yet
Diffstat (limited to 'x11/libqpe-x11') (more/less context) (ignore whitespace changes)
-rw-r--r--x11/libqpe-x11/qpe/qpeapplication.cpp90
-rw-r--r--x11/libqpe-x11/qpe/qpeapplication.h2
2 files changed, 92 insertions, 0 deletions
diff --git a/x11/libqpe-x11/qpe/qpeapplication.cpp b/x11/libqpe-x11/qpe/qpeapplication.cpp
index 8785c74..75a8189 100644
--- a/x11/libqpe-x11/qpe/qpeapplication.cpp
+++ b/x11/libqpe-x11/qpe/qpeapplication.cpp
@@ -1,102 +1,118 @@
#define QTOPIA_INTERNAL_LANGLIST
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/file.h>
+
#include <qdir.h>
#include <qdialog.h>
#include <qdragobject.h>
#include <qevent.h>
#include <qlabel.h>
#include <qlist.h>
#include <qtextstream.h>
#include <qtextcodec.h>
#include <qpalette.h>
#include <qptrdict.h>
#include <qregexp.h>
+#include <qtimer.h>
#include <qpe/alarmserver.h>
#include <qpe/applnk.h>
#include <qpe/qpemenubar.h>
#include <qpe/textcodecinterface.h>
#include <qpe/imagecodecinterface.h>
#include <qpe/qlibrary.h>
#include <qpe/qpestyle.h>
#include <qpe/styleinterface.h>
#include <qpe/global.h>
#include <qpe/resource.h>
#include <qpe/config.h>
#include <qpe/network.h>
#include <qpe/qpeapplication.h>
#include <qpe/timestring.h>
#include <qpe/qcopenvelope_qws.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+const int XKeyPress = KeyPress;
+const int XKeyRelease = KeyRelease;
+#undef KeyPress
+#undef KeyRelease
+
namespace {
struct QCopRec{
QCopRec( const QCString& ch, const QCString& msg, const QByteArray& ar )
: channel(ch), message(msg), data(ar) {
}
QCString channel;
QCString message;
QByteArray data;
};
};
class QPEApplication::Private {
public:
Private();
~Private();
void enqueueQCop( const QCString& ch, const QCString& msg,
const QByteArray& );
void sendQCopQ();
static void show_mx(QWidget* mw, bool nomaximize );
void show( QWidget* mw, bool nomax );
void loadTextCodecs();
void loadImageCodecs();
int kbgrabber;
int presstimer;
bool rightpressed : 1;
bool kbregrab : 1;
bool notbusysent : 1;
bool preloaded : 1;
bool forceshow : 1;
bool nomaximize : 1;
bool keep_running : 1;
QWidget* presswidget;
QPoint presspos;
QWidget* qpe_main_widget;
QString appName;
QString styleName;
QString decorationName;
+ Atom wm_delete_window;
+ Atom wm_take_focus;
+ Atom wm_context_help;
+ Atom wm_context_accept;
+ Atom wm_protocols;
private:
QList<QCopRec> qcopq;
};
QPEApplication::Private::~Private() {
}
QPEApplication::Private::Private()
: kbgrabber(0 ), presstimer(0 ), rightpressed( FALSE ), kbregrab( FALSE ), notbusysent( FALSE ),
preloaded( FALSE ), forceshow( FALSE ), nomaximize( FALSE ), keep_running( TRUE ),
presswidget( 0 ), qpe_main_widget(0 ) {
qcopq.setAutoDelete( TRUE );
}
void QPEApplication::Private::enqueueQCop( const QCString& chan, const QCString& msg,
const QByteArray& ar ) {
qcopq.append( new QCopRec(chan, msg, ar ) );
}
void QPEApplication::Private::sendQCopQ() {
QCopRec* r;
for ( r = qcopq.first(); r; r = qcopq.next() ) {
QCopChannel::sendLocally( r->channel, r->message, r->data );
}
qcopq.clear();
}
@@ -198,48 +214,74 @@ namespace {
r = new QImageDrag( img );
}
while ( !r && sl > 0 );
}
return r;
};
};
// QPEApplication
QPEApplication::~QPEApplication() {
qWarning("~QPEApplication");
ungrabKeyboard();
qWarning("UngrabKeyboard");
// delete m_sys;
// delete m_pid;
delete d;
}
QPEApplication::QPEApplication(int &arg, char** argv, Type t)
: QApplication( arg, argv, t ) {
d = new Private;
d->loadTextCodecs();
d->loadImageCodecs();
+ // Init X-Atom
+ Atom *atoms[5];
+ Atom atoms_re[5];
+ char* names[5];
+ int n = 0;
+ atoms[n] = &d->wm_delete_window;
+ names[n++] = "WM_DELETE_WINDOW";
+
+ atoms[n] = &d->wm_take_focus;
+ names[n++] = "WM_TAKE_FOCUS";
+
+ atoms[n] = &d->wm_context_help;
+ names[n++] = "_NET_WM_CONTEXT_HELP";
+
+ atoms[n] = &d->wm_context_accept;
+ names[n++] = "_NET_WM_CONTEXT_ACCEPT";
+
+ atoms[n] = &d->wm_protocols;
+ names[n++] = "WM_PROTOCOLS";
+
+ XInternAtoms( qt_xdisplay(), names, n, FALSE, atoms_re);
+ // now copy the values over to the properties
+ for (int i = 0; i < n; i++ )
+ *atoms[i] = atoms_re[i];
+ // done with X11 Stuff
+
int dw = desktop()->width();
if ( dw < 200 ) {
setFont( QFont( "helvetica", 8 ) );
AppLnk::setSmallIconSize( 10 );
AppLnk::setBigIconSize( 28 );
}else if ( dw > 600 ) {
setFont( QFont( "helvetica", 12 ) );
AppLnk::setSmallIconSize( 24 );
AppLnk::setBigIconSize( 48 );
}else if ( dw > 200 ) {
setFont( QFont( "helvetica", 10 ) );
AppLnk::setSmallIconSize( 16 );
AppLnk::setBigIconSize( 32 );
}
QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
connect( this, SIGNAL( lastWindowClosed() ), this, SLOT(hideOrQuit() ) );
QString qcopfn( "/tmp/qcop-msg-" );
qcopfn += QString( argv[0] ); // append command name to the QCOP name
QFile file( qcopfn );
if (file.open(IO_ReadOnly ) ) {
flock( file.handle(), LOCK_EX );
}
@@ -509,48 +551,68 @@ void QPEApplication::removeSenderFromStylusDict() {
stylusDict->remove( ( void* ) sender() );
if ( d->presswidget == sender() )
d->presswidget = 0;
}
void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode) {
createDict();
if ( mode == LeftOnly ) {
stylusDict->remove
( w );
w->removeEventFilter( qApp );
}else {
stylusDict->insert( w, ( void* ) mode );
connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
w->installEventFilter( qApp );
}
}
QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w) {
if ( stylusDict )
return ( StylusMode ) ( int ) stylusDict->find( w );
return LeftOnly;
}
// eventFilter......
bool QPEApplication::eventFilter( QObject* o, QEvent* e ) {
+ /*
+ * We want our WM to show Ok and a X button
+ * on dialogs
+ * our part is to set the _NET_WM_CONTEXT_ACCEPT
+ * propery
+ * and then wait for a client message -zecke
+ * on show we will add the prop
+ */
+ if (o->inherits("QDialog") && e->type() == QEvent::Show ) {
+ QDialog* dialog = (QDialog*)o;
+ Atom wm_prot[45];
+ int n = 0;
+ wm_prot[n++] = d->wm_delete_window;
+ wm_prot[n++] = d->wm_take_focus;
+ wm_prot[n++] = d->wm_context_accept;
+ if ( dialog->testWFlags( WStyle_ContextHelp ) )
+ wm_prot[n++] = d->wm_context_help;
+ XSetWMProtocols( qt_xdisplay(), dialog->winId(), wm_prot, n );
+ return TRUE; // should be save
+ }
if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
QMouseEvent * me = ( QMouseEvent* ) e;
StylusMode mode = (StylusMode)(int)stylusDict->find(o);
switch (mode) {
case RightOnHold:
switch ( me->type() ) {
case QEvent::MouseButtonPress:
if ( me->button() == LeftButton ) {
d->presstimer = startTimer(500); // #### pref.
d->presswidget = (QWidget*)o;
d->presspos = me->pos();
d->rightpressed = FALSE;
}
break;
case QEvent::MouseMove:
if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
killTimer(d->presstimer);
d->presstimer = 0;
}
break;
case QEvent::MouseButtonRelease:
if ( me->button() == LeftButton ) {
if ( d->presstimer ) {
killTimer(d->presstimer);
@@ -636,48 +698,76 @@ void QPEApplication::hideOrQuit() {
\internal
*/
void QPEApplication::prepareForTermination( bool willrestart )
{
if ( willrestart ) {
// Draw a big wait icon, the image can be altered in later revisions
// QWidget *d = QApplication::desktop();
QImage img = Resource::loadImage( "launcher/new_wait" );
QPixmap pix;
pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) );
QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize |
QWidget::WStyle_NoBorder | QWidget::WStyle_Tool );
lblWait->setPixmap( pix );
lblWait->setAlignment( QWidget::AlignCenter );
lblWait->show();
lblWait->showMaximized();
}
#ifndef SINGLE_APP
{ QCopEnvelope envelope( "QPE/System", "forceQuit()" );
}
processEvents(); // ensure the message goes out.
sleep( 1 ); // You have 1 second to comply.
#endif
}
+int QPEApplication::x11ClientMessage(QWidget* w, XEvent* event, bool b ) {
+ qWarning("X11 ClientMessage %d %d", event->type, ClientMessage);
+ if ( event->type == ClientMessage ) {
+ if ( (event->xclient.message_type == d->wm_protocols) &&
+ (event->xclient.data.l[0] == d->wm_context_accept ) ) {
+ qWarning("accepted!!!");
+ /*
+ * I'm not sure if we should use activeWidget
+ * or activeModalWidget
+ * a QDialog could be not modal too
+ */
+ if ( w->inherits("QDialog" ) ) {
+ qWarning("inherits QDialog!!!");
+ QDialog* dia = (QDialog*)w;
+ /*
+ * call it directly or via QTimer::singleShot?
+ */
+ QTimer::singleShot(0, dia, SLOT(reject() ) );
+ return 0;
+ }
+
+ }
+ }
+ return QApplication::x11ClientMessage(w, event, b );
+}
+
+#define KeyPress XKeyPress
+#define KeyRelease XKeyRelease
#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
// The libraries with the skiff package (and possibly others) have
// completely useless implementations of builtin new and delete that
// use about 50% of your CPU. Here we revert to the simple libc
// functions.
void* operator new[]( size_t size )
{
return malloc( size );
}
void* operator new( size_t size )
{
return malloc( size );
}
void operator delete[]( void* p )
{
free( p );
}
void operator delete[]( void* p, size_t /*size*/ )
diff --git a/x11/libqpe-x11/qpe/qpeapplication.h b/x11/libqpe-x11/qpe/qpeapplication.h
index 333f331..254fbfa 100644
--- a/x11/libqpe-x11/qpe/qpeapplication.h
+++ b/x11/libqpe-x11/qpe/qpeapplication.h
@@ -40,48 +40,50 @@ public:
AlwaysOn
};
static void setInputMethodHint( QWidget*, InputMethodHint );
static InputMethodHint inputMethodHint( QWidget* );
void showMainWidget( QWidget*, bool nomax = FALSE );
void showMainDocumentWidget( QWidget*, bool nomax = FALSE );
static void showDialog( QDialog*, bool nomax = FALSE );
static int execDialog( QDialog*, bool nomax = FALSE );
static void setKeepRunning();
bool keepRunning()const;
bool keyboardGrabbed()const;
int exec();
// QWS bits
enum screenSaverHint {
Disable = 0,
DisableLightOff = 1,
DisableSuspend = 2,
Enable = 100
};
+ /* reimplemented for internal purposes */
+ int x11ClientMessage( QWidget*, XEvent*, bool );
signals:
void clientMoused();
void timeChanged();
void clockChanged( bool pm );
void micChanged( bool muted );
void volumeChanged( bool muted );
void appMessage( const QCString& msg, const QByteArray& data);
void weekChanged( bool startOnMonday );
void dateFormatChanged( DateFormat );
void flush();
void reload();
private:
void initTranslations();
void internalSetStyle(const QString&);
private slots:
void hideOrQuit();
void systemMessage( const QCString&, const QByteArray& );
void pidMessage( const QCString&, const QByteArray& );
void removeSenderFromStylusDict();
protected:
virtual void restart();