Compare commits

..

4 Commits

Author SHA1 Message Date
Jean-Marc Lasgouttes
4d46f766ea Avoid missing updates after some operations on selection
The logic at the end of Text::dispatch failed when needsUpdate and
singleParUpdate were true at the same time.
2024-08-31 16:12:59 +02:00
Jean-Marc Lasgouttes
5ca48a7a39 Fix update of cursor in tab-delete when there is a selection
The position of the cursor should not be decreased if it is already at
the start of the paragraph. This can lead to a crash when trying to
display the caret.

(cherry picked from commit 16be88ca18)
2024-08-31 16:12:59 +02:00
Jean-Marc Lasgouttes
d7e2ca377f Get rid of QPA_XCB define
Since the platform is selected at run time (e.g. xcb vs. Wayland), it
is not a good idea to decide at compile time what code is run. Another
example is on macOS, where having xcb libraries available will lead to
lauching the Xquartz whenever LyX is running.

With this patch, things are separated:
- the code is run when run-time platform is "xcb".
- the support code is compiled in when xcb header and libraries are
  available.

The cmake code is courtesy of Kornel Benko.

Fixes ticket #13086.

(cherry picked from commit 18c310a8cf)
(cherry picked from commit f1fddd86ef)
(cherry picked from commit 3bc4554e57)
(cherry picked from commit 8c14748e78)
2024-08-31 15:07:29 +02:00
Jean-Marc Lasgouttes
390f458122 Streamline -geometry command-line option support
Instead of baking our own support for -geometry command line option on
Windows (Qt only does that for Xcb), use the fact that Qt 5 provides
the equivalent -qwindowgeometry flag.

All we need to do is to replace the -geometry option with -qwindowgeometry.

This is part of the effort in ticket #13086 to get rid of the
compile-time QPA_XCB define.

(cherry picked from commit ce9de28f06)
2024-08-31 15:05:34 +02:00
10 changed files with 52 additions and 83 deletions

View File

@ -805,7 +805,6 @@ if(LYX_USE_QT MATCHES "QT6|QT5")
Qt5_wrap_ui(${ARGN}) Qt5_wrap_ui(${ARGN})
endmacro() endmacro()
endif() endif()
# set QPA_XCB if QT uses X11
find_package(${QtVal}Core CONFIG REQUIRED) find_package(${QtVal}Core CONFIG REQUIRED)
if (${QtVal}Core_FOUND) if (${QtVal}Core_FOUND)
find_package(${QtVal}Widgets CONFIG REQUIRED) find_package(${QtVal}Widgets CONFIG REQUIRED)
@ -1188,6 +1187,13 @@ get_data_destination(dest_data)
list(APPEND tmp_vi " LyX files dir: ${CMAKE_INSTALL_PREFIX}/${dest_data}") list(APPEND tmp_vi " LyX files dir: ${CMAKE_INSTALL_PREFIX}/${dest_data}")
string(REPLACE ";" "\\n" VERSION_INFO "${tmp_vi}") string(REPLACE ";" "\\n" VERSION_INFO "${tmp_vi}")
# the result XCB_LIBRARY will be used in src/CMakeLists.txt and also in configuring config.h
find_library(XCB_LIBRARY NAMES xcb)
if (XCB_LIBRARY)
set(HAVE_LIBXCB 1 CACHE BOOL "" FORCE)
else()
set(HAVE_LIBXCB 0 CACHE BOOL "" FORCE)
endif()
configure_file(${LYX_CMAKE_DIR}/config.h.cmake ${TOP_BINARY_DIR}/config.h) configure_file(${LYX_CMAKE_DIR}/config.h.cmake ${TOP_BINARY_DIR}/config.h)
unset(opts) unset(opts)
unset(tmp_vi) unset(tmp_vi)

View File

