Take SardemFF7 feedback on putting g_source_[attach|add_callback] inside factory.

This commit is contained in:
Dave Davenport 2016-01-20 19:11:19 +01:00
parent 874f587021
commit 4b7a29a26f
3 changed files with 15 additions and 8 deletions

View File

@ -2,4 +2,5 @@
#define ROFI_X11_EVENT_SOURCE_H
GSource * x11_event_source_new ( Display *display );
void x11_event_source_set_callback ( GSource *source, GSourceFunc callback );
#endif // ROFI_X11_EVENT_SOURCE_H

View File

@ -2436,8 +2436,7 @@ int main ( int argc, char *argv[] )
XFlush ( display );
main_loop = g_main_loop_new ( NULL, FALSE );
GSource *source = x11_event_source_new ( display );
g_source_attach ( source, NULL );
g_source_set_callback ( source, main_loop_x11_event_handler, NULL, NULL );
x11_event_source_set_callback ( source, main_loop_x11_event_handler );
// Setup signal handling sources.
// SIGHup signal.

View File

@ -54,5 +54,12 @@ GSource * x11_event_source_new ( Display *display )
X11EventSource *source = (X11EventSource *) g_source_new ( &x11_event_source_funcs, sizeof ( X11EventSource ) );
source->display = display;
source->fd_x11 = g_source_add_unix_fd ( (GSource *) source, x11_fd, G_IO_IN | G_IO_ERR );
// Attach it to main loop.
g_source_attach ( (GSource *) source, NULL );
return (GSource *) source;
}
void x11_event_source_set_callback ( GSource *source, GSourceFunc callback )
{
g_source_set_callback ( source, callback, NULL, NULL );
}