@@ -75,6 +75,32 @@ northwestcmp (gconstpointer a, gconstpointer b)
7575 return 0 ;
7676}
7777
78+
79+ static gboolean
80+ place_by_pointer (MetaWindow * window ,
81+ MetaPlacementMode placement_mode ,
82+ int * new_x ,
83+ int * new_y )
84+ {
85+ MetaBackend * backend = meta_get_backend ();
86+ MetaCursorTracker * cursor_tracker = meta_backend_get_cursor_tracker (backend );
87+ int root_x , root_y ;
88+
89+ meta_cursor_tracker_get_pointer (cursor_tracker , & root_x , & root_y , NULL );
90+
91+ MetaRectangle frame_rect ;
92+ meta_window_get_frame_rect (window , & frame_rect );
93+
94+ * new_x = root_x - frame_rect .width / 2 ;
95+ * new_y = root_y - frame_rect .height / 2 ;
96+
97+ if (placement_mode == META_PLACEMENT_MODE_MANUAL )
98+ window -> move_after_placement = TRUE;
99+
100+ return TRUE;
101+ }
102+
103+
78104static void
79105find_next_cascade (MetaWindow * window ,
80106 /* visible windows on relevant workspaces */
@@ -323,7 +349,8 @@ window_place_centered (MetaWindow *window)
323349 return (type == META_WINDOW_DIALOG ||
324350 type == META_WINDOW_MODAL_DIALOG ||
325351 type == META_WINDOW_SPLASHSCREEN ||
326- (type == META_WINDOW_NORMAL && meta_prefs_get_center_new_windows ()));
352+ (type == META_WINDOW_NORMAL &&
353+ meta_prefs_get_new_window_placement_mode () == META_PLACEMENT_MODE_CENTER ));
327354}
328355
329356static void
@@ -668,6 +695,7 @@ meta_window_place (MetaWindow *window,
668695 MetaBackend * backend = meta_get_backend ();
669696 GList * windows = NULL ;
670697 MetaLogicalMonitor * logical_monitor ;
698+ MetaPlacementMode placement_mode ;
671699
672700 meta_topic (META_DEBUG_PLACEMENT , "Placing window %s\n" , window -> desc );
673701
@@ -884,6 +912,18 @@ meta_window_place (MetaWindow *window,
884912 x = logical_monitor -> rect .x ;
885913 y = logical_monitor -> rect .y ;
886914
915+
916+ /* Placement based on pointer position */
917+ placement_mode = meta_prefs_get_new_window_placement_mode ();
918+
919+ if (placement_mode == META_PLACEMENT_MODE_POINTER ||
920+ placement_mode == META_PLACEMENT_MODE_MANUAL )
921+ {
922+ if (place_by_pointer (window , placement_mode , & x , & y ))
923+ goto done_check_denied_focus ;
924+ }
925+
926+
887927 if (find_first_fit (window , windows ,
888928 logical_monitor ,
889929 x , y , & x , & y ))
0 commit comments