# HG changeset patch # User sqwishy # Date 1521698833 25200 # Wed Mar 21 23:07:13 2018 -0700 # Node ID f93fe39d4dfe9ed73041aae10a4c4ebadfe13ac3 # Parent 7a40ffbfad168c5865de44ec093d25e192ad87e7 enhances window border feature thing and adds a widget for it diff --git a/winrustler/__main__.py b/winrustler/__main__.py --- a/winrustler/__main__.py +++ b/winrustler/__main__.py @@ -27,7 +27,7 @@ from winrustler.winapi import WindowDiscovery, search # Imported for their side effects ... -from winrustler import deborder, mover, fader +from winrustler import border, mover, fader def main(): diff --git a/winrustler/border.py b/winrustler/border.py new file mode 100644 --- /dev/null +++ b/winrustler/border.py @@ -0,0 +1,40 @@ +import argparse +import ctypes +from ctypes import wintypes + +import attr + +from winrustler.core import register_module +from winrustler.winconsts import * + +user32 = ctypes.windll.user32 + +def from_args(collection, args): + hwnd = collection.search(args.window) + return BorderWindow(hwnd) + + +@register_module() +@attr.s(frozen=True) +class BorderWindow(object): + hwnd = attr.ib() + have = attr.ib(default=False) + + @classmethod + def add_subparser(cls, subparsers): + parser = subparsers.add_parser('border') + parser.add_argument('--remove', action='store_false', dest='have') + return parser + + def run(self): + style = user32.GetWindowLongA(self.hwnd, GWL_STYLE) + if self.have: + style |= (WS_SIZEBOX | WS_CAPTION) + else: + style &= ~(WS_SIZEBOX | WS_CAPTION) + if 0 == user32.SetWindowLongA(self.hwnd, GWL_STYLE, style): + raise ctypes.WinError() + + def summarized(self): + what = "Add" if self.have else "Remove" + return "{} window border".format(what) diff --git a/winrustler/deborder.py b/winrustler/deborder.py deleted file mode 100644 --- a/winrustler/deborder.py +++ /dev/null @@ -1,31 +0,0 @@ -import argparse -import ctypes -from ctypes import wintypes - -import attr - -from winrustler.core import register_module -from winrustler.winconsts import * - -user32 = ctypes.windll.user32 - -def from_args(collection, args): - hwnd = collection.search(args.window) - return DeborderWindow(hwnd) - - -@register_module() -@attr.s(frozen=True) -class DeborderWindow(object): - hwnd = attr.ib() - - @classmethod - def add_subparser(cls, subparsers): - parser = subparsers.add_parser('deborder') - return parser - - def run(self): - style = user32.GetWindowLongA(self.hwnd, GWL_STYLE) - style &= ~(WS_SIZEBOX | WS_CAPTION) - if 0 == user32.SetWindowLongA(self.hwnd, GWL_STYLE, style): - raise ctypes.WinError() diff --git a/winrustler/ui/history.py b/winrustler/ui/history.py --- a/winrustler/ui/history.py +++ b/winrustler/ui/history.py @@ -43,9 +43,11 @@ from winrustler.fader import FadeWindow from winrustler.mover import MoveWindow +from winrustler.border import BorderWindow serialization = Serialization() serialization.know(FadeWindow, 'fade') serialization.know(MoveWindow, 'move') +serialization.know(BorderWindow, 'border') serialization.know(PastRustle, 'past') diff --git a/winrustler/ui/res/1f5bc.png b/winrustler/ui/res/1f5bc.png new file mode 100644 index 0000000000000000000000000000000000000000..c620748b09abdf9d1d9018363c194765bf9744d7 GIT binary patch literal 773 zc$@(R1N!`lP)C0002kP)t-s00010 zT3%^#cQZ3HQC3+;OHEQ)UQ16=|NsBLv!uhgs?Wx|LapM7xuC4Te$d8UeYdOU%18gs zF-ED`ORU>ZpvHx2RmzxkU8&58W=zwUZe5b9c%`>)frOo(ntXF;xSNE}$GVb-dcdZS z{?M$oj&S3wh4;y(pL$-~qI&zxsOY?!kZn@dn{xKWpxLjE@xGbFn|$fCjqk&t(x`~8 zhic%df$qDN`N^c=wv@b-cIL2&^TM5&b6D7(cFUrI>$j0#W@<9Z70L2gFfZ%{qxl$>YV1R0^ z{;gUS11QyhRYCx&^+;6!pcVzx!UIZmRVg^2tO4cVfQklG@BsWK!0&|k!w`QW!k>!& z{fkkfiM<@R+MO=$hD7EQivR_fAR=a-L;++zu?R4LDUw*41^{Hf#7Ynj(3qhpfM=V* z0D3;L5|{$?;ddXP4o6dfo=>avPXR2dmPp6C zu4iTLSca4bTD`K(9|P19&jB0_gb~panL75$O~_H#S-W8>_DYtZf>t z0cmS{r~e#au)DW!dKgLvhpUeR){c%BB{P6p5%&Rl(X9c}=Add or remove a window border.

", parent=self) + self._have = QCheckBox("Add a border, leave unchecked to eliminate it", self) + + self._layout = QFormLayout(self) + self._layout.addRow(self._description) + self._layout.addRow(self._have) + self.setLayout(self._layout) + + def window_request(self, hwnd): + return BorderWindow(hwnd, have=self._have.checkState()==Qt.Checked) diff --git a/winrustler/ui/widgets/rustlerwindow.py b/winrustler/ui/widgets/rustlerwindow.py --- a/winrustler/ui/widgets/rustlerwindow.py +++ b/winrustler/ui/widgets/rustlerwindow.py @@ -12,7 +12,7 @@ from winrustler.ui import icon from winrustler.ui.debug import show_exceptions from winrustler.ui.widgets.select import WindowSelect -from winrustler.ui.widgets.rustle import MoveControls, FadeControls +from winrustler.ui.widgets.rustle import MoveControls, FadeControls, BorderControls from winrustler.ui.widgets.match import MatchDialog from winrustler.ui.state import save_window_geometry, restore_window_geometry @@ -32,10 +32,12 @@ self._move = MoveControls(self) self._fade = FadeControls(self) + self._border = BorderControls(self) self._function_tab = QTabWidget(self) self._function_tab.addTab(self._move, icon('1f4d0.png'), "M&ove") self._function_tab.addTab(self._fade, icon('1f47b.png'), "&Fade") + self._function_tab.addTab(self._border, icon('1f5bc.png'), "&Border") self._bb = QDialogButtonBox(self) self._bb.accepted.connect(self.accept)