FL_resource res[] =
{
- {"geometry", "geometryClass", FL_STRING, geometry, "690x510", 40}
+ {"geometry", "geometryClass", FL_STRING, geometry, "", 40}
};
fl_initialize(argc, argv, "LyX", cmdopt, num_res);
fl_get_app_resources(res, num_res);
- XParseGeometry(geometry, &xpos, &ypos, (unsigned int *) &width, (unsigned int *) &height);
+ static const int geometryBitmask = XParseGeometry( geometry,
+ &xpos,
+ &ypos,
+ (unsigned int *) &width,
+ (unsigned int *) &height
+ );
Display * display = fl_get_display();
if (!display) {
fcntl(ConnectionNumber(display), F_SETFD, FD_CLOEXEC);
// X Error handler install goes here
XSetErrorHandler(LyX_XErrHandler);
-
- // Make sure default screen is not larger than monitor
- if (width == 690 && height == 510) {
+
+ // A width less than 590 pops up an awkward main window
+ if (width < 590) width = 590;
+
+ // If width is not set by geometry, check it against monitor width
+ if ( !(geometryBitmask & 4) ) {
Screen * scr = DefaultScreenOfDisplay(fl_get_display());
- if (HeightOfScreen(scr) - 24 < height)
- height = HeightOfScreen(scr) - 24;
if (WidthOfScreen(scr) - 8 < width)
width = WidthOfScreen(scr) - 8;
}
+ // If height is not set by geometry, check it against monitor height
+ if ( !(geometryBitmask & 8) ) {
+ Screen * scr = DefaultScreenOfDisplay(fl_get_display());
+ if (HeightOfScreen(scr) - 24 < height)
+ height = HeightOfScreen(scr) - 24;
+ }
+
+ // Recalculate xpos if it's negative
+ if (geometryBitmask & 16)
+ xpos += WidthOfScreen(DefaultScreenOfDisplay(fl_get_display())) - width;
+
+ // Recalculate ypos if it's negative
+ if (geometryBitmask & 32)
+ ypos += HeightOfScreen(DefaultScreenOfDisplay(fl_get_display())) - height;
+
// Initialize the LyXColorHandler
lyxColorHandler = new LyXColorHandler;
}
"\t-help summarize LyX usage\n"
"\t-userdir dir try to set user directory to dir\n"
"\t-sysdir dir try to set system directory to dir\n"
- "\t-geometry WxH+X+Y set the width of the main window\n"
+ "\t-display display use display as DISPLAY\n"
+ "\t-geometry WxH+X+Y set geometry of the main window\n"
"\t-dbg feature[,feature]...\n"
" select the features to debug.\n"
" Type `lyx -dbg' to see the list of features\n"