@ -214,31 +214,15 @@ AC_DEFUN([QT_DO_IT_ALL],
fi;; fi;;
esac esac
dnl Specific support for X11 will be built if these are available
AC_CHECK_HEADERS([xcb/xcb.h])
AC_CHECK_LIB([xcb], [xcb_send_event])
save_CPPFLAGS=$CPPFLAGS save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$save_CPPFLAGS $QT_CORE_INCLUDES" CPPFLAGS="$save_CPPFLAGS $QT_CORE_INCLUDES"
AC_CHECK_HEADER(QtGui/qtgui-config.h, AC_CHECK_HEADER(QtGui/qtgui-config.h,
[lyx_qt_config=QtGui/qtgui-config.h], [lyx_qt_config=QtGui/qtgui-config.h],
[lyx_qt_config=qconfig.h]) [lyx_qt_config=qconfig.h])
AC_MSG_CHECKING([whether Qt uses the X Window system])
if test x$USE_QT6 = xyes ; then
dnl FIXME: Check whether defining QPA_XCB makes sense with Qt6
AC_PREPROC_IFELSE([AC_LANG_SOURCE([
[#include <$lyx_qt_config>]
[#if !defined(QT_FEATURE_xcb) || QT_FEATURE_xcb < 0]
[#error Fail]
[#endif]])],
[AC_MSG_RESULT(yes)
AC_DEFINE(QPA_XCB, 1, [Define if Qt uses the X Window System])],
[AC_MSG_RESULT(no)])
else
AC_EGREP_CPP(xcb,
[#include <$lyx_qt_config>
QT_QPA_DEFAULT_PLATFORM_NAME],
[AC_MSG_RESULT(yes)
AC_DEFINE(QPA_XCB, 1, [Define if Qt uses the X Window System])],
[AC_MSG_RESULT(no)])
fi
CPPFLAGS=$save_CPPFLAGS CPPFLAGS=$save_CPPFLAGS
QT_FIND_TOOL([QT_MOC], [moc]) QT_FIND_TOOL([QT_MOC], [moc])

View File

@ -28,7 +28,7 @@ test_big_endian(WORDS_BIGENDIAN)
set(Include_Defines) set(Include_Defines)
foreach(_h_file aspell.h aspell/aspell.h limits.h locale.h foreach(_h_file aspell.h aspell/aspell.h limits.h locale.h
stdlib.h sys/stat.h sys/time.h sys/types.h sys/utime.h stdlib.h sys/stat.h sys/time.h sys/types.h sys/utime.h
sys/socket.h unistd.h inttypes.h utime.h string.h argz.h) sys/socket.h unistd.h inttypes.h utime.h string.h argz.h xcb/xcb.h)
string(REGEX REPLACE "[/\\.]" "_" _hf ${_h_file}) string(REGEX REPLACE "[/\\.]" "_" _hf ${_h_file})
string(TOUPPER ${_hf} _HF) string(TOUPPER ${_hf} _HF)
check_include_files(${_h_file} HAVE_${_HF}) check_include_files(${_h_file} HAVE_${_HF})
@ -275,7 +275,6 @@ else()
endif() endif()
endif() endif()
set(QPA_XCB)
set(HAVE_QT5_X11_EXTRAS) set(HAVE_QT5_X11_EXTRAS)
set(HAVE_QT6_X11_EXTRAS) set(HAVE_QT6_X11_EXTRAS)
if (LYX_USE_QT MATCHES "QT5|QT6") if (LYX_USE_QT MATCHES "QT5|QT6")
@ -312,10 +311,6 @@ if (LYX_USE_QT MATCHES "QT5|QT6")
} }
" "
QT_USES_X11) QT_USES_X11)
if(QT_USES_X11 AND NOT LYX_USE_QT MATCHES "QT6")
set(QPA_XCB ${QT_USES_X11})
message(STATUS "Found QPA_XCB = ${QPA_XCB}")
endif()
endif() endif()
if (${QtVal}X11Extras_FOUND) if (${QtVal}X11Extras_FOUND)

View File

@ -64,9 +64,6 @@
#cmakedefine Z_PREFIX 1 #cmakedefine Z_PREFIX 1
// Defined if QT=QT5 uses X11
#cmakedefine QPA_XCB 1
// Define if you have the Qt5X11Extras module // Define if you have the Qt5X11Extras module
#cmakedefine HAVE_QT5_X11_EXTRAS 1 #cmakedefine HAVE_QT5_X11_EXTRAS 1
@ -91,10 +88,13 @@ ${Include_used_spellchecker}
// Define to 1 if enchant is version 2.x at least // Define to 1 if enchant is version 2.x at least
#cmakedefine HAVE_ENCHANT2 1 #cmakedefine HAVE_ENCHANT2 1
#endif // config.h guard // Define to 1 if have xcb library
#cmakedefine HAVE_LIBXCB ${HAVE_LIBXCB}
#define MYTHES_H_LOCATION <${MYTHES_DIR}/mythes.hxx> #define MYTHES_H_LOCATION <${MYTHES_DIR}/mythes.hxx>
#endif // config.h guard
// Unguarded cleanup of global namespace: // Unguarded cleanup of global namespace:
#ifdef ColorMode #ifdef ColorMode

View File

@ -148,7 +148,6 @@ if(QT_USES_X11)
find_package(X11 REQUIRED) find_package(X11 REQUIRED)
target_link_libraries(${_lyx} ${X11_X11_LIB}) # we need it because we use XSendEvent target_link_libraries(${_lyx} ${X11_X11_LIB}) # we need it because we use XSendEvent
if(HAVE_QT5_X11_EXTRAS) if(HAVE_QT5_X11_EXTRAS)
find_library(XCB_LIBRARY NAMES xcb)
if (XCB_LIBRARY MATCHES "NOTFOUND") if (XCB_LIBRARY MATCHES "NOTFOUND")
message(FATAL_ERROR "Need xcb library to use with QT5_X11_EXTRAS") message(FATAL_ERROR "Need xcb library to use with QT5_X11_EXTRAS")
endif() endif()

View File

@ -127,8 +127,6 @@ namespace {
string cl_system_support; string cl_system_support;
string cl_user_support; string cl_user_support;
string geometryArg;
LyX * singleton_ = nullptr; LyX * singleton_ = nullptr;
void showFileError(string const & error) void showFileError(string const & error)
@ -611,7 +609,7 @@ void LyX::execCommands()
} }
// create the first main window // create the first main window
lyx::dispatch(FuncRequest(LFUN_WINDOW_NEW, geometryArg)); lyx::dispatch(FuncRequest(LFUN_WINDOW_NEW));
if (!pimpl_->files_to_load_.empty()) { if (!pimpl_->files_to_load_.empty()) {
// if some files were specified at command-line we assume that the // if some files were specified at command-line we assume that the
@ -1342,20 +1340,6 @@ int parse_import(string const & type, string const & file, string & batch)
} }
int parse_geometry(string const & arg1, string const &, string &)
{
geometryArg = arg1;
#if !defined(QPA_XCB)
// don't remove "-geometry", it will be pruned out later in the
// frontend if need be.
return -1;
#else
// but that is only done if QPA_XCB is not defined.
return 1;
#endif
}
int parse_batch(string const &, string const &, string &) int parse_batch(string const &, string const &, string &)
{ {
use_gui = false; use_gui = false;
@ -1433,7 +1417,6 @@ void LyX::easyParse(int & argc, char * argv[])
cmdmap["--export-to"] = parse_export_to; cmdmap["--export-to"] = parse_export_to;
cmdmap["-i"] = parse_import; cmdmap["-i"] = parse_import;
cmdmap["--import"] = parse_import; cmdmap["--import"] = parse_import;
cmdmap["-geometry"] = parse_geometry;
cmdmap["-batch"] = parse_batch; cmdmap["-batch"] = parse_batch;
cmdmap["-f"] = parse_force; cmdmap["-f"] = parse_force;
cmdmap["--force-overwrite"] = parse_force; cmdmap["--force-overwrite"] = parse_force;
@ -1446,6 +1429,10 @@ void LyX::easyParse(int & argc, char * argv[])
cmdmap["--ignore-error-message"] = parse_ignore_error_message; cmdmap["--ignore-error-message"] = parse_ignore_error_message;
for (int i = 1; i < argc; ++i) { for (int i = 1; i < argc; ++i) {
// Let Qt handle -geometry even when not on X11.
if (from_utf8(argv[i]) == "-geometry")
argv[i] = const_cast<char *>("-qwindowgeometry");
map<string, cmd_helper>::const_iterator it map<string, cmd_helper>::const_iterator it
= cmdmap.find(argv[i]); = cmdmap.find(argv[i]);

View File

@ -4594,10 +4594,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
int const n = (c == ' ' ? 4 : 1); int const n = (c == ' ' ? 4 : 1);
for (int i = 0; i < n for (int i = 0; i < n
&& !par.empty() && par.getChar(0) == c; ++i) { && !par.empty() && par.getChar(0) == c; ++i) {
if (cur.pit() == pit) if (cur.pit() == pit && cur.pos() > 0)
cur.posBackward(); cur.posBackward();
if (cur.realAnchor().pit() == pit if (cur.realAnchor().pit() == pit && cur.realAnchor().pos() > 0)
&& cur.realAnchor().pos() > 0 )
cur.realAnchor().backwardPos(); cur.realAnchor().backwardPos();
par.eraseChar(0, tc); par.eraseChar(0, tc);
} }
@ -6387,7 +6386,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
// FIXME: the following code should go in favor of fine grained // FIXME: the following code should go in favor of fine grained
// update flag treatment. // update flag treatment.
if (singleParUpdate) { if (singleParUpdate && !needsUpdate) {
// Inserting characters does not change par height in general. So, try // Inserting characters does not change par height in general. So, try
// to update _only_ this paragraph. BufferView will detect if a full // to update _only_ this paragraph. BufferView will detect if a full
// metrics update is needed anyway. // metrics update is needed anyway.

View File

@ -121,7 +121,7 @@
#include <QThreadPool> #include <QThreadPool>
#include <QWidget> #include <QWidget>
#if defined(QPA_XCB) #ifdef HAVE_XCB_XCB_H
#include <xcb/xcb.h> #include <xcb/xcb.h>
#ifdef HAVE_QT5_X11_EXTRAS #ifdef HAVE_QT5_X11_EXTRAS
#include <QtX11Extras/QX11Info> #include <QtX11Extras/QX11Info>
@ -172,20 +172,6 @@ namespace lyx {
frontend::Application * createApplication(int & argc, char * argv[]) frontend::Application * createApplication(int & argc, char * argv[])
{ {
#if !defined(QPA_XCB)
// prune -geometry argument(s) by shifting
// the following ones 2 places down.
for (int i = 0 ; i < argc ; ++i) {
if (strcmp(argv[i], "-geometry") == 0) {
int const remove = (i+1) < argc ? 2 : 1;
argc -= remove;
for (int j = i; j < argc; ++j)
argv[j] = argv[j + remove];
--i;
}
}
#endif
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN) #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
// On Windows, allow bringing the LyX window to top // On Windows, allow bringing the LyX window to top
AllowSetForegroundWindow(ASFW_ANY); AllowSetForegroundWindow(ASFW_ANY);
@ -1171,10 +1157,14 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
// Install Qt native translator for GUI elements. // Install Qt native translator for GUI elements.
installTranslator(&d->qt_trans_); installTranslator(&d->qt_trans_);
#ifdef QPA_XCB if (platformName() == "xcb") {
#if defined(HAVE_XCB_XCB_H) && defined(HAVE_LIBXCB)
// Enable reception of XCB events. // Enable reception of XCB events.
installNativeEventFilter(this); installNativeEventFilter(this);
#else
LYXERR0("Warning: X11 support is incomplete in this LyX binary.");
#endif #endif
}
// FIXME: quitOnLastWindowClosed is true by default. We should have a // FIXME: quitOnLastWindowClosed is true by default. We should have a
// lyxrc setting for this in order to let the application stay resident. // lyxrc setting for this in order to let the application stay resident.
@ -1195,13 +1185,13 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
this, SLOT(onApplicationStateChanged(Qt::ApplicationState))); this, SLOT(onApplicationStateChanged(Qt::ApplicationState)));
#endif #endif
#if defined(QPA_XCB) if (platformName() == "xcb") {
// doubleClickInterval() is 400 ms on X11 which is just too long. // doubleClickInterval() is 400 ms on X11 which is just too long.
// On Windows and Mac OS X, the operating system's value is used. // On Windows and Mac OS X, the operating system's value is used.
// On Microsoft Windows, calling this function sets the double // On Microsoft Windows, calling this function sets the double
// click interval for all applications. So we don't! // click interval for all applications. So we don't!
QApplication::setDoubleClickInterval(300); QApplication::setDoubleClickInterval(300);
#endif }
connect(this, SIGNAL(lastWindowClosed()), this, SLOT(onLastWindowClosed())); connect(this, SIGNAL(lastWindowClosed()), this, SLOT(onLastWindowClosed()));
@ -3491,7 +3481,7 @@ bool GuiApplication::longOperationStarted() {
// //
// X11 specific stuff goes here... // X11 specific stuff goes here...
#if defined(QPA_XCB) #if defined(HAVE_XCB_XCB_H) && defined(HAVE_LIBXCB)
bool GuiApplication::nativeEventFilter(const QByteArray & eventType, bool GuiApplication::nativeEventFilter(const QByteArray & eventType,
void * message, QINTPTR *) void * message, QINTPTR *)
{ {

View File

@ -20,7 +20,7 @@
#include <QApplication> #include <QApplication>
#include <QList> #include <QList>
#ifdef QPA_XCB #if defined(HAVE_XCB_XCB_H) && defined(HAVE_LIBXCB)
#include <QAbstractNativeEventFilter> #include <QAbstractNativeEventFilter>
#endif #endif
@ -53,7 +53,7 @@ There should be only one instance of this class. No Qt object
initialisation should be done before the instantiation of this class. initialisation should be done before the instantiation of this class.
*/ */
class GuiApplication : public QApplication, public Application class GuiApplication : public QApplication, public Application
#ifdef QPA_XCB #if defined(HAVE_XCB_XCB_H) && defined(HAVE_LIBXCB)
, public QAbstractNativeEventFilter , public QAbstractNativeEventFilter
#endif #endif
{ {
@ -120,7 +120,7 @@ public:
//@{ //@{
bool notify(QObject * receiver, QEvent * event) override; bool notify(QObject * receiver, QEvent * event) override;
void commitData(QSessionManager & sm); void commitData(QSessionManager & sm);
#if defined(QPA_XCB) #if defined(HAVE_XCB_XCB_H) && defined(HAVE_LIBXCB)
#if (QT_VERSION < 0x060000) #if (QT_VERSION < 0x060000)
#define QINTPTR long #define QINTPTR long
#else #else

View File

@ -57,6 +57,11 @@ What's new
- Speedup interactive use by avoiding expensive math macros bookkeeping - Speedup interactive use by avoiding expensive math macros bookkeeping
when possible. when possible.
- Make -geometry command-line option work on all platforms.
- Fix macOS bug, where XQuartz application would be launched for no
reason (bug #13086).
* DOCUMENTATION AND LOCALIZATION * DOCUMENTATION AND LOCALIZATION
@ -116,8 +121,12 @@ What's new
and xltable), as this is not supported by the packages. Also fix the and xltable), as this is not supported by the packages. Also fix the
disabling mechanism in the table dialog. disabling mechanism in the table dialog.
- Fix display of integral limits on Windows (bug 13087) - Fix display of integral limits on Windows (bug 13087).
- Fix crash when deleting tabs in a selection (with S-BackTab) in a
text-only inset (ERT, Listings...).
- Fix display glitches when applying some operations to a selection.
* INTERNALS * INTERNALS