76e7faf34bdeb822315c247e2c4e2049ad97b5a1
[debian/lxpanel.git] / src / misc.h
1 /**
2 * Copyright (c) 2006-2014 LxDE Developers, see the file AUTHORS for details.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19 #ifndef __MISC_H__
20 #define __MISC_H__ 1
21
22 #include <X11/Xatom.h>
23 #include <gtk/gtk.h>
24 #include <gdk/gdk.h>
25 #include <gdk/gdkx.h>
26 #include <stdio.h>
27 #include <libfm/fm.h>
28
29 #include "panel.h"
30
31 G_BEGIN_DECLS
32
33 extern Atom a_UTF8_STRING;
34 extern Atom a_XROOTPMAP_ID;
35
36 extern Atom a_WM_STATE;
37 extern Atom a_WM_CLASS;
38 extern Atom a_WM_DELETE_WINDOW;
39 extern Atom a_WM_PROTOCOLS;
40 extern Atom a_NET_WORKAREA;
41 extern Atom a_NET_CLIENT_LIST;
42 extern Atom a_NET_CLIENT_LIST_STACKING;
43 extern Atom a_NET_NUMBER_OF_DESKTOPS;
44 extern Atom a_NET_CURRENT_DESKTOP;
45 extern Atom a_NET_DESKTOP_VIEWPORT;
46 extern Atom a_NET_DESKTOP_NAMES;
47 extern Atom a_NET_ACTIVE_WINDOW;
48 extern Atom a_NET_CLOSE_WINDOW;
49 extern Atom a_NET_SHOWING_DESKTOP;
50 extern Atom a_NET_SUPPORTED;
51 extern Atom a_NET_WM_STATE;
52 extern Atom a_NET_WM_STATE_SKIP_TASKBAR;
53 extern Atom a_NET_WM_STATE_SKIP_PAGER;
54 extern Atom a_NET_WM_STATE_STICKY;
55 extern Atom a_NET_WM_STATE_HIDDEN;
56 extern Atom a_NET_WM_STATE_SHADED;
57
58 #define a_NET_WM_STATE_REMOVE 0 /* remove/unset property */
59 #define a_NET_WM_STATE_ADD 1 /* add/set property */
60 #define a_NET_WM_STATE_TOGGLE 2 /* toggle property */
61
62 extern Atom a_NET_WM_WINDOW_TYPE;
63 extern Atom a_NET_WM_WINDOW_TYPE_DESKTOP;
64 extern Atom a_NET_WM_WINDOW_TYPE_DOCK;
65 extern Atom a_NET_WM_WINDOW_TYPE_TOOLBAR;
66 extern Atom a_NET_WM_WINDOW_TYPE_MENU;
67 extern Atom a_NET_WM_WINDOW_TYPE_UTILITY;
68 extern Atom a_NET_WM_WINDOW_TYPE_SPLASH;
69 extern Atom a_NET_WM_WINDOW_TYPE_DIALOG;
70 extern Atom a_NET_WM_WINDOW_TYPE_NORMAL;
71
72 extern Atom a_NET_WM_DESKTOP;
73 extern Atom a_NET_WM_NAME;
74 extern Atom a_NET_WM_VISIBLE_NAME;
75 extern Atom a_NET_WM_STRUT;
76 extern Atom a_NET_WM_STRUT_PARTIAL;
77 extern Atom a_NET_WM_ICON;
78 extern Atom a_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR;
79
80 extern Atom a_NET_SYSTEM_TRAY_OPCODE;
81 extern Atom a_NET_SYSTEM_TRAY_MESSAGE_DATA;
82 extern Atom a_NET_SYSTEM_TRAY_ORIENTATION;
83 extern Atom a_MANAGER;
84
85 extern Atom a_LXPANEL_CMD; /* for private client message */
86
87 /* Decoded value of WM_STATE property. */
88 typedef struct {
89 unsigned int modal : 1;
90 unsigned int sticky : 1;
91 unsigned int maximized_vert : 1;
92 unsigned int maximized_horz : 1;
93 unsigned int shaded : 1;
94 unsigned int skip_taskbar : 1;
95 unsigned int skip_pager : 1;
96 unsigned int hidden : 1;
97 unsigned int fullscreen : 1;
98 unsigned int above : 1;
99 unsigned int below : 1;
100 } NetWMState;
101
102 /* Decoded value of _NET_WM_WINDOW_TYPE property. */
103 typedef struct {
104 unsigned int desktop : 1;
105 unsigned int dock : 1;
106 unsigned int toolbar : 1;
107 unsigned int menu : 1;
108 unsigned int utility : 1;
109 unsigned int splash : 1;
110 unsigned int dialog : 1;
111 unsigned int normal : 1;
112 } NetWMWindowType;
113
114 void Xclimsg(Window win, Atom type, long l0, long l1, long l2, long l3, long l4);
115 void Xclimsgwm(Window win, Atom type, Atom arg);
116 void *get_xaproperty (Window win, Atom prop, Atom type, int *nitems);
117 char *get_textproperty(Window win, Atom prop);
118 void *get_utf8_property(Window win, Atom atom);
119 char **get_utf8_property_list(Window win, Atom atom, int *count);
120
121 void resolve_atoms();
122 //Window Select_Window(Display *dpy);
123 int get_net_number_of_desktops();
124 int get_net_current_desktop ();
125 int get_net_wm_desktop(Window win);
126 int get_wm_state (Window win);
127 void get_net_wm_state(Window win, NetWMState *nws);
128 void get_net_wm_window_type(Window win, NetWMWindowType *nwwt);
129 GPid get_net_wm_pid(Window win);
130
131 /**
132 * panel_handle_x_error
133 * @d: X display
134 * @ev: X error event
135 *
136 * Prints X error message to stderr if logging was enabled.
137 */
138 extern int panel_handle_x_error(Display * d, XErrorEvent * ev);
139 extern int panel_handle_x_error_swallow_BadWindow_BadDrawable(Display * d, XErrorEvent * ev);
140
141 gchar *expand_tilda(const gchar *file);
142
143 void get_button_spacing(GtkRequisition *req, GtkContainer *parent, gchar *name);
144 guint32 gcolor2rgb24(GdkColor *color);
145 GtkWidget *lxpanel_button_new_for_icon(LXPanel *panel, const gchar *name, GdkColor *color, const gchar *label);
146 GtkWidget *lxpanel_button_new_for_fm_icon(LXPanel *panel, FmIcon *icon, GdkColor *color, const gchar *label);
147 void lxpanel_button_set_icon(GtkWidget* btn, const gchar *name, gint size);
148 void lxpanel_button_update_icon(GtkWidget* btn, FmIcon *icon, gint size);
149
150 G_END_DECLS
151
152 #endif