Skip to content

Commit

Permalink
build: Require mutter 42
Browse files Browse the repository at this point in the history
Changes are generated by scripts except meson.build.
See the related pull request for more info.
  • Loading branch information
bobby285271 committed Nov 12, 2022
1 parent 18802b2 commit 2cca957
Show file tree
Hide file tree
Showing 12 changed files with 2 additions and 652 deletions.
147 changes: 0 additions & 147 deletions lib/DragDropAction.vala
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,10 @@ namespace Gala {
float last_x;
float last_y;

#if HAS_MUTTER42
Grab? grab = null;
static unowned Actor? grabbed_actor = null;
InputDevice? grabbed_device = null;
ulong on_event_id = 0;
#endif

/**
* Create a new DragDropAction
Expand Down Expand Up @@ -148,9 +146,6 @@ namespace Gala {

void release_actor (Actor actor) {
if (DragDropActionType.SOURCE in drag_type) {
#if !HAS_MUTTER42
actor.button_press_event.disconnect (source_clicked);
#endif

var source_list = sources.@get (drag_id);
source_list.remove (actor);
Expand All @@ -164,9 +159,6 @@ namespace Gala {

void connect_actor (Actor actor) {
if (DragDropActionType.SOURCE in drag_type) {
#if !HAS_MUTTER42
actor.button_press_event.connect (source_clicked);
#endif

var source_list = sources.@get (drag_id);
if (source_list == null) {
Expand All @@ -193,7 +185,6 @@ namespace Gala {
destination_crossed (destination, is_hovered);
}

#if HAS_MUTTER42
public override bool handle_event (Event event) {
if (!(DragDropActionType.SOURCE in drag_type)) {
return false;
Expand Down Expand Up @@ -380,140 +371,6 @@ namespace Gala {

return false;
}
#else
bool source_clicked (ButtonEvent event) {
if (event.button != 1) {
actor_clicked (event.button);
return false;
}

actor.get_stage ().captured_event.connect (follow_move);
clicked = true;
last_x = event.x;
last_y = event.y;

return true;
}

bool follow_move (Event event) {
// still determining if we actually want to start a drag action
if (!dragging) {
switch (event.get_type ()) {
case EventType.MOTION:
float x, y;
event.get_coords (out x, out y);

var drag_threshold = Clutter.Settings.get_default ().dnd_drag_threshold;
if (Math.fabsf (last_x - x) > drag_threshold || Math.fabsf (last_y - y) > drag_threshold) {
handle = drag_begin (x, y);
if (handle == null) {
actor.get_stage ().captured_event.disconnect (follow_move);
critical ("No handle has been returned by the started signal, aborting drag.");
return false;
}

handle.reactive = false;

clicked = false;
dragging = true;

var source_list = sources.@get (drag_id);
if (source_list != null) {
var dest_list = destinations[drag_id];
foreach (var actor in source_list) {
// Do not unset reactivity on destinations
if (dest_list == null || actor in dest_list) {
continue;
}

actor.reactive = false;
}
}
}
return true;
case EventType.BUTTON_RELEASE:
float x, y, ex, ey;
event.get_coords (out ex, out ey);
actor.get_transformed_position (out x, out y);

// release has happened within bounds of actor
if (x < ex && x + actor.width > ex && y < ey && y + actor.height > ey) {
actor_clicked (event.get_button ());
}

actor.get_stage ().captured_event.disconnect (follow_move);
clicked = false;
dragging = false;
return true;
default:
return true;
}
}

switch (event.get_type ()) {
case EventType.KEY_PRESS:
if (event.get_key_code () == Key.Escape) {
cancel ();
}
return true;
case EventType.MOTION:
float x, y;
event.get_coords (out x, out y);
handle.x -= last_x - x;
handle.y -= last_y - y;
last_x = x;
last_y = y;

var stage = actor.get_stage ();
var actor = stage.get_actor_at_pos (PickMode.REACTIVE, (int) x, (int) y);
DragDropAction action = null;
// if we're allowed to bubble and this actor is not a destination, check its parents
if (actor != null && (action = get_drag_drop_action (actor)) == null && allow_bubbling) {
while ((actor = actor.get_parent ()) != stage) {
if ((action = get_drag_drop_action (actor)) != null)
break;
}
}

// didn't change, no need to do anything
if (actor == hovered)
return true;

if (action == null) {
// apparently we left ours if we had one before
if (hovered != null) {
emit_crossed (hovered, false);
hovered = null;
}

return true;
}

// signal the previous one that we left it
if (hovered != null) {
emit_crossed (hovered, false);
}

// tell the new one that it is hovered
hovered = actor;
emit_crossed (hovered, true);

return true;
case EventType.BUTTON_RELEASE:
if (hovered != null) {
finish ();
} else {
cancel ();
}
return true;
case EventType.ENTER:
case EventType.LEAVE:
return true;
}

return false;
}
#endif

/**
* Looks for a DragDropAction instance if this actor has one or NULL.
Expand Down Expand Up @@ -583,11 +440,7 @@ namespace Gala {
}

if (dragging) {
#if HAS_MUTTER42
ungrab_actor ();
#else
actor.get_stage ().captured_event.disconnect (follow_move);
#endif
}

dragging = false;
Expand Down
2 changes: 0 additions & 2 deletions lib/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ namespace Gala {
* to end your modal mode again with {@link WindowManager.pop_modal}
*/
public class ModalProxy : Object {
#if HAS_MUTTER42
public Clutter.Grab? grab { get; set; }
#endif
/**
* A function which is called whenever a keybinding is pressed. If you supply a custom
* one you can filter out those that'd you like to be passed through and block all others.
Expand Down
15 changes: 2 additions & 13 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,6 @@ libmutter_dep = []

vala_flags = []

mutter41_dep = dependency('libmutter-9', version: ['>= 41', '< 42'], required: false)
if mutter41_dep.found()
libmutter_dep = dependency('libmutter-9', version: '>= 41')
mutter_dep = [
libmutter_dep,
dependency('mutter-cogl-9'), dependency('mutter-cogl-pango-9'),
dependency('mutter-clutter-9')
]
vala_flags = []
endif

mutter42_dep = dependency('libmutter-10', version: ['>= 42', '< 43'], required: false)
if mutter42_dep.found()
libmutter_dep = dependency('libmutter-10', version: '>= 42')
Expand All @@ -125,7 +114,7 @@ if mutter42_dep.found()
dependency('mutter-cogl-10'), dependency('mutter-cogl-pango-10'),
dependency('mutter-clutter-10')
]
vala_flags = ['--define', 'HAS_MUTTER42']
vala_flags = []
endif

mutter43_dep = dependency('libmutter-11', version: ['>= 43', '< 44'], required: false)
Expand All @@ -136,7 +125,7 @@ if mutter43_dep.found()
dependency('mutter-cogl-11'), dependency('mutter-cogl-pango-11'),
dependency('mutter-clutter-11')
]
vala_flags = ['--define', 'HAS_MUTTER42', '--define', 'HAS_MUTTER43']
vala_flags = ['--define', 'HAS_MUTTER43']
endif

if mutter_dep.length() == 0
Expand Down
12 changes: 0 additions & 12 deletions plugins/pip/PopupWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {

private bool resizing = false;
private bool off_screen = false;
#if HAS_MUTTER42
private Clutter.Grab? grab = null;
#endif

static unowned Meta.Window? previous_focus = null;

Expand Down Expand Up @@ -222,13 +220,8 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
begin_resize_width = width;
begin_resize_height = height;

#if HAS_MUTTER42
grab = resize_button.get_stage ().grab (resize_button);
resize_button.event.connect (on_resize_event);
#else
resize_button.get_stage ().set_motion_events_enabled (false);
resize_button.get_stage ().captured_event.connect (on_resize_event);
#endif

return true;
}
Expand Down Expand Up @@ -281,16 +274,11 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor {
return false;
}

#if HAS_MUTTER42
if (grab != null) {
grab.dismiss ();
resize_button.event.disconnect (on_resize_event);
grab = null;
}
#else
resize_button.get_stage ().captured_event.disconnect (on_resize_event);
resize_button.get_stage ().set_motion_events_enabled (true);
#endif

resizing = false;

Expand Down
5 changes: 0 additions & 5 deletions src/Widgets/Tooltip.vala
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,7 @@ public class Gala.Tooltip : Clutter.Actor {
y = padding.top,
ellipsize = Pango.EllipsizeMode.MIDDLE
};
#if HAS_MUTTER42
text_actor.text = text;
#else
text_actor.use_markup = true;
text_actor.set_markup (Markup.printf_escaped ("<span size='large'>%s</span>", text));
#endif

if ((text_actor.width + padding.left + padding.right) > max_width) {
text_actor.width = max_width - padding.left - padding.right;
Expand Down
3 changes: 0 additions & 3 deletions src/Widgets/WindowSwitcher.vala
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,6 @@ namespace Gala {
|| name == "switch-windows" || name == "switch-windows-backward");
});

#if !HAS_MUTTER42
grab_key_focus ();
#endif
}

void close_switcher (uint32 time, bool cancel = false) {
Expand Down
14 changes: 0 additions & 14 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,12 @@ namespace Gala {
display.add_keybinding ("cycle-workspaces-previous", keybinding_settings, 0, (Meta.KeyHandlerFunc) handle_cycle_workspaces);
display.add_keybinding ("panel-main-menu", keybinding_settings, 0, (Meta.KeyHandlerFunc) handle_applications_menu);

#if HAS_MUTTER42
display.add_keybinding ("screenshot", keybinding_settings, 0, (Meta.KeyHandlerFunc) handle_screenshot);
display.add_keybinding ("window-screenshot", keybinding_settings, 0, (Meta.KeyHandlerFunc) handle_screenshot);
display.add_keybinding ("area-screenshot", keybinding_settings, 0, (Meta.KeyHandlerFunc) handle_screenshot);
display.add_keybinding ("screenshot-clip", keybinding_settings, 0, (Meta.KeyHandlerFunc) handle_screenshot);
display.add_keybinding ("window-screenshot-clip", keybinding_settings, 0, (Meta.KeyHandlerFunc) handle_screenshot);
display.add_keybinding ("area-screenshot-clip", keybinding_settings, 0, (Meta.KeyHandlerFunc) handle_screenshot);
#endif

display.overlay_key.connect (() => {
launch_action ("overlay-action");
Expand Down Expand Up @@ -711,16 +709,9 @@ namespace Gala {
return proxy;

unowned Meta.Display display = get_display ();
#if !HAS_MUTTER42
var time = display.get_current_time ();
#endif

update_input_area ();
#if HAS_MUTTER42
proxy.grab = stage.grab (actor);
#else
begin_modal (0, time);
#endif

if (modal_stack.size == 1) {
display.disable_unredirect ();
Expand All @@ -738,19 +729,14 @@ namespace Gala {
return;
}

#if HAS_MUTTER42
proxy.grab.dismiss ();
#endif

if (is_modal ())
return;

update_input_area ();

unowned Meta.Display display = get_display ();
#if !HAS_MUTTER42
end_modal (display.get_current_time ());
#endif

display.enable_unredirect ();
}
Expand Down
2 changes: 0 additions & 2 deletions src/WindowTracker.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ public class Gala.WindowTracker : GLib.Object {
}

private void load_initial_windows (Meta.Display display) {
#if HAS_MUTTER42
GLib.List<weak Meta.Window> windows = display.list_all_windows ();
foreach (weak Meta.Window window in windows) {
track_window (window);
}
#endif
}

private void init_window_tracking (Meta.Display display) {
Expand Down
Loading

0 comments on commit 2cca957

Please sign in to comment.