summaryrefslogtreecommitdiff
path: root/freefilesync/debian/patches/revert_zenju_aggressive_upstreamisms.patch
blob: 20ccedb8c5e71083194ae4c7c4824f73c68260a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
Description: Some of these can be traced back to version 10.23 which was the last to not use <unordered_map>
 Had to revert gui_status_handler.cpp and .h entirely to version 11.0 to avoid the wx 3.1.4-isms here.
 .
 Now have to revert wxWidgets 3.1.4 upstreamisms
 cd 11.1-0 ; git diff HEAD~1 -- $( grep -l -rIE 'wxASCII_STR' ) > ~/foo1 ; ( cd ../11.1-2 ; vi ~/foo1 $( grep -l -rIE 'wxASCII_STR' ) ; )
 cd 11.1-0 ; git diff HEAD~1 -- $( grep -l -rIE 'wxDD_SHOW_HIDDEN' ) > ~/foo1 ; ( cd ../11.1-2 ; vi ~/foo1 $( grep -l -rIE 'wxDD_SHOW_HIDDEN' ) ; )
Date: 2022-09-07
Version: 11.26
Author: bgstack15
--- a/wx+/choice_enum.h
+++ b/wx+/choice_enum.h
@@ -7,7 +7,6 @@
 #ifndef CHOICE_ENUM_H_132413545345687
 #define CHOICE_ENUM_H_132413545345687
 
-#include <unordered_map>
 #include <vector>
 #include <wx/choice.h>
 
@@ -47,8 +46,6 @@ struct EnumDescrList
 
     using DescrList = std::vector<std::pair<Enum, std::pair<wxString, wxString>>>;
     DescrList descrList;
-
-    std::unordered_map<const wxChoice*, std::vector<wxString>> labelsSetLast;
 };
 template <class Enum> void setEnumVal(const EnumDescrList<Enum>& mapping, wxChoice& ctrl, Enum value);
 template <class Enum> Enum getEnumVal(const EnumDescrList<Enum>& mapping, const wxChoice& ctrl);
@@ -71,32 +68,24 @@ template <class Enum> void updateTooltip
 template <class Enum>
 void setEnumVal(EnumDescrList<Enum>& mapping, wxChoice& ctrl, Enum value)
 {
-    auto& labelsSetLast = mapping.labelsSetLast[&ctrl];
-
-    std::vector<wxString> labels;
-    for (const auto& [val, texts] : mapping.descrList)
-        labels.push_back(texts.first);
+    ctrl.Clear();
 
-    if (labels != labelsSetLast)
+    int selectedPos = 0;
+    for (auto it = mapping.descrList.begin(); it != mapping.descrList.end(); ++it)
     {
-        ctrl.Set(labels); //expensive as fuck! => only call when absolutely needed!
-        labelsSetLast = std::move(labels);
+        ctrl.Append(it->second.first);
+        if (it->first == value)
+        {
+            selectedPos = it - mapping.descrList.begin();
+
+            if (it->second.second.empty())
+                ctrl.UnsetToolTip();
+            else
+                ctrl.SetToolTip(it->second.second);
+        }
     }
-    //-----------------------------------------------------------------
 
-    const auto it = std::find_if(mapping.descrList.begin(), mapping.descrList.end(), [&](const auto& mapItem) { return mapItem.first == value; });
-    if (it != mapping.descrList.end())
-    {
-        if (const wxString& tooltip = it->second.second;
-            !tooltip.empty())
-            ctrl.SetToolTip(tooltip);
-        else
-            ctrl.UnsetToolTip();
-
-        const int selectedPos = it - mapping.descrList.begin();
-        ctrl.SetSelection(selectedPos);
-    }
-    else assert(false);
+    ctrl.SetSelection(selectedPos);
 }
 
 template <class Enum>
@@ -115,17 +104,11 @@ Enum getEnumVal(const EnumDescrList<Enum
 
 template <class Enum> void updateTooltipEnumVal(const EnumDescrList<Enum>& mapping, wxChoice& ctrl)
 {
-    const int selectedPos = ctrl.GetSelection();
+    const Enum currentValue = getEnumVal(mapping, ctrl);
 
-    if (0 <= selectedPos && selectedPos < std::ssize(mapping.descrList))
-    {
-        if (const auto& [text, tooltip] = mapping.descrList[selectedPos].second;
-            !tooltip.empty())
-            ctrl.SetToolTip(tooltip);
-        else
-            ctrl.UnsetToolTip();
-    }
-    else assert(false);
+    for (const auto& [enumValue, textAndTooltip] : mapping.descrList)
+        if (currentValue == enumValue)
+            ctrl.SetToolTip(textAndTooltip.second);
 }
 }
 
--- a/FreeFileSync/Source/RealTimeSync/folder_selector2.cpp
+++ b/FreeFileSync/Source/RealTimeSync/folder_selector2.cpp
@@ -165,7 +165,7 @@ void FolderSelector2::onSelectDir(wxComm
     }
 
     Zstring newFolderPath;
-    wxDirDialog folderSelector(parent_, _("Select a folder"), utfTo<wxString>(defaultFolderPath), wxDD_DEFAULT_STYLE | wxDD_SHOW_HIDDEN);
+    wxDirDialog folderSelector(parent_, _("Select a folder"), utfTo<wxString>(defaultFolderPath));
     if (folderSelector.ShowModal() != wxID_OK)
         return;
     newFolderPath = utfTo<Zstring>(folderSelector.GetPath());
--- a/FreeFileSync/Source/ui/command_box.h
+++ b/FreeFileSync/Source/ui/command_box.h
@@ -28,7 +28,7 @@ public:
                const wxString choices[] = nullptr,
                long style = 0,
                const wxValidator& validator = wxDefaultValidator,
-               const wxString& name = wxASCII_STR(wxComboBoxNameStr));
+               const wxString& name = wxComboBoxNameStr);
 
     void setHistory(const std::vector<Zstring>& history, size_t historyMax) { history_ = history; historyMax_ = historyMax; }
     std::vector<Zstring> getHistory() const { return history_; }
--- a/FreeFileSync/Source/ui/folder_history_box.h
+++ b/FreeFileSync/Source/ui/folder_history_box.h
@@ -68,7 +68,7 @@ public:
                      const wxString choices[] = nullptr,
                      long style = 0,
                      const wxValidator& validator = wxDefaultValidator,
-                     const wxString& name = wxASCII_STR(wxComboBoxNameStr));
+                     const wxString& name = wxComboBoxNameStr);
 
     void setHistory(std::shared_ptr<HistoryList> sharedHistory) { sharedHistory_ = std::move(sharedHistory); }
     std::shared_ptr<HistoryList> getHistory() { return sharedHistory_; }
--- a/FreeFileSync/Source/ui/folder_selector.cpp
+++ b/FreeFileSync/Source/ui/folder_selector.cpp
@@ -239,7 +239,7 @@ void FolderSelector::onSelectFolder(wxCo
 
     Zstring shellItemPath;
     //default size? Windows: not implemented, Linux(GTK2): not implemented, macOS: not implemented => wxWidgets, what is this shit!?
-    wxDirDialog folderSelector(parent_, _("Select a folder"), utfTo<wxString>(defaultFolderNative), wxDD_DEFAULT_STYLE | wxDD_SHOW_HIDDEN);
+    wxDirDialog folderSelector(parent_, _("Select a folder"), utfTo<wxString>(defaultFolderNative));
     //GTK2: "Show hidden" is also available as a context menu option in the folder picker!
     //It looks like wxDD_SHOW_HIDDEN only sets the default when opening for the first time!?
     if (folderSelector.ShowModal() != wxID_OK)
--- a/wx+/bitmap_button.h
+++ b/wx+/bitmap_button.h
@@ -28,7 +28,7 @@ public:
                      const wxSize& size           = wxDefaultSize,
                      long style                   = 0,
                      const wxValidator& validator = wxDefaultValidator,
-                     const wxString& name         = wxASCII_STR(wxButtonNameStr)) :
+                     const wxString& name         = wxButtonNameStr) :
         wxBitmapButton(parent, id, wxNullBitmap, pos, size, style, validator, name)
     {
         SetLabel(label);
@@ -104,7 +104,6 @@ inline
 wxBitmap renderSelectedButton(const wxSize& sz)
 {
     wxBitmap bmp(sz); //seems we don't need to pass 24-bit depth here even for high-contrast color schemes
-    bmp.SetScaleFactor(getDisplayScaleFactor());
     {
         wxMemoryDC dc(bmp);
 
@@ -120,7 +119,6 @@ inline
 wxBitmap renderPressedButton(const wxSize& sz)
 {
     wxBitmap bmp(sz); //seems we don't need to pass 24-bit depth here even for high-contrast color schemes
-    bmp.SetScaleFactor(getDisplayScaleFactor());
     {
         //draw rectangle border with gradient
         const wxColor colFrom = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
--- a/wx+/dc.h
+++ b/wx+/dc.h
@@ -12,7 +12,7 @@
 #include <zen/basic_math.h>
 #include <wx/dcbuffer.h> //for macro: wxALWAYS_NATIVE_DOUBLE_BUFFER
 #include <wx/dcscreen.h>
-#include <wx/bmpbndl.h>
+//#include <wx/bmpbndl.h>
     #include <gtk/gtk.h>
 
 
@@ -92,9 +92,6 @@ constexpr int defaultDpi = 96; //on Wind
 inline
 int getDPI()
 {
-#ifndef wxHAS_DPI_INDEPENDENT_PIXELS
-#error why is wxHAS_DPI_INDEPENDENT_PIXELS not defined?
-#endif
     //GTK2 doesn't properly support high DPI: https://freefilesync.org/forum/viewtopic.php?t=6114
     //=> requires general fix at wxWidgets-level
 
@@ -130,7 +127,6 @@ wxBitmap toScaledBitmap(const wxImage& i
 {
     //wxBitmap(const wxImage& image, int depth = -1, double WXUNUSED(scale) = 1.0) => wxWidgets just ignores scale parameter! WTF!
     wxBitmap bmpScaled(img);
-    bmpScaled.SetScaleFactor(getDisplayScaleFactor());
     return bmpScaled; //when testing use 175% scaling: wxWidgets' scaling logic doesn't kick in for 150% only
 }
 
--- a/wx+/graph.h
+++ b/wx+/graph.h
@@ -192,7 +192,7 @@ public:
             const wxPoint& pos   = wxDefaultPosition,
             const wxSize& size   = wxDefaultSize,
             long style           = wxTAB_TRAVERSAL | wxNO_BORDER,
-            const wxString& name = wxASCII_STR(wxPanelNameStr));
+            const wxString& name = wxPanelNameStr);
 
     class CurveAttributes
     {
--- a/wx+/grid.cpp
+++ b/wx+/grid.cpp
@@ -263,7 +263,7 @@ class Grid::SubWindow : public wxWindow
 {
 public:
     SubWindow(Grid& parent) :
-        wxWindow(&parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS | wxBORDER_NONE, wxASCII_STR(wxPanelNameStr)),
+        wxWindow(&parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS | wxBORDER_NONE, wxPanelNameStr),
         parent_(parent)
     {
         Bind(wxEVT_PAINT, [this](wxPaintEvent& event) { onPaintEvent(event); });
--- a/wx+/grid.h
+++ b/wx+/grid.h
@@ -149,7 +149,7 @@ public:
          const wxPoint& pos   = wxDefaultPosition,
          const wxSize& size   = wxDefaultSize,
          long style           = wxTAB_TRAVERSAL | wxNO_BORDER,
-         const wxString& name = wxASCII_STR(wxPanelNameStr));
+         const wxString& name = wxPanelNameStr);
 
     size_t getRowCount() const;
 
--- a/wx+/toggle_button.h
+++ b/wx+/toggle_button.h
@@ -24,7 +24,7 @@ public:
                  const wxSize&      size = wxDefaultSize,
                  long               style = 0,
                  const wxValidator& validator = wxDefaultValidator,
-                 const wxString&    name = wxASCII_STR(wxButtonNameStr)) :
+                 const wxString&    name = wxButtonNameStr) :
         wxBitmapButton(parent, id, bitmap, pos, size, style, validator, name) {}
 
     //wxButton constructor
@@ -35,7 +35,7 @@ public:
                  const wxSize&      size = wxDefaultSize,
                  long               style = 0,
                  const wxValidator& validator = wxDefaultValidator,
-                 const wxString&    name = wxASCII_STR(wxButtonNameStr)) :
+                 const wxString&    name = wxButtonNameStr) :
         wxBitmapButton(parent, id, wxNullBitmap, pos, size, style, validator, name)
     {
         SetLabel(label);
--- a/FreeFileSync/Source/ui/gui_status_handler.cpp
+++ b/FreeFileSync/Source/ui/gui_status_handler.cpp
@@ -44,8 +44,8 @@ StatusHandlerTemporaryPanel::StatusHandl
     mainDlg_.Update(); //don't wait until idle event!
 
     //register keys
-    mainDlg_.                Bind(wxEVT_CHAR_HOOK,              &StatusHandlerTemporaryPanel::onLocalKeyEvent, this);
-    mainDlg_.m_buttonCancel->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &StatusHandlerTemporaryPanel::onAbortCompare,  this);
+    mainDlg_.Connect(wxEVT_CHAR_HOOK, wxKeyEventHandler(StatusHandlerTemporaryPanel::OnKeyPressed), nullptr, this);
+    mainDlg_.m_buttonCancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusHandlerTemporaryPanel::OnAbortCompare), nullptr, this);
 }
 
 
