Giter Club home page Giter Club logo

Comments (9)

kovidgoyal avatar kovidgoyal commented on June 25, 2024

There's no code in kitty to select monitors on which windows are opened.
Indeed neither monitors nor window positions are set by kitty, only
window sizes. That's up to the window manager/OS.

from kitty.

FelixKratz avatar FelixKratz commented on June 25, 2024

Interesting, it seems other applications with single instances are able to achieve the expected behavior (e.g. Finder). I am wondering if this may be related to something kitty is not doing, which it is expected by macOS and the WindowServer.

from kitty.

kovidgoyal avatar kovidgoyal commented on June 25, 2024

No idea, but patches welcome.

from kitty.

FelixKratz avatar FelixKratz commented on June 25, 2024

Will have a look, thanks for the input.

from kitty.

kovidgoyal avatar kovidgoyal commented on June 25, 2024

You will probably need to change initWithGlfwWindow method to pass [[NSApp keyWindow] screen] as the screen parameter to the call to initWithContentRect. The wrinkle is figuring out what contentRect should be, I dont recall if cocoa uses monitor local co-ords or a virtual space for these.

from kitty.

FelixKratz avatar FelixKratz commented on June 25, 2024

I am not sure detecting the screen of the key window is actually enough, since the command can be executed on a display where kitty is not the key window (e.g. by a shortcut manager), so the display ID of the currently active display would likely need to be determined by a more general function:

static CFStringRef display_active_display_uuid(void) {
  CFStringRef menubar = CGSCopyActiveMenuBarDisplayIdentifier(CGSMainConnectionID());
  return menubar;
}

uint32_t display_active_display_count(void) {
    uint32_t count;
    CGGetActiveDisplayList(0, NULL, &count);
    return count;
}

uint32_t display_active_display_id(void) {
    if (display_active_display_count() == 1) {
      uint32_t did = 0;
      uint32_t count = 0;
      CGGetActiveDisplayList(1, &did, &count);
      if (count == 1) return did;
      else {
        printf("ERROR (id): No active display detected!\n");
        return 0;
      }
    }

    CFStringRef uuid = display_active_display_uuid();
    CFUUIDRef uuid_ref = CFUUIDCreateFromString(NULL, uuid);
    uint32_t result = CGDisplayGetDisplayIDFromUUID(uuid_ref);
    CFRelease(uuid_ref);
    CFRelease(uuid);
    return result;
}

from kitty.

FelixKratz avatar FelixKratz commented on June 25, 2024

For reference: glfw/glfw#1699

from kitty.

kovidgoyal avatar kovidgoyal commented on June 25, 2024

Isn't the expected behavior on macOS that the active display is the one
which has focus? Is there some reference/documentation saying that picking the display
with the menubar on it is correct?

from kitty.

FelixKratz avatar FelixKratz commented on June 25, 2024

Actually, there seems to be some code in kitty that controls the position of the window, which needs to be disabled such that the window is automatically spawned on the correct display (see #6932)

from kitty.

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.