diff options
author | Dan Gudmundsson <[email protected]> | 2015-07-08 16:13:13 +0200 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2015-07-08 16:13:13 +0200 |
commit | e16d2a78e6e60dcc57867748ae809e448ef578e4 (patch) | |
tree | 39c92df6d1e50cb65cfdf1049cc0c0074375d708 /lib/wx/src | |
parent | 9ebb4472d9cbe0dc907c894231ce1f61a04fa0b6 (diff) | |
parent | 3461837363d82e6c908ac81f664da4372aa3a8b0 (diff) | |
download | otp-e16d2a78e6e60dcc57867748ae809e448ef578e4.tar.gz otp-e16d2a78e6e60dcc57867748ae809e448ef578e4.tar.bz2 otp-e16d2a78e6e60dcc57867748ae809e448ef578e4.zip |
Merge branch 'maint'
* maint:
wx: Add event callback fastpath
wx: Event callbacks could hang wx application temporary
wx: Make wxLANGUAGE_ variable
wx: Send wxWdigets assert to error logger
wx: Add mouse_capture_lost event
wx: Fix code generator
Diffstat (limited to 'lib/wx/src')
-rw-r--r-- | lib/wx/src/gen/wxEvtHandler.erl | 2 | ||||
-rw-r--r-- | lib/wx/src/gen/wxMouseCaptureLostEvent.erl | 65 | ||||
-rw-r--r-- | lib/wx/src/wxe_server.erl | 35 |
3 files changed, 87 insertions, 15 deletions
diff --git a/lib/wx/src/gen/wxEvtHandler.erl b/lib/wx/src/gen/wxEvtHandler.erl index 6e9770bbb6..2d0a87f4dd 100644 --- a/lib/wx/src/gen/wxEvtHandler.erl +++ b/lib/wx/src/gen/wxEvtHandler.erl @@ -90,6 +90,8 @@ connect(This=#wx_ref{type=ThisT}, EventType, Options) -> parse_opts([{callback,Fun}|R], Opts) when is_function(Fun) -> %% Check Fun Arity? parse_opts(R, Opts#evh{cb=Fun}); +parse_opts([{callback,CB={nospawn, Fun}}|R], Opts) when is_function(Fun) -> + parse_opts(R, Opts#evh{cb=CB}); parse_opts([callback|R], Opts) -> parse_opts(R, Opts#evh{cb=self()}); parse_opts([{userData, UserData}|R],Opts) -> diff --git a/lib/wx/src/gen/wxMouseCaptureLostEvent.erl b/lib/wx/src/gen/wxMouseCaptureLostEvent.erl new file mode 100644 index 0000000000..a7e68a2d2f --- /dev/null +++ b/lib/wx/src/gen/wxMouseCaptureLostEvent.erl @@ -0,0 +1,65 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2008-2015. All Rights Reserved. +%% +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. +%% +%% %CopyrightEnd% +%% This file is generated DO NOT EDIT + +%% @doc See external documentation: <a href="http://www.wxwidgets.org/manuals/2.8.12/wx_wxmousecapturelostevent.html">wxMouseCaptureLostEvent</a>. +%% <dl><dt>Use {@link wxEvtHandler:connect/3.} with EventType:</dt> +%% <dd><em>mouse_capture_lost</em></dd></dl> +%% See also the message variant {@link wxEvtHandler:wxMouseCaptureLost(). #wxMouseCaptureLost{}} event record type. +%% +%% <p>This class is derived (and can use functions) from: +%% <br />{@link wxEvent} +%% </p> +%% @type wxMouseCaptureLostEvent(). An object reference, The representation is internal +%% and can be changed without notice. It can't be used for comparsion +%% stored on disc or distributed for use on other nodes. + +-module(wxMouseCaptureLostEvent). +-include("wxe.hrl"). +-export([]). + +%% inherited exports +-export([getId/1,getSkipped/1,getTimestamp/1,isCommandEvent/1,parent_class/1, + resumePropagation/2,shouldPropagate/1,skip/1,skip/2,stopPropagation/1]). + +-export_type([wxMouseCaptureLostEvent/0]). +%% @hidden +parent_class(wxEvent) -> true; +parent_class(_Class) -> erlang:error({badtype, ?MODULE}). + +-type wxMouseCaptureLostEvent() :: wx:wx_object(). + %% From wxEvent +%% @hidden +stopPropagation(This) -> wxEvent:stopPropagation(This). +%% @hidden +skip(This, Options) -> wxEvent:skip(This, Options). +%% @hidden +skip(This) -> wxEvent:skip(This). +%% @hidden +shouldPropagate(This) -> wxEvent:shouldPropagate(This). +%% @hidden +resumePropagation(This,PropagationLevel) -> wxEvent:resumePropagation(This,PropagationLevel). +%% @hidden +isCommandEvent(This) -> wxEvent:isCommandEvent(This). +%% @hidden +getTimestamp(This) -> wxEvent:getTimestamp(This). +%% @hidden +getSkipped(This) -> wxEvent:getSkipped(This). +%% @hidden +getId(This) -> wxEvent:getId(This). diff --git a/lib/wx/src/wxe_server.erl b/lib/wx/src/wxe_server.erl index 6679fcfbe1..cc253b1143 100644 --- a/lib/wx/src/wxe_server.erl +++ b/lib/wx/src/wxe_server.erl @@ -240,6 +240,8 @@ handle_connect(Object, EvData=#evh{handler=Handler}, invoke_cb({{Ev=#wx{}, Ref=#wx_ref{}}, FunId,_}, _S) -> %% Event callbacks case get(FunId) of + {{nospawn, Fun}, _} when is_function(Fun) -> + invoke_callback_fun(fun() -> Fun(Ev, Ref), <<>> end); {Fun,_} when is_function(Fun) -> invoke_callback(fun() -> Fun(Ev, Ref), <<>> end); {Pid,_} when is_pid(Pid) -> %% wx_object sync event @@ -258,21 +260,10 @@ invoke_cb({FunId, Args, _}, _S) when is_list(Args), is_integer(FunId) -> invoke_callback(Fun) -> Env = get(?WXE_IDENTIFIER), - CB = fun() -> - wx:set_env(Env), - wxe_util:cast(?WXE_CB_START, <<>>), - Res = try - Return = Fun(), - true = is_binary(Return), - Return - catch _:Reason -> - ?log("Callback fun crashed with {'EXIT, ~p, ~p}~n", - [Reason, erlang:get_stacktrace()]), - <<>> - end, - wxe_util:cast(?WXE_CB_RETURN, Res) - end, - spawn(CB), + spawn(fun() -> + wx:set_env(Env), + invoke_callback_fun(Fun) + end), ok. invoke_callback(Pid, Ev, Ref) -> @@ -302,6 +293,20 @@ invoke_callback(Pid, Ev, Ref) -> spawn(CB), ok. +invoke_callback_fun(Fun) -> + wxe_util:cast(?WXE_CB_START, <<>>), + Res = try + Return = Fun(), + true = is_binary(Return), + Return + catch _:Reason -> + ?log("Callback fun crashed with {'EXIT, ~p, ~p}~n", + [Reason, erlang:get_stacktrace()]), + <<>> + end, + wxe_util:cast(?WXE_CB_RETURN, Res). + + get_wx_object_state(Pid) -> case process_info(Pid, dictionary) of {dictionary, Dict} -> |