Compare commits

...

5 Commits

Author SHA1 Message Date
Jean-Marc Lasgouttes
16be88ca18 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.
2024-08-30 16:56:16 +02:00
Jean-Marc Lasgouttes
2eb4e3d3ca Fixup 999fb37e: fix thinko
The current buffer is part of allRelatives(), contrary to what I
thought. Therefore updateId() increased the buffer id by two.
2024-08-30 15:07:03 +02:00
Jean-Marc Lasgouttes
53c8e0b77d update comments 2024-08-30 14:53:07 +02:00
Jean-Marc Lasgouttes
3c59a9a23c Remove legacy code to compute geometry
This code is not necessary anymore after the fix to #13069.

Remove the first QString argument to createView(). Set the autoShow
parameter to false by default and rename createView(id) to
createAndShowView(id) to avoid member function overloading issues.

Remove optional <GEOMETRY> argument of window-new lfun.
Document the removal of the argument in release notes.
2024-08-30 14:45:36 +02:00
Kornel Benko
8c14748e78 Amend 18c310a8 for cmake build: Get rid of QPA_XCB define 2024-08-30 14:08:05 +02:00
10 changed files with 28 additions and 75 deletions

View File

@ -812,7 +812,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)
@ -1186,6 +1185,7 @@ 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) find_library(XCB_LIBRARY NAMES xcb)
if (XCB_LIBRARY) if (XCB_LIBRARY)
set(HAVE_LIBXCB 1 CACHE BOOL "" FORCE) set(HAVE_LIBXCB 1 CACHE BOOL "" FORCE)

View File

@ -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

View File

@ -15,6 +15,10 @@
!!!The following LyX functions have been changed in 2.5: !!!The following LyX functions have been changed in 2.5:
- The funcion window_new does not take an optional <GEOMETRY>
parameter anymore. This only worked in windows and existed for
internal reasons.
!!!The following LyX functions have been removed in 2.5: !!!The following LyX functions have been removed in 2.5:
!!!The following LyX function has been added and then removed in 2.5 development cycle: !!!The following LyX function has been added and then removed in 2.5 development cycle:

View File

@ -803,7 +803,6 @@ int Buffer::id() const
void Buffer::updateId() void Buffer::updateId()
{ {
++d->id_;
for(Buffer * b : allRelatives()) for(Buffer * b : allRelatives())
++(b->d->id_); ++(b->d->id_);
} }

View File

@ -661,10 +661,11 @@ public:
/// ///
Undo const & undo() const; Undo const & undo() const;
/// poor man versioning of the buffer (and its relatives). /// Poor man versioning of the buffer (and its relatives).
/// This is currently used by updateMacros() and Statistics::update().
int id() const; int id() const;
/// change the id of this buffer and its relatives (indicating /// change the id of this buffer and its relatives (indicating
/// something has changed). This is currently used by updateMacros(). /// something has changed).
void updateId(); void updateId();
/// This function is called when the buffer is changed. /// This function is called when the buffer is changed.

View File

@ -4417,9 +4417,7 @@ void LyXAction::init()
* \var lyx::FuncCode lyx::LFUN_WINDOW_NEW * \var lyx::FuncCode lyx::LFUN_WINDOW_NEW
* \li Action: Creates new empty LyX window. * \li Action: Creates new empty LyX window.
* \li Notion: Already opened documents from the previous window can be found under View menu. * \li Notion: Already opened documents from the previous window can be found under View menu.
* \li Syntax: window-new [<GEOMETRY>] * \li Syntax: window-new
* \li Params: <GEOMETRY>: pass the geometry of the window. This parameter is currently
accepted only on Windows platform.
* \li Origin: Abdel, 21 Oct 2006 * \li Origin: Abdel, 21 Oct 2006
* \endvar * \endvar
*/ */

View File

@ -4629,10 +4629,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);
} }

View File

@ -1771,7 +1771,7 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
switch (cmd.action()) { switch (cmd.action()) {
case LFUN_WINDOW_NEW: case LFUN_WINDOW_NEW:
createView(toqstr(cmd.argument())); createAndShowView();
break; break;
case LFUN_WINDOW_CLOSE: case LFUN_WINDOW_CLOSE:
@ -1811,7 +1811,7 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
validateCurrentView(); validateCurrentView();
if (!current_view_ if (!current_view_
|| (!lyxrc.open_buffers_in_tabs && current_view_->documentBufferView() != nullptr)) { || (!lyxrc.open_buffers_in_tabs && current_view_->documentBufferView() != nullptr)) {
createView(QString(), false); // keep hidden createView(); // keep hidden
current_view_->newDocument(to_utf8(cmd.argument())); current_view_->newDocument(to_utf8(cmd.argument()));
current_view_->show(); current_view_->show();
current_view_->activateWindow(); current_view_->activateWindow();
@ -1826,7 +1826,7 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
validateCurrentView(); validateCurrentView();
if (!current_view_ if (!current_view_
|| (!lyxrc.open_buffers_in_tabs && current_view_->documentBufferView() != nullptr)) { || (!lyxrc.open_buffers_in_tabs && current_view_->documentBufferView() != nullptr)) {
createView(); createAndShowView();
current_view_->newDocument(file, temp, true); current_view_->newDocument(file, temp, true);
if (!current_view_->documentBufferView()) if (!current_view_->documentBufferView())
current_view_->close(); current_view_->close();
@ -1850,7 +1850,7 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
&& !is_open)) { && !is_open)) {
// We want the ui session to be saved per document and not per // We want the ui session to be saved per document and not per
// window number. The filename crc is a good enough identifier. // window number. The filename crc is a good enough identifier.
createView(support::checksum(fname)); createAndShowView(support::checksum(fname));
current_view_->openDocuments(fname, cmd.origin()); current_view_->openDocuments(fname, cmd.origin());
if (!current_view_->documentBufferView()) if (!current_view_->documentBufferView())
current_view_->close(); current_view_->close();
@ -1873,7 +1873,7 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
case LFUN_HELP_OPEN: { case LFUN_HELP_OPEN: {
// FIXME: create a new method shared with LFUN_FILE_OPEN. // FIXME: create a new method shared with LFUN_FILE_OPEN.
if (current_view_ == nullptr) if (current_view_ == nullptr)
createView(); createAndShowView();
string const arg = to_utf8(cmd.argument()); string const arg = to_utf8(cmd.argument());
if (arg.empty()) { if (arg.empty()) {
current_view_->message(_("Missing argument")); current_view_->message(_("Missing argument"));
@ -2263,7 +2263,7 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|| name == "progress" || name == "texinfo") || name == "progress" || name == "texinfo")
{ {
if (current_view_ == nullptr) if (current_view_ == nullptr)
createView(); createAndShowView();
} }
} }
// fall through // fall through
@ -2572,14 +2572,13 @@ bool GuiApplication::rtlContext() const
} }
void GuiApplication::createView(int view_id) void GuiApplication::createAndShowView(int view_id)
{ {
createView(QString(), true, view_id); createView(true, view_id);
} }
void GuiApplication::createView(QString const & geometry_arg, bool autoShow, void GuiApplication::createView(bool autoShow, int view_id)
int view_id)
{ {
// release the keyboard which might have been grabbed by the global // release the keyboard which might have been grabbed by the global
// menubar on Mac to catch shortcuts even without any GuiView. // menubar on Mac to catch shortcuts even without any GuiView.
@ -2603,44 +2602,6 @@ void GuiApplication::createView(QString const & geometry_arg, bool autoShow,
view->activateWindow(); view->activateWindow();
} }
if (!geometry_arg.isEmpty()) {
#if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
int x, y;
int w, h;
QChar sx, sy;
QRegularExpression re( "[=]*(?:([0-9]+)[xX]([0-9]+)){0,1}[ ]*(?:([+-][0-9]*)){0,1}(?:([+-][0-9]*)){0,1}" );
QRegularExpressionMatch match = re.match(geometry_arg);
w = match.captured(1).toInt();
h = match.captured(2).toInt();
x = match.captured(3).toInt();
y = match.captured(4).toInt();
sx = match.captured(3).isEmpty() ? '+' : match.captured(3).at(0);
sy = match.captured(4).isEmpty() ? '+' : match.captured(4).at(0);
// Set initial geometry such that we can get the frame size.
view->setGeometry(x, y, w, h);
int framewidth = view->geometry().x() - view->x();
int titleheight = view->geometry().y() - view->y();
// Negative displacements must be interpreted as distances
// from the right or bottom screen borders.
if (sx == '-' || sy == '-') {
QRect rec = QGuiApplication::primaryScreen()->geometry();
if (sx == '-')
x += rec.width() - w - framewidth;
if (sy == '-')
y += rec.height() - h - titleheight;
view->setGeometry(x, y, w, h);
}
// Make sure that the left and top frame borders are visible.
if (view->x() < 0 || view->y() < 0) {
if (view->x() < 0)
x = framewidth;
if (view->y() < 0)
y = titleheight;
view->setGeometry(x, y, w, h);
}
#endif
}
view->setFocus(); view->setFocus();
} }
@ -2900,7 +2861,7 @@ void GuiApplication::restoreGuiSession()
if (!current_view_ || (!lyxrc.open_buffers_in_tabs if (!current_view_ || (!lyxrc.open_buffers_in_tabs
&& current_view_->documentBufferView() != nullptr)) { && current_view_->documentBufferView() != nullptr)) {
string const & fname = file_name.absFileName(); string const & fname = file_name.absFileName();
createView(support::checksum(fname)); createAndShowView(support::checksum(fname));
} }
current_view_->loadDocument(file_name, false); current_view_->loadDocument(file_name, false);
@ -3469,7 +3430,7 @@ void GuiApplication::onApplicationStateChanged(Qt::ApplicationState state)
/// cmd+tab only one QEvent::ApplicationStateChangeEvent event /// cmd+tab only one QEvent::ApplicationStateChangeEvent event
if (d->views_.empty() && d->last_state_ == state) { if (d->views_.empty() && d->last_state_ == state) {
LYXERR(Debug::GUI, "Open new window..."); LYXERR(Debug::GUI, "Open new window...");
createView(); createAndShowView();
} }
break; break;
} }

View File

@ -132,13 +132,12 @@ public:
#endif #endif
//@} //@}
/// Create the main window with given geometry settings. /// Create the main window
/// \param geometry_arg: only for Windows platform. /// \param autoShow: show the created window
/// \param optional id identifier. /// \param id: optional identifier.
void createView(QString const & geometry_arg = QString(), void createView(bool autoShow = false, int id = 0);
bool autoShow = true, int id = 0); /// Same as createView, but with \c autoShow = true
/// FIXME: this method and the one above are quite ugly. void createAndShowView(int id = 0);
void createView(int id);
/// ///
GuiView const * currentView() const { return current_view_; } GuiView const * currentView() const { return current_view_; }
/// ///