From 708ba0ffa9e884c699e9780a1d105e9301d49c14 Mon Sep 17 00:00:00 2001 From: cxxxr Date: Thu, 21 Nov 2024 00:02:03 +0900 Subject: [PATCH] Define maximise-frame/minimise-frame as lem-interface --- frontends/sdl2/frame.lisp | 16 ---------------- frontends/sdl2/lem-sdl2.asd | 1 - frontends/sdl2/main.lisp | 12 ++++++++++++ src/commands/frame.lisp | 8 ++++++++ src/interface.lisp | 4 ++++ src/internal-packages.lisp | 2 ++ 6 files changed, 26 insertions(+), 17 deletions(-) delete mode 100644 frontends/sdl2/frame.lisp diff --git a/frontends/sdl2/frame.lisp b/frontends/sdl2/frame.lisp deleted file mode 100644 index 4a0ccfca3..000000000 --- a/frontends/sdl2/frame.lisp +++ /dev/null @@ -1,16 +0,0 @@ -(defpackage :lem-sdl2/frame - (:use :cl :lem) - (:export :maximize-frame - :minimize-frame)) -(in-package :lem-sdl2/frame) - -(define-command maximize-frame () () - "Maximize the frame." - (sdl2:in-main-thread () - (sdl2:maximize-window (lem-sdl2/display::display-window (lem-sdl2/display:current-display))))) - -(define-command minimize-frame () () - "Minimize the frame." - (sdl2:in-main-thread () - (sdl2:minimize-window (lem-sdl2/display::display-window (lem-sdl2/display:current-display))))) - \ No newline at end of file diff --git a/frontends/sdl2/lem-sdl2.asd b/frontends/sdl2/lem-sdl2.asd index ba0264683..16ddad3e9 100644 --- a/frontends/sdl2/lem-sdl2.asd +++ b/frontends/sdl2/lem-sdl2.asd @@ -20,7 +20,6 @@ (:file "utils") (:file "display") (:file "view") - (:file "frame") (:file "main") (:file "drawing") (:file "graphics") diff --git a/frontends/sdl2/main.lisp b/frontends/sdl2/main.lisp index f6cbce630..819735d49 100644 --- a/frontends/sdl2/main.lisp +++ b/frontends/sdl2/main.lisp @@ -292,6 +292,18 @@ (sdl2:set-window-fullscreen (display:display-window display) (if fullscreen-p :desktop))))))) +(defmethod lem-if:maximize-frame ((implementation sdl2)) + (with-debug ("lem-if:maximize-frame") + (sdl2:in-main-thread () + (display:with-display (display) + (sdl2:maximize-window (lem-sdl2/display::display-window display)))))) + +(defmethod lem-if:minimize-frame ((implementation sdl2)) + (with-debug ("lem-if:minimize-frame") + (sdl2:in-main-thread () + (display:with-display (display) + (sdl2:minimize-window (lem-sdl2/display::display-window display)))))) + (defmethod lem-if:make-view ((implementation sdl2) window x y width height use-modeline) (with-debug ("lem-if:make-view" window x y width height use-modeline) (display:with-display (display) diff --git a/src/commands/frame.lisp b/src/commands/frame.lisp index 5ff9927b7..5d47ac037 100644 --- a/src/commands/frame.lisp +++ b/src/commands/frame.lisp @@ -8,3 +8,11 @@ (define-command toggle-frame-fullscreen () () "Toggles fullscreen." (setf (display-fullscreen-p) (not (display-fullscreen-p)))) + +(define-command maximize-frame () () + "Maximize the frame." + (lem-if:maximize-frame (implementation))) + +(define-command minimize-frame () () + "Minimize the frame." + (lem-if:minimize-frame (implementation))) diff --git a/src/interface.lisp b/src/interface.lisp index 2f8d3acc7..1aa4cf848 100644 --- a/src/interface.lisp +++ b/src/interface.lisp @@ -54,6 +54,10 @@ (defgeneric lem-if:set-display-title (implementation title)) (defgeneric lem-if:display-fullscreen-p (implementation)) (defgeneric lem-if:set-display-fullscreen-p (implementation fullscreen-p)) +(defgeneric lem-if:maximize-frame (implementation) + (:method (implementation))) +(defgeneric lem-if:minimize-frame (implementation) + (:method (implementation))) (defgeneric lem-if:make-view (implementation window x y width height use-modeline)) (defgeneric lem-if:view-width (implementation view)) (defgeneric lem-if:view-height (implementation view)) diff --git a/src/internal-packages.lisp b/src/internal-packages.lisp index 25a7dd676..63e3349ff 100644 --- a/src/internal-packages.lisp +++ b/src/internal-packages.lisp @@ -683,6 +683,8 @@ :set-display-title :display-fullscreen-p :set-display-fullscreen-p + :maximize-frame + :minimize-frame :make-view :view-width :view-height