summaryrefslogtreecommitdiffstats
path: root/x11vnc/pm.c
diff options
context:
space:
mode:
authorrunge <runge>2006-11-21 22:16:23 +0000
committerrunge <runge>2006-11-21 22:16:23 +0000
commit27a884d2f3775cf4d97ea8f3d7433cbe2deebbfc (patch)
treea4b7c9f0ae519b0afa0d14b646abca3ad01b35a8 /x11vnc/pm.c
parent05ba45f72e70b4372ef05a8aca34a3bddcfaeb71 (diff)
downloadlibtdevnc-27a884d2f3775cf4d97ea8f3d7433cbe2deebbfc.tar.gz
libtdevnc-27a884d2f3775cf4d97ea8f3d7433cbe2deebbfc.zip
x11vnc: Mac OS X fb fixes and cuttext, -nodpms option, local user wireframing
Diffstat (limited to 'x11vnc/pm.c')
-rw-r--r--x11vnc/pm.c96
1 files changed, 94 insertions, 2 deletions
diff --git a/x11vnc/pm.c b/x11vnc/pm.c
index 8ee0ebd..cb13ab1 100644
--- a/x11vnc/pm.c
+++ b/x11vnc/pm.c
@@ -4,14 +4,20 @@
void check_pm(void);
static void check_fbpm(void);
+static void check_dpms(void);
#if LIBVNCSERVER_HAVE_FBPM
#include <X11/Xmd.h>
#include <X11/extensions/fbpm.h>
#endif
+#if LIBVNCSERVER_HAVE_DPMS
+#include <X11/extensions/dpms.h>
+#endif
+
void check_pm(void) {
check_fbpm();
+ check_dpms();
/* someday dpms activities? */
}
@@ -20,7 +26,7 @@ static void check_fbpm(void) {
#if LIBVNCSERVER_HAVE_FBPM
static int fbpm_capable = 0;
static time_t last_fbpm = 0;
- int db = 1;
+ int db = 0;
CARD16 level;
BOOL enabled;
@@ -28,12 +34,15 @@ static void check_fbpm(void) {
RAWFB_RET_VOID
if (! init_fbpm) {
+ if (getenv("FBPM_DEBUG")) {
+ db = atoi(getenv("FBPM_DEBUG"));
+ }
if (FBPMCapable(dpy)) {
fbpm_capable = 1;
rfbLog("X display is capable of FBPM.\n");
if (watch_fbpm) {
rfbLog("Preventing low-power FBPM modes when"
- " VNC clients are connected.\n");
+ " clients are connected.\n");
}
} else {
if (! raw_fb_str) {
@@ -95,3 +104,86 @@ static void check_fbpm(void) {
#endif
}
+static void check_dpms(void) {
+ static int init_dpms = 0;
+#if LIBVNCSERVER_HAVE_DPMS
+ static int dpms_capable = 0;
+ static time_t last_dpms = 0;
+ int db = 0;
+
+ CARD16 level;
+ BOOL enabled;
+
+ RAWFB_RET_VOID
+
+ if (! init_dpms) {
+ if (getenv("DPMS_DEBUG")) {
+ db = atoi(getenv("DPMS_DEBUG"));
+ }
+ if (DPMSCapable(dpy)) {
+ dpms_capable = 1;
+ rfbLog("X display is capable of DPMS.\n");
+ if (watch_dpms) {
+ rfbLog("Preventing low-power DPMS modes when"
+ " clients are connected.\n");
+ }
+ } else {
+ if (! raw_fb_str) {
+ rfbLog("X display is not capable of DPMS.\n");
+ }
+ dpms_capable = 0;
+ }
+ init_dpms = 1;
+ }
+
+ if (! watch_dpms) {
+ return;
+ }
+ if (! dpms_capable) {
+ return;
+ }
+ if (! client_count) {
+ return;
+ }
+ if (time(NULL) < last_dpms + 5) {
+ return;
+ }
+ last_dpms = time(NULL);
+
+ if (DPMSInfo(dpy, &level, &enabled)) {
+ if (db) fprintf(stderr, "DPMSInfo level: %d enabled: %d\n", level, enabled);
+
+ if (enabled && level != DPMSModeOn) {
+ char *from = "unknown-dpms-state";
+ XErrorHandler old_handler = XSetErrorHandler(trap_xerror);
+ trapped_xerror = 0;
+
+ if (level == DPMSModeStandby) {
+ from = "DPMSModeStandby";
+ } else if (level == DPMSModeSuspend) {
+ from = "DPMSModeSuspend";
+ } else if (level == DPMSModeOff) {
+ from = "DPMSModeOff";
+ }
+
+ rfbLog("switching DPMS state from %s to DPMSModeOn\n", from);
+
+ DPMSForceLevel(dpy, DPMSModeOn);
+
+ XSetErrorHandler(old_handler);
+ trapped_xerror = 0;
+ }
+ } else {
+ if (db) fprintf(stderr, "DPMSInfo failed.\n");
+ }
+#else
+ RAWFB_RET_VOID
+ if (! init_dpms) {
+ if (! raw_fb_str) {
+ rfbLog("X DPMS extension not supported.\n");
+ }
+ init_dpms = 1;
+ }
+#endif
+}
+