mirror of
https://github.com/python/cpython.git
synced 2026-07-26 20:03:16 -04:00
[3.15] gh-66331: Set correct WM_CLASS on X11 for IDLE windows (GH-152733) (#152794)
gh-66331: Set correct WM_CLASS on X11 for IDLE windows (GH-152733)
Set the WM_CLASS of IDLE's long-lived windows (window-list windows and
the stack viewers) to "Idle" instead of the default "Toplevel", so that
window managers group and label them correctly.
(cherry picked from commit 4e16b8d4ee)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
committed by
GitHub
parent
63da6c86eb
commit
f7c26ed02f
@@ -35,6 +35,8 @@ class StackBrowserTest(unittest.TestCase):
|
||||
isi(stackviewer.sc, ScrolledCanvas)
|
||||
isi(stackviewer.item, stackviewer.StackTreeItem)
|
||||
isi(stackviewer.node, TreeNode)
|
||||
top = stackviewer.sc.frame.winfo_toplevel()
|
||||
self.assertEqual(top.winfo_class(), 'Idle')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -39,6 +39,11 @@ class ListedToplevelTest(unittest.TestCase):
|
||||
win = window.ListedToplevel(self.root)
|
||||
self.assertIn(win, window.registry)
|
||||
self.assertEqual(win.focused_widget, win)
|
||||
self.assertEqual(win.winfo_class(), 'Idle')
|
||||
|
||||
def test_init_class_override(self):
|
||||
win = window.ListedToplevel(self.root, class_='Other')
|
||||
self.assertEqual(win.winfo_class(), 'Other')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -644,7 +644,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
|
||||
return
|
||||
item = debugobj_r.StubObjectTreeItem(self.rpcclt, oid)
|
||||
from idlelib.tree import ScrolledCanvas, TreeNode
|
||||
top = Toplevel(self.tkconsole.root)
|
||||
top = Toplevel(self.tkconsole.root, class_='Idle')
|
||||
theme = idleConf.CurrentTheme()
|
||||
background = idleConf.GetHighlight(theme, 'normal')['background']
|
||||
sc = ScrolledCanvas(top, bg=background, highlightthickness=0)
|
||||
|
||||
@@ -11,7 +11,7 @@ from idlelib.tree import TreeNode, TreeItem, ScrolledCanvas
|
||||
def StackBrowser(root, exc, flist=None, top=None):
|
||||
global sc, item, node # For testing.
|
||||
if top is None:
|
||||
top = tk.Toplevel(root)
|
||||
top = tk.Toplevel(root, class_='Idle')
|
||||
sc = ScrolledCanvas(top, bg="white", highlightthickness=0)
|
||||
sc.frame.pack(expand=1, fill="both")
|
||||
item = StackTreeItem(exc, flist)
|
||||
|
||||
@@ -61,6 +61,10 @@ unregister_callback = registry.unregister_callback
|
||||
class ListedToplevel(Toplevel):
|
||||
|
||||
def __init__(self, master, **kw):
|
||||
# Set the WM_CLASS property so that X11 window managers group and
|
||||
# label IDLE's windows under 'Idle' instead of the default
|
||||
# 'Toplevel' (gh-66331). It matches the class name passed to Tk().
|
||||
kw.setdefault('class_', 'Idle')
|
||||
Toplevel.__init__(self, master, kw)
|
||||
registry.add(self)
|
||||
self.focused_widget = self
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
Set the ``WM_CLASS`` window property of IDLE's windows to ``Idle`` on X11,
|
||||
so that window managers group and label them correctly instead of using the
|
||||
default ``Toplevel``.
|
||||
Reference in New Issue
Block a user