File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,10 +50,20 @@ func (h *LidSwitchHandler) Start() error {
5050}
5151
5252func (h * LidSwitchHandler ) onLidClosed () {
53+ m := h .manager
54+ m .PropsMu .Lock ()
55+ m .lidSwitchState = lidSwitchStateClose
56+ m .PropsMu .Unlock ()
57+ logger .Info ("Lid Closed" )
5358 h .onLidDelayOperate (false )
5459}
5560
5661func (h * LidSwitchHandler ) onLidOpened () {
62+ m := h .manager
63+ m .PropsMu .Lock ()
64+ m .lidSwitchState = lidSwitchStateOpen
65+ m .PropsMu .Unlock ()
66+ logger .Info ("Lid Opened" )
5767 h .onLidDelayOperate (true )
5868}
5969
@@ -93,9 +103,6 @@ func (h *LidSwitchHandler) doLidStateChanged(state bool) {
93103 // 合盖
94104 if ! state {
95105 m .setPrepareSuspend (suspendStateLidClose )
96- m .PropsMu .Lock ()
97- m .lidSwitchState = lidSwitchStateClose
98- m .PropsMu .Unlock ()
99106 m .claimOrReleaseAmbientLight ()
100107
101108 var lidCloseAction int32
@@ -111,9 +118,6 @@ func (h *LidSwitchHandler) doLidStateChanged(state bool) {
111118 }
112119 } else { // 开盖
113120 m .setPrepareSuspend (suspendStateLidOpen )
114- m .PropsMu .Lock ()
115- m .lidSwitchState = lidSwitchStateOpen
116- m .PropsMu .Unlock ()
117121 m .claimOrReleaseAmbientLight ()
118122
119123 err := h .stopAskUser ()
Original file line number Diff line number Diff line change @@ -529,6 +529,10 @@ func (m *Manager) listenEventToHandleIdleOff() error {
529529}
530530
531531func (m * Manager ) doLidClosedAction (action int32 ) {
532+ if ! m .sessionActive {
533+ return
534+ }
535+
532536 switch action {
533537 case powerActionShutdown :
534538 m .doShutdown ()
You can’t perform that action at this time.
0 commit comments