Is this a step in the right direction?
Currently 'normalizing' the restored vertical-maximized
window isn't perfect, but I think I've-at least-
not broken the old behavior.
I've tested it with KDE so I don't know what
happens on Gnome, or does it not depend at
this level on the installed system?
Peter
Index: src/frontends/Application.h
===================================================================
--- src/frontends/Application.h (revision 17231)
+++ src/frontends/Application.h (working copy)
@@ -4,6 +4,7 @@
* Licence details can be found in the file COPYING.
*
* \author Abdelrazak Younes
+ * \author Peter Kümmel
*
* Full author contact details are available in file CREDITS.
*/
@@ -172,8 +173,8 @@
/// Create the main window with given geometry settings.
LyXView & createView(unsigned int width, unsigned int height,
- int posx, int posy, bool maximize, unsigned int iconSizeXY,
- const std::string & geometryArg);
+ int posx, int posy, bool maximize, bool verticalMax,
+ unsigned int iconSizeXY, const std::string & geometryArg);
///
LyXView const * currentView() const;
Index: src/frontends/LyXView.h
===================================================================
--- src/frontends/LyXView.h (revision 17231)
+++ src/frontends/LyXView.h (working copy)
@@ -6,6 +6,7 @@
*
* \author Lars Gullik Bjønnes
* \author John Levon
+ * \author Peter Kümmel
*
* Full author contact details are available in file CREDITS.
*/
@@ -96,6 +97,7 @@
unsigned int height,
int posx, int posy,
bool maximize,
+ bool verticalMax,
unsigned int iconSizeXY,
const std::string & geometryArg) = 0;
Index: src/frontends/qt4/GuiView.h
===================================================================
--- src/frontends/qt4/GuiView.h (revision 17231)
+++ src/frontends/qt4/GuiView.h (working copy)
@@ -4,7 +4,7 @@
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
- * \author Lars Gullik Bjornes
+ * \author Lars Gullik Bjørnes
* \author John Levon
* \author Abdelrazak Younes
* \author Peter Kümmel
@@ -62,6 +62,7 @@
unsigned int height,
int posx, int posy,
bool maximize,
+ bool verticalMax,
unsigned int iconSizeXY,
const std::string & geometryArg);
virtual void saveGeometry();
@@ -139,7 +140,7 @@
bool quitting_by_menu_;
///
- void updateFloatingGeometry();
+ QRect updateFloatingGeometry();
///
QRect floatingGeometry_;
Index: src/frontends/qt4/GuiView.C
===================================================================
--- src/frontends/qt4/GuiView.C (revision 17231)
+++ src/frontends/qt4/GuiView.C (working copy)
@@ -290,18 +290,39 @@
// Then also the moveEvent, resizeEvent, and the
// code for floatingGeometry_ can be removed;
// adjust GuiView::setGeometry()
+
+ QRect geometry;
+ bool maximized = false;
+ bool verticalMax = false;
#ifdef Q_WS_WIN
- QRect geometry = normalGeometry();
+ geometry = normalGeometry();
+ maximized = isMaximized();
+ verticalMax = false;
#else
- updateFloatingGeometry();
- QRect geometry = floatingGeometry_;
+ geometry = updateFloatingGeometry();
+
+ // code for vertical only maximized window
+ QDesktopWidget& dw = *qApp->desktop();
+ QRect desk = dw.availableGeometry(dw.primaryScreen());
+ if (isMaximized()) {
+ if (desk.width() == width()) {
+ maximized = true;
+ printf(" max !!!\n");
+ verticalMax = false;
+ } else {
+ maximized = false;
+ verticalMax = true;
+ geometry = QRect(pos().x(), pos().y(), width(),
height());
+ }
+ }
+
#endif
-
// save windows size and position
Session & session = LyX::ref().session();
session.sessionInfo().save("WindowWidth",
convert<string>(geometry.width()));
session.sessionInfo().save("WindowHeight",
convert<string>(geometry.height()));
- session.sessionInfo().save("WindowIsMaximized", (isMaximized() ? "yes"
: "no"));
+ session.sessionInfo().save("WindowIsMaximized", (maximized ? "yes" :
"no"));
+ session.sessionInfo().save("WindowIsVerticalMax", (verticalMax ? "yes"
: "no"));
session.sessionInfo().save("IconSizeXY",
convert<string>(iconSize().width()));
if (lyxrc.geometry_xysaved) {
session.sessionInfo().save("WindowPosX",
convert<string>(geometry.x() + d.posx_offset));
@@ -315,6 +336,7 @@
unsigned int height,
int posx, int posy,
bool maximize,
+ bool verticalMax,
unsigned int iconSizeXY,
const string & geometryArg)
{
@@ -347,8 +369,21 @@
resize(width, height);
}
- if (maximize)
+
+ if (maximize) {
+ floatingGeometry_ = QRect(posx, posy, width, height);
setWindowState(Qt::WindowMaximized);
+ }
+#ifndef Q_WS_WIN
+ else if (verticalMax) {
+ // code for vertical only maximized window
+ QDesktopWidget& dw = *qApp->desktop();
+ QRect desk = dw.availableGeometry(dw.primaryScreen());
+ resize(width, desk.height());
+ // remember original size
+ floatingGeometry_ = QRect(posx, posy, width, height);
+ }
+#endif
}
else
{
@@ -549,10 +584,11 @@
}
-void GuiView::updateFloatingGeometry()
+QRect GuiView::updateFloatingGeometry()
{
if (!isMaximized())
floatingGeometry_ = QRect(x(), y(), width(), height());
+ return floatingGeometry_;
}
Index: src/frontends/Application.C
===================================================================
--- src/frontends/Application.C (revision 17231)
+++ src/frontends/Application.C (working copy)
@@ -4,6 +4,7 @@
* Licence details can be found in the file COPYING.
*
* \author Abdelrazak Younes
+ * \author Peter Kümmel
*
* Full author contact details are available in file CREDITS.
*/
@@ -53,6 +54,7 @@
unsigned int height,
int posx, int posy,
bool maximize,
+ bool verticalMax,
unsigned int iconSizeXY,
const std::string & geometryArg)
{
@@ -64,7 +66,7 @@
/*int workArea_id_ =*/ gui().newWorkArea(width, height, view_id);
view.init();
- view.setGeometry(width, height, posx, posy, maximize, iconSizeXY,
geometryArg);
+ view.setGeometry(width, height, posx, posy, maximize, verticalMax,
iconSizeXY, geometryArg);
view.setFocus();
setCurrentView(view);
Index: src/lyx_main.C
===================================================================
--- src/lyx_main.C (revision 17231)
+++ src/lyx_main.C (working copy)
@@ -8,6 +8,7 @@
* \author Jean-Marc Lasgouttes
* \author John Levon
* \author André Pönitz
+ * \author Peter Kümmel
*
* Full author contact details are available in file CREDITS.
*/
@@ -646,6 +647,7 @@
// default icon size, will be overwritten by stored session value
unsigned int iconSizeXY = 0;
bool maximize = false;
+ bool verticalMax = false;
// first try lyxrc
if (lyxrc.geometry_width != 0 && lyxrc.geometry_height != 0 ) {
width = lyxrc.geometry_width;
@@ -661,6 +663,8 @@
height = convert<unsigned int>(val);
if (session().sessionInfo().load("WindowIsMaximized") == "yes")
maximize = true;
+ if (session().sessionInfo().load("WindowIsVerticalMax") ==
"yes")
+ verticalMax = true;
val = session().sessionInfo().load("IconSizeXY");
if (!val.empty())
iconSizeXY = convert<unsigned int>(val);
@@ -685,7 +689,8 @@
}
// create the main window
- LyXView * view = &pimpl_->application_->createView(width, height, posx,
posy, maximize, iconSizeXY, geometryArg);
+ LyXView * view = &pimpl_->application_->createView(width, height, posx,
posy,
+ maximize, verticalMax, iconSizeXY,
geometryArg);
return view;
}