Last active
June 7, 2025 00:28
-
-
Save t0rr3sp3dr0/331086dcb271cb4f98f18cf7fb282736 to your computer and use it in GitHub Desktop.
clang -framework CoreGraphics ./AlignTwoDisplaysHorizontally.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <CoreGraphics/CoreGraphics.h> | |
int main() { | |
CGDirectDisplayID displays[2]; | |
CGGetOnlineDisplayList(2, displays, NULL); | |
CGDirectDisplayID st; | |
CGDirectDisplayID nd; | |
if (CGDisplayIsMain(displays[0])) { | |
st = displays[0]; | |
nd = displays[1]; | |
} else { | |
st = displays[1]; | |
nd = displays[0]; | |
} | |
CGDisplayConfigRef configRef; | |
CGBeginDisplayConfiguration(&configRef); | |
CGConfigureDisplayOrigin(configRef, st, 0, 0); | |
CGConfigureDisplayOrigin(configRef, nd, (CGDisplayBounds(st).size.width - CGDisplayBounds(nd).size.width) / 2, CGDisplayBounds(st).size.height); | |
CGCompleteDisplayConfiguration(configRef, kCGConfigurePermanently); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment