Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions core/windowgeometry.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,13 @@ func (ws *windowGeometrySaver) settingEnd() {

// record records current state of window as preference
func (ws *windowGeometrySaver) record(win *renderWindow) {
if !ws.shouldSave() || !win.isVisible() || win.SystemWindow.Is(system.Fullscreen) {
if !ws.shouldSave() ||
!win.isVisible() ||
win.SystemWindow.Is(system.Fullscreen) ||
win.SystemWindow.Is(system.Minimized) {
return
}

win.SystemWindow.Lock()
wsz := win.SystemWindow.Size()
win.SystemWindow.Unlock()
Expand All @@ -257,12 +261,6 @@ func (ws *windowGeometrySaver) record(win *renderWindow) {
}
sc := win.SystemWindow.Screen()
pos := win.SystemWindow.Position(sc)
if TheApp.Platform() == system.Windows && pos.X == -32000 || pos.Y == -32000 { // windows badness
if DebugSettings.WindowGeometryTrace {
log.Printf("WindowGeometry: Record: NOT storing very negative pos: %v for win: %v\n", pos, win.name)
}
return
}
ws.mu.Lock()
if ws.settingNoSave {
if DebugSettings.WindowGeometryTrace {
Expand Down
9 changes: 5 additions & 4 deletions system/driver/desktop/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,13 @@ func (w *Window) SetGeometry(fullscreen bool, pos, size image.Point, screen *sys
}

func (w *Window) ConstrainFrame(topOnly bool) styles.Sides[int] {
if w.IsClosed() || w.Is(system.Fullscreen) || w.Is(system.Maximized) {
return w.FrameSize
}
if TheApp.Platform() == system.Windows && w.Pos.X == -32000 || w.Pos.Y == -32000 {
if w.IsClosed() ||
w.Is(system.Fullscreen) ||
w.Is(system.Maximized) ||
w.Is(system.Minimized) {
return w.FrameSize
}

l, t, r, b := w.Glw.GetFrameSize()
w.FrameSize.Set(t, r, b, l)
sc := w.Screen()
Expand Down
6 changes: 2 additions & 4 deletions system/screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,10 @@ func (sc *Screen) WindowSizeFromPixels(sz image.Point) image.Point {
func (sc *Screen) ConstrainWindowGeometry(pos, sz image.Point) (cpos, csz image.Point) {
scSize := sc.Geometry.Size() // in window coords size
if TheApp.Platform() == Windows {
// these are windows-specific special numbers for minimized windows
// can be sent here for WinGeom saved geom.
if pos.X == -32000 {
if pos.X == WindowsMinimizedPosition {
pos.X = 0
}
if pos.Y == -32000 {
if pos.Y == WindowsMinimizedPosition {
pos.Y = 50
}
}
Expand Down
1 change: 1 addition & 0 deletions system/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,3 +373,4 @@ func (o *NewWindowOptions) Fixup() {
o.Pos, o.Size = sc.ConstrainWindowGeometry(o.Pos, o.Size) // make sure ok
}
}

9 changes: 9 additions & 0 deletions system/window_position.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) 2018, Cogent Core. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package system

// this is windows-specific special number for minimized windows.
// ad-hoc way to figure out whether a window is minimized or not.
const WindowsMinimizedPosition = -32000