This was my temporary solution:

first in clipboard_paste_image I make sure x,y values are never negative

then in create_image_from_pixbuf

if the image is right/below then move it to the edge

  // let us make sure we are within boundaries, if not, place it at the edge
  // TODO:
  // there is a bug in calculating the location when the pointer is
outside the boundary for one of the dimensions
  // either x or y will be ok but not both.
  // too lazy to do now
  if (ui.cur_page->width < item->bbox.left) {
    item->bbox.left = ui.cur_page->width - (scale *
gdk_pixbuf_get_width(item->image));
  }
  if (ui.cur_page->height < item->bbox.top) {
    item->bbox.top = ui.cur_page->height - (scale *
gdk_pixbuf_get_height(item->image));
  }
  if (item->bbox.left < 0) {
    item->bbox.left  = 0;
  }
  if (item->bbox.top  < 0) {
    item->bbox.top  = 0;
  }

On Thu, Nov 14, 2013 at 2:24 AM, Denis Auroux <aur...@math.berkeley.edu> wrote:
> On 11/12/2013 11:33 PM, D M German wrote:
>>
>>
>> I _think_ I found a bug in xournal:
>>
>> - create a new document
>> - resize the page so there is grey space around it
>> - place the mouse under the page (within the canvas)
>> - try to paste an image with ctrl-v
>>
>> it should crash.
>
>
> Interesting: for me it doesn't crash but complains about
>
> (xournal:16950): GnomeCanvas-CRITICAL **: gnome_canvas_pixbuf_set_property:
> assertion `val >= 0.0' failed
>
> and produces evil display bugs as gnomecanvas attempts desperately to cope
> with a pixbuf scaled to negative width and height. Same when you paste
> further right than the page.
>
> In any case this is indeed a bug. A related misfeature is that pasting by
> clicking the toolbar button often places the image in the wrong location or
> on the wrong page: in continuous view mode, place the view to start at the
> top of page 2, click on the paste button to insert an image, the image ends
> up at very small scale at the bottom of page 1 (because its top-left corner
> gets placed at the click location i.e. under the paste button).
>
> The question is what the best behavior should be regarding scaling of pasted
> images -- right now they appear with upper-left corner at the click
> location, sized to 1 pixel = 1 pixel if that fits on the page, otherwise
> squished so they fit on the page (with the issue you pointed out when the
> click location is further right or down than the end of the page).
>
> Should the code be changed so that, if the cursor is well within (e.g. > 10
> pixels from the edge) of both the canvas and the page's lower-right
> boundaries, then we insert at the cursor with scaling to fit the page as
> currently, and otherwise we paste at unit scale at an arbitrary location
> more or less centered on the viewport (not sure exactly how, but similar to
> the regular paste code for selection items) ?
>
> Further comments or suggestions welcome. Won't have time to do this
> immediately, but within the next week or two I should be able to get to it
> -- pretty high priority, as usual for bugs.
>
> Denis



-- 
--dmg

---
Daniel M. German
http://turingmachine.org

------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
Xournal-devel mailing list
Xournal-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xournal-devel

Reply via email to