<commit_before>#include "x-events.h"

/**
 * Runs a single iteration of the event loop, by capturing an X event and
 * acting upon it.
 *
 * @return true if more events can be processed, false otherwise.
 */
bool XEvents::step()
{
    // Grab the next event from X, and then dispatch upon its type
    m_xdata.next_event(m_event);

    if (m_event.type == m_xdata.randr_event_offset + RRNotify)
        handle_rrnotify();
    
    if (m_event.type == KeyPress)
        handle_keypress();

    if (m_event.type == ButtonPress)
        handle_buttonpress();

    if (m_event.type == ButtonRelease)
        handle_buttonrelease();

    if (m_event.type == MotionNotify)
        handle_motionnotify();

    if (m_event.type == MapNotify)
        handle_mapnotify();

    if (m_event.type == Expose)
        handle_expose();

    if (m_event.type == DestroyNotify)
        handle_destroynotify();

    return !m_done;
}

/**
 * Rebuilds the display graph whenever XRandR notifies us.
 */
void XEvents::handle_rrnotify()
{
    std::vector<Box> screens;
    m_xdata.get_screen_boxes(screens);
    m_clients.update_screens(screens);
}

/**
 * Handles keyboard shortcuts.
 */
void XEvents::handle_keypress()
{
    KeySym key = m_xdata.get_keysym(m_event.xkey.keycode);
    bool is_using_secondary_action = (m_event.xkey.state & SECONDARY_MASK);

    Window client = None;
    if (m_config.hotkey == HK_MOUSE)
    {
        Window client = m_event.xkey.subwindow;
        if (client == None)
            client = m_event.xkey.window;
    }
    else if (m_config.hotkey == HK_FOCUS)
        client = m_clients.get_focused();

    bool is_client = m_clients.is_client(client);

    KeyBinding binding(key, is_using_secondary_action);
    KeyboardAction action = m_config.key_commands.binding_to_action[binding];
    switch (action)
    {
    case CLIENT_NEXT_DESKTOP:
        if (is_client)
             m_clients.client_next_desktop(client);
        break;
    case CLIENT_PREV_DESKTOP:
        if (is_client)
             m_clients.client_prev_desktop(client);<commit_msg>Fixed a bug with the mouse action mode.<commit_after>#include "x-events.h"

/**
 * Runs a single iteration of the event loop, by capturing an X event and
 * acting upon it.
 *
 * @return true if more events can be processed, false otherwise.
 */
bool XEvents::step()
{
    // Grab the next event from X, and then dispatch upon its type
    m_xdata.next_event(m_event);

    if (m_event.type == m_xdata.randr_event_offset + RRNotify)
        handle_rrnotify();
    
    if (m_event.type == KeyPress)
        handle_keypress();

    if (m_event.type == ButtonPress)
        handle_buttonpress();

    if (m_event.type == ButtonRelease)
        handle_buttonrelease();

    if (m_event.type == MotionNotify)
        handle_motionnotify();

    if (m_event.type == MapNotify)
        handle_mapnotify();

    if (m_event.type == Expose)
        handle_expose();

    if (m_event.type == DestroyNotify)
        handle_destroynotify();

    return !m_done;
}

/**
 * Rebuilds the display graph whenever XRandR notifies us.
 */
void XEvents::handle_rrnotify()
{
    std::vector<Box> screens;
    m_xdata.get_screen_boxes(screens);
    m_clients.update_screens(screens);
}

/**
 * Handles keyboard shortcuts.
 */
void XEvents::handle_keypress()
{
    KeySym key = m_xdata.get_keysym(m_event.xkey.keycode);
    bool is_using_secondary_action = (m_event.xkey.state & SECONDARY_MASK);

    Window client = None;
    if (m_config.hotkey == HK_MOUSE)
    {
        client = m_event.xkey.subwindow;
        if (client == None)
            client = m_event.xkey.window;
    }
    else if (m_config.hotkey == HK_FOCUS)
        client = m_clients.get_focused();

    bool is_client = m_clients.is_client(client);

    KeyBinding binding(key, is_using_secondary_action);
    KeyboardAction action = m_config.key_commands.binding_to_action[binding];
    switch (action)
    {
    case CLIENT_NEXT_DESKTOP:
        if (is_client)
             m_clients.client_next_desktop(client);
        break;
    case CLIENT_PREV_DESKTOP:
        if (is_client)
             m_clients.client_prev_desktop(client);
{'fraction_non_alphanumeric': 0.10596186338402123, 'fraction_numerical': 0.0, 'mean_word_length': 2.9466666666666668, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2922568', 'n_tokens_mistral': 1419, 'n_tokens_neox': 1372, 'n_words': 299}