mirror of
https://github.com/duncs/clusterssh.git
synced 2025-07-03 18:03:23 +00:00
Take into account WM decorations when tiling
Not all window managers support this but they won't be any worse off than they are now.
This commit is contained in:
parent
c83e9e785f
commit
b7b7ca70ac
3 changed files with 47 additions and 2 deletions
1
Build.PL
1
Build.PL
|
@ -86,6 +86,7 @@ my $build = $class->new(
|
||||||
'version' => '0',
|
'version' => '0',
|
||||||
'Tk' => '800.022',
|
'Tk' => '800.022',
|
||||||
'X11::Protocol' => '0.56',
|
'X11::Protocol' => '0.56',
|
||||||
|
'X11::Protocol::WM' => '0',
|
||||||
'Locale::Maketext' => 0,
|
'Locale::Maketext' => 0,
|
||||||
'Exception::Class' => '1.31',
|
'Exception::Class' => '1.31',
|
||||||
'Try::Tiny' => 0,
|
'Try::Tiny' => 0,
|
||||||
|
|
|
@ -24,6 +24,7 @@ WriteMakefile
|
||||||
'Tk' => '800.022',
|
'Tk' => '800.022',
|
||||||
'Try::Tiny' => 0,
|
'Try::Tiny' => 0,
|
||||||
'X11::Protocol' => '0.56',
|
'X11::Protocol' => '0.56',
|
||||||
|
'X11::Protocol::WM' => 0,
|
||||||
'version' => '0'
|
'version' => '0'
|
||||||
},
|
},
|
||||||
'INSTALLDIRS' => 'site',
|
'INSTALLDIRS' => 'site',
|
||||||
|
|
|
@ -27,6 +27,7 @@ require Tk::Dialog;
|
||||||
require Tk::LabEntry;
|
require Tk::LabEntry;
|
||||||
use X11::Protocol;
|
use X11::Protocol;
|
||||||
use X11::Protocol::Constants qw/ Shift Mod5 ShiftMask /;
|
use X11::Protocol::Constants qw/ Shift Mod5 ShiftMask /;
|
||||||
|
use X11::Protocol::WM;
|
||||||
use vars qw/ %keysymtocode %keycodetosym /;
|
use vars qw/ %keysymtocode %keycodetosym /;
|
||||||
use X11::Keysyms '%keysymtocode', 'MISCELLANY', 'XKB_KEYS', '3270', 'LATIN1',
|
use X11::Keysyms '%keysymtocode', 'MISCELLANY', 'XKB_KEYS', '3270', 'LATIN1',
|
||||||
'LATIN2', 'LATIN3', 'LATIN4', 'KATAKANA', 'ARABIC', 'CYRILLIC', 'GREEK',
|
'LATIN2', 'LATIN3', 'LATIN4', 'KATAKANA', 'ARABIC', 'CYRILLIC', 'GREEK',
|
||||||
|
@ -887,6 +888,17 @@ sub show_console() {
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# set the first argument to the second if the first is undefined
|
||||||
|
# the equivalent of //= but works in older Perls (e.g. 5.8)
|
||||||
|
sub slash_slash_equal(\$$) {
|
||||||
|
|
||||||
|
if (! defined(${$_[0]})) {
|
||||||
|
${$_[0]} = $_[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ${$_[0]};
|
||||||
|
}
|
||||||
|
|
||||||
# leave function def open here so we can be flexible in how it's called
|
# leave function def open here so we can be flexible in how it's called
|
||||||
sub retile_hosts {
|
sub retile_hosts {
|
||||||
my ( $self, $force ) = @_;
|
my ( $self, $force ) = @_;
|
||||||
|
@ -986,6 +998,28 @@ sub retile_hosts {
|
||||||
|
|
||||||
$self->config->dump("noexit") if ( $self->options->debug > 1 );
|
$self->config->dump("noexit") if ( $self->options->debug > 1 );
|
||||||
|
|
||||||
|
# now find the size of the window decorations
|
||||||
|
if (! exists($self->config->{internal_terminal_wm_decoration_left})) {
|
||||||
|
|
||||||
|
# use the first window as exemplary
|
||||||
|
my($wid) = $servers{(keys(%servers))[0]}{wid};
|
||||||
|
|
||||||
|
if (defined($wid)) {
|
||||||
|
# get the WM decoration sizes
|
||||||
|
($self->config->{internal_terminal_wm_decoration_left},
|
||||||
|
$self->config->{internal_terminal_wm_decoration_right},
|
||||||
|
$self->config->{internal_terminal_wm_decoration_top},
|
||||||
|
$self->config->{internal_terminal_wm_decoration_bottom}) =
|
||||||
|
X11::Protocol::WM::get_net_frame_extents($xdisplay, $wid);
|
||||||
|
}
|
||||||
|
|
||||||
|
# in case the WM call failed we set some defaults
|
||||||
|
slash_slash_equal($self->config->{internal_terminal_wm_decoration_left}, 0);
|
||||||
|
slash_slash_equal($self->config->{internal_terminal_wm_decoration_right}, 0);
|
||||||
|
slash_slash_equal($self->config->{internal_terminal_wm_decoration_top}, 0);
|
||||||
|
slash_slash_equal($self->config->{internal_terminal_wm_decoration_bottom}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
# now we have the info, plot first window position
|
# now we have the info, plot first window position
|
||||||
my @hosts;
|
my @hosts;
|
||||||
my ( $current_x, $current_y, $current_row, $current_col ) = 0;
|
my ( $current_x, $current_y, $current_row, $current_col ) = 0;
|
||||||
|
@ -1049,14 +1083,18 @@ sub retile_hosts {
|
||||||
$current_x
|
$current_x
|
||||||
+= $self->config->{terminal_reserve_left}
|
+= $self->config->{terminal_reserve_left}
|
||||||
+ $self->config->{terminal_reserve_right}
|
+ $self->config->{terminal_reserve_right}
|
||||||
+ $self->config->{internal_terminal_width};
|
+ $self->config->{internal_terminal_width}
|
||||||
|
+ $self->config->{internal_terminal_wm_decoration_left}
|
||||||
|
+ $self->config->{internal_terminal_wm_decoration_right};
|
||||||
|
|
||||||
$current_col += 1;
|
$current_col += 1;
|
||||||
if ( $current_col == $self->config->{internal_columns} ) {
|
if ( $current_col == $self->config->{internal_columns} ) {
|
||||||
$current_y
|
$current_y
|
||||||
+= $self->config->{terminal_reserve_top}
|
+= $self->config->{terminal_reserve_top}
|
||||||
+ $self->config->{terminal_reserve_bottom}
|
+ $self->config->{terminal_reserve_bottom}
|
||||||
+ $self->config->{internal_terminal_height};
|
+ $self->config->{internal_terminal_height}
|
||||||
|
+ $self->config->{internal_terminal_wm_decoration_top}
|
||||||
|
+ $self->config->{internal_terminal_wm_decoration_bottom};
|
||||||
$current_x = $self->config->{screen_reserve_left}
|
$current_x = $self->config->{screen_reserve_left}
|
||||||
+ $self->config->{terminal_reserve_left};
|
+ $self->config->{terminal_reserve_left};
|
||||||
$current_row++;
|
$current_row++;
|
||||||
|
@ -2239,6 +2277,11 @@ the code until this time.
|
||||||
|
|
||||||
=item resolve_names
|
=item resolve_names
|
||||||
|
|
||||||
|
=item slash_slash_equal
|
||||||
|
|
||||||
|
An implementation of the //= operator that works on older Perls.
|
||||||
|
slash_slash_equal($a, 0) is equivalent to $a //= 0
|
||||||
|
|
||||||
=item retile_hosts
|
=item retile_hosts
|
||||||
|
|
||||||
=item run
|
=item run
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue