-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathlockscreen.cpp
More file actions
124 lines (113 loc) · 3.4 KB
/
lockscreen.cpp
File metadata and controls
124 lines (113 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include "glib.h"
#include "locker.hpp"
#include "lockergrid.hpp"
#include "lockscreen.hpp"
WayfireLockerAppLockscreen::WayfireLockerAppLockscreen(std::string background_path)
{
grid = std::make_shared<WayfireLockerGrid>();
set_child(overlay);
overlay.set_child(background);
overlay.add_overlay(*grid);
grid->set_halign(Gtk::Align::FILL);
grid->set_valign(Gtk::Align::FILL);
add_css_class("wf-locker");
grid->set_expand(true);
/* Prepare background */
Glib::signal_idle().connect([this, background_path] ()
{
background.show_image(background_path);
return G_SOURCE_REMOVE;
});
auto wf_background_cb = [this] ()
{
if ((bool)wf_background)
{
background.show();
} else
{
background.hide();
}
};
wf_background.set_callback(wf_background_cb);
wf_background_cb();
/* Mouse press or screen touch */
auto click_gesture = Gtk::GestureClick::create();
click_gesture->set_propagation_phase(Gtk::PropagationPhase::CAPTURE);
signals.push_back(click_gesture->signal_released().connect([=] (int count, double x, double y)
{
window_activity();
}));
add_controller(click_gesture);
/* Mouse movement */
auto pointer_gesture = Gtk::EventControllerMotion::create();
signals.push_back(pointer_gesture->signal_motion().connect([=] (double x, double y)
{
// Avoid first motion event and repeated with same location
int ix = x;
int iy = y;
if ((last_x < 0) && (last_y < 0))
{
last_x = ix;
last_y = iy;
return;
}
if ((ix == last_x) && (iy == last_y))
{
return;
}
last_x = ix;
last_y = iy;
window_activity();
}));
add_controller(pointer_gesture);
/* Keypress */
auto typing_gesture = Gtk::EventControllerKey::create();
typing_gesture->set_propagation_phase(Gtk::PropagationPhase::CAPTURE);
signals.push_back(typing_gesture->signal_key_pressed().connect([=] (guint keyval, guint keycode,
Gdk::ModifierType state)
{
window_activity();
return false;
}, false));
/* Resize cb*/
signals.push_back(background.signal_resize().connect([this] (int width, int height)
{
int size = std::max(get_width(), get_height());
remove_css_class("sized-480");
remove_css_class("sized-720");
remove_css_class("sized-1080");
remove_css_class("sized-1440");
remove_css_class("sized-2160");
if (size <= 480)
{
add_css_class("sized-480");
} else if (size <= 720)
{
add_css_class("sized-720");
} else if (size <= 1080)
{
add_css_class("sized-1080");
} else if (size <= 1440)
{
add_css_class("sized-1440");
} else
{
add_css_class("sized-2160");
}
}));
add_controller(typing_gesture);
}
void WayfireLockerAppLockscreen::window_activity()
{
// Alert entire locker, in case of pre-wake
WayfireLockerApp::get().user_activity();
// Alert all widgets in window, to reveal themselves
grid->window_activity();
}
void WayfireLockerAppLockscreen::disconnect()
{
for (auto signal : signals)
{
signal.disconnect();
}
}