diff --git a/hw/xfree86/common/xf86PM.c b/hw/xfree86/common/xf86PM.c index eb56fb614..13adc6f06 100644 --- a/hw/xfree86/common/xf86PM.c +++ b/hw/xfree86/common/xf86PM.c @@ -36,25 +36,25 @@ pmWait (*xf86PMConfirmEventToOs)(int fd,pmEvent event) = NULL; static Bool suspended = FALSE; -static char * -eventName(pmEvent event) +static int +eventName(pmEvent event, char **str) { switch(event) { - case XF86_APM_SYS_STANDBY: return ("System Standby Request"); - case XF86_APM_SYS_SUSPEND: return ("System Suspend Request"); - case XF86_APM_CRITICAL_SUSPEND: return ("Critical Suspend"); - case XF86_APM_USER_STANDBY: return ("User System Standby Request"); - case XF86_APM_USER_SUSPEND: return ("User System Suspend Request"); - case XF86_APM_STANDBY_RESUME: return ("System Standby Resume"); - case XF86_APM_NORMAL_RESUME: return ("Normal Resume System"); - case XF86_APM_CRITICAL_RESUME: return ("Critical Resume System"); - case XF86_APM_LOW_BATTERY: return ("Battery Low"); - case XF86_APM_POWER_STATUS_CHANGE: return ("Power Status Change"); - case XF86_APM_UPDATE_TIME: return ("Update Time"); - case XF86_APM_CAPABILITY_CHANGED: return ("Capability Changed"); - case XF86_APM_STANDBY_FAILED: return ("Standby Request Failed"); - case XF86_APM_SUSPEND_FAILED: return ("Suspend Request Failed"); - default: return ("Unknown Event"); + case XF86_APM_SYS_STANDBY: *str="System Standby Request"; return 0; + case XF86_APM_SYS_SUSPEND: *str="System Suspend Request"; return 0; + case XF86_APM_CRITICAL_SUSPEND: *str="Critical Suspend"; return 0; + case XF86_APM_USER_STANDBY: *str="User System Standby Request"; return 0; + case XF86_APM_USER_SUSPEND: *str="User System Suspend Request"; return 0; + case XF86_APM_STANDBY_RESUME: *str="System Standby Resume"; return 0; + case XF86_APM_NORMAL_RESUME: *str="Normal Resume System"; return 0; + case XF86_APM_CRITICAL_RESUME: *str="Critical Resume System"; return 0; + case XF86_APM_LOW_BATTERY: *str="Battery Low"; return 3; + case XF86_APM_POWER_STATUS_CHANGE: *str="Power Status Change";return 3; + case XF86_APM_UPDATE_TIME: *str="Update Time";return 3; + case XF86_APM_CAPABILITY_CHANGED: *str="Capability Changed"; return 3; + case XF86_APM_STANDBY_FAILED: *str="Standby Request Failed"; return 0; + case XF86_APM_SUSPEND_FAILED: *str="Suspend Request Failed"; return 0; + default: *str="Unknown Event"; return 0; } } @@ -134,13 +134,15 @@ DoApmEvent(pmEvent event, Bool undo) * this might cause problems in the future. It is a global server * variable therefore it needs to be in a server info structure */ - int i; + int i, setup = 0; switch(event) { +#if 0 case XF86_APM_SYS_STANDBY: + case XF86_APM_USER_STANDBY: +#endif case XF86_APM_SYS_SUSPEND: case XF86_APM_CRITICAL_SUSPEND: /*do we want to delay a critical suspend?*/ - case XF86_APM_USER_STANDBY: case XF86_APM_USER_SUSPEND: /* should we do this ? */ if (!undo && !suspended) { @@ -151,7 +153,9 @@ DoApmEvent(pmEvent event, Bool undo) suspended = FALSE; } break; +#if 0 case XF86_APM_STANDBY_RESUME: +#endif case XF86_APM_NORMAL_RESUME: case XF86_APM_CRITICAL_RESUME: if (suspended) { @@ -160,13 +164,15 @@ DoApmEvent(pmEvent event, Bool undo) } break; default: - xf86EnterServerState(SETUP); for (i = 0; i < xf86NumScreens; i++) { - xf86EnableAccess(xf86Screens[i]); - if (xf86Screens[i]->PMEvent) + if (xf86Screens[i]->PMEvent) { + if (!setup) xf86EnterServerState(SETUP); + setup = 1; + xf86EnableAccess(xf86Screens[i]); xf86Screens[i]->PMEvent(i,event,undo); + } } - xf86EnterServerState(OPERATING); + if (setup) xf86EnterServerState(OPERATING); break; } } @@ -186,8 +192,10 @@ xf86HandlePMEvents(int fd, pointer data) if ((n = xf86PMGetEventFromOs(fd,events,MAX_NO_EVENTS))) { do { for (i = 0; i < n; i++) { - xf86MsgVerb(X_INFO,3,"PM Event received: %s\n", - eventName(events[i])); + char *str = NULL; + int verb = eventName(events[i],&str); + + xf86MsgVerb(X_INFO,verb,"PM Event received: %s\n",str); DoApmEvent(events[i],FALSE); switch (xf86PMConfirmEventToOs(fd,events[i])) { case PM_WAIT: