José Matos <jama...@fc.up.pt> writes:

> Hi,
>       I had this problem before but being busy I did not report it.
>
>       One of the features of F-13 is 
> http://fedoraproject.org/w/index.php?title=UnderstandingDSOLinkChange
>
> This means that lyx does not compile because when linking with qt we need to 
> pass -lX11 since qt uses symbols from X11.

This bug is also known in debian
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=555580

It is not the reason. With the new DSO thing linking against qt does
_not_ require to link against X11, and this is actually our problem. We
explicitely use X11 calls for some weird event ignoring in
GuiWorkArea.cpp, which fixes AFAICS the following bug
http://www.lyx.org/trac/ticket/3320

Before trying to add the -lX11 in autotools, let's see what we can do
about the actual code. It reads:

        // do nothing if there are other events
        // (the auto repeated events come too fast)
        // \todo FIXME: remove hard coded Qt keys, process the key binding
#ifdef Q_WS_X11
        if (XEventsQueued(QX11Info::display(), 0) > 1 && ev->isAutoRepeat()
                        && (Qt::Key_PageDown || Qt::Key_PageUp)) {
                LYXERR(Debug::KEY, "system is busy: scroll key event ignored");
                ev->ignore();
                return;
        }
#endif


Firstly, there is a very amusing detail: as I read it, the test for
Qt::Key_PageXXX does nothing :) Since nobody complained about it, and
since explicitly testing for hardcoded keys is tasteless, I propose to
remove this part.

Secondly, XEventQueued can be replaced with
QApplication:hasPendingEvents, also there is a slight difference, the
later calls XPending:

       The XPending function returns the number of events that have been
       received from the X server but have not been removed from the event
       queue.  XPending is identical to XEventsQueued with the mode
       QueuedAfterFlush specified.

So what do these mysterious flags mean?

       If mode is QueuedAlready, XEventsQueued returns the number of events
       already in the event queue (and never performs a system call).  If
       mode is QueuedAfterFlush, XEventsQueued returns the number of events
       already in the queue if the number is nonzero.  If there are no events
       in the queue, XEventsQueued flushes the output buffer, attempts to
       read more events out of the application's connection, and returns the
       number read.  If mode is QueuedAfterReading, XEventsQueued returns the
       number of events already in the queue if the number is nonzero.  If
       there are no events in the queue, XEventsQueued attempts to read more
       events out of the application's connection without flushing the output
       buffer and returns the number read.

For information, we use mode 0, which is QueuedAlready. It seems to me
that using QueuedAfterFlush is a better idea, so I think using
hasPendingEvents is good enough.

This leads to the following patch. Now is looks like the code should be
useful on other platforms too. Is this problem with page down also
present for Mac OS or Windows? I would propose to use the code on
all platforms.

Finally, could someone check that this solves the issue with F13?

JMarc

Index: src/frontends/qt4/GuiWorkArea.cpp
===================================================================
--- src/frontends/qt4/GuiWorkArea.cpp	(révision 34587)
+++ src/frontends/qt4/GuiWorkArea.cpp	(copie de travail)
@@ -72,11 +72,6 @@
 
 #include <cmath>
 
-#ifdef Q_WS_X11
-#include <QX11Info>
-extern "C" int XEventsQueued(Display *display, int mode);
-#endif
-
 #ifdef Q_WS_WIN
 int const CursorWidth = 2;
 #else
@@ -911,11 +906,9 @@
 
 	// do nothing if there are other events
 	// (the auto repeated events come too fast)
-	// \todo FIXME: remove hard coded Qt keys, process the key binding
 #ifdef Q_WS_X11
-	if (XEventsQueued(QX11Info::display(), 0) > 1 && ev->isAutoRepeat()
-			&& (Qt::Key_PageDown || Qt::Key_PageUp)) {
-		LYXERR(Debug::KEY, "system is busy: scroll key event ignored");
+	if (qApp->hasPendingEvents() && ev->isAutoRepeat()) {
+		LYXERR(Debug::KEY, "system is busy: keyPress event ignored");
 		ev->ignore();
 		return;
 	}

Reply via email to