15
15
#include <wayland-util.h>
16
16
#include <wordexp.h>
17
17
#include "config.h"
18
- #include "idle-client-protocol.h"
19
18
#include "ext-idle-notify-v1-client-protocol.h"
20
19
#include "log.h"
21
20
#if HAVE_SYSTEMD
26
25
#include <elogind/sd-login.h>
27
26
#endif
28
27
29
- static struct org_kde_kwin_idle * kde_idle_manager = NULL ;
30
28
static struct ext_idle_notifier_v1 * idle_notifier = NULL ;
31
29
static struct wl_seat * seat = NULL ;
32
30
@@ -48,7 +46,6 @@ struct swayidle_state {
48
46
struct swayidle_timeout_cmd {
49
47
struct wl_list link ;
50
48
int timeout , registered_timeout ;
51
- struct org_kde_kwin_idle_timeout * kde_idle_timer ;
52
49
struct ext_idle_notification_v1 * idle_notification ;
53
50
char * idle_cmd ;
54
51
char * resume_cmd ;
@@ -545,10 +542,7 @@ static const struct wl_seat_listener wl_seat_listener = {
545
542
546
543
static void handle_global (void * data , struct wl_registry * registry ,
547
544
uint32_t name , const char * interface , uint32_t version ) {
548
- if (strcmp (interface , org_kde_kwin_idle_interface .name ) == 0 ) {
549
- kde_idle_manager =
550
- wl_registry_bind (registry , name , & org_kde_kwin_idle_interface , 1 );
551
- } else if (strcmp (interface , ext_idle_notifier_v1_interface .name ) == 0 ) {
545
+ if (strcmp (interface , ext_idle_notifier_v1_interface .name ) == 0 ) {
552
546
idle_notifier =
553
547
wl_registry_bind (registry , name , & ext_idle_notifier_v1_interface , 1 );
554
548
} else if (strcmp (interface , wl_seat_interface .name ) == 0 ) {
@@ -570,15 +564,9 @@ static const struct wl_registry_listener registry_listener = {
570
564
.global_remove = handle_global_remove ,
571
565
};
572
566
573
- static const struct org_kde_kwin_idle_timeout_listener kde_idle_timer_listener ;
574
567
static const struct ext_idle_notification_v1_listener idle_notification_listener ;
575
568
576
569
static void destroy_cmd_timer (struct swayidle_timeout_cmd * cmd ) {
577
- if (cmd -> kde_idle_timer != NULL ) {
578
- swayidle_log (LOG_DEBUG , "Release idle timer" );
579
- org_kde_kwin_idle_timeout_release (cmd -> kde_idle_timer );
580
- cmd -> kde_idle_timer = NULL ;
581
- }
582
570
if (cmd -> idle_notification != NULL ) {
583
571
ext_idle_notification_v1_destroy (cmd -> idle_notification );
584
572
cmd -> idle_notification = NULL ;
@@ -594,17 +582,10 @@ static void register_timeout(struct swayidle_timeout_cmd *cmd,
594
582
return ;
595
583
}
596
584
swayidle_log (LOG_DEBUG , "Register with timeout: %d" , timeout );
597
- if (idle_notifier != NULL ) {
598
- cmd -> idle_notification =
599
- ext_idle_notifier_v1_get_idle_notification (idle_notifier , timeout , seat );
600
- ext_idle_notification_v1_add_listener (cmd -> idle_notification ,
601
- & idle_notification_listener , cmd );
602
- } else {
603
- cmd -> kde_idle_timer =
604
- org_kde_kwin_idle_get_idle_timeout (kde_idle_manager , seat , timeout );
605
- org_kde_kwin_idle_timeout_add_listener (cmd -> kde_idle_timer ,
606
- & kde_idle_timer_listener , cmd );
607
- }
585
+ cmd -> idle_notification =
586
+ ext_idle_notifier_v1_get_idle_notification (idle_notifier , timeout , seat );
587
+ ext_idle_notification_v1_add_listener (cmd -> idle_notification ,
588
+ & idle_notification_listener , cmd );
608
589
cmd -> registered_timeout = timeout ;
609
590
}
610
591
@@ -645,7 +626,8 @@ static void disable_timeouts(void) {
645
626
}
646
627
#endif
647
628
648
- static void handle_idled (struct swayidle_timeout_cmd * cmd ) {
629
+ static void handle_idled (void * data , struct ext_idle_notification_v1 * notif ) {
630
+ struct swayidle_timeout_cmd * cmd = data ;
649
631
cmd -> resume_pending = true;
650
632
swayidle_log (LOG_DEBUG , "idle state" );
651
633
#if HAVE_SYSTEMD || HAVE_ELOGIND
@@ -658,7 +640,8 @@ static void handle_idled(struct swayidle_timeout_cmd *cmd) {
658
640
}
659
641
}
660
642
661
- static void handle_resumed (struct swayidle_timeout_cmd * cmd ) {
643
+ static void handle_resumed (void * data , struct ext_idle_notification_v1 * notif ) {
644
+ struct swayidle_timeout_cmd * cmd = data ;
662
645
cmd -> resume_pending = false;
663
646
swayidle_log (LOG_DEBUG , "active state" );
664
647
if (cmd -> registered_timeout != cmd -> timeout ) {
@@ -674,34 +657,9 @@ static void handle_resumed(struct swayidle_timeout_cmd *cmd) {
674
657
}
675
658
}
676
659
677
- static void kde_handle_idle (void * data , struct org_kde_kwin_idle_timeout * timer ) {
678
- struct swayidle_timeout_cmd * cmd = data ;
679
- handle_idled (cmd );
680
- }
681
-
682
- static void kde_handle_resumed (void * data , struct org_kde_kwin_idle_timeout * timer ) {
683
- struct swayidle_timeout_cmd * cmd = data ;
684
- handle_resumed (cmd );
685
- }
686
-
687
- static const struct org_kde_kwin_idle_timeout_listener kde_idle_timer_listener = {
688
- .idle = kde_handle_idle ,
689
- .resumed = kde_handle_resumed ,
690
- };
691
-
692
- static void ext_handle_idled (void * data , struct ext_idle_notification_v1 * notif ) {
693
- struct swayidle_timeout_cmd * cmd = data ;
694
- handle_idled (cmd );
695
- }
696
-
697
- static void ext_handle_resumed (void * data , struct ext_idle_notification_v1 * notif ) {
698
- struct swayidle_timeout_cmd * cmd = data ;
699
- handle_resumed (cmd );
700
- }
701
-
702
660
static const struct ext_idle_notification_v1_listener idle_notification_listener = {
703
- .idled = ext_handle_idled ,
704
- .resumed = ext_handle_resumed ,
661
+ .idled = handle_idled ,
662
+ .resumed = handle_resumed ,
705
663
};
706
664
707
665
static char * parse_command (int argc , char * * argv ) {
@@ -934,7 +892,7 @@ static int handle_signal(int sig, void *data) {
934
892
swayidle_log (LOG_DEBUG , "Got SIGTERM" );
935
893
wl_list_for_each (cmd , & state .timeout_cmds , link ) {
936
894
if (cmd -> resume_pending ) {
937
- handle_resumed (cmd );
895
+ handle_resumed (cmd , NULL );
938
896
}
939
897
}
940
898
sway_terminate (0 );
@@ -1112,8 +1070,8 @@ int main(int argc, char *argv[]) {
1112
1070
}
1113
1071
}
1114
1072
1115
- if (kde_idle_manager == NULL && idle_notifier == NULL ) {
1116
- swayidle_log (LOG_ERROR , "Display doesn't support idle protocol" );
1073
+ if (idle_notifier == NULL ) {
1074
+ swayidle_log (LOG_ERROR , "Compositor doesn't support idle protocol" );
1117
1075
swayidle_finish ();
1118
1076
return -4 ;
1119
1077
}
0 commit comments