-
You can't 'lock' a uPVC window frame into masonry.
The uPVC will react much more quickly to temperature changes, the frame will expand and contract, as you can see in your picture by 2-3-4mm.You need to apply an elastomeric sealant, one that can accomodate the movement you can see.
The best elastomeric sealants claim '25% movement accomodation factor', in total.
This means you need for a durable waterproof seal, to apply a bead 16mm wide, and around 8-10mm deep between the masonry and the uPVC frame.
Soudal Fix All High Tack Adhesive & Sealant, (Toolstation 84704) comes in white,
so you save the painting you envisaged.
related to windows and frames above,
Any idea on what I should do about this internal window frame? There's a crack that runs all the way around the sides of the frame and if you open the window it wobbles a bit, it's leting in a draft and noise currently. Old old UPVC frames, but the renovation budget hasn't yet stretched to replacing them all yet - so a shorter term fix with filling and painting is planned
Scrape anything loose out and try and fill with expanding foam to lock it in place, or is this a job for a professional?