From 7f12c5c0620f322bd26e6e4b80bba612dd2a93ed Mon Sep 17 00:00:00 2001 From: Term Date: Tue, 16 Oct 2001 15:45:29 +0000 Subject: [PATCH] By popular demand, I'm committing the collisionless naming scheme now, even though E17 itself hasn't been updated. I don't like having to hand-merge raster's changes anyway. :) SVN revision: 5498 --- legacy/ecore/AUTHORS | 1 + legacy/ecore/src/Ecore.h | 1403 +++++---- legacy/ecore/src/e_ev_filter.c | 180 +- legacy/ecore/src/e_ev_signal.c | 380 +-- legacy/ecore/src/e_ev_x.c | 1909 ++++++------ legacy/ecore/src/e_events.c | 653 ++-- legacy/ecore/src/e_ipc.c | 134 +- legacy/ecore/src/e_util.c | 8 +- legacy/ecore/src/e_x.c | 5185 ++++++++++++++++---------------- 9 files changed, 4992 insertions(+), 4861 deletions(-) diff --git a/legacy/ecore/AUTHORS b/legacy/ecore/AUTHORS index cb54c18bba..69afa43acf 100644 --- a/legacy/ecore/AUTHORS +++ b/legacy/ecore/AUTHORS @@ -2,3 +2,4 @@ The Rasterman Tom Gilbert Burra Chris Ross +Term diff --git a/legacy/ecore/src/Ecore.h b/legacy/ecore/src/Ecore.h index f6345c6699..9551aa45f9 100644 --- a/legacy/ecore/src/Ecore.h +++ b/legacy/ecore/src/Ecore.h @@ -40,759 +40,824 @@ extern XContext xid_context; -typedef struct _e_xid E_XID; -typedef struct _e_keygrab E_KeyGrab; +typedef void (*Ecore_Error_Function) (Display * d, XErrorEvent * ev); -enum _ev_modifiers +typedef struct _ecore_xid Ecore_XID; +typedef struct _ecore_keygrab Ecore_KeyGrab; + +enum _ecore_ev_modifiers { - EV_KEY_MODIFIER_NONE = 0, - EV_KEY_MODIFIER_SHIFT = (1 << 0), - EV_KEY_MODIFIER_CTRL = (1 << 1), - EV_KEY_MODIFIER_ALT = (1 << 2), - EV_KEY_MODIFIER_WIN = (1 << 3) + ECORE_EVENT_KEY_MODIFIER_NONE = 0, + ECORE_EVENT_KEY_MODIFIER_SHIFT = (1 << 0), + ECORE_EVENT_KEY_MODIFIER_CTRL = (1 << 1), + ECORE_EVENT_KEY_MODIFIER_ALT = (1 << 2), + ECORE_EVENT_KEY_MODIFIER_WIN = (1 << 3) }; -typedef enum _ev_modifiers Ev_Key_Modifiers; +typedef enum _ecore_ev_modifiers Ecore_Event_Key_Modifiers; -struct _e_xid +struct _ecore_xid { - Window win; - Window parent; - Window root; - int children_num; - Window *children; - int x, y, w, h; - int mapped; - int mouse_in; - int depth; - int gravity; - int coords_invalid; - int bw; - int grab_button_auto_replay; + Window win; + Window parent; + Window root; + int children_num; + Window *children; + int x, y, w, h; + int mapped; + int mouse_in; + int depth; + int gravity; + int coords_invalid; + int bw; + int grab_button_auto_replay; }; #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif -void e_del_child(Window win, Window child); -void e_add_child(Window win, Window child); -void e_raise_child(Window win, Window child); -void e_lower_child(Window win, Window child); -E_XID *e_add_xid(Window win, int x, int y, int w, int h, int depth, - Window parent); -E_XID *e_validate_xid(Window win); -void e_unvalidate_xid(Window win); -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, + void ecore_del_child(Window win, Window child); + void ecore_add_child(Window win, Window child); + void ecore_raise_child(Window win, Window child); + void ecore_lower_child(Window win, Window child); + Ecore_XID *ecore_add_xid(Window win, int x, int y, int w, int h, + int depth, Window parent); + Ecore_XID *ecore_validate_xid(Window win); + void ecore_unvalidate_xid(Window win); + void ecore_sync(void); + void ecore_flush(void); + Window ecore_window_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); -void e_pixmap_free(Pixmap pmap); -void e_window_set_background_pixmap(Window win, Pixmap pmap); -void e_window_set_shape_mask(Window win, Pixmap mask); -void e_window_add_shape_mask(Window win, Pixmap mask); -void e_window_set_shape_window(Window win, Window src, int x, int y); -void e_window_add_shape_window(Window win, Window src, int x, int y); -void e_window_set_shape_rectangle(Window win, int x, int y, int w, int h); -void e_window_add_shape_rectangle(Window win, int x, int y, int w, int h); -void e_window_set_shape_rectangles(Window win, XRectangle *rect, int num); -void e_window_add_shape_rectangles(Window win, XRectangle *rect, int num); -void e_window_clip_shape_by_rectangle(Window win, int x, int y, int w, int h); -XRectangle *e_window_get_shape_rectangles(Window win, int *num); -void e_window_select_shape_events(Window win); -void e_window_unselect_shape_events(Window win); -void e_window_clear(Window win); -void e_window_clear_area(Window win, int x, int y, int w, int h); -void e_pointer_xy(Window win, int *x, int *y); -void e_pointer_xy_set(int x, int y); -void e_pointer_xy_get(int *x, int *y); -void e_window_set_events(Window win, long mask); -void e_window_remove_events(Window win, long mask); -void e_window_add_events(Window win, long mask); -void e_window_move(Window win, int x, int y); -void e_window_resize(Window win, int w, int h); -void e_window_move_resize(Window win, int x, int y, int w, - int h); -int e_x_get_fd(void); -void e_set_error_handler(void (*func) (Display * d, XErrorEvent * ev)); -void e_reset_error_handler(void); -int e_display_init(char *display); -int e_events_pending(void); -void e_get_next_event(XEvent * event); -int e_event_shape_get_id(void); -KeySym e_key_get_keysym_from_keycode(KeyCode keycode); -char *e_key_get_string_from_keycode(KeyCode keycode); -void e_event_allow(int mode, Time t); -int e_lock_mask_scroll_get(void); -int e_lock_mask_num_get(void); -int e_lock_mask_caps_get(void); -int e_mod_mask_shift_get(void); -int e_mod_mask_ctrl_get(void); -int e_mod_mask_alt_get(void); -int e_mod_mask_win_get(void); -int e_lock_mask_get(void); -int e_modifier_mask_get(void); -Window e_get_key_grab_win(void); -void e_key_grab(char *key, Ev_Key_Modifiers mods, int anymod, + Window ecore_window_override_new(Window parent, int x, int y, + int w, int h); + Window ecore_window_input_new(Window parent, int x, int y, int w, + int h); + void ecore_window_set_events_propagate(Window win, + int propagate); + void ecore_window_show(Window win); + void ecore_window_hide(Window win); + Pixmap ecore_pixmap_new(Window win, int w, int h, int dep); + void ecore_pixmap_free(Pixmap pmap); + void ecore_window_set_background_pixmap(Window win, + Pixmap pmap); + void ecore_window_set_shape_mask(Window win, Pixmap mask); + void ecore_window_add_shape_mask(Window win, Pixmap mask); + void ecore_window_set_shape_window(Window win, Window src, + int x, int y); + void ecore_window_add_shape_window(Window win, Window src, + int x, int y); + void ecore_window_set_shape_rectangle(Window win, int x, int y, + int w, int h); + void ecore_window_add_shape_rectangle(Window win, int x, int y, + int w, int h); + void ecore_window_set_shape_rectangles(Window win, + XRectangle * rect, + int num); + void ecore_window_add_shape_rectangles(Window win, + XRectangle * rect, + int num); + void ecore_window_clip_shape_by_rectangle(Window win, int x, + int y, int w, int h); + XRectangle *ecore_window_get_shape_rectangles(Window win, int *num); + void ecore_window_select_shape_events(Window win); + void ecore_window_unselect_shape_events(Window win); + void ecore_window_clear(Window win); + void ecore_window_clear_area(Window win, int x, int y, int w, + int h); + void ecore_pointer_xy(Window win, int *x, int *y); + void ecore_pointer_xy_set(int x, int y); + void ecore_pointer_xy_get(int *x, int *y); + void ecore_window_set_events(Window win, long mask); + void ecore_window_remove_events(Window win, long mask); + void ecore_window_add_events(Window win, long mask); + void ecore_window_move(Window win, int x, int y); + void ecore_window_resize(Window win, int w, int h); + void ecore_window_move_resize(Window win, int x, int y, int w, + int h); + int ecore_x_get_fd(void); + void ecore_set_error_handler(Ecore_Error_Function * func); + void ecore_reset_error_handler(void); + int ecore_display_init(char *display); + int ecore_events_pending(void); + void ecore_get_next_event(XEvent * event); + int ecore_event_shape_get_id(void); + KeySym ecore_key_get_keysym_from_keycode(KeyCode keycode); + char *ecore_key_get_string_from_keycode(KeyCode keycode); + void ecore_event_allow(int mode, Time t); + int ecore_lock_mask_scroll_get(void); + int ecore_lock_mask_num_get(void); + int ecore_lock_mask_caps_get(void); + int ecore_mod_mask_shift_get(void); + int ecore_mod_mask_ctrl_get(void); + int ecore_mod_mask_alt_get(void); + int ecore_mod_mask_win_get(void); + int ecore_lock_mask_get(void); + int ecore_modifier_mask_get(void); + Window ecore_get_key_grab_win(void); + void ecore_key_grab(char *key, Ecore_Event_Key_Modifiers mods, + int anymod, int sync); + void ecore_key_ungrab(char *key, + Ecore_Event_Key_Modifiers mods, + int anymod); + KeyCode ecore_key_get_keycode(char *key); + void ecore_window_destroy(Window win); + void ecore_window_reparent(Window win, Window parent, int x, + int y); + void ecore_window_raise(Window win); + void ecore_window_lower(Window win); + void ecore_window_get_geometry(Window win, int *x, int *y, + int *w, int *h); + int ecore_window_get_depth(Window win); + int ecore_window_exists(Window win); + Window ecore_window_get_parent(Window win); + Window *ecore_window_get_children(Window win, int *num); + int ecore_window_mouse_in(Window win); + void ecore_window_mouse_set_in(Window win, int in); + Display *ecore_display_get(void); + Window ecore_window_get_root(Window win); + void ecore_lock_scroll_set(int onoff); + int ecore_lock_scroll_get(void); + void ecore_lock_num_set(int onoff); + int ecore_lock_num_get(void); + void ecore_lock_caps_set(int onoff); + int ecore_lock_caps_get(void); + void ecore_mod_shift_set(int onoff); + int ecore_mod_shift_get(void); + void ecore_mod_ctrl_set(int onoff); + int ecore_mod_ctrl_get(void); + void ecore_mod_alt_set(int onoff); + int ecore_mod_alt_get(void); + void ecore_mod_win_set(int onoff); + int ecore_mod_win_get(void); + void ecore_focus_window_set(Window win); + Window ecore_focus_window_get(void); + void ecore_focus_to_window(Window win); + Atom ecore_atom_get(char *name); + void ecore_window_set_delete_inform(Window win); + void ecore_window_property_set(Window win, Atom type, + Atom format, int size, + void *data, int number); + void *ecore_window_property_get(Window win, Atom type, + Atom format, int *size); + void ecore_window_dnd_advertise(Window win); + void ecore_grab(void); + void ecore_ungrab(void); + void ecore_window_ignore(Window win); + void ecore_window_no_ignore(Window win); + int ecore_window_is_ignored(Window win); + Window ecore_window_get_at_xy(int x, int y); - int sync); -void e_key_ungrab(char *key, Ev_Key_Modifiers mods, int anymod); -KeyCode e_key_get_keycode(char *key); -void e_window_destroy(Window win); -void e_window_reparent(Window win, Window parent, int x, int y); -void e_window_raise(Window win); -void e_window_lower(Window win); -void e_window_get_geometry(Window win, int *x, int *y, int *w, + int ecore_window_dnd_capable(Window win); + void ecore_window_dnd_handle_motion(Window source_win, int x, + int y, int dragging); + int ecore_dnd_selection_convert(Window win, Window req, + Atom type); + void *ecore_dnd_selection_get(Window win, Window req, Atom type, + int *size); + void ecore_window_dnd_ok(int ok); + void ecore_window_dnd_finished(void); + void ecore_window_dnd_send_status_ok(Window source_win, + Window win, int x, int y, + int w, int h); + void ecore_window_dnd_send_finished(Window source_win, + Window win); + void ecore_dnd_set_data(Window win); + void ecore_dnd_send_data(Window win, Window source_win, + void *data, int size, Atom dest_atom, + int plain_text); + void ecore_window_set_title(Window win, char *title); + void ecore_window_set_name_class(Window win, char *name, + char *); + void ecore_window_get_name_class(Window win, char **name, + char **class); + char *ecore_window_get_machine(Window win); + char *ecore_window_get_command(Window win); + char *ecore_window_get_icon_name(Window win); + void ecore_window_get_hints(Window win, int *accepts_focus, + int *initial_state, + Pixmap * icon_pixmap, + Pixmap * icon_mask, + Window * icon_window, + Window * window_group); + void ecore_window_set_min_size(Window win, int w, int h); + void ecore_window_set_max_size(Window win, int w, int h); + void ecore_window_set_xy_hints(Window win, int x, int y); + void ecore_window_get_frame_size(Window win, int *l, int *r, + int *t, int *b); + int ecore_window_save_under(Window win); + GC ecore_gc_new(Drawable d); + void ecore_gc_free(GC gc); + void ecore_gc_set_fg(GC gc, int val); + void ecore_fill_rectangle(Drawable d, GC gc, int x, int y, + int w, int h); + void ecore_draw_rectangle(Drawable d, GC gc, int x, int y, + int w, int h); + void ecore_draw_line(Drawable d, GC gc, int x1, int y1, int x2, + int y2); + void ecore_draw_point(Drawable d, GC gc, int x, int y); + void ecore_window_hint_set_layer(Window win, int layer); + void ecore_window_hint_set_sticky(Window win, int sticky); + void ecore_window_hint_set_borderless(Window win); + void ecore_grab_mouse(Window win, int confine, Cursor cursor); + void ecore_ungrab_mouse(void); + Window ecore_grab_window_get(void); + void ecore_dnd_set_mode_copy(void); + void ecore_dnd_set_mode_link(void); + void ecore_dnd_set_mode_move(void); + void ecore_dnd_set_mode_ask(void); + void ecore_dnd_own_selection(Window win); + void ecore_dnd_send_drop(Window win, Window source_win); + int ecore_window_get_gravity(Window win); + void ecore_window_gravity_reset(Window win); + void ecore_window_gravity_set(Window win, int gravity); + void ecore_window_bit_gravity_set(Window win, int gravity); + void ecore_pointer_warp_by(int dx, int dy); + void ecore_pointer_warp_to(int x, int y); + void ecore_gc_set_include_inferiors(GC gc); + void ecore_area_copy(Drawable src, Drawable dest, GC gc, + int sx, int sy, int sw, int sh, int dx, + int dy); + Window ecore_window_root(void); + void ecore_window_get_virtual_area(Window win, int *area_x, + int *area_y); + void ecore_get_virtual_area(int *area_x, int *area_y); + void ecore_window_get_root_relative_location(Window win, + int *x, int *y); - int *h); -int e_window_get_depth(Window win); -int e_window_exists(Window win); -Window e_window_get_parent(Window win); -Window *e_window_get_children(Window win, int *num); -int e_window_mouse_in(Window win); -void e_window_mouse_set_in(Window win, int in); -Display *e_display_get(void); -Window e_window_get_root(Window win); -void e_lock_scroll_set(int onoff); -int e_lock_scroll_get(void); -void e_lock_num_set(int onoff); -int e_lock_num_get(void); -void e_lock_caps_set(int onoff); -int e_lock_caps_get(void); -void e_mod_shift_set(int onoff); -int e_mod_shift_get(void); -void e_mod_ctrl_set(int onoff); -int e_mod_ctrl_get(void); -void e_mod_alt_set(int onoff); -int e_mod_alt_get(void); -void e_mod_win_set(int onoff); -int e_mod_win_get(void); -void e_focus_window_set(Window win); -Window e_focus_window_get(void); -void e_focus_to_window(Window win); -Atom e_atom_get(char *name); -void e_window_set_delete_inform(Window win); -void e_window_property_set(Window win, Atom type, Atom format, - int size, void *data, int number); -void *e_window_property_get(Window win, Atom type, Atom format, + void ecore_button_grab(Window win, int button, int events, + Ecore_Event_Key_Modifiers mod, + int any_mod); + void ecore_button_ungrab(Window win, int button, + Ecore_Event_Key_Modifiers mod, + int any_mod); + void ecore_pointer_replay(Time t); + void ecore_pointer_grab(Window win, Time t); + void ecore_pointer_ungrab(Time t); + void ecore_window_send_event_move_resize(Window win, int x, + int y, int w, int h); + void ecore_window_send_client_message(Window win, Atom type, + int format, void *data); + void ecore_window_add_to_save_set(Window win); + void ecore_window_del_from_save_set(Window win); + void ecore_window_kill_client(Window win); + void ecore_window_set_border_width(Window win, int bw); + int ecore_window_get_border_width(Window win); + int ecore_window_get_wm_size_hints(Window win, + XSizeHints * hints, + int *mask); + int ecore_window_is_visible(Window win); + int ecore_window_is_normal(Window win); + int ecore_window_is_manageable(Window win); + void ecore_windows_restack(Window * wins, int num); + void ecore_window_stack_above(Window win, Window above); + void ecore_window_stack_below(Window win, Window below); + char *ecore_window_get_title(Window win); + void ecore_keyboard_grab(Window win); + void ecore_keyboard_ungrab(void); - int *size); -void e_window_dnd_advertise(Window win); -void e_grab(void); -void e_ungrab(void); -void e_window_ignore(Window win); -void e_window_no_ignore(Window win); -int e_window_is_ignored(Window win); -Window e_window_get_at_xy(int x, int y); + void ecore_ev_ipc_init(char *path); + void ecore_ev_ipc_cleanup(void); + void ecore_add_ipc_service(int service, void (*func) (int fd)); + void ecore_del_ipc_service(int service); -int e_window_dnd_capable(Window win); -void e_window_dnd_handle_motion(Window source_win, int x, int y, + char *ecore_selection_get_data(Window win, Atom prop); + Window ecore_selection_request(void); + Window ecore_selection_set(char *string); - int dragging); -int e_dnd_selection_convert(Window win, Window req, Atom type); -void *e_dnd_selection_get(Window win, Window req, Atom type, + void ecore_set_blank_pointer(Window w); + Cursor ecore_cursor_new(Pixmap pmap, Pixmap mask, int x, int y, + int fr, int fg, int fb, int br, int bg, + int bb); + void ecore_cursor_free(Cursor c); + void ecore_cursor_set(Window win, Cursor c); + void ecore_window_button_grab_auto_replay_set(Window win, + int on); + int ecore_window_button_grab_auto_replay_get(Window win); - int *size); -void e_window_dnd_ok(int ok); -void e_window_dnd_finished(void); -void e_window_dnd_send_status_ok(Window source_win, Window win, - int x, int y, int w, int h); -void e_window_dnd_send_finished(Window source_win, Window win); -void e_dnd_set_data(Window win); -void e_dnd_send_data(Window win, Window source_win, void *data, - int size, Atom dest_atom, int plain_text); -void e_window_set_title(Window win, char *title); -void e_window_set_name_class(Window win, char *name, + typedef struct _ecore_event Ecore_Event; + typedef struct _ecore_event_fd_handler Ecore_Event_Fd_Handler; + typedef struct _ecore_event_pid_handler Ecore_Event_Pid_Handler; + typedef struct _ecore_event_ipc_handler Ecore_Event_Ipc_Handler; + typedef struct _ecore_event_timer Ecore_Event_Timer; - char *); -void e_window_get_name_class(Window win, char **name, char **class); -char *e_window_get_machine(Window win); -char *e_window_get_command(Window win); -char *e_window_get_icon_name(Window win); -void e_window_get_hints(Window win, int *accepts_focus, int *initial_state, - Pixmap *icon_pixmap, Pixmap *icon_mask, - Window *icon_window, Window *window_group); -void e_window_set_min_size(Window win, int w, int h); -void e_window_set_max_size(Window win, int w, int h); -void e_window_set_xy_hints(Window win, int x, int y); -void e_window_get_frame_size(Window win, int *l, int *r, int *t, + typedef struct _ecore_event_key_down Ecore_Event_Key_Down; + typedef struct _ecore_event_key_up Ecore_Event_Key_Up; + typedef struct _ecore_event_mouse_down Ecore_Event_Mouse_Down; + typedef struct _ecore_event_mouse_up Ecore_Event_Mouse_Up; + typedef struct _ecore_event_wheel Ecore_Event_Wheel; + typedef struct _ecore_event_mouse_move Ecore_Event_Mouse_Move; + typedef struct _ecore_event_window_enter Ecore_Event_Window_Enter; + typedef struct _ecore_event_window_leave Ecore_Event_Window_Leave; + typedef struct _ecore_event_window_focus_in Ecore_Event_Window_Focus_In; + typedef struct _ecore_event_window_focus_out Ecore_Event_Window_Focus_Out; + typedef struct _ecore_event_window_expose Ecore_Event_Window_Expose; + typedef struct _ecore_event_window_visibility Ecore_Event_Window_Visibility; + typedef struct _ecore_event_window_create Ecore_Event_Window_Create; + typedef struct _ecore_event_window_destroy Ecore_Event_Window_Destroy; + typedef struct _ecore_event_window_map Ecore_Event_Window_Map; + typedef struct _ecore_event_window_unmap Ecore_Event_Window_Unmap; + typedef struct _ecore_event_window_map_request Ecore_Event_Window_Map_Request; + typedef struct _ecore_event_window_reparent Ecore_Event_Window_Reparent; + typedef struct _ecore_event_window_configure Ecore_Event_Window_Configure; + typedef struct _ecore_event_window_configure_request + Ecore_Event_Window_Configure_Request; + typedef struct _ecore_event_window_circulate Ecore_Event_Window_Circulate; + typedef struct _ecore_event_window_circulate_request + Ecore_Event_Window_Circulate_Request; + typedef struct _ecore_event_window_property Ecore_Event_Window_Property; + typedef struct _ecore_event_window_shape Ecore_Event_Window_Shape; + typedef struct _ecore_event_client_message Ecore_Event_Message; + typedef struct _ecore_event_colormap Ecore_Event_Colormap; + typedef struct _ecore_event_window_delete Ecore_Event_Window_Delete; + typedef struct _ecore_event_child Ecore_Event_Child; + typedef struct _ecore_event_user Ecore_Event_User; + typedef struct _ecore_event_file_progress Ecore_Event_File_Progress; + typedef struct _ecore_event_file_update Ecore_Event_File_Update; + typedef struct _ecore_event_dnd_drop_request Ecore_Event_Dnd_Drop_Request; + typedef struct _ecore_event_dnd_drop_end Ecore_Event_Dnd_Drop_End; + typedef struct _ecore_event_dnd_drop_position Ecore_Event_Dnd_Drop_Position; + typedef struct _ecore_event_dnd_drop Ecore_Event_Dnd_Drop; + typedef struct _ecore_event_dnd_drop_status Ecore_Event_Dnd_Drop_Status; + typedef struct _ecore_event_dnd_data_request Ecore_Event_Dnd_Data_Request; + typedef struct _ecore_event_paste_request Ecore_Event_Paste_Request; + typedef struct _ecore_event_clear_selection Ecore_Event_Clear_Selection; + typedef struct _ecore_event_ipc_service Ecore_Event_Ipc_Service; - int *b); -int e_window_save_under(Window win); -GC e_gc_new(Drawable d); -void e_gc_free(GC gc); -void e_gc_set_fg(GC gc, int val); -void e_fill_rectangle(Drawable d, GC gc, int x, int y, int w, + enum _ecore_event_stack_detail + { + ECORE_EVENT_STACK_ABOVE = Above, + ECORE_EVENT_STACK_BELOW = Below, + ECORE_EVENT_STACK_TOP_IF = TopIf, + ECORE_EVENT_STACK_BOTTOM_IF = BottomIf, + ECORE_EVENT_STACK_OPPOSITE = Opposite + }; - int h); -void e_draw_rectangle(Drawable d, GC gc, int x, int y, int w, + enum _ecore_event_value_mask + { + ECORE_EVENT_VALUE_X = CWX, + ECORE_EVENT_VALUE_Y = CWY, + ECORE_EVENT_VALUE_W = CWWidth, + ECORE_EVENT_VALUE_H = CWHeight, + ECORE_EVENT_VALUE_BORDER = CWBorderWidth, + ECORE_EVENT_VALUE_SIBLING = CWSibling, + ECORE_EVENT_VALUE_STACKING = CWStackMode + }; - int h); -void e_draw_line(Drawable d, GC gc, int x1, int y1, int x2, + enum _ecore_event_type + { + ECORE_EVENT_MOUSE_MOVE, + ECORE_EVENT_MOUSE_DOWN, + ECORE_EVENT_MOUSE_UP, + ECORE_EVENT_MOUSE_IN, + ECORE_EVENT_MOUSE_OUT, + ECORE_EVENT_MOUSE_WHEEL, + ECORE_EVENT_KEY_DOWN, + ECORE_EVENT_KEY_UP, + ECORE_EVENT_WINDOW_MAP, + ECORE_EVENT_WINDOW_UNMAP, + ECORE_EVENT_WINDOW_CREATE, + ECORE_EVENT_WINDOW_DESTROY, + ECORE_EVENT_WINDOW_CONFIGURE, + ECORE_EVENT_WINDOW_CONFIGURE_REQUEST, + ECORE_EVENT_WINDOW_MAP_REQUEST, + ECORE_EVENT_WINDOW_PROPERTY, + ECORE_EVENT_WINDOW_CIRCULATE, + ECORE_EVENT_WINDOW_CIRCULATE_REQUEST, + ECORE_EVENT_WINDOW_REPARENT, + ECORE_EVENT_WINDOW_EXPOSE, + ECORE_EVENT_WINDOW_VISIBILITY, + ECORE_EVENT_WINDOW_SHAPE, + ECORE_EVENT_WINDOW_FOCUS_IN, + ECORE_EVENT_WINDOW_FOCUS_OUT, + ECORE_EVENT_MESSAGE, + ECORE_EVENT_WINDOW_DELETE, + ECORE_EVENT_COLORMAP, - int y2); -void e_draw_point(Drawable d, GC gc, int x, int y); -void e_window_hint_set_layer(Window win, int layer); -void e_window_hint_set_sticky(Window win, int sticky); -void e_window_hint_set_borderless(Window win); -void e_grab_mouse(Window win, int confine, Cursor cursor); -void e_ungrab_mouse(void); -Window e_grab_window_get(void); -void e_dnd_set_mode_copy(void); -void e_dnd_set_mode_link(void); -void e_dnd_set_mode_move(void); -void e_dnd_set_mode_ask(void); -void e_dnd_own_selection(Window win); -void e_dnd_send_drop(Window win, Window source_win); -int e_window_get_gravity(Window win); -void e_window_gravity_reset(Window win); -void e_window_gravity_set(Window win, int gravity); -void e_window_bit_gravity_set(Window win, int gravity); -void e_pointer_warp_by(int dx, int dy); -void e_pointer_warp_to(int x, int y); -void e_gc_set_include_inferiors(GC gc); -void e_area_copy(Drawable src, Drawable dest, GC gc, - int sx, int sy, int sw, int sh, int dx, int dy); -Window e_window_root(void); -void e_window_get_virtual_area(Window win, int *area_x, + ECORE_EVENT_DND_DROP_REQUEST, + ECORE_EVENT_DND_DROP_END, + ECORE_EVENT_DND_DROP_POSITION, + ECORE_EVENT_DND_DROP, + ECORE_EVENT_DND_DROP_STATUS, + ECORE_EVENT_DND_DATA_REQUEST, + ECORE_EVENT_PASTE_REQUEST, + ECORE_EVENT_CLEAR_SELECTION, - int *area_y); -void e_get_virtual_area(int *area_x, int *area_y); -void e_window_get_root_relative_location(Window win, int *x, int *y); + ECORE_EVENT_CHILD, + ECORE_EVENT_USER, -void e_button_grab(Window win, int button, int events, Ev_Key_Modifiers mod, int any_mod); -void e_button_ungrab(Window win, int button, Ev_Key_Modifiers mod, int any_mod); -void e_pointer_replay(Time t); -void e_pointer_grab(Window win, Time t); -void e_pointer_ungrab(Time t); -void e_window_send_event_move_resize(Window win, int x, int y, int w, int h); -void e_window_send_client_message(Window win, Atom type, int format, void *data); -void e_window_add_to_save_set(Window win); -void e_window_del_from_save_set(Window win); -void e_window_kill_client(Window win); -void e_window_set_border_width(Window win, int bw); -int e_window_get_border_width(Window win); -int e_window_get_wm_size_hints(Window win, XSizeHints *hints, int *mask); -int e_window_is_visible(Window win); -int e_window_is_normal(Window win); -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); + ECORE_EVENT_MAX + }; -void e_ev_ipc_init(char *path); -void e_ev_ipc_cleanup(void); -void e_add_ipc_service(int service, void (*func) (int fd)); -void e_del_ipc_service(int service); + typedef enum _ecore_event_type Ecore_Event_Type; + typedef enum _ecore_event_stack_detail Ecore_Event_Stack_Detail; + typedef enum _ecore_event_value_mask Ecore_Event_Confgure_Value_Mask; + struct _ecore_event + { + Ecore_Event_Type type; + char ignore; + void *event; + void (*ev_free) (void *evnt); + Ecore_Event *next; + }; -char *e_selection_get_data(Window win, Atom prop); -Window e_selection_request(void); -Window e_selection_set(char *string); + struct _ecore_event_fd_handler + { + int fd; + void (*func) (int fd); + Ecore_Event_Fd_Handler *next; + }; -void e_set_blank_pointer(Window w); -Cursor e_cursor_new(Pixmap pmap, Pixmap mask, int x, int y, int fr, int fg, int fb, int br, int bg, int bb); -void e_cursor_free(Cursor c); -void e_cursor_set(Window win, Cursor c); + struct _ecore_event_pid_handler + { + pid_t pid; + void (*func) (pid_t pid); + Ecore_Event_Pid_Handler *next; + }; -void e_window_button_grab_auto_replay_set(Window win, int on); -int e_window_button_grab_auto_replay_get(Window win); - -typedef struct _eev Eevent; -typedef struct _ev_fd_handler Ev_Fd_Handler; -typedef struct _ev_pid_handler Ev_Pid_Handler; -typedef struct _ev_ipc_handler Ev_Ipc_Handler; -typedef struct _ev_timer Ev_Timer; + struct _ecore_event_ipc_handler + { + int ipc; + void (*func) (int ipc); + Ecore_Event_Ipc_Handler *next; + }; -typedef struct _ev_key_down Ev_Key_Down; -typedef struct _ev_key_up Ev_Key_Up; -typedef struct _ev_mouse_down Ev_Mouse_Down; -typedef struct _ev_mouse_up Ev_Mouse_Up; -typedef struct _ev_wheel Ev_Wheel; -typedef struct _ev_mouse_move Ev_Mouse_Move; -typedef struct _ev_window_enter Ev_Window_Enter; -typedef struct _ev_window_leave Ev_Window_Leave; -typedef struct _ev_window_focus_in Ev_Window_Focus_In; -typedef struct _ev_window_focus_out Ev_Window_Focus_Out; -typedef struct _ev_window_expose Ev_Window_Expose; -typedef struct _ev_window_visibility Ev_Window_Visibility; -typedef struct _ev_window_create Ev_Window_Create; -typedef struct _ev_window_destroy Ev_Window_Destroy; -typedef struct _ev_window_map Ev_Window_Map; -typedef struct _ev_window_unmap Ev_Window_Unmap; -typedef struct _ev_window_map_request Ev_Window_Map_Request; -typedef struct _ev_window_reparent Ev_Window_Reparent; -typedef struct _ev_window_configure Ev_Window_Configure; -typedef struct _ev_window_configure_request Ev_Window_Configure_Request; -typedef struct _ev_window_circulate Ev_Window_Circulate; -typedef struct _ev_window_circulate_request Ev_Window_Circulate_Request; -typedef struct _ev_window_property Ev_Window_Property; -typedef struct _ev_window_shape Ev_Window_Shape; -typedef struct _ev_client_message Ev_Message; -typedef struct _ev_colormap Ev_Colormap; -typedef struct _ev_window_delete Ev_Window_Delete; -typedef struct _ev_child Ev_Child; -typedef struct _ev_user Ev_User; -typedef struct _ev_file_progress Ev_File_Progress; -typedef struct _ev_file_update Ev_File_Update; -typedef struct _ev_dnd_drop_request Ev_Dnd_Drop_Request; -typedef struct _ev_dnd_drop_end Ev_Dnd_Drop_End; -typedef struct _ev_dnd_drop_position Ev_Dnd_Drop_Position; -typedef struct _ev_dnd_drop Ev_Dnd_Drop; -typedef struct _ev_dnd_drop_status Ev_Dnd_Drop_Status; -typedef struct _ev_dnd_data_request Ev_Dnd_Data_Request; -typedef struct _ev_paste_request Ev_Paste_Request; -typedef struct _ev_clear_selection Ev_Clear_Selection; -typedef struct _ev_ipc_service Ev_Ipc_Service; + struct _ecore_event_timer + { + char *name; + void (*func) (int val, void *data); + int val; + void *data; + double in; + char just_added; + Ecore_Event_Timer *next; + }; -enum _eev_stack_detail -{ - EV_STACK_ABOVE = Above, - EV_STACK_BELOW = Below, - EV_STACK_TOP_IF = TopIf, - EV_STACK_BOTTOM_IF = BottomIf, - EV_STACK_OPPOSITE = Opposite -}; + struct _ecore_event_key_down + { + Window win, root; + Ecore_Event_Key_Modifiers mods; + char *key; + char *compose; + Time time; + }; -enum _eev_value_mask -{ - EV_VALUE_X = CWX, - EV_VALUE_Y = CWY, - EV_VALUE_W = CWWidth, - EV_VALUE_H = CWHeight, - EV_VALUE_BORDER = CWBorderWidth, - EV_VALUE_SIBLING = CWSibling, - EV_VALUE_STACKING = CWStackMode -}; + struct _ecore_event_key_up + { + Window win, root; + Ecore_Event_Key_Modifiers mods; + char *key; + char *compose; + Time time; + }; -enum _eev_type -{ - EV_MOUSE_MOVE, - EV_MOUSE_DOWN, - EV_MOUSE_UP, - EV_MOUSE_IN, - EV_MOUSE_OUT, - EV_MOUSE_WHEEL, - EV_KEY_DOWN, - EV_KEY_UP, - EV_WINDOW_MAP, - EV_WINDOW_UNMAP, - EV_WINDOW_CREATE, - EV_WINDOW_DESTROY, - EV_WINDOW_CONFIGURE, - EV_WINDOW_CONFIGURE_REQUEST, - EV_WINDOW_MAP_REQUEST, - EV_WINDOW_PROPERTY, - EV_WINDOW_CIRCULATE, - EV_WINDOW_CIRCULATE_REQUEST, - EV_WINDOW_REPARENT, - EV_WINDOW_EXPOSE, - EV_WINDOW_VISIBILITY, - EV_WINDOW_SHAPE, - EV_WINDOW_FOCUS_IN, - EV_WINDOW_FOCUS_OUT, - EV_MESSAGE, - EV_WINDOW_DELETE, - EV_COLORMAP, + struct _ecore_event_mouse_down + { + Window win, root; + Ecore_Event_Key_Modifiers mods; + int button; + int x, y; + int rx, ry; + int double_click, triple_click; + Time time; + }; - EV_DND_DROP_REQUEST, - EV_DND_DROP_END, - EV_DND_DROP_POSITION, - EV_DND_DROP, - EV_DND_DROP_STATUS, - EV_DND_DATA_REQUEST, - EV_PASTE_REQUEST, - EV_CLEAR_SELECTION, + struct _ecore_event_mouse_up + { + Window win, root; + Ecore_Event_Key_Modifiers mods; + int button; + int x, y; + int rx, ry; + Time time; + }; - EV_CHILD, - EV_USER, + struct _ecore_event_wheel + { + Window win, root; + Ecore_Event_Key_Modifiers mods; + int x, y, z; + int rx, ry; + Time time; + }; - EV_MAX -}; + struct _ecore_event_mouse_move + { + Window win, root; + Ecore_Event_Key_Modifiers mods; + int x, y; + int rx, ry; + Time time; + }; -typedef enum _eev_type Eevent_Type; -typedef enum _eev_stack_detail Ev_Stack_Detail; -typedef enum _eev_value_mask Ev_Confgure_Value_Mask; + struct _ecore_event_window_enter + { + Window win, root; + int x, y; + int rx, ry; + Ecore_Event_Key_Modifiers mods; + Time time; + }; -struct _eev -{ - Eevent_Type type; - char ignore; - void *event; - void (*ev_free) (void *evnt); - Eevent *next; -}; + struct _ecore_event_window_leave + { + Window win, root; + int x, y; + int rx, ry; + Ecore_Event_Key_Modifiers mods; + Time time; + }; -struct _ev_fd_handler -{ - int fd; - void (*func) (int fd); - Ev_Fd_Handler *next; -}; + struct _ecore_event_window_focus_in + { + Window win, root; + int key_grab; + Time time; + }; -struct _ev_pid_handler -{ - pid_t pid; - void (*func) (pid_t pid); - Ev_Pid_Handler *next; -}; + struct _ecore_event_window_focus_out + { + Window win, root; + int key_grab; + Time time; + }; -struct _ev_ipc_handler -{ - int ipc; - void (*func) (int ipc); - Ev_Ipc_Handler *next; -}; + struct _ecore_event_window_expose + { + Window win, root; + int x, y, w, h; + }; -struct _ev_timer -{ - char *name; - void (*func) (int val, void *data); - int val; - void *data; - double in; - char just_added; - Ev_Timer *next; -}; + struct _ecore_event_window_visibility + { + Window win, root; + int fully_obscured; + }; -struct _ev_key_down -{ - Window win, root; - Ev_Key_Modifiers mods; - char *key; - char *compose; - Time time; -}; + struct _ecore_event_window_create + { + Window win, root; + int override; + }; -struct _ev_key_up -{ - Window win, root; - Ev_Key_Modifiers mods; - char *key; - char *compose; - Time time; -}; + struct _ecore_event_window_destroy + { + Window win, root; + }; -struct _ev_mouse_down -{ - Window win, root; - Ev_Key_Modifiers mods; - int button; - int x, y; - int rx, ry; - int double_click, triple_click; - Time time; -}; + struct _ecore_event_window_map + { + Window win, root; + }; -struct _ev_mouse_up -{ - Window win, root; - Ev_Key_Modifiers mods; - int button; - int x, y; - int rx, ry; - Time time; -}; + struct _ecore_event_window_unmap + { + Window win, root; + }; -struct _ev_wheel -{ - Window win, root; - Ev_Key_Modifiers mods; - int x, y, z; - int rx, ry; - Time time; -}; + struct _ecore_event_window_map_request + { + Window win, root; + }; -struct _ev_mouse_move -{ - Window win, root; - Ev_Key_Modifiers mods; - int x, y; - int rx, ry; - Time time; -}; + struct _ecore_event_window_reparent + { + Window win, root; + Window parent_from, parent; + }; -struct _ev_window_enter -{ - Window win, root; - int x, y; - int rx, ry; - Ev_Key_Modifiers mods; - Time time; -}; + struct _ecore_event_window_configure + { + Window win, root; + int x, y, w, h; + int wm_generated; + }; -struct _ev_window_leave -{ - Window win, root; - int x, y; - int rx, ry; - Ev_Key_Modifiers mods; - Time time; -}; + struct _ecore_event_window_configure_request + { + Window win, root; + int x, y, w, h; + int border; + Window stack_win; + Ecore_Event_Stack_Detail detail; + Ecore_Event_Confgure_Value_Mask mask; + }; -struct _ev_window_focus_in -{ - Window win, root; - int key_grab; - Time time; -}; + struct _ecore_event_window_circulate + { + Window win, root; + int lower; + }; -struct _ev_window_focus_out -{ - Window win, root; - int key_grab; - Time time; -}; + struct _ecore_event_window_circulate_request + { + Window win, root; + int lower; + }; -struct _ev_window_expose -{ - Window win, root; - int x, y, w, h; -}; + struct _ecore_event_window_property + { + Window win, root; + Atom atom; + Time time; + }; -struct _ev_window_visibility -{ - Window win, root; - int fully_obscured; -}; + struct _ecore_event_window_shape + { + Window win, root; + Time time; + }; -struct _ev_window_create -{ - Window win, root; - int override; -}; - -struct _ev_window_destroy -{ - Window win, root; -}; - -struct _ev_window_map -{ - Window win, root; -}; - -struct _ev_window_unmap -{ - Window win, root; -}; - -struct _ev_window_map_request -{ - Window win, root; -}; - -struct _ev_window_reparent -{ - Window win, root; - Window parent_from, parent; -}; - -struct _ev_window_configure -{ - Window win, root; - int x, y, w, h; - int wm_generated; -}; - -struct _ev_window_configure_request -{ - Window win, root; - int x, y, w, h; - int border; - Window stack_win; - Ev_Stack_Detail detail; - Ev_Confgure_Value_Mask mask; -}; - -struct _ev_window_circulate -{ - Window win, root; - int lower; -}; - -struct _ev_window_circulate_request -{ - Window win, root; - int lower; -}; - -struct _ev_window_property -{ - Window win, root; - Atom atom; - Time time; -}; - -struct _ev_window_shape -{ - Window win, root; - Time time; -}; - -struct _ev_client_message -{ - Window win; - int format; - Atom atom; - union - { + struct _ecore_event_client_message + { + Window win; + int format; + Atom atom; + union + { char b[20]; short s[10]; long l[5]; - } - data; -}; + } + data; + }; -struct _ev_colormap -{ - Window win, root; - Colormap cmap; - int installed; -}; + struct _ecore_event_colormap + { + Window win, root; + Colormap cmap; + int installed; + }; -struct _ev_window_delete -{ - Window win, root; -}; + struct _ecore_event_window_delete + { + Window win, root; + }; -struct _ev_paste_request -{ - Window win, root, source_win; - char *string; -}; + struct _ecore_event_paste_request + { + Window win, root, source_win; + char *string; + }; -struct _ev_clear_selection -{ - Window win, root; - Atom selection; -}; + struct _ecore_event_clear_selection + { + Window win, root; + Atom selection; + }; -struct _ev_dnd_drop_request -{ - Window win, root, source_win; - int num_files; - char **files; - int copy, link, move; -}; + struct _ecore_event_dnd_drop_request + { + Window win, root, source_win; + int num_files; + char **files; + int copy, link, move; + }; -struct _ev_dnd_drop_end -{ - Window win, root, source_win; -}; + struct _ecore_event_dnd_drop_end + { + Window win, root, source_win; + }; -struct _ev_dnd_drop_position -{ - Window win, root, source_win; - int x, y; -}; + struct _ecore_event_dnd_drop_position + { + Window win, root, source_win; + int x, y; + }; -struct _ev_dnd_drop -{ - Window win, root, source_win; -}; + struct _ecore_event_dnd_drop + { + Window win, root, source_win; + }; -struct _ev_dnd_drop_status -{ - Window win, root, source_win; - int x, y, w, h; - int ok; -}; + struct _ecore_event_dnd_drop_status + { + Window win, root, source_win; + int x, y, w, h; + int ok; + }; -struct _ev_dnd_data_request -{ - Window win, root, source_win; - int plain_text; - Atom destination_atom; -}; + struct _ecore_event_dnd_data_request + { + Window win, root, source_win; + int plain_text; + Atom destination_atom; + }; -struct _ev_child -{ - pid_t pid; - int exit_code; -}; + struct _ecore_event_child + { + pid_t pid; + int exit_code; + }; -struct _ev_user -{ - int num; - int hup; -}; + struct _ecore_event_user + { + int num; + int hup; + }; -struct _ev_ipc_service -{ - int service; - void (*func) (int fd); - Ev_Ipc_Service *next; -}; + struct _ecore_event_ipc_service + { + int service; + void (*func) (int fd); + Ecore_Event_Ipc_Service *next; + }; -void e_add_event(Eevent_Type type, void *event, - void (*ev_free) (void *event)); -void e_del_event(void *event); -void e_del_all_events(void); -Eevent *e_get_last_event(void); + void ecore_add_event(Ecore_Event_Type type, void *event, + void (*ev_free) (void *event)); + void ecore_del_event(void *event); + void ecore_del_all_events(void); + Ecore_Event *ecore_get_last_event(void); -void e_add_event_fd(int fd, void (*func) (int fd)); -void e_del_event_fd(int fd); -void e_add_event_pid(pid_t pid, void (*func) (pid_t pid)); -void e_del_event_pid(pid_t pid); -void e_add_event_ipc(int ipc, void (*func) (int ipc)); -void e_del_event_ipc(int ipc); + void ecore_add_event_fd(int fd, void (*func) (int fd)); + void ecore_del_event_fd(int fd); + void ecore_add_event_pid(pid_t pid, void (*func) (pid_t pid)); + void ecore_del_event_pid(pid_t pid); + void ecore_add_event_ipc(int ipc, void (*func) (int ipc)); + void ecore_del_event_ipc(int ipc); -void e_event_loop(void); -void e_event_loop_quit(void); + void ecore_event_loop(void); + void ecore_event_loop_quit(void); -void e_add_event_timer(char *name, double in, - void (*func) (int val, void *data), - int val, void *data); -void *e_del_event_timer(char *name); + void ecore_add_event_timer(char *name, double in, + void (*func) (int val, void *data), + int val, void *data); + void *ecore_del_event_timer(char *name); -void e_event_filter(Eevent * ev); -void e_event_filter_events_handle(Eevent * ev); -void e_event_filter_idle_handle(void); -void e_event_filter_init(void); -void e_event_filter_handler_add(Eevent_Type type, - void (*func) (Eevent * ev)); -void e_event_filter_idle_handler_add(void (*func) (void *data), + void ecore_event_filter(Ecore_Event * ev); + void ecore_event_filter_events_handle(Ecore_Event * ev); + void ecore_event_filter_idle_handle(void); + void ecore_event_filter_init(void); + void ecore_event_filter_handler_add(Ecore_Event_Type type, + void (*func) (Ecore_Event * + ev)); + void + + + + + + + + ecore_event_filter_idle_handler_add(void (*func) (void *data), void *data); - void *data); + void ecore_ev_signal_init(void); + int ecore_ev_signal_events_pending(void); -void e_ev_signal_init(void); -int e_ev_signal_events_pending(void); + void ecore_ev_x_init(void); + char + + + + *ecore_key_press_translate_into_typeable(Ecore_Event_Key_Down * e); -void e_ev_x_init(void); -char *e_key_press_translate_into_typeable(Ev_Key_Down * e); - - -#define E_ATOM(atom, name) \ -if (!atom) atom = e_atom_get(name); - -#define MEMCPY(src, dst, type, num) memcpy(dst, src, sizeof(type) * (num)) - -#define NEW(dat, num) malloc(sizeof(dat) * (num)) -#define ZERO(ptr, dat, num) memset(ptr, 0, sizeof(dat) * (num)) -#define NEW_PTR(num) malloc(sizeof(void *) * (num)) -#define FREE(dat) {free(dat); dat = NULL;} -#define IF_FREE(dat) {if (dat) FREE(dat);} -#define REALLOC(dat, type, num) {if (dat) dat = realloc(dat, sizeof(type) * (num)); else dat = malloc(sizeof(type) * (num));} -#define REALLOC_PTR(dat, num) {if (dat) dat = realloc(dat, sizeof(void *) * (num)); else dat = malloc(sizeof(void *) * (num));} +#define ECORE_ATOM(atom, name) \ + if (!atom) (atom) = ecore_atom_get(name); +#define MEMCPY(src, dst, type, num) \ + memcpy(dst, src, sizeof(type) * (num)) +#define NEW(dat, num) \ + malloc(sizeof(dat) * (num)) +#define ZERO(ptr, dat, num) \ + memset((ptr), 0, sizeof(dat) * (num)) +#define NEW_PTR(num) \ + malloc(sizeof(void *) * (num)) +#define FREE(dat) \ + { \ + free(dat); \ + (dat) = NULL; \ + } +#define IF_FREE(dat) \ + {if (dat) FREE(dat);} +#define REALLOC(dat, type, num) \ + { \ + if (dat) dat = realloc((dat), sizeof(type) * (num)); \ + else dat = malloc(sizeof(type) * (num)); \ + } +#define REALLOC_PTR(dat, num) \ + { \ + if (dat) dat = realloc(dat, sizeof(void *) * (num)); \ + else dat = malloc(sizeof(void *) * (num)); \ + } #define START_LIST_DEL(type, base, cmp) \ -type *_p, *_pp; _pp = NULL; _p = (base); while(_p) { if (cmp) { \ -if (_pp) _pp->next = _p->next; else (base) = _p->next; + type *_p, *_pp; _pp = NULL; \ + _p = (base); \ + while(_p) \ + { \ + if (cmp) \ + { \ + if (_pp) _pp->next = _p->next; \ + else (base) = _p->next; #define END_LIST_DEL \ -return; } _pp = _p; _p = _p->next; } + return; \ + } \ + _pp = _p; \ + _p = _p->next; \ + } -double e_get_time(void); + double ecore_get_time(void); #ifdef __cplusplus } diff --git a/legacy/ecore/src/e_ev_filter.c b/legacy/ecore/src/e_ev_filter.c index 1411580ddb..58c7e0f1f4 100644 --- a/legacy/ecore/src/e_ev_filter.c +++ b/legacy/ecore/src/e_ev_filter.c @@ -1,130 +1,132 @@ #include "Ecore.h" -typedef struct _ev_handler Ev_Handler; -typedef struct _ev_idle_handler Ev_Idle_Handler; +typedef struct _ecore_event_handler Ecore_Event_Handler; +typedef struct _ecore_event_idle_handler Ecore_Event_Idle_Handler; -struct _ev_handler +struct _ecore_event_handler { - void (*func) (Eevent * ev); - Ev_Handler *next; + void (*func) (Ecore_Event * ev); + Ecore_Event_Handler *next; }; -struct _ev_idle_handler +struct _ecore_event_idle_handler { - void (*func) (void *data); - void *data; - Ev_Idle_Handler *next; + void (*func) (void *data); + void *data; + Ecore_Event_Idle_Handler *next; }; -static Ev_Handler *handler[EV_MAX]; -static Ev_Idle_Handler *idle_handlers = NULL; +static Ecore_Event_Handler *handler[ECORE_EVENT_MAX]; +static Ecore_Event_Idle_Handler *idle_handlers = NULL; void -e_event_filter(Eevent * ev) +ecore_event_filter(Ecore_Event * ev) { - Eevent *evp; - int motion_events = 0; - int dnd_pos_events = 0; - int dnd_status_events = 0; + Ecore_Event *evp; + int motion_events = 0; + int dnd_pos_events = 0; + int dnd_status_events = 0; - /* count events to only use last events of some types */ - for (evp = ev; evp; evp = evp->next) - { - if (evp->type == EV_MOUSE_MOVE) - motion_events++; - if (evp->type == EV_DND_DROP_POSITION) - dnd_pos_events++; - if (evp->type == EV_DND_DROP_STATUS) - dnd_status_events++; - } - for (evp = ev; evp; evp = evp->next) - { - if (evp->type == EV_MOUSE_MOVE) - { - if (motion_events > 1) - { - evp->ignore = 1; - motion_events--; - } - } - else if (evp->type == EV_DND_DROP_POSITION) - { - if (dnd_pos_events > 1) - { - evp->ignore = 1; - dnd_pos_events--; - } - } - else if (evp->type == EV_DND_DROP_STATUS) - { - if (dnd_status_events > 1) - { - evp->ignore = 1; - dnd_status_events--; - } - } - } + /* count events to only use last events of some types */ + for (evp = ev; evp; evp = evp->next) + { + if (evp->type == ECORE_EVENT_MOUSE_MOVE) + motion_events++; + if (evp->type == ECORE_EVENT_DND_DROP_POSITION) + dnd_pos_events++; + if (evp->type == ECORE_EVENT_DND_DROP_STATUS) + dnd_status_events++; + } + for (evp = ev; evp; evp = evp->next) + { + if (evp->type == ECORE_EVENT_MOUSE_MOVE) + { + if (motion_events > 1) + { + evp->ignore = 1; + motion_events--; + } + } + else if (evp->type == ECORE_EVENT_DND_DROP_POSITION) + { + if (dnd_pos_events > 1) + { + evp->ignore = 1; + dnd_pos_events--; + } + } + else if (evp->type == ECORE_EVENT_DND_DROP_STATUS) + { + if (dnd_status_events > 1) + { + evp->ignore = 1; + dnd_status_events--; + } + } + } } void -e_event_filter_events_handle(Eevent * ev) +ecore_event_filter_events_handle(Ecore_Event * ev) { - Eevent *evp; + Ecore_Event *evp; - for (evp = ev; evp; evp = evp->next) - { - Ev_Handler *h; + for (evp = ev; evp; evp = evp->next) + { + Ecore_Event_Handler *h; - if (!evp->ignore) - { - for (h = handler[evp->type]; h; h = h->next) - { - if (h->func) h->func(evp); - } - } - } + if (!evp->ignore) + { + for (h = handler[evp->type]; h; h = h->next) + { + if (h->func) + h->func(evp); + } + } + } } void -e_event_filter_idle_handle(void) +ecore_event_filter_idle_handle(void) { - Ev_Idle_Handler *h; + Ecore_Event_Idle_Handler *h; - for (h = idle_handlers; h; h = h->next) - h->func(h->data); + for (h = idle_handlers; h; h = h->next) + h->func(h->data); } -extern int __quit_ev_loop; +extern int __quit_ev_loop; void -e_event_filter_init(void) +ecore_event_filter_init(void) { - int i; + int i; - __quit_ev_loop = 0; - for (i = 0; i < EV_MAX; i++) - handler[i] = NULL; + __quit_ev_loop = 0; + for (i = 0; i < ECORE_EVENT_MAX; i++) + handler[i] = NULL; } void -e_event_filter_handler_add(Eevent_Type type, void (*func) (Eevent * ev)) +ecore_event_filter_handler_add(Ecore_Event_Type type, + void (*func) (Ecore_Event * ev)) { - Ev_Handler *h; + Ecore_Event_Handler *h; - h = NEW(Ev_Handler, 1); - h->func = func; - h->next = handler[type]; - handler[type] = h; + h = NEW(Ecore_Event_Handler, 1); + h->func = func; + h->next = handler[type]; + handler[type] = h; } void -e_event_filter_idle_handler_add(void (*func) (void *data), void *data) +ecore_event_filter_idle_handler_add(void (*func) (void *data), void *data) { - Ev_Idle_Handler *h; + Ecore_Event_Idle_Handler *h; - h = NEW(Ev_Idle_Handler, 1); - h->func = func; - h->data = data; - h->next = idle_handlers; - idle_handlers = h; + h = NEW(Ecore_Event_Idle_Handler, 1); + h->func = func; + h->data = data; + h->next = idle_handlers; + idle_handlers = h; } diff --git a/legacy/ecore/src/e_ev_signal.c b/legacy/ecore/src/e_ev_signal.c index 3eed025a4b..b0e34cb021 100644 --- a/legacy/ecore/src/e_ev_signal.c +++ b/legacy/ecore/src/e_ev_signal.c @@ -5,25 +5,25 @@ #include #include -static void e_ev_signal_free(void *event); -static void e_ev_signal_handle_sigchld(int num); -static void e_ev_signal_handle_sigusr1(int num); -static void e_ev_signal_handle_sigusr2(int num); -static void e_ev_signal_handle_sighup(int num); -static void e_ev_signal_handle_sigpipe(int num); -static void e_ev_signal_handle_sigsegv(int num); -static void e_ev_signal_handle_sigfpe(int num); -static void e_ev_signal_handle_sigill(int num); -static void e_ev_signal_handle_sigbus(int num); +static void ecore_event_signal_free(void *event); +static void ecore_event_signal_handle_sigchld(int num); +static void ecore_event_signal_handle_sigusr1(int num); +static void ecore_event_signal_handle_sigusr2(int num); +static void ecore_event_signal_handle_sighup(int num); +static void ecore_event_signal_handle_sigpipe(int num); +static void ecore_event_signal_handle_sigsegv(int num); +static void ecore_event_signal_handle_sigfpe(int num); +static void ecore_event_signal_handle_sigill(int num); +static void ecore_event_signal_handle_sigbus(int num); #ifdef HAVE_SIGSTKFLT -static void e_ev_signal_handle_sigstkflt(int num); +static void ecore_event_signal_handle_sigstkflt(int num); #endif #ifdef HAVE_SIGPWR -static void e_ev_signal_handle_sigpwr(int num); +static void ecore_event_signal_handle_sigpwr(int num); #endif -static void e_ev_signal_handle_sigchld(int num); -static void e_ev_signal_handle_all(pid_t pid); +static void ecore_event_signal_handle_sigchld(int num); +static void ecore_event_signal_handle_all(pid_t pid); static int signal_chld_count = 0; static int signal_usr1_count = 0; @@ -32,289 +32,289 @@ static int signal_hup_count = 0; /* freeing stuff */ static void -e_ev_signal_free(void *event) +ecore_event_signal_free(void *event) { - FREE(event); + FREE(event); } /* signal handlers we can return from and add to signal recieved counts */ static void -e_ev_signal_handle_sigchld(int num) +ecore_event_signal_handle_sigchld(int num) { - signal_chld_count++; - return; - num = 0; + signal_chld_count++; + return; + num = 0; } static void -e_ev_signal_handle_sigusr1(int num) +ecore_event_signal_handle_sigusr1(int num) { - signal_usr1_count++; - return; - num = 0; + signal_usr1_count++; + return; + num = 0; } static void -e_ev_signal_handle_sigusr2(int num) +ecore_event_signal_handle_sigusr2(int num) { - signal_usr2_count++; - return; - num = 0; + signal_usr2_count++; + return; + num = 0; } static void -e_ev_signal_handle_sighup(int num) +ecore_event_signal_handle_sighup(int num) { - signal_hup_count++; - return; - num = 0; + signal_hup_count++; + return; + num = 0; } /* signals to ignore */ static void -e_ev_signal_handle_sigpipe(int num) +ecore_event_signal_handle_sigpipe(int num) { - return; - num = 0; + return; + num = 0; } /* signal handlers we cant return from - so handle here */ static void -e_ev_signal_handle_sigsegv(int num) +ecore_event_signal_handle_sigsegv(int num) { - for (;;) - { - fprintf(stderr, "EEEEEEEEK SEGV - waiting 10 seconds\n"); - sleep(10); - } - /* EEK - can't return - bad */ - abort(); - num = 0; + for (;;) + { + fprintf(stderr, "EEEEEEEEK SEGV - waiting 10 seconds\n"); + sleep(10); + } + /* EEK - can't return - bad */ + abort(); + num = 0; } static void -e_ev_signal_handle_sigfpe(int num) +ecore_event_signal_handle_sigfpe(int num) { - /* EEK - can't return - bad */ - abort(); - num = 0; + /* EEK - can't return - bad */ + abort(); + num = 0; } static void -e_ev_signal_handle_sigill(int num) +ecore_event_signal_handle_sigill(int num) { - /* EEK - can't return - bad */ - abort(); - num = 0; + /* EEK - can't return - bad */ + abort(); + num = 0; } static void -e_ev_signal_handle_sigbus(int num) +ecore_event_signal_handle_sigbus(int num) { - /* EEK - can't return - bad */ - abort(); - num = 0; + /* EEK - can't return - bad */ + abort(); + num = 0; } #ifdef HAVE_SIGSTKFLT static void -e_ev_signal_handle_sigstkflt(int num) +ecore_event_signal_handle_sigstkflt(int num) { - /* EEK - can't return - bad */ - abort(); - return; - num = 0; + /* EEK - can't return - bad */ + abort(); + return; + num = 0; } #endif static void -e_ev_signal_handle_sigint(int num) +ecore_event_signal_handle_sigint(int num) { - exit(0); - return; - num = 0; + exit(0); + return; + num = 0; } static void -e_ev_signal_handle_sigquit(int num) +ecore_event_signal_handle_sigquit(int num) { - exit(0); - return; - num = 0; + exit(0); + return; + num = 0; } static void -e_ev_signal_handle_sigabrt(int num) +ecore_event_signal_handle_sigabrt(int num) { - abort(); - return; - num = 0; + abort(); + return; + num = 0; } static void -e_ev_signal_handle_sigalrm(int num) +ecore_event_signal_handle_sigalrm(int num) { - return; - num = 0; + return; + num = 0; } static void -e_ev_signal_handle_sigterm(int num) +ecore_event_signal_handle_sigterm(int num) { - exit(0); - return; - num = 0; + exit(0); + return; + num = 0; } #ifdef HAVE_SIGPWR static void -e_ev_signal_handle_sigpwr(int num) +ecore_event_signal_handle_sigpwr(int num) { - exit(0); - return; - num = 0; + exit(0); + return; + num = 0; } #endif static void -e_ev_signal_handle_all(pid_t pid_pass) +ecore_event_signal_handle_all(pid_t pid_pass) { - int status; - pid_t pid; + int status; + pid_t pid; - if (signal_chld_count > 0) - { - while ((pid = waitpid(-1, &status, WNOHANG)) > 0) - { - if (WIFEXITED(status)) - { - Ev_Child *e; - int code; + if (signal_chld_count > 0) + { + while ((pid = waitpid(-1, &status, WNOHANG)) > 0) + { + if (WIFEXITED(status)) + { + Ecore_Event_Child *e; + int code; - code = WEXITSTATUS(status); - e = NEW(Ev_Child, 1); - e->pid = pid; - e->exit_code = code; - e_add_event(EV_CHILD, e, e_ev_signal_free); - } - } - signal_chld_count = 0; - } - while (signal_usr1_count > 0) - { - Ev_User *e; + code = WEXITSTATUS(status); + e = NEW(Ecore_Event_Child, 1); + e->pid = pid; + e->exit_code = code; + ecore_add_event(ECORE_EVENT_CHILD, e, ecore_event_signal_free); + } + } + signal_chld_count = 0; + } + while (signal_usr1_count > 0) + { + Ecore_Event_User *e; - e = NEW(Ev_User, 1); - e->num = 0; - e->hup = 0; - e_add_event(EV_USER, e, e_ev_signal_free); - signal_usr1_count--; - } - while (signal_hup_count > 0) - { - Ev_User *e; + e = NEW(Ecore_Event_User, 1); + e->num = 0; + e->hup = 0; + ecore_add_event(ECORE_EVENT_USER, e, ecore_event_signal_free); + signal_usr1_count--; + } + while (signal_hup_count > 0) + { + Ecore_Event_User *e; - e = NEW(Ev_User, 1); - e->num = 0; - e->hup = 1; - e_add_event(EV_USER, e, e_ev_signal_free); - signal_hup_count--; - } - return; - pid_pass = 0; + e = NEW(Ecore_Event_User, 1); + e->num = 0; + e->hup = 1; + ecore_add_event(ECORE_EVENT_USER, e, ecore_event_signal_free); + signal_hup_count--; + } + return; + pid_pass = 0; } int -e_ev_signal_events_pending(void) +ecore_event_signal_events_pending(void) { - return (signal_chld_count + signal_usr1_count + signal_hup_count); + return (signal_chld_count + signal_usr1_count + signal_hup_count); } void -e_ev_signal_init(void) +ecore_event_signal_init(void) { - struct sigaction sa; + struct sigaction sa; - e_add_event_pid(0, e_ev_signal_handle_all); + ecore_add_event_pid(0, ecore_event_signal_handle_all); - sa.sa_handler = e_ev_signal_handle_sigchld; - sa.sa_flags = SA_RESTART; - sigemptyset(&sa.sa_mask); - sigaction(SIGCHLD, &sa, (struct sigaction *)0); + sa.sa_handler = ecore_event_signal_handle_sigchld; + sa.sa_flags = SA_RESTART; + sigemptyset(&sa.sa_mask); + sigaction(SIGCHLD, &sa, (struct sigaction *)0); - sa.sa_handler = e_ev_signal_handle_sigusr1; - sa.sa_flags = SA_RESTART; - sigemptyset(&sa.sa_mask); - sigaction(SIGUSR1, &sa, (struct sigaction *)0); + sa.sa_handler = ecore_event_signal_handle_sigusr1; + sa.sa_flags = SA_RESTART; + sigemptyset(&sa.sa_mask); + sigaction(SIGUSR1, &sa, (struct sigaction *)0); - sa.sa_handler = e_ev_signal_handle_sigusr2; - sa.sa_flags = SA_RESTART; - sigemptyset(&sa.sa_mask); - sigaction(SIGUSR2, &sa, (struct sigaction *)0); + sa.sa_handler = ecore_event_signal_handle_sigusr2; + sa.sa_flags = SA_RESTART; + sigemptyset(&sa.sa_mask); + sigaction(SIGUSR2, &sa, (struct sigaction *)0); - sa.sa_handler = e_ev_signal_handle_sighup; - sa.sa_flags = SA_RESTART; - sigemptyset(&sa.sa_mask); - sigaction(SIGHUP, &sa, (struct sigaction *)0); + sa.sa_handler = ecore_event_signal_handle_sighup; + sa.sa_flags = SA_RESTART; + sigemptyset(&sa.sa_mask); + sigaction(SIGHUP, &sa, (struct sigaction *)0); - sa.sa_handler = e_ev_signal_handle_sigpipe; - sa.sa_flags = SA_RESTART; - sigemptyset(&sa.sa_mask); - sigaction(SIGPIPE, &sa, (struct sigaction *)0); + sa.sa_handler = ecore_event_signal_handle_sigpipe; + sa.sa_flags = SA_RESTART; + sigemptyset(&sa.sa_mask); + sigaction(SIGPIPE, &sa, (struct sigaction *)0); /* - sa.sa_handler = e_ev_signal_handle_sigsegv; + sa.sa_handler = ecore_event_signal_handle_sigsegv; sa.sa_flags = SA_RESTART; sigemptyset(&sa.sa_mask); sigaction(SIGSEGV, &sa, (struct sigaction *)0); */ - sa.sa_handler = e_ev_signal_handle_sigfpe; - sa.sa_flags = SA_RESTART; - sigemptyset(&sa.sa_mask); - sigaction(SIGFPE, &sa, (struct sigaction *)0); + sa.sa_handler = ecore_event_signal_handle_sigfpe; + sa.sa_flags = SA_RESTART; + sigemptyset(&sa.sa_mask); + sigaction(SIGFPE, &sa, (struct sigaction *)0); - sa.sa_handler = e_ev_signal_handle_sigill; - sa.sa_flags = SA_RESTART; - sigemptyset(&sa.sa_mask); - sigaction(SIGILL, &sa, (struct sigaction *)0); + sa.sa_handler = ecore_event_signal_handle_sigill; + sa.sa_flags = SA_RESTART; + sigemptyset(&sa.sa_mask); + sigaction(SIGILL, &sa, (struct sigaction *)0); - sa.sa_handler = e_ev_signal_handle_sigbus; - sa.sa_flags = SA_RESTART; - sigemptyset(&sa.sa_mask); - sigaction(SIGBUS, &sa, (struct sigaction *)0); + sa.sa_handler = ecore_event_signal_handle_sigbus; + sa.sa_flags = SA_RESTART; + sigemptyset(&sa.sa_mask); + sigaction(SIGBUS, &sa, (struct sigaction *)0); #ifdef HAVE_SIGSTKFLT - sa.sa_handler = e_ev_signal_handle_sigstkflt; - sa.sa_flags = SA_RESTART; - sigemptyset(&sa.sa_mask); - sigaction(SIGSTKFLT, &sa, (struct sigaction *)0); + sa.sa_handler = ecore_event_signal_handle_sigstkflt; + sa.sa_flags = SA_RESTART; + sigemptyset(&sa.sa_mask); + sigaction(SIGSTKFLT, &sa, (struct sigaction *)0); #endif - sa.sa_handler = e_ev_signal_handle_sigint; - sa.sa_flags = SA_RESTART; - sigemptyset(&sa.sa_mask); - sigaction(SIGINT, &sa, (struct sigaction *)0); + sa.sa_handler = ecore_event_signal_handle_sigint; + sa.sa_flags = SA_RESTART; + sigemptyset(&sa.sa_mask); + sigaction(SIGINT, &sa, (struct sigaction *)0); - sa.sa_handler = e_ev_signal_handle_sigquit; - sa.sa_flags = SA_RESTART; - sigemptyset(&sa.sa_mask); - sigaction(SIGQUIT, &sa, (struct sigaction *)0); + sa.sa_handler = ecore_event_signal_handle_sigquit; + sa.sa_flags = SA_RESTART; + sigemptyset(&sa.sa_mask); + sigaction(SIGQUIT, &sa, (struct sigaction *)0); - sa.sa_handler = e_ev_signal_handle_sigabrt; - sa.sa_flags = SA_RESTART; - sigemptyset(&sa.sa_mask); - sigaction(SIGABRT, &sa, (struct sigaction *)0); + sa.sa_handler = ecore_event_signal_handle_sigabrt; + sa.sa_flags = SA_RESTART; + sigemptyset(&sa.sa_mask); + sigaction(SIGABRT, &sa, (struct sigaction *)0); - sa.sa_handler = e_ev_signal_handle_sigalrm; - sa.sa_flags = SA_RESTART; - sigemptyset(&sa.sa_mask); - sigaction(SIGALRM, &sa, (struct sigaction *)0); + sa.sa_handler = ecore_event_signal_handle_sigalrm; + sa.sa_flags = SA_RESTART; + sigemptyset(&sa.sa_mask); + sigaction(SIGALRM, &sa, (struct sigaction *)0); - sa.sa_handler = e_ev_signal_handle_sigterm; - sa.sa_flags = SA_RESTART; - sigemptyset(&sa.sa_mask); - sigaction(SIGTERM, &sa, (struct sigaction *)0); + sa.sa_handler = ecore_event_signal_handle_sigterm; + sa.sa_flags = SA_RESTART; + sigemptyset(&sa.sa_mask); + sigaction(SIGTERM, &sa, (struct sigaction *)0); #ifdef HAVE_SIGPWR - sa.sa_handler = e_ev_signal_handle_sigpwr; - sa.sa_flags = SA_RESTART; - sigemptyset(&sa.sa_mask); - sigaction(SIGPWR, &sa, (struct sigaction *)0); + sa.sa_handler = ecore_event_signal_handle_sigpwr; + sa.sa_flags = SA_RESTART; + sigemptyset(&sa.sa_mask); + sigaction(SIGPWR, &sa, (struct sigaction *)0); #endif } diff --git a/legacy/ecore/src/e_ev_x.c b/legacy/ecore/src/e_ev_x.c index 19e472333f..8db368de8b 100644 --- a/legacy/ecore/src/e_ev_x.c +++ b/legacy/ecore/src/e_ev_x.c @@ -4,1180 +4,1189 @@ #include /* private funtion prototypes */ -static void e_ev_x_handle_events(int fd); -static void e_ev_x_translate_events(XEvent * events, int num_events); +static void ecore_event_x_handle_events(int fd); +static void ecore_event_x_translate_events(XEvent * events, + int num_events); -static void e_ev_key_down_free(void *event); -static void e_ev_key_up_free(void *event); -static void e_ev_generic_free(void *event); -static void e_ev_dnd_drop_request_free(void *event); -static void e_ev_paste_request_free(void *event); +static void ecore_event_key_down_free(void *event); +static void ecore_event_key_up_free(void *event); +static void ecore_event_generic_free(void *event); +static void ecore_event_dnd_drop_request_free(void *event); +static void ecore_event_paste_request_free(void *event); -static void e_ev_x_handle_key_press(XEvent * xevent); -static void e_ev_x_handle_key_release(XEvent * xevent); -static void e_ev_x_handle_button_press(XEvent * xevent); -static void e_ev_x_handle_button_release(XEvent * xevent); -static void e_ev_x_handle_motion_notify(XEvent * xevent); -static void e_ev_x_handle_enter_notify(XEvent * xevent); -static void e_ev_x_handle_leave_notify(XEvent * xevent); -static void e_ev_x_handle_focus_in(XEvent * xevent); -static void e_ev_x_handle_focus_out(XEvent * xevent); -static void e_ev_x_handle_expose(XEvent * xevent); -static void e_ev_x_handle_visibility_notify(XEvent * xevent); -static void e_ev_x_handle_create_notify(XEvent * xevent); -static void e_ev_x_handle_destroy_notify(XEvent * xevent); -static void e_ev_x_handle_unmap_notify(XEvent * xevent); -static void e_ev_x_handle_map_notify(XEvent * xevent); -static void e_ev_x_handle_map_request(XEvent * xevent); -static void e_ev_x_handle_reparent_notify(XEvent * xevent); -static void e_ev_x_handle_configure_notify(XEvent * xevent); -static void e_ev_x_handle_configure_request(XEvent * xevent); -static void e_ev_x_handle_circulate_notify(XEvent * xevent); -static void e_ev_x_handle_circulate_request(XEvent * xevent); -static void e_ev_x_handle_property_notify(XEvent * xevent); -static void e_ev_x_handle_colormap_notify(XEvent * xevent); -static void e_ev_x_handle_selection_notify(XEvent * xevent); -static void e_ev_x_handle_selection_clear(XEvent * xevent); -static void e_ev_x_handle_selection_request(XEvent * xevent); -static void e_ev_x_handle_client_message(XEvent * xevent); -static void e_ev_x_handle_shape_change(XEvent * xevent); +static void ecore_event_x_handle_keypress(XEvent * xevent); +static void ecore_event_x_handle_keyrelease(XEvent * xevent); +static void ecore_event_x_handle_button_press(XEvent * xevent); +static void ecore_event_x_handle_button_release(XEvent * xevent); +static void ecore_event_x_handle_motion_notify(XEvent * xevent); +static void ecore_event_x_handle_enter_notify(XEvent * xevent); +static void ecore_event_x_handle_leave_notify(XEvent * xevent); +static void ecore_event_x_handle_focus_in(XEvent * xevent); +static void ecore_event_x_handle_focus_out(XEvent * xevent); +static void ecore_event_x_handle_expose(XEvent * xevent); +static void ecore_event_x_handle_visibility_notify(XEvent * xevent); +static void ecore_event_x_handle_create_notify(XEvent * xevent); +static void ecore_event_x_handle_destroy_notify(XEvent * xevent); +static void ecore_event_x_handle_unmap_notify(XEvent * xevent); +static void ecore_event_x_handle_map_notify(XEvent * xevent); +static void ecore_event_x_handle_map_request(XEvent * xevent); +static void ecore_event_x_handle_reparent_notify(XEvent * xevent); +static void ecore_event_x_handle_configure_notify(XEvent * xevent); +static void ecore_event_x_handle_configure_request(XEvent * xevent); +static void ecore_event_x_handle_circulate_notify(XEvent * xevent); +static void ecore_event_x_handle_circulate_request(XEvent * xevent); +static void ecore_event_x_handle_property_notify(XEvent * xevent); +static void ecore_event_x_handle_colormap_notify(XEvent * xevent); +static void ecore_event_x_handle_selection_notify(XEvent * xevent); +static void ecore_event_x_handle_selection_clear(XEvent * xevent); +static void ecore_event_x_handle_selection_request(XEvent * xevent); +static void ecore_event_x_handle_client_message(XEvent * xevent); +static void ecore_event_x_handle_shape_change(XEvent * xevent); static int max_event_id = 0; static void (**event_translator) (XEvent * event) = NULL; static int lock_mask_scroll = 0, lock_mask_num = 0, lock_mask_caps = 0; static int mod_mask_shift = 0, mod_mask_ctrl = 0, mod_mask_alt = - 0, mod_mask_win = 0; + 0, mod_mask_win = 0; /* convenience macros */ #define GETSET_MODS(state, mods) \ -(mods) = EV_KEY_MODIFIER_NONE;\ -if ((state) & mod_mask_shift) { e_mod_shift_set(1); (mods) |= EV_KEY_MODIFIER_SHIFT; }\ -else e_mod_shift_set(0);\ -if ((state) & mod_mask_ctrl) { e_mod_ctrl_set(1); (mods) |= EV_KEY_MODIFIER_CTRL; }\ -else e_mod_ctrl_set(0);\ -if ((state) & mod_mask_alt) { e_mod_alt_set(1); (mods) |= EV_KEY_MODIFIER_ALT; }\ -else e_mod_alt_set(0);\ -if ((state) & mod_mask_win) { e_mod_win_set(1); (mods) |= EV_KEY_MODIFIER_WIN; }\ -else e_mod_win_set(0); +(mods) = ECORE_EVENT_KEY_MODIFIER_NONE;\ +if ((state) & mod_mask_shift) { ecore_mod_shift_set(1); (mods) |= ECORE_EVENT_KEY_MODIFIER_SHIFT; }\ +else ecore_mod_shift_set(0);\ +if ((state) & mod_mask_ctrl) { ecore_mod_ctrl_set(1); (mods) |= ECORE_EVENT_KEY_MODIFIER_CTRL; }\ +else ecore_mod_ctrl_set(0);\ +if ((state) & mod_mask_alt) { ecore_mod_alt_set(1); (mods) |= ECORE_EVENT_KEY_MODIFIER_ALT; }\ +else ecore_mod_alt_set(0);\ +if ((state) & mod_mask_win) { ecore_mod_win_set(1); (mods) |= ECORE_EVENT_KEY_MODIFIER_WIN; }\ +else ecore_mod_win_set(0); /* public functions */ /* initialise event handling for the fd X is on */ void -e_ev_x_init(void) +ecore_event_x_init(void) { - int i, shape_event_id, current_lock; + int i, shape_event_id, current_lock; - shape_event_id = max_event_id = e_event_shape_get_id(); - event_translator = NEW_PTR(max_event_id + 1); - for (i = 0; i < max_event_id + 1; i++) - event_translator[i] = NULL; - event_translator[KeyPress] = e_ev_x_handle_key_press; - event_translator[KeyRelease] = e_ev_x_handle_key_release; - event_translator[ButtonPress] = e_ev_x_handle_button_press; - event_translator[ButtonRelease] = e_ev_x_handle_button_release; - event_translator[MotionNotify] = e_ev_x_handle_motion_notify; - event_translator[EnterNotify] = e_ev_x_handle_enter_notify; - event_translator[LeaveNotify] = e_ev_x_handle_leave_notify; - event_translator[FocusIn] = e_ev_x_handle_focus_in; - event_translator[FocusOut] = e_ev_x_handle_focus_out; - event_translator[Expose] = e_ev_x_handle_expose; - event_translator[VisibilityNotify] = e_ev_x_handle_visibility_notify; - event_translator[CreateNotify] = e_ev_x_handle_create_notify; - event_translator[DestroyNotify] = e_ev_x_handle_destroy_notify; - event_translator[UnmapNotify] = e_ev_x_handle_unmap_notify; - event_translator[MapNotify] = e_ev_x_handle_map_notify; - event_translator[MapRequest] = e_ev_x_handle_map_request; - event_translator[ReparentNotify] = e_ev_x_handle_reparent_notify; - event_translator[ConfigureNotify] = e_ev_x_handle_configure_notify; - event_translator[ConfigureRequest] = e_ev_x_handle_configure_request; - event_translator[CirculateNotify] = e_ev_x_handle_circulate_notify; - event_translator[CirculateRequest] = e_ev_x_handle_circulate_request; - event_translator[PropertyNotify] = e_ev_x_handle_property_notify; - event_translator[ColormapNotify] = e_ev_x_handle_colormap_notify; - event_translator[ClientMessage] = e_ev_x_handle_client_message; - event_translator[SelectionNotify] = e_ev_x_handle_selection_notify; - event_translator[SelectionClear] = e_ev_x_handle_selection_clear; - event_translator[SelectionRequest] = e_ev_x_handle_selection_request; - event_translator[shape_event_id] = e_ev_x_handle_shape_change; + shape_event_id = max_event_id = ecore_event_shape_get_id(); + event_translator = NEW_PTR(max_event_id + 1); + for (i = 0; i < max_event_id + 1; i++) + event_translator[i] = NULL; + event_translator[KeyPress] = ecore_event_x_handle_keypress; + event_translator[KeyRelease] = ecore_event_x_handle_keyrelease; + event_translator[ButtonPress] = ecore_event_x_handle_button_press; + event_translator[ButtonRelease] = ecore_event_x_handle_button_release; + event_translator[MotionNotify] = ecore_event_x_handle_motion_notify; + event_translator[EnterNotify] = ecore_event_x_handle_enter_notify; + event_translator[LeaveNotify] = ecore_event_x_handle_leave_notify; + event_translator[FocusIn] = ecore_event_x_handle_focus_in; + event_translator[FocusOut] = ecore_event_x_handle_focus_out; + event_translator[Expose] = ecore_event_x_handle_expose; + event_translator[VisibilityNotify] = ecore_event_x_handle_visibility_notify; + event_translator[CreateNotify] = ecore_event_x_handle_create_notify; + event_translator[DestroyNotify] = ecore_event_x_handle_destroy_notify; + event_translator[UnmapNotify] = ecore_event_x_handle_unmap_notify; + event_translator[MapNotify] = ecore_event_x_handle_map_notify; + event_translator[MapRequest] = ecore_event_x_handle_map_request; + event_translator[ReparentNotify] = ecore_event_x_handle_reparent_notify; + event_translator[ConfigureNotify] = ecore_event_x_handle_configure_notify; + event_translator[ConfigureRequest] = ecore_event_x_handle_configure_request; + event_translator[CirculateNotify] = ecore_event_x_handle_circulate_notify; + event_translator[CirculateRequest] = ecore_event_x_handle_circulate_request; + event_translator[PropertyNotify] = ecore_event_x_handle_property_notify; + event_translator[ColormapNotify] = ecore_event_x_handle_colormap_notify; + event_translator[ClientMessage] = ecore_event_x_handle_client_message; + event_translator[SelectionNotify] = ecore_event_x_handle_selection_notify; + event_translator[SelectionClear] = ecore_event_x_handle_selection_clear; + event_translator[SelectionRequest] = ecore_event_x_handle_selection_request; + event_translator[shape_event_id] = ecore_event_x_handle_shape_change; - lock_mask_scroll = e_lock_mask_scroll_get(); - lock_mask_num = e_lock_mask_num_get(); - lock_mask_caps = e_lock_mask_caps_get(); + lock_mask_scroll = ecore_lock_mask_scroll_get(); + lock_mask_num = ecore_lock_mask_num_get(); + lock_mask_caps = ecore_lock_mask_caps_get(); - mod_mask_shift = e_mod_mask_shift_get(); - mod_mask_ctrl = e_mod_mask_ctrl_get(); - mod_mask_alt = e_mod_mask_alt_get(); - mod_mask_win = e_mod_mask_win_get(); + mod_mask_shift = ecore_mod_mask_shift_get(); + mod_mask_ctrl = ecore_mod_mask_ctrl_get(); + mod_mask_alt = ecore_mod_mask_alt_get(); + mod_mask_win = ecore_mod_mask_win_get(); /* HRRRMMM lets not do this - e_key_grab("Num_Lock", EV_KEY_MODIFIER_NONE, 1, 1); - e_key_grab("Scroll_Lock", EV_KEY_MODIFIER_NONE, 1, 1); - e_key_grab("Caps_Lock", EV_KEY_MODIFIER_NONE, 1, 1); + ecorecore_keygrab("Num_Lock", ECORE_EVENT_KEY_MODIFIER_NONE, 1, 1); + ecorecore_keygrab("Scroll_Lock", ECORE_EVENT_KEY_MODIFIER_NONE, 1, 1); + ecorecore_keygrab("Caps_Lock", ECORE_EVENT_KEY_MODIFIER_NONE, 1, 1); */ - current_lock = e_modifier_mask_get(); - if (current_lock & lock_mask_scroll) - e_lock_scroll_set(1); - if (current_lock & lock_mask_num) - e_lock_num_set(1); - if (current_lock & lock_mask_caps) - e_lock_caps_set(1); - if (current_lock & mod_mask_shift) - e_mod_shift_set(1); - if (current_lock & mod_mask_ctrl) - e_mod_ctrl_set(1); - if (current_lock & mod_mask_alt) - e_mod_alt_set(1); - if (current_lock & mod_mask_win) - e_mod_win_set(1); - e_add_event_fd(e_x_get_fd(), e_ev_x_handle_events); + current_lock = ecore_modifier_mask_get(); + if (current_lock & lock_mask_scroll) + ecore_lock_scroll_set(1); + if (current_lock & lock_mask_num) + ecore_lock_num_set(1); + if (current_lock & lock_mask_caps) + ecore_lock_caps_set(1); + if (current_lock & mod_mask_shift) + ecore_mod_shift_set(1); + if (current_lock & mod_mask_ctrl) + ecore_mod_ctrl_set(1); + if (current_lock & mod_mask_alt) + ecore_mod_alt_set(1); + if (current_lock & mod_mask_win) + ecore_mod_win_set(1); + ecore_add_event_fd(ecore_x_get_fd(), ecore_event_x_handle_events); } /* private functions */ /* get all events onthe event queue and translate them */ static void -e_ev_x_handle_events(int fd) +ecore_event_x_handle_events(int fd) { - int num_events = 0, size_events = 0; - XEvent *events = NULL; + int num_events = 0, size_events = 0; + XEvent *events = NULL; - /* while there are events in the queue */ - while (e_events_pending()) - { - /* incriment our event count */ - num_events++; - /* if the numebr fo events is > than our buffer size then */ - if (num_events > size_events) - { - /* increase the buffer size by 64 events */ - size_events += 64; - if (events) - { - REALLOC(events, XEvent, size_events) - } - else - events = NEW(XEvent, size_events); - } - /* get the next event into the event buffer */ - e_get_next_event(&(events[num_events - 1])); - } - /* call the XEvent -> Eevent translator */ - if (events) - { - e_ev_x_translate_events(events, num_events); - /* if theres an event buffer - free it */ - FREE(events); - } - return; - fd = 0; + /* while there are events in the queue */ + while (ecore_events_pending()) + { + /* incriment our event count */ + num_events++; + /* if the numebr fo events is > than our buffer size then */ + if (num_events > size_events) + { + /* increase the buffer size by 64 events */ + size_events += 64; + if (events) + { + REALLOC(events, XEvent, size_events)} + else + events = NEW(XEvent, size_events); + } + /* get the next event into the event buffer */ + ecore_get_next_event(&(events[num_events - 1])); + } + /* call the XEvent -> Eevent translator */ + if (events) + { + ecore_event_x_translate_events(events, num_events); + /* if theres an event buffer - free it */ + FREE(events); + } + return; + fd = 0; } /* take an array of events and translate them into E events */ static void -e_ev_x_translate_events(XEvent * events, int num_events) +ecore_event_x_translate_events(XEvent * events, int num_events) { - int i; + int i; - for (i = 0; i < num_events; i++) - { - if ((events[i].type <= max_event_id) && - (event_translator[events[i].type])) - (*(event_translator[events[i].type])) (&(events[i])); - } + for (i = 0; i < num_events; i++) + { + if ((events[i].type <= max_event_id) && + (event_translator[events[i].type])) + (*(event_translator[events[i].type])) (&(events[i])); + } } static void -e_ev_key_down_free(void *event) +ecore_event_key_down_free(void *event) { - Ev_Key_Down *e; + Ecore_Event_Key_Down *e; - e = (Ev_Key_Down *) event; - IF_FREE(e->key); - IF_FREE(e->compose); - FREE(e); + e = (Ecore_Event_Key_Down *) event; + IF_FREE(e->key); + IF_FREE(e->compose); + FREE(e); } static void -e_ev_key_up_free(void *event) +ecore_event_key_up_free(void *event) { - Ev_Key_Up *e; + Ecore_Event_Key_Up *e; - e = (Ev_Key_Up *) event; - IF_FREE(e->key); - IF_FREE(e->compose); - FREE(e); + e = (Ecore_Event_Key_Up *) event; + IF_FREE(e->key); + IF_FREE(e->compose); + FREE(e); } static void -e_ev_generic_free(void *event) +ecore_event_generic_free(void *event) { - FREE(event); + FREE(event); } static void -e_ev_dnd_drop_request_free(void *event) +ecore_event_dnd_drop_request_free(void *event) { - Ev_Dnd_Drop_Request *e; + Ecore_Event_Dnd_Drop_Request *e; - e = (Ev_Dnd_Drop_Request *) event; - if (e->files) - { - int i; - for (i=0; i< e->num_files; i++) - FREE(e->files[i]); - } - FREE(event); + e = (Ecore_Event_Dnd_Drop_Request *) event; + if (e->files) + { + int i; + + for (i = 0; i < e->num_files; i++) + FREE(e->files[i]); + } + FREE(event); } static void -e_ev_paste_request_free(void *event) +ecore_event_paste_request_free(void *event) { - Ev_Paste_Request *e; + Ecore_Event_Paste_Request *e; - e = (Ev_Paste_Request *) event; - IF_FREE(e->string); - FREE(event); + e = (Ecore_Event_Paste_Request *) event; + IF_FREE(e->string); + FREE(event); } static void -e_ev_x_handle_key_press(XEvent * xevent) +ecore_event_x_handle_keypress(XEvent * xevent) { - Ev_Key_Down *e; - static KeyCode previous_code = 0; - static Time previous_time = 0; + Ecore_Event_Key_Down *e; + static KeyCode previous_code = 0; + static Time previous_time = 0; - /* avoid doubling events up from passive grabs */ - if ((xevent->xkey.keycode == previous_code) && - xevent->xkey.time == previous_time) - return; - previous_code = xevent->xkey.keycode; - previous_time = xevent->xkey.time; + /* avoid doubling events up from passive grabs */ + if ((xevent->xkey.keycode == previous_code) && + xevent->xkey.time == previous_time) + return; + previous_code = xevent->xkey.keycode; + previous_time = xevent->xkey.time; /* - if (e_key_get_keysym_from_keycode(xevent->xkey.keycode) == XK_Scroll_Lock) + if (ecore_keyget_keysym_from_keycode(xevent->xkey.keycode) == XK_Scroll_Lock) { - if (e_lock_scroll_get()) - e_lock_scroll_set(0); + if (ecore_lock_scroll_get()) + ecore_lock_scroll_set(0); else - e_lock_scroll_set(1); + ecore_lock_scroll_set(1); e_event_allow(ReplayKeyboard, xevent->xkey.time); - e_flush(); + ecore_flush(); } - else if (e_key_get_keysym_from_keycode(xevent->xkey.keycode) == XK_Num_Lock) + else if (ecore_keyget_keysym_from_keycode(xevent->xkey.keycode) == XK_Num_Lock) { - if (e_lock_num_get()) - e_lock_num_set(0); + if (ecore_lock_num_get()) + ecore_lock_num_set(0); else - e_lock_num_set(1); + ecore_lock_num_set(1); e_event_allow(ReplayKeyboard, xevent->xkey.time); - e_flush(); + ecore_flush(); } - else if (e_key_get_keysym_from_keycode(xevent->xkey.keycode) == XK_Caps_Lock) + else if (ecore_keyget_keysym_from_keycode(xevent->xkey.keycode) == XK_Caps_Lock) { - if (e_lock_caps_get()) - e_lock_caps_set(0); + if (ecore_lock_caps_get()) + ecore_lock_caps_set(0); else - e_lock_caps_set(1); + ecore_lock_caps_set(1); e_event_allow(ReplayKeyboard, xevent->xkey.time); - e_flush(); + ecore_flush(); } */ - e = NEW(Ev_Key_Down, 1); - e->win = xevent->xkey.window; - e->root = xevent->xkey.root; - GETSET_MODS(xevent->xkey.state, e->mods); - e->time = xevent->xkey.time; - e->key = e_key_get_string_from_keycode(xevent->xkey.keycode); - { - int val; - char buf[256]; - KeySym sym; - XComposeStatus stat; + e = NEW(Ecore_Event_Key_Down, 1); + e->win = xevent->xkey.window; + e->root = xevent->xkey.root; + GETSET_MODS(xevent->xkey.state, e->mods); + e->time = xevent->xkey.time; + e->key = ecore_key_get_string_from_keycode(xevent->xkey.keycode); + { + int val; + char buf[256]; + KeySym sym; + XComposeStatus stat; - val = XLookupString((XKeyEvent *) xevent, buf, sizeof(buf), &sym, &stat); - if (val > 0) - { - buf[val] = 0; - e->compose = strdup(buf); - } + val = XLookupString((XKeyEvent *) xevent, buf, sizeof(buf), &sym, &stat); + if (val > 0) + { + buf[val] = 0; + e->compose = strdup(buf); + } + else + e->compose = NULL; + } + ecore_add_event(ECORE_EVENT_KEY_DOWN, e, ecore_event_key_down_free); +} + +static void +ecore_event_x_handle_keyrelease(XEvent * xevent) +{ + Ecore_Event_Key_Up *e; + static KeyCode previous_code = 0; + static Time previous_time = 0; + + /* avoid doubling events up from passive grabs */ + if ((xevent->xkey.keycode == previous_code) && + xevent->xkey.time == previous_time) + return; + previous_code = xevent->xkey.keycode; + previous_time = xevent->xkey.time; + + e = NEW(Ecore_Event_Key_Up, 1); + e->win = xevent->xkey.window; + e->root = xevent->xkey.root; + GETSET_MODS(xevent->xkey.state, e->mods); + e->time = xevent->xkey.time; + e->key = ecore_key_get_string_from_keycode(xevent->xkey.keycode); + { + int val; + char buf[256]; + KeySym sym; + XComposeStatus stat; + + val = XLookupString((XKeyEvent *) xevent, buf, sizeof(buf), &sym, &stat); + if (val > 0) + { + buf[val] = 0; + e->compose = strdup(buf); + } + else + e->compose = NULL; + } + ecore_add_event(ECORE_EVENT_KEY_UP, e, ecore_event_key_up_free); +} + +static void +ecore_event_x_handle_button_press(XEvent * xevent) +{ + static Time last_time = 0, last_last_time = 0; + static int last_button = 0, last_last_button = 0; + static Window last_window = 0, last_last_window = 0; + + ecore_pointer_xy_set(xevent->xbutton.x_root, xevent->xbutton.y_root); + if ((xevent->xbutton.button == 4) || (xevent->xbutton.button == 5)) + { + Ecore_Event_Wheel *e; + + e = NEW(Ecore_Event_Wheel, 1); + e->win = xevent->xbutton.window; + e->root = xevent->xbutton.root; + e->x = xevent->xbutton.x; + e->y = xevent->xbutton.y; + e->rx = xevent->xbutton.x_root; + e->ry = xevent->xbutton.y_root; + e->time = xevent->xbutton.time; + if (xevent->xbutton.button == 5) + e->z = 1; else - e->compose = NULL; - } - e_add_event(EV_KEY_DOWN, e, e_ev_key_down_free); -} + e->z = -1; + if (xevent->xbutton.time - last_time < 15) + e->z *= 16; + else if (xevent->xbutton.time - last_time < 30) + e->z *= 4; + GETSET_MODS(xevent->xbutton.state, e->mods); + ecore_add_event(ECORE_EVENT_MOUSE_WHEEL, e, ecore_event_generic_free); + } + else + { + Ecore_Event_Mouse_Down *e; -static void -e_ev_x_handle_key_release(XEvent * xevent) -{ - Ev_Key_Up *e; - static KeyCode previous_code = 0; - static Time previous_time = 0; - - /* avoid doubling events up from passive grabs */ - if ((xevent->xkey.keycode == previous_code) && - xevent->xkey.time == previous_time) - return; - previous_code = xevent->xkey.keycode; - previous_time = xevent->xkey.time; - - e = NEW(Ev_Key_Up, 1); - e->win = xevent->xkey.window; - e->root = xevent->xkey.root; - GETSET_MODS(xevent->xkey.state, e->mods); - e->time = xevent->xkey.time; - e->key = e_key_get_string_from_keycode(xevent->xkey.keycode); - { - int val; - char buf[256]; - KeySym sym; - XComposeStatus stat; - - val = XLookupString((XKeyEvent *) xevent, buf, sizeof(buf), &sym, &stat); - if (val > 0) + e = NEW(Ecore_Event_Mouse_Down, 1); + e->win = xevent->xbutton.window; + e->root = xevent->xbutton.root; + e->button = xevent->xbutton.button; + e->x = xevent->xbutton.x; + e->y = xevent->xbutton.y; + e->rx = xevent->xbutton.x_root; + e->ry = xevent->xbutton.y_root; + e->time = xevent->xbutton.time; + e->double_click = 0; + e->triple_click = 0; + GETSET_MODS(xevent->xbutton.state, e->mods); + if (xevent->xbutton.time - last_last_time < 500) { - buf[val] = 0; - e->compose = strdup(buf); + if ((xevent->xbutton.window == (unsigned int)last_window) && + (last_window == last_last_window) && + (xevent->xbutton.button == (unsigned int)last_button) && + (last_button == last_button)) + e->triple_click = 1; } - else - e->compose = NULL; - } - e_add_event(EV_KEY_UP, e, e_ev_key_up_free); + else if (xevent->xbutton.time - last_time < 250) + { + if ((xevent->xbutton.window == (unsigned int)last_window) && + (xevent->xbutton.button == (unsigned int)last_button)) + e->double_click = 1; + } + ecore_add_event(ECORE_EVENT_MOUSE_DOWN, e, ecore_event_generic_free); + { + Ecore_XID *xid = NULL; + + if (XFindContext(xevent->xbutton.display, e->win, + xid_context, (XPointer *) & xid) != XCNOENT) + { + if (xid->grab_button_auto_replay) + { + ecore_pointer_replay(e->time); + } + } + } + } + last_last_window = last_window; + last_window = xevent->xbutton.window; + last_last_button = last_button; + last_button = xevent->xbutton.button; + last_last_time = last_time; + last_time = xevent->xbutton.time; } static void -e_ev_x_handle_button_press(XEvent * xevent) +ecore_event_x_handle_button_release(XEvent * xevent) { - static Time last_time = 0, last_last_time = 0; - static int last_button = 0, last_last_button = 0; - static Window last_window = 0, last_last_window = 0; + Ecore_Event_Mouse_Up *e; - e_pointer_xy_set(xevent->xbutton.x_root, xevent->xbutton.y_root); - if ((xevent->xbutton.button == 4) || (xevent->xbutton.button == 5)) - { - Ev_Wheel *e; + if (xevent->xbutton.button > 3) + return; - e = NEW(Ev_Wheel, 1); - e->win = xevent->xbutton.window; - e->root = xevent->xbutton.root; - e->x = xevent->xbutton.x; - e->y = xevent->xbutton.y; - e->rx = xevent->xbutton.x_root; - e->ry = xevent->xbutton.y_root; - e->time = xevent->xbutton.time; - if (xevent->xbutton.button == 5) - e->z = 1; - else - e->z = -1; - if (xevent->xbutton.time - last_time < 15) - e->z *= 16; - else if (xevent->xbutton.time - last_time < 30) - e->z *= 4; - GETSET_MODS(xevent->xbutton.state, e->mods); - e_add_event(EV_MOUSE_WHEEL, e, e_ev_generic_free); - } - else - { - Ev_Mouse_Down *e; - - e = NEW(Ev_Mouse_Down, 1); - e->win = xevent->xbutton.window; - e->root = xevent->xbutton.root; - e->button = xevent->xbutton.button; - e->x = xevent->xbutton.x; - e->y = xevent->xbutton.y; - e->rx = xevent->xbutton.x_root; - e->ry = xevent->xbutton.y_root; - e->time = xevent->xbutton.time; - e->double_click = 0; - e->triple_click = 0; - GETSET_MODS(xevent->xbutton.state, e->mods); - if (xevent->xbutton.time - last_last_time < 500) - { - if ((xevent->xbutton.window == (unsigned int)last_window) && - (last_window == last_last_window) && - (xevent->xbutton.button == (unsigned int)last_button) && - (last_button == last_button)) - e->triple_click = 1; - } - else if (xevent->xbutton.time - last_time < 250) - { - if ((xevent->xbutton.window == (unsigned int)last_window) && - (xevent->xbutton.button == (unsigned int)last_button)) - e->double_click = 1; - } - e_add_event(EV_MOUSE_DOWN, e, e_ev_generic_free); - { - E_XID *xid = NULL; - - if (XFindContext(xevent->xbutton.display, e->win, - xid_context, (XPointer *) & xid) != XCNOENT) - { - if (xid->grab_button_auto_replay) - { - e_pointer_replay(e->time); - } - } - } - } - last_last_window = last_window; - last_window = xevent->xbutton.window; - last_last_button = last_button; - last_button = xevent->xbutton.button; - last_last_time = last_time; - last_time = xevent->xbutton.time; + e = NEW(Ecore_Event_Mouse_Up, 1); + e->win = xevent->xbutton.window; + e->root = xevent->xbutton.root; + e->button = xevent->xbutton.button; + e->x = xevent->xbutton.x; + e->y = xevent->xbutton.y; + e->rx = xevent->xbutton.x_root; + e->ry = xevent->xbutton.y_root; + e->time = xevent->xbutton.time; + GETSET_MODS(xevent->xbutton.state, e->mods); + ecore_add_event(ECORE_EVENT_MOUSE_UP, e, ecore_event_generic_free); } static void -e_ev_x_handle_button_release(XEvent * xevent) +ecore_event_x_handle_motion_notify(XEvent * xevent) { - Ev_Mouse_Up *e; + Ecore_Event_Mouse_Move *e; - if (xevent->xbutton.button > 3) - return; - - e = NEW(Ev_Mouse_Up, 1); - e->win = xevent->xbutton.window; - e->root = xevent->xbutton.root; - e->button = xevent->xbutton.button; - e->x = xevent->xbutton.x; - e->y = xevent->xbutton.y; - e->rx = xevent->xbutton.x_root; - e->ry = xevent->xbutton.y_root; - e->time = xevent->xbutton.time; - GETSET_MODS(xevent->xbutton.state, e->mods); - e_add_event(EV_MOUSE_UP, e, e_ev_generic_free); + ecore_pointer_xy_set(xevent->xmotion.x_root, xevent->xmotion.y_root); + e = NEW(Ecore_Event_Mouse_Move, 1); + e->win = xevent->xmotion.window; + e->root = xevent->xmotion.root; + e->x = xevent->xmotion.x; + e->y = xevent->xmotion.y; + e->rx = xevent->xmotion.x_root; + e->ry = xevent->xmotion.y_root; + e->time = xevent->xmotion.time; + GETSET_MODS(xevent->xmotion.state, e->mods); + ecore_add_event(ECORE_EVENT_MOUSE_MOVE, e, ecore_event_generic_free); } static void -e_ev_x_handle_motion_notify(XEvent * xevent) +ecore_event_x_handle_enter_notify(XEvent * xevent) { - Ev_Mouse_Move *e; - - e_pointer_xy_set(xevent->xmotion.x_root, xevent->xmotion.y_root); - e = NEW(Ev_Mouse_Move, 1); - e->win = xevent->xmotion.window; - e->root = xevent->xmotion.root; - e->x = xevent->xmotion.x; - e->y = xevent->xmotion.y; - e->rx = xevent->xmotion.x_root; - e->ry = xevent->xmotion.y_root; - e->time = xevent->xmotion.time; - GETSET_MODS(xevent->xmotion.state, e->mods); - e_add_event(EV_MOUSE_MOVE, e, e_ev_generic_free); -} - -static void -e_ev_x_handle_enter_notify(XEvent * xevent) -{ - Ev_Window_Enter *e; - -/* 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; - e->root = xevent->xcrossing.root; - e->x = xevent->xcrossing.x; - e->y = xevent->xcrossing.y; - e->rx = xevent->xcrossing.x_root; - e->ry = xevent->xcrossing.y_root; - e->time = xevent->xcrossing.time; - GETSET_MODS(xevent->xcrossing.state, e->mods); - e_add_event(EV_MOUSE_IN, e, e_ev_generic_free); - e_window_mouse_set_in(e->win, 1); - { - Ev_Mouse_Move *e; - - e = NEW(Ev_Mouse_Move, 1); - e->win = xevent->xcrossing.window; - e->root = xevent->xcrossing.root; - e->x = xevent->xcrossing.x; - e->y = xevent->xcrossing.y; - e->rx = xevent->xcrossing.x_root; - e->ry = xevent->xcrossing.y_root; - e->time = xevent->xcrossing.time; - GETSET_MODS(xevent->xcrossing.state, e->mods); - e_add_event(EV_MOUSE_MOVE, e, e_ev_generic_free); - } -} - -static void -e_ev_x_handle_leave_notify(XEvent * xevent) -{ - Ev_Window_Leave *e; + Ecore_Event_Window_Enter *e; /* 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; - - e = NEW(Ev_Mouse_Move, 1); - e->win = xevent->xcrossing.window; - e->root = xevent->xcrossing.root; - e->x = xevent->xcrossing.x; - e->y = xevent->xcrossing.y; - e->rx = xevent->xcrossing.x_root; - e->ry = xevent->xcrossing.y_root; - e->time = xevent->xcrossing.time; - GETSET_MODS(xevent->xcrossing.state, e->mods); - e_add_event(EV_MOUSE_MOVE, e, e_ev_generic_free); - } - e = NEW(Ev_Window_Leave, 1); - e->win = xevent->xcrossing.window; - e->root = xevent->xcrossing.root; - e->x = xevent->xcrossing.x; - e->y = xevent->xcrossing.y; - e->rx = xevent->xcrossing.x_root; - e->ry = xevent->xcrossing.y_root; - e->time = xevent->xcrossing.time; - GETSET_MODS(xevent->xcrossing.state, e->mods); - e_add_event(EV_MOUSE_OUT, e, e_ev_generic_free); - e_window_mouse_set_in(e->win, 0); + ecore_pointer_xy_set(xevent->xcrossing.x_root, xevent->xcrossing.y_root); + e = NEW(Ecore_Event_Window_Enter, 1); + e->win = xevent->xcrossing.window; + e->root = xevent->xcrossing.root; + e->x = xevent->xcrossing.x; + e->y = xevent->xcrossing.y; + e->rx = xevent->xcrossing.x_root; + e->ry = xevent->xcrossing.y_root; + e->time = xevent->xcrossing.time; + GETSET_MODS(xevent->xcrossing.state, e->mods); + ecore_add_event(ECORE_EVENT_MOUSE_IN, e, ecore_event_generic_free); + ecore_window_mouse_set_in(e->win, 1); + { + Ecore_Event_Mouse_Move *e; + + e = NEW(Ecore_Event_Mouse_Move, 1); + e->win = xevent->xcrossing.window; + e->root = xevent->xcrossing.root; + e->x = xevent->xcrossing.x; + e->y = xevent->xcrossing.y; + e->rx = xevent->xcrossing.x_root; + e->ry = xevent->xcrossing.y_root; + e->time = xevent->xcrossing.time; + GETSET_MODS(xevent->xcrossing.state, e->mods); + ecore_add_event(ECORE_EVENT_MOUSE_MOVE, e, ecore_event_generic_free); + } } static void -e_ev_x_handle_focus_in(XEvent * xevent) +ecore_event_x_handle_leave_notify(XEvent * xevent) { - Ev_Window_Focus_In *e; + Ecore_Event_Window_Leave *e; - e = NEW(Ev_Window_Focus_In, 1); - e->win = xevent->xfocus.window; - e->root = e_window_get_root(e->win); - if (xevent->xfocus.mode != NotifyNormal) e->key_grab = 1; - else e->key_grab = 0; - e_add_event(EV_WINDOW_FOCUS_IN, e, e_ev_generic_free); - e_focus_window_set(e->win); +/* if ((xevent->xcrossing.mode == NotifyGrab) || (xevent->xcrossing.mode == NotifyUngrab)) return;*/ + ecore_pointer_xy_set(xevent->xcrossing.x_root, xevent->xcrossing.y_root); + { + Ecore_Event_Mouse_Move *e; + + e = NEW(Ecore_Event_Mouse_Move, 1); + e->win = xevent->xcrossing.window; + e->root = xevent->xcrossing.root; + e->x = xevent->xcrossing.x; + e->y = xevent->xcrossing.y; + e->rx = xevent->xcrossing.x_root; + e->ry = xevent->xcrossing.y_root; + e->time = xevent->xcrossing.time; + GETSET_MODS(xevent->xcrossing.state, e->mods); + ecore_add_event(ECORE_EVENT_MOUSE_MOVE, e, ecore_event_generic_free); + } + e = NEW(Ecore_Event_Window_Leave, 1); + e->win = xevent->xcrossing.window; + e->root = xevent->xcrossing.root; + e->x = xevent->xcrossing.x; + e->y = xevent->xcrossing.y; + e->rx = xevent->xcrossing.x_root; + e->ry = xevent->xcrossing.y_root; + e->time = xevent->xcrossing.time; + GETSET_MODS(xevent->xcrossing.state, e->mods); + ecore_add_event(ECORE_EVENT_MOUSE_OUT, e, ecore_event_generic_free); + ecore_window_mouse_set_in(e->win, 0); } static void -e_ev_x_handle_focus_out(XEvent * xevent) +ecore_event_x_handle_focus_in(XEvent * xevent) { - Ev_Window_Focus_Out *e; + Ecore_Event_Window_Focus_In *e; - e = NEW(Ev_Window_Focus_Out, 1); - e->win = xevent->xfocus.window; - e->root = e_window_get_root(e->win); - if (xevent->xfocus.mode != NotifyNormal) e->key_grab = 1; - else e->key_grab = 0; - e_add_event(EV_WINDOW_FOCUS_OUT, e, e_ev_generic_free); - e_focus_window_set(0); + e = NEW(Ecore_Event_Window_Focus_In, 1); + e->win = xevent->xfocus.window; + e->root = ecore_window_get_root(e->win); + if (xevent->xfocus.mode != NotifyNormal) + e->key_grab = 1; + else + e->key_grab = 0; + ecore_add_event(ECORE_EVENT_WINDOW_FOCUS_IN, e, ecore_event_generic_free); + ecore_focus_window_set(e->win); } static void -e_ev_x_handle_expose(XEvent * xevent) +ecore_event_x_handle_focus_out(XEvent * xevent) { - Ev_Window_Expose *e; + Ecore_Event_Window_Focus_Out *e; - e = NEW(Ev_Window_Expose, 1); - e->win = xevent->xexpose.window; - e->root = e_window_get_root(e->win); - e->x = xevent->xexpose.x; - e->y = xevent->xexpose.y; - e->w = xevent->xexpose.width; - e->h = xevent->xexpose.height; - e_add_event(EV_WINDOW_EXPOSE, e, e_ev_generic_free); + e = NEW(Ecore_Event_Window_Focus_Out, 1); + e->win = xevent->xfocus.window; + e->root = ecore_window_get_root(e->win); + if (xevent->xfocus.mode != NotifyNormal) + e->key_grab = 1; + else + e->key_grab = 0; + ecore_add_event(ECORE_EVENT_WINDOW_FOCUS_OUT, e, ecore_event_generic_free); + ecore_focus_window_set(0); } static void -e_ev_x_handle_visibility_notify(XEvent * xevent) +ecore_event_x_handle_expose(XEvent * xevent) { - if (xevent->xvisibility.state != VisibilityPartiallyObscured) - { - Ev_Window_Visibility *e; + Ecore_Event_Window_Expose *e; - e = NEW(Ev_Window_Visibility, 1); - e->win = xevent->xvisibility.window; - e->root = e_window_get_root(e->win); - if (xevent->xvisibility.state == VisibilityFullyObscured) - e->fully_obscured = 1; - else - e->fully_obscured = 0; - e_add_event(EV_WINDOW_VISIBILITY, e, e_ev_generic_free); - } + e = NEW(Ecore_Event_Window_Expose, 1); + e->win = xevent->xexpose.window; + e->root = ecore_window_get_root(e->win); + e->x = xevent->xexpose.x; + e->y = xevent->xexpose.y; + e->w = xevent->xexpose.width; + e->h = xevent->xexpose.height; + ecore_add_event(ECORE_EVENT_WINDOW_EXPOSE, e, ecore_event_generic_free); } static void -e_ev_x_handle_create_notify(XEvent * xevent) +ecore_event_x_handle_visibility_notify(XEvent * xevent) { - Ev_Window_Create *e; + if (xevent->xvisibility.state != VisibilityPartiallyObscured) + { + Ecore_Event_Window_Visibility *e; - e = NEW(Ev_Window_Create, 1); - e->win = xevent->xcreatewindow.window; - e_validate_xid(e->win); - e->root = e_window_get_root(e->win); - if (xevent->xcreatewindow.override_redirect) - e->override = 1; - else - e->override = 0; - e_add_event(EV_WINDOW_CREATE, e, e_ev_generic_free); + e = NEW(Ecore_Event_Window_Visibility, 1); + e->win = xevent->xvisibility.window; + e->root = ecore_window_get_root(e->win); + if (xevent->xvisibility.state == VisibilityFullyObscured) + e->fully_obscured = 1; + else + e->fully_obscured = 0; + ecore_add_event(ECORE_EVENT_WINDOW_VISIBILITY, e, + ecore_event_generic_free); + } } static void -e_ev_x_handle_destroy_notify(XEvent * xevent) +ecore_event_x_handle_create_notify(XEvent * xevent) { - Ev_Window_Destroy *e; + Ecore_Event_Window_Create *e; - e = NEW(Ev_Window_Destroy, 1); - e->win = xevent->xdestroywindow.window; - e->root = e_window_get_root(e->win); - e_add_event(EV_WINDOW_DESTROY, e, e_ev_generic_free); - e_unvalidate_xid(e->win); + e = NEW(Ecore_Event_Window_Create, 1); + e->win = xevent->xcreatewindow.window; + ecore_validate_xid(e->win); + e->root = ecore_window_get_root(e->win); + if (xevent->xcreatewindow.override_redirect) + e->override = 1; + else + e->override = 0; + ecore_add_event(ECORE_EVENT_WINDOW_CREATE, e, ecore_event_generic_free); } static void -e_ev_x_handle_unmap_notify(XEvent * xevent) +ecore_event_x_handle_destroy_notify(XEvent * xevent) { - Ev_Window_Unmap *e; - E_XID *xid = NULL; + Ecore_Event_Window_Destroy *e; - e = NEW(Ev_Window_Unmap, 1); - e->win = xevent->xunmap.window; - e->root = e_window_get_root(e->win); - e_add_event(EV_WINDOW_UNMAP, e, e_ev_generic_free); - xid = e_validate_xid(e->win); - if (xid) - xid->mapped = 0; + e = NEW(Ecore_Event_Window_Destroy, 1); + e->win = xevent->xdestroywindow.window; + e->root = ecore_window_get_root(e->win); + ecore_add_event(ECORE_EVENT_WINDOW_DESTROY, e, ecore_event_generic_free); + ecore_unvalidate_xid(e->win); } static void -e_ev_x_handle_map_notify(XEvent * xevent) +ecore_event_x_handle_unmap_notify(XEvent * xevent) { - Ev_Window_Map *e; - E_XID *xid = NULL; + Ecore_Event_Window_Unmap *e; + Ecore_XID *xid = NULL; - e = NEW(Ev_Window_Map, 1); - e->win = xevent->xmap.window; - e->root = e_window_get_root(e->win); - e_add_event(EV_WINDOW_MAP, e, e_ev_generic_free); - xid = e_validate_xid(e->win); - if (xid) - xid->mapped = 1; + e = NEW(Ecore_Event_Window_Unmap, 1); + e->win = xevent->xunmap.window; + e->root = ecore_window_get_root(e->win); + ecore_add_event(ECORE_EVENT_WINDOW_UNMAP, e, ecore_event_generic_free); + xid = ecore_validate_xid(e->win); + if (xid) + xid->mapped = 0; } static void -e_ev_x_handle_map_request(XEvent * xevent) +ecore_event_x_handle_map_notify(XEvent * xevent) { - Ev_Window_Map_Request *e; + Ecore_Event_Window_Map *e; + Ecore_XID *xid = NULL; - e = NEW(Ev_Window_Map_Request, 1); - e->win = xevent->xmaprequest.window; - e->root = e_window_get_root(e->win); - e_add_event(EV_WINDOW_MAP_REQUEST, e, e_ev_generic_free); - e_validate_xid(e->win); + e = NEW(Ecore_Event_Window_Map, 1); + e->win = xevent->xmap.window; + e->root = ecore_window_get_root(e->win); + ecore_add_event(ECORE_EVENT_WINDOW_MAP, e, ecore_event_generic_free); + xid = ecore_validate_xid(e->win); + if (xid) + xid->mapped = 1; } static void -e_ev_x_handle_reparent_notify(XEvent * xevent) +ecore_event_x_handle_map_request(XEvent * xevent) { - Ev_Window_Reparent *e; - Window parent; - E_XID *xid = NULL; + Ecore_Event_Window_Map_Request *e; - e = NEW(Ev_Window_Reparent, 1); - e->win = xevent->xreparent.window; - xid = e_validate_xid(e->win); - e->root = e_window_get_root(e->win); - parent = e_window_get_parent(e->win); - e->parent_from = parent; - e->parent = xevent->xreparent.parent; - e_validate_xid(e->parent); - e_del_child(parent, e->win); - e_add_child(xevent->xreparent.parent, xevent->xreparent.window); - if (xid) - xid->parent = e->parent; - e_add_event(EV_WINDOW_REPARENT, e, e_ev_generic_free); + e = NEW(Ecore_Event_Window_Map_Request, 1); + e->win = xevent->xmaprequest.window; + e->root = ecore_window_get_root(e->win); + ecore_add_event(ECORE_EVENT_WINDOW_MAP_REQUEST, e, ecore_event_generic_free); + ecore_validate_xid(e->win); } static void -e_ev_x_handle_configure_notify(XEvent * xevent) +ecore_event_x_handle_reparent_notify(XEvent * xevent) { - Ev_Window_Configure *e; - E_XID *xid; + Ecore_Event_Window_Reparent *e; + Window parent; + Ecore_XID *xid = NULL; - e = NEW(Ev_Window_Configure, 1); - e->win = xevent->xconfigure.window; - e->root = e_window_get_root(e->win); - e->x = xevent->xconfigure.x; - e->y = xevent->xconfigure.y; - e->w = xevent->xconfigure.width; - e->h = xevent->xconfigure.height; - if (!xevent->xconfigure.send_event) - { - xid = e_validate_xid(e->win); - if (xid) - { - xid->x = e->x; - xid->y = e->y; - xid->w = e->w; - xid->h = e->h; - } - e->wm_generated = 0; - /* FIXME: dont handle redioing stack for xevent->xconfigure.above */ - /* member (the window is stacked immediately in stack above this) */ - } - else - e->wm_generated = 1; - e_add_event(EV_WINDOW_CONFIGURE, e, e_ev_generic_free); + e = NEW(Ecore_Event_Window_Reparent, 1); + e->win = xevent->xreparent.window; + xid = ecore_validate_xid(e->win); + e->root = ecore_window_get_root(e->win); + parent = ecore_window_get_parent(e->win); + e->parent_from = parent; + e->parent = xevent->xreparent.parent; + ecore_validate_xid(e->parent); + ecore_del_child(parent, e->win); + ecore_add_child(xevent->xreparent.parent, xevent->xreparent.window); + if (xid) + xid->parent = e->parent; + ecore_add_event(ECORE_EVENT_WINDOW_REPARENT, e, ecore_event_generic_free); } static void -e_ev_x_handle_configure_request(XEvent * xevent) +ecore_event_x_handle_configure_notify(XEvent * xevent) { - Ev_Window_Configure_Request *e; + Ecore_Event_Window_Configure *e; + Ecore_XID *xid; - e = NEW(Ev_Window_Configure_Request, 1); - e->win = xevent->xconfigurerequest.window; - e->root = e_window_get_root(e->win); - e->x = xevent->xconfigurerequest.x; - e->y = xevent->xconfigurerequest.y; - e->w = xevent->xconfigurerequest.width; - e->h = xevent->xconfigurerequest.height; - e->stack_win = xevent->xconfigurerequest.above; - e->detail = xevent->xconfigurerequest.detail; - e->mask = xevent->xconfigurerequest.value_mask; - e_add_event(EV_WINDOW_CONFIGURE_REQUEST, e, e_ev_generic_free); + e = NEW(Ecore_Event_Window_Configure, 1); + e->win = xevent->xconfigure.window; + e->root = ecore_window_get_root(e->win); + e->x = xevent->xconfigure.x; + e->y = xevent->xconfigure.y; + e->w = xevent->xconfigure.width; + e->h = xevent->xconfigure.height; + if (!xevent->xconfigure.send_event) + { + xid = ecore_validate_xid(e->win); + if (xid) + { + xid->x = e->x; + xid->y = e->y; + xid->w = e->w; + xid->h = e->h; + } + e->wm_generated = 0; + /* FIXME: don't handle redoing stack for xevent->xconfigure.above */ + /* member (the window is stacked immediately in stack above this) */ + } + else + e->wm_generated = 1; + ecore_add_event(ECORE_EVENT_WINDOW_CONFIGURE, e, ecore_event_generic_free); } static void -e_ev_x_handle_circulate_notify(XEvent * xevent) +ecore_event_x_handle_configure_request(XEvent * xevent) { - Ev_Window_Circulate *e; + Ecore_Event_Window_Configure_Request *e; - e = NEW(Ev_Window_Circulate, 1); - e->win = xevent->xcirculate.window; - e->root = e_window_get_root(e->win); - if (xevent->xcirculate.place == PlaceOnBottom) - e->lower = 1; - else - e->lower = 0; - e_add_event(EV_WINDOW_CIRCULATE, e, e_ev_generic_free); + e = NEW(Ecore_Event_Window_Configure_Request, 1); + e->win = xevent->xconfigurerequest.window; + e->root = ecore_window_get_root(e->win); + e->x = xevent->xconfigurerequest.x; + e->y = xevent->xconfigurerequest.y; + e->w = xevent->xconfigurerequest.width; + e->h = xevent->xconfigurerequest.height; + e->stack_win = xevent->xconfigurerequest.above; + e->detail = xevent->xconfigurerequest.detail; + e->mask = xevent->xconfigurerequest.value_mask; + ecore_add_event(ECORE_EVENT_WINDOW_CONFIGURE_REQUEST, e, + ecore_event_generic_free); } static void -e_ev_x_handle_circulate_request(XEvent * xevent) +ecore_event_x_handle_circulate_notify(XEvent * xevent) { - Ev_Window_Circulate_Request *e; + Ecore_Event_Window_Circulate *e; - e = NEW(Ev_Window_Circulate_Request, 1); - e->win = xevent->xcirculaterequest.window; - e->root = e_window_get_root(e->win); - if (xevent->xcirculaterequest.place == PlaceOnBottom) - e->lower = 1; - else - e->lower = 0; - e_add_event(EV_WINDOW_CIRCULATE_REQUEST, e, e_ev_generic_free); + e = NEW(Ecore_Event_Window_Circulate, 1); + e->win = xevent->xcirculate.window; + e->root = ecore_window_get_root(e->win); + if (xevent->xcirculate.place == PlaceOnBottom) + e->lower = 1; + else + e->lower = 0; + ecore_add_event(ECORE_EVENT_WINDOW_CIRCULATE, e, ecore_event_generic_free); } static void -e_ev_x_handle_property_notify(XEvent * xevent) +ecore_event_x_handle_circulate_request(XEvent * xevent) { - Ev_Window_Property *e; + Ecore_Event_Window_Circulate_Request *e; - e = NEW(Ev_Window_Property, 1); - e->win = xevent->xproperty.window; - e->root = e_window_get_root(e->win); - e->atom = xevent->xproperty.atom; - e->time = xevent->xproperty.time; - e_add_event(EV_WINDOW_PROPERTY, e, e_ev_generic_free); + e = NEW(Ecore_Event_Window_Circulate_Request, 1); + e->win = xevent->xcirculaterequest.window; + e->root = ecore_window_get_root(e->win); + if (xevent->xcirculaterequest.place == PlaceOnBottom) + e->lower = 1; + else + e->lower = 0; + ecore_add_event(ECORE_EVENT_WINDOW_CIRCULATE_REQUEST, e, + ecore_event_generic_free); } static void -e_ev_x_handle_colormap_notify(XEvent * xevent) +ecore_event_x_handle_property_notify(XEvent * xevent) { - Ev_Colormap *e; + Ecore_Event_Window_Property *e; - e = NEW(Ev_Colormap, 1); - e->win = xevent->xcolormap.window; - e->root = e_window_get_root(e->win); - e->cmap = xevent->xcolormap.colormap; - if (xevent->xcolormap.state == ColormapInstalled) - e->installed = 1; - else - e->installed = 0; - e_add_event(EV_COLORMAP, e, e_ev_generic_free); + e = NEW(Ecore_Event_Window_Property, 1); + e->win = xevent->xproperty.window; + e->root = ecore_window_get_root(e->win); + e->atom = xevent->xproperty.atom; + e->time = xevent->xproperty.time; + ecore_add_event(ECORE_EVENT_WINDOW_PROPERTY, e, ecore_event_generic_free); } -Ev_Dnd_Drop_Request *ev_drop_request_pending = NULL; +static void +ecore_event_x_handle_colormap_notify(XEvent * xevent) +{ + Ecore_Event_Colormap *e; + + e = NEW(Ecore_Event_Colormap, 1); + e->win = xevent->xcolormap.window; + e->root = ecore_window_get_root(e->win); + e->cmap = xevent->xcolormap.colormap; + if (xevent->xcolormap.state == ColormapInstalled) + e->installed = 1; + else + e->installed = 0; + ecore_add_event(ECORE_EVENT_COLORMAP, e, ecore_event_generic_free); +} + +Ecore_Event_Dnd_Drop_Request *ev_drop_request_pending = NULL; static void -e_ev_x_handle_selection_notify(XEvent * xevent) +ecore_event_x_handle_selection_notify(XEvent * xevent) { - Ev_Dnd_Drop_Request *e; - char *data; - int size; - static Atom atom_xdndactioncopy = 0; - static Atom atom_xdndactionmove = 0; - static Atom atom_xdndactionlink = 0; - static Atom atom_xdndactionask = 0; - static Atom atom_xdndactionlist = 0; + Ecore_Event_Dnd_Drop_Request *e; + char *data; + int size; + static Atom atom_xdndactioncopy = 0; + static Atom atom_xdndactionmove = 0; + static Atom atom_xdndactionlink = 0; + static Atom atom_xdndactionask = 0; + static Atom atom_xdndactionlist = 0; - e = ev_drop_request_pending; - if (!e) - { - Ev_Paste_Request *e2; - - e2 = NEW(Ev_Paste_Request, 1); - e2->string = e_selection_get_data(xevent->xselection.requestor, - xevent->xselection.property); - if (e2->string) - { - e2->win = xevent->xselection.requestor; - e2->root = e_window_get_root(e2->win); - e2->source_win = xevent->xselection.requestor; - e_add_event(EV_PASTE_REQUEST, e2, e_ev_paste_request_free); - } - else - { - FREE(e2); - } - return; - } + e = ev_drop_request_pending; + if (!e) + { + Ecore_Event_Paste_Request *e2; - E_ATOM(atom_xdndactioncopy, "XdndActionCopy"); - E_ATOM(atom_xdndactionmove, "XdndActionMove"); - E_ATOM(atom_xdndactionlink, "XdndActionLink"); - E_ATOM(atom_xdndactionask, "XdndActionAsk"); - E_ATOM(atom_xdndactionlist, "XdndActionList"); - data = e_dnd_selection_get(xevent->xany.window, e->source_win, - xevent->xselection.property, &size); - if (data) - { - char *s, *buf; - int i, is; - Atom *method = NULL; + e2 = NEW(Ecore_Event_Paste_Request, 1); + e2->string = ecore_selection_get_data(xevent->xselection.requestor, + xevent->xselection.property); + if (e2->string) + { + e2->win = xevent->xselection.requestor; + e2->root = ecore_window_get_root(e2->win); + e2->source_win = xevent->xselection.requestor; + ecore_add_event(ECORE_EVENT_PASTE_REQUEST, e2, + ecore_event_paste_request_free); + } + else + { + FREE(e2); + } + return; + } - method = e_window_property_get(e->source_win, - atom_xdndactionlist, XA_ATOM, &is); - if (method) - { - e->copy = 0; - e->link = 0; - e->move = 0; - if (*method == atom_xdndactioncopy) - e->copy = 1; - else if (*method == atom_xdndactionmove) - e->move = 1; - else if (*method == atom_xdndactionlink) - e->link = 1; - FREE(method); - } - else - { - e->copy = 0; - e->link = 0; - e->move = 0; - } - s = data; - buf = NEW(char, size); + ECORE_ATOM(atom_xdndactioncopy, "XdndActionCopy"); + ECORE_ATOM(atom_xdndactionmove, "XdndActionMove"); + ECORE_ATOM(atom_xdndactionlink, "XdndActionLink"); + ECORE_ATOM(atom_xdndactionask, "XdndActionAsk"); + ECORE_ATOM(atom_xdndactionlist, "XdndActionList"); + data = ecore_dnd_selection_get(xevent->xany.window, e->source_win, + xevent->xselection.property, &size); + if (data) + { + char *s, *buf; + int i, is; + Atom *method = NULL; - i = 0; - is = 0; - e->files = NULL; - while ((s[is]) && (is < size)) - { - if ((i == 0) && (s[is] == '#')) - { - for (; ((s[is] != 0) && (s[is] != '\n')); is++); - } - else - { - if (s[is] != '\r') + method = ecore_window_property_get(e->source_win, + atom_xdndactionlist, XA_ATOM, &is); + if (method) + { + e->copy = 0; + e->link = 0; + e->move = 0; + if (*method == atom_xdndactioncopy) + e->copy = 1; + else if (*method == atom_xdndactionmove) + e->move = 1; + else if (*method == atom_xdndactionlink) + e->link = 1; + FREE(method); + } + else + { + e->copy = 0; + e->link = 0; + e->move = 0; + } + s = data; + buf = NEW(char, size); + + i = 0; + is = 0; + e->files = NULL; + while ((s[is]) && (is < size)) + { + if ((i == 0) && (s[is] == '#')) + { + for (; ((s[is] != 0) && (s[is] != '\n')); is++); + } + else + { + if (s[is] != '\r') + { + buf[i++] = s[is]; + } + else + { + buf[i] = 0; + e->num_files++; + if (e->files) { - buf[i++] = s[is]; + REALLOC_PTR(e->files, e->num_files); } else - { - buf[i] = 0; - e->num_files++; - if (e->files) - { - REALLOC_PTR(e->files, e->num_files); - } - else - e->files = NEW_PTR(e->num_files); - e->files[e->num_files - 1] = strdup(buf); - buf[0] = 0; - i = 0; - is++; - } + e->files = NEW_PTR(e->num_files); + e->files[e->num_files - 1] = strdup(buf); + buf[0] = 0; + i = 0; is++; - } - } - FREE(buf); - FREE(data); - } - e_add_event(EV_DND_DROP_REQUEST, e, e_ev_dnd_drop_request_free); - ev_drop_request_pending = NULL; + } + is++; + } + } + FREE(buf); + FREE(data); + } + ecore_add_event(ECORE_EVENT_DND_DROP_REQUEST, e, + ecore_event_dnd_drop_request_free); + ev_drop_request_pending = NULL; } static void -e_ev_x_handle_selection_clear(XEvent * xevent) +ecore_event_x_handle_selection_clear(XEvent * xevent) { - Ev_Clear_Selection *e; - - e = NEW(Ev_Clear_Selection, 1); - e->win = xevent->xselectionclear.window; - e->root = e_window_get_root(e->win); - e->selection = xevent->xselectionclear.selection; - e_add_event(EV_CLEAR_SELECTION, e, e_ev_generic_free); + Ecore_Event_Clear_Selection *e; + + e = NEW(Ecore_Event_Clear_Selection, 1); + e->win = xevent->xselectionclear.window; + e->root = ecore_window_get_root(e->win); + e->selection = xevent->xselectionclear.selection; + ecore_add_event(ECORE_EVENT_CLEAR_SELECTION, e, ecore_event_generic_free); } static void -e_ev_x_handle_selection_request(XEvent * xevent) +ecore_event_x_handle_selection_request(XEvent * xevent) { - static Atom atom_xdndselection = 0; - static Atom atom_text_plain = 0; - static Atom atom_text_selection = 0; - Ev_Dnd_Data_Request *e; + static Atom atom_xdndselection = 0; + static Atom atom_text_plain = 0; + static Atom atom_text_selection = 0; + Ecore_Event_Dnd_Data_Request *e; - E_ATOM(atom_xdndselection, "XdndSelection"); - E_ATOM(atom_text_plain, "text/plain"); - E_ATOM(atom_text_selection, "TEXT_SELECTION"); - if (xevent->xselectionrequest.selection == atom_xdndselection) - { - e = NEW(Ev_Dnd_Data_Request, 1); - e->win = xevent->xselectionrequest.owner; - e->root = e_window_get_root(e->win); - e->source_win = xevent->xselectionrequest.requestor; - if (xevent->xselectionrequest.target == atom_text_plain) - e->plain_text = 1; - else - e->plain_text = 0; - e->destination_atom = xevent->xselectionrequest.property; - e_add_event(EV_DND_DATA_REQUEST, e, e_ev_generic_free); - } - else - { - XEvent ev; - Atom target_list[2]; - static Atom xa_targets = None; - - if (xa_targets == None) - xa_targets = XInternAtom(xevent->xselectionrequest.display, - "TARGETS", False); - ev.xselection.type = SelectionNotify; - ev.xselection.property = None; - ev.xselection.display = xevent->xselectionrequest.display; - ev.xselection.requestor = xevent->xselectionrequest.requestor; - ev.xselection.selection = xevent->xselectionrequest.selection; - ev.xselection.target = xevent->xselectionrequest.target; - ev.xselection.time = xevent->xselectionrequest.time; - if (xevent->xselectionrequest.target == xa_targets) - { - target_list[0] = (Atom) xa_targets; - target_list[1] = (Atom) XA_STRING; - XChangeProperty(xevent->xselectionrequest.display, - xevent->xselectionrequest.requestor, - xevent->xselectionrequest.property, - xevent->xselectionrequest.target, - (8 * sizeof(target_list[0])), - PropModeReplace, - (unsigned char *) target_list, - (sizeof(target_list) / sizeof(target_list[0]))); - ev.xselection.property = xevent->xselectionrequest.property; - } - else if (xevent->xselectionrequest.target == XA_STRING) - { - void *data; - int size; - - data = e_window_property_get(xevent->xselectionrequest.owner, - atom_text_selection, XA_STRING, - &size); - if (data) - { - XChangeProperty(xevent->xselectionrequest.display, - xevent->xselectionrequest.requestor, - xevent->xselectionrequest.property, - xevent->xselectionrequest.target, - 8, - PropModeReplace, - data, size); - FREE(data); - } - ev.xselection.property = xevent->xselectionrequest.property; - } - XSendEvent(xevent->xselectionrequest.display, - xevent->xselectionrequest.requestor, False, 0, &ev); - } + ECORE_ATOM(atom_xdndselection, "XdndSelection"); + ECORE_ATOM(atom_text_plain, "text/plain"); + ECORE_ATOM(atom_text_selection, "TEXT_SELECTION"); + if (xevent->xselectionrequest.selection == atom_xdndselection) + { + e = NEW(Ecore_Event_Dnd_Data_Request, 1); + e->win = xevent->xselectionrequest.owner; + e->root = ecore_window_get_root(e->win); + e->source_win = xevent->xselectionrequest.requestor; + if (xevent->xselectionrequest.target == atom_text_plain) + e->plain_text = 1; + else + e->plain_text = 0; + e->destination_atom = xevent->xselectionrequest.property; + ecore_add_event(ECORE_EVENT_DND_DATA_REQUEST, e, + ecore_event_generic_free); + } + else + { + XEvent ev; + Atom target_list[2]; + static Atom xa_targets = None; + + if (xa_targets == None) + xa_targets = XInternAtom(xevent->xselectionrequest.display, + "TARGETS", False); + ev.xselection.type = SelectionNotify; + ev.xselection.property = None; + ev.xselection.display = xevent->xselectionrequest.display; + ev.xselection.requestor = xevent->xselectionrequest.requestor; + ev.xselection.selection = xevent->xselectionrequest.selection; + ev.xselection.target = xevent->xselectionrequest.target; + ev.xselection.time = xevent->xselectionrequest.time; + if (xevent->xselectionrequest.target == xa_targets) + { + target_list[0] = (Atom) xa_targets; + target_list[1] = (Atom) XA_STRING; + XChangeProperty(xevent->xselectionrequest.display, + xevent->xselectionrequest.requestor, + xevent->xselectionrequest.property, + xevent->xselectionrequest.target, + (8 * sizeof(target_list[0])), + PropModeReplace, + (unsigned char *)target_list, + (sizeof(target_list) / sizeof(target_list[0]))); + ev.xselection.property = xevent->xselectionrequest.property; + } + else if (xevent->xselectionrequest.target == XA_STRING) + { + void *data; + int size; + + data = ecore_window_property_get(xevent->xselectionrequest.owner, + atom_text_selection, XA_STRING, + &size); + if (data) + { + XChangeProperty(xevent->xselectionrequest.display, + xevent->xselectionrequest.requestor, + xevent->xselectionrequest.property, + xevent->xselectionrequest.target, + 8, PropModeReplace, data, size); + FREE(data); + } + ev.xselection.property = xevent->xselectionrequest.property; + } + XSendEvent(xevent->xselectionrequest.display, + xevent->xselectionrequest.requestor, False, 0, &ev); + } } static void -e_ev_x_handle_client_message(XEvent * xevent) +ecore_event_x_handle_client_message(XEvent * xevent) { - static Atom atom_wm_delete_window = 0; - static Atom atom_wm_protocols = 0; - static Atom atom_xdndstatus = 0; - static Atom atom_xdndenter = 0; - static Atom atom_xdndleave = 0; - static Atom atom_xdndfinished = 0; - static Atom atom_xdndposition = 0; - static Atom atom_xdnddrop = 0; - static Atom atom_text_uri_list = 0; - static Atom atom_xdndactioncopy = 0; - static Atom atom_xdndactionlink = 0; - static Atom atom_xdndactionmove = 0; + static Atom atom_wm_delete_window = 0; + static Atom atom_wm_protocols = 0; + static Atom atom_xdndstatus = 0; + static Atom atom_xdndenter = 0; + static Atom atom_xdndleave = 0; + static Atom atom_xdndfinished = 0; + static Atom atom_xdndposition = 0; + static Atom atom_xdnddrop = 0; + static Atom atom_text_uri_list = 0; + static Atom atom_xdndactioncopy = 0; + static Atom atom_xdndactionlink = 0; + static Atom atom_xdndactionmove = 0; - /* setup some known atoms to translate this message into a sensible event */ - E_ATOM(atom_wm_delete_window, "WM_DELETE_WINDOW"); - E_ATOM(atom_wm_protocols, "WM_PROTOCOLS"); - E_ATOM(atom_xdndstatus, "XdndStatus"); - E_ATOM(atom_xdndfinished, "XdndFinished"); - E_ATOM(atom_xdndenter, "XdndEnter"); - E_ATOM(atom_xdndleave, "XdndLeave"); - E_ATOM(atom_xdnddrop, "XdndDrop"); - E_ATOM(atom_xdndposition, "XdndPosition"); - E_ATOM(atom_xdndactioncopy, "XdndActionCopy"); - E_ATOM(atom_xdndactionlink, "XdndActionLink"); - E_ATOM(atom_xdndactionmove, "XdndActionMove"); - E_ATOM(atom_text_uri_list, "text/uri-list"); - /* forst type = delete event sent to client */ - if ((xevent->xclient.message_type == atom_wm_protocols) && - (xevent->xclient.format == 32) && - (xevent->xclient.data.l[0] == (long)atom_wm_delete_window)) - { - Ev_Window_Delete *e; + /* setup some known atoms to translate this message into a sensible event */ + ECORE_ATOM(atom_wm_delete_window, "WM_DELETE_WINDOW"); + ECORE_ATOM(atom_wm_protocols, "WM_PROTOCOLS"); + ECORE_ATOM(atom_xdndstatus, "XdndStatus"); + ECORE_ATOM(atom_xdndfinished, "XdndFinished"); + ECORE_ATOM(atom_xdndenter, "XdndEnter"); + ECORE_ATOM(atom_xdndleave, "XdndLeave"); + ECORE_ATOM(atom_xdnddrop, "XdndDrop"); + ECORE_ATOM(atom_xdndposition, "XdndPosition"); + ECORE_ATOM(atom_xdndactioncopy, "XdndActionCopy"); + ECORE_ATOM(atom_xdndactionlink, "XdndActionLink"); + ECORE_ATOM(atom_xdndactionmove, "XdndActionMove"); + ECORE_ATOM(atom_text_uri_list, "text/uri-list"); + /* forst type = delete event sent to client */ + if ((xevent->xclient.message_type == atom_wm_protocols) && + (xevent->xclient.format == 32) && + (xevent->xclient.data.l[0] == (long)atom_wm_delete_window)) + { + Ecore_Event_Window_Delete *e; - e = NEW(Ev_Window_Delete, 1); - e->win = xevent->xclient.window; - e->root = e_window_get_root(e->win); - e_add_event(EV_WINDOW_DELETE, e, e_ev_generic_free); - } - else if ((xevent->xclient.message_type == atom_xdndenter) && - (xevent->xclient.format == 32)) - { - if (xevent->xclient.data.l[2] == (long)atom_text_uri_list) - { - Ev_Dnd_Drop_Request *e; + e = NEW(Ecore_Event_Window_Delete, 1); + e->win = xevent->xclient.window; + e->root = ecore_window_get_root(e->win); + ecore_add_event(ECORE_EVENT_WINDOW_DELETE, e, ecore_event_generic_free); + } + else if ((xevent->xclient.message_type == atom_xdndenter) && + (xevent->xclient.format == 32)) + { + if (xevent->xclient.data.l[2] == (long)atom_text_uri_list) + { + Ecore_Event_Dnd_Drop_Request *e; - if (ev_drop_request_pending) - { - e_ev_dnd_drop_request_free(ev_drop_request_pending); - ev_drop_request_pending = NULL; - } - e = NEW(Ev_Dnd_Drop_Request, 1); - e->win = xevent->xclient.window; - e->root = e_window_get_root(e->win); - e->source_win = (Window) xevent->xclient.data.l[0]; - if (!e_dnd_selection_convert - (e->source_win, e->win, atom_text_uri_list)) - { - FREE(e); - return; - } - e->files = NULL; - e->num_files = 0; - ev_drop_request_pending = e; - } - } - else if ((xevent->xclient.message_type == atom_xdndleave) && - (xevent->xclient.format == 32)) - { - Ev_Dnd_Drop_End *e; + if (ev_drop_request_pending) + { + ecore_event_dnd_drop_request_free(ev_drop_request_pending); + ev_drop_request_pending = NULL; + } + e = NEW(Ecore_Event_Dnd_Drop_Request, 1); + e->win = xevent->xclient.window; + e->root = ecore_window_get_root(e->win); + e->source_win = (Window) xevent->xclient.data.l[0]; + if (!ecore_dnd_selection_convert + (e->source_win, e->win, atom_text_uri_list)) + { + FREE(e); + return; + } + e->files = NULL; + e->num_files = 0; + ev_drop_request_pending = e; + } + } + else if ((xevent->xclient.message_type == atom_xdndleave) && + (xevent->xclient.format == 32)) + { + Ecore_Event_Dnd_Drop_End *e; - e = NEW(Ev_Dnd_Drop_End, 1); - e->win = xevent->xclient.window; - e->root = e_window_get_root(e->win); - e->source_win = (Window) xevent->xclient.data.l[0]; - e_add_event(EV_DND_DROP_END, e, e_ev_generic_free); - } - else if ((xevent->xclient.message_type == atom_xdndposition) && - (xevent->xclient.format == 32)) - { - Ev_Dnd_Drop_Position *e; + e = NEW(Ecore_Event_Dnd_Drop_End, 1); + e->win = xevent->xclient.window; + e->root = ecore_window_get_root(e->win); + e->source_win = (Window) xevent->xclient.data.l[0]; + ecore_add_event(ECORE_EVENT_DND_DROP_END, e, ecore_event_generic_free); + } + else if ((xevent->xclient.message_type == atom_xdndposition) && + (xevent->xclient.format == 32)) + { + Ecore_Event_Dnd_Drop_Position *e; - e = NEW(Ev_Dnd_Drop_Position, 1); - e->win = xevent->xclient.window; - e->root = e_window_get_root(e->win); - e->source_win = (Window) xevent->xclient.data.l[0]; - e->x = (xevent->xclient.data.l[2] >> 16) & 0xffff; - e->y = xevent->xclient.data.l[2] & 0xffff; - e_add_event(EV_DND_DROP_POSITION, e, e_ev_generic_free); - } - else if ((xevent->xclient.message_type == atom_xdndstatus) && - (xevent->xclient.format == 32)) - { - Ev_Dnd_Drop_Status *e; + e = NEW(Ecore_Event_Dnd_Drop_Position, 1); + e->win = xevent->xclient.window; + e->root = ecore_window_get_root(e->win); + e->source_win = (Window) xevent->xclient.data.l[0]; + e->x = (xevent->xclient.data.l[2] >> 16) & 0xffff; + e->y = xevent->xclient.data.l[2] & 0xffff; + ecore_add_event(ECORE_EVENT_DND_DROP_POSITION, e, + ecore_event_generic_free); + } + else if ((xevent->xclient.message_type == atom_xdndstatus) && + (xevent->xclient.format == 32)) + { + Ecore_Event_Dnd_Drop_Status *e; - e = NEW(Ev_Dnd_Drop_Status, 1); - e->win = xevent->xclient.window; - e->root = e_window_get_root(e->win); - e->source_win = (Window) xevent->xclient.data.l[0]; - e->x = (xevent->xclient.data.l[2] >> 16) & 0xffff; - e->y = xevent->xclient.data.l[2] & 0xffff; - e->w = (xevent->xclient.data.l[3] >> 16) & 0xffff; - e->h = xevent->xclient.data.l[3] & 0xffff; - if (xevent->xclient.data.l[1] & 0x1) - e->ok = 1; - else - e->ok = 0; - e_add_event(EV_DND_DROP_STATUS, e, e_ev_generic_free); - } - else if ((xevent->xclient.message_type == atom_xdndfinished) && - (xevent->xclient.format == 32)) - { - Ev_Dnd_Drop_End *e; + e = NEW(Ecore_Event_Dnd_Drop_Status, 1); + e->win = xevent->xclient.window; + e->root = ecore_window_get_root(e->win); + e->source_win = (Window) xevent->xclient.data.l[0]; + e->x = (xevent->xclient.data.l[2] >> 16) & 0xffff; + e->y = xevent->xclient.data.l[2] & 0xffff; + e->w = (xevent->xclient.data.l[3] >> 16) & 0xffff; + e->h = xevent->xclient.data.l[3] & 0xffff; + if (xevent->xclient.data.l[1] & 0x1) + e->ok = 1; + else + e->ok = 0; + ecore_add_event(ECORE_EVENT_DND_DROP_STATUS, e, ecore_event_generic_free); + } + else if ((xevent->xclient.message_type == atom_xdndfinished) && + (xevent->xclient.format == 32)) + { + Ecore_Event_Dnd_Drop_End *e; - e = NEW(Ev_Dnd_Drop_End, 1); - e->win = xevent->xclient.window; - e->root = e_window_get_root(e->win); - e->source_win = (Window) xevent->xclient.data.l[0]; - e_add_event(EV_DND_DROP_END, e, e_ev_generic_free); - } - else if ((xevent->xclient.message_type == atom_xdnddrop) && - (xevent->xclient.format == 32)) - { - Ev_Dnd_Drop *e; + e = NEW(Ecore_Event_Dnd_Drop_End, 1); + e->win = xevent->xclient.window; + e->root = ecore_window_get_root(e->win); + e->source_win = (Window) xevent->xclient.data.l[0]; + ecore_add_event(ECORE_EVENT_DND_DROP_END, e, ecore_event_generic_free); + } + else if ((xevent->xclient.message_type == atom_xdnddrop) && + (xevent->xclient.format == 32)) + { + Ecore_Event_Dnd_Drop *e; - e = NEW(Ev_Dnd_Drop, 1); - e->win = xevent->xclient.window; - e->root = e_window_get_root(e->win); - e->source_win = (Window) xevent->xclient.data.l[0]; - e_add_event(EV_DND_DROP, e, e_ev_generic_free); - } - else - { - Ev_Message *e; + e = NEW(Ecore_Event_Dnd_Drop, 1); + e->win = xevent->xclient.window; + e->root = ecore_window_get_root(e->win); + e->source_win = (Window) xevent->xclient.data.l[0]; + ecore_add_event(ECORE_EVENT_DND_DROP, e, ecore_event_generic_free); + } + else + { + Ecore_Event_Message *e; - e = NEW(Ev_Message, 1); - e->win = xevent->xclient.window; - e->format = xevent->xclient.format; - e->atom = xevent->xclient.message_type; - MEMCPY(xevent->xclient.data.b, e->data.b, char, 20); + e = NEW(Ecore_Event_Message, 1); + e->win = xevent->xclient.window; + e->format = xevent->xclient.format; + e->atom = xevent->xclient.message_type; + MEMCPY(xevent->xclient.data.b, e->data.b, char, 20); - e_add_event(EV_MESSAGE, e, e_ev_generic_free); - } + ecore_add_event(ECORE_EVENT_MESSAGE, e, ecore_event_generic_free); + } } static void -e_ev_x_handle_shape_change(XEvent * xevent) +ecore_event_x_handle_shape_change(XEvent * xevent) { - Ev_Window_Shape *e; - XShapeEvent *shape_event; + Ecore_Event_Window_Shape *e; + XShapeEvent *shape_event; - shape_event = (XShapeEvent *) xevent; - e = NEW(Ev_Window_Shape, 1); - e->win = shape_event->window; - e->root = e_window_get_root(e->win); - e->time = shape_event->time; - e_add_event(EV_WINDOW_SHAPE, e, e_ev_generic_free); + shape_event = (XShapeEvent *) xevent; + e = NEW(Ecore_Event_Window_Shape, 1); + e->win = shape_event->window; + e->root = ecore_window_get_root(e->win); + e->time = shape_event->time; + ecore_add_event(ECORE_EVENT_WINDOW_SHAPE, e, ecore_event_generic_free); } char * -e_key_press_translate_into_typeable(Ev_Key_Down * e) +ecore_keypress_translate_into_typeable(Ecore_Event_Key_Down * e) { - /* exceptions */ - if ((!strcmp(e->key, "Delete")) || - (!strcmp(e->key, "BackSpace")) || - (!strcmp(e->key, "Tab")) || - (!strcmp(e->key, "Escape")) || - (!strcmp(e->key, "Return")) || - (!strcmp(e->key, "KP_Enter")) || - (!strcmp(e->key, "Enter")) || - (!strcmp(e->key, "KP_Divide")) || - (!strcmp(e->key, "KP_Multiply")) || - (!strcmp(e->key, "KP_Subtract")) || - (!strcmp(e->key, "KP_Add")) || - (!strcmp(e->key, "Enter"))) - return NULL; - return e->compose; + /* exceptions */ + if ((!strcmp(e->key, "Delete")) || + (!strcmp(e->key, "BackSpace")) || + (!strcmp(e->key, "Tab")) || + (!strcmp(e->key, "Escape")) || + (!strcmp(e->key, "Return")) || + (!strcmp(e->key, "KP_Enter")) || + (!strcmp(e->key, "Enter")) || + (!strcmp(e->key, "KP_Divide")) || + (!strcmp(e->key, "KP_Multiply")) || + (!strcmp(e->key, "KP_Subtract")) || + (!strcmp(e->key, "KP_Add")) || (!strcmp(e->key, "Enter"))) + return NULL; + return e->compose; } diff --git a/legacy/ecore/src/e_events.c b/legacy/ecore/src/e_events.c index 7859f70e16..bb20043b2f 100644 --- a/legacy/ecore/src/e_events.c +++ b/legacy/ecore/src/e_events.c @@ -6,425 +6,424 @@ #include /* glocal (yes global/local) variabels for events */ -Ev_Fd_Handler *fd_handlers = NULL; -Ev_Ipc_Handler *ipc_handlers = NULL; -Ev_Pid_Handler *pid_handlers = NULL; -Ev_Timer *timers = NULL; +Ecore_Event_Fd_Handler *fd_handlers = NULL; +Ecore_Event_Ipc_Handler *ipc_handlers = NULL; +Ecore_Event_Pid_Handler *pid_handlers = NULL; +Ecore_Event_Timer *timers = NULL; -Eevent *events = NULL; -Eevent *last_event = NULL; +Ecore_Event *events = NULL; +Ecore_Event *last_event = NULL; int __quit_ev_loop = 0; /* local functions for event handling */ -static void e_handle_event_timer(void); -static void e_handle_zero_event_timer(void); +static void ecore_handle_event_timer(void); +static void ecore_handle_zero_event_timer(void); /* public functions */ /* add an event to the end of the event queue */ void -e_add_event(Eevent_Type type, void *event, void (*ev_free) (void *event)) +ecore_add_event(Ecore_Event_Type type, void *event, + void (*ev_free) (void *event)) { - Eevent *ev; + Ecore_Event *ev; - ev = NEW(Eevent, 1); - ev->type = type; - ev->ignore = 0; - ev->event = event; - ev->next = NULL; - ev->ev_free = ev_free; - if (!events) - events = ev; - else - last_event->next = ev; - last_event = ev; + ev = NEW(Ecore_Event, 1); + ev->type = type; + ev->ignore = 0; + ev->event = event; + ev->next = NULL; + ev->ev_free = ev_free; + if (!events) + events = ev; + else + last_event->next = ev; + last_event = ev; } /* delete an event from the event queue */ void -e_del_event(void *event) +ecore_del_event(void *event) { - Eevent *ev, *pev; + Ecore_Event *ev, *pev; - pev = NULL; - ev = events; - while (ev) - { - if (ev->event == event) - { - if (pev) - pev->next = ev->next; - else - events = ev->next; - if (!ev->next) - last_event = pev; - if ((ev->event) && (ev->ev_free)) - (*ev->ev_free) (ev->event); - FREE(ev); - return; - } - pev = ev; - ev = ev->next; - } + pev = NULL; + ev = events; + while (ev) + { + if (ev->event == event) + { + if (pev) + pev->next = ev->next; + else + events = ev->next; + if (!ev->next) + last_event = pev; + if ((ev->event) && (ev->ev_free)) + (*ev->ev_free) (ev->event); + FREE(ev); + return; + } + pev = ev; + ev = ev->next; + } } void -e_del_all_events(void) +ecore_del_all_events(void) { - Eevent *ev, *pev; + Ecore_Event *ev, *pev; - ev = events; - while (ev) - { - pev = ev; - ev = ev->next; - if ((pev->event) && (pev->ev_free)) - pev->ev_free(pev->event); - FREE(pev); - } - events = NULL; - last_event = NULL; + ev = events; + while (ev) + { + pev = ev; + ev = ev->next; + if ((pev->event) && (pev->ev_free)) + pev->ev_free(pev->event); + FREE(pev); + } + events = NULL; + last_event = NULL; } -Eevent * -e_get_last_event(void) +Ecore_Event * +ecore_get_last_event(void) { - return last_event; + return last_event; } /* add a callback handler if fd is active for reading */ void -e_add_event_fd(int fd, void (*func) (int fd)) +ecore_add_event_fd(int fd, void (*func) (int fd)) { - Ev_Fd_Handler *fd_h; + Ecore_Event_Fd_Handler *fd_h; - /* new handler struct */ - fd_h = NEW(Ev_Fd_Handler, 1); - fd_h->next = fd_handlers; - fd_h->fd = fd; - fd_h->func = func; - fd_handlers = fd_h; + /* new handler struct */ + fd_h = NEW(Ecore_Event_Fd_Handler, 1); + fd_h->next = fd_handlers; + fd_h->fd = fd; + fd_h->func = func; + fd_handlers = fd_h; } /* delete handler for fd */ void -e_del_event_fd(int fd) +ecore_del_event_fd(int fd) { - START_LIST_DEL(Ev_Fd_Handler, fd_handlers, (_p->fd == fd)); - FREE(_p); - END_LIST_DEL; + START_LIST_DEL(Ecore_Event_Fd_Handler, fd_handlers, (_p->fd == fd)); + FREE(_p); + END_LIST_DEL; } void -e_add_event_pid(pid_t pid, void (*func) (pid_t pid)) +ecore_add_event_pid(pid_t pid, void (*func) (pid_t pid)) { - Ev_Pid_Handler *pid_h; + Ecore_Event_Pid_Handler *pid_h; - /* delete the old handler */ - e_del_event_pid(pid); - /* new handler struct */ - pid_h = NEW(Ev_Pid_Handler, 1); - pid_h->next = pid_handlers; - pid_h->pid = pid; - pid_h->func = func; - pid_handlers = pid_h; + /* delete the old handler */ + ecore_del_event_pid(pid); + /* new handler struct */ + pid_h = NEW(Ecore_Event_Pid_Handler, 1); + pid_h->next = pid_handlers; + pid_h->pid = pid; + pid_h->func = func; + pid_handlers = pid_h; } void -e_del_event_pid(pid_t pid) +ecore_del_event_pid(pid_t pid) { - START_LIST_DEL(Ev_Pid_Handler, pid_handlers, (_p->pid == pid)); - FREE(_p); - END_LIST_DEL; + START_LIST_DEL(Ecore_Event_Pid_Handler, pid_handlers, (_p->pid == pid)); + FREE(_p); + END_LIST_DEL; } void -e_add_event_ipc(int ipc, void (*func) (int ipc)) +ecore_add_event_ipc(int ipc, void (*func) (int ipc)) { - Ev_Ipc_Handler *ipc_h; + Ecore_Event_Ipc_Handler *ipc_h; - /* delete the old handler */ - e_del_event_ipc(ipc); - /* new handler struct */ - ipc_h = NEW(Ev_Ipc_Handler, 1); - ipc_h->next = ipc_handlers; - ipc_h->ipc = ipc; - ipc_h->func = func; - ipc_handlers = ipc_h; + /* delete the old handler */ + ecore_del_event_ipc(ipc); + /* new handler struct */ + ipc_h = NEW(Ecore_Event_Ipc_Handler, 1); + ipc_h->next = ipc_handlers; + ipc_h->ipc = ipc; + ipc_h->func = func; + ipc_handlers = ipc_h; } void -e_del_event_ipc(int ipc) +ecore_del_event_ipc(int ipc) { - START_LIST_DEL(Ev_Ipc_Handler, ipc_handlers, (_p->ipc == ipc)); - FREE(_p); - END_LIST_DEL; + START_LIST_DEL(Ecore_Event_Ipc_Handler, ipc_handlers, (_p->ipc == ipc)); + FREE(_p); + END_LIST_DEL; } /* sit in this loop forever and process events */ void -e_event_loop(void) +ecore_event_loop(void) { - int fdcount, fdsize, ipccount, ipcsize; - int timed_out, were_events; - double time1, time2, prev_time = 0.0; - struct timeval tval; - fd_set fdset, ipcset; - Ev_Fd_Handler *fd_h; - Ev_Pid_Handler *pid_h; - Ev_Ipc_Handler *ipc_h; + int fdcount, fdsize, ipccount, ipcsize; + int timed_out, were_events; + double time1, time2, prev_time = 0.0; + struct timeval tval; + fd_set fdset, ipcset; + Ecore_Event_Fd_Handler *fd_h; + Ecore_Event_Pid_Handler *pid_h; + Ecore_Event_Ipc_Handler *ipc_h; - /* init some of the time variables */ - time1 = e_get_time(); - time2 = time1 - prev_time; - prev_time = time1; - while( __quit_ev_loop == 0 ) - { - /* state setup */ - timed_out = 0; - were_events = 0; - - /* setup fd array from list of listening fd's */ - fdsize = 0; - FD_ZERO(&fdset); - /* for ever fd handler add the fd to the array and incriment fdsize */ - for (fd_h = fd_handlers; fd_h; fd_h = fd_h->next) - { - FD_SET(fd_h->fd, &fdset); - if (fd_h->fd > fdsize) - fdsize = fd_h->fd; - } - fdcount = 1; - ipcsize = 0; - FD_ZERO(&ipcset); - /* for ever fd handler add the fd to the array and incriment fdsize */ - for (ipc_h = ipc_handlers; ipc_h; ipc_h = ipc_h->next) - { - FD_SET(ipc_h->ipc, &ipcset); - if (ipc_h->ipc > ipcsize) - ipcsize = ipc_h->ipc; - } - ipccount = 1; - /* if there are timers setup adjust timeout value and select */ - if (timers) - { - if (timers->just_added) - { - timers->just_added = 0; - time1 = timers->in; - } - else - { - time1 = timers->in - time2; - if (time1 < 0.0) - time1 = 0.0; - timers->in = time1; - } - tval.tv_sec = (long)time1; - tval.tv_usec = (long)((time1 - ((double)tval.tv_sec)) * 1000000); - if (tval.tv_sec < 0) - tval.tv_sec = 0; - if (tval.tv_usec <= 1000) - tval.tv_usec = 1000; - e_handle_zero_event_timer(); - if ((!e_events_pending()) && - (!e_ev_signal_events_pending())) - fdcount = select(fdsize + 1, &fdset, NULL, NULL, &tval); - } - /* no timers - just sit and block */ - else - { - if ((!e_events_pending()) && - (!e_ev_signal_events_pending())) - fdcount = select(fdsize + 1, &fdset, NULL, NULL, NULL); - } - for (pid_h = pid_handlers; pid_h; pid_h = pid_h->next) - pid_h->func(pid_h->pid); + /* init some of the time variables */ + time1 = ecore_get_time(); + time2 = time1 - prev_time; + prev_time = time1; + while (__quit_ev_loop == 0) + { + /* state setup */ + timed_out = 0; + were_events = 0; - /* see if we have any new ipc connections */ - tval.tv_sec = 0; - tval.tv_usec = 0; - ipccount += select(ipcsize + 1, &ipcset, NULL, NULL, &tval); + /* setup fd array from list of listening fd's */ + fdsize = 0; + FD_ZERO(&fdset); + /* for ever fd handler add the fd to the array and incriment fdsize */ + for (fd_h = fd_handlers; fd_h; fd_h = fd_h->next) + { + FD_SET(fd_h->fd, &fdset); + if (fd_h->fd > fdsize) + fdsize = fd_h->fd; + } + fdcount = 1; + ipcsize = 0; + FD_ZERO(&ipcset); + /* for ever fd handler add the fd to the array and incriment fdsize */ + for (ipc_h = ipc_handlers; ipc_h; ipc_h = ipc_h->next) + { + FD_SET(ipc_h->ipc, &ipcset); + if (ipc_h->ipc > ipcsize) + ipcsize = ipc_h->ipc; + } + ipccount = 1; + /* if there are timers setup adjust timeout value and select */ + if (timers) + { + if (timers->just_added) + { + timers->just_added = 0; + time1 = timers->in; + } + else + { + time1 = timers->in - time2; + if (time1 < 0.0) + time1 = 0.0; + timers->in = time1; + } + tval.tv_sec = (long)time1; + tval.tv_usec = (long)((time1 - ((double)tval.tv_sec)) * 1000000); + if (tval.tv_sec < 0) + tval.tv_sec = 0; + if (tval.tv_usec <= 1000) + tval.tv_usec = 1000; + ecore_handle_zero_event_timer(); + if ((!ecore_events_pending()) && (!ecore_ev_signal_events_pending())) + fdcount = select(fdsize + 1, &fdset, NULL, NULL, &tval); + } + /* no timers - just sit and block */ + else + { + if ((!ecore_events_pending()) && (!ecore_ev_signal_events_pending())) + fdcount = select(fdsize + 1, &fdset, NULL, NULL, NULL); + } + for (pid_h = pid_handlers; pid_h; pid_h = pid_h->next) + pid_h->func(pid_h->pid); - /* return < 0 - error or signal interrupt */ - if (fdcount < 0) - { - /* error */ - if ((errno == ENOMEM) || (errno == EINVAL) || (errno == EBADF)) - { - fprintf(stderr, "Lost connection to X display.\n"); - exit(1); - } - } - /* timers are available and its a timeout */ - if ((timers) && (fdcount == 0)) - { - e_handle_event_timer(); - timed_out = 1; - } - if (fdcount < 0) - fdcount = 0; - if (e_events_pending()) - { - fdcount++; - FD_SET(e_x_get_fd(), &fdset); - } - /* fd's are active */ - if (fdcount > 0) - { - /* for every fd handler - if its fd is set - call the func */ - for (fd_h = fd_handlers; fd_h;) - { - Ev_Fd_Handler *fdh; + /* see if we have any new ipc connections */ + tval.tv_sec = 0; + tval.tv_usec = 0; + ipccount += select(ipcsize + 1, &ipcset, NULL, NULL, &tval); - fdh = fd_h; - fd_h = fd_h->next; - if (FD_ISSET(fdh->fd, &fdset)) - fdh->func(fdh->fd); - } - } + /* return < 0 - error or signal interrupt */ + if (fdcount < 0) + { + /* error */ + if ((errno == ENOMEM) || (errno == EINVAL) || (errno == EBADF)) + { + fprintf(stderr, "Lost connection to X display.\n"); + exit(1); + } + } + /* timers are available and its a timeout */ + if ((timers) && (fdcount == 0)) + { + ecore_handle_event_timer(); + timed_out = 1; + } + if (fdcount < 0) + fdcount = 0; + if (ecore_events_pending()) + { + fdcount++; + FD_SET(ecore_x_get_fd(), &fdset); + } + /* fd's are active */ + if (fdcount > 0) + { + /* for every fd handler - if its fd is set - call the func */ + for (fd_h = fd_handlers; fd_h;) + { + Ecore_Event_Fd_Handler *fdh; - /* ipc clients are active */ - if (ipccount > 0) - { - for (ipc_h = ipc_handlers; ipc_h;) - { - Ev_Ipc_Handler *ipch; + fdh = fd_h; + fd_h = fd_h->next; + if (FD_ISSET(fdh->fd, &fdset)) + fdh->func(fdh->fd); + } + } - ipch = ipc_h; - ipc_h = ipc_h->next; - if (FD_ISSET(ipch->ipc, &ipcset)) - ipch->func(ipch->ipc); - } - } - if (events) - e_event_filter(events); - if (events) - { - e_event_filter_events_handle(events); - were_events = 1; - } - e_del_all_events(); - if ((timed_out) || (were_events)) - e_event_filter_idle_handle(); - e_flush(); - time1 = e_get_time(); - time2 = time1 - prev_time; - prev_time = time1; - } + /* ipc clients are active */ + if (ipccount > 0) + { + for (ipc_h = ipc_handlers; ipc_h;) + { + Ecore_Event_Ipc_Handler *ipch; + + ipch = ipc_h; + ipc_h = ipc_h->next; + if (FD_ISSET(ipch->ipc, &ipcset)) + ipch->func(ipch->ipc); + } + } + if (events) + ecore_event_filter(events); + if (events) + { + ecore_event_filter_events_handle(events); + were_events = 1; + } + ecore_del_all_events(); + if ((timed_out) || (were_events)) + ecore_event_filter_idle_handle(); + ecore_flush(); + time1 = ecore_get_time(); + time2 = time1 - prev_time; + prev_time = time1; + } } /* set a flag to 0 so that we can quit the event loop and shutdown * properly */ -void -e_event_loop_quit(void) +void +ecore_event_loop_quit(void) { - __quit_ev_loop = 1; + __quit_ev_loop = 1; } /* add a timeout funcitont o be called in "in" seconds with name name */ void -e_add_event_timer(char *name, double in, void (*func) (int val, void *data), - int val, void *data) +ecore_add_event_timer(char *name, double in, void (*func) (int val, void *data), + int val, void *data) { - Ev_Timer *timer, *ptr, *pptr; - double tally; + Ecore_Event_Timer *timer, *ptr, *pptr; + double tally; - if (name) - e_del_event_timer(name); - timer = NEW(Ev_Timer, 1); - timer->next = NULL; - timer->func = func; - timer->data = data; - timer->val = val; - timer->just_added = 1; - timer->in = in; - timer->name = strdup(name); - if (!timers) - timers = timer; - else - { - pptr = NULL; - ptr = timers; - tally = 0.0; - while (ptr) - { - tally += ptr->in; - if (tally > in) - { - tally -= ptr->in; - timer->next = ptr; - if (pptr) - pptr->next = timer; - else - timers = timer; - timer->in -= tally; - if (timer->next) - timer->next->in -= timer->in; - return; - } - pptr = ptr; - ptr = ptr->next; - } - if (pptr) - pptr->next = timer; - else - timers = timer; - timer->in -= tally; - } + if (name) + ecore_del_event_timer(name); + timer = NEW(Ecore_Event_Timer, 1); + timer->next = NULL; + timer->func = func; + timer->data = data; + timer->val = val; + timer->just_added = 1; + timer->in = in; + timer->name = strdup(name); + if (!timers) + timers = timer; + else + { + pptr = NULL; + ptr = timers; + tally = 0.0; + while (ptr) + { + tally += ptr->in; + if (tally > in) + { + tally -= ptr->in; + timer->next = ptr; + if (pptr) + pptr->next = timer; + else + timers = timer; + timer->in -= tally; + if (timer->next) + timer->next->in -= timer->in; + return; + } + pptr = ptr; + ptr = ptr->next; + } + if (pptr) + pptr->next = timer; + else + timers = timer; + timer->in -= tally; + } } /* delete a timer timeout entry named "name" */ void * -e_del_event_timer(char *name) +ecore_del_event_timer(char *name) { - Ev_Timer *timer, *ptr, *pptr; + Ecore_Event_Timer *timer, *ptr, *pptr; - pptr = NULL; - ptr = timers; - while (ptr) - { - timer = ptr; - if (!strcmp(timer->name, name)) - { - void *data; + pptr = NULL; + ptr = timers; + while (ptr) + { + timer = ptr; + if (!strcmp(timer->name, name)) + { + void *data; - if (pptr) - pptr->next = timer->next; - else - timers = timer->next; - if (timer->next) - timer->next->in += timer->in; - IF_FREE(timer->name); - data = timer->data; - FREE(timer); - return data; - } - pptr = ptr; - ptr = ptr->next; - } - return NULL; + if (pptr) + pptr->next = timer->next; + else + timers = timer->next; + if (timer->next) + timer->next->in += timer->in; + IF_FREE(timer->name); + data = timer->data; + FREE(timer); + return data; + } + pptr = ptr; + ptr = ptr->next; + } + return NULL; } /* private functions */ static void -e_handle_event_timer(void) +ecore_handle_event_timer(void) { - Ev_Timer *timer; + Ecore_Event_Timer *timer; - if (!timers) - return; - timer = timers; - timers = timer->next; - (*(timer->func)) (timer->val, timer->data); - IF_FREE(timer->name); - FREE(timer); + if (!timers) + return; + timer = timers; + timers = timer->next; + (*(timer->func)) (timer->val, timer->data); + IF_FREE(timer->name); + FREE(timer); } static void -e_handle_zero_event_timer(void) +ecore_handle_zero_event_timer(void) { - while ((timers) && (timers->in == 0.0)) - e_handle_event_timer(); + while ((timers) && (timers->in == 0.0)) + ecore_handle_event_timer(); } diff --git a/legacy/ecore/src/e_ipc.c b/legacy/ecore/src/e_ipc.c index 128987527e..2a6de2b4ab 100644 --- a/legacy/ecore/src/e_ipc.c +++ b/legacy/ecore/src/e_ipc.c @@ -5,28 +5,28 @@ #include #include -void e_ipc_init(char *path); -void e_ipc_cleanup(void); -static void e_ipc_connect_handler(int fd); -static void e_ipc_client_handler(int fd); -void e_ipc_get_data(int fd, void *buf); -void e_ipc_send_data(int fd, void *buf, int size); -void e_add_ipc_service(int service, void (*func) (int fd)); -void e_del_ipc_service(int service); +void ecore_ipc_init(char *path); +void ecore_ipc_cleanup(void); +static void ecore_ipc_connect_handler(int fd); +static void ecore_ipc_client_handler(int fd); +void ecore_ipc_get_data(int fd, void *buf); +void ecore_ipc_send_data(int fd, void *buf, int size); +void ecore_add_ipc_service(int service, void (*func) (int fd)); +void ecore_del_ipc_service(int service); -Ev_Ipc_Service *ipc_services = NULL; +Ecore_Event_Ipc_Service *ipc_services = NULL; void -e_ev_ipc_init(char *path) +ecore_ev_ipc_init(char *path) { - int fd, len; - struct sockaddr_un saun; + int fd, len; + struct sockaddr_un saun; - if(path == NULL) + if (path == NULL) return; /* a UNIX domain, stream socket */ - if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) + if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { printf("Cannot create ipc socket... disabling ipc.\n"); return; @@ -40,7 +40,7 @@ e_ev_ipc_init(char *path) unlink(path); len = sizeof(saun.sun_family) + strlen(saun.sun_path); - if (bind(fd, &saun, len) < 0) + if (bind(fd, (struct sockaddr *)&saun, len) < 0) { printf("Cannot bind ipc socket... disabling ipc.\n"); return; @@ -54,126 +54,134 @@ e_ev_ipc_init(char *path) } /* add ipc listener */ - e_add_event_ipc(fd, e_ipc_connect_handler); + ecore_add_event_ipc(fd, ecore_ipc_connect_handler); } -void -e_ev_ipc_cleanup(void) +void +ecore_ev_ipc_cleanup(void) { - Ev_Ipc_Service *ipc_s; + Ecore_Event_Ipc_Service *ipc_s; /* cleanup services list */ for (ipc_s = ipc_services; ipc_s; ipc_s = ipc_s->next) - { - e_del_ipc_service(ipc_s->service); - } + { + ecore_del_ipc_service(ipc_s->service); + } } static void -e_ipc_connect_handler(int fd) +ecore_ipc_connect_handler(int fd) { - struct sockaddr_un fsaun; - int fromlen, nfd; + struct sockaddr_un fsaun; + int fromlen, nfd; /* accept ipc connection */ fromlen = sizeof(fsaun); - if ((nfd = accept(fd, &fsaun, &fromlen)) < 0) + if ((nfd = accept(fd, (struct sockaddr *)&fsaun, &fromlen)) < 0) { printf("Cannot accept ipc connection... ignoring connection attempt.\n"); return; } /* add ipc client */ - e_add_event_ipc(nfd, e_ipc_client_handler); + ecore_add_event_ipc(nfd, ecore_ipc_client_handler); } static void -e_ipc_client_handler(int fd) +ecore_ipc_client_handler(int fd) { - int nread, service; - Ev_Ipc_Service *ipc_s; + int nread, service; + Ecore_Event_Ipc_Service *ipc_s; if ((nread = read(fd, &service, sizeof(service))) == 0) { close(fd); - e_del_event_ipc(fd); + ecore_del_event_ipc(fd); } else if (nread > 0) { /* call the service function */ for (ipc_s = ipc_services; ipc_s; ipc_s = ipc_s->next) - { - if (ipc_s->service == service) - { - ipc_s->func(fd); - break; - } - } + { + if (ipc_s->service == service) + { + ipc_s->func(fd); + break; + } + } } else { - printf("ipc error in read service.\n"); fflush(stdout); + printf("ipc error in read service.\n"); + fflush(stdout); } } void -e_ipc_get_data(int fd, void *buf) +ecore_ipc_get_data(int fd, void *buf) { - int readn, nread; + int readn, nread; /* read number of bytes being sent */ - if ((nread = read(fd, &readn, sizeof(readn))) == -1) + if ((nread = read(fd, &readn, sizeof(readn))) == -1) { - printf("ipc error in get data.\n"); fflush(stdout); + printf("ipc error in get data.\n"); + fflush(stdout); return; } /* get data structure */ - if ((nread = read(fd, buf, readn)) == -1) + if ((nread = read(fd, buf, readn)) == -1) { - printf("ipc error in get data.\n"); fflush(stdout); + printf("ipc error in get data.\n"); + fflush(stdout); return; } } void -e_ipc_send_data(int fd, void *buf, int size) +ecore_ipc_send_data(int fd, void *buf, int size) { - int n; + int n; + /* send length of data being sent */ if ((n = write(fd, &size, sizeof(size))) == -1) { - printf("ipc error in send data length.\n"); fflush(stdout); + printf("ipc error in send data length.\n"); + fflush(stdout); return; } /* send data */ if ((n = write(fd, buf, size)) == -1) { - printf("ipc error in send data.\n"); fflush(stdout); + printf("ipc error in send data.\n"); + fflush(stdout); return; } } void -e_add_ipc_service(int service, void (*func) (int fd)) +ecore_add_ipc_service(int service, void (*func) (int fd)) { - Ev_Ipc_Service *ipc_s; + Ecore_Event_Ipc_Service *ipc_s; - /* delete the old service */ - e_del_ipc_service(service); - /* new service struct */ - ipc_s = NEW(Ev_Ipc_Service, 1); - ipc_s->next = ipc_services; - ipc_s->service = service; - ipc_s->func = func; - ipc_services = ipc_s; + /* delete the old service */ + ecore_del_ipc_service(service); + /* new service struct */ + ipc_s = NEW(Ecore_Event_Ipc_Service, 1); + ipc_s->next = ipc_services; + ipc_s->service = service; + ipc_s->func = func; + ipc_services = ipc_s; } -void e_del_ipc_service(int service) +void +ecore_del_ipc_service(int service) { - START_LIST_DEL(Ev_Ipc_Service, ipc_services, (_p->service == service)); - FREE(_p); - END_LIST_DEL; + START_LIST_DEL(Ecore_Event_Ipc_Service, ipc_services, + (_p->service == service)); + FREE(_p); + END_LIST_DEL; } diff --git a/legacy/ecore/src/e_util.c b/legacy/ecore/src/e_util.c index c50faf98e9..fc4a2ae0cb 100644 --- a/legacy/ecore/src/e_util.c +++ b/legacy/ecore/src/e_util.c @@ -1,10 +1,10 @@ #include "Ecore.h" double -e_get_time(void) +ecore_get_time(void) { - struct timeval timev; + struct timeval timev; - gettimeofday(&timev, NULL); - return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000); + gettimeofday(&timev, NULL); + return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000); } diff --git a/legacy/ecore/src/e_x.c b/legacy/ecore/src/e_x.c index 8f4a88319a..93266eca3d 100644 --- a/legacy/ecore/src/e_x.c +++ b/legacy/ecore/src/e_x.c @@ -16,8 +16,8 @@ typedef struct _window_list Window_List; struct _window_list { - Window win; - Window_List *next; + Window win; + Window_List *next; }; XContext xid_context = 0; @@ -57,12 +57,13 @@ static int dnd_copy = 0; static int dnd_link = 0; static int dnd_move = 1; -static void e_handle_x_error(Display * d, XErrorEvent * ev); -static void e_handle_x_io_error(Display * d); -static Window e_window_at_xy_0(Window base, int bx, int by, int x, int y); +static void ecore_handle_x_error(Display * d, XErrorEvent * ev); +static void ecore_handle_x_io_error(Display * d); +static Window ecore_window_at_xy_0(Window base, int bx, int by, int x, + int y); static void -e_handle_x_error(Display * d, XErrorEvent * ev) +ecore_handle_x_error(Display * d, XErrorEvent * ev) { /* char err[16384]; @@ -71,576 +72,584 @@ e_handle_x_error(Display * d, XErrorEvent * ev) printf("X Error:\n" "Error: %s\nrequest: %i\nminor: %i\n", err, ev->request_code, ev->minor_code); */ - /* ignore all X errors */ - return; - d = NULL; - ev = NULL; + /* ignore all X errors */ + return; + d = NULL; + ev = NULL; } static void -e_handle_x_io_error(Display * d) +ecore_handle_x_io_error(Display * d) { - /* FIXME: call clean exit handler */ - exit(1); - d = NULL; + /* FIXME: call clean exit handler */ + exit(1); + d = NULL; } void -e_del_child(Window win, Window child) +ecore_del_child(Window win, Window child) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; - if (XFindContext(disp, win, xid_context, (XPointer *) & xid) == XCNOENT) - return; - if (xid) - { - int i; + if (XFindContext(disp, win, xid_context, (XPointer *) & xid) == XCNOENT) + return; + if (xid) + { + int i; - for (i = 0; i < xid->children_num; i++) - { - if (xid->children[i] == child) - { - int j; + for (i = 0; i < xid->children_num; i++) + { + if (xid->children[i] == child) + { + int j; - for (j = i; j < xid->children_num - 1; j++) - xid->children[j] = xid->children[j + 1]; - xid->children_num--; - REALLOC(xid->children, Window, xid->children_num); - return; - } - } - } + for (j = i; j < xid->children_num - 1; j++) + xid->children[j] = xid->children[j + 1]; + xid->children_num--; + REALLOC(xid->children, Window, xid->children_num); + return; + } + } + } } void -e_add_child(Window win, Window child) +ecore_add_child(Window win, Window child) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; - if (XFindContext(disp, win, xid_context, (XPointer *) & xid) == XCNOENT) - return; - if (xid) - { - int i; - - for (i = 0; i < xid->children_num; i++) - { - if (xid->children[i] == child) return; - } - xid->children_num++; - if (!xid->children) - xid->children = NEW(Window, xid->children_num); - else - REALLOC(xid->children, Window, xid->children_num); - xid->children[xid->children_num - 1] = child; - } - xid = e_validate_xid(child); + if (XFindContext(disp, win, xid_context, (XPointer *) & xid) == XCNOENT) + return; + if (xid) + { + int i; + + for (i = 0; i < xid->children_num; i++) + { + if (xid->children[i] == child) + return; + } + xid->children_num++; + if (!xid->children) + xid->children = NEW(Window, xid->children_num); + else + REALLOC(xid->children, Window, xid->children_num); + xid->children[xid->children_num - 1] = child; + } + xid = ecore_validate_xid(child); } void -e_raise_child(Window win, Window child) +ecore_raise_child(Window win, Window child) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; - if (XFindContext(disp, win, xid_context, (XPointer *) & xid) == XCNOENT) - return; - if (xid) - { - int i; + if (XFindContext(disp, win, xid_context, (XPointer *) & xid) == XCNOENT) + return; + if (xid) + { + int i; - for (i = 0; i < xid->children_num; i++) - { - if (xid->children[i] == child) - { - int j; + for (i = 0; i < xid->children_num; i++) + { + if (xid->children[i] == child) + { + int j; - for (j = i; j < xid->children_num - 1; j++) - xid->children[j] = xid->children[j + 1]; - xid->children[xid->children_num - 1] = child; - return; - } - } - } + for (j = i; j < xid->children_num - 1; j++) + xid->children[j] = xid->children[j + 1]; + xid->children[xid->children_num - 1] = child; + return; + } + } + } } void -e_lower_child(Window win, Window child) +ecore_lower_child(Window win, Window child) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; - if (XFindContext(disp, win, xid_context, (XPointer *) & xid) == XCNOENT) - return; - if (xid) - { - int i; + if (XFindContext(disp, win, xid_context, (XPointer *) & xid) == XCNOENT) + return; + if (xid) + { + int i; - for (i = 0; i < xid->children_num; i++) - { - if (xid->children[i] == child) - { - int j; + for (i = 0; i < xid->children_num; i++) + { + if (xid->children[i] == child) + { + int j; - for (j = i; j > 0; j--) - xid->children[j] = xid->children[j - 1]; - xid->children[0] = child; - return; - } - } - } + for (j = i; j > 0; j--) + xid->children[j] = xid->children[j - 1]; + xid->children[0] = child; + return; + } + } + } } -E_XID * -e_add_xid(Window win, int x, int y, int w, int h, int depth, Window parent) +Ecore_XID * +ecore_add_xid(Window win, int x, int y, int w, int h, int depth, Window parent) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; - e_window_add_events(win, XEV_IN_OUT | XEV_CONFIGURE | XEV_VISIBILITY); - xid = NEW(E_XID, 1); - xid->win = win; - xid->x = x; - xid->y = y; - xid->w = w; - xid->h = h; - xid->mapped = 0; - xid->depth = depth; - xid->mouse_in = 0; - xid->parent = parent; - xid->root = e_window_get_root(parent); - xid->children_num = 0; - xid->children = NULL; - xid->gravity = e_window_get_gravity(win); - xid->bw = 0; - xid->grab_button_auto_replay = 0; - XSaveContext(disp, xid->win, xid_context, (XPointer) xid); - e_add_child(parent, win); - return xid; + ecore_window_add_events(win, XEV_IN_OUT | XEV_CONFIGURE | XEV_VISIBILITY); + xid = NEW(Ecore_XID, 1); + xid->win = win; + xid->x = x; + xid->y = y; + xid->w = w; + xid->h = h; + xid->mapped = 0; + xid->depth = depth; + xid->mouse_in = 0; + xid->parent = parent; + xid->root = ecore_window_get_root(parent); + xid->children_num = 0; + xid->children = NULL; + xid->gravity = ecore_window_get_gravity(win); + xid->bw = 0; + xid->grab_button_auto_replay = 0; + XSaveContext(disp, xid->win, xid_context, (XPointer) xid); + ecore_add_child(parent, win); + return xid; } -E_XID * -e_validate_xid(Window win) +Ecore_XID * +ecore_validate_xid(Window win) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; - if (XFindContext(disp, win, xid_context, (XPointer *) & xid) == XCNOENT) - { - XWindowAttributes att; - Window root_ret = 0, parent_ret = 0, *children_ret = NULL; - unsigned int children_ret_num = 0; + if (XFindContext(disp, win, xid_context, (XPointer *) & xid) == XCNOENT) + { + XWindowAttributes att; + Window root_ret = 0, parent_ret = 0, *children_ret = NULL; + unsigned int children_ret_num = 0; - e_window_add_events(win, XEV_IN_OUT | XEV_CONFIGURE | - XEV_VISIBILITY | XEV_CHILD_CHANGE); - xid = NEW(E_XID, 1); - xid->win = win; - if (!XGetWindowAttributes(disp, win, &att)) - { - FREE(xid); - return NULL; - } - if (!XQueryTree(disp, win, &root_ret, &parent_ret, &children_ret, - &children_ret_num)) - { - FREE(xid); - return NULL; - } - xid->parent = parent_ret; - if (xid->parent) - e_validate_xid(xid->parent); - if (children_ret) - { - xid->children_num = children_ret_num; - xid->children = NEW(Window, children_ret_num); - MEMCPY(children_ret, xid->children, Window, children_ret_num); - XFree(children_ret); - } - else - { - xid->children_num = 0; - xid->children = NULL; - } - xid->root = root_ret; - xid->x = att.x; - xid->y = att.y; - xid->w = att.width; - xid->h = att.height; - if (att.map_state == IsUnmapped) - xid->mapped = 0; - else - xid->mapped = 1; - xid->depth = att.depth; - xid->mouse_in = 0; - xid->gravity = att.win_gravity; - xid->bw = att.border_width; - xid->grab_button_auto_replay = 0; - XSaveContext(disp, xid->win, xid_context, (XPointer) xid); - e_add_child(xid->parent, win); - } - return xid; -} - -void -e_unvalidate_xid(Window win) -{ - E_XID *xid = NULL; - - if (XFindContext(disp, win, xid_context, (XPointer *) & xid) == XCNOENT) - return; - if (xid) - { - int i; - - for (i = 0; i < xid->children_num; i++) - e_unvalidate_xid(xid->children[i]); - e_del_child(xid->parent, win); - IF_FREE(xid->children); - FREE(xid); - XDeleteContext(disp, win, xid_context); - } -} - -void -e_sync(void) -{ - XSync(disp, False); -} - -void -e_flush(void) -{ - XFlush(disp); -} - -Window -e_window_new(Window parent, int x, int y, int w, int h) -{ - Window win; - XSetWindowAttributes attr; - - if (!parent) - parent = default_root; - attr.backing_store = NotUseful; - attr.override_redirect = False; - attr.colormap = default_cm; - attr.border_pixel = 0; - attr.background_pixmap = None; - attr.save_under = False; - attr.do_not_propagate_mask = True; - win = XCreateWindow(disp, parent, - x, y, w, h, 0, - default_depth, InputOutput, default_vis, - CWOverrideRedirect | CWSaveUnder | CWBackingStore | - CWColormap | CWBackPixmap | CWBorderPixel | - CWDontPropagate, &attr); - e_add_xid(win, x, y, w, h, default_depth, parent); - e_add_child(parent, win); - e_validate_xid(parent); - return win; -} - -Window -e_window_override_new(Window parent, int x, int y, int w, int h) -{ - Window win; - XSetWindowAttributes attr; - - if (!parent) - parent = default_root; - attr.backing_store = NotUseful; - attr.override_redirect = True; - attr.colormap = default_cm; - attr.border_pixel = 0; - attr.background_pixmap = None; - attr.save_under = False; - attr.do_not_propagate_mask = True; - win = XCreateWindow(disp, parent, - x, y, w, h, 0, - default_depth, InputOutput, default_vis, - CWOverrideRedirect | CWSaveUnder | CWBackingStore | - CWColormap | CWBackPixmap | CWBorderPixel | - CWDontPropagate, &attr); - e_add_xid(win, x, y, w, h, default_depth, parent); - e_add_child(parent, win); - e_validate_xid(parent); - return win; -} - -Window -e_window_input_new(Window parent, int x, int y, int w, int h) -{ - Window win; - XSetWindowAttributes attr; - - if (!parent) - parent = default_root; - attr.override_redirect = True; - attr.do_not_propagate_mask = True; - win = XCreateWindow(disp, parent, - x, y, w, h, 0, - 0, InputOnly, default_vis, - CWOverrideRedirect | CWDontPropagate, &attr); - e_add_xid(win, x, y, w, h, 0, parent); - e_add_child(parent, win); - e_validate_xid(parent); - 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) -{ - E_XID *xid = NULL; - - xid = e_validate_xid(win); - if (xid) - { - if (xid->mapped) - return; - xid->mapped = 1; - XMapWindow(disp, win); - } -} - -void -e_window_hide(Window win) -{ - E_XID *xid = NULL; - - xid = e_validate_xid(win); - if (xid) - { - if (!xid->mapped) - return; + ecore_window_add_events(win, XEV_IN_OUT | XEV_CONFIGURE | + XEV_VISIBILITY | XEV_CHILD_CHANGE); + xid = NEW(Ecore_XID, 1); + xid->win = win; + if (!XGetWindowAttributes(disp, win, &att)) + { + FREE(xid); + return NULL; + } + if (!XQueryTree(disp, win, &root_ret, &parent_ret, &children_ret, + &children_ret_num)) + { + FREE(xid); + return NULL; + } + xid->parent = parent_ret; + if (xid->parent) + ecore_validate_xid(xid->parent); + if (children_ret) + { + xid->children_num = children_ret_num; + xid->children = NEW(Window, children_ret_num); + MEMCPY(children_ret, xid->children, Window, children_ret_num); + XFree(children_ret); + } + else + { + xid->children_num = 0; + xid->children = NULL; + } + xid->root = root_ret; + xid->x = att.x; + xid->y = att.y; + xid->w = att.width; + xid->h = att.height; + if (att.map_state == IsUnmapped) xid->mapped = 0; - XUnmapWindow(disp, win); - } + else + xid->mapped = 1; + xid->depth = att.depth; + xid->mouse_in = 0; + xid->gravity = att.win_gravity; + xid->bw = att.border_width; + xid->grab_button_auto_replay = 0; + XSaveContext(disp, xid->win, xid_context, (XPointer) xid); + ecore_add_child(xid->parent, win); + } + return xid; +} + +void +ecore_unvalidate_xid(Window win) +{ + Ecore_XID *xid = NULL; + + if (XFindContext(disp, win, xid_context, (XPointer *) & xid) == XCNOENT) + return; + if (xid) + { + int i; + + for (i = 0; i < xid->children_num; i++) + ecore_unvalidate_xid(xid->children[i]); + ecore_del_child(xid->parent, win); + IF_FREE(xid->children); + FREE(xid); + XDeleteContext(disp, win, xid_context); + } +} + +void +ecore_sync(void) +{ + XSync(disp, False); +} + +void +ecore_flush(void) +{ + XFlush(disp); +} + +Window +ecore_window_new(Window parent, int x, int y, int w, int h) +{ + Window win; + XSetWindowAttributes attr; + + if (!parent) + parent = default_root; + attr.backing_store = NotUseful; + attr.override_redirect = False; + attr.colormap = default_cm; + attr.border_pixel = 0; + attr.background_pixmap = None; + attr.save_under = False; + attr.do_not_propagate_mask = True; + win = XCreateWindow(disp, parent, + x, y, w, h, 0, + default_depth, InputOutput, default_vis, + CWOverrideRedirect | CWSaveUnder | CWBackingStore | + CWColormap | CWBackPixmap | CWBorderPixel | + CWDontPropagate, &attr); + ecore_add_xid(win, x, y, w, h, default_depth, parent); + ecore_add_child(parent, win); + ecore_validate_xid(parent); + return win; +} + +Window +ecore_window_override_new(Window parent, int x, int y, int w, int h) +{ + Window win; + XSetWindowAttributes attr; + + if (!parent) + parent = default_root; + attr.backing_store = NotUseful; + attr.override_redirect = True; + attr.colormap = default_cm; + attr.border_pixel = 0; + attr.background_pixmap = None; + attr.save_under = False; + attr.do_not_propagate_mask = True; + win = XCreateWindow(disp, parent, + x, y, w, h, 0, + default_depth, InputOutput, default_vis, + CWOverrideRedirect | CWSaveUnder | CWBackingStore | + CWColormap | CWBackPixmap | CWBorderPixel | + CWDontPropagate, &attr); + ecore_add_xid(win, x, y, w, h, default_depth, parent); + ecore_add_child(parent, win); + ecore_validate_xid(parent); + return win; +} + +Window +ecore_window_input_new(Window parent, int x, int y, int w, int h) +{ + Window win; + XSetWindowAttributes attr; + + if (!parent) + parent = default_root; + attr.override_redirect = True; + attr.do_not_propagate_mask = True; + win = XCreateWindow(disp, parent, + x, y, w, h, 0, + 0, InputOnly, default_vis, + CWOverrideRedirect | CWDontPropagate, &attr); + ecore_add_xid(win, x, y, w, h, 0, parent); + ecore_add_child(parent, win); + ecore_validate_xid(parent); + return win; +} + +void +ecore_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 +ecore_window_show(Window win) +{ + Ecore_XID *xid = NULL; + + xid = ecore_validate_xid(win); + if (xid) + { + if (xid->mapped) + return; + xid->mapped = 1; + XMapWindow(disp, win); + } +} + +void +ecore_window_hide(Window win) +{ + Ecore_XID *xid = NULL; + + xid = ecore_validate_xid(win); + if (xid) + { + if (!xid->mapped) + return; + xid->mapped = 0; + XUnmapWindow(disp, win); + } } Pixmap -e_pixmap_new(Window win, int w, int h, int dep) +ecore_pixmap_new(Window win, int w, int h, int dep) { - if (!win) - win = default_win; - if (dep == 0) - dep = default_depth; - return XCreatePixmap(disp, win, w, h, dep); + if (!win) + win = default_win; + if (dep == 0) + dep = default_depth; + return XCreatePixmap(disp, win, w, h, dep); } void -e_pixmap_free(Pixmap pmap) +ecore_pixmap_free(Pixmap pmap) { - if (!pmap) - return; - XFreePixmap(disp, pmap); + if (!pmap) + return; + XFreePixmap(disp, pmap); } void -e_window_set_background_pixmap(Window win, Pixmap pmap) +ecore_window_set_background_pixmap(Window win, Pixmap pmap) { - XSetWindowBackgroundPixmap(disp, win, pmap); + XSetWindowBackgroundPixmap(disp, win, pmap); } void -e_window_set_shape_mask(Window win, Pixmap mask) +ecore_window_set_shape_mask(Window win, Pixmap mask) { - XShapeCombineMask(disp, win, ShapeBounding, 0, 0, mask, ShapeSet); + XShapeCombineMask(disp, win, ShapeBounding, 0, 0, mask, ShapeSet); } void -e_window_add_shape_mask(Window win, Pixmap mask) +ecore_window_add_shape_mask(Window win, Pixmap mask) { - XShapeCombineMask(disp, win, ShapeBounding, 0, 0, mask, ShapeUnion); + XShapeCombineMask(disp, win, ShapeBounding, 0, 0, mask, ShapeUnion); } void -e_window_set_shape_window(Window win, Window src, int x, int y) +ecore_window_set_shape_window(Window win, Window src, int x, int y) { - XShapeCombineShape(disp, win, ShapeBounding, x, y, src, ShapeBounding, ShapeSet); + XShapeCombineShape(disp, win, ShapeBounding, x, y, src, ShapeBounding, + ShapeSet); } void -e_window_add_shape_window(Window win, Window src, int x, int y) +ecore_window_add_shape_window(Window win, Window src, int x, int y) { - XShapeCombineShape(disp, win, ShapeBounding, x, y, src, ShapeBounding, ShapeUnion); + XShapeCombineShape(disp, win, ShapeBounding, x, y, src, ShapeBounding, + ShapeUnion); } void -e_window_set_shape_rectangle(Window win, int x, int y, int w, int h) +ecore_window_set_shape_rectangle(Window win, int x, int y, int w, int h) { - XRectangle rect; - - rect.x = x; - rect.y = y; - rect.width = w; - rect.height = h; - XShapeCombineRectangles(disp, win, ShapeBounding, 0, 0, &rect, 1, ShapeSet, Unsorted); + XRectangle rect; + + rect.x = x; + rect.y = y; + rect.width = w; + rect.height = h; + XShapeCombineRectangles(disp, win, ShapeBounding, 0, 0, &rect, 1, ShapeSet, + Unsorted); } void -e_window_add_shape_rectangle(Window win, int x, int y, int w, int h) +ecore_window_add_shape_rectangle(Window win, int x, int y, int w, int h) { - XRectangle rect; - - rect.x = x; - rect.y = y; - rect.width = w; - rect.height = h; - XShapeCombineRectangles(disp, win, ShapeBounding, 0, 0, &rect, 1, ShapeUnion, Unsorted); + XRectangle rect; + + rect.x = x; + rect.y = y; + rect.width = w; + rect.height = h; + XShapeCombineRectangles(disp, win, ShapeBounding, 0, 0, &rect, 1, ShapeUnion, + Unsorted); } void -e_window_set_shape_rectangles(Window win, XRectangle *rect, int num) +ecore_window_set_shape_rectangles(Window win, XRectangle * rect, int num) { - XShapeCombineRectangles(disp, win, ShapeBounding, 0, 0, rect, num, ShapeSet, Unsorted); + XShapeCombineRectangles(disp, win, ShapeBounding, 0, 0, rect, num, ShapeSet, + Unsorted); } void -e_window_add_shape_rectangles(Window win, XRectangle *rect, int num) +ecore_window_add_shape_rectangles(Window win, XRectangle * rect, int num) { - XShapeCombineRectangles(disp, win, ShapeBounding, 0, 0, rect, num, ShapeUnion, Unsorted); + XShapeCombineRectangles(disp, win, ShapeBounding, 0, 0, rect, num, ShapeUnion, + Unsorted); } void -e_window_clip_shape_by_rectangle(Window win, int x, int y, int w, int h) +ecore_window_clip_shape_by_rectangle(Window win, int x, int y, int w, int h) { - XRectangle rect; - - rect.x = x; - rect.y = y; - rect.width = w; - rect.height = h; - XShapeCombineRectangles(disp, win, ShapeBounding, 0, 0, &rect, 1, ShapeIntersect, Unsorted); + XRectangle rect; + + rect.x = x; + rect.y = y; + rect.width = w; + rect.height = h; + XShapeCombineRectangles(disp, win, ShapeBounding, 0, 0, &rect, 1, + ShapeIntersect, Unsorted); } -XRectangle * -e_window_get_shape_rectangles(Window win, int *num) +XRectangle * +ecore_window_get_shape_rectangles(Window win, int *num) { - int ord; - - return XShapeGetRectangles(disp, win, ShapeBounding, num, &ord); + int ord; + + return XShapeGetRectangles(disp, win, ShapeBounding, num, &ord); } void -e_window_select_shape_events(Window win) +ecore_window_select_shape_events(Window win) { - XShapeSelectInput(disp, win, ShapeNotifyMask); + XShapeSelectInput(disp, win, ShapeNotifyMask); } void -e_window_unselect_shape_events(Window win) +ecore_window_unselect_shape_events(Window win) { - XShapeSelectInput(disp, win, 0); + XShapeSelectInput(disp, win, 0); } void -e_window_clear(Window win) +ecore_window_clear(Window win) { - XClearWindow(disp, win); + XClearWindow(disp, win); } void -e_window_clear_area(Window win, int x, int y, int w, int h) +ecore_window_clear_area(Window win, int x, int y, int w, int h) { - XClearArea(disp, win, x, y, w, h, False); + XClearArea(disp, win, x, y, w, h, False); } void -e_pointer_xy(Window win, int *x, int *y) +ecore_pointer_xy(Window win, int *x, int *y) { - Window dw; - unsigned int dm; - int wx, wy; + Window dw; + unsigned int dm; + int wx, wy; - if (win == 0) - win = default_root; - XQueryPointer(disp, win, &dw, &dw, &mouse_x, &mouse_y, &wx, &wy, &dm); - if (x) - *x = wx; - if (y) - *y = wy; + if (win == 0) + win = default_root; + XQueryPointer(disp, win, &dw, &dw, &mouse_x, &mouse_y, &wx, &wy, &dm); + if (x) + *x = wx; + if (y) + *y = wy; } void -e_pointer_xy_set(int x, int y) +ecore_pointer_xy_set(int x, int y) { - mouse_x = x; - mouse_y = y; + mouse_x = x; + mouse_y = y; } void -e_pointer_xy_get(int *x, int *y) +ecore_pointer_xy_get(int *x, int *y) { - if (x) - *x = mouse_x; - if (y) - *y = mouse_y; + if (x) + *x = mouse_x; + if (y) + *y = mouse_y; } void -e_window_set_events(Window win, long mask) +ecore_window_set_events(Window win, long mask) { - if (win == 0) - win = default_root; - XSelectInput(disp, win, mask); + if (win == 0) + win = default_root; + XSelectInput(disp, win, mask); } void -e_window_remove_events(Window win, long mask) +ecore_window_remove_events(Window win, long mask) { - XWindowAttributes att; + XWindowAttributes att; - if (win == 0) - win = default_root; - if (XGetWindowAttributes(disp, win, &att) == True) - { - mask = att.your_event_mask & (~mask); - e_window_set_events(win, mask); - } + if (win == 0) + win = default_root; + if (XGetWindowAttributes(disp, win, &att) == True) + { + mask = att.your_event_mask & (~mask); + ecore_window_set_events(win, mask); + } } void -e_window_add_events(Window win, long mask) +ecore_window_add_events(Window win, long mask) { - XWindowAttributes att; + XWindowAttributes att; - if (win == 0) - win = default_root; - if (XGetWindowAttributes(disp, win, &att) == True) - { - mask = att.your_event_mask | mask; - e_window_set_events(win, mask); - } + if (win == 0) + win = default_root; + if (XGetWindowAttributes(disp, win, &att) == True) + { + mask = att.your_event_mask | mask; + ecore_window_set_events(win, mask); + } } void -e_window_move(Window win, int x, int y) +ecore_window_move(Window win, int x, int y) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; - xid = e_validate_xid(win); - if (xid) - { - if (!xid->coords_invalid) - { - if ((xid->x == x) && (xid->y == y)) - return; - } - xid->x = x; - xid->y = y; - xid->coords_invalid = 0; - XMoveWindow(disp, win, x, y); - } + xid = ecore_validate_xid(win); + if (xid) + { + if (!xid->coords_invalid) + { + if ((xid->x == x) && (xid->y == y)) + return; + } + xid->x = x; + xid->y = y; + xid->coords_invalid = 0; + XMoveWindow(disp, win, x, y); + } } #define REGRAVITATE \ @@ -650,9 +659,9 @@ if (xid->children) \ \ for (j = 0; j < xid->children_num; j++) \ { \ - E_XID *xid2; \ + Ecore_XID *xid2; \ \ - xid2 = e_validate_xid(xid->children[j]); \ + xid2 = ecore_validate_xid(xid->children[j]); \ if (xid2) \ { \ xid2->coords_invalid = 1; \ @@ -661,126 +670,125 @@ if (xid->children) \ } #if 0 - switch (xid2->gravity) \ - { \ - case UnmapGravity: \ - xid2->mapped = 0; \ - break; \ - case NorthWestGravity: \ - break; \ - case NorthGravity: \ - xid2->x += (w - xid->w) / 2; \ - break; \ - case NorthEastGravity: \ - xid2->x += (w - xid->w); \ - break; \ - case WestGravity: \ - xid2->h += (h - xid->h) / 2; \ - break; \ - case CenterGravity: \ - xid2->x += (w - xid->w) / 2; \ - xid2->h += (h - xid->h) / 2; \ - break; \ - case EastGravity: \ - xid2->x += (w - xid->w); \ - break; \ - case SouthWestGravity: \ - xid2->y += (h - xid->h); \ - break; \ - case SouthGravity: \ - xid2->x += (w - xid->w) / 2; \ - xid2->y += (h - xid->h); \ - break; \ - case SouthEastGravity: \ - xid2->x += (w - xid->w); \ - xid2->y += (h - xid->h); \ - break; \ - case StaticGravity: \ - xid2->coords_invalid = 1; \ - break; \ - default: \ - break; \ - } \ - } \ - } \ +switch (xid2->gravity) + { + case UnmapGravity: + xid2->mapped = 0; + break; + case NorthWestGravity: + break; + case NorthGravity: + xid2->x += (w - xid->w) / 2; + break; + case NorthEastGravity: + xid2->x += (w - xid->w); + break; + case WestGravity: + xid2->h += (h - xid->h) / 2; + break; + case CenterGravity: + xid2->x += (w - xid->w) / 2; + xid2->h += (h - xid->h) / 2; + break; + case EastGravity: + xid2->x += (w - xid->w); + break; + case SouthWestGravity: + xid2->y += (h - xid->h); + break; + case SouthGravity: + xid2->x += (w - xid->w) / 2; + xid2->y += (h - xid->h); + break; + case SouthEastGravity: + xid2->x += (w - xid->w); + xid2->y += (h - xid->h); + break; + case StaticGravity: + xid2->coords_invalid = 1; + break; + default: + break; + } +} +} } #endif void -e_window_resize(Window win, int w, int h) +ecore_window_resize(Window win, int w, int h) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; - xid = e_validate_xid(win); - if (xid) - { - if (!xid->coords_invalid) - { - if ((xid->w == w) && (xid->h == h)) - return; - } - REGRAVITATE; - xid->w = w; - xid->h = h; - xid->coords_invalid = 0; - XResizeWindow(disp, win, w, h); - } + xid = ecore_validate_xid(win); + if (xid) + { + if (!xid->coords_invalid) + { + if ((xid->w == w) && (xid->h == h)) + return; + } + REGRAVITATE; + xid->w = w; + xid->h = h; + xid->coords_invalid = 0; + XResizeWindow(disp, win, w, h); + } } void -e_window_move_resize(Window win, int x, int y, int w, int h) +ecore_window_move_resize(Window win, int x, int y, int w, int h) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; - xid = e_validate_xid(win); - if (xid) - { - if (!xid->coords_invalid) - { - if ((xid->x == x) && (xid->y == y) && (xid->w == w) && (xid->h == h)) - return; - } - REGRAVITATE; - xid->x = x; - xid->y = y; - xid->w = w; - xid->h = h; - xid->coords_invalid = 0; - XMoveResizeWindow(disp, win, x, y, w, h); - } + xid = ecore_validate_xid(win); + if (xid) + { + if (!xid->coords_invalid) + { + if ((xid->x == x) && (xid->y == y) && (xid->w == w) && (xid->h == h)) + return; + } + REGRAVITATE; + xid->x = x; + xid->y = y; + xid->w = w; + xid->h = h; + xid->coords_invalid = 0; + XMoveResizeWindow(disp, win, x, y, w, h); + } } int -e_x_get_fd(void) +ecore_x_get_fd(void) { - return ConnectionNumber(disp); + return ConnectionNumber(disp); } void -e_set_error_handler(void (*func) (Display * d, XErrorEvent * ev)) - +ecore_set_error_handler(Ecore_Error_Function * func) { - XSetErrorHandler((XErrorHandler)func); + XSetErrorHandler((XErrorHandler) func); } void -e_reset_error_handler(void) +ecore_reset_error_handler(void) { - XSetErrorHandler((XErrorHandler) e_handle_x_error); + XSetErrorHandler((XErrorHandler) ecore_handle_x_error); } int -e_display_init(char *display) +ecore_display_init(char *display) { - int revert; + int revert; - xid_context = XUniqueContext(); - disp = XOpenDisplay(display); - if (!disp) - { - char *d; + xid_context = XUniqueContext(); + disp = XOpenDisplay(display); + if (!disp) + { + char *d; - d = getenv("DISPLAY"); + d = getenv("DISPLAY"); /* no need for this anymore if (d) fprintf(stderr, @@ -796,2501 +804,2540 @@ e_display_init(char *display) "Try setting your DISPLAY variable like:\n" "DISPLAY=host:0 appication_name\n"); */ - return 0; - } - XSetErrorHandler((XErrorHandler) e_handle_x_error); - XSetIOErrorHandler((XIOErrorHandler) e_handle_x_io_error); - default_vis = DefaultVisual(disp, DefaultScreen(disp)); - default_depth = DefaultDepth(disp, DefaultScreen(disp)); - default_cm = DefaultColormap(disp, DefaultScreen(disp)); - default_win = DefaultRootWindow(disp); - default_root = DefaultRootWindow(disp); - mod_shift = e_mod_mask_shift_get(); - mod_ctrl = e_mod_mask_ctrl_get(); - mod_alt = e_mod_mask_alt_get(); - mod_win = e_mod_mask_win_get(); - XGetInputFocus(disp, &focused_win, &revert); - e_window_set_events(default_root, XEV_KEY | XEV_IN_OUT | XEV_MOUSE_MOVE | - XEV_CONFIGURE | XEV_CHILD_CHANGE | XEV_PROPERTY | - XEV_COLORMAP | XEV_VISIBILITY); - e_pointer_xy(0, NULL, NULL); - return 1; + return 0; + } + XSetErrorHandler((XErrorHandler) ecore_handle_x_error); + XSetIOErrorHandler((XIOErrorHandler) ecore_handle_x_io_error); + default_vis = DefaultVisual(disp, DefaultScreen(disp)); + default_depth = DefaultDepth(disp, DefaultScreen(disp)); + default_cm = DefaultColormap(disp, DefaultScreen(disp)); + default_win = DefaultRootWindow(disp); + default_root = DefaultRootWindow(disp); + mod_shift = ecore_mod_mask_shift_get(); + mod_ctrl = ecore_mod_mask_ctrl_get(); + mod_alt = ecore_mod_mask_alt_get(); + mod_win = ecore_mod_mask_win_get(); + XGetInputFocus(disp, &focused_win, &revert); + ecore_window_set_events(default_root, XEV_KEY | XEV_IN_OUT | XEV_MOUSE_MOVE | + XEV_CONFIGURE | XEV_CHILD_CHANGE | XEV_PROPERTY | + XEV_COLORMAP | XEV_VISIBILITY); + ecore_pointer_xy(0, NULL, NULL); + return 1; } int -e_events_pending(void) +ecore_events_pending(void) { - if (!disp) return 0; - return XPending(disp); + if (!disp) + return 0; + return XPending(disp); } void -e_get_next_event(XEvent * event) +ecore_get_next_event(XEvent * event) { - XNextEvent(disp, event); + XNextEvent(disp, event); } int -e_event_shape_get_id(void) +ecore_event_shape_get_id(void) { - int base = -1, err_base; + int base = -1, err_base; - XShapeQueryExtension(disp, &base, &err_base); - base += ShapeNotify; - return base; + XShapeQueryExtension(disp, &base, &err_base); + base += ShapeNotify; + return base; } KeySym -e_key_get_keysym_from_keycode(KeyCode keycode) +ecore_key_get_keysym_from_keycode(KeyCode keycode) { - return XKeycodeToKeysym(disp, keycode, 0); + return XKeycodeToKeysym(disp, keycode, 0); } char * -e_key_get_string_from_keycode(KeyCode keycode) +ecore_key_get_string_from_keycode(KeyCode keycode) { - char *str; - - str = XKeysymToString(e_key_get_keysym_from_keycode(keycode)); - if (!str) return strdup(""); - return strdup(str); + char *str; + + str = XKeysymToString(ecore_key_get_keysym_from_keycode(keycode)); + if (!str) + return strdup(""); + return strdup(str); } void -e_event_allow(int mode, Time t) +ecore_event_allow(int mode, Time t) { - XAllowEvents(disp, mode, t); + XAllowEvents(disp, mode, t); } int -e_lock_mask_scroll_get(void) +ecore_lock_mask_scroll_get(void) { - static int have_mask = 0; - static int mask = 0; - XModifierKeymap *mod; - KeyCode nl; - int i; - int masks[8] = { - ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, - Mod4Mask, Mod5Mask - }; + static int have_mask = 0; + static int mask = 0; + XModifierKeymap *mod; + KeyCode nl; + int i; + int masks[8] = { + ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, + Mod4Mask, Mod5Mask + }; - if (have_mask) - return mask; - mod = XGetModifierMapping(disp); - nl = XKeysymToKeycode(disp, XK_Scroll_Lock); - if ((mod) && (mod->max_keypermod > 0)) - { - for (i = 0; i < (8 * mod->max_keypermod); i++) - { - if ((nl) && (mod->modifiermap[i] == nl)) - { - mask = masks[i / mod->max_keypermod]; - if (mod->modifiermap) - XFree(mod->modifiermap); - XFree(mod); - have_mask = 1; - return mask; - } - } - } - if (mod) - { - if (mod->modifiermap) - XFree(mod->modifiermap); - XFree(mod); - } - return 0; + if (have_mask) + return mask; + mod = XGetModifierMapping(disp); + nl = XKeysymToKeycode(disp, XK_Scroll_Lock); + if ((mod) && (mod->max_keypermod > 0)) + { + for (i = 0; i < (8 * mod->max_keypermod); i++) + { + if ((nl) && (mod->modifiermap[i] == nl)) + { + mask = masks[i / mod->max_keypermod]; + if (mod->modifiermap) + XFree(mod->modifiermap); + XFree(mod); + have_mask = 1; + return mask; + } + } + } + if (mod) + { + if (mod->modifiermap) + XFree(mod->modifiermap); + XFree(mod); + } + return 0; } int -e_lock_mask_num_get(void) +ecore_lock_mask_num_get(void) { - static int have_mask = 0; - static int mask = 0; - XModifierKeymap *mod; - KeyCode nl; - int i; - int masks[8] = { - ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, - Mod4Mask, Mod5Mask - }; + static int have_mask = 0; + static int mask = 0; + XModifierKeymap *mod; + KeyCode nl; + int i; + int masks[8] = { + ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, + Mod4Mask, Mod5Mask + }; - if (have_mask) - return mask; - mod = XGetModifierMapping(disp); - nl = XKeysymToKeycode(disp, XK_Num_Lock); - if ((mod) && (mod->max_keypermod > 0)) - { - for (i = 0; i < (8 * mod->max_keypermod); i++) - { - if ((nl) && (mod->modifiermap[i] == nl)) - { - mask = masks[i / mod->max_keypermod]; - if (mod->modifiermap) - XFree(mod->modifiermap); - XFree(mod); - have_mask = 1; - return mask; - } - } - } - if (mod) - { - if (mod->modifiermap) - XFree(mod->modifiermap); - XFree(mod); - } - return 0; + if (have_mask) + return mask; + mod = XGetModifierMapping(disp); + nl = XKeysymToKeycode(disp, XK_Num_Lock); + if ((mod) && (mod->max_keypermod > 0)) + { + for (i = 0; i < (8 * mod->max_keypermod); i++) + { + if ((nl) && (mod->modifiermap[i] == nl)) + { + mask = masks[i / mod->max_keypermod]; + if (mod->modifiermap) + XFree(mod->modifiermap); + XFree(mod); + have_mask = 1; + return mask; + } + } + } + if (mod) + { + if (mod->modifiermap) + XFree(mod->modifiermap); + XFree(mod); + } + return 0; } int -e_lock_mask_caps_get(void) +ecore_lock_mask_caps_get(void) { - static int have_mask = 0; - static int mask = 0; - XModifierKeymap *mod; - KeyCode nl; - int i; - int masks[8] = { - ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, - Mod4Mask, Mod5Mask - }; + static int have_mask = 0; + static int mask = 0; + XModifierKeymap *mod; + KeyCode nl; + int i; + int masks[8] = { + ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, + Mod4Mask, Mod5Mask + }; - if (have_mask) - return mask; - mod = XGetModifierMapping(disp); - nl = XKeysymToKeycode(disp, XK_Caps_Lock); - if ((mod) && (mod->max_keypermod > 0)) - { - for (i = 0; i < (8 * mod->max_keypermod); i++) - { - if ((nl) && (mod->modifiermap[i] == nl)) - { - mask = masks[i / mod->max_keypermod]; - if (mod->modifiermap) - XFree(mod->modifiermap); - XFree(mod); - have_mask = 1; - return mask; - } - } - } - if (mod) - { - if (mod->modifiermap) - XFree(mod->modifiermap); - XFree(mod); - } - return 0; + if (have_mask) + return mask; + mod = XGetModifierMapping(disp); + nl = XKeysymToKeycode(disp, XK_Caps_Lock); + if ((mod) && (mod->max_keypermod > 0)) + { + for (i = 0; i < (8 * mod->max_keypermod); i++) + { + if ((nl) && (mod->modifiermap[i] == nl)) + { + mask = masks[i / mod->max_keypermod]; + if (mod->modifiermap) + XFree(mod->modifiermap); + XFree(mod); + have_mask = 1; + return mask; + } + } + } + if (mod) + { + if (mod->modifiermap) + XFree(mod->modifiermap); + XFree(mod); + } + return 0; } int -e_mod_mask_shift_get(void) +ecore_mod_mask_shift_get(void) { - static int have_mask = 0; - static int mask = 0; - XModifierKeymap *mod; - KeyCode nl; - int i; - int masks[8] = { - ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, - Mod4Mask, Mod5Mask - }; + static int have_mask = 0; + static int mask = 0; + XModifierKeymap *mod; + KeyCode nl; + int i; + int masks[8] = { + ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, + Mod4Mask, Mod5Mask + }; - if (have_mask) - return mask; - mod = XGetModifierMapping(disp); - nl = XKeysymToKeycode(disp, XK_Shift_L); - if ((mod) && (mod->max_keypermod > 0)) - { - for (i = 0; i < (8 * mod->max_keypermod); i++) - { - if ((nl) && (mod->modifiermap[i] == nl)) - { - mask = masks[i / mod->max_keypermod]; - if (mod->modifiermap) - XFree(mod->modifiermap); - XFree(mod); - have_mask = 1; - return mask; - } - } - } - if (mod) - { - if (mod->modifiermap) - XFree(mod->modifiermap); - XFree(mod); - } - return 0; + if (have_mask) + return mask; + mod = XGetModifierMapping(disp); + nl = XKeysymToKeycode(disp, XK_Shift_L); + if ((mod) && (mod->max_keypermod > 0)) + { + for (i = 0; i < (8 * mod->max_keypermod); i++) + { + if ((nl) && (mod->modifiermap[i] == nl)) + { + mask = masks[i / mod->max_keypermod]; + if (mod->modifiermap) + XFree(mod->modifiermap); + XFree(mod); + have_mask = 1; + return mask; + } + } + } + if (mod) + { + if (mod->modifiermap) + XFree(mod->modifiermap); + XFree(mod); + } + return 0; } int -e_mod_mask_ctrl_get(void) +ecore_mod_mask_ctrl_get(void) { - static int have_mask = 0; - static int mask = 0; - XModifierKeymap *mod; - KeyCode nl; - int i; - int masks[8] = { - ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, - Mod4Mask, Mod5Mask - }; + static int have_mask = 0; + static int mask = 0; + XModifierKeymap *mod; + KeyCode nl; + int i; + int masks[8] = { + ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, + Mod4Mask, Mod5Mask + }; - if (have_mask) - return mask; - mod = XGetModifierMapping(disp); - nl = XKeysymToKeycode(disp, XK_Control_L); - if ((mod) && (mod->max_keypermod > 0)) - { - for (i = 0; i < (8 * mod->max_keypermod); i++) - { - if ((nl) && (mod->modifiermap[i] == nl)) - { - mask = masks[i / mod->max_keypermod]; - if (mod->modifiermap) - XFree(mod->modifiermap); - XFree(mod); - have_mask = 1; - return mask; - } - } - } - if (mod) - { - if (mod->modifiermap) - XFree(mod->modifiermap); - XFree(mod); - } - return 0; + if (have_mask) + return mask; + mod = XGetModifierMapping(disp); + nl = XKeysymToKeycode(disp, XK_Control_L); + if ((mod) && (mod->max_keypermod > 0)) + { + for (i = 0; i < (8 * mod->max_keypermod); i++) + { + if ((nl) && (mod->modifiermap[i] == nl)) + { + mask = masks[i / mod->max_keypermod]; + if (mod->modifiermap) + XFree(mod->modifiermap); + XFree(mod); + have_mask = 1; + return mask; + } + } + } + if (mod) + { + if (mod->modifiermap) + XFree(mod->modifiermap); + XFree(mod); + } + return 0; } int -e_mod_mask_alt_get(void) +ecore_mod_mask_alt_get(void) { - static int have_mask = 0; - static int mask = 0; - XModifierKeymap *mod; - KeyCode nl; - int i; - int masks[8] = { - ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, - Mod4Mask, Mod5Mask - }; + static int have_mask = 0; + static int mask = 0; + XModifierKeymap *mod; + KeyCode nl; + int i; + int masks[8] = { + ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, + Mod4Mask, Mod5Mask + }; - if (have_mask) - return mask; - mod = XGetModifierMapping(disp); - nl = XKeysymToKeycode(disp, XK_Alt_L); - if ((mod) && (mod->max_keypermod > 0)) - { - for (i = 0; i < (8 * mod->max_keypermod); i++) - { - if ((nl) && (mod->modifiermap[i] == nl)) - { - mask = masks[i / mod->max_keypermod]; - if (mod->modifiermap) - XFree(mod->modifiermap); - XFree(mod); - have_mask = 1; - return mask; - } - } - } - if (mod) - { - if (mod->modifiermap) - XFree(mod->modifiermap); - XFree(mod); - } - return 0; + if (have_mask) + return mask; + mod = XGetModifierMapping(disp); + nl = XKeysymToKeycode(disp, XK_Alt_L); + if ((mod) && (mod->max_keypermod > 0)) + { + for (i = 0; i < (8 * mod->max_keypermod); i++) + { + if ((nl) && (mod->modifiermap[i] == nl)) + { + mask = masks[i / mod->max_keypermod]; + if (mod->modifiermap) + XFree(mod->modifiermap); + XFree(mod); + have_mask = 1; + return mask; + } + } + } + if (mod) + { + if (mod->modifiermap) + XFree(mod->modifiermap); + XFree(mod); + } + return 0; } int -e_mod_mask_win_get(void) +ecore_mod_mask_win_get(void) { - static int have_mask = 0; - static int mask = 0; - XModifierKeymap *mod; - KeyCode nl; - int i; - int masks[8] = { - ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, - Mod4Mask, Mod5Mask - }; + static int have_mask = 0; + static int mask = 0; + XModifierKeymap *mod; + KeyCode nl; + int i; + int masks[8] = { + ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, + Mod4Mask, Mod5Mask + }; - if (have_mask) - return mask; - mod = XGetModifierMapping(disp); - nl = XKeysymToKeycode(disp, XK_Meta_L); - if ((mod) && (mod->max_keypermod > 0)) - { - for (i = 0; i < (8 * mod->max_keypermod); i++) - { - if ((nl) && (mod->modifiermap[i] == nl)) - { - mask = masks[i / mod->max_keypermod]; - if (mod->modifiermap) - XFree(mod->modifiermap); - XFree(mod); - if (mask == e_mod_mask_alt_get()) - mask = 0; - if (mask == e_mod_mask_ctrl_get()) - mask = 0; - have_mask = 1; - return mask; - } - } - } - if (mod) - { - if (mod->modifiermap) - XFree(mod->modifiermap); - XFree(mod); - } - return 0; + if (have_mask) + return mask; + mod = XGetModifierMapping(disp); + nl = XKeysymToKeycode(disp, XK_Meta_L); + if ((mod) && (mod->max_keypermod > 0)) + { + for (i = 0; i < (8 * mod->max_keypermod); i++) + { + if ((nl) && (mod->modifiermap[i] == nl)) + { + mask = masks[i / mod->max_keypermod]; + if (mod->modifiermap) + XFree(mod->modifiermap); + XFree(mod); + if (mask == ecore_mod_mask_alt_get()) + mask = 0; + if (mask == ecore_mod_mask_ctrl_get()) + mask = 0; + have_mask = 1; + return mask; + } + } + } + if (mod) + { + if (mod->modifiermap) + XFree(mod->modifiermap); + XFree(mod); + } + return 0; } int -e_lock_mask_get(void) +ecore_lock_mask_get(void) { - static int mask = 0; - Window root_ret, child_ret; - int root_x_ret, root_y_ret, win_x_ret, win_y_ret; - unsigned int mask_ret; + static int mask = 0; + Window root_ret, child_ret; + int root_x_ret, root_y_ret, win_x_ret, win_y_ret; + unsigned int mask_ret; - if (!mask) - mask = e_lock_mask_scroll_get() | e_lock_mask_num_get() | - e_lock_mask_caps_get(); - XQueryPointer(disp, default_root, &root_ret, &child_ret, &root_x_ret, - &root_y_ret, &win_x_ret, &win_y_ret, &mask_ret); - return (mask_ret & mask); + if (!mask) + mask = ecore_lock_mask_scroll_get() | ecore_lock_mask_num_get() | + ecore_lock_mask_caps_get(); + XQueryPointer(disp, default_root, &root_ret, &child_ret, &root_x_ret, + &root_y_ret, &win_x_ret, &win_y_ret, &mask_ret); + return (mask_ret & mask); } int -e_modifier_mask_get(void) +ecore_modifier_mask_get(void) { - Window root_ret, child_ret; - int root_x_ret, root_y_ret, win_x_ret, win_y_ret; - unsigned int mask_ret; + Window root_ret, child_ret; + int root_x_ret, root_y_ret, win_x_ret, win_y_ret; + unsigned int mask_ret; - XQueryPointer(disp, default_root, &root_ret, &child_ret, &root_x_ret, - &root_y_ret, &win_x_ret, &win_y_ret, &mask_ret); - return (mask_ret); + XQueryPointer(disp, default_root, &root_ret, &child_ret, &root_x_ret, + &root_y_ret, &win_x_ret, &win_y_ret, &mask_ret); + return (mask_ret); } Window -e_get_key_grab_win(void) +ecore_get_key_grab_win(void) { - return grabkey_win; + return grabkey_win; } void -e_key_grab(char *key, Ev_Key_Modifiers mods, int anymod, int sync) +ecore_key_grab(char *key, Ecore_Event_Key_Modifiers mods, int anymod, int sync) { - KeyCode keycode; - int i, mod, mask_scroll, mask_num, mask_caps, masks[8], mode; + KeyCode keycode; + int i, mod, mask_scroll, mask_num, mask_caps, masks[8], mode; - keycode = e_key_get_keycode(key); - mod = 0; - mode = GrabModeAsync; - if (sync) - mode = GrabModeSync; - if (!grabkey_win) - grabkey_win = default_root; - if (mods & EV_KEY_MODIFIER_SHIFT) - mod |= e_mod_mask_shift_get(); - if (mods & EV_KEY_MODIFIER_CTRL) - mod |= e_mod_mask_ctrl_get(); - if (mods & EV_KEY_MODIFIER_ALT) - mod |= e_mod_mask_alt_get(); - if (mods & EV_KEY_MODIFIER_WIN) - mod |= e_mod_mask_win_get(); - mask_scroll = e_lock_mask_scroll_get(); - mask_num = e_lock_mask_num_get(); - mask_caps = e_lock_mask_caps_get(); - masks[0] = 0; - masks[1] = mask_scroll; - masks[2] = mask_num; - masks[3] = mask_caps; - masks[4] = mask_scroll | mask_num; - masks[5] = mask_scroll | mask_caps; - masks[6] = mask_num | mask_caps; - masks[7] = mask_scroll | mask_num | mask_caps; - if (anymod) - XGrabKey(disp, keycode, AnyModifier, grabkey_win, False, mode, mode); - else - { - for (i = 0; i < 8; i++) - XGrabKey(disp, keycode, masks[i] | mod, grabkey_win, False, - mode, mode); - } + keycode = ecore_key_get_keycode(key); + mod = 0; + mode = GrabModeAsync; + if (sync) + mode = GrabModeSync; + if (!grabkey_win) + grabkey_win = default_root; + if (mods & ECORE_EVENT_KEY_MODIFIER_SHIFT) + mod |= ecore_mod_mask_shift_get(); + if (mods & ECORE_EVENT_KEY_MODIFIER_CTRL) + mod |= ecore_mod_mask_ctrl_get(); + if (mods & ECORE_EVENT_KEY_MODIFIER_ALT) + mod |= ecore_mod_mask_alt_get(); + if (mods & ECORE_EVENT_KEY_MODIFIER_WIN) + mod |= ecore_mod_mask_win_get(); + mask_scroll = ecore_lock_mask_scroll_get(); + mask_num = ecore_lock_mask_num_get(); + mask_caps = ecore_lock_mask_caps_get(); + masks[0] = 0; + masks[1] = mask_scroll; + masks[2] = mask_num; + masks[3] = mask_caps; + masks[4] = mask_scroll | mask_num; + masks[5] = mask_scroll | mask_caps; + masks[6] = mask_num | mask_caps; + masks[7] = mask_scroll | mask_num | mask_caps; + if (anymod) + XGrabKey(disp, keycode, AnyModifier, grabkey_win, False, mode, mode); + else + { + for (i = 0; i < 8; i++) + XGrabKey(disp, keycode, masks[i] | mod, grabkey_win, False, mode, mode); + } } void -e_key_ungrab(char *key, Ev_Key_Modifiers mods, int anymod) +ecore_key_ungrab(char *key, Ecore_Event_Key_Modifiers mods, int anymod) { - KeyCode keycode; + KeyCode keycode; - keycode = e_key_get_keycode(key); - if (anymod) - XUngrabKey(disp, keycode, AnyModifier, default_root); - else - { - int i, mod, mask_scroll, mask_num, mask_caps, masks[8]; + keycode = ecore_key_get_keycode(key); + if (anymod) + XUngrabKey(disp, keycode, AnyModifier, default_root); + else + { + int i, mod, mask_scroll, mask_num, mask_caps, masks[8]; - mod = 0; - if (mods & EV_KEY_MODIFIER_SHIFT) - mod |= e_mod_mask_shift_get(); - if (mods & EV_KEY_MODIFIER_CTRL) - mod |= e_mod_mask_ctrl_get(); - if (mods & EV_KEY_MODIFIER_ALT) - mod |= e_mod_mask_alt_get(); - if (mods & EV_KEY_MODIFIER_WIN) - mod |= e_mod_mask_win_get(); - mask_scroll = e_lock_mask_scroll_get(); - mask_num = e_lock_mask_num_get(); - mask_caps = e_lock_mask_caps_get(); - masks[0] = 0; - masks[1] = mask_scroll; - masks[2] = mask_num; - masks[3] = mask_caps; - masks[4] = mask_scroll | mask_num; - masks[5] = mask_scroll | mask_caps; - masks[6] = mask_num | mask_caps; - masks[7] = mask_scroll | mask_num | mask_caps; - for (i = 0; i < 8; i++) - XUngrabKey(disp, keycode, masks[i] | mod, grabkey_win); - } + mod = 0; + if (mods & ECORE_EVENT_KEY_MODIFIER_SHIFT) + mod |= ecore_mod_mask_shift_get(); + if (mods & ECORE_EVENT_KEY_MODIFIER_CTRL) + mod |= ecore_mod_mask_ctrl_get(); + if (mods & ECORE_EVENT_KEY_MODIFIER_ALT) + mod |= ecore_mod_mask_alt_get(); + if (mods & ECORE_EVENT_KEY_MODIFIER_WIN) + mod |= ecore_mod_mask_win_get(); + mask_scroll = ecore_lock_mask_scroll_get(); + mask_num = ecore_lock_mask_num_get(); + mask_caps = ecore_lock_mask_caps_get(); + masks[0] = 0; + masks[1] = mask_scroll; + masks[2] = mask_num; + masks[3] = mask_caps; + masks[4] = mask_scroll | mask_num; + masks[5] = mask_scroll | mask_caps; + masks[6] = mask_num | mask_caps; + masks[7] = mask_scroll | mask_num | mask_caps; + for (i = 0; i < 8; i++) + XUngrabKey(disp, keycode, masks[i] | mod, grabkey_win); + } } KeyCode -e_key_get_keycode(char *key) +ecore_key_get_keycode(char *key) { - return XKeysymToKeycode(disp, XStringToKeysym(key)); + return XKeysymToKeycode(disp, XStringToKeysym(key)); } void -e_window_destroy(Window win) +ecore_window_destroy(Window win) { - e_unvalidate_xid(win); - XDestroyWindow(disp, win); + ecore_unvalidate_xid(win); + XDestroyWindow(disp, win); } void -e_window_reparent(Window win, Window parent, int x, int y) +ecore_window_reparent(Window win, Window parent, int x, int y) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; - xid = e_validate_xid(win); - if (xid) - { - if (parent == 0) - parent = default_root; - XReparentWindow(disp, win, parent, x, y); - e_del_child(xid->parent, win); - e_add_child(parent, win); - xid->parent = parent; - xid->x = x; - xid->y = y; - } + xid = ecore_validate_xid(win); + if (xid) + { + if (parent == 0) + parent = default_root; + XReparentWindow(disp, win, parent, x, y); + ecore_del_child(xid->parent, win); + ecore_add_child(parent, win); + xid->parent = parent; + xid->x = x; + xid->y = y; + } } void -e_window_raise(Window win) +ecore_window_raise(Window win) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; - xid = e_validate_xid(win); - if (xid) - { - XRaiseWindow(disp, win); - e_raise_child(xid->parent, win); - } + xid = ecore_validate_xid(win); + if (xid) + { + XRaiseWindow(disp, win); + ecore_raise_child(xid->parent, win); + } } void -e_window_lower(Window win) +ecore_window_lower(Window win) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; - xid = e_validate_xid(win); - if (xid) - { - XLowerWindow(disp, win); - e_lower_child(xid->parent, win); - } + xid = ecore_validate_xid(win); + if (xid) + { + XLowerWindow(disp, win); + ecore_lower_child(xid->parent, win); + } } void -e_window_get_geometry(Window win, int *x, int *y, int *w, int *h) +ecore_window_get_geometry(Window win, int *x, int *y, int *w, int *h) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; - if (win == 0) - win = default_root; - xid = e_validate_xid(win); - if ((xid) && (xid->coords_invalid)) - { - Window dw; - int rx, ry; - unsigned int rw, rh, di; - - XGetGeometry(disp, win, &dw, &rx, &ry, &rw, &rh, &di, &di); - xid->x = rx; - xid->y = ry; - xid->w = (int)rw; - xid->h = (int)rh; - xid->coords_invalid = 0; - } - if (xid) - { - if (x) - *x = xid->x; - if (y) - *y = xid->y; - if (w) - *w = xid->w; - if (h) - *h = xid->h; - } - else - { - if (x) - *x = 0; - if (y) - *y = 0; - if (w) - *w = 0; - if (h) - *h = 0; - } + if (win == 0) + win = default_root; + xid = ecore_validate_xid(win); + if ((xid) && (xid->coords_invalid)) + { + Window dw; + int rx, ry; + unsigned int rw, rh, di; + + XGetGeometry(disp, win, &dw, &rx, &ry, &rw, &rh, &di, &di); + xid->x = rx; + xid->y = ry; + xid->w = (int)rw; + xid->h = (int)rh; + xid->coords_invalid = 0; + } + if (xid) + { + if (x) + *x = xid->x; + if (y) + *y = xid->y; + if (w) + *w = xid->w; + if (h) + *h = xid->h; + } + else + { + if (x) + *x = 0; + if (y) + *y = 0; + if (w) + *w = 0; + if (h) + *h = 0; + } } int -e_window_get_depth(Window win) +ecore_window_get_depth(Window win) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; - if (win == 0) - win = default_root; - xid = e_validate_xid(win); - if (xid) - return xid->depth; - return -1; + if (win == 0) + win = default_root; + xid = ecore_validate_xid(win); + if (xid) + return xid->depth; + return -1; } int -e_window_exists(Window win) +ecore_window_exists(Window win) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; - xid = e_validate_xid(win); - if (xid) - return 1; - return 0; + xid = ecore_validate_xid(win); + if (xid) + return 1; + return 0; } Window -e_window_get_parent(Window win) +ecore_window_get_parent(Window win) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; - xid = e_validate_xid(win); - if (xid) - return xid->parent; - return 0; + xid = ecore_validate_xid(win); + if (xid) + return xid->parent; + return 0; } Window * -e_window_get_children(Window win, int *num) +ecore_window_get_children(Window win, int *num) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; - if (win == 0) - win = default_root; - xid = e_validate_xid(win); - if (xid) - { - Window *wlist = NULL; + if (win == 0) + win = default_root; + xid = ecore_validate_xid(win); + if (xid) + { + Window *wlist = NULL; - *num = xid->children_num; - if (xid->children) - { - wlist = NEW(Window, xid->children_num); - MEMCPY(xid->children, wlist, Window, xid->children_num); - } - return wlist; - } - *num = 0; - return NULL; + *num = xid->children_num; + if (xid->children) + { + wlist = NEW(Window, xid->children_num); + MEMCPY(xid->children, wlist, Window, xid->children_num); + } + return wlist; + } + *num = 0; + return NULL; } int -e_window_mouse_in(Window win) +ecore_window_mouse_in(Window win) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; - if (win == 0) - win = default_root; - xid = e_validate_xid(win); - if (xid) - return xid->mouse_in; - return 0; + if (win == 0) + win = default_root; + xid = ecore_validate_xid(win); + if (xid) + return xid->mouse_in; + return 0; } void -e_window_mouse_set_in(Window win, int in) +ecore_window_mouse_set_in(Window win, int in) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; - if (win == 0) - win = default_root; - xid = e_validate_xid(win); - if (xid) - xid->mouse_in = in; + if (win == 0) + win = default_root; + xid = ecore_validate_xid(win); + if (xid) + xid->mouse_in = in; } Display * -e_display_get(void) +ecore_display_get(void) { - return disp; + return disp; } Window -e_window_get_root(Window win) +ecore_window_get_root(Window win) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; - xid = e_validate_xid(win); - if (xid) - return xid->root; - return 0; + xid = ecore_validate_xid(win); + if (xid) + return xid->root; + return 0; } void -e_lock_scroll_set(int onoff) +ecore_lock_scroll_set(int onoff) { - lock_scroll = onoff; + lock_scroll = onoff; } int -e_lock_scroll_get(void) +ecore_lock_scroll_get(void) { - return lock_scroll; + return lock_scroll; } void -e_lock_num_set(int onoff) +ecore_lock_num_set(int onoff) { - lock_num = onoff; + lock_num = onoff; } int -e_lock_num_get(void) +ecore_lock_num_get(void) { - return lock_num; + return lock_num; } void -e_lock_caps_set(int onoff) +ecore_lock_caps_set(int onoff) { - lock_caps = onoff; + lock_caps = onoff; } int -e_lock_caps_get(void) +ecore_lock_caps_get(void) { - return lock_caps; + return lock_caps; } void -e_mod_shift_set(int onoff) +ecore_mod_shift_set(int onoff) { - mod_shift = onoff; + mod_shift = onoff; } int -e_mod_shift_get(void) +ecore_mod_shift_get(void) { - return mod_shift; + return mod_shift; } void -e_mod_ctrl_set(int onoff) +ecore_mod_ctrl_set(int onoff) { - mod_ctrl = onoff; + mod_ctrl = onoff; } int -e_mod_ctrl_get(void) +ecore_mod_ctrl_get(void) { - return mod_ctrl; + return mod_ctrl; } void -e_mod_alt_set(int onoff) +ecore_mod_alt_set(int onoff) { - mod_alt = onoff; + mod_alt = onoff; } int -e_mod_alt_get(void) +ecore_mod_alt_get(void) { - return mod_alt; + return mod_alt; } void -e_mod_win_set(int onoff) +ecore_mod_win_set(int onoff) { - mod_win = onoff; + mod_win = onoff; } int -e_mod_win_get(void) +ecore_mod_win_get(void) { - return mod_win; + return mod_win; } void -e_focus_window_set(Window win) +ecore_focus_window_set(Window win) { - focused_win = win; + focused_win = win; } Window -e_focus_window_get(void) +ecore_focus_window_get(void) { - return focused_win; + return focused_win; } void -e_focus_to_window(Window win) +ecore_focus_to_window(Window win) { - if (win == 0) - win = default_root; - XSetInputFocus(disp, win, RevertToPointerRoot, CurrentTime); + if (win == 0) + win = default_root; + XSetInputFocus(disp, win, RevertToPointerRoot, CurrentTime); } Atom -e_atom_get(char *name) +ecore_atom_get(char *name) { - return XInternAtom(disp, name, False); + return XInternAtom(disp, name, False); } void -e_window_set_delete_inform(Window win) +ecore_window_set_delete_inform(Window win) { - static Atom protocols[1] = { 0 }; + static Atom protocols[1] = { 0 }; - E_ATOM(protocols[0], "WM_DELETE_WINDOW"); - XSetWMProtocols(disp, win, protocols, 1); + ECORE_ATOM(protocols[0], "WM_DELETE_WINDOW"); + XSetWMProtocols(disp, win, protocols, 1); } void -e_window_property_set(Window win, Atom type, Atom format, int size, void *data, - int number) +ecore_window_property_set(Window win, Atom type, Atom format, int size, + void *data, int number) { - if (win == 0) - win = default_root; - if (size != 32) + if (win == 0) + win = default_root; + if (size != 32) + XChangeProperty(disp, win, type, format, size, PropModeReplace, + (unsigned char *)data, number); + else + { + long *dat; + int i, *ptr; + + dat = NEW(long, number); + + for (ptr = (int *)data, i = 0; i < number; i++) + dat[i] = ptr[i]; XChangeProperty(disp, win, type, format, size, PropModeReplace, - (unsigned char *)data, number); - else - { - long *dat; - int i, *ptr; - - dat = NEW(long, number); - - for (ptr = (int *)data, i = 0; i < number; i++) - dat[i] = ptr[i]; - XChangeProperty(disp, win, type, format, size, PropModeReplace, - (unsigned char *)dat, number); - FREE(dat); - } + (unsigned char *)dat, number); + FREE(dat); + } } void * -e_window_property_get(Window win, Atom type, Atom format, int *size) +ecore_window_property_get(Window win, Atom type, Atom format, int *size) { - unsigned char *retval; - Atom type_ret; - unsigned long bytes_after, num_ret; - int format_ret; - void *data = NULL; + unsigned char *retval; + Atom type_ret; + unsigned long bytes_after, num_ret; + int format_ret; + void *data = NULL; - retval = NULL; - if (win == 0) - win = default_root; - XGetWindowProperty(disp, win, type, 0, 0x7fffffffL, False, format, - &type_ret, &format_ret, &num_ret, &bytes_after, &retval); - if (retval) - { - if (format_ret == 32) - { - int i; + retval = NULL; + if (win == 0) + win = default_root; + XGetWindowProperty(disp, win, type, 0, 0x7fffffffL, False, format, + &type_ret, &format_ret, &num_ret, &bytes_after, &retval); + if (retval) + { + if (format_ret == 32) + { + int i; - *size = num_ret * sizeof(unsigned int); + *size = num_ret * sizeof(unsigned int); - data = NEW(unsigned int, num_ret); + data = NEW(unsigned int, num_ret); - for (i = 0; i < (int)num_ret; i++) - ((unsigned int *)data)[i] = ((unsigned long *)retval)[i]; - } - else if (format_ret == 16) - { - int i; + for (i = 0; i < (int)num_ret; i++) + ((unsigned int *)data)[i] = ((unsigned long *)retval)[i]; + } + else if (format_ret == 16) + { + int i; - *size = num_ret * sizeof(unsigned short); + *size = num_ret * sizeof(unsigned short); - data = NEW(unsigned short, *size); + data = NEW(unsigned short, *size); - for (i = 0; i < (int)num_ret; i++) - ((unsigned short *)data)[i] = ((unsigned short *)retval)[i]; - } - else if (format_ret == 8) - { - /* format_ret == 8 */ - *size = num_ret; - data = NEW(char, num_ret); + for (i = 0; i < (int)num_ret; i++) + ((unsigned short *)data)[i] = ((unsigned short *)retval)[i]; + } + else if (format_ret == 8) + { + /* format_ret == 8 */ + *size = num_ret; + data = NEW(char, num_ret); - if (data) - memcpy(data, retval, num_ret); - } - XFree(retval); - return data; - } - *size = 0; - return NULL; + if (data) + memcpy(data, retval, num_ret); + } + XFree(retval); + return data; + } + *size = 0; + return NULL; } void -e_window_dnd_advertise(Window win) +ecore_window_dnd_advertise(Window win) { - static Atom atom_xdndaware = 0; - int dnd_version = 3; + static Atom atom_xdndaware = 0; + int dnd_version = 3; - E_ATOM(atom_xdndaware, "XdndAware"); - e_window_property_set(win, atom_xdndaware, XA_ATOM, 32, &dnd_version, 1); + ECORE_ATOM(atom_xdndaware, "XdndAware"); + ecore_window_property_set(win, atom_xdndaware, XA_ATOM, 32, &dnd_version, 1); } void -e_grab(void) +ecore_grab(void) { - x_grabs++; - if (x_grabs == 1) - XGrabServer(disp); + x_grabs++; + if (x_grabs == 1) + XGrabServer(disp); } void -e_ungrab(void) +ecore_ungrab(void) { - x_grabs--; - if (x_grabs == 0) - { - XUngrabServer(disp); - e_sync(); - } + x_grabs--; + if (x_grabs == 0) + { + XUngrabServer(disp); + ecore_sync(); + } } void -e_window_ignore(Window win) +ecore_window_ignore(Window win) { - Window_List *w; + Window_List *w; - if (win == 0) - win = default_root; - w = NEW(Window_List, 1); - w->win = win; - w->next = ignore_wins; - ignore_wins = w; + if (win == 0) + win = default_root; + w = NEW(Window_List, 1); + w->win = win; + w->next = ignore_wins; + ignore_wins = w; } void -e_window_no_ignore(Window win) +ecore_window_no_ignore(Window win) { - Window_List *w, *pw; + Window_List *w, *pw; - if (win == 0) - win = default_root; - for (pw = NULL, w = ignore_wins; w; pw = w, w = w->next) - { - if (w->win == win) - { - if (pw) - pw->next = w->next; - else - ignore_wins = w->next; - FREE(w); - return; - } - } + if (win == 0) + win = default_root; + for (pw = NULL, w = ignore_wins; w; pw = w, w = w->next) + { + if (w->win == win) + { + if (pw) + pw->next = w->next; + else + ignore_wins = w->next; + FREE(w); + return; + } + } } int -e_window_is_ignored(Window win) +ecore_window_is_ignored(Window win) { - Window_List *w; + Window_List *w; - if (win == 0) - win = default_root; - for (w = ignore_wins; w; w = w->next) - { - if (w->win == win) - return 1; - } - return 0; + if (win == 0) + win = default_root; + for (w = ignore_wins; w; w = w->next) + { + if (w->win == win) + return 1; + } + return 0; } static Window -e_window_at_xy_0(Window base, int bx, int by, int x, int y) +ecore_window_at_xy_0(Window base, int bx, int by, int x, int y) { - Window *list = NULL; - XWindowAttributes att; - Window child = 0, parent_win = 0, root_win = 0; - int i; - unsigned int ww, wh, num; - int wx, wy; + Window *list = NULL; + XWindowAttributes att; + Window child = 0, parent_win = 0, root_win = 0; + int i; + unsigned int ww, wh, num; + int wx, wy; - if ((!XGetWindowAttributes(disp, base, &att)) || - (att.map_state != IsViewable)) - return 0; + if ((!XGetWindowAttributes(disp, base, &att)) || + (att.map_state != IsViewable)) + return 0; - wx = att.x; - wy = att.y; - ww = att.width; - wh = att.height; + wx = att.x; + wy = att.y; + ww = att.width; + wh = att.height; - wx += bx; - wy += by; + wx += bx; + wy += by; - if (!((x >= wx) && - (y >= wy) && (x < (int)(wx + ww)) && (y < (int)(wy + wh)))) - return 0; + if (!((x >= wx) && (y >= wy) && (x < (int)(wx + ww)) && (y < (int)(wy + wh)))) + return 0; - if (!XQueryTree(disp, base, &root_win, &parent_win, &list, &num)) - return base; - if (list) - { - for (i = num - 1;; i--) - { - if (!e_window_is_ignored(list[i])) - { - if ((child = e_window_at_xy_0(list[i], wx, wy, x, y)) != 0) - { - XFree(list); - return child; - } - } - if (!i) - break; - } - XFree(list); - } - return base; + if (!XQueryTree(disp, base, &root_win, &parent_win, &list, &num)) + return base; + if (list) + { + for (i = num - 1;; i--) + { + if (!ecore_window_is_ignored(list[i])) + { + if ((child = ecore_window_at_xy_0(list[i], wx, wy, x, y)) != 0) + { + XFree(list); + return child; + } + } + if (!i) + break; + } + XFree(list); + } + return base; } Window -e_window_get_at_xy(int x, int y) +ecore_window_get_at_xy(int x, int y) { - Window child; + Window child; - e_grab(); - child = e_window_at_xy_0(default_root, 0, 0, x, y); - if (child) - { - e_ungrab(); - return child; - } - e_ungrab(); - return default_root; + ecore_grab(); + child = ecore_window_at_xy_0(default_root, 0, 0, x, y); + if (child) + { + ecore_ungrab(); + return child; + } + ecore_ungrab(); + return default_root; } int -e_window_dnd_capable(Window win) +ecore_window_dnd_capable(Window win) { - static Atom atom_xdndaware = 0; - int dnd_version = 3; - int *atom_ret; - int size = 0; + static Atom atom_xdndaware = 0; + int dnd_version = 3; + int *atom_ret; + int size = 0; - E_ATOM(atom_xdndaware, "XdndAware"); - atom_ret = e_window_property_get(win, atom_xdndaware, XA_ATOM, &size); - if ((atom_ret) && (size >= (int)sizeof(int))) - { - if (atom_ret[0] == dnd_version) - { - FREE(atom_ret); - return 1; - } - FREE(atom_ret); - } - return 0; + ECORE_ATOM(atom_xdndaware, "XdndAware"); + atom_ret = ecore_window_property_get(win, atom_xdndaware, XA_ATOM, &size); + if ((atom_ret) && (size >= (int)sizeof(int))) + { + if (atom_ret[0] == dnd_version) + { + FREE(atom_ret); + return 1; + } + FREE(atom_ret); + } + return 0; } void -e_window_dnd_handle_motion(Window source_win, int x, int y, int dragging) +ecore_window_dnd_handle_motion(Window source_win, int x, int y, int dragging) { - static Atom atom_xdndenter = 0; - static Atom atom_xdndleave = 0; - static Atom atom_xdnddrop = 0; - static Atom atom_xdndposition = 0; - static Atom atom_xdndactioncopy = 0; - static Atom atom_xdndactionmove = 0; - static Atom atom_xdndactionlink = 0; - static Atom atom_xdndactionask = 0; - static Atom atom_text_uri_list = 0; - static Atom atom_text_plain = 0; - Window win; - XEvent xevent; + static Atom atom_xdndenter = 0; + static Atom atom_xdndleave = 0; + static Atom atom_xdnddrop = 0; + static Atom atom_xdndposition = 0; + static Atom atom_xdndactioncopy = 0; + static Atom atom_xdndactionmove = 0; + static Atom atom_xdndactionlink = 0; + static Atom atom_xdndactionask = 0; + static Atom atom_text_uri_list = 0; + static Atom atom_text_plain = 0; + Window win; + XEvent xevent; - win = e_window_get_at_xy(x, y); - while ((win) && (!e_window_dnd_capable(win))) - win = e_window_get_parent(win); - E_ATOM(atom_xdndenter, "XdndEnter"); - E_ATOM(atom_xdndleave, "XdndLeave"); - E_ATOM(atom_xdnddrop, "XdndDrop"); - E_ATOM(atom_xdndposition, "XdndPosition"); - E_ATOM(atom_xdndactioncopy, "XdndActionCopy"); - E_ATOM(atom_xdndactionmove, "XdndActionMove"); - E_ATOM(atom_xdndactionlink, "XdndActionLink"); - E_ATOM(atom_xdndactionask, "XdndActionAsk"); - E_ATOM(atom_text_uri_list, "text/uri-list"); - E_ATOM(atom_text_plain, "text/plain"); - if ((win != current_dnd_win) && (current_dnd_win)) - { - /* send leave to old dnd win */ - xevent.xany.type = ClientMessage; - xevent.xany.display = disp; - xevent.xclient.format = 32; - xevent.xclient.window = current_dnd_win; - xevent.xclient.message_type = atom_xdndleave; - xevent.xclient.data.l[0] = source_win; - xevent.xclient.data.l[1] = 0; - xevent.xclient.data.l[2] = 0; - xevent.xclient.data.l[3] = 0; - xevent.xclient.data.l[4] = 0; - XSendEvent(disp, current_dnd_win, False, 0, &xevent); - } - if (win) - { - if (win != current_dnd_win) - { - /* send enter on new win */ - xevent.xany.type = ClientMessage; - xevent.xany.display = disp; - xevent.xclient.window = win; - xevent.xclient.message_type = atom_xdndenter; - xevent.xclient.format = 32; - xevent.xclient.data.l[0] = source_win; - xevent.xclient.data.l[1] = (3 << 24); - xevent.xclient.data.l[2] = atom_text_uri_list; - xevent.xclient.data.l[3] = atom_text_plain; - xevent.xclient.data.l[4] = 0; - XSendEvent(disp, win, False, 0, &xevent); - } - /* send position information */ - xevent.xany.type = ClientMessage; - xevent.xany.display = disp; - xevent.xclient.window = win; - xevent.xclient.message_type = atom_xdndposition; - xevent.xclient.format = 32; - xevent.xclient.data.l[0] = source_win; - xevent.xclient.data.l[1] = (3 << 24); - xevent.xclient.data.l[2] = ((x << 16) & 0xffff0000) | (y & 0xffff); - xevent.xclient.data.l[3] = CurrentTime; - if (dnd_copy) - xevent.xclient.data.l[4] = atom_xdndactioncopy; - else if (dnd_link) - xevent.xclient.data.l[4] = atom_xdndactionlink; - else if (dnd_move) - xevent.xclient.data.l[4] = atom_xdndactionmove; - else - xevent.xclient.data.l[4] = atom_xdndactionask; - XSendEvent(disp, win, False, 0, &xevent); - } - if (!dragging) - { - if (win) - { - if (current_dnd_target_ok) - { - xevent.xany.type = ClientMessage; - xevent.xany.display = disp; - xevent.xclient.window = win; - xevent.xclient.message_type = atom_xdnddrop; - xevent.xclient.format = 32; - xevent.xclient.data.l[0] = source_win; - xevent.xclient.data.l[1] = 0; - xevent.xclient.data.l[2] = CurrentTime; - xevent.xclient.data.l[3] = 0; - xevent.xclient.data.l[4] = 0; - XSendEvent(disp, win, False, 0, &xevent); - } - else - { - xevent.xany.type = ClientMessage; - xevent.xany.display = disp; - xevent.xclient.window = win; - xevent.xclient.message_type = atom_xdndleave; - xevent.xclient.format = 32; - xevent.xclient.data.l[0] = source_win; - xevent.xclient.data.l[1] = 0; - xevent.xclient.data.l[2] = 0; - xevent.xclient.data.l[3] = 0; - xevent.xclient.data.l[4] = 0; - XSendEvent(disp, win, False, 0, &xevent); - } - } - current_dnd_target_ok = 0; - } - current_dnd_win = win; + win = ecore_window_get_at_xy(x, y); + while ((win) && (!ecore_window_dnd_capable(win))) + win = ecore_window_get_parent(win); + ECORE_ATOM(atom_xdndenter, "XdndEnter"); + ECORE_ATOM(atom_xdndleave, "XdndLeave"); + ECORE_ATOM(atom_xdnddrop, "XdndDrop"); + ECORE_ATOM(atom_xdndposition, "XdndPosition"); + ECORE_ATOM(atom_xdndactioncopy, "XdndActionCopy"); + ECORE_ATOM(atom_xdndactionmove, "XdndActionMove"); + ECORE_ATOM(atom_xdndactionlink, "XdndActionLink"); + ECORE_ATOM(atom_xdndactionask, "XdndActionAsk"); + ECORE_ATOM(atom_text_uri_list, "text/uri-list"); + ECORE_ATOM(atom_text_plain, "text/plain"); + if ((win != current_dnd_win) && (current_dnd_win)) + { + /* send leave to old dnd win */ + xevent.xany.type = ClientMessage; + xevent.xany.display = disp; + xevent.xclient.format = 32; + xevent.xclient.window = current_dnd_win; + xevent.xclient.message_type = atom_xdndleave; + xevent.xclient.data.l[0] = source_win; + xevent.xclient.data.l[1] = 0; + xevent.xclient.data.l[2] = 0; + xevent.xclient.data.l[3] = 0; + xevent.xclient.data.l[4] = 0; + XSendEvent(disp, current_dnd_win, False, 0, &xevent); + } + if (win) + { + if (win != current_dnd_win) + { + /* send enter on new win */ + xevent.xany.type = ClientMessage; + xevent.xany.display = disp; + xevent.xclient.window = win; + xevent.xclient.message_type = atom_xdndenter; + xevent.xclient.format = 32; + xevent.xclient.data.l[0] = source_win; + xevent.xclient.data.l[1] = (3 << 24); + xevent.xclient.data.l[2] = atom_text_uri_list; + xevent.xclient.data.l[3] = atom_text_plain; + xevent.xclient.data.l[4] = 0; + XSendEvent(disp, win, False, 0, &xevent); + } + /* send position information */ + xevent.xany.type = ClientMessage; + xevent.xany.display = disp; + xevent.xclient.window = win; + xevent.xclient.message_type = atom_xdndposition; + xevent.xclient.format = 32; + xevent.xclient.data.l[0] = source_win; + xevent.xclient.data.l[1] = (3 << 24); + xevent.xclient.data.l[2] = ((x << 16) & 0xffff0000) | (y & 0xffff); + xevent.xclient.data.l[3] = CurrentTime; + if (dnd_copy) + xevent.xclient.data.l[4] = atom_xdndactioncopy; + else if (dnd_link) + xevent.xclient.data.l[4] = atom_xdndactionlink; + else if (dnd_move) + xevent.xclient.data.l[4] = atom_xdndactionmove; + else + xevent.xclient.data.l[4] = atom_xdndactionask; + XSendEvent(disp, win, False, 0, &xevent); + } + if (!dragging) + { + if (win) + { + if (current_dnd_target_ok) + { + xevent.xany.type = ClientMessage; + xevent.xany.display = disp; + xevent.xclient.window = win; + xevent.xclient.message_type = atom_xdnddrop; + xevent.xclient.format = 32; + xevent.xclient.data.l[0] = source_win; + xevent.xclient.data.l[1] = 0; + xevent.xclient.data.l[2] = CurrentTime; + xevent.xclient.data.l[3] = 0; + xevent.xclient.data.l[4] = 0; + XSendEvent(disp, win, False, 0, &xevent); + } + else + { + xevent.xany.type = ClientMessage; + xevent.xany.display = disp; + xevent.xclient.window = win; + xevent.xclient.message_type = atom_xdndleave; + xevent.xclient.format = 32; + xevent.xclient.data.l[0] = source_win; + xevent.xclient.data.l[1] = 0; + xevent.xclient.data.l[2] = 0; + xevent.xclient.data.l[3] = 0; + xevent.xclient.data.l[4] = 0; + XSendEvent(disp, win, False, 0, &xevent); + } + } + current_dnd_target_ok = 0; + } + current_dnd_win = win; } int -e_dnd_selection_convert(Window win, Window req, Atom type) +ecore_dnd_selection_convert(Window win, Window req, Atom type) { - static Atom atom_xdndselection = 0; - static Atom atom_jxselectionwindowproperty = 0; + static Atom atom_xdndselection = 0; + static Atom atom_jxselectionwindowproperty = 0; - E_ATOM(atom_xdndselection, "XdndSelection"); - E_ATOM(atom_jxselectionwindowproperty, "JXSelectionWindowProperty"); - if (win == XGetSelectionOwner(disp, atom_xdndselection)) - { - XConvertSelection(disp, atom_xdndselection, type, - atom_jxselectionwindowproperty, req, CurrentTime); - return 1; - } - return 0; + ECORE_ATOM(atom_xdndselection, "XdndSelection"); + ECORE_ATOM(atom_jxselectionwindowproperty, "JXSelectionWindowProperty"); + if (win == XGetSelectionOwner(disp, atom_xdndselection)) + { + XConvertSelection(disp, atom_xdndselection, type, + atom_jxselectionwindowproperty, req, CurrentTime); + return 1; + } + return 0; } void * -e_dnd_selection_get(Window win, Window req, Atom type, int *size) +ecore_dnd_selection_get(Window win, Window req, Atom type, int *size) { - unsigned char *data = NULL; - long bytes_read; - unsigned long remaining = 1; + unsigned char *data = NULL; + long bytes_read; + unsigned long remaining = 1; - *size = 0; - bytes_read = 0; - while (remaining) - { - unsigned char *s; - Atom actual; - int format; - unsigned long count; + *size = 0; + bytes_read = 0; + while (remaining) + { + unsigned char *s; + Atom actual; + int format; + unsigned long count; - s = NULL; - if (XGetWindowProperty(disp, win, type, bytes_read / 4, 0x10000, 1, - AnyPropertyType, &actual, &format, &count, - &remaining, &s) != Success) - { - /* error occured */ - XFree(s); - IF_FREE(data); - *size = 0; - return NULL; - } - if (s) - { - /* got some mroe data - append it */ - bytes_read += count; - if (!data) - data = NEW(char, bytes_read); - - else - REALLOC(data, char, bytes_read); - MEMCPY(s, data + (bytes_read - count), char, count); - - XFree(s); - } - } - *size = bytes_read; - return data; - req = 0; -} - -void -e_dnd_set_data(Window win) -{ - static int atom_xdndactioncopy = 0; - static int atom_xdndactionmove = 0; - static int atom_xdndactionlink = 0; - static int atom_xdndactionask = 0; - static Atom atom_xdndactionlist = 0; - static Atom atom_xdndselection = 0; - - E_ATOM(atom_xdndactioncopy, "XdndActionCopy"); - E_ATOM(atom_xdndactionmove, "XdndActionMove"); - E_ATOM(atom_xdndactionlink, "XdndActionLink"); - E_ATOM(atom_xdndactionask, "XdndActionAsk"); - E_ATOM(atom_xdndactionlist, "XdndActionList"); - E_ATOM(atom_xdndselection, "XdndSelection"); - if (dnd_copy) - e_window_property_set(win, atom_xdndactionlist, XA_ATOM, 32, - &atom_xdndactioncopy, 1); - else if (dnd_link) - e_window_property_set(win, atom_xdndactionlist, XA_ATOM, 32, - &atom_xdndactionlink, 1); - else if (dnd_move) - e_window_property_set(win, atom_xdndactionlist, XA_ATOM, 32, - &atom_xdndactionmove, 1); - else - e_window_property_set(win, atom_xdndactionlist, XA_ATOM, 32, - &atom_xdndactionask, 1); - XSetSelectionOwner(disp, atom_xdndselection, win, CurrentTime); -} - -void -e_dnd_send_data(Window win, Window source_win, void *data, int size, - Atom dest_atom, int plain_text) -{ - XEvent xevent; - static Atom atom_text_plain = 0; - static Atom atom_text_uri_list = 0; - static Atom atom_xdndselection = 0; - Atom target; - - E_ATOM(atom_xdndselection, "XdndSelection"); - E_ATOM(atom_text_uri_list, "text/uri-list"); - E_ATOM(atom_text_plain, "text/plain"); - target = atom_text_uri_list; - if (plain_text) - target = atom_text_plain; - e_window_property_set(win, dest_atom, target, 8, data, size); - xevent.xselection.type = SelectionNotify; - xevent.xselection.property = dest_atom; - xevent.xselection.display = disp; - xevent.xselection.requestor = win; - xevent.xselection.selection = atom_xdndselection; - xevent.xselection.target = target; - xevent.xselection.time = CurrentTime; - XSendEvent(disp, win, False, 0, &xevent); - return; - source_win = 0; -} - -void -e_dnd_set_mode_copy(void) -{ - dnd_copy = 1; - dnd_link = 0; - dnd_move = 0; -} - -void -e_dnd_set_mode_link(void) -{ - dnd_copy = 0; - dnd_link = 1; - dnd_move = 0; -} - -void -e_dnd_set_mode_move(void) -{ - dnd_copy = 0; - dnd_link = 0; - dnd_move = 1; -} - -void -e_dnd_set_mode_ask(void) -{ - dnd_copy = 0; - dnd_link = 0; - dnd_move = 0; -} - -void -e_dnd_own_selection(Window win) -{ - static Atom atom_xdndselection = 0; - static Atom atom_jxselectionwindowproperty = 0; - - E_ATOM(atom_xdndselection, "XdndSelection"); - E_ATOM(atom_jxselectionwindowproperty, "JXSelectionWindowProperty"); - - if (!XSetSelectionOwner(disp, atom_xdndselection, win, CurrentTime)) - return; -} - -void -e_dnd_send_drop(Window win, Window source_win) -{ - static Atom atom_xdnddrop = 0; - XEvent xevent; - - E_ATOM(atom_xdnddrop, "XdndDrop"); - - e_dnd_own_selection(source_win); - - memset(&xevent, 0, sizeof(xevent)); - xevent.xany.type = ClientMessage; - xevent.xany.display = disp; - xevent.xclient.window = win; - xevent.xclient.message_type = atom_xdnddrop; - xevent.xclient.format = 32; - - xevent.xclient.data.l[0] = source_win; - xevent.xclient.data.l[1] = CurrentTime; - xevent.xclient.data.l[2] = 0; - xevent.xclient.data.l[3] = 0; - xevent.xclient.data.l[4] = 0; - XSendEvent(disp, win, False, 0, &xevent); -} - -void -e_window_dnd_send_status_ok(Window source_win, Window win, int x, int y, int w, - int h) -{ - static Atom atom_xdndstatus = 0; - static Atom atom_xdndactioncopy = 0; - static Atom atom_xdndactionmove = 0; - static Atom atom_xdndactionlink = 0; - static Atom atom_xdndactionask = 0; - XEvent xevent; - - E_ATOM(atom_xdndstatus, "XdndStatus"); - E_ATOM(atom_xdndactioncopy, "XdndActionCopy"); - E_ATOM(atom_xdndactionmove, "XdndActionMove"); - E_ATOM(atom_xdndactionlink, "XdndActionLink"); - E_ATOM(atom_xdndactionask, "XdndActionAsk"); - memset(&xevent, 0, sizeof(xevent)); - - xevent.xany.type = ClientMessage; - xevent.xany.display = disp; - xevent.xclient.window = win; - xevent.xclient.message_type = atom_xdndstatus; - xevent.xclient.format = 32; - - xevent.xclient.data.l[0] = source_win; - xevent.xclient.data.l[1] = 3; - xevent.xclient.data.l[2] = ((x << 16) & 0xffff0000) | (y & 0xffff); - xevent.xclient.data.l[3] = ((h << 16) & 0xffff0000) | (w & 0xffff); - if (dnd_copy) - xevent.xclient.data.l[4] = atom_xdndactioncopy; - else if (dnd_link) - xevent.xclient.data.l[4] = atom_xdndactionlink; - else if (dnd_move) - xevent.xclient.data.l[4] = atom_xdndactionmove; - else - xevent.xclient.data.l[4] = atom_xdndactionask; - XSendEvent(disp, win, False, 0, &xevent); -} - -void -e_window_dnd_send_finished(Window source_win, Window win) -{ - static Atom atom_xdndfinished = 0; - XEvent xevent; - - E_ATOM(atom_xdndfinished, "XdndFinished"); - memset(&xevent, 0, sizeof(xevent)); - - xevent.xany.type = ClientMessage; - xevent.xany.display = disp; - xevent.xclient.window = win; - xevent.xclient.message_type = atom_xdndfinished; - xevent.xclient.format = 32; - - xevent.xclient.data.l[0] = source_win; - xevent.xclient.data.l[1] = 0; - xevent.xclient.data.l[2] = 0; - xevent.xclient.data.l[3] = 0; - xevent.xclient.data.l[4] = 0; - XSendEvent(disp, win, False, 0, &xevent); -} - -void -e_window_dnd_ok(int ok) -{ - current_dnd_target_ok = ok; -} - -void -e_window_dnd_finished(void) -{ - current_dnd_win = 0; -} - -void -e_window_set_title(Window win, char *title) -{ - XStoreName(disp, win, title); -} - -void -e_window_set_name_class(Window win, char *name, char *class) -{ - XClassHint hint; - - hint.res_name = name; - hint.res_class = class; - XSetClassHint(disp, win, &hint); -} - -void -e_window_get_name_class(Window win, char **name, char **class) -{ - XClassHint xch; - - if (name) *name = NULL; - if (class) *class = NULL; - if (XGetClassHint(disp, win, &xch)) - { - if (name) - { - if (xch.res_name) *name = strdup(xch.res_name); - } - if (class) - { - if (xch.res_class) *class = strdup(xch.res_class); - } - XFree(xch.res_name); - XFree(xch.res_class); - } -} - -void -e_window_get_hints(Window win, int *accepts_focus, int *initial_state, - Pixmap *icon_pixmap, Pixmap *icon_mask, - Window *icon_window, Window *window_group) -{ - XWMHints *hints; - - hints = XGetWMHints(disp, win); - if (hints) - { - if ((hints->flags & InputHint) && (accepts_focus)) - { - if (hints->input) *accepts_focus = 1; - else *accepts_focus = 0; - } - if ((hints->flags & StateHint) && (initial_state)) - { - *initial_state = hints->initial_state; - } - if ((hints->flags & IconPixmapHint) && (icon_pixmap)) - { - *icon_pixmap = hints->icon_pixmap; - } - if ((hints->flags & IconMaskHint) && (icon_mask)) - { - *icon_mask = hints->icon_pixmap; - } - if ((hints->flags & IconWindowHint) && (icon_window)) - { - *icon_window = hints->icon_window; - } - if ((hints->flags & WindowGroupHint) && (window_group)) - { - *window_group = hints->window_group; - } - XFree(hints); - } -} - -char * -e_window_get_machine(Window win) -{ - XTextProperty xtp; - - if (XGetWMClientMachine(disp, win, &xtp)) - { - char *s; - - if (!xtp.value) return NULL; - s = strdup(xtp.value); - XFree(xtp.value); - return s; - } - return NULL; -} - -char * -e_window_get_command(Window win) -{ - int cargc; - char **cargv; - - if (XGetCommand(disp, win, &cargv, &cargc)) - { - if (cargc > 0) - { - char *s; - int size, i; - - s = NULL; - size = strlen(cargv[0]); - REALLOC(s, char, size + 1); - strcpy(s, cargv[0]); - for (i = 1; i < cargc; i++) - { - size += strlen(cargv[i]); - REALLOC(s, char, size + 2); - strcat(s, " "); - strcat(s, cargv[i]); - } - XFreeStringList(cargv); - return s; - } - else + s = NULL; + if (XGetWindowProperty(disp, win, type, bytes_read / 4, 0x10000, 1, + AnyPropertyType, &actual, &format, &count, + &remaining, &s) != Success) + { + /* error occured */ + XFree(s); + IF_FREE(data); + *size = 0; return NULL; - } - return NULL; -} + } + if (s) + { + /* got some mroe data - append it */ + bytes_read += count; + if (!data) + data = NEW(char, bytes_read); -char * -e_window_get_icon_name(Window win) -{ - XTextProperty xtp; - - if (XGetWMIconName(disp, win, &xtp)) - { - char *s; - - if (!xtp.value) return NULL; - s = strdup(xtp.value); - XFree(xtp.value); - return s; - } - return NULL; + else + REALLOC(data, char, bytes_read); + MEMCPY(s, data + (bytes_read - count), char, count); + + XFree(s); + } + } + *size = bytes_read; + return data; + req = 0; } void -e_window_set_min_size(Window win, int w, int h) +ecore_dnd_set_data(Window win) { - XSizeHints hints; - long ret; + static int atom_xdndactioncopy = 0; + static int atom_xdndactionmove = 0; + static int atom_xdndactionlink = 0; + static int atom_xdndactionask = 0; + static Atom atom_xdndactionlist = 0; + static Atom atom_xdndselection = 0; - memset(&hints, 0, sizeof(XSizeHints)); - XGetWMNormalHints(disp, win, &hints, &ret); - hints.flags |= PMinSize | PSize | USSize; - hints.min_width = w; - hints.min_height = h; - XSetWMNormalHints(disp, win, &hints); + ECORE_ATOM(atom_xdndactioncopy, "XdndActionCopy"); + ECORE_ATOM(atom_xdndactionmove, "XdndActionMove"); + ECORE_ATOM(atom_xdndactionlink, "XdndActionLink"); + ECORE_ATOM(atom_xdndactionask, "XdndActionAsk"); + ECORE_ATOM(atom_xdndactionlist, "XdndActionList"); + ECORE_ATOM(atom_xdndselection, "XdndSelection"); + if (dnd_copy) + ecore_window_property_set(win, atom_xdndactionlist, XA_ATOM, 32, + &atom_xdndactioncopy, 1); + else if (dnd_link) + ecore_window_property_set(win, atom_xdndactionlist, XA_ATOM, 32, + &atom_xdndactionlink, 1); + else if (dnd_move) + ecore_window_property_set(win, atom_xdndactionlist, XA_ATOM, 32, + &atom_xdndactionmove, 1); + else + ecore_window_property_set(win, atom_xdndactionlist, XA_ATOM, 32, + &atom_xdndactionask, 1); + XSetSelectionOwner(disp, atom_xdndselection, win, CurrentTime); } void -e_window_set_max_size(Window win, int w, int h) +ecore_dnd_send_data(Window win, Window source_win, void *data, int size, + Atom dest_atom, int plain_text) { - XSizeHints hints; - long ret; + XEvent xevent; + static Atom atom_text_plain = 0; + static Atom atom_text_uri_list = 0; + static Atom atom_xdndselection = 0; + Atom target; - memset(&hints, 0, sizeof(XSizeHints)); - XGetWMNormalHints(disp, win, &hints, &ret); - hints.flags |= PMaxSize | PSize | USSize; - hints.max_width = w; - hints.max_height = h; - XSetWMNormalHints(disp, win, &hints); + ECORE_ATOM(atom_xdndselection, "XdndSelection"); + ECORE_ATOM(atom_text_uri_list, "text/uri-list"); + ECORE_ATOM(atom_text_plain, "text/plain"); + target = atom_text_uri_list; + if (plain_text) + target = atom_text_plain; + ecore_window_property_set(win, dest_atom, target, 8, data, size); + xevent.xselection.type = SelectionNotify; + xevent.xselection.property = dest_atom; + xevent.xselection.display = disp; + xevent.xselection.requestor = win; + xevent.xselection.selection = atom_xdndselection; + xevent.xselection.target = target; + xevent.xselection.time = CurrentTime; + XSendEvent(disp, win, False, 0, &xevent); + return; + source_win = 0; } void -e_window_set_xy_hints(Window win, int x, int y) +ecore_dnd_set_mode_copy(void) { - XSizeHints hints; - long ret; - - memset(&hints, 0, sizeof(XSizeHints)); - XGetWMNormalHints(disp, win, &hints, &ret); - hints.flags |= PPosition | USPosition | PSize | USSize; - hints.x = x; - hints.y = y; - XSetWMNormalHints(disp, win, &hints); + dnd_copy = 1; + dnd_link = 0; + dnd_move = 0; } void -e_window_get_frame_size(Window win, int *l, int *r, int *t, int *b) +ecore_dnd_set_mode_link(void) { - static Atom atom_e_frame_size = 0; - int *data, size; + dnd_copy = 0; + dnd_link = 1; + dnd_move = 0; +} - E_ATOM(atom_e_frame_size, "_E_FRAME_SIZE"); - data = e_window_property_get(win, atom_e_frame_size, XA_CARDINAL, &size); - if (data) - { - if (size == (4 * sizeof(int))) - { - if (l) - *l = data[0]; - if (r) - *r = data[1]; - if (t) - *t = data[2]; - if (b) - *b = data[3]; - } - else - { - if (l) - *l = 0; - if (r) - *r = 0; - if (t) - *t = 0; - if (b) - *b = 0; - } - FREE(data); - } - else - { - if (l) - *l = 0; - if (r) - *r = 0; - if (t) - *t = 0; - if (b) - *b = 0; - } +void +ecore_dnd_set_mode_move(void) +{ + dnd_copy = 0; + dnd_link = 0; + dnd_move = 1; +} + +void +ecore_dnd_set_mode_ask(void) +{ + dnd_copy = 0; + dnd_link = 0; + dnd_move = 0; +} + +void +ecore_dnd_own_selection(Window win) +{ + static Atom atom_xdndselection = 0; + static Atom atom_jxselectionwindowproperty = 0; + + ECORE_ATOM(atom_xdndselection, "XdndSelection"); + ECORE_ATOM(atom_jxselectionwindowproperty, "JXSelectionWindowProperty"); + + if (!XSetSelectionOwner(disp, atom_xdndselection, win, CurrentTime)) + return; +} + +void +ecore_dnd_send_drop(Window win, Window source_win) +{ + static Atom atom_xdnddrop = 0; + XEvent xevent; + + ECORE_ATOM(atom_xdnddrop, "XdndDrop"); + + ecore_dnd_own_selection(source_win); + + memset(&xevent, 0, sizeof(xevent)); + xevent.xany.type = ClientMessage; + xevent.xany.display = disp; + xevent.xclient.window = win; + xevent.xclient.message_type = atom_xdnddrop; + xevent.xclient.format = 32; + + xevent.xclient.data.l[0] = source_win; + xevent.xclient.data.l[1] = CurrentTime; + xevent.xclient.data.l[2] = 0; + xevent.xclient.data.l[3] = 0; + xevent.xclient.data.l[4] = 0; + XSendEvent(disp, win, False, 0, &xevent); +} + +void +ecore_window_dnd_send_status_ok(Window source_win, Window win, int x, int y, + int w, int h) +{ + static Atom atom_xdndstatus = 0; + static Atom atom_xdndactioncopy = 0; + static Atom atom_xdndactionmove = 0; + static Atom atom_xdndactionlink = 0; + static Atom atom_xdndactionask = 0; + XEvent xevent; + + ECORE_ATOM(atom_xdndstatus, "XdndStatus"); + ECORE_ATOM(atom_xdndactioncopy, "XdndActionCopy"); + ECORE_ATOM(atom_xdndactionmove, "XdndActionMove"); + ECORE_ATOM(atom_xdndactionlink, "XdndActionLink"); + ECORE_ATOM(atom_xdndactionask, "XdndActionAsk"); + memset(&xevent, 0, sizeof(xevent)); + + xevent.xany.type = ClientMessage; + xevent.xany.display = disp; + xevent.xclient.window = win; + xevent.xclient.message_type = atom_xdndstatus; + xevent.xclient.format = 32; + + xevent.xclient.data.l[0] = source_win; + xevent.xclient.data.l[1] = 3; + xevent.xclient.data.l[2] = ((x << 16) & 0xffff0000) | (y & 0xffff); + xevent.xclient.data.l[3] = ((h << 16) & 0xffff0000) | (w & 0xffff); + if (dnd_copy) + xevent.xclient.data.l[4] = atom_xdndactioncopy; + else if (dnd_link) + xevent.xclient.data.l[4] = atom_xdndactionlink; + else if (dnd_move) + xevent.xclient.data.l[4] = atom_xdndactionmove; + else + xevent.xclient.data.l[4] = atom_xdndactionask; + XSendEvent(disp, win, False, 0, &xevent); +} + +void +ecore_window_dnd_send_finished(Window source_win, Window win) +{ + static Atom atom_xdndfinished = 0; + XEvent xevent; + + ECORE_ATOM(atom_xdndfinished, "XdndFinished"); + memset(&xevent, 0, sizeof(xevent)); + + xevent.xany.type = ClientMessage; + xevent.xany.display = disp; + xevent.xclient.window = win; + xevent.xclient.message_type = atom_xdndfinished; + xevent.xclient.format = 32; + + xevent.xclient.data.l[0] = source_win; + xevent.xclient.data.l[1] = 0; + xevent.xclient.data.l[2] = 0; + xevent.xclient.data.l[3] = 0; + xevent.xclient.data.l[4] = 0; + XSendEvent(disp, win, False, 0, &xevent); +} + +void +ecore_window_dnd_ok(int ok) +{ + current_dnd_target_ok = ok; +} + +void +ecore_window_dnd_finished(void) +{ + current_dnd_win = 0; +} + +void +ecore_window_set_title(Window win, char *title) +{ + XStoreName(disp, win, title); +} + +void +ecore_window_set_name_class(Window win, char *name, char *class) +{ + XClassHint hint; + + hint.res_name = name; + hint.res_class = class; + XSetClassHint(disp, win, &hint); +} + +void +ecore_window_get_name_class(Window win, char **name, char **class) +{ + XClassHint xch; + + if (name) + *name = NULL; + if (class) + *class = NULL; + if (XGetClassHint(disp, win, &xch)) + { + if (name) + { + if (xch.res_name) + *name = strdup(xch.res_name); + } + if (class) + { + if (xch.res_class) + *class = strdup(xch.res_class); + } + XFree(xch.res_name); + XFree(xch.res_class); + } +} + +void +ecore_window_get_hints(Window win, int *accepts_focus, int *initial_state, + Pixmap * icon_pixmap, Pixmap * icon_mask, + Window * icon_window, Window * window_group) +{ + XWMHints *hints; + + hints = XGetWMHints(disp, win); + if (hints) + { + if ((hints->flags & InputHint) && (accepts_focus)) + { + if (hints->input) + *accepts_focus = 1; + else + *accepts_focus = 0; + } + if ((hints->flags & StateHint) && (initial_state)) + { + *initial_state = hints->initial_state; + } + if ((hints->flags & IconPixmapHint) && (icon_pixmap)) + { + *icon_pixmap = hints->icon_pixmap; + } + if ((hints->flags & IconMaskHint) && (icon_mask)) + { + *icon_mask = hints->icon_pixmap; + } + if ((hints->flags & IconWindowHint) && (icon_window)) + { + *icon_window = hints->icon_window; + } + if ((hints->flags & WindowGroupHint) && (window_group)) + { + *window_group = hints->window_group; + } + XFree(hints); + } +} + +char * +ecore_window_get_machine(Window win) +{ + XTextProperty xtp; + + if (XGetWMClientMachine(disp, win, &xtp)) + { + char *s; + + if (!xtp.value) + return NULL; + s = strdup(xtp.value); + XFree(xtp.value); + return s; + } + return NULL; +} + +char * +ecore_window_get_command(Window win) +{ + int cargc; + char **cargv; + + if (XGetCommand(disp, win, &cargv, &cargc)) + { + if (cargc > 0) + { + char *s; + int size, i; + + s = NULL; + size = strlen(cargv[0]); + REALLOC(s, char, size + 1); + + strcpy(s, cargv[0]); + for (i = 1; i < cargc; i++) + { + size += strlen(cargv[i]); + REALLOC(s, char, size + 2); + + strcat(s, " "); + strcat(s, cargv[i]); + } + XFreeStringList(cargv); + return s; + } + else + return NULL; + } + return NULL; +} + +char * +ecore_window_get_icon_name(Window win) +{ + XTextProperty xtp; + + if (XGetWMIconName(disp, win, &xtp)) + { + char *s; + + if (!xtp.value) + return NULL; + s = strdup(xtp.value); + XFree(xtp.value); + return s; + } + return NULL; +} + +void +ecore_window_set_min_size(Window win, int w, int h) +{ + XSizeHints hints; + long ret; + + memset(&hints, 0, sizeof(XSizeHints)); + XGetWMNormalHints(disp, win, &hints, &ret); + hints.flags |= PMinSize | PSize | USSize; + hints.min_width = w; + hints.min_height = h; + XSetWMNormalHints(disp, win, &hints); +} + +void +ecore_window_set_max_size(Window win, int w, int h) +{ + XSizeHints hints; + long ret; + + memset(&hints, 0, sizeof(XSizeHints)); + XGetWMNormalHints(disp, win, &hints, &ret); + hints.flags |= PMaxSize | PSize | USSize; + hints.max_width = w; + hints.max_height = h; + XSetWMNormalHints(disp, win, &hints); +} + +void +ecore_window_set_xy_hints(Window win, int x, int y) +{ + XSizeHints hints; + long ret; + + memset(&hints, 0, sizeof(XSizeHints)); + XGetWMNormalHints(disp, win, &hints, &ret); + hints.flags |= PPosition | USPosition | PSize | USSize; + hints.x = x; + hints.y = y; + XSetWMNormalHints(disp, win, &hints); +} + +void +ecore_window_get_frame_size(Window win, int *l, int *r, int *t, int *b) +{ + static Atom atom_e_frame_size = 0; + int *data, size; + + ECORE_ATOM(atom_e_frame_size, "_E_FRAME_SIZE"); + data = ecore_window_property_get(win, atom_e_frame_size, XA_CARDINAL, &size); + if (data) + { + if (size == (4 * sizeof(int))) + { + if (l) + *l = data[0]; + if (r) + *r = data[1]; + if (t) + *t = data[2]; + if (b) + *b = data[3]; + } + else + { + if (l) + *l = 0; + if (r) + *r = 0; + if (t) + *t = 0; + if (b) + *b = 0; + } + FREE(data); + } + else + { + if (l) + *l = 0; + if (r) + *r = 0; + if (t) + *t = 0; + if (b) + *b = 0; + } } int -e_window_save_under(Window win) +ecore_window_save_under(Window win) { - XSetWindowAttributes att; - XWindowAttributes gatt; + XSetWindowAttributes att; + XWindowAttributes gatt; - att.save_under = True; - XChangeWindowAttributes(disp, win, CWSaveUnder, &att); - XGetWindowAttributes(disp, win, &gatt); - if (gatt.save_under == True) - return 1; - return 0; + att.save_under = True; + XChangeWindowAttributes(disp, win, CWSaveUnder, &att); + XGetWindowAttributes(disp, win, &gatt); + return (gatt.save_under == True) ? 1 : 0; } GC -e_gc_new(Drawable d) +ecore_gc_new(Drawable d) { - XGCValues gcv; + XGCValues gcv; - if (d == 0) - d = default_root; - return XCreateGC(disp, d, 0, &gcv); + if (d == 0) + d = default_root; + return XCreateGC(disp, d, 0, &gcv); } void -e_gc_free(GC gc) +ecore_gc_free(GC gc) { - XFreeGC(disp, gc); + XFreeGC(disp, gc); } void -e_gc_set_fg(GC gc, int val) +ecore_gc_set_fg(GC gc, int val) { - XSetForeground(disp, gc, val); + XSetForeground(disp, gc, val); } void -e_fill_rectangle(Drawable d, GC gc, int x, int y, int w, int h) +ecore_fill_rectangle(Drawable d, GC gc, int x, int y, int w, int h) { - XFillRectangle(disp, d, gc, x, y, w, h); + XFillRectangle(disp, d, gc, x, y, w, h); } void -e_draw_rectangle(Drawable d, GC gc, int x, int y, int w, int h) +ecore_draw_rectangle(Drawable d, GC gc, int x, int y, int w, int h) { - XDrawRectangle(disp, d, gc, x, y, w - 1, h - 1); + XDrawRectangle(disp, d, gc, x, y, w - 1, h - 1); } void -e_draw_line(Drawable d, GC gc, int x1, int y1, int x2, int y2) +ecore_draw_line(Drawable d, GC gc, int x1, int y1, int x2, int y2) { - XDrawLine(disp, d, gc, x1, y1, x2, y2); + XDrawLine(disp, d, gc, x1, y1, x2, y2); } void -e_draw_point(Drawable d, GC gc, int x, int y) +ecore_draw_point(Drawable d, GC gc, int x, int y) { - XDrawPoint(disp, d, gc, x, y); + XDrawPoint(disp, d, gc, x, y); } void -e_window_hint_set_layer(Window win, int layer) +ecore_window_hint_set_layer(Window win, int layer) { - static Atom atom_win_layer = 0; + static Atom atom_win_layer = 0; - E_ATOM(atom_win_layer, "_WIN_LAYER"); - e_window_property_set(win, atom_win_layer, XA_CARDINAL, 32, &layer, 1); + ECORE_ATOM(atom_win_layer, "_WIN_LAYER"); + ecore_window_property_set(win, atom_win_layer, XA_CARDINAL, 32, &layer, 1); } void -e_window_hint_set_sticky(Window win, int sticky) +ecore_window_hint_set_sticky(Window win, int sticky) { - static Atom atom_win_state = 0; - static Atom atom_win_hints = 0; - int data; + static Atom atom_win_state = 0; + static Atom atom_win_hints = 0; + int data; - E_ATOM(atom_win_state, "_WIN_STATE"); - E_ATOM(atom_win_hints, "_WIN_HINTS"); - if (sticky) - { - data = ((1 << 0) | (1 << 8) | (1 << 9)); - e_window_property_set(win, atom_win_state, XA_CARDINAL, 32, &data, 1); - data = ((1 << 0) | (1 << 1) | (1 << 2)); - e_window_property_set(win, atom_win_hints, XA_CARDINAL, 32, &data, 1); - } - else - { - data = 0; - e_window_property_set(win, atom_win_state, XA_CARDINAL, 32, &data, 1); - e_window_property_set(win, atom_win_hints, XA_CARDINAL, 32, &data, 1); - } + ECORE_ATOM(atom_win_state, "_WIN_STATE"); + ECORE_ATOM(atom_win_hints, "_WIN_HINTS"); + if (sticky) + { + data = ((1 << 0) | (1 << 8) | (1 << 9)); + ecore_window_property_set(win, atom_win_state, XA_CARDINAL, 32, &data, 1); + data = ((1 << 0) | (1 << 1) | (1 << 2)); + ecore_window_property_set(win, atom_win_hints, XA_CARDINAL, 32, &data, 1); + } + else + { + data = 0; + ecore_window_property_set(win, atom_win_state, XA_CARDINAL, 32, &data, 1); + ecore_window_property_set(win, atom_win_hints, XA_CARDINAL, 32, &data, 1); + } } void -e_window_hint_set_borderless(Window win) +ecore_window_hint_set_borderless(Window win) { - static Atom atom_motif_wm_hints = 0; - int data[5]; + static Atom atom_motif_wm_hints = 0; + int data[5]; - E_ATOM(atom_motif_wm_hints, "_MOTIF_WM_HINTS"); - data[0] = 0x3; - data[1] = 0x0; - data[2] = 0x0; - data[3] = 0x2ada27b0; - data[4] = 0x2aabd6b0; - e_window_property_set(win, atom_motif_wm_hints, atom_motif_wm_hints, 32, - data, 5); + ECORE_ATOM(atom_motif_wm_hints, "_MOTIF_WM_HINTS"); + data[0] = 0x3; + data[1] = 0x0; + data[2] = 0x0; + data[3] = 0x2ada27b0; + data[4] = 0x2aabd6b0; + ecore_window_property_set(win, atom_motif_wm_hints, atom_motif_wm_hints, 32, + data, 5); } void -e_grab_mouse(Window win, int confine, Cursor cursor) +ecore_grab_mouse(Window win, int confine, Cursor cursor) { - int ret; + int ret; - if (confine) - ret = XGrabPointer(disp, win, False, - XEV_BUTTON | XEV_MOUSE_MOVE | XEV_IN_OUT, - GrabModeAsync, GrabModeAsync, - win, cursor, CurrentTime); - else - ret = XGrabPointer(disp, win, False, - XEV_BUTTON | XEV_MOUSE_MOVE | XEV_IN_OUT, - GrabModeAsync, GrabModeAsync, - None, cursor, CurrentTime); - if (ret == GrabSuccess) - grab_pointer_win = win; + if (confine) + ret = XGrabPointer(disp, win, False, + XEV_BUTTON | XEV_MOUSE_MOVE | XEV_IN_OUT, + GrabModeAsync, GrabModeAsync, win, cursor, CurrentTime); + else + ret = XGrabPointer(disp, win, False, + XEV_BUTTON | XEV_MOUSE_MOVE | XEV_IN_OUT, + GrabModeAsync, GrabModeAsync, None, cursor, CurrentTime); + if (ret == GrabSuccess) + grab_pointer_win = win; } void -e_ungrab_mouse(void) +ecore_ungrab_mouse(void) { - XUngrabPointer(disp, CurrentTime); - grab_pointer_win = 0; + XUngrabPointer(disp, CurrentTime); + grab_pointer_win = 0; } Window -e_grab_window_get(void) +ecore_grab_window_get(void) { - return grab_pointer_win; + return grab_pointer_win; } int -e_window_get_gravity(Window win) +ecore_window_get_gravity(Window win) { - XWindowAttributes att; - - XGetWindowAttributes(disp, win, &att); - return att.win_gravity; + XWindowAttributes att; + + XGetWindowAttributes(disp, win, &att); + return att.win_gravity; } void -e_window_gravity_reset(Window win) +ecore_window_gravity_reset(Window win) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; + + xid = ecore_validate_xid(win); + if (xid) + { + XSetWindowAttributes att; - xid = e_validate_xid(win); - if (xid) - { - XSetWindowAttributes att; - /* if (xid->gravity != NorthWestGravity)*/ - { - att.win_gravity = NorthWestGravity; - XChangeWindowAttributes(disp, win, CWWinGravity, &att); - xid->gravity = NorthWestGravity; - xid->coords_invalid = 1; - } - } + { + att.win_gravity = NorthWestGravity; + XChangeWindowAttributes(disp, win, CWWinGravity, &att); + xid->gravity = NorthWestGravity; + xid->coords_invalid = 1; + } + } } void -e_window_gravity_set(Window win, int gravity) +ecore_window_gravity_set(Window win, int gravity) { - E_XID *xid = NULL; + Ecore_XID *xid = NULL; - xid = e_validate_xid(win); - if (xid) - { + xid = ecore_validate_xid(win); + if (xid) + { /* if (xid->gravity != gravity)*/ - { - XSetWindowAttributes att; - - att.win_gravity = gravity; - XChangeWindowAttributes(disp, win, CWWinGravity, &att); - xid->gravity = gravity; - xid->coords_invalid = 1; - } - } -} - -void -e_window_bit_gravity_set(Window win, int gravity) -{ - E_XID *xid = NULL; - - xid = e_validate_xid(win); - if (xid) - { + { XSetWindowAttributes att; - - att.bit_gravity = gravity; - XChangeWindowAttributes(disp, win, CWBitGravity, &att); - } + + att.win_gravity = gravity; + XChangeWindowAttributes(disp, win, CWWinGravity, &att); + xid->gravity = gravity; + xid->coords_invalid = 1; + } + } } void -e_pointer_warp_by(int dx, int dy) +ecore_window_bit_gravity_set(Window win, int gravity) { - XWarpPointer(disp, None, None, 0, 0, 0, 0, dx, dy); + Ecore_XID *xid = NULL; + + xid = ecore_validate_xid(win); + if (xid) + { + XSetWindowAttributes att; + + att.bit_gravity = gravity; + XChangeWindowAttributes(disp, win, CWBitGravity, &att); + } } void -e_pointer_warp_to(int x, int y) +ecore_pointer_warp_by(int dx, int dy) { - XWarpPointer(disp, None, default_root, 0, 0, 0, 0, x, y); + XWarpPointer(disp, None, None, 0, 0, 0, 0, dx, dy); } void -e_gc_set_include_inferiors(GC gc) +ecore_pointer_warp_to(int x, int y) { - XGCValues gcv; - - gcv.subwindow_mode = IncludeInferiors; - XChangeGC(disp, gc, GCSubwindowMode, &gcv); + XWarpPointer(disp, None, default_root, 0, 0, 0, 0, x, y); } void -e_area_copy(Drawable src, Drawable dest, GC gc, - int sx, int sy, int sw, int sh, int dx, int dy) +ecore_gc_set_include_inferiors(GC gc) { - if (src == 0) - src = default_root; - if (dest == 0) - dest = default_root; - XCopyArea(disp, src, dest, gc, sx, sy, sw, sh, dx, dy); -} + XGCValues gcv; -Window e_window_root(void) -{ - return default_root; + gcv.subwindow_mode = IncludeInferiors; + XChangeGC(disp, gc, GCSubwindowMode, &gcv); } void -e_window_get_virtual_area(Window win, int *area_x, int *area_y) +ecore_area_copy(Drawable src, Drawable dest, GC gc, + int sx, int sy, int sw, int sh, int dx, int dy) { - static Atom atom_win_area = 0; - int *data, size; - - E_ATOM(atom_win_area, "_WIN_AREA"); - data = e_window_property_get(win, atom_win_area, XA_CARDINAL, &size); - if (data) - { - if (size == (sizeof(int) * 2)) - { - if (area_x) - *area_x = data[0]; - if (area_y) - *area_y = data[1]; - } - FREE(data); - } -} - -void -e_get_virtual_area(int *area_x, int *area_y) -{ - static Atom atom_win_area = 0; - int *data, size; - - E_ATOM(atom_win_area, "_WIN_AREA"); - data = - e_window_property_get(default_root, atom_win_area, XA_CARDINAL, &size); - if (data) - { - if (size == (sizeof(int) * 2)) - { - if (area_x) - *area_x = data[0]; - if (area_y) - *area_y = data[1]; - } - FREE(data); - } -} - -void -e_window_get_root_relative_location(Window win, int *x, int *y) -{ - int dx, dy; - Window parent; - E_XID *xid = NULL; - - if (win == 0) - win = default_root; - if (win == default_root) - { - if (x) *x = 0; - if (y) *y = 0; - return; - } - xid = e_validate_xid(win); - if (!xid) - { - if (x) *x = 0; - if (y) *y = 0; - return; - } - dx = 0; - dy = 0; - do - { - parent = xid->parent; - dx += xid->x; - dy += xid->y; - if (parent != default_root) - { - xid = e_validate_xid(parent); - if (!xid) - { - if (x) *x = dx; - if (y) *y = dy; - return; - } - } - } - while (parent != default_root); - if (x) *x = dx; - if (y) *y = dy; -} - -void -e_window_button_grab_auto_replay_set(Window win, int on) -{ - E_XID *xid = NULL; - - xid = e_validate_xid(win); - if (!xid) return; - xid->grab_button_auto_replay = on; -} - -int -e_window_button_grab_auto_replay_get(Window win) -{ - E_XID *xid = NULL; - - xid = e_validate_xid(win); - if (!xid) return 0; - return xid->grab_button_auto_replay; -} - -void -e_button_grab(Window win, int button, int events, Ev_Key_Modifiers mod, int any_mod) -{ - unsigned int b; - unsigned int m; - unsigned int locks[8]; - int i; - - b = button; - if (b == 0) b = AnyButton; - m = 0; - if (any_mod) m = AnyModifier; - else - { - if (mod & EV_KEY_MODIFIER_SHIFT) m |= e_mod_mask_shift_get(); - if (mod & EV_KEY_MODIFIER_CTRL) m |= e_mod_mask_ctrl_get(); - if (mod & EV_KEY_MODIFIER_ALT) m |= e_mod_mask_alt_get(); - if (mod & EV_KEY_MODIFIER_WIN) m |= e_mod_mask_win_get(); - } - locks[0] = 0; - locks[1] = e_lock_mask_caps_get(); - locks[2] = e_lock_mask_num_get(); - locks[3] = e_lock_mask_scroll_get(); - locks[4] = e_lock_mask_caps_get() | e_lock_mask_num_get(); - locks[5] = e_lock_mask_caps_get() | e_lock_mask_scroll_get(); - locks[6] = e_lock_mask_num_get() | e_lock_mask_scroll_get(); - locks[7] = e_lock_mask_caps_get() | e_lock_mask_num_get() | e_lock_mask_scroll_get(); - for (i = 0; i < 8; i++) - XGrabButton(disp, b, m | locks[i], - win, False, events, - GrabModeSync, GrabModeAsync, None, None); -} - -void -e_button_ungrab(Window win, int button, Ev_Key_Modifiers mod, int any_mod) -{ - unsigned int b; - unsigned int m; - unsigned int locks[8]; - int i; - - b = button; - if (b == 0) b = AnyButton; - m = 0; - if (any_mod) m = AnyModifier; - else - { - if (mod & EV_KEY_MODIFIER_SHIFT) m |= e_mod_mask_shift_get(); - if (mod & EV_KEY_MODIFIER_CTRL) m |= e_mod_mask_ctrl_get(); - if (mod & EV_KEY_MODIFIER_ALT) m |= e_mod_mask_alt_get(); - if (mod & EV_KEY_MODIFIER_WIN) m |= e_mod_mask_win_get(); - } - locks[0] = 0; - locks[1] = e_lock_mask_caps_get(); - locks[2] = e_lock_mask_num_get(); - locks[3] = e_lock_mask_scroll_get(); - locks[4] = e_lock_mask_caps_get() | e_lock_mask_num_get(); - locks[5] = e_lock_mask_caps_get() | e_lock_mask_scroll_get(); - locks[6] = e_lock_mask_num_get() | e_lock_mask_scroll_get(); - locks[7] = e_lock_mask_caps_get() | e_lock_mask_num_get() | e_lock_mask_scroll_get(); - for (i = 0; i < 8; i++) - XUngrabButton(disp, b, m | locks[i], win); -} - -void -e_pointer_replay(Time t) -{ - XSync(disp, False); - XAllowEvents(disp, ReplayPointer, t); - XSync(disp, False); -} - -void -e_pointer_grab(Window win, Time t) -{ - XGrabPointer(disp, win, False, XEV_BUTTON | XEV_MOUSE_MOVE | XEV_IN_OUT, - GrabModeAsync, GrabModeAsync, None, None, t); -} - -void -e_pointer_ungrab(Time t) -{ - XUngrabPointer(disp, t); -} - -void -e_window_send_event_move_resize(Window win, int x, int y, int w, int h) -{ - XEvent ev; - - ev.type = ConfigureNotify; - ev.xconfigure.display = disp; - ev.xconfigure.event = win; - ev.xconfigure.window = win; - ev.xconfigure.x = x; - ev.xconfigure.y = y; - ev.xconfigure.width = w; - ev.xconfigure.height = h; - ev.xconfigure.border_width = 0; - ev.xconfigure.above = win; - ev.xconfigure.override_redirect = False; - XSendEvent(disp, win, False, StructureNotifyMask, &ev); -} - -void -e_window_send_client_message(Window win, Atom type, int format, void *data) -{ - XClientMessageEvent ev; - int i; - - ev.type = ClientMessage; - ev.window = win; - ev.message_type = type; - ev.format = format; - if (format == 32) - { - for (i = 0; i < 5; i++) - ev.data.l[i] = ((unsigned int *)data)[i]; - } - else if (format == 16) - { - for (i = 0; i < 10; i++) - ev.data.s[i] = ((unsigned short *)data)[i]; - } - else if (format == 8) - { - for (i = 0; i < 20; i++) - ev.data.b[i] = ((unsigned char *)data)[i]; - } - XSendEvent(disp, win, False, 0, (XEvent *) & ev); -} - -void -e_window_add_to_save_set(Window win) -{ - XAddToSaveSet(disp, win); -} - -void -e_window_del_from_save_set(Window win) -{ - XRemoveFromSaveSet(disp, win); -} - -void -e_window_kill_client(Window win) -{ - XKillClient(disp, (XID)win); -} - -void -e_window_set_border_width(Window win, int bw) -{ - E_XID *xid = NULL; - - xid = e_validate_xid(win); - if (xid) - { - xid->bw = bw; - } - XSetWindowBorderWidth(disp, win, bw); -} - -int -e_window_get_border_width(Window win) -{ - E_XID *xid = NULL; - - xid = e_validate_xid(win); - if (xid) - { - return xid->bw; - } - return 0; -} - -int -e_window_get_wm_size_hints(Window win, XSizeHints *hints, int *mask) -{ - long sup_ret; - Status ok; - - ok = XGetWMNormalHints(disp, win, hints, &sup_ret); - *mask = (int)sup_ret; - return ok; -} - -int -e_window_is_visible(Window win) -{ - XWindowAttributes att; - - if (win == 0) - win = default_root; - if (XGetWindowAttributes(disp, win, &att) == True) - { - if (att.map_state == IsUnmapped) return 0; - return 1; - } - return 0; -} - -int -e_window_is_normal(Window win) -{ - XWindowAttributes att; - - if (win == 0) - win = default_root; - if (XGetWindowAttributes(disp, win, &att) == True) - { - if ((att.override_redirect) || (att.class == InputOnly)) return 0; - return 1; - } - return 0; -} - -int -e_window_is_manageable(Window win) -{ - XWindowAttributes att; - - if (win == 0) - win = default_root; - if (XGetWindowAttributes(disp, win, &att) == True) - { - if ((att.map_state == IsUnmapped) || (att.override_redirect) || (att.class == InputOnly)) return 0; - return 1; - } - return 0; -} - -void -e_windows_restack(Window *wins, int num) -{ - XRestackWindows(disp, wins, num); -} - -void -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); -} - -void -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); + if (src == 0) + src = default_root; + if (dest == 0) + dest = default_root; + XCopyArea(disp, src, dest, gc, sx, sy, sw, sh, dx, dy); } Window -e_selection_set(char *string) +ecore_window_root(void) { - Window target = 0; - static Atom dest = 0; - Atom selection; - - selection = X_CLIPBOARD_SELECTION; - E_ATOM(dest, "TEXT_SELECTION"); - target = e_window_new(0, 0, 0, 77, 7); - e_window_add_events(target, XEV_CONFIGURE | XEV_PROPERTY); - XSetSelectionOwner(disp, selection, target, CurrentTime); - if (XGetSelectionOwner(disp, XA_PRIMARY) != target) - { - e_window_destroy(target); + return default_root; +} + +void +ecore_window_get_virtual_area(Window win, int *area_x, int *area_y) +{ + static Atom atom_win_area = 0; + int *data, size; + + ECORE_ATOM(atom_win_area, "_WIN_AREA"); + data = ecore_window_property_get(win, atom_win_area, XA_CARDINAL, &size); + if (data) + { + if (size == (sizeof(int) * 2)) + { + if (area_x) + *area_x = data[0]; + if (area_y) + *area_y = data[1]; + } + FREE(data); + } +} + +void +ecore_get_virtual_area(int *area_x, int *area_y) +{ + static Atom atom_win_area = 0; + int *data, size; + + ECORE_ATOM(atom_win_area, "_WIN_AREA"); + data = + ecore_window_property_get(default_root, atom_win_area, XA_CARDINAL, &size); + if (data) + { + if (size == (sizeof(int) * 2)) + { + if (area_x) + *area_x = data[0]; + if (area_y) + *area_y = data[1]; + } + FREE(data); + } +} + +void +ecore_window_get_root_relative_location(Window win, int *x, int *y) +{ + int dx, dy; + Window parent; + Ecore_XID *xid = NULL; + + if (win == 0) + win = default_root; + if (win == default_root) + { + if (x) + *x = 0; + if (y) + *y = 0; + return; + } + xid = ecore_validate_xid(win); + if (!xid) + { + if (x) + *x = 0; + if (y) + *y = 0; + return; + } + dx = 0; + dy = 0; + do + { + parent = xid->parent; + dx += xid->x; + dy += xid->y; + if (parent != default_root) + { + xid = ecore_validate_xid(parent); + if (!xid) + { + if (x) + *x = dx; + if (y) + *y = dy; + return; + } + } + } + while (parent != default_root); + if (x) + *x = dx; + if (y) + *y = dy; +} + +void +ecore_window_button_grab_auto_replay_set(Window win, int on) +{ + Ecore_XID *xid = NULL; + + xid = ecore_validate_xid(win); + if (!xid) return; + xid->grab_button_auto_replay = on; +} + +int +ecore_window_button_grab_auto_replay_get(Window win) +{ + Ecore_XID *xid = NULL; + + xid = ecore_validate_xid(win); + if (!xid) return 0; + return xid->grab_button_auto_replay; +} + +void +ecore_button_grab(Window win, int button, int events, + Ecore_Event_Key_Modifiers mod, int any_mod) +{ + unsigned int b; + unsigned int m; + unsigned int locks[8]; + int i; + + b = button; + if (b == 0) + b = AnyButton; + m = 0; + if (any_mod) + m = AnyModifier; + else + { + if (mod & ECORE_EVENT_KEY_MODIFIER_SHIFT) + m |= ecore_mod_mask_shift_get(); + if (mod & ECORE_EVENT_KEY_MODIFIER_CTRL) + m |= ecore_mod_mask_ctrl_get(); + if (mod & ECORE_EVENT_KEY_MODIFIER_ALT) + m |= ecore_mod_mask_alt_get(); + if (mod & ECORE_EVENT_KEY_MODIFIER_WIN) + m |= ecore_mod_mask_win_get(); + } + locks[0] = 0; + locks[1] = ecore_lock_mask_caps_get(); + locks[2] = ecore_lock_mask_num_get(); + locks[3] = ecore_lock_mask_scroll_get(); + locks[4] = ecore_lock_mask_caps_get() | ecore_lock_mask_num_get(); + locks[5] = ecore_lock_mask_caps_get() | ecore_lock_mask_scroll_get(); + locks[6] = ecore_lock_mask_num_get() | ecore_lock_mask_scroll_get(); + locks[7] = + ecore_lock_mask_caps_get() | ecore_lock_mask_num_get() | + ecore_lock_mask_scroll_get(); + for (i = 0; i < 8; i++) + XGrabButton(disp, b, m | locks[i], + win, False, events, GrabModeSync, GrabModeAsync, None, None); +} + +void +ecore_button_ungrab(Window win, int button, Ecore_Event_Key_Modifiers mod, + int any_mod) +{ + unsigned int b; + unsigned int m; + unsigned int locks[8]; + int i; + + b = button; + if (b == 0) + b = AnyButton; + m = 0; + if (any_mod) + m = AnyModifier; + else + { + if (mod & ECORE_EVENT_KEY_MODIFIER_SHIFT) + m |= ecore_mod_mask_shift_get(); + if (mod & ECORE_EVENT_KEY_MODIFIER_CTRL) + m |= ecore_mod_mask_ctrl_get(); + if (mod & ECORE_EVENT_KEY_MODIFIER_ALT) + m |= ecore_mod_mask_alt_get(); + if (mod & ECORE_EVENT_KEY_MODIFIER_WIN) + m |= ecore_mod_mask_win_get(); + } + locks[0] = 0; + locks[1] = ecore_lock_mask_caps_get(); + locks[2] = ecore_lock_mask_num_get(); + locks[3] = ecore_lock_mask_scroll_get(); + locks[4] = ecore_lock_mask_caps_get() | ecore_lock_mask_num_get(); + locks[5] = ecore_lock_mask_caps_get() | ecore_lock_mask_scroll_get(); + locks[6] = ecore_lock_mask_num_get() | ecore_lock_mask_scroll_get(); + locks[7] = + ecore_lock_mask_caps_get() | ecore_lock_mask_num_get() | + ecore_lock_mask_scroll_get(); + for (i = 0; i < 8; i++) + XUngrabButton(disp, b, m | locks[i], win); +} + +void +ecore_pointer_replay(Time t) +{ + XSync(disp, False); + XAllowEvents(disp, ReplayPointer, t); + XSync(disp, False); +} + +void +ecore_pointer_grab(Window win, Time t) +{ + XGrabPointer(disp, win, False, XEV_BUTTON | XEV_MOUSE_MOVE | XEV_IN_OUT, + GrabModeAsync, GrabModeAsync, None, None, t); +} + +void +ecore_pointer_ungrab(Time t) +{ + XUngrabPointer(disp, t); +} + +void +ecore_window_send_event_move_resize(Window win, int x, int y, int w, int h) +{ + XEvent ev; + + ev.type = ConfigureNotify; + ev.xconfigure.display = disp; + ev.xconfigure.event = win; + ev.xconfigure.window = win; + ev.xconfigure.x = x; + ev.xconfigure.y = y; + ev.xconfigure.width = w; + ev.xconfigure.height = h; + ev.xconfigure.border_width = 0; + ev.xconfigure.above = win; + ev.xconfigure.override_redirect = False; + XSendEvent(disp, win, False, StructureNotifyMask, &ev); +} + +void +ecore_window_send_client_message(Window win, Atom type, int format, void *data) +{ + XClientMessageEvent ev; + int i; + + ev.type = ClientMessage; + ev.window = win; + ev.message_type = type; + ev.format = format; + if (format == 32) + { + for (i = 0; i < 5; i++) + ev.data.l[i] = ((unsigned int *)data)[i]; + } + else if (format == 16) + { + for (i = 0; i < 10; i++) + ev.data.s[i] = ((unsigned short *)data)[i]; + } + else if (format == 8) + { + for (i = 0; i < 20; i++) + ev.data.b[i] = ((unsigned char *)data)[i]; + } + XSendEvent(disp, win, False, 0, (XEvent *) & ev); +} + +void +ecore_window_add_to_save_set(Window win) +{ + XAddToSaveSet(disp, win); +} + +void +ecore_window_del_from_save_set(Window win) +{ + XRemoveFromSaveSet(disp, win); +} + +void +ecore_window_kill_client(Window win) +{ + XKillClient(disp, (XID) win); +} + +void +ecore_window_set_border_width(Window win, int bw) +{ + Ecore_XID *xid = NULL; + + xid = ecore_validate_xid(win); + if (xid) + { + xid->bw = bw; + } + XSetWindowBorderWidth(disp, win, bw); +} + +int +ecore_window_get_border_width(Window win) +{ + Ecore_XID *xid = NULL; + + xid = ecore_validate_xid(win); + if (xid) + { + return xid->bw; + } + return 0; +} + +int +ecore_window_get_wm_size_hints(Window win, XSizeHints * hints, int *mask) +{ + long sup_ret; + Status ok; + + ok = XGetWMNormalHints(disp, win, hints, &sup_ret); + *mask = (int)sup_ret; + return ok; +} + +int +ecore_window_is_visible(Window win) +{ + XWindowAttributes att; + + if (win == 0) + win = default_root; + if (XGetWindowAttributes(disp, win, &att) == True) + { + if (att.map_state == IsUnmapped) return 0; - } - XChangeProperty(disp, target, dest, - XA_STRING, 8, PropModeReplace, - string, strlen(string)); - return target; + return 1; + } + return 0; } -Window -e_selection_request(void) +int +ecore_window_is_normal(Window win) { - static Atom dest = 0; - Atom selection; - Window target = 0; - - selection = X_CLIPBOARD_SELECTION; - E_ATOM(dest, "TEXT_SELECTION"); - target = e_window_new(0, 0, 0, 7, 77); - e_window_add_events(target, XEV_CONFIGURE | XEV_PROPERTY); - XConvertSelection(disp, XA_PRIMARY, - XA_STRING, dest, - target, - CurrentTime); - return target; + XWindowAttributes att; + + if (win == 0) + win = default_root; + if (XGetWindowAttributes(disp, win, &att) == True) + { + if ((att.override_redirect) || (att.class == InputOnly)) + return 0; + return 1; + } + return 0; } -char * -e_selection_get_data(Window win, Atom prop) +int +ecore_window_is_manageable(Window win) { - char *string = NULL; - long nread; - unsigned long bytes_after, nitems; - unsigned char *data; - Atom actual_type; - int actual_fmt; - - if (prop == None) - return NULL; - for (nread = 0, bytes_after = 1; bytes_after > 0;) - { - if ((XGetWindowProperty(disp, win, prop, nread / 4, - 0x10000, True, AnyPropertyType, - &actual_type, &actual_fmt, &nitems, - &bytes_after, &data) != Success)) - { - IF_FREE(string); - if (data) - { - XFree(data); - } - return NULL; - } - nread += nitems; - - if (actual_type == XA_STRING) - { - if (string) - string = realloc(string, strlen(string) + nitems + 1); - else - { - string = malloc(nitems + 1); - string[0] = 0; - } - string[strlen(string) + nitems] = 0; - strncat(string, data, nitems); - } - else - { - int size, i; - XTextProperty xtextp; - char **cl = NULL; - - xtextp.value = data; - xtextp.encoding = actual_type; - xtextp.format = actual_fmt; - xtextp.nitems = nitems; - XmbTextPropertyToTextList(disp, &xtextp, &cl, &size); - - if (cl) - { - for (i = 0 ; i < size ; i ++) - { - if (cl[i]) - { - if (string) - string = realloc(string, strlen(string) + strlen(cl[i]) + 1); - else - { - string = malloc(strlen(cl[i]) + 1); - string[0] = 0; - } - string[strlen(string) + strlen(cl[i])] = 0; - strcat(string, cl[i]); - } - } - XFreeStringList(cl); - } - } - if (data) - { - XFree(data); - } - } - return string; + XWindowAttributes att; + + if (win == 0) + win = default_root; + if (XGetWindowAttributes(disp, win, &att) == True) + { + if ((att.map_state == IsUnmapped) || (att.override_redirect) + || (att.class == InputOnly)) + return 0; + return 1; + } + return 0; } void -e_set_blank_pointer(Window w) +ecore_windows_restack(Window * wins, int num) { - Cursor c; - XColor cl; - Pixmap p, m; - GC gc; - XGCValues gcv; - - if (w == 0) - w = default_root; - p = XCreatePixmap(disp, w, 1, 1, 1); - m = XCreatePixmap(disp, w, 1, 1, 1); - gc = XCreateGC(disp, m, 0, &gcv); - XSetForeground(disp, gc, 0); - XDrawPoint(disp, m, gc, 0, 0); - XFreeGC(disp, gc); - c = XCreatePixmapCursor(disp, p, m, &cl, &cl, 0, 0); - XDefineCursor(disp, w, c); - XFreeCursor(disp, c); - XFreePixmap(disp, p); - XFreePixmap(disp, m); + XRestackWindows(disp, wins, num); +} + +void +ecore_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); +} + +void +ecore_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 * +ecore_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 +ecore_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 +ecore_keyboard_ungrab(void) +{ + if (!keyboard_grab_win) + return; + keyboard_grab_win = 0; + XUngrabKeyboard(disp, CurrentTime); +} + +Window +ecore_selection_set(char *string) +{ + Window target = 0; + static Atom dest = 0; + Atom selection; + + selection = X_CLIPBOARD_SELECTION; + ECORE_ATOM(dest, "TEXT_SELECTION"); + target = ecore_window_new(0, 0, 0, 77, 7); + ecore_window_add_events(target, XEV_CONFIGURE | XEV_PROPERTY); + XSetSelectionOwner(disp, selection, target, CurrentTime); + if (XGetSelectionOwner(disp, XA_PRIMARY) != target) + { + ecore_window_destroy(target); + return 0; + } + XChangeProperty(disp, target, dest, + XA_STRING, 8, PropModeReplace, string, strlen(string)); + return target; +} + +Window +ecore_selection_request(void) +{ + static Atom dest = 0; + Atom selection; + Window target = 0; + + selection = X_CLIPBOARD_SELECTION; + ECORE_ATOM(dest, "TEXT_SELECTION"); + target = ecore_window_new(0, 0, 0, 7, 77); + ecore_window_add_events(target, XEV_CONFIGURE | XEV_PROPERTY); + XConvertSelection(disp, XA_PRIMARY, XA_STRING, dest, target, CurrentTime); + return target; +} + +char * +ecore_selection_get_data(Window win, Atom prop) +{ + char *string = NULL; + long nread; + unsigned long bytes_after, nitems; + unsigned char *data; + Atom actual_type; + int actual_fmt; + + if (prop == None) + return NULL; + for (nread = 0, bytes_after = 1; bytes_after > 0;) + { + if ((XGetWindowProperty(disp, win, prop, nread / 4, + 0x10000, True, AnyPropertyType, + &actual_type, &actual_fmt, &nitems, + &bytes_after, &data) != Success)) + { + IF_FREE(string); + if (data) + { + XFree(data); + } + return NULL; + } + nread += nitems; + + if (actual_type == XA_STRING) + { + if (string) + string = realloc(string, strlen(string) + nitems + 1); + else + { + string = malloc(nitems + 1); + string[0] = 0; + } + string[strlen(string) + nitems] = 0; + strncat(string, data, nitems); + } + else + { + int size, i; + XTextProperty xtextp; + char **cl = NULL; + + xtextp.value = data; + xtextp.encoding = actual_type; + xtextp.format = actual_fmt; + xtextp.nitems = nitems; + XmbTextPropertyToTextList(disp, &xtextp, &cl, &size); + + if (cl) + { + for (i = 0; i < size; i++) + { + if (cl[i]) + { + if (string) + string = + realloc(string, strlen(string) + strlen(cl[i]) + 1); + else + { + string = malloc(strlen(cl[i]) + 1); + string[0] = 0; + } + string[strlen(string) + strlen(cl[i])] = 0; + strcat(string, cl[i]); + } + } + XFreeStringList(cl); + } + } + if (data) + { + XFree(data); + } + } + return string; +} + +void +ecore_set_blank_pointer(Window w) +{ + Cursor c; + XColor cl; + Pixmap p, m; + GC gc; + XGCValues gcv; + + if (w == 0) + w = default_root; + p = XCreatePixmap(disp, w, 1, 1, 1); + m = XCreatePixmap(disp, w, 1, 1, 1); + gc = XCreateGC(disp, m, 0, &gcv); + XSetForeground(disp, gc, 0); + XDrawPoint(disp, m, gc, 0, 0); + XFreeGC(disp, gc); + c = XCreatePixmapCursor(disp, p, m, &cl, &cl, 0, 0); + XDefineCursor(disp, w, c); + XFreeCursor(disp, c); + XFreePixmap(disp, p); + XFreePixmap(disp, m); } Cursor -e_cursor_new(Pixmap pmap, Pixmap mask, int x, int y, int fr, int fg, int fb, int br, int bg, int bb) +ecore_cursor_new(Pixmap pmap, Pixmap mask, int x, int y, int fr, int fg, int fb, + int br, int bg, int bb) { - XColor cl1, cl2; - - cl1.pixel = 0; - cl1.red = fr << 8 | fr; - cl1.green = fg << 8 | fg; - cl1.blue = fb << 8 | fb; - cl1.flags = DoRed|DoGreen|DoBlue; - cl2.pixel = 0; - cl2.red = br << 8 | br; - cl2.green = bg << 8 | bg; - cl2.blue = bb << 8 | bb; - cl2.flags = DoRed|DoGreen|DoBlue; - return XCreatePixmapCursor(disp, pmap, mask, &cl1, &cl2, x, y); + XColor cl1, cl2; + + cl1.pixel = 0; + cl1.red = fr << 8 | fr; + cl1.green = fg << 8 | fg; + cl1.blue = fb << 8 | fb; + cl1.flags = DoRed | DoGreen | DoBlue; + cl2.pixel = 0; + cl2.red = br << 8 | br; + cl2.green = bg << 8 | bg; + cl2.blue = bb << 8 | bb; + cl2.flags = DoRed | DoGreen | DoBlue; + return XCreatePixmapCursor(disp, pmap, mask, &cl1, &cl2, x, y); } void -e_cursor_free(Cursor c) +ecore_cursor_free(Cursor c) { - XFreeCursor(disp, c); + XFreeCursor(disp, c); } void -e_cursor_set(Window win, Cursor c) +ecore_cursor_set(Window win, Cursor c) { - if (win == 0) - win = default_root; - XDefineCursor(disp, win, c); + if (win == 0) + win = default_root; + XDefineCursor(disp, win, c); }