more functions to support E17

SVN revision: 4075
This commit is contained in:
Carsten Haitzler 2001-01-02 23:09:49 +00:00
parent 72a83a2724
commit cacfc4d7a1
3 changed files with 86 additions and 6 deletions

View File

@ -79,11 +79,10 @@ void e_sync(void);
void e_flush(void);
Window e_window_new(Window parent, int x, int y, int w, int h);
Window e_window_override_new(Window parent, int x, int y, int w,
int h);
Window e_window_input_new(Window parent, int x, int y, int w,
int h);
void e_window_set_events_propagate(Window win, int propagate);
void e_window_show(Window win);
void e_window_hide(Window win);
Pixmap e_pixmap_new(Window win, int w, int h, int dep);
@ -268,7 +267,10 @@ int e_window_is_manageable(Window win);
void e_windows_restack(Window *wins, int num);
void e_window_stack_above(Window win, Window above);
void e_window_stack_below(Window win, Window below);
char *e_window_get_title(Window win);
void e_keyboard_grab(Window win);
void e_keyboard_ungrab(void);
typedef struct _eev Eevent;
typedef struct _ev_fd_handler Ev_Fd_Handler;
typedef struct _ev_pid_handler Ev_Pid_Handler;

View File

@ -443,7 +443,7 @@ e_ev_x_handle_enter_notify(XEvent * xevent)
{
Ev_Window_Enter *e;
if ((xevent->xcrossing.mode == NotifyGrab) || (xevent->xcrossing.mode == NotifyUngrab)) return;
/* if ((xevent->xcrossing.mode == NotifyGrab) || (xevent->xcrossing.mode == NotifyUngrab)) return;*/
e_pointer_xy_set(xevent->xcrossing.x_root, xevent->xcrossing.y_root);
e = NEW(Ev_Window_Enter, 1);
e->win = xevent->xcrossing.window;
@ -477,7 +477,7 @@ e_ev_x_handle_leave_notify(XEvent * xevent)
{
Ev_Window_Leave *e;
if ((xevent->xcrossing.mode == NotifyGrab) || (xevent->xcrossing.mode == NotifyUngrab)) return;
/* if ((xevent->xcrossing.mode == NotifyGrab) || (xevent->xcrossing.mode == NotifyUngrab)) return;*/
e_pointer_xy_set(xevent->xcrossing.x_root, xevent->xcrossing.y_root);
{
Ev_Mouse_Move *e;

View File

@ -354,6 +354,20 @@ e_window_input_new(Window parent, int x, int y, int w, int h)
return win;
}
void
e_window_set_events_propagate(Window win, int propagate)
{
XSetWindowAttributes attr;
if (!win)
win = default_root;
if (!propagate)
attr.do_not_propagate_mask = True;
else
attr.do_not_propagate_mask = False;
XChangeWindowAttributes(disp, win, CWDontPropagate, &attr);
}
void
e_window_show(Window win)
{
@ -782,7 +796,11 @@ e_key_get_keysym_from_keycode(KeyCode keycode)
char *
e_key_get_string_from_keycode(KeyCode keycode)
{
return strdup(XKeysymToString(e_key_get_keysym_from_keycode(keycode)));
char *str;
str = XKeysymToString(e_key_get_keysym_from_keycode(keycode));
if (!str) return strdup("");
return strdup(str);
}
void
@ -2798,6 +2816,8 @@ e_window_stack_above(Window win, Window above)
{
XWindowChanges xwc;
if (win == 0)
win = default_root;
xwc.sibling = above;
xwc.stack_mode = Above;
XConfigureWindow(disp, win, CWSibling | CWStackMode, &xwc);
@ -2808,7 +2828,65 @@ e_window_stack_below(Window win, Window below)
{
XWindowChanges xwc;
if (win == 0)
win = default_root;
xwc.sibling = below;
xwc.stack_mode = Below;
XConfigureWindow(disp, win, CWSibling | CWStackMode, &xwc);
}
char *
e_window_get_title(Window win)
{
XTextProperty xtp;
if (win == 0)
win = default_root;
if (XGetWMName(disp, win, &xtp))
{
int items;
char **list;
Status s;
char *title = NULL;
if (xtp.format == 8)
{
s = XmbTextPropertyToTextList(disp, &xtp, &list, &items);
if ((s == Success) && (items > 0))
{
title = strdup(*list);
XFreeStringList(list);
}
else title = strdup((char *)xtp.value);
}
else title = strdup((char *)xtp.value);
XFree(xtp.value);
return title;
}
return NULL;
}
static Window keyboard_grab_win = 0;
void
e_keyboard_grab(Window win)
{
int status;
if (keyboard_grab_win) return;
if (win == 0)
win = default_root;
keyboard_grab_win = win;
status = XGrabKeyboard(disp, win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
if ((status == AlreadyGrabbed) || (status == GrabNotViewable) ||
(status == GrabFrozen) || (status == GrabInvalidTime))
keyboard_grab_win = 0;
}
void
e_keyboard_ungrab(void)
{
if (!keyboard_grab_win) return;
keyboard_grab_win = 0;
XUngrabKeyboard(disp, CurrentTime);
}