summaryrefslogtreecommitdiffstats
path: root/abs/extra/xine-ui/xine-ui-xdg.diff
blob: 959d674b27e027af18f2002fcf3698e0f4b8954c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
--- xine-ui-0.99.6.orig/src/xitk/common.h
+++ xine-ui-0.99.6/src/xitk/common.h
@@ -331,6 +331,5 @@ typedef struct {
   int                       use_root_window;
 
   int                       ssaver_enabled;
-  int                       ssaver_timeout;
 
   int                       skip_by_chapter;
--- xine-ui-0.99.6.orig/src/xitk/main.c
+++ xine-ui-0.99.6/src/xitk/main.c
@@ -1383,6 +1383,8 @@ int main(int argc, char *argv[]) {
   if (sigprocmask (SIG_BLOCK,  &vo_mask, NULL))
     fprintf (stderr, "sigprocmask() failed.\n");
 
+  signal(SIGCHLD, SIG_IGN);
+
   gGui = (gGui_t *) calloc(1, sizeof(gGui_t));
   
   gGui->stream                 = NULL;
--- xine-ui-0.99.6.orig/src/xitk/panel.c
+++ xine-ui-0.99.6/src/xitk/panel.c
@@ -356,7 +356,6 @@ void panel_update_runtime_display(void)
  * Update slider thread.
  */
 static void *slider_loop(void *dummy) {
-  int screensaver_timer = 0;
   int status, speed;
   int pos, secs;
   int i = 0;
@@ -441,20 +440,7 @@ static void *slider_loop(void *dummy) {
 	else
 	  video_window_set_mrl((char *)gGui->mmk.mrl);
 	
-	if(!xitk_is_window_iconified(gGui->video_display, gGui->video_window)) {
-	  
-	  if(gGui->ssaver_timeout) {
-	    
-	    if(!(i % 2))
-	      screensaver_timer++;
-	    
-	    if(screensaver_timer >= gGui->ssaver_timeout) {
-	      screensaver_timer = 0;
-	      video_window_reset_ssaver();
-	      
-	    }
-	  }  
-	}
+       video_window_suspend_ssaver(!xitk_is_window_iconified(gGui->video_display, gGui->video_window));
 
 	if(gGui->logo_mode == 0) {
 	  
@@ -494,6 +480,8 @@ static void *slider_loop(void *dummy) {
 	    stream_infos_update_infos();
 
 	}
+      } else {
+       video_window_suspend_ssaver(0);
       }
     }
     
--- xine-ui-0.99.6.orig/src/xitk/videowin.c
+++ xine-ui-0.99.6/src/xitk/videowin.c
@@ -1087,6 +1087,9 @@ static void video_window_adapt_size (voi
 
   /* The old window should be destroyed now */
   if(old_video_window != None) {
+    /* Screensaver control is tied to our window id */
+    video_window_suspend_ssaver(0);
+
     XDestroyWindow(gGui->video_display, old_video_window);
      
     if(gGui->cursor_grabbed)
@@ -2261,69 +2264,34 @@ static void video_window_handle_event (X
 
 }
 
-void video_window_reset_ssaver(void) {
+void video_window_suspend_ssaver(int do_suspend) {
+  static int was_suspended;
 
-  if(gGui->ssaver_enabled && (xitk_get_last_keypressed_time() >= (long int) gGui->ssaver_timeout)) {
+  do_suspend = do_suspend && gGui->ssaver_enabled;
 
-#ifdef HAVE_XTESTEXTENSION
-    if(gVw.have_xtest == True) {
-      
-      gVw.fake_key_cur++;
-      
-      if(gVw.fake_key_cur >= 2)
-	gVw.fake_key_cur = 0;
-
-      XLockDisplay(gGui->video_display);
-      XTestFakeKeyEvent(gGui->video_display, gVw.fake_keys[gVw.fake_key_cur], True, CurrentTime);
-      XTestFakeKeyEvent(gGui->video_display, gVw.fake_keys[gVw.fake_key_cur], False, CurrentTime);
-      XSync(gGui->video_display, False);
-      XUnlockDisplay(gGui->video_display);
+  if(was_suspended != do_suspend) {
+    if(fork() == 0) {
+      char window_id[30];
+      char *args[] = { "xdg-screensaver", NULL, window_id, NULL };
+      int fd;
+
+      for(fd = 3; fd < 256; fd++)
+	close(fd);
+
+      args[1] = do_suspend ? "suspend" : "resume";
+      sprintf(window_id, "%lu", (unsigned long)gGui->video_window);
+      execvp(args[0], args);
+      _exit(0);
     }
-    else 
-#endif
-    {
-      /* Reset the gnome screensaver. Look up the command in PATH only once to save time, */
-      /* assuming its location and permission will not change during run time of xine-ui. */
-      {
-	static char *const gssaver_args[] = { "gnome-screensaver-command", "--poke", NULL };
-	static char *gssaver_path   = NULL;
-
-	if(!gssaver_path) {
-	  char *path = getenv("PATH");
-
-	  if(!path)
-	    path = "/usr/local/bin:/usr/bin";
-	  do {
-	    char *p, *pbuf;
-	    int   plen;
-
-	    for(p = path; *path && *path != ':'; path++)
-	      ;
-	    if(p == path)
-	      plen = 1, p = ".";
-	    else
-	      plen = path - p;
-	    asprintf(&pbuf, "%.*s/%s", plen, p, gssaver_args[0]);
-	    if ( access(pbuf, X_OK) ) {
-	      free(pbuf);
-	      gssaver_path = "";
-	    } else
-	      gssaver_path = pbuf;
-	  } while(!gssaver_path[0] && *path++);
-	}
-	if(gssaver_path[0] && (fork() == 0)) {
-	  execv(gssaver_path, gssaver_args);
-	  exit(0);
-	}
-      }
 
-      XLockDisplay(gGui->video_display);
-      XResetScreenSaver(gGui->video_display);
-      XUnlockDisplay(gGui->video_display);
-    }
+    was_suspended = do_suspend;
   }
 }
 
+void video_window_reset_ssaver(void) {
+  video_window_suspend_ssaver(1);
+}
+
 void video_window_get_frame_size(int *w, int *h) {
   if(w)
     *w = gVw.frame_width;
--- xine-ui-0.99.6.orig/src/xitk/videowin.h
+++ xine-ui-0.99.6/src/xitk/videowin.h
@@ -81,6 +81,7 @@ void video_window_get_mag (float *xmag,
 void video_window_update_logo(void);
 void video_window_change_skins(int);
 
+void video_window_suspend_ssaver(int do_suspend);
 void video_window_reset_ssaver(void);
 
 void video_window_get_frame_size(int *w, int *h);
--- xine-ui-0.99.6.orig/src/xitk/event.c
+++ xine-ui-0.99.6/src/xitk/event.c
@@ -135,9 +135,6 @@ static void skip_by_chapter_cb(void *dat
   gGui->skip_by_chapter = cfg->num_value;
   panel_update_nextprev_tips();
 }
-static void ssaver_timeout_cb(void *data, xine_cfg_entry_t *cfg) {
-  gGui->ssaver_timeout = cfg->num_value;
-}
 
 static void visual_anim_cb(void *data, xine_cfg_entry_t *cfg) {
   
@@ -1614,14 +1611,6 @@ void gui_init (int nfiles, char *filenam
 					 snapshot_loc_cb,
 					 CONFIG_NO_DATA);
   
-  gGui->ssaver_timeout =
-    xine_config_register_num (__xineui_global_xine_instance, "gui.screensaver_timeout", 10,
-			      _("Screensaver reset interval (s)"),
-			      _("Time, in seconds, between two faked events to keep a screensaver quiet, 0 to disable."),
-			      CONFIG_LEVEL_ADV,
-			      ssaver_timeout_cb,
-			      CONFIG_NO_DATA);
-  
   gGui->skip_by_chapter = 
     xine_config_register_bool (__xineui_global_xine_instance, "gui.skip_by_chapter", 1,
 			       _("Chapter hopping"),