<commit_before>/*
 * vim:ts=8:expandtab
 *
 * i3 - an improved dynamic tiling window manager
 *
 * © 2009 <NAME> and contributors
 *
 * See file LICENSE for license information.
 *
 * src/floating.c: contains all functions for handling floating clients
 *
 */
#include <stdlib.h>
#include <string.h>
#include <assert.h>

#include <xcb/xcb.h>
#include <xcb/xcb_event.h>

#include "i3.h"
#include "config.h"
#include "data.h"
#include "util.h"
#include "xcb.h"
#include "debug.h"
#include "layout.h"
#include "client.h"
#include "floating.h"
#include "workspace.h"

/*
 * Toggles floating mode for the given client.
 * Correctly takes care of the position/size (separately stored for tiling/floating mode)
 * and repositions/resizes/redecorates the client.
 *
 * If the automatic flag is set to true, this was an automatic update by a change of the
 * window class from the application which can be overwritten by the user.
 *
 */
void toggle_floating_mode(xcb_connection_t *conn, Client *client, bool automatic) {
        Container *con = client->container;
        i3Font *font = load_font(conn, config.font);

        if (client->dock) {
                DLOG("Not putting dock client into floating mode\n");
                return;
        }

        if (con == NULL) {
                LOG("This client is already in floating (container == NULL), re-inserting\n");
                Client *next_tiling;
                Workspace *ws = client->workspace;
                SLIST_FOREACH(next_tiling, &(ws->focus_stack), focus_clients)
                        if (!client_is_floating(next_tiling))
                                break;
                /* If there are no tiling clients on this workspace, there can only be one
                 * container: the first one */
                if (next_tiling == TAILQ_END(&(ws->focus_stack)))
                        con = ws->table[0][0];
                else con = next_tiling->container;

                /* Remove the client from the list of floating clients */
                TAILQ_REMOVE(&(ws->floating_clients), client, floating_clients);

                LOG("destination container = %p\n", con);
                Client *old_focused = con->currently_focused;
                /* Preserve position/size */
                memcpy(&(client->floating_rect), &(client->rect), sizeof(Rect));<commit_msg>We don’t have DLOG yet in master branch (Thanks ccount)<commit_after>/*
 * vim:ts=8:expandtab
 *
 * i3 - an improved dynamic tiling window manager
 *
 * © 2009 <NAME> and contributors
 *
 * See file LICENSE for license information.
 *
 * src/floating.c: contains all functions for handling floating clients
 *
 */
#include <stdlib.h>
#include <string.h>
#include <assert.h>

#include <xcb/xcb.h>
#include <xcb/xcb_event.h>

#include "i3.h"
#include "config.h"
#include "data.h"
#include "util.h"
#include "xcb.h"
#include "debug.h"
#include "layout.h"
#include "client.h"
#include "floating.h"
#include "workspace.h"

/*
 * Toggles floating mode for the given client.
 * Correctly takes care of the position/size (separately stored for tiling/floating mode)
 * and repositions/resizes/redecorates the client.
 *
 * If the automatic flag is set to true, this was an automatic update by a change of the
 * window class from the application which can be overwritten by the user.
 *
 */
void toggle_floating_mode(xcb_connection_t *conn, Client *client, bool automatic) {
        Container *con = client->container;
        i3Font *font = load_font(conn, config.font);

        if (client->dock) {
                LOG("Not putting dock client into floating mode\n");
                return;
        }

        if (con == NULL) {
                LOG("This client is already in floating (container == NULL), re-inserting\n");
                Client *next_tiling;
                Workspace *ws = client->workspace;
                SLIST_FOREACH(next_tiling, &(ws->focus_stack), focus_clients)
                        if (!client_is_floating(next_tiling))
                                break;
                /* If there are no tiling clients on this workspace, there can only be one
                 * container: the first one */
                if (next_tiling == TAILQ_END(&(ws->focus_stack)))
                        con = ws->table[0][0];
                else con = next_tiling->container;

                /* Remove the client from the list of floating clients */
                TAILQ_REMOVE(&(ws->floating_clients), client, floating_clients);

                LOG("destination container = %p\n", con);
                Client *old_focused = con->currently_focused;
                /* Preserve position/size */
                memcpy(&(client->floating_rect), &(client->rect), sizeof(Rect));
{'fraction_non_alphanumeric': 0.11120489554758388, 'fraction_numerical': 0.00422029964127453, 'mean_word_length': 2.3333333333333335, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 37, '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': '6386576', 'n_tokens_mistral': 1423, 'n_tokens_neox': 1345, 'n_words': 422}