mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-31 22:25:30 +00:00
e368dc9c85
This patch was generated by a script. Here's the source of the script for future reference: function convert() { echo "Converting $1 to $2..." find . ! -wholename "*nsprpub*" \ ! -wholename "*security/nss*" \ ! -wholename "*/.hg*" \ ! -wholename "obj-ff-dbg*" \ ! -name nsXPCOMCID.h \ ! -name prtypes.h \ -type f \ \( -iname "*.cpp" \ -o -iname "*.h" \ -o -iname "*.c" \ -o -iname "*.cc" \ -o -iname "*.idl" \ -o -iname "*.ipdl" \ -o -iname "*.ipdlh" \ -o -iname "*.mm" \) | \ xargs -n 1 sed -i -e "s/\b$1\b/$2/g" } convert PRInt8 int8_t convert PRUint8 uint8_t convert PRInt16 int16_t convert PRUint16 uint16_t convert PRInt32 int32_t convert PRUint32 uint32_t convert PRInt64 int64_t convert PRUint64 uint64_t convert PRIntn int convert PRUintn unsigned convert PRSize size_t convert PROffset32 int32_t convert PROffset64 int64_t convert PRPtrdiff ptrdiff_t convert PRFloat64 double
124 lines
3.3 KiB
C++
124 lines
3.3 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/* vim:expandtab:shiftwidth=4:tabstop=4:
|
|
*/
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifdef MOZ_X11
|
|
#include "mozilla/X11Util.h"
|
|
#endif
|
|
#include "nsIdleServiceQt.h"
|
|
#include "nsIServiceManager.h"
|
|
#include "nsDebug.h"
|
|
#include "prlink.h"
|
|
|
|
#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
|
|
typedef bool (*_XScreenSaverQueryExtension_fn)(Display* dpy, int* event_base,
|
|
int* error_base);
|
|
|
|
typedef XScreenSaverInfo* (*_XScreenSaverAllocInfo_fn)(void);
|
|
|
|
typedef void (*_XScreenSaverQueryInfo_fn)(Display* dpy, Drawable drw,
|
|
XScreenSaverInfo *info);
|
|
|
|
static _XScreenSaverQueryExtension_fn _XSSQueryExtension = nullptr;
|
|
static _XScreenSaverAllocInfo_fn _XSSAllocInfo = nullptr;
|
|
static _XScreenSaverQueryInfo_fn _XSSQueryInfo = nullptr;
|
|
#endif
|
|
|
|
static bool sInitialized = false;
|
|
|
|
NS_IMPL_ISUPPORTS_INHERITED0(nsIdleServiceQt, nsIdleService)
|
|
|
|
nsIdleServiceQt::nsIdleServiceQt()
|
|
#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
|
|
: mXssInfo(nullptr)
|
|
#endif
|
|
{
|
|
}
|
|
|
|
static void Initialize()
|
|
{
|
|
sInitialized = true;
|
|
|
|
#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
|
|
// This will leak - See comments in ~nsIdleServiceQt().
|
|
PRLibrary* xsslib = PR_LoadLibrary("libXss.so.1");
|
|
if (!xsslib) {
|
|
return;
|
|
}
|
|
|
|
_XSSQueryExtension = (_XScreenSaverQueryExtension_fn)
|
|
PR_FindFunctionSymbol(xsslib, "XScreenSaverQueryExtension");
|
|
_XSSAllocInfo = (_XScreenSaverAllocInfo_fn)
|
|
PR_FindFunctionSymbol(xsslib, "XScreenSaverAllocInfo");
|
|
_XSSQueryInfo = (_XScreenSaverQueryInfo_fn)
|
|
PR_FindFunctionSymbol(xsslib, "XScreenSaverQueryInfo");
|
|
#endif
|
|
}
|
|
|
|
nsIdleServiceQt::~nsIdleServiceQt()
|
|
{
|
|
#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
|
|
if (mXssInfo)
|
|
XFree(mXssInfo);
|
|
|
|
// It is not safe to unload libXScrnSaver until each display is closed because
|
|
// the library registers callbacks through XESetCloseDisplay (Bug 397607).
|
|
// (Also the library and its functions are scoped for the file not the object.)
|
|
#if 0
|
|
if (xsslib) {
|
|
PR_UnloadLibrary(xsslib);
|
|
xsslib = nullptr;
|
|
}
|
|
#endif
|
|
#endif
|
|
}
|
|
|
|
bool
|
|
nsIdleServiceQt::PollIdleTime(uint32_t *aIdleTime)
|
|
{
|
|
#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
|
|
// Ask xscreensaver about idle time:
|
|
*aIdleTime = 0;
|
|
|
|
// We might not have a display (cf. in xpcshell)
|
|
Display *dplay = mozilla::DefaultXDisplay();
|
|
if (!dplay) {
|
|
return false;
|
|
}
|
|
|
|
if (!sInitialized) {
|
|
Initialize();
|
|
}
|
|
if (!_XSSQueryExtension || !_XSSAllocInfo || !_XSSQueryInfo) {
|
|
return false;
|
|
}
|
|
|
|
int event_base, error_base;
|
|
if (_XSSQueryExtension(dplay, &event_base, &error_base)) {
|
|
if (!mXssInfo)
|
|
mXssInfo = _XSSAllocInfo();
|
|
if (!mXssInfo)
|
|
return false;
|
|
|
|
_XSSQueryInfo(dplay, RootWindowOfScreen(DefaultScreenOfDisplay(mozilla::DefaultXDisplay())), mXssInfo);
|
|
*aIdleTime = mXssInfo->idle;
|
|
return true;
|
|
}
|
|
#endif
|
|
|
|
return false;
|
|
}
|
|
|
|
bool
|
|
nsIdleServiceQt::UsePollMode()
|
|
{
|
|
#if !defined(MOZ_PLATFORM_MAEMO) && defined(MOZ_X11)
|
|
return false;
|
|
#endif
|
|
return true;
|
|
}
|
|
|