Opened 11 months ago

Closed 10 months ago

Last modified 10 months ago

#18463 closed defect (invalid)

(wxGTK3.0 && GTK3) only: wDC::Clear() seems not to work

Reported by: gunterkoenigsmann Owned by:
Priority: normal Milestone: 3.0.5
Component: wxGTK Version: 3.0.4
Keywords: Cc: gunter@…
Blocked By: Blocking:
Patch: no


Debian wants all package maintainers to rebuild their wx-based packages to the combination wxGTK3.0 on wxGTK3. Unfortunately in this combination wxDC::Clear() seems not to work as can be seen using the scroll sample. The workaround I currently use is drawing a rectangle instead, which works fine.

Change History (7)

comment:1 Changed 11 months ago by pcor

scroll sample seems to work fine for me with current 3.0 branch.

comment:2 Changed 11 months ago by gunterkoenigsmann

  • Cc gunter@… added

An additional puzzle piece that was found thanks to the debian maintainers ( This problem only happens if an X11 session is used (as opposed to wayland) or if GDK_BACKEND=x11.

comment:3 Changed 11 months ago by pcor

  • Status changed from new to infoneeded_new

The fact that this does not affect 3.1 would have been useful information. Does it happen with the current 3.0 branch?

comment:4 Changed 11 months ago by pcor


Attaching a patch that introduces dc.Clear() calls that are ignored on GTK3

That patch sets the foreground brush. Clear() uses the background brush.

comment:5 Changed 11 months ago by ojwb

  • Component changed from base to wxGTK

I just tested the patched scroll sample using Debian unstable's wxGTK packages (which are currently 3.0.4 plus all changes from the WX_3_0_BRANCH which are relevant to GTK except except for one - we wanted to avoid wasting effort tracking down GTK3-related issues which were already fixed on the branch).

With the patch as posted to the linked thread, if I run the scroll sample and hit F4, the background behind "Row 1", etc and "Column 1", etc is grey with both GTK2 and GTK3.

If I modify the patch to use dc.SetBackground(*wxWHITE_BRUSH); instead in all cases, then I instead get the expected white background with both GTK2 and GTK3.

So that reproducer doesn't show a GTK2 vs GTK3 difference, and the difference it does show is due to incorrect use of the wx API.

gunterkoenigsmann: Does your app also use SetBrush() when it should use SetBackground()?

If not, then can you modify your patch against the scroll sample to show the problem you're actually encountering?

If there is a wx bug here, I wonder if the fix for #18330 is related - that added a wxGTKCairoDCImpl::Clear() method for 3.0.x which isn't present for master. It looks like master instead uses wxGCDCImpl::Clear() (the implementation of which is fairly different between the two branches). If gunterkoenigsmann is using Debian wx packages version 3.0.4+dfsg-9 then this patch is present; for 3.0.4+dfsg-8 or older it isn't.

comment:6 Changed 10 months ago by vadz

  • Resolution set to invalid
  • Status changed from infoneeded_new to closed

Sorry, the bug was opened with my encouragement, but I completely failed to notice the user of a wrong function.

I've checked that the behaviour under MSW is the same (i.e. not only SetBackground() works, but SetBrush() also does not work), so there really doesn't seem to be anything wrong here except that, maybe, we could emphasize the difference between these 2 functions.

comment:7 Changed 10 months ago by Vadim Zeitlin <vadim@…>

In dfc6cdc06/git-wxWidgets:

Emphasize that wxDC::Clear() used brush set by SetBackground()

Ensure that people don't get the impression that using SetBrush() is
supposed to affect Clears().

See #18463.

Note: See TracTickets for help on using tickets.