Re: [evince] dvi text select and mouse-dvi alignment

2019-10-25 Thread Mike Marchywka via evince-list
On Fri, Oct 25, 2019 at 03:45:29AM -0600, Jason Crain wrote:
> On 10/25/19 3:03 AM, Mike Marchywka via evince-list wrote:
> > 1) The code I found looked like an error, the y-coord was apparently
> > shifted with border.right which sounds incorrect vs say border.top .
> > 2) On the first page without scrolling the above y seems to work ok.
> > 3) With scrolling, the text and mouse seemed to drift at about a 3-4 percent
> > rate hence the nice kluge. I wanted typeset the document as a single ( long 
> > )
> > page and aside from the obvious hazards of such a drift this becomes
> > a huge problem here. If this is some kind of fp round off or other known
> > problem it would be nice to fix- alternatively I can track it down as I 
> > wanted
> > to look at the coords anyway although hopefully mich later.
> > 4) The use of the view->scale in the empircally working code does not seem
> > consistent, it has a value around
> > 1.2 whcn I looked, and misuse should be an obvious problem
> > even on a normal page.
> > 
> > Was text select disabled on dvi for a reason or am I working with
> > very old code, apparently by source download is labelled
> > as evince-3.18.2.
> 
> Version 3.18.2 is from 2015. The newest version is 3.34.1. See
> https://wiki.gnome.org/Apps/Evince/Downloads for links to the official
> downloads.
> 
> As far as I know, the dvi backend has never supported the text interfaces.
> Only the PDF and DjVu backends currently support it.
> 
> There very well may be a bug in evince, though since text selection is
> working fairly well with PDF documents, if there is a bug, it might be
> limited to only the DVI backend.

I guess I forgot I added margins to DviContext and got them from here, 
see last two lines, this is from dvi-document.c. I have no idea
if these are baked into the other quantities somewhere,

static cairo_surface_t *
dvi_document_render (EvDocument  *document,
 EvRenderContext *rc)
{
cairo_surface_t *surface;
cairo_surface_t *rotated_surface;
DviDocument *dvi_document = DVI_DOCUMENT(document);
gdouble xscale, yscale;
gint required_width, required_height;
gint proposed_width, proposed_height;
gint xmargin = 0, ymargin = 0;

/* We should protect our context since it's not 
 * thread safe. The work to the future - 
 * let context render page independently
 */
g_mutex_lock (_context_mutex);

mdvi_setpage (dvi_document->context, rc->page->index);

ev_render_context_compute_scales (rc, dvi_document->base_width, 
dvi_document->base_height,
  , );
mdvi_set_shrink (dvi_document->context,
 (int)((dvi_document->params->hshrink - 1) / xscale) + 
1,
 (int)((dvi_document->params->vshrink - 1) / yscale) + 
1);

ev_render_context_compute_scaled_size (rc, dvi_document->base_width, 
dvi_document->base_height,
   _width, 
_height);
proposed_width = dvi_document->context->dvi_page_w * 
dvi_document->context->params.conv;
proposed_height = dvi_document->context->dvi_page_h * 
dvi_document->context->params.vconv;

if (required_width >= proposed_width)
xmargin = (required_width - proposed_width) / 2;
if (required_height >= proposed_height)
ymargin = (required_height - proposed_height) / 2;

mdvi_cairo_device_set_margins (_document->context->device, xmargin, 
ymargin);
mdvi_cairo_device_set_scale (_document->context->device, xscale, 
yscale);
mdvi_cairo_device_render (dvi_document->context);
surface = mdvi_cairo_device_get_surface 
(_document->context->device);
dvi_document->context->xmargin=xmargin; // mjm 
dvi_document->context->ymargin=ymargin; // mjm 




> 
> ___
> evince-list mailing list
> evince-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/evince-list

-- 

mike marchywka
306 charles cox
canton GA 30115
USA, Earth 
marchy...@hotmail.com
404-788-1216
ORCID: -0001-9237-455X
___
evince-list mailing list
evince-list@gnome.org
https://mail.gnome.org/mailman/listinfo/evince-list


Re: [evince] dvi text select and mouse-dvi alignment

2019-10-25 Thread Jason Crain

On 10/25/19 3:03 AM, Mike Marchywka via evince-list wrote:

1) The code I found looked like an error, the y-coord was apparently
shifted with border.right which sounds incorrect vs say border.top .
2) On the first page without scrolling the above y seems to work ok.
3) With scrolling, the text and mouse seemed to drift at about a 3-4 percent
rate hence the nice kluge. I wanted typeset the document as a single ( long )
page and aside from the obvious hazards of such a drift this becomes
a huge problem here. If this is some kind of fp round off or other known
problem it would be nice to fix- alternatively I can track it down as I wanted
to look at the coords anyway although hopefully mich later.
4) The use of the view->scale in the empircally working code does not seem
consistent, it has a value around
1.2 whcn I looked, and misuse should be an obvious problem
even on a normal page.

  
Was text select disabled on dvi for a reason or am I working with

