summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/connectiondialog.h1
-rw-r--r--src/gui/popupmenu.cpp3
-rw-r--r--src/gui/quitdialog.cpp2
-rw-r--r--src/gui/statuswindow.cpp3
-rw-r--r--src/gui/widgets/layout.h5
-rw-r--r--src/gui/widgets/shortcutcontainer.cpp6
-rw-r--r--src/gui/widgets/textfield.cpp2
-rw-r--r--src/keyboardconfig.cpp6
-rw-r--r--src/net/tmwa/protocol.h15
-rw-r--r--src/resources/action.cpp7
-rw-r--r--src/resources/mapreader.cpp3
-rw-r--r--src/resources/resource.h2
-rw-r--r--src/utils/copynpaste.cpp349
-rw-r--r--src/utils/copynpaste.h2
14 files changed, 226 insertions, 180 deletions
diff --git a/src/gui/connectiondialog.h b/src/gui/connectiondialog.h
index 623a66455..e6a1c03f3 100644
--- a/src/gui/connectiondialog.h
+++ b/src/gui/connectiondialog.h
@@ -55,7 +55,6 @@ class ConnectionDialog : public Window, gcn::ActionListener
void draw(gcn::Graphics *graphics);
private:
- gcn::Label *mLabel;
State mCancelState;
};
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 1a164687c..90813ed80 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -92,6 +92,9 @@ PopupMenu::PopupMenu():
mBrowserBox->setHighlightMode(BrowserBox::BACKGROUND);
mBrowserBox->setOpaque(false);
mBrowserBox->setLinkHandler(this);
+ mRenameListener.setMapItem(0);
+ mRenameListener.setDialog(0);
+
add(mBrowserBox);
}
diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp
index 7fc87c02a..221a94747 100644
--- a/src/gui/quitdialog.cpp
+++ b/src/gui/quitdialog.cpp
@@ -140,7 +140,7 @@ void QuitDialog::action(const gcn::ActionEvent &event)
Client::setState(STATE_EXIT);
}
else if (Net::getGameHandler()->isConnected()
- && mSwitchAccountServer->isSelected())
+ && mSwitchAccountServer->isSelected())
{
Client::setState(STATE_SWITCH_SERVER);
}
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index 58d3d0957..8dc1ed46d 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -356,7 +356,8 @@ void StatusWindow::event(Channels channel _UNUSED_,
// new job exp limit, we fixing it
lvl ++;
blocked = true;
- PlayerInfo::setStatExperience(id, exp.first, 20000 + lvl * 150);
+ PlayerInfo::setStatExperience(
+ id, exp.first, 20000 + lvl * 150);
PlayerInfo::setStatBase(id, lvl);
blocked = false;
}
diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h
index 4c1e40bb9..f6621ee11 100644
--- a/src/gui/widgets/layout.h
+++ b/src/gui/widgets/layout.h
@@ -170,7 +170,10 @@ class LayoutCell
FILL
};
- LayoutCell(): mType(NONE) {}
+ LayoutCell():
+ mWidget(0),
+ mType(NONE)
+ { }
~LayoutCell();
diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp
index 8ce252150..0426c8c79 100644
--- a/src/gui/widgets/shortcutcontainer.cpp
+++ b/src/gui/widgets/shortcutcontainer.cpp
@@ -30,14 +30,14 @@
float ShortcutContainer::mAlpha = 1.0;
ShortcutContainer::ShortcutContainer():
- mGridWidth(1),
- mGridHeight(1),
mBackgroundImg(0),
mMaxItems(0),
mBoxWidth(1),
mBoxHeight(1),
mCursorPosX(0),
- mCursorPosY(0)
+ mCursorPosY(0),
+ mGridWidth(1),
+ mGridHeight(1)
{
}
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index e7c181de2..67339e361 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -300,7 +300,7 @@ void TextField::handlePaste()
std::string text = getText();
std::string::size_type caretPos = getCaretPosition();
- if (RetrieveBuffer(text, caretPos))
+ if (retrieveBuffer(text, caretPos))
{
setText(text);
setCaretPosition(static_cast<unsigned>(caretPos));
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index c746880c2..b477fd6ed 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -41,7 +41,8 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
{"keyMoveUp", SDLK_UP, N_("Move Up"), KeyboardConfig::GRP_DEFAULT},
{"keyMoveDown", SDLK_DOWN, N_("Move Down"), KeyboardConfig::GRP_DEFAULT},
{"keyMoveLeft", SDLK_LEFT, N_("Move Left"), KeyboardConfig::GRP_DEFAULT},
- {"keyMoveRight", SDLK_RIGHT, N_("Move Right"), KeyboardConfig::GRP_DEFAULT},
+ {"keyMoveRight", SDLK_RIGHT, N_("Move Right"),
+ KeyboardConfig::GRP_DEFAULT},
{"keyAttack", SDLK_LCTRL, N_("Attack"), KeyboardConfig::GRP_DEFAULT},
{"keyTargetAttack", SDLK_x, N_("Target & Attack"),
KeyboardConfig::GRP_DEFAULT},
@@ -66,7 +67,8 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
{"keyPickup", SDLK_z, N_("Pickup"), KeyboardConfig::GRP_DEFAULT},
{"keyChangePickupType", SDLK_o, N_("Change Pickup Type"),
KeyboardConfig::GRP_DEFAULT},
- {"keyHideWindows", SDLK_h, N_("Hide Windows"), KeyboardConfig::GRP_DEFAULT},
+ {"keyHideWindows", SDLK_h, N_("Hide Windows"),
+ KeyboardConfig::GRP_DEFAULT},
{"keyBeingSit", SDLK_s, N_("Sit"), KeyboardConfig::GRP_DEFAULT},
{"keyScreenshot", SDLK_p, N_("Screenshot"), KeyboardConfig::GRP_DEFAULT},
{"keyTrade", SDLK_r, N_("Enable/Disable Trading"),
diff --git a/src/net/tmwa/protocol.h b/src/net/tmwa/protocol.h
index 83854c4c6..e41275757 100644
--- a/src/net/tmwa/protocol.h
+++ b/src/net/tmwa/protocol.h
@@ -86,7 +86,8 @@ static const int STORAGE_OFFSET = 1;
#define SMSG_CHAR_DELETE_SUCCEEDED 0x006f
#define SMSG_CHAR_DELETE_FAILED 0x0070
#define SMSG_CHAR_MAP_INFO 0x0071
-#define SMSG_CHAR_PASSWORD_RESPONSE 0x0062 /**< Custom packet reply to password change request */
+#define SMSG_CHAR_PASSWORD_RESPONSE 0x0062 /**< Custom packet reply \
+ to password change request */
#define SMSG_CHAR_SWITCH_RESPONSE 0x00b3
#define SMSG_CHANGE_MAP_SERVER 0x0092
@@ -130,7 +131,8 @@ static const int STORAGE_OFFSET = 1;
#define SMSG_BEING_MOVE2 0x0086 /**< New eAthena being moves */
#define SMSG_BEING_REMOVE 0x0080
#define SMSG_BEING_CHANGE_LOOKS 0x00c3
-#define SMSG_BEING_CHANGE_LOOKS2 0x01d7 /**< Same as 0x00c3, but 16 bit ID */
+#define SMSG_BEING_CHANGE_LOOKS2 0x01d7 /**< Same as 0x00c3, \
+ but 16 bit ID */
#define SMSG_BEING_SELFEFFECT 0x019b
#define SMSG_BEING_EMOTION 0x00c0
#define SMSG_BEING_ACTION 0x008a /**< Attack, sit, stand up, ... */
@@ -160,7 +162,8 @@ static const int STORAGE_OFFSET = 1;
#define SMSG_GM_CHAT 0x009a /**< GM announce */
#define SMSG_WALK_RESPONSE 0x0087
-#define SMSG_TRADE_REQUEST 0x00e5 /**< Receiving a request to trade */
+#define SMSG_TRADE_REQUEST 0x00e5 /**< Receiving a request \
+ to trade */
#define SMSG_TRADE_RESPONSE 0x00e7
#define SMSG_TRADE_ITEM_ADD 0x00e9
#define SMSG_TRADE_ITEM_ADD_RESPONSE 0x01b1 /**< Not standard eAthena! */
@@ -183,7 +186,8 @@ static const int STORAGE_OFFSET = 1;
#define SMSG_PLAYER_STORAGE_EQUIP 0x00a6 /**< Equipment list for storage */
#define SMSG_PLAYER_STORAGE_STATUS 0x00f2 /**< Slots used and total slots */
#define SMSG_PLAYER_STORAGE_ADD 0x00f4 /**< Add item/equip to storage */
-#define SMSG_PLAYER_STORAGE_REMOVE 0x00f6 /**< Remove item/equip from storage */
+#define SMSG_PLAYER_STORAGE_REMOVE 0x00f6 /**< Remove item/equip \
+ from storage */
#define SMSG_PLAYER_STORAGE_CLOSE 0x00f8 /**< Storage access closed */
#define SMSG_ADMIN_KICK_ACK 0x00cd
@@ -222,7 +226,8 @@ static const int STORAGE_OFFSET = 1;
**********************************/
#define CMSG_SERVER_VERSION_REQUEST 0x7530
-#define CMSG_CHAR_PASSWORD_CHANGE 0x0061 /**< Custom change password packet */
+#define CMSG_CHAR_PASSWORD_CHANGE 0x0061 /**< Custom change \
+ password packet */
#define CMSG_CHAR_SERVER_CONNECT 0x0065
#define CMSG_CHAR_SELECT 0x0066
#define CMSG_CHAR_CREATE 0x0067
diff --git a/src/resources/action.cpp b/src/resources/action.cpp
index b8cfde611..9781d6514 100644
--- a/src/resources/action.cpp
+++ b/src/resources/action.cpp
@@ -42,9 +42,14 @@ Animation *Action::getAnimation(int direction) const
if (i == mAnimations.end())
{
if (direction == DIRECTION_UPLEFT || direction == DIRECTION_UPRIGHT)
+ {
direction = DIRECTION_UP;
- else if (direction == DIRECTION_DOWNLEFT || direction == DIRECTION_DOWNRIGHT)
+ }
+ else if (direction == DIRECTION_DOWNLEFT
+ || direction == DIRECTION_DOWNRIGHT)
+ {
direction = DIRECTION_DOWN;
+ }
i = mAnimations.find(direction);
// When the given direction is not available, return the first one.
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index d990d2cb0..a2e81ae07 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -438,7 +438,8 @@ void MapReader::readLayer(xmlNodePtr node, Map *map)
if (encoding == "base64")
{
- if (!compression.empty() && compression != "gzip" && compression != "zlib")
+ if (!compression.empty() && compression != "gzip"
+ && compression != "zlib")
{
logger->log1("Warning: only gzip layer"
" compression supported!");
diff --git a/src/resources/resource.h b/src/resources/resource.h
index 89fcc9de7..d2f8ca313 100644
--- a/src/resources/resource.h
+++ b/src/resources/resource.h
@@ -62,7 +62,7 @@ class Resource
/**
* Return refCount for this resource.
*/
- unsigned getRefCount()
+ unsigned getRefCount() const
{ return mRefCount; }
protected:
diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp
index 498c012b5..1107400e1 100644
--- a/src/utils/copynpaste.cpp
+++ b/src/utils/copynpaste.cpp
@@ -36,55 +36,57 @@
#include "copynpaste.h"
#ifdef WIN32
-bool RetrieveBuffer(std::string& text, std::string::size_type& pos)
+bool retrieveBuffer(std::string& text, std::string::size_type& pos)
{
- bool ret = false;
+ bool ret = false;
- if (!OpenClipboard(NULL))
- return false;
-
- HANDLE h = GetClipboardData(CF_UNICODETEXT);
- if (h)
- {
- LPCWSTR data = (LPCWSTR)GlobalLock(h);
+ if (!OpenClipboard(NULL))
+ return false;
- if (data)
+ HANDLE h = GetClipboardData(CF_UNICODETEXT);
+ if (h)
{
- int len = WideCharToMultiByte(CP_UTF8, 0, data, -1, NULL, 0, NULL, NULL);
- if (len > 0)
- {
- // Convert from UTF-16 to UTF-8
- void *temp = malloc(len);
- if (WideCharToMultiByte(CP_UTF8, 0, data, -1, (LPSTR)temp, len, NULL, NULL))
+ LPCWSTR data = (LPCWSTR)GlobalLock(h);
+
+ if (data)
{
- text.insert(pos, (char*)temp);
- pos += len-1;
+ int len = WideCharToMultiByte(CP_UTF8, 0, data, -1,
+ NULL, 0, NULL, NULL);
+ if (len > 0)
+ {
+ // Convert from UTF-16 to UTF-8
+ void *temp = malloc(len);
+ if (WideCharToMultiByte(CP_UTF8, 0, data, -1,
+ (LPSTR)temp, len, NULL, NULL))
+ {
+ text.insert(pos, (char*)temp);
+ pos += len-1;
+ }
+ free(temp);
+ ret = true;
+ }
}
- free(temp);
- ret = true;
- }
+ GlobalUnlock(h);
}
- GlobalUnlock(h);
- }
- else
- {
- h = GetClipboardData(CF_TEXT);
-
- if (h)
+ else
{
- const char *data = (char*)GlobalLock(h);
- if (data)
- {
- text.insert(pos, data);
- pos += strlen(data);
- ret = true;
- }
- GlobalUnlock(h);
+ h = GetClipboardData(CF_TEXT);
+
+ if (h)
+ {
+ const char *data = (char*)GlobalLock(h);
+ if (data)
+ {
+ text.insert(pos, data);
+ pos += strlen(data);
+ ret = true;
+ }
+ GlobalUnlock(h);
+ }
}
- }
- CloseClipboard();
- return ret;
+ CloseClipboard();
+ return ret;
}
#elif defined(__APPLE__)
@@ -94,99 +96,120 @@ bool RetrieveBuffer(std::string& text, std::string::size_type& pos)
#include <Carbon/Carbon.h>
-// Sorry for the very long code, all nicer OS X APIs are coded in Objective C and not C!
+// Sorry for the very long code, all nicer OS X APIs are coded in
+// Objective C and not C!
// Also it does very thorough error handling
-bool GetDataFromPasteboard( PasteboardRef inPasteboard, char* flavorText /* out */, const int bufSize )
+bool getDataFromPasteboard(PasteboardRef inPasteboard,
+ char* flavorText /* out */,
+ const int bufSize)
{
OSStatus err = noErr;
PasteboardSyncFlags syncFlags;
ItemCount itemCount;
- syncFlags = PasteboardSynchronize( inPasteboard );
+ syncFlags = PasteboardSynchronize(inPasteboard);
//require_action( syncFlags & kPasteboardModified, PasteboardOutOfSync,
// err = badPasteboardSyncErr );
- err = PasteboardGetItemCount( inPasteboard, &itemCount );
- require_noerr( err, CantGetPasteboardItemCount );
+ err = PasteboardGetItemCount(inPasteboard, &itemCount);
+ require_noerr(err, CantGetPasteboardItemCount);
- for (UInt32 itemIndex = 1; itemIndex <= itemCount; itemIndex++)
+ for (UInt32 itemIndex = 1; itemIndex <= itemCount; itemIndex ++)
{
PasteboardItemID itemID;
CFArrayRef flavorTypeArray;
CFIndex flavorCount;
- err = PasteboardGetItemIdentifier( inPasteboard, itemIndex, &itemID );
- require_noerr( err, CantGetPasteboardItemIdentifier );
+ err = PasteboardGetItemIdentifier(inPasteboard, itemIndex, &itemID);
+ require_noerr(err, CantGetPasteboardItemIdentifier);
- err = PasteboardCopyItemFlavors( inPasteboard, itemID, &flavorTypeArray );
- require_noerr( err, CantCopyPasteboardItemFlavors );
+ err = PasteboardCopyItemFlavors(inPasteboard,
+ itemID, &flavorTypeArray);
+ require_noerr(err, CantCopyPasteboardItemFlavors);
- flavorCount = CFArrayGetCount( flavorTypeArray );
+ flavorCount = CFArrayGetCount(flavorTypeArray);
- for (CFIndex flavorIndex = 0; flavorIndex < flavorCount; flavorIndex++)
+ for (CFIndex flavorIndex = 0; flavorIndex < flavorCount;
+ flavorIndex ++)
{
CFStringRef flavorType;
CFDataRef flavorData;
CFIndex flavorDataSize;
- flavorType = (CFStringRef)CFArrayGetValueAtIndex(flavorTypeArray, flavorIndex);
+ flavorType = (CFStringRef)CFArrayGetValueAtIndex(
+ flavorTypeArray, flavorIndex);
// we're only interested by text...
if (UTTypeConformsTo(flavorType, CFSTR("public.utf8-plain-text")))
{
- err = PasteboardCopyItemFlavorData( inPasteboard, itemID,
- flavorType, &flavorData );
- require_noerr( err, CantCopyFlavorData );
- flavorDataSize = CFDataGetLength( flavorData );
+ err = PasteboardCopyItemFlavorData(inPasteboard, itemID,
+ flavorType, &flavorData);
+ require_noerr(err, CantCopyFlavorData);
+ flavorDataSize = CFDataGetLength(flavorData);
flavorDataSize = (flavorDataSize<254) ? flavorDataSize : 254;
- if (flavorDataSize+2 > bufSize)
+ if (flavorDataSize + 2 > bufSize)
{
- fprintf(stderr, "Cannot copy clipboard, contents is too big!\n");
+ fprintf(stderr,
+ "Cannot copy clipboard, contents is too big!\n");
return false;
}
- for (short dataIndex = 0; dataIndex <= flavorDataSize; dataIndex++)
+ for (short dataIndex = 0; dataIndex <= flavorDataSize;
+ dataIndex ++)
{
- char byte = *(CFDataGetBytePtr( flavorData ) + dataIndex);
+ char byte = *(CFDataGetBytePtr(flavorData) + dataIndex);
flavorText[dataIndex] = byte;
}
flavorText[flavorDataSize] = '\0';
- flavorText[flavorDataSize+1] = '\n';
+ flavorText[flavorDataSize + 1] = '\n';
CFRelease (flavorData);
return true;
}
continue;
- CantCopyFlavorData: fprintf(stderr, "Cannot copy clipboard, CantCopyFlavorData!\n");
+CantCopyFlavorData:
+ fprintf(stderr, "Cannot copy clipboard, CantCopyFlavorData!\n");
}
CFRelease (flavorTypeArray);
continue;
- CantCopyPasteboardItemFlavors: fprintf(stderr, "Cannot copy clipboard, CantCopyPasteboardItemFlavors!\n"); continue;
- CantGetPasteboardItemIdentifier: fprintf(stderr, "Cannot copy clipboard, CantGetPasteboardItemIdentifier!\n"); continue;
+CantCopyPasteboardItemFlavors:
+ fprintf(stderr,
+ "Cannot copy clipboard, CantCopyPasteboardItemFlavors!\n");
+ continue;
+CantGetPasteboardItemIdentifier:
+ fprintf(stderr,
+ "Cannot copy clipboard, CantGetPasteboardItemIdentifier!\n");
+ continue;
}
- fprintf(stderr, "Cannot copy clipboard, found no acceptable flavour!\n");
+ fprintf(stderr,
+ "Cannot copy clipboard, found no acceptable flavour!\n");
return false;
- CantGetPasteboardItemCount: fprintf(stderr, "Cannot copy clipboard, CantGetPasteboardItemCount!\n"); return false;
- //PasteboardOutOfSync: fprintf(stderr, "Cannot copy clipboard, PasteboardOutOfSync!\n"); return false;
+CantGetPasteboardItemCount:
+ fprintf(stderr, "Cannot copy clipboard, CantGetPasteboardItemCount!\n");
+ return false;
+//PasteboardOutOfSync:
+// fprintf(stderr, "Cannot copy clipboard, PasteboardOutOfSync!\n");
+// return false;
}
-bool getClipBoard(char* text /* out */, const int bufSize )
+bool getClipBoard(char* text /* out */, const int bufSize)
{
OSStatus err = noErr;
PasteboardRef theClipboard;
- err = PasteboardCreate( kPasteboardClipboard, &theClipboard );
- require_noerr( err, PasteboardCreateFailed );
+ err = PasteboardCreate(kPasteboardClipboard, &theClipboard);
+ require_noerr(err, PasteboardCreateFailed);
- if (!GetDataFromPasteboard(theClipboard, text, bufSize))
+ if (!getDataFromPasteboard(theClipboard, text, bufSize))
{
- fprintf(stderr, "Cannot copy clipboard, GetDataFromPasteboardFailed!\n");
+ fprintf(stderr,
+ "Cannot copy clipboard, getDataFromPasteboardFailed!\n");
return false;
}
@@ -195,15 +218,16 @@ bool getClipBoard(char* text /* out */, const int bufSize )
return true;
// ---- error handling
- PasteboardCreateFailed: fprintf(stderr, "Cannot copy clipboard, PasteboardCreateFailed!\n");
+PasteboardCreateFailed:
+ fprintf(stderr, "Cannot copy clipboard, PasteboardCreateFailed!\n");
CFRelease(theClipboard);
return false;
}
-bool RetrieveBuffer(std::string& text, std::string::size_type& pos)
+bool retrieveBuffer(std::string& text, std::string::size_type& pos)
{
const int bufSize = 512;
- char buffer[bufSize+1];
+ char buffer[bufSize + 1];
if (getClipBoard(buffer, bufSize))
{
@@ -220,105 +244,108 @@ bool RetrieveBuffer(std::string& text, std::string::size_type& pos)
#elif USE_X11
static char* getSelection(Display *dpy, Window us, Atom selection)
{
- int max_events = 50;
- Window owner = XGetSelectionOwner (dpy, selection);
- int ret;
-
- //printf("XConvertSelection on %s\n", XGetAtomName(dpy, selection));
- if (owner == None)
- {
- //printf("No owner\n");
- return NULL;
- }
- XConvertSelection(dpy, selection, XA_STRING, XA_PRIMARY, us, CurrentTime);
- XFlush(dpy);
-
- while (max_events--)
- {
- XEvent e;
+ int max_events = 50;
+ Window owner = XGetSelectionOwner(dpy, selection);
+ int ret;
- XNextEvent(dpy, &e);
- if(e.type == SelectionNotify)
+ //printf("XConvertSelection on %s\n", XGetAtomName(dpy, selection));
+ if (owner == None)
{
- //printf("Received %s\n", XGetAtomName(dpy, e.xselection.selection));
- if(e.xselection.property == None)
- {
- //printf("Couldn't convert\n");
- return NULL;
- }
-
- long unsigned len, left, dummy;
- int format;
- Atom type;
- unsigned char *data = NULL;
-
- ret = XGetWindowProperty(dpy, us, e.xselection.property, 0, 0, False,
- AnyPropertyType, &type, &format, &len, &left,
- &data);
- if (left < 1)
- {
- if (ret == Success)
- XFree(data);
- return NULL;
- }
-
- ret = XGetWindowProperty(dpy, us, e.xselection.property, 0, left, False,
- AnyPropertyType, &type, &format, &len, &dummy,
- &data);
- if (ret != Success)
- {
- //printf("Failed to get property: %p on %lu\n", data, len);
+ //printf("No owner\n");
return NULL;
- }
+ }
+ XConvertSelection(dpy, selection, XA_STRING, XA_PRIMARY, us, CurrentTime);
+ XFlush(dpy);
+
+ while (max_events --)
+ {
+ XEvent e;
+
+ XNextEvent(dpy, &e);
+ if (e.type == SelectionNotify)
+ {
+ //printf("Received %s\n", XGetAtomName(dpy, e.xselection.selection));
+ if (e.xselection.property == None)
+ {
+ //printf("Couldn't convert\n");
+ return NULL;
+ }
- //printf(">>> Got %s: len=%lu left=%lu (event %i)\n", data, len, left, 50-max_events);
- return (char*)data;
+ long unsigned len, left, dummy;
+ int format;
+ Atom type;
+ unsigned char *data = NULL;
+
+ ret = XGetWindowProperty(dpy, us, e.xselection.property, 0, 0,
+ False, AnyPropertyType, &type, &format, &len, &left, &data);
+ if (left < 1)
+ {
+ if (ret == Success)
+ XFree(data);
+ return NULL;
+ }
+
+ ret = XGetWindowProperty(dpy, us, e.xselection.property, 0,
+ left, False, AnyPropertyType, &type, &format, &len,
+ &dummy, &data);
+
+ if (ret != Success)
+ {
+ //printf("Failed to get property: %p on %lu\n", data, len);
+ return NULL;
+ }
+
+ //printf(">>> Got %s: len=%lu left=%lu (event %i)\n", data,
+ // len, left, 50-max_events);
+ return (char*)data;
+ }
}
- }
- return NULL;
+ return NULL;
}
-bool RetrieveBuffer(std::string& text, std::string::size_type& pos)
+bool retrieveBuffer(std::string& text, std::string::size_type& pos)
{
- SDL_SysWMinfo info;
+ SDL_SysWMinfo info;
- //printf("Retrieving buffer...\n");
- SDL_VERSION(&info.version);
- if ( SDL_GetWMInfo(&info) )
- {
- Display *dpy = info.info.x11.display;
- Window us = info.info.x11.window;
- char *data = NULL;
-
- if (!data)
- {
- data = getSelection(dpy, us, XA_PRIMARY);
- }
- if (!data)
- {
- data = getSelection(dpy, us, XA_SECONDARY);
- }
- if (!data)
+ //printf("Retrieving buffer...\n");
+ SDL_VERSION(&info.version);
+ if (SDL_GetWMInfo(&info))
{
- Atom XA_CLIPBOARD = XInternAtom(dpy, "CLIPBOARD", 0);
- data = getSelection(dpy, us, XA_CLIPBOARD);
- }
- if (data)
- {
- // check cursor position
- if (pos > text.size()) {
- pos = text.size();
- }
+ Display *dpy = info.info.x11.display;
+ Window us = info.info.x11.window;
+ char *data = NULL;
- text.insert(pos, data);
- pos += strlen(data);
- XFree(data);
+ if (!data)
+ {
+ data = getSelection(dpy, us, XA_PRIMARY);
+ }
+ if (!data)
+ {
+ data = getSelection(dpy, us, XA_SECONDARY);
+ }
+ if (!data)
+ {
+ Atom XA_CLIPBOARD = XInternAtom(dpy, "CLIPBOARD", 0);
+ data = getSelection(dpy, us, XA_CLIPBOARD);
+ }
+ if (data)
+ {
+ // check cursor position
+ if (pos > text.size())
+ pos = text.size();
+
+ text.insert(pos, data);
+ pos += strlen(data);
+ XFree(data);
- return true;
+ return true;
+ }
}
- }
- return false;
+ return false;
}
#else
-bool RetrieveBuffer(std::string&, std::string::size_type&) { return false; }
+bool retrieveBuffer(std::string&, std::string::size_type&)
+{
+ return false;
+}
#endif
diff --git a/src/utils/copynpaste.h b/src/utils/copynpaste.h
index 1a7c81d05..aaafa3bcc 100644
--- a/src/utils/copynpaste.h
+++ b/src/utils/copynpaste.h
@@ -29,5 +29,5 @@
* @return <code>true</code> when successful or <code>false</code> when there
* was a problem retrieving the clipboard buffer.
*/
-bool RetrieveBuffer(std::string& text, std::string::size_type& pos);
+bool retrieveBuffer(std::string& text, std::string::size_type& pos);