diff --git a/src/dialog_colorpicker.cpp b/src/dialog_colorpicker.cpp index f6e080636..a9f20afef 100644 --- a/src/dialog_colorpicker.cpp +++ b/src/dialog_colorpicker.cpp @@ -386,15 +386,21 @@ void ColorPickerScreenDropper::DropFromScreenXY(int x, int y) { wxMemoryDC capdc(capture); capdc.SetPen(*wxTRANSPARENT_PEN); #ifndef __WXMAC__ - wxWindow *superparent = GetParent(); - while (superparent->GetParent() != nullptr) { - superparent = superparent->GetParent(); - } - superparent->ScreenToClient(&x, &y); + std::unique_ptr screen; - wxWindowDC screen(superparent); + if (!OPT_GET("Tool/Color Picker/Restrict to Window")->GetBool()) { + screen = agi::make_unique(); + } else { + wxWindow *superparent = GetParent(); + while (superparent->GetParent() != nullptr) { + superparent = superparent->GetParent(); + } + superparent->ScreenToClient(&x, &y); + + screen = agi::make_unique(superparent); + } capdc.StretchBlit(0, 0, resx * magnification, resy * magnification, - &screen, x - resx / 2, y - resy / 2, resx, resy); + screen.get(), x - resx / 2, y - resy / 2, resx, resy); #else // wxScreenDC doesn't work on recent versions of OS X so do it manually diff --git a/src/libresrc/default_config.json b/src/libresrc/default_config.json index 318f8d3ee..7b8e9228e 100644 --- a/src/libresrc/default_config.json +++ b/src/libresrc/default_config.json @@ -573,6 +573,9 @@ "Maximized" : false, "Skip Whitespace" : true }, + "Color Picker" : { + "Restrict to Window" : false + }, "Visual" : { "Autohide": false } diff --git a/src/libresrc/osx/default_config.json b/src/libresrc/osx/default_config.json index 59f2ed05f..9e89707b5 100644 --- a/src/libresrc/osx/default_config.json +++ b/src/libresrc/osx/default_config.json @@ -573,6 +573,9 @@ "Maximized" : false, "Skip Whitespace" : true }, + "Color Picker" : { + "Restrict to Window" : false + }, "Visual" : { "Autohide": false } diff --git a/src/preferences.cpp b/src/preferences.cpp index f6320dd75..d595caa63 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -228,6 +228,9 @@ void Interface(wxTreebook *book, Preferences *parent) { auto tl_assistant = p->PageSizer(_("Translation Assistant")); p->OptionAdd(tl_assistant, _("Skip over whitespace"), "Tool/Translation Assistant/Skip Whitespace"); + auto color_picker = p->PageSizer(_("Color Picker")); + p->OptionAdd(color_picker, _("Restrict Screen Picker to Window"), "Tool/Color Picker/Restrict to Window"); + p->SetSizerAndFit(p->sizer); }