very old code, apparently by source download is labelled
as evince-3.18.2.


Version 3.18.2 is from 2015. The newest version is 3.34.1. See 
https://wiki.gnome.org/Apps/Evince/Downloads for links to the official 
downloads.


As far as I know, the dvi backend has never supported the text 
interfaces. Only the PDF and DjVu backends currently support it.


There very well may be a bug in evince, though since text selection is 
working fairly well with PDF documents, if there is a bug, it might be 
limited to only the DVI backend.


___
evince-list mailing list
evince-list@gnome.org
https://mail.gnome.org/mailman/listinfo/evince-list


[evince] dvi text select and mouse-dvi alignment

2019-10-25 Thread Mike Marchywka via evince-list


This is probably something really stupid I missed and I was
hoping to discover it while writing the message but
have not found it yet so curious if anyone knows offhand how to
align the mouse coords and dvi coords for text select. 

Apparently my modifications are against evince-3.18.2.

I'm trying to modify the dvi backend from evince to control the visibility
of text blocks defined by new specials using mouse clicks. The basic
code seems to run to some extent- I can create dvi files from latex
with my new specials and view them in the modified evince, expanding
and iconifying the blocks I defined. However, the mouse clicks don't
seem to line up exactly with the dvi cursor and I'm not sure how this
is supposed to work. I took a "normal" latex document and compiled it into
pdf and dvi. The text select feature seems to work in pdf but not dvi-
it is not even implemented AFAICT.

So, that could explain why I could not find the code to copy :)

I think I came pretty close but it looks like there is drift or
round off error that is currently evident in the y position. Empirically
I came up with this gem which kind of works,

ev-view.c, circa line 5100,
,
gint xm,ym;
gtk_widget_get_pointer(widget,,);
// "border.right" was copied from existing code [sic?] 
int ym2=ym- 
0*(page_area.y+border.right)/view->scale+view->scroll_y+(3.5*view->scroll_y)/100.0+.5
 ;

or , 

int ym2=ym+view->scroll_y+(3.5*view->scroll_y)/100.0+.5 ;

in function ( line 4940 or so ), 
static gboolean ev_view_button_press_event (GtkWidget  *widget, 
GdkEventButton *event)


For context, the x value is made similarly and sent as a datagram, bypassing the
interfaces, 

d[0]=xm2; // xo; // xo; // event->x+view->scroll_x;
d[1]=ym2; // yo; // event->y+view->scroll_y;
// my code to send a time stamped event coord along with any needed
// pointers - this makes threading of the reload request another issue
// and yes it does segfault sometimes but works ok for testing  :)  
int csock= mjm_send_ts_ints(sname, sock, d, szi);

And when received in my new c++ code, compared to values like this,

 y=dvi->ymargin+ dvi->pos.vv;

Text laid out with this y value is thought to be what the user was clicking on.

Several comments and questions,

1) The code I found looked like an error, the y-coord was apparently
shifted with border.right which sounds incorrect vs say border.top .
2) On the first page without scrolling the above y seems to work ok.
3) With scrolling, the text and mouse seemed to drift at about a 3-4 percent
rate hence the nice kluge. I wanted typeset the document as a single ( long )
page and aside from the obvious hazards of such a drift this becomes
a huge problem here. If this is some kind of fp round off or other known
problem it would be nice to fix- alternatively I can track it down as I wanted
to look at the coords anyway although hopefully mich later. 
4) The use of the view->scale in the empircally working code does not seem 
consistent, it has a value around
1.2 whcn I looked, and misuse should be an obvious problem 
even on a normal page.

 
Was text select disabled on dvi for a reason or am I working with
very old code, apparently by source download is labelled
as evince-3.18.2.

Thanks.

 

-- 

mike marchywka
306 charles cox
canton GA 30115
USA, Earth 
marchy...@hotmail.com
404-788-1216
ORCID: -0001-9237-455X
___
evince-list mailing list
evince-list@gnome.org
https://mail.gnome.org/mailman/listinfo/evince-list