1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ 2 3 /* Marco interface used by GTK+ UI to talk to core */ 4 5 /* 6 * Copyright (C) 2001 Havoc Pennington 7 * Copyright (C) 2005 Elijah Newren 8 * 9 * This program is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU General Public License as 11 * published by the Free Software Foundation; either version 2 of the 12 * License, or (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, but 15 * WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 22 * 02110-1301, USA. 23 */ 24 25 #ifndef META_CORE_H 26 #define META_CORE_H 27 28 /* Don't include core headers here */ 29 #include <gdk/gdkx.h> 30 #include "common.h" 31 32 typedef enum 33 { 34 META_CORE_GET_END = 0, 35 META_CORE_WINDOW_HAS_FRAME, 36 META_CORE_GET_CLIENT_WIDTH, 37 META_CORE_GET_CLIENT_HEIGHT, 38 META_CORE_IS_TITLEBAR_ONSCREEN, 39 META_CORE_GET_CLIENT_XWINDOW, 40 META_CORE_GET_FRAME_FLAGS, 41 META_CORE_GET_FRAME_TYPE, 42 META_CORE_GET_MINI_ICON, 43 META_CORE_GET_ICON, 44 META_CORE_GET_X, 45 META_CORE_GET_Y, 46 META_CORE_GET_FRAME_WORKSPACE, 47 META_CORE_GET_FRAME_X, 48 META_CORE_GET_FRAME_Y, 49 META_CORE_GET_FRAME_WIDTH, 50 META_CORE_GET_FRAME_HEIGHT, 51 META_CORE_GET_THEME_VARIANT, 52 META_CORE_GET_SCREEN_WIDTH, 53 META_CORE_GET_SCREEN_HEIGHT, 54 } MetaCoreGetType; 55 56 /* General information function about the given window. Pass in a sequence of 57 * pairs of MetaCoreGetTypes and pointers to variables; the variables will be 58 * filled with the requested values. End the list with META_CORE_GET_END. 59 * For example: 60 * 61 * meta_core_get (my_display, my_window, 62 * META_CORE_GET_X, &x, 63 * META_CORE_GET_Y, &y, 64 * META_CORE_GET_END); 65 * 66 * If the window doesn't have a frame, this will raise a meta_bug. To suppress 67 * this behaviour, ask META_CORE_WINDOW_HAS_FRAME as the *first* question in 68 * the list. If the window has no frame, the answer to this question will be 69 * False, and anything else you asked will be undefined. Otherwise, the answer 70 * will be True. The answer will necessarily be True if you ask the question 71 * in any other position. The positions of all other questions don't matter. 72 * 73 * The reason for this function is that some parts of the program don't know 74 * about MetaWindows. But they *can* see core.h. So we used to have a whole 75 * load of functions which took a display and an X window, looked up the 76 * relevant MetaWindow, and returned information about it. The trouble with 77 * that is that looking up the MetaWindow is a nontrivial operation, and 78 * consolidating the calls in this way makes (for example) frame exposes 79 * 33% faster, according to valgrind. 80 * 81 * This function would perhaps be slightly better if the questions were 82 * represented by pointers, perhaps gchar*s, because then we could take 83 * advantage of gcc's automatic sentinel checking. On the other hand, this 84 * immediately suggests string comparison, and that's slow. 85 * 86 * Another possible improvement is that core.h still has a bunch of 87 * functions which can't be described by the formula "give a display and 88 * an X window, get a single value" (meta_core_user_move, for example), but 89 * which could theoretically be handled by this function if we relaxed the 90 * requirement that all questions should have exactly one argument. 91 */ 92 void meta_core_get (Display *xdisplay, 93 Window window, 94 ...); 95 96 void meta_core_queue_frame_resize (Display *xdisplay, 97 Window frame_xwindow); 98 99 /* Move as a result of user operation */ 100 void meta_core_user_move (Display *xdisplay, 101 Window frame_xwindow, 102 int x, 103 int y); 104 void meta_core_user_resize (Display *xdisplay, 105 Window frame_xwindow, 106 int gravity, 107 int width, 108 int height); 109 110 void meta_core_user_raise (Display *xdisplay, 111 Window frame_xwindow); 112 void meta_core_user_lower_and_unfocus (Display *xdisplay, 113 Window frame_xwindow, 114 guint32 timestamp); 115 116 void meta_core_user_focus (Display *xdisplay, 117 Window frame_xwindow, 118 guint32 timestamp); 119 120 void meta_core_lower_beneath_focus_window (Display *xdisplay, 121 Window xwindow, 122 guint32 timestamp); 123 124 void meta_core_minimize (Display *xdisplay, 125 Window frame_xwindow); 126 void meta_core_toggle_maximize (Display *xdisplay, 127 Window frame_xwindow); 128 void meta_core_toggle_maximize_horizontally (Display *xdisplay, 129 Window frame_xwindow); 130 void meta_core_toggle_maximize_vertically (Display *xdisplay, 131 Window frame_xwindow); 132 void meta_core_unmaximize (Display *xdisplay, 133 Window frame_xwindow); 134 void meta_core_maximize (Display *xdisplay, 135 Window frame_xwindow); 136 void meta_core_delete (Display *xdisplay, 137 Window frame_xwindow, 138 guint32 timestamp); 139 void meta_core_unshade (Display *xdisplay, 140 Window frame_xwindow, 141 guint32 timestamp); 142 void meta_core_shade (Display *xdisplay, 143 Window frame_xwindow, 144 guint32 timestamp); 145 void meta_core_unstick (Display *xdisplay, 146 Window frame_xwindow); 147 void meta_core_stick (Display *xdisplay, 148 Window frame_xwindow); 149 void meta_core_unmake_above (Display *xdisplay, 150 Window frame_xwindow); 151 void meta_core_make_above (Display *xdisplay, 152 Window frame_xwindow); 153 void meta_core_change_workspace (Display *xdisplay, 154 Window frame_xwindow, 155 int new_workspace); 156 157 int meta_core_get_num_workspaces (Screen *xscreen); 158 int meta_core_get_active_workspace (Screen *xscreen); 159 int meta_core_get_frame_workspace (Display *xdisplay, 160 Window frame_xwindow); 161 const char* meta_core_get_workspace_name_with_index (Display *xdisplay, 162 Window xroot, 163 int index); 164 165 void meta_core_show_window_menu (Display *xdisplay, 166 Window frame_xwindow, 167 int root_x, 168 int root_y, 169 int button, 170 guint32 timestamp); 171 172 void meta_core_get_menu_accelerator (MetaMenuOp menu_op, 173 int workspace, 174 unsigned int *keysym, 175 MetaVirtualModifier *modifiers); 176 177 gboolean meta_core_begin_grab_op (Display *xdisplay, 178 Window frame_xwindow, 179 MetaGrabOp op, 180 gboolean pointer_already_grabbed, 181 gboolean frame_action, 182 int button, 183 gulong modmask, 184 guint32 timestamp, 185 int root_x, 186 int root_y); 187 void meta_core_end_grab_op (Display *xdisplay, 188 guint32 timestamp); 189 MetaGrabOp meta_core_get_grab_op (Display *xdisplay); 190 Window meta_core_get_grab_frame (Display *xdisplay); 191 int meta_core_get_grab_button (Display *xdisplay); 192 193 void meta_core_grab_buttons (Display *xdisplay, 194 Window frame_xwindow); 195 196 void meta_core_set_screen_cursor (Display *xdisplay, 197 Window frame_on_screen, 198 MetaCursor cursor); 199 200 /* Used because we ignore EnterNotify when a window is unmapped that 201 * really shouldn't cause focus changes, by comparing the event serial 202 * of the EnterNotify and the UnmapNotify. 203 */ 204 void meta_core_increment_event_serial (Display *display); 205 206 void meta_invalidate_default_icons (void); 207 208 void meta_invalidate_all_icons (void); 209 210 #endif 211 212