<commit_before>/*
 * (C)opyright MMIV-MMV <NAME> <<EMAIL>>
 * See LICENSE file for license details.
 */

#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Xatom.h>

#include "wm.h"

Client *
alloc_client(Window w)
{
    XTextProperty name;
    Client *c = (Client *) cext_emallocz(sizeof(Client));

    c->win = w;
    XGetWMName(dpy, c->win, &name);
	if(name.value) {
		cext_strlcpy(c->name, (char *)name.value, sizeof(c->name));
    	free(name.value);
	}
    return c;
}

void
focus_client(Client * c)
{
    Frame *f = 0;
	static Client *old = nil;

	if(old && (old != c)) {
		ungrab_client(old, AnyModifier, AnyButton);
		grab_client(old, AnyModifier, AnyButton);
	}
	
    /* sel client */
	ungrab_client(c, AnyModifier, AnyButton);
    grab_client(c, Mod1Mask, Button1);
    grab_client(c, Mod1Mask, Button3);
    f = c->frame;
    f->sel = c;
    XRaiseWindow(dpy, c->win);
    XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
	XSync(dpy, False);
    invoke_wm_event(def[WM_EVENT_CLIENT_UPDATE]);
	old = c;
}

void
set_client_state(Client * c, int state)
{
    long data[2];

    data[0] = (long) state;
    data[1] = (long) None;
    XChangeProperty(dpy, c->win, wm_state, wm_state, 32, PropModeReplace,
                    (unsigned char *) data, 2);<commit_msg>definately another focus algorithm is necessary<commit_after>/*
 * (C)opyright MMIV-MMV <NAME> <<EMAIL>>
 * See LICENSE file for license details.
 */

#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Xatom.h>

#include "wm.h"

Client *
alloc_client(Window w)
{
    XTextProperty name;
    Client *c = (Client *) cext_emallocz(sizeof(Client));

    c->win = w;
    XGetWMName(dpy, c->win, &name);
	if(name.value) {
		cext_strlcpy(c->name, (char *)name.value, sizeof(c->name));
    	free(name.value);
	}
    return c;
}

void
focus_client(Client * c)
{
    Frame *f = 0;
	/*
	static Client *old = nil;

	if(old && (old != c)) {
		ungrab_client(old, AnyModifier, AnyButton);
		grab_client(old, AnyModifier, AnyButton);
	}
	*/
	
    /* sel client */
	ungrab_client(c, AnyModifier, AnyButton);
    grab_client(c, Mod1Mask, Button1);
    grab_client(c, Mod1Mask, Button3);
    f = c->frame;
    f->sel = c;
    XRaiseWindow(dpy, c->win);
    XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
	XSync(dpy, False);
    invoke_wm_event(def[WM_EVENT_CLIENT_UPDATE]);
	/*
	old = c;
	*/
}

void
set_client_state(Client * c, int state)
{
    long data[2];

    data[0] = (long) state;
    data[1] = (long) None;
    XChangeProperty(dpy, c->win, wm_state, wm_state, 32, PropModeReplace,
                    (unsigned char *) data, 2);
{'fraction_non_alphanumeric': 0.1614114114114114, 'fraction_numerical': 0.00975975975975976, 'mean_word_length': 3.4865319865319866, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 35, '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': '5167275', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1055, 'n_words': 226}