OoMrFlibble / oolite-debug-console-flibble-mad-alpha

0 stars 1 forks source link

Main window geometry saved but not loaded. #7

Closed OoMrFlibble closed 2 weeks ago

OoMrFlibble commented 3 weeks ago

The geometry for the main window is saved in the config file, but not applied on application start.

The relevant config option is in the [Settings] section, beneath "internal, alter at your own risk" Geometry = 600x400+0+0

OoMrFlibble commented 3 weeks ago

in def setupApp(self):

    # check if geometry is valid, adjust as needed
    geom = gv.CurrentOptions['Settings'].get('Geometry', con.DEFAULT_GEOMETRY)
    print ("Geometry: " + str(geom))
    width, height, xOffset, yOffset = au.fitToMonitors(geom)
    gv.root.geometry(f'{width}x{height}+{xOffset}+{yOffset}')
    print ('New Geom: ' + str(f'{width}x{height}+{xOffset}+{yOffset}') )

The first print has the value from config file, the second is default from constants. au is the name appUtils.py is imported with.

Looking at appUtils.py : fitToMonitors Adding prints to see behaviour.

def fitToMonitors(geom):
    # adjust geometry values to fit monitor resolution
    width, height, xOffset, yOffset = mu.parseGeometry(geom)
    print ('In fitToMonitors Geom 1 : ' + str(f'{width}x{height}+{xOffset}+{yOffset}') )
        print ("gv.monitorsWidth: " + str(gv.monitorsWidth) + "   gv.monitorsHeight : " + str(gv.monitorsHeight) )
    if width > gv.monitorsWidth:
        width, xOffset = gv.monitorsWidth, 0
    elif xOffset + width > gv.monitorsWidth:
        xOffset = max(0, gv.monitorsWidth - width)
    if height > gv.monitorsHeight:
        height, yOffset = gv.monitorsHeight, 0
    elif yOffset + height > gv.monitorsHeight:
        yOffset = max(0, gv.monitorsHeight - height)
    print ('In fitToMonitors Geom 2 : ' + str(f'{width}x{height}+{xOffset}+{yOffset}') )
    return width, height, xOffset, yOffset

Extracts of the config file: Geometry = 913x592+0+0 AliasWindow = 1012x549+763+187 FinderWindow = 1517x899+23+208

The prints I've installed above churn out this:-

In fitToMonitors Geom 1 : 913x592+0+0
gv.monitorsWidth: 600   gv.monitorsHeight : 400
In fitToMonitors Geom 2 : 600x400+0+0
New Geom: 600x400+0+0
In fitToMonitors Geom 1 : 1012x549+763+187
gv.monitorsWidth: 600   gv.monitorsHeight : 400
In fitToMonitors Geom 2 : 600x400+0+0
In fitToMonitors Geom 1 : 1517x899+23+208
gv.monitorsWidth: 600   gv.monitorsHeight : 400
In fitToMonitors Geom 2 : 600x400+0+0```

So fitToMonitors is making EVERYTHING defaults.

This seems to be how it's grabbed. Not much help on linux x86_64
```gv.monitorsWidth = user32.GetSystemMetrics(78)```

Right: I think the screen size gubbins is too complex and failing. I'm hacking this in to the DebugConsole.py
def __init__(self):
    top = gv.root = tk.Tk(className='Oodebug')

Which, if it works on the other platforms, gets rid of a big chunk in appUtils.py, by removing the whole monitorResolutions function. Does this remove the dependency on msvcr90.dll ? 

Need to verify that this works.
OoMrFlibble commented 3 weeks ago

Have uploaded this change for testing.

OoMrFlibble commented 2 weeks ago

Fixed a while back. Forgot to close.