Tile linkage can be broken if the tiles are resized so that their height/width no longer are equal along the seam, or if they are not adjacent (seam gap). I will post some window activation code that may help as a substitute, basically the code activates a window relative to the currently active window in 8 directions, up,down,left,right and diagonals. Adjust the key bindings to your liking before loading the module. Note: This code is guaranteed to not work perfectly in all cases
How it works: Using the center of the active window as a starting point, points are queried in the direction given to find a window that has a portion showing. The step of the query is given a granularity of 150 pixels -- this means it may miss windows showing only a small part of themselves (which is by design for coding expediency sake). The upshot of it all is that the code will work as expected so long as your window layout is reasonably tidy, otherwise it may activate something you do not expect.
Also, the diagonal search is not on 45 degrees, but takes its angle from the shape of the active window -- this means the search for a bottom-right window for example is going to follow a line from the center of the active window to its bottom-right corner.
CORRECTION: It does not filter for the state of the window (oops), so minimized windows are candidates also according to their restored size. Correction has been posted in winact_wins, I think this works now to ignore windows that are not p_window_state='restored'.
#pragma option(strict2,on)
#pragma option(strictprotos,on)
#include "slick.sh"
defeventtab default_keys;
def '`' 'DOWN'= winact_d;
def '`' 'UP'= winact_u;
def '`' 'RIGHT'= winact_r;
def '`' 'LEFT'= winact_l;
def '`' 'HOME'= winact_ul;
def '`' 'END'= winact_dl;
def '`' 'PGUP'= winact_ur;
def '`' 'PGDN'= winact_dr;
definit(){
//The definit module is called before defload
//the definit procedure is invoked each time the editor is invoked
if (arg(1)!="L") {
// This is an editor invocation
}
}
defload(){
}
_command void winact_test() name_info(','){
int i=winact_pane_get('r');
//Msg(i);
if (i!=0) {
activate_window(i);
_set_focus();
}
}
_command int winact_dir(_str udlr=''){
if (udlr=='') {
return 1;
}
int i=winact_pane_get(udlr);
if (i!=0) {
activate_window(i);
_set_focus();
return 0;
}
return 1;
}
_command int winact_r(){
return winact_dir('r');
}
_command int winact_l(){
return winact_dir('l');
}
_command int winact_u(){
return winact_dir('u');
}
_command int winact_d(){
return winact_dir('d');
}
_command int winact_ur(){
return winact_dir('ur');
}
_command int winact_ul(){
return winact_dir('ul');
}
_command int winact_dr(){
return winact_dir('dr');
}
_command int winact_dl(){
return winact_dir('dl');
}
static int winact_pane_get(_str udlr,int gran=150){
// was winp_pane_get
//winact_win_list();
typeless a=winact_wins();
if (a._length()<2) {
//Msg('ok');
return 0;
}
if (0) {
int cx,cy,cw,ch;
_MDIChildGetWindow(cx,cy,cw,ch);
say('x:'(cx));
say('x+w:'(cx+cw));
//_MDIChildSetWindow(cx+cw,cy,cw,ch);
//return 0;
}
double xi=0.0;
double yi=0;
if (pos('u',udlr)) {yi=-1;}
if (pos('d',udlr)) {yi=1;}
if (pos('l',udlr)) {xi=-1;}
if (pos('r',udlr)) {xi=1;}
//say('A xi:'xi' yi:'yi);
int x_,y_;
winact_child_center(x_,y_);
int wid=p_window_id;
double w_w=(wid.p_window_state=='I')?wid.p_old_width:wid.p_width;
double w_h=(wid.p_window_state=='I')?wid.p_old_height:wid.p_height;
int nid=wid;
xi=xi*gran;
//say('xi:'xi' yi:'yi);
yi=yi*gran;
yi=yi*(w_h/w_w);
yi=yi intdiv 1;
//say('xi:'xi' yi:'yi);
int z=0;
int y=y_;
int x=x_;
//msg_2(gran);
int xyh=0;
//p_client_width
//p_client_height
int mx,my,mx2,my2;
mx=0;my=0;
mx2=_mdi.p_client_width;
my2=_mdi.p_client_height;
//winp_mdi_screen_pos(mx,my,mx2,my2);
int zzz=0;
while (1) {
x+=(1*xi);
y+=(1*yi);
z++;
if (z>1000) {
//say('z>100');
//Msg('>1000');
int x1;
for (x1=0;x1<a._length();x1++) {
int ii=a[x1];
if (ii!=wid) {
return ii;
}
}
return 0;
}
//gdi_rop_rect_on_desk(x,y,x+10,y+10);
//gdi_focus_rects_on_desk_zoom(x,y,x+20,y+20,.04,2,1);
//say('x:'x' y:'y);
nid=winact_first_child_with_xy(x,y);
if (nid!=0) {
break;
}
if (x<mx||x>mx2) {
xi=xi*-1;
xyh++;
if (xyh>2) {
yi=yi+10;
xyh=0;
}
}
if (y<my||y>my2) {
yi=yi*-1;
xyh++;
if (xyh>2) {
xi=xi+10;
xyh=0;
}
}
if (z>200) {
//break;
}
}
if (nid==0) {
if (gran>4) {
winact_pane_get(udlr,(gran intdiv 2));
}
}
//Msg('nid:'nid);
return(nid);
}
static typeless winact_wins(){
typeless a[];
int first_window_id=p_window_id;
if (p_window_id==0) {
return a;
}
a[a._length()]=p_window_id;
int view_id=0;
get_window_id(view_id);
for (;;) {
_next_window('HR');
if ( p_window_id==first_window_id ) {
return a;
}
//Corrected code to deal with only restored windows
if (p_window_id.p_window_state=='N') {
a[a._length()]=p_window_id;
}
}
return a;
}
static winact_win_list(){
int wid=p_window_id;
typeless a=winact_wins();
int x;
for (x=0;x<a._length();x++) {
//int view_id=wid.p_view_id;
//int buf_id=view_id.p_buf_id;
activate_window(a[x]);
say(p_buf_name);
}
activate_window(wid);
}
static int winact_first_child_with_xy(int x_,int y_){
int wid=p_window_id;
typeless a=winact_wins();
int rv=0;
int x;
for (x=1;x<a._length()-1;x++) {
if (winact_win_has_xy(a[x],x_, y_)) {
if (!winact_win_has_xy(a[0],x_, y_)) {
return a[x];
}
}
}
return rv;
}
static void winact_say_bufname(int w,_str pfx=''){
int wid=p_window_id;
activate_window(w);
say(pfx p_buf_name);
activate_window(wid);
}
static boolean winact_win_has_xy(int w_,int x_,int y_){
int wid=p_window_id;
activate_window(w_);
int w=w_;
int cx,cy,cw,ch;
_MDIChildGetWindow(cx,cy,cw,ch);
activate_window(wid);
if (cx<x_&&(cx+cw)>x_&&
cy<y_&&(cy+ch)>y_
) {
return true;
}
return false;
}
static void winact_child_center(int &x_,int &y_){
int t_,r_,l_,b_;
winact_child_trlb(t_,r_,l_,b_);
x_=l_+((r_-l_)intdiv 2);
y_=t_+((b_-t_)intdiv 2);
}
static void winact_child_trlb(int &t_,int &r_,int &l_,int &b_){
int cx,cy,cw,ch;
_MDIChildGetWindow(cx,cy,cw,ch);
int x=cx;
int y=cy;
int ww=cw;
int hh=ch;
t_=y;
l_=x;
r_=x+ww;
b_=y+hh;
}