key input works for ObPrompt windows now
[dana/openbox.git] / openbox / prompt.h
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    prompt.h for the Openbox window manager
4    Copyright (c) 2008        Dana Jansens
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #ifndef ob__prompt_h
20 #define ob__prompt_h
21
22 typedef struct _ObPrompt       ObPrompt;
23 typedef struct _ObPromptElement ObPromptElement;
24
25 #include "window.h"
26 #include "geom.h"
27 #include "render/render.h"
28 #include <glib.h>
29 #include <X11/Xlib.h>
30
31 struct _ObPromptElement {
32     gchar *text;
33     Window window;
34
35     gint x, y, width, height;
36     gboolean pressed;
37 };
38
39 struct _ObPrompt
40 {
41     InternalWindow super;
42     gint ref;
43
44     guint event_mask;
45
46     /* keep a copy of this because we re-render things that may need it
47        (i.e. the buttons) */
48     RrAppearance *a_bg;
49
50     gboolean mapped;
51     gint width, height;
52     gint msg_wbound;
53
54     ObPromptElement msg;
55
56     /* one for each answer */
57     ObPromptElement *button;
58     guint n_buttons;
59
60     /* points to the button with the focus */
61     ObPromptElement *focus;
62 };
63
64 void prompt_startup(gboolean reconfig);
65 void prompt_shutdown(gboolean reconfig);
66
67 ObPrompt* prompt_new(const gchar *msg, const gchar *const *answers);
68 void prompt_ref(ObPrompt *self);
69 void prompt_unref(ObPrompt *self);
70
71 /*! Show the prompt.  It will be centered within the given area rectangle */
72 void prompt_show(ObPrompt *self, struct _ObClient *parent);
73 void prompt_hide(ObPrompt *self);
74
75 void prompt_key_event(ObPrompt *self, XEvent *e);
76 void prompt_mouse_event(ObPrompt *self, XEvent *e);
77
78 #endif