我正在尝试让 Guake 终端在 Unity 中正常工作。它的窗口宽度等于屏幕宽度。但是由于 Unity 左栏窗口的右边框变得不可见。所以,我想为窗口设置适当的宽度。它必须小于实际窗口大小。并且代码必须在有或没有 Unity 的情况下都能正常工作。
这就是 Guake 如何确定其窗口的位置和大小:
def get_final_window_rect(self):
"""Gets the final size of the main window of guake. The height
is the window_height property, width is window_width and the
horizontal alignment is given by window_alignment.
"""
screen = self.window.get_screen()
height = self.client.get_int(KEY('/general/window_height'))
width = 100
halignment = self.client.get_int(KEY('/general/window_halignment'))
# get the rectangle just from the first/default monitor in the
# future we might create a field to select which monitor you
# wanna use
window_rect = screen.get_monitor_geometry(0)
total_width = window_rect.width
window_rect.height = window_rect.height * height / 100
window_rect.width = window_rect.width * width / 100
if width < total_width:
if halignment == ALIGN_CENTER:
window_rect.x = (total_width - window_rect.width) / 2
elif halignment == ALIGN_LEFT:
window_rect.x = 0
elif halignment == ALIGN_RIGHT:
window_rect.x = total_width - window_rect.width
window_rect.y = 0
window_rect.width = 250
return window_rect