@@ -524,11 +524,13 @@ meta_frames_calc_geometry (MetaFrames *frames,
524524 MetaUIFrame * frame ,
525525 MetaFrameGeometry * fgeom )
526526{
527- int width , height ;
527+ int width , height , scale ;
528528 MetaFrameFlags flags ;
529529 MetaFrameType type ;
530530 MetaButtonLayout button_layout ;
531531
532+ scale = gdk_window_get_scale_factor (frame -> window );
533+
532534 meta_core_get (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), frame -> xwindow ,
533535 META_CORE_GET_CLIENT_WIDTH , & width ,
534536 META_CORE_GET_CLIENT_HEIGHT , & height ,
@@ -544,9 +546,14 @@ meta_frames_calc_geometry (MetaFrames *frames,
544546 type ,
545547 frame -> text_height ,
546548 flags ,
547- width , height ,
549+ width / scale , height / scale ,
548550 & button_layout ,
549551 fgeom );
552+
553+ fgeom -> top_height *= scale ;
554+ fgeom -> bottom_height *= scale ;
555+ fgeom -> left_width *= scale ;
556+ fgeom -> right_width *= scale ;
550557}
551558
552559MetaFrames *
@@ -695,8 +702,10 @@ meta_frames_get_geometry (MetaFrames *frames,
695702 MetaFrameFlags flags ;
696703 MetaUIFrame * frame ;
697704 MetaFrameType type ;
705+ gint scale ;
698706
699707 frame = meta_frames_lookup_window (frames , xwindow );
708+ scale = gdk_window_get_scale_factor (frame -> window );
700709
701710 if (frame == NULL )
702711 meta_bug ("No such frame 0x%lx\n" , xwindow );
@@ -721,6 +730,12 @@ meta_frames_get_geometry (MetaFrames *frames,
721730 flags ,
722731 top_height , bottom_height ,
723732 left_width , right_width );
733+
734+ /* Scale frame geometry to ensure proper frame position */
735+ * top_height *= scale ;
736+ * bottom_height *= scale ;
737+ * left_width *= scale ;
738+ * right_width *= scale ;
724739}
725740
726741void
@@ -783,6 +798,7 @@ meta_frames_apply_shapes (MetaFrames *frames,
783798 XRectangle xrect ;
784799 Region corners_xregion ;
785800 Region window_xregion ;
801+ gint scale ;
786802
787803 frame = meta_frames_lookup_window (frames , xwindow );
788804 g_return_if_fail (frame != NULL );
@@ -816,10 +832,11 @@ meta_frames_apply_shapes (MetaFrames *frames,
816832 }
817833
818834 corners_xregion = XCreateRegion ();
835+ scale = gdk_window_get_scale_factor (frame -> window );
819836
820837 if (fgeom .top_left_corner_rounded_radius != 0 )
821838 {
822- const int corner = fgeom .top_left_corner_rounded_radius ;
839+ const int corner = fgeom .top_left_corner_rounded_radius * scale ;
823840 const float radius = sqrt (corner ) + corner ;
824841 int i ;
825842
@@ -837,7 +854,7 @@ meta_frames_apply_shapes (MetaFrames *frames,
837854
838855 if (fgeom .top_right_corner_rounded_radius != 0 )
839856 {
840- const int corner = fgeom .top_right_corner_rounded_radius ;
857+ const int corner = fgeom .top_right_corner_rounded_radius * scale ;
841858 const float radius = sqrt (corner ) + corner ;
842859 int i ;
843860
@@ -855,7 +872,7 @@ meta_frames_apply_shapes (MetaFrames *frames,
855872
856873 if (fgeom .bottom_left_corner_rounded_radius != 0 )
857874 {
858- const int corner = fgeom .bottom_left_corner_rounded_radius ;
875+ const int corner = fgeom .bottom_left_corner_rounded_radius * scale ;
859876 const float radius = sqrt (corner ) + corner ;
860877 int i ;
861878
@@ -873,7 +890,7 @@ meta_frames_apply_shapes (MetaFrames *frames,
873890
874891 if (fgeom .bottom_right_corner_rounded_radius != 0 )
875892 {
876- const int corner = fgeom .bottom_right_corner_rounded_radius ;
893+ const int corner = fgeom .bottom_right_corner_rounded_radius * scale ;
877894 const float radius = sqrt (corner ) + corner ;
878895 int i ;
879896
@@ -1006,11 +1023,14 @@ meta_frames_move_resize_frame (MetaFrames *frames,
10061023{
10071024 MetaUIFrame * frame = meta_frames_lookup_window (frames , xwindow );
10081025 int old_width , old_height ;
1026+ gint scale ;
10091027
10101028 old_width = gdk_window_get_width (frame -> window );
10111029 old_height = gdk_window_get_height (frame -> window );
10121030
1013- gdk_window_move_resize (frame -> window , x , y , width , height );
1031+ scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
1032+
1033+ gdk_window_move_resize (frame -> window , x / scale , y / scale , width / scale , height / scale );
10141034
10151035 if (old_width != width || old_height != height )
10161036 invalidate_whole_window (frames , frame );
@@ -1153,15 +1173,16 @@ show_tip_now (MetaFrames *frames)
11531173 {
11541174 MetaFrameGeometry fgeom ;
11551175 GdkRectangle * rect ;
1156- int dx , dy ;
1176+ int dx , dy , scale ;
11571177
11581178 meta_frames_calc_geometry (frames , frame , & fgeom );
11591179
11601180 rect = control_rect (control , & fgeom );
1181+ scale = gdk_window_get_scale_factor (frame -> window );
11611182
11621183 /* get conversion delta for root-to-frame coords */
1163- dx = root_x - x ;
1164- dy = root_y - y ;
1184+ dx = ( root_x - x ) / scale ;
1185+ dy = ( root_y - y ) / scale ;
11651186
11661187 /* Align the tooltip to the button right end if RTL */
11671188 if (meta_ui_get_direction () == META_UI_DIRECTION_RTL )
@@ -1920,10 +1941,13 @@ meta_frames_motion_notify_event (GtkWidget *widget,
19201941 case META_GRAB_OP_CLICKING_UNSTICK :
19211942 {
19221943 MetaFrameControl control ;
1923- int x , y ;
1944+ int x , y , scale ;
19241945
19251946 gdk_window_get_device_position (frame -> window , event -> device ,
19261947 & x , & y , NULL );
1948+ scale = gdk_window_get_scale_factor (frame -> window );
1949+ x *= scale ;
1950+ y *= scale ;
19271951
19281952 /* Control is set to none unless it matches
19291953 * the current grab
@@ -1966,10 +1990,13 @@ meta_frames_motion_notify_event (GtkWidget *widget,
19661990 case META_GRAB_OP_NONE :
19671991 {
19681992 MetaFrameControl control ;
1969- int x , y ;
1993+ int x , y , scale ;
19701994
19711995 gdk_window_get_device_position (frame -> window , event -> device ,
19721996 & x , & y , NULL );
1997+ scale = gdk_window_get_scale_factor (frame -> window );
1998+ x *= scale ;
1999+ y *= scale ;
19732000
19742001 control = get_control (frames , frame , x , y );
19752002
@@ -2063,6 +2090,7 @@ populate_cache (MetaFrames *frames,
20632090 int top , bottom , left , right ;
20642091 int width , height ;
20652092 int frame_width , frame_height , screen_width , screen_height ;
2093+ gint scale ;
20662094 CachedPixels * pixels ;
20672095 MetaFrameType frame_type ;
20682096 MetaFrameFlags frame_flags ;
@@ -2093,28 +2121,29 @@ populate_cache (MetaFrames *frames,
20932121 & top , & bottom , & left , & right );
20942122
20952123 pixels = get_cache (frames , frame );
2124+ scale = gdk_window_get_scale_factor (frame -> window );
20962125
20972126 /* Setup the rectangles for the four frame borders. First top, then
20982127 left, right and bottom. */
20992128 pixels -> piece [0 ].rect .x = 0 ;
21002129 pixels -> piece [0 ].rect .y = 0 ;
2101- pixels -> piece [0 ].rect .width = left + width + right ;
2102- pixels -> piece [0 ].rect .height = top ;
2130+ pixels -> piece [0 ].rect .width = ( left + width + right ) * scale ;
2131+ pixels -> piece [0 ].rect .height = top * scale ;
21032132
21042133 pixels -> piece [1 ].rect .x = 0 ;
2105- pixels -> piece [1 ].rect .y = top ;
2106- pixels -> piece [1 ].rect .width = left ;
2107- pixels -> piece [1 ].rect .height = height ;
2134+ pixels -> piece [1 ].rect .y = top / scale ;
2135+ pixels -> piece [1 ].rect .width = left * scale ;
2136+ pixels -> piece [1 ].rect .height = height * scale ;
21082137
2109- pixels -> piece [2 ].rect .x = left + width ;
2110- pixels -> piece [2 ].rect .y = top ;
2111- pixels -> piece [2 ].rect .width = right ;
2112- pixels -> piece [2 ].rect .height = height ;
2138+ pixels -> piece [2 ].rect .x = ( left + width ) / scale ;
2139+ pixels -> piece [2 ].rect .y = top / scale ;
2140+ pixels -> piece [2 ].rect .width = right * scale ;
2141+ pixels -> piece [2 ].rect .height = height * scale ;
21132142
21142143 pixels -> piece [3 ].rect .x = 0 ;
2115- pixels -> piece [3 ].rect .y = top + height ;
2116- pixels -> piece [3 ].rect .width = left + width + right ;
2117- pixels -> piece [3 ].rect .height = bottom ;
2144+ pixels -> piece [3 ].rect .y = ( top + height ) / scale ;
2145+ pixels -> piece [3 ].rect .width = ( left + width + right ) * scale ;
2146+ pixels -> piece [3 ].rect .height = bottom * scale ;
21182147
21192148 for (i = 0 ; i < 4 ; i ++ )
21202149 {
@@ -2196,19 +2225,27 @@ subtract_client_area (cairo_region_t *region, MetaUIFrame *frame)
21962225 MetaFrameType type ;
21972226 cairo_region_t * tmp_region ;
21982227 Display * display ;
2228+ gint scale ;
21992229
22002230 display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
2231+ scale = gdk_window_get_scale_factor (frame -> window );
22012232
22022233 meta_core_get (display , frame -> xwindow ,
22032234 META_CORE_GET_FRAME_FLAGS , & flags ,
22042235 META_CORE_GET_FRAME_TYPE , & type ,
22052236 META_CORE_GET_CLIENT_WIDTH , & area .width ,
22062237 META_CORE_GET_CLIENT_HEIGHT , & area .height ,
22072238 META_CORE_GET_END );
2239+
22082240 meta_theme_get_frame_borders (meta_theme_get_current (),
22092241 type , frame -> text_height , flags ,
22102242 & area .x , NULL , & area .y , NULL );
22112243
2244+ area .width /= scale ;
2245+ area .height /= scale ;
2246+ area .x /= scale ;
2247+ area .y /= scale ;
2248+
22122249 tmp_region = cairo_region_create_rectangle (& area );
22132250 cairo_region_subtract (region , tmp_region );
22142251 cairo_region_destroy (tmp_region );
@@ -2295,7 +2332,7 @@ meta_frames_paint_to_drawable (MetaFrames *frames,
22952332 MetaFrameType type ;
22962333 GdkPixbuf * mini_icon ;
22972334 GdkPixbuf * icon ;
2298- int w , h ;
2335+ int w , h , scale ;
22992336 MetaButtonState button_states [META_BUTTON_TYPE_LAST ];
23002337 Window grab_frame ;
23012338 int i ;
@@ -2398,12 +2435,13 @@ meta_frames_paint_to_drawable (MetaFrames *frames,
23982435
23992436 meta_prefs_get_button_layout (& button_layout );
24002437
2438+ scale = gdk_window_get_scale_factor (frame -> window );
24012439 meta_theme_draw_frame_with_style (meta_theme_get_current (),
24022440 frame -> style ,
24032441 cr ,
24042442 type ,
24052443 flags ,
2406- w , h ,
2444+ w / scale , h / scale ,
24072445 frame -> layout ,
24082446 frame -> text_height ,
24092447 & button_layout ,
@@ -2576,9 +2614,14 @@ get_control (MetaFrames *frames,
25762614 MetaFrameFlags flags ;
25772615 gboolean has_vert , has_horiz ;
25782616 GdkRectangle client ;
2617+ gint scale ;
25792618
25802619 meta_frames_calc_geometry (frames , frame , & fgeom );
25812620
2621+ scale = gdk_window_get_scale_factor (frame -> window );
2622+ x /= scale ;
2623+ y /= scale ;
2624+
25822625 client .x = fgeom .left_width ;
25832626 client .y = fgeom .top_height ;
25842627 client .width = fgeom .width - fgeom .left_width - fgeom .right_width ;
@@ -2605,7 +2648,7 @@ get_control (MetaFrames *frames,
26052648
26062649 if (POINT_IN_RECT (x , y , fgeom .title_rect ))
26072650 {
2608- if (has_vert && y <= TOP_RESIZE_HEIGHT )
2651+ if (has_vert && y <= TOP_RESIZE_HEIGHT * scale )
26092652 return META_FRAME_CONTROL_RESIZE_N ;
26102653 else
26112654 return META_FRAME_CONTROL_TITLE ;
@@ -2698,7 +2741,7 @@ get_control (MetaFrames *frames,
26982741 if (has_vert )
26992742 return META_FRAME_CONTROL_RESIZE_S ;
27002743 }
2701- else if (y <= TOP_RESIZE_HEIGHT )
2744+ else if (y <= TOP_RESIZE_HEIGHT * scale )
27022745 {
27032746 if (has_vert )
27042747 return META_FRAME_CONTROL_RESIZE_N ;
0 commit comments