Commit 6a2cc159 authored by Alberts Muktupāvels's avatar Alberts Muktupāvels

add support for app-menu button in theme

Add app-menu button support in themes. This is done only to support
metacity theme format 3.5 version. Metacity will not show this
button!

Based on mutter commit:
https://git.gnome.org/browse/mutter/commit/?id=c2ea650b3c484312c14f69b8b245ab117ef7c6e1
parent d2b13461
......@@ -1084,6 +1084,8 @@ button_function_from_string (const char *str)
{
if (strcmp (str, "menu") == 0)
return META_BUTTON_FUNCTION_MENU;
else if (strcmp (str, "appmenu") == 0)
return META_BUTTON_FUNCTION_APPMENU;
else if (strcmp (str, "minimize") == 0)
return META_BUTTON_FUNCTION_MINIMIZE;
else if (strcmp (str, "maximize") == 0)
......
......@@ -37,21 +37,22 @@ 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,
META_FRAME_TILED_LEFT = 1 << 15,
META_FRAME_TILED_RIGHT = 1 << 16
META_FRAME_ALLOWS_APPMENU = 1 << 2,
META_FRAME_ALLOWS_MINIMIZE = 1 << 3,
META_FRAME_ALLOWS_MAXIMIZE = 1 << 4,
META_FRAME_ALLOWS_VERTICAL_RESIZE = 1 << 5,
META_FRAME_ALLOWS_HORIZONTAL_RESIZE = 1 << 6,
META_FRAME_HAS_FOCUS = 1 << 7,
META_FRAME_SHADED = 1 << 8,
META_FRAME_STUCK = 1 << 9,
META_FRAME_MAXIMIZED = 1 << 10,
META_FRAME_ALLOWS_SHADE = 1 << 11,
META_FRAME_ALLOWS_MOVE = 1 << 12,
META_FRAME_FULLSCREEN = 1 << 13,
META_FRAME_IS_FLASHING = 1 << 14,
META_FRAME_ABOVE = 1 << 15,
META_FRAME_TILED_LEFT = 1 << 16,
META_FRAME_TILED_RIGHT = 1 << 17
} MetaFrameFlags;
typedef enum
......@@ -138,6 +139,7 @@ typedef enum
META_GRAB_OP_CLICKING_UNMAXIMIZE,
META_GRAB_OP_CLICKING_DELETE,
META_GRAB_OP_CLICKING_MENU,
META_GRAB_OP_CLICKING_APPMENU,
META_GRAB_OP_CLICKING_SHADE,
META_GRAB_OP_CLICKING_UNSHADE,
META_GRAB_OP_CLICKING_ABOVE,
......@@ -233,6 +235,7 @@ typedef enum
typedef enum
{
META_BUTTON_FUNCTION_MENU,
META_BUTTON_FUNCTION_APPMENU,
META_BUTTON_FUNCTION_MINIMIZE,
META_BUTTON_FUNCTION_MAXIMIZE,
META_BUTTON_FUNCTION_CLOSE,
......
......@@ -1095,6 +1095,9 @@ show_tip_now (MetaFrames *frames)
case META_FRAME_CONTROL_MENU:
tiptext = _("Window Menu");
break;
case META_FRAME_CONTROL_APPMENU:
tiptext = _("Window App Menu");
break;
case META_FRAME_CONTROL_MINIMIZE:
tiptext = _("Minimize Window");
break;
......@@ -1442,6 +1445,9 @@ meta_frames_button_press_event (GtkWidget *widget,
case META_FRAME_CONTROL_MENU:
op = META_GRAB_OP_CLICKING_MENU;
break;
case META_FRAME_CONTROL_APPMENU:
op = META_GRAB_OP_CLICKING_APPMENU;
break;
case META_FRAME_CONTROL_SHADE:
op = META_GRAB_OP_CLICKING_SHADE;
break;
......@@ -1690,6 +1696,7 @@ meta_frames_button_release_event (GtkWidget *widget,
break;
case META_GRAB_OP_CLICKING_MENU:
case META_GRAB_OP_CLICKING_APPMENU:
meta_core_end_grab_op (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), event->time);
break;
......@@ -1776,6 +1783,8 @@ meta_frames_update_prelit_control (MetaFrames *frames,
break;
case META_FRAME_CONTROL_MENU:
break;
case META_FRAME_CONTROL_APPMENU:
break;
case META_FRAME_CONTROL_MINIMIZE:
break;
case META_FRAME_CONTROL_MAXIMIZE:
......@@ -1828,6 +1837,7 @@ meta_frames_update_prelit_control (MetaFrames *frames,
switch (control)
{
case META_FRAME_CONTROL_MENU:
case META_FRAME_CONTROL_APPMENU:
case META_FRAME_CONTROL_MINIMIZE:
case META_FRAME_CONTROL_MAXIMIZE:
case META_FRAME_CONTROL_DELETE:
......@@ -1881,6 +1891,7 @@ meta_frames_motion_notify_event (GtkWidget *widget,
switch (grab_op)
{
case META_GRAB_OP_CLICKING_MENU:
case META_GRAB_OP_CLICKING_APPMENU:
case META_GRAB_OP_CLICKING_DELETE:
case META_GRAB_OP_CLICKING_MINIMIZE:
case META_GRAB_OP_CLICKING_MAXIMIZE:
......@@ -1904,6 +1915,8 @@ meta_frames_motion_notify_event (GtkWidget *widget,
control = get_control (frames, frame, x, y);
if (! ((control == META_FRAME_CONTROL_MENU &&
grab_op == META_GRAB_OP_CLICKING_MENU) ||
(control == META_FRAME_CONTROL_APPMENU &&
grab_op == META_GRAB_OP_CLICKING_APPMENU) ||
(control == META_FRAME_CONTROL_DELETE &&
grab_op == META_GRAB_OP_CLICKING_DELETE) ||
(control == META_FRAME_CONTROL_MINIMIZE &&
......@@ -2321,6 +2334,12 @@ meta_frames_paint (MetaFrames *frames,
else
button_states[META_BUTTON_TYPE_MENU] = META_BUTTON_STATE_PRELIGHT;
break;
case META_FRAME_CONTROL_APPMENU:
if (grab_op == META_GRAB_OP_CLICKING_MENU)
button_states[META_BUTTON_TYPE_APPMENU] = META_BUTTON_STATE_PRESSED;
else
button_states[META_BUTTON_TYPE_APPMENU] = META_BUTTON_STATE_PRELIGHT;
break;
case META_FRAME_CONTROL_MINIMIZE:
if (grab_op == META_GRAB_OP_CLICKING_MINIMIZE)
button_states[META_BUTTON_TYPE_MINIMIZE] = META_BUTTON_STATE_PRESSED;
......@@ -2515,6 +2534,9 @@ control_rect (MetaFrameControl control,
case META_FRAME_CONTROL_MENU:
rect = &fgeom->menu_rect.visible;
break;
case META_FRAME_CONTROL_APPMENU:
rect = &fgeom->appmenu_rect.visible;
break;
case META_FRAME_CONTROL_MINIMIZE:
rect = &fgeom->min_rect.visible;
break;
......@@ -2596,6 +2618,9 @@ get_control (MetaFrames *frames,
if (POINT_IN_RECT (x, y, fgeom.menu_rect.clickable))
return META_FRAME_CONTROL_MENU;
if (POINT_IN_RECT (x, y, fgeom.appmenu_rect.clickable))
return META_FRAME_CONTROL_APPMENU;
meta_core_get (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), frame->xwindow,
META_CORE_GET_FRAME_FLAGS, &flags,
META_CORE_GET_END);
......
......@@ -33,6 +33,7 @@ typedef enum
META_FRAME_CONTROL_TITLE,
META_FRAME_CONTROL_DELETE,
META_FRAME_CONTROL_MENU,
META_FRAME_CONTROL_APPMENU,
META_FRAME_CONTROL_MINIMIZE,
META_FRAME_CONTROL_MAXIMIZE,
META_FRAME_CONTROL_UNMAXIMIZE,
......
......@@ -36,7 +36,7 @@
* look out for.
*/
#define THEME_MAJOR_VERSION 3
#define THEME_MINOR_VERSION 4
#define THEME_MINOR_VERSION 5
#define THEME_VERSION (1000 * THEME_MAJOR_VERSION + THEME_MINOR_VERSION)
#define METACITY_THEME_FILENAME_FORMAT "metacity-theme-%d.xml"
......
......@@ -448,6 +448,8 @@ map_button_function_to_type (MetaButtonFunction function)
return META_BUTTON_TYPE_UNSTICK;
case META_BUTTON_FUNCTION_MENU:
return META_BUTTON_TYPE_MENU;
case META_BUTTON_FUNCTION_APPMENU:
return META_BUTTON_TYPE_APPMENU;
case META_BUTTON_FUNCTION_MINIMIZE:
return META_BUTTON_TYPE_MINIMIZE;
case META_BUTTON_FUNCTION_MAXIMIZE:
......@@ -516,6 +518,11 @@ rect_for_function (MetaFrameGeometry *fgeom,
return &fgeom->menu_rect;
else
return NULL;
case META_BUTTON_FUNCTION_APPMENU:
if (flags & META_FRAME_ALLOWS_APPMENU)
return &fgeom->appmenu_rect;
else
return NULL;
case META_BUTTON_FUNCTION_MINIMIZE:
if (flags & META_FRAME_ALLOWS_MINIMIZE)
return &fgeom->min_rect;
......@@ -818,6 +825,12 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
else if (strip_button (left_func_rects, left_bg_rects,
&n_left, &fgeom->menu_rect))
continue;
else if (strip_button (right_func_rects, right_bg_rects,
&n_right, &fgeom->appmenu_rect))
continue;
else if (strip_button (left_func_rects, left_bg_rects,
&n_left, &fgeom->appmenu_rect))
continue;
else
{
meta_bug ("Could not find a button to strip. n_left = %d n_right = %d\n",
......@@ -4345,7 +4358,7 @@ map_button_state (MetaButtonType button_type,
switch (button_type)
{
/* First hande functions, which map directly */
/* First handle functions, which map directly */
case META_BUTTON_TYPE_SHADE:
case META_BUTTON_TYPE_ABOVE:
case META_BUTTON_TYPE_STICK:
......@@ -4353,6 +4366,7 @@ map_button_state (MetaButtonType button_type,
case META_BUTTON_TYPE_UNABOVE:
case META_BUTTON_TYPE_UNSTICK:
case META_BUTTON_TYPE_MENU:
case META_BUTTON_TYPE_APPMENU:
case META_BUTTON_TYPE_MINIMIZE:
case META_BUTTON_TYPE_MAXIMIZE:
case META_BUTTON_TYPE_CLOSE:
......@@ -4559,6 +4573,10 @@ button_rect (MetaButtonType type,
*rect = fgeom->menu_rect.visible;
break;
case META_BUTTON_TYPE_APPMENU:
*rect = fgeom->appmenu_rect.visible;
break;
case META_BUTTON_TYPE_LAST:
g_assert_not_reached ();
break;
......@@ -5918,6 +5936,8 @@ meta_button_type_from_string (const char *str, MetaTheme *theme)
return META_BUTTON_TYPE_MINIMIZE;
else if (strcmp ("menu", str) == 0)
return META_BUTTON_TYPE_MENU;
else if (strcmp ("appmenu", str) == 0)
return META_BUTTON_TYPE_APPMENU;
else if (strcmp ("left_left_background", str) == 0)
return META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND;
else if (strcmp ("left_middle_background", str) == 0)
......@@ -5961,8 +5981,10 @@ meta_button_type_to_string (MetaButtonType type)
return "unabove";
case META_BUTTON_TYPE_UNSTICK:
return "unstick";
case META_BUTTON_TYPE_MENU:
case META_BUTTON_TYPE_MENU:
return "menu";
case META_BUTTON_TYPE_APPMENU:
return "appmenu";
case META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND:
return "left_left_background";
case META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND:
......@@ -6518,6 +6540,9 @@ meta_theme_earliest_version_with_button (MetaButtonType type)
case META_BUTTON_TYPE_RIGHT_SINGLE_BACKGROUND:
return 3003;
case META_BUTTON_TYPE_APPMENU:
return 3005;
default:
meta_warning("Unknown button %d\n", type);
return 1000;
......
......@@ -238,6 +238,7 @@ struct _MetaFrameGeometry
MetaButtonSpace max_rect;
MetaButtonSpace min_rect;
MetaButtonSpace menu_rect;
MetaButtonSpace appmenu_rect;
MetaButtonSpace shade_rect;
MetaButtonSpace above_rect;
MetaButtonSpace stick_rect;
......@@ -657,6 +658,7 @@ typedef enum
META_BUTTON_TYPE_MAXIMIZE,
META_BUTTON_TYPE_MINIMIZE,
META_BUTTON_TYPE_MENU,
META_BUTTON_TYPE_APPMENU,
META_BUTTON_TYPE_SHADE,
META_BUTTON_TYPE_ABOVE,
META_BUTTON_TYPE_STICK,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment