diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/all-keybindings.h | 386 | ||||
-rw-r--r-- | src/include/boxes.h | 290 | ||||
-rw-r--r-- | src/include/common.h | 300 | ||||
-rw-r--r-- | src/include/compositor.h | 76 | ||||
-rw-r--r-- | src/include/core.h | 208 | ||||
-rw-r--r-- | src/include/display.h | 48 | ||||
-rw-r--r-- | src/include/errors.h | 51 | ||||
-rw-r--r-- | src/include/frame.h | 31 | ||||
-rw-r--r-- | src/include/main.h | 43 | ||||
-rw-r--r-- | src/include/prefs.h | 233 | ||||
-rw-r--r-- | src/include/resizepopup.h | 47 | ||||
-rw-r--r-- | src/include/screen.h | 48 | ||||
-rw-r--r-- | src/include/tabpopup.h | 67 | ||||
-rw-r--r-- | src/include/types.h | 31 | ||||
-rw-r--r-- | src/include/ui.h | 209 | ||||
-rw-r--r-- | src/include/util.h | 136 | ||||
-rw-r--r-- | src/include/window.h | 39 | ||||
-rw-r--r-- | src/include/xprops.h | 227 |
18 files changed, 2470 insertions, 0 deletions
diff --git a/src/include/all-keybindings.h b/src/include/all-keybindings.h new file mode 100644 index 00000000..ee9b5d37 --- /dev/null +++ b/src/include/all-keybindings.h @@ -0,0 +1,386 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* + * Copyright (C) 2008 Thomas Thurman + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +/** + * A list of screen keybinding information. + * + * Each action which can have a keystroke bound to it is listed below. + * To use this file, define keybind() to be a seven-argument macro (you can + * throw any of the arguments you please away), include this file, + * and then undefine the macro again. + * + * (If you aren't familiar with this technique, sometimes called "x-macros", + * see DDJ of May 2001: <http://www.ddj.com/cpp/184401387>.) + * + * This makes it possible to keep all information about all the keybindings + * in the same place. The only exception is the code to run when an action + * is actually invoked; while we *could* have put that in this file, it would + * have made debugging ridiculously difficult. Instead, each action should + * have a corresponding static function named handle_<name>() in + * keybindings.c. + * + * The arguments to keybind() are: + * 1) the name of the binding; a bareword identifier + * (it's fine if it happens to clash with a C reserved word) + * 2) the name of the function which implements it. + * Clearly we could have guessed this from the binding very often, + * but we choose to write it in full for the benefit of grep. + * 3) an integer parameter to pass to the handler + * 4) a set of boolean flags, ORed together: + * BINDING_PER_WINDOW - this is a window-based binding. + * It is only valid if there is a + * current window, and will operate in + * some way on that window. + * BINDING_REVERSES - the binding can reverse if you hold down Shift + * BINDING_IS_REVERSED - the same, but the senses are reversed from the + * handler's point of view (let me know if I should + * explain this better) + * or 0 if no flag applies. + * + * 5) a string representing the default binding. + * If this is NULL, the action is unbound by default. + * Please use NULL and not "disabled". + * 6) a short description. + * It must be marked translatable (i.e. inside "_(...)"). + * + * Don't try to do XML entity escaping anywhere in the strings. + */ + +#ifndef keybind +#error "keybind () must be defined when you include screen-bindings.h" +#endif + +/***********************************/ + +#ifndef _BINDINGS_DEFINED_CONSTANTS +#define _BINDINGS_DEFINED_CONSTANTS 1 + +#define BINDING_PER_WINDOW 0x01 +#define BINDING_REVERSES 0x02 +#define BINDING_IS_REVERSED 0x04 + +#endif /* _BINDINGS_DEFINED_CONSTANTS */ + +/***********************************/ + +/* convenience, since in this file they must always be set together */ +#define REVERSES_AND_REVERSED (BINDING_REVERSES | BINDING_IS_REVERSED) + +keybind (switch_to_workspace_1, handle_switch_to_workspace, 0, 0, NULL, + _("Switch to workspace 1")) +keybind (switch_to_workspace_2, handle_switch_to_workspace, 1, 0, NULL, + _("Switch to workspace 2")) +keybind (switch_to_workspace_3, handle_switch_to_workspace, 2, 0, NULL, + _("Switch to workspace 3")) +keybind (switch_to_workspace_4, handle_switch_to_workspace, 3, 0, NULL, + _("Switch to workspace 4")) +keybind (switch_to_workspace_5, handle_switch_to_workspace, 4, 0, NULL, + _("Switch to workspace 5")) +keybind (switch_to_workspace_6, handle_switch_to_workspace, 5, 0, NULL, + _("Switch to workspace 6")) +keybind (switch_to_workspace_7, handle_switch_to_workspace, 6, 0, NULL, + _("Switch to workspace 7")) +keybind (switch_to_workspace_8, handle_switch_to_workspace, 7, 0, NULL, + _("Switch to workspace 8")) +keybind (switch_to_workspace_9, handle_switch_to_workspace, 8, 0, NULL, + _("Switch to workspace 9")) +keybind (switch_to_workspace_10, handle_switch_to_workspace, 9, 0, NULL, + _("Switch to workspace 10")) +keybind (switch_to_workspace_11, handle_switch_to_workspace, 10, 0, NULL, + _("Switch to workspace 11")) +keybind (switch_to_workspace_12, handle_switch_to_workspace, 11, 0, NULL, + _("Switch to workspace 12")) + +/* META_MOTION_* are negative, and so distinct from workspace numbers, + * which are always zero or positive. + * If you make use of these constants, you will need to include workspace.h + * (which you're probably using already for other reasons anyway). + * If your definition of keybind() throws them away, you don't need to include + * workspace.h, of course. + */ + +keybind (switch_to_workspace_left, handle_switch_to_workspace, + META_MOTION_LEFT, 0, "<Control><Alt>Left", + _("Switch to workspace on the left of the current workspace")) + +keybind (switch_to_workspace_right, handle_switch_to_workspace, + META_MOTION_RIGHT, 0, "<Control><Alt>Right", + _("Switch to workspace on the right of the current workspace")) + +keybind (switch_to_workspace_up, handle_switch_to_workspace, + META_MOTION_UP, 0, "<Control><Alt>Up", + _("Switch to workspace above the current workspace")) + +keybind (switch_to_workspace_down, handle_switch_to_workspace, + META_MOTION_DOWN, 0, "<Control><Alt>Down", + _("Switch to workspace below the current workspace")) + +/***********************************/ + +/* The ones which have inverses. These can't be bound to any keystroke + * containing Shift because Shift will invert their "backward" state. + * + * TODO: "NORMAL" and "DOCKS" should be renamed to the same name as their + * action, for obviousness. + * + * TODO: handle_switch and handle_cycle should probably really be the + * same function checking a bit in the parameter for difference. + */ + +keybind (switch_group, handle_switch, META_TAB_LIST_GROUP, + BINDING_REVERSES, NULL, + _("Move between windows of an application, using a popup window")) +keybind (switch_group_backward, handle_switch, META_TAB_LIST_GROUP, + REVERSES_AND_REVERSED, NULL, + _("Move backward between windows of an application, " + "using a popup window")) +keybind (switch_windows, handle_switch, META_TAB_LIST_NORMAL, + BINDING_REVERSES, "<Alt>Tab", + _("Move between windows, using a popup window")) +keybind (switch_windows_backward, handle_switch, META_TAB_LIST_NORMAL, + REVERSES_AND_REVERSED, NULL, + _("Move backward between windows, using a popup window")) +keybind (switch_panels, handle_switch, META_TAB_LIST_DOCKS, + BINDING_REVERSES, "<Control><Alt>Tab", + _("Move between panels and the desktop, using a popup window")) +keybind (switch_panels_backward, handle_switch, META_TAB_LIST_DOCKS, + REVERSES_AND_REVERSED, NULL, + _("Move backward between panels and the desktop, " + "using a popup window")) + +keybind (cycle_group, handle_cycle, META_TAB_LIST_GROUP, + BINDING_REVERSES, "<Alt>F6", + _("Move between windows of an application immediately")) +keybind (cycle_group_backward, handle_cycle, META_TAB_LIST_GROUP, + REVERSES_AND_REVERSED, NULL, + _("Move backward between windows of an application immediately")) +keybind (cycle_windows, handle_cycle, META_TAB_LIST_NORMAL, + BINDING_REVERSES, "<Alt>Escape", + _("Move between windows immediately")) +keybind (cycle_windows_backward, handle_cycle, META_TAB_LIST_NORMAL, + REVERSES_AND_REVERSED, NULL, + _("Move backward between windows immediately")) +keybind (cycle_panels, handle_cycle, META_TAB_LIST_DOCKS, + BINDING_REVERSES, "<Control><Alt>Escape", + _("Move between panels and the desktop immediately")) +keybind (cycle_panels_backward, handle_cycle, META_TAB_LIST_DOCKS, + REVERSES_AND_REVERSED, NULL, + _("Move backward between panels and the desktop immediately")) + +/***********************************/ + +keybind (show_desktop, handle_show_desktop, 0, 0, "<Control><Alt>d", + _("Hide all normal windows and set focus to the desktop")) +keybind (panel_main_menu, handle_panel, + META_KEYBINDING_ACTION_PANEL_MAIN_MENU, 0, "<Alt>F1", + _("Show the panel's main menu")) +keybind (panel_run_dialog, handle_panel, + META_KEYBINDING_ACTION_PANEL_RUN_DIALOG, 0, "<Alt>F2", + _("Show the panel's \"Run Application\" dialog box")) + +/* Yes, the param is offset by one. Historical reasons. (Maybe worth fixing + * at some point.) The description is NULL here because the stanza is + * irregularly shaped in marco.schemas.in. This will probably be fixed + * as well. + */ +keybind (run_command_1, handle_run_command, 0, 0, NULL, NULL) +keybind (run_command_2, handle_run_command, 1, 0, NULL, NULL) +keybind (run_command_3, handle_run_command, 2, 0, NULL, NULL) +keybind (run_command_4, handle_run_command, 3, 0, NULL, NULL) +keybind (run_command_5, handle_run_command, 4, 0, NULL, NULL) +keybind (run_command_6, handle_run_command, 5, 0, NULL, NULL) +keybind (run_command_7, handle_run_command, 6, 0, NULL, NULL) +keybind (run_command_8, handle_run_command, 7, 0, NULL, NULL) +keybind (run_command_9, handle_run_command, 8, 0, NULL, NULL) +keybind (run_command_10, handle_run_command, 9, 0, NULL, NULL) +keybind (run_command_11, handle_run_command, 10, 0, NULL, NULL) +keybind (run_command_12, handle_run_command, 11, 0, NULL, NULL) +keybind (run_command_13, handle_run_command, 12, 0, NULL, NULL) +keybind (run_command_14, handle_run_command, 13, 0, NULL, NULL) +keybind (run_command_15, handle_run_command, 14, 0, NULL, NULL) +keybind (run_command_16, handle_run_command, 15, 0, NULL, NULL) +keybind (run_command_17, handle_run_command, 16, 0, NULL, NULL) +keybind (run_command_18, handle_run_command, 17, 0, NULL, NULL) +keybind (run_command_19, handle_run_command, 18, 0, NULL, NULL) +keybind (run_command_20, handle_run_command, 19, 0, NULL, NULL) +keybind (run_command_21, handle_run_command, 20, 0, NULL, NULL) +keybind (run_command_22, handle_run_command, 21, 0, NULL, NULL) +keybind (run_command_23, handle_run_command, 22, 0, NULL, NULL) +keybind (run_command_24, handle_run_command, 23, 0, NULL, NULL) +keybind (run_command_25, handle_run_command, 24, 0, NULL, NULL) +keybind (run_command_26, handle_run_command, 25, 0, NULL, NULL) +keybind (run_command_27, handle_run_command, 26, 0, NULL, NULL) +keybind (run_command_28, handle_run_command, 27, 0, NULL, NULL) +keybind (run_command_29, handle_run_command, 28, 0, NULL, NULL) +keybind (run_command_30, handle_run_command, 29, 0, NULL, NULL) +keybind (run_command_31, handle_run_command, 30, 0, NULL, NULL) +keybind (run_command_32, handle_run_command, 31, 0, NULL, NULL) + +keybind (run_command_screenshot, handle_run_command, 32, 0, "Print", + _("Take a screenshot")) +keybind (run_command_window_screenshot, handle_run_command, 33, 0,"<Alt>Print", + _("Take a screenshot of a window")) + +keybind (run_command_terminal, handle_run_terminal, 0, 0, NULL, _("Run a terminal")) + +/* No description because this is undocumented */ +keybind (set_spew_mark, handle_set_spew_mark, 0, 0, NULL, NULL) + +#undef REVERSES_AND_REVERSED + +/************************ PER WINDOW BINDINGS ************************/ + +/* These take a window as an extra parameter; they have no effect + * if no window is active. + */ + +keybind (activate_window_menu, handle_activate_window_menu, 0, + BINDING_PER_WINDOW, "<Alt>space", + _("Activate the window menu")) +keybind (toggle_fullscreen, handle_toggle_fullscreen, 0, BINDING_PER_WINDOW, + NULL, + _("Toggle fullscreen mode")) +keybind (toggle_maximized, handle_toggle_maximized, 0, BINDING_PER_WINDOW, "<Alt>F10", + _("Toggle maximization state")) +keybind (toggle_above, handle_toggle_above, 0, BINDING_PER_WINDOW, NULL, + _("Toggle whether a window will always be visible over other windows")) +keybind (maximize, handle_maximize, 0, BINDING_PER_WINDOW, NULL, + _("Maximize window")) +keybind (unmaximize, handle_unmaximize, 0, BINDING_PER_WINDOW, "<Alt>F5", + _("Restore window")) +keybind (toggle_shaded, handle_toggle_shaded, 0, BINDING_PER_WINDOW, NULL, + _("Toggle shaded state")) +keybind (minimize, handle_minimize, 0, BINDING_PER_WINDOW, "<Alt>F9", + _("Minimize window")) +keybind (close, handle_close, 0, BINDING_PER_WINDOW, "<Alt>F4", + _("Close window")) +keybind (begin_move, handle_begin_move, 0, BINDING_PER_WINDOW, "<Alt>F7", + _("Move window")) +keybind (begin_resize, handle_begin_resize, 0, BINDING_PER_WINDOW, "<Alt>F8", + _("Resize window")) +keybind (toggle_on_all_workspaces, handle_toggle_on_all_workspaces, 0, + BINDING_PER_WINDOW, NULL, + _("Toggle whether window is on all workspaces or just one")) + +keybind (move_to_workspace_1, handle_move_to_workspace, 0, BINDING_PER_WINDOW, + NULL, + _("Move window to workspace 1")) +keybind (move_to_workspace_2, handle_move_to_workspace, 1, BINDING_PER_WINDOW, + NULL, + _("Move window to workspace 2")) +keybind (move_to_workspace_3, handle_move_to_workspace, 2, BINDING_PER_WINDOW, + NULL, + _("Move window to workspace 3")) +keybind (move_to_workspace_4, handle_move_to_workspace, 3, BINDING_PER_WINDOW, + NULL, + _("Move window to workspace 4")) +keybind (move_to_workspace_5, handle_move_to_workspace, 4, BINDING_PER_WINDOW, + NULL, + _("Move window to workspace 5")) +keybind (move_to_workspace_6, handle_move_to_workspace, 5, BINDING_PER_WINDOW, + NULL, + _("Move window to workspace 6")) +keybind (move_to_workspace_7, handle_move_to_workspace, 6, BINDING_PER_WINDOW, + NULL, + _("Move window to workspace 7")) +keybind (move_to_workspace_8, handle_move_to_workspace, 7, BINDING_PER_WINDOW, + NULL, + _("Move window to workspace 8")) +keybind (move_to_workspace_9, handle_move_to_workspace, 8, BINDING_PER_WINDOW, + NULL, + _("Move window to workspace 9")) +keybind (move_to_workspace_10, handle_move_to_workspace, 9, BINDING_PER_WINDOW, + NULL, + _("Move window to workspace 10")) +keybind (move_to_workspace_11, handle_move_to_workspace, 10, BINDING_PER_WINDOW, + NULL, + _("Move window to workspace 11")) +keybind (move_to_workspace_12, handle_move_to_workspace, 11, BINDING_PER_WINDOW, + NULL, + _("Move window to workspace 12")) + +/* META_MOTION_* are negative, and so distinct from workspace numbers, + * which are always zero or positive. + * If you make use of these constants, you will need to include workspace.h + * (which you're probably using already for other reasons anyway). + * If your definition of keybind() throws them away, you don't need to include + * workspace.h, of course. + */ + +keybind (move_to_workspace_left, handle_move_to_workspace, + META_MOTION_LEFT, BINDING_PER_WINDOW, "<Control><Shift><Alt>Left", + _("Move window one workspace to the left")) +keybind (move_to_workspace_right, handle_move_to_workspace, + META_MOTION_RIGHT, BINDING_PER_WINDOW, "<Control><Shift><Alt>Right", + _("Move window one workspace to the right")) +keybind (move_to_workspace_up, handle_move_to_workspace, + META_MOTION_UP, BINDING_PER_WINDOW, "<Control><Shift><Alt>Up", + _("Move window one workspace up")) +keybind (move_to_workspace_down, handle_move_to_workspace, + META_MOTION_DOWN, BINDING_PER_WINDOW, "<Control><Shift><Alt>Down", + _("Move window one workspace down")) + +keybind (raise_or_lower, handle_raise_or_lower, 0, BINDING_PER_WINDOW, NULL, + _("Raise window if it's covered by another window, otherwise lower it")) +keybind (raise, handle_raise, 0, BINDING_PER_WINDOW, NULL, + _("Raise window above other windows")) +keybind (lower, handle_lower, 0, BINDING_PER_WINDOW, NULL, + _("Lower window below other windows")) + +keybind (maximize_vertically, handle_maximize_vertically, 0, + BINDING_PER_WINDOW, NULL, + _("Maximize window vertically")) + +keybind (maximize_horizontally, handle_maximize_horizontally, 0, + BINDING_PER_WINDOW, NULL, + _("Maximize window horizontally")) + +keybind (move_to_corner_nw, handle_move_to_corner_nw, 0, + BINDING_PER_WINDOW, NULL, + _("Move window to north-west (top left) corner")) +keybind (move_to_corner_ne, handle_move_to_corner_ne, 0, + BINDING_PER_WINDOW, NULL, + _("Move window to north-east (top right) corner")) +keybind (move_to_corner_sw, handle_move_to_corner_sw, 0, + BINDING_PER_WINDOW, NULL, + _("Move window to south-west (bottom left) corner")) +keybind (move_to_corner_se, handle_move_to_corner_se, 0, + BINDING_PER_WINDOW, NULL, + _("Move window to south-east (bottom right) corner")) + +keybind (move_to_side_n, handle_move_to_side_n, 0, + BINDING_PER_WINDOW, NULL, + _("Move window to north (top) side of screen")) +keybind (move_to_side_s, handle_move_to_side_s, 0, + BINDING_PER_WINDOW, NULL, + _("Move window to south (bottom) side of screen")) +keybind (move_to_side_e, handle_move_to_side_e, 0, + BINDING_PER_WINDOW, NULL, + _("Move window to east (right) side of screen")) +keybind (move_to_side_w, handle_move_to_side_w, 0, + BINDING_PER_WINDOW, NULL, + _("Move window to west (left) side of screen")) +keybind (move_to_center, handle_move_to_center, 0, + BINDING_PER_WINDOW, NULL, + _("Move window to center of screen")) + +/* eof all-keybindings.h */ + diff --git a/src/include/boxes.h b/src/include/boxes.h new file mode 100644 index 00000000..5c76ed6b --- /dev/null +++ b/src/include/boxes.h @@ -0,0 +1,290 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* Simple box operations */ + +/* + * Copyright (C) 2005, 2006 Elijah Newren + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_BOXES_H +#define META_BOXES_H + +#include <glib.h> +#include "common.h" + +typedef struct _MetaRectangle MetaRectangle; +struct _MetaRectangle +{ + int x; + int y; + int width; + int height; +}; + +typedef struct _MetaStrut MetaStrut; +struct _MetaStrut +{ + MetaRectangle rect; + MetaSide side; +}; + +#define BOX_LEFT(box) ((box).x) /* Leftmost pixel of rect */ +#define BOX_RIGHT(box) ((box).x + (box).width) /* One pixel past right */ +#define BOX_TOP(box) ((box).y) /* Topmost pixel of rect */ +#define BOX_BOTTOM(box) ((box).y + (box).height) /* One pixel past bottom */ + +typedef enum +{ + FIXED_DIRECTION_NONE = 0, + FIXED_DIRECTION_X = 1 << 0, + FIXED_DIRECTION_Y = 1 << 1, +} FixedDirections; + +typedef enum +{ + META_EDGE_WINDOW, + META_EDGE_XINERAMA, + META_EDGE_SCREEN +} MetaEdgeType; + +typedef struct _MetaEdge MetaEdge; +struct _MetaEdge +{ + MetaRectangle rect; /* width or height should be 1 */ + MetaSide side_type; + MetaEdgeType edge_type; +}; + +/* Output functions -- note that the output buffer had better be big enough: + * rect_to_string: RECT_LENGTH + * region_to_string: (RECT_LENGTH+strlen(separator_string)) * + * g_list_length (region) + * edge_to_string: EDGE_LENGTH + * edge_list_to_...: (EDGE_LENGTH+strlen(separator_string)) * + * g_list_length (edge_list) + */ +#define RECT_LENGTH 27 +#define EDGE_LENGTH 37 +char* meta_rectangle_to_string (const MetaRectangle *rect, + char *output); +char* meta_rectangle_region_to_string (GList *region, + const char *separator_string, + char *output); +char* meta_rectangle_edge_to_string (const MetaEdge *edge, + char *output); +char* meta_rectangle_edge_list_to_string ( + GList *edge_list, + const char *separator_string, + char *output); + +/* Function to make initializing a rect with a single line of code easy */ +MetaRectangle meta_rect (int x, int y, int width, int height); + +/* Basic comparison functions */ +int meta_rectangle_area (const MetaRectangle *rect); +gboolean meta_rectangle_intersect (const MetaRectangle *src1, + const MetaRectangle *src2, + MetaRectangle *dest); +gboolean meta_rectangle_equal (const MetaRectangle *src1, + const MetaRectangle *src2); + +/* Find the bounding box of the union of two rectangles */ +void meta_rectangle_union (const MetaRectangle *rect1, + const MetaRectangle *rect2, + MetaRectangle *dest); + +/* overlap is similar to intersect but doesn't provide location of + * intersection information. + */ +gboolean meta_rectangle_overlap (const MetaRectangle *rect1, + const MetaRectangle *rect2); + +/* vert_overlap means ignore the horizontal location and ask if the + * vertical parts overlap. An alternate way to think of it is "Does there + * exist a way to shift either rect horizontally so that the two rects + * overlap?" horiz_overlap is similar. + */ +gboolean meta_rectangle_vert_overlap (const MetaRectangle *rect1, + const MetaRectangle *rect2); +gboolean meta_rectangle_horiz_overlap (const MetaRectangle *rect1, + const MetaRectangle *rect2); + +/* could_fit_rect determines whether "outer_rect" is big enough to contain + * inner_rect. contains_rect checks whether it actually contains it. + */ +gboolean meta_rectangle_could_fit_rect (const MetaRectangle *outer_rect, + const MetaRectangle *inner_rect); +gboolean meta_rectangle_contains_rect (const MetaRectangle *outer_rect, + const MetaRectangle *inner_rect); + +/* Resize old_rect to the given new_width and new_height, but store the + * result in rect. NOTE THAT THIS IS RESIZE ONLY SO IT CANNOT BE USED FOR + * A MOVERESIZE OPERATION (that simplies the routine a little bit as it + * means there's no difference between NorthWestGravity and StaticGravity. + * Also, I lied a little bit--technically, you could use it in a MoveResize + * operation if you muck with old_rect just right). + */ +void meta_rectangle_resize_with_gravity (const MetaRectangle *old_rect, + MetaRectangle *rect, + int gravity, + int new_width, + int new_height); + +/* find a list of rectangles with the property that a window is contained + * in the given region if and only if it is contained in one of the + * rectangles in the list. + * + * In this case, the region is given by taking basic_rect, removing from + * it the intersections with all the rectangles in the all_struts list, + * then expanding all the rectangles in the resulting list by the given + * amounts on each side. + * + * See boxes.c for more details. + */ +GList* meta_rectangle_get_minimal_spanning_set_for_region ( + const MetaRectangle *basic_rect, + const GSList *all_struts); + +/* Expand all rectangles in region by the given amount on each side */ +GList* meta_rectangle_expand_region (GList *region, + const int left_expand, + const int right_expand, + const int top_expand, + const int bottom_expand); +/* Same as for meta_rectangle_expand_region except that rectangles not at + * least min_x or min_y in size are not expanded in that direction + */ +GList* meta_rectangle_expand_region_conditionally ( + GList *region, + const int left_expand, + const int right_expand, + const int top_expand, + const int bottom_expand, + const int min_x, + const int min_y); + +/* Expand rect in direction to the size of expand_to, and then clip out any + * overlapping struts oriented orthognal to the expansion direction. (Think + * horizontal or vertical maximization) + */ +void meta_rectangle_expand_to_avoiding_struts ( + MetaRectangle *rect, + const MetaRectangle *expand_to, + const MetaDirection direction, + const GSList *all_struts); + +/* Free the list created by + * meta_rectangle_get_minimal_spanning_set_for_region() + * or + * meta_rectangle_find_onscreen_edges () + * or + * meta_rectangle_find_nonintersected_xinerama_edges() + */ +void meta_rectangle_free_list_and_elements (GList *filled_list); + +/* could_fit_in_region determines whether one of the spanning_rects is + * big enough to contain rect. contained_in_region checks whether one + * actually contains it. + */ +gboolean meta_rectangle_could_fit_in_region ( + const GList *spanning_rects, + const MetaRectangle *rect); +gboolean meta_rectangle_contained_in_region ( + const GList *spanning_rects, + const MetaRectangle *rect); +gboolean meta_rectangle_overlaps_with_region ( + const GList *spanning_rects, + const MetaRectangle *rect); + +/* Make the rectangle small enough to fit into one of the spanning_rects, + * but make it no smaller than min_size. + */ +void meta_rectangle_clamp_to_fit_into_region ( + const GList *spanning_rects, + FixedDirections fixed_directions, + MetaRectangle *rect, + const MetaRectangle *min_size); + +/* Clip the rectangle so that it fits into one of the spanning_rects, assuming + * it overlaps with at least one of them + */ +void meta_rectangle_clip_to_region (const GList *spanning_rects, + FixedDirections fixed_directions, + MetaRectangle *rect); + +/* Shove the rectangle into one of the spanning_rects, assuming it fits in + * one of them. + */ +void meta_rectangle_shove_into_region( + const GList *spanning_rects, + FixedDirections fixed_directions, + MetaRectangle *rect); + +/* Finds the point on the line connecting (x1,y1) to (x2,y2) which is closest + * to (px, py). Useful for finding an optimal rectangle size when given a + * range between two sizes that are all candidates. + */ +void meta_rectangle_find_linepoint_closest_to_point (double x1, double y1, + double x2, double y2, + double px, double py, + double *valx, double *valy); + +/***************************************************************************/ +/* */ +/* Switching gears to code for edges instead of just rectangles */ +/* */ +/***************************************************************************/ + +/* Return whether an edge overlaps or is adjacent to the rectangle in the + * nonzero-width dimension of the edge. + */ +gboolean meta_rectangle_edge_aligns (const MetaRectangle *rect, + const MetaEdge *edge); + +/* Compare two edges, so that sorting functions can put a list of edges in + * canonical order. + */ +gint meta_rectangle_edge_cmp (gconstpointer a, gconstpointer b); + +/* Compare two edges, so that sorting functions can put a list of edges in + * order. This function doesn't separate left edges first, then right edges, + * etc., but rather compares only upon location. + */ +gint meta_rectangle_edge_cmp_ignore_type (gconstpointer a, gconstpointer b); + +/* Removes an parts of edges in the given list that intersect any box in the + * given rectangle list. Returns the result. + */ +GList* meta_rectangle_remove_intersections_with_boxes_from_edges ( + GList *edges, + const GSList *rectangles); + +/* Finds all the edges of an onscreen region, returning a GList* of + * MetaEdgeRect's. + */ +GList* meta_rectangle_find_onscreen_edges (const MetaRectangle *basic_rect, + const GSList *all_struts); + +/* Finds edges between adjacent xineramas which are not covered by the given + * struts. + */ +GList* meta_rectangle_find_nonintersected_xinerama_edges ( + const GList *xinerama_rects, + const GSList *all_struts); + +#endif /* META_BOXES_H */ diff --git a/src/include/common.h b/src/include/common.h new file mode 100644 index 00000000..ccb592f6 --- /dev/null +++ b/src/include/common.h @@ -0,0 +1,300 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* Marco common types shared by core.h and ui.h */ + +/* + * Copyright (C) 2001 Havoc Pennington + * Copyright (C) 2005 Elijah Newren + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_COMMON_H +#define META_COMMON_H + +/* Don't include GTK or core headers here */ +#include <X11/Xlib.h> +#include <glib.h> + +typedef struct _MetaResizePopup MetaResizePopup; + +typedef enum +{ + META_FRAME_ALLOWS_DELETE = 1 << 0, + META_FRAME_ALLOWS_MENU = 1 << 1, + META_FRAME_ALLOWS_MINIMIZE = 1 << 2, + META_FRAME_ALLOWS_MAXIMIZE = 1 << 3, + META_FRAME_ALLOWS_VERTICAL_RESIZE = 1 << 4, + META_FRAME_ALLOWS_HORIZONTAL_RESIZE = 1 << 5, + META_FRAME_HAS_FOCUS = 1 << 6, + META_FRAME_SHADED = 1 << 7, + META_FRAME_STUCK = 1 << 8, + META_FRAME_MAXIMIZED = 1 << 9, + META_FRAME_ALLOWS_SHADE = 1 << 10, + META_FRAME_ALLOWS_MOVE = 1 << 11, + META_FRAME_FULLSCREEN = 1 << 12, + META_FRAME_IS_FLASHING = 1 << 13, + META_FRAME_ABOVE = 1 << 14 +} MetaFrameFlags; + +typedef enum +{ + META_MENU_OP_NONE = 0, + META_MENU_OP_DELETE = 1 << 0, + META_MENU_OP_MINIMIZE = 1 << 1, + META_MENU_OP_UNMAXIMIZE = 1 << 2, + META_MENU_OP_MAXIMIZE = 1 << 3, + META_MENU_OP_UNSHADE = 1 << 4, + META_MENU_OP_SHADE = 1 << 5, + META_MENU_OP_UNSTICK = 1 << 6, + META_MENU_OP_STICK = 1 << 7, + META_MENU_OP_WORKSPACES = 1 << 8, + META_MENU_OP_MOVE = 1 << 9, + META_MENU_OP_RESIZE = 1 << 10, + META_MENU_OP_ABOVE = 1 << 11, + META_MENU_OP_UNABOVE = 1 << 12, + META_MENU_OP_MOVE_LEFT = 1 << 13, + META_MENU_OP_MOVE_RIGHT = 1 << 14, + META_MENU_OP_MOVE_UP = 1 << 15, + META_MENU_OP_MOVE_DOWN = 1 << 16, + META_MENU_OP_RECOVER = 1 << 17 +} MetaMenuOp; + +typedef struct _MetaWindowMenu MetaWindowMenu; + +typedef void (* MetaWindowMenuFunc) (MetaWindowMenu *menu, + Display *xdisplay, + Window client_xwindow, + guint32 timestamp, + MetaMenuOp op, + int workspace, + gpointer data); + +/* when changing this enum, there are various switch statements + * you have to update + */ +typedef enum +{ + META_GRAB_OP_NONE, + + /* Mouse ops */ + META_GRAB_OP_MOVING, + META_GRAB_OP_RESIZING_SE, + META_GRAB_OP_RESIZING_S, + META_GRAB_OP_RESIZING_SW, + META_GRAB_OP_RESIZING_N, + META_GRAB_OP_RESIZING_NE, + META_GRAB_OP_RESIZING_NW, + META_GRAB_OP_RESIZING_W, + META_GRAB_OP_RESIZING_E, + + /* Keyboard ops */ + META_GRAB_OP_KEYBOARD_MOVING, + META_GRAB_OP_KEYBOARD_RESIZING_UNKNOWN, + META_GRAB_OP_KEYBOARD_RESIZING_S, + META_GRAB_OP_KEYBOARD_RESIZING_N, + META_GRAB_OP_KEYBOARD_RESIZING_W, + META_GRAB_OP_KEYBOARD_RESIZING_E, + META_GRAB_OP_KEYBOARD_RESIZING_SE, + META_GRAB_OP_KEYBOARD_RESIZING_NE, + META_GRAB_OP_KEYBOARD_RESIZING_SW, + META_GRAB_OP_KEYBOARD_RESIZING_NW, + + /* Alt+Tab */ + META_GRAB_OP_KEYBOARD_TABBING_NORMAL, + META_GRAB_OP_KEYBOARD_TABBING_DOCK, + + /* Alt+Esc */ + META_GRAB_OP_KEYBOARD_ESCAPING_NORMAL, + META_GRAB_OP_KEYBOARD_ESCAPING_DOCK, + + META_GRAB_OP_KEYBOARD_ESCAPING_GROUP, + + /* Alt+F6 */ + META_GRAB_OP_KEYBOARD_TABBING_GROUP, + + META_GRAB_OP_KEYBOARD_WORKSPACE_SWITCHING, + + /* Frame button ops */ + META_GRAB_OP_CLICKING_MINIMIZE, + META_GRAB_OP_CLICKING_MAXIMIZE, + META_GRAB_OP_CLICKING_UNMAXIMIZE, + META_GRAB_OP_CLICKING_DELETE, + META_GRAB_OP_CLICKING_MENU, + META_GRAB_OP_CLICKING_SHADE, + META_GRAB_OP_CLICKING_UNSHADE, + META_GRAB_OP_CLICKING_ABOVE, + META_GRAB_OP_CLICKING_UNABOVE, + META_GRAB_OP_CLICKING_STICK, + META_GRAB_OP_CLICKING_UNSTICK +} MetaGrabOp; + +typedef enum +{ + META_CURSOR_DEFAULT, + META_CURSOR_NORTH_RESIZE, + META_CURSOR_SOUTH_RESIZE, + META_CURSOR_WEST_RESIZE, + META_CURSOR_EAST_RESIZE, + META_CURSOR_SE_RESIZE, + META_CURSOR_SW_RESIZE, + META_CURSOR_NE_RESIZE, + META_CURSOR_NW_RESIZE, + META_CURSOR_MOVE_OR_RESIZE_WINDOW, + META_CURSOR_BUSY + +} MetaCursor; + +typedef enum +{ + META_FOCUS_MODE_CLICK, + META_FOCUS_MODE_SLOPPY, + META_FOCUS_MODE_MOUSE +} MetaFocusMode; + +typedef enum +{ + META_FOCUS_NEW_WINDOWS_SMART, + META_FOCUS_NEW_WINDOWS_STRICT +} MetaFocusNewWindows; + +typedef enum +{ + META_ACTION_TITLEBAR_TOGGLE_SHADE, + META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE, + META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE_HORIZONTALLY, + META_ACTION_TITLEBAR_TOGGLE_MAXIMIZE_VERTICALLY, + META_ACTION_TITLEBAR_MINIMIZE, + META_ACTION_TITLEBAR_NONE, + META_ACTION_TITLEBAR_LOWER, + META_ACTION_TITLEBAR_MENU, + META_ACTION_TITLEBAR_LAST +} MetaActionTitlebar; + +typedef enum +{ + META_FRAME_TYPE_NORMAL, + META_FRAME_TYPE_DIALOG, + META_FRAME_TYPE_MODAL_DIALOG, + META_FRAME_TYPE_UTILITY, + META_FRAME_TYPE_MENU, + META_FRAME_TYPE_BORDER, + META_FRAME_TYPE_LAST +} MetaFrameType; + +typedef enum +{ + /* Create gratuitous divergence from regular + * X mod bits, to be sure we find bugs + */ + META_VIRTUAL_SHIFT_MASK = 1 << 5, + META_VIRTUAL_CONTROL_MASK = 1 << 6, + META_VIRTUAL_ALT_MASK = 1 << 7, + META_VIRTUAL_META_MASK = 1 << 8, + META_VIRTUAL_SUPER_MASK = 1 << 9, + META_VIRTUAL_HYPER_MASK = 1 << 10, + META_VIRTUAL_MOD2_MASK = 1 << 11, + META_VIRTUAL_MOD3_MASK = 1 << 12, + META_VIRTUAL_MOD4_MASK = 1 << 13, + META_VIRTUAL_MOD5_MASK = 1 << 14 +} MetaVirtualModifier; + +/* Relative directions or sides seem to come up all over the place... */ +/* FIXME: Replace + * screen.[ch]:MetaScreenDirection, + * workspace.[ch]:MetaMotionDirection, + * with the use of MetaDirection. + */ +typedef enum +{ + META_DIRECTION_LEFT = 1 << 0, + META_DIRECTION_RIGHT = 1 << 1, + META_DIRECTION_TOP = 1 << 2, + META_DIRECTION_BOTTOM = 1 << 3, + + /* Some aliases for making code more readable for various circumstances. */ + META_DIRECTION_UP = META_DIRECTION_TOP, + META_DIRECTION_DOWN = META_DIRECTION_BOTTOM, + + /* A few more definitions using aliases */ + META_DIRECTION_HORIZONTAL = META_DIRECTION_LEFT | META_DIRECTION_RIGHT, + META_DIRECTION_VERTICAL = META_DIRECTION_UP | META_DIRECTION_DOWN, +} MetaDirection; + +/* Sometimes we want to talk about sides instead of directions; note + * that the values must be as follows or meta_window_update_struts() + * won't work. Using these values also is a safety blanket since + * MetaDirection used to be used as a side. + */ +typedef enum +{ + META_SIDE_LEFT = META_DIRECTION_LEFT, + META_SIDE_RIGHT = META_DIRECTION_RIGHT, + META_SIDE_TOP = META_DIRECTION_TOP, + META_SIDE_BOTTOM = META_DIRECTION_BOTTOM +} MetaSide; + +/* Function a window button can have. Note, you can't add stuff here + * without extending the theme format to draw a new function and + * breaking all existing themes. + */ +typedef enum +{ + META_BUTTON_FUNCTION_MENU, + META_BUTTON_FUNCTION_MINIMIZE, + META_BUTTON_FUNCTION_MAXIMIZE, + META_BUTTON_FUNCTION_CLOSE, + META_BUTTON_FUNCTION_SHADE, + META_BUTTON_FUNCTION_ABOVE, + META_BUTTON_FUNCTION_STICK, + META_BUTTON_FUNCTION_UNSHADE, + META_BUTTON_FUNCTION_UNABOVE, + META_BUTTON_FUNCTION_UNSTICK, + META_BUTTON_FUNCTION_LAST +} MetaButtonFunction; + +#define MAX_BUTTONS_PER_CORNER META_BUTTON_FUNCTION_LAST + +typedef struct _MetaButtonLayout MetaButtonLayout; +struct _MetaButtonLayout +{ + /* buttons in the group on the left side */ + MetaButtonFunction left_buttons[MAX_BUTTONS_PER_CORNER]; + gboolean left_buttons_has_spacer[MAX_BUTTONS_PER_CORNER]; + + /* buttons in the group on the right side */ + MetaButtonFunction right_buttons[MAX_BUTTONS_PER_CORNER]; + gboolean right_buttons_has_spacer[MAX_BUTTONS_PER_CORNER]; +}; + +/* should investigate changing these to whatever most apps use */ +#define META_ICON_WIDTH 32 +#define META_ICON_HEIGHT 32 +#define META_MINI_ICON_WIDTH 16 +#define META_MINI_ICON_HEIGHT 16 + +#define META_DEFAULT_ICON_NAME "window" + +#define META_PRIORITY_PREFS_NOTIFY (G_PRIORITY_DEFAULT_IDLE + 10) +#define META_PRIORITY_WORK_AREA_HINT (G_PRIORITY_DEFAULT_IDLE + 15) + +#define POINT_IN_RECT(xcoord, ycoord, rect) \ + ((xcoord) >= (rect).x && \ + (xcoord) < ((rect).x + (rect).width) && \ + (ycoord) >= (rect).y && \ + (ycoord) < ((rect).y + (rect).height)) + +#endif diff --git a/src/include/compositor.h b/src/include/compositor.h new file mode 100644 index 00000000..a7f9bf1f --- /dev/null +++ b/src/include/compositor.h @@ -0,0 +1,76 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* + * Copyright (C) 2008 Iain Holmes + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_COMPOSITOR_H +#define META_COMPOSITOR_H + +#include <glib.h> +#include <X11/Xlib.h> + +#include "types.h" +#include "boxes.h" + +MetaCompositor *meta_compositor_new (MetaDisplay *display); +void meta_compositor_destroy (MetaCompositor *compositor); + +void meta_compositor_manage_screen (MetaCompositor *compositor, + MetaScreen *screen); +void meta_compositor_unmanage_screen (MetaCompositor *compositor, + MetaScreen *screen); + +void meta_compositor_add_window (MetaCompositor *compositor, + MetaWindow *window, + Window xwindow, + XWindowAttributes *attrs); +void meta_compositor_remove_window (MetaCompositor *compositor, + Window xwindow); + +void meta_compositor_set_updates (MetaCompositor *compositor, + MetaWindow *window, + gboolean updates); + +void meta_compositor_process_event (MetaCompositor *compositor, + XEvent *event, + MetaWindow *window); +Pixmap meta_compositor_get_window_pixmap (MetaCompositor *compositor, + MetaWindow *window); +void meta_compositor_set_active_window (MetaCompositor *compositor, + MetaScreen *screen, + MetaWindow *window); + +void meta_compositor_begin_move (MetaCompositor *compositor, + MetaWindow *window, + MetaRectangle *initial, + int grab_x, int grab_y); +void meta_compositor_update_move (MetaCompositor *compositor, + MetaWindow *window, + int x, int y); +void meta_compositor_end_move (MetaCompositor *compositor, + MetaWindow *window); +void meta_compositor_free_window (MetaCompositor *compositor, + MetaWindow *window); + +#endif + + + + + diff --git a/src/include/core.h b/src/include/core.h new file mode 100644 index 00000000..ded94c4e --- /dev/null +++ b/src/include/core.h @@ -0,0 +1,208 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* Marco interface used by GTK+ UI to talk to core */ + +/* + * Copyright (C) 2001 Havoc Pennington + * Copyright (C) 2005 Elijah Newren + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_CORE_H +#define META_CORE_H + +/* Don't include core headers here */ +#include <gdk/gdkx.h> +#include "common.h" + +typedef enum +{ + META_CORE_GET_END = 0, + META_CORE_WINDOW_HAS_FRAME, + META_CORE_GET_CLIENT_WIDTH, + META_CORE_GET_CLIENT_HEIGHT, + META_CORE_IS_TITLEBAR_ONSCREEN, + META_CORE_GET_CLIENT_XWINDOW, + META_CORE_GET_FRAME_FLAGS, + META_CORE_GET_FRAME_TYPE, + META_CORE_GET_MINI_ICON, + META_CORE_GET_ICON, + META_CORE_GET_X, + META_CORE_GET_Y, + META_CORE_GET_FRAME_WORKSPACE, + META_CORE_GET_FRAME_X, + META_CORE_GET_FRAME_Y, + META_CORE_GET_FRAME_WIDTH, + META_CORE_GET_FRAME_HEIGHT, + META_CORE_GET_SCREEN_WIDTH, + META_CORE_GET_SCREEN_HEIGHT, +} MetaCoreGetType; + +/* General information function about the given window. Pass in a sequence of + * pairs of MetaCoreGetTypes and pointers to variables; the variables will be + * filled with the requested values. End the list with META_CORE_GET_END. + * For example: + * + * meta_core_get (my_display, my_window, + * META_CORE_GET_X, &x, + * META_CORE_GET_Y, &y, + * META_CORE_GET_END); + * + * If the window doesn't have a frame, this will raise a meta_bug. To suppress + * this behaviour, ask META_CORE_WINDOW_HAS_FRAME as the *first* question in + * the list. If the window has no frame, the answer to this question will be + * False, and anything else you asked will be undefined. Otherwise, the answer + * will be True. The answer will necessarily be True if you ask the question + * in any other position. The positions of all other questions don't matter. + * + * The reason for this function is that some parts of the program don't know + * about MetaWindows. But they *can* see core.h. So we used to have a whole + * load of functions which took a display and an X window, looked up the + * relevant MetaWindow, and returned information about it. The trouble with + * that is that looking up the MetaWindow is a nontrivial operation, and + * consolidating the calls in this way makes (for example) frame exposes + * 33% faster, according to valgrind. + * + * This function would perhaps be slightly better if the questions were + * represented by pointers, perhaps gchar*s, because then we could take + * advantage of gcc's automatic sentinel checking. On the other hand, this + * immediately suggests string comparison, and that's slow. + * + * Another possible improvement is that core.h still has a bunch of + * functions which can't be described by the formula "give a display and + * an X window, get a single value" (meta_core_user_move, for example), but + * which could theoretically be handled by this function if we relaxed the + * requirement that all questions should have exactly one argument. + */ +void meta_core_get (Display *xdisplay, + Window window, + ...); + +void meta_core_queue_frame_resize (Display *xdisplay, + Window frame_xwindow); + +/* Move as a result of user operation */ +void meta_core_user_move (Display *xdisplay, + Window frame_xwindow, + int x, + int y); +void meta_core_user_resize (Display *xdisplay, + Window frame_xwindow, + int gravity, + int width, + int height); + +void meta_core_user_raise (Display *xdisplay, + Window frame_xwindow); +void meta_core_user_lower_and_unfocus (Display *xdisplay, + Window frame_xwindow, + guint32 timestamp); + +void meta_core_user_focus (Display *xdisplay, + Window frame_xwindow, + guint32 timestamp); + +void meta_core_minimize (Display *xdisplay, + Window frame_xwindow); +void meta_core_toggle_maximize (Display *xdisplay, + Window frame_xwindow); +void meta_core_toggle_maximize_horizontally (Display *xdisplay, + Window frame_xwindow); +void meta_core_toggle_maximize_vertically (Display *xdisplay, + Window frame_xwindow); +void meta_core_unmaximize (Display *xdisplay, + Window frame_xwindow); +void meta_core_maximize (Display *xdisplay, + Window frame_xwindow); +void meta_core_delete (Display *xdisplay, + Window frame_xwindow, + guint32 timestamp); +void meta_core_unshade (Display *xdisplay, + Window frame_xwindow, + guint32 timestamp); +void meta_core_shade (Display *xdisplay, + Window frame_xwindow, + guint32 timestamp); +void meta_core_unstick (Display *xdisplay, + Window frame_xwindow); +void meta_core_stick (Display *xdisplay, + Window frame_xwindow); +void meta_core_unmake_above (Display *xdisplay, + Window frame_xwindow); +void meta_core_make_above (Display *xdisplay, + Window frame_xwindow); +void meta_core_change_workspace (Display *xdisplay, + Window frame_xwindow, + int new_workspace); + +int meta_core_get_num_workspaces (Screen *xscreen); +int meta_core_get_active_workspace (Screen *xscreen); +int meta_core_get_frame_workspace (Display *xdisplay, + Window frame_xwindow); +const char* meta_core_get_workspace_name_with_index (Display *xdisplay, + Window xroot, + int index); + +void meta_core_show_window_menu (Display *xdisplay, + Window frame_xwindow, + int root_x, + int root_y, + int button, + guint32 timestamp); + +void meta_core_get_menu_accelerator (MetaMenuOp menu_op, + int workspace, + unsigned int *keysym, + MetaVirtualModifier *modifiers); + +gboolean meta_core_begin_grab_op (Display *xdisplay, + Window frame_xwindow, + MetaGrabOp op, + gboolean pointer_already_grabbed, + gboolean frame_action, + int button, + gulong modmask, + guint32 timestamp, + int root_x, + int root_y); +void meta_core_end_grab_op (Display *xdisplay, + guint32 timestamp); +MetaGrabOp meta_core_get_grab_op (Display *xdisplay); +Window meta_core_get_grab_frame (Display *xdisplay); +int meta_core_get_grab_button (Display *xdisplay); + + +void meta_core_grab_buttons (Display *xdisplay, + Window frame_xwindow); + +void meta_core_set_screen_cursor (Display *xdisplay, + Window frame_on_screen, + MetaCursor cursor); + +/* Used because we ignore EnterNotify when a window is unmapped that + * really shouldn't cause focus changes, by comparing the event serial + * of the EnterNotify and the UnmapNotify. + */ +void meta_core_increment_event_serial (Display *display); + +void meta_invalidate_default_icons (void); + +#endif + + + + diff --git a/src/include/display.h b/src/include/display.h new file mode 100644 index 00000000..53dd9d75 --- /dev/null +++ b/src/include/display.h @@ -0,0 +1,48 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* + * Copyright (C) 2008 Iain Holmes + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_DISPLAY_H +#define META_DISPLAY_H + +#include <glib.h> +#include <X11/Xlib.h> + +#include "types.h" + +#define meta_XFree(p) do { if ((p)) XFree ((p)); } while (0) + +void meta_display_get_compositor_version (MetaDisplay *display, + int *major, + int *minor); +Display *meta_display_get_xdisplay (MetaDisplay *display); +MetaCompositor *meta_display_get_compositor (MetaDisplay *display); +GSList *meta_display_get_screens (MetaDisplay *display); + +gboolean meta_display_has_shape (MetaDisplay *display); + +MetaScreen *meta_display_screen_for_root (MetaDisplay *display, + Window xroot); +MetaWindow *meta_display_get_focus_window (MetaDisplay *display); + +int meta_display_get_damage_event_base (MetaDisplay *display); +int meta_display_get_shape_event_base (MetaDisplay *display); + +#endif diff --git a/src/include/errors.h b/src/include/errors.h new file mode 100644 index 00000000..d3fa5a96 --- /dev/null +++ b/src/include/errors.h @@ -0,0 +1,51 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* Marco X error handling */ + +/* + * Copyright (C) 2001 Havoc Pennington + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_ERRORS_H +#define META_ERRORS_H + +#include <X11/Xlib.h> + +#include "util.h" +#include "display.h" + +typedef void (* ErrorHandler) (Display *dpy, + XErrorEvent *error, + gpointer data); + +void meta_errors_init (void); +void meta_errors_register_foreign_display (Display *foreign_dpy, + ErrorHandler handler, + gpointer data); + +void meta_error_trap_push (MetaDisplay *display); +void meta_error_trap_pop (MetaDisplay *display, + gboolean last_request_was_roundtrip); + +void meta_error_trap_push_with_return (MetaDisplay *display); +/* returns X error code, or 0 for no error */ +int meta_error_trap_pop_with_return (MetaDisplay *display, + gboolean last_request_was_roundtrip); + + +#endif diff --git a/src/include/frame.h b/src/include/frame.h new file mode 100644 index 00000000..eeb57263 --- /dev/null +++ b/src/include/frame.h @@ -0,0 +1,31 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* + * Copyright (C) 2008 Iain Holmes + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_FRAME_H +#define META_FRAME_H + +#include <X11/Xlib.h> + +#include "types.h" + +Window meta_frame_get_xwindow (MetaFrame *frame); + +#endif diff --git a/src/include/main.h b/src/include/main.h new file mode 100644 index 00000000..d5789696 --- /dev/null +++ b/src/include/main.h @@ -0,0 +1,43 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* Marco main */ + +/* + * Copyright (C) 2001 Havoc Pennington + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_MAIN_H +#define META_MAIN_H + +#include <glib.h> + +typedef enum +{ + META_EXIT_SUCCESS, + META_EXIT_ERROR +} MetaExitCode; + +/* exit immediately */ +void meta_exit (MetaExitCode code); + +/* g_main_loop_quit() then fall out of main() */ +void meta_quit (MetaExitCode code); + +void meta_restart (void); + +#endif diff --git a/src/include/prefs.h b/src/include/prefs.h new file mode 100644 index 00000000..39597f9f --- /dev/null +++ b/src/include/prefs.h @@ -0,0 +1,233 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* Marco preferences */ + +/* + * Copyright (C) 2001 Havoc Pennington + * Copyright (C) 2006 Elijah Newren + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_PREFS_H +#define META_PREFS_H + +/* This header is a "common" one between the UI and core side */ +#include "common.h" +#include <pango/pango-font.h> + +typedef enum +{ + META_PREF_MOUSE_BUTTON_MODS, + META_PREF_FOCUS_MODE, + META_PREF_FOCUS_NEW_WINDOWS, + META_PREF_RAISE_ON_CLICK, + META_PREF_ACTION_DOUBLE_CLICK_TITLEBAR, + META_PREF_ACTION_MIDDLE_CLICK_TITLEBAR, + META_PREF_ACTION_RIGHT_CLICK_TITLEBAR, + META_PREF_AUTO_RAISE, + META_PREF_AUTO_RAISE_DELAY, + META_PREF_THEME, + META_PREF_TITLEBAR_FONT, + META_PREF_NUM_WORKSPACES, + META_PREF_APPLICATION_BASED, + META_PREF_KEYBINDINGS, + META_PREF_DISABLE_WORKAROUNDS, + META_PREF_COMMANDS, + META_PREF_TERMINAL_COMMAND, + META_PREF_BUTTON_LAYOUT, + META_PREF_WORKSPACE_NAMES, + META_PREF_VISUAL_BELL, + META_PREF_AUDIBLE_BELL, + META_PREF_VISUAL_BELL_TYPE, + META_PREF_REDUCED_RESOURCES, + META_PREF_MATE_ACCESSIBILITY, + META_PREF_MATE_ANIMATIONS, + META_PREF_CURSOR_THEME, + META_PREF_CURSOR_SIZE, + META_PREF_COMPOSITING_MANAGER, + META_PREF_RESIZE_WITH_RIGHT_BUTTON, + META_PREF_FORCE_FULLSCREEN +} MetaPreference; + +typedef void (* MetaPrefsChangedFunc) (MetaPreference pref, + gpointer data); + +void meta_prefs_add_listener (MetaPrefsChangedFunc func, + gpointer data); +void meta_prefs_remove_listener (MetaPrefsChangedFunc func, + gpointer data); + +void meta_prefs_init (void); +const char* meta_preference_to_string (MetaPreference pref); + +MetaVirtualModifier meta_prefs_get_mouse_button_mods (void); +guint meta_prefs_get_mouse_button_resize (void); +guint meta_prefs_get_mouse_button_menu (void); +MetaFocusMode meta_prefs_get_focus_mode (void); +MetaFocusNewWindows meta_prefs_get_focus_new_windows (void); +gboolean meta_prefs_get_raise_on_click (void); +const char* meta_prefs_get_theme (void); +/* returns NULL if GTK default should be used */ +const PangoFontDescription* meta_prefs_get_titlebar_font (void); +int meta_prefs_get_num_workspaces (void); +gboolean meta_prefs_get_application_based (void); +gboolean meta_prefs_get_disable_workarounds (void); +gboolean meta_prefs_get_auto_raise (void); +int meta_prefs_get_auto_raise_delay (void); +gboolean meta_prefs_get_reduced_resources (void); +gboolean meta_prefs_get_mate_accessibility (void); +gboolean meta_prefs_get_mate_animations (void); + +const char* meta_prefs_get_command (int i); + +char* meta_prefs_get_mateconf_key_for_command (int i); + +const char* meta_prefs_get_terminal_command (void); +const char* meta_prefs_get_mateconf_key_for_terminal_command (void); + +void meta_prefs_get_button_layout (MetaButtonLayout *button_layout); + +/* Double, right, middle click can be configured to any titlebar meta-action */ +MetaActionTitlebar meta_prefs_get_action_double_click_titlebar (void); +MetaActionTitlebar meta_prefs_get_action_middle_click_titlebar (void); +MetaActionTitlebar meta_prefs_get_action_right_click_titlebar (void); + +void meta_prefs_set_num_workspaces (int n_workspaces); + +const char* meta_prefs_get_workspace_name (int i); +void meta_prefs_change_workspace_name (int i, + const char *name); + +const char* meta_prefs_get_cursor_theme (void); +int meta_prefs_get_cursor_size (void); +gboolean meta_prefs_get_compositing_manager (void); +gboolean meta_prefs_get_force_fullscreen (void); + +/** + * Sets whether the compositor is turned on. + * + * \param whether TRUE to turn on, FALSE to turn off + */ +void meta_prefs_set_compositing_manager (gboolean whether); + +void meta_prefs_set_force_fullscreen (gboolean whether); + +/* XXX FIXME This should be x-macroed, but isn't yet because it would be + * difficult (or perhaps impossible) to add the suffixes using the current + * system. It needs some more thought, perhaps after the current system + * evolves a little. + */ +typedef enum _MetaKeyBindingAction +{ + META_KEYBINDING_ACTION_NONE = -1, + META_KEYBINDING_ACTION_WORKSPACE_1, + META_KEYBINDING_ACTION_WORKSPACE_2, + META_KEYBINDING_ACTION_WORKSPACE_3, + META_KEYBINDING_ACTION_WORKSPACE_4, + META_KEYBINDING_ACTION_WORKSPACE_5, + META_KEYBINDING_ACTION_WORKSPACE_6, + META_KEYBINDING_ACTION_WORKSPACE_7, + META_KEYBINDING_ACTION_WORKSPACE_8, + META_KEYBINDING_ACTION_WORKSPACE_9, + META_KEYBINDING_ACTION_WORKSPACE_10, + META_KEYBINDING_ACTION_WORKSPACE_11, + META_KEYBINDING_ACTION_WORKSPACE_12, + META_KEYBINDING_ACTION_WORKSPACE_LEFT, + META_KEYBINDING_ACTION_WORKSPACE_RIGHT, + META_KEYBINDING_ACTION_WORKSPACE_UP, + META_KEYBINDING_ACTION_WORKSPACE_DOWN, + META_KEYBINDING_ACTION_SWITCH_GROUP, + META_KEYBINDING_ACTION_SWITCH_GROUP_BACKWARD, + META_KEYBINDING_ACTION_SWITCH_WINDOWS, + META_KEYBINDING_ACTION_SWITCH_WINDOWS_BACKWARD, + META_KEYBINDING_ACTION_SWITCH_PANELS, + META_KEYBINDING_ACTION_SWITCH_PANELS_BACKWARD, + META_KEYBINDING_ACTION_CYCLE_GROUP, + META_KEYBINDING_ACTION_CYCLE_GROUP_BACKWARD, + META_KEYBINDING_ACTION_CYCLE_WINDOWS, + META_KEYBINDING_ACTION_CYCLE_WINDOWS_BACKWARD, + META_KEYBINDING_ACTION_CYCLE_PANELS, + META_KEYBINDING_ACTION_CYCLE_PANELS_BACKWARD, + META_KEYBINDING_ACTION_SHOW_DESKTOP, + META_KEYBINDING_ACTION_PANEL_MAIN_MENU, + META_KEYBINDING_ACTION_PANEL_RUN_DIALOG, + META_KEYBINDING_ACTION_COMMAND_1, + META_KEYBINDING_ACTION_COMMAND_2, + META_KEYBINDING_ACTION_COMMAND_3, + META_KEYBINDING_ACTION_COMMAND_4, + META_KEYBINDING_ACTION_COMMAND_5, + META_KEYBINDING_ACTION_COMMAND_6, + META_KEYBINDING_ACTION_COMMAND_7, + META_KEYBINDING_ACTION_COMMAND_8, + META_KEYBINDING_ACTION_COMMAND_9, + META_KEYBINDING_ACTION_COMMAND_10, + META_KEYBINDING_ACTION_COMMAND_11, + META_KEYBINDING_ACTION_COMMAND_12 +} MetaKeyBindingAction; + +typedef struct +{ + unsigned int keysym; + unsigned int keycode; + MetaVirtualModifier modifiers; +} MetaKeyCombo; + +typedef struct +{ + const char *name; + /** + * A list of MetaKeyCombos. Each of them is bound to + * this keypref. If one has keysym==modifiers==0, it is + * ignored. For historical reasons, the first entry is + * governed by the pref FOO and the remainder are + * governed by the pref FOO_list. + */ + GSList *bindings; + + /** for keybindings that can have shift or not like Alt+Tab */ + gboolean add_shift:1; + + /** for keybindings that apply only to a window */ + gboolean per_window:1; +} MetaKeyPref; + +void meta_prefs_get_key_bindings (const MetaKeyPref **bindings, + int *n_bindings); + +MetaKeyBindingAction meta_prefs_get_keybinding_action (const char *name); + +void meta_prefs_get_window_binding (const char *name, + unsigned int *keysym, + MetaVirtualModifier *modifiers); + +typedef enum +{ + META_VISUAL_BELL_INVALID = 0, + META_VISUAL_BELL_FULLSCREEN_FLASH, + META_VISUAL_BELL_FRAME_FLASH + +} MetaVisualBellType; + +gboolean meta_prefs_get_visual_bell (void); +gboolean meta_prefs_bell_is_audible (void); +MetaVisualBellType meta_prefs_get_visual_bell_type (void); + +#endif + + + + diff --git a/src/include/resizepopup.h b/src/include/resizepopup.h new file mode 100644 index 00000000..4e03d5d3 --- /dev/null +++ b/src/include/resizepopup.h @@ -0,0 +1,47 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* Marco resizing-terminal-window feedback */ + +/* + * Copyright (C) 2001 Havoc Pennington + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_RESIZEPOPUP_H +#define META_RESIZEPOPUP_H + +/* Don't include gtk.h or gdk.h here */ +#include "boxes.h" +#include "common.h" +#include <X11/Xlib.h> +#include <glib.h> +#include <gdk-pixbuf/gdk-pixbuf.h> + +MetaResizePopup* meta_ui_resize_popup_new (Display *display, + int screen_number); +void meta_ui_resize_popup_free (MetaResizePopup *popup); +void meta_ui_resize_popup_set (MetaResizePopup *popup, + MetaRectangle rect, + int base_width, + int base_height, + int width_inc, + int height_inc); +void meta_ui_resize_popup_set_showing (MetaResizePopup *popup, + gboolean showing); + +#endif + diff --git a/src/include/screen.h b/src/include/screen.h new file mode 100644 index 00000000..9f842317 --- /dev/null +++ b/src/include/screen.h @@ -0,0 +1,48 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* + * Copyright (C) 2008 Iain Holmes + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_SCREEN_H +#define META_SCREEN_H + +#include <X11/Xlib.h> +#include <glib.h> +#include "types.h" + +int meta_screen_get_screen_number (MetaScreen *screen); +MetaDisplay *meta_screen_get_display (MetaScreen *screen); + +Window meta_screen_get_xroot (MetaScreen *screen); +void meta_screen_get_size (MetaScreen *screen, + int *width, + int *height); + +gpointer meta_screen_get_compositor_data (MetaScreen *screen); +void meta_screen_set_compositor_data (MetaScreen *screen, + gpointer info); + +MetaScreen *meta_screen_for_x_screen (Screen *xscreen); + +#ifdef HAVE_COMPOSITE_EXTENSIONS +void meta_screen_set_cm_selection (MetaScreen *screen); +void meta_screen_unset_cm_selection (MetaScreen *screen); +#endif + +#endif diff --git a/src/include/tabpopup.h b/src/include/tabpopup.h new file mode 100644 index 00000000..2bee506e --- /dev/null +++ b/src/include/tabpopup.h @@ -0,0 +1,67 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* Marco tab popup window */ + +/* + * Copyright (C) 2001 Havoc Pennington + * Copyright (C) 2005 Elijah Newren + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_TABPOPUP_H +#define META_TABPOPUP_H + +/* Don't include gtk.h or gdk.h here */ +#include "common.h" +#include "boxes.h" +#include <X11/Xlib.h> +#include <glib.h> +#include <gdk-pixbuf/gdk-pixbuf.h> + +typedef struct _MetaTabEntry MetaTabEntry; +typedef struct _MetaTabPopup MetaTabPopup; +typedef void *MetaTabEntryKey; + +struct _MetaTabEntry +{ + MetaTabEntryKey key; + const char *title; + GdkPixbuf *icon; + MetaRectangle rect; + MetaRectangle inner_rect; + guint blank : 1; + guint hidden : 1; + guint demands_attention : 1; +}; + +MetaTabPopup* meta_ui_tab_popup_new (const MetaTabEntry *entries, + int screen_number, + int entry_count, + int width, + gboolean outline); +void meta_ui_tab_popup_free (MetaTabPopup *popup); +void meta_ui_tab_popup_set_showing (MetaTabPopup *popup, + gboolean showing); +void meta_ui_tab_popup_forward (MetaTabPopup *popup); +void meta_ui_tab_popup_backward (MetaTabPopup *popup); +MetaTabEntryKey meta_ui_tab_popup_get_selected (MetaTabPopup *popup); +void meta_ui_tab_popup_select (MetaTabPopup *popup, + MetaTabEntryKey key); + + +#endif + diff --git a/src/include/types.h b/src/include/types.h new file mode 100644 index 00000000..045b102f --- /dev/null +++ b/src/include/types.h @@ -0,0 +1,31 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* + * Copyright (C) 2008 Iain Holmes + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_TYPES_H +#define META_TYPES_H + +typedef struct _MetaCompositor MetaCompositor; +typedef struct _MetaDisplay MetaDisplay; +typedef struct _MetaFrame MetaFrame; +typedef struct _MetaScreen MetaScreen; +typedef struct _MetaWindow MetaWindow; + +#endif diff --git a/src/include/ui.h b/src/include/ui.h new file mode 100644 index 00000000..1fce402c --- /dev/null +++ b/src/include/ui.h @@ -0,0 +1,209 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* Marco interface for talking to GTK+ UI module */ + +/* + * Copyright (C) 2001 Havoc Pennington + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_UI_H +#define META_UI_H + +/* Don't include gtk.h or gdk.h here */ +#include "common.h" +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <glib.h> +#include <gdk-pixbuf/gdk-pixbuf.h> + +/* This is between GTK_PRIORITY_RESIZE (+10) and GDK_PRIORITY_REDRAW (+20) */ +#define META_PRIORITY_RESIZE (G_PRIORITY_HIGH_IDLE + 15) + +typedef struct _MetaUI MetaUI; + +typedef struct _MetaImageWindow MetaImageWindow; + +typedef gboolean (* MetaEventFunc) (XEvent *xevent, gpointer data); + +typedef enum +{ + META_UI_DIRECTION_LTR, + META_UI_DIRECTION_RTL +} MetaUIDirection; + +void meta_ui_init (int *argc, char ***argv); + +Display* meta_ui_get_display (void); + +void meta_ui_add_event_func (Display *xdisplay, + MetaEventFunc func, + gpointer data); +void meta_ui_remove_event_func (Display *xdisplay, + MetaEventFunc func, + gpointer data); + +MetaUI* meta_ui_new (Display *xdisplay, + Screen *screen); +void meta_ui_free (MetaUI *ui); + +void meta_ui_theme_get_frame_borders (MetaUI *ui, + MetaFrameType type, + MetaFrameFlags flags, + int *top_height, + int *bottom_height, + int *left_width, + int *right_width); +void meta_ui_get_frame_geometry (MetaUI *ui, + Window frame_xwindow, + int *top_height, int *bottom_height, + int *left_width, int *right_width); +Window meta_ui_create_frame_window (MetaUI *ui, + Display *xdisplay, + Visual *xvisual, + gint x, + gint y, + gint width, + gint height, + gint screen_no); +void meta_ui_destroy_frame_window (MetaUI *ui, + Window xwindow); +void meta_ui_move_resize_frame (MetaUI *ui, + Window frame, + int x, + int y, + int width, + int height); + +/* GDK insists on tracking map/unmap */ +void meta_ui_map_frame (MetaUI *ui, + Window xwindow); +void meta_ui_unmap_frame (MetaUI *ui, + Window xwindow); + +void meta_ui_unflicker_frame_bg (MetaUI *ui, + Window xwindow, + int target_width, + int target_height); +void meta_ui_reset_frame_bg (MetaUI *ui, + Window xwindow); + +void meta_ui_apply_frame_shape (MetaUI *ui, + Window xwindow, + int new_window_width, + int new_window_height, + gboolean window_has_shape); + +void meta_ui_queue_frame_draw (MetaUI *ui, + Window xwindow); + +void meta_ui_set_frame_title (MetaUI *ui, + Window xwindow, + const char *title); + +void meta_ui_repaint_frame (MetaUI *ui, + Window xwindow); + +MetaWindowMenu* meta_ui_window_menu_new (MetaUI *ui, + Window client_xwindow, + MetaMenuOp ops, + MetaMenuOp insensitive, + unsigned long active_workspace, + int n_workspaces, + MetaWindowMenuFunc func, + gpointer data); +void meta_ui_window_menu_popup (MetaWindowMenu *menu, + int root_x, + int root_y, + int button, + guint32 timestamp); +void meta_ui_window_menu_free (MetaWindowMenu *menu); + + +MetaImageWindow* meta_image_window_new (Display *xdisplay, + int screen_number, + int max_width, + int max_height); +void meta_image_window_free (MetaImageWindow *iw); +void meta_image_window_set_showing (MetaImageWindow *iw, + gboolean showing); +void meta_image_window_set (MetaImageWindow *iw, + GdkPixbuf *pixbuf, + int x, + int y); + +/* FIXME these lack a display arg */ +GdkPixbuf* meta_gdk_pixbuf_get_from_window (GdkPixbuf *dest, + Window xwindow, + int src_x, + int src_y, + int dest_x, + int dest_y, + int width, + int height); + +GdkPixbuf* meta_gdk_pixbuf_get_from_pixmap (GdkPixbuf *dest, + Pixmap xpixmap, + int src_x, + int src_y, + int dest_x, + int dest_y, + int width, + int height); + +/* Used when we have a server grab and draw all over everything, + * then we need to handle exposes after doing that, instead of + * during it + */ +void meta_ui_push_delay_exposes (MetaUI *ui); +void meta_ui_pop_delay_exposes (MetaUI *ui); + +GdkPixbuf* meta_ui_get_default_window_icon (MetaUI *ui); +GdkPixbuf* meta_ui_get_default_mini_icon (MetaUI *ui); + +gboolean meta_ui_window_should_not_cause_focus (Display *xdisplay, + Window xwindow); + +char* meta_text_property_to_utf8 (Display *xdisplay, + const XTextProperty *prop); + +void meta_ui_set_current_theme (const char *name, + gboolean force_reload); +gboolean meta_ui_have_a_theme (void); + +gboolean meta_ui_parse_accelerator (const char *accel, + unsigned int *keysym, + unsigned int *keycode, + MetaVirtualModifier *mask); +gboolean meta_ui_parse_modifier (const char *accel, + MetaVirtualModifier *mask); + +/* Caller responsible for freeing return string of meta_ui_accelerator_name! */ +gchar* meta_ui_accelerator_name (unsigned int keysym, + MetaVirtualModifier mask); +gboolean meta_ui_window_is_widget (MetaUI *ui, + Window xwindow); + +int meta_ui_get_drag_threshold (MetaUI *ui); + +MetaUIDirection meta_ui_get_direction (void); + +GdkPixbuf *meta_ui_get_pixbuf_from_pixmap (Pixmap pmap); + +#include "tabpopup.h" + +#endif diff --git a/src/include/util.h b/src/include/util.h new file mode 100644 index 00000000..0607c568 --- /dev/null +++ b/src/include/util.h @@ -0,0 +1,136 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* Marco utilities */ + +/* + * Copyright (C) 2001 Havoc Pennington + * Copyright (C) 2005 Elijah Newren + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_UTIL_H +#define META_UTIL_H + +#include <glib.h> +#include <glib-object.h> + +gboolean meta_is_verbose (void); +void meta_set_verbose (gboolean setting); +gboolean meta_is_debugging (void); +void meta_set_debugging (gboolean setting); +gboolean meta_is_syncing (void); +void meta_set_syncing (gboolean setting); +gboolean meta_get_replace_current_wm (void); +void meta_set_replace_current_wm (gboolean setting); + +void meta_debug_spew_real (const char *format, + ...) G_GNUC_PRINTF (1, 2); +void meta_verbose_real (const char *format, + ...) G_GNUC_PRINTF (1, 2); + +void meta_bug (const char *format, + ...) G_GNUC_PRINTF (1, 2); +void meta_warning (const char *format, + ...) G_GNUC_PRINTF (1, 2); +void meta_fatal (const char *format, + ...) G_GNUC_PRINTF (1, 2); + +typedef enum +{ + META_DEBUG_FOCUS = 1 << 0, + META_DEBUG_WORKAREA = 1 << 1, + META_DEBUG_STACK = 1 << 2, + META_DEBUG_THEMES = 1 << 3, + META_DEBUG_SM = 1 << 4, + META_DEBUG_EVENTS = 1 << 5, + META_DEBUG_WINDOW_STATE = 1 << 6, + META_DEBUG_WINDOW_OPS = 1 << 7, + META_DEBUG_GEOMETRY = 1 << 8, + META_DEBUG_PLACEMENT = 1 << 9, + META_DEBUG_PING = 1 << 10, + META_DEBUG_XINERAMA = 1 << 11, + META_DEBUG_KEYBINDINGS = 1 << 12, + META_DEBUG_SYNC = 1 << 13, + META_DEBUG_ERRORS = 1 << 14, + META_DEBUG_STARTUP = 1 << 15, + META_DEBUG_PREFS = 1 << 16, + META_DEBUG_GROUPS = 1 << 17, + META_DEBUG_RESIZING = 1 << 18, + META_DEBUG_SHAPES = 1 << 19, + META_DEBUG_COMPOSITOR = 1 << 20, + META_DEBUG_EDGE_RESISTANCE = 1 << 21 +} MetaDebugTopic; + +void meta_topic_real (MetaDebugTopic topic, + const char *format, + ...) G_GNUC_PRINTF (2, 3); + +void meta_push_no_msg_prefix (void); +void meta_pop_no_msg_prefix (void); + +gint meta_unsigned_long_equal (gconstpointer v1, + gconstpointer v2); +guint meta_unsigned_long_hash (gconstpointer v); + +void meta_print_backtrace (void); + +const char* meta_gravity_to_string (int gravity); + +#include <libintl.h> +#define _(x) dgettext (GETTEXT_PACKAGE, x) +#define N_(x) x + +char* meta_g_utf8_strndup (const gchar *src, gsize n); + +void meta_free_gslist_and_elements (GSList *list_to_deep_free); + +GPid meta_show_dialog (const char *type, + const char *title, + const char *message, + gint timeout, + const char *ok_text, + const char *cancel_text, + const int transient_for, + GSList *columns, + GSList *entries); + +/* To disable verbose mode, we make these functions into no-ops */ +#ifdef WITH_VERBOSE_MODE + +#define meta_debug_spew meta_debug_spew_real +#define meta_verbose meta_verbose_real +#define meta_topic meta_topic_real + +#else + +# ifdef G_HAVE_ISO_VARARGS +# define meta_debug_spew(...) +# define meta_verbose(...) +# define meta_topic(...) +# elif defined(G_HAVE_GNUC_VARARGS) +# define meta_debug_spew(format...) +# define meta_verbose(format...) +# define meta_topic(format...) +# else +# error "This compiler does not support varargs macros and thus verbose mode can't be disabled meaningfully" +# endif + +#endif /* !WITH_VERBOSE_MODE */ + +#endif /* META_UTIL_H */ + + diff --git a/src/include/window.h b/src/include/window.h new file mode 100644 index 00000000..8a338660 --- /dev/null +++ b/src/include/window.h @@ -0,0 +1,39 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* + * Copyright (C) 2008 Iain Holmes + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_WINDOW_H +#define META_WINDOW_H + +#include <glib.h> +#include <X11/Xlib.h> + +#include "boxes.h" +#include "types.h" + +MetaFrame *meta_window_get_frame (MetaWindow *window); +gboolean meta_window_has_focus (MetaWindow *window); +gboolean meta_window_is_shaded (MetaWindow *window); +MetaRectangle *meta_window_get_rect (MetaWindow *window); +MetaScreen *meta_window_get_screen (MetaWindow *window); +MetaDisplay *meta_window_get_display (MetaWindow *window); +Window meta_window_get_xwindow (MetaWindow *window); + +#endif diff --git a/src/include/xprops.h b/src/include/xprops.h new file mode 100644 index 00000000..58ad22c7 --- /dev/null +++ b/src/include/xprops.h @@ -0,0 +1,227 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ + +/* Marco X property convenience routines */ + +/* + * Copyright (C) 2001 Havoc Pennington + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#ifndef META_XPROPS_H +#define META_XPROPS_H + +#include <config.h> + +#include "display.h" +#include <X11/Xutil.h> + +#ifdef HAVE_XSYNC +#include <X11/extensions/sync.h> +#endif + +/* Copied from Lesstif by way of GTK. Rudimentary docs can be + * found in some Motif reference guides online. + */ +typedef struct { + unsigned long flags; + unsigned long functions; + unsigned long decorations; + long input_mode; + unsigned long status; +} MotifWmHints, MwmHints; + +#define MWM_HINTS_FUNCTIONS (1L << 0) +#define MWM_HINTS_DECORATIONS (1L << 1) +#define MWM_HINTS_INPUT_MODE (1L << 2) +#define MWM_HINTS_STATUS (1L << 3) + +#define MWM_FUNC_ALL (1L << 0) +#define MWM_FUNC_RESIZE (1L << 1) +#define MWM_FUNC_MOVE (1L << 2) +#define MWM_FUNC_MINIMIZE (1L << 3) +#define MWM_FUNC_MAXIMIZE (1L << 4) +#define MWM_FUNC_CLOSE (1L << 5) + +#define MWM_DECOR_ALL (1L << 0) +#define MWM_DECOR_BORDER (1L << 1) +#define MWM_DECOR_RESIZEH (1L << 2) +#define MWM_DECOR_TITLE (1L << 3) +#define MWM_DECOR_MENU (1L << 4) +#define MWM_DECOR_MINIMIZE (1L << 5) +#define MWM_DECOR_MAXIMIZE (1L << 6) + +#define MWM_INPUT_MODELESS 0 +#define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1 +#define MWM_INPUT_SYSTEM_MODAL 2 +#define MWM_INPUT_FULL_APPLICATION_MODAL 3 +#define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL + +#define MWM_TEAROFF_WINDOW (1L<<0) + +/* These all return the memory from Xlib, so require an XFree() + * when they return TRUE. They return TRUE on success. + */ +gboolean meta_prop_get_atom_list (MetaDisplay *display, + Window xwindow, + Atom xatom, + Atom **atoms_p, + int *n_atoms_p); +gboolean meta_prop_get_motif_hints (MetaDisplay *display, + Window xwindow, + Atom xatom, + MotifWmHints **hints_p); +gboolean meta_prop_get_cardinal_list (MetaDisplay *display, + Window xwindow, + Atom xatom, + gulong **cardinals_p, + int *n_cardinals_p); +gboolean meta_prop_get_latin1_string (MetaDisplay *display, + Window xwindow, + Atom xatom, + char **str_p); +gboolean meta_prop_get_utf8_string (MetaDisplay *display, + Window xwindow, + Atom xatom, + char **str_p); +gboolean meta_prop_get_utf8_list (MetaDisplay *display, + Window xwindow, + Atom xatom, + char ***str_p, + int *n_str_p); +void meta_prop_set_utf8_string_hint + (MetaDisplay *display, + Window xwindow, + Atom atom, + const char *val); +gboolean meta_prop_get_window (MetaDisplay *display, + Window xwindow, + Atom xatom, + Window *window_p); +gboolean meta_prop_get_cardinal (MetaDisplay *display, + Window xwindow, + Atom xatom, + gulong *cardinal_p); +gboolean meta_prop_get_cardinal_with_atom_type (MetaDisplay *display, + Window xwindow, + Atom xatom, + Atom prop_type, + gulong *cardinal_p); +gboolean meta_prop_get_text_property (MetaDisplay *display, + Window xwindow, + Atom xatom, + char **utf8_str_p); + +gboolean meta_prop_get_wm_hints (MetaDisplay *display, + Window xwindow, + Atom xatom, + XWMHints **hints_p); + +gboolean meta_prop_get_class_hint (MetaDisplay *display, + Window xwindow, + Atom xatom, + XClassHint *class_hint); + +gboolean meta_prop_get_size_hints (MetaDisplay *display, + Window xwindow, + Atom xatom, + XSizeHints **hints_p, + gulong *flags_p); + +typedef enum +{ + META_PROP_VALUE_INVALID, + META_PROP_VALUE_UTF8, + META_PROP_VALUE_STRING, + META_PROP_VALUE_STRING_AS_UTF8, + META_PROP_VALUE_MOTIF_HINTS, + META_PROP_VALUE_CARDINAL, + META_PROP_VALUE_WINDOW, + META_PROP_VALUE_CARDINAL_LIST, + META_PROP_VALUE_UTF8_LIST, + META_PROP_VALUE_ATOM_LIST, + META_PROP_VALUE_TEXT_PROPERTY, /* comes back as UTF-8 string */ + META_PROP_VALUE_WM_HINTS, + META_PROP_VALUE_CLASS_HINT, + META_PROP_VALUE_SIZE_HINTS, + META_PROP_VALUE_SYNC_COUNTER /* comes back as CARDINAL */ +} MetaPropValueType; + +/* used to request/return/store property values */ +typedef struct +{ + MetaPropValueType type; + Atom atom; + Atom required_type; /* autofilled if None */ + + union + { + char *str; + MotifWmHints *motif_hints; + Window xwindow; + gulong cardinal; + XWMHints *wm_hints; + XClassHint class_hint; +#ifdef HAVE_XSYNC + XSyncCounter xcounter; +#endif + + struct + { + XSizeHints *hints; + unsigned long flags; + } size_hints; + + struct + { + gulong *cardinals; + int n_cardinals; + } cardinal_list; + + struct + { + char **strings; + int n_strings; + } string_list; + + struct + { + Atom *atoms; + int n_atoms; + } atom_list; + + } v; + +} MetaPropValue; + +/* Each value has type and atom initialized. If there's an error, + * or property is unset, type comes back as INVALID; + * else type comes back as it originated, and the data + * is filled in. + */ +void meta_prop_get_values (MetaDisplay *display, + Window xwindow, + MetaPropValue *values, + int n_values); + +void meta_prop_free_values (MetaPropValue *values, + int n_values); + +#endif + + + + |