kbgwm

sucklessy floating window manager
git clone https://git.neuralcrash.com/kbgwm.git
Log | Files | Refs | README | LICENSE

list.h (1688B)


      1 /*
      2  * kbgwm, a sucklessy floating window manager
      3  * Copyright (c) 2020-2021, Kebigon <git@kebigon.xyz>
      4  *
      5  * Permission to use, copy, modify, and/or distribute this software for any
      6  * purpose with or without fee is hereby granted, provided that the above
      7  * copyright notice and this permission notice appear in all copies.
      8  *
      9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     16  */
     17 
     18 #pragma once
     19 
     20 #include <stdbool.h>
     21 #include <xcb/xproto.h>
     22 
     23 struct item
     24 {
     25     void *data;
     26     struct item *previous;
     27     struct item *next;
     28 };
     29 
     30 struct item *list_tail(struct item **);
     31 void list_move_to_head(struct item **, struct item *);
     32 void list_move_to_tail(struct item **, struct item *);
     33 
     34 void list_add(struct item **, void *);
     35 void *list_remove(struct item **, struct item *);
     36 void *list_remove_head(struct item **);
     37 
     38 struct item *list_find_client(struct item **, xcb_window_t);
     39 
     40 // returns true if the list contains no items
     41 // the goal of this function is to make the intent explicit
     42 static inline bool list_is_empty(struct item **list)
     43 {
     44     return *list == NULL;
     45 }
     46 
     47 // returns the head of the list
     48 // the goal of this function is to make the intent explicit
     49 static inline struct item *list_head(struct item **list)
     50 {
     51     return *list;
     52 }