summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2015-04-02 22:23:17 +0200
committerDave Davenport <qball@gmpclient.org>2015-04-02 22:23:17 +0200
commit0ab7aa4bbac021bab76be59dde83cf0a516d4e08 (patch)
tree45a6355b9be661b3a1357c9481c14cfc9b4044c6
parent2b340a47624c0a6f6e9f485185148536981b0e04 (diff)
Add italic support and use it for windows that demand attention (working?)
-rw-r--r--include/textbox.h15
-rw-r--r--include/x11-helper.h27
-rw-r--r--source/dialogs/window.c11
-rw-r--r--source/textbox.c5
4 files changed, 36 insertions, 22 deletions
diff --git a/include/textbox.h b/include/textbox.h
index 4177cf98..b035ecee 100644
--- a/include/textbox.h
+++ b/include/textbox.h
@@ -23,12 +23,12 @@ typedef struct
typedef enum
{
- TB_AUTOHEIGHT = 1 << 0,
- TB_AUTOWIDTH = 1 << 1,
- TB_LEFT = 1 << 16,
- TB_RIGHT = 1 << 17,
- TB_CENTER = 1 << 18,
- TB_EDITABLE = 1 << 19,
+ TB_AUTOHEIGHT = 1 << 0,
+ TB_AUTOWIDTH = 1 << 1,
+ TB_LEFT = 1 << 16,
+ TB_RIGHT = 1 << 17,
+ TB_CENTER = 1 << 18,
+ TB_EDITABLE = 1 << 19,
} TextboxFlags;
@@ -44,6 +44,9 @@ typedef enum
STATE_MASK = ( NORMAL | ALT | HIGHLIGHT ),
BOLD = 8,
+ ITALIC = 16,
+
+ FMOD_MASK = ( BOLD | ITALIC )
} TextBoxFontType;
textbox* textbox_create ( Window parent,
diff --git a/include/x11-helper.h b/include/x11-helper.h
index dae16772..3df9f8fb 100644
--- a/include/x11-helper.h
+++ b/include/x11-helper.h
@@ -30,19 +30,20 @@ int window_get_cardinal_prop ( Display *display, Window w, Atom atom, unsigned l
#define ATOM_CHAR( x ) # x
// usable space on a monitor
-#define EWMH_ATOMS( X ) \
- X ( _NET_CLIENT_LIST_STACKING ), \
- X ( _NET_NUMBER_OF_DESKTOPS ), \
- X ( _NET_CURRENT_DESKTOP ), \
- X ( _NET_ACTIVE_WINDOW ), \
- X ( _NET_WM_NAME ), \
- X ( _NET_WM_STATE ), \
- X ( _NET_WM_STATE_SKIP_TASKBAR ), \
- X ( _NET_WM_STATE_SKIP_PAGER ), \
- X ( _NET_WM_STATE_ABOVE ), \
- X ( _NET_WM_DESKTOP ), \
- X ( CLIPBOARD ), \
- X ( UTF8_STRING ), \
+#define EWMH_ATOMS( X ) \
+ X ( _NET_CLIENT_LIST_STACKING ), \
+ X ( _NET_NUMBER_OF_DESKTOPS ), \
+ X ( _NET_CURRENT_DESKTOP ), \
+ X ( _NET_ACTIVE_WINDOW ), \
+ X ( _NET_WM_NAME ), \
+ X ( _NET_WM_STATE ), \
+ X ( _NET_WM_STATE_SKIP_TASKBAR ), \
+ X ( _NET_WM_STATE_SKIP_PAGER ), \
+ X ( _NET_WM_STATE_ABOVE ), \
+ X ( _NET_WM_STATE_DEMANDS_ATTENTION ), \
+ X ( _NET_WM_DESKTOP ), \
+ X ( CLIPBOARD ), \
+ X ( UTF8_STRING ), \
X ( _NET_WM_WINDOW_OPACITY )
enum { EWMH_ATOMS ( ATOM_ENUM ), NUM_NETATOMS };
diff --git a/source/dialogs/window.c b/source/dialogs/window.c
index 8b01ed1a..4c8d8057 100644
--- a/source/dialogs/window.c
+++ b/source/dialogs/window.c
@@ -47,7 +47,7 @@
#define CLIENTTITLE 100
#define CLIENTCLASS 50
#define CLIENTNAME 50
-#define CLIENTSTATE 10
+#define CLIENTSTATE 20
#define CLIENTROLE 50
// a manageable window
@@ -63,6 +63,7 @@ typedef struct
Atom state[CLIENTSTATE];
workarea monitor;
int active;
+ int demands;
} client;
// TODO
extern Display *display;
@@ -397,6 +398,9 @@ static char ** window_mode_get_data ( unsigned int *length, Switcher *sw )
if ( pd->config_i3_mode && strstr ( c->class, "i3bar" ) != NULL ) {
continue;
}
+ if ( client_has_state ( c, netatoms[_NET_WM_STATE_DEMANDS_ATTENTION] ) ) {
+ c->demands = TRUE;
+ }
if ( c->window == curr_win_id ) {
c->active = TRUE;
@@ -508,8 +512,11 @@ static void window_mode_destroy ( Switcher *sw )
static const char *mgrv ( unsigned int selected_line, void *sw, G_GNUC_UNUSED int *state )
{
SwitcherModePrivateData *rmpd = ( (Switcher *) sw )->private_data;
+ if ( window_client ( display, rmpd->ids->array[selected_line] )->demands ) {
+ *state |= ITALIC;
+ }
if ( window_client ( display, rmpd->ids->array[selected_line] )->active ) {
- *state = BOLD;
+ *state |= BOLD;
}
return rmpd->cmd_list[selected_line];
}
diff --git a/source/textbox.c b/source/textbox.c
index 78632559..f1144d91 100644
--- a/source/textbox.c
+++ b/source/textbox.c
@@ -127,11 +127,14 @@ textbox* textbox_create ( Window parent,
// set an Xft font by name
void textbox_font ( textbox *tb, TextBoxFontType tbft )
{
- if ( ( tbft & BOLD ) != ( tb->tbft & BOLD ) ) {
+ if ( ( tbft & FMOD_MASK ) != ( tb->tbft & FMOD_MASK ) ) {
PangoFontDescription *pfd = pango_font_description_from_string ( config.menu_font );
if ( ( tbft & BOLD ) == BOLD ) {
pango_font_description_set_weight ( pfd, PANGO_WEIGHT_BOLD );
}
+ if ( ( tbft & ITALIC ) == ITALIC ) {
+ pango_font_description_set_style ( pfd, PANGO_STYLE_ITALIC );
+ }
pango_layout_set_font_description ( tb->layout, pfd );
pango_font_description_free ( pfd );
}