Example #1
0
static void on_xserver_stop(void *data,int pid, int status)
{
	LXSession *s=data;
	LXSession *greeter;

	g_message("xserver stop, restart. return status %x\n",status);

	stop_pid(pid);
	s->server = -1;
	lxsession_stop(s);
	greeter=lxsession_find_greeter();
	if(s->greeter || !greeter)
	{
		s->greeter=TRUE;
		xconn_close(s->dpy);
		s->dpy=NULL;
		lxdm_startx(s);
		ui_drop();
		ui_prepare();
		lxsession_set_active(greeter);
	}
	else
	{
		lxsession_free(s);
		lxsession_set_active(greeter);
	}
}
Example #2
0
static void lxsession_stop(LXSession *s)
{
	if(s->greeter)
	{
		ui_drop();
		s->greeter=FALSE;
	}
	if(s->child>0)
	{
		lxcom_del_child_watch(s->child);
		killpg(s->child, SIGHUP);
		stop_pid(s->child);
		s->child = -1;
	}
	if( s->server > 0 )
	{
		xconn_clean(s->dpy);
	}
	lxdm_auth_session_end(&s->auth);
#if HAVE_LIBCK_CONNECTOR
	if( s->ckc != NULL )
	{
		DBusError error;
		dbus_error_init(&error);
		ck_connector_close_session(s->ckc, &error);
		if(dbus_error_is_set(&error))
		{
			dbus_error_free(&error);
		}
		ck_connector_unref(s->ckc);
		s->ckc=NULL;
	}
#endif
	s->idle=TRUE;
}
Example #3
0
static void lxsession_free(LXSession *s)
{
	if(!s)
		return;
	session_list=g_slist_remove(session_list,s);
	lxsession_stop(s);
	if(s->server)
	{
		if(s->dpy)
		{
			xconn_close(s->dpy);
			s->dpy=NULL;
		}
		stop_pid(s->server);
		s->server=0;
	}
	g_free(s->option);
	g_strfreev(s->env);
	g_free(s);
}
Example #4
0
static void on_active_window_changed(WnckScreen *screen,
		WnckWindow *previously_active_window,
		gpointer user_data)
{
	GList *window_l;
	WnckWindow *active_window = wnck_screen_get_active_window(screen);
	WnckWorkspace *active_workspace = wnck_screen_get_active_workspace(screen);
	GList *pids_current = NULL;
	GList *pids_other = NULL;

	for (window_l = wnck_screen_get_windows(screen); window_l != NULL; window_l = window_l->next) {
		WnckWindow *window = WNCK_WINDOW(window_l->data);
		WnckApplication *app = wnck_application_get(wnck_window_get_group_leader(window));
		WnckWorkspace *w_workspace = wnck_window_get_workspace(window);
		if (!w_workspace)
			continue;
		GList *app_window_l;

		int w_pid = wnck_application_get_pid(app);
		if (w_workspace == active_workspace) {
			GList *g = g_list_find(pids_current, GINT_TO_POINTER(w_pid));
			if (!g) pids_current = g_list_append(pids_current, GINT_TO_POINTER(w_pid));
		} else {
			GList *g = g_list_find(pids_other, GINT_TO_POINTER(w_pid));
			if (!g) pids_other = g_list_append(pids_other, GINT_TO_POINTER(w_pid));
		}
	}
	for (; pids_other != NULL; pids_other = pids_other->next) {
		GList *g = g_list_find(pids_current, pids_other->data);
		if (g)
			g_print("Another window of this application is active\n");
		else
			g_print("PID: %d\n", stop_pid(GPOINTER_TO_INT(pids_other->data)));
	}
	for (; pids_current != NULL; pids_current = pids_current->next) {
		cont_pid(GPOINTER_TO_INT(pids_current->data));
	}
	g_print("-----\n");
}
Example #5
0
int main()
{
	pololu_3pi_init(2000);  
	play_mode(PLAY_CHECK);
	clear();

	// start receiving data at 115.2 kbaud
	serial_set_baud_rate(115200);
	serial_receive_ring(buffer, 100);

	while(1)
	{
		// wait for a command
		char command = read_next_byte();

		// The list of commands is below: add your own simply by
		// choosing a command byte and introducing another case
		// statement.
		switch(command)
		{
		case (char)0x00:
			// silent error - probable master resetting
			break;

		case (char)0x81:
			send_signature();
			break;
		case (char)0x86:
			send_raw_sensor_values();
			break;
		case (char)0x87:
			send_calibrated_sensor_values(1);
			break;
		case (char)0xB0:
			send_trimpot();
			break;
		case (char)0xB1:
			send_battery_millivolts();
			break;
		case (char)0xB3:
			do_play();
			break;
		case (char)0xB4:
			calibrate_line_sensors(IR_EMITTERS_ON);
			send_calibrated_sensor_values(1);
			break;
		case (char)0xB5:
			line_sensors_reset_calibration();
			break;
		case (char)0xB6:
			send_line_position();
			break;
		case (char)0xB7:
			do_clear();
			break;
		case (char)0xB8:
			do_print();
			break;
		case (char)0xB9:
			do_lcd_goto_xy();
			break;
		case (char)0xBA:
			auto_calibrate();
			break;
		case (char)0xBB:
			set_pid();
			break;
		case (char)0xBC:
			stop_pid();
			break;

		case (char)0xC1:
			m1_forward();
			break;
		case (char)0xC2:
			m1_backward();
			break;
		case (char)0xC5:
			m2_forward();
			break;
		case (char)0xC6:
			m2_backward();
			break;

		default:
			clear();
			print("Bad cmd");
			lcd_goto_xy(0,1);
			print_hex_byte(command);

			play("o7l16crc");
			continue; // bad command
		}
	}
}