bemenu/lib/renderers/x11/x11.h
Maxim Karasev 43255bbbe8 Add relative width option
It works on Wayland and X11 and acts as a complement to margin. Exact
behavior is as follows:
- If width factor is 0, width minus margin is used.
- If width multiplied by factor is greater than width minus margin,
  width minus is used. (so margin may be used to make sure that bemenu
  is at least N pixels away from the view border)
- Otherwise width multiplied by factor is used.

I think it's fine to disable warnings about floating point numbers
comparision. We don't do any arithmetics on them anyway, so we can't
suffer from inaccuracy.
2021-12-29 17:22:10 +09:00

65 lines
1.5 KiB
C

#ifndef _BM_X11_H_
#define _BM_X11_H_
#include "internal.h"
#include <X11/Xlib.h>
#include <X11/keysym.h>
#include "renderers/cairo_renderer.h"
enum mod_bit {
MOD_SHIFT = 1<<0,
MOD_CTRL = 1<<1,
MOD_ALT = 1<<2,
};
struct buffer {
struct cairo cairo;
uint32_t width, height;
bool created;
};
struct window {
Display *display;
int32_t screen;
Drawable drawable;
XIM xim;
XIC xic;
Visual *visual;
KeySym keysym;
uint32_t mods;
struct buffer buffer;
uint32_t x, y, width, height, max_height;
uint32_t orig_width, orig_x;
uint32_t hmargin_size;
float width_factor;
uint32_t displayed;
int32_t monitor;
enum bm_align align;
struct {
void (*render)(struct cairo *cairo, uint32_t width, uint32_t max_height, const struct bm_menu *menu, struct cairo_paint_result *result);
} notify;
};
struct x11 {
Display *display;
struct window window;
};
void bm_x11_window_render(struct window *window, const struct bm_menu *menu);
void bm_x11_window_key_press(struct window *window, XKeyEvent *ev);
void bm_x11_window_set_monitor(struct window *window, int32_t monitor);
void bm_x11_window_set_align(struct window *window, enum bm_align align);
void bm_x11_window_set_width(struct window *window, uint32_t margin, float factor);
bool bm_x11_window_create(struct window *window, Display *display);
void bm_x11_window_destroy(struct window *window);
#endif /* _BM_WAYLAND_H_ */
/* vim: set ts=8 sw=4 tw=0 :*/