Skip to content

Commit df9954f

Browse files
fossfreedomEbonJaeger
authored andcommitted
No need for scaling factors for screenshots
1 parent 4ef101b commit df9954f

1 file changed

Lines changed: 10 additions & 25 deletions

File tree

src/dialogs/screenshot/screenshot.vala

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ namespace Budgie {
161161

162162
class MakeScreenshot {
163163
int delay;
164-
int scale;
165164
int[]? area;
166165
string screenshot_mode;
167166
bool include_cursor;
@@ -199,7 +198,6 @@ namespace Budgie {
199198

200199
windowstate = new CurrentState();
201200
this.area = area;
202-
scale = get_scaling();
203201
delay = windowstate.screenshot_settings.get_int("delay");
204202
emit_capture_sound = windowstate.screenshot_settings.get_boolean("screenshot-capture-sound");
205203
screenshot_mode = windowstate.screenshot_settings.get_string("screenshot-mode");
@@ -278,7 +276,7 @@ namespace Budgie {
278276

279277
try {
280278
yield client.ScreenshotArea(
281-
topleftx * scale, toplefty * scale, width * scale, height * scale,
279+
topleftx, toplefty, width, height,
282280
include_cursor, true, windowstate.tempfile_path, out success, out filename_used
283281
);
284282
} catch (Error e) {
@@ -843,12 +841,11 @@ namespace Budgie {
843841

844842
private void makeaftershotwindow(Pixbuf pxb) {
845843
this.set_keep_above(true);
846-
int scale = get_scaling();
847844
Clipboard clp = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD);
848845
windowstate.statechanged(WindowState.AFTERSHOT);
849846

850847
// create resized image for preview
851-
var pixbuf = resize_pixbuf(pxb, scale);
848+
var pixbuf = resize_pixbuf(pxb);
852849
img.set_from_pixbuf(pixbuf);
853850
filenameentry.set_text(get_scrshotname());
854851

@@ -1046,23 +1043,23 @@ namespace Budgie {
10461043
b.show_all();
10471044
}
10481045

1049-
private Gdk.Pixbuf resize_pixbuf(Pixbuf pxb, int scale) {
1046+
private Gdk.Pixbuf resize_pixbuf(Pixbuf pxb) {
10501047
/*
10511048
* before showing the image, resize it to fit the max available
10521049
* available space in the decision window (345 x 345)
10531050
*/
10541051
int maxw_h = 345;
10551052
float resize = 1;
1056-
int scaled_width = (int) (pxb.get_width() / scale);
1057-
int scaled_height = (int) (pxb.get_height() / scale);
1053+
int width = pxb.get_width();
1054+
int height = pxb.get_height();
10581055

1059-
if (scaled_width > maxw_h || scaled_height > maxw_h) {
1060-
(scaled_width >= scaled_height) ? resize = (float) maxw_h / scaled_width : resize;
1061-
(scaled_height >= scaled_width) ? resize = (float) maxw_h / scaled_height : resize;
1056+
if (width > maxw_h || height > maxw_h) {
1057+
(width >= height) ? resize = (float) maxw_h / width : resize;
1058+
(height >= width) ? resize = (float) maxw_h / height : resize;
10621059
}
10631060

1064-
int dest_width = (int) (scaled_width * resize);
1065-
int dest_height = (int) (scaled_height * resize);
1061+
int dest_width = (int)(width * resize);
1062+
int dest_height = (int)(height * resize);
10661063
Gdk.Pixbuf resized = pxb.scale_simple(dest_width, dest_height, InterpType.BILINEAR);
10671064

10681065
return resized;
@@ -1316,18 +1313,6 @@ namespace Budgie {
13161313
}
13171314
}
13181315

1319-
private int get_scaling() {
1320-
// not very sophisticated, but for now, we'll assume one scale
1321-
var wayland_client = new WaylandClient();
1322-
1323-
if (!wayland_client.is_initialised()) {
1324-
warning("WaylandClient not initialized, using default scale of 1");
1325-
return 1;
1326-
}
1327-
1328-
return wayland_client.scale;
1329-
}
1330-
13311316
private int find_stringindex(string str, string[] arr) {
13321317
for(int i = 0; i < arr.length; i++) {
13331318
if (str == arr[i]) {

0 commit comments

Comments
 (0)