Last active
January 26, 2019 06:11
-
-
Save shellexy/620a58124e6d524234275ec1bd9c3c09 to your computer and use it in GitHub Desktop.
临时修复 telegram desktop 点开图片查看时没法真全屏的问题
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
'''临时修复 telegram desktop 点开图片查看时没法真全屏的问题 | |
现在 telegram desktop 在 ubuntu unity 下点开消息里的图片,会正常全屏显示图片, | |
但是在 gnome shell 下会被 gnome 顶栏把“全屏图片”挤下去,让图片底部和左下角文字信息挤到屏幕外看不到, | |
在 kde 下则图片底部和左下角文字信息会被任务栏遮挡,同样看不全画面。 | |
fc 教授说:“现在 的 行 为 是 tg 创建 了 一个 屏幕 大小 的 窗口 , | |
但是 位置 不一定 在 左上角 , 然后 就有 一部分 东西 在 屏幕 外面” | |
fc 教授写了个补丁 https://fars.ee/9TKO.patch 修复这个问题并 pr 了 telegram 官方, | |
在官方修复前可以先用本程序来临时修复。 | |
用法: | |
将本文件保存为 ~/bin/fix_telegram_desktop_media_viewer.py | |
然后执行 python3 ~/bin/fix_telegram_desktop_media_viewer.py | |
或者再在自启动里添加一条 python3 ~/bin/fix_telegram_desktop_media_viewer.py 命令 | |
然后在 telegram desktop 里点开图片就会发现自动全屏显示了。 | |
''' | |
import gi | |
gi.require_version('Gtk', '3.0') | |
gi.require_version('Wnck', '3.0') | |
from gi.repository import Gtk, GLib, GObject, Gdk, GdkX11, Wnck | |
def fullscreen(xid): | |
'''让 xid 的窗口全屏 | |
''' | |
print('fullscreen window: xid=', xid) | |
xw = GdkX11.X11Window.foreign_new_for_display(GdkX11.X11Display.get_default(), xid) | |
xw.fullscreen() | |
pass | |
def watch_window_opened(screen=None): | |
'''监视新打开的窗口,处理 telegram 的 Media viewer 窗口 | |
''' | |
screen = screen or Wnck.Screen.get_default() | |
def on_window_opened(screen, window): | |
if window.get_name() == 'Media viewer' and window.get_class_group_name() == 'TelegramDesktop': | |
print('window opened: xid=%s, name=%s, class_group=%s' % | |
(window.get_xid(), window.get_name(), window.get_class_group_name())) | |
GObject.timeout_add(100, fullscreen, window.get_xid()) | |
pass | |
pass | |
screen.connect_after('window-opened', on_window_opened) | |
pass | |
def main(): | |
'''开始处理 | |
''' | |
watch_window_opened() | |
Gtk.main() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment