summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--x11/ipc/server/ocopserver.cpp59
-rw-r--r--x11/libqpe-x11/qpe/qpeapplication.cpp90
-rw-r--r--x11/libqpe-x11/qpe/qpeapplication.h2
3 files changed, 127 insertions, 24 deletions
diff --git a/x11/ipc/server/ocopserver.cpp b/x11/ipc/server/ocopserver.cpp
index 4940cb8..0f818b7 100644
--- a/x11/ipc/server/ocopserver.cpp
+++ b/x11/ipc/server/ocopserver.cpp
@@ -159,33 +159,33 @@ void OCopServer::newOnClient( int fd ) {
* otherwise do read
* channel
* func
* data into mem
* and then send the OCOPPacket
*
*/
if (head.magic == 47 ) {
- qWarning("magic match");
+// qWarning("magic match");
QCString channel( head.chlen+1 );
QCString func( head.funclen+1 );
QByteArray data ( head.datalen );
/*
* we do not check for errors
*/
- qWarning("read ");
+// qWarning("read ");
int s = read(fd, channel.data(), head.chlen );
s = read(fd, func.data(), head.funclen );
s = read(fd, data.data(), head.datalen );
- qWarning("read");
+// qWarning("read");
/* debug output */
- qWarning("channel %s %d", channel.data(), head.chlen );
- qWarning("func %s %d", func.data(), head.funclen );
+// qWarning("channel %s %d", channel.data(), head.chlen );
+// qWarning("func %s %d", func.data(), head.funclen );
/* debug end */
/*
* now that we got the complete body
* we need to make a package
* and then we need to send it to clients
* making a package is done here
* dispatching it not
@@ -209,62 +209,64 @@ void OCopServer::registerClient( int fd ) {
client.fd = fd;
client.notify = notify;
m_clients.insert( client.fd, client );
qWarning("clients are up to %d", m_clients.count() );
};
void OCopServer::deregisterClient(int fd ) {
QMap<int, OCOPClient>::Iterator it = m_clients.find( fd );
if (it != m_clients.end() ) {
- OCOPClient client = it.data();
- delete client.notify;
- m_clients.remove(fd );
- close(fd );
/*
* TIME_ME
*
* now delete from all channels
* go through all channels
* remove the fd from the list
* if count becomes 0 remove the channel
* otherwise replace QArray<int>
*/
QMap<QCString, QValueList<int> >::Iterator it2;
repeatIt:
for ( it2 = m_channels.begin(); it2 != m_channels.end(); ++it2 ) {
/*
* The channel contains this fd
*/
- qWarning("Channel %s", it2.key().data() );
+ qWarning("Channel %s %d", it2.key().data(), it2.data().count() );
if ( it2.data().contains( fd ) ) {
qWarning("contains");
QValueList<int> array = it2.data();
/*
* remove channel or just replace
*/
- if ( array.count() == 1 ) {
+ if ( array.count() == 1 || array.count() == 0) {
qWarning("Invalidate!");
/* is the list now invalidatet? */
m_channels.remove( it2 );
/* That is the first go to of my life
* but Iterator remove( Iterator )
* does not exist
* it2 = --it2;
* does not work reliable too
* so the only way is to reiterate :(
*/
goto repeatIt;
}else{
- qWarning("removing");
- array.remove( fd );
- it2 = m_channels.replace( it2.key(), array );
+ qWarning("removing count %d %d",fd, array.count() );
+ QValueList<int>::Iterator it3 = array.find( fd );
+ it3 = array.remove( it3 );
+ QCString key = it2.key().copy();
+ it2 = m_channels.replace( key, array );
}
}
} // off all channels
+ OCOPClient client = it.data();
+ delete client.notify;
+ m_clients.remove(fd );
+ close(fd );
}
qWarning("clients are now at %d", m_clients.count() );
};
/**
* this function will evaluate
* the package and then do the appropriate thins
*/
void OCopServer::dispatch( const OCOPPacket& packet, int sourceFD ) {
@@ -322,44 +324,53 @@ QStringList OCopServer::channels() {
}
bool OCopServer::isChannelRegistered( const QCString& chan ) const{
return m_channels.contains( chan );
}
void OCopServer::addChannel( const QCString& channel,
int fd ) {
QMap<QCString, QValueList<int> >::Iterator it;
it = m_channels.find( channel );
-
- /* could be empty */
- QValueList<int> list = it.data();
- list.append( fd );
- it = m_channels.replace( channel, list );
+ if ( it != m_channels.end() ) {
+ /* could be empty */
+ QValueList<int> list = it.data();
+ list.append( fd );
+ qWarning("count is now in addChannel %d %s", list.count(), channel.data() );
+ it = m_channels.replace( channel, list );
+ }else {
+ QValueList<int> ints;
+ ints.append( fd );
+ m_channels.insert( channel, ints );
+ }
};
void OCopServer::delChannel( const QCString& channel,
int fd ) {
+ qWarning("remove %s, %d", channel.data(), fd );
if (!m_channels.contains( channel ) )
return;
QMap<QCString, QValueList<int> >::Iterator it;
it = m_channels.find( channel );
if ( it.data().contains(fd) ) {
-
QValueList<int> ints = it.data();
if ( ints.count() == 1 )
- m_channels.remove( it );
+ m_channels.remove( channel );
else{
QValueList<int> ints = it.data();
- ints.remove( fd );
- m_channels.replace( it.key(), ints );
+ QValueList<int>::Iterator rem = ints.find( fd );
+ rem = ints.remove( rem );
+ QCString str = it.key().copy();
+ m_channels.replace( str, ints );
}
+ qWarning(" channel count is now %d", ints.count() );
}
}
void OCopServer::isRegistered( const QCString& channel, int fd) {
- qWarning("isRegistered");
+// qWarning("isRegistered");
OCOPHead head;
QCString func(2);
memset(&head, 0, sizeof(head ) );
head.magic = 47;
head.type = OCOPPacket::IsRegistered;
head.chlen = channel.size();
head.funclen = func.size();
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,26 +1,28 @@
#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>
@@ -29,16 +31,25 @@
#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;
@@ -71,16 +82,21 @@ public:
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 ),
@@ -214,16 +230,42 @@ QPEApplication::~QPEApplication() {
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 );
@@ -525,16 +567,36 @@ void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode) {
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 ) {
@@ -652,16 +714,44 @@ void QPEApplication::prepareForTermination( bool willrestart )
}
#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.
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
@@ -56,16 +56,18 @@ public:
// 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);