deskflow/src/lib/platform/OSXScreenSaverUtil.m

69 lines
1.7 KiB
Mathematica
Raw Normal View History

2012-06-10 16:50:54 +00:00
/*
* Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2011 Nick Bolton
* SPDX-FileCopyrightText: (C) 2009 Sorin Sbarnea
* SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
2012-06-10 16:50:54 +00:00
*/
#import "platform/OSXScreenSaverUtil.h"
#import "platform/OSXScreenSaverControl.h"
2012-06-10 16:50:54 +00:00
#import <Foundation/NSAutoreleasePool.h>
//
// screenSaverUtil functions
//
// Note: these helper functions exist only so we can avoid using ObjC++.
// autoconf/automake don't know about ObjC++ and I don't know how to
// teach them about it.
//
2024-12-18 01:42:03 +00:00
void *screenSaverUtilCreatePool()
2012-06-10 16:50:54 +00:00
{
2024-12-18 01:42:03 +00:00
return [[NSAutoreleasePool alloc] init];
2012-06-10 16:50:54 +00:00
}
2024-12-18 01:42:03 +00:00
void screenSaverUtilReleasePool(void *pool)
2012-06-10 16:50:54 +00:00
{
2024-12-18 01:42:03 +00:00
[(NSAutoreleasePool *)pool release];
2012-06-10 16:50:54 +00:00
}
2024-12-18 01:42:03 +00:00
void *screenSaverUtilCreateController()
2012-06-10 16:50:54 +00:00
{
2024-12-18 01:42:03 +00:00
return [[ScreenSaverController controller] retain];
2012-06-10 16:50:54 +00:00
}
2024-12-18 01:42:03 +00:00
void screenSaverUtilReleaseController(void *controller)
2012-06-10 16:50:54 +00:00
{
2024-12-18 01:42:03 +00:00
[(ScreenSaverController *)controller release];
2012-06-10 16:50:54 +00:00
}
2024-12-18 01:42:03 +00:00
void screenSaverUtilEnable(void *controller)
2012-06-10 16:50:54 +00:00
{
2024-12-18 01:42:03 +00:00
[(ScreenSaverController *)controller setScreenSaverCanRun:YES];
2012-06-10 16:50:54 +00:00
}
2024-12-18 01:42:03 +00:00
void screenSaverUtilDisable(void *controller)
2012-06-10 16:50:54 +00:00
{
2024-12-18 01:42:03 +00:00
[(ScreenSaverController *)controller setScreenSaverCanRun:NO];
2012-06-10 16:50:54 +00:00
}
2024-12-18 01:42:03 +00:00
void screenSaverUtilActivate(void *controller)
2012-06-10 16:50:54 +00:00
{
2024-12-18 01:42:03 +00:00
[(ScreenSaverController *)controller setScreenSaverCanRun:YES];
[(ScreenSaverController *)controller screenSaverStartNow];
2012-06-10 16:50:54 +00:00
}
2024-12-18 01:42:03 +00:00
void screenSaverUtilDeactivate(void *controller, int isEnabled)
2012-06-10 16:50:54 +00:00
{
2024-12-18 01:42:03 +00:00
[(ScreenSaverController *)controller screenSaverStopNow];
[(ScreenSaverController *)controller setScreenSaverCanRun:isEnabled];
2012-06-10 16:50:54 +00:00
}
2024-12-18 01:42:03 +00:00
int screenSaverUtilIsActive(void *controller)
2012-06-10 16:50:54 +00:00
{
2024-12-18 01:42:03 +00:00
return [(ScreenSaverController *)controller screenSaverIsRunning];
2012-06-10 16:50:54 +00:00
}