-
-
Notifications
You must be signed in to change notification settings - Fork 622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove dpi scaling of maximum width #1877
Changes from all commits
1efc24d
5051e0a
061fd11
d8fb65e
6d194af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
#include <cmath> | ||
#include <cstdarg> | ||
#include <ctime> | ||
#include <filesystem> | ||
#include <iostream> | ||
#include <memory> | ||
#include <sstream> | ||
|
@@ -275,7 +276,7 @@ int text_width = 1, | |
struct information info; | ||
|
||
/* path to config file */ | ||
std::string current_config; | ||
std::filesystem::path current_config; | ||
|
||
/* set to 1 if you want all text to be in uppercase */ | ||
static conky::simple_config_setting<bool> stuff_in_uppercase("uppercase", false, | ||
|
@@ -864,7 +865,7 @@ void update_text_area() { | |
if (text_height < dpi_scale(minimum_height.get(*state))) { | ||
text_height = dpi_scale(minimum_height.get(*state)); | ||
} | ||
int mw = dpi_scale(maximum_width.get(*state)); | ||
int mw = maximum_width.get(*state); | ||
if (text_width > mw && mw > 0) { text_width = mw; } | ||
} | ||
|
||
|
@@ -987,7 +988,7 @@ static int text_size_updater(char *s, int special_index) { | |
w += get_string_width(s); | ||
|
||
if (w > text_width) { text_width = w; } | ||
int mw = dpi_scale(maximum_width.get(*state)); | ||
int mw = maximum_width.get(*state); | ||
if (text_width > mw && mw > 0) { text_width = mw; } | ||
|
||
text_height += last_font_height; | ||
|
@@ -1051,7 +1052,7 @@ static void draw_string(const char *s) { | |
} | ||
#ifdef BUILD_GUI | ||
if (display_output() && display_output()->graphical()) { | ||
int mw = display_output()->dpi_scale(maximum_width.get(*state)); | ||
int mw = maximum_width.get(*state); | ||
if (text_width == mw) { | ||
/* this means the text is probably pushing the limit, | ||
* so we'll chop it */ | ||
|
@@ -1121,7 +1122,7 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied) { | |
|
||
#ifdef BUILD_GUI | ||
if (display_output() && display_output()->graphical()) { | ||
mw = display_output()->dpi_scale(maximum_width.get(*state)); | ||
mw = maximum_width.get(*state); | ||
font_h = font_height(); | ||
cur_y += font_ascent(); | ||
} | ||
|
@@ -1961,6 +1962,40 @@ void load_config_file() { | |
lua::stack_sentry s(l); | ||
l.checkstack(2); | ||
|
||
// Extend lua package.path so scripts can use relative paths | ||
{ | ||
struct stat file_stat {}; | ||
|
||
std::string path_ext; | ||
|
||
// add XDG directory to lua path | ||
auto xdg_path = | ||
std::filesystem::path(to_real_path(XDG_CONFIG_FILE)).parent_path(); | ||
if (stat(xdg_path.c_str(), &file_stat) == 0) { | ||
path_ext.push_back(';'); | ||
path_ext.append(xdg_path); | ||
path_ext.append("/?.lua"); | ||
} | ||
|
||
auto parent_path = current_config.parent_path(); | ||
if (xdg_path != parent_path && stat(path_ext.c_str(), &file_stat) == 0) { | ||
path_ext.push_back(';'); | ||
path_ext.append(parent_path); | ||
path_ext.append("/?.lua"); | ||
} | ||
|
||
l.getglobal("package"); | ||
l.getfield(-1, "path"); | ||
|
||
auto path = l.tostring(-1); | ||
path.append(path_ext); | ||
l.pop(); | ||
l.pushstring(path.c_str()); | ||
|
||
l.setfield(-2, "path"); | ||
l.pop(); | ||
} | ||
Comment on lines
+1965
to
+1997
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding |
||
|
||
try { | ||
#ifdef BUILD_BUILTIN_CONFIG | ||
if (current_config == builtin_config_magic) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -300,7 +300,17 @@ static void output_geometry(void *data, struct wl_output *wl_output, int32_t x, | |
int32_t y, int32_t physical_width, | ||
int32_t physical_height, int32_t subpixel, | ||
const char *make, const char *model, | ||
int32_t transform) {} | ||
int32_t transform) { | ||
// TODO: Add support for proper output management through: | ||
// - xdg-output-unstable-v1 | ||
// Maybe also support (if XDG protocol not reported): | ||
// - kde-output-management(-v2) | ||
// - wlr-output-management-unstable-v1 | ||
workarea[0] = x; // TODO: use xdg_output.logical_position | ||
workarea[1] = y; | ||
workarea[2] = physical_width; | ||
workarea[3] = physical_height; | ||
Comment on lines
+304
to
+312
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the workarea change. |
||
} | ||
|
||
static void output_mode(void *data, struct wl_output *wl_output, uint32_t flags, | ||
int32_t width, int32_t height, int32_t refresh) {} | ||
|
@@ -913,10 +923,7 @@ void display_output_wayland::move_win(int x, int y) { | |
// window.y = y; | ||
// TODO | ||
} | ||
template <typename T, typename> | ||
T display_output_wayland::dpi_scale(T value) { | ||
return value; | ||
} | ||
float display_output_wayland::get_dpi_scale() { return 1.0; } | ||
|
||
void display_output_wayland::end_draw_stuff() { | ||
window_commit_buffer(global_window); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -657,7 +657,7 @@ bool handle_event<x_event_handler::CONFIGURE>( | |
|
||
text_width = window.width - 2 * border_total; | ||
text_height = window.height - 2 * border_total; | ||
int mw = surface->dpi_scale(maximum_width.get(*state)); | ||
int mw = maximum_width.get(*state); | ||
if (text_width > mw && mw > 0) { text_width = mw; } | ||
} | ||
|
||
|
@@ -945,18 +945,14 @@ void display_output_x11::move_win(int x, int y) { | |
#endif /* OWN_WINDOW */ | ||
} | ||
|
||
const size_t PIXELS_PER_INCH = 96; | ||
template <typename T, typename> | ||
T display_output_x11::dpi_scale(T value) { | ||
#if defined(BUILD_XFT) | ||
const float PIXELS_PER_INCH = 96.0; | ||
float display_output_x11::get_dpi_scale() { | ||
#ifdef BUILD_XFT | ||
if (use_xft.get(*state) && xft_dpi > 0) { | ||
return (value * xft_dpi + (value > 0 ? 48 : -48)) / PIXELS_PER_INCH; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe |
||
} else { | ||
return value; | ||
return static_cast<float>(xft_dpi) / PIXELS_PER_INCH; | ||
} | ||
#else /* defined(BUILD_XFT) */ | ||
return value; | ||
#endif /* defined(BUILD_XFT) */ | ||
#endif /* BUILD_XFT */ | ||
return 1.0; | ||
} | ||
|
||
void display_output_x11::end_draw_stuff() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice