Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
09d44b2
small forge compat change, unsure exactly how necessary it'll be, but…
GiantLuigi4 Aug 6, 2023
e4dbdea
start migrating off awt
GiantLuigi4 Aug 7, 2023
9f3ae05
more glfw porting
GiantLuigi4 Aug 7, 2023
793d646
Update README.md
ds58 Aug 7, 2023
1038540
glfw-ify mouse events
GiantLuigi4 Aug 7, 2023
9f78815
should be done with the events
GiantLuigi4 Aug 7, 2023
0dc4f4a
Merge branch 'CinemaMod:master' into master
GiantLuigi4 Aug 7, 2023
63ee43e
actually, I'll undo this for now
GiantLuigi4 Aug 7, 2023
ebcc7c8
Merge remote-tracking branch 'origin/master'
GiantLuigi4 Aug 7, 2023
ebf4292
realized this is useful
GiantLuigi4 Aug 8, 2023
719493d
realized that only mouse exit and mouse move is meaningful
GiantLuigi4 Aug 8, 2023
97173bb
variables for key constants, add basic notes on what the constants are
GiantLuigi4 Aug 8, 2023
ab05420
apparently I messed this number up
GiantLuigi4 Aug 8, 2023
e86d264
follow ds's comments
GiantLuigi4 Aug 8, 2023
2fddac2
cleanup
GiantLuigi4 Aug 8, 2023
bf384e9
Merge pull request #2 from GiantLuigi4/master
ds58 Aug 8, 2023
df8a667
remove need for awt canvas
GiantLuigi4 Aug 8, 2023
d8eca50
Merge branch 'CinemaMod:master' into master
GiantLuigi4 Aug 8, 2023
e10d321
no awt, except for in like drag events
GiantLuigi4 Aug 9, 2023
5df3240
finish glfw migration completely(?)
GiantLuigi4 Aug 9, 2023
6321e4b
Merge remote-tracking branch 'origin/master'
GiantLuigi4 Aug 9, 2023
00bad07
Merge pull request #3 from GiantLuigi4/master
ds58 Aug 9, 2023
dcb4144
don't map mouse types, but I'm gonna wanna make a java enum for that …
GiantLuigi4 Aug 9, 2023
37e09ab
Merge branch 'CinemaMod:master' into master
GiantLuigi4 Aug 9, 2023
70e55dc
Merge pull request #4 from GiantLuigi4/master
ds58 Aug 9, 2023
d3b5607
cursor types
GiantLuigi4 Aug 9, 2023
d3cf009
Merge branch 'CinemaMod:master' into master
GiantLuigi4 Aug 9, 2023
bb11155
remove some setFocus calls from CefClient, as they cause errors
GiantLuigi4 Aug 9, 2023
c3ae3b6
Merge remote-tracking branch 'origin/master'
GiantLuigi4 Aug 9, 2023
0ad5c38
I always forget access modifiers on enum fields and methods
GiantLuigi4 Aug 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# CinemaMod java-cef
Modified version of java-cef for use with CinemaMod
# MCEF java-cef
Modified version of java-cef for use with MCEF
103 changes: 23 additions & 80 deletions java/org/cef/CefClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@
import org.cef.network.CefResponse;
import org.cef.network.CefURLRequest;

import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FocusTraversalPolicy;
import java.awt.KeyboardFocusManager;
import java.awt.Point;
import java.awt.Rectangle;
import java.beans.PropertyChangeEvent;
Expand All @@ -68,9 +64,9 @@
*/
public class CefClient extends CefClientHandler
implements CefContextMenuHandler, CefDialogHandler, CefDisplayHandler, CefDownloadHandler,
CefDragHandler, CefFocusHandler, CefJSDialogHandler, CefKeyboardHandler,
CefLifeSpanHandler, CefLoadHandler, CefPrintHandler, CefRenderHandler,
CefRequestHandler, CefWindowHandler {
CefDragHandler, CefFocusHandler, CefJSDialogHandler, CefKeyboardHandler,
CefLifeSpanHandler, CefLoadHandler, CefPrintHandler, CefRenderHandler,
CefRequestHandler, CefWindowHandler {
private HashMap<Integer, CefBrowser> browser_ = new HashMap<Integer, CefBrowser>();
private CefContextMenuHandler contextMenuHandler_ = null;
private CefDialogHandler dialogHandler_ = null;
Expand All @@ -85,43 +81,15 @@ public class CefClient extends CefClientHandler
private CefPrintHandler printHandler_ = null;
private CefRequestHandler requestHandler_ = null;
private boolean isDisposed_ = false;
private volatile CefBrowser focusedBrowser_ = null;
private final PropertyChangeListener propertyChangeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (focusedBrowser_ != null) {
Component browserUI = focusedBrowser_.getUIComponent();
Object oldUI = evt.getOldValue();
if (isPartOf(oldUI, browserUI)) {
focusedBrowser_.setFocus(false);
focusedBrowser_ = null;
}
}
}
};

/**
* The CTOR is only accessible within this package.
* Use CefApp.createClient() to create an instance of
* this class.
* @see org.cef.CefApp.createClient()
* @see org.cef.CefApp#createClient()
*/
CefClient() throws UnsatisfiedLinkError {
super();

KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(
propertyChangeListener);
}

private boolean isPartOf(Object obj, Component browserUI) {
if (obj == browserUI) return true;
if (obj instanceof Container) {
Component childs[] = ((Container) obj).getComponents();
for (Component child : childs) {
return isPartOf(child, browserUI);
}
}
return false;
}

@Override
Expand All @@ -133,15 +101,15 @@ public void dispose() {
// CefClientHandler

public CefBrowser createBrowser(
String url, boolean isOffscreenRendered, boolean isTransparent) {
return createBrowser(url, isOffscreenRendered, isTransparent, null);
String url, boolean isTransparent) {
return createBrowser(url, isTransparent, null);
}

public CefBrowser createBrowser(String url, boolean isOffscreenRendered, boolean isTransparent,
CefRequestContext context) {
public CefBrowser createBrowser(String url, boolean isTransparent,
CefRequestContext context) {
if (isDisposed_)
throw new IllegalStateException("Can't create browser. CefClient is disposed");
return CefBrowserFactory.create(this, url, isOffscreenRendered, isTransparent, context);
return CefBrowserFactory.create(this, url, isTransparent, context);
}

@Override
Expand Down Expand Up @@ -248,7 +216,7 @@ public void onBeforeContextMenu(

@Override
public boolean onContextMenuCommand(CefBrowser browser, CefFrame frame,
CefContextMenuParams params, int commandId, int eventFlags) {
CefContextMenuParams params, int commandId, int eventFlags) {
if (contextMenuHandler_ != null && browser != null)
return contextMenuHandler_.onContextMenuCommand(
browser, frame, params, commandId, eventFlags);
Expand All @@ -274,7 +242,7 @@ public void removeDialogHandler() {

@Override
public boolean onFileDialog(CefBrowser browser, FileDialogMode mode, String title,
String defaultFilePath, Vector<String> acceptFilters, CefFileDialogCallback callback) {
String defaultFilePath, Vector<String> acceptFilters, CefFileDialogCallback callback) {
if (dialogHandler_ != null && browser != null) {
return dialogHandler_.onFileDialog(
browser, mode, title, defaultFilePath, acceptFilters, callback);
Expand Down Expand Up @@ -322,7 +290,7 @@ public void onStatusMessage(CefBrowser browser, String value) {

@Override
public boolean onConsoleMessage(CefBrowser browser, CefSettings.LogSeverity level,
String message, String source, int line) {
String message, String source, int line) {
if (displayHandler_ != null && browser != null) {
return displayHandler_.onConsoleMessage(browser, level, message, source, line);
}
Expand Down Expand Up @@ -360,7 +328,7 @@ public void removeDownloadHandler() {

@Override
public void onBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem,
String suggestedName, CefBeforeDownloadCallback callback) {
String suggestedName, CefBeforeDownloadCallback callback) {
if (downloadHandler_ != null && browser != null)
downloadHandler_.onBeforeDownload(browser, downloadItem, suggestedName, callback);
}
Expand Down Expand Up @@ -405,27 +373,6 @@ public void removeFocusHandler() {
public void onTakeFocus(CefBrowser browser, boolean next) {
if (browser == null) return;

browser.setFocus(false);
Container parent = browser.getUIComponent().getParent();
if (parent != null) {
FocusTraversalPolicy policy = null;
while (parent != null) {
policy = parent.getFocusTraversalPolicy();
if (policy != null) break;
parent = parent.getParent();
}
if (policy != null) {
Component nextComp = next
? policy.getComponentAfter(parent, browser.getUIComponent())
: policy.getComponentBefore(parent, browser.getUIComponent());
if (nextComp == null) {
policy.getDefaultComponent(parent).requestFocus();
} else {
nextComp.requestFocus();
}
}
}
focusedBrowser_ = null;
if (focusHandler_ != null) focusHandler_.onTakeFocus(browser, next);
}

Expand All @@ -442,8 +389,6 @@ public boolean onSetFocus(final CefBrowser browser, FocusSource source) {
public void onGotFocus(CefBrowser browser) {
if (browser == null) return;

focusedBrowser_ = browser;
browser.setFocus(true);
if (focusHandler_ != null) focusHandler_.onGotFocus(browser);
}

Expand All @@ -460,8 +405,8 @@ public void removeJSDialogHandler() {

@Override
public boolean onJSDialog(CefBrowser browser, String origin_url, JSDialogType dialog_type,
String message_text, String default_prompt_text, CefJSDialogCallback callback,
BoolRef suppress_message) {
String message_text, String default_prompt_text, CefJSDialogCallback callback,
BoolRef suppress_message) {
if (jsDialogHandler_ != null && browser != null)
return jsDialogHandler_.onJSDialog(browser, origin_url, dialog_type, message_text,
default_prompt_text, callback, suppress_message);
Expand All @@ -470,7 +415,7 @@ public boolean onJSDialog(CefBrowser browser, String origin_url, JSDialogType di

@Override
public boolean onBeforeUnloadDialog(CefBrowser browser, String message_text, boolean is_reload,
CefJSDialogCallback callback) {
CefJSDialogCallback callback) {
if (jsDialogHandler_ != null && browser != null)
return jsDialogHandler_.onBeforeUnloadDialog(
browser, message_text, is_reload, callback);
Expand Down Expand Up @@ -584,8 +529,6 @@ private void cleanupBrowser(int identifier) {
}

if (browser_.isEmpty() && isDisposed_) {
KeyboardFocusManager.getCurrentKeyboardFocusManager().removePropertyChangeListener(
propertyChangeListener);
removeContextMenuHandler(this);
removeDialogHandler(this);
removeDisplayHandler(this);
Expand Down Expand Up @@ -639,7 +582,7 @@ public void onLoadEnd(CefBrowser browser, CefFrame frame, int httpStatusCode) {

@Override
public void onLoadError(CefBrowser browser, CefFrame frame, ErrorCode errorCode,
String errorText, String failedUrl) {
String errorText, String failedUrl) {
if (loadHandler_ != null && browser != null)
loadHandler_.onLoadError(browser, frame, errorCode, errorText, failedUrl);
}
Expand Down Expand Up @@ -677,7 +620,7 @@ public boolean onPrintDialog(

@Override
public boolean onPrintJob(CefBrowser browser, String documentName, String pdfFilePath,
CefPrintJobCallback callback) {
CefPrintJobCallback callback) {
if (printHandler_ != null && browser != null)
return printHandler_.onPrintJob(browser, documentName, pdfFilePath, callback);
return false;
Expand Down Expand Up @@ -745,7 +688,7 @@ public void onPopupSize(CefBrowser browser, Rectangle size) {

@Override
public void onPaint(CefBrowser browser, boolean popup, Rectangle[] dirtyRects,
ByteBuffer buffer, int width, int height) {
ByteBuffer buffer, int width, int height) {
if (browser == null) return;

CefRenderHandler realHandler = browser.getRenderHandler();
Expand Down Expand Up @@ -783,7 +726,7 @@ public void removeRequestHandler() {

@Override
public boolean onBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request,
boolean user_gesture, boolean is_redirect) {
boolean user_gesture, boolean is_redirect) {
if (requestHandler_ != null && browser != null)
return requestHandler_.onBeforeBrowse(
browser, frame, request, user_gesture, is_redirect);
Expand All @@ -801,8 +744,8 @@ public boolean onOpenURLFromTab(

@Override
public CefResourceRequestHandler getResourceRequestHandler(CefBrowser browser, CefFrame frame,
CefRequest request, boolean isNavigation, boolean isDownload, String requestInitiator,
BoolRef disableDefaultHandling) {
CefRequest request, boolean isNavigation, boolean isDownload, String requestInitiator,
BoolRef disableDefaultHandling) {
if (requestHandler_ != null && browser != null) {
return requestHandler_.getResourceRequestHandler(browser, frame, request, isNavigation,
isDownload, requestInitiator, disableDefaultHandling);
Expand All @@ -812,7 +755,7 @@ public CefResourceRequestHandler getResourceRequestHandler(CefBrowser browser, C

@Override
public boolean getAuthCredentials(CefBrowser browser, String origin_url, boolean isProxy,
String host, int port, String realm, String scheme, CefAuthCallback callback) {
String host, int port, String realm, String scheme, CefAuthCallback callback) {
if (requestHandler_ != null && browser != null)
return requestHandler_.getAuthCredentials(
browser, origin_url, isProxy, host, port, realm, scheme, callback);
Expand Down
5 changes: 2 additions & 3 deletions java/org/cef/browser/CefBrowserFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
* Creates a new instance of CefBrowser according the passed values
*/
public class CefBrowserFactory {
public static CefBrowser create(CefClient client, String url, boolean isOffscreenRendered,
public static CefBrowser create(CefClient client, String url,
boolean isTransparent, CefRequestContext context) {
if (isOffscreenRendered) return new CefBrowserOsr(client, url, isTransparent, context);
return new CefBrowserWr(client, url, context);
return new CefBrowserOsr(client, url, isTransparent, context);
}
}
4 changes: 2 additions & 2 deletions java/org/cef/browser/CefBrowserOsr.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ private void createBrowserIfRequired(boolean hasParent) {
if (getNativeRef("CefBrowser") == 0) {
if (getParentBrowser() != null) {
createDevTools(getParentBrowser(), getClient(), windowHandle, true, isTransparent_,
null, getInspectAt());
getInspectAt());
} else {
createBrowser(getClient(), windowHandle, getUrl(), true, isTransparent_, null,
createBrowser(getClient(), windowHandle, getUrl(), true, isTransparent_,
getRequestContext());
}
} else if (hasParent && justCreated_) {
Expand Down
Loading