From 66bd7af3e59e509000b8a55a9429e7a8e133fd81 Mon Sep 17 00:00:00 2001
From: Simeon Simeonov
Date: Tue, 14 Mar 2023 23:30:32 +0100
Subject: Sync with upstream 2.14.1 and update the documentation
---
include/cursors.h | 8 ++++
include/dpi.h | 22 ++++++++++
include/extras.h | 106 +++++++++++++++++++++++++++++++++++++++++++++
include/i3lock.h | 15 +++++++
include/randr.h | 17 ++++++++
include/unlock_indicator.h | 29 +++++++++++++
include/xcb.h | 17 ++++++++
7 files changed, 214 insertions(+)
create mode 100644 include/cursors.h
create mode 100644 include/dpi.h
create mode 100644 include/extras.h
create mode 100644 include/i3lock.h
create mode 100644 include/randr.h
create mode 100644 include/unlock_indicator.h
create mode 100644 include/xcb.h
(limited to 'include')
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 @@
+#ifndef _CURSORS_H
+#define _CURSORS_H
+
+#define CURS_NONE 0
+#define CURS_WIN 1
+#define CURS_DEFAULT 2
+
+#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 @@
+#pragma once
+
+/**
+ * Initialize the DPI setting.
+ * This will use the 'Xft.dpi' X resource if available and fall back to
+ * guessing the correct value otherwise.
+ */
+void init_dpi(void);
+
+/**
+ * This function returns the value of the DPI setting.
+ *
+ */
+long get_dpi_value(void);
+
+/**
+ * Convert a logical amount of pixels (e.g. 2 pixels on a “standard” 96 DPI
+ * screen) to a corresponding amount of physical pixels on a standard or retina
+ * screen, e.g. 5 pixels on a 227 DPI MacBook Pro 13" Retina screen.
+ *
+ */
+int 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 @@
+/*
+ * This file is part of i3lock-extended
+ * Copyright (C) 2020-2023 Simeon Simeonov
+
+ * i3lock-extended is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * i3lock-extended is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef EXTRAS_H
+#define EXTRAS_H
+
+#include
+
+
+#define I3LOCK_SCALE_LED_LENGTH 60
+#define I3LOCK_SCALE_LED_SPACING 30
+
+
+typedef enum {
+
+ I3LOCK_ALIGN_LEFT = 0,
+ I3LOCK_ALIGN_CENTER,
+ I3LOCK_ALIGN_RIGHT
+
+} i3lock_horizontal_alignment;
+
+
+typedef enum {
+
+ I3LOCK_ALIGN_TOP = 0,
+ I3LOCK_ALIGN_MIDDLE,
+ I3LOCK_ALIGN_BOTTOM
+
+} i3lock_vertical_alignment;
+
+
+typedef struct i3lock_digital_clock_t_ {
+
+ int text_size;
+ char color[7];
+ char *template;
+ i3lock_horizontal_alignment horizontal_alignment;
+ i3lock_vertical_alignment vertical_alignment;
+
+} i3lock_digital_clock_t;
+
+
+typedef struct i3lock_elapsed_time_t_ {
+
+ int text_size;
+ char color[7];
+ time_t start_time;
+ i3lock_horizontal_alignment horizontal_alignment;
+ i3lock_vertical_alignment vertical_alignment;
+
+} i3lock_elapsed_time_t;
+
+
+typedef struct i3lock_led_clock_t_ {
+
+ char led_on_color[7];
+ char led_off_color[7];
+ char led_border_color[7];
+ i3lock_horizontal_alignment horizontal_alignment;
+ i3lock_vertical_alignment vertical_alignment;
+
+} i3lock_led_clock_t;
+
+
+void i3lock_draw_digital_clock(cairo_t *cr,
+ const i3lock_digital_clock_t *dc,
+ const uint32_t *resolution,
+ const struct tm *brokentime);
+
+
+void i3lock_draw_elapsed_time(cairo_t *cr,
+ const i3lock_elapsed_time_t *et,
+ const uint32_t *resolution,
+ const time_t *now);
+
+void i3lock_draw_led_clock(cairo_t *cr,
+ const i3lock_led_clock_t *lc,
+ const uint32_t *resolution,
+ const struct tm *brokentime);
+
+
+void i3lock_draw_string(cairo_t *cr,
+ const char *formatted_string,
+ const i3lock_elapsed_time_t *et,
+ const uint32_t *resolution);
+
+char * i3lock_format_elapsed_time(char *to,
+ const char *template,
+ int max_size,
+ int seconds);
+#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 @@
+#ifndef _I3LOCK_H
+#define _I3LOCK_H
+
+/* This macro will only print debug output when started with --debug.
+ * This is important because xautolock (for example) closes stdout/stderr by
+ * default, so just printing something to stdout will lead to the data ending
+ * up on the X11 socket (!). */
+#define DEBUG(fmt, ...) \
+ do { \
+ if (debug_mode) { \
+ fprintf(stderr, "[i3lock-extended-debug] " fmt, ##__VA_ARGS__); \
+ } \
+ } while (0)
+
+#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 @@
+#ifndef _XINERAMA_H
+#define _XINERAMA_H
+
+typedef struct Rect {
+ int16_t x;
+ int16_t y;
+ uint16_t width;
+ uint16_t height;
+} Rect;
+
+extern int xr_screens;
+extern Rect *xr_resolutions;
+
+void randr_init(int *event_base, xcb_window_t root);
+void randr_query(xcb_window_t root);
+
+#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 @@
+#ifndef _UNLOCK_INDICATOR_H
+#define _UNLOCK_INDICATOR_H
+
+#include
+
+typedef enum {
+ STATE_STARTED = 0, /* default state */
+ STATE_KEY_PRESSED = 1, /* key was pressed, show unlock indicator */
+ STATE_KEY_ACTIVE = 2, /* a key was pressed recently, highlight part
+ of the unlock indicator. */
+ STATE_BACKSPACE_ACTIVE = 3, /* backspace was pressed recently, highlight
+ part of the unlock indicator in red. */
+ STATE_NOTHING_TO_DELETE = 4, /* backspace was pressed, but there is nothing to delete. */
+} unlock_state_t;
+
+typedef enum {
+ STATE_AUTH_IDLE = 0, /* no authenticator interaction at the moment */
+ STATE_AUTH_VERIFY = 1, /* currently verifying the password via authenticator */
+ STATE_AUTH_LOCK = 2, /* currently locking the screen */
+ STATE_AUTH_WRONG = 3, /* the password was wrong */
+ STATE_I3LOCK_LOCK_FAILED = 4, /* i3lock failed to load */
+} auth_state_t;
+
+void free_bg_pixmap(void);
+void draw_image(xcb_pixmap_t bg_pixmap, uint32_t* resolution);
+void redraw_screen(void);
+void clear_indicator(void);
+
+#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 @@
+#ifndef _XCB_H
+#define _XCB_H
+
+#include
+
+extern xcb_connection_t *conn;
+extern xcb_screen_t *screen;
+
+xcb_visualtype_t *get_root_visual_type(xcb_screen_t *s);
+xcb_pixmap_t create_bg_pixmap(xcb_connection_t *conn, xcb_screen_t *scr, u_int32_t *resolution, char *color);
+xcb_window_t open_fullscreen_window(xcb_connection_t *conn, xcb_screen_t *scr, char *color, xcb_pixmap_t pixmap);
+bool grab_pointer_and_keyboard(xcb_connection_t *conn, xcb_screen_t *screen, xcb_cursor_t cursor, int tries);
+xcb_cursor_t create_cursor(xcb_connection_t *conn, xcb_screen_t *screen, xcb_window_t win, int choice);
+xcb_window_t find_focused_window(xcb_connection_t *conn, const xcb_window_t root);
+void set_focused_window(xcb_connection_t *conn, const xcb_window_t root, const xcb_window_t window);
+
+#endif
--
cgit v1.3