Bug 254451

Summary: graphics/mupdf: clipboard support for -gl
Product: Ports & Packages Reporter: yzrh
Component: Individual Port(s)Assignee: freebsd-ports-bugs (Nobody) <ports-bugs>
Status: New ---    
Severity: Affects Some People CC: uzsolt
Priority: --- Flags: bugzilla: maintainer-feedback? (uzsolt)
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
0001-Use-bundled-freeglut-lib-for-mupdf.patch
none
mupdf freeglut patch none

Description yzrh 2021-03-21 05:50:01 UTC
Reading PDF files using mupdf-gl emits the following:

warning: This version of MuPDF has been built WITHOUT clipboard or unicode input support!
warning: Please file a complaint with your friendly local distribution manager.

One cannot copy text from mupdf-gl.  It does not happen
with mupdf (which uses x11 not opengl) and primary selection works.
It seems that no option in ports can enable clipboard for the -gl
variant of mupdf.

Any idea why clipboard support is not enabled?  Thanks.
Comment 1 Zsolt Udvari 2021-03-21 06:48:33 UTC
I think I found the reason.

The mupdf's source contains a file, platform/gl/gl-ui.c, and in line 402 can found this message (https://git.ghostscript.com/?p=mupdf.git;a=blob;f=platform/gl/gl-ui.c;h=838ce61ade8acfc550e1d8409cf93f7bba0e9b63;hb=HEAD#l399).

The line 399 contains a condition: GLUT_API_VERSION >= 6. The FreeBSD ports has graphics/freeglut 3.0.0, and in the /usr/local/include/GL/freeglut_std.h the GLUT_API_VERSION is:
#define  GLUT_API_VERSION     4

I think the freeglut should upgrade because there is version 3.2.1 since September 2019 (http://freeglut.sourceforge.net/index.php#download). I try update it.

Thanks for report!
Comment 2 Zsolt Udvari 2021-03-21 09:17:55 UTC
I send a request to update graphics/freeglut: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=254454
Could you test this patch please? The mupdf build with newest freeglut without any other patches.
Comment 3 wjenkner 2021-03-23 11:44:51 UTC
I'm afraid this won't be enough as upstream freeglut doesn't contain the
relevant mupdf-specific changes.

The full story is told in

https://github.com/NixOS/nixpkgs/issues/104017

I've been using the attached patch (but never tested it in poudriere).
Comment 4 wjenkner 2021-03-23 11:46:56 UTC
Created attachment 223520 [details]
0001-Use-bundled-freeglut-lib-for-mupdf.patch

Use bundled freeglut for mupdf
Comment 5 Zsolt Udvari 2021-03-23 12:04:12 UTC
I see. I didn't was enough open-eyed, sorry.

The Porter's Handbook suggests avoid bundled libraries:
https://docs.freebsd.org/en/books/porters-handbook/book.html#bundled-libs

If anybody takes this report I hope (s)he can show any solution.
Comment 6 yzrh 2021-03-23 17:33:51 UTC
(In reply to wjenkner from comment #3)

Thanks for the insight.  I guess rebasing
the patches from mupdf to graphics/freeglut 3.2.1 is one
possible solution.
Comment 7 Zsolt Udvari 2021-03-24 09:54:45 UTC
(In reply to yzrh from comment #6)
I think it would be maybe the best solution.
But the better would be the official freeglut use these patches :)
Comment 8 yzrh 2021-03-24 15:56:46 UTC
Created attachment 223548 [details]
mupdf freeglut patch

Extracted from mupdf repo.  It is based on freeglut 3.0.0.
Considered the size,  it will take some time to review.
For this specific case,  bundled library may be better.
The patch can potentially break other programmes.
Comment 9 Zsolt Udvari 2021-03-25 08:00:40 UTC
(In reply to yzrh from comment #8)
I think it should be a report on graphics/freeglut.