@@ -65,13 +65,16 @@ static inline void set_cairo_color(cairo_t *cr, const Color *color)
6565
6666/**
6767 * @brief Calculate temperature fill width with bounds checking
68+ * @param temp_value Current temperature value
69+ * @param max_width Maximum width of the bar in pixels
70+ * @param max_temp Maximum temperature from configuration (highest threshold)
6871 */
69- static inline int calculate_temp_fill_width (float temp_value , int max_width )
72+ static inline int calculate_temp_fill_width (float temp_value , int max_width , float max_temp )
7073{
7174 if (temp_value <= 0.0f )
7275 return 0 ;
7376
74- const float ratio = fminf (temp_value / 105.0f , 1.0f );
77+ const float ratio = fminf (temp_value / max_temp , 1.0f );
7578 return (int )(ratio * max_width );
7679}
7780
@@ -106,15 +109,30 @@ static void calculate_scaling_params(const struct Config *config, ScalingParams
106109 int is_circular_by_device = is_circular_display_device (device_name ,
107110 config -> display_width ,
108111 config -> display_height );
109- params -> is_circular = is_circular_by_device ;
110- params -> inscribe_factor = params -> is_circular ? M_SQRT1_2 : 1.0 ;
112+
113+ // Allow developer override from config (set via CLI --develop)
114+ if (config -> force_display_circular )
115+ {
116+ params -> is_circular = 1 ;
117+ params -> inscribe_factor = M_SQRT1_2 ;
118+ log_message (LOG_INFO , "Developer override active: forcing circular display detection (device: %s)" , device_name ? device_name : "unknown" );
119+ }
120+ else
121+ {
122+ params -> is_circular = is_circular_by_device ;
123+ params -> inscribe_factor = params -> is_circular ? M_SQRT1_2 : 1.0 ;
124+ }
111125
112126 // Calculate safe area width
113127 const double safe_area_width = config -> display_width * params -> inscribe_factor ;
114128 params -> safe_bar_width = (int )(safe_area_width * CONTENT_SCALE_FACTOR );
115129 params -> safe_content_margin = (config -> display_width - params -> safe_bar_width ) / 2.0 ;
116130
117131 params -> corner_radius = 8.0 * scale_avg ;
132+
133+ // Log detailed scaling calculations (verbose only)
134+ log_message (LOG_INFO , "Scaling: safe_area=%.0fpx, bar_width=%dpx, margin=%.1fpx" ,
135+ safe_area_width , params -> safe_bar_width , params -> safe_content_margin );
118136}
119137
120138/**
@@ -128,6 +146,16 @@ static Color get_temperature_bar_color(const struct Config *config, float val);
128146static void draw_rounded_rectangle_path (cairo_t * cr , int x , int y , int width , int height , double radius );
129147static cairo_t * create_cairo_context (const struct Config * config , cairo_surface_t * * surface );
130148static void render_display_content (cairo_t * cr , const struct Config * config , const monitor_sensor_data_t * data , const ScalingParams * params );
149+ // Helper to draw degree symbol at calculated position with proper font scaling
150+ static void draw_degree_symbol (cairo_t * cr , double x , double y , const struct Config * config )
151+ {
152+ if (!cr || !config )
153+ return ;
154+ cairo_set_font_size (cr , config -> font_size_temp / 1.66 );
155+ cairo_move_to (cr , x , y );
156+ cairo_show_text (cr , "°" );
157+ cairo_set_font_size (cr , config -> font_size_temp );
158+ }
131159
132160/**
133161 * @brief Draw rounded rectangle path for temperature bars
@@ -194,13 +222,24 @@ static void draw_temperature_displays(cairo_t *cr, const monitor_sensor_data_t *
194222 cairo_font_extents_t font_ext ;
195223 cairo_font_extents (cr , & font_ext );
196224
197- // Calculate maximum width for 2-digit numbers to keep position stable
198- cairo_text_extents_t max_num_ext ;
199- cairo_text_extents (cr , "88" , & max_num_ext ); // Widest 2-digit number
225+ // Use actual text extents for positioning to handle 3-digit temperatures correctly
226+ // For values ≥100, use actual width; for <100, use fixed width of "88" for stability
227+ double cpu_width = (data -> temp_cpu >= 100.0f ) ? cpu_num_ext .width : cpu_num_ext .width ;
228+ double gpu_width = (data -> temp_gpu >= 100.0f ) ? gpu_num_ext .width : gpu_num_ext .width ;
229+
230+ // Calculate reference width (widest 2-digit number) for sub-100 alignment
231+ cairo_text_extents_t ref_width_ext ;
232+ cairo_text_extents (cr , "88" , & ref_width_ext );
233+
234+ // Use reference width for values <100 to keep position stable
235+ if (data -> temp_cpu < 100.0f )
236+ cpu_width = ref_width_ext .width ;
237+ if (data -> temp_gpu < 100.0f )
238+ gpu_width = ref_width_ext .width ;
200239
201- // Left -align numbers at center position (fixed X to prevent jumping)
202- double cpu_temp_x = bar_x + (effective_bar_width - max_num_ext . width ) / 2.0 ;
203- double gpu_temp_x = bar_x + (effective_bar_width - max_num_ext . width ) / 2.0 ;
240+ // Center -align based on actual or reference width
241+ double cpu_temp_x = bar_x + (effective_bar_width - cpu_width ) / 2.0 ;
242+ double gpu_temp_x = bar_x + (effective_bar_width - gpu_width ) / 2.0 ;
204243
205244 // For small displays (≤240×240), shift temperatures 12px to the right
206245 if (config -> display_width <= 240 && config -> display_height <= 240 )
@@ -241,29 +280,26 @@ static void draw_temperature_displays(cairo_t *cr, const monitor_sensor_data_t *
241280 // Draw degree symbols at fixed offset
242281 cairo_set_font_size (cr , config -> font_size_temp / 1.66 );
243282
244- // Position degree symbols 18px to the right of temperature numbers
245- double degree_symbol_x = cpu_temp_x + max_num_ext .width + 16 ;
283+ // Position degree symbols 16px to the right of temperature numbers (using actual widths)
284+ double degree_cpu_x = cpu_temp_x + cpu_width + 16 ;
285+ double degree_gpu_x = gpu_temp_x + gpu_width + 16 ;
246286 double degree_cpu_y = cpu_temp_y - cpu_num_ext .height * 0.40 ;
247287 double degree_gpu_y = gpu_temp_y - gpu_num_ext .height * 0.40 ;
248288
249289 // Apply user-defined degree offsets if set
250290 if (config -> display_degree_offset_x != -9999 )
251291 {
252- degree_symbol_x += config -> display_degree_offset_x ;
292+ degree_cpu_x += config -> display_degree_offset_x ;
293+ degree_gpu_x += config -> display_degree_offset_x ;
253294 }
254295 if (config -> display_degree_offset_y != -9999 )
255296 {
256297 degree_cpu_y += config -> display_degree_offset_y ;
257298 degree_gpu_y += config -> display_degree_offset_y ;
258299 }
259300
260- cairo_move_to (cr , degree_symbol_x , degree_cpu_y );
261- cairo_show_text (cr , "°" );
262-
263- cairo_move_to (cr , degree_symbol_x , degree_gpu_y );
264- cairo_show_text (cr , "°" );
265-
266- cairo_set_font_size (cr , config -> font_size_temp );
301+ draw_degree_symbol (cr , degree_cpu_x , degree_cpu_y , config );
302+ draw_degree_symbol (cr , degree_gpu_x , degree_gpu_y , config );
267303}
268304
269305/**
@@ -274,7 +310,9 @@ static void draw_single_temperature_bar(cairo_t *cr, const struct Config *config
274310 if (!cr || !config || !params )
275311 return ;
276312
277- const int fill_width = calculate_temp_fill_width (temp_value , bar_width );
313+ // Use configured maximum temperature for bar scaling (default: 115°C)
314+ const float max_temp = config -> temp_max_scale ;
315+ const int fill_width = calculate_temp_fill_width (temp_value , bar_width , max_temp );
278316
279317 // Background
280318 set_cairo_color (cr , & config -> layout_bar_color_background );
0 commit comments