@@ -129,9 +129,8 @@ StatusHandlerTemporaryPanel::~StatusHand
     mainDlg_.auiMgr_.Update();
 
     //unregister keys
-    [[maybe_unused]] bool ubOk1 = mainDlg_.                Unbind(wxEVT_CHAR_HOOK,              &StatusHandlerTemporaryPanel::onLocalKeyEvent, this);
-    [[maybe_unused]] bool ubOk2 = mainDlg_.m_buttonCancel->Unbind(wxEVT_COMMAND_BUTTON_CLICKED, &StatusHandlerTemporaryPanel::onAbortCompare,  this);
-    assert(ubOk1 && ubOk2);
+    mainDlg_.Disconnect(wxEVT_CHAR_HOOK, wxKeyEventHandler(StatusHandlerTemporaryPanel::OnKeyPressed), nullptr, this);
+    mainDlg_.m_buttonCancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusHandlerTemporaryPanel::OnAbortCompare), nullptr, this);
 
     mainDlg_.compareStatus_->teardown();
 
@@ -336,7 +335,7 @@ void StatusHandlerTemporaryPanel::forceU
 }
 
 
-void StatusHandlerTemporaryPanel::onLocalKeyEvent(wxKeyEvent& event)
+void StatusHandlerTemporaryPanel::OnKeyPressed(wxKeyEvent& event)
 {
     const int keyCode = event.GetKeyCode();
     if (keyCode == WXK_ESCAPE)
@@ -346,7 +345,7 @@ void StatusHandlerTemporaryPanel::onLoca
 }
 
 
-void StatusHandlerTemporaryPanel::onAbortCompare(wxCommandEvent& event)
+void StatusHandlerTemporaryPanel::OnAbortCompare(wxCommandEvent& event)
 {
     userRequestAbort();
 }
--- a/FreeFileSync/Source/ui/gui_status_handler.h
+++ b/FreeFileSync/Source/ui/gui_status_handler.h
@@ -46,8 +46,8 @@ public:
     Result reportResults(); //noexcept!!
 
 private:
-    void onLocalKeyEvent(wxKeyEvent& event);
-    void onAbortCompare(wxCommandEvent& event); //handle abort button click
+    void OnKeyPressed(wxKeyEvent& event);
+    void OnAbortCompare(wxCommandEvent& event); //handle abort button click
     void showStatsPanel();
 
     MainDialog& mainDlg_;
