1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ 2 3 /* Metacity interface for talking to GTK+ UI module */ 4 5 /* 6 * Copyright (C) 2001 Havoc Pennington 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License as 10 * published by the Free Software Foundation; either version 2 of the 11 * License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, but 14 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef META_UI_H 23 #define META_UI_H 24 25 /* Don't include gtk.h or gdk.h here */ 26 #include "common.h" 27 #include <X11/Xlib.h> 28 #include <X11/Xutil.h> 29 #include <cairo.h> 30 #include <glib.h> 31 #include <gdk-pixbuf/gdk-pixbuf.h> 32 #include <libmetacity/meta-frame-borders.h> 33 #include <libmetacity/meta-frame-enums.h> 34 35 typedef struct _MetaUI MetaUI; 36 37 typedef gboolean (* MetaEventFunc) (XEvent *xevent, gpointer data); 38 39 typedef enum 40 { 41 META_UI_DIRECTION_LTR, 42 META_UI_DIRECTION_RTL 43 } MetaUIDirection; 44 45 void meta_ui_init (int *argc, char ***argv); 46 47 Display* meta_ui_get_display (void); 48 49 void meta_ui_add_event_func (Display *xdisplay, 50 MetaEventFunc func, 51 gpointer data); 52 void meta_ui_remove_event_func (Display *xdisplay, 53 MetaEventFunc func, 54 gpointer data); 55 56 MetaUI* meta_ui_new (Display *xdisplay, 57 gboolean composited); 58 void meta_ui_free (MetaUI *ui); 59 60 void meta_ui_set_composited (MetaUI *ui, 61 gboolean composited); 62 63 gint meta_ui_get_scale (MetaUI *ui); 64 65 void meta_ui_theme_get_frame_borders (MetaUI *ui, 66 MetaFrameType type, 67 MetaFrameFlags flags, 68 MetaFrameBorders *borders); 69 void meta_ui_get_frame_borders (MetaUI *ui, 70 Window frame_xwindow, 71 MetaFrameBorders *borders); 72 73 Window meta_ui_create_frame_window (MetaUI *ui, 74 Display *xdisplay, 75 Visual *xvisual, 76 gint x, 77 gint y, 78 gint width, 79 gint height, 80 gulong *create_serial); 81 82 void meta_ui_destroy_frame_window (MetaUI *ui, 83 Window xwindow); 84 void meta_ui_move_resize_frame (MetaUI *ui, 85 Window frame, 86 int x, 87 int y, 88 int width, 89 int height); 90 91 /* GDK insists on tracking map/unmap */ 92 void meta_ui_map_frame (MetaUI *ui, 93 Window xwindow); 94 void meta_ui_unmap_frame (MetaUI *ui, 95 Window xwindow); 96 97 void meta_ui_apply_frame_shape (MetaUI *ui, 98 Window xwindow, 99 int new_window_width, 100 int new_window_height, 101 gboolean window_has_shape); 102 103 cairo_region_t *meta_ui_get_frame_bounds (MetaUI *ui, 104 Window xwindow, 105 int window_width, 106 int window_height); 107 108 void meta_ui_queue_frame_draw (MetaUI *ui, 109 Window xwindow); 110 111 void meta_ui_set_frame_title (MetaUI *ui, 112 Window xwindow, 113 const char *title); 114 115 void meta_ui_update_frame_style (MetaUI *ui, 116 Window window); 117 118 void meta_ui_repaint_frame (MetaUI *ui, 119 Window xwindow); 120 121 MetaWindowMenu* meta_ui_window_menu_new (MetaUI *ui, 122 Window client_xwindow, 123 MetaMenuOp ops, 124 MetaMenuOp insensitive, 125 unsigned long active_workspace, 126 int n_workspaces, 127 MetaWindowMenuFunc func, 128 gpointer data); 129 void meta_ui_window_menu_popup (MetaWindowMenu *menu, 130 const GdkRectangle *rect, 131 guint32 timestamp); 132 void meta_ui_window_menu_free (MetaWindowMenu *menu); 133 134 135 GdkPixbuf* meta_gdk_pixbuf_get_from_pixmap (Pixmap xpixmap, 136 int src_x, 137 int src_y, 138 int width, 139 int height); 140 141 GdkPixbuf *meta_ui_get_default_window_icon (MetaUI *ui, 142 int ideal_size); 143 144 GdkPixbuf *meta_ui_get_default_mini_icon (MetaUI *ui, 145 int ideal_size); 146 147 gboolean meta_ui_window_should_not_cause_focus (Display *xdisplay, 148 Window xwindow); 149 150 void meta_ui_reload_theme (MetaUI *ui); 151 void meta_ui_update_button_layout (MetaUI *ui); 152 153 /* Not a real key symbol but means "key above the tab key"; this is 154 * used as the default keybinding for cycle_group. 155 * 0x2xxxxxxx is a range not used by GDK or X. the remaining digits are 156 * randomly chosen */ 157 #define META_KEY_ABOVE_TAB 0x2f7259c9 158 159 gboolean meta_ui_parse_accelerator (const char *accel, 160 unsigned int *keysym, 161 unsigned int *keycode, 162 MetaVirtualModifier *mask); 163 gboolean meta_ui_parse_modifier (const char *accel, 164 MetaVirtualModifier *mask); 165 166 gboolean meta_ui_window_is_widget (MetaUI *ui, 167 Window xwindow); 168 169 int meta_ui_get_drag_threshold (MetaUI *ui); 170 171 MetaUIDirection meta_ui_get_direction (void); 172 173 GdkPixbuf *meta_ui_get_pixbuf_from_surface (cairo_surface_t *surface); 174 175 #include "tabpopup.h" 176 #include "tile-preview.h" 177 178 #endif 179