Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component is jumping to a new window only in Linux #38

Closed
lucianomartini opened this issue Dec 19, 2016 · 8 comments
Closed

Component is jumping to a new window only in Linux #38

lucianomartini opened this issue Dec 19, 2016 · 8 comments

Comments

@lucianomartini
Copy link

lucianomartini commented Dec 19, 2016

I am having a issue with fpCEF3.

In windows i can create a project fine and add the component Chromium pointed to https://www.google.com.br, but in Linux (Debian 8), when i try to do that, the component detaches from the main window, the loading of google occurs fine but in a another strange window.

I am going crazy because there is no errors at all.

What i do:
1- Create a new project from zero.
2- Copy resources and release to the root of the project.
3- Add a Chromium component to the main form.
4- Set default url to https://www.google.com.br in the component properties.

What happen if a compile and run it on:
1- Windows: It opens only a window with chromium component loading google in the main form.

2- Linux - It opens 2 windows, the main form , and a new additional window, loading google fine but in a new detached window.

And the strangest thing is that the LCLsimple example, works in the same window **but it broken openning a new window, when i remove the simpletext component from the example app. (yes! the 'Url:' text)

Maybe is something related to the lazarus version?

Lazarus 1.6 FPCEF for CEF 2743 Debian 8 64 bits operating system, graphical environment: Mate

@lucianomartini
Copy link
Author

UPDATE: This only occurs when using GTK2, if i use Lazarus for QT the application runs fine.

@dliw
Copy link
Owner

dliw commented Dec 20, 2016

I mostly test with GTK2 and it works ok for me (KDE 4).

  • Which gtk2 version do you have?
  • Do you have any other graphical environment installed and if yes, is the behavior the same?
  • Does anything change, if you don't assign a default url?

There is one big difference between CEF on Windows and CEF on Linux:
On Windows the browser is a "real" component (like e.g. buttons, text fields, ...). On Linux CEF is embedded into the main form directly on X11 level. If it fails to determine the main form or the main form does not have an xwindow assigned (should never be the case), CEF creates its own window - and that's what you are seeing.

Could you please set a breakpoint in cef3lcl.pas, line 690 and see, whether info.parent_window is assigned or a zero value?

Maybe is something related to the lazarus version?

I tested the latest fpCEF version with Lazarus 1.6, so there should be no problem.

@lucianomartini
Copy link
Author

lucianomartini commented Dec 21, 2016

  • GTK Version is 2.24.30-2 (libgtk2)
  • WM is Mate
  • No.

I added the breakpoint the app runs with the separated window but is very strange breakpoint indicates 0 passes. I tried to re-execute the app a few times, what i am doing wrong? Maybe is because i installed fpcef on lazarus?

error

Note i tried to put a breakpoint into a application button, and it is counting the hits.

@dliw
Copy link
Owner

dliw commented Dec 21, 2016

Ok, I can reproduce this. A new window is created, if I remove the url label in the LCLSimple example. GTK issues this warning

Gdk-WARNING **: gdkdrawable-x11.c:952 drawable is not a pixmap or window

I will need to look into this issue more closely, as I don't really have an idea right now.

EDIT: Actually the function gets called, but the debugger somehow fails to stop at the breakpoint.

@lucianomartini
Copy link
Author

lucianomartini commented Dec 21, 2016

Thank you very much friend. If you create a new project the issue will happen too!

@dliw
Copy link
Owner

dliw commented Dec 21, 2016

The following diff fixes the issue for me:

diff --git a/Component/cef3lcl.pas b/Component/cef3lcl.pas
@@ -687,6 +687,7 @@ begin
       fParentForm := GetParentForm(Self);
 
       {$IFDEF LCLGTK2}
+        gtk_widget_realize(PGtkWidget(fParentForm.Handle));
         info.parent_window := gdk_window_xwindow(PGtkWidget(fParentForm.Handle)^.window);
       {$ENDIF}
       {$IFDEF LCLQT}

I will commit this fix once I'm sure there are no downsides. But I don't have the time for testing right now.

@lucianomartini
Copy link
Author

lucianomartini commented Dec 21, 2016

I think its really fixed and can be closed thank you so very much!, friend i know it is off-topic but you can help with some example of how can i implement the printer ? I will understand if you can't... Sorry to bother you like this. I am trying to port a webrowser that is running in Windows to Linux. Please visit lazarus forum when you have some time or can i use a issue for that?

Can i try the printtopdf function in linux, or need to be implemented too? I think i can do some adaption to make this to print to the real printer.. haha!

@dliw
Copy link
Owner

dliw commented Dec 21, 2016

This belongs to issue #39.

Please visit lazarus forum when you have some time or can i use a issue for that?

Did you open a thread? Please send me a link if you do / did so. Please follow issue #40 to see the progress. It will take some time though, as I'm very busy right now.

Can i try the printtopdf function in linux, or need to be implemented too?

Sorry, I don't know. You could try this code, but it could be, that one needs to implement the print handler on Linux in any case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants