mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-30 05:12:40 +00:00
fix bug: vert. maximized window is completely maximized after restart
src/frontends/Application.h : enum for maximized src/frontends/LyXView.h : enum for maximized src/frontends/qt4/GuiView.h : enum for maximized src/frontends/Application.C : enum for maximized src/lyx_main.C : enum for maximized src/frontends/qt4/GuiView.C : restore complete, vert. hor. maximized window git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17463 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
b1b76d22f1
commit
38cdcd70c1
@ -47,7 +47,7 @@ Application::Application(int &, char **)
|
||||
LyXView & Application::createView(unsigned int width,
|
||||
unsigned int height,
|
||||
int posx, int posy,
|
||||
bool maximize,
|
||||
int maximized,
|
||||
unsigned int iconSizeXY,
|
||||
const std::string & geometryArg)
|
||||
{
|
||||
@ -59,7 +59,7 @@ LyXView & Application::createView(unsigned int width,
|
||||
/*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, maximized, iconSizeXY, geometryArg);
|
||||
view.setFocus();
|
||||
|
||||
setCurrentView(view);
|
||||
|
@ -172,8 +172,8 @@ public:
|
||||
|
||||
/// 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, int maximized,
|
||||
unsigned int iconSizeXY, const std::string & geometryArg);
|
||||
|
||||
///
|
||||
LyXView const * currentView() const;
|
||||
|
@ -90,12 +90,19 @@ public:
|
||||
*/
|
||||
virtual void init() = 0;
|
||||
|
||||
enum Maximized {
|
||||
NotMaximized,
|
||||
VerticallyMaximized,
|
||||
HorizontallyMaximized,
|
||||
CompletelyMaximized
|
||||
};
|
||||
|
||||
///
|
||||
virtual void setGeometry(
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
int posx, int posy,
|
||||
bool maximize,
|
||||
int maximize,
|
||||
unsigned int iconSizeXY,
|
||||
const std::string & geometryArg) = 0;
|
||||
|
||||
|
@ -290,22 +290,51 @@ void GuiView::saveGeometry()
|
||||
// Then also the moveEvent, resizeEvent, and the
|
||||
// code for floatingGeometry_ can be removed;
|
||||
// adjust GuiView::setGeometry()
|
||||
|
||||
QRect normal_geometry;
|
||||
int maximized;
|
||||
#ifdef Q_WS_WIN
|
||||
QRect geometry = normalGeometry();
|
||||
normal_geometry = normalGeometry();
|
||||
if (isMaximized()) {
|
||||
maximized = CompletelyMaximized;
|
||||
} else {
|
||||
maximized = NotMaximized;
|
||||
}
|
||||
#else
|
||||
updateFloatingGeometry();
|
||||
QRect geometry = floatingGeometry_;
|
||||
#endif
|
||||
normal_geometry = updateFloatingGeometry();
|
||||
|
||||
QDesktopWidget& dw = *qApp->desktop();
|
||||
QRect desk = dw.availableGeometry(dw.primaryScreen());
|
||||
// Qt bug on Linux: load completely maximized, vert max. save-> frameGeometry().height() is wrong
|
||||
if (isMaximized() && desk.width() <= frameGeometry().width() && desk.height() <= frameGeometry().height()) {
|
||||
maximized = CompletelyMaximized;
|
||||
// maximizing does not work when the window is allready hor. or vert. maximized
|
||||
// Tested only on KDE
|
||||
int dh = frameGeometry().height() - height();
|
||||
if (desk.height() <= normal_geometry.height() + dh)
|
||||
normal_geometry.setHeight(normal_geometry.height() - 1);
|
||||
int dw = frameGeometry().width() - width();
|
||||
if (desk.width() <= normal_geometry.width() + dw)
|
||||
normal_geometry.setWidth(normal_geometry.width() - 1);
|
||||
} else if (desk.height() <= frameGeometry().height()) {
|
||||
maximized = VerticallyMaximized;
|
||||
} else if (desk.width() <= frameGeometry().width()) {
|
||||
maximized = HorizontallyMaximized;
|
||||
} else {
|
||||
maximized = NotMaximized;
|
||||
}
|
||||
|
||||
|
||||
#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("WindowWidth", convert<string>(normal_geometry.width()));
|
||||
session.sessionInfo().save("WindowHeight", convert<string>(normal_geometry.height()));
|
||||
session.sessionInfo().save("WindowMaximized", convert<string>(maximized));
|
||||
session.sessionInfo().save("IconSizeXY", convert<string>(iconSize().width()));
|
||||
if (lyxrc.geometry_xysaved) {
|
||||
session.sessionInfo().save("WindowPosX", convert<string>(geometry.x() + d.posx_offset));
|
||||
session.sessionInfo().save("WindowPosY", convert<string>(geometry.y() + d.posy_offset));
|
||||
session.sessionInfo().save("WindowPosX", convert<string>(normal_geometry.x() + d.posx_offset));
|
||||
session.sessionInfo().save("WindowPosY", convert<string>(normal_geometry.y() + d.posy_offset));
|
||||
}
|
||||
getToolbars().saveToolbarInfo();
|
||||
}
|
||||
@ -314,7 +343,7 @@ void GuiView::saveGeometry()
|
||||
void GuiView::setGeometry(unsigned int width,
|
||||
unsigned int height,
|
||||
int posx, int posy,
|
||||
bool maximize,
|
||||
int maximized,
|
||||
unsigned int iconSizeXY,
|
||||
const string & geometryArg)
|
||||
{
|
||||
@ -347,8 +376,26 @@ void GuiView::setGeometry(unsigned int width,
|
||||
resize(width, height);
|
||||
}
|
||||
|
||||
if (maximize)
|
||||
setWindowState(Qt::WindowMaximized);
|
||||
// remember original size
|
||||
floatingGeometry_ = QRect(posx, posy, width, height);
|
||||
|
||||
if (maximized != NotMaximized) {
|
||||
if (maximized == CompletelyMaximized) {
|
||||
setWindowState(Qt::WindowMaximized);
|
||||
} else {
|
||||
#ifndef Q_WS_WIN
|
||||
// TODO How to set by the window manager?
|
||||
// setWindowState(Qt::WindowVerticallyMaximized);
|
||||
// is not possible
|
||||
QDesktopWidget& dw = *qApp->desktop();
|
||||
QRect desk = dw.availableGeometry(dw.primaryScreen());
|
||||
if (maximized == VerticallyMaximized)
|
||||
resize(width, desk.height());
|
||||
if (maximized == HorizontallyMaximized)
|
||||
resize(desk.width(), height);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -386,7 +433,7 @@ void GuiView::setGeometry(unsigned int width,
|
||||
d.posy_offset = posy - normalGeometry().y();
|
||||
#else
|
||||
#ifndef Q_WS_MACX
|
||||
if (!maximize) {
|
||||
if (maximized == NotMaximized) {
|
||||
d.posx_offset = posx - geometry().x();
|
||||
d.posy_offset = posy - geometry().y();
|
||||
}
|
||||
@ -550,10 +597,15 @@ bool GuiView::hasFocus() const
|
||||
}
|
||||
|
||||
|
||||
void GuiView::updateFloatingGeometry()
|
||||
QRect GuiView::updateFloatingGeometry()
|
||||
{
|
||||
if (!isMaximized())
|
||||
QDesktopWidget& dw = *qApp->desktop();
|
||||
QRect desk = dw.availableGeometry(dw.primaryScreen());
|
||||
// remember only non-maximized sizes
|
||||
if (!isMaximized() && desk.width() > frameGeometry().width() && desk.height() > frameGeometry().height()) {
|
||||
floatingGeometry_ = QRect(x(), y(), width(), height());
|
||||
}
|
||||
return floatingGeometry_;
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,7 +61,7 @@ public:
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
int posx, int posy,
|
||||
bool maximize,
|
||||
int maximized,
|
||||
unsigned int iconSizeXY,
|
||||
const std::string & geometryArg);
|
||||
virtual void saveGeometry();
|
||||
@ -139,7 +139,7 @@ private:
|
||||
bool quitting_by_menu_;
|
||||
|
||||
///
|
||||
void updateFloatingGeometry();
|
||||
QRect updateFloatingGeometry();
|
||||
///
|
||||
QRect floatingGeometry_;
|
||||
|
||||
|
@ -634,7 +634,7 @@ LyXView * LyX::newLyXView()
|
||||
unsigned int height = 510;
|
||||
// default icon size, will be overwritten by stored session value
|
||||
unsigned int iconSizeXY = 0;
|
||||
bool maximize = false;
|
||||
int maximized = LyXView::NotMaximized;
|
||||
// first try lyxrc
|
||||
if (lyxrc.geometry_width != 0 && lyxrc.geometry_height != 0 ) {
|
||||
width = lyxrc.geometry_width;
|
||||
@ -648,8 +648,9 @@ LyXView * LyX::newLyXView()
|
||||
val = session().sessionInfo().load("WindowHeight");
|
||||
if (!val.empty())
|
||||
height = convert<unsigned int>(val);
|
||||
if (session().sessionInfo().load("WindowIsMaximized") == "yes")
|
||||
maximize = true;
|
||||
val = session().sessionInfo().load("WindowMaximized");
|
||||
if (!val.empty())
|
||||
maximized = convert<int>(val);
|
||||
val = session().sessionInfo().load("IconSizeXY");
|
||||
if (!val.empty())
|
||||
iconSizeXY = convert<unsigned int>(val);
|
||||
@ -674,7 +675,7 @@ LyXView * LyX::newLyXView()
|
||||
}
|
||||
|
||||
// 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, maximized, iconSizeXY, geometryArg);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user