mirror of
https://github.com/darlinghq/darling-iokitd.git
synced 2024-11-23 04:29:40 +00:00
Implement PowerAssertions for X11 displays
This commit is contained in:
parent
a102eaf152
commit
06d3e5898f
@ -48,7 +48,7 @@ set(iokitd_sources
|
||||
)
|
||||
|
||||
add_darling_executable(iokitd ${iokitd_sources})
|
||||
target_link_libraries(iokitd cxx CoreFoundation Foundation X11 XRandR)
|
||||
target_link_libraries(iokitd cxx CoreFoundation Foundation X11 XRandR Xext)
|
||||
|
||||
install(TARGETS iokitd DESTINATION libexec/darling/usr/sbin)
|
||||
install(FILES org.darlinghq.iokitd.plist DESTINATION libexec/darling/System/Library/LaunchDaemons)
|
||||
|
@ -11,10 +11,14 @@ class IODisplayConnectX11 : IODisplayConnect
|
||||
{
|
||||
private:
|
||||
IODisplayConnectX11(int index, NSDictionary* props);
|
||||
|
||||
public:
|
||||
~IODisplayConnectX11();
|
||||
static void discoverDevices(ServiceRegistry* targetRegistry);
|
||||
NSDictionary* getProperties() override;
|
||||
|
||||
// TODO: Make the whole display server abstraction nicer?
|
||||
static Display* getDisplay() { return m_display; }
|
||||
private:
|
||||
static Display* m_display;
|
||||
// Index of the corresponding XrandR output
|
||||
|
@ -165,7 +165,7 @@ kern_return_t _io_pm_assertion_create
|
||||
pid_t callerPid;
|
||||
audit_token_to_au32(token, nullptr, nullptr, nullptr, nullptr, nullptr, &callerPid, nullptr, nullptr);
|
||||
|
||||
std::cout << "Creating assertion for PID " << callerPid << std::endl;
|
||||
// std::cout << "Creating assertion for PID " << callerPid << std::endl;
|
||||
*assertion_id = AppAssertions::get(callerPid)->createAssertion(pa);
|
||||
*return_code = 0;
|
||||
|
||||
|
@ -1,12 +1,34 @@
|
||||
#include "PowerAssertionsX11.h"
|
||||
#include "IODisplayConnectX11.h"
|
||||
#include <iostream>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#define BOOL BOOL_THOU_SHALT_NOT_TYPEDEF_BOOL_IN_UNIMPORTANT_HEADERS
|
||||
#include <X11/extensions/dpms.h>
|
||||
#undef BOOL
|
||||
|
||||
void PowerAssertionPreventDisplaySleep::activate()
|
||||
{
|
||||
std::cout << "STUB: PowerAssertionPreventDisplaySleep::activate()\n";
|
||||
Display* display = IODisplayConnectX11::getDisplay();
|
||||
if (!display)
|
||||
return;
|
||||
|
||||
int eventBase, errorBase;
|
||||
if (DPMSQueryExtension(display, &eventBase, &errorBase))
|
||||
{
|
||||
DPMSDisable(display);
|
||||
}
|
||||
}
|
||||
|
||||
void PowerAssertionPreventDisplaySleep::deactivate()
|
||||
{
|
||||
std::cout << "STUB: PowerAssertionPreventDisplaySleep::deactivate()\n";
|
||||
Display* display = IODisplayConnectX11::getDisplay();
|
||||
if (!display)
|
||||
return;
|
||||
|
||||
int eventBase, errorBase;
|
||||
if (DPMSQueryExtension(display, &eventBase, &errorBase))
|
||||
{
|
||||
DPMSEnable(display);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user