aboutsummaryrefslogtreecommitdiffstats
path: root/lib/observer/src/observer_app_wx.erl
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2012-02-21 11:43:08 +0100
committerDan Gudmundsson <[email protected]>2012-02-21 15:06:43 +0100
commitf413a27b73d1e0ceaf0d31fc9615208f11645108 (patch)
tree5a40727d3f846829db0a06b8040f584e3a09e425 /lib/observer/src/observer_app_wx.erl
parent5584462be1c6dce1990a9031c0e43a89e758a263 (diff)
downloadotp-f413a27b73d1e0ceaf0d31fc9615208f11645108.tar.gz
otp-f413a27b73d1e0ceaf0d31fc9615208f11645108.tar.bz2
otp-f413a27b73d1e0ceaf0d31fc9615208f11645108.zip
[observer] Windows double buffer fixes
DC's and GC's is not double buffered by default on windows, and there is a separate erase event which causes awful flickering when constant updating a window. Hack around wx (to be able to use wxBufferPaintDC), to avoid flickering on windows. This works on windows because there (and only there) wxGC:create/1 also takes a memoryDC as argument.
Diffstat (limited to 'lib/observer/src/observer_app_wx.erl')
-rw-r--r--lib/observer/src/observer_app_wx.erl20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/observer/src/observer_app_wx.erl b/lib/observer/src/observer_app_wx.erl
index 900fba911a..7eac2b8fab 100644
--- a/lib/observer/src/observer_app_wx.erl
+++ b/lib/observer/src/observer_app_wx.erl
@@ -108,11 +108,18 @@ init([Notebook, Parent]) ->
wxPanel:connect(DrawingArea, left_up),
wxPanel:connect(DrawingArea, left_dclick),
wxPanel:connect(DrawingArea, right_down),
+ case os:type() of
+ {win32, _} -> %% Ignore erase on windows
+ wxPanel:connect(DrawingArea, erase_background, [{callback, fun(_,_) -> ok end}]);
+ _ -> ok
+ end,
UseGC = haveGC(DrawingArea),
- Font = case UseGC of
- true -> wxSystemSettings:getFont(?wxSYS_DEFAULT_GUI_FONT);
- false -> wxFont:new(12,?wxFONTFAMILY_DECORATIVE,?wxFONTSTYLE_NORMAL,?wxFONTWEIGHT_NORMAL)
+ Font = case os:type() of
+ {unix,_} when UseGC ->
+ wxFont:new(12,?wxFONTFAMILY_DECORATIVE,?wxFONTSTYLE_NORMAL,?wxFONTWEIGHT_NORMAL);
+ _ ->
+ wxSystemSettings:getFont(?wxSYS_DEFAULT_GUI_FONT)
end,
SelCol = wxSystemSettings:getColour(?wxSYS_COLOUR_HIGHLIGHT),
GreyBrush = wxBrush:new({230,230,240}),
@@ -231,7 +238,12 @@ handle_event(Event, _State) ->
handle_sync_event(#wx{event = #wxPaint{}},_,
#state{app_w=DA, app=App, sel=Sel, paint=Paint, usegc=UseGC}) ->
%% PaintDC must be created in a callback to work on windows.
- DC = wxPaintDC:new(DA),
+ IsWindows = element(1, os:type()) =:= win32,
+ %% Avoid Windows flickering hack
+ DC = if IsWindows -> wx:typeCast(wxBufferedPaintDC:new(DA), wxPaintDC);
+ true -> wxPaintDC:new(DA)
+ end,
+ IsWindows andalso wxDC:clear(DC),
GC = case UseGC of
true ->
GC0 = ?wxGC:create(DC),