如何防止 Ubuntu Unity 中的窗口自动最大化?

如何防止 Ubuntu Unity 中的窗口自动最大化?

以下动画演示了如何无法阻止窗口在 Ubuntu 16.04 Unity 中打开时自动最大化。

GIF 动画

答案1

ComizConfig 设置管理器有一个“放置窗口”插件,您可以在其中配置新打开的窗口的放置位置。以下是我为 Google Chrome 放置位置设置的屏幕截图示例。

在此处输入图片描述

如果这不起作用,这里有替代解决方案。下面的脚本持续运行并阻止最大化焦点窗口。

#!/usr/bin/env python
#
#
# Author: Serg Kolo , contact: [email protected]
# Date: Oct 27, 2016
# Purpose: prevents x11 windows form maximizing
# Written for: http://askubuntu.com/q/842317/295286
# Tested on: Ubuntu 16.04 LTS
#
# Copyright: Serg Kolo , 2016
#
#     Permission to use, copy, modify, and distribute this software is hereby granted
#     without fee, provided that  the copyright notice above and this permission statement
#     appear in all copies.
#
#     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
#     THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
#     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
#     DEALINGS IN THE SOFTWARE.
from __future__ import print_function
import gi
gi.require_version('Gdk', '3.0')
from gi.repository import Gdk, Gio
import subprocess
import signal
import time


def run_cmd(cmdlist):
    """ reusable function for running shell commands"""
    try:
        stdout = subprocess.check_output(cmdlist)
    except subprocess.CalledProcessError:
        pass
    else:
        if stdout:
            return stdout


def main():
    """ defines entry point of the program """
    screen = Gdk.Screen.get_default()
    while True:
        active_window = screen.get_active_window()
        active_xid = str(active_window.get_xid())
        wm_state = run_cmd(
            ['xprop', '-root', '-notype', '-id', active_xid, '_NET_WM_STATE'])
        if ('_NET_WM_STATE_MAXIMIZED_VERT' in wm_state and
                '_NET_WM_STATE_MAXIMIZED_HORZ' in wm_state):
            active_window.unmaximize()
            active_window.process_all_updates()
        time.sleep(0.25)

if __name__ == "__main__":
    main()

相关内容