Path: csiph.com!news.mixmin.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.graphics.misc Subject: Re: Running into problems while trying to scale Cairo surface to take up maximum space at specific aspect ratio Date: Mon, 12 Jun 2023 12:24:31 +0100 Organization: A noiseless patient Spider Lines: 34 Message-ID: <87legox6s0.fsf@bsb.me.uk> References: <87352xy24e.fsf@bsb.me.uk> MIME-Version: 1.0 Content-Type: text/plain Injection-Info: dont-email.me; posting-host="f067ee4065517ea2b744c2266857a574"; logging-data="3264363"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/cvpyWSW9zjas9uEh5kWXugWnYR+u4Jis=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Cancel-Lock: sha1:UF1aDl8lEvlMldhXLPLBLx4z6k4= sha1:mbGqY5SxDrUPWhD+hoP0kPSrCeo= X-BSB-Auth: 1.cd81da2afb99a40fc44e.20230612122431BST.87legox6s0.fsf@bsb.me.uk Xref: csiph.com comp.graphics.misc:548 Blue-Maned_Hawk writes: > On 6/11/23 20:07, Ben Bacarisse wrote: >> Blue-Maned_Hawk writes: >>> cairo_xlib_surface_set_size(cairo_get_target(root_instance), fmax(width, >>> e.xconfigure.width), fmax(height, e.xconfigure.height)); >> This case looks odd. What's the intent? Do you want stop the user >> making the window narrower than width or shorted than height? > > Yes, i do. I didn't know of any other way to do this. > >> If that's >> what you want you should probably limit e.xconfigure.{width,height}, set >> the X window size and then carry on as before because you still need to >> set the offset and scale and offset the source in this case as well. > > How would i do that? You could change e.xconfigure.width (and height) but rather than do that I'd base all the code on two new sizes int new_width = e.xconfigure.width, new_height = e.xconfigure.height; if (new_width < width || new_height < height) { new_width = fmax(width, new_width); ditto height set Xwindow size to new_width/new_height } what goes here is what was your else clause but using new_width and new_height rather than the e.xconfigure versions -- Ben.