打开愿望而不偷窃焦点

时间:2015-07-07 12:39:31

标签: linux tcl x11 tk tclsh

我想在linux(kde,vnc)上打开一个Tcl / Tk对话框并输入一些信息:

  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <ListView
        android:id="@+id/list_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:scrollingCache="false"
        android:animationCache="false"
        android:smoothScrollbar="true"
        android:stretchMode="columnWidth">
    </ListView>


    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adSize="SMART_BANNER"
        android:layout_weight="0"
        ads:adUnitId="@string/ads_banner">
    </com.google.android.gms.ads.AdView>


</LinearLayout>

执行此操作后,对话框将打开,新对话框将成为焦点。

我该如何防止这种情况?

package require Tk
toplevel .my
pack [label .my.l -text "hallo"]

我看到了几个关于类似主题的问题,但没有关于Tcl / Tk的问题。

2 个答案:

答案 0 :(得分:0)

这高度依赖于窗口管理器。 对于metacity和marco,有一个名为“焦点 - 新窗口”的设置。可以更改为严格&#39;

与marco窗口管理员交配:

gsettings set org.mate.Marco.general focus-new-windows strict

我不使用KDE,但您可以尝试:   系统设置 - &gt;窗口行为 - &gt;焦点 并查看那里的设置是否有帮助。

Compiz在常规选项中具有焦点预防设置 - &gt;焦点。

答案 1 :(得分:0)

这是我的解决方案:

 1  package require Tk

 2  proc leave {w e} {
 3      puts "gui left $w $e ..."
 4      if {$e != $w}  return
 5      focusHandler::restore

 6  }

 7  proc press {w} {
 8      puts "press $w"
 9      focusHandler::save
10      bind $w <Leave> focusHandler::restore
11      wm overrideredirect  [winfo toplevel $w] 0
12      raise  $w
13      focus -force $w
14      wm overrideredirect  [winfo toplevel $w] 1

15  }

16  namespace eval focusHandler {
17      variable helper
18  }
19  proc focusHandler::save {} {
20      variable helper
21      if ![info exists helper] {
22          puts "create helper"
23          set helper .xxx[clock clicks]
24          # create a new toplevel window
25          # this is controlled by the window manager
26          toplevel $helper
27          wm geometry $helper 0x0-1-1
28      }
29      puts "set focus of helper $helper"
30      raise $helper
31      update 
32      after 100
33  }
34  proc focusHandler::restore {} {
35      variable helper
36      if ![info exists helper] return
37      # destroy this toplevel and windows manager focus on the last know window
38      # which is not this gui, because of overrideredirect
39      destroy $helper
40      unset helper
41  }

42  wm withdraw .
43  toplevel .my
44  wm overrideredirect  .my 1
45  text .my.text  -height 10 -width 40
46  button .my.exit -command exit -text exit
47  bind .my.text <ButtonPress-1> [list press %W]
48  pack .my.text
49  pack .my.exit
相关问题