mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 16:02:51 -05:00
screenshot: add window capture for Hyprland
This commit is contained in:
@@ -77,6 +77,8 @@ func (s *Screenshoter) Run() (*CaptureResult, error) {
|
||||
return s.captureLastRegion()
|
||||
case ModeRegion:
|
||||
return s.captureRegion()
|
||||
case ModeWindow:
|
||||
return s.captureWindow()
|
||||
case ModeOutput:
|
||||
return s.captureOutput(s.config.OutputName)
|
||||
case ModeFullScreen:
|
||||
@@ -119,6 +121,27 @@ func (s *Screenshoter) captureRegion() (*CaptureResult, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *Screenshoter) captureWindow() (*CaptureResult, error) {
|
||||
geom, err := GetActiveWindow()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
region := Region{
|
||||
X: geom.X,
|
||||
Y: geom.Y,
|
||||
Width: geom.Width,
|
||||
Height: geom.Height,
|
||||
}
|
||||
|
||||
output := s.findOutputForRegion(region)
|
||||
if output == nil {
|
||||
return nil, fmt.Errorf("could not find output for window")
|
||||
}
|
||||
|
||||
return s.captureRegionOnOutput(output, region)
|
||||
}
|
||||
|
||||
func (s *Screenshoter) captureFullScreen() (*CaptureResult, error) {
|
||||
output := s.findFocusedOutput()
|
||||
if output == nil {
|
||||
|
||||
Reference in New Issue
Block a user