deskflow/src/lib/platform/OSXScreenSaverUtil.m

75 lines
2 KiB
Mathematica
Raw Normal View History

2012-06-10 16:50:54 +00:00
/*
* Deskflow -- mouse and keyboard sharing utility
2012-06-10 16:50:54 +00:00
* Copyright (C) 2004 Chris Schoeneman, Nick Bolton, Sorin Sbarnea
2024-12-18 01:42:03 +00:00
*
2012-06-10 16:50:54 +00:00
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
2024-12-18 01:42:03 +00:00
*
2012-06-10 16:50:54 +00:00
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#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
}