summaryrefslogtreecommitdiff
path: root/ext/tk/lib
diff options
context:
space:
mode:
Diffstat (limited to 'ext/tk/lib')
-rw-r--r--ext/tk/lib/tk.rb90
1 files changed, 60 insertions, 30 deletions
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb
index 594442c3b6..927cf18063 100644
--- a/ext/tk/lib/tk.rb
+++ b/ext/tk/lib/tk.rb
@@ -1179,40 +1179,43 @@ module TkCore
unless self.const_defined? :RUN_EVENTLOOP_ON_MAIN_THREAD
if WITH_RUBY_VM ### check Ruby 1.9 !!!!!!!
# *** NEED TO FIX ***
- ip = TclTkIp.new(name, opts)
- if RUBY_PLATFORM =~ /cygwin/
+ case RUBY_PLATFORM
+ when /cygwin/
RUN_EVENTLOOP_ON_MAIN_THREAD = true
- INTERP = ip
- elsif ip._invoke_without_enc('tk', 'windowingsystem') == 'aqua' &&
- (TclTkLib.get_version<=>[8,4,TclTkLib::RELEASE_TYPE::FINAL,6]) > 0
- # *** KNOWN BUG ***
- # Main event loop thread of TkAqua (> Tk8.4.9) must be the main
- # application thread. So, ruby1.9 users must call Tk.mainloop on
- # the main application thread.
- #
- # *** ADD (2009/05/10) ***
- # In some cases (I don't know the description of conditions),
- # TkAqua 8.4.7 has a same kind of hang-up trouble.
- # So, if 8.4.7 or later, set RUN_EVENTLOOP_ON_MAIN_THREAD to true.
- # When you want to control this mode, please call the following
- # (set true/false as you want) before "require 'tk'".
- # ----------------------------------------------------------
- # module TkCore; RUN_EVENTLOOP_ON_MAIN_THREAD = true; end
- # ----------------------------------------------------------
- #
- RUN_EVENTLOOP_ON_MAIN_THREAD = true
- INTERP = ip
- else
- unless self.const_defined? :RUN_EVENTLOOP_ON_MAIN_THREAD
- RUN_EVENTLOOP_ON_MAIN_THREAD = false
- end
- if RUN_EVENTLOOP_ON_MAIN_THREAD
- INTERP = ip
+ when /darwin/ # MacOS X
+=begin
+ ip = TclTkIp.new(name, opts)
+ if ip._invoke_without_enc('tk', 'windowingsystem') == 'aqua' &&
+ (TclTkLib.get_version<=>[8,4,TclTkLib::RELEASE_TYPE::FINAL,6]) > 0
+=end
+ if TclTkLib::WINDOWING_SYSTEM == 'aqua' &&
+ (TclTkLib.get_version<=>[8,4,TclTkLib::RELEASE_TYPE::FINAL,6]) > 0
+ # *** KNOWN BUG ***
+ # Main event loop thread of TkAqua (> Tk8.4.9) must be the main
+ # application thread. So, ruby1.9 users must call Tk.mainloop on
+ # the main application thread.
+ #
+ # *** ADD (2009/05/10) ***
+ # In some cases (I don't know the description of conditions),
+ # TkAqua 8.4.7 has a same kind of hang-up trouble.
+ # So, if 8.4.7 or later, set RUN_EVENTLOOP_ON_MAIN_THREAD to true.
+ # When you want to control this mode, please call the following
+ # (set true/false as you want) before "require 'tk'".
+ # ----------------------------------------------------------
+ # module TkCore; RUN_EVENTLOOP_ON_MAIN_THREAD = true; end
+ # ----------------------------------------------------------
+ #
+ RUN_EVENTLOOP_ON_MAIN_THREAD = true
else
+ RUN_EVENTLOOP_ON_MAIN_THREAD = false
+=begin
ip.delete
+ ip = nil
+=end
end
+ else
+ RUN_EVENTLOOP_ON_MAIN_THREAD = false
end
- ip = nil
else # Ruby 1.8.x
RUN_EVENTLOOP_ON_MAIN_THREAD = false
@@ -1243,6 +1246,30 @@ module TkCore
Thread.current[:status] = status
#sleep
+ # like as 1.8, withdraw a root widget before calling Tk.mainloop
+ interp._eval <<EOS
+rename wm __wm_orig__
+proc wm {subcmd win args} {
+ eval [list __wm_orig__ $subcmd $win] $args
+ if {[string equal $subcmd withdraw] && [string equal $win .]} {
+ rename wm {}
+ rename __wm_orig__ wm
+ }
+}
+proc __startup_rbtk_mainloop__ {args} {
+ rename __startup_rbtk_mainloop__ {}
+ if {[info command __wm_orig__] == "__wm_orig__"} {
+ rename wm {}
+ rename __wm_orig__ wm
+ if [string equal [wm state .] withdrawn] {
+ wm deiconify .
+ }
+ }
+}
+set __initial_state_of_rubytk__ 1
+trace add variable __initial_state_of_rubytk__ unset __startup_rbtk_mainloop__
+EOS
+
begin
begin
#TclTkLib.mainloop_abort_on_exception = false
@@ -1808,6 +1835,9 @@ module TkCore
return TkCore::INTERP._thread_tkwait('window', '.') if check_root
end
+ # like as 1.8, withdraw a root widget before calling Tk.mainloop
+ TkCore::INTERP._eval_without_enc('unset __initail_state_of_rubytk__')
+
begin
TclTkLib.set_eventloop_window_mode(true)
if check_root
@@ -5663,7 +5693,7 @@ TkWidget = TkWindow
#Tk.freeze
module Tk
- RELEASE_DATE = '2010-02-01'.freeze
+ RELEASE_DATE = '2010-05-31'.freeze
autoload :AUTO_PATH, 'tk/variable'
autoload :TCL_PACKAGE_PATH, 'tk/variable'