mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-25 03:12:56 +00:00
format and indent qx11embed_x11 source file
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
2dbe488dff
commit
bab65cc009
1 changed files with 207 additions and 184 deletions
|
@ -1234,10 +1234,10 @@ void QX11EmbedContainer::embedClient(WId id)
|
||||||
switch (XReparentWindow(x11Info().display(), id, internalWinId(), 0, 0)) {
|
switch (XReparentWindow(x11Info().display(), id, internalWinId(), 0, 0)) {
|
||||||
case BadWindow:
|
case BadWindow:
|
||||||
case BadMatch:
|
case BadMatch:
|
||||||
d->emitError(InvalidWindowID);
|
d->emitError(InvalidWindowID);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1249,29 +1249,32 @@ bool QX11EmbedContainer::eventFilter(QObject *o, QEvent *event)
|
||||||
{
|
{
|
||||||
Q_D(QX11EmbedContainer);
|
Q_D(QX11EmbedContainer);
|
||||||
switch (event->type()) {
|
switch (event->type()) {
|
||||||
case QEvent::KeyPress:
|
case QEvent::KeyPress: {
|
||||||
// Forward any keypresses to our client.
|
// Forward any keypresses to our client.
|
||||||
if (o == this && d->client) {
|
if (o == this && d->client) {
|
||||||
lastKeyEvent.window = d->client;
|
lastKeyEvent.window = d->client;
|
||||||
XSendEvent(x11Info().display(), d->client, false, KeyPressMask, (XEvent *) &lastKeyEvent);
|
XSendEvent(x11Info().display(), d->client, false, KeyPressMask, (XEvent *) &lastKeyEvent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case QEvent::KeyRelease:
|
}
|
||||||
// Forward any keyreleases to our client.
|
|
||||||
if (o == this && d->client) {
|
|
||||||
lastKeyEvent.window = d->client;
|
|
||||||
XSendEvent(x11Info().display(), d->client, false, KeyReleaseMask, (XEvent *) &lastKeyEvent);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case QEvent::WindowActivate:
|
case QEvent::KeyRelease: {
|
||||||
// When our container window is activated, we pass the
|
// Forward any keyreleases to our client.
|
||||||
// activation message on to our client. Note that X input
|
if (o == this && d->client) {
|
||||||
// focus is set to our focus proxy. We want to intercept all
|
lastKeyEvent.window = d->client;
|
||||||
// keypresses.
|
XSendEvent(x11Info().display(), d->client, false, KeyReleaseMask, (XEvent *) &lastKeyEvent);
|
||||||
if (o == window() && d->client) {
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case QEvent::WindowActivate: {
|
||||||
|
// When our container window is activated, we pass the
|
||||||
|
// activation message on to our client. Note that X input
|
||||||
|
// focus is set to our focus proxy. We want to intercept all
|
||||||
|
// keypresses.
|
||||||
|
if (o == window() && d->client) {
|
||||||
if (d->clientIsXEmbed) {
|
if (d->clientIsXEmbed) {
|
||||||
sendXEmbedMessage(d->client, x11Info().display(), XEMBED_WINDOW_ACTIVATE);
|
sendXEmbedMessage(d->client, x11Info().display(), XEMBED_WINDOW_ACTIVATE);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1281,24 +1284,28 @@ bool QX11EmbedContainer::eventFilter(QObject *o, QEvent *event)
|
||||||
}
|
}
|
||||||
if (!d->isEmbedded())
|
if (!d->isEmbedded())
|
||||||
d->moveInputToProxy();
|
d->moveInputToProxy();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case QEvent::WindowDeactivate:
|
}
|
||||||
// When our container window is deactivated, we pass the
|
|
||||||
// deactivation message to our client.
|
case QEvent::WindowDeactivate: {
|
||||||
if (o == window() && d->client) {
|
// When our container window is deactivated, we pass the
|
||||||
if (d->clientIsXEmbed)
|
// deactivation message to our client.
|
||||||
sendXEmbedMessage(d->client, x11Info().display(), XEMBED_WINDOW_DEACTIVATE);
|
if (o == window() && d->client) {
|
||||||
else
|
if (d->clientIsXEmbed)
|
||||||
d->checkGrab();
|
sendXEmbedMessage(d->client, x11Info().display(), XEMBED_WINDOW_DEACTIVATE);
|
||||||
}
|
else
|
||||||
break;
|
d->checkGrab();
|
||||||
case QEvent::FocusIn:
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case QEvent::FocusIn: {
|
||||||
// When receiving FocusIn events generated by Tab or Backtab,
|
// When receiving FocusIn events generated by Tab or Backtab,
|
||||||
// we pass focus on to our client. Any mouse activity is sent
|
// we pass focus on to our client. Any mouse activity is sent
|
||||||
// directly to the client, and it will ask us for focus with
|
// directly to the client, and it will ask us for focus with
|
||||||
// XEMBED_REQUEST_FOCUS.
|
// XEMBED_REQUEST_FOCUS.
|
||||||
if (o == this && d->client) {
|
if (o == this && d->client) {
|
||||||
if (!d->isEmbedded())
|
if (!d->isEmbedded())
|
||||||
d->activeContainer = this;
|
d->activeContainer = this;
|
||||||
|
|
||||||
|
@ -1306,77 +1313,80 @@ bool QX11EmbedContainer::eventFilter(QObject *o, QEvent *event)
|
||||||
if (!d->isEmbedded())
|
if (!d->isEmbedded())
|
||||||
d->moveInputToProxy();
|
d->moveInputToProxy();
|
||||||
|
|
||||||
QFocusEvent *fe = (QFocusEvent *)event;
|
QFocusEvent *fe = (QFocusEvent *)event;
|
||||||
switch (fe->reason()) {
|
switch (fe->reason()) {
|
||||||
case Qt::TabFocusReason:
|
case Qt::TabFocusReason:
|
||||||
sendXEmbedMessage(d->client, x11Info().display(), XEMBED_FOCUS_IN, XEMBED_FOCUS_FIRST);
|
sendXEmbedMessage(d->client, x11Info().display(), XEMBED_FOCUS_IN, XEMBED_FOCUS_FIRST);
|
||||||
break;
|
break;
|
||||||
case Qt::BacktabFocusReason:
|
case Qt::BacktabFocusReason:
|
||||||
sendXEmbedMessage(d->client, x11Info().display(), XEMBED_FOCUS_IN, XEMBED_FOCUS_LAST);
|
sendXEmbedMessage(d->client, x11Info().display(), XEMBED_FOCUS_IN, XEMBED_FOCUS_LAST);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sendXEmbedMessage(d->client, x11Info().display(), XEMBED_FOCUS_IN, XEMBED_FOCUS_CURRENT);
|
sendXEmbedMessage(d->client, x11Info().display(), XEMBED_FOCUS_IN, XEMBED_FOCUS_CURRENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
d->checkGrab();
|
d->checkGrab();
|
||||||
XSetInputFocus(x11Info().display(), d->client, RevertToParent, x11Time());
|
XSetInputFocus(x11Info().display(), d->client, RevertToParent, x11Time());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
|
||||||
case QEvent::FocusOut: {
|
case QEvent::FocusOut: {
|
||||||
// When receiving a FocusOut, we ask our client to remove its
|
// When receiving a FocusOut, we ask our client to remove its
|
||||||
// focus.
|
// focus.
|
||||||
if (o == this && d->client) {
|
if (o == this && d->client) {
|
||||||
if (!d->isEmbedded()) {
|
if (!d->isEmbedded()) {
|
||||||
d->activeContainer = 0;
|
d->activeContainer = 0;
|
||||||
if (isActiveWindow())
|
if (isActiveWindow())
|
||||||
d->moveInputToProxy();
|
d->moveInputToProxy();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->clientIsXEmbed) {
|
if (d->clientIsXEmbed) {
|
||||||
QFocusEvent *fe = (QFocusEvent *)event;
|
QFocusEvent *fe = (QFocusEvent *)event;
|
||||||
if (o == this && d->client && fe->reason() != Qt::ActiveWindowFocusReason)
|
if (o == this && d->client && fe->reason() != Qt::ActiveWindowFocusReason)
|
||||||
sendXEmbedMessage(d->client, x11Info().display(), XEMBED_FOCUS_OUT);
|
sendXEmbedMessage(d->client, x11Info().display(), XEMBED_FOCUS_OUT);
|
||||||
} else {
|
} else {
|
||||||
d->checkGrab();
|
d->checkGrab();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
case QEvent::Close: {
|
case QEvent::Close: {
|
||||||
if (o == this && d->client) {
|
if (o == this && d->client) {
|
||||||
// Unmap the client and reparent it to the root window.
|
// Unmap the client and reparent it to the root window.
|
||||||
// Wait until the messages have been processed. Then ask
|
// Wait until the messages have been processed. Then ask
|
||||||
// the window manager to delete the window.
|
// the window manager to delete the window.
|
||||||
XUnmapWindow(x11Info().display(), d->client);
|
XUnmapWindow(x11Info().display(), d->client);
|
||||||
XReparentWindow(x11Info().display(), d->client, x11Info().appRootWindow(x11Info().screen()), 0, 0);
|
XReparentWindow(x11Info().display(), d->client, x11Info().appRootWindow(x11Info().screen()), 0, 0);
|
||||||
XSync(x11Info().display(), false);
|
XSync(x11Info().display(), false);
|
||||||
|
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
memset(&ev, 0, sizeof(ev));
|
memset(&ev, 0, sizeof(ev));
|
||||||
ev.xclient.type = ClientMessage;
|
ev.xclient.type = ClientMessage;
|
||||||
ev.xclient.window = d->client;
|
ev.xclient.window = d->client;
|
||||||
ev.xclient.message_type = ATOM(WM_PROTOCOLS);
|
ev.xclient.message_type = ATOM(WM_PROTOCOLS);
|
||||||
ev.xclient.format = 32;
|
ev.xclient.format = 32;
|
||||||
ev.xclient.data.s[0] = ATOM(WM_DELETE_WINDOW);
|
ev.xclient.data.s[0] = ATOM(WM_DELETE_WINDOW);
|
||||||
XSendEvent(x11Info().display(), d->client, false, NoEventMask, &ev);
|
XSendEvent(x11Info().display(), d->client, false, NoEventMask, &ev);
|
||||||
|
|
||||||
XFlush(x11Info().display());
|
XFlush(x11Info().display());
|
||||||
d->client = 0;
|
d->client = 0;
|
||||||
d->clientIsXEmbed = false;
|
d->clientIsXEmbed = false;
|
||||||
d->wmMinimumSizeHint = QSize();
|
d->wmMinimumSizeHint = QSize();
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
update();
|
update();
|
||||||
|
|
||||||
emit clientClosed();
|
emit clientClosed();
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QWidget::eventFilter(o, event);
|
return QWidget::eventFilter(o, event);
|
||||||
|
@ -1391,132 +1401,145 @@ bool QX11EmbedContainer::x11Event(XEvent *event)
|
||||||
Q_D(QX11EmbedContainer);
|
Q_D(QX11EmbedContainer);
|
||||||
|
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case CreateNotify:
|
case CreateNotify: {
|
||||||
// The client created an embedded window.
|
// The client created an embedded window.
|
||||||
if (d->client)
|
if (d->client)
|
||||||
d->rejectClient(event->xcreatewindow.window);
|
d->rejectClient(event->xcreatewindow.window);
|
||||||
else
|
else
|
||||||
d->acceptClient(event->xcreatewindow.window);
|
d->acceptClient(event->xcreatewindow.window);
|
||||||
break;
|
|
||||||
case DestroyNotify:
|
|
||||||
if (event->xdestroywindow.window == d->client) {
|
|
||||||
// The client died.
|
|
||||||
d->client = 0;
|
|
||||||
d->clientIsXEmbed = false;
|
|
||||||
d->wmMinimumSizeHint = QSize();
|
|
||||||
updateGeometry();
|
|
||||||
update();
|
|
||||||
setEnabled(false);
|
|
||||||
emit clientClosed();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case ReparentNotify:
|
}
|
||||||
// The client sends us this if it reparents itself out of our
|
|
||||||
// widget.
|
case DestroyNotify: {
|
||||||
if (event->xreparent.window == d->client && event->xreparent.parent != internalWinId()) {
|
if (event->xdestroywindow.window == d->client) {
|
||||||
d->client = 0;
|
// The client died.
|
||||||
d->clientIsXEmbed = false;
|
d->client = 0;
|
||||||
|
d->clientIsXEmbed = false;
|
||||||
d->wmMinimumSizeHint = QSize();
|
d->wmMinimumSizeHint = QSize();
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
update();
|
update();
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
emit clientClosed();
|
emit clientClosed();
|
||||||
} else if (event->xreparent.parent == internalWinId()) {
|
}
|
||||||
// The client reparented itself into this window.
|
break;
|
||||||
if (d->client)
|
}
|
||||||
d->rejectClient(event->xreparent.window);
|
|
||||||
else
|
case ReparentNotify: {
|
||||||
d->acceptClient(event->xreparent.window);
|
// The client sends us this if it reparents itself out of our
|
||||||
}
|
// widget.
|
||||||
break;
|
if (event->xreparent.window == d->client && event->xreparent.parent != internalWinId()) {
|
||||||
|
d->client = 0;
|
||||||
|
d->clientIsXEmbed = false;
|
||||||
|
d->wmMinimumSizeHint = QSize();
|
||||||
|
updateGeometry();
|
||||||
|
update();
|
||||||
|
setEnabled(false);
|
||||||
|
emit clientClosed();
|
||||||
|
} else if (event->xreparent.parent == internalWinId()) {
|
||||||
|
// The client reparented itself into this window.
|
||||||
|
if (d->client)
|
||||||
|
d->rejectClient(event->xreparent.window);
|
||||||
|
else
|
||||||
|
d->acceptClient(event->xreparent.window);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ClientMessage: {
|
case ClientMessage: {
|
||||||
if (event->xclient.message_type == ATOM(_XEMBED)) {
|
if (event->xclient.message_type == ATOM(_XEMBED)) {
|
||||||
// Ignore XEMBED messages not to ourselves
|
// Ignore XEMBED messages not to ourselves
|
||||||
if (event->xclient.window != internalWinId())
|
if (event->xclient.window != internalWinId())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Receiving an XEmbed message means the client
|
// Receiving an XEmbed message means the client
|
||||||
// is an XEmbed client.
|
// is an XEmbed client.
|
||||||
d->clientIsXEmbed = true;
|
d->clientIsXEmbed = true;
|
||||||
|
|
||||||
Time msgtime = (Time) event->xclient.data.l[0];
|
Time msgtime = (Time) event->xclient.data.l[0];
|
||||||
if (msgtime > qt_x11Data->time)
|
if (msgtime > qt_x11Data->time)
|
||||||
qt_x11Data->time = msgtime;
|
qt_x11Data->time = msgtime;
|
||||||
|
|
||||||
switch (event->xclient.data.l[1]) {
|
switch (event->xclient.data.l[1]) {
|
||||||
case XEMBED_REQUEST_FOCUS: {
|
case XEMBED_REQUEST_FOCUS: {
|
||||||
// This typically happens when the client gets focus
|
// This typically happens when the client gets focus
|
||||||
// because of a mouse click.
|
// because of a mouse click.
|
||||||
if (!hasFocus())
|
if (!hasFocus())
|
||||||
setFocus(Qt::OtherFocusReason);
|
setFocus(Qt::OtherFocusReason);
|
||||||
|
|
||||||
// The message is passed along to the topmost container
|
// The message is passed along to the topmost container
|
||||||
// that eventually responds with a XEMBED_FOCUS_IN
|
// that eventually responds with a XEMBED_FOCUS_IN
|
||||||
// message. The focus in message is passed all the way
|
// message. The focus in message is passed all the way
|
||||||
// back until it reaches the original focus
|
// back until it reaches the original focus
|
||||||
// requestor. In the end, not only the original client
|
// requestor. In the end, not only the original client
|
||||||
// has focus, but also all its ancestor containers.
|
// has focus, but also all its ancestor containers.
|
||||||
if (d->isEmbedded()) {
|
if (d->isEmbedded()) {
|
||||||
// If our window's embedded flag is set, then
|
// If our window's embedded flag is set, then
|
||||||
// that suggests that we are part of a client. The
|
// that suggests that we are part of a client. The
|
||||||
// parentWinId will then point to an container to whom
|
// parentWinId will then point to an container to whom
|
||||||
// we must pass this message.
|
// we must pass this message.
|
||||||
sendXEmbedMessage(d->topLevelParentWinId(), x11Info().display(), XEMBED_REQUEST_FOCUS);
|
sendXEmbedMessage(d->topLevelParentWinId(), x11Info().display(), XEMBED_REQUEST_FOCUS);
|
||||||
} else {
|
} else {
|
||||||
// Our window's embedded flag is not set,
|
// Our window's embedded flag is not set,
|
||||||
// so we are the topmost container. We respond to
|
// so we are the topmost container. We respond to
|
||||||
// the focus request message with a focus in
|
// the focus request message with a focus in
|
||||||
// message. This message will pass on from client
|
// message. This message will pass on from client
|
||||||
// to container to client until it reaches the
|
// to container to client until it reaches the
|
||||||
// originator of the XEMBED_REQUEST_FOCUS message.
|
// originator of the XEMBED_REQUEST_FOCUS message.
|
||||||
sendXEmbedMessage(d->client, x11Info().display(), XEMBED_FOCUS_IN, XEMBED_FOCUS_CURRENT);
|
sendXEmbedMessage(d->client, x11Info().display(), XEMBED_FOCUS_IN, XEMBED_FOCUS_CURRENT);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
case XEMBED_FOCUS_NEXT: {
|
||||||
}
|
// Client sends this event when it received a tab
|
||||||
case XEMBED_FOCUS_NEXT:
|
// forward and was at the end of its focus chain. If
|
||||||
// Client sends this event when it received a tab
|
// we are the only widget in the focus chain, we send
|
||||||
// forward and was at the end of its focus chain. If
|
// ourselves a FocusIn event.
|
||||||
// we are the only widget in the focus chain, we send
|
|
||||||
// ourselves a FocusIn event.
|
|
||||||
if (d->focus_next != this) {
|
if (d->focus_next != this) {
|
||||||
focusNextPrevChild(true);
|
focusNextPrevChild(true);
|
||||||
} else {
|
} else {
|
||||||
QFocusEvent event(QEvent::FocusIn, Qt::TabFocusReason);
|
QFocusEvent event(QEvent::FocusIn, Qt::TabFocusReason);
|
||||||
qApp->sendEvent(this, &event);
|
qApp->sendEvent(this, &event);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
case XEMBED_FOCUS_PREV: {
|
||||||
case XEMBED_FOCUS_PREV:
|
// Client sends this event when it received a backtab
|
||||||
// Client sends this event when it received a backtab
|
// and was at the start of its focus chain. If we are
|
||||||
// and was at the start of its focus chain. If we are
|
// the only widget in the focus chain, we send
|
||||||
// the only widget in the focus chain, we send
|
// ourselves a FocusIn event.
|
||||||
// ourselves a FocusIn event.
|
|
||||||
if (d->focus_next != this) {
|
if (d->focus_next != this) {
|
||||||
focusNextPrevChild(false);
|
focusNextPrevChild(false);
|
||||||
} else {
|
} else {
|
||||||
QFocusEvent event(QEvent::FocusIn, Qt::BacktabFocusReason);
|
QFocusEvent event(QEvent::FocusIn, Qt::BacktabFocusReason);
|
||||||
qApp->sendEvent(this, &event);
|
qApp->sendEvent(this, &event);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
default:
|
||||||
default:
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case XButtonPress:
|
}
|
||||||
|
|
||||||
|
case XButtonPress: {
|
||||||
if (!d->clientIsXEmbed) {
|
if (!d->clientIsXEmbed) {
|
||||||
setFocus(Qt::MouseFocusReason);
|
setFocus(Qt::MouseFocusReason);
|
||||||
XAllowEvents(x11Info().display(), ReplayPointer, CurrentTime);
|
XAllowEvents(x11Info().display(), ReplayPointer, CurrentTime);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XButtonRelease:
|
}
|
||||||
|
|
||||||
|
case XButtonRelease: {
|
||||||
if (!d->clientIsXEmbed)
|
if (!d->clientIsXEmbed)
|
||||||
XAllowEvents(x11Info().display(), SyncPointer, CurrentTime);
|
XAllowEvents(x11Info().display(), SyncPointer, CurrentTime);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue