widget/gtk/nsIdleServiceGTK.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/gtk/nsIdleServiceGTK.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,52 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* vim:expandtab:shiftwidth=4:tabstop=4:
     1.6 + */
     1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
    1.10 +
    1.11 +#ifndef nsIdleServiceGTK_h__
    1.12 +#define nsIdleServiceGTK_h__
    1.13 +
    1.14 +#include "nsIdleService.h"
    1.15 +#include <X11/Xlib.h>
    1.16 +#include <X11/Xutil.h>
    1.17 +#include <gdk/gdkx.h>
    1.18 +
    1.19 +typedef struct {
    1.20 +    Window window;              // Screen saver window
    1.21 +    int state;                  // ScreenSaver(Off,On,Disabled)
    1.22 +    int kind;                   // ScreenSaver(Blanked,Internal,External)
    1.23 +    unsigned long til_or_since; // milliseconds since/til screensaver kicks in
    1.24 +    unsigned long idle;         // milliseconds idle
    1.25 +    unsigned long event_mask;   // event stuff
    1.26 +} XScreenSaverInfo;
    1.27 +
    1.28 +class nsIdleServiceGTK : public nsIdleService
    1.29 +{
    1.30 +public:
    1.31 +    NS_DECL_ISUPPORTS_INHERITED
    1.32 +
    1.33 +    bool PollIdleTime(uint32_t* aIdleTime);
    1.34 +
    1.35 +    static already_AddRefed<nsIdleServiceGTK> GetInstance()
    1.36 +    {
    1.37 +        nsRefPtr<nsIdleServiceGTK> idleService =
    1.38 +            nsIdleService::GetInstance().downcast<nsIdleServiceGTK>();
    1.39 +        if (!idleService) {
    1.40 +            idleService = new nsIdleServiceGTK();
    1.41 +        }
    1.42 +
    1.43 +        return idleService.forget();
    1.44 +    }
    1.45 +
    1.46 +private:
    1.47 +    ~nsIdleServiceGTK();
    1.48 +    XScreenSaverInfo* mXssInfo;
    1.49 +
    1.50 +protected:
    1.51 +    nsIdleServiceGTK();
    1.52 +    bool UsePollMode();
    1.53 +};
    1.54 +
    1.55 +#endif // nsIdleServiceGTK_h__

mercurial