summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/cursors.h8
-rw-r--r--include/dpi.h22
-rw-r--r--include/extras.h106
-rw-r--r--include/i3lock.h15
-rw-r--r--include/randr.h17
-rw-r--r--include/unlock_indicator.h29
-rw-r--r--include/xcb.h17
7 files changed, 214 insertions, 0 deletions
diff --git a/include/cursors.h b/include/cursors.h
new file mode 100644
index 0000000..bfce895
--- /dev/null
+++ b/include/cursors.h
@@ -0,0 +1,8 @@
1#ifndef _CURSORS_H
2#define _CURSORS_H
3
4#define CURS_NONE 0
5#define CURS_WIN 1
6#define CURS_DEFAULT 2
7
8#endif
diff --git a/include/dpi.h b/include/dpi.h
new file mode 100644
index 0000000..35840d2
--- /dev/null
+++ b/include/dpi.h
@@ -0,0 +1,22 @@
1#pragma once
2
3/**
4 * Initialize the DPI setting.
5 * This will use the 'Xft.dpi' X resource if available and fall back to
6 * guessing the correct value otherwise.
7 */
8void init_dpi(void);
9
10/**
11 * This function returns the value of the DPI setting.
12 *
13 */
14long get_dpi_value(void);
15
16/**
17 * Convert a logical amount of pixels (e.g. 2 pixels on a “standard” 96 DPI
18 * screen) to a corresponding amount of physical pixels on a standard or retina
19 * screen, e.g. 5 pixels on a 227 DPI MacBook Pro 13" Retina screen.
20 *
21 */
22int logical_px(const int logical);
diff --git a/include/extras.h b/include/extras.h
new file mode 100644
index 0000000..4f791d8
--- /dev/null
+++ b/include/extras.h
@@ -0,0 +1,106 @@
1/*
2 * This file is part of i3lock-extended
3 * Copyright (C) 2020-2023 Simeon Simeonov
4
5 * i3lock-extended is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9
10 * i3lock-extended is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef EXTRAS_H
20#define EXTRAS_H
21
22#include <time.h>
23
24
25#define I3LOCK_SCALE_LED_LENGTH 60
26#define I3LOCK_SCALE_LED_SPACING 30
27
28
29typedef enum {
30
31 I3LOCK_ALIGN_LEFT = 0,
32 I3LOCK_ALIGN_CENTER,
33 I3LOCK_ALIGN_RIGHT
34
35} i3lock_horizontal_alignment;
36
37
38typedef enum {
39
40 I3LOCK_ALIGN_TOP = 0,
41 I3LOCK_ALIGN_MIDDLE,
42 I3LOCK_ALIGN_BOTTOM
43
44} i3lock_vertical_alignment;
45
46
47typedef struct i3lock_digital_clock_t_ {
48
49 int text_size;
50 char color[7];
51 char *template;
52 i3lock_horizontal_alignment horizontal_alignment;
53 i3lock_vertical_alignment vertical_alignment;
54
55} i3lock_digital_clock_t;
56
57
58typedef struct i3lock_elapsed_time_t_ {
59
60 int text_size;
61 char color[7];
62 time_t start_time;
63 i3lock_horizontal_alignment horizontal_alignment;
64 i3lock_vertical_alignment vertical_alignment;
65
66} i3lock_elapsed_time_t;
67
68
69typedef struct i3lock_led_clock_t_ {
70
71 char led_on_color[7];
72 char led_off_color[7];
73 char led_border_color[7];
74 i3lock_horizontal_alignment horizontal_alignment;
75 i3lock_vertical_alignment vertical_alignment;
76
77} i3lock_led_clock_t;
78
79
80void i3lock_draw_digital_clock(cairo_t *cr,
81 const i3lock_digital_clock_t *dc,
82 const uint32_t *resolution,
83 const struct tm *brokentime);
84
85
86void i3lock_draw_elapsed_time(cairo_t *cr,
87 const i3lock_elapsed_time_t *et,
88 const uint32_t *resolution,
89 const time_t *now);
90
91void i3lock_draw_led_clock(cairo_t *cr,
92 const i3lock_led_clock_t *lc,
93 const uint32_t *resolution,
94 const struct tm *brokentime);
95
96
97void i3lock_draw_string(cairo_t *cr,
98 const char *formatted_string,
99 const i3lock_elapsed_time_t *et,
100 const uint32_t *resolution);
101
102char * i3lock_format_elapsed_time(char *to,
103 const char *template,
104 int max_size,
105 int seconds);
106#endif
diff --git a/include/i3lock.h b/include/i3lock.h
new file mode 100644
index 0000000..6cf7694
--- /dev/null
+++ b/include/i3lock.h
@@ -0,0 +1,15 @@
1#ifndef _I3LOCK_H
2#define _I3LOCK_H
3
4/* This macro will only print debug output when started with --debug.
5 * This is important because xautolock (for example) closes stdout/stderr by
6 * default, so just printing something to stdout will lead to the data ending
7 * up on the X11 socket (!). */
8#define DEBUG(fmt, ...) \
9 do { \
10 if (debug_mode) { \
11 fprintf(stderr, "[i3lock-extended-debug] " fmt, ##__VA_ARGS__); \
12 } \
13 } while (0)
14
15#endif
diff --git a/include/randr.h b/include/randr.h
new file mode 100644
index 0000000..510a7cb
--- /dev/null
+++ b/include/randr.h
@@ -0,0 +1,17 @@
1#ifndef _XINERAMA_H
2#define _XINERAMA_H
3
4typedef struct Rect {
5 int16_t x;
6 int16_t y;
7 uint16_t width;
8 uint16_t height;
9} Rect;
10
11extern int xr_screens;
12extern Rect *xr_resolutions;
13
14void randr_init(int *event_base, xcb_window_t root);
15void randr_query(xcb_window_t root);
16
17#endif
diff --git a/include/unlock_indicator.h b/include/unlock_indicator.h
new file mode 100644
index 0000000..581d028
--- /dev/null
+++ b/include/unlock_indicator.h
@@ -0,0 +1,29 @@
1#ifndef _UNLOCK_INDICATOR_H
2#define _UNLOCK_INDICATOR_H
3
4#include <xcb/xcb.h>
5
6typedef enum {
7 STATE_STARTED = 0, /* default state */
8 STATE_KEY_PRESSED = 1, /* key was pressed, show unlock indicator */
9 STATE_KEY_ACTIVE = 2, /* a key was pressed recently, highlight part
10 of the unlock indicator. */
11 STATE_BACKSPACE_ACTIVE = 3, /* backspace was pressed recently, highlight
12 part of the unlock indicator in red. */
13 STATE_NOTHING_TO_DELETE = 4, /* backspace was pressed, but there is nothing to delete. */
14} unlock_state_t;
15
16typedef enum {
17 STATE_AUTH_IDLE = 0, /* no authenticator interaction at the moment */
18 STATE_AUTH_VERIFY = 1, /* currently verifying the password via authenticator */
19 STATE_AUTH_LOCK = 2, /* currently locking the screen */
20 STATE_AUTH_WRONG = 3, /* the password was wrong */
21 STATE_I3LOCK_LOCK_FAILED = 4, /* i3lock failed to load */
22} auth_state_t;
23
24void free_bg_pixmap(void);
25void draw_image(xcb_pixmap_t bg_pixmap, uint32_t* resolution);
26void redraw_screen(void);
27void clear_indicator(void);
28
29#endif
diff --git a/include/xcb.h b/include/xcb.h
new file mode 100644
index 0000000..3555c58
--- /dev/null
+++ b/include/xcb.h
@@ -0,0 +1,17 @@
1#ifndef _XCB_H
2#define _XCB_H
3
4#include <xcb/xcb.h>
5
6extern xcb_connection_t *conn;
7extern xcb_screen_t *screen;
8
9xcb_visualtype_t *get_root_visual_type(xcb_screen_t *s);
10xcb_pixmap_t create_bg_pixmap(xcb_connection_t *conn, xcb_screen_t *scr, u_int32_t *resolution, char *color);
11xcb_window_t open_fullscreen_window(xcb_connection_t *conn, xcb_screen_t *scr, char *color, xcb_pixmap_t pixmap);
12bool grab_pointer_and_keyboard(xcb_connection_t *conn, xcb_screen_t *screen, xcb_cursor_t cursor, int tries);
13xcb_cursor_t create_cursor(xcb_connection_t *conn, xcb_screen_t *screen, xcb_window_t win, int choice);
14xcb_window_t find_focused_window(xcb_connection_t *conn, const xcb_window_t root);
15void set_focused_window(xcb_connection_t *conn, const xcb_window_t root, const xcb_window_t window);
16
17#endif