}
-void lyx_gui::start(string const & batch, std::vector<string> const & files)
+void lyx_gui::start(string const & batch, std::vector<string> const & files,
+ int width, int height, int posx, int posy)
{
boost::shared_ptr<GView> view_ptr(new GView);
LyX::ref().addLyXView(view_ptr);
* Start the main event loop, after executing the given
* batch commands, and loading the given documents
*/
-void start(std::string const & batch, std::vector<std::string> const & files);
+void start(std::string const & batch, std::vector<std::string> const & files,
+ int width, int height, int posx, int posy);
/**
* Synchronise all pending events.
#include "lyxrc.h"
#include "lyxserver.h"
#include "lyxsocket.h"
-#include "session.h"
#include "graphics/LoaderQueue.h"
#include "support/lstrings.h"
-#include "support/convert.h"
#include "support/os.h"
#include "support/package.h"
#include "debug.h"
{}
-void start(string const & batch, vector<string> const & files)
+void start(string const & batch, vector<string> const & files,
+ int width, int height, int posx, int posy)
{
// this can't be done before because it needs the Languages object
initEncodings();
- // initial geometry
- unsigned int width = 690;
- unsigned int height = 510;
- // first try lyxrc
- if (lyxrc.geometry_width != 0 && lyxrc.geometry_height != 0 ) {
- width = lyxrc.geometry_width;
- height = lyxrc.geometry_height;
- }
- // if lyxrc returns (0,0), then use session info
- else {
- string val = LyX::ref().session().loadSessionInfo("WindowWidth");
- if (val != "")
- width = convert<unsigned int>(val);
- val = LyX::ref().session().loadSessionInfo("WindowHeight");
- if (val != "")
- height = convert<unsigned int>(val);
- }
-
boost::shared_ptr<QtView> view_ptr(new QtView(width, height));
LyX::ref().addLyXView(view_ptr);
QtView & view = *view_ptr.get();
- // if user wants to restore window position
- if (lyxrc.geometry_xysaved) {
- QPoint p = view.pos();
- string val = LyX::ref().session().loadSessionInfo("WindowPosX");
- if (val != "")
- p.setX(convert<unsigned int>(val));
- val = LyX::ref().session().loadSessionInfo("WindowPosY");
- if (val != "")
- p.setY(convert<unsigned int>(val));
- view.move(p);
- }
+ if (posx != -1 && posy != -1)
+ view.move(QPoint(posx, posy));
+
view.show();
view.init();
#include "lyxrc.h"
#include "lyxserver.h"
#include "lyxsocket.h"
-#include "session.h"
#include "graphics/LoaderQueue.h"
#include "support/lstrings.h"
-#include "support/convert.h"
#include "support/os.h"
#include "support/package.h"
#include "debug.h"
{}
-void start(string const & batch, vector<string> const & files)
+void start(string const & batch, vector<string> const & files,
+ int width, int height, int posx, int posy)
{
// this can't be done before because it needs the Languages object
initEncodings();
- // initial geometry
- unsigned int width = 690;
- unsigned int height = 510;
- // first try lyxrc
- if (lyxrc.geometry_width != 0 && lyxrc.geometry_height != 0 ) {
- width = lyxrc.geometry_width;
- height = lyxrc.geometry_height;
- }
- // if lyxrc returns (0,0), then use session info
- else {
- string val = LyX::ref().session().loadSessionInfo("WindowWidth");
- if (val != "")
- width = convert<unsigned int>(val);
- val = LyX::ref().session().loadSessionInfo("WindowHeight");
- if (val != "")
- height = convert<unsigned int>(val);
- }
-
boost::shared_ptr<QtView> view_ptr(new QtView(width, height));
LyX::ref().addLyXView(view_ptr);
QtView & view = *view_ptr.get();
- // if user wants to restore window position
- if (lyxrc.geometry_xysaved) {
- QPoint p = view.pos();
- string val = LyX::ref().session().loadSessionInfo("WindowPosX");
- if (val != "")
- p.setX(convert<unsigned int>(val));
- val = LyX::ref().session().loadSessionInfo("WindowPosY");
- if (val != "")
- p.setY(convert<unsigned int>(val));
- view.move(p);
- }
+ if (posx != -1 && posy != -1)
+ view.move(QPoint(posx, posy));
+
view.show();
view.init();
#include "LyXAction.h"
#include "lyxfunc.h"
#include "lyxrc.h"
-#include "session.h"
#include "lyxserver.h"
#include "lyxsocket.h"
#include "support/lyxlib.h"
#include "support/os.h"
#include "support/package.h"
-#include "support/convert.h"
#include "lyx_forms.h"
}
-void start(string const & batch, vector<string> const & files)
+void start(string const & batch, vector<string> const & files,
+ int width, int height, int posx, int posy)
{
- // initial geometry
- int xpos = -1;
- int ypos = -1;
- unsigned int width = 690;
- unsigned int height = 510;
- // first try lyxrc
- if (lyxrc.geometry_width != 0 && lyxrc.geometry_height != 0 ) {
- width = lyxrc.geometry_width;
- height = lyxrc.geometry_height;
- }
- // if lyxrc returns (0,0), then use session info
- else {
- string val = LyX::ref().session().loadSessionInfo("WindowWidth");
- if (val != "")
- width = convert<unsigned int>(val);
- val = LyX::ref().session().loadSessionInfo("WindowHeight");
- if (val != "")
- height = convert<unsigned int>(val);
- }
-
int const geometryBitmask =
XParseGeometry(geometry,
&xpos, &ypos, &width, &height);
Screen * s = ScreenOfDisplay(fl_get_display(), fl_screen);
- // recalculate xpos if it's not set
- if (xpos == -1)
- xpos = (WidthOfScreen(s) - width) / 2;
-
- // recalculate ypos if it's not set
- if (ypos == -1)
- ypos = (HeightOfScreen(s) - height) / 2;
-
lyxerr[Debug::GUI] << "Creating view: " << width << 'x' << height
- << '+' << xpos << '+' << ypos << endl;
+ << '+' << posx << '+' << posy << endl;
boost::shared_ptr<XFormsView> view(new XFormsView(width, height));
LyX::ref().addLyXView(view);
- view->show(xpos, ypos, "LyX");
+ view->show(posx == -1 ? (WidthOfScreen(s) - width) / 2 : posx,
+ posy == -1 ? (HeightOfScreen(s) - height) / 2 : posy, "LyX");
view->init();
// FIXME: some code below needs moving
#include "support/environment.h"
#include "support/filetools.h"
#include "support/lyxlib.h"
+#include "support/convert.h"
#include "support/os.h"
#include "support/package.h"
#include "support/path.h"
files.clear(); // the files are already loaded
}
- if (want_gui)
- lyx_gui::start(batch_command, files);
- else {
+ if (want_gui) {
+ // determine windows size and position, from lyxrc and/or session
+ // initial geometry
+ unsigned int width = 690;
+ unsigned int height = 510;
+ // first try lyxrc
+ if (lyxrc.geometry_width != 0 && lyxrc.geometry_height != 0 ) {
+ width = lyxrc.geometry_width;
+ height = lyxrc.geometry_height;
+ }
+ // if lyxrc returns (0,0), then use session info
+ else {
+ string val = LyX::ref().session().loadSessionInfo("WindowWidth");
+ if (!val.empty())
+ width = convert<unsigned int>(val);
+ val = LyX::ref().session().loadSessionInfo("WindowHeight");
+ if (!val.empty())
+ height = convert<unsigned int>(val);
+ }
+ // if user wants to restore window position
+ int posx = -1;
+ int posy = -1;
+ if (lyxrc.geometry_xysaved) {
+ string val = LyX::ref().session().loadSessionInfo("WindowPosX");
+ if (!val.empty())
+ posx = convert<int>(val);
+ val = LyX::ref().session().loadSessionInfo("WindowPosY");
+ if (!val.empty())
+ posy = convert<int>(val);
+ }
+ lyx_gui::start(batch_command, files, width, height, posx, posy);
+ } else {
// Something went wrong above
quitLyX(false);
exit(EXIT_FAILURE);