Exemplo n.º 1
0
Arquivo: lock.c Projeto: aosm/X11
Bool
CheckSessionLocked(char *session_name, Bool get_id, char **id_ret)
{
    if (get_id)
	*id_ret = GetLockId (session_name);

    if (!LockSession (session_name, False))
	return (1);

    UnlockSession (session_name);
    return (0);
}
Exemplo n.º 2
0
void COpenLock::ResetLockInfo()
{
	Open_lockCfg* lockCfg = OpenLockData.get(GetLockId());
	if(!lockCfg) return;

	int randRange = abs(lockCfg->random_min)+lockCfg->random_max;
	srand (time(NULL));
	m_openDegreeMin = rand()%randRange + 1;
	if(m_openDegreeMin>lockCfg->random_max)
	{
		m_openDegreeMin = lockCfg->random_max - m_openDegreeMin;
	}
	m_openDegreeMax = m_openDegreeMin + lockCfg->section;
	m_openDegreeMiddle = (m_openDegreeMin+m_openDegreeMax)/2;

	SetMaxTime(lockCfg->max_time);
	SetLeftTime(lockCfg->max_time);
	unschedule(SEL_SCHEDULE(&COpenLock::ScheduleLeftTime));
	schedule(SEL_SCHEDULE(&COpenLock::ScheduleLeftTime),1.0f,GetMaxTime()+1,0.0f);
}
Exemplo n.º 3
0
static void
ChooseSessionBreakLockXtProc(Widget w, XtPointer client_data, 
			     XtPointer callData)
{
    XawListReturnStruct *current;
    char *name;

    CheckDeleteCancel ();

    current = XawListShowCurrent (chooseSessionListWidget);

    if (!current || !(name = current->string) || *name == '\0')
    {
	if (current)
	    XtFree ((char *) current);
#ifdef XKB
	XkbStdBell(XtDisplay(topLevel),XtWindow(topLevel),0,XkbBI_BadValue);
#else
	XBell (XtDisplay (topLevel), 0);
#endif
	return;
    }

    break_lock_phase++;

    if (break_lock_phase == 1)
    {
	XtVaSetValues (chooseSessionMessageLabel,
	    XtNforeground, save_message_foreground,
            NULL);

#ifdef XKB
	XkbStdBell(XtDisplay(topLevel),XtWindow(topLevel),0,XkbBI_BadValue);
#else
	XBell (XtDisplay (topLevel), 0);
#endif
    }
    else
    {
	int longest;

	XtVaSetValues (chooseSessionMessageLabel,
	    XtNforeground, save_message_background,
            NULL);

	name = sessionNamesShort[current->list_index];

	(void) GetLockId (name);

	UnlockSession (name);

	sessionsLocked[current->list_index] = False;
	XtFree ((char *) sessionNamesLong[current->list_index]);
	sessionNamesLong[current->list_index] =
	    sessionNamesShort[current->list_index];

	XtVaGetValues (chooseSessionListWidget,
	    XtNlongest, &longest,
	    NULL);

	XawListChange (chooseSessionListWidget,
	    sessionNamesLong, sessionNameCount, longest, True);

	SessionSelected (current->list_index, True);

	break_lock_phase = 0;
    }

    XtFree ((char *) current);
}