Coder Social home page Coder Social logo

Comments (9)

crisidev avatar crisidev commented on May 27, 2024 1

Thanks for the explanation.. This makes sense. I could try to hack around and see if I can find a way to ensure the window id is acquired properly, but it's the first time I work with MacOS internals, so it will probably take a while 😄

from jankyborders.

FelixKratz avatar FelixKratz commented on May 27, 2024 1

Ill mark this as not planned for now, but feel free to experiment with the code and submit a PR if you find something that works.

from jankyborders.

crisidev avatar crisidev commented on May 27, 2024 1

To reduce a little the scope, I have found that the issue happens only with windows from the same application.

from jankyborders.

Timothee avatar Timothee commented on May 27, 2024 1

Lol, somehow missed you suggested that exact thing in your original post 🤦‍♂️ 😄

from jankyborders.

FelixKratz avatar FelixKratz commented on May 27, 2024 1

I have resolved the issue. See #66 (comment)

from jankyborders.

FelixKratz avatar FelixKratz commented on May 27, 2024

The assumption I made while building this tool is that a window which has focus is also ordered on top of the apps window list. This assumption is needed to acquire the window id of the active window without resorting to accessibility api. This heuristic works very well when no external tools modify the windows because it is rare (I never saw it happen actually) that a window is focused but not raised.

In principle this could be included with a more robust function that acquires the window id of the focused window (but without accessibility permissions) here:

JankyBorders/src/helpers.h

Lines 65 to 102 in 616b015

static inline uint32_t get_front_window(int cid) {
uint64_t active_sid = get_active_space_id(cid);
debug("Active space id: %d\n", active_sid);
CFArrayRef space_list_ref = cfarray_of_cfnumbers(&active_sid,
sizeof(uint64_t),
1,
kCFNumberSInt64Type);
ProcessSerialNumber psn;
_SLPSGetFrontProcess(&psn);
int target_cid;
SLSGetConnectionIDForPSN(cid, &psn, &target_cid);
uint64_t set_tags = 1;
uint64_t clear_tags = 0;
CFArrayRef window_list = SLSCopyWindowsWithOptionsAndTags(cid,
target_cid,
space_list_ref,
0x2,
&set_tags,
&clear_tags );
uint32_t wid = 0;
if (window_list) {
if (CFArrayGetCount(window_list) > 0) {
CFNumberRef wid_ref = (CFNumberRef)CFArrayGetValueAtIndex(window_list,
0 );
CFNumberGetValue(wid_ref, kCFNumberSInt32Type, &wid);
CFRelease(wid_ref);
} else {
debug("Empty window list\n");
}
CFRelease(window_list);
}
CFRelease(space_list_ref);
return wid;
}

from jankyborders.

Timothee avatar Timothee commented on May 27, 2024

@crisidev I had the same issue. I had focus_follows_mouse set to autofocus for yabai, and it seems that changing that to autoraise fixes the issue here.

from jankyborders.

crisidev avatar crisidev commented on May 27, 2024

Yeah, setting it to autoraise solves the issue, but I really do not like the autoraise behavior..

from jankyborders.

FelixKratz avatar FelixKratz commented on May 27, 2024

Lets track this issue here: #66.

from jankyborders.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.