From 238dbb386dd68825b2e65a9e3ce661e8eab5a745 Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Tue, 12 Jul 2022 20:27:56 +0200 Subject: [PATCH] Restrict color picker's screenshot to window This fixes issues like Aegisub/Aegisub#264 with taking screenshots on linux, especially with wxgtk3 or wayland. --- src/dialog_colorpicker.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/dialog_colorpicker.cpp b/src/dialog_colorpicker.cpp index 510d2a6ce..f6e080636 100644 --- a/src/dialog_colorpicker.cpp +++ b/src/dialog_colorpicker.cpp @@ -386,7 +386,13 @@ void ColorPickerScreenDropper::DropFromScreenXY(int x, int y) { wxMemoryDC capdc(capture); capdc.SetPen(*wxTRANSPARENT_PEN); #ifndef __WXMAC__ - wxScreenDC screen; + wxWindow *superparent = GetParent(); + while (superparent->GetParent() != nullptr) { + superparent = superparent->GetParent(); + } + superparent->ScreenToClient(&x, &y); + + wxWindowDC screen(superparent); capdc.StretchBlit(0, 0, resx * magnification, resy * magnification, &screen, x - resx / 2, y - resy / 2, resx, resy); #else