gtk3 black wxFrame problem

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 427
Joined: Fri Dec 09, 2016 7:28 am
Contact:

gtk3 black wxFrame problem

Post by cutecode »

Debian 9, gtk3

After moving from gtk2 to gtk3, all wxFrames are black before controls are showed up on it.
I downloaded wx-master and there's no change.

Catching events

Code: Select all

	EVT_ERASE_BACKGROUND(dMyFrame::OnEraseBackground)
	EVT_PAINT(dMyFrame::OnPaint)
did not help

I compiled minimum application and if I resize it with mouse, then it becomes black while resizinig.

I found that OS "system monitor" becomes black too, before controls showed up.

So I think it is problem with my theme, but whatever themes I tried - the same efect

Is there a solution to make my on background color on GTK3.
wxFrame do becomes with my backround color, but only after all controls are showed up.
I dont have this behaver on GTK2
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru
DavidHart
Site Admin
Site Admin
Posts: 4254
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: gtk3 black wxFrame problem

Post by DavidHart »

Hi,

Possibly a variant of https://wiki.wxwidgets.org/WxFAQ#Why_ar ... log_boxes..

In any case, it fixes/prevents various issues to do with size/colour/events/etc if you always add a wxPanel to a wxFrame as the frame's only child control, and then do everything else inside that panel (and that panel's sizer).

Regards,

David
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 427
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: gtk3 black wxFrame problem

Post by cutecode »

hello, not my case.
I already have wxPanel on wxFrames and wxDialgs

As I wrote bofore
wxFrame do becomes with my backround color, but only after all controls are showed up.
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru
DavidHart
Site Admin
Site Admin
Posts: 4254
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: gtk3 black wxFrame problem

Post by DavidHart »

But...
EVT_ERASE_BACKGROUND(dMyFrame::OnEraseBackground)
EVT_PAINT(dMyFrame::OnPaint)
If you have a panel filling the frame, surely you should be erasing/painting that panel instead.

FWIW, I don't have that sort of problem with debian 10 and gtk3, and I didn't previously with debian 9. Which DE and Window manager are you using?
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 427
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: gtk3 black wxFrame problem

Post by cutecode »

LightDM MATE

I put OnEraseBackground and OnPaint both on wxFrame and wxPanel
I even put different colours on them "red" and "green" respectively, to see how it works

"green" color never is seen, but "red" is pained only if I set SetAutoLayout(true); and comment "Sisers"
After opening wxFrame it becoms black and then in red color
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 427
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: gtk3 black wxFrame problem

Post by cutecode »

hello

I attached video how it blinks on GTK3
Attachments
2222.mkv.tar.7z
(335.67 KiB) Downloaded 84 times
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru
DavidHart
Site Admin
Site Admin
Posts: 4254
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: gtk3 black wxFrame problem

Post by DavidHart »

I see what you mean.

Not quite the same situation but, FWIW, this is an old comment from my own code:

Code: Select all

void FileDirDlg::OnEraseBackground(wxEraseEvent& event)  // This is only needed in gtk2 under kde and brain-dead theme-manager, but can cause a blackout in some gtk3(themes?)
So, do you actually need to erase/paint with gtk3?

If you do, you need to work out what actually causing the problem. I suggest you try to reproduce it in the 'minimal' sample, then test with a different DE, a different window manager; and, best of all, a more recent gtk+3 version.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: gtk3 black wxFrame problem

Post by ONEEYEMAN »

Hi,
Are you using wxPaintDC? Or any other DC?

Thank you.
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 427
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: gtk3 black wxFrame problem

Post by cutecode »

shure

Code: Select all


dMyFrame::dMyFrame(wxFrame *parent, LPCTSTR lpszCaption, const wxPoint& point, const wxSize& size, int style)
{
    SetBackgroundStyle(wxBG_STYLE_PAINT);

	Create(	parent,	wxID_ANY,	lpszCaption,	point, size, style);
	SetAutoLayout(true);
}
void dMyFrame::OnEraseBackground(wxEraseEvent& event)
{
    wxPaintDC dc(this);

    wxBrush brush(wxColor("red"));
    dc.SetBackground(brush);
    dc.Clear();
}

void dMyFrame::OnPaint(wxPaintEvent& event)
{
    wxPaintDC dc(this);

    wxBrush brush(wxColor("red"));
    dc.SetBackground(brush);
    dc.Clear();
}
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: gtk3 black wxFrame problem

Post by ONEEYEMAN »

Hi,
And drawing and image samples works OK?

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: gtk3 black wxFrame problem

Post by doublemax »

I don't know if it matters, but:

a) If you set wxBG_STYLE_PAINT, you don't need OnEraseBackground

b) You should not create a wxPaintDC inside a EVT_ERASE_BACKGROUND event handler (use wxEraseEvent::GetDC() )

Check if commenting out the SetBackgroundStyle() call makes any difference
Use the source, Luke!
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 427
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: gtk3 black wxFrame problem

Post by cutecode »

Hello

I tried it befor posting

I just cleaned GTK3 and rebuilding wx back with GTK2

Thank you
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 427
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: gtk3 black wxFrame problem

Post by cutecode »

Hello!

I was trying to build wx on Debian 10, and found that webkitgtk is not supported on this platform.

So back to GTK3.

I did as doublemax sugested

1. removed wxBG_STYLE_PAINT style
2. rewrote OnEraseBackground as

Code: Select all

    wxDC *dc = event.GetDC();

    wxBrush brush(GetFormBgColor());
    dc->SetBackground(brush);
    dc->Clear();
3. removed freeze/thaw

Now it is much better, but still blinks black for some period of time

without freeze/thaw I have less blinks
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru
User avatar
cutecode
Super wx Problem Solver
Super wx Problem Solver
Posts: 427
Joined: Fri Dec 09, 2016 7:28 am
Contact:

Re: gtk3 black wxFrame problem

Post by cutecode »

Hello!

I installed wx on debian 10 with GTK3 build.

The above problem has gone.

Thanks to all for help !!!
wx 3.1.6 win/mac/linux

regards,
Alexander Saprykin
https://v2.dental-soft.ru
Post Reply