Skip to content
Draft
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
4 changes: 4 additions & 0 deletions inputLoop.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ var (
// InputChange is triggered when the most recent input device changes (e.g. keyboard to joystick or vice versa). It
// is only sent if Config.TrackInputChanges is true when Init is called.
InputChange = event.RegisterEvent[InputType]()
// WindowSizeChange is triggered when a desktop window is resized automatically or via user request.
// A call to ChangeWindow does not trigger this.
WindowSizeChange = event.RegisterEvent[intgeom.Point2]()
)

func (w *Window) inputLoop() {
Expand Down Expand Up @@ -106,6 +109,7 @@ func (w *Window) inputLoop() {

// Size events update what we scale the screen to
case size.Event:
event.TriggerOn(w.eventHandler, WindowSizeChange, intgeom.Point2{e.WidthPx, e.HeightPx})
err := w.ChangeWindow(e.WidthPx, e.HeightPx)
dlog.ErrorCheck(err)
}
Expand Down
13 changes: 13 additions & 0 deletions shiny/driver/internal/win32/helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package win32

func Minimize(hwnd HWND) bool {
return ShowWindow(hwnd, _SW_MINIMIZE)
}

func Maximize(hwnd HWND) bool {
return ShowWindow(hwnd, _SW_SHOWMAXIMIZED)
}

func Normalize(hwnd HWND) bool {
return ShowWindow(hwnd, _SW_SHOWNORMAL)
}
6 changes: 5 additions & 1 deletion shiny/driver/internal/win32/syscall_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ const (
const (
_CW_USEDEFAULT = 0x80000000 - 0x100000000

_SW_SHOWDEFAULT = 10
_SW_SHOWNORMAL = 1
_SW_SHOWMINIMIZED = 2
_SW_SHOWMAXIMIZED = 3
_SW_MINIMIZE = 6
_SW_SHOWDEFAULT = 10

_SWP_NOSIZE = 0x0001
)
Expand Down
26 changes: 26 additions & 0 deletions shiny/driver/windriver/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,3 +501,29 @@ func (w *Window) SetTopMost(topMost bool) error {
w.topMost = topMost
return nil
}

func (w *Window) GetDesktopPosition() (x, y float64) {
w.windowRect, _ = win32.GetWindowRect(w.hwnd)
return float64(w.windowRect.Left), float64(w.windowRect.Top)
}

func (w *Window) Minimize() error {
if !win32.Minimize(w.hwnd) {
return fmt.Errorf("minimize failed")
}
return nil
}

func (w *Window) Maximize() error {
if !win32.Maximize(w.hwnd) {
return fmt.Errorf("maximize failed")
}
return nil
}

func (w *Window) Normalize() error {
if !win32.Normalize(w.hwnd) {
return fmt.Errorf("normalize failed")
}
return nil
}
1 change: 0 additions & 1 deletion window/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ type Window interface {
// component.
SetIcon(image.Image) error
// MoveWindow moves a window to the given x,y coordinates with the given dimensions.
// TODO v4: intgeom.Rect2?
MoveWindow(x, y, w, h int) error
// HideCursor will cause the mouse cursor to not display when it lies within this window.
HideCursor() error
Expand Down