Ejemplo n.º 1
0
/**
 * Changes the current desktop to the desktop before the current.
 */
void ClientModel::prev_desktop()
{
    // We have to add the maximum desktops back in, since C++ doesn't
    // guarantee what will happen with a negative modulus
    unsigned long long desktop_index =
        (m_current_desktop->desktop - 1 + m_max_desktops)
        % m_max_desktops;

    // We can't change while a window is being moved or resized
    if (m_desktops.count_members_of(MOVING_DESKTOP) > 0 ||
            m_desktops.count_members_of(RESIZING_DESKTOP) > 0)
        return;

    UserDesktop* old_desktop = m_current_desktop;
    m_current_desktop = USER_DESKTOPS[desktop_index];

    Window old_focus = m_focused;
    if (m_focused != None)
    {
        if (is_child(m_focused) && !is_visible(get_parent_of(m_focused)))
            unfocus(false);

        if (is_client(m_focused) && !is_visible(m_focused))
            unfocus(false);
    }

    m_changes.push(new ChangeCurrentDesktop(old_desktop, m_current_desktop));

    // If we can still focus the window we were focused on before, then do so
    // Otherwise, figure out the next logical window in the focus cycle
    if (m_focused != None && m_focused == old_focus)
        m_current_desktop->focus_cycle.set(m_focused);
    else
        sync_focus_to_cycle();
}
Ejemplo n.º 2
0
    void Widget::hide()
    {
        m_Visible = false;

        // If the widget is focused then it must be unfocused
        unfocus();
    }
Ejemplo n.º 3
0
bool InputControl::onKeyDown(Common::KeyState keyState) {
	if (_engine->getScriptManager()->getStateFlag(_key) & Puzzle::DISABLED)
		return false;

	if (!_focused) {
		return false;
	}

	if (keyState.keycode == Common::KEYCODE_BACKSPACE) {
		if (!_readOnly) {
			_currentInputText.deleteLastChar();
			_textChanged = true;
		}
	} else if (keyState.keycode == Common::KEYCODE_RETURN) {
		_enterPressed = true;
	} else if (keyState.keycode == Common::KEYCODE_TAB) {
		unfocus();
		// Focus the next input control
		_engine->getScriptManager()->focusControl(_nextTabstop);
		// Don't process this event for other controls
		return true;
	} else {
		if (!_readOnly) {
			// Otherwise, append the new character to the end of the current text
			uint16 asciiValue = keyState.ascii;
			// We only care about text values
			if (asciiValue >= 32 && asciiValue <= 126) {
				_currentInputText += (char)asciiValue;
				_textChanged = true;
			}
		}
	}
	return false;
}
Ejemplo n.º 4
0
/**
 * Removes a child from the given client.
 */
void ClientModel::remove_child(Window child, bool focus_parent)
{
    if (!is_child(child))
        return;

    Window parent = m_parents[child];
    m_children[parent]->erase(child);
    m_parents.erase(child);

    if (m_focused == child)
    {
        if (focus_parent)
            focus(parent);
        else
            unfocus();
    }

    Desktop *desktop = find_desktop(parent);
    if (desktop->is_user_desktop())
    {
        UserDesktop *user_desktop = dynamic_cast<UserDesktop*>(desktop);
        user_desktop->focus_cycle.remove(child, false);
    }
    else if (desktop->is_all_desktop())
        dynamic_cast<AllDesktops*>(ALL_DESKTOPS)->focus_cycle.remove(child, false);

    m_changes.push(new ChildRemoveChange(parent, child));
}
Ejemplo n.º 5
0
/**
 * Synchronizes the currently focused window to what the focus cycle
 * says should be focused.
 */
void ClientModel::sync_focus_to_cycle()
{
    FocusCycle &cycle = m_current_desktop->focus_cycle;
    if (!cycle.valid())
        unfocus();
    else if (cycle.get() != m_focused)
        focus(cycle.get());
}
Ejemplo n.º 6
0
 void Checkbox::widgetFocused()
 {
     // We can't be focused when we don't have a focus image
     if ((m_WidgetPhase & WidgetPhase_Focused) == 0)
         unfocus();
     else
         Widget::widgetFocused();
 }
Ejemplo n.º 7
0
    void Widget::disable()
    {
        m_Enabled = false;

        // Change the mouse button state.
        m_MouseHover = false;
        m_MouseDown = false;

        // If the widget is focused then it must be unfocused
        unfocus();
    }
Ejemplo n.º 8
0
void ChromeClientWinCE::takeFocus(FocusDirection)
{
    unfocus();
}
Ejemplo n.º 9
0
    bool Widget::setProperty(std::string property, const std::string& value)
    {
        property = toLower(property);

        if (property == "left")
        {
            setPosition(static_cast<float>(atof(value.c_str())), getPosition().y);
        }
        else if (property == "top")
        {
            setPosition(getPosition().x, static_cast<float>(atof(value.c_str())));
        }
        else if (property == "width")
        {
            setSize(static_cast<float>(atof(value.c_str())), getSize().y);
        }
        else if (property == "height")
        {
            setSize(getSize().x, static_cast<float>(atof(value.c_str())));
        }
        else if (property == "visible")
        {
            if ((value == "true") || (value == "True"))
                m_Visible = true;
            else if ((value == "false") || (value == "False"))
                m_Visible = false;
            else
                TGUI_OUTPUT("TGUI error: Failed to parse 'Visible' property.");
        }
        else if (property == "enabled")
        {
            if ((value == "true") || (value == "True"))
                m_Enabled = true;
            else if ((value == "false") || (value == "False"))
                m_Enabled = false;
            else
                TGUI_OUTPUT("TGUI error: Failed to parse 'Enabled' property.");
        }
        else if(property == "focused")
        {
            if ((value == "true") || (value == "True"))
                focus();
            else if ((value == "false") || (value == "False"))
                unfocus();
            else
                TGUI_OUTPUT("TGUI error: Failed to parse 'Focused' property.");
        }
        else if (property == "transparency")
        {
            setTransparency(static_cast<char>(atoi(value.c_str())));
        }
        else if (property == "callbackid")
        {
            m_Callback.id = static_cast<unsigned int>(std::atoi(value.c_str()));
        }
        else if (property == "callback")
        {
            std::vector<sf::String> callbacks;
            decodeList(value, callbacks);

            for (auto it = callbacks.begin(); it != callbacks.end(); ++it)
            {
                if ((*it == "Focused") || (*it == "focused"))
                    bindCallback(Focused);
                else if ((*it == "Unfocused") || (*it == "unfocused"))
                    bindCallback(Unfocused);
                else if ((*it == "MouseEntered") || (*it == "mouseentered"))
                    bindCallback(MouseEntered);
                else if ((*it == "MouseLeft") || (*it == "mouseleft"))
                    bindCallback(MouseLeft);
            }
        }
        else // The property didn't match
            return false;

        // You pass here when one of the properties matched
        return true;
    }
Ejemplo n.º 10
0
/**
 * Unfocuses a window if it is currently focused, otherwise the focus is
 * not changed.
 */
void ClientModel::unfocus_if_focused(Window client)
{
    if (m_focused == client)
        unfocus();
}
Ejemplo n.º 11
0
/**
 * Unfocuses a window if it is currently focused.
 */
void ClientModel::unfocus()
{
    unfocus(true);
}
Ejemplo n.º 12
0
/**
 * Moves a client between two desktops and fires the resulting event.
 */
void ClientModel::move_to_desktop(Window client, Desktop* new_desktop, bool should_unfocus)
{
    Desktop* old_desktop = m_desktops.get_category_of(client);
    if (*old_desktop == *new_desktop)
        return;

    bool can_focus = m_autofocus[client];
    m_desktops.move_member(client, new_desktop);

    if (can_focus && old_desktop->is_user_desktop())
    {
        UserDesktop *user_desktop = dynamic_cast<UserDesktop*>(old_desktop);
        user_desktop->focus_cycle.remove(client, false);

        for (std::set<Window>::iterator child = m_children[client]->begin();
                child != m_children[client]->end();
                child++)
            user_desktop->focus_cycle.remove(*child, false);
    }
    else if (can_focus && old_desktop->is_all_desktop())
    {
        dynamic_cast<AllDesktops*>(ALL_DESKTOPS)->focus_cycle.remove(client, false);

        for (std::set<Window>::iterator child = m_children[client]->begin();
                child != m_children[client]->end();
                child++)
            dynamic_cast<AllDesktops*>(ALL_DESKTOPS)->focus_cycle.remove(*child, false);
    }

    if (can_focus && new_desktop->is_user_desktop())
    {
        UserDesktop *user_desktop = dynamic_cast<UserDesktop*>(new_desktop);
        user_desktop->focus_cycle.add(client);

        for (std::set<Window>::iterator child = m_children[client]->begin();
                child != m_children[client]->end();
                child++)
            user_desktop->focus_cycle.add_after(*child, client);
    }
    else if (can_focus && new_desktop->is_all_desktop())
    {
        dynamic_cast<AllDesktops*>(ALL_DESKTOPS)->focus_cycle.add(client);

        for (std::set<Window>::iterator child = m_children[client]->begin();
                child != m_children[client]->end();
                child++)
            dynamic_cast<AllDesktops*>(ALL_DESKTOPS)->focus_cycle.add_after(*child, client);
    }

    if (should_unfocus)
    {
        if (m_focused == client)
        {
            unfocus();
        }
        else if (is_child(m_focused) && get_parent_of(m_focused) == client)
        {
            unfocus();
        }
    }
    // Make sure that the focus is transferred properly into the new cycle
    else if (can_focus && new_desktop->is_user_desktop())
    {
        UserDesktop *user_desktop = dynamic_cast<UserDesktop*>(new_desktop);
        user_desktop->focus_cycle.set(client);
    }
    else if (can_focus && new_desktop->is_all_desktop())
        dynamic_cast<AllDesktops*>(ALL_DESKTOPS)->focus_cycle.set(client);

    m_changes.push(new ChangeClientDesktop(client, old_desktop, new_desktop));
}
Ejemplo n.º 13
0
void ChromeClientEfl::takeFocus(FocusDirection)
{
    unfocus();
}
Ejemplo n.º 14
0
 void Slider::widgetFocused()
 {
     // A slider can't be focused (yet)
     unfocus();
 }