--- a/wx+/no_flicker.h
+++ b/wx+/no_flicker.h
@@ -72,7 +72,7 @@ void setTextWithUrls(wxRichTextCtrl& ric
     ZEN_ON_SCOPE_EXIT(richCtrl.EndSuppressUndo());
 
     //fix mouse scroll speed: why the FUCK is this even necessary!
-    richCtrl.SetLineHeight(richCtrl.GetCharHeight());
+    //richCtrl.SetLineHeight(richCtrl.GetCharHeight()); // this is not even documented in wxWidgets 3.1.5!
 
     //get rid of margins and space between text blocks/"paragraphs"
     richCtrl.SetMargins({0, 0});
--- a/FreeFileSync/Source/ui/progress_indicator.cpp
+++ b/FreeFileSync/Source/ui/progress_indicator.cpp
@@ -878,12 +878,10 @@ dlgSizeBuf_(dlgSize)
     auto generateSquareBitmap = [&](const wxColor& fillCol, const wxColor& borderCol)
     {
         wxBitmap bmpSquare(this->GetCharHeight(), this->GetCharHeight()); //seems we don't need to pass 24-bit depth here even for high-contrast color schemes
-        bmpSquare.SetScaleFactor(getDisplayScaleFactor());
         {
             wxMemoryDC dc(bmpSquare);
             drawInsetRectangle(dc, wxRect(bmpSquare.GetSize()), fastFromDIP(1), borderCol, fillCol);
         }
-        bmpSquare.SetScaleFactor(static_cast<double>(getDPI()) / defaultDpi);
         return bmpSquare;
     };
     pnl_.m_bitmapGraphKeyBytes->SetBitmap(generateSquareBitmap(getColorBytes(), getColorBytesRim()));
--- a/wx+/rtl.h
+++ b/wx+/rtl.h
@@ -70,8 +70,6 @@ void drawBitmapRtlMirror(wxDC& dc, const
                 if (!buffer || buffer->GetSize() != rect.GetSize()) //[!] since we do a mirror, width needs to match exactly!
                     buffer.emplace(rect.GetSize());
 
-                if (buffer->GetScaleFactor() != dc.GetContentScaleFactor()) //needed here?
-                    buffer->SetScaleFactor(dc.GetContentScaleFactor());     //
 
                 wxMemoryDC memDc(*buffer); //copies scale factor from wxBitmap
                 memDc.Blit(wxPoint(0, 0), rect.GetSize(), &dc, rect.GetTopLeft()); //blit in: background is mirrored due to memDc, dc having different layout direction!
--- a/FreeFileSync/Source/ui/main_dlg.cpp
+++ b/FreeFileSync/Source/ui/main_dlg.cpp
@@ -3586,7 +3586,6 @@ void MainDialog::onCfgGridContext(GridCo
     auto addColorOption = [&](const wxColor& col, const wxString& name)
     {
         wxBitmap bmpSquare(this->GetCharHeight(), this->GetCharHeight()); //seems we don't need to pass 24-bit depth here even for high-contrast color schemes
-        bmpSquare.SetScaleFactor(getDisplayScaleFactor());
         {
             wxMemoryDC dc(bmpSquare);
             const wxColor borderCol(0xdd, 0xdd, 0xdd); //light grey
@@ -3619,7 +3618,6 @@ void MainDialog::onCfgGridContext(GridCo
 
     //show color picker
     wxBitmap bmpColorPicker(this->GetCharHeight(), this->GetCharHeight()); //seems we don't need to pass 24-bit depth here even for high-contrast color schemes
-    bmpColorPicker.SetScaleFactor(getDisplayScaleFactor());
     {
         wxMemoryDC dc(bmpColorPicker);
         const wxColor borderCol(0xdd, 0xdd, 0xdd); //light grey
@@ -3633,7 +3631,6 @@ void MainDialog::onCfgGridContext(GridCo
     {
         wxColourData colCfg;
         colCfg.SetChooseFull(true);
-        colCfg.SetChooseAlpha(false);
         colCfg.SetColour(defaultColors[1].first); //tentative
 
         if (const ConfigView::Details* cfg = cfggrid::getDataView(*m_gridCfgHistory).getItem(selectedRows[0]))
@@ -3650,19 +3647,6 @@ void MainDialog::onCfgGridContext(GridCo
             assert(col.Alpha() == 255);
             return col;
         };
-        wxColourDialog dlg(this, &colCfg);
-        dlg.Center();
-
-        dlg.Bind(wxEVT_COLOUR_CHANGED, [&](wxColourDialogEvent& event2)
-        {
-            //show preview during color selection (Windows-only atm)
-            cfggrid::getDataView(*m_gridCfgHistory).setBackColor(cfgFilePaths, fixColorPickerColor(event2.GetColour()), true /*previewOnly*/);
-            m_gridCfgHistory->Refresh();
-        });
-
-        if (dlg.ShowModal() == wxID_OK)
-            applyBackColor(fixColorPickerColor(dlg.GetColourData().GetColour()));
-        else //shut off color preview
         {
             cfggrid::getDataView(*m_gridCfgHistory).setBackColor(cfgFilePaths, wxNullColour, true /*previewOnly*/);
             m_gridCfgHistory->Refresh();
--- a/wx+/image_tools.cpp
+++ b/wx+/image_tools.cpp
@@ -188,7 +188,6 @@ wxImage zen::createImageFromText(const w
         return wxNullImage;
 
     wxBitmap newBitmap(maxWidth, lineHeight * lineInfo.size()); //seems we don't need to pass 24-bit depth here even for high-contrast color schemes
-    newBitmap.SetScaleFactor(getDisplayScaleFactor());
     {
         dc.SelectObject(newBitmap); //copies scale factor from wxBitmap
         ZEN_ON_SCOPE_EXIT(dc.SelectObject(wxNullBitmap));
bgstack15