How to implement floating Desktop icon button with half hidden on screen border

I need to make one clickable icon image on click of that icon it will open a new window above that icon.
Apart from this requirement i need that icon should be floatable anywhere in the screen as well as when that icon is near to any end (left, right, bottom, top) it should stick with border with half hidden.